diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2017-03-23 15:09:42 -0700 |
---|---|---|
committer | Sinclair Yeh <syeh@vmware.com> | 2017-03-31 15:21:17 -0700 |
commit | d4d21902222d44acc76a520f11f78040b1e34b5a (patch) | |
tree | fb909312ad6d76917811f2f054c59a1984fdb8da /drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | |
parent | 50f837371dd9aea5470c06d5d10bc9ca3e8155b6 (diff) | |
download | lwn-d4d21902222d44acc76a520f11f78040b1e34b5a.tar.gz lwn-d4d21902222d44acc76a520f11f78040b1e34b5a.zip |
drm/vmwgfx: Introduce a simple resource type
The callbacks we need to provide to many resources are very similar, so
provide a simple resource type with a number of helpers for these
callbacks.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h index 5994ef6265e0..ac05968a832b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h @@ -30,6 +30,8 @@ #include "vmwgfx_drv.h" +#define VMW_IDA_ACC_SIZE 128 + enum vmw_cmdbuf_res_state { VMW_CMDBUF_RES_COMMITTED, VMW_CMDBUF_RES_ADD, @@ -83,6 +85,35 @@ struct vmw_res_func { enum vmw_cmdbuf_res_state state); }; +/** + * struct vmw_simple_resource_func - members and functions common for the + * simple resource helpers. + * @res_func: struct vmw_res_func as described above. + * @ttm_res_type: TTM resource type used for handle recognition. + * @size: Size of the simple resource information struct. + * @init: Initialize the simple resource information. + * @hw_destroy: A resource hw_destroy function. + * @set_arg_handle: Set the handle output argument of the ioctl create struct. + */ +struct vmw_simple_resource_func { + const struct vmw_res_func res_func; + int ttm_res_type; + size_t size; + int (*init)(struct vmw_resource *res, void *data); + void (*hw_destroy)(struct vmw_resource *res); + void (*set_arg_handle)(void *data, u32 handle); +}; + +/** + * struct vmw_simple_resource - Kernel only side simple resource + * @res: The resource we derive from. + * @func: The method and member virtual table. + */ +struct vmw_simple_resource { + struct vmw_resource res; + const struct vmw_simple_resource_func *func; +}; + int vmw_resource_alloc_id(struct vmw_resource *res); void vmw_resource_release_id(struct vmw_resource *res); int vmw_resource_init(struct vmw_private *dev_priv, struct vmw_resource *res, @@ -91,4 +122,13 @@ int vmw_resource_init(struct vmw_private *dev_priv, struct vmw_resource *res, const struct vmw_res_func *func); void vmw_resource_activate(struct vmw_resource *res, void (*hw_destroy) (struct vmw_resource *)); +int +vmw_simple_resource_create_ioctl(struct drm_device *dev, + void *data, + struct drm_file *file_priv, + const struct vmw_simple_resource_func *func); +struct vmw_resource * +vmw_simple_resource_lookup(struct ttm_object_file *tfile, + uint32_t handle, + const struct vmw_simple_resource_func *func); #endif |