Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
omap_drv.h
Go to the documentation of this file.
1 /*
2  * drivers/staging/omapdrm/omap_drv.h
3  *
4  * Copyright (C) 2011 Texas Instruments
5  * Author: Rob Clark <[email protected]>
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>
29 #include "omap_drm.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 
43  unsigned int num_crtcs;
44  struct drm_crtc *crtcs[8];
45 
46  unsigned int num_planes;
47  struct drm_plane *planes[8];
48 
49  unsigned int num_encoders;
50  struct drm_encoder *encoders[8];
51 
52  unsigned int num_connectors;
54 
56 
58 
60 
61  bool has_dmm;
62 
63  /* properties: */
66 };
67 
68 /* this should probably be in drm-core to standardize amongst drivers */
69 #define DRM_ROTATE_0 0
70 #define DRM_ROTATE_90 1
71 #define DRM_ROTATE_180 2
72 #define DRM_ROTATE_270 3
73 #define DRM_REFLECT_X 4
74 #define DRM_REFLECT_Y 5
75 
76 /* parameters which describe (unrotated) coordinates of scanout within a fb: */
79  int32_t crtc_x, crtc_y; /* signed because can be offscreen */
83 };
84 
85 #ifdef CONFIG_DEBUG_FS
86 int omap_debugfs_init(struct drm_minor *minor);
87 void omap_debugfs_cleanup(struct drm_minor *minor);
88 void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
89 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
90 void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
91 #endif
92 
94 void omap_fbdev_free(struct drm_device *dev);
95 
96 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
97  struct omap_overlay *ovl, int id);
98 
99 struct drm_plane *omap_plane_init(struct drm_device *dev,
100  struct omap_overlay *ovl, unsigned int possible_crtcs,
101  bool priv);
102 int omap_plane_dpms(struct drm_plane *plane, int mode);
104  struct drm_crtc *crtc, struct drm_framebuffer *fb,
105  int crtc_x, int crtc_y,
106  unsigned int crtc_w, unsigned int crtc_h,
107  uint32_t src_x, uint32_t src_y,
108  uint32_t src_w, uint32_t src_h);
110  void (*fxn)(void *), void *arg);
111 void omap_plane_install_properties(struct drm_plane *plane,
112  struct drm_mode_object *obj);
113 int omap_plane_set_property(struct drm_plane *plane,
114  struct drm_property *property, uint64_t val);
115 
117  struct omap_overlay_manager *mgr);
119  struct drm_encoder *encoder);
121  struct drm_connector *connector);
123  struct drm_connector *connector, bool force);
124 
126  int connector_type, struct omap_dss_device *dssdev);
128  struct drm_display_mode *mode);
130  int x, int y, int w, int h);
131 
133  uint32_t max_formats, enum omap_color_mode supported_modes);
135  struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd);
137  struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
138 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p);
140  struct drm_framebuffer *b, void *arg,
141  void (*unpin)(void *arg, struct drm_gem_object *bo));
143  struct omap_drm_window *win, struct omap_overlay_info *info);
145  struct drm_framebuffer *fb, struct drm_connector *from);
147  int x, int y, int w, int h);
148 
149 void omap_gem_init(struct drm_device *dev);
150 void omap_gem_deinit(struct drm_device *dev);
151 
152 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
153  union omap_gem_size gsize, uint32_t flags);
154 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
155  union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
156 void omap_gem_free_object(struct drm_gem_object *obj);
157 int omap_gem_init_object(struct drm_gem_object *obj);
158 void *omap_gem_vaddr(struct drm_gem_object *obj);
159 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
161 int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
162  uint32_t handle);
163 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
164  struct drm_mode_create_dumb *args);
165 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
166 int omap_gem_mmap_obj(struct drm_gem_object *obj,
167  struct vm_area_struct *vma);
168 int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
169 int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
170 int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
171 int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
172 int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
173  void (*fxn)(void *arg), void *arg);
174 int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
175 void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff);
176 void omap_gem_dma_sync(struct drm_gem_object *obj,
177  enum dma_data_direction dir);
178 int omap_gem_get_paddr(struct drm_gem_object *obj,
179  dma_addr_t *paddr, bool remap);
180 int omap_gem_put_paddr(struct drm_gem_object *obj);
181 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
182  bool remap);
183 int omap_gem_put_pages(struct drm_gem_object *obj);
184 uint32_t omap_gem_flags(struct drm_gem_object *obj);
185 int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient,
186  int x, int y, dma_addr_t *paddr);
187 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
188 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
189 int omap_gem_tiled_size(struct drm_gem_object *obj, uint16_t *w, uint16_t *h);
190 int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
191 
193  struct drm_gem_object *obj, int flags);
194 struct drm_gem_object * omap_gem_prime_import(struct drm_device *dev,
195  struct dma_buf *buffer);
196 
197 static inline int align_pitch(int pitch, int width, int bpp)
198 {
199  int bytespp = (bpp + 7) / 8;
200  /* in case someone tries to feed us a completely bogus stride: */
201  pitch = max(pitch, width * bytespp);
202  /* PVR needs alignment to 8 pixels.. right now that is the most
203  * restrictive stride requirement..
204  */
205  return ALIGN(pitch, 8 * bytespp);
206 }
207 
208 /* should these be made into common util helpers?
209  */
210 
211 static inline int objects_lookup(struct drm_device *dev,
212  struct drm_file *filp, uint32_t pixel_format,
213  struct drm_gem_object **bos, uint32_t *handles)
214 {
215  int i, n = drm_format_num_planes(pixel_format);
216 
217  for (i = 0; i < n; i++) {
218  bos[i] = drm_gem_object_lookup(dev, filp, handles[i]);
219  if (!bos[i]) {
220  goto fail;
221  }
222  }
223 
224  return 0;
225 
226 fail:
227  while (--i > 0) {
228  drm_gem_object_unreference_unlocked(bos[i]);
229  }
230  return -ENOENT;
231 }
232 
233 #endif /* __OMAP_DRV_H__ */