Changeset 198a9ef in mainline


Ignore:
Timestamp:
2009-02-10T10:31:46Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd72312
Parents:
753d851
Message:

Make EGA fb driver handle colors correctly when servicing a DRAW_TEXT_DATA request.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fb/ega.c

    r753d851 r198a9ef  
    7373#define INVERTED_COLOR          ega_inverted_color
    7474
    75 #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR)
    76 
    7775/* Allow only 1 connection */
    7876static int client_connected = 0;
     
    8381
    8482static unsigned int style;
     83
     84static unsigned attr_to_ega_style(const attrs_t *a);
    8585
    8686static void clrscr(void)
     
    157157        for (i = 0; i < scr_width * scr_height; i++) {
    158158                scr_addr[i * 2] = data[i].character;
    159                 /* FIXME
    160                 scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color,
    161                     data[i].style.bg_color);
    162                 */
     159                scr_addr[i * 2 + 1] = attr_to_ega_style(&data[i].attrs);
    163160        }
    164161}
     
    189186}
    190187
     188static int style_to_ega_style(int style)
     189{
     190        unsigned int ega_style;
     191
     192        switch (style) {
     193        case STYLE_NORMAL:
     194                ega_style = INVERTED_COLOR;
     195                break;
     196        case STYLE_EMPHASIS:
     197                ega_style = INVERTED_COLOR | 4;
     198                break;
     199        default:
     200                return INVERTED_COLOR;
     201        }
     202
     203        return ega_style;
     204}
     205
     206static unsigned int color_to_ega_style(int fg_color, int bg_color, int attr)
     207{
     208        unsigned int style;
     209
     210        style = (fg_color & 7) | ((bg_color & 7) << 4);
     211        if (attr & CATTR_BRIGHT)
     212                style = style | 0x08;
     213
     214        return style;
     215}
     216
     217static unsigned int rgb_to_ega_style(uint32_t fg, uint32_t bg)
     218{
     219        return (fg > bg) ? NORMAL_COLOR : INVERTED_COLOR;
     220}
     221
     222static unsigned attr_to_ega_style(const attrs_t *a)
     223{
     224        switch (a->t) {
     225        case at_style: return style_to_ega_style(a->a.s.style);
     226        case at_rgb: return rgb_to_ega_style(a->a.r.fg_color, a->a.r.bg_color);
     227        case at_idx: return color_to_ega_style(a->a.i.fg_color,
     228            a->a.i.bg_color, a->a.i.flags);
     229        default: return INVERTED_COLOR;
     230        }
     231}
    191232
    192233static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     
    197238        char c;
    198239        unsigned int row, col;
    199         int bgcolor,fgcolor;
     240        int bg_color, fg_color, attr;
     241        uint32_t bg_rgb, fg_rgb;
    200242        keyfield_t *interbuf = NULL;
    201243        size_t intersize = 0;
     
    280322                        break;
    281323                case FB_SET_STYLE:
    282                         retval = 0;
    283                         switch (IPC_GET_ARG1(call)) {
    284                         case STYLE_NORMAL: style = INVERTED_COLOR; break;
    285                         case STYLE_EMPHASIS: style = INVERTED_COLOR | 4; break;
    286                         default: retval = EINVAL;
    287                         }
     324                        style = style_to_ega_style(IPC_GET_ARG1(call));
     325                        retval = 0;
    288326                        break;
    289327                case FB_SET_COLOR:
    290                         fgcolor = IPC_GET_ARG1(call);
    291                         bgcolor = IPC_GET_ARG2(call);
    292                         style = (fgcolor & 7) | ((bgcolor & 7) << 4);
    293                         if (IPC_GET_ARG3(call) & CATTR_BRIGHT)
    294                                 style = style | 0x08;
     328                        fg_color = IPC_GET_ARG1(call);
     329                        bg_color = IPC_GET_ARG2(call);
     330                        attr = IPC_GET_ARG3(call);
     331                        style = color_to_ega_style(fg_color, bg_color, attr);
    295332                        retval = 0;
    296333                        break;
    297334                case FB_SET_RGB_COLOR:
    298                         fgcolor = IPC_GET_ARG1(call);
    299                         bgcolor = IPC_GET_ARG2(call);
    300                         style = EGA_STYLE(fgcolor, bgcolor);
     335                        fg_rgb = IPC_GET_ARG1(call);
     336                        bg_rgb = IPC_GET_ARG2(call);
     337                        style = rgb_to_ega_style(fg_rgb, bg_rgb);
    301338                        retval = 0;
    302339                        break;
     
    336373        scr_width = sysinfo_value("fb.width");
    337374        scr_height = sysinfo_value("fb.height");
    338         if(sysinfo_value("fb.blinking"))
    339         {
    340                         ega_normal_color &= 0x77;
    341                         ega_inverted_color &= 0x77;
    342         }
     375
     376        if(sysinfo_value("fb.blinking")) {
     377                ega_normal_color &= 0x77;
     378                ega_inverted_color &= 0x77;
     379        }
     380
    343381        style = NORMAL_COLOR;
    344382
Note: See TracChangeset for help on using the changeset viewer.