diff options
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/drm_fb_cma_helper.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_fourcc.c | 25 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_framebuffer.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_modeset_helper.c | 2 |
4 files changed, 34 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 74cd393a6407..50abd1faf38f 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -177,7 +177,7 @@ struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct drm_device *dev, int ret; int i; - info = drm_format_info(mode_cmd->pixel_format); + info = drm_get_format_info(dev, mode_cmd); if (!info) return ERR_PTR(-EINVAL); diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index 90d2cc8da8eb..f9b6445e846a 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32 format) EXPORT_SYMBOL(drm_format_info); /** + * drm_get_format_info - query information for a given framebuffer configuration + * @dev: DRM device + * @mode_cmd: metadata from the userspace fb creation request + * + * Returns: + * The instance of struct drm_format_info that describes the pixel format, or + * NULL if the format is unsupported. + */ +const struct drm_format_info * +drm_get_format_info(struct drm_device *dev, + const struct drm_mode_fb_cmd2 *mode_cmd) +{ + const struct drm_format_info *info = NULL; + + if (dev->mode_config.funcs->get_format_info) + info = dev->mode_config.funcs->get_format_info(mode_cmd); + + if (!info) + info = drm_format_info(mode_cmd->pixel_format); + + return info; +} +EXPORT_SYMBOL(drm_get_format_info); + +/** * drm_format_num_planes - get the number of planes for format * @format: pixel format (DRM_FORMAT_*) * diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 69e4c1487420..e8f9c13a0afd 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -144,11 +144,13 @@ static int fb_plane_height(int height, return DIV_ROUND_UP(height, format->vsub); } -static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) +static int framebuffer_check(struct drm_device *dev, + const struct drm_mode_fb_cmd2 *r) { const struct drm_format_info *info; int i; + /* check if the format is supported at all */ info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN); if (!info) { struct drm_format_name_buf format_name; @@ -158,6 +160,9 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) return -EINVAL; } + /* now let the driver pick its own format info */ + info = drm_get_format_info(dev, r); + if (r->width == 0) { DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width); return -EINVAL; @@ -281,7 +286,7 @@ drm_internal_framebuffer_create(struct drm_device *dev, return ERR_PTR(-EINVAL); } - ret = framebuffer_check(r); + ret = framebuffer_check(dev, r); if (ret) return ERR_PTR(ret); diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c index cc44a9a4b004..2b33825f2f93 100644 --- a/drivers/gpu/drm/drm_modeset_helper.c +++ b/drivers/gpu/drm/drm_modeset_helper.c @@ -78,7 +78,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev, int i; fb->dev = dev; - fb->format = drm_format_info(mode_cmd->pixel_format); + fb->format = drm_get_format_info(dev, mode_cmd); fb->width = mode_cmd->width; fb->height = mode_cmd->height; for (i = 0; i < 4; i++) { |