From patchwork Wed Oct 31 09:28:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Trumtrar X-Patchwork-Id: 1677101 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 9B134DF2F6 for ; Wed, 31 Oct 2012 09:32:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C527A0ACE for ; Wed, 31 Oct 2012 02:32:10 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTP id 91BA79E9FF for ; Wed, 31 Oct 2012 02:29:07 -0700 (PDT) Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1TTUbf-0003zr-6W; Wed, 31 Oct 2012 10:29:03 +0100 Received: from str by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1TTUbf-0000d1-3g; Wed, 31 Oct 2012 10:29:03 +0100 From: Steffen Trumtrar To: devicetree-discuss@lists.ozlabs.org Subject: [PATCH v7 3/8] of: add generic videomode description Date: Wed, 31 Oct 2012 10:28:03 +0100 Message-Id: <1351675689-26814-4-git-send-email-s.trumtrar@pengutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1351675689-26814-1-git-send-email-s.trumtrar@pengutronix.de> References: <1351675689-26814-1-git-send-email-s.trumtrar@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: str@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: linux-fbdev@vger.kernel.org, kernel@pengutronix.de, Stephen Warren , dri-devel@lists.freedesktop.org, Tomi Valkeinen , Rob Herring , Laurent Pinchart , Philipp Zabel , Steffen Trumtrar , Guennady Liakhovetski , linux-media@vger.kernel.org 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 Get videomode from devicetree in a format appropriate for the backend. drm_display_mode and fb_videomode are supported atm. Uses the display signal timings from of_display_timings Signed-off-by: Philipp Zabel Signed-off-by: Steffen Trumtrar --- drivers/of/Kconfig | 6 ++++++ drivers/of/Makefile | 1 + drivers/of/of_videomode.c | 47 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of_videomode.h | 15 ++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 drivers/of/of_videomode.c create mode 100644 include/linux/of_videomode.h diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 781e773..0575ffe 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -89,4 +89,10 @@ config OF_DISPLAY_TIMINGS help helper to parse display timings from the devicetree +config OF_VIDEOMODE + def_bool y + depends on VIDEOMODE + help + helper to get videomodes from the devicetree + endmenu # OF diff --git a/drivers/of/Makefile b/drivers/of/Makefile index c8e9603..09d556f 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_OF_PCI) += of_pci.o obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o obj-$(CONFIG_OF_MTD) += of_mtd.o obj-$(CONFIG_OF_DISPLAY_TIMINGS) += of_display_timings.o +obj-$(CONFIG_OF_VIDEOMODE) += of_videomode.o diff --git a/drivers/of/of_videomode.c b/drivers/of/of_videomode.c new file mode 100644 index 0000000..91a26fc --- /dev/null +++ b/drivers/of/of_videomode.c @@ -0,0 +1,47 @@ +/* + * generic videomode helper + * + * Copyright (c) 2012 Steffen Trumtrar , Pengutronix + * + * This file is released under the GPLv2 + */ +#include +#include +#include +#include + +/** + * of_get_videomode - get the videomode # from devicetree + * @np - devicenode with the display_timings + * @vm - set to return value + * @index - index into list of display_timings + * DESCRIPTION: + * Get a list of all display timings and put the one + * specified by index into *vm. This function should only be used, if + * only one videomode is to be retrieved. A driver that needs to work + * with multiple/all videomodes should work with + * of_get_display_timing_list instead. + **/ +int of_get_videomode(struct device_node *np, struct videomode *vm, int index) +{ + struct display_timings *disp; + int ret; + + disp = of_get_display_timing_list(np); + if (!disp) { + pr_err("%s: no timings specified\n", __func__); + return -EINVAL; + } + + if (index == OF_USE_NATIVE_MODE) + index = disp->native_mode; + + ret = videomode_from_timing(disp, vm, index); + if (ret) + return ret; + + display_timings_release(disp); + + return 0; +} +EXPORT_SYMBOL_GPL(of_get_videomode); diff --git a/include/linux/of_videomode.h b/include/linux/of_videomode.h new file mode 100644 index 0000000..01518e6 --- /dev/null +++ b/include/linux/of_videomode.h @@ -0,0 +1,15 @@ +/* + * Copyright 2012 Steffen Trumtrar + * + * videomode of-helpers + * + * This file is released under the GPLv2 + */ + +#ifndef __LINUX_OF_VIDEOMODE_H +#define __LINUX_OF_VIDEOMODE_H + +#include + +int of_get_videomode(struct device_node *np, struct videomode *vm, int index); +#endif /* __LINUX_OF_VIDEOMODE_H */