Statistics
| Branch: | Revision:

root / hw / tc6393xb_template.h @ d94f9486

History | View | Annotate | Download (2.3 kB)

1
/*
2
 * Toshiba TC6393XB I/O Controller.
3
 * Found in Sharp Zaurus SL-6000 (tosa) or some
4
 * Toshiba e-Series PDAs.
5
 *
6
 * FB support code. Based on G364 fb emulator
7
 *
8
 * Copyright (c) 2007 Herv? Poussineau
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License as
12
 * published by the Free Software Foundation; either version 2 of
13
 * the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License along
21
 * with this program; if not, write to the Free Software Foundation, Inc.,
22
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
 */
24

    
25
#if BITS == 8
26
# define SET_PIXEL(addr, color)        *(uint8_t*)addr = color;
27
#elif BITS == 15 || BITS == 16
28
# define SET_PIXEL(addr, color)        *(uint16_t*)addr = color;
29
#elif BITS == 24
30
# define SET_PIXEL(addr, color)        \
31
    addr[0] = color; addr[1] = (color) >> 8; addr[2] = (color) >> 16;
32
#elif BITS == 32
33
# define SET_PIXEL(addr, color)        *(uint32_t*)addr = color;
34
#else
35
# error unknown bit depth
36
#endif
37

    
38

    
39
static void glue(tc6393xb_draw_graphic, BITS)(struct tc6393xb_s *s)
40
{
41
    int i;
42
    int w_display;
43
    uint16_t *data_buffer;
44
    uint8_t *data_display;
45

    
46
    data_buffer = s->vram_ptr;
47
    w_display = s->scr_width * BITS / 8;
48
    data_display = ds_get_data(s->ds);
49
    for(i = 0; i < s->scr_height; i++) {
50
#if (BITS == 16)
51
        memcpy(data_display, data_buffer, s->scr_width * 2);
52
        data_buffer += s->scr_width;
53
        data_display += ds_get_linesize(s->ds);
54
#else
55
        int j;
56
        for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
57
            uint16_t color = *data_buffer;
58
            uint32_t dest_color = glue(rgb_to_pixel, BITS)(
59
                           ((color & 0xf800) * 0x108) >> 11,
60
                           ((color & 0x7e0) * 0x41) >> 9,
61
                           ((color & 0x1f) * 0x21) >> 2
62
                           );
63
            SET_PIXEL(data_display, dest_color);
64
        }
65
#endif
66
    }
67
}
68

    
69
#undef BITS
70
#undef SET_PIXEL