dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Cc: "Boris Brezillon" <boris.brezillon@bootlin.com>,
	nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	"Ben Skeggs" <bskeggs@redhat.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: [PATCH v2 3/4] drm/vc4: Attach underscan props to the HDMI connector
Date: Fri, 11 May 2018 16:59:18 +0200	[thread overview]
Message-ID: <20180511145919.22447-4-boris.brezillon@bootlin.com> (raw)
In-Reply-To: <20180511145919.22447-1-boris.brezillon@bootlin.com>

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>
---
Changes in v2:
- none
---
 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,
+						  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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2018-05-11 14:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11 14:59 [PATCH v2 0/4] drm/connector: Provide generic support for underscan Boris Brezillon
     [not found] ` <20180511145919.22447-1-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
2018-05-11 14:59   ` [PATCH v2 1/4] drm/connector: Add generic underscan properties Boris Brezillon
2018-05-11 14:59   ` [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes Boris Brezillon
     [not found]     ` <20180511145919.22447-3-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
2018-05-11 15:34       ` Ville Syrjälä
     [not found]         ` <20180511153450.GS23723-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-05-11 15:52           ` Boris Brezillon
2018-05-11 16:54             ` Ville Syrjälä
     [not found]               ` <20180511165402.GU23723-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-05-11 17:12                 ` Boris Brezillon
2018-05-11 17:29                   ` Ville Syrjälä
     [not found]                     ` <20180511172948.GV23723-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-05-11 19:47                       ` Boris Brezillon
2018-05-11 20:46                         ` Ville Syrjälä
     [not found]                           ` <20180511204643.GW23723-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-05-14  7:05                             ` Eric Anholt
2018-05-11 20:11                       ` Eric Anholt
2018-05-11 14:59   ` [PATCH v2 4/4] drm/nouveau: Switch to the generic underscan props Boris Brezillon
2018-05-11 14:59 ` Boris Brezillon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180511145919.22447-4-boris.brezillon@bootlin.com \
    --to=boris.brezillon@bootlin.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nouveau@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox