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