Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/armada: use common helper for plane base address

Use a common helper to calculate the plane base address(es) for the
framebuffer.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

+34 -20
+22 -4
drivers/gpu/drm/armada/armada_crtc.c
··· 165 165 } 166 166 } 167 167 168 + void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb, 169 + int x, int y) 170 + { 171 + u32 addr = drm_fb_obj(fb)->dev_addr; 172 + u32 pixel_format = fb->pixel_format; 173 + int num_planes = drm_format_num_planes(pixel_format); 174 + int i; 175 + 176 + if (num_planes > 3) 177 + num_planes = 3; 178 + 179 + for (i = 0; i < num_planes; i++) 180 + addrs[i] = addr + fb->offsets[i] + y * fb->pitches[i] + 181 + x * drm_format_plane_cpp(pixel_format, i); 182 + for (; i < 3; i++) 183 + addrs[i] = 0; 184 + } 185 + 168 186 static unsigned armada_drm_crtc_calc_fb(struct drm_framebuffer *fb, 169 187 int x, int y, struct armada_regs *regs, bool interlaced) 170 188 { 171 - struct armada_gem_object *obj = drm_fb_obj(fb); 172 189 unsigned pitch = fb->pitches[0]; 173 - unsigned offset = y * pitch + x * fb->bits_per_pixel / 8; 174 - uint32_t addr_odd, addr_even; 190 + u32 addrs[3], addr_odd, addr_even; 175 191 unsigned i = 0; 176 192 177 193 DRM_DEBUG_DRIVER("pitch %u x %d y %d bpp %d\n", 178 194 pitch, x, y, fb->bits_per_pixel); 179 195 180 - addr_odd = addr_even = obj->dev_addr + offset; 196 + armada_drm_plane_calc_addrs(addrs, fb, x, y); 197 + 198 + addr_odd = addr_even = addrs[0]; 181 199 182 200 if (interlaced) { 183 201 addr_even += pitch;
+2
drivers/gpu/drm/armada/armada_crtc.h
··· 62 62 int armada_drm_plane_work_wait(struct armada_plane *plane, long timeout); 63 63 struct armada_plane_work *armada_drm_plane_work_cancel( 64 64 struct armada_crtc *dcrtc, struct armada_plane *plane); 65 + void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb, 66 + int x, int y); 65 67 66 68 struct armada_crtc { 67 69 struct drm_crtc crtc;
+10 -16
drivers/gpu/drm/armada/armada_overlay.c
··· 169 169 armada_drm_plane_work_cancel(dcrtc, &dplane->base); 170 170 171 171 if (plane->fb != fb) { 172 - struct armada_gem_object *obj = drm_fb_obj(fb); 173 - uint32_t addr[3], pixel_format; 174 - int i, num_planes, hsub; 172 + u32 addrs[3], pixel_format; 173 + int num_planes, hsub; 175 174 176 175 /* 177 176 * Take a reference on the new framebuffer - we want to ··· 184 185 src_y = src.y1 >> 16; 185 186 src_x = src.x1 >> 16; 186 187 188 + armada_drm_plane_calc_addrs(addrs, fb, src_x, src_y); 189 + 187 190 pixel_format = fb->pixel_format; 188 191 hsub = drm_format_horz_chroma_subsampling(pixel_format); 189 192 num_planes = drm_format_num_planes(pixel_format); ··· 198 197 if (src_x & (hsub - 1) && num_planes == 1) 199 198 ctrl0 ^= CFG_DMA_MOD(CFG_SWAPUV); 200 199 201 - for (i = 0; i < num_planes; i++) 202 - addr[i] = obj->dev_addr + fb->offsets[i] + 203 - src_y * fb->pitches[i] + 204 - src_x * drm_format_plane_cpp(pixel_format, i); 205 - for (; i < ARRAY_SIZE(addr); i++) 206 - addr[i] = 0; 207 - 208 - armada_reg_queue_set(dplane->vbl.regs, idx, addr[0], 200 + armada_reg_queue_set(dplane->vbl.regs, idx, addrs[0], 209 201 LCD_SPU_DMA_START_ADDR_Y0); 210 - armada_reg_queue_set(dplane->vbl.regs, idx, addr[1], 202 + armada_reg_queue_set(dplane->vbl.regs, idx, addrs[1], 211 203 LCD_SPU_DMA_START_ADDR_U0); 212 - armada_reg_queue_set(dplane->vbl.regs, idx, addr[2], 204 + armada_reg_queue_set(dplane->vbl.regs, idx, addrs[2], 213 205 LCD_SPU_DMA_START_ADDR_V0); 214 - armada_reg_queue_set(dplane->vbl.regs, idx, addr[0], 206 + armada_reg_queue_set(dplane->vbl.regs, idx, addrs[0], 215 207 LCD_SPU_DMA_START_ADDR_Y1); 216 - armada_reg_queue_set(dplane->vbl.regs, idx, addr[1], 208 + armada_reg_queue_set(dplane->vbl.regs, idx, addrs[1], 217 209 LCD_SPU_DMA_START_ADDR_U1); 218 - armada_reg_queue_set(dplane->vbl.regs, idx, addr[2], 210 + armada_reg_queue_set(dplane->vbl.regs, idx, addrs[2], 219 211 LCD_SPU_DMA_START_ADDR_V1); 220 212 221 213 val = fb->pitches[0] << 16 | fb->pitches[0];