]> Pileus Git - ~andy/linux/blob - drivers/staging/omapdrm/omap_drv.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
[~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 "omap_drm.h"
28 #include "omap_priv.h"
29
30 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
31 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
32
33 #define MODULE_NAME     "omapdrm"
34
35 /* max # of mapper-id's that can be assigned.. todo, come up with a better
36  * (but still inexpensive) way to store/access per-buffer mapper private
37  * data..
38  */
39 #define MAX_MAPPERS 2
40
41 struct omap_drm_private {
42         unsigned int num_crtcs;
43         struct drm_crtc *crtcs[8];
44         unsigned int num_encoders;
45         struct drm_encoder *encoders[8];
46         unsigned int num_connectors;
47         struct drm_connector *connectors[8];
48
49         struct drm_fb_helper *fbdev;
50
51         bool has_dmm;
52 };
53
54 #ifdef CONFIG_DEBUG_FS
55 int omap_debugfs_init(struct drm_minor *minor);
56 void omap_debugfs_cleanup(struct drm_minor *minor);
57 #endif
58
59 struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
60 void omap_fbdev_free(struct drm_device *dev);
61
62 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
63                 struct omap_overlay *ovl, int id);
64 struct omap_overlay *omap_crtc_get_overlay(struct drm_crtc *crtc);
65
66 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
67                 struct omap_overlay_manager *mgr);
68 struct omap_overlay_manager *omap_encoder_get_manager(
69                 struct drm_encoder *encoder);
70 struct drm_encoder *omap_connector_attached_encoder(
71                 struct drm_connector *connector);
72 enum drm_connector_status omap_connector_detect(
73                 struct drm_connector *connector, bool force);
74
75 struct drm_connector *omap_connector_init(struct drm_device *dev,
76                 int connector_type, struct omap_dss_device *dssdev);
77 void omap_connector_mode_set(struct drm_connector *connector,
78                 struct drm_display_mode *mode);
79 void omap_connector_flush(struct drm_connector *connector,
80                 int x, int y, int w, int h);
81
82 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
83                 struct drm_file *file, struct drm_mode_fb_cmd *mode_cmd);
84 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
85                 struct drm_mode_fb_cmd *mode_cmd, struct drm_gem_object *bo);
86 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb);
87 int omap_framebuffer_get_buffer(struct drm_framebuffer *fb, int x, int y,
88                 void **vaddr, dma_addr_t *paddr, unsigned int *screen_width);
89 struct drm_connector *omap_framebuffer_get_next_connector(
90                 struct drm_framebuffer *fb, struct drm_connector *from);
91 void omap_framebuffer_flush(struct drm_framebuffer *fb,
92                 int x, int y, int w, int h);
93
94 void omap_gem_init(struct drm_device *dev);
95 void omap_gem_deinit(struct drm_device *dev);
96
97 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
98                 union omap_gem_size gsize, uint32_t flags);
99 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
100                 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
101 void omap_gem_free_object(struct drm_gem_object *obj);
102 int omap_gem_init_object(struct drm_gem_object *obj);
103 void *omap_gem_vaddr(struct drm_gem_object *obj);
104 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
105                 uint32_t handle, uint64_t *offset);
106 int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
107                 uint32_t handle);
108 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
109                 struct drm_mode_create_dumb *args);
110 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
111 int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
112 int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
113 int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
114 int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
115 int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
116                 void (*fxn)(void *arg), void *arg);
117 int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
118 int omap_gem_get_paddr(struct drm_gem_object *obj,
119                 dma_addr_t *paddr, bool remap);
120 int omap_gem_put_paddr(struct drm_gem_object *obj);
121 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
122 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
123
124 static inline int align_pitch(int pitch, int width, int bpp)
125 {
126         int bytespp = (bpp + 7) / 8;
127         /* in case someone tries to feed us a completely bogus stride: */
128         pitch = max(pitch, width * bytespp);
129         /* PVR needs alignment to 8 pixels.. right now that is the most
130          * restrictive stride requirement..
131          */
132         return ALIGN(pitch, 8 * bytespp);
133 }
134
135 #endif /* __OMAP_DRV_H__ */