Commit 2aafafab authored by Ayan Kumar Halder's avatar Ayan Kumar Halder Committed by Maxime Ripard

drm/sun4i: Use (struct drm_format_info) fields to determine if a format is yuv...

drm/sun4i: Use (struct drm_format_info) fields to determine if a format is yuv and multi planar or not.

We do not need sun4i_backend_format_is_packed_yuv422() /
sun4i_backend_format_is_planar_yuv() to determine if the format is yuv multi planar
or not. (struct drm_format_info *)->is_yuv tells if the format is yuv or not.
And (struct drm_format_info *)->num_planes denotes the number of planes.

This issue was identified during a review on a previous patch:-
https://lists.freedesktop.org/archives/dri-devel/2018-July/183840.htmlSigned-off-by: default avatarAyan Kumar halder <ayan.halder@arm.com>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1532336220-3791-1-git-send-email-ayan.halder@arm.com
parent 574e0fbf
...@@ -63,32 +63,6 @@ static const u32 sunxi_bt601_yuv2rgb_coef[12] = { ...@@ -63,32 +63,6 @@ static const u32 sunxi_bt601_yuv2rgb_coef[12] = {
0x000004a7, 0x00000812, 0x00000000, 0x00002eb1, 0x000004a7, 0x00000812, 0x00000000, 0x00002eb1,
}; };
static inline bool sun4i_backend_format_is_planar_yuv(uint32_t format)
{
switch (format) {
case DRM_FORMAT_YUV411:
case DRM_FORMAT_YUV422:
case DRM_FORMAT_YUV444:
return true;
default:
return false;
}
}
static inline bool sun4i_backend_format_is_packed_yuv422(uint32_t format)
{
switch (format) {
case DRM_FORMAT_YUYV:
case DRM_FORMAT_YVYU:
case DRM_FORMAT_UYVY:
case DRM_FORMAT_VYUY:
return true;
default:
return false;
}
}
static void sun4i_backend_apply_color_correction(struct sunxi_engine *engine) static void sun4i_backend_apply_color_correction(struct sunxi_engine *engine)
{ {
int i; int i;
...@@ -218,7 +192,8 @@ static int sun4i_backend_update_yuv_format(struct sun4i_backend *backend, ...@@ -218,7 +192,8 @@ static int sun4i_backend_update_yuv_format(struct sun4i_backend *backend,
{ {
struct drm_plane_state *state = plane->state; struct drm_plane_state *state = plane->state;
struct drm_framebuffer *fb = state->fb; struct drm_framebuffer *fb = state->fb;
uint32_t format = fb->format->format; const struct drm_format_info *format = fb->format;
const uint32_t fmt = format->format;
u32 val = SUN4I_BACKEND_IYUVCTL_EN; u32 val = SUN4I_BACKEND_IYUVCTL_EN;
int i; int i;
...@@ -236,16 +211,16 @@ static int sun4i_backend_update_yuv_format(struct sun4i_backend *backend, ...@@ -236,16 +211,16 @@ static int sun4i_backend_update_yuv_format(struct sun4i_backend *backend,
SUN4I_BACKEND_ATTCTL_REG0_LAY_YUVEN); SUN4I_BACKEND_ATTCTL_REG0_LAY_YUVEN);
/* TODO: Add support for the multi-planar YUV formats */ /* TODO: Add support for the multi-planar YUV formats */
if (sun4i_backend_format_is_packed_yuv422(format)) if (format->num_planes == 1)
val |= SUN4I_BACKEND_IYUVCTL_FBFMT_PACKED_YUV422; val |= SUN4I_BACKEND_IYUVCTL_FBFMT_PACKED_YUV422;
else else
DRM_DEBUG_DRIVER("Unsupported YUV format (0x%x)\n", format); DRM_DEBUG_DRIVER("Unsupported YUV format (0x%x)\n", fmt);
/* /*
* Allwinner seems to list the pixel sequence from right to left, while * Allwinner seems to list the pixel sequence from right to left, while
* DRM lists it from left to right. * DRM lists it from left to right.
*/ */
switch (format) { switch (fmt) {
case DRM_FORMAT_YUYV: case DRM_FORMAT_YUYV:
val |= SUN4I_BACKEND_IYUVCTL_FBPS_VYUY; val |= SUN4I_BACKEND_IYUVCTL_FBPS_VYUY;
break; break;
...@@ -260,7 +235,7 @@ static int sun4i_backend_update_yuv_format(struct sun4i_backend *backend, ...@@ -260,7 +235,7 @@ static int sun4i_backend_update_yuv_format(struct sun4i_backend *backend,
break; break;
default: default:
DRM_DEBUG_DRIVER("Unsupported YUV pixel sequence (0x%x)\n", DRM_DEBUG_DRIVER("Unsupported YUV pixel sequence (0x%x)\n",
format); fmt);
} }
regmap_write(backend->engine.regs, SUN4I_BACKEND_IYUVCTL_REG, val); regmap_write(backend->engine.regs, SUN4I_BACKEND_IYUVCTL_REG, val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment