All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com,
	lgirdwood@gmail.com, broonie@kernel.org, robh@kernel.org,
	sam@ravnborg.org, emil.l.velikov@gmail.com, noralf@tronnes.org,
	geert+renesas@glider.be, hdegoede@redhat.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 5/9] drm/simplekms: Initialize framebuffer data from device-tree node
Date: Thu, 25 Jun 2020 14:00:07 +0200	[thread overview]
Message-ID: <20200625120011.16168-6-tzimmermann@suse.de> (raw)
In-Reply-To: <20200625120011.16168-1-tzimmermann@suse.de>

A firmware framebuffer might also be specified via device-tree files. If
no device platform data is given, try the DT device node.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tiny/simplekms.c | 84 ++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/drivers/gpu/drm/tiny/simplekms.c b/drivers/gpu/drm/tiny/simplekms.c
index ac2ebfcedd22..87636307aa4f 100644
--- a/drivers/gpu/drm/tiny/simplekms.c
+++ b/drivers/gpu/drm/tiny/simplekms.c
@@ -113,6 +113,76 @@ simplefb_get_format_pd(struct drm_device *dev,
 	return simplefb_get_validated_format(dev, pd->format);
 }
 
+static int
+simplefb_read_u32_of(struct drm_device *dev, struct device_node *of_node,
+		     const char* name, u32 *value)
+{
+	int ret = of_property_read_u32(of_node, name, value);
+	if (ret)
+		drm_err(dev, "simplefb: can't parse framebuffer %s: error %d\n",
+			name, ret);
+	return ret;
+}
+
+static int
+simplefb_read_string_of(struct drm_device *dev, struct device_node *of_node,
+			const char* name, const char **value)
+{
+	int ret = of_property_read_string(of_node, name, value);
+	if (ret)
+		drm_err(dev, "simplefb: can't parse framebuffer %s: error %d\n",
+			name, ret);
+	return ret;
+}
+
+static int
+simplefb_get_width_of(struct drm_device *dev, struct device_node *of_node)
+{
+	int ret;
+	u32 width;
+
+	ret = simplefb_read_u32_of(dev, of_node, "width", &width);
+	if (ret)
+		return ret;
+	return simplefb_get_validated_int0(dev, "width", width);
+}
+
+static int
+simplefb_get_height_of(struct drm_device *dev, struct device_node *of_node)
+{
+	int ret;
+	u32 height;
+
+	ret = simplefb_read_u32_of(dev, of_node, "height", &height);
+	if (ret)
+		return ret;
+	return simplefb_get_validated_int0(dev, "height", height);
+}
+
+static int
+simplefb_get_stride_of(struct drm_device *dev, struct device_node *of_node)
+{
+	int ret;
+	u32 stride;
+
+	ret = simplefb_read_u32_of(dev, of_node, "stride", &stride);
+	if (ret)
+		return ret;
+	return simplefb_get_validated_int(dev, "stride", stride);
+}
+
+static const struct drm_format_info *
+simplefb_get_format_of(struct drm_device *dev, struct device_node *of_node)
+{
+	int ret;
+	const char *format;
+
+	ret = simplefb_read_string_of(dev, of_node, "format", &format);
+	if (ret)
+		return ERR_PTR(ret);
+	return simplefb_get_validated_format(dev, format);
+}
+
 /*
  * Simple Framebuffer device
  */
@@ -163,6 +233,7 @@ static int simplekms_device_init_fb(struct simplekms_device *sdev)
 	struct drm_device *dev = &sdev->dev;
 	struct platform_device *pdev = sdev->pdev;
 	const struct simplefb_platform_data *pd = dev_get_platdata(&pdev->dev);
