Skip to content

Commit 0e7d587

Browse files
committed
drm: Pass pixel_format+modifier directly to drm_get_format_info()
Decouple drm_get_format_info() from struct drm_mode_fb_cmd2 and just pass the pixel format+modifier combo in by hand. We may want to use drm_get_format_info() outside of the normal addfb paths where we won't have a struct drm_mode_fb_cmd2, and creating a temporary one just for this seems silly. Done with cocci: @@ identifier dev, mode_cmd; @@ struct drm_format_info * drm_get_format_info(struct drm_device *dev, - const struct drm_mode_fb_cmd2 *mode_cmd + u32 pixel_format, u64 modifier ) { <... ( - mode_cmd->pixel_format + pixel_format | - mode_cmd->modifier[0] + modifier ) ...> } @@ identifier dev, mode_cmd; @@ struct drm_format_info * drm_get_format_info(struct drm_device *dev, - const struct drm_mode_fb_cmd2 *mode_cmd + u32 pixel_format, u64 modifier ); @@ expression dev, mode_cmd; @@ - drm_get_format_info(dev, mode_cmd) + drm_get_format_info(dev, mode_cmd->pixel_format, mode_cmd->modifier[0]) v2: Fix kernel docs (Laurent) Drop drm_mode_fb_cmd2 forward declaration (Thomas) Cc: Liviu Dudau <[email protected]> Cc: Russell King <[email protected]> Cc: Inki Dae <[email protected]> Cc: Seung-Woo Kim <[email protected]> Cc: Kyungmin Park <[email protected]> Cc: Patrik Jakobsson <[email protected]> Cc: Chun-Kuang Hu <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Rob Clark <[email protected]> Cc: Abhinav Kumar <[email protected]> Cc: Dmitry Baryshkov <[email protected]> Cc: Sean Paul <[email protected]> Cc: Marijn Suijten <[email protected]> Cc: Marek Vasut <[email protected]> Cc: Stefan Agner <[email protected]> Cc: Lyude Paul <[email protected]> Cc: Danilo Krummrich <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Sandy Huang <[email protected]> Cc: "Heiko Stübner" <[email protected]> Cc: Andy Yan <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Mikko Perttunen <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Reviewed-by: Thomas Zimmermann <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Liviu Dudau <[email protected]> Acked-by: Alex Deucher <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 0389e42 commit 0e7d587

File tree

17 files changed

+48
-26
lines changed

17 files changed

+48
-26
lines changed

drivers/gpu/drm/arm/malidp_drv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ malidp_verify_afbc_framebuffer_size(struct drm_device *dev,
325325
return false;
326326
}
327327

328-
info = drm_get_format_info(dev, mode_cmd);
328+
info = drm_get_format_info(dev, mode_cmd->pixel_format,
329+
mode_cmd->modifier[0]);
329330

330331
n_superblocks = (mode_cmd->width / afbc_superblock_width) *
331332
(mode_cmd->height / afbc_superblock_height);

drivers/gpu/drm/armada/armada_fb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ struct armada_framebuffer *armada_framebuffer_create(struct drm_device *dev,
8686
struct drm_framebuffer *armada_fb_create(struct drm_device *dev,
8787
struct drm_file *dfile, const struct drm_mode_fb_cmd2 *mode)
8888
{
89-
const struct drm_format_info *info = drm_get_format_info(dev, mode);
89+
const struct drm_format_info *info = drm_get_format_info(dev,
90+
mode->pixel_format,
91+
mode->modifier[0]);
9092
struct armada_gem_object *obj;
9193
struct armada_framebuffer *dfb;
9294
int ret;

drivers/gpu/drm/drm_fourcc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,24 +417,25 @@ EXPORT_SYMBOL(drm_format_info);
417417
/**
418418
* drm_get_format_info - query information for a given framebuffer configuration
419419
* @dev: DRM device
420-
* @mode_cmd: metadata from the userspace fb creation request
420+
* @pixel_format: pixel format (DRM_FORMAT_*)
421+
* @modifier: modifier
421422
*
422423
* Returns:
423424
* The instance of struct drm_format_info that describes the pixel format, or
424425
* NULL if the format is unsupported.
425426
*/
426427
const struct drm_format_info *
427428
drm_get_format_info(struct drm_device *dev,
428-
const struct drm_mode_fb_cmd2 *mode_cmd)
429+
u32 pixel_format, u64 modifier)
429430
{
430431
const struct drm_format_info *info = NULL;
431432

432433
if (dev->mode_config.funcs->get_format_info)
433-
info = dev->mode_config.funcs->get_format_info(mode_cmd->pixel_format,
434-
mode_cmd->modifier[0]);
434+
info = dev->mode_config.funcs->get_format_info(pixel_format,
435+
modifier);
435436

436437
if (!info)
437-
info = drm_format_info(mode_cmd->pixel_format);
438+
info = drm_format_info(pixel_format);
438439

439440
return info;
440441
}

drivers/gpu/drm/drm_framebuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int framebuffer_check(struct drm_device *dev,
176176
}
177177

178178
/* now let the driver pick its own format info */
179-
info = drm_get_format_info(dev, r);
179+
info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]);
180180

