drm/vc4: Modesetting fixes
Subsystems (3)
This series fixes the highest priority problems reported from the driver getting enabled in Raspbian: modesetting on HDMI was broken if you weren't at the same resolution that the firmware had set up, or if the firmware hadn't set up HDMI at all.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/6 drm/vc4: Fix a framebuffer reference leak on async flip interrupt.
We'd need X to queue up an async pageflip while another is outstanding, and then take a SIGIO. I think X actually avoids sending out the next pageflip while one's already queued, but I'm not sure.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/vc4/vc4_crtc.c +1 -0
@@ -527,6 +527,7 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,/* Make sure all other async modesetes have landed. */ ret =down_interruptible (&vc4->async_modeset);if (ret) { +drm_framebuffer_unreference (fb);kfree (flip_state);return ret; }
Signature · 6 lines
2.7.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/6 drm/vc4: Bring HDMI up from power off if necessary.
In reply to Eric AnholtIf the firmware hadn't brought up HDMI for us, we need to do its power-on reset sequence (reset HD and and clear its STANDBY bits, reset HDMI, and leave the PHY disabled).
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 29 ++++++++++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_regs.h | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +28 -1
@@ -497,6 +497,16 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) goto err_put_i2c; } +/* This is the rate that is set by the firmware. The number +* needs to be a bit higher than the pixel clock rate +* (generally 148.5Mhz). +*/ + ret =clk_set_rate (hdmi->hsm_clock,163682864 ); +if (ret) { +DRM_ERROR ("Failed to set HSM clock rate: %d\n" , ret); + goto err_unprepare_pix; + } + ret =clk_prepare_enable (hdmi->hsm_clock);if (ret) { DRM_ERROR("Failed to turn on HDMI state machine clock: %d\n",
@@ -518,7 +528,24 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) vc4->hdmi = hdmi;/* HDMI core must be enabled. */ -WARN_ON_ONCE ((HD_READ (VC4_HD_M_CTL ) &VC4_HD_M_ENABLE ) ==0 ); +if (!(HD_READ (VC4_HD_M_CTL ) &VC4_HD_M_ENABLE )) { +HD_WRITE (VC4_HD_M_CTL ,VC4_HD_M_SW_RST ); +udelay (1 ); +HD_WRITE (VC4_HD_M_CTL ,0 ); + +HD_WRITE (VC4_HD_M_CTL ,VC4_HD_M_ENABLE ); + +HDMI_WRITE (VC4_HDMI_SW_RESET_CONTROL , +VC4_HDMI_SW_RESET_HDMI | +VC4_HDMI_SW_RESET_FORMAT_DETECT ); + +HDMI_WRITE (VC4_HDMI_SW_RESET_CONTROL ,0 ); + +/* PHY should be in reset, like +* vc4_hdmi_encoder_disable() does. +*/ +HDMI_WRITE (VC4_HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); + }drm_encoder_init (drm, hdmi->encoder, &vc4_hdmi_encoder_funcs,DRM_MODE_ENCODER_TMDS ,NULL );
drivers/gpu/drm/vc4/vc4_regs.h +2 -0
@@ -456,6 +456,8 @@#define VC4_HDMI_TX_PHY_RESET_CTL 0x2c0#define VC4_HD_M_CTL 0x00c +# define VC4_HD_M_REGISTER_FILE_STANDBY (3 << 6) +# define VC4_HD_M_RAM_STANDBY (3 << 4)# define VC4_HD_M_SW_RST BIT(2)# define VC4_HD_M_ENABLE BIT(0)
Signature · 6 lines
2.7.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/6 drm/vc4: Add another reg to HDMI debug dumping.
In reply to Eric AnholtThis is also involved in the HDMI setup sequence so it's nice to see it.
---
This patch and the next one I'd target for -next, since they aren't functional fixes.
drivers/gpu/drm/vc4/vc4_hdmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -0
@@ -95,6 +95,7 @@ static const struct {HDMI_REG (VC4_HDMI_SW_RESET_CONTROL ),HDMI_REG (VC4_HDMI_HOTPLUG_INT ),HDMI_REG (VC4_HDMI_HOTPLUG ), +HDMI_REG (VC4_HDMI_RAM_PACKET_CONFIG ),HDMI_REG (VC4_HDMI_HORZA ),HDMI_REG (VC4_HDMI_HORZB ), HDMI_REG(VC4_HDMI_FIFO_CTL),
Signature · 6 lines
2.7.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/6 drm/vc4: Fix the name of the VSYNCD_EVEN register.
In reply to Eric AnholtIt's used for delaying vsync in interlaced mode.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 2 +- drivers/gpu/drm/vc4/vc4_regs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
@@ -88,7 +88,7 @@ static const struct { } crtc_regs[] = {CRTC_REG (PV_CONTROL ),CRTC_REG (PV_V_CONTROL ), -CRTC_REG (PV_VSYNCD ), +CRTC_REG (PV_VSYNCD_EVEN ),CRTC_REG (PV_HORZA ),CRTC_REG (PV_HORZB ), CRTC_REG(PV_VERTA),
drivers/gpu/drm/vc4/vc4_regs.h +1 -1
@@ -187,7 +187,7 @@# define PV_VCONTROL_CONTINUOUS BIT(1)# define PV_VCONTROL_VIDEN BIT(0) -#define PV_VSYNCD 0x08 +#define PV_VSYNCD_EVEN 0x08#define PV_HORZA 0x0c# define PV_HORZA_HBP_MASK VC4_MASK(31, 16)
Signature · 6 lines
2.7.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/6 drm/vc4: Fix setting of vertical timings in the CRTC.
In reply to Eric AnholtIt looks like when I went to add the interlaced bits, I just took the existing PV_VERT* block and indented it, instead of copy and pasting it first. Without this, changing resolution never worked.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/vc4/vc4_crtc.c +10 -0
@@ -217,6 +217,16 @@ static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc) PV_HORZB_HFP) | VC4_SET_FIELD(mode->hdisplay, PV_HORZB_HACTIVE)); +CRTC_WRITE (PV_VERTA , +VC4_SET_FIELD (mode->vtotal - mode->vsync_end, +PV_VERTA_VBP ) | +VC4_SET_FIELD (mode->vsync_end - mode->vsync_start, +PV_VERTA_VSYNC )); +CRTC_WRITE (PV_VERTB , +VC4_SET_FIELD (mode->vsync_start - mode->vdisplay, +PV_VERTB_VFP ) | +VC4_SET_FIELD (vactive,PV_VERTB_VACTIVE )); +if (interlace) { CRTC_WRITE(PV_VERTA_EVEN, VC4_SET_FIELD(mode->vtotal - mode->vsync_end - 1,
Signature · 6 lines
2.7.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/6 drm/vc4: Initialize scaler DISPBKGND on modeset.
In reply to Eric AnholtWe weren't updating the interlaced bit, so we'd scan out incorrectly if the firmware had brought up the TV encoder and we were switching to HDMI.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 6 ++++++ drivers/gpu/drm/vc4/vc4_regs.h | 14 ++++++++++++++ 2 files changed, 20 insertions(+)
drivers/gpu/drm/vc4/vc4_crtc.c +6 -0
@@ -188,6 +188,8 @@ static int vc4_get_clock_select(struct drm_crtc *crtc)static void vc4_crtc_mode_set_nofb (struct drm_crtc *crtc) { +struct drm_device *dev = crtc->dev; +struct vc4_dev *vc4 =to_vc4_dev (dev);struct vc4_crtc *vc4_crtc =to_vc4_crtc (crtc);struct drm_crtc_state *state = crtc->state;struct drm_display_mode *mode = &state->adjusted_mode;
@@ -256,6 +258,10 @@ static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)PV_CONTROL_FIFO_CLR | PV_CONTROL_EN); +HVS_WRITE (SCALER_DISPBKGNDX (vc4_crtc->channel), +SCALER_DISPBKGND_AUTOHS | + (interlace ?SCALER_DISPBKGND_INTERLACE :0 )); +if (debug_dump_regs) {DRM_INFO ("CRTC %d regs after:\n" ,drm_crtc_index (crtc));vc4_crtc_dump_regs (vc4_crtc);
drivers/gpu/drm/vc4/vc4_regs.h +14 -0
@@ -350,6 +350,17 @@# define SCALER_DISPCTRLX_HEIGHT_SHIFT 0#define SCALER_DISPBKGND0 0x00000044 +# define SCALER_DISPBKGND_AUTOHS BIT(31) +# define SCALER_DISPBKGND_INTERLACE BIT(30) +# define SCALER_DISPBKGND_GAMMA BIT(29) +# define SCALER_DISPBKGND_TESTMODE_MASK VC4_MASK(28, 25) +# define SCALER_DISPBKGND_TESTMODE_SHIFT 25 +/* Enables filling the scaler line with the RGB value in the low 24 +* bits before compositing. Costs cycles, so should be skipped if +* opaque display planes will cover everything. +*/ +# define SCALER_DISPBKGND_FILL BIT(24) +#define SCALER_DISPSTAT0 0x00000048#define SCALER_DISPBASE0 0x0000004c# define SCALER_DISPSTATX_MODE_MASK VC4_MASK(31, 30)
@@ -362,6 +373,9 @@# define SCALER_DISPSTATX_EMPTY BIT(28)#define SCALER_DISPCTRL1 0x00000050#define SCALER_DISPBKGND1 0x00000054 +#define SCALER_DISPBKGNDX (x) (SCALER_DISPBKGND0 + \ + (x) * (SCALER_DISPBKGND1 - \ + SCALER_DISPBKGND0))#define SCALER_DISPSTAT1 0x00000058#define SCALER_DISPSTATX (x) (SCALER_DISPSTAT0 + \ (x) * (SCALER_DISPSTAT1 - \
Signature · 6 lines
2.7.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel