Home | History | Annotate | Line # | Download | only in drm
      1  1.4     skrll /*	$NetBSD: drm_gem_cma_helper.h,v 1.4 2022/07/02 04:37:15 skrll Exp $	*/
      2  1.1  riastrad 
      3  1.3  riastrad /*-
      4  1.3  riastrad  * Copyright (c) 2022 The NetBSD Foundation, Inc.
      5  1.3  riastrad  * All rights reserved.
      6  1.3  riastrad  *
      7  1.3  riastrad  * Redistribution and use in source and binary forms, with or without
      8  1.3  riastrad  * modification, are permitted provided that the following conditions
      9  1.3  riastrad  * are met:
     10  1.3  riastrad  * 1. Redistributions of source code must retain the above copyright
     11  1.3  riastrad  *    notice, this list of conditions and the following disclaimer.
     12  1.3  riastrad  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.3  riastrad  *    notice, this list of conditions and the following disclaimer in the
     14  1.3  riastrad  *    documentation and/or other materials provided with the distribution.
     15  1.3  riastrad  *
     16  1.3  riastrad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.3  riastrad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.3  riastrad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.3  riastrad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.3  riastrad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.3  riastrad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.3  riastrad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.3  riastrad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.3  riastrad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.3  riastrad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.3  riastrad  * POSSIBILITY OF SUCH DAMAGE.
     27  1.3  riastrad  */
     28  1.1  riastrad 
     29  1.3  riastrad #ifndef	_DRM_DRM_GEM_CMA_HELPER_H_
     30  1.3  riastrad #define	_DRM_DRM_GEM_CMA_HELPER_H_
     31  1.3  riastrad 
     32  1.3  riastrad #include <sys/types.h>
     33  1.1  riastrad 
     34  1.3  riastrad #include <sys/bus.h>
     35  1.2  riastrad #include <sys/vmem.h>
     36  1.2  riastrad 
     37  1.3  riastrad #include <uvm/uvm_pager.h>
     38  1.3  riastrad 
     39  1.3  riastrad #include <drm/drm_gem.h>
     40  1.3  riastrad 
     41  1.4     skrll struct dma_buf_attachment;
     42  1.3  riastrad struct drm_device;
     43  1.3  riastrad struct drm_file;
     44  1.3  riastrad struct drm_gem_cma_object;
     45  1.3  riastrad struct drm_gem_object;
     46  1.1  riastrad struct drm_mode_create_dumb;
     47  1.3  riastrad struct sg_table;
     48  1.3  riastrad struct vmem;
     49  1.1  riastrad 
     50  1.1  riastrad struct drm_gem_cma_object {
     51  1.1  riastrad 	struct drm_gem_object base;
     52  1.3  riastrad 	bus_dmamap_t dmamap;
     53  1.1  riastrad 	bus_dma_segment_t dmasegs[1];
     54  1.1  riastrad 	bus_size_t dmasize;
     55  1.3  riastrad 	bus_dma_tag_t dmat;
     56  1.1  riastrad 	struct sg_table *sgt;
     57  1.1  riastrad 	void *vaddr;
     58  1.3  riastrad 	vmem_addr_t vmem_addr;
     59  1.3  riastrad 	struct vmem *vmem_pool;
     60  1.1  riastrad };
     61  1.1  riastrad 
     62  1.3  riastrad #define	to_drm_gem_cma_obj(GEM_OBJ)					      \
     63  1.3  riastrad 	container_of((GEM_OBJ), struct drm_gem_cma_object, base)
     64  1.1  riastrad 
     65  1.3  riastrad extern const struct uvm_pagerops drm_gem_cma_uvm_ops;
     66  1.1  riastrad 
     67  1.3  riastrad struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *, size_t);
     68  1.3  riastrad int drm_gem_cma_dumb_create(struct drm_file *, struct drm_device *,
     69  1.3  riastrad     struct drm_mode_create_dumb *);
     70  1.3  riastrad void drm_gem_cma_free_object(struct drm_gem_object *);
     71  1.3  riastrad struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *);
     72  1.3  riastrad struct drm_gem_object *drm_gem_cma_prime_import_sg_table(struct drm_device *,
     73  1.3  riastrad     struct dma_buf_attachment *, struct sg_table *);
     74  1.3  riastrad void *drm_gem_cma_prime_vmap(struct drm_gem_object *);
     75  1.3  riastrad void drm_gem_cma_prime_vunmap(struct drm_gem_object *, void *);
     76  1.1  riastrad 
     77  1.3  riastrad #endif	/* _DRM_DRM_GEM_CMA_HELPER_H_ */
     78