linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: denis@eukrea.com (Denis Carikli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v10][ 08/10] imx-drm: imx-drm-core: provide a common display timings retrival function.
Date: Wed, 12 Mar 2014 17:31:05 +0100	[thread overview]
Message-ID: <1394641867-15629-8-git-send-email-denis@eukrea.com> (raw)
In-Reply-To: <1394641867-15629-1-git-send-email-denis@eukrea.com>

imx_drm_of_get_extra_timing_flags will be used to
retrive the native-mode and de-active display-timings
node properties in the device tree.

Signed-off-by: Denis Carikli <denis@eukrea.com>
---
ChangeLog v9->v10:
- New patch that was splitted out of
  "staging: imx-drm: Use de-active and pixelclk-active
- When a IMXDRM_MODE_FLAG_ flag is set, its opposite
  flag is also unset.
---
 drivers/staging/imx-drm/imx-drm-core.c |   57 ++++++++++++++++++++++++++++++++
 drivers/staging/imx-drm/imx-drm.h      |    2 ++
 2 files changed, 59 insertions(+)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 6a71cd9..d877b77 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -24,6 +24,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
+#include <video/of_display_timing.h>
 
 #include "imx-drm.h"
 
@@ -492,6 +493,62 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
 }
 EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of);
 
+int imx_drm_of_get_extra_timing_flags(struct drm_connector *connector,
+				 struct drm_display_mode *mode,
+				 struct device_node *display_np)
+{
+	struct drm_display_mode *new_mode = drm_mode_create(connector->dev);
+	struct device_node *timings_np;
+	struct device_node *mode_np;
+	u32 val;
+
+	if (!new_mode)
+		return -EINVAL;
+
+	of_get_drm_display_mode(display_np, mode, OF_USE_NATIVE_MODE);
+
+	timings_np = of_get_child_by_name(display_np, "display-timings");
+	if (timings_np) {
+		/* get the display mode node */
+		mode_np = of_parse_phandle(timings_np,
+					   "native-mode", 0);
+		if (!mode_np)
+			mode_np = of_get_next_child(timings_np, NULL);
+
+		if (!of_property_read_u32(mode_np, "de-active", &val)) {
+			if (val) {
+				mode->private_flags |=
+					IMXDRM_MODE_FLAG_DE_HIGH;
+				mode->private_flags &=
+					~IMXDRM_MODE_FLAG_DE_LOW;
+			} else {
+				mode->private_flags &=
+					~IMXDRM_MODE_FLAG_DE_HIGH;
+				mode->private_flags |=
+					IMXDRM_MODE_FLAG_DE_LOW;
+			}
+		}
+
+		if (!of_property_read_u32(mode_np, "pixelclk-active",
+					  &val)) {
+			if (val) {
+				mode->private_flags |=
+					IMXDRM_MODE_FLAG_PIXDATA_POSEDGE;
+				mode->private_flags &=
+					~IMXDRM_MODE_FLAG_PIXDATA_NEGEDGE;
+			} else {
+				mode->private_flags &=
+					~IMXDRM_MODE_FLAG_PIXDATA_POSEDGE;
+				mode->private_flags |=
+					IMXDRM_MODE_FLAG_PIXDATA_NEGEDGE;
+			}
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(imx_drm_of_get_extra_timing_flags);
+
 void imx_drm_set_default_timing_flags(struct drm_display_mode *mode)
 {
 	mode->private_flags &= ~IMXDRM_MODE_FLAG_DE_LOW;
diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h
index ae07d9d..ae01f4d 100644
--- a/drivers/staging/imx-drm/imx-drm.h
+++ b/drivers/staging/imx-drm/imx-drm.h
@@ -54,6 +54,8 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
 		struct drm_encoder *encoder);
 int imx_drm_encoder_parse_of(struct drm_device *drm,
 	struct drm_encoder *encoder, struct device_node *np);
+int imx_drm_of_get_extra_timing_flags(struct drm_connector *connector,
+	struct drm_display_mode *mode, struct device_node *display_np);
 void imx_drm_set_default_timing_flags(struct drm_display_mode *mode);
 
 int imx_drm_connector_mode_valid(struct drm_connector *connector,
-- 
1.7.9.5

  parent reply	other threads:[~2014-03-12 16:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12 16:30 [PATCH v10][ 01/10] [media] v4l2: add new V4L2_PIX_FMT_RGB666 pixel format Denis Carikli
2014-03-12 16:30 ` [PATCH v10][ 02/10] imx-drm: Add RGB666 support for parallel display Denis Carikli
2014-03-12 16:31 ` [PATCH v10][ 03/10] imx-drm: Correct BGR666 and the board's dts that use them Denis Carikli
2014-03-12 16:31 ` [PATCH v10][ 04/10] imx-drm: Match ipu_di_signal_cfg's clk_pol with its description Denis Carikli
2014-03-12 16:31 ` [PATCH v10][ 05/10] imx-drm: use defines for clock polarity settings Denis Carikli
2014-03-12 16:31 ` [PATCH v10][ 06/10] ARM: dts: imx5*, imx6*: correct display-timings nodes Denis Carikli
2014-03-12 16:31 ` [PATCH v10][ 07/10] imx-drm: Prepare imx-drm for extra display-timings retrival Denis Carikli
2014-03-12 16:31 ` Denis Carikli [this message]
2014-03-12 16:31 ` [PATCH v10][ 09/10] imx-drm: parallel-display: retrive extra display-timings Denis Carikli
2014-03-12 16:31 ` [PATCH v10][ 10/10] ARM: dts: mbimx51sd: Add display support Denis Carikli

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=1394641867-15629-8-git-send-email-denis@eukrea.com \
    --to=denis@eukrea.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).