diff mbox series

[6/8] drm/fb-helper: Pass buffer format via drm_fb_helper_surface_size

Message ID 00790d022752b672a28256db7b9393eca0801b99.1689252746.git.geert@linux-m68k.org (mailing list archive)
State New, archived
Headers show
Series drm: fb-helper/ssd130x: Add support for DRM_FORMAT_R1 | expand

Commit Message

Geert Uytterhoeven July 13, 2023, 1:17 p.m. UTC
drm_fb_helper_single_fb_probe() first calls drm_fb_helper_find_sizes(),
followed by drm_fbdev_generic_helper_fb_probe():
  - The former tries to find a suitable buffer format, taking into
    account limitations of the whole display pipeline,
  - The latter just calls drm_mode_legacy_fb_format() again.

Simplify this by passing the buffer format between these functions
via a new buffer format member in the drm_fb_helper_surface_size
structure.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/gpu/drm/drm_fb_helper.c     | 1 +
 drivers/gpu/drm/drm_fbdev_generic.c | 9 ++++-----
 include/drm/drm_fb_helper.h         | 2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)

Comments

Javier Martinez Canillas July 14, 2023, 10:25 a.m. UTC | #1
Geert Uytterhoeven <geert@linux-m68k.org> writes:

> drm_fb_helper_single_fb_probe() first calls drm_fb_helper_find_sizes(),
> followed by drm_fbdev_generic_helper_fb_probe():
>   - The former tries to find a suitable buffer format, taking into
>     account limitations of the whole display pipeline,
>   - The latter just calls drm_mode_legacy_fb_format() again.
>
> Simplify this by passing the buffer format between these functions
> via a new buffer format member in the drm_fb_helper_surface_size
> structure.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---

[...]

> -	drm_dbg_kms(dev, "surface width(%d), height(%d) and bpp(%d)\n",
> +	drm_info(dev, "surface width(%d), height(%d), bpp(%d) and format(%p4cc)\n",

You are promoting a debug printout here to info but that change is not
mentioned in the commit message. If you think this will be useful, maybe
do it as a separate patch ?

The rest of the patch looks good to me though.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Geert Uytterhoeven July 14, 2023, 11:32 a.m. UTC | #2
Hi Javier,

On Fri, Jul 14, 2023 at 12:25 PM Javier Martinez Canillas
<javierm@redhat.com> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> writes:
> > drm_fb_helper_single_fb_probe() first calls drm_fb_helper_find_sizes(),
> > followed by drm_fbdev_generic_helper_fb_probe():
> >   - The former tries to find a suitable buffer format, taking into
> >     account limitations of the whole display pipeline,
> >   - The latter just calls drm_mode_legacy_fb_format() again.
> >
> > Simplify this by passing the buffer format between these functions
> > via a new buffer format member in the drm_fb_helper_surface_size
> > structure.
> >
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
>
> [...]
>
> > -     drm_dbg_kms(dev, "surface width(%d), height(%d) and bpp(%d)\n",
> > +     drm_info(dev, "surface width(%d), height(%d), bpp(%d) and format(%p4cc)\n",
>
> You are promoting a debug printout here to info but that change is not
> mentioned in the commit message. If you think this will be useful, maybe
> do it as a separate patch ?

Oops, that was unintentional.  Will fix in v2.

> The rest of the patch looks good to me though.
>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Thanks!

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 61a5d450cc20ef0a..e870b2ce7a8625e3 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1564,6 +1564,7 @@  static int __drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper,
 	info = drm_format_info(surface_format);
 	sizes->surface_bpp = drm_format_info_bpp(info, 0);
 	sizes->surface_depth = info->depth;
+	sizes->surface_format = surface_format;
 
 	/* first up get a count of crtcs now in use and new min/maxes width/heights */
 	crtc_count = 0;
diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c
index 98ae703848a02fa3..953056896c1a5652 100644
--- a/drivers/gpu/drm/drm_fbdev_generic.c
+++ b/drivers/gpu/drm/drm_fbdev_generic.c
@@ -77,16 +77,15 @@  static int drm_fbdev_generic_helper_fb_probe(struct drm_fb_helper *fb_helper,
 	struct fb_info *info;
 	size_t screen_size;
 	void *screen_buffer;
-	u32 format;
 	int ret;
 
-	drm_dbg_kms(dev, "surface width(%d), height(%d) and bpp(%d)\n",
+	drm_info(dev, "surface width(%d), height(%d), bpp(%d) and format(%p4cc)\n",
 		    sizes->surface_width, sizes->surface_height,
-		    sizes->surface_bpp);
+		    sizes->surface_bpp, &sizes->surface_format);
 
-	format = drm_mode_legacy_fb_format(sizes->surface_bpp, sizes->surface_depth);
 	buffer = drm_client_framebuffer_create(client, sizes->surface_width,
-					       sizes->surface_height, format);
+					       sizes->surface_height,
+					       sizes->surface_format);
 	if (IS_ERR(buffer))
 		return PTR_ERR(buffer);
 
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 4863b0f8299e89b6..430a17b530fa49e6 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -45,6 +45,7 @@  struct drm_fb_helper;
  * @surface_height: scanout buffer height
  * @surface_bpp: scanout buffer bpp
  * @surface_depth: scanout buffer depth
+ * @surface_format: scanout buffer format (optional)
  *
  * Note that the scanout surface width/height may be larger than the fbdev
  * width/height.  In case of multiple displays, the scanout surface is sized
@@ -61,6 +62,7 @@  struct drm_fb_helper_surface_size {
 	u32 surface_height;
 	u32 surface_bpp;
 	u32 surface_depth;
+	u32 surface_format;
 };
 
 /**