From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steffen Trumtrar Subject: =?UTF-8?q?=5BPATCH=20v17=203/7=5D=20video=3A=20add=20of=20helper=20for=20display=20timings/videomode?= Date: Fri, 25 Jan 2013 10:01:51 +0100 Message-ID: <1359104515-8907-4-git-send-email-s.trumtrar@pengutronix.de> References: <1359104515-8907-1-git-send-email-s.trumtrar@pengutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1359104515-8907-1-git-send-email-s.trumtrar@pengutronix.de> Sender: linux-media-owner@vger.kernel.org To: devicetree-discuss@lists.ozlabs.org, Dave Airlie Cc: Steffen Trumtrar , Philipp Zabel , Rob Herring , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Laurent Pinchart , Thierry Reding , Guennady Liakhovetski , linux-media@vger.kernel.org, Tomi Valkeinen , Stephen Warren , Florian Tobias Schandinat , Rob Clark , Leela Krishna Amudala , "Mohammed, Afzal" , kernel@pengutronix.de List-Id: devicetree@vger.kernel.org This adds support for reading display timings from DT into a struct display_timings. The of_display_timing implementation supports multiple subnodes. All children are read into an array, that can be queried. If no native mode is specified, the first subnode will be used. =46or cases where the graphics driver knows there can be only one mode description or where the driver only supports one mode, a helper function of_get_videomode is added, that gets a struct videomode from D= T. Signed-off-by: Steffen Trumtrar Signed-off-by: Philipp Zabel Acked-by: Stephen Warren Reviewed-by: Thierry Reding Acked-by: Thierry Reding Tested-by: Thierry Reding Tested-by: Philipp Zabel Reviewed-by: Laurent Pinchart Acked-by: Laurent Pinchart Tested-by: Afzal Mohammed Tested-by: Rob Clark Tested-by: Leela Krishna Amudala --- .../devicetree/bindings/video/display-timing.txt | 109 +++++++++ drivers/video/Kconfig | 15 ++ drivers/video/Makefile | 2 + drivers/video/of_display_timing.c | 239 ++++++++++++= ++++++++ drivers/video/of_videomode.c | 54 +++++ include/video/of_display_timing.h | 20 ++ include/video/of_videomode.h | 18 ++ 7 files changed, 457 insertions(+) create mode 100644 Documentation/devicetree/bindings/video/display-tim= ing.txt create mode 100644 drivers/video/of_display_timing.c create mode 100644 drivers/video/of_videomode.c create mode 100644 include/video/of_display_timing.h create mode 100644 include/video/of_videomode.h diff --git a/Documentation/devicetree/bindings/video/display-timing.txt= b/Documentation/devicetree/bindings/video/display-timing.txt new file mode 100644 index 0000000..1500385 --- /dev/null +++ b/Documentation/devicetree/bindings/video/display-timing.txt @@ -0,0 +1,109 @@ +display-timing bindings +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +display-timings node +-------------------- + +required properties: + - none + +optional properties: + - native-mode: The native mode for the display, in case multiple mode= s are + provided. When omitted, assume the first node is the native. + +timing subnode +-------------- + +required properties: + - hactive, vactive: display resolution + - hfront-porch, hback-porch, hsync-len: horizontal display timing par= ameters + in pixels + vfront-porch, vback-porch, vsync-len: vertical display timing param= eters in + lines + - clock-frequency: display clock in Hz + +optional properties: + - hsync-active: hsync pulse is active low/high/ignored + - vsync-active: vsync pulse is active low/high/ignored + - de-active: data-enable pulse is active low/high/ignored + - pixelclk-active: with + - active high =3D drive pixel data on rising edge/ + sample data on falling edge + - active low =3D drive pixel data on falling edge/ + sample data on rising edge + - ignored =3D ignored + - interlaced (bool): boolean to enable interlaced mode + - doublescan (bool): boolean to enable doublescan mode + +All the optional properties that are not bool follow the following log= ic: + <1>: high active + <0>: low active + omitted: not used on hardware + +There are different ways of describing the capabilities of a display. = The +devicetree representation corresponds to the one commonly found in dat= asheets +for displays. If a display supports multiple signal timings, the nativ= e-mode +can be specified. + +The parameters are defined as: + + +----------+-------------------------------------+----------+-------= + + | | =E2=86=91 | = | | + | | |vback_porch | | = | + | | =E2=86=93 | = | | + +----------#######################################----------+-------= + + | # =E2=86=91 # = | | + | # | # | = | + | hback # | # hfront | hsync = | + | porch # | hactive # porch | len = | + |<-------->#<-------+--------------------------->#<-------->|<----->= | + | # | # | = | + | # |vactive # | = | + | # | # | = | + | # =E2=86=93 # = | | + +----------#######################################----------+-------= + + | | =E2=86=91 | = | | + | | |vfront_porch | | = | + | | =E2=86=93 | = | | + +----------+-------------------------------------+----------+-------= + + | | =E2=86=91 | = | | + | | |vsync_len | | = | + | | =E2=86=93 | = | | + +----------+-------------------------------------+----------+-------= + + +Example: + + display-timings { + native-mode =3D <&timing0>; + timing0: 1080p24 { + /* 1920x1080p24 */ + clock-frequency =3D <52000000>; + hactive =3D <1920>; + vactive =3D <1080>; + hfront-porch =3D <25>; + hback-porch =3D <25>; + hsync-len =3D <25>; + vback-porch =3D <2>; + vfront-porch =3D <2>; + vsync-len =3D <2>; + hsync-active =3D <1>; + }; + }; + +Every required property also supports the use of ranges, so the common= ly used +datasheet description with minimum, typical and maximum values can be = used. + +Example: + + timing1: timing { + /* 1920x1080p24 */ + clock-frequency =3D <148500000>; + hactive =3D <1920>; + vactive =3D <1080>; + hsync-len =3D <0 44 60>; + hfront-porch =3D <80 88 95>; + hback-porch =3D <100 148 160>; + vfront-porch =3D <0 4 6>; + vback-porch =3D <0 36 50>; + vsync-len =3D <0 5 6>; + }; diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 09a8f0d..807c7fa 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -39,6 +39,21 @@ config DISPLAY_TIMING config VIDEOMODE bool =20 +config OF_DISPLAY_TIMING + bool "Enable device tree display timing support" + depends on OF + select DISPLAY_TIMING + help + helper to parse display timings from the devicetree + +config OF_VIDEOMODE + bool "Enable device tree videomode support" + depends on OF + select VIDEOMODE + select OF_DISPLAY_TIMING + help + helper to get videomodes from the devicetree + menuconfig FB tristate "Support for frame buffer devices" ---help--- diff --git a/drivers/video/Makefile b/drivers/video/Makefile index e0dd820..f592f3b 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -169,4 +169,6 @@ obj-$(CONFIG_FB_VIRTUAL) +=3D vfb.o #video output switch sysfs driver obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) +=3D output.o obj-$(CONFIG_DISPLAY_TIMING) +=3D display_timing.o +obj-$(CONFIG_OF_DISPLAY_TIMING) +=3D of_display_timing.o obj-$(CONFIG_VIDEOMODE) +=3D videomode.o +obj-$(CONFIG_OF_VIDEOMODE) +=3D of_videomode.o diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_displ= ay_timing.c new file mode 100644 index 0000000..13ecd98 --- /dev/null +++ b/drivers/video/of_display_timing.c @@ -0,0 +1,239 @@ +/* + * OF helpers for parsing display timings + * + * Copyright (c) 2012 Steffen Trumtrar , Pe= ngutronix + * + * based on of_videomode.c by Sascha Hauer + * + * This file is released under the GPLv2 + */ +#include +#include +#include +#include