drm/vc4: hvs: Introduce a function to get the assigned FIFO

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
This commit is contained in:
Maxime Ripard
2020-09-03 10:01:05 +02:00
parent 50e9d6cb5d
commit 29bbb93080
2 changed files with 55 additions and 0 deletions

View 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)
{