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