181181
for (i = 0; i < info->num_planes; i++) {
182182
unsigned int width = drm_format_info_plane_width(info, r->width, i);

drivers/gpu/drm/drm_gem_framebuffer_helper.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ int drm_gem_fb_init_with_funcs(struct drm_device *dev,
160160
unsigned int i;
161161
int ret;
162162

163-
info = drm_get_format_info(dev, mode_cmd);
163+
info = drm_get_format_info(dev, mode_cmd->pixel_format,
164+
mode_cmd->modifier[0]);
164165
if (!info) {
165166
drm_dbg_kms(dev, "Failed to get FB format info\n");
166167
return -EINVAL;
@@ -502,7 +503,8 @@ static __u32 drm_gem_afbc_get_bpp(struct drm_device *dev,
502503
{
503504
const struct drm_format_info *info;
504505

505-
info = drm_get_format_info(dev, mode_cmd);
506+
info = drm_get_format_info(dev, mode_cmd->pixel_format,
507+
mode_cmd->modifier[0]);
506508

507509
switch (info->format) {
508510
case DRM_FORMAT_YUV420_8BIT:
@@ -600,7 +602,8 @@ int drm_gem_fb_afbc_init(struct drm_device *dev,
600602
int ret;
601603

602604
objs = afbc_fb->base.obj;
603-
info = drm_get_format_info(dev, mode_cmd);
605+
info = drm_get_format_info(dev, mode_cmd->pixel_format,
606+
mode_cmd->modifier[0]);
604607
if (!info)
605608
return -EINVAL;
606609

drivers/gpu/drm/drm_modeset_helper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
8686
int i;
8787

8888
fb->dev = dev;
89-
fb->format = drm_get_format_info(dev, mode_cmd);
89+
fb->format = drm_get_format_info(dev, mode_cmd->pixel_format,
90+
mode_cmd->modifier[0]);
9091
fb->width = mode_cmd->width;
9192
fb->height = mode_cmd->height;
9293
for (i = 0; i < 4; i++) {

drivers/gpu/drm/exynos/exynos_drm_fb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ static struct drm_framebuffer *
9696
exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
9797
const struct drm_mode_fb_cmd2 *mode_cmd)
9898
{
99-
const struct drm_format_info *info = drm_get_format_info(dev, mode_cmd);
99+
const struct drm_format_info *info = drm_get_format_info(dev,
100+
mode_cmd->pixel_format,
101+
mode_cmd->modifier[0]);
100102
struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
101103
struct drm_framebuffer *fb;
102104
int i;

drivers/gpu/drm/gma500/framebuffer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ static int psb_framebuffer_init(struct drm_device *dev,
3939
* Reject unknown formats, YUV formats, and formats with more than
4040
* 4 bytes per pixel.
4141
*/
42-
info = drm_get_format_info(dev, mode_cmd);
42+
info = drm_get_format_info(dev, mode_cmd->pixel_format,
43+
mode_cmd->modifier[0]);
4344
if (!info || !info->depth || info->cpp[0] > 4)
4445
return -EINVAL;
4546

drivers/gpu/drm/mediatek/mtk_drm_drv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ mtk_drm_mode_fb_create(struct drm_device *dev,
4545
struct drm_file *file,
4646
const struct drm_mode_fb_cmd2 *cmd)
4747
{
48-
const struct drm_format_info *info = drm_get_format_info(dev, cmd);
48+
const struct drm_format_info *info = drm_get_format_info(dev,
49+
cmd->pixel_format,
50+
cmd->modifier[0]);
4951

5052
if (info->num_planes != 1)
5153
return ERR_PTR(-EINVAL);

drivers/gpu/drm/msm/msm_fb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
142142
struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd)
143143
{
144144
const struct drm_format_info *info = drm_get_format_info(dev,
145-
mode_cmd);
145+
mode_cmd->pixel_format,
146+
mode_cmd->modifier[0]);
146147
struct drm_gem_object *bos[4] = {0};
147148
struct drm_framebuffer *fb;
148149
int ret, i, n = info->num_planes;
@@ -173,7 +174,8 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
173174
const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos)
174175
{
175176
const struct drm_format_info *info = drm_get_format_info(dev,
176-
mode_cmd);
177+
mode_cmd->pixel_format,
178+
mode_cmd->modifier[0]);
177179
struct msm_drm_private *priv = dev->dev_private;
178180
struct msm_kms *kms = priv->kms;
179181
struct msm_framebuffer *msm_fb = NULL;

0 commit comments

Comments
 (0)