diff mbox

[3/3] drm/vc4: Attach underscan props to the HDMI connector

Message ID 20180507144434.20466-4-boris.brezillon@bootlin.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boris Brezillon May 7, 2018, 2:44 p.m. UTC
Now that the plane code takes the underscan setup into account, we can
safely attach the underscan props to the HDMI connector.

We also take care of filling AVI infoframes correctly to expose the
top/botton/left/right bar.

Note that these underscan props match pretty well the
overscan_{left,right,top,bottom} properties defined in config.txt and
parsed by the VC4 firmware.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Daniel Vetter May 7, 2018, 3:24 p.m. UTC | #1
On Mon, May 07, 2018 at 04:44:34PM +0200, Boris Brezillon wrote:
> Now that the plane code takes the underscan setup into account, we can
> safely attach the underscan props to the HDMI connector.
> 
> We also take care of filling AVI infoframes correctly to expose the
> top/botton/left/right bar.
> 
> Note that these underscan props match pretty well the
> overscan_{left,right,top,bottom} properties defined in config.txt and
> parsed by the VC4 firmware.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
>  drivers/gpu/drm/vc4/vc4_hdmi.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index 1a6db291d48b..17464b5981f9 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -323,6 +323,16 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
>  			   DRM_MODE_CONNECTOR_HDMIA);
>  	drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs);
>  
> +	/* The hborder and vborder limit is arbitrarily set to 1024 which
> +	 * should be more than enough for real use cases. Note that the actual
> +	 * limitation comes from the display mode:
> +	 *	hborder < hdisplay && vborder < vdisplay
> +	 */
> +	drm_connector_attach_underscan_properties(connector,

We should probably sprinkle __must_check over all these :-)
-Daniel

> +						  BIT(DRM_UNDERSCAN_OFF) |
> +						  BIT(DRM_UNDERSCAN_ON),
> +						  1024, 1024);
> +
>  	connector->polled = (DRM_CONNECTOR_POLL_CONNECT |
>  			     DRM_CONNECTOR_POLL_DISCONNECT);
>  
> @@ -408,6 +418,9 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder,
>  static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
>  {
>  	struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
> +	struct vc4_dev *vc4 = encoder->dev->dev_private;
> +	struct vc4_hdmi *hdmi = vc4->hdmi;
> +	struct drm_connector_state *cstate = hdmi->connector->state;
>  	struct drm_crtc *crtc = encoder->crtc;
>  	const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
>  	union hdmi_infoframe frame;
> @@ -426,6 +439,18 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
>  					   vc4_encoder->rgb_range_selectable,
>  					   false);
>  
> +	if (cstate->underscan.mode == DRM_UNDERSCAN_ON) {
> +		if (cstate->underscan.hborder) {
> +			frame.avi.right_bar = cstate->underscan.hborder / 2;
> +			frame.avi.left_bar = frame.avi.right_bar;
> +		}
> +
> +		if (cstate->underscan.vborder) {
> +			frame.avi.top_bar = cstate->underscan.vborder / 2;
> +			frame.avi.bottom_bar = frame.avi.top_bar;
> +		}
> +	}
> +
>  	vc4_hdmi_write_infoframe(encoder, &frame);
>  }
>  
> -- 
> 2.14.1
>
Boris Brezillon May 9, 2018, 2:52 p.m. UTC | #2
On Mon, 7 May 2018 17:24:08 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:

> On Mon, May 07, 2018 at 04:44:34PM +0200, Boris Brezillon wrote:
> > Now that the plane code takes the underscan setup into account, we can
> > safely attach the underscan props to the HDMI connector.
> > 
> > We also take care of filling AVI infoframes correctly to expose the
> > top/botton/left/right bar.
> > 
> > Note that these underscan props match pretty well the
> > overscan_{left,right,top,bottom} properties defined in config.txt and
> > parsed by the VC4 firmware.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---
> >  drivers/gpu/drm/vc4/vc4_hdmi.c | 25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > index 1a6db291d48b..17464b5981f9 100644
> > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > @@ -323,6 +323,16 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
> >  			   DRM_MODE_CONNECTOR_HDMIA);
> >  	drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs);
> >  
> > +	/* The hborder and vborder limit is arbitrarily set to 1024 which
> > +	 * should be more than enough for real use cases. Note that the actual
> > +	 * limitation comes from the display mode:
> > +	 *	hborder < hdisplay && vborder < vdisplay
> > +	 */
> > +	drm_connector_attach_underscan_properties(connector,  
> 
> We should probably sprinkle __must_check over all these :-)

