Rev 3674 | Rev 4341 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3674 | Rev 4337 | ||
---|---|---|---|
Line 296... | Line 296... | ||
296 | { |
296 | { |
297 | unsigned int ac = ofw_get_address_cells(ofw_memory) / |
297 | unsigned int ac = ofw_get_address_cells(ofw_memory) / |
298 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
298 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
299 | unsigned int sc = ofw_get_size_cells(ofw_memory) / |
299 | unsigned int sc = ofw_get_size_cells(ofw_memory) / |
300 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
300 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
301 | printf("address cells: %d, size cells: %d. ", ac, sc); |
- | |
302 | 301 | ||
303 | uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; |
302 | uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; |
304 | int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf)); |
303 | int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf)); |
305 | if (ret <= 0) /* ret is the number of written bytes */ |
304 | if (ret <= 0) /* ret is the number of written bytes */ |
306 | return false; |
305 | return false; |
Line 371... | Line 370... | ||
371 | return false; |
370 | return false; |
372 | 371 | ||
373 | return true; |
372 | return true; |
374 | } |
373 | } |
375 | 374 | ||
- | 375 | /** |
|
- | 376 | * Sets up the palette for the 8-bit color depth configuration so that the |
|
- | 377 | * 3:2:3 color scheme can be used. Checks that setting the palette makes sense |
|
- | 378 | * (appropriate nodes exist in the OBP tree and the color depth is not greater |
|
- | 379 | * than 8). |
|
- | 380 | * |
|
- | 381 | * @return true if the palette has been set, false otherwise |
|
- | 382 | */ |
|
- | 383 | int setup_palette(void) |
|
- | 384 | { |
|
- | 385 | char device_name[BUF_SIZE]; |
|
- | 386 | ||
- | 387 | /* resolve alias */ |
|
- | 388 | if (ofw_get_property(ofw_aliases, "screen", device_name, |
|
- | 389 | sizeof(device_name)) <= 0) |
|
- | 390 | return false; |
|
- | 391 | ||
- | 392 | /* for depth greater than 8 it makes no sense to set up the palette */ |
|
- | 393 | uint32_t depth; |
|
- | 394 | phandle device = ofw_find_device(device_name); |
|
- | 395 | if (device == -1) |
|
- | 396 | return false; |
|
- | 397 | if (ofw_get_property(device, "depth", &depth, sizeof(uint32_t)) <= 0) |
|
- | 398 | return false; |
|
- | 399 | if (depth != 8) |
|
- | 400 | return false; |
|
- | 401 | ||
- | 402 | /* required in order to be able to make a method call */ |
|
- | 403 | ihandle screen = ofw_open(device_name); |
|
- | 404 | if (screen == -1) |
|
- | 405 | return false; |
|
- | 406 | ||
- | 407 | /* setup the palette so that the (inverted) 3:2:3 scheme is usable */ |
|
- | 408 | unsigned int i; |
|
- | 409 | for (i = 0; i < 256; i++) |
|
- | 410 | if (ofw_call("call-method", 6, 1, NULL, "color!", screen, |
|
- | 411 | 255 - i, |
|
- | 412 | i << 5, |
|
- | 413 | (i >> 3) << 6, |
|
- | 414 | (i >> 5) << 5) != 0); |
|
- | 415 | return true; |
|
- | 416 | } |
|
376 | 417 | ||
377 | void ofw_quiesce(void) |
418 | void ofw_quiesce(void) |
378 | { |
419 | { |
379 | ofw_call("quiesce", 0, 0, NULL); |
420 | ofw_call("quiesce", 0, 0, NULL); |
380 | } |
421 | } |