Changeset fd375a8d in mainline for boot/genarch/ofw.c


Ignore:
Timestamp:
2009-02-03T13:50:26Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
753d851
Parents:
eddf924
Message:

more exact RGB323 palette calculation
set the RGB323 palette on ppc32

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/ofw.c

    reddf924 rfd375a8d  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#include <ofw.h>
    3030#include <ofwarch.h>
     
    373373}
    374374
     375#define RED(i)    (((i) >> 5) & ((1 << 3) - 1))
     376#define GREEN(i)  (((i) >> 3) & ((1 << 2) - 1))
     377#define BLUE(i)   ((i) & ((1 << 3) - 1))
     378#define CLIP(i)   ((i) <= 255 ? (i) : 255)
     379
     380
    375381/**
    376382 * Sets up the palette for the 8-bit color depth configuration so that the
    377383 * 3:2:3 color scheme can be used. Checks that setting the palette makes sense
    378384 * (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
     385 * than 8).
     386 *
     387 * @return true if the palette has been set, false otherwise
     388 *
    382389 */
    383 int setup_palette(void)
     390int ofw_setup_palette(void)
    384391{
    385392        char device_name[BUF_SIZE];
     
    387394        /* resolve alias */
    388395        if (ofw_get_property(ofw_aliases, "screen", device_name,
    389                 sizeof(device_name)) <= 0)
    390                 return false;
    391 
     396            sizeof(device_name)) <= 0)
     397                return false;
     398       
    392399        /* for depth greater than 8 it makes no sense to set up the palette */
    393400        uint32_t depth;
     
    404411        if (screen == -1)
    405412                return false;
    406 
     413       
    407414        /* setup the palette so that the (inverted) 3:2:3 scheme is usable */
    408415        unsigned int i;
    409416        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);
     417                ofw_call("call-method", 6, 1, NULL, "color!", screen,
     418                    255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37));
    415419        return true;
    416420}
Note: See TracChangeset for help on using the changeset viewer.