Re: [PATCH v2 5/8] drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()
Hi Am 24.08.23 um 17:22 schrieb Geert Uytterhoeven: Hi Daniel, On Thu, Aug 24, 2023 at 5:12 PM Daniel Stone wrote: On Thu, 24 Aug 2023 at 16:09, Geert Uytterhoeven wrote: 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, _req, client->file); + ret = drm_mode_addfb2(client->dev, _req, client->file); if (ret) return ret; This should explicitly set the LINEAR modifier (and the modifier flag) if the driver supports modifiers. Thanks for your comment! I have no idea how to do that, and I do not know what the impact would be. All I know is that the current implementation of drm_client_buffer_addfb() does not do that, so changing that in this patch would mean that this would no longer be a trivial conversion. I agree. That change is too large and invasive for this patchset. Rather add a comment or TODO item. The correct way for adding the modifier is to extend the drm_client_buffer_addfb() and pass in the information from the caller. That caller is fbdev code. We currently detect the format from (bpp, depth) values and forward the format to _addfb(). [1] Here we'd have to check the driver for a modifier as well and forward it to _addfb() [1] https://elixir.bootlin.com/linux/v6.5/source/drivers/gpu/drm/drm_fbdev_generic.c#L88 The pair of (bpp, depth) values comes from __drm_fb_helper_find_sizes, [2] which looks through the planes' formats and tries to find something that fits the user's requested color mode. It would have to look for modifiers as well. At some point, I want the helper to return formats directly, but that's still a bit away. [2] https://elixir.bootlin.com/linux/v6.5/source/drivers/gpu/drm/drm_fb_helper.c#L1504 Best regards Thomas Gr{oetje,eeting}s, Geert -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg) OpenPGP_signature Description: OpenPGP digital signature
Re: [PATCH v2 5/8] drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()
Geert Uytterhoeven writes: Hello Geert and Daniel, > Hi Daniel, > > On Thu, Aug 24, 2023 at 5:12 PM Daniel Stone wrote: >> On Thu, 24 Aug 2023 at 16:09, Geert Uytterhoeven >> wrote: >> > 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, _req, client->file); >> > + ret = drm_mode_addfb2(client->dev, _req, client->file); >> > if (ret) >> > return ret; >> >> This should explicitly set the LINEAR modifier (and the modifier flag) >> if the driver supports modifiers. > > Thanks for your comment! > > I have no idea how to do that, and I do not know what the impact > would be. All I know is that the current implementation of > drm_client_buffer_addfb() does not do that, so changing that in this > patch would mean that this would no longer be a trivial conversion. > Agree with Geert, this patch basically just inlines the drm_mode_addfb() implementation which already calls drm_mode_addfb2() but without setting a struct drm_mode_fb_cmd2 .modifier field or anything modififers related. So if that is wrong then it should be done as a follow-up patch (which should also fix the drm_mode_addfb() helper implementation) ? -- Best regards, Javier Martinez Canillas Core Platforms Red Hat
Re: [PATCH v2 5/8] drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()
Hi Daniel, On Thu, Aug 24, 2023 at 5:12 PM Daniel Stone wrote: > On Thu, 24 Aug 2023 at 16:09, Geert Uytterhoeven wrote: > > 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, _req, client->file); > > + ret = drm_mode_addfb2(client->dev, _req, client->file); > > if (ret) > > return ret; > > This should explicitly set the LINEAR modifier (and the modifier flag) > if the driver supports modifiers. Thanks for your comment! I have no idea how to do that, and I do not know what the impact would be. All I know is that the current implementation of drm_client_buffer_addfb() does not do that, so changing that in this patch would mean that this would no longer be a trivial conversion. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v2 5/8] drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()
Hi Geert, On Thu, 24 Aug 2023 at 16:09, Geert Uytterhoeven wrote: > 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, _req, client->file); > + ret = drm_mode_addfb2(client->dev, _req, client->file); > if (ret) > return ret; This should explicitly set the LINEAR modifier (and the modifier flag) if the driver supports modifiers. Cheers, Daniel
[PATCH v2 5/8] drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()
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 Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas --- 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 037e36f2049c1793..0ced189befebae12 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, _req, client->file); + ret = drm_mode_addfb2(client->dev, _req, client->file); if (ret) return ret; -- 2.34.1