staging/omapdrm: Fix spacing coding style in omap_drv.c
[deliverable/linux.git] / drivers / staging / omapdrm / omap_drv.h
CommitLineData
cd5351f4
RC
1/*
2 * drivers/staging/omapdrm/omap_drv.h
3 *
4 * Copyright (C) 2011 Texas Instruments
5 * Author: Rob Clark <rob@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __OMAP_DRV_H__
21#define __OMAP_DRV_H__
22
23#include <video/omapdss.h>
24#include <linux/module.h>
25#include <linux/types.h>
26#include <drm/drmP.h>
ae43d7ca 27#include <drm/drm_crtc_helper.h>
e2fb5052 28#include <linux/platform_data/omap_drm.h>
cd5351f4 29#include "omap_drm.h"
cd5351f4
RC
30
31#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
32#define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
33
34#define MODULE_NAME "omapdrm"
35
36/* max # of mapper-id's that can be assigned.. todo, come up with a better
37 * (but still inexpensive) way to store/access per-buffer mapper private
38 * data..
39 */
40#define MAX_MAPPERS 2
41
42struct omap_drm_private {
5e3b0874
RC
43 uint32_t omaprev;
44
cd5351f4
RC
45 unsigned int num_crtcs;
46 struct drm_crtc *crtcs[8];
f6b6036e 47
bb5c2d9a
RC
48 unsigned int num_planes;
49 struct drm_plane *planes[8];
f6b6036e 50
cd5351f4
RC
51 unsigned int num_encoders;
52 struct drm_encoder *encoders[8];
f6b6036e 53
cd5351f4
RC
54 unsigned int num_connectors;
55 struct drm_connector *connectors[8];
56
57 struct drm_fb_helper *fbdev;
a6a91827 58
5609f7fe
RC
59 struct workqueue_struct *wq;
60
f6b6036e
RC
61 struct list_head obj_list;
62
a6a91827 63 bool has_dmm;
3c810c61
RC
64
65 /* properties: */
66 struct drm_property *rotation_prop;
8451b5ad 67 struct drm_property *zorder_prop;
3c810c61
RC
68};
69
70/* this should probably be in drm-core to standardize amongst drivers */
71#define DRM_ROTATE_0 0
72#define DRM_ROTATE_90 1
73#define DRM_ROTATE_180 2
74#define DRM_ROTATE_270 3
75#define DRM_REFLECT_X 4
76#define DRM_REFLECT_Y 5
77
78/* parameters which describe (unrotated) coordinates of scanout within a fb: */
79struct omap_drm_window {
80 uint32_t rotation;
81 int32_t crtc_x, crtc_y; /* signed because can be offscreen */
82 uint32_t crtc_w, crtc_h;
83 uint32_t src_x, src_y;
84 uint32_t src_w, src_h;
cd5351f4
RC
85};
86
6169a148
AG
87#ifdef CONFIG_DEBUG_FS
88int omap_debugfs_init(struct drm_minor *minor);
89void omap_debugfs_cleanup(struct drm_minor *minor);
f6b6036e
RC
90void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
91void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
92void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
6169a148
AG
93#endif
94
cd5351f4
RC
95struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
96void omap_fbdev_free(struct drm_device *dev);
97
98struct drm_crtc *omap_crtc_init(struct drm_device *dev,
99 struct omap_overlay *ovl, int id);
bb5c2d9a
RC
100
101struct drm_plane *omap_plane_init(struct drm_device *dev,
102 struct omap_overlay *ovl, unsigned int possible_crtcs,
103 bool priv);
104int omap_plane_dpms(struct drm_plane *plane, int mode);
2f53700d
RC
105int omap_plane_mode_set(struct drm_plane *plane,
106 struct drm_crtc *crtc, struct drm_framebuffer *fb,
107 int crtc_x, int crtc_y,
108 unsigned int crtc_w, unsigned int crtc_h,
109 uint32_t src_x, uint32_t src_y,
110 uint32_t src_w, uint32_t src_h);
72d0c336
RC
111void omap_plane_on_endwin(struct drm_plane *plane,
112 void (*fxn)(void *), void *arg);
3c810c61
RC
113void omap_plane_install_properties(struct drm_plane *plane,
114 struct drm_mode_object *obj);
115int omap_plane_set_property(struct drm_plane *plane,
116 struct drm_property *property, uint64_t val);
cd5351f4
RC
117
118struct drm_encoder *omap_encoder_init(struct drm_device *dev,
119 struct omap_overlay_manager *mgr);
120struct omap_overlay_manager *omap_encoder_get_manager(
121 struct drm_encoder *encoder);
122struct drm_encoder *omap_connector_attached_encoder(
123 struct drm_connector *connector);
124enum drm_connector_status omap_connector_detect(
125 struct drm_connector *connector, bool force);
126
127struct drm_connector *omap_connector_init(struct drm_device *dev,
128 int connector_type, struct omap_dss_device *dssdev);
129void omap_connector_mode_set(struct drm_connector *connector,
130 struct drm_display_mode *mode);
131void omap_connector_flush(struct drm_connector *connector,
132 int x, int y, int w, int h);
133
a890e662
RC
134uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats,
135 uint32_t max_formats, enum omap_color_mode supported_modes);
cd5351f4 136struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
ae43d7ca 137 struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd);
cd5351f4 138struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
ae43d7ca 139 struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
9a0774e0 140struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p);
b33f34d3
RC
141int omap_framebuffer_replace(struct drm_framebuffer *a,
142 struct drm_framebuffer *b, void *arg,
143 void (*unpin)(void *arg, struct drm_gem_object *bo));
3c810c61
RC
144void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
145 struct omap_drm_window *win, struct omap_overlay_info *info);
cd5351f4
RC
146struct drm_connector *omap_framebuffer_get_next_connector(
147 struct drm_framebuffer *fb, struct drm_connector *from);
148void omap_framebuffer_flush(struct drm_framebuffer *fb,
149 int x, int y, int w, int h);
150
f7f9f453
RC
151void omap_gem_init(struct drm_device *dev);
152void omap_gem_deinit(struct drm_device *dev);
cd5351f4
RC
153
154struct drm_gem_object *omap_gem_new(struct drm_device *dev,
155 union omap_gem_size gsize, uint32_t flags);
156int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
157 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
158void omap_gem_free_object(struct drm_gem_object *obj);
159int omap_gem_init_object(struct drm_gem_object *obj);
160void *omap_gem_vaddr(struct drm_gem_object *obj);
161int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
162 uint32_t handle, uint64_t *offset);
163int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
164 uint32_t handle);
165int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
166 struct drm_mode_create_dumb *args);
167int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
8b6b569e
RC
168int omap_gem_mmap_obj(struct drm_gem_object *obj,
169 struct vm_area_struct *vma);
cd5351f4
RC
170int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
171int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
172int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
173int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
174int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
175 void (*fxn)(void *arg), void *arg);
a6a91827 176int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
8b6b569e
RC
177void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff);
178void omap_gem_dma_sync(struct drm_gem_object *obj,
179 enum dma_data_direction dir);
cd5351f4
RC
180int omap_gem_get_paddr(struct drm_gem_object *obj,
181 dma_addr_t *paddr, bool remap);
182int omap_gem_put_paddr(struct drm_gem_object *obj);
6ad11bc3
RC
183int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
184 bool remap);
185int omap_gem_put_pages(struct drm_gem_object *obj);
186uint32_t omap_gem_flags(struct drm_gem_object *obj);
3c810c61
RC
187int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient,
188 int x, int y, dma_addr_t *paddr);
cd5351f4 189uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
f7f9f453 190size_t omap_gem_mmap_size(struct drm_gem_object *obj);
3c810c61
RC
191int omap_gem_tiled_size(struct drm_gem_object *obj, uint16_t *w, uint16_t *h);
192int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
cd5351f4 193
6ad11bc3
RC
194struct dma_buf * omap_gem_prime_export(struct drm_device *dev,
195 struct drm_gem_object *obj, int flags);
3080b838
RC
196struct drm_gem_object * omap_gem_prime_import(struct drm_device *dev,
197 struct dma_buf *buffer);
6ad11bc3 198
cd5351f4
RC
199static inline int align_pitch(int pitch, int width, int bpp)
200{
201 int bytespp = (bpp + 7) / 8;
202 /* in case someone tries to feed us a completely bogus stride: */
203 pitch = max(pitch, width * bytespp);
204 /* PVR needs alignment to 8 pixels.. right now that is the most
205 * restrictive stride requirement..
206 */
207 return ALIGN(pitch, 8 * bytespp);
208}
209
ae43d7ca
RC
210/* should these be made into common util helpers?
211 */
212
213static inline int objects_lookup(struct drm_device *dev,
214 struct drm_file *filp, uint32_t pixel_format,
215 struct drm_gem_object **bos, uint32_t *handles)
216{
217 int i, n = drm_format_num_planes(pixel_format);
218
219 for (i = 0; i < n; i++) {
220 bos[i] = drm_gem_object_lookup(dev, filp, handles[i]);
221 if (!bos[i]) {
222 goto fail;
223 }
224 }
225
226 return 0;
227
228fail:
229 while (--i > 0) {
230 drm_gem_object_unreference_unlocked(bos[i]);
231 }
232 return -ENOENT;
233}
234
cd5351f4 235#endif /* __OMAP_DRV_H__ */
This page took 0.123641 seconds and 5 git commands to generate.