I'm perfectly fine adding __must_check to
drm_connector_attach_underscan_properties(), but I'm definitely not
volunteering for a massive __must_check sanitization :P.
Daniel Vetter May 14, 2018, 4:43 p.m. UTC | #3
On Wed, May 09, 2018 at 04:52:38PM +0200, Boris Brezillon wrote:
> On Mon, 7 May 2018 17:24:08 +0200
> Daniel Vetter <daniel@ffwll.ch> wrote:
> 
> > On Mon, May 07, 2018 at 04:44:34PM +0200, Boris Brezillon wrote:
> > > Now that the plane code takes the underscan setup into account, we can
> > > safely attach the underscan props to the HDMI connector.
> > > 
> > > We also take care of filling AVI infoframes correctly to expose the
> > > top/botton/left/right bar.
> > > 
> > > Note that these underscan props match pretty well the
> > > overscan_{left,right,top,bottom} properties defined in config.txt and
> > > parsed by the VC4 firmware.
> > > 
> > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > > ---
> > >  drivers/gpu/drm/vc4/vc4_hdmi.c | 25 +++++++++++++++++++++++++
> > >  1 file changed, 25 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > > index 1a6db291d48b..17464b5981f9 100644
> > > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> > > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > > @@ -323,6 +323,16 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
> > >  			   DRM_MODE_CONNECTOR_HDMIA);
> > >  	drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs);
> > >  
> > > +	/* The hborder and vborder limit is arbitrarily set to 1024 which
> > > +	 * should be more than enough for real use cases. Note that the actual
> > > +	 * limitation comes from the display mode:
> > > +	 *	hborder < hdisplay && vborder < vdisplay
> > > +	 */
> > > +	drm_connector_attach_underscan_properties(connector,  
> > 
> > We should probably sprinkle __must_check over all these :-)
> 
> I'm perfectly fine adding __must_check to
> drm_connector_attach_underscan_properties(), but I'm definitely not
> volunteering for a massive __must_check sanitization :P.

Yeah I just meant for this one here. The others might be a good candidate
for Documentation/gpu/todo.rst.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 1a6db291d48b..17464b5981f9 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -323,6 +323,16 @@  static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
 			   DRM_MODE_CONNECTOR_HDMIA);
 	drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs);
 
+	/* The hborder and vborder limit is arbitrarily set to 1024 which
+	 * should be more than enough for real use cases. Note that the actual
+	 * limitation comes from the display mode:
+	 *	hborder < hdisplay && vborder < vdisplay
+	 */
+	drm_connector_attach_underscan_properties(connector,
+						  BIT(DRM_UNDERSCAN_OFF) |
+						  BIT(DRM_UNDERSCAN_ON),
+						  1024, 1024);
+
 	connector->polled = (DRM_CONNECTOR_POLL_CONNECT |
 			     DRM_CONNECTOR_POLL_DISCONNECT);
 
@@ -408,6 +418,9 @@  static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder,
 static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
 {
 	struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
+	struct vc4_dev *vc4 = encoder->dev->dev_private;
+	struct vc4_hdmi *hdmi = vc4->hdmi;
+	struct drm_connector_state *cstate = hdmi->connector->state;
 	struct drm_crtc *crtc = encoder->crtc;
 	const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
 	union hdmi_infoframe frame;
@@ -426,6 +439,18 @@  static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
 					   vc4_encoder->rgb_range_selectable,
 					   false);
 
+	if (cstate->underscan.mode == DRM_UNDERSCAN_ON) {
+		if (cstate->underscan.hborder) {
+			frame.avi.right_bar = cstate->underscan.hborder / 2;
+			frame.avi.left_bar = frame.avi.right_bar;
+		}
+
+		if (cstate->underscan.vborder) {
+			frame.avi.top_bar = cstate->underscan.vborder / 2;
+			frame.avi.bottom_bar = frame.avi.top_bar;
+		}
+	}
+
 	vc4_hdmi_write_infoframe(encoder, &frame);
 }