blob: c9866be0460a1afbe7a150f53284c457f11a8dbd [file] [log] [blame]
Tomi Valkeinenb39a982d2009-08-04 16:12:50 +03001/*
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 <plat/display.h>
31
32#ifdef DEBUG
33extern unsigned int omapfb_debug;
34#define DBG(format, ...) \
35 if (omapfb_debug) \
36 printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__)
37#else
38#define DBG(format, ...)
39#endif
40
41#define FB2OFB(fb_info) ((struct omapfb_info *)(fb_info->par))
42
43/* max number of overlays to which a framebuffer data can be direct */
44#define OMAPFB_MAX_OVL_PER_FB 3
45
46struct omapfb2_mem_region {
47 u32 paddr;
48 void __iomem *vaddr;
49 struct vrfb vrfb;
50 unsigned long size;
51 u8 type; /* OMAPFB_PLANE_MEM_* */
52 bool alloc; /* allocated by the driver */
53 bool map; /* kernel mapped by the driver */
54};
55
56/* appended to fb_info */
57struct omapfb_info {
58 int id;
59 struct omapfb2_mem_region region;
60 atomic_t map_count;
61 int num_overlays;
62 struct omap_overlay *overlays[OMAPFB_MAX_OVL_PER_FB];
63 struct omapfb2_device *fbdev;
64 enum omap_dss_rotation_type rotation_type;
65 u8 rotation[OMAPFB_MAX_OVL_PER_FB];
66 bool mirror;
67};
68
69struct omapfb2_device {
70 struct device *dev;
71 struct mutex mtx;
72
73 u32 pseudo_palette[17];
74
75 int state;
76
77 unsigned num_fbs;
78 struct fb_info *fbs[10];
79
80 unsigned num_displays;
81 struct omap_dss_device *displays[10];
82 unsigned num_overlays;
83 struct omap_overlay *overlays[10];
84 unsigned num_managers;
85 struct omap_overlay_manager *managers[10];
Tomi Valkeinena2699502010-01-11 14:33:40 +020086
87 unsigned num_bpp_overrides;
88 struct {
89 struct omap_dss_device *dssdev;
90 u8 bpp;
91 } bpp_overrides[10];
Tomi Valkeinenb39a982d2009-08-04 16:12:50 +030092};
93
94struct omapfb_colormode {
95 enum omap_color_mode dssmode;
96 u32 bits_per_pixel;
97 u32 nonstd;
98 struct fb_bitfield red;
99 struct fb_bitfield green;
100 struct fb_bitfield blue;
101 struct fb_bitfield transp;
102};
103
104void set_fb_fix(struct fb_info *fbi);
105int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var);
106int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type);
107int omapfb_apply_changes(struct fb_info *fbi, int init);
108
109int omapfb_create_sysfs(struct omapfb2_device *fbdev);
110void omapfb_remove_sysfs(struct omapfb2_device *fbdev);
111
112int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg);
113
Tomi Valkeinenb63c97f52010-02-05 14:46:19 +0200114int omapfb_update_window(struct fb_info *fbi,
115 u32 x, u32 y, u32 w, u32 h);
116
Tomi Valkeinenb39a982d2009-08-04 16:12:50 +0300117int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
118 struct fb_var_screeninfo *var);
119
120/* find the display connected to this fb, if any */
121static inline struct omap_dss_device *fb2display(struct fb_info *fbi)
122{
123 struct omapfb_info *ofbi = FB2OFB(fbi);
124 int i;
125
126 /* XXX: returns the display connected to first attached overlay */
127 for (i = 0; i < ofbi->num_overlays; i++) {
128 if (ofbi->overlays[i]->manager)
129 return ofbi->overlays[i]->manager->device;
130 }
131
132 return NULL;
133}
134
135static inline void omapfb_lock(struct omapfb2_device *fbdev)
136{
137 mutex_lock(&fbdev->mtx);
138}
139
140static inline void omapfb_unlock(struct omapfb2_device *fbdev)
141{
142 mutex_unlock(&fbdev->mtx);
143}
144
145static inline int omapfb_overlay_enable(struct omap_overlay *ovl,
146 int enable)
147{
148 struct omap_overlay_info info;
149
150 ovl->get_overlay_info(ovl, &info);
Ville Syrjälä2ad0c502010-03-17 20:13:44 +0200151 if (info.enabled == enable)
152 return 0;
Tomi Valkeinenb39a982d2009-08-04 16:12:50 +0300153 info.enabled = enable;
154 return ovl->set_overlay_info(ovl, &info);
155}
156
157#endif