]> Pileus Git - ~andy/linux/blob - drivers/staging/omapdrm/omap_drv.h
staging: drm/omap: multiplanar and YUV support
[~andy/linux] / drivers / staging / omapdrm / omap_drv.h
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>
27 #include <drm/drm_crtc_helper.h>
28 #include "omap_drm.h"
29 #include "omap_priv.h"
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
42 struct omap_drm_private {
43         unsigned int num_crtcs;
44         struct drm_crtc *crtcs[8];
45         unsigned int num_planes;
46         struct drm_plane *planes[8];
47         unsigned int num_encoders;
48         struct drm_encoder *encoders[8];
49         unsigned int num_connectors;
50         struct drm_connector *connectors[8];
51
52         struct drm_fb_helper *fbdev;
53
54         bool has_dmm;
55 };
56
57 #ifdef CONFIG_DEBUG_FS
58 int omap_debugfs_init(struct drm_minor *minor);
59 void omap_debugfs_cleanup(struct drm_minor *minor);
60 #endif
61
62 struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
63 void omap_fbdev_free(struct drm_device *dev);
64
65 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
66                 struct omap_overlay *ovl, int id);
67
68 struct drm_plane *omap_plane_init(struct drm_device *dev,
69                 struct omap_overlay *ovl, unsigned int possible_crtcs,
70                 bool priv);
71 int omap_plane_dpms(struct drm_plane *plane, int mode);
72
73 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
74                 struct omap_overlay_manager *mgr);
75 struct omap_overlay_manager *omap_encoder_get_manager(
76                 struct drm_encoder *encoder);
77 struct drm_encoder *omap_connector_attached_encoder(
78                 struct drm_connector *connector);
79 enum drm_connector_status omap_connector_detect(
80                 struct drm_connector *connector, bool force);
81
82 struct drm_connector *omap_connector_init(struct drm_device *dev,
83                 int connector_type, struct omap_dss_device *dssdev);
84 void omap_connector_mode_set(struct drm_connector *connector,
85                 struct drm_display_mode *mode);
86 void omap_connector_flush(struct drm_connector *connector,
87                 int x, int y, int w, int h);
88
89 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
90                 struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd);
91 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
92                 struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
93 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p);
94 int omap_framebuffer_pin(struct drm_framebuffer *fb);
95 void omap_framebuffer_unpin(struct drm_framebuffer *fb);
96 void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, int x, int y,
97                 struct omap_overlay_info *info);
98 struct drm_connector *omap_framebuffer_get_next_connector(
99                 struct drm_framebuffer *fb, struct drm_connector *from);
100 void omap_framebuffer_flush(struct drm_framebuffer *fb,
101                 int x, int y, int w, int h);
102
103 void omap_gem_init(struct drm_device *dev);
104 void omap_gem_deinit(struct drm_device *dev);
105
106 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
107                 union omap_gem_size gsize, uint32_t flags);
108 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
109                 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
110 void omap_gem_free_object(struct drm_gem_object *obj);
111 int omap_gem_init_object(struct drm_gem_object *obj);
112 void *omap_gem_vaddr(struct drm_gem_object *obj);
113 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
114                 uint32_t handle, uint64_t *offset);
115 int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
116                 uint32_t handle);
117 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
118                 struct drm_mode_create_dumb *args);
119 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
120 int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
121 int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
122 int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
123 int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
124 int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
125                 void (*fxn)(void *arg), void *arg);
126 int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
127 int omap_gem_get_paddr(struct drm_gem_object *obj,
128                 dma_addr_t *paddr, bool remap);
129 int omap_gem_put_paddr(struct drm_gem_object *obj);
130 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
131 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
132
133 static inline int align_pitch(int pitch, int width, int bpp)
134 {
135         int bytespp = (bpp + 7) / 8;
136         /* in case someone tries to feed us a completely bogus stride: */
137         pitch = max(pitch, width * bytespp);
138         /* PVR needs alignment to 8 pixels.. right now that is the most
139          * restrictive stride requirement..
140          */
141         return ALIGN(pitch, 8 * bytespp);
142 }
143
144 /* should these be made into common util helpers?
145  */
146
147 static inline int objects_lookup(struct drm_device *dev,
148                 struct drm_file *filp, uint32_t pixel_format,
149                 struct drm_gem_object **bos, uint32_t *handles)
150 {
151         int i, n = drm_format_num_planes(pixel_format);
152
153         for (i = 0; i < n; i++) {
154                 bos[i] = drm_gem_object_lookup(dev, filp, handles[i]);
155                 if (!bos[i]) {
156                         goto fail;
157                 }
158         }
159
160         return 0;
161
162 fail:
163         while (--i > 0) {
164                 drm_gem_object_unreference_unlocked(bos[i]);
165         }
166         return -ENOENT;
167 }
168
169 #endif /* __OMAP_DRV_H__ */