pstore/ram: Add ECC support
[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>
cd5351f4
RC
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
42struct omap_drm_private {
43 unsigned int num_crtcs;
44 struct drm_crtc *crtcs[8];
f6b6036e 45
bb5c2d9a
RC
46 unsigned int num_planes;
47 struct drm_plane *planes[8];
f6b6036e 48
cd5351f4
RC
49 unsigned int num_encoders;
50 struct drm_encoder *encoders[8];
f6b6036e 51
cd5351f4
RC
52 unsigned int num_connectors;
53 struct drm_connector *connectors[8];
54
55 struct drm_fb_helper *fbdev;
a6a91827 56
5609f7fe
RC
57 struct workqueue_struct *wq;
58
f6b6036e
RC
59 struct list_head obj_list;
60
a6a91827 61 bool has_dmm;
cd5351f4
RC
62};
63
6169a148
AG
64#ifdef CONFIG_DEBUG_FS
65int omap_debugfs_init(struct drm_minor *minor);
66void omap_debugfs_cleanup(struct drm_minor *minor);
f6b6036e
RC
67void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
68void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
69void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
6169a148
AG
70#endif
71
cd5351f4
RC
72struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
73void omap_fbdev_free(struct drm_device *dev);
74
75struct drm_crtc *omap_crtc_init(struct drm_device *dev,
76 struct omap_overlay *ovl, int id);
bb5c2d9a
RC
77
78struct drm_plane *omap_plane_init(struct drm_device *dev,
79 struct omap_overlay *ovl, unsigned int possible_crtcs,
80 bool priv);
81int omap_plane_dpms(struct drm_plane *plane, int mode);
2f53700d
RC
82int omap_plane_mode_set(struct drm_plane *plane,
83 struct drm_crtc *crtc, struct drm_framebuffer *fb,
84 int crtc_x, int crtc_y,
85 unsigned int crtc_w, unsigned int crtc_h,
86 uint32_t src_x, uint32_t src_y,
87 uint32_t src_w, uint32_t src_h);
72d0c336
RC
88void omap_plane_on_endwin(struct drm_plane *plane,
89 void (*fxn)(void *), void *arg);
cd5351f4
RC
90
91struct drm_encoder *omap_encoder_init(struct drm_device *dev,
92 struct omap_overlay_manager *mgr);
93struct omap_overlay_manager *omap_encoder_get_manager(
94 struct drm_encoder *encoder);
95struct drm_encoder *omap_connector_attached_encoder(
96 struct drm_connector *connector);
97enum drm_connector_status omap_connector_detect(
98 struct drm_connector *connector, bool force);
99
100struct drm_connector *omap_connector_init(struct drm_device *dev,
101 int connector_type, struct omap_dss_device *dssdev);
102void omap_connector_mode_set(struct drm_connector *connector,
103 struct drm_display_mode *mode);
104void omap_connector_flush(struct drm_connector *connector,
105 int x, int y, int w, int h);
106
a890e662
RC
107uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats,
108 uint32_t max_formats, enum omap_color_mode supported_modes);
cd5351f4 109struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
ae43d7ca 110 struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd);
cd5351f4 111struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
ae43d7ca 112 struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
9a0774e0 113struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p);
b33f34d3
RC
114int omap_framebuffer_replace(struct drm_framebuffer *a,
115 struct drm_framebuffer *b, void *arg,
116 void (*unpin)(void *arg, struct drm_gem_object *bo));
9a0774e0
RC
117void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, int x, int y,
118 struct omap_overlay_info *info);
cd5351f4
RC
119struct drm_connector *omap_framebuffer_get_next_connector(
120 struct drm_framebuffer *fb, struct drm_connector *from);
121void omap_framebuffer_flush(struct drm_framebuffer *fb,
122 int x, int y, int w, int h);
123
f7f9f453
RC
124void omap_gem_init(struct drm_device *dev);
125void omap_gem_deinit(struct drm_device *dev);
cd5351f4
RC
126
127struct drm_gem_object *omap_gem_new(struct drm_device *dev,
128 union omap_gem_size gsize, uint32_t flags);
129int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
130 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
131void omap_gem_free_object(struct drm_gem_object *obj);
132int omap_gem_init_object(struct drm_gem_object *obj);
133void *omap_gem_vaddr(struct drm_gem_object *obj);
134int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
135 uint32_t handle, uint64_t *offset);
136int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
137 uint32_t handle);
138int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
139 struct drm_mode_create_dumb *args);
140int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
141int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
142int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
143int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
144int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
145int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
146 void (*fxn)(void *arg), void *arg);
a6a91827 147int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
cd5351f4
RC
148int omap_gem_get_paddr(struct drm_gem_object *obj,
149 dma_addr_t *paddr, bool remap);
150int omap_gem_put_paddr(struct drm_gem_object *obj);
6ad11bc3
RC
151int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
152 bool remap);
153int omap_gem_put_pages(struct drm_gem_object *obj);
154uint32_t omap_gem_flags(struct drm_gem_object *obj);
cd5351f4 155uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
f7f9f453 156size_t omap_gem_mmap_size(struct drm_gem_object *obj);
cd5351f4 157
6ad11bc3
RC
158struct dma_buf * omap_gem_prime_export(struct drm_device *dev,
159 struct drm_gem_object *obj, int flags);
160
cd5351f4
RC
161static inline int align_pitch(int pitch, int width, int bpp)
162{
163 int bytespp = (bpp + 7) / 8;
164 /* in case someone tries to feed us a completely bogus stride: */
165 pitch = max(pitch, width * bytespp);
166 /* PVR needs alignment to 8 pixels.. right now that is the most
167 * restrictive stride requirement..
168 */
169 return ALIGN(pitch, 8 * bytespp);
170}
171
ae43d7ca
RC
172/* should these be made into common util helpers?
173 */
174
175static inline int objects_lookup(struct drm_device *dev,
176 struct drm_file *filp, uint32_t pixel_format,
177 struct drm_gem_object **bos, uint32_t *handles)
178{
179 int i, n = drm_format_num_planes(pixel_format);
180
181 for (i = 0; i < n; i++) {
182 bos[i] = drm_gem_object_lookup(dev, filp, handles[i]);
183 if (!bos[i]) {
184 goto fail;
185 }
186 }
187
188 return 0;
189
190fail:
191 while (--i > 0) {
192 drm_gem_object_unreference_unlocked(bos[i]);
193 }
194 return -ENOENT;
195}
196
cd5351f4 197#endif /* __OMAP_DRV_H__ */
This page took 0.073382 seconds and 5 git commands to generate.