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

drm/cma-helper: Add DRM_GEM_CMA_DRIVER_OPS to set default GEM CMA functions

The macro to DRM_GEM_CMA_DRIVER_OPS sets GEM callbacks in struct drm_driver
to their defaults for CMA. A variant of the macro is provided for drivers
that override the default .dumb_create callback. Adapt drivers to the changes.

v4:
* remove parenthesis around dumb_create_func
* fix grammar in commit message

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200605073247.4057-4-tzimmermann@suse.de

+44 -4
+44 -4
include/drm/drm_gem_cma_helper.h
··· 110 110 drm_gem_cma_create_object_default_funcs(struct drm_device *dev, size_t size); 111 111 112 112 /** 113 + * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE - CMA GEM driver operations 114 + * @dumb_create_func: callback function for .dumb_create 115 + * 116 + * This macro provides a shortcut for setting the default GEM operations in the 117 + * &drm_driver structure. 118 + * 119 + * This macro is a variant of DRM_GEM_CMA_DRIVER_OPS for drivers that 120 + * override the default implementation of &struct rm_driver.dumb_create. Use 121 + * DRM_GEM_CMA_DRIVER_OPS if possible. Drivers that require a virtual address 122 + * on imported buffers should use 123 + * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE() instead. 124 + */ 125 + #define DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(dumb_create_func) \ 126 + .gem_create_object = drm_gem_cma_create_object_default_funcs, \ 127 + .dumb_create = (dumb_create_func), \ 128 + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \ 129 + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \ 130 + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, \ 131 + .gem_prime_mmap = drm_gem_cma_prime_mmap 132 + 133 + /** 134 + * DRM_GEM_CMA_DRIVER_OPS - CMA GEM driver operations 135 + * 136 + * This macro provides a shortcut for setting the default GEM operations in the 137 + * &drm_driver structure. 138 + * 139 + * Drivers that come with their own implementation of 140 + * &struct drm_driver.dumb_create should use 141 + * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE() instead. Use 142 + * DRM_GEM_CMA_DRIVER_OPS if possible. Drivers that require a virtual address 143 + * on imported buffers should use DRM_GEM_CMA_DRIVER_OPS_VMAP instead. 144 + */ 145 + #define DRM_GEM_CMA_DRIVER_OPS \ 146 + DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(drm_gem_cma_dumb_create) 147 + 148 + /** 113 149 * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE - CMA GEM driver operations 114 150 * ensuring a virtual address 115 151 * on the buffer ··· 156 120 * imported buffers. 157 121 * 158 122 * This macro is a variant of DRM_GEM_CMA_DRIVER_OPS_VMAP for drivers that 159 - * override the default implementation of &struct rm_driver.dumb_create. Use 160 - * DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. 123 + * override the default implementation of &struct drm_driver.dumb_create. Use 124 + * DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. Drivers that do not require a 125 + * virtual address on imported buffers should use 126 + * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE() instead. 161 127 */ 162 128 #define DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(dumb_create_func) \ 163 129 .gem_create_object = drm_gem_cma_create_object_default_funcs, \ 164 - .dumb_create = (dumb_create_func), \ 130 + .dumb_create = dumb_create_func, \ 165 131 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \ 166 132 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \ 167 133 .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table_vmap, \ ··· 180 142 * Drivers that come with their own implementation of 181 143 * &struct drm_driver.dumb_create should use 182 144 * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE() instead. Use 183 - * DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. 145 + * DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. Drivers that do not require a 146 + * virtual address on imported buffers should use DRM_GEM_CMA_DRIVER_OPS 147 + * instead. 184 148 */ 185 149 #define DRM_GEM_CMA_DRIVER_OPS_VMAP \ 186 150 DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(drm_gem_cma_dumb_create)