]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/vc4: hvs: Introduce a function to get the assigned FIFO
authorMaxime Ripard <maxime@cerno.tech>
Thu, 3 Sep 2020 08:01:05 +0000 (10:01 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 7 Sep 2020 16:04:26 +0000 (18:04 +0200)
At boot time, if we detect that a pixelvalve has been enabled, we need to
be able to retrieve the HVS channel it has been assigned to so that we can
disable that channel too. Let's create that function that returns the FIFO
or an error from a given output.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/178192d90874559b8386139f2226e773347729fc.1599120059.git-series.maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_hvs.c

index 554c2e29b23d3106f49181aba1c97115af612c27..860be019d8e3033780ae88d721c1dd05bb1f9391 100644 (file)
@@ -908,6 +908,7 @@ void vc4_irq_reset(struct drm_device *dev);
 /* vc4_hvs.c */
 extern struct platform_driver vc4_hvs_driver;
 void vc4_hvs_stop_channel(struct drm_device *dev, unsigned int output);
+int vc4_hvs_get_fifo_from_output(struct drm_device *dev, unsigned int output);
 int vc4_hvs_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
 void vc4_hvs_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
 void vc4_hvs_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
index b5ee9556e8218cdba2fa1e42a9fda73202d24008..4d0a833366cee10eb6fca2644433738b78985eeb 100644 (file)
@@ -19,6 +19,7 @@
  * each CRTC.
  */
 
+#include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <linux/platform_device.h>
@@ -196,6 +197,59 @@ static void vc4_hvs_update_gamma_lut(struct drm_crtc *crtc)
        vc4_hvs_lut_load(crtc);
 }
 
+int vc4_hvs_get_fifo_from_output(struct drm_device *dev, unsigned int output)
+{
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
+       u32 reg;
+       int ret;
+
+       if (!vc4->hvs->hvs5)
+               return output;
+
+       switch (output) {
+       case 0:
+               return 0;
+
+       case 1:
+               return 1;
+
+       case 2:
+               reg = HVS_READ(SCALER_DISPECTRL);
+               ret = FIELD_GET(SCALER_DISPECTRL_DSP2_MUX_MASK, reg);
+               if (ret == 0)
+                       return 2;
+
+               return 0;
+
+       case 3:
+               reg = HVS_READ(SCALER_DISPCTRL);
+               ret = FIELD_GET(SCALER_DISPCTRL_DSP3_MUX_MASK, reg);
+               if (ret == 3)
+                       return -EPIPE;
+
+               return ret;
+
+       case 4:
+               reg = HVS_READ(SCALER_DISPEOLN);
+               ret = FIELD_GET(SCALER_DISPEOLN_DSP4_MUX_MASK, reg);
+               if (ret == 3)
+                       return -EPIPE;
+
+               return ret;
+
+       case 5:
+               reg = HVS_READ(SCALER_DISPDITHER);
+               ret = FIELD_GET(SCALER_DISPDITHER_DSP5_MUX_MASK, reg);
+               if (ret == 3)
+                       return -EPIPE;
+
+               return ret;
+
+       default:
+               return -EPIPE;
+       }
+}
+
 static int vc4_hvs_init_channel(struct vc4_dev *vc4, struct drm_crtc *crtc,
                                struct drm_display_mode *mode, bool oneshot)
 {