]>
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 | * | |
d81aecb5 ID |
6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2 of the License, or (at your | |
9 | * option) any later version. | |
1c248b7d ID |
10 | */ |
11 | ||
12 | #ifndef _EXYNOS_DRM_GEM_H_ | |
13 | #define _EXYNOS_DRM_GEM_H_ | |
14 | ||
d9fc9413 | 15 | #include <drm/drm_gem.h> |
8a8d9b2c | 16 | #include <linux/mm_types.h> |
d9fc9413 | 17 | |
813fd67b | 18 | #define to_exynos_gem(x) container_of(x, struct exynos_drm_gem, base) |
1c248b7d | 19 | |
dcf9af82 ID |
20 | #define IS_NONCONTIG_BUFFER(f) (f & EXYNOS_BO_NONCONTIG) |
21 | ||
1c248b7d ID |
22 | /* |
23 | * exynos drm buffer structure. | |
24 | * | |
25 | * @base: a gem object. | |
26 | * - a new handle to this gem object would be created | |
27 | * by drm_gem_handle_create(). | |
2c871127 ID |
28 | * @buffer: a pointer to exynos_drm_gem_buffer object. |
29 | * - contain the information to memory region allocated | |
30 | * by user request or at framebuffer creation. | |
1c248b7d ID |
31 | * continuous memory region allocated by user request |
32 | * or at framebuffer creation. | |
2a8cb489 | 33 | * @flags: indicate memory type to allocated buffer and cache attruibute. |
3c52b880 ID |
34 | * @size: size requested from user, in bytes and this size is aligned |
35 | * in page unit. | |
2a8cb489 JS |
36 | * @cookie: cookie returned by dma_alloc_attrs |
37 | * @kvaddr: kernel virtual address to allocated memory region. | |
38 | * @dma_addr: bus address(accessed by dma) to allocated memory region. | |
39 | * - this address could be physical address without IOMMU and | |
40 | * device address with IOMMU. | |
41 | * @pages: Array of backing pages. | |
7c93537a | 42 | * @sgt: Imported sg_table. |
1c248b7d | 43 | * |
c6b78bc8 | 44 | * P.S. this object would be transferred to user as kms_bo.handle so |
1c248b7d ID |
45 | * user can access the buffer through kms_bo.handle. |
46 | */ | |
813fd67b | 47 | struct exynos_drm_gem { |
2a8cb489 JS |
48 | struct drm_gem_object base; |
49 | unsigned int flags; | |
50 | unsigned long size; | |
51 | void *cookie; | |
52 | void __iomem *kvaddr; | |
53 | dma_addr_t dma_addr; | |
00085f1e | 54 | unsigned long dma_attrs; |
2a8cb489 | 55 | struct page **pages; |
7c93537a | 56 | struct sg_table *sgt; |
1c248b7d ID |
57 | }; |
58 | ||
2364839a | 59 | /* destroy a buffer with gem object */ |
813fd67b | 60 | void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem); |
2364839a JS |
61 | |
62 | /* create a new buffer with gem object */ | |
813fd67b JS |
63 | struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev, |
64 | unsigned int flags, | |
65 | unsigned long size); | |
1c248b7d ID |
66 | |
67 | /* | |
68 | * request gem object creation and buffer allocation as the size | |
69 | * that it is calculated with framebuffer information such as width, | |
70 | * height and bpp. | |
71 | */ | |
72 | int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data, | |
ee5e770e | 73 | struct drm_file *file_priv); |
1c248b7d | 74 | |
6564c65f JS |
75 | /* get fake-offset of gem object that can be used with mmap. */ |
76 | int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data, | |
77 | struct drm_file *file_priv); | |
78 | ||
f0b1bda7 ID |
79 | /* |
80 | * get dma address from gem handle and this function could be used for | |
81 | * other drivers such as 2d/3d acceleration drivers. | |
82 | * with this function call, gem object reference count would be increased. | |
83 | */ | |
d87342c1 | 84 | dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev, |
f0b1bda7 | 85 | unsigned int gem_handle, |
d87342c1 | 86 | struct drm_file *filp); |
f0b1bda7 ID |
87 | |
88 | /* | |
89 | * put dma address from gem handle and this function could be used for | |
90 | * other drivers such as 2d/3d acceleration drivers. | |
91 | * with this function call, gem object reference count would be decreased. | |
92 | */ | |
93 | void exynos_drm_gem_put_dma_addr(struct drm_device *dev, | |
94 | unsigned int gem_handle, | |
d87342c1 | 95 | struct drm_file *filp); |
f0b1bda7 | 96 | |
40cd7e0c ID |
97 | /* get buffer information to memory region allocated by gem. */ |
98 | int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data, | |
99 | struct drm_file *file_priv); | |
100 | ||
a4f19aaa ID |
101 | /* get buffer size to gem handle. */ |
102 | unsigned long exynos_drm_gem_get_size(struct drm_device *dev, | |
103 | unsigned int gem_handle, | |
104 | struct drm_file *file_priv); | |
105 | ||
1c248b7d | 106 | /* free gem object. */ |
813fd67b | 107 | void exynos_drm_gem_free_object(struct drm_gem_object *obj); |
1c248b7d ID |
108 | |
109 | /* create memory region for drm framebuffer. */ | |
110 | int exynos_drm_gem_dumb_create(struct drm_file *file_priv, | |
ee5e770e JS |
111 | struct drm_device *dev, |
112 | struct drm_mode_create_dumb *args); | |
1c248b7d | 113 | |
ee5e770e | 114 | /* page fault handler and mmap fault address(virtual) to physical memory. */ |
8a8d9b2c | 115 | vm_fault_t exynos_drm_gem_fault(struct vm_fault *vmf); |
ee5e770e JS |
116 | |
117 | /* set vm_flags and we can change the vm attribute to other one at here. */ | |
118 | int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | |
1c248b7d | 119 | |
01ed50dd | 120 | /* low-level interface prime helpers */ |
89452d4a MS |
121 | struct drm_gem_object *exynos_drm_gem_prime_import(struct drm_device *dev, |
122 | struct dma_buf *dma_buf); | |
01ed50dd JS |
123 | struct sg_table *exynos_drm_gem_prime_get_sg_table(struct drm_gem_object *obj); |
124 | struct drm_gem_object * | |
125 | exynos_drm_gem_prime_import_sg_table(struct drm_device *dev, | |
126 | struct dma_buf_attachment *attach, | |
127 | struct sg_table *sgt); | |
128 | void *exynos_drm_gem_prime_vmap(struct drm_gem_object *obj); | |
129 | void exynos_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); | |
5a0202f7 JS |
130 | int exynos_drm_gem_prime_mmap(struct drm_gem_object *obj, |
131 | struct vm_area_struct *vma); | |
01ed50dd | 132 | |
1c248b7d | 133 | #endif |