[PATCH v2 10/15] fb: Accept overlay framebuffers without modes

Sascha Hauer s.hauer at pengutronix.de
Fri Sep 27 03:37:43 PDT 2024


This adds a pointer to the base framebuffer to struct fb_info
in case the framebuffer is an overlay. As overlays do not have modes,
accept them in fb_enable() even when it doesn't have a mode.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/video/fb.c | 20 ++++++++++++++------
 include/fb.h       |  3 +++
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index a752c114e2..ccc755322e 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -138,7 +138,7 @@ static int fb_enable_set(struct param_d *param, void *priv)
 {
 	struct fb_info *info = priv;
 
-	if (!info->mode)
+	if (!info->mode && !info->base_plane)
 		return -EINVAL;
 
 	if (info->p_enable)
@@ -284,7 +284,7 @@ static int fb_set_shadowfb(struct param_d *p, void *priv)
 
 int register_framebuffer(struct fb_info *info)
 {
-	int id = get_free_deviceid("fb");
+	int id;
 	struct device *dev;
 	int ret, num_modes, i;
 	const char **names;
@@ -304,7 +304,18 @@ int register_framebuffer(struct fb_info *info)
 		info->line_length = info->xres * (info->bits_per_pixel >> 3);
 
 	info->cdev.ops = &fb_ops;
-	info->cdev.name = basprintf("fb%d", id);
+	if (info->base_plane) {
+		int ovl_id = info->base_plane->n_overlays++;
+
+		info->cdev.name = basprintf("%s_%d", dev_name(&info->base_plane->dev), ovl_id);
+		dev->id = DEVICE_ID_SINGLE;
+		dev_set_name(dev, info->cdev.name);
+	} else {
+		id = get_free_deviceid("fb");
+		dev->id = id;
+		dev_set_name(dev, "fb");
+		info->cdev.name = basprintf("fb%d", id);
+	}
 	info->cdev.size = info->line_length * info->yres;
 	info->cdev.dev = dev;
 	info->cdev.priv = info;
@@ -315,11 +326,8 @@ int register_framebuffer(struct fb_info *info)
 	dev->num_resources = 1;
 
 	dev->priv = info;
-	dev->id = id;
 	dev->info = fb_info;
 
-	dev_set_name(dev, "fb");
-
 	ret = register_device(&info->dev);
 	if (ret)
 		goto err_free;
diff --git a/include/fb.h b/include/fb.h
index 574a66a396..76f0c99449 100644
--- a/include/fb.h
+++ b/include/fb.h
@@ -175,6 +175,9 @@ struct fb_info {
 					 * be created.
 					 */
 	int shadowfb;
+
+	struct fb_info *base_plane;
+	int n_overlays;
 };
 
 int of_get_display_timing(const struct device_node *np, const char *name,

-- 
2.39.5




More information about the barebox mailing list