3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * Authoer: Inki Dae <inki.dae@samsung.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
26 #ifndef _EXYNOS_DRM_GEM_H_
27 #define _EXYNOS_DRM_GEM_H_
29 #define to_exynos_gem_obj(x) container_of(x,\
30 struct exynos_drm_gem_obj, base)
33 * exynos drm gem buffer structure.
35 * @kvaddr: kernel virtual address to allocated memory region.
36 * @dma_addr: bus address(accessed by dma) to allocated memory region.
37 * - this address could be physical address without IOMMU and
38 * device address with IOMMU.
39 * @sgt: sg table to transfer page data.
40 * @pages: contain all pages to allocated memory region.
41 * @size: size of allocated memory region.
43 struct exynos_drm_gem_buf {
52 * exynos drm buffer structure.
54 * @base: a gem object.
55 * - a new handle to this gem object would be created
56 * by drm_gem_handle_create().
57 * @buffer: a pointer to exynos_drm_gem_buffer object.
58 * - contain the information to memory region allocated
59 * by user request or at framebuffer creation.
60 * continuous memory region allocated by user request
61 * or at framebuffer creation.
62 * @size: total memory size to physically non-continuous memory region.
63 * @flags: indicate memory type to allocated buffer and cache attruibute.
65 * P.S. this object would be transfered to user as kms_bo.handle so
66 * user can access the buffer through kms_bo.handle.
68 struct exynos_drm_gem_obj {
69 struct drm_gem_object base;
70 struct exynos_drm_gem_buf *buffer;
75 /* destroy a buffer with gem object */
76 void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj);
78 /* create a new buffer with gem object */
79 struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
84 * request gem object creation and buffer allocation as the size
85 * that it is calculated with framebuffer information such as width,
88 int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
89 struct drm_file *file_priv);
91 /* get buffer offset to map to user space. */
92 int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data,
93 struct drm_file *file_priv);
96 * mmap the physically continuous memory that a gem object contains
99 int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
100 struct drm_file *file_priv);
102 /* initialize gem object. */
103 int exynos_drm_gem_init_object(struct drm_gem_object *obj);
105 /* free gem object. */
106 void exynos_drm_gem_free_object(struct drm_gem_object *gem_obj);
108 /* create memory region for drm framebuffer. */
109 int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
110 struct drm_device *dev,
111 struct drm_mode_create_dumb *args);
113 /* map memory region for drm framebuffer to user space. */
114 int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv,
115 struct drm_device *dev, uint32_t handle,
119 * destroy memory region allocated.
120 * - a gem handle and physical memory region pointed by a gem object
121 * would be released by drm_gem_handle_delete().
123 int exynos_drm_gem_dumb_destroy(struct drm_file *file_priv,
124 struct drm_device *dev,
125 unsigned int handle);
127 /* page fault handler and mmap fault address(virtual) to physical memory. */
128 int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
130 /* set vm_flags and we can change the vm attribute to other one at here. */
131 int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);