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: 2454101 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C9DF7DF23A for ; Wed, 17 Apr 2013 15:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754050Ab3DQPRo (ORCPT ); Wed, 17 Apr 2013 11:17:44 -0400 Received: from service87.mimecast.com ([91.220.42.44]:34224 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966633Ab3DQPRn (ORCPT ); Wed, 17 Apr 2013 11:17:43 -0400 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 Cc: Laurent Pinchart , Linus Walleij , Russell King - ARM Linux , Pawel Moll 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 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.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