1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 <plat/display.h>
33
34#ifdef DEBUG
35extern unsigned int omapfb_debug;
36#define DBG(format, ...) \
37 if (omapfb_debug) \
38 printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__)
39#else
40#define DBG(format, ...)
41#endif
42
43#define FB2OFB(fb_info) ((struct omapfb_info *)(fb_info->par))
44
45
46#define OMAPFB_MAX_OVL_PER_FB 3
47
48struct omapfb2_mem_region {
49 int id;
50 u32 paddr;
51 void __iomem *vaddr;
52 struct vrfb vrfb;
53 unsigned long size;
54 u8 type;
55 bool alloc;
56 bool map;
57 atomic_t map_count;
58 struct rw_semaphore lock;
59 atomic_t lock_count;
60};
61
62
63struct omapfb_info {
64 int id;
65 struct omapfb2_mem_region *region;
66 int num_overlays;
67 struct omap_overlay *overlays[OMAPFB_MAX_OVL_PER_FB];
68 struct omapfb2_device *fbdev;
69 enum omap_dss_rotation_type rotation_type;
70 u8 rotation[OMAPFB_MAX_OVL_PER_FB];
71 bool mirror;
72};
73
74struct omapfb2_device {
75 struct device *dev;
76 struct mutex mtx;
77
78 u32 pseudo_palette[17];
79
80 int state;
81
82 unsigned num_fbs;
83 struct fb_info *fbs[10];
84 struct omapfb2_mem_region regions[10];
85
86 unsigned num_displays;
87 struct omap_dss_device *displays[10];
88 unsigned num_overlays;
89 struct omap_overlay *overlays[10];
90 unsigned num_managers;
91 struct omap_overlay_manager *managers[10];
92
93 unsigned num_bpp_overrides;
94 struct {
95 struct omap_dss_device *dssdev;
96 u8 bpp;
97 } bpp_overrides[10];
98};
99
100struct omapfb_colormode {
101 enum omap_color_mode dssmode;
102 u32 bits_per_pixel;
103 u32 nonstd;
104 struct fb_bitfield red;
105 struct fb_bitfield green;
106 struct fb_bitfield blue;
107 struct fb_bitfield transp;
108};
109
110void set_fb_fix(struct fb_info *fbi);
111int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var);
112int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type);
113int omapfb_apply_changes(struct fb_info *fbi, int init);
114
115int omapfb_create_sysfs(struct omapfb2_device *fbdev);
116void omapfb_remove_sysfs(struct omapfb2_device *fbdev);
117
118int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg);
119
120int omapfb_update_window(struct fb_info *fbi,
121 u32 x, u32 y, u32 w, u32 h);
122
123int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
124 struct fb_var_screeninfo *var);
125
126int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
127 u16 posx, u16 posy, u16 outw, u16 outh);
128
129
130static inline struct omap_dss_device *fb2display(struct fb_info *fbi)
131{
132 struct omapfb_info *ofbi = FB2OFB(fbi);
133 int i;
134
135
136 for (i = 0; i < ofbi->num_overlays; i++) {
137 if (ofbi->overlays[i]->manager)
138 return ofbi->overlays[i]->manager->device;
139 }
140
141 return NULL;
142}
143
144static inline void omapfb_lock(struct omapfb2_device *fbdev)
145{
146 mutex_lock(&fbdev->mtx);
147}
148
149static inline void omapfb_unlock(struct omapfb2_device *fbdev)
150{
151 mutex_unlock(&fbdev->mtx);
152}
153
154static inline int omapfb_overlay_enable(struct omap_overlay *ovl,
155 int enable)
156{
157 struct omap_overlay_info info;
158
159 ovl->get_overlay_info(ovl, &info);
160 if (info.enabled == enable)
161 return 0;
162 info.enabled = enable;
163 return ovl->set_overlay_info(ovl, &info);
164}
165
166static inline struct omapfb2_mem_region *
167omapfb_get_mem_region(struct omapfb2_mem_region *rg)
168{
169 down_read_nested(&rg->lock, rg->id);
170 atomic_inc(&rg->lock_count);
171 return rg;
172}
173
174static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg)
175{
176 atomic_dec(&rg->lock_count);
177 up_read(&rg->lock);
178}
179
180#endif
181