xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/qxl/qxl_prime.c (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1*41ec0267Sriastradh /*	$NetBSD: qxl_prime.c,v 1.3 2021/12/18 23:45:42 riastradh Exp $	*/
2efa246c0Sriastradh 
3efa246c0Sriastradh /*
4efa246c0Sriastradh  * Copyright 2014 Canonical
5efa246c0Sriastradh  *
6efa246c0Sriastradh  * Permission is hereby granted, free of charge, to any person obtaining a
7efa246c0Sriastradh  * copy of this software and associated documentation files (the "Software"),
8efa246c0Sriastradh  * to deal in the Software without restriction, including without limitation
9efa246c0Sriastradh  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10efa246c0Sriastradh  * and/or sell copies of the Software, and to permit persons to whom the
11efa246c0Sriastradh  * Software is furnished to do so, subject to the following conditions:
12efa246c0Sriastradh  *
13efa246c0Sriastradh  * The above copyright notice and this permission notice shall be included in
14efa246c0Sriastradh  * all copies or substantial portions of the Software.
15efa246c0Sriastradh  *
16efa246c0Sriastradh  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17efa246c0Sriastradh  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18efa246c0Sriastradh  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19efa246c0Sriastradh  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20efa246c0Sriastradh  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21efa246c0Sriastradh  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22efa246c0Sriastradh  * OTHER DEALINGS IN THE SOFTWARE.
23efa246c0Sriastradh  *
24efa246c0Sriastradh  * Authors: Andreas Pokorny
25efa246c0Sriastradh  */
26efa246c0Sriastradh 
27efa246c0Sriastradh #include <sys/cdefs.h>
28*41ec0267Sriastradh __KERNEL_RCSID(0, "$NetBSD: qxl_prime.c,v 1.3 2021/12/18 23:45:42 riastradh Exp $");
29efa246c0Sriastradh 
30efa246c0Sriastradh #include "qxl_drv.h"
31*41ec0267Sriastradh #include "qxl_object.h"
32efa246c0Sriastradh 
33efa246c0Sriastradh /* Empty Implementations as there should not be any other driver for a virtual
34efa246c0Sriastradh  * device that might share buffers with qxl */
35efa246c0Sriastradh 
qxl_gem_prime_pin(struct drm_gem_object * obj)36efa246c0Sriastradh int qxl_gem_prime_pin(struct drm_gem_object *obj)
37efa246c0Sriastradh {
38*41ec0267Sriastradh 	struct qxl_bo *bo = gem_to_qxl_bo(obj);
39*41ec0267Sriastradh 
40*41ec0267Sriastradh 	return qxl_bo_pin(bo);
41efa246c0Sriastradh }
42efa246c0Sriastradh 
qxl_gem_prime_unpin(struct drm_gem_object * obj)43efa246c0Sriastradh void qxl_gem_prime_unpin(struct drm_gem_object *obj)
44efa246c0Sriastradh {
45*41ec0267Sriastradh 	struct qxl_bo *bo = gem_to_qxl_bo(obj);
46efa246c0Sriastradh 
47*41ec0267Sriastradh 	qxl_bo_unpin(bo);
48*41ec0267Sriastradh }
49efa246c0Sriastradh 
qxl_gem_prime_get_sg_table(struct drm_gem_object * obj)50efa246c0Sriastradh struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj)
51efa246c0Sriastradh {
52efa246c0Sriastradh 	return ERR_PTR(-ENOSYS);
53efa246c0Sriastradh }
54efa246c0Sriastradh 
qxl_gem_prime_import_sg_table(struct drm_device * dev,struct dma_buf_attachment * attach,struct sg_table * table)55efa246c0Sriastradh struct drm_gem_object *qxl_gem_prime_import_sg_table(
56efa246c0Sriastradh 	struct drm_device *dev, struct dma_buf_attachment *attach,
57efa246c0Sriastradh 	struct sg_table *table)
58efa246c0Sriastradh {
59efa246c0Sriastradh 	return ERR_PTR(-ENOSYS);
60efa246c0Sriastradh }
61efa246c0Sriastradh 
qxl_gem_prime_vmap(struct drm_gem_object * obj)62efa246c0Sriastradh void *qxl_gem_prime_vmap(struct drm_gem_object *obj)
63efa246c0Sriastradh {
64*41ec0267Sriastradh 	struct qxl_bo *bo = gem_to_qxl_bo(obj);
65*41ec0267Sriastradh 	void *ptr;
66*41ec0267Sriastradh 	int ret;
67*41ec0267Sriastradh 
68*41ec0267Sriastradh 	ret = qxl_bo_kmap(bo, &ptr);
69*41ec0267Sriastradh 	if (ret < 0)
70*41ec0267Sriastradh 		return ERR_PTR(ret);
71*41ec0267Sriastradh 
72*41ec0267Sriastradh 	return ptr;
73efa246c0Sriastradh }
74efa246c0Sriastradh 
qxl_gem_prime_vunmap(struct drm_gem_object * obj,void * vaddr)75efa246c0Sriastradh void qxl_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
76efa246c0Sriastradh {
77*41ec0267Sriastradh 	struct qxl_bo *bo = gem_to_qxl_bo(obj);
78*41ec0267Sriastradh 
79*41ec0267Sriastradh 	qxl_bo_kunmap(bo);
80efa246c0Sriastradh }
81efa246c0Sriastradh 
qxl_gem_prime_mmap(struct drm_gem_object * obj,struct vm_area_struct * area)82efa246c0Sriastradh int qxl_gem_prime_mmap(struct drm_gem_object *obj,
83efa246c0Sriastradh 		       struct vm_area_struct *area)
84efa246c0Sriastradh {
85*41ec0267Sriastradh 	return -ENOSYS;
86efa246c0Sriastradh }
87