Commit d31c3a81893e3416ea519d1b1383f319c046641f
Committed by
Tomi Valkeinen
1 parent
a937536b86
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
omapfb: fix broken build on OMAP1
Fix the following build regression in 3.9-rc1 by including <mach/hardware.h>: drivers/video/omap/omapfb_main.c: In function 'set_fb_var': drivers/video/omap/omapfb_main.c:505:3: error: implicit declaration of function 'cpu_is_omap15xx' [-Werror=implicit-function-declaration] Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Showing 1 changed file with 2 additions and 0 deletions Inline Diff
drivers/video/omap/omapfb_main.c
1 | /* | 1 | /* |
2 | * Framebuffer driver for TI OMAP boards | 2 | * Framebuffer driver for TI OMAP boards |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Nokia Corporation | 4 | * Copyright (C) 2004 Nokia Corporation |
5 | * Author: Imre Deak <imre.deak@nokia.com> | 5 | * Author: Imre Deak <imre.deak@nokia.com> |
6 | * | 6 | * |
7 | * Acknowledgements: | 7 | * Acknowledgements: |
8 | * Alex McMains <aam@ridgerun.com> - Original driver | 8 | * Alex McMains <aam@ridgerun.com> - Original driver |
9 | * Juha Yrjola <juha.yrjola@nokia.com> - Original driver and improvements | 9 | * Juha Yrjola <juha.yrjola@nokia.com> - Original driver and improvements |
10 | * Dirk Behme <dirk.behme@de.bosch.com> - changes for 2.6 kernel API | 10 | * Dirk Behme <dirk.behme@de.bosch.com> - changes for 2.6 kernel API |
11 | * Texas Instruments - H3 support | 11 | * Texas Instruments - H3 support |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or modify it | 13 | * This program is free software; you can redistribute it and/or modify it |
14 | * under the terms of the GNU General Public License as published by the | 14 | * under the terms of the GNU General Public License as published by the |
15 | * Free Software Foundation; either version 2 of the License, or (at your | 15 | * Free Software Foundation; either version 2 of the License, or (at your |
16 | * option) any later version. | 16 | * option) any later version. |
17 | * | 17 | * |
18 | * This program is distributed in the hope that it will be useful, but | 18 | * This program is distributed in the hope that it will be useful, but |
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 | * General Public License for more details. | 21 | * General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU General Public License along | 23 | * You should have received a copy of the GNU General Public License along |
24 | * with this program; if not, write to the Free Software Foundation, Inc., | 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
25 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 25 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
26 | */ | 26 | */ |
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/uaccess.h> | 30 | #include <linux/uaccess.h> |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | 32 | ||
33 | #include <linux/omap-dma.h> | 33 | #include <linux/omap-dma.h> |
34 | 34 | ||
35 | #include <mach/hardware.h> | ||
36 | |||
35 | #include "omapfb.h" | 37 | #include "omapfb.h" |
36 | #include "lcdc.h" | 38 | #include "lcdc.h" |
37 | 39 | ||
38 | #define MODULE_NAME "omapfb" | 40 | #define MODULE_NAME "omapfb" |
39 | 41 | ||
40 | static unsigned int def_accel; | 42 | static unsigned int def_accel; |
41 | static unsigned long def_vram[OMAPFB_PLANE_NUM]; | 43 | static unsigned long def_vram[OMAPFB_PLANE_NUM]; |
42 | static unsigned int def_vram_cnt; | 44 | static unsigned int def_vram_cnt; |
43 | static unsigned long def_vxres; | 45 | static unsigned long def_vxres; |
44 | static unsigned long def_vyres; | 46 | static unsigned long def_vyres; |
45 | static unsigned int def_rotate; | 47 | static unsigned int def_rotate; |
46 | static unsigned int def_mirror; | 48 | static unsigned int def_mirror; |
47 | 49 | ||
48 | #ifdef CONFIG_FB_OMAP_MANUAL_UPDATE | 50 | #ifdef CONFIG_FB_OMAP_MANUAL_UPDATE |
49 | static bool manual_update = 1; | 51 | static bool manual_update = 1; |
50 | #else | 52 | #else |
51 | static bool manual_update; | 53 | static bool manual_update; |
52 | #endif | 54 | #endif |
53 | 55 | ||
54 | static struct platform_device *fbdev_pdev; | 56 | static struct platform_device *fbdev_pdev; |
55 | static struct lcd_panel *fbdev_panel; | 57 | static struct lcd_panel *fbdev_panel; |
56 | static struct omapfb_device *omapfb_dev; | 58 | static struct omapfb_device *omapfb_dev; |
57 | 59 | ||
58 | struct caps_table_struct { | 60 | struct caps_table_struct { |
59 | unsigned long flag; | 61 | unsigned long flag; |
60 | const char *name; | 62 | const char *name; |
61 | }; | 63 | }; |
62 | 64 | ||
63 | static struct caps_table_struct ctrl_caps[] = { | 65 | static struct caps_table_struct ctrl_caps[] = { |
64 | { OMAPFB_CAPS_MANUAL_UPDATE, "manual update" }, | 66 | { OMAPFB_CAPS_MANUAL_UPDATE, "manual update" }, |
65 | { OMAPFB_CAPS_TEARSYNC, "tearing synchronization" }, | 67 | { OMAPFB_CAPS_TEARSYNC, "tearing synchronization" }, |
66 | { OMAPFB_CAPS_PLANE_RELOCATE_MEM, "relocate plane memory" }, | 68 | { OMAPFB_CAPS_PLANE_RELOCATE_MEM, "relocate plane memory" }, |
67 | { OMAPFB_CAPS_PLANE_SCALE, "scale plane" }, | 69 | { OMAPFB_CAPS_PLANE_SCALE, "scale plane" }, |
68 | { OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE, "pixel double window" }, | 70 | { OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE, "pixel double window" }, |
69 | { OMAPFB_CAPS_WINDOW_SCALE, "scale window" }, | 71 | { OMAPFB_CAPS_WINDOW_SCALE, "scale window" }, |
70 | { OMAPFB_CAPS_WINDOW_OVERLAY, "overlay window" }, | 72 | { OMAPFB_CAPS_WINDOW_OVERLAY, "overlay window" }, |
71 | { OMAPFB_CAPS_WINDOW_ROTATE, "rotate window" }, | 73 | { OMAPFB_CAPS_WINDOW_ROTATE, "rotate window" }, |
72 | { OMAPFB_CAPS_SET_BACKLIGHT, "backlight setting" }, | 74 | { OMAPFB_CAPS_SET_BACKLIGHT, "backlight setting" }, |
73 | }; | 75 | }; |
74 | 76 | ||
75 | static struct caps_table_struct color_caps[] = { | 77 | static struct caps_table_struct color_caps[] = { |
76 | { 1 << OMAPFB_COLOR_RGB565, "RGB565", }, | 78 | { 1 << OMAPFB_COLOR_RGB565, "RGB565", }, |
77 | { 1 << OMAPFB_COLOR_YUV422, "YUV422", }, | 79 | { 1 << OMAPFB_COLOR_YUV422, "YUV422", }, |
78 | { 1 << OMAPFB_COLOR_YUV420, "YUV420", }, | 80 | { 1 << OMAPFB_COLOR_YUV420, "YUV420", }, |
79 | { 1 << OMAPFB_COLOR_CLUT_8BPP, "CLUT8", }, | 81 | { 1 << OMAPFB_COLOR_CLUT_8BPP, "CLUT8", }, |
80 | { 1 << OMAPFB_COLOR_CLUT_4BPP, "CLUT4", }, | 82 | { 1 << OMAPFB_COLOR_CLUT_4BPP, "CLUT4", }, |
81 | { 1 << OMAPFB_COLOR_CLUT_2BPP, "CLUT2", }, | 83 | { 1 << OMAPFB_COLOR_CLUT_2BPP, "CLUT2", }, |
82 | { 1 << OMAPFB_COLOR_CLUT_1BPP, "CLUT1", }, | 84 | { 1 << OMAPFB_COLOR_CLUT_1BPP, "CLUT1", }, |
83 | { 1 << OMAPFB_COLOR_RGB444, "RGB444", }, | 85 | { 1 << OMAPFB_COLOR_RGB444, "RGB444", }, |
84 | { 1 << OMAPFB_COLOR_YUY422, "YUY422", }, | 86 | { 1 << OMAPFB_COLOR_YUY422, "YUY422", }, |
85 | }; | 87 | }; |
86 | 88 | ||
87 | static void omapdss_release(struct device *dev) | 89 | static void omapdss_release(struct device *dev) |
88 | { | 90 | { |
89 | } | 91 | } |
90 | 92 | ||
91 | /* dummy device for clocks */ | 93 | /* dummy device for clocks */ |
92 | static struct platform_device omapdss_device = { | 94 | static struct platform_device omapdss_device = { |
93 | .name = "omapdss_dss", | 95 | .name = "omapdss_dss", |
94 | .id = -1, | 96 | .id = -1, |
95 | .dev = { | 97 | .dev = { |
96 | .release = omapdss_release, | 98 | .release = omapdss_release, |
97 | }, | 99 | }, |
98 | }; | 100 | }; |
99 | 101 | ||
100 | /* | 102 | /* |
101 | * --------------------------------------------------------------------------- | 103 | * --------------------------------------------------------------------------- |
102 | * LCD panel | 104 | * LCD panel |
103 | * --------------------------------------------------------------------------- | 105 | * --------------------------------------------------------------------------- |
104 | */ | 106 | */ |
105 | extern struct lcd_ctrl hwa742_ctrl; | 107 | extern struct lcd_ctrl hwa742_ctrl; |
106 | 108 | ||
107 | static const struct lcd_ctrl *ctrls[] = { | 109 | static const struct lcd_ctrl *ctrls[] = { |
108 | &omap1_int_ctrl, | 110 | &omap1_int_ctrl, |
109 | 111 | ||
110 | #ifdef CONFIG_FB_OMAP_LCDC_HWA742 | 112 | #ifdef CONFIG_FB_OMAP_LCDC_HWA742 |
111 | &hwa742_ctrl, | 113 | &hwa742_ctrl, |
112 | #endif | 114 | #endif |
113 | }; | 115 | }; |
114 | 116 | ||
115 | #ifdef CONFIG_FB_OMAP_LCDC_EXTERNAL | 117 | #ifdef CONFIG_FB_OMAP_LCDC_EXTERNAL |
116 | extern struct lcd_ctrl_extif omap1_ext_if; | 118 | extern struct lcd_ctrl_extif omap1_ext_if; |
117 | #endif | 119 | #endif |
118 | 120 | ||
119 | static void omapfb_rqueue_lock(struct omapfb_device *fbdev) | 121 | static void omapfb_rqueue_lock(struct omapfb_device *fbdev) |
120 | { | 122 | { |
121 | mutex_lock(&fbdev->rqueue_mutex); | 123 | mutex_lock(&fbdev->rqueue_mutex); |
122 | } | 124 | } |
123 | 125 | ||
124 | static void omapfb_rqueue_unlock(struct omapfb_device *fbdev) | 126 | static void omapfb_rqueue_unlock(struct omapfb_device *fbdev) |
125 | { | 127 | { |
126 | mutex_unlock(&fbdev->rqueue_mutex); | 128 | mutex_unlock(&fbdev->rqueue_mutex); |
127 | } | 129 | } |
128 | 130 | ||
129 | /* | 131 | /* |
130 | * --------------------------------------------------------------------------- | 132 | * --------------------------------------------------------------------------- |
131 | * LCD controller and LCD DMA | 133 | * LCD controller and LCD DMA |
132 | * --------------------------------------------------------------------------- | 134 | * --------------------------------------------------------------------------- |
133 | */ | 135 | */ |
134 | /* | 136 | /* |
135 | * Allocate resources needed for LCD controller and LCD DMA operations. Video | 137 | * Allocate resources needed for LCD controller and LCD DMA operations. Video |
136 | * memory is allocated from system memory according to the virtual display | 138 | * memory is allocated from system memory according to the virtual display |
137 | * size, except if a bigger memory size is specified explicitly as a kernel | 139 | * size, except if a bigger memory size is specified explicitly as a kernel |
138 | * parameter. | 140 | * parameter. |
139 | */ | 141 | */ |
140 | static int ctrl_init(struct omapfb_device *fbdev) | 142 | static int ctrl_init(struct omapfb_device *fbdev) |
141 | { | 143 | { |
142 | int r; | 144 | int r; |
143 | int i; | 145 | int i; |
144 | 146 | ||
145 | /* kernel/module vram parameters override boot tags/board config */ | 147 | /* kernel/module vram parameters override boot tags/board config */ |
146 | if (def_vram_cnt) { | 148 | if (def_vram_cnt) { |
147 | for (i = 0; i < def_vram_cnt; i++) | 149 | for (i = 0; i < def_vram_cnt; i++) |
148 | fbdev->mem_desc.region[i].size = | 150 | fbdev->mem_desc.region[i].size = |
149 | PAGE_ALIGN(def_vram[i]); | 151 | PAGE_ALIGN(def_vram[i]); |
150 | fbdev->mem_desc.region_cnt = i; | 152 | fbdev->mem_desc.region_cnt = i; |
151 | } | 153 | } |
152 | 154 | ||
153 | if (!fbdev->mem_desc.region_cnt) { | 155 | if (!fbdev->mem_desc.region_cnt) { |
154 | struct lcd_panel *panel = fbdev->panel; | 156 | struct lcd_panel *panel = fbdev->panel; |
155 | int def_size; | 157 | int def_size; |
156 | int bpp = panel->bpp; | 158 | int bpp = panel->bpp; |
157 | 159 | ||
158 | /* 12 bpp is packed in 16 bits */ | 160 | /* 12 bpp is packed in 16 bits */ |
159 | if (bpp == 12) | 161 | if (bpp == 12) |
160 | bpp = 16; | 162 | bpp = 16; |
161 | def_size = def_vxres * def_vyres * bpp / 8; | 163 | def_size = def_vxres * def_vyres * bpp / 8; |
162 | fbdev->mem_desc.region_cnt = 1; | 164 | fbdev->mem_desc.region_cnt = 1; |
163 | fbdev->mem_desc.region[0].size = PAGE_ALIGN(def_size); | 165 | fbdev->mem_desc.region[0].size = PAGE_ALIGN(def_size); |
164 | } | 166 | } |
165 | r = fbdev->ctrl->init(fbdev, 0, &fbdev->mem_desc); | 167 | r = fbdev->ctrl->init(fbdev, 0, &fbdev->mem_desc); |
166 | if (r < 0) { | 168 | if (r < 0) { |
167 | dev_err(fbdev->dev, "controller initialization failed (%d)\n", | 169 | dev_err(fbdev->dev, "controller initialization failed (%d)\n", |
168 | r); | 170 | r); |
169 | return r; | 171 | return r; |
170 | } | 172 | } |
171 | 173 | ||
172 | #ifdef DEBUG | 174 | #ifdef DEBUG |
173 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { | 175 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { |
174 | dev_dbg(fbdev->dev, "region%d phys %08x virt %p size=%lu\n", | 176 | dev_dbg(fbdev->dev, "region%d phys %08x virt %p size=%lu\n", |
175 | i, | 177 | i, |
176 | fbdev->mem_desc.region[i].paddr, | 178 | fbdev->mem_desc.region[i].paddr, |
177 | fbdev->mem_desc.region[i].vaddr, | 179 | fbdev->mem_desc.region[i].vaddr, |
178 | fbdev->mem_desc.region[i].size); | 180 | fbdev->mem_desc.region[i].size); |
179 | } | 181 | } |
180 | #endif | 182 | #endif |
181 | return 0; | 183 | return 0; |
182 | } | 184 | } |
183 | 185 | ||
184 | static void ctrl_cleanup(struct omapfb_device *fbdev) | 186 | static void ctrl_cleanup(struct omapfb_device *fbdev) |
185 | { | 187 | { |
186 | fbdev->ctrl->cleanup(); | 188 | fbdev->ctrl->cleanup(); |
187 | } | 189 | } |
188 | 190 | ||
189 | /* Must be called with fbdev->rqueue_mutex held. */ | 191 | /* Must be called with fbdev->rqueue_mutex held. */ |
190 | static int ctrl_change_mode(struct fb_info *fbi) | 192 | static int ctrl_change_mode(struct fb_info *fbi) |
191 | { | 193 | { |
192 | int r; | 194 | int r; |
193 | unsigned long offset; | 195 | unsigned long offset; |
194 | struct omapfb_plane_struct *plane = fbi->par; | 196 | struct omapfb_plane_struct *plane = fbi->par; |
195 | struct omapfb_device *fbdev = plane->fbdev; | 197 | struct omapfb_device *fbdev = plane->fbdev; |
196 | struct fb_var_screeninfo *var = &fbi->var; | 198 | struct fb_var_screeninfo *var = &fbi->var; |
197 | 199 | ||
198 | offset = var->yoffset * fbi->fix.line_length + | 200 | offset = var->yoffset * fbi->fix.line_length + |
199 | var->xoffset * var->bits_per_pixel / 8; | 201 | var->xoffset * var->bits_per_pixel / 8; |
200 | 202 | ||
201 | if (fbdev->ctrl->sync) | 203 | if (fbdev->ctrl->sync) |
202 | fbdev->ctrl->sync(); | 204 | fbdev->ctrl->sync(); |
203 | r = fbdev->ctrl->setup_plane(plane->idx, plane->info.channel_out, | 205 | r = fbdev->ctrl->setup_plane(plane->idx, plane->info.channel_out, |
204 | offset, var->xres_virtual, | 206 | offset, var->xres_virtual, |
205 | plane->info.pos_x, plane->info.pos_y, | 207 | plane->info.pos_x, plane->info.pos_y, |
206 | var->xres, var->yres, plane->color_mode); | 208 | var->xres, var->yres, plane->color_mode); |
207 | if (r < 0) | 209 | if (r < 0) |
208 | return r; | 210 | return r; |
209 | 211 | ||
210 | if (fbdev->ctrl->set_rotate != NULL) { | 212 | if (fbdev->ctrl->set_rotate != NULL) { |
211 | r = fbdev->ctrl->set_rotate(var->rotate); | 213 | r = fbdev->ctrl->set_rotate(var->rotate); |
212 | if (r < 0) | 214 | if (r < 0) |
213 | return r; | 215 | return r; |
214 | } | 216 | } |
215 | 217 | ||
216 | if (fbdev->ctrl->set_scale != NULL) | 218 | if (fbdev->ctrl->set_scale != NULL) |
217 | r = fbdev->ctrl->set_scale(plane->idx, | 219 | r = fbdev->ctrl->set_scale(plane->idx, |
218 | var->xres, var->yres, | 220 | var->xres, var->yres, |
219 | plane->info.out_width, | 221 | plane->info.out_width, |
220 | plane->info.out_height); | 222 | plane->info.out_height); |
221 | 223 | ||
222 | return r; | 224 | return r; |
223 | } | 225 | } |
224 | 226 | ||
225 | /* | 227 | /* |
226 | * --------------------------------------------------------------------------- | 228 | * --------------------------------------------------------------------------- |
227 | * fbdev framework callbacks and the ioctl interface | 229 | * fbdev framework callbacks and the ioctl interface |
228 | * --------------------------------------------------------------------------- | 230 | * --------------------------------------------------------------------------- |
229 | */ | 231 | */ |
230 | /* Called each time the omapfb device is opened */ | 232 | /* Called each time the omapfb device is opened */ |
231 | static int omapfb_open(struct fb_info *info, int user) | 233 | static int omapfb_open(struct fb_info *info, int user) |
232 | { | 234 | { |
233 | return 0; | 235 | return 0; |
234 | } | 236 | } |
235 | 237 | ||
236 | static void omapfb_sync(struct fb_info *info); | 238 | static void omapfb_sync(struct fb_info *info); |
237 | 239 | ||
238 | /* Called when the omapfb device is closed. We make sure that any pending | 240 | /* Called when the omapfb device is closed. We make sure that any pending |
239 | * gfx DMA operations are ended, before we return. */ | 241 | * gfx DMA operations are ended, before we return. */ |
240 | static int omapfb_release(struct fb_info *info, int user) | 242 | static int omapfb_release(struct fb_info *info, int user) |
241 | { | 243 | { |
242 | omapfb_sync(info); | 244 | omapfb_sync(info); |
243 | return 0; | 245 | return 0; |
244 | } | 246 | } |
245 | 247 | ||
246 | /* Store a single color palette entry into a pseudo palette or the hardware | 248 | /* Store a single color palette entry into a pseudo palette or the hardware |
247 | * palette if one is available. For now we support only 16bpp and thus store | 249 | * palette if one is available. For now we support only 16bpp and thus store |
248 | * the entry only to the pseudo palette. | 250 | * the entry only to the pseudo palette. |
249 | */ | 251 | */ |
250 | static int _setcolreg(struct fb_info *info, u_int regno, u_int red, u_int green, | 252 | static int _setcolreg(struct fb_info *info, u_int regno, u_int red, u_int green, |
251 | u_int blue, u_int transp, int update_hw_pal) | 253 | u_int blue, u_int transp, int update_hw_pal) |
252 | { | 254 | { |
253 | struct omapfb_plane_struct *plane = info->par; | 255 | struct omapfb_plane_struct *plane = info->par; |
254 | struct omapfb_device *fbdev = plane->fbdev; | 256 | struct omapfb_device *fbdev = plane->fbdev; |
255 | struct fb_var_screeninfo *var = &info->var; | 257 | struct fb_var_screeninfo *var = &info->var; |
256 | int r = 0; | 258 | int r = 0; |
257 | 259 | ||
258 | switch (plane->color_mode) { | 260 | switch (plane->color_mode) { |
259 | case OMAPFB_COLOR_YUV422: | 261 | case OMAPFB_COLOR_YUV422: |
260 | case OMAPFB_COLOR_YUV420: | 262 | case OMAPFB_COLOR_YUV420: |
261 | case OMAPFB_COLOR_YUY422: | 263 | case OMAPFB_COLOR_YUY422: |
262 | r = -EINVAL; | 264 | r = -EINVAL; |
263 | break; | 265 | break; |
264 | case OMAPFB_COLOR_CLUT_8BPP: | 266 | case OMAPFB_COLOR_CLUT_8BPP: |
265 | case OMAPFB_COLOR_CLUT_4BPP: | 267 | case OMAPFB_COLOR_CLUT_4BPP: |
266 | case OMAPFB_COLOR_CLUT_2BPP: | 268 | case OMAPFB_COLOR_CLUT_2BPP: |
267 | case OMAPFB_COLOR_CLUT_1BPP: | 269 | case OMAPFB_COLOR_CLUT_1BPP: |
268 | if (fbdev->ctrl->setcolreg) | 270 | if (fbdev->ctrl->setcolreg) |
269 | r = fbdev->ctrl->setcolreg(regno, red, green, blue, | 271 | r = fbdev->ctrl->setcolreg(regno, red, green, blue, |
270 | transp, update_hw_pal); | 272 | transp, update_hw_pal); |
271 | /* Fallthrough */ | 273 | /* Fallthrough */ |
272 | case OMAPFB_COLOR_RGB565: | 274 | case OMAPFB_COLOR_RGB565: |
273 | case OMAPFB_COLOR_RGB444: | 275 | case OMAPFB_COLOR_RGB444: |
274 | if (r != 0) | 276 | if (r != 0) |
275 | break; | 277 | break; |
276 | 278 | ||
277 | if (regno < 0) { | 279 | if (regno < 0) { |
278 | r = -EINVAL; | 280 | r = -EINVAL; |
279 | break; | 281 | break; |
280 | } | 282 | } |
281 | 283 | ||
282 | if (regno < 16) { | 284 | if (regno < 16) { |
283 | u16 pal; | 285 | u16 pal; |
284 | pal = ((red >> (16 - var->red.length)) << | 286 | pal = ((red >> (16 - var->red.length)) << |
285 | var->red.offset) | | 287 | var->red.offset) | |
286 | ((green >> (16 - var->green.length)) << | 288 | ((green >> (16 - var->green.length)) << |
287 | var->green.offset) | | 289 | var->green.offset) | |
288 | (blue >> (16 - var->blue.length)); | 290 | (blue >> (16 - var->blue.length)); |
289 | ((u32 *)(info->pseudo_palette))[regno] = pal; | 291 | ((u32 *)(info->pseudo_palette))[regno] = pal; |
290 | } | 292 | } |
291 | break; | 293 | break; |
292 | default: | 294 | default: |
293 | BUG(); | 295 | BUG(); |
294 | } | 296 | } |
295 | return r; | 297 | return r; |
296 | } | 298 | } |
297 | 299 | ||
298 | static int omapfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | 300 | static int omapfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, |
299 | u_int transp, struct fb_info *info) | 301 | u_int transp, struct fb_info *info) |
300 | { | 302 | { |
301 | return _setcolreg(info, regno, red, green, blue, transp, 1); | 303 | return _setcolreg(info, regno, red, green, blue, transp, 1); |
302 | } | 304 | } |
303 | 305 | ||
304 | static int omapfb_setcmap(struct fb_cmap *cmap, struct fb_info *info) | 306 | static int omapfb_setcmap(struct fb_cmap *cmap, struct fb_info *info) |
305 | { | 307 | { |
306 | int count, index, r; | 308 | int count, index, r; |
307 | u16 *red, *green, *blue, *transp; | 309 | u16 *red, *green, *blue, *transp; |
308 | u16 trans = 0xffff; | 310 | u16 trans = 0xffff; |
309 | 311 | ||
310 | red = cmap->red; | 312 | red = cmap->red; |
311 | green = cmap->green; | 313 | green = cmap->green; |
312 | blue = cmap->blue; | 314 | blue = cmap->blue; |
313 | transp = cmap->transp; | 315 | transp = cmap->transp; |
314 | index = cmap->start; | 316 | index = cmap->start; |
315 | 317 | ||
316 | for (count = 0; count < cmap->len; count++) { | 318 | for (count = 0; count < cmap->len; count++) { |
317 | if (transp) | 319 | if (transp) |
318 | trans = *transp++; | 320 | trans = *transp++; |
319 | r = _setcolreg(info, index++, *red++, *green++, *blue++, trans, | 321 | r = _setcolreg(info, index++, *red++, *green++, *blue++, trans, |
320 | count == cmap->len - 1); | 322 | count == cmap->len - 1); |
321 | if (r != 0) | 323 | if (r != 0) |
322 | return r; | 324 | return r; |
323 | } | 325 | } |
324 | 326 | ||
325 | return 0; | 327 | return 0; |
326 | } | 328 | } |
327 | 329 | ||
328 | static int omapfb_update_full_screen(struct fb_info *fbi); | 330 | static int omapfb_update_full_screen(struct fb_info *fbi); |
329 | 331 | ||
330 | static int omapfb_blank(int blank, struct fb_info *fbi) | 332 | static int omapfb_blank(int blank, struct fb_info *fbi) |
331 | { | 333 | { |
332 | struct omapfb_plane_struct *plane = fbi->par; | 334 | struct omapfb_plane_struct *plane = fbi->par; |
333 | struct omapfb_device *fbdev = plane->fbdev; | 335 | struct omapfb_device *fbdev = plane->fbdev; |
334 | int do_update = 0; | 336 | int do_update = 0; |
335 | int r = 0; | 337 | int r = 0; |
336 | 338 | ||
337 | omapfb_rqueue_lock(fbdev); | 339 | omapfb_rqueue_lock(fbdev); |
338 | switch (blank) { | 340 | switch (blank) { |
339 | case FB_BLANK_UNBLANK: | 341 | case FB_BLANK_UNBLANK: |
340 | if (fbdev->state == OMAPFB_SUSPENDED) { | 342 | if (fbdev->state == OMAPFB_SUSPENDED) { |
341 | if (fbdev->ctrl->resume) | 343 | if (fbdev->ctrl->resume) |
342 | fbdev->ctrl->resume(); | 344 | fbdev->ctrl->resume(); |
343 | fbdev->panel->enable(fbdev->panel); | 345 | fbdev->panel->enable(fbdev->panel); |
344 | fbdev->state = OMAPFB_ACTIVE; | 346 | fbdev->state = OMAPFB_ACTIVE; |
345 | if (fbdev->ctrl->get_update_mode() == | 347 | if (fbdev->ctrl->get_update_mode() == |
346 | OMAPFB_MANUAL_UPDATE) | 348 | OMAPFB_MANUAL_UPDATE) |
347 | do_update = 1; | 349 | do_update = 1; |
348 | } | 350 | } |
349 | break; | 351 | break; |
350 | case FB_BLANK_POWERDOWN: | 352 | case FB_BLANK_POWERDOWN: |
351 | if (fbdev->state == OMAPFB_ACTIVE) { | 353 | if (fbdev->state == OMAPFB_ACTIVE) { |
352 | fbdev->panel->disable(fbdev->panel); | 354 | fbdev->panel->disable(fbdev->panel); |
353 | if (fbdev->ctrl->suspend) | 355 | if (fbdev->ctrl->suspend) |
354 | fbdev->ctrl->suspend(); | 356 | fbdev->ctrl->suspend(); |
355 | fbdev->state = OMAPFB_SUSPENDED; | 357 | fbdev->state = OMAPFB_SUSPENDED; |
356 | } | 358 | } |
357 | break; | 359 | break; |
358 | default: | 360 | default: |
359 | r = -EINVAL; | 361 | r = -EINVAL; |
360 | } | 362 | } |
361 | omapfb_rqueue_unlock(fbdev); | 363 | omapfb_rqueue_unlock(fbdev); |
362 | 364 | ||
363 | if (r == 0 && do_update) | 365 | if (r == 0 && do_update) |
364 | r = omapfb_update_full_screen(fbi); | 366 | r = omapfb_update_full_screen(fbi); |
365 | 367 | ||
366 | return r; | 368 | return r; |
367 | } | 369 | } |
368 | 370 | ||
369 | static void omapfb_sync(struct fb_info *fbi) | 371 | static void omapfb_sync(struct fb_info *fbi) |
370 | { | 372 | { |
371 | struct omapfb_plane_struct *plane = fbi->par; | 373 | struct omapfb_plane_struct *plane = fbi->par; |
372 | struct omapfb_device *fbdev = plane->fbdev; | 374 | struct omapfb_device *fbdev = plane->fbdev; |
373 | 375 | ||
374 | omapfb_rqueue_lock(fbdev); | 376 | omapfb_rqueue_lock(fbdev); |
375 | if (fbdev->ctrl->sync) | 377 | if (fbdev->ctrl->sync) |
376 | fbdev->ctrl->sync(); | 378 | fbdev->ctrl->sync(); |
377 | omapfb_rqueue_unlock(fbdev); | 379 | omapfb_rqueue_unlock(fbdev); |
378 | } | 380 | } |
379 | 381 | ||
380 | /* | 382 | /* |
381 | * Set fb_info.fix fields and also updates fbdev. | 383 | * Set fb_info.fix fields and also updates fbdev. |
382 | * When calling this fb_info.var must be set up already. | 384 | * When calling this fb_info.var must be set up already. |
383 | */ | 385 | */ |
384 | static void set_fb_fix(struct fb_info *fbi, int from_init) | 386 | static void set_fb_fix(struct fb_info *fbi, int from_init) |
385 | { | 387 | { |
386 | struct fb_fix_screeninfo *fix = &fbi->fix; | 388 | struct fb_fix_screeninfo *fix = &fbi->fix; |
387 | struct fb_var_screeninfo *var = &fbi->var; | 389 | struct fb_var_screeninfo *var = &fbi->var; |
388 | struct omapfb_plane_struct *plane = fbi->par; | 390 | struct omapfb_plane_struct *plane = fbi->par; |
389 | struct omapfb_mem_region *rg; | 391 | struct omapfb_mem_region *rg; |
390 | int bpp; | 392 | int bpp; |
391 | 393 | ||
392 | rg = &plane->fbdev->mem_desc.region[plane->idx]; | 394 | rg = &plane->fbdev->mem_desc.region[plane->idx]; |
393 | fbi->screen_base = rg->vaddr; | 395 | fbi->screen_base = rg->vaddr; |
394 | 396 | ||
395 | if (!from_init) { | 397 | if (!from_init) { |
396 | mutex_lock(&fbi->mm_lock); | 398 | mutex_lock(&fbi->mm_lock); |
397 | fix->smem_start = rg->paddr; | 399 | fix->smem_start = rg->paddr; |
398 | fix->smem_len = rg->size; | 400 | fix->smem_len = rg->size; |
399 | mutex_unlock(&fbi->mm_lock); | 401 | mutex_unlock(&fbi->mm_lock); |
400 | } else { | 402 | } else { |
401 | fix->smem_start = rg->paddr; | 403 | fix->smem_start = rg->paddr; |
402 | fix->smem_len = rg->size; | 404 | fix->smem_len = rg->size; |
403 | } | 405 | } |
404 | 406 | ||
405 | fix->type = FB_TYPE_PACKED_PIXELS; | 407 | fix->type = FB_TYPE_PACKED_PIXELS; |
406 | bpp = var->bits_per_pixel; | 408 | bpp = var->bits_per_pixel; |
407 | if (var->nonstd) | 409 | if (var->nonstd) |
408 | fix->visual = FB_VISUAL_PSEUDOCOLOR; | 410 | fix->visual = FB_VISUAL_PSEUDOCOLOR; |
409 | else switch (var->bits_per_pixel) { | 411 | else switch (var->bits_per_pixel) { |
410 | case 16: | 412 | case 16: |
411 | case 12: | 413 | case 12: |
412 | fix->visual = FB_VISUAL_TRUECOLOR; | 414 | fix->visual = FB_VISUAL_TRUECOLOR; |
413 | /* 12bpp is stored in 16 bits */ | 415 | /* 12bpp is stored in 16 bits */ |
414 | bpp = 16; | 416 | bpp = 16; |
415 | break; | 417 | break; |
416 | case 1: | 418 | case 1: |
417 | case 2: | 419 | case 2: |
418 | case 4: | 420 | case 4: |
419 | case 8: | 421 | case 8: |
420 | fix->visual = FB_VISUAL_PSEUDOCOLOR; | 422 | fix->visual = FB_VISUAL_PSEUDOCOLOR; |
421 | break; | 423 | break; |
422 | } | 424 | } |
423 | fix->accel = FB_ACCEL_OMAP1610; | 425 | fix->accel = FB_ACCEL_OMAP1610; |
424 | fix->line_length = var->xres_virtual * bpp / 8; | 426 | fix->line_length = var->xres_virtual * bpp / 8; |
425 | } | 427 | } |
426 | 428 | ||
427 | static int set_color_mode(struct omapfb_plane_struct *plane, | 429 | static int set_color_mode(struct omapfb_plane_struct *plane, |
428 | struct fb_var_screeninfo *var) | 430 | struct fb_var_screeninfo *var) |
429 | { | 431 | { |
430 | switch (var->nonstd) { | 432 | switch (var->nonstd) { |
431 | case 0: | 433 | case 0: |
432 | break; | 434 | break; |
433 | case OMAPFB_COLOR_YUV422: | 435 | case OMAPFB_COLOR_YUV422: |
434 | var->bits_per_pixel = 16; | 436 | var->bits_per_pixel = 16; |
435 | plane->color_mode = var->nonstd; | 437 | plane->color_mode = var->nonstd; |
436 | return 0; | 438 | return 0; |
437 | case OMAPFB_COLOR_YUV420: | 439 | case OMAPFB_COLOR_YUV420: |
438 | var->bits_per_pixel = 12; | 440 | var->bits_per_pixel = 12; |
439 | plane->color_mode = var->nonstd; | 441 | plane->color_mode = var->nonstd; |
440 | return 0; | 442 | return 0; |
441 | case OMAPFB_COLOR_YUY422: | 443 | case OMAPFB_COLOR_YUY422: |
442 | var->bits_per_pixel = 16; | 444 | var->bits_per_pixel = 16; |
443 | plane->color_mode = var->nonstd; | 445 | plane->color_mode = var->nonstd; |
444 | return 0; | 446 | return 0; |
445 | default: | 447 | default: |
446 | return -EINVAL; | 448 | return -EINVAL; |
447 | } | 449 | } |
448 | 450 | ||
449 | switch (var->bits_per_pixel) { | 451 | switch (var->bits_per_pixel) { |
450 | case 1: | 452 | case 1: |
451 | plane->color_mode = OMAPFB_COLOR_CLUT_1BPP; | 453 | plane->color_mode = OMAPFB_COLOR_CLUT_1BPP; |
452 | return 0; | 454 | return 0; |
453 | case 2: | 455 | case 2: |
454 | plane->color_mode = OMAPFB_COLOR_CLUT_2BPP; | 456 | plane->color_mode = OMAPFB_COLOR_CLUT_2BPP; |
455 | return 0; | 457 | return 0; |
456 | case 4: | 458 | case 4: |
457 | plane->color_mode = OMAPFB_COLOR_CLUT_4BPP; | 459 | plane->color_mode = OMAPFB_COLOR_CLUT_4BPP; |
458 | return 0; | 460 | return 0; |
459 | case 8: | 461 | case 8: |
460 | plane->color_mode = OMAPFB_COLOR_CLUT_8BPP; | 462 | plane->color_mode = OMAPFB_COLOR_CLUT_8BPP; |
461 | return 0; | 463 | return 0; |
462 | case 12: | 464 | case 12: |
463 | var->bits_per_pixel = 16; | 465 | var->bits_per_pixel = 16; |
464 | case 16: | 466 | case 16: |
465 | if (plane->fbdev->panel->bpp == 12) | 467 | if (plane->fbdev->panel->bpp == 12) |
466 | plane->color_mode = OMAPFB_COLOR_RGB444; | 468 | plane->color_mode = OMAPFB_COLOR_RGB444; |
467 | else | 469 | else |
468 | plane->color_mode = OMAPFB_COLOR_RGB565; | 470 | plane->color_mode = OMAPFB_COLOR_RGB565; |
469 | return 0; | 471 | return 0; |
470 | default: | 472 | default: |
471 | return -EINVAL; | 473 | return -EINVAL; |
472 | } | 474 | } |
473 | } | 475 | } |
474 | 476 | ||
475 | /* | 477 | /* |
476 | * Check the values in var against our capabilities and in case of out of | 478 | * Check the values in var against our capabilities and in case of out of |
477 | * bound values try to adjust them. | 479 | * bound values try to adjust them. |
478 | */ | 480 | */ |
479 | static int set_fb_var(struct fb_info *fbi, | 481 | static int set_fb_var(struct fb_info *fbi, |
480 | struct fb_var_screeninfo *var) | 482 | struct fb_var_screeninfo *var) |
481 | { | 483 | { |
482 | int bpp; | 484 | int bpp; |
483 | unsigned long max_frame_size; | 485 | unsigned long max_frame_size; |
484 | unsigned long line_size; | 486 | unsigned long line_size; |
485 | int xres_min, xres_max; | 487 | int xres_min, xres_max; |
486 | int yres_min, yres_max; | 488 | int yres_min, yres_max; |
487 | struct omapfb_plane_struct *plane = fbi->par; | 489 | struct omapfb_plane_struct *plane = fbi->par; |
488 | struct omapfb_device *fbdev = plane->fbdev; | 490 | struct omapfb_device *fbdev = plane->fbdev; |
489 | struct lcd_panel *panel = fbdev->panel; | 491 | struct lcd_panel *panel = fbdev->panel; |
490 | 492 | ||
491 | if (set_color_mode(plane, var) < 0) | 493 | if (set_color_mode(plane, var) < 0) |
492 | return -EINVAL; | 494 | return -EINVAL; |
493 | 495 | ||
494 | bpp = var->bits_per_pixel; | 496 | bpp = var->bits_per_pixel; |
495 | if (plane->color_mode == OMAPFB_COLOR_RGB444) | 497 | if (plane->color_mode == OMAPFB_COLOR_RGB444) |
496 | bpp = 16; | 498 | bpp = 16; |
497 | 499 | ||
498 | switch (var->rotate) { | 500 | switch (var->rotate) { |
499 | case 0: | 501 | case 0: |
500 | case 180: | 502 | case 180: |
501 | xres_min = OMAPFB_PLANE_XRES_MIN; | 503 | xres_min = OMAPFB_PLANE_XRES_MIN; |
502 | xres_max = panel->x_res; | 504 | xres_max = panel->x_res; |
503 | yres_min = OMAPFB_PLANE_YRES_MIN; | 505 | yres_min = OMAPFB_PLANE_YRES_MIN; |
504 | yres_max = panel->y_res; | 506 | yres_max = panel->y_res; |
505 | if (cpu_is_omap15xx()) { | 507 | if (cpu_is_omap15xx()) { |
506 | var->xres = panel->x_res; | 508 | var->xres = panel->x_res; |
507 | var->yres = panel->y_res; | 509 | var->yres = panel->y_res; |
508 | } | 510 | } |
509 | break; | 511 | break; |
510 | case 90: | 512 | case 90: |
511 | case 270: | 513 | case 270: |
512 | xres_min = OMAPFB_PLANE_YRES_MIN; | 514 | xres_min = OMAPFB_PLANE_YRES_MIN; |
513 | xres_max = panel->y_res; | 515 | xres_max = panel->y_res; |
514 | yres_min = OMAPFB_PLANE_XRES_MIN; | 516 | yres_min = OMAPFB_PLANE_XRES_MIN; |
515 | yres_max = panel->x_res; | 517 | yres_max = panel->x_res; |
516 | if (cpu_is_omap15xx()) { | 518 | if (cpu_is_omap15xx()) { |
517 | var->xres = panel->y_res; | 519 | var->xres = panel->y_res; |
518 | var->yres = panel->x_res; | 520 | var->yres = panel->x_res; |
519 | } | 521 | } |
520 | break; | 522 | break; |
521 | default: | 523 | default: |
522 | return -EINVAL; | 524 | return -EINVAL; |
523 | } | 525 | } |
524 | 526 | ||
525 | if (var->xres < xres_min) | 527 | if (var->xres < xres_min) |
526 | var->xres = xres_min; | 528 | var->xres = xres_min; |
527 | if (var->yres < yres_min) | 529 | if (var->yres < yres_min) |
528 | var->yres = yres_min; | 530 | var->yres = yres_min; |
529 | if (var->xres > xres_max) | 531 | if (var->xres > xres_max) |
530 | var->xres = xres_max; | 532 | var->xres = xres_max; |
531 | if (var->yres > yres_max) | 533 | if (var->yres > yres_max) |
532 | var->yres = yres_max; | 534 | var->yres = yres_max; |
533 | 535 | ||
534 | if (var->xres_virtual < var->xres) | 536 | if (var->xres_virtual < var->xres) |
535 | var->xres_virtual = var->xres; | 537 | var->xres_virtual = var->xres; |
536 | if (var->yres_virtual < var->yres) | 538 | if (var->yres_virtual < var->yres) |
537 | var->yres_virtual = var->yres; | 539 | var->yres_virtual = var->yres; |
538 | max_frame_size = fbdev->mem_desc.region[plane->idx].size; | 540 | max_frame_size = fbdev->mem_desc.region[plane->idx].size; |
539 | line_size = var->xres_virtual * bpp / 8; | 541 | line_size = var->xres_virtual * bpp / 8; |
540 | if (line_size * var->yres_virtual > max_frame_size) { | 542 | if (line_size * var->yres_virtual > max_frame_size) { |
541 | /* Try to keep yres_virtual first */ | 543 | /* Try to keep yres_virtual first */ |
542 | line_size = max_frame_size / var->yres_virtual; | 544 | line_size = max_frame_size / var->yres_virtual; |
543 | var->xres_virtual = line_size * 8 / bpp; | 545 | var->xres_virtual = line_size * 8 / bpp; |
544 | if (var->xres_virtual < var->xres) { | 546 | if (var->xres_virtual < var->xres) { |
545 | /* Still doesn't fit. Shrink yres_virtual too */ | 547 | /* Still doesn't fit. Shrink yres_virtual too */ |
546 | var->xres_virtual = var->xres; | 548 | var->xres_virtual = var->xres; |
547 | line_size = var->xres * bpp / 8; | 549 | line_size = var->xres * bpp / 8; |
548 | var->yres_virtual = max_frame_size / line_size; | 550 | var->yres_virtual = max_frame_size / line_size; |
549 | } | 551 | } |
550 | /* Recheck this, as the virtual size changed. */ | 552 | /* Recheck this, as the virtual size changed. */ |
551 | if (var->xres_virtual < var->xres) | 553 | if (var->xres_virtual < var->xres) |
552 | var->xres = var->xres_virtual; | 554 | var->xres = var->xres_virtual; |
553 | if (var->yres_virtual < var->yres) | 555 | if (var->yres_virtual < var->yres) |
554 | var->yres = var->yres_virtual; | 556 | var->yres = var->yres_virtual; |
555 | if (var->xres < xres_min || var->yres < yres_min) | 557 | if (var->xres < xres_min || var->yres < yres_min) |
556 | return -EINVAL; | 558 | return -EINVAL; |
557 | } | 559 | } |
558 | if (var->xres + var->xoffset > var->xres_virtual) | 560 | if (var->xres + var->xoffset > var->xres_virtual) |
559 | var->xoffset = var->xres_virtual - var->xres; | 561 | var->xoffset = var->xres_virtual - var->xres; |
560 | if (var->yres + var->yoffset > var->yres_virtual) | 562 | if (var->yres + var->yoffset > var->yres_virtual) |
561 | var->yoffset = var->yres_virtual - var->yres; | 563 | var->yoffset = var->yres_virtual - var->yres; |
562 | 564 | ||
563 | if (plane->color_mode == OMAPFB_COLOR_RGB444) { | 565 | if (plane->color_mode == OMAPFB_COLOR_RGB444) { |
564 | var->red.offset = 8; var->red.length = 4; | 566 | var->red.offset = 8; var->red.length = 4; |
565 | var->red.msb_right = 0; | 567 | var->red.msb_right = 0; |
566 | var->green.offset = 4; var->green.length = 4; | 568 | var->green.offset = 4; var->green.length = 4; |
567 | var->green.msb_right = 0; | 569 | var->green.msb_right = 0; |
568 | var->blue.offset = 0; var->blue.length = 4; | 570 | var->blue.offset = 0; var->blue.length = 4; |
569 | var->blue.msb_right = 0; | 571 | var->blue.msb_right = 0; |
570 | } else { | 572 | } else { |
571 | var->red.offset = 11; var->red.length = 5; | 573 | var->red.offset = 11; var->red.length = 5; |
572 | var->red.msb_right = 0; | 574 | var->red.msb_right = 0; |
573 | var->green.offset = 5; var->green.length = 6; | 575 | var->green.offset = 5; var->green.length = 6; |
574 | var->green.msb_right = 0; | 576 | var->green.msb_right = 0; |
575 | var->blue.offset = 0; var->blue.length = 5; | 577 | var->blue.offset = 0; var->blue.length = 5; |
576 | var->blue.msb_right = 0; | 578 | var->blue.msb_right = 0; |
577 | } | 579 | } |
578 | 580 | ||
579 | var->height = -1; | 581 | var->height = -1; |
580 | var->width = -1; | 582 | var->width = -1; |
581 | var->grayscale = 0; | 583 | var->grayscale = 0; |
582 | 584 | ||
583 | /* pixclock in ps, the rest in pixclock */ | 585 | /* pixclock in ps, the rest in pixclock */ |
584 | var->pixclock = 10000000 / (panel->pixel_clock / 100); | 586 | var->pixclock = 10000000 / (panel->pixel_clock / 100); |
585 | var->left_margin = panel->hfp; | 587 | var->left_margin = panel->hfp; |
586 | var->right_margin = panel->hbp; | 588 | var->right_margin = panel->hbp; |
587 | var->upper_margin = panel->vfp; | 589 | var->upper_margin = panel->vfp; |
588 | var->lower_margin = panel->vbp; | 590 | var->lower_margin = panel->vbp; |
589 | var->hsync_len = panel->hsw; | 591 | var->hsync_len = panel->hsw; |
590 | var->vsync_len = panel->vsw; | 592 | var->vsync_len = panel->vsw; |
591 | 593 | ||
592 | /* TODO: get these from panel->config */ | 594 | /* TODO: get these from panel->config */ |
593 | var->vmode = FB_VMODE_NONINTERLACED; | 595 | var->vmode = FB_VMODE_NONINTERLACED; |
594 | var->sync = 0; | 596 | var->sync = 0; |
595 | 597 | ||
596 | return 0; | 598 | return 0; |
597 | } | 599 | } |
598 | 600 | ||
599 | 601 | ||
600 | /* Set rotation (0, 90, 180, 270 degree), and switch to the new mode. */ | 602 | /* Set rotation (0, 90, 180, 270 degree), and switch to the new mode. */ |
601 | static void omapfb_rotate(struct fb_info *fbi, int rotate) | 603 | static void omapfb_rotate(struct fb_info *fbi, int rotate) |
602 | { | 604 | { |
603 | struct omapfb_plane_struct *plane = fbi->par; | 605 | struct omapfb_plane_struct *plane = fbi->par; |
604 | struct omapfb_device *fbdev = plane->fbdev; | 606 | struct omapfb_device *fbdev = plane->fbdev; |
605 | 607 | ||
606 | omapfb_rqueue_lock(fbdev); | 608 | omapfb_rqueue_lock(fbdev); |
607 | if (rotate != fbi->var.rotate) { | 609 | if (rotate != fbi->var.rotate) { |
608 | struct fb_var_screeninfo *new_var = &fbdev->new_var; | 610 | struct fb_var_screeninfo *new_var = &fbdev->new_var; |
609 | 611 | ||
610 | memcpy(new_var, &fbi->var, sizeof(*new_var)); | 612 | memcpy(new_var, &fbi->var, sizeof(*new_var)); |
611 | new_var->rotate = rotate; | 613 | new_var->rotate = rotate; |
612 | if (set_fb_var(fbi, new_var) == 0 && | 614 | if (set_fb_var(fbi, new_var) == 0 && |
613 | memcmp(new_var, &fbi->var, sizeof(*new_var))) { | 615 | memcmp(new_var, &fbi->var, sizeof(*new_var))) { |
614 | memcpy(&fbi->var, new_var, sizeof(*new_var)); | 616 | memcpy(&fbi->var, new_var, sizeof(*new_var)); |
615 | ctrl_change_mode(fbi); | 617 | ctrl_change_mode(fbi); |
616 | } | 618 | } |
617 | } | 619 | } |
618 | omapfb_rqueue_unlock(fbdev); | 620 | omapfb_rqueue_unlock(fbdev); |
619 | } | 621 | } |
620 | 622 | ||
621 | /* | 623 | /* |
622 | * Set new x,y offsets in the virtual display for the visible area and switch | 624 | * Set new x,y offsets in the virtual display for the visible area and switch |
623 | * to the new mode. | 625 | * to the new mode. |
624 | */ | 626 | */ |
625 | static int omapfb_pan_display(struct fb_var_screeninfo *var, | 627 | static int omapfb_pan_display(struct fb_var_screeninfo *var, |
626 | struct fb_info *fbi) | 628 | struct fb_info *fbi) |
627 | { | 629 | { |
628 | struct omapfb_plane_struct *plane = fbi->par; | 630 | struct omapfb_plane_struct *plane = fbi->par; |
629 | struct omapfb_device *fbdev = plane->fbdev; | 631 | struct omapfb_device *fbdev = plane->fbdev; |
630 | int r = 0; | 632 | int r = 0; |
631 | 633 | ||
632 | omapfb_rqueue_lock(fbdev); | 634 | omapfb_rqueue_lock(fbdev); |
633 | if (var->xoffset != fbi->var.xoffset || | 635 | if (var->xoffset != fbi->var.xoffset || |
634 | var->yoffset != fbi->var.yoffset) { | 636 | var->yoffset != fbi->var.yoffset) { |
635 | struct fb_var_screeninfo *new_var = &fbdev->new_var; | 637 | struct fb_var_screeninfo *new_var = &fbdev->new_var; |
636 | 638 | ||
637 | memcpy(new_var, &fbi->var, sizeof(*new_var)); | 639 | memcpy(new_var, &fbi->var, sizeof(*new_var)); |
638 | new_var->xoffset = var->xoffset; | 640 | new_var->xoffset = var->xoffset; |
639 | new_var->yoffset = var->yoffset; | 641 | new_var->yoffset = var->yoffset; |
640 | if (set_fb_var(fbi, new_var)) | 642 | if (set_fb_var(fbi, new_var)) |
641 | r = -EINVAL; | 643 | r = -EINVAL; |
642 | else { | 644 | else { |
643 | memcpy(&fbi->var, new_var, sizeof(*new_var)); | 645 | memcpy(&fbi->var, new_var, sizeof(*new_var)); |
644 | ctrl_change_mode(fbi); | 646 | ctrl_change_mode(fbi); |
645 | } | 647 | } |
646 | } | 648 | } |
647 | omapfb_rqueue_unlock(fbdev); | 649 | omapfb_rqueue_unlock(fbdev); |
648 | 650 | ||
649 | return r; | 651 | return r; |
650 | } | 652 | } |
651 | 653 | ||
652 | /* Set mirror to vertical axis and switch to the new mode. */ | 654 | /* Set mirror to vertical axis and switch to the new mode. */ |
653 | static int omapfb_mirror(struct fb_info *fbi, int mirror) | 655 | static int omapfb_mirror(struct fb_info *fbi, int mirror) |
654 | { | 656 | { |
655 | struct omapfb_plane_struct *plane = fbi->par; | 657 | struct omapfb_plane_struct *plane = fbi->par; |
656 | struct omapfb_device *fbdev = plane->fbdev; | 658 | struct omapfb_device *fbdev = plane->fbdev; |
657 | int r = 0; | 659 | int r = 0; |
658 | 660 | ||
659 | omapfb_rqueue_lock(fbdev); | 661 | omapfb_rqueue_lock(fbdev); |
660 | mirror = mirror ? 1 : 0; | 662 | mirror = mirror ? 1 : 0; |
661 | if (cpu_is_omap15xx()) | 663 | if (cpu_is_omap15xx()) |
662 | r = -EINVAL; | 664 | r = -EINVAL; |
663 | else if (mirror != plane->info.mirror) { | 665 | else if (mirror != plane->info.mirror) { |
664 | plane->info.mirror = mirror; | 666 | plane->info.mirror = mirror; |
665 | r = ctrl_change_mode(fbi); | 667 | r = ctrl_change_mode(fbi); |
666 | } | 668 | } |
667 | omapfb_rqueue_unlock(fbdev); | 669 | omapfb_rqueue_unlock(fbdev); |
668 | 670 | ||
669 | return r; | 671 | return r; |
670 | } | 672 | } |
671 | 673 | ||
672 | /* | 674 | /* |
673 | * Check values in var, try to adjust them in case of out of bound values if | 675 | * Check values in var, try to adjust them in case of out of bound values if |
674 | * possible, or return error. | 676 | * possible, or return error. |
675 | */ | 677 | */ |
676 | static int omapfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fbi) | 678 | static int omapfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fbi) |
677 | { | 679 | { |
678 | struct omapfb_plane_struct *plane = fbi->par; | 680 | struct omapfb_plane_struct *plane = fbi->par; |
679 | struct omapfb_device *fbdev = plane->fbdev; | 681 | struct omapfb_device *fbdev = plane->fbdev; |
680 | int r; | 682 | int r; |
681 | 683 | ||
682 | omapfb_rqueue_lock(fbdev); | 684 | omapfb_rqueue_lock(fbdev); |
683 | if (fbdev->ctrl->sync != NULL) | 685 | if (fbdev->ctrl->sync != NULL) |
684 | fbdev->ctrl->sync(); | 686 | fbdev->ctrl->sync(); |
685 | r = set_fb_var(fbi, var); | 687 | r = set_fb_var(fbi, var); |
686 | omapfb_rqueue_unlock(fbdev); | 688 | omapfb_rqueue_unlock(fbdev); |
687 | 689 | ||
688 | return r; | 690 | return r; |
689 | } | 691 | } |
690 | 692 | ||
691 | /* | 693 | /* |
692 | * Switch to a new mode. The parameters for it has been check already by | 694 | * Switch to a new mode. The parameters for it has been check already by |
693 | * omapfb_check_var. | 695 | * omapfb_check_var. |
694 | */ | 696 | */ |
695 | static int omapfb_set_par(struct fb_info *fbi) | 697 | static int omapfb_set_par(struct fb_info *fbi) |
696 | { | 698 | { |
697 | struct omapfb_plane_struct *plane = fbi->par; | 699 | struct omapfb_plane_struct *plane = fbi->par; |
698 | struct omapfb_device *fbdev = plane->fbdev; | 700 | struct omapfb_device *fbdev = plane->fbdev; |
699 | int r = 0; | 701 | int r = 0; |
700 | 702 | ||
701 | omapfb_rqueue_lock(fbdev); | 703 | omapfb_rqueue_lock(fbdev); |
702 | set_fb_fix(fbi, 0); | 704 | set_fb_fix(fbi, 0); |
703 | r = ctrl_change_mode(fbi); | 705 | r = ctrl_change_mode(fbi); |
704 | omapfb_rqueue_unlock(fbdev); | 706 | omapfb_rqueue_unlock(fbdev); |
705 | 707 | ||
706 | return r; | 708 | return r; |
707 | } | 709 | } |
708 | 710 | ||
709 | int omapfb_update_window_async(struct fb_info *fbi, | 711 | int omapfb_update_window_async(struct fb_info *fbi, |
710 | struct omapfb_update_window *win, | 712 | struct omapfb_update_window *win, |
711 | void (*callback)(void *), | 713 | void (*callback)(void *), |
712 | void *callback_data) | 714 | void *callback_data) |
713 | { | 715 | { |
714 | int xres, yres; | 716 | int xres, yres; |
715 | struct omapfb_plane_struct *plane = fbi->par; | 717 | struct omapfb_plane_struct *plane = fbi->par; |
716 | struct omapfb_device *fbdev = plane->fbdev; | 718 | struct omapfb_device *fbdev = plane->fbdev; |
717 | struct fb_var_screeninfo *var = &fbi->var; | 719 | struct fb_var_screeninfo *var = &fbi->var; |
718 | 720 | ||
719 | switch (var->rotate) { | 721 | switch (var->rotate) { |
720 | case 0: | 722 | case 0: |
721 | case 180: | 723 | case 180: |
722 | xres = fbdev->panel->x_res; | 724 | xres = fbdev->panel->x_res; |
723 | yres = fbdev->panel->y_res; | 725 | yres = fbdev->panel->y_res; |
724 | break; | 726 | break; |
725 | case 90: | 727 | case 90: |
726 | case 270: | 728 | case 270: |
727 | xres = fbdev->panel->y_res; | 729 | xres = fbdev->panel->y_res; |
728 | yres = fbdev->panel->x_res; | 730 | yres = fbdev->panel->x_res; |
729 | break; | 731 | break; |
730 | default: | 732 | default: |
731 | return -EINVAL; | 733 | return -EINVAL; |
732 | } | 734 | } |
733 | 735 | ||
734 | if (win->x >= xres || win->y >= yres || | 736 | if (win->x >= xres || win->y >= yres || |
735 | win->out_x > xres || win->out_y > yres) | 737 | win->out_x > xres || win->out_y > yres) |
736 | return -EINVAL; | 738 | return -EINVAL; |
737 | 739 | ||
738 | if (!fbdev->ctrl->update_window || | 740 | if (!fbdev->ctrl->update_window || |
739 | fbdev->ctrl->get_update_mode() != OMAPFB_MANUAL_UPDATE) | 741 | fbdev->ctrl->get_update_mode() != OMAPFB_MANUAL_UPDATE) |
740 | return -ENODEV; | 742 | return -ENODEV; |
741 | 743 | ||
742 | if (win->x + win->width > xres) | 744 | if (win->x + win->width > xres) |
743 | win->width = xres - win->x; | 745 | win->width = xres - win->x; |
744 | if (win->y + win->height > yres) | 746 | if (win->y + win->height > yres) |
745 | win->height = yres - win->y; | 747 | win->height = yres - win->y; |
746 | if (win->out_x + win->out_width > xres) | 748 | if (win->out_x + win->out_width > xres) |
747 | win->out_width = xres - win->out_x; | 749 | win->out_width = xres - win->out_x; |
748 | if (win->out_y + win->out_height > yres) | 750 | if (win->out_y + win->out_height > yres) |
749 | win->out_height = yres - win->out_y; | 751 | win->out_height = yres - win->out_y; |
750 | if (!win->width || !win->height || !win->out_width || !win->out_height) | 752 | if (!win->width || !win->height || !win->out_width || !win->out_height) |
751 | return 0; | 753 | return 0; |
752 | 754 | ||
753 | return fbdev->ctrl->update_window(fbi, win, callback, callback_data); | 755 | return fbdev->ctrl->update_window(fbi, win, callback, callback_data); |
754 | } | 756 | } |
755 | EXPORT_SYMBOL(omapfb_update_window_async); | 757 | EXPORT_SYMBOL(omapfb_update_window_async); |
756 | 758 | ||
757 | static int omapfb_update_win(struct fb_info *fbi, | 759 | static int omapfb_update_win(struct fb_info *fbi, |
758 | struct omapfb_update_window *win) | 760 | struct omapfb_update_window *win) |
759 | { | 761 | { |
760 | struct omapfb_plane_struct *plane = fbi->par; | 762 | struct omapfb_plane_struct *plane = fbi->par; |
761 | int ret; | 763 | int ret; |
762 | 764 | ||
763 | omapfb_rqueue_lock(plane->fbdev); | 765 | omapfb_rqueue_lock(plane->fbdev); |
764 | ret = omapfb_update_window_async(fbi, win, NULL, NULL); | 766 | ret = omapfb_update_window_async(fbi, win, NULL, NULL); |
765 | omapfb_rqueue_unlock(plane->fbdev); | 767 | omapfb_rqueue_unlock(plane->fbdev); |
766 | 768 | ||
767 | return ret; | 769 | return ret; |
768 | } | 770 | } |
769 | 771 | ||
770 | static int omapfb_update_full_screen(struct fb_info *fbi) | 772 | static int omapfb_update_full_screen(struct fb_info *fbi) |
771 | { | 773 | { |
772 | struct omapfb_plane_struct *plane = fbi->par; | 774 | struct omapfb_plane_struct *plane = fbi->par; |
773 | struct omapfb_device *fbdev = plane->fbdev; | 775 | struct omapfb_device *fbdev = plane->fbdev; |
774 | struct omapfb_update_window win; | 776 | struct omapfb_update_window win; |
775 | int r; | 777 | int r; |
776 | 778 | ||
777 | if (!fbdev->ctrl->update_window || | 779 | if (!fbdev->ctrl->update_window || |
778 | fbdev->ctrl->get_update_mode() != OMAPFB_MANUAL_UPDATE) | 780 | fbdev->ctrl->get_update_mode() != OMAPFB_MANUAL_UPDATE) |
779 | return -ENODEV; | 781 | return -ENODEV; |
780 | 782 | ||
781 | win.x = 0; | 783 | win.x = 0; |
782 | win.y = 0; | 784 | win.y = 0; |
783 | win.width = fbi->var.xres; | 785 | win.width = fbi->var.xres; |
784 | win.height = fbi->var.yres; | 786 | win.height = fbi->var.yres; |
785 | win.out_x = 0; | 787 | win.out_x = 0; |
786 | win.out_y = 0; | 788 | win.out_y = 0; |
787 | win.out_width = fbi->var.xres; | 789 | win.out_width = fbi->var.xres; |
788 | win.out_height = fbi->var.yres; | 790 | win.out_height = fbi->var.yres; |
789 | win.format = 0; | 791 | win.format = 0; |
790 | 792 | ||
791 | omapfb_rqueue_lock(fbdev); | 793 | omapfb_rqueue_lock(fbdev); |
792 | r = fbdev->ctrl->update_window(fbi, &win, NULL, NULL); | 794 | r = fbdev->ctrl->update_window(fbi, &win, NULL, NULL); |
793 | omapfb_rqueue_unlock(fbdev); | 795 | omapfb_rqueue_unlock(fbdev); |
794 | 796 | ||
795 | return r; | 797 | return r; |
796 | } | 798 | } |
797 | 799 | ||
798 | static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) | 800 | static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) |
799 | { | 801 | { |
800 | struct omapfb_plane_struct *plane = fbi->par; | 802 | struct omapfb_plane_struct *plane = fbi->par; |
801 | struct omapfb_device *fbdev = plane->fbdev; | 803 | struct omapfb_device *fbdev = plane->fbdev; |
802 | struct lcd_panel *panel = fbdev->panel; | 804 | struct lcd_panel *panel = fbdev->panel; |
803 | struct omapfb_plane_info old_info; | 805 | struct omapfb_plane_info old_info; |
804 | int r = 0; | 806 | int r = 0; |
805 | 807 | ||
806 | if (pi->pos_x + pi->out_width > panel->x_res || | 808 | if (pi->pos_x + pi->out_width > panel->x_res || |
807 | pi->pos_y + pi->out_height > panel->y_res) | 809 | pi->pos_y + pi->out_height > panel->y_res) |
808 | return -EINVAL; | 810 | return -EINVAL; |
809 | 811 | ||
810 | omapfb_rqueue_lock(fbdev); | 812 | omapfb_rqueue_lock(fbdev); |
811 | if (pi->enabled && !fbdev->mem_desc.region[plane->idx].size) { | 813 | if (pi->enabled && !fbdev->mem_desc.region[plane->idx].size) { |
812 | /* | 814 | /* |
813 | * This plane's memory was freed, can't enable it | 815 | * This plane's memory was freed, can't enable it |
814 | * until it's reallocated. | 816 | * until it's reallocated. |
815 | */ | 817 | */ |
816 | r = -EINVAL; | 818 | r = -EINVAL; |
817 | goto out; | 819 | goto out; |
818 | } | 820 | } |
819 | old_info = plane->info; | 821 | old_info = plane->info; |
820 | plane->info = *pi; | 822 | plane->info = *pi; |
821 | if (pi->enabled) { | 823 | if (pi->enabled) { |
822 | r = ctrl_change_mode(fbi); | 824 | r = ctrl_change_mode(fbi); |
823 | if (r < 0) { | 825 | if (r < 0) { |
824 | plane->info = old_info; | 826 | plane->info = old_info; |
825 | goto out; | 827 | goto out; |
826 | } | 828 | } |
827 | } | 829 | } |
828 | r = fbdev->ctrl->enable_plane(plane->idx, pi->enabled); | 830 | r = fbdev->ctrl->enable_plane(plane->idx, pi->enabled); |
829 | if (r < 0) { | 831 | if (r < 0) { |
830 | plane->info = old_info; | 832 | plane->info = old_info; |
831 | goto out; | 833 | goto out; |
832 | } | 834 | } |
833 | out: | 835 | out: |
834 | omapfb_rqueue_unlock(fbdev); | 836 | omapfb_rqueue_unlock(fbdev); |
835 | return r; | 837 | return r; |
836 | } | 838 | } |
837 | 839 | ||
838 | static int omapfb_query_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) | 840 | static int omapfb_query_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) |
839 | { | 841 | { |
840 | struct omapfb_plane_struct *plane = fbi->par; | 842 | struct omapfb_plane_struct *plane = fbi->par; |
841 | 843 | ||
842 | *pi = plane->info; | 844 | *pi = plane->info; |
843 | return 0; | 845 | return 0; |
844 | } | 846 | } |
845 | 847 | ||
846 | static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) | 848 | static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) |
847 | { | 849 | { |
848 | struct omapfb_plane_struct *plane = fbi->par; | 850 | struct omapfb_plane_struct *plane = fbi->par; |
849 | struct omapfb_device *fbdev = plane->fbdev; | 851 | struct omapfb_device *fbdev = plane->fbdev; |
850 | struct omapfb_mem_region *rg = &fbdev->mem_desc.region[plane->idx]; | 852 | struct omapfb_mem_region *rg = &fbdev->mem_desc.region[plane->idx]; |
851 | size_t size; | 853 | size_t size; |
852 | int r = 0; | 854 | int r = 0; |
853 | 855 | ||
854 | if (fbdev->ctrl->setup_mem == NULL) | 856 | if (fbdev->ctrl->setup_mem == NULL) |
855 | return -ENODEV; | 857 | return -ENODEV; |
856 | if (mi->type != OMAPFB_MEMTYPE_SDRAM) | 858 | if (mi->type != OMAPFB_MEMTYPE_SDRAM) |
857 | return -EINVAL; | 859 | return -EINVAL; |
858 | 860 | ||
859 | size = PAGE_ALIGN(mi->size); | 861 | size = PAGE_ALIGN(mi->size); |
860 | omapfb_rqueue_lock(fbdev); | 862 | omapfb_rqueue_lock(fbdev); |
861 | if (plane->info.enabled) { | 863 | if (plane->info.enabled) { |
862 | r = -EBUSY; | 864 | r = -EBUSY; |
863 | goto out; | 865 | goto out; |
864 | } | 866 | } |
865 | if (rg->size != size || rg->type != mi->type) { | 867 | if (rg->size != size || rg->type != mi->type) { |
866 | struct fb_var_screeninfo *new_var = &fbdev->new_var; | 868 | struct fb_var_screeninfo *new_var = &fbdev->new_var; |
867 | unsigned long old_size = rg->size; | 869 | unsigned long old_size = rg->size; |
868 | u8 old_type = rg->type; | 870 | u8 old_type = rg->type; |
869 | unsigned long paddr; | 871 | unsigned long paddr; |
870 | 872 | ||
871 | rg->size = size; | 873 | rg->size = size; |
872 | rg->type = mi->type; | 874 | rg->type = mi->type; |
873 | /* | 875 | /* |
874 | * size == 0 is a special case, for which we | 876 | * size == 0 is a special case, for which we |
875 | * don't check / adjust the screen parameters. | 877 | * don't check / adjust the screen parameters. |
876 | * This isn't a problem since the plane can't | 878 | * This isn't a problem since the plane can't |
877 | * be reenabled unless its size is > 0. | 879 | * be reenabled unless its size is > 0. |
878 | */ | 880 | */ |
879 | if (old_size != size && size) { | 881 | if (old_size != size && size) { |
880 | if (size) { | 882 | if (size) { |
881 | memcpy(new_var, &fbi->var, sizeof(*new_var)); | 883 | memcpy(new_var, &fbi->var, sizeof(*new_var)); |
882 | r = set_fb_var(fbi, new_var); | 884 | r = set_fb_var(fbi, new_var); |
883 | if (r < 0) | 885 | if (r < 0) |
884 | goto out; | 886 | goto out; |
885 | } | 887 | } |
886 | } | 888 | } |
887 | 889 | ||
888 | if (fbdev->ctrl->sync) | 890 | if (fbdev->ctrl->sync) |
889 | fbdev->ctrl->sync(); | 891 | fbdev->ctrl->sync(); |
890 | r = fbdev->ctrl->setup_mem(plane->idx, size, mi->type, &paddr); | 892 | r = fbdev->ctrl->setup_mem(plane->idx, size, mi->type, &paddr); |
891 | if (r < 0) { | 893 | if (r < 0) { |
892 | /* Revert changes. */ | 894 | /* Revert changes. */ |
893 | rg->size = old_size; | 895 | rg->size = old_size; |
894 | rg->type = old_type; | 896 | rg->type = old_type; |
895 | goto out; | 897 | goto out; |
896 | } | 898 | } |
897 | rg->paddr = paddr; | 899 | rg->paddr = paddr; |
898 | 900 | ||
899 | if (old_size != size) { | 901 | if (old_size != size) { |
900 | if (size) { | 902 | if (size) { |
901 | memcpy(&fbi->var, new_var, sizeof(fbi->var)); | 903 | memcpy(&fbi->var, new_var, sizeof(fbi->var)); |
902 | set_fb_fix(fbi, 0); | 904 | set_fb_fix(fbi, 0); |
903 | } else { | 905 | } else { |
904 | /* | 906 | /* |
905 | * Set these explicitly to indicate that the | 907 | * Set these explicitly to indicate that the |
906 | * plane memory is dealloce'd, the other | 908 | * plane memory is dealloce'd, the other |
907 | * screen parameters in var / fix are invalid. | 909 | * screen parameters in var / fix are invalid. |
908 | */ | 910 | */ |
909 | mutex_lock(&fbi->mm_lock); | 911 | mutex_lock(&fbi->mm_lock); |
910 | fbi->fix.smem_start = 0; | 912 | fbi->fix.smem_start = 0; |
911 | fbi->fix.smem_len = 0; | 913 | fbi->fix.smem_len = 0; |
912 | mutex_unlock(&fbi->mm_lock); | 914 | mutex_unlock(&fbi->mm_lock); |
913 | } | 915 | } |
914 | } | 916 | } |
915 | } | 917 | } |
916 | out: | 918 | out: |
917 | omapfb_rqueue_unlock(fbdev); | 919 | omapfb_rqueue_unlock(fbdev); |
918 | 920 | ||
919 | return r; | 921 | return r; |
920 | } | 922 | } |
921 | 923 | ||
922 | static int omapfb_query_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) | 924 | static int omapfb_query_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) |
923 | { | 925 | { |
924 | struct omapfb_plane_struct *plane = fbi->par; | 926 | struct omapfb_plane_struct *plane = fbi->par; |
925 | struct omapfb_device *fbdev = plane->fbdev; | 927 | struct omapfb_device *fbdev = plane->fbdev; |
926 | struct omapfb_mem_region *rg; | 928 | struct omapfb_mem_region *rg; |
927 | 929 | ||
928 | rg = &fbdev->mem_desc.region[plane->idx]; | 930 | rg = &fbdev->mem_desc.region[plane->idx]; |
929 | memset(mi, 0, sizeof(*mi)); | 931 | memset(mi, 0, sizeof(*mi)); |
930 | mi->size = rg->size; | 932 | mi->size = rg->size; |
931 | mi->type = rg->type; | 933 | mi->type = rg->type; |
932 | 934 | ||
933 | return 0; | 935 | return 0; |
934 | } | 936 | } |
935 | 937 | ||
936 | static int omapfb_set_color_key(struct omapfb_device *fbdev, | 938 | static int omapfb_set_color_key(struct omapfb_device *fbdev, |
937 | struct omapfb_color_key *ck) | 939 | struct omapfb_color_key *ck) |
938 | { | 940 | { |
939 | int r; | 941 | int r; |
940 | 942 | ||
941 | if (!fbdev->ctrl->set_color_key) | 943 | if (!fbdev->ctrl->set_color_key) |
942 | return -ENODEV; | 944 | return -ENODEV; |
943 | 945 | ||
944 | omapfb_rqueue_lock(fbdev); | 946 | omapfb_rqueue_lock(fbdev); |
945 | r = fbdev->ctrl->set_color_key(ck); | 947 | r = fbdev->ctrl->set_color_key(ck); |
946 | omapfb_rqueue_unlock(fbdev); | 948 | omapfb_rqueue_unlock(fbdev); |
947 | 949 | ||
948 | return r; | 950 | return r; |
949 | } | 951 | } |
950 | 952 | ||
951 | static int omapfb_get_color_key(struct omapfb_device *fbdev, | 953 | static int omapfb_get_color_key(struct omapfb_device *fbdev, |
952 | struct omapfb_color_key *ck) | 954 | struct omapfb_color_key *ck) |
953 | { | 955 | { |
954 | int r; | 956 | int r; |
955 | 957 | ||
956 | if (!fbdev->ctrl->get_color_key) | 958 | if (!fbdev->ctrl->get_color_key) |
957 | return -ENODEV; | 959 | return -ENODEV; |
958 | 960 | ||
959 | omapfb_rqueue_lock(fbdev); | 961 | omapfb_rqueue_lock(fbdev); |
960 | r = fbdev->ctrl->get_color_key(ck); | 962 | r = fbdev->ctrl->get_color_key(ck); |
961 | omapfb_rqueue_unlock(fbdev); | 963 | omapfb_rqueue_unlock(fbdev); |
962 | 964 | ||
963 | return r; | 965 | return r; |
964 | } | 966 | } |
965 | 967 | ||
966 | static struct blocking_notifier_head omapfb_client_list[OMAPFB_PLANE_NUM]; | 968 | static struct blocking_notifier_head omapfb_client_list[OMAPFB_PLANE_NUM]; |
967 | static int notifier_inited; | 969 | static int notifier_inited; |
968 | 970 | ||
969 | static void omapfb_init_notifier(void) | 971 | static void omapfb_init_notifier(void) |
970 | { | 972 | { |
971 | int i; | 973 | int i; |
972 | 974 | ||
973 | for (i = 0; i < OMAPFB_PLANE_NUM; i++) | 975 | for (i = 0; i < OMAPFB_PLANE_NUM; i++) |
974 | BLOCKING_INIT_NOTIFIER_HEAD(&omapfb_client_list[i]); | 976 | BLOCKING_INIT_NOTIFIER_HEAD(&omapfb_client_list[i]); |
975 | } | 977 | } |
976 | 978 | ||
977 | int omapfb_register_client(struct omapfb_notifier_block *omapfb_nb, | 979 | int omapfb_register_client(struct omapfb_notifier_block *omapfb_nb, |
978 | omapfb_notifier_callback_t callback, | 980 | omapfb_notifier_callback_t callback, |
979 | void *callback_data) | 981 | void *callback_data) |
980 | { | 982 | { |
981 | int r; | 983 | int r; |
982 | 984 | ||
983 | if ((unsigned)omapfb_nb->plane_idx > OMAPFB_PLANE_NUM) | 985 | if ((unsigned)omapfb_nb->plane_idx > OMAPFB_PLANE_NUM) |
984 | return -EINVAL; | 986 | return -EINVAL; |
985 | 987 | ||
986 | if (!notifier_inited) { | 988 | if (!notifier_inited) { |
987 | omapfb_init_notifier(); | 989 | omapfb_init_notifier(); |
988 | notifier_inited = 1; | 990 | notifier_inited = 1; |
989 | } | 991 | } |
990 | 992 | ||
991 | omapfb_nb->nb.notifier_call = (int (*)(struct notifier_block *, | 993 | omapfb_nb->nb.notifier_call = (int (*)(struct notifier_block *, |
992 | unsigned long, void *))callback; | 994 | unsigned long, void *))callback; |
993 | omapfb_nb->data = callback_data; | 995 | omapfb_nb->data = callback_data; |
994 | r = blocking_notifier_chain_register( | 996 | r = blocking_notifier_chain_register( |
995 | &omapfb_client_list[omapfb_nb->plane_idx], | 997 | &omapfb_client_list[omapfb_nb->plane_idx], |
996 | &omapfb_nb->nb); | 998 | &omapfb_nb->nb); |
997 | if (r) | 999 | if (r) |
998 | return r; | 1000 | return r; |
999 | if (omapfb_dev != NULL && | 1001 | if (omapfb_dev != NULL && |
1000 | omapfb_dev->ctrl && omapfb_dev->ctrl->bind_client) { | 1002 | omapfb_dev->ctrl && omapfb_dev->ctrl->bind_client) { |
1001 | omapfb_dev->ctrl->bind_client(omapfb_nb); | 1003 | omapfb_dev->ctrl->bind_client(omapfb_nb); |
1002 | } | 1004 | } |
1003 | 1005 | ||
1004 | return 0; | 1006 | return 0; |
1005 | } | 1007 | } |
1006 | EXPORT_SYMBOL(omapfb_register_client); | 1008 | EXPORT_SYMBOL(omapfb_register_client); |
1007 | 1009 | ||
1008 | int omapfb_unregister_client(struct omapfb_notifier_block *omapfb_nb) | 1010 | int omapfb_unregister_client(struct omapfb_notifier_block *omapfb_nb) |
1009 | { | 1011 | { |
1010 | return blocking_notifier_chain_unregister( | 1012 | return blocking_notifier_chain_unregister( |
1011 | &omapfb_client_list[omapfb_nb->plane_idx], &omapfb_nb->nb); | 1013 | &omapfb_client_list[omapfb_nb->plane_idx], &omapfb_nb->nb); |
1012 | } | 1014 | } |
1013 | EXPORT_SYMBOL(omapfb_unregister_client); | 1015 | EXPORT_SYMBOL(omapfb_unregister_client); |
1014 | 1016 | ||
1015 | void omapfb_notify_clients(struct omapfb_device *fbdev, unsigned long event) | 1017 | void omapfb_notify_clients(struct omapfb_device *fbdev, unsigned long event) |
1016 | { | 1018 | { |
1017 | int i; | 1019 | int i; |
1018 | 1020 | ||
1019 | if (!notifier_inited) | 1021 | if (!notifier_inited) |
1020 | /* no client registered yet */ | 1022 | /* no client registered yet */ |
1021 | return; | 1023 | return; |
1022 | 1024 | ||
1023 | for (i = 0; i < OMAPFB_PLANE_NUM; i++) | 1025 | for (i = 0; i < OMAPFB_PLANE_NUM; i++) |
1024 | blocking_notifier_call_chain(&omapfb_client_list[i], event, | 1026 | blocking_notifier_call_chain(&omapfb_client_list[i], event, |
1025 | fbdev->fb_info[i]); | 1027 | fbdev->fb_info[i]); |
1026 | } | 1028 | } |
1027 | EXPORT_SYMBOL(omapfb_notify_clients); | 1029 | EXPORT_SYMBOL(omapfb_notify_clients); |
1028 | 1030 | ||
1029 | static int omapfb_set_update_mode(struct omapfb_device *fbdev, | 1031 | static int omapfb_set_update_mode(struct omapfb_device *fbdev, |
1030 | enum omapfb_update_mode mode) | 1032 | enum omapfb_update_mode mode) |
1031 | { | 1033 | { |
1032 | int r; | 1034 | int r; |
1033 | 1035 | ||
1034 | omapfb_rqueue_lock(fbdev); | 1036 | omapfb_rqueue_lock(fbdev); |
1035 | r = fbdev->ctrl->set_update_mode(mode); | 1037 | r = fbdev->ctrl->set_update_mode(mode); |
1036 | omapfb_rqueue_unlock(fbdev); | 1038 | omapfb_rqueue_unlock(fbdev); |
1037 | 1039 | ||
1038 | return r; | 1040 | return r; |
1039 | } | 1041 | } |
1040 | 1042 | ||
1041 | static enum omapfb_update_mode omapfb_get_update_mode(struct omapfb_device *fbdev) | 1043 | static enum omapfb_update_mode omapfb_get_update_mode(struct omapfb_device *fbdev) |
1042 | { | 1044 | { |
1043 | int r; | 1045 | int r; |
1044 | 1046 | ||
1045 | omapfb_rqueue_lock(fbdev); | 1047 | omapfb_rqueue_lock(fbdev); |
1046 | r = fbdev->ctrl->get_update_mode(); | 1048 | r = fbdev->ctrl->get_update_mode(); |
1047 | omapfb_rqueue_unlock(fbdev); | 1049 | omapfb_rqueue_unlock(fbdev); |
1048 | 1050 | ||
1049 | return r; | 1051 | return r; |
1050 | } | 1052 | } |
1051 | 1053 | ||
1052 | static void omapfb_get_caps(struct omapfb_device *fbdev, int plane, | 1054 | static void omapfb_get_caps(struct omapfb_device *fbdev, int plane, |
1053 | struct omapfb_caps *caps) | 1055 | struct omapfb_caps *caps) |
1054 | { | 1056 | { |
1055 | memset(caps, 0, sizeof(*caps)); | 1057 | memset(caps, 0, sizeof(*caps)); |
1056 | fbdev->ctrl->get_caps(plane, caps); | 1058 | fbdev->ctrl->get_caps(plane, caps); |
1057 | caps->ctrl |= fbdev->panel->get_caps(fbdev->panel); | 1059 | caps->ctrl |= fbdev->panel->get_caps(fbdev->panel); |
1058 | } | 1060 | } |
1059 | 1061 | ||
1060 | /* For lcd testing */ | 1062 | /* For lcd testing */ |
1061 | void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval) | 1063 | void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval) |
1062 | { | 1064 | { |
1063 | omapfb_rqueue_lock(fbdev); | 1065 | omapfb_rqueue_lock(fbdev); |
1064 | *(u16 *)fbdev->mem_desc.region[0].vaddr = pixval; | 1066 | *(u16 *)fbdev->mem_desc.region[0].vaddr = pixval; |
1065 | if (fbdev->ctrl->get_update_mode() == OMAPFB_MANUAL_UPDATE) { | 1067 | if (fbdev->ctrl->get_update_mode() == OMAPFB_MANUAL_UPDATE) { |
1066 | struct omapfb_update_window win; | 1068 | struct omapfb_update_window win; |
1067 | 1069 | ||
1068 | memset(&win, 0, sizeof(win)); | 1070 | memset(&win, 0, sizeof(win)); |
1069 | win.width = 2; | 1071 | win.width = 2; |
1070 | win.height = 2; | 1072 | win.height = 2; |
1071 | win.out_width = 2; | 1073 | win.out_width = 2; |
1072 | win.out_height = 2; | 1074 | win.out_height = 2; |
1073 | fbdev->ctrl->update_window(fbdev->fb_info[0], &win, NULL, NULL); | 1075 | fbdev->ctrl->update_window(fbdev->fb_info[0], &win, NULL, NULL); |
1074 | } | 1076 | } |
1075 | omapfb_rqueue_unlock(fbdev); | 1077 | omapfb_rqueue_unlock(fbdev); |
1076 | } | 1078 | } |
1077 | EXPORT_SYMBOL(omapfb_write_first_pixel); | 1079 | EXPORT_SYMBOL(omapfb_write_first_pixel); |
1078 | 1080 | ||
1079 | /* | 1081 | /* |
1080 | * Ioctl interface. Part of the kernel mode frame buffer API is duplicated | 1082 | * Ioctl interface. Part of the kernel mode frame buffer API is duplicated |
1081 | * here to be accessible by user mode code. | 1083 | * here to be accessible by user mode code. |
1082 | */ | 1084 | */ |
1083 | static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, | 1085 | static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, |
1084 | unsigned long arg) | 1086 | unsigned long arg) |
1085 | { | 1087 | { |
1086 | struct omapfb_plane_struct *plane = fbi->par; | 1088 | struct omapfb_plane_struct *plane = fbi->par; |
1087 | struct omapfb_device *fbdev = plane->fbdev; | 1089 | struct omapfb_device *fbdev = plane->fbdev; |
1088 | struct fb_ops *ops = fbi->fbops; | 1090 | struct fb_ops *ops = fbi->fbops; |
1089 | union { | 1091 | union { |
1090 | struct omapfb_update_window update_window; | 1092 | struct omapfb_update_window update_window; |
1091 | struct omapfb_plane_info plane_info; | 1093 | struct omapfb_plane_info plane_info; |
1092 | struct omapfb_mem_info mem_info; | 1094 | struct omapfb_mem_info mem_info; |
1093 | struct omapfb_color_key color_key; | 1095 | struct omapfb_color_key color_key; |
1094 | enum omapfb_update_mode update_mode; | 1096 | enum omapfb_update_mode update_mode; |
1095 | struct omapfb_caps caps; | 1097 | struct omapfb_caps caps; |
1096 | unsigned int mirror; | 1098 | unsigned int mirror; |
1097 | int plane_out; | 1099 | int plane_out; |
1098 | int enable_plane; | 1100 | int enable_plane; |
1099 | } p; | 1101 | } p; |
1100 | int r = 0; | 1102 | int r = 0; |
1101 | 1103 | ||
1102 | BUG_ON(!ops); | 1104 | BUG_ON(!ops); |
1103 | switch (cmd) { | 1105 | switch (cmd) { |
1104 | case OMAPFB_MIRROR: | 1106 | case OMAPFB_MIRROR: |
1105 | if (get_user(p.mirror, (int __user *)arg)) | 1107 | if (get_user(p.mirror, (int __user *)arg)) |
1106 | r = -EFAULT; | 1108 | r = -EFAULT; |
1107 | else | 1109 | else |
1108 | omapfb_mirror(fbi, p.mirror); | 1110 | omapfb_mirror(fbi, p.mirror); |
1109 | break; | 1111 | break; |
1110 | case OMAPFB_SYNC_GFX: | 1112 | case OMAPFB_SYNC_GFX: |
1111 | omapfb_sync(fbi); | 1113 | omapfb_sync(fbi); |
1112 | break; | 1114 | break; |
1113 | case OMAPFB_VSYNC: | 1115 | case OMAPFB_VSYNC: |
1114 | break; | 1116 | break; |
1115 | case OMAPFB_SET_UPDATE_MODE: | 1117 | case OMAPFB_SET_UPDATE_MODE: |
1116 | if (get_user(p.update_mode, (int __user *)arg)) | 1118 | if (get_user(p.update_mode, (int __user *)arg)) |
1117 | r = -EFAULT; | 1119 | r = -EFAULT; |
1118 | else | 1120 | else |
1119 | r = omapfb_set_update_mode(fbdev, p.update_mode); | 1121 | r = omapfb_set_update_mode(fbdev, p.update_mode); |
1120 | break; | 1122 | break; |
1121 | case OMAPFB_GET_UPDATE_MODE: | 1123 | case OMAPFB_GET_UPDATE_MODE: |
1122 | p.update_mode = omapfb_get_update_mode(fbdev); | 1124 | p.update_mode = omapfb_get_update_mode(fbdev); |
1123 | if (put_user(p.update_mode, | 1125 | if (put_user(p.update_mode, |
1124 | (enum omapfb_update_mode __user *)arg)) | 1126 | (enum omapfb_update_mode __user *)arg)) |
1125 | r = -EFAULT; | 1127 | r = -EFAULT; |
1126 | break; | 1128 | break; |
1127 | case OMAPFB_UPDATE_WINDOW_OLD: | 1129 | case OMAPFB_UPDATE_WINDOW_OLD: |
1128 | if (copy_from_user(&p.update_window, (void __user *)arg, | 1130 | if (copy_from_user(&p.update_window, (void __user *)arg, |
1129 | sizeof(struct omapfb_update_window_old))) | 1131 | sizeof(struct omapfb_update_window_old))) |
1130 | r = -EFAULT; | 1132 | r = -EFAULT; |
1131 | else { | 1133 | else { |
1132 | struct omapfb_update_window *u = &p.update_window; | 1134 | struct omapfb_update_window *u = &p.update_window; |
1133 | u->out_x = u->x; | 1135 | u->out_x = u->x; |
1134 | u->out_y = u->y; | 1136 | u->out_y = u->y; |
1135 | u->out_width = u->width; | 1137 | u->out_width = u->width; |
1136 | u->out_height = u->height; | 1138 | u->out_height = u->height; |
1137 | memset(u->reserved, 0, sizeof(u->reserved)); | 1139 | memset(u->reserved, 0, sizeof(u->reserved)); |
1138 | r = omapfb_update_win(fbi, u); | 1140 | r = omapfb_update_win(fbi, u); |
1139 | } | 1141 | } |
1140 | break; | 1142 | break; |
1141 | case OMAPFB_UPDATE_WINDOW: | 1143 | case OMAPFB_UPDATE_WINDOW: |
1142 | if (copy_from_user(&p.update_window, (void __user *)arg, | 1144 | if (copy_from_user(&p.update_window, (void __user *)arg, |
1143 | sizeof(p.update_window))) | 1145 | sizeof(p.update_window))) |
1144 | r = -EFAULT; | 1146 | r = -EFAULT; |
1145 | else | 1147 | else |
1146 | r = omapfb_update_win(fbi, &p.update_window); | 1148 | r = omapfb_update_win(fbi, &p.update_window); |
1147 | break; | 1149 | break; |
1148 | case OMAPFB_SETUP_PLANE: | 1150 | case OMAPFB_SETUP_PLANE: |
1149 | if (copy_from_user(&p.plane_info, (void __user *)arg, | 1151 | if (copy_from_user(&p.plane_info, (void __user *)arg, |
1150 | sizeof(p.plane_info))) | 1152 | sizeof(p.plane_info))) |
1151 | r = -EFAULT; | 1153 | r = -EFAULT; |
1152 | else | 1154 | else |
1153 | r = omapfb_setup_plane(fbi, &p.plane_info); | 1155 | r = omapfb_setup_plane(fbi, &p.plane_info); |
1154 | break; | 1156 | break; |
1155 | case OMAPFB_QUERY_PLANE: | 1157 | case OMAPFB_QUERY_PLANE: |
1156 | if ((r = omapfb_query_plane(fbi, &p.plane_info)) < 0) | 1158 | if ((r = omapfb_query_plane(fbi, &p.plane_info)) < 0) |
1157 | break; | 1159 | break; |
1158 | if (copy_to_user((void __user *)arg, &p.plane_info, | 1160 | if (copy_to_user((void __user *)arg, &p.plane_info, |
1159 | sizeof(p.plane_info))) | 1161 | sizeof(p.plane_info))) |
1160 | r = -EFAULT; | 1162 | r = -EFAULT; |
1161 | break; | 1163 | break; |
1162 | case OMAPFB_SETUP_MEM: | 1164 | case OMAPFB_SETUP_MEM: |
1163 | if (copy_from_user(&p.mem_info, (void __user *)arg, | 1165 | if (copy_from_user(&p.mem_info, (void __user *)arg, |
1164 | sizeof(p.mem_info))) | 1166 | sizeof(p.mem_info))) |
1165 | r = -EFAULT; | 1167 | r = -EFAULT; |
1166 | else | 1168 | else |
1167 | r = omapfb_setup_mem(fbi, &p.mem_info); | 1169 | r = omapfb_setup_mem(fbi, &p.mem_info); |
1168 | break; | 1170 | break; |
1169 | case OMAPFB_QUERY_MEM: | 1171 | case OMAPFB_QUERY_MEM: |
1170 | if ((r = omapfb_query_mem(fbi, &p.mem_info)) < 0) | 1172 | if ((r = omapfb_query_mem(fbi, &p.mem_info)) < 0) |
1171 | break; | 1173 | break; |
1172 | if (copy_to_user((void __user *)arg, &p.mem_info, | 1174 | if (copy_to_user((void __user *)arg, &p.mem_info, |
1173 | sizeof(p.mem_info))) | 1175 | sizeof(p.mem_info))) |
1174 | r = -EFAULT; | 1176 | r = -EFAULT; |
1175 | break; | 1177 | break; |
1176 | case OMAPFB_SET_COLOR_KEY: | 1178 | case OMAPFB_SET_COLOR_KEY: |
1177 | if (copy_from_user(&p.color_key, (void __user *)arg, | 1179 | if (copy_from_user(&p.color_key, (void __user *)arg, |
1178 | sizeof(p.color_key))) | 1180 | sizeof(p.color_key))) |
1179 | r = -EFAULT; | 1181 | r = -EFAULT; |
1180 | else | 1182 | else |
1181 | r = omapfb_set_color_key(fbdev, &p.color_key); | 1183 | r = omapfb_set_color_key(fbdev, &p.color_key); |
1182 | break; | 1184 | break; |
1183 | case OMAPFB_GET_COLOR_KEY: | 1185 | case OMAPFB_GET_COLOR_KEY: |
1184 | if ((r = omapfb_get_color_key(fbdev, &p.color_key)) < 0) | 1186 | if ((r = omapfb_get_color_key(fbdev, &p.color_key)) < 0) |
1185 | break; | 1187 | break; |
1186 | if (copy_to_user((void __user *)arg, &p.color_key, | 1188 | if (copy_to_user((void __user *)arg, &p.color_key, |
1187 | sizeof(p.color_key))) | 1189 | sizeof(p.color_key))) |
1188 | r = -EFAULT; | 1190 | r = -EFAULT; |
1189 | break; | 1191 | break; |
1190 | case OMAPFB_GET_CAPS: | 1192 | case OMAPFB_GET_CAPS: |
1191 | omapfb_get_caps(fbdev, plane->idx, &p.caps); | 1193 | omapfb_get_caps(fbdev, plane->idx, &p.caps); |
1192 | if (copy_to_user((void __user *)arg, &p.caps, sizeof(p.caps))) | 1194 | if (copy_to_user((void __user *)arg, &p.caps, sizeof(p.caps))) |
1193 | r = -EFAULT; | 1195 | r = -EFAULT; |
1194 | break; | 1196 | break; |
1195 | case OMAPFB_LCD_TEST: | 1197 | case OMAPFB_LCD_TEST: |
1196 | { | 1198 | { |
1197 | int test_num; | 1199 | int test_num; |
1198 | 1200 | ||
1199 | if (get_user(test_num, (int __user *)arg)) { | 1201 | if (get_user(test_num, (int __user *)arg)) { |
1200 | r = -EFAULT; | 1202 | r = -EFAULT; |
1201 | break; | 1203 | break; |
1202 | } | 1204 | } |
1203 | if (!fbdev->panel->run_test) { | 1205 | if (!fbdev->panel->run_test) { |
1204 | r = -EINVAL; | 1206 | r = -EINVAL; |
1205 | break; | 1207 | break; |
1206 | } | 1208 | } |
1207 | r = fbdev->panel->run_test(fbdev->panel, test_num); | 1209 | r = fbdev->panel->run_test(fbdev->panel, test_num); |
1208 | break; | 1210 | break; |
1209 | } | 1211 | } |
1210 | case OMAPFB_CTRL_TEST: | 1212 | case OMAPFB_CTRL_TEST: |
1211 | { | 1213 | { |
1212 | int test_num; | 1214 | int test_num; |
1213 | 1215 | ||
1214 | if (get_user(test_num, (int __user *)arg)) { | 1216 | if (get_user(test_num, (int __user *)arg)) { |
1215 | r = -EFAULT; | 1217 | r = -EFAULT; |
1216 | break; | 1218 | break; |
1217 | } | 1219 | } |
1218 | if (!fbdev->ctrl->run_test) { | 1220 | if (!fbdev->ctrl->run_test) { |
1219 | r = -EINVAL; | 1221 | r = -EINVAL; |
1220 | break; | 1222 | break; |
1221 | } | 1223 | } |
1222 | r = fbdev->ctrl->run_test(test_num); | 1224 | r = fbdev->ctrl->run_test(test_num); |
1223 | break; | 1225 | break; |
1224 | } | 1226 | } |
1225 | default: | 1227 | default: |
1226 | r = -EINVAL; | 1228 | r = -EINVAL; |
1227 | } | 1229 | } |
1228 | 1230 | ||
1229 | return r; | 1231 | return r; |
1230 | } | 1232 | } |
1231 | 1233 | ||
1232 | static int omapfb_mmap(struct fb_info *info, struct vm_area_struct *vma) | 1234 | static int omapfb_mmap(struct fb_info *info, struct vm_area_struct *vma) |
1233 | { | 1235 | { |
1234 | struct omapfb_plane_struct *plane = info->par; | 1236 | struct omapfb_plane_struct *plane = info->par; |
1235 | struct omapfb_device *fbdev = plane->fbdev; | 1237 | struct omapfb_device *fbdev = plane->fbdev; |
1236 | int r; | 1238 | int r; |
1237 | 1239 | ||
1238 | omapfb_rqueue_lock(fbdev); | 1240 | omapfb_rqueue_lock(fbdev); |
1239 | r = fbdev->ctrl->mmap(info, vma); | 1241 | r = fbdev->ctrl->mmap(info, vma); |
1240 | omapfb_rqueue_unlock(fbdev); | 1242 | omapfb_rqueue_unlock(fbdev); |
1241 | 1243 | ||
1242 | return r; | 1244 | return r; |
1243 | } | 1245 | } |
1244 | 1246 | ||
1245 | /* | 1247 | /* |
1246 | * Callback table for the frame buffer framework. Some of these pointers | 1248 | * Callback table for the frame buffer framework. Some of these pointers |
1247 | * will be changed according to the current setting of fb_info->accel_flags. | 1249 | * will be changed according to the current setting of fb_info->accel_flags. |
1248 | */ | 1250 | */ |
1249 | static struct fb_ops omapfb_ops = { | 1251 | static struct fb_ops omapfb_ops = { |
1250 | .owner = THIS_MODULE, | 1252 | .owner = THIS_MODULE, |
1251 | .fb_open = omapfb_open, | 1253 | .fb_open = omapfb_open, |
1252 | .fb_release = omapfb_release, | 1254 | .fb_release = omapfb_release, |
1253 | .fb_setcolreg = omapfb_setcolreg, | 1255 | .fb_setcolreg = omapfb_setcolreg, |
1254 | .fb_setcmap = omapfb_setcmap, | 1256 | .fb_setcmap = omapfb_setcmap, |
1255 | .fb_fillrect = cfb_fillrect, | 1257 | .fb_fillrect = cfb_fillrect, |
1256 | .fb_copyarea = cfb_copyarea, | 1258 | .fb_copyarea = cfb_copyarea, |
1257 | .fb_imageblit = cfb_imageblit, | 1259 | .fb_imageblit = cfb_imageblit, |
1258 | .fb_blank = omapfb_blank, | 1260 | .fb_blank = omapfb_blank, |
1259 | .fb_ioctl = omapfb_ioctl, | 1261 | .fb_ioctl = omapfb_ioctl, |
1260 | .fb_check_var = omapfb_check_var, | 1262 | .fb_check_var = omapfb_check_var, |
1261 | .fb_set_par = omapfb_set_par, | 1263 | .fb_set_par = omapfb_set_par, |
1262 | .fb_rotate = omapfb_rotate, | 1264 | .fb_rotate = omapfb_rotate, |
1263 | .fb_pan_display = omapfb_pan_display, | 1265 | .fb_pan_display = omapfb_pan_display, |
1264 | }; | 1266 | }; |
1265 | 1267 | ||
1266 | /* | 1268 | /* |
1267 | * --------------------------------------------------------------------------- | 1269 | * --------------------------------------------------------------------------- |
1268 | * Sysfs interface | 1270 | * Sysfs interface |
1269 | * --------------------------------------------------------------------------- | 1271 | * --------------------------------------------------------------------------- |
1270 | */ | 1272 | */ |
1271 | /* omapfbX sysfs entries */ | 1273 | /* omapfbX sysfs entries */ |
1272 | static ssize_t omapfb_show_caps_num(struct device *dev, | 1274 | static ssize_t omapfb_show_caps_num(struct device *dev, |
1273 | struct device_attribute *attr, char *buf) | 1275 | struct device_attribute *attr, char *buf) |
1274 | { | 1276 | { |
1275 | struct omapfb_device *fbdev = dev_get_drvdata(dev); | 1277 | struct omapfb_device *fbdev = dev_get_drvdata(dev); |
1276 | int plane; | 1278 | int plane; |
1277 | size_t size; | 1279 | size_t size; |
1278 | struct omapfb_caps caps; | 1280 | struct omapfb_caps caps; |
1279 | 1281 | ||
1280 | plane = 0; | 1282 | plane = 0; |
1281 | size = 0; | 1283 | size = 0; |
1282 | while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) { | 1284 | while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) { |
1283 | omapfb_get_caps(fbdev, plane, &caps); | 1285 | omapfb_get_caps(fbdev, plane, &caps); |
1284 | size += snprintf(&buf[size], PAGE_SIZE - size, | 1286 | size += snprintf(&buf[size], PAGE_SIZE - size, |
1285 | "plane#%d %#010x %#010x %#010x\n", | 1287 | "plane#%d %#010x %#010x %#010x\n", |
1286 | plane, caps.ctrl, caps.plane_color, caps.wnd_color); | 1288 | plane, caps.ctrl, caps.plane_color, caps.wnd_color); |
1287 | plane++; | 1289 | plane++; |
1288 | } | 1290 | } |
1289 | return size; | 1291 | return size; |
1290 | } | 1292 | } |
1291 | 1293 | ||
1292 | static ssize_t omapfb_show_caps_text(struct device *dev, | 1294 | static ssize_t omapfb_show_caps_text(struct device *dev, |
1293 | struct device_attribute *attr, char *buf) | 1295 | struct device_attribute *attr, char *buf) |
1294 | { | 1296 | { |
1295 | struct omapfb_device *fbdev = dev_get_drvdata(dev); | 1297 | struct omapfb_device *fbdev = dev_get_drvdata(dev); |
1296 | int i; | 1298 | int i; |
1297 | struct omapfb_caps caps; | 1299 | struct omapfb_caps caps; |
1298 | int plane; | 1300 | int plane; |
1299 | size_t size; | 1301 | size_t size; |
1300 | 1302 | ||
1301 | plane = 0; | 1303 | plane = 0; |
1302 | size = 0; | 1304 | size = 0; |
1303 | while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) { | 1305 | while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) { |
1304 | omapfb_get_caps(fbdev, plane, &caps); | 1306 | omapfb_get_caps(fbdev, plane, &caps); |
1305 | size += snprintf(&buf[size], PAGE_SIZE - size, | 1307 | size += snprintf(&buf[size], PAGE_SIZE - size, |
1306 | "plane#%d:\n", plane); | 1308 | "plane#%d:\n", plane); |
1307 | for (i = 0; i < ARRAY_SIZE(ctrl_caps) && | 1309 | for (i = 0; i < ARRAY_SIZE(ctrl_caps) && |
1308 | size < PAGE_SIZE; i++) { | 1310 | size < PAGE_SIZE; i++) { |
1309 | if (ctrl_caps[i].flag & caps.ctrl) | 1311 | if (ctrl_caps[i].flag & caps.ctrl) |
1310 | size += snprintf(&buf[size], PAGE_SIZE - size, | 1312 | size += snprintf(&buf[size], PAGE_SIZE - size, |
1311 | " %s\n", ctrl_caps[i].name); | 1313 | " %s\n", ctrl_caps[i].name); |
1312 | } | 1314 | } |
1313 | size += snprintf(&buf[size], PAGE_SIZE - size, | 1315 | size += snprintf(&buf[size], PAGE_SIZE - size, |
1314 | " plane colors:\n"); | 1316 | " plane colors:\n"); |
1315 | for (i = 0; i < ARRAY_SIZE(color_caps) && | 1317 | for (i = 0; i < ARRAY_SIZE(color_caps) && |
1316 | size < PAGE_SIZE; i++) { | 1318 | size < PAGE_SIZE; i++) { |
1317 | if (color_caps[i].flag & caps.plane_color) | 1319 | if (color_caps[i].flag & caps.plane_color) |
1318 | size += snprintf(&buf[size], PAGE_SIZE - size, | 1320 | size += snprintf(&buf[size], PAGE_SIZE - size, |
1319 | " %s\n", color_caps[i].name); | 1321 | " %s\n", color_caps[i].name); |
1320 | } | 1322 | } |
1321 | size += snprintf(&buf[size], PAGE_SIZE - size, | 1323 | size += snprintf(&buf[size], PAGE_SIZE - size, |
1322 | " window colors:\n"); | 1324 | " window colors:\n"); |
1323 | for (i = 0; i < ARRAY_SIZE(color_caps) && | 1325 | for (i = 0; i < ARRAY_SIZE(color_caps) && |
1324 | size < PAGE_SIZE; i++) { | 1326 | size < PAGE_SIZE; i++) { |
1325 | if (color_caps[i].flag & caps.wnd_color) | 1327 | if (color_caps[i].flag & caps.wnd_color) |
1326 | size += snprintf(&buf[size], PAGE_SIZE - size, | 1328 | size += snprintf(&buf[size], PAGE_SIZE - size, |
1327 | " %s\n", color_caps[i].name); | 1329 | " %s\n", color_caps[i].name); |
1328 | } | 1330 | } |
1329 | 1331 | ||
1330 | plane++; | 1332 | plane++; |
1331 | } | 1333 | } |
1332 | return size; | 1334 | return size; |
1333 | } | 1335 | } |
1334 | 1336 | ||
1335 | static DEVICE_ATTR(caps_num, 0444, omapfb_show_caps_num, NULL); | 1337 | static DEVICE_ATTR(caps_num, 0444, omapfb_show_caps_num, NULL); |
1336 | static DEVICE_ATTR(caps_text, 0444, omapfb_show_caps_text, NULL); | 1338 | static DEVICE_ATTR(caps_text, 0444, omapfb_show_caps_text, NULL); |
1337 | 1339 | ||
1338 | /* panel sysfs entries */ | 1340 | /* panel sysfs entries */ |
1339 | static ssize_t omapfb_show_panel_name(struct device *dev, | 1341 | static ssize_t omapfb_show_panel_name(struct device *dev, |
1340 | struct device_attribute *attr, char *buf) | 1342 | struct device_attribute *attr, char *buf) |
1341 | { | 1343 | { |
1342 | struct omapfb_device *fbdev = dev_get_drvdata(dev); | 1344 | struct omapfb_device *fbdev = dev_get_drvdata(dev); |
1343 | 1345 | ||
1344 | return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->panel->name); | 1346 | return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->panel->name); |
1345 | } | 1347 | } |
1346 | 1348 | ||
1347 | static ssize_t omapfb_show_bklight_level(struct device *dev, | 1349 | static ssize_t omapfb_show_bklight_level(struct device *dev, |
1348 | struct device_attribute *attr, | 1350 | struct device_attribute *attr, |
1349 | char *buf) | 1351 | char *buf) |
1350 | { | 1352 | { |
1351 | struct omapfb_device *fbdev = dev_get_drvdata(dev); | 1353 | struct omapfb_device *fbdev = dev_get_drvdata(dev); |
1352 | int r; | 1354 | int r; |
1353 | 1355 | ||
1354 | if (fbdev->panel->get_bklight_level) { | 1356 | if (fbdev->panel->get_bklight_level) { |
1355 | r = snprintf(buf, PAGE_SIZE, "%d\n", | 1357 | r = snprintf(buf, PAGE_SIZE, "%d\n", |
1356 | fbdev->panel->get_bklight_level(fbdev->panel)); | 1358 | fbdev->panel->get_bklight_level(fbdev->panel)); |
1357 | } else | 1359 | } else |
1358 | r = -ENODEV; | 1360 | r = -ENODEV; |
1359 | return r; | 1361 | return r; |
1360 | } | 1362 | } |
1361 | 1363 | ||
1362 | static ssize_t omapfb_store_bklight_level(struct device *dev, | 1364 | static ssize_t omapfb_store_bklight_level(struct device *dev, |
1363 | struct device_attribute *attr, | 1365 | struct device_attribute *attr, |
1364 | const char *buf, size_t size) | 1366 | const char *buf, size_t size) |
1365 | { | 1367 | { |
1366 | struct omapfb_device *fbdev = dev_get_drvdata(dev); | 1368 | struct omapfb_device *fbdev = dev_get_drvdata(dev); |
1367 | int r; | 1369 | int r; |
1368 | 1370 | ||
1369 | if (fbdev->panel->set_bklight_level) { | 1371 | if (fbdev->panel->set_bklight_level) { |
1370 | unsigned int level; | 1372 | unsigned int level; |
1371 | 1373 | ||
1372 | if (sscanf(buf, "%10d", &level) == 1) { | 1374 | if (sscanf(buf, "%10d", &level) == 1) { |
1373 | r = fbdev->panel->set_bklight_level(fbdev->panel, | 1375 | r = fbdev->panel->set_bklight_level(fbdev->panel, |
1374 | level); | 1376 | level); |
1375 | } else | 1377 | } else |
1376 | r = -EINVAL; | 1378 | r = -EINVAL; |
1377 | } else | 1379 | } else |
1378 | r = -ENODEV; | 1380 | r = -ENODEV; |
1379 | return r ? r : size; | 1381 | return r ? r : size; |
1380 | } | 1382 | } |
1381 | 1383 | ||
1382 | static ssize_t omapfb_show_bklight_max(struct device *dev, | 1384 | static ssize_t omapfb_show_bklight_max(struct device *dev, |
1383 | struct device_attribute *attr, char *buf) | 1385 | struct device_attribute *attr, char *buf) |
1384 | { | 1386 | { |
1385 | struct omapfb_device *fbdev = dev_get_drvdata(dev); | 1387 | struct omapfb_device *fbdev = dev_get_drvdata(dev); |
1386 | int r; | 1388 | int r; |
1387 | 1389 | ||
1388 | if (fbdev->panel->get_bklight_level) { | 1390 | if (fbdev->panel->get_bklight_level) { |
1389 | r = snprintf(buf, PAGE_SIZE, "%d\n", | 1391 | r = snprintf(buf, PAGE_SIZE, "%d\n", |
1390 | fbdev->panel->get_bklight_max(fbdev->panel)); | 1392 | fbdev->panel->get_bklight_max(fbdev->panel)); |
1391 | } else | 1393 | } else |
1392 | r = -ENODEV; | 1394 | r = -ENODEV; |
1393 | return r; | 1395 | return r; |
1394 | } | 1396 | } |
1395 | 1397 | ||
1396 | static struct device_attribute dev_attr_panel_name = | 1398 | static struct device_attribute dev_attr_panel_name = |
1397 | __ATTR(name, 0444, omapfb_show_panel_name, NULL); | 1399 | __ATTR(name, 0444, omapfb_show_panel_name, NULL); |
1398 | static DEVICE_ATTR(backlight_level, 0664, | 1400 | static DEVICE_ATTR(backlight_level, 0664, |
1399 | omapfb_show_bklight_level, omapfb_store_bklight_level); | 1401 | omapfb_show_bklight_level, omapfb_store_bklight_level); |
1400 | static DEVICE_ATTR(backlight_max, 0444, omapfb_show_bklight_max, NULL); | 1402 | static DEVICE_ATTR(backlight_max, 0444, omapfb_show_bklight_max, NULL); |
1401 | 1403 | ||
1402 | static struct attribute *panel_attrs[] = { | 1404 | static struct attribute *panel_attrs[] = { |
1403 | &dev_attr_panel_name.attr, | 1405 | &dev_attr_panel_name.attr, |
1404 | &dev_attr_backlight_level.attr, | 1406 | &dev_attr_backlight_level.attr, |
1405 | &dev_attr_backlight_max.attr, | 1407 | &dev_attr_backlight_max.attr, |
1406 | NULL, | 1408 | NULL, |
1407 | }; | 1409 | }; |
1408 | 1410 | ||
1409 | static struct attribute_group panel_attr_grp = { | 1411 | static struct attribute_group panel_attr_grp = { |
1410 | .name = "panel", | 1412 | .name = "panel", |
1411 | .attrs = panel_attrs, | 1413 | .attrs = panel_attrs, |
1412 | }; | 1414 | }; |
1413 | 1415 | ||
1414 | /* ctrl sysfs entries */ | 1416 | /* ctrl sysfs entries */ |
1415 | static ssize_t omapfb_show_ctrl_name(struct device *dev, | 1417 | static ssize_t omapfb_show_ctrl_name(struct device *dev, |
1416 | struct device_attribute *attr, char *buf) | 1418 | struct device_attribute *attr, char *buf) |
1417 | { | 1419 | { |
1418 | struct omapfb_device *fbdev = dev_get_drvdata(dev); | 1420 | struct omapfb_device *fbdev = dev_get_drvdata(dev); |
1419 | 1421 | ||
1420 | return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->ctrl->name); | 1422 | return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->ctrl->name); |
1421 | } | 1423 | } |
1422 | 1424 | ||
1423 | static struct device_attribute dev_attr_ctrl_name = | 1425 | static struct device_attribute dev_attr_ctrl_name = |
1424 | __ATTR(name, 0444, omapfb_show_ctrl_name, NULL); | 1426 | __ATTR(name, 0444, omapfb_show_ctrl_name, NULL); |
1425 | 1427 | ||
1426 | static struct attribute *ctrl_attrs[] = { | 1428 | static struct attribute *ctrl_attrs[] = { |
1427 | &dev_attr_ctrl_name.attr, | 1429 | &dev_attr_ctrl_name.attr, |
1428 | NULL, | 1430 | NULL, |
1429 | }; | 1431 | }; |
1430 | 1432 | ||
1431 | static struct attribute_group ctrl_attr_grp = { | 1433 | static struct attribute_group ctrl_attr_grp = { |
1432 | .name = "ctrl", | 1434 | .name = "ctrl", |
1433 | .attrs = ctrl_attrs, | 1435 | .attrs = ctrl_attrs, |
1434 | }; | 1436 | }; |
1435 | 1437 | ||
1436 | static int omapfb_register_sysfs(struct omapfb_device *fbdev) | 1438 | static int omapfb_register_sysfs(struct omapfb_device *fbdev) |
1437 | { | 1439 | { |
1438 | int r; | 1440 | int r; |
1439 | 1441 | ||
1440 | if ((r = device_create_file(fbdev->dev, &dev_attr_caps_num))) | 1442 | if ((r = device_create_file(fbdev->dev, &dev_attr_caps_num))) |
1441 | goto fail0; | 1443 | goto fail0; |
1442 | 1444 | ||
1443 | if ((r = device_create_file(fbdev->dev, &dev_attr_caps_text))) | 1445 | if ((r = device_create_file(fbdev->dev, &dev_attr_caps_text))) |
1444 | goto fail1; | 1446 | goto fail1; |
1445 | 1447 | ||
1446 | if ((r = sysfs_create_group(&fbdev->dev->kobj, &panel_attr_grp))) | 1448 | if ((r = sysfs_create_group(&fbdev->dev->kobj, &panel_attr_grp))) |
1447 | goto fail2; | 1449 | goto fail2; |
1448 | 1450 | ||
1449 | if ((r = sysfs_create_group(&fbdev->dev->kobj, &ctrl_attr_grp))) | 1451 | if ((r = sysfs_create_group(&fbdev->dev->kobj, &ctrl_attr_grp))) |
1450 | goto fail3; | 1452 | goto fail3; |
1451 | 1453 | ||
1452 | return 0; | 1454 | return 0; |
1453 | fail3: | 1455 | fail3: |
1454 | sysfs_remove_group(&fbdev->dev->kobj, &panel_attr_grp); | 1456 | sysfs_remove_group(&fbdev->dev->kobj, &panel_attr_grp); |
1455 | fail2: | 1457 | fail2: |
1456 | device_remove_file(fbdev->dev, &dev_attr_caps_text); | 1458 | device_remove_file(fbdev->dev, &dev_attr_caps_text); |
1457 | fail1: | 1459 | fail1: |
1458 | device_remove_file(fbdev->dev, &dev_attr_caps_num); | 1460 | device_remove_file(fbdev->dev, &dev_attr_caps_num); |
1459 | fail0: | 1461 | fail0: |
1460 | dev_err(fbdev->dev, "unable to register sysfs interface\n"); | 1462 | dev_err(fbdev->dev, "unable to register sysfs interface\n"); |
1461 | return r; | 1463 | return r; |
1462 | } | 1464 | } |
1463 | 1465 | ||
1464 | static void omapfb_unregister_sysfs(struct omapfb_device *fbdev) | 1466 | static void omapfb_unregister_sysfs(struct omapfb_device *fbdev) |
1465 | { | 1467 | { |
1466 | sysfs_remove_group(&fbdev->dev->kobj, &ctrl_attr_grp); | 1468 | sysfs_remove_group(&fbdev->dev->kobj, &ctrl_attr_grp); |
1467 | sysfs_remove_group(&fbdev->dev->kobj, &panel_attr_grp); | 1469 | sysfs_remove_group(&fbdev->dev->kobj, &panel_attr_grp); |
1468 | device_remove_file(fbdev->dev, &dev_attr_caps_num); | 1470 | device_remove_file(fbdev->dev, &dev_attr_caps_num); |
1469 | device_remove_file(fbdev->dev, &dev_attr_caps_text); | 1471 | device_remove_file(fbdev->dev, &dev_attr_caps_text); |
1470 | } | 1472 | } |
1471 | 1473 | ||
1472 | /* | 1474 | /* |
1473 | * --------------------------------------------------------------------------- | 1475 | * --------------------------------------------------------------------------- |
1474 | * LDM callbacks | 1476 | * LDM callbacks |
1475 | * --------------------------------------------------------------------------- | 1477 | * --------------------------------------------------------------------------- |
1476 | */ | 1478 | */ |
1477 | /* Initialize system fb_info object and set the default video mode. | 1479 | /* Initialize system fb_info object and set the default video mode. |
1478 | * The frame buffer memory already allocated by lcddma_init | 1480 | * The frame buffer memory already allocated by lcddma_init |
1479 | */ | 1481 | */ |
1480 | static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info) | 1482 | static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info) |
1481 | { | 1483 | { |
1482 | struct fb_var_screeninfo *var = &info->var; | 1484 | struct fb_var_screeninfo *var = &info->var; |
1483 | struct fb_fix_screeninfo *fix = &info->fix; | 1485 | struct fb_fix_screeninfo *fix = &info->fix; |
1484 | int r = 0; | 1486 | int r = 0; |
1485 | 1487 | ||
1486 | info->fbops = &omapfb_ops; | 1488 | info->fbops = &omapfb_ops; |
1487 | info->flags = FBINFO_FLAG_DEFAULT; | 1489 | info->flags = FBINFO_FLAG_DEFAULT; |
1488 | 1490 | ||
1489 | strncpy(fix->id, MODULE_NAME, sizeof(fix->id)); | 1491 | strncpy(fix->id, MODULE_NAME, sizeof(fix->id)); |
1490 | 1492 | ||
1491 | info->pseudo_palette = fbdev->pseudo_palette; | 1493 | info->pseudo_palette = fbdev->pseudo_palette; |
1492 | 1494 | ||
1493 | var->accel_flags = def_accel ? FB_ACCELF_TEXT : 0; | 1495 | var->accel_flags = def_accel ? FB_ACCELF_TEXT : 0; |
1494 | var->xres = def_vxres; | 1496 | var->xres = def_vxres; |
1495 | var->yres = def_vyres; | 1497 | var->yres = def_vyres; |
1496 | var->xres_virtual = def_vxres; | 1498 | var->xres_virtual = def_vxres; |
1497 | var->yres_virtual = def_vyres; | 1499 | var->yres_virtual = def_vyres; |
1498 | var->rotate = def_rotate; | 1500 | var->rotate = def_rotate; |
1499 | var->bits_per_pixel = fbdev->panel->bpp; | 1501 | var->bits_per_pixel = fbdev->panel->bpp; |
1500 | 1502 | ||
1501 | set_fb_var(info, var); | 1503 | set_fb_var(info, var); |
1502 | set_fb_fix(info, 1); | 1504 | set_fb_fix(info, 1); |
1503 | 1505 | ||
1504 | r = fb_alloc_cmap(&info->cmap, 16, 0); | 1506 | r = fb_alloc_cmap(&info->cmap, 16, 0); |
1505 | if (r != 0) | 1507 | if (r != 0) |
1506 | dev_err(fbdev->dev, "unable to allocate color map memory\n"); | 1508 | dev_err(fbdev->dev, "unable to allocate color map memory\n"); |
1507 | 1509 | ||
1508 | return r; | 1510 | return r; |
1509 | } | 1511 | } |
1510 | 1512 | ||
1511 | /* Release the fb_info object */ | 1513 | /* Release the fb_info object */ |
1512 | static void fbinfo_cleanup(struct omapfb_device *fbdev, struct fb_info *fbi) | 1514 | static void fbinfo_cleanup(struct omapfb_device *fbdev, struct fb_info *fbi) |
1513 | { | 1515 | { |
1514 | fb_dealloc_cmap(&fbi->cmap); | 1516 | fb_dealloc_cmap(&fbi->cmap); |
1515 | } | 1517 | } |
1516 | 1518 | ||
1517 | static void planes_cleanup(struct omapfb_device *fbdev) | 1519 | static void planes_cleanup(struct omapfb_device *fbdev) |
1518 | { | 1520 | { |
1519 | int i; | 1521 | int i; |
1520 | 1522 | ||
1521 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { | 1523 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { |
1522 | if (fbdev->fb_info[i] == NULL) | 1524 | if (fbdev->fb_info[i] == NULL) |
1523 | break; | 1525 | break; |
1524 | fbinfo_cleanup(fbdev, fbdev->fb_info[i]); | 1526 | fbinfo_cleanup(fbdev, fbdev->fb_info[i]); |
1525 | framebuffer_release(fbdev->fb_info[i]); | 1527 | framebuffer_release(fbdev->fb_info[i]); |
1526 | } | 1528 | } |
1527 | } | 1529 | } |
1528 | 1530 | ||
1529 | static int planes_init(struct omapfb_device *fbdev) | 1531 | static int planes_init(struct omapfb_device *fbdev) |
1530 | { | 1532 | { |
1531 | struct fb_info *fbi; | 1533 | struct fb_info *fbi; |
1532 | int i; | 1534 | int i; |
1533 | int r; | 1535 | int r; |
1534 | 1536 | ||
1535 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { | 1537 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { |
1536 | struct omapfb_plane_struct *plane; | 1538 | struct omapfb_plane_struct *plane; |
1537 | fbi = framebuffer_alloc(sizeof(struct omapfb_plane_struct), | 1539 | fbi = framebuffer_alloc(sizeof(struct omapfb_plane_struct), |
1538 | fbdev->dev); | 1540 | fbdev->dev); |
1539 | if (fbi == NULL) { | 1541 | if (fbi == NULL) { |
1540 | dev_err(fbdev->dev, | 1542 | dev_err(fbdev->dev, |
1541 | "unable to allocate memory for plane info\n"); | 1543 | "unable to allocate memory for plane info\n"); |
1542 | planes_cleanup(fbdev); | 1544 | planes_cleanup(fbdev); |
1543 | return -ENOMEM; | 1545 | return -ENOMEM; |
1544 | } | 1546 | } |
1545 | plane = fbi->par; | 1547 | plane = fbi->par; |
1546 | plane->idx = i; | 1548 | plane->idx = i; |
1547 | plane->fbdev = fbdev; | 1549 | plane->fbdev = fbdev; |
1548 | plane->info.mirror = def_mirror; | 1550 | plane->info.mirror = def_mirror; |
1549 | fbdev->fb_info[i] = fbi; | 1551 | fbdev->fb_info[i] = fbi; |
1550 | 1552 | ||
1551 | if ((r = fbinfo_init(fbdev, fbi)) < 0) { | 1553 | if ((r = fbinfo_init(fbdev, fbi)) < 0) { |
1552 | framebuffer_release(fbi); | 1554 | framebuffer_release(fbi); |
1553 | planes_cleanup(fbdev); | 1555 | planes_cleanup(fbdev); |
1554 | return r; | 1556 | return r; |
1555 | } | 1557 | } |
1556 | plane->info.out_width = fbi->var.xres; | 1558 | plane->info.out_width = fbi->var.xres; |
1557 | plane->info.out_height = fbi->var.yres; | 1559 | plane->info.out_height = fbi->var.yres; |
1558 | } | 1560 | } |
1559 | return 0; | 1561 | return 0; |
1560 | } | 1562 | } |
1561 | 1563 | ||
1562 | /* | 1564 | /* |
1563 | * Free driver resources. Can be called to rollback an aborted initialization | 1565 | * Free driver resources. Can be called to rollback an aborted initialization |
1564 | * sequence. | 1566 | * sequence. |
1565 | */ | 1567 | */ |
1566 | static void omapfb_free_resources(struct omapfb_device *fbdev, int state) | 1568 | static void omapfb_free_resources(struct omapfb_device *fbdev, int state) |
1567 | { | 1569 | { |
1568 | int i; | 1570 | int i; |
1569 | 1571 | ||
1570 | switch (state) { | 1572 | switch (state) { |
1571 | case OMAPFB_ACTIVE: | 1573 | case OMAPFB_ACTIVE: |
1572 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) | 1574 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) |
1573 | unregister_framebuffer(fbdev->fb_info[i]); | 1575 | unregister_framebuffer(fbdev->fb_info[i]); |
1574 | case 7: | 1576 | case 7: |
1575 | omapfb_unregister_sysfs(fbdev); | 1577 | omapfb_unregister_sysfs(fbdev); |
1576 | case 6: | 1578 | case 6: |
1577 | fbdev->panel->disable(fbdev->panel); | 1579 | fbdev->panel->disable(fbdev->panel); |
1578 | case 5: | 1580 | case 5: |
1579 | omapfb_set_update_mode(fbdev, OMAPFB_UPDATE_DISABLED); | 1581 | omapfb_set_update_mode(fbdev, OMAPFB_UPDATE_DISABLED); |
1580 | case 4: | 1582 | case 4: |
1581 | planes_cleanup(fbdev); | 1583 | planes_cleanup(fbdev); |
1582 | case 3: | 1584 | case 3: |
1583 | ctrl_cleanup(fbdev); | 1585 | ctrl_cleanup(fbdev); |
1584 | case 2: | 1586 | case 2: |
1585 | fbdev->panel->cleanup(fbdev->panel); | 1587 | fbdev->panel->cleanup(fbdev->panel); |
1586 | case 1: | 1588 | case 1: |
1587 | dev_set_drvdata(fbdev->dev, NULL); | 1589 | dev_set_drvdata(fbdev->dev, NULL); |
1588 | kfree(fbdev); | 1590 | kfree(fbdev); |
1589 | case 0: | 1591 | case 0: |
1590 | /* nothing to free */ | 1592 | /* nothing to free */ |
1591 | break; | 1593 | break; |
1592 | default: | 1594 | default: |
1593 | BUG(); | 1595 | BUG(); |
1594 | } | 1596 | } |
1595 | } | 1597 | } |
1596 | 1598 | ||
1597 | static int omapfb_find_ctrl(struct omapfb_device *fbdev) | 1599 | static int omapfb_find_ctrl(struct omapfb_device *fbdev) |
1598 | { | 1600 | { |
1599 | struct omapfb_platform_data *conf; | 1601 | struct omapfb_platform_data *conf; |
1600 | char name[17]; | 1602 | char name[17]; |
1601 | int i; | 1603 | int i; |
1602 | 1604 | ||
1603 | conf = fbdev->dev->platform_data; | 1605 | conf = fbdev->dev->platform_data; |
1604 | 1606 | ||
1605 | fbdev->ctrl = NULL; | 1607 | fbdev->ctrl = NULL; |
1606 | 1608 | ||
1607 | strncpy(name, conf->lcd.ctrl_name, sizeof(name) - 1); | 1609 | strncpy(name, conf->lcd.ctrl_name, sizeof(name) - 1); |
1608 | name[sizeof(name) - 1] = '\0'; | 1610 | name[sizeof(name) - 1] = '\0'; |
1609 | 1611 | ||
1610 | if (strcmp(name, "internal") == 0) { | 1612 | if (strcmp(name, "internal") == 0) { |
1611 | fbdev->ctrl = fbdev->int_ctrl; | 1613 | fbdev->ctrl = fbdev->int_ctrl; |
1612 | return 0; | 1614 | return 0; |
1613 | } | 1615 | } |
1614 | 1616 | ||
1615 | for (i = 0; i < ARRAY_SIZE(ctrls); i++) { | 1617 | for (i = 0; i < ARRAY_SIZE(ctrls); i++) { |
1616 | dev_dbg(fbdev->dev, "ctrl %s\n", ctrls[i]->name); | 1618 | dev_dbg(fbdev->dev, "ctrl %s\n", ctrls[i]->name); |
1617 | if (strcmp(ctrls[i]->name, name) == 0) { | 1619 | if (strcmp(ctrls[i]->name, name) == 0) { |
1618 | fbdev->ctrl = ctrls[i]; | 1620 | fbdev->ctrl = ctrls[i]; |
1619 | break; | 1621 | break; |
1620 | } | 1622 | } |
1621 | } | 1623 | } |
1622 | 1624 | ||
1623 | if (fbdev->ctrl == NULL) { | 1625 | if (fbdev->ctrl == NULL) { |
1624 | dev_dbg(fbdev->dev, "ctrl %s not supported\n", name); | 1626 | dev_dbg(fbdev->dev, "ctrl %s not supported\n", name); |
1625 | return -1; | 1627 | return -1; |
1626 | } | 1628 | } |
1627 | 1629 | ||
1628 | return 0; | 1630 | return 0; |
1629 | } | 1631 | } |
1630 | 1632 | ||
1631 | static void check_required_callbacks(struct omapfb_device *fbdev) | 1633 | static void check_required_callbacks(struct omapfb_device *fbdev) |
1632 | { | 1634 | { |
1633 | #define _C(x) (fbdev->ctrl->x != NULL) | 1635 | #define _C(x) (fbdev->ctrl->x != NULL) |
1634 | #define _P(x) (fbdev->panel->x != NULL) | 1636 | #define _P(x) (fbdev->panel->x != NULL) |
1635 | BUG_ON(fbdev->ctrl == NULL || fbdev->panel == NULL); | 1637 | BUG_ON(fbdev->ctrl == NULL || fbdev->panel == NULL); |
1636 | BUG_ON(!(_C(init) && _C(cleanup) && _C(get_caps) && | 1638 | BUG_ON(!(_C(init) && _C(cleanup) && _C(get_caps) && |
1637 | _C(set_update_mode) && _C(setup_plane) && _C(enable_plane) && | 1639 | _C(set_update_mode) && _C(setup_plane) && _C(enable_plane) && |
1638 | _P(init) && _P(cleanup) && _P(enable) && _P(disable) && | 1640 | _P(init) && _P(cleanup) && _P(enable) && _P(disable) && |
1639 | _P(get_caps))); | 1641 | _P(get_caps))); |
1640 | #undef _P | 1642 | #undef _P |
1641 | #undef _C | 1643 | #undef _C |
1642 | } | 1644 | } |
1643 | 1645 | ||
1644 | /* | 1646 | /* |
1645 | * Called by LDM binding to probe and attach a new device. | 1647 | * Called by LDM binding to probe and attach a new device. |
1646 | * Initialization sequence: | 1648 | * Initialization sequence: |
1647 | * 1. allocate system omapfb_device structure | 1649 | * 1. allocate system omapfb_device structure |
1648 | * 2. select controller type according to platform configuration | 1650 | * 2. select controller type according to platform configuration |
1649 | * init LCD panel | 1651 | * init LCD panel |
1650 | * 3. init LCD controller and LCD DMA | 1652 | * 3. init LCD controller and LCD DMA |
1651 | * 4. init system fb_info structure for all planes | 1653 | * 4. init system fb_info structure for all planes |
1652 | * 5. setup video mode for first plane and enable it | 1654 | * 5. setup video mode for first plane and enable it |
1653 | * 6. enable LCD panel | 1655 | * 6. enable LCD panel |
1654 | * 7. register sysfs attributes | 1656 | * 7. register sysfs attributes |
1655 | * OMAPFB_ACTIVE: register system fb_info structure for all planes | 1657 | * OMAPFB_ACTIVE: register system fb_info structure for all planes |
1656 | */ | 1658 | */ |
1657 | static int omapfb_do_probe(struct platform_device *pdev, | 1659 | static int omapfb_do_probe(struct platform_device *pdev, |
1658 | struct lcd_panel *panel) | 1660 | struct lcd_panel *panel) |
1659 | { | 1661 | { |
1660 | struct omapfb_device *fbdev = NULL; | 1662 | struct omapfb_device *fbdev = NULL; |
1661 | int init_state; | 1663 | int init_state; |
1662 | unsigned long phz, hhz, vhz; | 1664 | unsigned long phz, hhz, vhz; |
1663 | unsigned long vram; | 1665 | unsigned long vram; |
1664 | int i; | 1666 | int i; |
1665 | int r = 0; | 1667 | int r = 0; |
1666 | 1668 | ||
1667 | init_state = 0; | 1669 | init_state = 0; |
1668 | 1670 | ||
1669 | if (pdev->num_resources != 0) { | 1671 | if (pdev->num_resources != 0) { |
1670 | dev_err(&pdev->dev, "probed for an unknown device\n"); | 1672 | dev_err(&pdev->dev, "probed for an unknown device\n"); |
1671 | r = -ENODEV; | 1673 | r = -ENODEV; |
1672 | goto cleanup; | 1674 | goto cleanup; |
1673 | } | 1675 | } |
1674 | 1676 | ||
1675 | if (pdev->dev.platform_data == NULL) { | 1677 | if (pdev->dev.platform_data == NULL) { |
1676 | dev_err(&pdev->dev, "missing platform data\n"); | 1678 | dev_err(&pdev->dev, "missing platform data\n"); |
1677 | r = -ENOENT; | 1679 | r = -ENOENT; |
1678 | goto cleanup; | 1680 | goto cleanup; |
1679 | } | 1681 | } |
1680 | 1682 | ||
1681 | fbdev = kzalloc(sizeof(struct omapfb_device), GFP_KERNEL); | 1683 | fbdev = kzalloc(sizeof(struct omapfb_device), GFP_KERNEL); |
1682 | if (fbdev == NULL) { | 1684 | if (fbdev == NULL) { |
1683 | dev_err(&pdev->dev, | 1685 | dev_err(&pdev->dev, |
1684 | "unable to allocate memory for device info\n"); | 1686 | "unable to allocate memory for device info\n"); |
1685 | r = -ENOMEM; | 1687 | r = -ENOMEM; |
1686 | goto cleanup; | 1688 | goto cleanup; |
1687 | } | 1689 | } |
1688 | init_state++; | 1690 | init_state++; |
1689 | 1691 | ||
1690 | fbdev->dev = &pdev->dev; | 1692 | fbdev->dev = &pdev->dev; |
1691 | fbdev->panel = panel; | 1693 | fbdev->panel = panel; |
1692 | fbdev->dssdev = &omapdss_device; | 1694 | fbdev->dssdev = &omapdss_device; |
1693 | platform_set_drvdata(pdev, fbdev); | 1695 | platform_set_drvdata(pdev, fbdev); |
1694 | 1696 | ||
1695 | mutex_init(&fbdev->rqueue_mutex); | 1697 | mutex_init(&fbdev->rqueue_mutex); |
1696 | 1698 | ||
1697 | fbdev->int_ctrl = &omap1_int_ctrl; | 1699 | fbdev->int_ctrl = &omap1_int_ctrl; |
1698 | #ifdef CONFIG_FB_OMAP_LCDC_EXTERNAL | 1700 | #ifdef CONFIG_FB_OMAP_LCDC_EXTERNAL |
1699 | fbdev->ext_if = &omap1_ext_if; | 1701 | fbdev->ext_if = &omap1_ext_if; |
1700 | #endif | 1702 | #endif |
1701 | if (omapfb_find_ctrl(fbdev) < 0) { | 1703 | if (omapfb_find_ctrl(fbdev) < 0) { |
1702 | dev_err(fbdev->dev, | 1704 | dev_err(fbdev->dev, |
1703 | "LCD controller not found, board not supported\n"); | 1705 | "LCD controller not found, board not supported\n"); |
1704 | r = -ENODEV; | 1706 | r = -ENODEV; |
1705 | goto cleanup; | 1707 | goto cleanup; |
1706 | } | 1708 | } |
1707 | 1709 | ||
1708 | r = fbdev->panel->init(fbdev->panel, fbdev); | 1710 | r = fbdev->panel->init(fbdev->panel, fbdev); |
1709 | if (r) | 1711 | if (r) |
1710 | goto cleanup; | 1712 | goto cleanup; |
1711 | 1713 | ||
1712 | pr_info("omapfb: configured for panel %s\n", fbdev->panel->name); | 1714 | pr_info("omapfb: configured for panel %s\n", fbdev->panel->name); |
1713 | 1715 | ||
1714 | def_vxres = def_vxres ? def_vxres : fbdev->panel->x_res; | 1716 | def_vxres = def_vxres ? def_vxres : fbdev->panel->x_res; |
1715 | def_vyres = def_vyres ? def_vyres : fbdev->panel->y_res; | 1717 | def_vyres = def_vyres ? def_vyres : fbdev->panel->y_res; |
1716 | 1718 | ||
1717 | init_state++; | 1719 | init_state++; |
1718 | 1720 | ||
1719 | r = ctrl_init(fbdev); | 1721 | r = ctrl_init(fbdev); |
1720 | if (r) | 1722 | if (r) |
1721 | goto cleanup; | 1723 | goto cleanup; |
1722 | if (fbdev->ctrl->mmap != NULL) | 1724 | if (fbdev->ctrl->mmap != NULL) |
1723 | omapfb_ops.fb_mmap = omapfb_mmap; | 1725 | omapfb_ops.fb_mmap = omapfb_mmap; |
1724 | init_state++; | 1726 | init_state++; |
1725 | 1727 | ||
1726 | check_required_callbacks(fbdev); | 1728 | check_required_callbacks(fbdev); |
1727 | 1729 | ||
1728 | r = planes_init(fbdev); | 1730 | r = planes_init(fbdev); |
1729 | if (r) | 1731 | if (r) |
1730 | goto cleanup; | 1732 | goto cleanup; |
1731 | init_state++; | 1733 | init_state++; |
1732 | 1734 | ||
1733 | #ifdef CONFIG_FB_OMAP_DMA_TUNE | 1735 | #ifdef CONFIG_FB_OMAP_DMA_TUNE |
1734 | /* Set DMA priority for EMIFF access to highest */ | 1736 | /* Set DMA priority for EMIFF access to highest */ |
1735 | omap_set_dma_priority(0, OMAP_DMA_PORT_EMIFF, 15); | 1737 | omap_set_dma_priority(0, OMAP_DMA_PORT_EMIFF, 15); |
1736 | #endif | 1738 | #endif |
1737 | 1739 | ||
1738 | r = ctrl_change_mode(fbdev->fb_info[0]); | 1740 | r = ctrl_change_mode(fbdev->fb_info[0]); |
1739 | if (r) { | 1741 | if (r) { |
1740 | dev_err(fbdev->dev, "mode setting failed\n"); | 1742 | dev_err(fbdev->dev, "mode setting failed\n"); |
1741 | goto cleanup; | 1743 | goto cleanup; |
1742 | } | 1744 | } |
1743 | 1745 | ||
1744 | /* GFX plane is enabled by default */ | 1746 | /* GFX plane is enabled by default */ |
1745 | r = fbdev->ctrl->enable_plane(OMAPFB_PLANE_GFX, 1); | 1747 | r = fbdev->ctrl->enable_plane(OMAPFB_PLANE_GFX, 1); |
1746 | if (r) | 1748 | if (r) |
1747 | goto cleanup; | 1749 | goto cleanup; |
1748 | 1750 | ||
1749 | omapfb_set_update_mode(fbdev, manual_update ? | 1751 | omapfb_set_update_mode(fbdev, manual_update ? |
1750 | OMAPFB_MANUAL_UPDATE : OMAPFB_AUTO_UPDATE); | 1752 | OMAPFB_MANUAL_UPDATE : OMAPFB_AUTO_UPDATE); |
1751 | init_state++; | 1753 | init_state++; |
1752 | 1754 | ||
1753 | r = fbdev->panel->enable(fbdev->panel); | 1755 | r = fbdev->panel->enable(fbdev->panel); |
1754 | if (r) | 1756 | if (r) |
1755 | goto cleanup; | 1757 | goto cleanup; |
1756 | init_state++; | 1758 | init_state++; |
1757 | 1759 | ||
1758 | r = omapfb_register_sysfs(fbdev); | 1760 | r = omapfb_register_sysfs(fbdev); |
1759 | if (r) | 1761 | if (r) |
1760 | goto cleanup; | 1762 | goto cleanup; |
1761 | init_state++; | 1763 | init_state++; |
1762 | 1764 | ||
1763 | vram = 0; | 1765 | vram = 0; |
1764 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { | 1766 | for (i = 0; i < fbdev->mem_desc.region_cnt; i++) { |
1765 | r = register_framebuffer(fbdev->fb_info[i]); | 1767 | r = register_framebuffer(fbdev->fb_info[i]); |
1766 | if (r != 0) { | 1768 | if (r != 0) { |
1767 | dev_err(fbdev->dev, | 1769 | dev_err(fbdev->dev, |
1768 | "registering framebuffer %d failed\n", i); | 1770 | "registering framebuffer %d failed\n", i); |
1769 | goto cleanup; | 1771 | goto cleanup; |
1770 | } | 1772 | } |
1771 | vram += fbdev->mem_desc.region[i].size; | 1773 | vram += fbdev->mem_desc.region[i].size; |
1772 | } | 1774 | } |
1773 | 1775 | ||
1774 | fbdev->state = OMAPFB_ACTIVE; | 1776 | fbdev->state = OMAPFB_ACTIVE; |
1775 | 1777 | ||
1776 | panel = fbdev->panel; | 1778 | panel = fbdev->panel; |
1777 | phz = panel->pixel_clock * 1000; | 1779 | phz = panel->pixel_clock * 1000; |
1778 | hhz = phz * 10 / (panel->hfp + panel->x_res + panel->hbp + panel->hsw); | 1780 | hhz = phz * 10 / (panel->hfp + panel->x_res + panel->hbp + panel->hsw); |
1779 | vhz = hhz / (panel->vfp + panel->y_res + panel->vbp + panel->vsw); | 1781 | vhz = hhz / (panel->vfp + panel->y_res + panel->vbp + panel->vsw); |
1780 | 1782 | ||
1781 | omapfb_dev = fbdev; | 1783 | omapfb_dev = fbdev; |
1782 | 1784 | ||
1783 | pr_info("omapfb: Framebuffer initialized. Total vram %lu planes %d\n", | 1785 | pr_info("omapfb: Framebuffer initialized. Total vram %lu planes %d\n", |
1784 | vram, fbdev->mem_desc.region_cnt); | 1786 | vram, fbdev->mem_desc.region_cnt); |
1785 | pr_info("omapfb: Pixclock %lu kHz hfreq %lu.%lu kHz " | 1787 | pr_info("omapfb: Pixclock %lu kHz hfreq %lu.%lu kHz " |
1786 | "vfreq %lu.%lu Hz\n", | 1788 | "vfreq %lu.%lu Hz\n", |
1787 | phz / 1000, hhz / 10000, hhz % 10, vhz / 10, vhz % 10); | 1789 | phz / 1000, hhz / 10000, hhz % 10, vhz / 10, vhz % 10); |
1788 | 1790 | ||
1789 | return 0; | 1791 | return 0; |
1790 | 1792 | ||
1791 | cleanup: | 1793 | cleanup: |
1792 | omapfb_free_resources(fbdev, init_state); | 1794 | omapfb_free_resources(fbdev, init_state); |
1793 | 1795 | ||
1794 | return r; | 1796 | return r; |
1795 | } | 1797 | } |
1796 | 1798 | ||
1797 | static int omapfb_probe(struct platform_device *pdev) | 1799 | static int omapfb_probe(struct platform_device *pdev) |
1798 | { | 1800 | { |
1799 | int r; | 1801 | int r; |
1800 | 1802 | ||
1801 | BUG_ON(fbdev_pdev != NULL); | 1803 | BUG_ON(fbdev_pdev != NULL); |
1802 | 1804 | ||
1803 | r = platform_device_register(&omapdss_device); | 1805 | r = platform_device_register(&omapdss_device); |
1804 | if (r) { | 1806 | if (r) { |
1805 | dev_err(&pdev->dev, "can't register omapdss device\n"); | 1807 | dev_err(&pdev->dev, "can't register omapdss device\n"); |
1806 | return r; | 1808 | return r; |
1807 | } | 1809 | } |
1808 | 1810 | ||
1809 | /* Delay actual initialization until the LCD is registered */ | 1811 | /* Delay actual initialization until the LCD is registered */ |
1810 | fbdev_pdev = pdev; | 1812 | fbdev_pdev = pdev; |
1811 | if (fbdev_panel != NULL) | 1813 | if (fbdev_panel != NULL) |
1812 | omapfb_do_probe(fbdev_pdev, fbdev_panel); | 1814 | omapfb_do_probe(fbdev_pdev, fbdev_panel); |
1813 | return 0; | 1815 | return 0; |
1814 | } | 1816 | } |
1815 | 1817 | ||
1816 | void omapfb_register_panel(struct lcd_panel *panel) | 1818 | void omapfb_register_panel(struct lcd_panel *panel) |
1817 | { | 1819 | { |
1818 | BUG_ON(fbdev_panel != NULL); | 1820 | BUG_ON(fbdev_panel != NULL); |
1819 | 1821 | ||
1820 | fbdev_panel = panel; | 1822 | fbdev_panel = panel; |
1821 | if (fbdev_pdev != NULL) | 1823 | if (fbdev_pdev != NULL) |
1822 | omapfb_do_probe(fbdev_pdev, fbdev_panel); | 1824 | omapfb_do_probe(fbdev_pdev, fbdev_panel); |
1823 | } | 1825 | } |
1824 | 1826 | ||
1825 | /* Called when the device is being detached from the driver */ | 1827 | /* Called when the device is being detached from the driver */ |
1826 | static int omapfb_remove(struct platform_device *pdev) | 1828 | static int omapfb_remove(struct platform_device *pdev) |
1827 | { | 1829 | { |
1828 | struct omapfb_device *fbdev = platform_get_drvdata(pdev); | 1830 | struct omapfb_device *fbdev = platform_get_drvdata(pdev); |
1829 | enum omapfb_state saved_state = fbdev->state; | 1831 | enum omapfb_state saved_state = fbdev->state; |
1830 | 1832 | ||
1831 | /* FIXME: wait till completion of pending events */ | 1833 | /* FIXME: wait till completion of pending events */ |
1832 | 1834 | ||
1833 | fbdev->state = OMAPFB_DISABLED; | 1835 | fbdev->state = OMAPFB_DISABLED; |
1834 | omapfb_free_resources(fbdev, saved_state); | 1836 | omapfb_free_resources(fbdev, saved_state); |
1835 | 1837 | ||
1836 | platform_device_unregister(&omapdss_device); | 1838 | platform_device_unregister(&omapdss_device); |
1837 | fbdev->dssdev = NULL; | 1839 | fbdev->dssdev = NULL; |
1838 | 1840 | ||
1839 | return 0; | 1841 | return 0; |
1840 | } | 1842 | } |
1841 | 1843 | ||
1842 | /* PM suspend */ | 1844 | /* PM suspend */ |
1843 | static int omapfb_suspend(struct platform_device *pdev, pm_message_t mesg) | 1845 | static int omapfb_suspend(struct platform_device *pdev, pm_message_t mesg) |
1844 | { | 1846 | { |
1845 | struct omapfb_device *fbdev = platform_get_drvdata(pdev); | 1847 | struct omapfb_device *fbdev = platform_get_drvdata(pdev); |
1846 | 1848 | ||
1847 | if (fbdev != NULL) | 1849 | if (fbdev != NULL) |
1848 | omapfb_blank(FB_BLANK_POWERDOWN, fbdev->fb_info[0]); | 1850 | omapfb_blank(FB_BLANK_POWERDOWN, fbdev->fb_info[0]); |
1849 | return 0; | 1851 | return 0; |
1850 | } | 1852 | } |
1851 | 1853 | ||
1852 | /* PM resume */ | 1854 | /* PM resume */ |
1853 | static int omapfb_resume(struct platform_device *pdev) | 1855 | static int omapfb_resume(struct platform_device *pdev) |
1854 | { | 1856 | { |
1855 | struct omapfb_device *fbdev = platform_get_drvdata(pdev); | 1857 | struct omapfb_device *fbdev = platform_get_drvdata(pdev); |
1856 | 1858 | ||
1857 | if (fbdev != NULL) | 1859 | if (fbdev != NULL) |
1858 | omapfb_blank(FB_BLANK_UNBLANK, fbdev->fb_info[0]); | 1860 | omapfb_blank(FB_BLANK_UNBLANK, fbdev->fb_info[0]); |
1859 | return 0; | 1861 | return 0; |
1860 | } | 1862 | } |
1861 | 1863 | ||
1862 | static struct platform_driver omapfb_driver = { | 1864 | static struct platform_driver omapfb_driver = { |
1863 | .probe = omapfb_probe, | 1865 | .probe = omapfb_probe, |
1864 | .remove = omapfb_remove, | 1866 | .remove = omapfb_remove, |
1865 | .suspend = omapfb_suspend, | 1867 | .suspend = omapfb_suspend, |
1866 | .resume = omapfb_resume, | 1868 | .resume = omapfb_resume, |
1867 | .driver = { | 1869 | .driver = { |
1868 | .name = MODULE_NAME, | 1870 | .name = MODULE_NAME, |
1869 | .owner = THIS_MODULE, | 1871 | .owner = THIS_MODULE, |
1870 | }, | 1872 | }, |
1871 | }; | 1873 | }; |
1872 | 1874 | ||
1873 | #ifndef MODULE | 1875 | #ifndef MODULE |
1874 | 1876 | ||
1875 | /* Process kernel command line parameters */ | 1877 | /* Process kernel command line parameters */ |
1876 | static int __init omapfb_setup(char *options) | 1878 | static int __init omapfb_setup(char *options) |
1877 | { | 1879 | { |
1878 | char *this_opt = NULL; | 1880 | char *this_opt = NULL; |
1879 | int r = 0; | 1881 | int r = 0; |
1880 | 1882 | ||
1881 | pr_debug("omapfb: options %s\n", options); | 1883 | pr_debug("omapfb: options %s\n", options); |
1882 | 1884 | ||
1883 | if (!options || !*options) | 1885 | if (!options || !*options) |
1884 | return 0; | 1886 | return 0; |
1885 | 1887 | ||
1886 | while (!r && (this_opt = strsep(&options, ",")) != NULL) { | 1888 | while (!r && (this_opt = strsep(&options, ",")) != NULL) { |
1887 | if (!strncmp(this_opt, "accel", 5)) | 1889 | if (!strncmp(this_opt, "accel", 5)) |
1888 | def_accel = 1; | 1890 | def_accel = 1; |
1889 | else if (!strncmp(this_opt, "vram:", 5)) { | 1891 | else if (!strncmp(this_opt, "vram:", 5)) { |
1890 | char *suffix; | 1892 | char *suffix; |
1891 | unsigned long vram; | 1893 | unsigned long vram; |
1892 | vram = (simple_strtoul(this_opt + 5, &suffix, 0)); | 1894 | vram = (simple_strtoul(this_opt + 5, &suffix, 0)); |
1893 | switch (suffix[0]) { | 1895 | switch (suffix[0]) { |
1894 | case '\0': | 1896 | case '\0': |
1895 | break; | 1897 | break; |
1896 | case 'm': | 1898 | case 'm': |
1897 | case 'M': | 1899 | case 'M': |
1898 | vram *= 1024; | 1900 | vram *= 1024; |
1899 | /* Fall through */ | 1901 | /* Fall through */ |
1900 | case 'k': | 1902 | case 'k': |
1901 | case 'K': | 1903 | case 'K': |
1902 | vram *= 1024; | 1904 | vram *= 1024; |
1903 | break; | 1905 | break; |
1904 | default: | 1906 | default: |
1905 | pr_debug("omapfb: invalid vram suffix %c\n", | 1907 | pr_debug("omapfb: invalid vram suffix %c\n", |
1906 | suffix[0]); | 1908 | suffix[0]); |
1907 | r = -1; | 1909 | r = -1; |
1908 | } | 1910 | } |
1909 | def_vram[def_vram_cnt++] = vram; | 1911 | def_vram[def_vram_cnt++] = vram; |
1910 | } | 1912 | } |
1911 | else if (!strncmp(this_opt, "vxres:", 6)) | 1913 | else if (!strncmp(this_opt, "vxres:", 6)) |
1912 | def_vxres = simple_strtoul(this_opt + 6, NULL, 0); | 1914 | def_vxres = simple_strtoul(this_opt + 6, NULL, 0); |
1913 | else if (!strncmp(this_opt, "vyres:", 6)) | 1915 | else if (!strncmp(this_opt, "vyres:", 6)) |
1914 | def_vyres = simple_strtoul(this_opt + 6, NULL, 0); | 1916 | def_vyres = simple_strtoul(this_opt + 6, NULL, 0); |
1915 | else if (!strncmp(this_opt, "rotate:", 7)) | 1917 | else if (!strncmp(this_opt, "rotate:", 7)) |
1916 | def_rotate = (simple_strtoul(this_opt + 7, NULL, 0)); | 1918 | def_rotate = (simple_strtoul(this_opt + 7, NULL, 0)); |
1917 | else if (!strncmp(this_opt, "mirror:", 7)) | 1919 | else if (!strncmp(this_opt, "mirror:", 7)) |
1918 | def_mirror = (simple_strtoul(this_opt + 7, NULL, 0)); | 1920 | def_mirror = (simple_strtoul(this_opt + 7, NULL, 0)); |
1919 | else if (!strncmp(this_opt, "manual_update", 13)) | 1921 | else if (!strncmp(this_opt, "manual_update", 13)) |
1920 | manual_update = 1; | 1922 | manual_update = 1; |
1921 | else { | 1923 | else { |
1922 | pr_debug("omapfb: invalid option\n"); | 1924 | pr_debug("omapfb: invalid option\n"); |
1923 | r = -1; | 1925 | r = -1; |
1924 | } | 1926 | } |
1925 | } | 1927 | } |
1926 | 1928 | ||
1927 | return r; | 1929 | return r; |
1928 | } | 1930 | } |
1929 | 1931 | ||
1930 | #endif | 1932 | #endif |
1931 | 1933 | ||
1932 | /* Register both the driver and the device */ | 1934 | /* Register both the driver and the device */ |
1933 | static int __init omapfb_init(void) | 1935 | static int __init omapfb_init(void) |
1934 | { | 1936 | { |
1935 | #ifndef MODULE | 1937 | #ifndef MODULE |
1936 | char *option; | 1938 | char *option; |
1937 | 1939 | ||
1938 | if (fb_get_options("omapfb", &option)) | 1940 | if (fb_get_options("omapfb", &option)) |
1939 | return -ENODEV; | 1941 | return -ENODEV; |
1940 | omapfb_setup(option); | 1942 | omapfb_setup(option); |
1941 | #endif | 1943 | #endif |
1942 | /* Register the driver with LDM */ | 1944 | /* Register the driver with LDM */ |
1943 | if (platform_driver_register(&omapfb_driver)) { | 1945 | if (platform_driver_register(&omapfb_driver)) { |
1944 | pr_debug("failed to register omapfb driver\n"); | 1946 | pr_debug("failed to register omapfb driver\n"); |
1945 | return -ENODEV; | 1947 | return -ENODEV; |
1946 | } | 1948 | } |
1947 | 1949 | ||
1948 | return 0; | 1950 | return 0; |
1949 | } | 1951 | } |
1950 | 1952 | ||
1951 | static void __exit omapfb_cleanup(void) | 1953 | static void __exit omapfb_cleanup(void) |
1952 | { | 1954 | { |
1953 | platform_driver_unregister(&omapfb_driver); | 1955 | platform_driver_unregister(&omapfb_driver); |
1954 | } | 1956 | } |
1955 | 1957 | ||
1956 | module_param_named(accel, def_accel, uint, 0664); | 1958 | module_param_named(accel, def_accel, uint, 0664); |
1957 | module_param_array_named(vram, def_vram, ulong, &def_vram_cnt, 0664); | 1959 | module_param_array_named(vram, def_vram, ulong, &def_vram_cnt, 0664); |
1958 | module_param_named(vxres, def_vxres, long, 0664); | 1960 | module_param_named(vxres, def_vxres, long, 0664); |
1959 | module_param_named(vyres, def_vyres, long, 0664); | 1961 | module_param_named(vyres, def_vyres, long, 0664); |
1960 | module_param_named(rotate, def_rotate, uint, 0664); | 1962 | module_param_named(rotate, def_rotate, uint, 0664); |
1961 | module_param_named(mirror, def_mirror, uint, 0664); | 1963 | module_param_named(mirror, def_mirror, uint, 0664); |
1962 | module_param_named(manual_update, manual_update, bool, 0664); | 1964 | module_param_named(manual_update, manual_update, bool, 0664); |
1963 | 1965 | ||
1964 | module_init(omapfb_init); | 1966 | module_init(omapfb_init); |
1965 | module_exit(omapfb_cleanup); | 1967 | module_exit(omapfb_cleanup); |
1966 | 1968 | ||
1967 | MODULE_DESCRIPTION("TI OMAP framebuffer driver"); | 1969 | MODULE_DESCRIPTION("TI OMAP framebuffer driver"); |
1968 | MODULE_AUTHOR("Imre Deak <imre.deak@nokia.com>"); | 1970 | MODULE_AUTHOR("Imre Deak <imre.deak@nokia.com>"); |
1969 | MODULE_LICENSE("GPL"); | 1971 | MODULE_LICENSE("GPL"); |
1970 | 1972 |