aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2015-06-15 05:18:02 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2015-07-15 11:45:29 -0400
commit73068ce3b5d85780466ecab1bf2459dbd660c1c8 (patch)
tree681e4612bc4b47ec823a0b27d47788a7b83939f7
parent98fb74f4ecb8a70c75d7cfcfec17432cb0db2f5d (diff)
drm/armada: fix overlay when partially off-screen
Fix the start address calculation when overlay is partially off screen. fb->bits_per_pixel is not set for YUV formats, and is always zero, which led to the first component always starting at zero. Use drm_format_plane_cpp() instead. This also revealed a problem in that YUYV formats toggle the U/V data for odd pixel start address offsets. We try to rectify that by toggling the U/V swap, which for the most part works, but seemingly introduces a flicker for one scan frame of swapped U/V. However, these changes result in an overall improvement. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--drivers/gpu/drm/armada/armada_overlay.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index d7df34f3d504..e939faba7fcc 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -166,7 +166,8 @@ armada_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
166 166
167 if (plane->fb != fb) { 167 if (plane->fb != fb) {
168 struct armada_gem_object *obj = drm_fb_obj(fb); 168 struct armada_gem_object *obj = drm_fb_obj(fb);
169 uint32_t sy, su, sv; 169 uint32_t addr[3], pixel_format;
170 int i, num_planes, hsub;
170 171
171 /* 172 /*
172 * Take a reference on the new framebuffer - we want to 173 * Take a reference on the new framebuffer - we want to
@@ -188,24 +189,37 @@ armada_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
188 189
189 src_y = src.y1 >> 16; 190 src_y = src.y1 >> 16;
190 src_x = src.x1 >> 16; 191 src_x = src.x1 >> 16;
191 sy = obj->dev_addr + fb->offsets[0] + src_y * fb->pitches[0] + 192
192 src_x * fb->bits_per_pixel / 8; 193 pixel_format = fb->pixel_format;
193 su = obj->dev_addr + fb->offsets[1] + src_y * fb->pitches[1] + 194 hsub = drm_format_horz_chroma_subsampling(pixel_format);
194 src_x; 195 num_planes = drm_format_num_planes(pixel_format);
195 sv = obj->dev_addr + fb->offsets[2] + src_y * fb->pitches[2] + 196
196 src_x; 197 /*
197 198 * Annoyingly, shifting a YUYV-format image by one pixel
198 armada_reg_queue_set(dplane->vbl.regs, idx, sy, 199 * causes the U/V planes to toggle. Toggle the UV swap.
200 * (Unfortunately, this causes momentary colour flickering.)
201 */
202 if (src_x & (hsub - 1) && num_planes == 1)
203 ctrl0 ^= CFG_DMA_MOD(CFG_SWAPUV);
204
205 for (i = 0; i < num_planes; i++)
206 addr[i] = obj->dev_addr + fb->offsets[i] +
207 src_y * fb->pitches[i] +
208 src_x * drm_format_plane_cpp(pixel_format, i);
209 for (; i < ARRAY_SIZE(addr); i++)
210 addr[i] = 0;
211
212 armada_reg_queue_set(dplane->vbl.regs, idx, addr[0],
199 LCD_SPU_DMA_START_ADDR_Y0); 213 LCD_SPU_DMA_START_ADDR_Y0);
200 armada_reg_queue_set(dplane->vbl.regs, idx, su, 214 armada_reg_queue_set(dplane->vbl.regs, idx, addr[1],
201 LCD_SPU_DMA_START_ADDR_U0); 215 LCD_SPU_DMA_START_ADDR_U0);
202 armada_reg_queue_set(dplane->vbl.regs, idx, sv, 216 armada_reg_queue_set(dplane->vbl.regs, idx, addr[2],
203 LCD_SPU_DMA_START_ADDR_V0); 217 LCD_SPU_DMA_START_ADDR_V0);
204 armada_reg_queue_set(dplane->vbl.regs, idx, sy, 218 armada_reg_queue_set(dplane->vbl.regs, idx, addr[0],
205 LCD_SPU_DMA_START_ADDR_Y1); 219 LCD_SPU_DMA_START_ADDR_Y1);
206 armada_reg_queue_set(dplane->vbl.regs, idx, su, 220 armada_reg_queue_set(dplane->vbl.regs, idx, addr[1],
207 LCD_SPU_DMA_START_ADDR_U1); 221 LCD_SPU_DMA_START_ADDR_U1);
208 armada_reg_queue_set(dplane->vbl.regs, idx, sv, 222 armada_reg_queue_set(dplane->vbl.regs, idx, addr[2],
209 LCD_SPU_DMA_START_ADDR_V1); 223 LCD_SPU_DMA_START_ADDR_V1);
210 224
211 val = fb->pitches[0] << 16 | fb->pitches[0]; 225 val = fb->pitches[0] << 16 | fb->pitches[0];