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

Configure Feed

Select the types of activity you want to include in your feed.

drm/sun4i: layers: Use drm_fb_dma_get_gem_addr() to get display memory

Commit 4636ce93d5b2 ("drm/fb-cma-helper: Add drm_fb_cma_get_gem_addr()")
adds a new helper, which covers fetching a drm_framebuffer's GEM object
and calculating the buffer address for a given plane.

This patch uses this helper to replace our own open coded version of the
same function.

Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://patch.msgid.link/20260309165635.1138413-1-wens@kernel.org
Signed-off-by: Chen-Yu Tsai <wens@kernel.org>

+4 -39
+2 -14
drivers/gpu/drm/sun4i/sun8i_ui_layer.c
··· 124 124 { 125 125 struct drm_plane_state *state = plane->state; 126 126 struct drm_framebuffer *fb = state->fb; 127 - struct drm_gem_dma_object *gem; 128 127 dma_addr_t dma_addr; 129 128 u32 ch_base; 130 - int bpp; 131 129 132 130 ch_base = sun8i_channel_base(layer); 133 131 134 - /* Get the physical address of the buffer in memory */ 135 - gem = drm_fb_dma_get_gem_obj(fb, 0); 136 - 137 - DRM_DEBUG_DRIVER("Using GEM @ %pad\n", &gem->dma_addr); 138 - 139 - /* Compute the start of the displayed memory */ 140 - bpp = fb->format->cpp[0]; 141 - dma_addr = gem->dma_addr + fb->offsets[0]; 142 - 143 - /* Fixup framebuffer address for src coordinates */ 144 - dma_addr += (state->src.x1 >> 16) * bpp; 145 - dma_addr += (state->src.y1 >> 16) * fb->pitches[0]; 132 + /* Get the start of the displayed memory */ 133 + dma_addr = drm_fb_dma_get_gem_addr(fb, state, 0); 146 134 147 135 /* Set the line width */ 148 136 DRM_DEBUG_DRIVER("Layer line width: %d bytes\n", fb->pitches[0]);
+2 -25
drivers/gpu/drm/sun4i/sun8i_vi_layer.c
··· 197 197 struct drm_plane_state *state = plane->state; 198 198 struct drm_framebuffer *fb = state->fb; 199 199 const struct drm_format_info *format = fb->format; 200 - struct drm_gem_dma_object *gem; 201 - u32 dx, dy, src_x, src_y; 202 200 dma_addr_t dma_addr; 203 201 u32 ch_base; 204 202 int i; 205 203 206 204 ch_base = sun8i_channel_base(layer); 207 205 208 - /* Adjust x and y to be dividable by subsampling factor */ 209 - src_x = (state->src.x1 >> 16) & ~(format->hsub - 1); 210 - src_y = (state->src.y1 >> 16) & ~(format->vsub - 1); 211 - 212 206 for (i = 0; i < format->num_planes; i++) { 213 - /* Get the physical address of the buffer in memory */ 214 - gem = drm_fb_dma_get_gem_obj(fb, i); 215 - 216 - DRM_DEBUG_DRIVER("Using GEM @ %pad\n", &gem->dma_addr); 217 - 218 - /* Compute the start of the displayed memory */ 219 - dma_addr = gem->dma_addr + fb->offsets[i]; 220 - 221 - dx = src_x; 222 - dy = src_y; 223 - 224 - if (i > 0) { 225 - dx /= format->hsub; 226 - dy /= format->vsub; 227 - } 228 - 229 - /* Fixup framebuffer address for src coordinates */ 230 - dma_addr += dx * format->cpp[i]; 231 - dma_addr += dy * fb->pitches[i]; 207 + /* Get the start of the displayed memory */ 208 + dma_addr = drm_fb_dma_get_gem_addr(fb, state, i); 232 209 233 210 /* Set the line width */ 234 211 DRM_DEBUG_DRIVER("Layer %d. line width: %d bytes\n",