Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
omapfb.h
Go to the documentation of this file.
1 /*
2  * linux/drivers/video/omap2/omapfb.h
3  *
4  * Copyright (C) 2008 Nokia Corporation
5  * Author: Tomi Valkeinen <[email protected]>
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 bool 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 
51  int id;
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 */
62 };
63 
64 /* appended to fb_info */
65 struct omapfb_info {
66  int id;
73  bool mirror;
74 };
75 
83 };
84 
86  struct device *dev;
87  struct mutex mtx;
88 
90 
91  int state;
92 
93  unsigned num_fbs;
94  struct fb_info *fbs[10];
96 
97  unsigned num_displays;
99  unsigned num_overlays;
100  struct omap_overlay *overlays[10];
101  unsigned num_managers;
103 
105 };
106 
111  struct fb_bitfield red;
115 };
116 
117 void set_fb_fix(struct fb_info *fbi);
118 int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var);
119 int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type);
120 int omapfb_apply_changes(struct fb_info *fbi, int init);
121 
124 
125 int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg);
126 
127 int omapfb_update_window(struct fb_info *fbi,
128  u32 x, u32 y, u32 w, u32 h);
129 
130 int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
131  struct fb_var_screeninfo *var);
132 
133 int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
134  u16 posx, u16 posy, u16 outw, u16 outh);
135 
137  struct omap_dss_device *display);
139  struct omap_dss_device *display);
140 int omapfb_get_update_mode(struct fb_info *fbi, enum omapfb_update_mode *mode);
142 
143 /* find the display connected to this fb, if any */
144 static inline struct omap_dss_device *fb2display(struct fb_info *fbi)
145 {
146  struct omapfb_info *ofbi = FB2OFB(fbi);
147  int i;
148 
149  /* XXX: returns the display connected to first attached overlay */
150  for (i = 0; i < ofbi->num_overlays; i++) {
151  struct omap_overlay *ovl = ofbi->overlays[i];
152 
153  return ovl->get_device(ovl);
154  }
155 
156  return NULL;
157 }
158 
159 static inline struct omapfb_display_data *get_display_data(
160  struct omapfb2_device *fbdev, struct omap_dss_device *dssdev)
161 {
162  int i;
163 
164  for (i = 0; i < fbdev->num_displays; ++i)
165  if (fbdev->displays[i].dssdev == dssdev)
166  return &fbdev->displays[i];
167 
168  /* This should never happen */
169  BUG();
170  return NULL;
171 }
172 
173 static inline void omapfb_lock(struct omapfb2_device *fbdev)
174 {
175  mutex_lock(&fbdev->mtx);
176 }
177 
178 static inline void omapfb_unlock(struct omapfb2_device *fbdev)
179 {
180  mutex_unlock(&fbdev->mtx);
181 }
182 
183 static inline int omapfb_overlay_enable(struct omap_overlay *ovl,
184  int enable)
185 {
186  if (enable)
187  return ovl->enable(ovl);
188  else
189  return ovl->disable(ovl);
190 }
191 
192 static inline struct omapfb2_mem_region *
193 omapfb_get_mem_region(struct omapfb2_mem_region *rg)
194 {
195  down_read_nested(&rg->lock, rg->id);
196  atomic_inc(&rg->lock_count);
197  return rg;
198 }
199 
200 static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg)
201 {
202  atomic_dec(&rg->lock_count);
203  up_read(&rg->lock);
204 }
205 
206 #endif