Skip to content

Commit d5d6340

Browse files
committed
drm: Look up the format info earlier
Look up the format info already in drm_internal_framebuffer_create() so that we can later pass it along to .fb_create(). Currently various drivers are doing additional lookups in their .fb_create() implementations, and these lookups are rather expensive now (given how many different pixel formats we have). v2: Fix commit msg (Thomas) Reviewed-by: Thomas Zimmermann <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 0e7d587 commit d5d6340

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

drivers/gpu/drm/drm_framebuffer.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,11 @@ int drm_mode_addfb_ioctl(struct drm_device *dev,
153153
}
154154

155155
static int framebuffer_check(struct drm_device *dev,
156+
const struct drm_format_info *info,
156157
const struct drm_mode_fb_cmd2 *r)
157158
{
158-
const struct drm_format_info *info;
159159
int i;
160160

161-
/* check if the format is supported at all */
162-
if (!__drm_format_info(r->pixel_format)) {
163-
drm_dbg_kms(dev, "bad framebuffer format %p4cc\n",
164-
&r->pixel_format);
165-
return -EINVAL;
166-
}
167-
168161
if (r->width == 0) {
169162
drm_dbg_kms(dev, "bad framebuffer width %u\n", r->width);
170163
return -EINVAL;
@@ -175,9 +168,6 @@ static int framebuffer_check(struct drm_device *dev,
175168
return -EINVAL;
176169
}
177170

178-
/* now let the driver pick its own format info */
179-
info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]);
180-
181171
for (i = 0; i < info->num_planes; i++) {
182172
unsigned int width = drm_format_info_plane_width(info, r->width, i);
183173
unsigned int height = drm_format_info_plane_height(info, r->height, i);
@@ -272,6 +262,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
272262
struct drm_file *file_priv)
273263
{
274264
struct drm_mode_config *config = &dev->mode_config;
265+
const struct drm_format_info *info;
275266
struct drm_framebuffer *fb;
276267
int ret;
277268

@@ -297,7 +288,17 @@ drm_internal_framebuffer_create(struct drm_device *dev,
297288
return ERR_PTR(-EINVAL);
298289
}
299290

300-
ret = framebuffer_check(dev, r);
291+
/* check if the format is supported at all */
292+
if (!__drm_format_info(r->pixel_format)) {
293+
drm_dbg_kms(dev, "bad framebuffer format %p4cc\n",
294+
&r->pixel_format);
295+
return ERR_PTR(-EINVAL);
296+
}
297+
298+
/* now let the driver pick its own format info */
299+
info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]);
300+
301+
ret = framebuffer_check(dev, info, r);
301302
if (ret)
302303
return ERR_PTR(ret);
303304

0 commit comments

Comments
 (0)