diff options
| author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-02-22 18:25:19 -0500 |
|---|---|---|
| committer | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-03-03 09:16:24 -0500 |
| commit | f398f344eb59cd9803091ee08bee77b4e473971e (patch) | |
| tree | dd9cd2f04c4105882f5635122d07ff987a1d3745 | |
| parent | 4407cc02c9251b0ce6bad3718211353a7dba93ef (diff) | |
drm: rcar-du: Rework plane setup code
Now that the plane setup code isn't called outside of the plane
implementation, it can be simplified by merging the
rcar_du_plane_compute_base() and rcar_du_plane_update_base() functions.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
| -rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_plane.c | 34 | ||||
| -rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_plane.h | 3 |
2 files changed, 12 insertions, 25 deletions
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index 7e0e2731ea27..f28d13dc6fc9 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c | |||
| @@ -129,12 +129,14 @@ static void rcar_du_plane_release(struct rcar_du_plane *plane) | |||
| 129 | plane->hwindex = -1; | 129 | plane->hwindex = -1; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | static void rcar_du_plane_update_base(struct rcar_du_plane *plane) | 132 | static void rcar_du_plane_setup_fb(struct rcar_du_plane *plane) |
| 133 | { | 133 | { |
| 134 | struct drm_framebuffer *fb = plane->plane.state->fb; | ||
| 134 | struct rcar_du_group *rgrp = plane->group; | 135 | struct rcar_du_group *rgrp = plane->group; |
| 135 | unsigned int src_x = plane->plane.state->src_x >> 16; | 136 | unsigned int src_x = plane->plane.state->src_x >> 16; |
| 136 | unsigned int src_y = plane->plane.state->src_y >> 16; | 137 | unsigned int src_y = plane->plane.state->src_y >> 16; |
| 137 | unsigned int index = plane->hwindex; | 138 | unsigned int index = plane->hwindex; |
| 139 | struct drm_gem_cma_object *gem; | ||
| 138 | bool interlaced; | 140 | bool interlaced; |
| 139 | u32 mwr; | 141 | u32 mwr; |
| 140 | 142 | ||
| @@ -144,9 +146,9 @@ static void rcar_du_plane_update_base(struct rcar_du_plane *plane) | |||
| 144 | * operation with 32bpp formats. | 146 | * operation with 32bpp formats. |
| 145 | */ | 147 | */ |
| 146 | if (plane->format->planes == 2) | 148 | if (plane->format->planes == 2) |
| 147 | mwr = plane->pitch; | 149 | mwr = fb->pitches[0]; |
| 148 | else | 150 | else |
| 149 | mwr = plane->pitch * 8 / plane->format->bpp; | 151 | mwr = fb->pitches[0] * 8 / plane->format->bpp; |
| 150 | 152 | ||
| 151 | if (interlaced && plane->format->bpp == 32) | 153 | if (interlaced && plane->format->bpp == 32) |
| 152 | mwr *= 2; | 154 | mwr *= 2; |
| @@ -168,33 +170,22 @@ static void rcar_du_plane_update_base(struct rcar_du_plane *plane) | |||
| 168 | rcar_du_plane_write(rgrp, index, PnSPXR, src_x); | 170 | rcar_du_plane_write(rgrp, index, PnSPXR, src_x); |
| 169 | rcar_du_plane_write(rgrp, index, PnSPYR, src_y * | 171 | rcar_du_plane_write(rgrp, index, PnSPYR, src_y * |
| 170 | (!interlaced && plane->format->bpp == 32 ? 2 : 1)); | 172 | (!interlaced && plane->format->bpp == 32 ? 2 : 1)); |
| 171 | rcar_du_plane_write(rgrp, index, PnDSA0R, plane->dma[0]); | 173 | |
| 174 | gem = drm_fb_cma_get_gem_obj(fb, 0); | ||
| 175 | rcar_du_plane_write(rgrp, index, PnDSA0R, gem->paddr + fb->offsets[0]); | ||
| 172 | 176 | ||
| 173 | if (plane->format->planes == 2) { | 177 | if (plane->format->planes == 2) { |
| 174 | index = (index + 1) % 8; | 178 | index = (index + 1) % 8; |
| 175 | 179 | ||
| 176 | rcar_du_plane_write(rgrp, index, PnMWR, plane->pitch); | 180 | rcar_du_plane_write(rgrp, index, PnMWR, fb->pitches[0]); |
| 177 | 181 | ||
| 178 | rcar_du_plane_write(rgrp, index, PnSPXR, src_x); | 182 | rcar_du_plane_write(rgrp, index, PnSPXR, src_x); |
| 179 | rcar_du_plane_write(rgrp, index, PnSPYR, src_y * | 183 | rcar_du_plane_write(rgrp, index, PnSPYR, src_y * |
| 180 | (plane->format->bpp == 16 ? 2 : 1) / 2); | 184 | (plane->format->bpp == 16 ? 2 : 1) / 2); |
| 181 | rcar_du_plane_write(rgrp, index, PnDSA0R, plane->dma[1]); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | static void rcar_du_plane_compute_base(struct rcar_du_plane *plane, | ||
| 186 | struct drm_framebuffer *fb) | ||
| 187 | { | ||
| 188 | struct drm_gem_cma_object *gem; | ||
| 189 | |||
| 190 | plane->pitch = fb->pitches[0]; | ||
| 191 | 185 | ||
| 192 | gem = drm_fb_cma_get_gem_obj(fb, 0); | ||
| 193 | plane->dma[0] = gem->paddr + fb->offsets[0]; | ||
| 194 | |||
| 195 | if (plane->format->planes == 2) { | ||
| 196 | gem = drm_fb_cma_get_gem_obj(fb, 1); | 186 | gem = drm_fb_cma_get_gem_obj(fb, 1); |
| 197 | plane->dma[1] = gem->paddr + fb->offsets[1]; | 187 | rcar_du_plane_write(rgrp, index, PnDSA0R, |
| 188 | gem->paddr + fb->offsets[1]); | ||
| 198 | } | 189 | } |
| 199 | } | 190 | } |
| 200 | 191 | ||
| @@ -316,7 +307,7 @@ void rcar_du_plane_setup(struct rcar_du_plane *plane) | |||
| 316 | if (plane->format->planes == 2) | 307 | if (plane->format->planes == 2) |
| 317 | __rcar_du_plane_setup(plane, (plane->hwindex + 1) % 8); | 308 | __rcar_du_plane_setup(plane, (plane->hwindex + 1) % 8); |
| 318 | 309 | ||
| 319 | rcar_du_plane_update_base(plane); | 310 | rcar_du_plane_setup_fb(plane); |
| 320 | } | 311 | } |
| 321 | 312 | ||
| 322 | static int rcar_du_plane_atomic_check(struct drm_plane *plane, | 313 | static int rcar_du_plane_atomic_check(struct drm_plane *plane, |
| @@ -403,7 +394,6 @@ static void rcar_du_plane_atomic_update(struct drm_plane *plane, | |||
| 403 | rplane->crtc = state->crtc; | 394 | rplane->crtc = state->crtc; |
| 404 | rplane->format = format; | 395 | rplane->format = format; |
| 405 | 396 | ||
| 406 | rcar_du_plane_compute_base(rplane, state->fb); | ||
| 407 | rcar_du_plane_setup(rplane); | 397 | rcar_du_plane_setup(rplane); |
| 408 | 398 | ||
| 409 | mutex_lock(&rplane->group->planes.lock); | 399 | mutex_lock(&rplane->group->planes.lock); |
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h b/drivers/gpu/drm/rcar-du/rcar_du_plane.h index d291e85896ef..012f2185ca1f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h | |||
| @@ -41,9 +41,6 @@ struct rcar_du_plane { | |||
| 41 | int hwindex; /* 0-based, -1 means unused */ | 41 | int hwindex; /* 0-based, -1 means unused */ |
| 42 | 42 | ||
| 43 | const struct rcar_du_format_info *format; | 43 | const struct rcar_du_format_info *format; |
| 44 | |||
| 45 | unsigned long dma[2]; | ||
| 46 | unsigned int pitch; | ||
| 47 | }; | 44 | }; |
| 48 | 45 | ||
| 49 | struct rcar_du_planes { | 46 | struct rcar_du_planes { |
