diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2006-07-03 03:19:48 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-07-03 03:19:48 -0400 |
commit | ab13446616118dc61c00ea50cc49919400717dd0 (patch) | |
tree | 3758a9db2938e354ea77629330551d7be8236ccd | |
parent | 4ce631e7a229a0e073078a197ed37d437cabcde0 (diff) |
[POWERPC] Fix various offb and BootX-related issues
This patch fixes various issues with offb (the default fbdev used on
powerpc when no proper fbdev is supported). It was broken when using
BootX under some circumstances and would fail to properly get the
framebuffer base address in others.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/kernel/btext.c | 20 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_32.c | 1 | ||||
-rw-r--r-- | arch/powerpc/platforms/powermac/bootx_init.c | 29 | ||||
-rw-r--r-- | drivers/video/offb.c | 284 |
4 files changed, 161 insertions, 173 deletions
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c index a6920919d68e..f4e5e14ee2b6 100644 --- a/arch/powerpc/kernel/btext.c +++ b/arch/powerpc/kernel/btext.c | |||
@@ -111,7 +111,7 @@ void __init btext_setup_display(int width, int height, int depth, int pitch, | |||
111 | logicalDisplayBase = (unsigned char *)address; | 111 | logicalDisplayBase = (unsigned char *)address; |
112 | dispDeviceBase = (unsigned char *)address; | 112 | dispDeviceBase = (unsigned char *)address; |
113 | dispDeviceRowBytes = pitch; | 113 | dispDeviceRowBytes = pitch; |
114 | dispDeviceDepth = depth; | 114 | dispDeviceDepth = depth == 15 ? 16 : depth; |
115 | dispDeviceRect[0] = dispDeviceRect[1] = 0; | 115 | dispDeviceRect[0] = dispDeviceRect[1] = 0; |
116 | dispDeviceRect[2] = width; | 116 | dispDeviceRect[2] = width; |
117 | dispDeviceRect[3] = height; | 117 | dispDeviceRect[3] = height; |
@@ -160,20 +160,28 @@ int btext_initialize(struct device_node *np) | |||
160 | unsigned long address = 0; | 160 | unsigned long address = 0; |
161 | u32 *prop; | 161 | u32 *prop; |
162 | 162 | ||
163 | prop = (u32 *)get_property(np, "width", NULL); | 163 | prop = (u32 *)get_property(np, "linux,bootx-width", NULL); |
164 | if (prop == NULL) | ||
165 | prop = (u32 *)get_property(np, "width", NULL); | ||
164 | if (prop == NULL) | 166 | if (prop == NULL) |
165 | return -EINVAL; | 167 | return -EINVAL; |
166 | width = *prop; | 168 | width = *prop; |
167 | prop = (u32 *)get_property(np, "height", NULL); | 169 | prop = (u32 *)get_property(np, "linux,bootx-height", NULL); |
170 | if (prop == NULL) | ||
171 | prop = (u32 *)get_property(np, "height", NULL); | ||
168 | if (prop == NULL) | 172 | if (prop == NULL) |
169 | return -EINVAL; | 173 | return -EINVAL; |
170 | height = *prop; | 174 | height = *prop; |
171 | prop = (u32 *)get_property(np, "depth", NULL); | 175 | prop = (u32 *)get_property(np, "linux,bootx-depth", NULL); |
176 | if (prop == NULL) | ||
177 | prop = (u32 *)get_property(np, "depth", NULL); | ||
172 | if (prop == NULL) | 178 | if (prop == NULL) |
173 | return -EINVAL; | 179 | return -EINVAL; |
174 | depth = *prop; | 180 | depth = *prop; |
175 | pitch = width * ((depth + 7) / 8); | 181 | pitch = width * ((depth + 7) / 8); |
176 | prop = (u32 *)get_property(np, "linebytes", NULL); | 182 | prop = (u32 *)get_property(np, "linux,bootx-linebytes", NULL); |
183 | if (prop == NULL) | ||
184 | prop = (u32 *)get_property(np, "linebytes", NULL); | ||
177 | if (prop) | 185 | if (prop) |
178 | pitch = *prop; | 186 | pitch = *prop; |
179 | if (pitch == 1) | 187 | if (pitch == 1) |
@@ -194,7 +202,7 @@ int btext_initialize(struct device_node *np) | |||
194 | g_max_loc_Y = height / 16; | 202 | g_max_loc_Y = height / 16; |
195 | dispDeviceBase = (unsigned char *)address; | 203 | dispDeviceBase = (unsigned char *)address; |
196 | dispDeviceRowBytes = pitch; | 204 | dispDeviceRowBytes = pitch; |
197 | dispDeviceDepth = depth; | 205 | dispDeviceDepth = depth == 15 ? 16 : depth; |
198 | dispDeviceRect[0] = dispDeviceRect[1] = 0; | 206 | dispDeviceRect[0] = dispDeviceRect[1] = 0; |
199 | dispDeviceRect[2] = width; | 207 | dispDeviceRect[2] = width; |
200 | dispDeviceRect[3] = height; | 208 | dispDeviceRect[3] = height; |
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index ba7cd50d820d..0c21de39c161 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -51,7 +51,6 @@ | |||
51 | 51 | ||
52 | extern void bootx_init(unsigned long r4, unsigned long phys); | 52 | extern void bootx_init(unsigned long r4, unsigned long phys); |
53 | 53 | ||
54 | boot_infos_t *boot_infos; | ||
55 | struct ide_machdep_calls ppc_ide_md; | 54 | struct ide_machdep_calls ppc_ide_md; |
56 | 55 | ||
57 | int boot_cpuid; | 56 | int boot_cpuid; |
diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c index cb257aeb91f6..5685ad9e88e8 100644 --- a/arch/powerpc/platforms/powermac/bootx_init.c +++ b/arch/powerpc/platforms/powermac/bootx_init.c | |||
@@ -181,8 +181,25 @@ static void __init bootx_add_chosen_props(unsigned long base, | |||
181 | static void __init bootx_add_display_props(unsigned long base, | 181 | static void __init bootx_add_display_props(unsigned long base, |
182 | unsigned long *mem_end) | 182 | unsigned long *mem_end) |
183 | { | 183 | { |
184 | boot_infos_t *bi = bootx_info; | ||
185 | u32 tmp; | ||
186 | |||
184 | bootx_dt_add_prop("linux,boot-display", NULL, 0, mem_end); | 187 | bootx_dt_add_prop("linux,boot-display", NULL, 0, mem_end); |
185 | bootx_dt_add_prop("linux,opened", NULL, 0, mem_end); | 188 | bootx_dt_add_prop("linux,opened", NULL, 0, mem_end); |
189 | tmp = bi->dispDeviceDepth; | ||
190 | bootx_dt_add_prop("linux,bootx-depth", &tmp, 4, mem_end); | ||
191 | tmp = bi->dispDeviceRect[2] - bi->dispDeviceRect[0]; | ||
192 | bootx_dt_add_prop("linux,bootx-width", &tmp, 4, mem_end); | ||
193 | tmp = bi->dispDeviceRect[3] - bi->dispDeviceRect[1]; | ||
194 | bootx_dt_add_prop("linux,bootx-height", &tmp, 4, mem_end); | ||
195 | tmp = bi->dispDeviceRowBytes; | ||
196 | bootx_dt_add_prop("linux,bootx-linebytes", &tmp, 4, mem_end); | ||
197 | tmp = (u32)bi->dispDeviceBase; | ||
198 | if (tmp == 0) | ||
199 | tmp = (u32)bi->logicalDisplayBase; | ||
200 | tmp += bi->dispDeviceRect[1] * bi->dispDeviceRowBytes; | ||
201 | tmp += bi->dispDeviceRect[0] * ((bi->dispDeviceDepth + 7) / 8); | ||
202 | bootx_dt_add_prop("linux,bootx-addr", &tmp, 4, mem_end); | ||
186 | } | 203 | } |
187 | 204 | ||
188 | static void __init bootx_dt_add_string(char *s, unsigned long *mem_end) | 205 | static void __init bootx_dt_add_string(char *s, unsigned long *mem_end) |
@@ -222,6 +239,11 @@ static void __init bootx_scan_dt_build_strings(unsigned long base, | |||
222 | DBG(" detected display ! adding properties names !\n"); | 239 | DBG(" detected display ! adding properties names !\n"); |
223 | bootx_dt_add_string("linux,boot-display", mem_end); | 240 | bootx_dt_add_string("linux,boot-display", mem_end); |
224 | bootx_dt_add_string("linux,opened", mem_end); | 241 | bootx_dt_add_string("linux,opened", mem_end); |
242 | bootx_dt_add_string("linux,bootx-depth", mem_end); | ||
243 | bootx_dt_add_string("linux,bootx-width", mem_end); | ||
244 | bootx_dt_add_string("linux,bootx-height", mem_end); | ||
245 | bootx_dt_add_string("linux,bootx-linebytes", mem_end); | ||
246 | bootx_dt_add_string("linux,bootx-addr", mem_end); | ||
225 | strncpy(bootx_disp_path, namep, 255); | 247 | strncpy(bootx_disp_path, namep, 255); |
226 | } | 248 | } |
227 | 249 | ||
@@ -443,7 +465,14 @@ void __init bootx_init(unsigned long r3, unsigned long r4) | |||
443 | if (!BOOT_INFO_IS_V2_COMPATIBLE(bi)) | 465 | if (!BOOT_INFO_IS_V2_COMPATIBLE(bi)) |
444 | bi->logicalDisplayBase = bi->dispDeviceBase; | 466 | bi->logicalDisplayBase = bi->dispDeviceBase; |
445 | 467 | ||
468 | /* Fixup depth 16 -> 15 as that's what MacOS calls 16bpp */ | ||
469 | if (bi->dispDeviceDepth == 16) | ||
470 | bi->dispDeviceDepth = 15; | ||
471 | |||
446 | #ifdef CONFIG_BOOTX_TEXT | 472 | #ifdef CONFIG_BOOTX_TEXT |
473 | ptr = (unsigned long)bi->logicalDisplayBase; | ||
474 | ptr += bi->dispDeviceRect[1] * bi->dispDeviceRowBytes; | ||
475 | ptr += bi->dispDeviceRect[0] * ((bi->dispDeviceDepth + 7) / 8); | ||
447 | btext_setup_display(bi->dispDeviceRect[2] - bi->dispDeviceRect[0], | 476 | btext_setup_display(bi->dispDeviceRect[2] - bi->dispDeviceRect[0], |
448 | bi->dispDeviceRect[3] - bi->dispDeviceRect[1], | 477 | bi->dispDeviceRect[3] - bi->dispDeviceRect[1], |
449 | bi->dispDeviceDepth, bi->dispDeviceRowBytes, | 478 | bi->dispDeviceDepth, bi->dispDeviceRowBytes, |
diff --git a/drivers/video/offb.c b/drivers/video/offb.c index bfeb11bd4712..71ce1fa45cf4 100644 --- a/drivers/video/offb.c +++ b/drivers/video/offb.c | |||
@@ -97,14 +97,43 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
97 | u_int transp, struct fb_info *info) | 97 | u_int transp, struct fb_info *info) |
98 | { | 98 | { |
99 | struct offb_par *par = (struct offb_par *) info->par; | 99 | struct offb_par *par = (struct offb_par *) info->par; |
100 | int i, depth; | ||
101 | u32 *pal = info->pseudo_palette; | ||
100 | 102 | ||
101 | if (!par->cmap_adr || regno > 255) | 103 | depth = info->var.bits_per_pixel; |
104 | if (depth == 16) | ||
105 | depth = (info->var.green.length == 5) ? 15 : 16; | ||
106 | |||
107 | if (regno > 255 || | ||
108 | (depth == 16 && regno > 63) || | ||
109 | (depth == 15 && regno > 31)) | ||
102 | return 1; | 110 | return 1; |
103 | 111 | ||
112 | if (regno < 16) { | ||
113 | switch (depth) { | ||
114 | case 15: | ||
115 | pal[regno] = (regno << 10) | (regno << 5) | regno; | ||
116 | break; | ||
117 | case 16: | ||
118 | pal[regno] = (regno << 11) | (regno << 5) | regno; | ||
119 | break; | ||
120 | case 24: | ||
121 | pal[regno] = (regno << 16) | (regno << 8) | regno; | ||
122 | break; | ||
123 | case 32: | ||
124 | i = (regno << 8) | regno; | ||
125 | pal[regno] = (i << 16) | i; | ||
126 | break; | ||
127 | } | ||
128 | } | ||
129 | |||
104 | red >>= 8; | 130 | red >>= 8; |
105 | green >>= 8; | 131 | green >>= 8; |
106 | blue >>= 8; | 132 | blue >>= 8; |
107 | 133 | ||
134 | if (!par->cmap_adr) | ||
135 | return 0; | ||
136 | |||
108 | switch (par->cmap_type) { | 137 | switch (par->cmap_type) { |
109 | case cmap_m64: | 138 | case cmap_m64: |
110 | writeb(regno, par->cmap_adr); | 139 | writeb(regno, par->cmap_adr); |
@@ -141,20 +170,6 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
141 | break; | 170 | break; |
142 | } | 171 | } |
143 | 172 | ||
144 | if (regno < 16) | ||
145 | switch (info->var.bits_per_pixel) { | ||
146 | case 16: | ||
147 | ((u16 *) (info->pseudo_palette))[regno] = | ||
148 | (regno << 10) | (regno << 5) | regno; | ||
149 | break; | ||
150 | case 32: | ||
151 | { | ||
152 | int i = (regno << 8) | regno; | ||
153 | ((u32 *) (info->pseudo_palette))[regno] = | ||
154 | (i << 16) | i; | ||
155 | break; | ||
156 | } | ||
157 | } | ||
158 | return 0; | 173 | return 0; |
159 | } | 174 | } |
160 | 175 | ||
@@ -223,81 +238,9 @@ int __init offb_init(void) | |||
223 | { | 238 | { |
224 | struct device_node *dp = NULL, *boot_disp = NULL; | 239 | struct device_node *dp = NULL, *boot_disp = NULL; |
225 | 240 | ||
226 | #if defined(CONFIG_BOOTX_TEXT) && defined(CONFIG_PPC32) | ||
227 | struct device_node *macos_display = NULL; | ||
228 | #endif | ||
229 | if (fb_get_options("offb", NULL)) | 241 | if (fb_get_options("offb", NULL)) |
230 | return -ENODEV; | 242 | return -ENODEV; |
231 | 243 | ||
232 | #if defined(CONFIG_BOOTX_TEXT) && defined(CONFIG_PPC32) | ||
233 | /* If we're booted from BootX... */ | ||
234 | if (boot_infos != 0) { | ||
235 | unsigned long addr = | ||
236 | (unsigned long) boot_infos->dispDeviceBase; | ||
237 | u32 *addrp; | ||
238 | u64 daddr, dsize; | ||
239 | unsigned int flags; | ||
240 | |||
241 | /* find the device node corresponding to the macos display */ | ||
242 | while ((dp = of_find_node_by_type(dp, "display"))) { | ||
243 | int i; | ||
244 | |||
245 | /* | ||
246 | * Look for an AAPL,address property first. | ||
247 | */ | ||
248 | unsigned int na; | ||
249 | unsigned int *ap = | ||
250 | (unsigned int *)get_property(dp, "AAPL,address", | ||
251 | &na); | ||
252 | if (ap != 0) { | ||
253 | for (na /= sizeof(unsigned int); na > 0; | ||
254 | --na, ++ap) | ||
255 | if (*ap <= addr && | ||
256 | addr < *ap + 0x1000000) { | ||
257 | macos_display = dp; | ||
258 | goto foundit; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | /* | ||
263 | * See if the display address is in one of the address | ||
264 | * ranges for this display. | ||
265 | */ | ||
266 | i = 0; | ||
267 | for (;;) { | ||
268 | addrp = of_get_address(dp, i++, &dsize, &flags); | ||
269 | if (addrp == NULL) | ||
270 | break; | ||
271 | if (!(flags & IORESOURCE_MEM)) | ||
272 | continue; | ||
273 | daddr = of_translate_address(dp, addrp); | ||
274 | if (daddr == OF_BAD_ADDR) | ||
275 | continue; | ||
276 | if (daddr <= addr && addr < (daddr + dsize)) { | ||
277 | macos_display = dp; | ||
278 | goto foundit; | ||
279 | } | ||
280 | } | ||
281 | foundit: | ||
282 | if (macos_display) { | ||
283 | printk(KERN_INFO "MacOS display is %s\n", | ||
284 | dp->full_name); | ||
285 | break; | ||
286 | } | ||
287 | } | ||
288 | |||
289 | /* initialize it */ | ||
290 | offb_init_fb(macos_display ? macos_display-> | ||
291 | name : "MacOS display", | ||
292 | macos_display ? macos_display-> | ||
293 | full_name : "MacOS display", | ||
294 | boot_infos->dispDeviceRect[2], | ||
295 | boot_infos->dispDeviceRect[3], | ||
296 | boot_infos->dispDeviceDepth, | ||
297 | boot_infos->dispDeviceRowBytes, addr, NULL); | ||
298 | } | ||
299 | #endif /* defined(CONFIG_BOOTX_TEXT) && defined(CONFIG_PPC32) */ | ||
300 | |||
301 | for (dp = NULL; (dp = of_find_node_by_type(dp, "display"));) { | 244 | for (dp = NULL; (dp = of_find_node_by_type(dp, "display"));) { |
302 | if (get_property(dp, "linux,opened", NULL) && | 245 | if (get_property(dp, "linux,opened", NULL) && |
303 | get_property(dp, "linux,boot-display", NULL)) { | 246 | get_property(dp, "linux,boot-display", NULL)) { |
@@ -317,94 +260,93 @@ int __init offb_init(void) | |||
317 | 260 | ||
318 | static void __init offb_init_nodriver(struct device_node *dp) | 261 | static void __init offb_init_nodriver(struct device_node *dp) |
319 | { | 262 | { |
320 | int *pp, i; | ||
321 | unsigned int len; | 263 | unsigned int len; |
322 | int width = 640, height = 480, depth = 8, pitch; | 264 | int i, width = 640, height = 480, depth = 8, pitch = 640; |
323 | unsigned int flags, rsize, *up; | 265 | unsigned int flags, rsize, addr_prop = 0; |
324 | u64 address = OF_BAD_ADDR; | 266 | unsigned long max_size = 0; |
325 | u32 *addrp; | 267 | u64 rstart, address = OF_BAD_ADDR; |
268 | u32 *pp, *addrp, *up; | ||
326 | u64 asize; | 269 | u64 asize; |
327 | 270 | ||
328 | if ((pp = (int *) get_property(dp, "depth", &len)) != NULL | 271 | pp = (u32 *)get_property(dp, "linux,bootx-depth", &len); |
329 | && len == sizeof(int)) | 272 | if (pp == NULL) |
273 | pp = (u32 *)get_property(dp, "depth", &len); | ||
274 | if (pp && len == sizeof(u32)) | ||
330 | depth = *pp; | 275 | depth = *pp; |
331 | if ((pp = (int *) get_property(dp, "width", &len)) != NULL | 276 | |
332 | && len == sizeof(int)) | 277 | pp = (u32 *)get_property(dp, "linux,bootx-width", &len); |
278 | if (pp == NULL) | ||
279 | pp = (u32 *)get_property(dp, "width", &len); | ||
280 | if (pp && len == sizeof(u32)) | ||
333 | width = *pp; | 281 | width = *pp; |
334 | if ((pp = (int *) get_property(dp, "height", &len)) != NULL | 282 | |
335 | && len == sizeof(int)) | 283 | pp = (u32 *)get_property(dp, "linux,bootx-height", &len); |
284 | if (pp == NULL) | ||
285 | pp = (u32 *)get_property(dp, "height", &len); | ||
286 | if (pp && len == sizeof(u32)) | ||
336 | height = *pp; | 287 | height = *pp; |
337 | if ((pp = (int *) get_property(dp, "linebytes", &len)) != NULL | 288 | |
338 | && len == sizeof(int)) { | 289 | pp = (u32 *)get_property(dp, "linux,bootx-linebytes", &len); |
290 | if (pp == NULL) | ||
291 | pp = (u32 *)get_property(dp, "linebytes", &len); | ||
292 | if (pp && len == sizeof(u32)) | ||
339 | pitch = *pp; | 293 | pitch = *pp; |
340 | if (pitch == 1) | 294 | else |
341 | pitch = 0x1000; | 295 | pitch = width * ((depth + 7) / 8); |
342 | } else | 296 | |
343 | pitch = width; | 297 | rsize = (unsigned long)pitch * (unsigned long)height; |
344 | 298 | ||
345 | rsize = (unsigned long)pitch * (unsigned long)height * | 299 | /* Ok, now we try to figure out the address of the framebuffer. |
346 | (unsigned long)(depth / 8); | 300 | * |
347 | 301 | * Unfortunately, Open Firmware doesn't provide a standard way to do | |
348 | /* Try to match device to a PCI device in order to get a properly | 302 | * so. All we can do is a dodgy heuristic that happens to work in |
349 | * translated address rather then trying to decode the open firmware | 303 | * practice. On most machines, the "address" property contains what |
350 | * stuff in various incorrect ways | 304 | * we need, though not on Matrox cards found in IBM machines. What I've |
351 | */ | 305 | * found that appears to give good results is to go through the PCI |
352 | #ifdef CONFIG_PCI | 306 | * ranges and pick one that is both big enough and if possible encloses |
353 | /* First try to locate the PCI device if any */ | 307 | * the "address" property. If none match, we pick the biggest |
354 | { | 308 | */ |
355 | struct pci_dev *pdev = NULL; | 309 | up = (u32 *)get_property(dp, "linux,bootx-addr", &len); |
356 | 310 | if (up == NULL) | |
357 | for_each_pci_dev(pdev) { | 311 | up = (u32 *)get_property(dp, "address", &len); |
358 | if (dp == pci_device_to_OF_node(pdev)) | 312 | if (up && len == sizeof(u32)) |
359 | break; | 313 | addr_prop = *up; |
360 | } | 314 | |
361 | if (pdev) { | 315 | for (i = 0; (addrp = of_get_address(dp, i, &asize, &flags)) |
362 | for (i = 0; i < 6 && address == OF_BAD_ADDR; i++) { | 316 | != NULL; i++) { |
363 | if ((pci_resource_flags(pdev, i) & | 317 | int match_addrp = 0; |
364 | IORESOURCE_MEM) && | 318 | |
365 | (pci_resource_len(pdev, i) >= rsize)) | 319 | if (!(flags & IORESOURCE_MEM)) |
366 | address = pci_resource_start(pdev, i); | 320 | continue; |
367 | } | 321 | if (asize < rsize) |
368 | pci_dev_put(pdev); | 322 | continue; |
369 | } | 323 | rstart = of_translate_address(dp, addrp); |
370 | } | 324 | if (rstart == OF_BAD_ADDR) |
371 | #endif /* CONFIG_PCI */ | 325 | continue; |
372 | 326 | if (addr_prop && (rstart <= addr_prop) && | |
373 | /* This one is dodgy, we may drop it ... */ | 327 | ((rstart + asize) >= (addr_prop + rsize))) |
374 | if (address == OF_BAD_ADDR && | 328 | match_addrp = 1; |
375 | (up = (unsigned *) get_property(dp, "address", &len)) != NULL && | 329 | if (match_addrp) { |
376 | len == sizeof(unsigned int)) | 330 | address = addr_prop; |
377 | address = (u64) * up; | 331 | break; |
378 | |||
379 | if (address == OF_BAD_ADDR) { | ||
380 | for (i = 0; (addrp = of_get_address(dp, i, &asize, &flags)) | ||
381 | != NULL; i++) { | ||
382 | if (!(flags & IORESOURCE_MEM)) | ||
383 | continue; | ||
384 | if (asize >= pitch * height * depth / 8) | ||
385 | break; | ||
386 | } | ||
387 | if (addrp == NULL) { | ||
388 | printk(KERN_ERR | ||
389 | "no framebuffer address found for %s\n", | ||
390 | dp->full_name); | ||
391 | return; | ||
392 | } | ||
393 | address = of_translate_address(dp, addrp); | ||
394 | if (address == OF_BAD_ADDR) { | ||
395 | printk(KERN_ERR | ||
396 | "can't translate framebuffer address for %s\n", | ||
397 | dp->full_name); | ||
398 | return; | ||
399 | } | 332 | } |
333 | if (rsize > max_size) { | ||
334 | max_size = rsize; | ||
335 | address = OF_BAD_ADDR; | ||
336 | } | ||
400 | 337 | ||
338 | if (address == OF_BAD_ADDR) | ||
339 | address = rstart; | ||
340 | } | ||
341 | if (address == OF_BAD_ADDR && addr_prop) | ||
342 | address = (u64)addr_prop; | ||
343 | if (address != OF_BAD_ADDR) { | ||
401 | /* kludge for valkyrie */ | 344 | /* kludge for valkyrie */ |
402 | if (strcmp(dp->name, "valkyrie") == 0) | 345 | if (strcmp(dp->name, "valkyrie") == 0) |
403 | address += 0x1000; | 346 | address += 0x1000; |
347 | offb_init_fb(dp->name, dp->full_name, width, height, depth, | ||
348 | pitch, address, dp); | ||
404 | } | 349 | } |
405 | offb_init_fb(dp->name, dp->full_name, width, height, depth, | ||
406 | pitch, address, dp); | ||
407 | |||
408 | } | 350 | } |
409 | 351 | ||
410 | static void __init offb_init_fb(const char *name, const char *full_name, | 352 | static void __init offb_init_fb(const char *name, const char *full_name, |
@@ -412,7 +354,7 @@ static void __init offb_init_fb(const char *name, const char *full_name, | |||
412 | int pitch, unsigned long address, | 354 | int pitch, unsigned long address, |
413 | struct device_node *dp) | 355 | struct device_node *dp) |
414 | { | 356 | { |
415 | unsigned long res_size = pitch * height * depth / 8; | 357 | unsigned long res_size = pitch * height * (depth + 7) / 8; |
416 | struct offb_par *par = &default_par; | 358 | struct offb_par *par = &default_par; |
417 | unsigned long res_start = address; | 359 | unsigned long res_start = address; |
418 | struct fb_fix_screeninfo *fix; | 360 | struct fb_fix_screeninfo *fix; |
@@ -426,7 +368,7 @@ static void __init offb_init_fb(const char *name, const char *full_name, | |||
426 | printk(KERN_INFO | 368 | printk(KERN_INFO |
427 | "Using unsupported %dx%d %s at %lx, depth=%d, pitch=%d\n", | 369 | "Using unsupported %dx%d %s at %lx, depth=%d, pitch=%d\n", |
428 | width, height, name, address, depth, pitch); | 370 | width, height, name, address, depth, pitch); |
429 | if (depth != 8 && depth != 16 && depth != 32) { | 371 | if (depth != 8 && depth != 15 && depth != 16 && depth != 32) { |
430 | printk(KERN_ERR "%s: can't use depth = %d\n", full_name, | 372 | printk(KERN_ERR "%s: can't use depth = %d\n", full_name, |
431 | depth); | 373 | depth); |
432 | release_mem_region(res_start, res_size); | 374 | release_mem_region(res_start, res_size); |
@@ -502,7 +444,6 @@ static void __init offb_init_fb(const char *name, const char *full_name, | |||
502 | : */ FB_VISUAL_TRUECOLOR; | 444 | : */ FB_VISUAL_TRUECOLOR; |
503 | 445 | ||
504 | var->xoffset = var->yoffset = 0; | 446 | var->xoffset = var->yoffset = 0; |
505 | var->bits_per_pixel = depth; | ||
506 | switch (depth) { | 447 | switch (depth) { |
507 | case 8: | 448 | case 8: |
508 | var->bits_per_pixel = 8; | 449 | var->bits_per_pixel = 8; |
@@ -515,7 +456,7 @@ static void __init offb_init_fb(const char *name, const char *full_name, | |||
515 | var->transp.offset = 0; | 456 | var->transp.offset = 0; |
516 | var->transp.length = 0; | 457 | var->transp.length = 0; |
517 | break; | 458 | break; |
518 | case 16: /* RGB 555 */ | 459 | case 15: /* RGB 555 */ |
519 | var->bits_per_pixel = 16; | 460 | var->bits_per_pixel = 16; |
520 | var->red.offset = 10; | 461 | var->red.offset = 10; |
521 | var->red.length = 5; | 462 | var->red.length = 5; |
@@ -526,6 +467,17 @@ static void __init offb_init_fb(const char *name, const char *full_name, | |||
526 | var->transp.offset = 0; | 467 | var->transp.offset = 0; |
527 | var->transp.length = 0; | 468 | var->transp.length = 0; |
528 | break; | 469 | break; |
470 | case 16: /* RGB 565 */ | ||
471 | var->bits_per_pixel = 16; | ||
472 | var->red.offset = 11; | ||
473 | var->red.length = 5; | ||
474 | var->green.offset = 5; | ||
475 | var->green.length = 6; | ||
476 | var->blue.offset = 0; | ||
477 | var->blue.length = 5; | ||
478 | var->transp.offset = 0; | ||
479 | var->transp.length = 0; | ||
480 | break; | ||
529 | case 32: /* RGB 888 */ | 481 | case 32: /* RGB 888 */ |
530 | var->bits_per_pixel = 32; | 482 | var->bits_per_pixel = 32; |
531 | var->red.offset = 16; | 483 | var->red.offset = 16; |