[PATCH 01/41] drm/gem: Add drm_gem_dumb_map_offset()
Sean Paul
seanpaul at chromium.org
Wed Jul 26 14:19:51 UTC 2017
On Sun, Jul 23, 2017 at 09:16:17PM +0200, Noralf Trønnes wrote:
> Add a common drm_driver.dumb_map_offset function for GEM backed drivers.
>
> Signed-off-by: Noralf Trønnes <noralf at tronnes.org>
Reviewed-by: Sean Paul <seanpaul at chromium.org>
> ---
> drivers/gpu/drm/drm_gem.c | 35 +++++++++++++++++++++++++++++++++++
> include/drm/drm_gem.h | 2 ++
> 2 files changed, 37 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 5df028a..a8d396b 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -311,6 +311,41 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
> EXPORT_SYMBOL(drm_gem_handle_delete);
>
> /**
> + * drm_gem_dumb_map_offset - return the fake mmap offset for a gem object
> + * @file: drm file-private structure containing the gem object
> + * @dev: corresponding drm_device
> + * @handle: gem object handle
> + * @offset: return location for the fake mmap offset
> + *
> + * This implements the &drm_driver.dumb_map_offset kms driver callback for
> + * drivers which use gem to manage their backing storage.
> + *
> + * Returns:
> + * 0 on success or a negative error code on failure.
> + */
> +int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
> + u32 handle, u64 *offset)
> +{
> + struct drm_gem_object *obj;
> + int ret;
> +
> + obj = drm_gem_object_lookup(file, handle);
> + if (!obj)
> + return -ENOENT;
> +
> + ret = drm_gem_create_mmap_offset(obj);
> + if (ret)
> + goto out;
> +
> + *offset = drm_vma_node_offset_addr(&obj->vma_node);
> +out:
> + drm_gem_object_put_unlocked(obj);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(drm_gem_dumb_map_offset);
> +
> +/**
> * drm_gem_dumb_destroy - dumb fb callback helper for gem based drivers
> * @file: drm file-private structure to remove the dumb handle from
> * @dev: corresponding drm_device
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 4a9d231..9c55c2a 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -302,6 +302,8 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
> bool dirty, bool accessed);
>
> struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle);
> +int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
> + u32 handle, u64 *offset);
> int drm_gem_dumb_destroy(struct drm_file *file,
> struct drm_device *dev,
> uint32_t handle);
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Sean Paul, Software Engineer, Google / Chromium OS
More information about the dri-devel
mailing list