diff mbox

[01/10] drm/imx: ipuv3-plane: make sure x/y offsets are even in case of chroma subsampling

Message ID 1476872477-29493-1-git-send-email-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Philipp Zabel Oct. 19, 2016, 10:21 a.m. UTC
Odd x/y offsets are not allowed for horizontally/vertically chroma
subsampled planar YUV formats.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v1:
 - Improve comment
---
 drivers/gpu/drm/imx/ipuv3-plane.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Ying Liu Oct. 20, 2016, 6:18 a.m. UTC | #1
On Wed, Oct 19, 2016 at 6:21 PM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Odd x/y offsets are not allowed for horizontally/vertically chroma
> subsampled planar YUV formats.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Acked-by: Liu Ying <gnuiyl@gmail.com>

> ---
> Changes since v1:
>  - Improve comment
> ---
>  drivers/gpu/drm/imx/ipuv3-plane.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
> index 5c34299..e1ad844 100644
> --- a/drivers/gpu/drm/imx/ipuv3-plane.c
> +++ b/drivers/gpu/drm/imx/ipuv3-plane.c
> @@ -259,6 +259,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
>         struct drm_framebuffer *fb = state->fb;
>         struct drm_framebuffer *old_fb = old_state->fb;
>         unsigned long eba, ubo, vbo, old_ubo, old_vbo;
> +       int hsub, vsub;
>
>         /* Ok to disable */
>         if (!fb)
> @@ -372,6 +373,16 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
>
>                 if (old_fb && old_fb->pitches[1] != fb->pitches[1])
>                         crtc_state->mode_changed = true;
> +
> +               /*
> +                * The x/y offsets must be even in case of horizontal/vertical
> +                * chroma subsampling.
> +                */
> +               hsub = drm_format_horz_chroma_subsampling(fb->pixel_format);
> +               vsub = drm_format_vert_chroma_subsampling(fb->pixel_format);
> +               if (((state->src_x >> 16) & (hsub - 1)) ||
> +                   ((state->src_y >> 16) & (vsub - 1)))
> +                       return -EINVAL;
>         }
>
>         return 0;
> --
> 2.9.3
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index 5c34299..e1ad844 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -259,6 +259,7 @@  static int ipu_plane_atomic_check(struct drm_plane *plane,
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_framebuffer *old_fb = old_state->fb;
 	unsigned long eba, ubo, vbo, old_ubo, old_vbo;
+	int hsub, vsub;
 
 	/* Ok to disable */
 	if (!fb)
@@ -372,6 +373,16 @@  static int ipu_plane_atomic_check(struct drm_plane *plane,
 
 		if (old_fb && old_fb->pitches[1] != fb->pitches[1])
 			crtc_state->mode_changed = true;
+
+		/*
+		 * The x/y offsets must be even in case of horizontal/vertical
+		 * chroma subsampling.
+		 */
+		hsub = drm_format_horz_chroma_subsampling(fb->pixel_format);
+		vsub = drm_format_vert_chroma_subsampling(fb->pixel_format);
+		if (((state->src_x >> 16) & (hsub - 1)) ||
+		    ((state->src_y >> 16) & (vsub - 1)))
+			return -EINVAL;
 	}
 
 	return 0;