forked from Minki/linux
drm: Share plane pixel format check code between legacy and atomic
Both the legacy and atomic helpers need to check whether a plane supports a given pixel format. The code is currently duplicated, share it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [danvet: Slightly extend the docbook.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
2a97acd637
commit
ead8610d42
@ -475,7 +475,7 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
|
|||||||
struct drm_plane_state *state)
|
struct drm_plane_state *state)
|
||||||
{
|
{
|
||||||
unsigned int fb_width, fb_height;
|
unsigned int fb_width, fb_height;
|
||||||
unsigned int i;
|
int ret;
|
||||||
|
|
||||||
/* either *both* CRTC and FB must be set, or neither */
|
/* either *both* CRTC and FB must be set, or neither */
|
||||||
if (WARN_ON(state->crtc && !state->fb)) {
|
if (WARN_ON(state->crtc && !state->fb)) {
|
||||||
@ -497,13 +497,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether this plane supports the fb pixel format. */
|
/* Check whether this plane supports the fb pixel format. */
|
||||||
for (i = 0; i < plane->format_count; i++)
|
ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format);
|
||||||
if (state->fb->pixel_format == plane->format_types[i])
|
if (ret) {
|
||||||
break;
|
|
||||||
if (i == plane->format_count) {
|
|
||||||
DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
|
DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
|
||||||
drm_get_format_name(state->fb->pixel_format));
|
drm_get_format_name(state->fb->pixel_format));
|
||||||
return -EINVAL;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Give drivers some help against integer overflows */
|
/* Give drivers some help against integer overflows */
|
||||||
|
@ -2408,6 +2408,27 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* drm_plane_check_pixel_format - Check if the plane supports the pixel format
|
||||||
|
* @plane: plane to check for format support
|
||||||
|
* @format: the pixel format
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* Zero of @plane has @format in its list of supported pixel formats, -EINVAL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int drm_plane_check_pixel_format(const struct drm_plane *plane, u32 format)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < plane->format_count; i++) {
|
||||||
|
if (format == plane->format_types[i])
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setplane_internal - setplane handler for internal callers
|
* setplane_internal - setplane handler for internal callers
|
||||||
*
|
*
|
||||||
@ -2428,7 +2449,6 @@ static int __setplane_internal(struct drm_plane *plane,
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned int fb_width, fb_height;
|
unsigned int fb_width, fb_height;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
/* No fb means shut it down */
|
/* No fb means shut it down */
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
@ -2451,13 +2471,10 @@ static int __setplane_internal(struct drm_plane *plane,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether this plane supports the fb pixel format. */
|
/* Check whether this plane supports the fb pixel format. */
|
||||||
for (i = 0; i < plane->format_count; i++)
|
ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
|
||||||
if (fb->pixel_format == plane->format_types[i])
|
if (ret) {
|
||||||
break;
|
|
||||||
if (i == plane->format_count) {
|
|
||||||
DRM_DEBUG_KMS("Invalid pixel format %s\n",
|
DRM_DEBUG_KMS("Invalid pixel format %s\n",
|
||||||
drm_get_format_name(fb->pixel_format));
|
drm_get_format_name(fb->pixel_format));
|
||||||
ret = -EINVAL;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,6 +1263,8 @@ extern int drm_plane_init(struct drm_device *dev,
|
|||||||
extern void drm_plane_cleanup(struct drm_plane *plane);
|
extern void drm_plane_cleanup(struct drm_plane *plane);
|
||||||
extern unsigned int drm_plane_index(struct drm_plane *plane);
|
extern unsigned int drm_plane_index(struct drm_plane *plane);
|
||||||
extern void drm_plane_force_disable(struct drm_plane *plane);
|
extern void drm_plane_force_disable(struct drm_plane *plane);
|
||||||
|
extern int drm_plane_check_pixel_format(const struct drm_plane *plane,
|
||||||
|
u32 format);
|
||||||
extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode,
|
extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode,
|
||||||
int *hdisplay, int *vdisplay);
|
int *hdisplay, int *vdisplay);
|
||||||
extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,
|
extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,
|
||||||
|
Loading…
Reference in New Issue
Block a user