Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/* exynos_drm_gem.h
  3 *
  4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  5 * Authoer: Inki Dae <inki.dae@samsung.com>
  6 */
  7
  8#ifndef _EXYNOS_DRM_GEM_H_
  9#define _EXYNOS_DRM_GEM_H_
 10
 11#include <drm/drm_gem.h>
 12#include <linux/mm_types.h>
 13
 14#define to_exynos_gem(x)	container_of(x, struct exynos_drm_gem, base)
 15
 16#define IS_NONCONTIG_BUFFER(f)		(f & EXYNOS_BO_NONCONTIG)
 17
 18/*
 19 * exynos drm buffer structure.
 20 *
 21 * @base: a gem object.
 22 *	- a new handle to this gem object would be created
 23 *	by drm_gem_handle_create().
 24 * @buffer: a pointer to exynos_drm_gem_buffer object.
 25 *	- contain the information to memory region allocated
 26 *	by user request or at framebuffer creation.
 27 *	continuous memory region allocated by user request
 28 *	or at framebuffer creation.
 29 * @flags: indicate memory type to allocated buffer and cache attruibute.
 30 * @size: size requested from user, in bytes and this size is aligned
 31 *	in page unit.
 32 * @cookie: cookie returned by dma_alloc_attrs
 33 * @kvaddr: kernel virtual address to allocated memory region.
 34 * @dma_addr: bus address(accessed by dma) to allocated memory region.
 35 *	- this address could be physical address without IOMMU and
 36 *	device address with IOMMU.
 37 * @pages: Array of backing pages.
 38 * @sgt: Imported sg_table.
 39 *
 40 * P.S. this object would be transferred to user as kms_bo.handle so
 41 *	user can access the buffer through kms_bo.handle.
 42 */
 43struct exynos_drm_gem {
 44	struct drm_gem_object	base;
 45	unsigned int		flags;
 46	unsigned long		size;
 47	void			*cookie;
 48	void __iomem		*kvaddr;
 49	dma_addr_t		dma_addr;
 50	unsigned long		dma_attrs;
 51	struct page		**pages;
 52	struct sg_table		*sgt;
 53};
 54
 55/* destroy a buffer with gem object */
 56void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem);
 57
 58/* create a new buffer with gem object */
 59struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
 60					     unsigned int flags,
 61					     unsigned long size);
 62
 63/*
 64 * request gem object creation and buffer allocation as the size
 65 * that it is calculated with framebuffer information such as width,
 66 * height and bpp.
 67 */
 68int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
 69				struct drm_file *file_priv);
 70
 71/* get fake-offset of gem object that can be used with mmap. */
 72int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
 73			     struct drm_file *file_priv);
 74
 75/*
 76 * get exynos drm object from gem handle, this function could be used for
 77 * other drivers such as 2d/3d acceleration drivers.
 78 * with this function call, gem object reference count would be increased.
 79 */
 80struct exynos_drm_gem *exynos_drm_gem_get(struct drm_file *filp,
 81					  unsigned int gem_handle);
 82
 83/*
 84 * put exynos drm object acquired from exynos_drm_gem_get(),
 85 * gem object reference count would be decreased.
 86 */
 87static inline void exynos_drm_gem_put(struct exynos_drm_gem *exynos_gem)
 88{
 89	drm_gem_object_put_unlocked(&exynos_gem->base);
 90}
 91
 92/* get buffer information to memory region allocated by gem. */
 93int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data,
 94				      struct drm_file *file_priv);
 95
 96/* free gem object. */
 97void exynos_drm_gem_free_object(struct drm_gem_object *obj);
 98
 99/* create memory region for drm framebuffer. */
100int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
101			       struct drm_device *dev,
102			       struct drm_mode_create_dumb *args);
103
104/* page fault handler and mmap fault address(virtual) to physical memory. */
105vm_fault_t exynos_drm_gem_fault(struct vm_fault *vmf);
106
107/* set vm_flags and we can change the vm attribute to other one at here. */
108int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
109
110/* low-level interface prime helpers */
111struct drm_gem_object *exynos_drm_gem_prime_import(struct drm_device *dev,
112					    struct dma_buf *dma_buf);
113struct sg_table *exynos_drm_gem_prime_get_sg_table(struct drm_gem_object *obj);
114struct drm_gem_object *
115exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,
116				     struct dma_buf_attachment *attach,
117				     struct sg_table *sgt);
118void *exynos_drm_gem_prime_vmap(struct drm_gem_object *obj);
119void exynos_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
120int exynos_drm_gem_prime_mmap(struct drm_gem_object *obj,
121			      struct vm_area_struct *vma);
122
123#endif