xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/i915/gvt/dmabuf.h (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: dmabuf.h,v 1.2 2021/12/18 23:45:31 riastradh Exp $	*/
2 
3 /*
4  * Copyright(c) 2017 Intel Corporation. All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  *
25  * Authors:
26  *    Zhiyuan Lv <zhiyuan.lv@intel.com>
27  *
28  * Contributors:
29  *    Xiaoguang Chen
30  *    Tina Zhang <tina.zhang@intel.com>
31  */
32 
33 #ifndef _GVT_DMABUF_H_
34 #define _GVT_DMABUF_H_
35 #include <linux/vfio.h>
36 
37 struct intel_vgpu_fb_info {
38 	__u64 start;
39 	__u64 start_gpa;
40 	__u64 drm_format_mod;
41 	__u32 drm_format;	/* drm format of plane */
42 	__u32 width;	/* width of plane */
43 	__u32 height;	/* height of plane */
44 	__u32 stride;	/* stride of plane */
45 	__u32 size;	/* size of plane in bytes, align on page */
46 	__u32 x_pos;	/* horizontal position of cursor plane */
47 	__u32 y_pos;	/* vertical position of cursor plane */
48 	__u32 x_hot;    /* horizontal position of cursor hotspot */
49 	__u32 y_hot;    /* vertical position of cursor hotspot */
50 	struct intel_vgpu_dmabuf_obj *obj;
51 };
52 
53 /**
54  * struct intel_vgpu_dmabuf_obj- Intel vGPU device buffer object
55  */
56 struct intel_vgpu_dmabuf_obj {
57 	struct intel_vgpu *vgpu;
58 	struct intel_vgpu_fb_info *info;
59 	__u32 dmabuf_id;
60 	struct kref kref;
61 	bool initref;
62 	struct list_head list;
63 };
64 
65 int intel_vgpu_query_plane(struct intel_vgpu *vgpu, void *args);
66 int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id);
67 void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu);
68 
69 #endif
70