2 * drivers/staging/omapdrm/omap_drv.h
4 * Copyright (C) 2011 Texas Instruments
5 * Author: Rob Clark <rob@ti.com>
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.
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
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/>.
20 #ifndef __OMAP_DRV_H__
21 #define __OMAP_DRV_H__
23 #include <video/omapdss.h>
24 #include <linux/module.h>
25 #include <linux/types.h>
27 #include <drm/drm_crtc_helper.h>
28 #include <linux/platform_data/omap_drm.h>
31 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
32 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
34 #define MODULE_NAME "omapdrm"
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
42 struct omap_drm_private {
43 unsigned int num_crtcs;
44 struct drm_crtc *crtcs[8];
45 unsigned int num_encoders;
46 struct drm_encoder *encoders[8];
47 unsigned int num_connectors;
48 struct drm_connector *connectors[8];
50 struct drm_fb_helper *fbdev;
53 struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
54 void omap_fbdev_free(struct drm_device *dev);
56 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
57 struct omap_overlay *ovl, int id);
58 struct omap_overlay *omap_crtc_get_overlay(struct drm_crtc *crtc);
60 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
61 struct omap_overlay_manager *mgr);
62 struct omap_overlay_manager *omap_encoder_get_manager(
63 struct drm_encoder *encoder);
64 struct drm_encoder *omap_connector_attached_encoder(
65 struct drm_connector *connector);
66 enum drm_connector_status omap_connector_detect(
67 struct drm_connector *connector, bool force);
69 struct drm_connector *omap_connector_init(struct drm_device *dev,
70 int connector_type, struct omap_dss_device *dssdev);
71 void omap_connector_mode_set(struct drm_connector *connector,
72 struct drm_display_mode *mode);
73 void omap_connector_flush(struct drm_connector *connector,
74 int x, int y, int w, int h);
76 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
77 struct drm_file *file, struct drm_mode_fb_cmd *mode_cmd);
78 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
79 struct drm_mode_fb_cmd *mode_cmd, struct drm_gem_object *bo);
80 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb);
81 int omap_framebuffer_get_buffer(struct drm_framebuffer *fb, int x, int y,
82 void **vaddr, dma_addr_t *paddr, unsigned int *screen_width);
83 struct drm_connector *omap_framebuffer_get_next_connector(
84 struct drm_framebuffer *fb, struct drm_connector *from);
85 void omap_framebuffer_flush(struct drm_framebuffer *fb,
86 int x, int y, int w, int h);
89 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
90 union omap_gem_size gsize, uint32_t flags);
91 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
92 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
93 void omap_gem_free_object(struct drm_gem_object *obj);
94 int omap_gem_init_object(struct drm_gem_object *obj);
95 void *omap_gem_vaddr(struct drm_gem_object *obj);
96 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
97 uint32_t handle, uint64_t *offset);
98 int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
100 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
101 struct drm_mode_create_dumb *args);
102 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
103 int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
104 int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
105 int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
106 int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
107 int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
108 void (*fxn)(void *arg), void *arg);
109 int omap_gem_get_paddr(struct drm_gem_object *obj,
110 dma_addr_t *paddr, bool remap);
111 int omap_gem_put_paddr(struct drm_gem_object *obj);
112 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
114 static inline int align_pitch(int pitch, int width, int bpp)
116 int bytespp = (bpp + 7) / 8;
117 /* in case someone tries to feed us a completely bogus stride: */
118 pitch = max(pitch, width * bytespp);
119 /* PVR needs alignment to 8 pixels.. right now that is the most
120 * restrictive stride requirement..
122 return ALIGN(pitch, 8 * bytespp);
125 #endif /* __OMAP_DRV_H__ */