public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Igor Opaniuk <igor.opaniuk@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/6] video: mxsfb: fix mxsfb fbdev binding issues
Date: Wed, 19 Jun 2019 11:47:05 +0300	[thread overview]
Message-ID: <20190619084710.19074-2-igor.opaniuk@gmail.com> (raw)
In-Reply-To: <20190619084710.19074-1-igor.opaniuk@gmail.com>

From: Igor Opaniuk <igor.opaniuk@toradex.com>

Add support for display and bits-per-pixel properties.

Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
---
 drivers/video/mxsfb.c | 74 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 12 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index f02ba20138..6c9a7c05e8 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -271,6 +271,42 @@ dealloc_fb:
 }
 #else /* ifndef CONFIG_DM_VIDEO */
 
+static int mxs_of_get_timings(struct udevice *dev,
+			      struct display_timing *timings,
+			      u32 *bpp)
+{
+	int ret = 0;
+	u32 display_phandle;
+	ofnode display_node;
+
+	ret = ofnode_read_u32(dev_ofnode(dev), "display", &display_phandle);
+	if (ret) {
+		dev_err(dev, "required display property isn't provided\n");
+		return -EINVAL;
+	}
+
+	display_node = ofnode_get_by_phandle(display_phandle);
+	if (!ofnode_valid(display_node)) {
+		dev_err(dev, "failed to find display subnode\n");
+		return -EINVAL;
+	}
+
+	ret = ofnode_read_u32(display_node, "bits-per-pixel", bpp);
+	if (ret) {
+		dev_err(dev,
+			"required bits-per-pixel property isn't provided\n");
+		return -EINVAL;
+	}
+
+	ret = ofnode_decode_display_timing(display_node, 0, timings);
+	if (ret) {
+		dev_err(dev, "failed to get any display timings\n");
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
 static int mxs_video_probe(struct udevice *dev)
 {
 	struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
@@ -278,18 +314,16 @@ static int mxs_video_probe(struct udevice *dev)
 
 	struct ctfb_res_modes mode;
 	struct display_timing timings;
-	int bpp = -1;
+	u32 bpp = 0;
 	u32 fb_start, fb_end;
 	int ret;
 
 	debug("%s() plat: base 0x%lx, size 0x%x\n",
 	       __func__, plat->base, plat->size);
 
-	ret = ofnode_decode_display_timing(dev_ofnode(dev), 0, &timings);
-	if (ret) {
-		dev_err(dev, "failed to get any display timings\n");
-		return -EINVAL;
-	}
+	ret = mxs_of_get_timings(dev, &timings, &bpp);
+	if (ret)
+		return ret;
 
 	mode.xres = timings.hactive.typ;
 	mode.yres = timings.vactive.typ;
@@ -301,13 +335,12 @@ static int mxs_video_probe(struct udevice *dev)
 	mode.vsync_len = timings.vsync_len.typ;
 	mode.pixclock = HZ2PS(timings.pixelclock.typ);
 
-	bpp = BITS_PP;
-
 	ret = mxs_probe_common(&mode, bpp, plat->base);
 	if (ret)
 		return ret;
 
 	switch (bpp) {
+	case 32:
 	case 24:
 	case 18:
 		uc_priv->bpix = VIDEO_BPP32;
@@ -341,15 +374,32 @@ static int mxs_video_bind(struct udevice *dev)
 {
 	struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
 	struct display_timing timings;
+	u32 bpp = 0;
+	u32 bytes_pp = 0;
 	int ret;
 
-	ret = ofnode_decode_display_timing(dev_ofnode(dev), 0, &timings);
-	if (ret) {
-		dev_err(dev, "failed to get any display timings\n");
+	ret = mxs_of_get_timings(dev, &timings, &bpp);
+	if (ret)
+		return ret;
+
+	switch (bpp) {
+	case 32:
+	case 24:
+	case 18:
+		bytes_pp = 4;
+		break;
+	case 16:
+		bytes_pp = 2;
+		break;
+	case 8:
+		bytes_pp = 1;
+		break;
+	default:
+		dev_err(dev, "invalid bpp specified (bpp = %i)\n", bpp);
 		return -EINVAL;
 	}
 
-	plat->size = timings.hactive.typ * timings.vactive.typ * BYTES_PP;
+	plat->size = timings.hactive.typ * timings.vactive.typ * bytes_pp;
 
 	return 0;
 }
-- 
2.17.1

  reply	other threads:[~2019-06-19  8:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-19  8:47 [U-Boot] [PATCH 0/6] Enabled DM_VIDEO for Colibri iMX7 NAND/iMX6ULL Igor Opaniuk
2019-06-19  8:47 ` Igor Opaniuk [this message]
2019-07-11  8:56   ` [U-Boot] [PATCH 1/6] video: mxsfb: fix mxsfb fbdev binding issues Igor Opaniuk
2019-07-11  9:07     ` Oleksandr Suvorov
2019-06-19  8:47 ` [U-Boot] [PATCH 2/6] ARM: dts: colibri_imx7: Fix lcdif node definition Igor Opaniuk
2019-07-11  8:57   ` Igor Opaniuk
2019-07-11  9:09     ` Oleksandr Suvorov
2019-06-19  8:47 ` [U-Boot] [PATCH 3/6] configs: colibri_imx7: enable DM_VIDEO Igor Opaniuk
2019-07-11  8:57   ` Igor Opaniuk
2019-07-11  9:10     ` Oleksandr Suvorov
2019-06-19  8:47 ` [U-Boot] [PATCH 4/6] colibri-imx6ull: support building with DM_VIDEO=y Igor Opaniuk
2019-07-11  8:57   ` Igor Opaniuk
2019-07-11  9:16     ` Oleksandr Suvorov
2019-06-19  8:47 ` [U-Boot] [PATCH 5/6] ARM: dts: colibri-imx6ull: extend lcdif node Igor Opaniuk
2019-07-11  8:57   ` Igor Opaniuk
2019-07-11  9:18     ` Oleksandr Suvorov
2019-06-19  8:47 ` [U-Boot] [PATCH 6/6] configs: colibri-imx6ull: switch to DM_VIDEO Igor Opaniuk
2019-07-11  8:58   ` Igor Opaniuk
2019-07-11  9:24     ` Oleksandr Suvorov
2019-07-11  8:56 ` [U-Boot] [PATCH 0/6] Enabled DM_VIDEO for Colibri iMX7 NAND/iMX6ULL Igor Opaniuk
2019-07-11 10:59 ` Igor Opaniuk
2019-07-25 11:13   ` Igor Opaniuk
2019-07-29  9:27   ` Anatolij Gustschin
2019-07-29 10:01     ` Igor Opaniuk
2019-07-29  9:23 ` 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=20190619084710.19074-2-igor.opaniuk@gmail.com \
    --to=igor.opaniuk@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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