From patchwork Thu Nov 22 11:23:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10693933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CE135A4 for ; Thu, 22 Nov 2018 11:23:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E1C62858D for ; Thu, 22 Nov 2018 11:23:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6204E285A6; Thu, 22 Nov 2018 11:23:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E33C02858D for ; Thu, 22 Nov 2018 11:23:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C45016E480; Thu, 22 Nov 2018 11:23:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 9ACA96E46A; Thu, 22 Nov 2018 11:23:34 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id C91042072F; Thu, 22 Nov 2018 12:23:33 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 808EC20510; Thu, 22 Nov 2018 12:23:33 +0100 (CET) From: Boris Brezillon To: Eric Anholt Subject: [PATCH v3 3/3] drm/vc4: Attach underscan props to the HDMI connector Date: Thu, 22 Nov 2018 12:23:31 +0100 Message-Id: <20181122112331.17735-4-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122112331.17735-1-boris.brezillon@bootlin.com> References: <20181122112331.17735-1-boris.brezillon@bootlin.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Boris Brezillon , Ben Skeggs , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changes in v3: - none 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 fd5522fd179e..b1b39256f4bc 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); }