Statistics
| Branch: | Revision:

root / hw / tc6393xb_template.h @ aba35a6c

History | View | Annotate | Download (2.3 kB)

1 64b40bc5 balrog
/*
2 64b40bc5 balrog
 * Toshiba TC6393XB I/O Controller.
3 64b40bc5 balrog
 * Found in Sharp Zaurus SL-6000 (tosa) or some
4 64b40bc5 balrog
 * Toshiba e-Series PDAs.
5 64b40bc5 balrog
 *
6 64b40bc5 balrog
 * FB support code. Based on G364 fb emulator
7 64b40bc5 balrog
 *
8 64b40bc5 balrog
 * Copyright (c) 2007 Herv? Poussineau
9 64b40bc5 balrog
 *
10 64b40bc5 balrog
 * This program is free software; you can redistribute it and/or
11 64b40bc5 balrog
 * modify it under the terms of the GNU General Public License as
12 64b40bc5 balrog
 * published by the Free Software Foundation; either version 2 of
13 64b40bc5 balrog
 * the License, or (at your option) any later version.
14 64b40bc5 balrog
 *
15 64b40bc5 balrog
 * This program is distributed in the hope that it will be useful,
16 64b40bc5 balrog
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 64b40bc5 balrog
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 64b40bc5 balrog
 * GNU General Public License for more details.
19 64b40bc5 balrog
 *
20 fad6cb1a aurel32
 * You should have received a copy of the GNU General Public License along
21 fad6cb1a aurel32
 * with this program; if not, write to the Free Software Foundation, Inc.,
22 fad6cb1a aurel32
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 64b40bc5 balrog
 */
24 64b40bc5 balrog
25 64b40bc5 balrog
#if BITS == 8
26 64b40bc5 balrog
# define SET_PIXEL(addr, color)        *(uint8_t*)addr = color;
27 64b40bc5 balrog
#elif BITS == 15 || BITS == 16
28 64b40bc5 balrog
# define SET_PIXEL(addr, color)        *(uint16_t*)addr = color;
29 64b40bc5 balrog
#elif BITS == 24
30 64b40bc5 balrog
# define SET_PIXEL(addr, color)        \
31 64b40bc5 balrog
    addr[0] = color; addr[1] = (color) >> 8; addr[2] = (color) >> 16;
32 64b40bc5 balrog
#elif BITS == 32
33 64b40bc5 balrog
# define SET_PIXEL(addr, color)        *(uint32_t*)addr = color;
34 64b40bc5 balrog
#else
35 64b40bc5 balrog
# error unknown bit depth
36 64b40bc5 balrog
#endif
37 64b40bc5 balrog
38 64b40bc5 balrog
39 64b40bc5 balrog
static void glue(tc6393xb_draw_graphic, BITS)(struct tc6393xb_s *s)
40 64b40bc5 balrog
{
41 64b40bc5 balrog
    int i;
42 64b40bc5 balrog
    int w_display;
43 64b40bc5 balrog
    uint16_t *data_buffer;
44 64b40bc5 balrog
    uint8_t *data_display;
45 64b40bc5 balrog
46 64b40bc5 balrog
    data_buffer = (uint16_t*)(phys_ram_base + s->vram_addr);
47 64b40bc5 balrog
    w_display = s->scr_width * BITS / 8;
48 0e1f5a0c aliguori
    data_display = ds_get_data(s->ds);
49 64b40bc5 balrog
    for(i = 0; i < s->scr_height; i++) {
50 64b40bc5 balrog
#if (BITS == 16)
51 64b40bc5 balrog
        memcpy(data_display, data_buffer, s->scr_width * 2);
52 64b40bc5 balrog
        data_buffer += s->scr_width;
53 0e1f5a0c aliguori
        data_display += ds_get_linesize(s->ds);
54 64b40bc5 balrog
#else
55 64b40bc5 balrog
        int j;
56 64b40bc5 balrog
        for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
57 64b40bc5 balrog
            uint16_t color = *data_buffer;
58 64b40bc5 balrog
            uint32_t dest_color = glue(rgb_to_pixel, BITS)(
59 64b40bc5 balrog
                           ((color & 0xf800) * 0x108) >> 11,
60 64b40bc5 balrog
                           ((color & 0x7e0) * 0x41) >> 9,
61 64b40bc5 balrog
                           ((color & 0x1f) * 0x21) >> 2
62 64b40bc5 balrog
                           );
63 64b40bc5 balrog
            SET_PIXEL(data_display, dest_color);
64 64b40bc5 balrog
        }
65 64b40bc5 balrog
#endif
66 64b40bc5 balrog
    }
67 64b40bc5 balrog
}
68 64b40bc5 balrog
69 64b40bc5 balrog
#undef BITS
70 64b40bc5 balrog
#undef SET_PIXEL