![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0 OR MIT 0002 /************************************************************************** 0003 * 0004 * Copyright 2012-2016 VMware, Inc., Palo Alto, CA., USA 0005 * 0006 * Permission is hereby granted, free of charge, to any person obtaining a 0007 * copy of this software and associated documentation files (the 0008 * "Software"), to deal in the Software without restriction, including 0009 * without limitation the rights to use, copy, modify, merge, publish, 0010 * distribute, sub license, and/or sell copies of the Software, and to 0011 * permit persons to whom the Software is furnished to do so, subject to 0012 * the following conditions: 0013 * 0014 * The above copyright notice and this permission notice (including the 0015 * next paragraph) shall be included in all copies or substantial portions 0016 * of the Software. 0017 * 0018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0019 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0020 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 0021 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 0022 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 0023 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 0024 * USE OR OTHER DEALINGS IN THE SOFTWARE. 0025 * 0026 **************************************************************************/ 0027 0028 #include "vmwgfx_drv.h" 0029 #include "vmwgfx_resource_priv.h" 0030 0031 /** 0032 * struct vmw_stream - Overlay stream simple resource. 0033 * @sres: The simple resource we derive from. 0034 * @stream_id: The overlay stream id. 0035 */ 0036 struct vmw_stream { 0037 struct vmw_simple_resource sres; 0038 u32 stream_id; 0039 }; 0040 0041 /** 0042 * vmw_stream - Typecast a struct vmw_resource to a struct vmw_stream. 0043 * @res: Pointer to the struct vmw_resource. 0044 * 0045 * Returns: Returns a pointer to the struct vmw_stream. 0046 */ 0047 static struct vmw_stream * 0048 vmw_stream(struct vmw_resource *res) 0049 { 0050 return container_of(res, struct vmw_stream, sres.res); 0051 } 0052 0053 /*************************************************************************** 0054 * Simple resource callbacks for struct vmw_stream 0055 **************************************************************************/ 0056 static void vmw_stream_hw_destroy(struct vmw_resource *res) 0057 { 0058 struct vmw_private *dev_priv = res->dev_priv; 0059 struct vmw_stream *stream = vmw_stream(res); 0060 int ret; 0061 0062 ret = vmw_overlay_unref(dev_priv, stream->stream_id); 0063 WARN_ON_ONCE(ret != 0); 0064 } 0065 0066 static int vmw_stream_init(struct vmw_resource *res, void *data) 0067 { 0068 struct vmw_stream *stream = vmw_stream(res); 0069 0070 return vmw_overlay_claim(res->dev_priv, &stream->stream_id); 0071 } 0072 0073 static void vmw_stream_set_arg_handle(void *data, u32 handle) 0074 { 0075 struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data; 0076 0077 arg->stream_id = handle; 0078 } 0079 0080 static const struct vmw_simple_resource_func va_stream_func = { 0081 .res_func = { 0082 .res_type = vmw_res_stream, 0083 .needs_backup = false, 0084 .may_evict = false, 0085 .type_name = "overlay stream", 0086 .backup_placement = NULL, 0087 .create = NULL, 0088 .destroy = NULL, 0089 .bind = NULL, 0090 .unbind = NULL 0091 }, 0092 .ttm_res_type = VMW_RES_STREAM, 0093 .size = sizeof(struct vmw_stream), 0094 .init = vmw_stream_init, 0095 .hw_destroy = vmw_stream_hw_destroy, 0096 .set_arg_handle = vmw_stream_set_arg_handle, 0097 }; 0098 0099 /*************************************************************************** 0100 * End simple resource callbacks for struct vmw_stream 0101 **************************************************************************/ 0102 0103 /** 0104 * vmw_stream_unref_ioctl - Ioctl to unreference a user-space handle to 0105 * a struct vmw_stream. 0106 * @dev: Pointer to the drm device. 0107 * @data: The ioctl argument 0108 * @file_priv: Pointer to a struct drm_file identifying the caller. 0109 * 0110 * Return: 0111 * 0 if successful. 0112 * Negative error value on failure. 0113 */ 0114 int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, 0115 struct drm_file *file_priv) 0116 { 0117 struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data; 0118 0119 return ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile, 0120 arg->stream_id); 0121 } 0122 0123 /** 0124 * vmw_stream_claim_ioctl - Ioctl to claim a struct vmw_stream overlay. 0125 * @dev: Pointer to the drm device. 0126 * @data: The ioctl argument 0127 * @file_priv: Pointer to a struct drm_file identifying the caller. 0128 * 0129 * Return: 0130 * 0 if successful. 0131 * Negative error value on failure. 0132 */ 0133 int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, 0134 struct drm_file *file_priv) 0135 { 0136 return vmw_simple_resource_create_ioctl(dev, data, file_priv, 0137 &va_stream_func); 0138 } 0139 0140 /** 0141 * vmw_user_stream_lookup - Look up a struct vmw_user_stream from a handle. 0142 * @dev_priv: Pointer to a struct vmw_private. 0143 * @tfile: struct ttm_object_file identifying the caller. 0144 * @inout_id: In: The user-space handle. Out: The stream id. 0145 * @out: On output contains a refcounted pointer to the embedded 0146 * struct vmw_resource. 0147 * 0148 * Return: 0149 * 0 if successful. 0150 * Negative error value on failure. 0151 */ 0152 int vmw_user_stream_lookup(struct vmw_private *dev_priv, 0153 struct ttm_object_file *tfile, 0154 uint32_t *inout_id, struct vmw_resource **out) 0155 { 0156 struct vmw_stream *stream; 0157 struct vmw_resource *res = 0158 vmw_simple_resource_lookup(tfile, *inout_id, &va_stream_func); 0159 0160 if (IS_ERR(res)) 0161 return PTR_ERR(res); 0162 0163 stream = vmw_stream(res); 0164 *inout_id = stream->stream_id; 0165 *out = res; 0166 0167 return 0; 0168 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |