Lines Matching +full:non +full:- +full:contiguous

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
20 #include <linux/dma-mapping.h>
26 * Provides helper functions for creating a DMA-contiguous framebuffer.
28 * Depending on the platform, the buffers may be physically non-contiguous and
30 * physically-contiguous memory (using, for instance, CMA or a pool of memory
35 * callback function to create a DMA-contiguous framebuffer.
39 * drm_fb_dma_get_gem_obj() - Get DMA GEM object for framebuffer
61 * drm_fb_dma_get_gem_addr() - Get DMA (bus) address for framebuffer, for pixel
78 u32 block_w = drm_format_info_block_width(fb->format, plane); in drm_fb_dma_get_gem_addr()
79 u32 block_h = drm_format_info_block_height(fb->format, plane); in drm_fb_dma_get_gem_addr()
80 u32 block_size = fb->format->char_per_block[plane]; in drm_fb_dma_get_gem_addr()
90 dma_addr = obj->dma_addr + fb->offsets[plane]; in drm_fb_dma_get_gem_addr()
93 h_div = fb->format->hsub; in drm_fb_dma_get_gem_addr()
94 v_div = fb->format->vsub; in drm_fb_dma_get_gem_addr()
97 sample_x = (state->src_x >> 16) / h_div; in drm_fb_dma_get_gem_addr()
98 sample_y = (state->src_y >> 16) / v_div; in drm_fb_dma_get_gem_addr()
102 dma_addr += fb->pitches[plane] * block_start_y; in drm_fb_dma_get_gem_addr()
110 * drm_fb_dma_sync_non_coherent - Sync GEM object to non-coherent backing
117 * DMA GEM objects backed by non-coherent memory. Calling this function
125 const struct drm_format_info *finfo = state->fb->format; in drm_fb_dma_sync_non_coherent()
133 for (i = 0; i < finfo->num_planes; i++) { in drm_fb_dma_sync_non_coherent()
134 dma_obj = drm_fb_dma_get_gem_obj(state->fb, i); in drm_fb_dma_sync_non_coherent()
135 if (!dma_obj->map_noncoherent) in drm_fb_dma_sync_non_coherent()
138 daddr = drm_fb_dma_get_gem_addr(state->fb, state, i); in drm_fb_dma_sync_non_coherent()
143 offset = clip.y1 * state->fb->pitches[i]; in drm_fb_dma_sync_non_coherent()
145 nb_bytes = (clip.y2 - clip.y1) * state->fb->pitches[i]; in drm_fb_dma_sync_non_coherent()
146 dma_sync_single_for_device(drm->dev, daddr + offset, in drm_fb_dma_sync_non_coherent()
154 * drm_fb_dma_get_scanout_buffer - Provide a scanout buffer in case of panic
170 if (!plane->state || !plane->state->fb) in drm_fb_dma_get_scanout_buffer()
171 return -EINVAL; in drm_fb_dma_get_scanout_buffer()
173 fb = plane->state->fb; in drm_fb_dma_get_scanout_buffer()
175 if (fb->modifier != DRM_FORMAT_MOD_LINEAR) in drm_fb_dma_get_scanout_buffer()
176 return -ENODEV; in drm_fb_dma_get_scanout_buffer()
181 if (dma_obj->base.import_attach) in drm_fb_dma_get_scanout_buffer()
182 return -ENODEV; in drm_fb_dma_get_scanout_buffer()
185 if (!dma_obj->vaddr) in drm_fb_dma_get_scanout_buffer()
186 return -ENODEV; in drm_fb_dma_get_scanout_buffer()
188 iosys_map_set_vaddr(&sb->map[0], dma_obj->vaddr); in drm_fb_dma_get_scanout_buffer()
189 sb->format = fb->format; in drm_fb_dma_get_scanout_buffer()
190 sb->height = fb->height; in drm_fb_dma_get_scanout_buffer()
191 sb->width = fb->width; in drm_fb_dma_get_scanout_buffer()
192 sb->pitch[0] = fb->pitches[0]; in drm_fb_dma_get_scanout_buffer()