Lines Matching +full:simple +full:- +full:framebuffer
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drm gem framebuffer helper functions
8 #include <linux/dma-buf.h>
9 #include <linux/dma-fence.h>
10 #include <linux/dma-resv.h>
36 * drm_gem_fb_get_obj() - Get GEM object backing the framebuffer
37 * @fb: Framebuffer
44 * Pointer to &drm_gem_object for the given framebuffer and plane index or NULL
53 return fb->obj[plane]; in drm_gem_fb_get_obj()
68 return ERR_PTR(-ENOMEM); in drm_gem_fb_alloc()
73 fb->obj[i] = obj[i]; in drm_gem_fb_alloc()
77 DRM_DEV_ERROR(dev->dev, "Failed to init framebuffer: %d\n", in drm_gem_fb_alloc()
87 * drm_gem_fb_destroy - Free GEM backed framebuffer
88 * @fb: Framebuffer
90 * Frees a GEM backed framebuffer with its backing buffer(s) and the structure
91 * itself. Drivers can use this as their &drm_framebuffer_funcs->destroy
99 drm_gem_object_put_unlocked(fb->obj[i]); in drm_gem_fb_destroy()
107 * drm_gem_fb_create_handle - Create handle for GEM backed framebuffer
108 * @fb: Framebuffer
112 * This function creates a handle for the GEM object backing the framebuffer.
113 * Drivers can use this as their &drm_framebuffer_funcs->create_handle
122 return drm_gem_handle_create(file, fb->obj[0], handle); in drm_gem_fb_create_handle()
127 * drm_gem_fb_create_with_funcs() - Helper function for the
131 * @file: DRM file that holds the GEM handle(s) backing the framebuffer
132 * @mode_cmd: Metadata from the userspace framebuffer creation request
133 * @funcs: vtable to be used for the new framebuffer object
136 * custom framebuffer callbacks. Use drm_gem_fb_create() if you don't need to
154 return ERR_PTR(-EINVAL); in drm_gem_fb_create_with_funcs()
156 for (i = 0; i < info->num_planes; i++) { in drm_gem_fb_create_with_funcs()
157 unsigned int width = mode_cmd->width / (i ? info->hsub : 1); in drm_gem_fb_create_with_funcs()
158 unsigned int height = mode_cmd->height / (i ? info->vsub : 1); in drm_gem_fb_create_with_funcs()
161 objs[i] = drm_gem_object_lookup(file, mode_cmd->handles[i]); in drm_gem_fb_create_with_funcs()
164 ret = -ENOENT; in drm_gem_fb_create_with_funcs()
168 min_size = (height - 1) * mode_cmd->pitches[i] in drm_gem_fb_create_with_funcs()
170 + mode_cmd->offsets[i]; in drm_gem_fb_create_with_funcs()
172 if (objs[i]->size < min_size) { in drm_gem_fb_create_with_funcs()
174 ret = -EINVAL; in drm_gem_fb_create_with_funcs()
188 for (i--; i >= 0; i--) in drm_gem_fb_create_with_funcs()
201 * drm_gem_fb_create() - Helper function for the
204 * @file: DRM file that holds the GEM handle(s) backing the framebuffer
205 * @mode_cmd: Metadata from the userspace framebuffer creation request
207 * This function creates a new framebuffer object described by
209 * backing the framebuffer.
213 * validation. Use drm_gem_fb_create_with_dirty() if you need framebuffer
238 * drm_gem_fb_create_with_dirty() - Helper function for the
241 * @file: DRM file that holds the GEM handle(s) backing the framebuffer
242 * @mode_cmd: Metadata from the userspace framebuffer creation request
244 * This function creates a new framebuffer object described by
246 * backing the framebuffer. drm_atomic_helper_dirtyfb() is used for the dirty
247 * callback giving framebuffer flushing through the atomic machinery. Use
270 * drm_gem_fb_prepare_fb() - Prepare a GEM backed framebuffer
280 * There is no need for &drm_plane_helper_funcs.cleanup_fb hook for simple
281 * gem based framebuffer drivers which have their buffers always pinned in
293 if (!state->fb) in drm_gem_fb_prepare_fb()
296 obj = drm_gem_fb_get_obj(state->fb, 0); in drm_gem_fb_prepare_fb()
297 fence = dma_resv_get_excl_rcu(obj->resv); in drm_gem_fb_prepare_fb()
305 * drm_gem_fb_simple_display_pipe_prepare_fb - prepare_fb helper for
307 * @pipe: Simple display pipe
322 return drm_gem_fb_prepare_fb(&pipe->plane, plane_state); in drm_gem_fb_simple_display_pipe_prepare_fb()