]>
Commit | Line | Data |
---|---|---|
1c248b7d ID |
1 | /* 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 | /* | |
33 | * exynos drm buffer structure. | |
34 | * | |
35 | * @base: a gem object. | |
36 | * - a new handle to this gem object would be created | |
37 | * by drm_gem_handle_create(). | |
38 | * @entry: pointer to exynos drm buffer entry object. | |
39 | * - containing the information to physically | |
40 | * continuous memory region allocated by user request | |
41 | * or at framebuffer creation. | |
42 | * | |
43 | * P.S. this object would be transfered to user as kms_bo.handle so | |
44 | * user can access the buffer through kms_bo.handle. | |
45 | */ | |
46 | struct exynos_drm_gem_obj { | |
47 | struct drm_gem_object base; | |
48 | struct exynos_drm_buf_entry *entry; | |
49 | }; | |
50 | ||
51 | /* create a new buffer and get a new gem handle. */ | |
52 | struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_file *file_priv, | |
53 | struct drm_device *dev, unsigned int size, | |
54 | unsigned int *handle); | |
55 | ||
56 | /* | |
57 | * request gem object creation and buffer allocation as the size | |
58 | * that it is calculated with framebuffer information such as width, | |
59 | * height and bpp. | |
60 | */ | |
61 | int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data, | |
62 | struct drm_file *file_priv); | |
63 | ||
64 | /* get buffer offset to map to user space. */ | |
65 | int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data, | |
66 | struct drm_file *file_priv); | |
67 | ||
68 | /* unmap a buffer from user space. */ | |
69 | int exynos_drm_gem_munmap_ioctl(struct drm_device *dev, void *data, | |
70 | struct drm_file *file_priv); | |
71 | ||
72 | /* initialize gem object. */ | |
73 | int exynos_drm_gem_init_object(struct drm_gem_object *obj); | |
74 | ||
75 | /* free gem object. */ | |
76 | void exynos_drm_gem_free_object(struct drm_gem_object *gem_obj); | |
77 | ||
78 | /* create memory region for drm framebuffer. */ | |
79 | int exynos_drm_gem_dumb_create(struct drm_file *file_priv, | |
80 | struct drm_device *dev, struct drm_mode_create_dumb *args); | |
81 | ||
82 | /* map memory region for drm framebuffer to user space. */ | |
83 | int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv, | |
84 | struct drm_device *dev, uint32_t handle, uint64_t *offset); | |
85 | ||
86 | /* page fault handler and mmap fault address(virtual) to physical memory. */ | |
87 | int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); | |
88 | ||
89 | /* | |
90 | * mmap the physically continuous memory that a gem object contains | |
91 | * to user space. | |
92 | */ | |
93 | int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data, | |
94 | struct drm_file *file_priv); | |
95 | ||
96 | /* set vm_flags and we can change the vm attribute to other one at here. */ | |
97 | int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | |
98 | ||
99 | /* | |
100 | * destroy memory region allocated. | |
101 | * - a gem handle and physical memory region pointed by a gem object | |
102 | * would be released by drm_gem_handle_delete(). | |
103 | */ | |
104 | int exynos_drm_gem_dumb_destroy(struct drm_file *file_priv, | |
105 | struct drm_device *dev, unsigned int handle); | |
106 | ||
107 | #endif |