From patchwork Thu Apr 11 13:22:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 10896011 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 07E8117EF for ; Thu, 11 Apr 2019 13:23:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCDE228D29 for ; Thu, 11 Apr 2019 13:23:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB0EE28D74; Thu, 11 Apr 2019 13:23:21 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 614F128D29 for ; Thu, 11 Apr 2019 13:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K8Ajgk5F7C6tNRwOiEmVV/eo9ap17NKy2PCxQaabRO0=; b=nLGZ56oYn9mMBU guBU+j8d/lr2cN2ADeI82rXvatZv/6Lv05oA5VvqIcAS6F14dEkJsKDYM4Cj+GCbqzB1FvuaVzHN5 vM4sNe55y12TXrdTErYElnWLGLD0WDVgMowc0XYoEPJK7fTaVlfSLbnY4DqOFkTyO3I6ZbUmyQhFH 6kGGLppQFK8rYVahwqGomNkHv8zi0gHFYOzF4gE2Wz//cuknZ4VXEIgxXODqTOXeWbzIqC5V9P4lY Wv4tYW0hoWOjdBd+NqPWepUf6fI68sFkXW1DeJRK3dSVe/JLkT4Dyx8l501z840wVrqq03XcuCGEV J65f84/dSvEeeRxp7z9A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEZfh-000481-7o; Thu, 11 Apr 2019 13:23:17 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEZfP-0003l2-4s for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2019 13:23:02 +0000 X-Originating-IP: 90.88.18.121 Received: from localhost (aaubervilliers-681-1-63-121.w90-88.abo.wanadoo.fr [90.88.18.121]) (Authenticated sender: maxime.ripard@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id ED4D620008; Thu, 11 Apr 2019 13:22:55 +0000 (UTC) From: Maxime Ripard To: Maarten Lankhorst , Sean Paul , Maxime Ripard , Daniel Vetter , David Airlie Subject: [PATCH v2 4/5] drm/modes: Parse overscan properties Date: Thu, 11 Apr 2019 15:22:42 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_062259_878319_654F5669 X-CRM114-Status: GOOD ( 13.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eben@raspberrypi.org, dri-devel@lists.freedesktop.org, Paul Kocialkowski , Eric Anholt , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Properly configuring the overscan properties might be needed for the initial setup of the framebuffer for display that still have overscan. Let's allow for more properties on the kernel command line to setup each margin. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/drm_fb_helper.c | 47 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_modes.c | 44 ++++++++++++++++++++++++++++++++- include/drm/drm_connector.h | 1 +- 3 files changed, 92 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 8781897559b2..4e403fe1f451 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -2567,6 +2567,51 @@ static void drm_setup_crtc_rotation(struct drm_fb_helper *fb_helper, fb_helper->sw_rotations |= DRM_MODE_ROTATE_0; } +static void drm_setup_connector_margins(struct drm_connector *connector) +{ + struct drm_cmdline_mode *cmdline = &connector->cmdline_mode; + struct drm_modeset_acquire_ctx ctx; + struct drm_atomic_state *state; + struct drm_device *dev = connector->dev; + int ret; + + if (!drm_drv_uses_atomic_modeset(dev)) + return; + + drm_modeset_acquire_init(&ctx, 0); + + state = drm_atomic_state_alloc(dev); + state->acquire_ctx = &ctx; + +retry: + drm_atomic_set_property(state, &connector->base, + dev->mode_config.tv_left_margin_property, + cmdline->overscan_left); + + drm_atomic_set_property(state, &connector->base, + dev->mode_config.tv_right_margin_property, + cmdline->overscan_right); + + drm_atomic_set_property(state, &connector->base, + dev->mode_config.tv_top_margin_property, + cmdline->overscan_top); + + drm_atomic_set_property(state, &connector->base, + dev->mode_config.tv_bottom_margin_property, + cmdline->overscan_bottom); + + ret = drm_atomic_commit(state); + if (ret == -EDEADLK) { + drm_atomic_state_clear(state); + drm_modeset_backoff(&ctx); + goto retry; + } + + drm_atomic_state_put(state); + drm_modeset_drop_locks(&ctx); + drm_modeset_acquire_fini(&ctx); +} + static void drm_setup_crtcs(struct drm_fb_helper *fb_helper, u32 width, u32 height) { @@ -2680,6 +2725,8 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper) struct drm_connector *connector = fb_helper->connector_info[i]->connector; + drm_setup_connector_margins(connector); + /* use first connected connector for the physical dimensions */ if (connector->status == connector_status_connected) { info->var.width = connector->display_info.width_mm; diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index ac8d70b92b62..493ba3ccde70 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -1586,6 +1586,50 @@ static int drm_mode_parse_cmdline_options(char *str, size_t len, } else if (!strncmp(option, "reflect_y", delim - option)) { rotation |= DRM_MODE_REFLECT_Y; sep = delim; + } else if (!strncmp(option, "overscan_right", delim - option)) { + const char *value = delim + 1; + unsigned int margin; + + margin = simple_strtol(value, &sep, 10); + + /* Make sure we have parsed something */ + if (sep == value) + return -EINVAL; + + mode->overscan_right = margin; + } else if (!strncmp(option, "overscan_left", delim - option)) { + const char *value = delim + 1; + unsigned int margin; + + margin = simple_strtol(value, &sep, 10); + + /* Make sure we have parsed something */ + if (sep == value) + return -EINVAL; + + mode->overscan_left = margin; + } else if (!strncmp(option, "overscan_top", delim - option)) { + const char *value = delim + 1; + unsigned int margin; + + margin = simple_strtol(value, &sep, 10); + + /* Make sure we have parsed something */ + if (sep == value) + return -EINVAL; + + mode->overscan_top = margin; + } else if (!strncmp(option, "overscan_bottom", delim - option)) { + const char *value = delim + 1; + unsigned int margin; + + margin = simple_strtol(value, &sep, 10); + + /* Make sure we have parsed something */ + if (sep == value) + return -EINVAL; + + mode->overscan_bottom = margin; } else { return -EINVAL; } diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index dfe7f2304b35..44d9885dd401 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -903,6 +903,7 @@ struct drm_cmdline_mode { int xres, yres; int bpp; int refresh; + int overscan_right, overscan_top, overscan_left, overscan_bottom; bool rb; bool interlace; bool cvt;