From patchwork Wed Apr 17 15:17:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 2459661 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id C5E743FCA5 for ; Thu, 18 Apr 2013 11:12:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D442BE632B for ; Thu, 18 Apr 2013 04:12:44 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from service88.mimecast.com (service88.mimecast.com [195.130.217.12]) by gabe.freedesktop.org (Postfix) with ESMTP id 32267E6718 for ; Wed, 17 Apr 2013 08:24:38 -0700 (PDT) Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 17 Apr 2013 16:17:40 +0100 Received: from hornet.Cambridge.Arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Apr 2013 16:17:37 +0100 From: Pawel Moll To: linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 05/10] fbmon: Add extra video helper Date: Wed, 17 Apr 2013 16:17:17 +0100 Message-Id: <1366211842-21497-6-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366211842-21497-1-git-send-email-pawel.moll@arm.com> References: <1366211842-21497-1-git-send-email-pawel.moll@arm.com> X-OriginalArrivalTime: 17 Apr 2013 15:17:37.0795 (UTC) FILETIME=[B1F64D30:01CE3B7E] X-MC-Unique: 113041716174014001 X-Mailman-Approved-At: Thu, 18 Apr 2013 04:09:27 -0700 Cc: Russell King - ARM Linux , Laurent Pinchart , Pawel Moll X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org This function converts the fb_var_screeninfo to the videomode structure, to be used in fbdev drivers working with the Common Display Framework. Signed-off-by: Pawel Moll --- drivers/video/fbmon.c | 29 +++++++++++++++++++++++++++++ include/linux/fb.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c index 7f67099..f0ff2bf 100644 --- a/drivers/video/fbmon.c +++ b/drivers/video/fbmon.c @@ -1424,6 +1424,35 @@ int fb_videomode_from_videomode(const struct videomode *vm, return 0; } EXPORT_SYMBOL_GPL(fb_videomode_from_videomode); + +void videomode_from_fb_var_screeninfo(const struct fb_var_screeninfo *var, + struct videomode *vm) +{ + vm->pixelclock = PICOS2KHZ(var->pixclock) * 1000; + + vm->hactive = var->xres; + vm->hfront_porch = var->right_margin; + vm->hback_porch = var->left_margin; + vm->hsync_len = var->hsync_len; + + vm->vactive = var->yres; + vm->vfront_porch = var->lower_margin; + vm->vback_porch = var->upper_margin; + vm->vsync_len = var->vsync_len; + + vm->dmt_flags = 0; + if (var->sync & FB_SYNC_HOR_HIGH_ACT) + vm->dmt_flags |= VESA_DMT_HSYNC_HIGH; + if (var->sync & FB_SYNC_VERT_HIGH_ACT) + vm->dmt_flags |= VESA_DMT_VSYNC_HIGH; + + vm->data_flags = 0; + if (var->vmode & FB_VMODE_INTERLACED) + vm->data_flags |= DISPLAY_FLAGS_INTERLACED; + if (var->vmode & FB_VMODE_DOUBLE) + vm->data_flags |= DISPLAY_FLAGS_DOUBLESCAN; +} +EXPORT_SYMBOL_GPL(videomode_from_fb_var_screeninfo); #endif #if IS_ENABLED(CONFIG_OF_VIDEOMODE) diff --git a/include/linux/fb.h b/include/linux/fb.h index 58b9860..aae2ed3 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -721,6 +721,9 @@ extern int of_get_fb_videomode(struct device_node *np, int index); extern int fb_videomode_from_videomode(const struct videomode *vm, struct fb_videomode *fbmode); +extern void videomode_from_fb_var_screeninfo( + const struct fb_var_screeninfo *var, + struct videomode *vm); /* drivers/video/modedb.c */ #define VESA_MODEDB_SIZE 34