mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
drm: Check in setcrtc if the primary plane supports the fb pixel format
Drivers implementing the universal planes API report the list of supported pixel formats for the primary plane. Make sure the fb passed to the setcrtc ioctl is compatible. Drivers not implementing the universal planes API will have no format reported for the primary plane, skip the check in that case. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
c484f02d0f
commit
7eb5f302bb
3 changed files with 24 additions and 0 deletions
|
@ -2798,6 +2798,23 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
|
||||||
|
|
||||||
drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
|
drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether the primary plane supports the fb pixel format.
|
||||||
|
* Drivers not implementing the universal planes API use a
|
||||||
|
* default formats list provided by the DRM core which doesn't
|
||||||
|
* match real hardware capabilities. Skip the check in that
|
||||||
|
* case.
|
||||||
|
*/
|
||||||
|
if (!crtc->primary->format_default) {
|
||||||
|
ret = drm_plane_check_pixel_format(crtc->primary,
|
||||||
|
fb->pixel_format);
|
||||||
|
if (ret) {
|
||||||
|
DRM_DEBUG_KMS("Invalid pixel format %s\n",
|
||||||
|
drm_get_format_name(fb->pixel_format));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = drm_crtc_check_viewport(crtc, crtc_req->x, crtc_req->y,
|
ret = drm_crtc_check_viewport(crtc, crtc_req->x, crtc_req->y,
|
||||||
mode, fb);
|
mode, fb);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -353,6 +353,11 @@ static struct drm_plane *create_primary_plane(struct drm_device *dev)
|
||||||
if (primary == NULL) {
|
if (primary == NULL) {
|
||||||
DRM_DEBUG_KMS("Failed to allocate primary plane\n");
|
DRM_DEBUG_KMS("Failed to allocate primary plane\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
/*
|
||||||
|
* Remove the format_default field from drm_plane when dropping
|
||||||
|
* this helper.
|
||||||
|
*/
|
||||||
|
primary->format_default = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* possible_crtc's will be filled in later by crtc_init */
|
/* possible_crtc's will be filled in later by crtc_init */
|
||||||
|
|
|
@ -830,6 +830,7 @@ enum drm_plane_type {
|
||||||
* @possible_crtcs: pipes this plane can be bound to
|
* @possible_crtcs: pipes this plane can be bound to
|
||||||
* @format_types: array of formats supported by this plane
|
* @format_types: array of formats supported by this plane
|
||||||
* @format_count: number of formats supported
|
* @format_count: number of formats supported
|
||||||
|
* @format_default: driver hasn't supplied supported formats for the plane
|
||||||
* @crtc: currently bound CRTC
|
* @crtc: currently bound CRTC
|
||||||
* @fb: currently bound fb
|
* @fb: currently bound fb
|
||||||
* @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
|
* @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
|
||||||
|
@ -850,6 +851,7 @@ struct drm_plane {
|
||||||
uint32_t possible_crtcs;
|
uint32_t possible_crtcs;
|
||||||
uint32_t *format_types;
|
uint32_t *format_types;
|
||||||
uint32_t format_count;
|
uint32_t format_count;
|
||||||
|
bool format_default;
|
||||||
|
|
||||||
struct drm_crtc *crtc;
|
struct drm_crtc *crtc;
|
||||||
struct drm_framebuffer *fb;
|
struct drm_framebuffer *fb;
|
||||||
|
|
Loading…
Reference in a new issue