From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbdHBSNF (ORCPT ); Wed, 2 Aug 2017 14:13:05 -0400 Received: from vern.gendns.com ([206.190.152.46]:53336 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751154AbdHBSNE (ORCPT ); Wed, 2 Aug 2017 14:13:04 -0400 From: David Lechner To: dri-devel@lists.freedesktop.org Cc: David Lechner , Daniel Vetter , Jani Nikula , Sean Paul , David Airlie , linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/fb-helper: pass physical dimensions to fbdev Date: Wed, 2 Aug 2017 13:12:51 -0500 Message-Id: <1501697571-16823-1-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The fbdev subsystem has a place for physical dimensions (width and height in mm) that is readable by userspace. Since DRM also knows these dimensions, pass this information to the fbdev device. Signed-off-by: David Lechner --- v1 changes (from RFC): * Use loop to get info from first connected connector instead of just the first connector. v2 changes: * Update width in height in drm_setup_crtcs() also to handle hotplug events. As mentioned in the comments below, drm_setup_crtcs() can't set these values during init because the data structure hasn't been allocated yet, so we end up doing the same thing in two different places. drivers/gpu/drm/drm_fb_helper.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index b2a01d1..7813b86 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1884,6 +1884,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe uint32_t fb_width, uint32_t fb_height) { struct drm_framebuffer *fb = fb_helper->fb; + int i; info->pseudo_palette = fb_helper->pseudo_palette; info->var.xres_virtual = fb->width; @@ -1896,6 +1897,18 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe info->var.height = -1; info->var.width = -1; + drm_fb_helper_for_each_connector(fb_helper, i) { + struct drm_connector *connector = + fb_helper->connector_info[i]->connector; + + /* use the first connected connector for the physical dimensions */ + if (connector->status == connector_status_connected) { + info->var.height = connector->display_info.width_mm; + info->var.width = connector->display_info.height_mm; + break; + } + } + switch (fb->format->depth) { case 8: info->var.red.offset = 0; @@ -2355,6 +2368,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper, struct drm_display_mode **modes; struct drm_fb_offset *offsets; bool *enabled; + bool var_updated = false; int i; DRM_DEBUG_KMS("\n"); @@ -2429,6 +2443,23 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper, modeset->fb = fb_helper->fb; modeset->x = offset->x; modeset->y = offset->y; + + /* + * During init, drm_setup_crtcs() is called before the + * fbdev is allocated, so this only affects hotplug + * events. + * Only the info from the first connected connector is + * used. + */ + if (!var_updated && fb_helper->fbdev && + connector->status == connector_status_connected) { + struct fb_var_screeninfo *var = + &fb_helper->fbdev->var; + + var->width = connector->display_info.width_mm; + var->height = connector->display_info.height_mm; + var_updated = true; + } } } out: -- 2.7.4