OMAP: DSS2: OMAPFB: make DBG() more resistant in if-else constructions
[deliverable/linux.git] / drivers / video / omap2 / omapfb / omapfb.h
1 /*
2 * linux/drivers/video/omap2/omapfb.h
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6 *
7 * Some code and ideas taken from drivers/video/omap/ driver
8 * by Imre Deak.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
24 #define __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
25
26 #ifdef CONFIG_FB_OMAP2_DEBUG_SUPPORT
27 #define DEBUG
28 #endif
29
30 #include <linux/rwsem.h>
31
32 #include <video/omapdss.h>
33
34 #ifdef DEBUG
35 extern unsigned int omapfb_debug;
36 #define DBG(format, ...) \
37 do { \
38 if (omapfb_debug) \
39 printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__); \
40 } while (0)
41 #else
42 #define DBG(format, ...)
43 #endif
44
45 #define FB2OFB(fb_info) ((struct omapfb_info *)(fb_info->par))
46
47 /* max number of overlays to which a framebuffer data can be direct */
48 #define OMAPFB_MAX_OVL_PER_FB 3
49
50 struct omapfb2_mem_region {
51 int id;
52 u32 paddr;
53 void __iomem *vaddr;
54 struct vrfb vrfb;
55 unsigned long size;
56 u8 type; /* OMAPFB_PLANE_MEM_* */
57 bool alloc; /* allocated by the driver */
58 bool map; /* kernel mapped by the driver */
59 atomic_t map_count;
60 struct rw_semaphore lock;
61 atomic_t lock_count;
62 };
63
64 /* appended to fb_info */
65 struct omapfb_info {
66 int id;
67 struct omapfb2_mem_region *region;
68 int num_overlays;
69 struct omap_overlay *overlays[OMAPFB_MAX_OVL_PER_FB];
70 struct omapfb2_device *fbdev;
71 enum omap_dss_rotation_type rotation_type;
72 u8 rotation[OMAPFB_MAX_OVL_PER_FB];
73 bool mirror;
74 };
75
76 struct omapfb2_device {
77 struct device *dev;
78 struct mutex mtx;
79
80 u32 pseudo_palette[17];
81
82 int state;
83
84 unsigned num_fbs;
85 struct fb_info *fbs[10];
86 struct omapfb2_mem_region regions[10];
87
88 unsigned num_displays;
89 struct omap_dss_device *displays[10];
90 unsigned num_overlays;
91 struct omap_overlay *overlays[10];
92 unsigned num_managers;
93 struct omap_overlay_manager *managers[10];
94
95 unsigned num_bpp_overrides;
96 struct {
97 struct omap_dss_device *dssdev;
98 u8 bpp;
99 } bpp_overrides[10];
100 };
101
102 struct omapfb_colormode {
103 enum omap_color_mode dssmode;
104 u32 bits_per_pixel;
105 u32 nonstd;
106 struct fb_bitfield red;
107 struct fb_bitfield green;
108 struct fb_bitfield blue;
109 struct fb_bitfield transp;
110 };
111
112 void set_fb_fix(struct fb_info *fbi);
113 int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var);
114 int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type);
115 int omapfb_apply_changes(struct fb_info *fbi, int init);
116
117 int omapfb_create_sysfs(struct omapfb2_device *fbdev);
118 void omapfb_remove_sysfs(struct omapfb2_device *fbdev);
119
120 int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg);
121
122 int omapfb_update_window(struct fb_info *fbi,
123 u32 x, u32 y, u32 w, u32 h);
124
125 int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
126 struct fb_var_screeninfo *var);
127
128 int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
129 u16 posx, u16 posy, u16 outw, u16 outh);
130
131 /* find the display connected to this fb, if any */
132 static inline struct omap_dss_device *fb2display(struct fb_info *fbi)
133 {
134 struct omapfb_info *ofbi = FB2OFB(fbi);
135 int i;
136
137 /* XXX: returns the display connected to first attached overlay */
138 for (i = 0; i < ofbi->num_overlays; i++) {
139 if (ofbi->overlays[i]->manager)
140 return ofbi->overlays[i]->manager->device;
141 }
142
143 return NULL;
144 }
145
146 static inline void omapfb_lock(struct omapfb2_device *fbdev)
147 {
148 mutex_lock(&fbdev->mtx);
149 }
150
151 static inline void omapfb_unlock(struct omapfb2_device *fbdev)
152 {
153 mutex_unlock(&fbdev->mtx);
154 }
155
156 static inline int omapfb_overlay_enable(struct omap_overlay *ovl,
157 int enable)
158 {
159 struct omap_overlay_info info;
160
161 ovl->get_overlay_info(ovl, &info);
162 if (info.enabled == enable)
163 return 0;
164 info.enabled = enable;
165 return ovl->set_overlay_info(ovl, &info);
166 }
167
168 static inline struct omapfb2_mem_region *
169 omapfb_get_mem_region(struct omapfb2_mem_region *rg)
170 {
171 down_read_nested(&rg->lock, rg->id);
172 atomic_inc(&rg->lock_count);
173 return rg;
174 }
175
176 static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg)
177 {
178 atomic_dec(&rg->lock_count);
179 up_read(&rg->lock);
180 }
181
182 #endif
This page took 0.054524 seconds and 5 git commands to generate.