From: Anatolij Gustschin <agust@denx.de>
To: linuxppc-dev@ozlabs.org
Cc: linux-fbdev@vger.kernel.org, wd@denx.de, dzu@denx.de,
jrigby@gmail.com, Anatolij Gustschin <agust@denx.de>,
yorksun@freescale.com
Subject: [PATCH 1/3] video: add support for getting video mode from device tree
Date: Sat, 27 Feb 2010 21:58:20 +0000 [thread overview]
Message-ID: <1267307902-31939-2-git-send-email-agust@denx.de> (raw)
In-Reply-To: <fa686aa41002161006l3b301febt94fe990df4bddfe9@mail.gmail.com>
Framebuffer drivers may want to get panel timing info
from the device tree. This patch adds appropriate support.
Subsequent patch for FSL DIU frame buffer driver makes use
of this functionality.
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
drivers/video/Kconfig | 5 +++
drivers/video/Makefile | 1 +
drivers/video/ofmode.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++
drivers/video/ofmode.h | 6 +++
4 files changed, 107 insertions(+), 0 deletions(-)
create mode 100644 drivers/video/ofmode.c
create mode 100644 drivers/video/ofmode.h
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 5a5c303..dc1beb0 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -203,6 +203,11 @@ config FB_MACMODES
depends on FB
default n
+config FB_OF_MODE
+ tristate
+ depends on FB && OF
+ default n
+
config FB_BACKLIGHT
bool
depends on FB
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 4ecb30c..c4a912b 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_FB_SVGALIB) += svgalib.o
obj-$(CONFIG_FB_MACMODES) += macmodes.o
obj-$(CONFIG_FB_DDC) += fb_ddc.o
obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
+obj-$(CONFIG_FB_OF_MODE) += ofmode.o
# Hardware specific drivers go first
obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
diff --git a/drivers/video/ofmode.c b/drivers/video/ofmode.c
new file mode 100644
index 0000000..78caad1
--- /dev/null
+++ b/drivers/video/ofmode.c
@@ -0,0 +1,95 @@
+/*
+ * Get video mode settings from Flattened Device Tree.
+ *
+ * Copyright (C) 2010 DENX Software Engineering.
+ * Anatolij Gustschin <agust@denx.de>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License version 2. See the file COPYING in the main directory
+ * of this archive for more details.
+ */
+
+#include <linux/fb.h>
+#include <linux/of.h>
+
+int __devinit of_get_video_mode(struct device_node *np,
+ struct fb_info *info)
+{
+ struct fb_videomode dt_mode;
+ const u32 *prop;
+ unsigned int len;
+
+ if (!np || !info)
+ return -EINVAL;
+
+ prop = of_get_property(np, "width", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.xres = *prop;
+
+ prop = of_get_property(np, "height", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.yres = *prop;
+
+ prop = of_get_property(np, "depth", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ info->var.bits_per_pixel = *prop;
+
+ prop = of_get_property(np, "linebytes", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ info->fix.line_length = *prop;
+
+ prop = of_get_property(np, "refresh", &len);
+ if (prop && len = sizeof(u32))
+ dt_mode.refresh = *prop; /* optional */
+
+ prop = of_get_property(np, "pixclock", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.pixclock = *prop;
+
+ prop = of_get_property(np, "left_margin", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.left_margin = *prop;
+
+ prop = of_get_property(np, "right_margin", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.right_margin = *prop;
+
+ prop = of_get_property(np, "upper_margin", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.upper_margin = *prop;
+
+ prop = of_get_property(np, "lower_margin", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.lower_margin = *prop;
+
+ prop = of_get_property(np, "hsync_len", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.hsync_len = *prop;
+
+ prop = of_get_property(np, "vsync_len", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.vsync_len = *prop;
+
+ prop = of_get_property(np, "sync", &len);
+ if (!prop || len != sizeof(u32))
+ goto err;
+ dt_mode.sync = *prop;
+
+ fb_videomode_to_var(&info->var, &dt_mode);
+
+ return 0;
+err:
+ pr_err("%s: Can't find expected mode entry\n", np->full_name);
+ return -EINVAL;
+}
diff --git a/drivers/video/ofmode.h b/drivers/video/ofmode.h
new file mode 100644
index 0000000..9a13bec
--- /dev/null
+++ b/drivers/video/ofmode.h
@@ -0,0 +1,6 @@
+#ifndef _OFMODE_H
+#define _OFMODE_H
+
+extern int __devinit of_get_video_mode(struct device_node *np,
+ struct fb_info *info);
+#endif
--
1.6.3.3
next prev parent reply other threads:[~2010-02-27 21:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fa686aa41002161006l3b301febt94fe990df4bddfe9@mail.gmail.com>
2010-02-27 21:58 ` [PATCH 0/3] Rework MPC5121 DIU support (for 2.6.34) Anatolij Gustschin
2010-02-28 7:04 ` Grant Likely
2010-02-28 14:32 ` sun york-R58495
2010-02-27 21:58 ` Anatolij Gustschin [this message]
2010-02-28 6:30 ` [PATCH 1/3] video: add support for getting video mode from device Grant Likely
[not found] ` <fa686aa41002272230s7f900c0fv1aabf0e26ccbf84c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-28 8:44 ` Mitch Bradley
[not found] ` <4B8A2CD7.7070305-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2010-02-28 14:47 ` Grant Likely
2010-03-01 3:45 ` [PATCH 1/3] video: add support for getting video mode from Benjamin Herrenschmidt
2010-04-28 13:43 ` Anatolij Gustschin
2010-05-19 21:19 ` [PATCH 1/3] video: add support for getting video mode from device Grant Likely
2010-02-27 21:58 ` [PATCH 2/3] fbdev: fsl-diu-fb.c: allow setting panel video mode from DT Anatolij Gustschin
2010-02-28 6:52 ` [PATCH 2/3] fbdev: fsl-diu-fb.c: allow setting panel video mode Grant Likely
2010-02-27 21:58 ` [PATCH 3/3] powerpc/mpc5121: shared DIU framebuffer support Anatolij Gustschin
2010-02-28 6:50 ` Grant Likely
2010-04-28 20:28 ` Anatolij Gustschin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1267307902-31939-2-git-send-email-agust@denx.de \
--to=agust@denx.de \
--cc=dzu@denx.de \
--cc=jrigby@gmail.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=wd@denx.de \
--cc=yorksun@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).