diff mbox series

[v3] drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()

Message ID 4b84adfc686288714e69d0442d22f1259ff74903.1697379891.git.geert@linux-m68k.org (mailing list archive)
State New, archived
Headers show
Series [v3] drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2() | expand

Commit Message

Geert Uytterhoeven Oct. 15, 2023, 2:27 p.m. UTC
Currently drm_client_buffer_addfb() uses the legacy drm_mode_addfb(),
which uses bpp and depth to guess the wanted buffer format.
However, drm_client_buffer_addfb() already knows the exact buffer
format, so there is no need to convert back and forth between buffer
format and bpp/depth, and the function can just call drm_mode_addfb2()
directly instead.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Javier Martinez Canillas <javierm@redhat.com>
---
v3:
  - Extract from series "[PATCH v2 0/8] drm: fb-helper/ssd130x: Add
    support for DRM_FORMAT_R1"
    (https://lore.kernel.org/all/cover.1692888745.git.geert@linux-m68k.org),
    as this patch has merits on its own,
v2:
  - Add Reviewed-by, Tested-by,
  - s/drm_mode_create_dumb/drm_client_buffer_addfb/ in one-line summary.
---
 drivers/gpu/drm/drm_client.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Hamza Mahfooz Oct. 24, 2023, 4:33 p.m. UTC | #1
On 10/15/23 10:27, Geert Uytterhoeven wrote:
> Currently drm_client_buffer_addfb() uses the legacy drm_mode_addfb(),
> which uses bpp and depth to guess the wanted buffer format.
> However, drm_client_buffer_addfb() already knows the exact buffer
> format, so there is no need to convert back and forth between buffer
> format and bpp/depth, and the function can just call drm_mode_addfb2()
> directly instead.
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Tested-by: Javier Martinez Canillas <javierm@redhat.com>

Applied and pushed to drm-misc-next, thanks!

> ---
> v3:
>    - Extract from series "[PATCH v2 0/8] drm: fb-helper/ssd130x: Add
>      support for DRM_FORMAT_R1"
>      (https://lore.kernel.org/all/cover.1692888745.git.geert@linux-m68k.org),
>      as this patch has merits on its own,
> v2:
>    - Add Reviewed-by, Tested-by,
>    - s/drm_mode_create_dumb/drm_client_buffer_addfb/ in one-line summary.
> ---
>   drivers/gpu/drm/drm_client.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
> index d4296440f297fc5a..a780832a0963fe38 100644
> --- a/drivers/gpu/drm/drm_client.c
> +++ b/drivers/gpu/drm/drm_client.c
> @@ -395,19 +395,16 @@ static int drm_client_buffer_addfb(struct drm_client_buffer *buffer,
>   				   u32 handle)
>   {
>   	struct drm_client_dev *client = buffer->client;
> -	struct drm_mode_fb_cmd fb_req = { };
> -	const struct drm_format_info *info;
> +	struct drm_mode_fb_cmd2 fb_req = { };
>   	int ret;
>   
> -	info = drm_format_info(format);
> -	fb_req.bpp = drm_format_info_bpp(info, 0);
> -	fb_req.depth = info->depth;
>   	fb_req.width = width;
>   	fb_req.height = height;
> -	fb_req.handle = handle;
> -	fb_req.pitch = buffer->pitch;
> +	fb_req.pixel_format = format;
> +	fb_req.handles[0] = handle;
> +	fb_req.pitches[0] = buffer->pitch;
>   
> -	ret = drm_mode_addfb(client->dev, &fb_req, client->file);
> +	ret = drm_mode_addfb2(client->dev, &fb_req, client->file);
>   	if (ret)
>   		return ret;
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index d4296440f297fc5a..a780832a0963fe38 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -395,19 +395,16 @@  static int drm_client_buffer_addfb(struct drm_client_buffer *buffer,
 				   u32 handle)
 {
 	struct drm_client_dev *client = buffer->client;
-	struct drm_mode_fb_cmd fb_req = { };
-	const struct drm_format_info *info;
+	struct drm_mode_fb_cmd2 fb_req = { };
 	int ret;
 
-	info = drm_format_info(format);
-	fb_req.bpp = drm_format_info_bpp(info, 0);
-	fb_req.depth = info->depth;
 	fb_req.width = width;
 	fb_req.height = height;
-	fb_req.handle = handle;
-	fb_req.pitch = buffer->pitch;
+	fb_req.pixel_format = format;
+	fb_req.handles[0] = handle;
+	fb_req.pitches[0] = buffer->pitch;
 
-	ret = drm_mode_addfb(client->dev, &fb_req, client->file);
+	ret = drm_mode_addfb2(client->dev, &fb_req, client->file);
 	if (ret)
 		return ret;