+	struct device_node *of_node = pdev->dev.of_node;
 
 	if (pd) {
 		width = simplefb_get_width_pd(dev, pd);
@@ -177,6 +248,19 @@ static int simplekms_device_init_fb(struct simplekms_device *sdev)
 		format = simplefb_get_format_pd(dev, pd);
 		if (IS_ERR(format))
 			return PTR_ERR(format);
+	} else if (of_node) {
+		width = simplefb_get_width_of(dev, of_node);
+		if (width < 0)
+			return width;
+		height = simplefb_get_height_of(dev, of_node);
+		if (height < 0)
+			return height;
+		stride = simplefb_get_stride_of(dev, of_node);
+		if (stride < 0)
+			return stride;
+		format = simplefb_get_format_of(dev, of_node);
+		if (IS_ERR(format))
+			return PTR_ERR(format);
 	} else {
 		drm_err(dev, "no simplefb configuration found\n");
 		return -ENODEV;
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-06-25 12:00 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 12:00 [RFC][PATCH 0/9] drm: Support simple-framebuffer devices and firmware fbs Thomas Zimmermann
2020-06-25 12:00 ` [PATCH 1/9] drm/format-helper: Pass destination pitch to drm_fb_memcpy_dstclip() Thomas Zimmermann
2020-06-29  8:40   ` Daniel Vetter
2020-09-25 14:55     ` Thomas Zimmermann
2020-09-26 16:42       ` Daniel Vetter
2020-09-28  7:22         ` Thomas Zimmermann
2020-09-28  8:53           ` Daniel Vetter
2020-09-28  9:13             ` Thomas Zimmermann
2020-09-29  9:19               ` Daniel Vetter
2020-09-29  9:39                 ` Thomas Zimmermann
2020-09-29 11:32                   ` Daniel Vetter
2020-09-28 10:24             ` Gerd Hoffmann
2020-09-28 13:42               ` Pekka Paalanen
2020-06-25 12:00 ` [PATCH 2/9] drm/format-helper: Add blitter functions Thomas Zimmermann
2020-06-29  8:46   ` Daniel Vetter
2020-06-25 12:00 ` [PATCH 3/9] drm: Add simplekms driver Thomas Zimmermann
2020-06-25 15:37   ` kernel test robot
2020-06-25 21:08   ` kernel test robot
2020-06-29  9:06   ` Daniel Vetter
2020-09-25 15:01     ` Thomas Zimmermann
2020-09-25 15:14       ` Maxime Ripard
2020-09-28  7:25         ` Thomas Zimmermann
2021-02-10 16:14     ` Thomas Zimmermann
2020-06-25 12:00 ` [PATCH 4/9] drm/simplekms: Add fbdev emulation Thomas Zimmermann
2020-06-29  9:11   ` Daniel Vetter
2020-06-25 12:00 ` Thomas Zimmermann [this message]
2020-06-30  2:36   ` [PATCH 5/9] drm/simplekms: Initialize framebuffer data from device-tree node Rob Herring
2020-06-25 12:00 ` [PATCH 6/9] drm/simplekms: Acquire clocks from DT device node Thomas Zimmermann
2020-06-25 13:34   ` Geert Uytterhoeven
2020-06-29  9:07     ` Daniel Vetter
2020-06-25 12:00 ` [PATCH 7/9] drm/simplekms: Acquire regulators " Thomas Zimmermann
2020-06-25 13:36   ` Geert Uytterhoeven
2020-06-25 12:00 ` [PATCH 8/9] drm: Add infrastructure for platform devices Thomas Zimmermann
2020-06-29  9:27   ` Daniel Vetter
2020-09-28  8:40     ` Thomas Zimmermann
2020-09-28  8:50       ` Daniel Vetter
2020-09-28  9:14         ` Thomas Zimmermann
2020-09-29  8:59     ` Thomas Zimmermann
2020-09-29  9:20       ` Daniel Vetter
2020-06-30  9:11   ` Daniel Vetter
2020-06-25 12:00 ` [PATCH 9/9] drm/simplekms: Acquire memory aperture for framebuffer Thomas Zimmermann
2020-06-25 16:08   ` kernel test robot
2020-06-29  9:22   ` Daniel Vetter
2020-06-29 16:04     ` Greg KH
2020-06-29 16:23       ` Mark Brown
2020-06-29 16:57         ` Greg KH
2020-06-30  2:13       ` Rob Herring
2020-06-30  8:50         ` Greg KH
2020-06-29  9:38 ` [RFC][PATCH 0/9] drm: Support simple-framebuffer devices and firmware fbs Hans de Goede
2020-06-30  9:06   ` Daniel Vetter
2020-06-30  9:13     ` Hans de Goede
2020-07-01 14:10     ` Thomas Zimmermann
2020-07-03 10:55       ` Hans de Goede
2020-07-03 11:42         ` Thomas Zimmermann
2020-07-03 12:58         ` Daniel Vetter
2020-07-03 14:11           ` Hans de Goede
2020-07-01 13:48   ` Thomas Zimmermann
2020-07-03 10:44     ` Hans de Goede

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=20200625120011.16168-6-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=broonie@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=hdegoede@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lgirdwood@gmail.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=robh@kernel.org \
    --cc=sam@ravnborg.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.