blob: 4fe4a8b148185229eae01b6110324121e0c856d2 [file] [log] [blame]
Inki Dae1c248b72011-10-04 19:19:01 +09001/* exynos_drm_gem.h
2 *
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * Authoer: Inki Dae <inki.dae@samsung.com>
5 *
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:
12 *
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
15 * Software.
16 *
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.
24 */
25
26#ifndef _EXYNOS_DRM_GEM_H_
27#define _EXYNOS_DRM_GEM_H_
28
29#define to_exynos_gem_obj(x) container_of(x,\
30 struct exynos_drm_gem_obj, base)
31
32/*
Inki Dae2c871122011-11-12 15:23:32 +090033 * exynos drm gem buffer structure.
34 *
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 * @size: size of allocated memory region.
40 */
41struct exynos_drm_gem_buf {
42 void __iomem *kvaddr;
43 dma_addr_t dma_addr;
44 unsigned long size;
45};
46
47/*
Inki Dae1c248b72011-10-04 19:19:01 +090048 * exynos drm buffer structure.
49 *
50 * @base: a gem object.
51 * - a new handle to this gem object would be created
52 * by drm_gem_handle_create().
Inki Dae2c871122011-11-12 15:23:32 +090053 * @buffer: a pointer to exynos_drm_gem_buffer object.
54 * - contain the information to memory region allocated
55 * by user request or at framebuffer creation.
Inki Dae1c248b72011-10-04 19:19:01 +090056 * continuous memory region allocated by user request
57 * or at framebuffer creation.
58 *
59 * P.S. this object would be transfered to user as kms_bo.handle so
60 * user can access the buffer through kms_bo.handle.
61 */
62struct exynos_drm_gem_obj {
Joonyoung Shimee5e7702011-12-13 14:20:23 +090063 struct drm_gem_object base;
64 struct exynos_drm_gem_buf *buffer;
Inki Dae1c248b72011-10-04 19:19:01 +090065};
66
67/* create a new buffer and get a new gem handle. */
Inki Daef088d5a2011-11-12 14:51:23 +090068struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
Joonyoung Shimee5e7702011-12-13 14:20:23 +090069 struct drm_file *file_priv,
70 unsigned int *handle,
71 unsigned long size);
Inki Dae1c248b72011-10-04 19:19:01 +090072
73/*
74 * request gem object creation and buffer allocation as the size
75 * that it is calculated with framebuffer information such as width,
76 * height and bpp.
77 */
78int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
Joonyoung Shimee5e7702011-12-13 14:20:23 +090079 struct drm_file *file_priv);
Inki Dae1c248b72011-10-04 19:19:01 +090080
81/* get buffer offset to map to user space. */
82int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data,
Joonyoung Shimee5e7702011-12-13 14:20:23 +090083 struct drm_file *file_priv);
Inki Dae1c248b72011-10-04 19:19:01 +090084
Joonyoung Shimee5e7702011-12-13 14:20:23 +090085/*
86 * mmap the physically continuous memory that a gem object contains
87 * to user space.
88 */
89int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
90 struct drm_file *file_priv);
Inki Dae1c248b72011-10-04 19:19:01 +090091
92/* initialize gem object. */
93int exynos_drm_gem_init_object(struct drm_gem_object *obj);
94
95/* free gem object. */
96void exynos_drm_gem_free_object(struct drm_gem_object *gem_obj);
97
98/* create memory region for drm framebuffer. */
99int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
Joonyoung Shimee5e7702011-12-13 14:20:23 +0900100 struct drm_device *dev,
101 struct drm_mode_create_dumb *args);
Inki Dae1c248b72011-10-04 19:19:01 +0900102
103/* map memory region for drm framebuffer to user space. */
104int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv,
Joonyoung Shimee5e7702011-12-13 14:20:23 +0900105 struct drm_device *dev, uint32_t handle,
106 uint64_t *offset);
Inki Dae1c248b72011-10-04 19:19:01 +0900107
108/*
109 * destroy memory region allocated.
110 * - a gem handle and physical memory region pointed by a gem object
111 * would be released by drm_gem_handle_delete().
112 */
113int exynos_drm_gem_dumb_destroy(struct drm_file *file_priv,
Joonyoung Shimee5e7702011-12-13 14:20:23 +0900114 struct drm_device *dev,
115 unsigned int handle);
116
117/* page fault handler and mmap fault address(virtual) to physical memory. */
118int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
119
120/* set vm_flags and we can change the vm attribute to other one at here. */
121int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
Inki Dae1c248b72011-10-04 19:19:01 +0900122
123#endif