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

drm/exynos: move dma_addr attribute from exynos plane to exynos fb

DMA address is a framebuffer attribute and the right place for it is
exynos_drm_framebuffer not exynos_drm_plane. This patch also introduces
helper function for getting dma address of the given framebuffer.

Changelog v2:
- use state->fb instead of plane->base.fb.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Inki Dae <inki.dae@samsung.com>

authored by

Marek Szyprowski and committed by
Inki Dae
0488f50e 42f8119c

+39 -53
+8 -5
drivers/gpu/drm/exynos/exynos5433_drm_decon.c
··· 21 21 22 22 #include "exynos_drm_drv.h" 23 23 #include "exynos_drm_crtc.h" 24 + #include "exynos_drm_fb.h" 24 25 #include "exynos_drm_plane.h" 25 26 #include "exynos_drm_iommu.h" 26 27 ··· 262 261 { 263 262 struct decon_context *ctx = crtc->ctx; 264 263 struct drm_plane_state *state = plane->base.state; 264 + struct drm_framebuffer *fb = state->fb; 265 265 unsigned int win = plane->zpos; 266 - unsigned int bpp = state->fb->bits_per_pixel >> 3; 267 - unsigned int pitch = state->fb->pitches[0]; 266 + unsigned int bpp = fb->bits_per_pixel >> 3; 267 + unsigned int pitch = fb->pitches[0]; 268 + dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0); 268 269 u32 val; 269 270 270 271 if (test_bit(BIT_SUSPENDED, &ctx->flags)) ··· 287 284 VIDOSD_Wx_ALPHA_B_F(0x0); 288 285 writel(val, ctx->addr + DECON_VIDOSDxD(win)); 289 286 290 - writel(plane->dma_addr[0], ctx->addr + DECON_VIDW0xADD0B0(win)); 287 + writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win)); 291 288 292 - val = plane->dma_addr[0] + pitch * plane->crtc_h; 289 + val = dma_addr + pitch * plane->crtc_h; 293 290 writel(val, ctx->addr + DECON_VIDW0xADD1B0(win)); 294 291 295 292 if (ctx->out_type != IFTYPE_HDMI) ··· 300 297 | BIT_VAL(plane->crtc_w * bpp, 14, 0); 301 298 writel(val, ctx->addr + DECON_VIDW0xADD2(win)); 302 299 303 - decon_win_set_pixfmt(ctx, win, state->fb); 300 + decon_win_set_pixfmt(ctx, win, fb); 304 301 305 302 /* window enable */ 306 303 decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0);
+9 -7
drivers/gpu/drm/exynos/exynos7_drm_decon.c
··· 30 30 #include "exynos_drm_crtc.h" 31 31 #include "exynos_drm_plane.h" 32 32 #include "exynos_drm_drv.h" 33 + #include "exynos_drm_fb.h" 33 34 #include "exynos_drm_fbdev.h" 34 35 #include "exynos_drm_iommu.h" 35 36 ··· 396 395 { 397 396 struct decon_context *ctx = crtc->ctx; 398 397 struct drm_plane_state *state = plane->base.state; 398 + struct drm_framebuffer *fb = state->fb; 399 399 int padding; 400 400 unsigned long val, alpha; 401 401 unsigned int last_x; 402 402 unsigned int last_y; 403 403 unsigned int win = plane->zpos; 404 - unsigned int bpp = state->fb->bits_per_pixel >> 3; 405 - unsigned int pitch = state->fb->pitches[0]; 404 + unsigned int bpp = fb->bits_per_pixel >> 3; 405 + unsigned int pitch = fb->pitches[0]; 406 406 407 407 if (ctx->suspended) 408 408 return; ··· 419 417 */ 420 418 421 419 /* buffer start address */ 422 - val = (unsigned long)plane->dma_addr[0]; 420 + val = (unsigned long)exynos_drm_fb_dma_addr(fb, 0); 423 421 writel(val, ctx->regs + VIDW_BUF_START(win)); 424 422 425 - padding = (pitch / bpp) - state->fb->width; 423 + padding = (pitch / bpp) - fb->width; 426 424 427 425 /* buffer size */ 428 - writel(state->fb->width + padding, ctx->regs + VIDW_WHOLE_X(win)); 429 - writel(state->fb->height, ctx->regs + VIDW_WHOLE_Y(win)); 426 + writel(fb->width + padding, ctx->regs + VIDW_WHOLE_X(win)); 427 + writel(fb->height, ctx->regs + VIDW_WHOLE_Y(win)); 430 428 431 429 /* offset from the start of the buffer to read */ 432 430 writel(plane->src_x, ctx->regs + VIDW_OFFSET_X(win)); ··· 468 466 469 467 writel(alpha, ctx->regs + VIDOSD_D(win)); 470 468 471 - decon_win_set_pixfmt(ctx, win, state->fb); 469 + decon_win_set_pixfmt(ctx, win, fb); 472 470 473 471 /* hardware window 0 doesn't support color key. */ 474 472 if (win != 0)
-3
drivers/gpu/drm/exynos/exynos_drm_drv.h
··· 54 54 * @crtc_h: window height to be displayed (hardware screen). 55 55 * @h_ratio: horizontal scaling ratio, 16.16 fixed point 56 56 * @v_ratio: vertical scaling ratio, 16.16 fixed point 57 - * @dma_addr: array of bus(accessed by dma) address to the memory region 58 - * allocated for a overlay. 59 57 * @zpos: order of overlay layer(z position). 60 58 * 61 59 * this structure is common to exynos SoC and its contents would be copied ··· 72 74 unsigned int crtc_h; 73 75 unsigned int h_ratio; 74 76 unsigned int v_ratio; 75 - dma_addr_t dma_addr[MAX_FB_BUFFER]; 76 77 unsigned int zpos; 77 78 struct drm_framebuffer *pending_fb; 78 79 };
+6 -10
drivers/gpu/drm/exynos/exynos_drm_fb.c
··· 37 37 struct exynos_drm_fb { 38 38 struct drm_framebuffer fb; 39 39 struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER]; 40 + dma_addr_t dma_addr[MAX_FB_BUFFER]; 40 41 }; 41 42 42 43 static int check_fb_gem_memory_type(struct drm_device *drm_dev, ··· 136 135 goto err; 137 136 138 137 exynos_fb->exynos_gem[i] = exynos_gem[i]; 138 + exynos_fb->dma_addr[i] = exynos_gem[i]->dma_addr 139 + + mode_cmd->offsets[i]; 139 140 } 140 141 141 142 drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); ··· 192 189 return ERR_PTR(ret); 193 190 } 194 191 195 - struct exynos_drm_gem *exynos_drm_fb_gem(struct drm_framebuffer *fb, int index) 192 + dma_addr_t exynos_drm_fb_dma_addr(struct drm_framebuffer *fb, int index) 196 193 { 197 194 struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb); 198 - struct exynos_drm_gem *exynos_gem; 199 195 200 196 if (index >= MAX_FB_BUFFER) 201 - return NULL; 197 + return DMA_ERROR_CODE; 202 198 203 - exynos_gem = exynos_fb->exynos_gem[index]; 204 - if (!exynos_gem) 205 - return NULL; 206 - 207 - DRM_DEBUG_KMS("dma_addr: 0x%lx\n", (unsigned long)exynos_gem->dma_addr); 208 - 209 - return exynos_gem; 199 + return exynos_fb->dma_addr[index]; 210 200 } 211 201 212 202 static void exynos_drm_output_poll_changed(struct drm_device *dev)
+1 -2
drivers/gpu/drm/exynos/exynos_drm_fb.h
··· 22 22 struct exynos_drm_gem **exynos_gem, 23 23 int count); 24 24 25 - /* get gem object of a drm framebuffer */ 26 - struct exynos_drm_gem *exynos_drm_fb_gem(struct drm_framebuffer *fb, int index); 25 + dma_addr_t exynos_drm_fb_dma_addr(struct drm_framebuffer *fb, int index); 27 26 28 27 void exynos_drm_mode_config_init(struct drm_device *dev); 29 28
+6 -4
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 29 29 #include <drm/exynos_drm.h> 30 30 31 31 #include "exynos_drm_drv.h" 32 + #include "exynos_drm_fb.h" 32 33 #include "exynos_drm_fbdev.h" 33 34 #include "exynos_drm_crtc.h" 34 35 #include "exynos_drm_plane.h" ··· 643 642 { 644 643 struct fimd_context *ctx = crtc->ctx; 645 644 struct drm_plane_state *state = plane->base.state; 645 + struct drm_framebuffer *fb = state->fb; 646 646 dma_addr_t dma_addr; 647 647 unsigned long val, size, offset; 648 648 unsigned int last_x, last_y, buf_offsize, line_size; 649 649 unsigned int win = plane->zpos; 650 - unsigned int bpp = state->fb->bits_per_pixel >> 3; 651 - unsigned int pitch = state->fb->pitches[0]; 650 + unsigned int bpp = fb->bits_per_pixel >> 3; 651 + unsigned int pitch = fb->pitches[0]; 652 652 653 653 if (ctx->suspended) 654 654 return; ··· 658 656 offset += plane->src_y * pitch; 659 657 660 658 /* buffer start address */ 661 - dma_addr = plane->dma_addr[0] + offset; 659 + dma_addr = exynos_drm_fb_dma_addr(fb, 0) + offset; 662 660 val = (unsigned long)dma_addr; 663 661 writel(val, ctx->regs + VIDWx_BUF_START(win, 0)); 664 662 ··· 714 712 DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val); 715 713 } 716 714 717 - fimd_win_set_pixfmt(ctx, win, state->fb); 715 + fimd_win_set_pixfmt(ctx, win, fb); 718 716 719 717 /* hardware window 0 doesn't support color key. */ 720 718 if (win != 0)
-18
drivers/gpu/drm/exynos/exynos_drm_plane.c
··· 120 120 struct drm_plane_state *state) 121 121 { 122 122 struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); 123 - int nr; 124 - int i; 125 123 126 124 if (!state->fb) 127 125 return 0; 128 - 129 - nr = drm_format_num_planes(state->fb->pixel_format); 130 - for (i = 0; i < nr; i++) { 131 - struct exynos_drm_gem *exynos_gem = 132 - exynos_drm_fb_gem(state->fb, i); 133 - if (!exynos_gem) { 134 - DRM_DEBUG_KMS("gem object is null\n"); 135 - return -EFAULT; 136 - } 137 - 138 - exynos_plane->dma_addr[i] = exynos_gem->dma_addr + 139 - state->fb->offsets[i]; 140 - 141 - DRM_DEBUG_KMS("buffer: %d, dma_addr = 0x%lx\n", 142 - i, (unsigned long)exynos_plane->dma_addr[i]); 143 - } 144 126 145 127 return 0; 146 128 }
+5 -1
drivers/gpu/drm/exynos/exynos_drm_vidi.c
··· 24 24 25 25 #include "exynos_drm_drv.h" 26 26 #include "exynos_drm_crtc.h" 27 + #include "exynos_drm_fb.h" 27 28 #include "exynos_drm_plane.h" 28 29 #include "exynos_drm_vidi.h" 29 30 ··· 126 125 static void vidi_update_plane(struct exynos_drm_crtc *crtc, 127 126 struct exynos_drm_plane *plane) 128 127 { 128 + struct drm_plane_state *state = plane->base.state; 129 129 struct vidi_context *ctx = crtc->ctx; 130 + dma_addr_t addr; 130 131 131 132 if (ctx->suspended) 132 133 return; 133 134 134 - DRM_DEBUG_KMS("dma_addr = %pad\n", plane->dma_addr); 135 + addr = exynos_drm_fb_dma_addr(state->fb, 0); 136 + DRM_DEBUG_KMS("dma_addr = %pad\n", &addr); 135 137 136 138 if (ctx->vblank_on) 137 139 schedule_work(&ctx->work);
+4 -3
drivers/gpu/drm/exynos/exynos_mixer.c
··· 37 37 38 38 #include "exynos_drm_drv.h" 39 39 #include "exynos_drm_crtc.h" 40 + #include "exynos_drm_fb.h" 40 41 #include "exynos_drm_plane.h" 41 42 #include "exynos_drm_iommu.h" 42 43 ··· 423 422 return; 424 423 } 425 424 426 - luma_addr[0] = plane->dma_addr[0]; 427 - chroma_addr[0] = plane->dma_addr[1]; 425 + luma_addr[0] = exynos_drm_fb_dma_addr(fb, 0); 426 + chroma_addr[0] = exynos_drm_fb_dma_addr(fb, 1); 428 427 429 428 if (mode->flags & DRM_MODE_FLAG_INTERLACE) { 430 429 ctx->interlace = true; ··· 576 575 dst_y_offset = plane->crtc_y; 577 576 578 577 /* converting dma address base and source offset */ 579 - dma_addr = plane->dma_addr[0] 578 + dma_addr = exynos_drm_fb_dma_addr(fb, 0) 580 579 + (plane->src_x * fb->bits_per_pixel >> 3) 581 580 + (plane->src_y * fb->pitches[0]); 582 581 src_x_offset = 0;