xref: /OK3568_Linux_fs/kernel/drivers/gpu/drm/vgem/vgem_drv.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright © 2012 Intel Corporation
3*4882a593Smuzhiyun  * Copyright © 2014 The Chromium OS Authors
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
6*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
7*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
8*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
10*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * The above copyright notice and this permission notice (including the next
13*4882a593Smuzhiyun  * paragraph) shall be included in all copies or substantial portions of the
14*4882a593Smuzhiyun  * Software.
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19*4882a593Smuzhiyun  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*4882a593Smuzhiyun  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21*4882a593Smuzhiyun  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22*4882a593Smuzhiyun  * IN THE SOFTWARE.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * Authors:
25*4882a593Smuzhiyun  *    Ben Widawsky <ben@bwidawsk.net>
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  */
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #ifndef _VGEM_DRV_H_
30*4882a593Smuzhiyun #define _VGEM_DRV_H_
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #include <drm/drm_gem.h>
33*4882a593Smuzhiyun #include <drm/drm_cache.h>
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #include <uapi/drm/vgem_drm.h>
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun struct vgem_file {
38*4882a593Smuzhiyun 	struct idr fence_idr;
39*4882a593Smuzhiyun 	struct mutex fence_mutex;
40*4882a593Smuzhiyun };
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #define to_vgem_bo(x) container_of(x, struct drm_vgem_gem_object, base)
43*4882a593Smuzhiyun struct drm_vgem_gem_object {
44*4882a593Smuzhiyun 	struct drm_gem_object base;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun 	struct page **pages;
47*4882a593Smuzhiyun 	unsigned int pages_pin_count;
48*4882a593Smuzhiyun 	struct mutex pages_lock;
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun 	struct sg_table *table;
51*4882a593Smuzhiyun };
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun int vgem_fence_open(struct vgem_file *file);
54*4882a593Smuzhiyun int vgem_fence_attach_ioctl(struct drm_device *dev,
55*4882a593Smuzhiyun 			    void *data,
56*4882a593Smuzhiyun 			    struct drm_file *file);
57*4882a593Smuzhiyun int vgem_fence_signal_ioctl(struct drm_device *dev,
58*4882a593Smuzhiyun 			    void *data,
59*4882a593Smuzhiyun 			    struct drm_file *file);
60*4882a593Smuzhiyun void vgem_fence_close(struct vgem_file *file);
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun #endif
63