[PATCH] drm/exynos: use drm_atomic_state directly

2015-05-21 Thread Gustavo Padovan
Just ignore this one. The patch file was by mistake in the same folder
as the atomic ones. It is part of a patchset that will come out later.

Gustavo

2015-05-21 Gustavo Padovan :

> From: Gustavo Padovan 
> 
> Instead of use duplicated information stored on struct exynos_drm_plane
> use the atomic state directly to have a more clear understanding and clean
> code.
> 
> Signed-off-by: Gustavo Padovan 
> ---
>  drivers/gpu/drm/exynos/exynos7_drm_decon.c |  49 ++--
>  drivers/gpu/drm/exynos/exynos_drm_drv.h|  51 -
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c   |  47 ++--
>  drivers/gpu/drm/exynos/exynos_drm_plane.c  |  86 ++---
>  drivers/gpu/drm/exynos/exynos_mixer.c  | 116 
> ++---
>  5 files changed, 131 insertions(+), 218 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
> b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
> index ed4461f..612ee29 100644
> --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
> +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
> @@ -281,16 +281,16 @@ static void decon_disable_vblank(struct exynos_drm_crtc 
> *crtc)
>   }
>  }
>  
> -static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win)
> +static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
> +  struct drm_framebuffer *fb)
>  {
> - struct exynos_drm_plane *plane = >planes[win];
>   unsigned long val;
>   int padding;
>  
>   val = readl(ctx->regs + WINCON(win));
>   val &= ~WINCONx_BPPMODE_MASK;
>  
> - switch (plane->pixel_format) {
> + switch (fb->pixel_format) {
>   case DRM_FORMAT_RGB565:
>   val |= WINCONx_BPPMODE_16BPP_565;
>   val |= WINCONx_BURSTLEN_16WORD;
> @@ -339,7 +339,7 @@ static void decon_win_set_pixfmt(struct decon_context 
> *ctx, unsigned int win)
>   break;
>   }
>  
> - DRM_DEBUG_KMS("bpp = %d\n", plane->bpp);
> + DRM_DEBUG_KMS("bpp = %d\n", fb->bits_per_pixel);
>  
>   /*
>* In case of exynos, setting dma-burst to 16Word causes permanent
> @@ -349,8 +349,8 @@ static void decon_win_set_pixfmt(struct decon_context 
> *ctx, unsigned int win)
>* movement causes unstable DMA which results into iommu crash/tear.
>*/
>  
> - padding = (plane->pitch / (plane->bpp >> 3)) - plane->fb_width;
> - if (plane->fb_width + padding < MIN_FB_WIDTH_FOR_16WORD_BURST) {
> + padding = (fb->pitches[0] / (fb->bits_per_pixel >> 3)) - fb->width;
> + if (fb->width + padding < MIN_FB_WIDTH_FOR_16WORD_BURST) {
>   val &= ~WINCONx_BURSTLEN_MASK;
>   val |= WINCONx_BURSTLEN_8WORD;
>   }
> @@ -396,12 +396,15 @@ static void decon_update_plane(struct exynos_drm_crtc 
> *crtc,
>  struct exynos_drm_plane *plane)
>  {
>   struct decon_context *ctx = crtc->ctx;
> + struct drm_plane_state *state = plane->base.state;
>   struct drm_display_mode *mode = >base.mode;
>   int padding;
>   unsigned long val, alpha;
>   unsigned int last_x;
>   unsigned int last_y;
>   unsigned int win = plane->zpos;
> + unsigned int bpp = state->fb->bits_per_pixel >> 3;
> + unsigned int pitch = state->fb->pitches[0];
>  
>   /* If suspended, enable this on resume */
>   if (ctx->suspended) {
> @@ -426,38 +429,38 @@ static void decon_update_plane(struct exynos_drm_crtc 
> *crtc,
>   val = (unsigned long)plane->dma_addr[0];
>   writel(val, ctx->regs + VIDW_BUF_START(win));
>  
> - padding = (plane->pitch / (plane->bpp >> 3)) - plane->fb_width;
> + padding = (pitch / bpp) - state->fb->width;
>  
>   /* buffer size */
> - writel(plane->fb_width + padding, ctx->regs + VIDW_WHOLE_X(win));
> - writel(plane->fb_height, ctx->regs + VIDW_WHOLE_Y(win));
> + writel(state->fb->width + padding, ctx->regs + VIDW_WHOLE_X(win));
> + writel(state->fb->height, ctx->regs + VIDW_WHOLE_Y(win));
>  
>   /* offset from the start of the buffer to read */
> - writel(plane->src_x, ctx->regs + VIDW_OFFSET_X(win));
> - writel(plane->src_y, ctx->regs + VIDW_OFFSET_Y(win));
> + writel(state->src_x, ctx->regs + VIDW_OFFSET_X(win));
> + writel(state->src_y, ctx->regs + VIDW_OFFSET_Y(win));
>  
>   DRM_DEBUG_KMS("start addr = 0x%lx\n",
>   (unsigned long)val);
> - DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
> - plane->crtc_width, plane->crtc_height);
> + DRM_DEBUG_KMS("crtc_w = %d, crtc_h = %d\n",
> + state->crtc_w, state->crtc_h);
>  
>   /*
>* OSD position.
>* In case the window layout goes of LCD layout, DECON fails.
>*/
> - if ((plane->crtc_x + plane->crtc_width) > mode->hdisplay)
> - plane->crtc_x = mode->hdisplay - plane->crtc_width;
> - if ((plane->crtc_y + plane->crtc_height) > mode->vdisplay)
> - 

[PATCH] drm/exynos: use drm_atomic_state directly

2015-05-21 Thread Gustavo Padovan
From: Gustavo Padovan 

Instead of use duplicated information stored on struct exynos_drm_plane
use the atomic state directly to have a more clear understanding and clean
code.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c |  49 ++--
 drivers/gpu/drm/exynos/exynos_drm_drv.h|  51 -
 drivers/gpu/drm/exynos/exynos_drm_fimd.c   |  47 ++--
 drivers/gpu/drm/exynos/exynos_drm_plane.c  |  86 ++---
 drivers/gpu/drm/exynos/exynos_mixer.c  | 116 ++---
 5 files changed, 131 insertions(+), 218 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index ed4461f..612ee29 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -281,16 +281,16 @@ static void decon_disable_vblank(struct exynos_drm_crtc 
*crtc)
}
 }

-static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win)
+static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
+struct drm_framebuffer *fb)
 {
-   struct exynos_drm_plane *plane = >planes[win];
unsigned long val;
int padding;

val = readl(ctx->regs + WINCON(win));
val &= ~WINCONx_BPPMODE_MASK;

-   switch (plane->pixel_format) {
+   switch (fb->pixel_format) {
case DRM_FORMAT_RGB565:
val |= WINCONx_BPPMODE_16BPP_565;
val |= WINCONx_BURSTLEN_16WORD;
@@ -339,7 +339,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, 
unsigned int win)
break;
}

-   DRM_DEBUG_KMS("bpp = %d\n", plane->bpp);
+   DRM_DEBUG_KMS("bpp = %d\n", fb->bits_per_pixel);

/*
 * In case of exynos, setting dma-burst to 16Word causes permanent
@@ -349,8 +349,8 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, 
unsigned int win)
 * movement causes unstable DMA which results into iommu crash/tear.
 */

-   padding = (plane->pitch / (plane->bpp >> 3)) - plane->fb_width;
-   if (plane->fb_width + padding < MIN_FB_WIDTH_FOR_16WORD_BURST) {
+   padding = (fb->pitches[0] / (fb->bits_per_pixel >> 3)) - fb->width;
+   if (fb->width + padding < MIN_FB_WIDTH_FOR_16WORD_BURST) {
val &= ~WINCONx_BURSTLEN_MASK;
val |= WINCONx_BURSTLEN_8WORD;
}
@@ -396,12 +396,15 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
   struct exynos_drm_plane *plane)
 {
struct decon_context *ctx = crtc->ctx;
+   struct drm_plane_state *state = plane->base.state;
struct drm_display_mode *mode = >base.mode;
int padding;
unsigned long val, alpha;
unsigned int last_x;
unsigned int last_y;
unsigned int win = plane->zpos;
+   unsigned int bpp = state->fb->bits_per_pixel >> 3;
+   unsigned int pitch = state->fb->pitches[0];

/* If suspended, enable this on resume */
if (ctx->suspended) {
@@ -426,38 +429,38 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
val = (unsigned long)plane->dma_addr[0];
writel(val, ctx->regs + VIDW_BUF_START(win));

-   padding = (plane->pitch / (plane->bpp >> 3)) - plane->fb_width;
+   padding = (pitch / bpp) - state->fb->width;

/* buffer size */
-   writel(plane->fb_width + padding, ctx->regs + VIDW_WHOLE_X(win));
-   writel(plane->fb_height, ctx->regs + VIDW_WHOLE_Y(win));
+   writel(state->fb->width + padding, ctx->regs + VIDW_WHOLE_X(win));
+   writel(state->fb->height, ctx->regs + VIDW_WHOLE_Y(win));

/* offset from the start of the buffer to read */
-   writel(plane->src_x, ctx->regs + VIDW_OFFSET_X(win));
-   writel(plane->src_y, ctx->regs + VIDW_OFFSET_Y(win));
+   writel(state->src_x, ctx->regs + VIDW_OFFSET_X(win));
+   writel(state->src_y, ctx->regs + VIDW_OFFSET_Y(win));

DRM_DEBUG_KMS("start addr = 0x%lx\n",
(unsigned long)val);
-   DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
-   plane->crtc_width, plane->crtc_height);
+   DRM_DEBUG_KMS("crtc_w = %d, crtc_h = %d\n",
+   state->crtc_w, state->crtc_h);

/*
 * OSD position.
 * In case the window layout goes of LCD layout, DECON fails.
 */
-   if ((plane->crtc_x + plane->crtc_width) > mode->hdisplay)
-   plane->crtc_x = mode->hdisplay - plane->crtc_width;
-   if ((plane->crtc_y + plane->crtc_height) > mode->vdisplay)
-   plane->crtc_y = mode->vdisplay - plane->crtc_height;
+   if ((state->crtc_x + state->crtc_w) > mode->hdisplay)
+   state->crtc_x = mode->hdisplay - state->crtc_w;
+   if ((state->crtc_y + state->crtc_h) > mode->vdisplay)
+