Changeset a35b458 in mainline for uspace/srv/hid/output


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
uspace/srv/hid/output
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/output/ctl/serial.c

    r3061bc1 ra35b458  
    6363{
    6464        vt100_state_t *state = (vt100_state_t *) dev->data;
    65        
     65
    6666        return vt100_yield(state);
    6767}
     
    7070{
    7171        vt100_state_t *state = (vt100_state_t *) dev->data;
    72        
     72
    7373        return vt100_claim(state);
    7474}
     
    7878{
    7979        vt100_state_t *state = (vt100_state_t *) dev->data;
    80        
     80
    8181        vt100_get_dimensions(state, cols, rows);
    8282}
     
    9191{
    9292        vt100_state_t *state = (vt100_state_t *) dev->data;
    93        
     93
    9494        vt100_goto(state, col, row);
    9595        vt100_cursor_visibility(state, visible);
     
    101101        charfield_t *field =
    102102            chargrid_charfield_at(dev->backbuf, col, row);
    103        
     103
    104104        draw_char(state, field, col, row);
    105105}
     
    130130        if (state == NULL)
    131131                return ENOMEM;
    132        
     132
    133133        outdev_t *dev = outdev_register(&serial_ops, state);
    134134        if (dev == NULL) {
     
    136136                return ENOMEM;
    137137        }
    138        
     138
    139139        return EOK;
    140140}
  • uspace/srv/hid/output/gfx/font-8x16.c

    r3061bc1 ra35b458  
    4949        if (ch == 0x0000)
    5050                return 0;
    51        
     51
    5252        if ((ch >= 0x0020) && (ch <= 0x007f))
    5353                return (ch - 32);
    54        
     54
    5555        if ((ch >= 0x00a0) && (ch <= 0x021f))
    5656                return (ch - 64);
    57        
     57
    5858        if ((ch >= 0x0222) && (ch <= 0x0233))
    5959                return (ch - 66);
    60        
     60
    6161        if ((ch >= 0x0250) && (ch <= 0x02ad))
    6262                return (ch - 94);
    63        
     63
    6464        if ((ch >= 0x02b0) && (ch <= 0x02cf))
    6565                return (ch - 96);
    66        
     66
    6767        if ((ch >= 0x02d8) && (ch <= 0x02dd))
    6868                return (ch - 104);
    69        
     69
    7070        if (ch == 0x02ee)
    7171                return 630;
    72        
     72
    7373        if ((ch >= 0x0300) && (ch <= 0x0301))
    7474                return (ch - 137);
    75        
     75
    7676        if (ch == 0x0303)
    7777                return 633;
    78        
     78
    7979        if (ch == 0x0309)
    8080                return 634;
    81        
     81
    8282        if ((ch >= 0x0312) && (ch <= 0x0314))
    8383                return (ch - 151);
    84        
     84
    8585        if (ch == 0x0323)
    8686                return 638;
    87        
     87
    8888        if ((ch >= 0x0340) && (ch <= 0x0341))
    8989                return (ch - 193);
    90        
     90
    9191        if ((ch >= 0x0374) && (ch <= 0x0375))
    9292                return (ch - 243);
    93        
     93
    9494        if (ch == 0x037a)
    9595                return 643;
    96        
     96
    9797        if (ch == 0x037e)
    9898                return 644;
    99        
     99
    100100        if ((ch >= 0x0384) && (ch <= 0x038a))
    101101                return (ch - 255);
    102        
     102
    103103        if (ch == 0x038c)
    104104                return 652;
    105        
     105
    106106        if ((ch >= 0x038e) && (ch <= 0x03a1))
    107107                return (ch - 257);
    108        
     108
    109109        if ((ch >= 0x03a3) && (ch <= 0x03ce))
    110110                return (ch - 258);
    111        
     111
    112112        if ((ch >= 0x03d0) && (ch <= 0x03d7))
    113113                return (ch - 259);
    114        
     114
    115115        if ((ch >= 0x03da) && (ch <= 0x03f3))
    116116                return (ch - 261);
    117        
     117
    118118        if ((ch >= 0x0400) && (ch <= 0x0486))
    119119                return (ch - 273);
    120        
     120
    121121        if ((ch >= 0x0488) && (ch <= 0x04ce))
    122122                return (ch - 274);
    123        
     123
    124124        if ((ch >= 0x04d0) && (ch <= 0x04f5))
    125125                return (ch - 275);
    126        
     126
    127127        if ((ch >= 0x04f8) && (ch <= 0x04f9))
    128128                return (ch - 277);
    129        
     129
    130130        if ((ch >= 0x0500) && (ch <= 0x050f))
    131131                return (ch - 283);
    132        
     132
    133133        if ((ch >= 0x0530) && (ch <= 0x0556))
    134134                return (ch - 315);
    135        
     135
    136136        if ((ch >= 0x0559) && (ch <= 0x055f))
    137137                return (ch - 317);
    138        
     138
    139139        if ((ch >= 0x0561) && (ch <= 0x0587))
    140140                return (ch - 318);
    141        
     141
    142142        if ((ch >= 0x0589) && (ch <= 0x058a))
    143143                return (ch - 319);
    144        
     144
    145145        if ((ch >= 0x0591) && (ch <= 0x05a1))
    146146                return (ch - 325);
    147        
     147
    148148        if ((ch >= 0x05a3) && (ch <= 0x05b9))
    149149                return (ch - 326);
    150        
     150
    151151        if ((ch >= 0x05bb) && (ch <= 0x05c4))
    152152                return (ch - 327);
    153        
     153
    154154        if ((ch >= 0x05d0) && (ch <= 0x05ea))
    155155                return (ch - 338);
    156        
     156
    157157        if ((ch >= 0x05f0) && (ch <= 0x05f4))
    158158                return (ch - 343);
    159        
     159
    160160        if (ch == 0x060c)
    161161                return 1182;
    162        
     162
    163163        if (ch == 0x061b)
    164164                return 1183;
    165        
     165
    166166        if (ch == 0x061f)
    167167                return 1184;
    168        
     168
    169169        if ((ch >= 0x0621) && (ch <= 0x063a))
    170170                return (ch - 384);
    171        
     171
    172172        if ((ch >= 0x0640) && (ch <= 0x0655))
    173173                return (ch - 389);
    174        
     174
    175175        if ((ch >= 0x0660) && (ch <= 0x066d))
    176176                return (ch - 399);
    177        
     177
    178178        if ((ch >= 0x0670) && (ch <= 0x06ed))
    179179                return (ch - 401);
    180        
     180
    181181        if ((ch >= 0x06f0) && (ch <= 0x06fe))
    182182                return (ch - 403);
    183        
     183
    184184        if (ch == 0x10d3)
    185185                return 1388;
    186        
     186
    187187        if (ch == 0x10d7)
    188188                return 1389;
    189        
     189
    190190        if (ch == 0x10da)
    191191                return 1390;
    192        
     192
    193193        if (ch == 0x10dd)
    194194                return 1391;
    195        
     195
    196196        if (ch == 0x10e6)
    197197                return 1392;
    198        
     198
    199199        if ((ch >= 0x1e00) && (ch <= 0x1e9b))
    200200                return (ch - 6287);
    201        
     201
    202202        if ((ch >= 0x1ea0) && (ch <= 0x1ef9))
    203203                return (ch - 6291);
    204        
     204
    205205        if ((ch >= 0x1f00) && (ch <= 0x1f07))
    206206                return (ch - 6297);
    207        
     207
    208208        if ((ch >= 0x2000) && (ch <= 0x2027))
    209209                return (ch - 6545);
    210        
     210
    211211        if ((ch >= 0x2030) && (ch <= 0x2046))
    212212                return (ch - 6553);
    213        
     213
    214214        if ((ch >= 0x2048) && (ch <= 0x204d))
    215215                return (ch - 6554);
    216        
     216
    217217        if (ch == 0x2070)
    218218                return 1716;
    219        
     219
    220220        if ((ch >= 0x2074) && (ch <= 0x208f))
    221221                return (ch - 6591);
    222        
     222
    223223        if ((ch >= 0x20a0) && (ch <= 0x20af))
    224224                return (ch - 6607);
    225        
     225
    226226        if ((ch >= 0x2100) && (ch <= 0x213a))
    227227                return (ch - 6687);
    228        
     228
    229229        if ((ch >= 0x2153) && (ch <= 0x2183))
    230230                return (ch - 6711);
    231        
     231
    232232        if ((ch >= 0x2190) && (ch <= 0x21f3))
    233233                return (ch - 6723);
    234        
     234
    235235        if ((ch >= 0x2200) && (ch <= 0x22f1))
    236236                return (ch - 6735);
    237        
     237
    238238        if (ch == 0x2300)
    239239                return 2211;
    240        
     240
    241241        if (ch == 0x2302)
    242242                return 2212;
    243        
     243
    244244        if ((ch >= 0x2308) && (ch <= 0x230b))
    245245                return (ch - 6755);
    246        
     246
    247247        if (ch == 0x2310)
    248248                return 2217;
    249        
     249
    250250        if (ch == 0x2318)
    251251                return 2218;
    252        
     252
    253253        if ((ch >= 0x231a) && (ch <= 0x231b))
    254254                return (ch - 6767);
    255        
     255
    256256        if ((ch >= 0x2320) && (ch <= 0x2321))
    257257                return (ch - 6771);
    258        
     258
    259259        if ((ch >= 0x2329) && (ch <= 0x232a))
    260260                return (ch - 6778);
    261        
     261
    262262        if ((ch >= 0x239b) && (ch <= 0x23bd))
    263263                return (ch - 6890);
    264        
     264
    265265        if (ch == 0x23ce)
    266266                return 2260;
    267        
     267
    268268        if ((ch >= 0x2409) && (ch <= 0x240d))
    269269                return (ch - 6964);
    270        
     270
    271271        if ((ch >= 0x2423) && (ch <= 0x2424))
    272272                return (ch - 6985);
    273        
     273
    274274        if (ch == 0x2426)
    275275                return 2268;
    276        
     276
    277277        if ((ch >= 0x2500) && (ch <= 0x2595))
    278278                return (ch - 7203);
    279        
     279
    280280        if ((ch >= 0x25a0) && (ch <= 0x25f7))
    281281                return (ch - 7213);
    282        
     282
    283283        if ((ch >= 0x2600) && (ch <= 0x2602))
    284284                return (ch - 7221);
    285        
     285
    286286        if ((ch >= 0x2605) && (ch <= 0x260d))
    287287                return (ch - 7223);
    288        
     288
    289289        if ((ch >= 0x2610) && (ch <= 0x2613))
    290290                return (ch - 7225);
    291        
     291
    292292        if (ch == 0x2620)
    293293                return 2523;
    294        
     294
    295295        if (ch == 0x2622)
    296296                return 2524;
    297        
     297
    298298        if (ch == 0x2626)
    299299                return 2525;
    300        
     300
    301301        if ((ch >= 0x2628) && (ch <= 0x262b))
    302302                return (ch - 7242);
    303        
     303
    304304        if ((ch >= 0x262e) && (ch <= 0x2637))
    305305                return (ch - 7244);
    306        
     306
    307307        if ((ch >= 0x2639) && (ch <= 0x2653))
    308308                return (ch - 7245);
    309        
     309
    310310        if ((ch >= 0x2660) && (ch <= 0x2667))
    311311                return (ch - 7257);
    312        
     312
    313313        if ((ch >= 0x2669) && (ch <= 0x266f))
    314314                return (ch - 7258);
    315        
     315
    316316        if ((ch >= 0xfb00) && (ch <= 0xfb05))
    317317                return (ch - 61674);
    318        
     318
    319319        if ((ch >= 0xfb50) && (ch <= 0xfbb1))
    320320                return (ch - 61748);
    321        
     321
    322322        if ((ch >= 0xfbd3) && (ch <= 0xfbe9))
    323323                return (ch - 61781);
    324        
     324
    325325        if ((ch >= 0xfbfc) && (ch <= 0xfbff))
    326326                return (ch - 61799);
    327        
     327
    328328        if ((ch >= 0xfc5b) && (ch <= 0xfc63))
    329329                return (ch - 61890);
    330        
     330
    331331        if (ch == 0xfc90)
    332332                return 2722;
    333        
     333
    334334        if ((ch >= 0xfcf2) && (ch <= 0xfcf4))
    335335                return (ch - 62031);
    336        
     336
    337337        if ((ch >= 0xfd3c) && (ch <= 0xfd3f))
    338338                return (ch - 62102);
    339        
     339
    340340        if (ch == 0xfdf2)
    341341                return 2730;
    342        
     342
    343343        if ((ch >= 0xfe50) && (ch <= 0xfe52))
    344344                return (ch - 62373);
    345        
     345
    346346        if ((ch >= 0xfe54) && (ch <= 0xfe66))
    347347                return (ch - 62374);
    348        
     348
    349349        if ((ch >= 0xfe68) && (ch <= 0xfe6b))
    350350                return (ch - 62375);
    351        
     351
    352352        if ((ch >= 0xfe70) && (ch <= 0xfe72))
    353353                return (ch - 62379);
    354        
     354
    355355        if (ch == 0xfe74)
    356356                return 2760;
    357        
     357
    358358        if ((ch >= 0xfe76) && (ch <= 0xfefc))
    359359                return (ch - 62381);
    360        
     360
    361361        if (ch == 0xfeff)
    362362                return 2896;
    363        
     363
    364364        return 2898;
    365365}
     
    32643264        {0xf1, 0x35, 0x55, 0x8a, 0xe0, 0x06, 0x95, 0xd6, 0xb5, 0x97, 0x00, 0xee, 0x8a, 0xee, 0x28, 0xe8},
    32653265        {0x00, 0x38, 0x7c, 0x7c, 0xc6, 0x92, 0xf2, 0xe6, 0xfe, 0xe6, 0x7c, 0x7c, 0x38, 0x00, 0x00, 0x00},
    3266        
     3266
    32673267        /* Special glyph for unknown character */
    32683268        {0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00}
  • uspace/srv/hid/output/output.c

    r3061bc1 ra35b458  
    4444typedef struct {
    4545        link_t link;
    46        
     46
    4747        size_t size;
    4848        unsigned int flags;
     
    5656{
    5757        assert(ops->get_dimensions);
    58        
     58
    5959        outdev_t *dev = (outdev_t *) malloc(sizeof(outdev_t));
    6060        if (dev == NULL)
    6161                return NULL;
    62        
     62
    6363        link_initialize(&dev->link);
    64        
     64
    6565        dev->ops = *ops;
    6666        dev->data = data;
    67        
     67
    6868        ops->get_dimensions(dev, &dev->cols, &dev->rows);
    6969        dev->backbuf = chargrid_create(dev->cols, dev->rows,
     
    7373                return NULL;
    7474        }
    75        
     75
    7676        list_append(&dev->link, &outdevs);
    7777        return dev;
     
    8181{
    8282        errno_t ret = EOK;
    83        
     83
    8484        list_foreach(outdevs, link, outdev_t, dev) {
    8585                assert(dev->ops.yield);
    86                
     86
    8787                errno_t rc = dev->ops.yield(dev);
    8888                if (rc != EOK)
    8989                        ret = rc;
    9090        }
    91        
     91
    9292        async_answer_0(iid, ret);
    9393}
     
    9696{
    9797        errno_t ret = EOK;
    98        
     98
    9999        list_foreach(outdevs, link, outdev_t, dev) {
    100100                assert(dev->ops.claim);
    101                
     101
    102102                errno_t rc = dev->ops.claim(dev);
    103103                if (rc != EOK)
    104104                        ret = rc;
    105105        }
    106        
     106
    107107        async_answer_0(iid, ret);
    108108}
     
    112112        sysarg_t cols = MAX_COLS;
    113113        sysarg_t rows = MAX_ROWS;
    114        
     114
    115115        list_foreach(outdevs, link, outdev_t, dev) {
    116116                cols = min(cols, dev->cols);
    117117                rows = min(rows, dev->rows);
    118118        }
    119        
     119
    120120        async_answer_2(iid, EOK, cols, rows);
    121121}
     
    124124{
    125125        console_caps_t caps = 0;
    126        
     126
    127127        list_foreach(outdevs, link, outdev_t, dev) {
    128128                assert(dev->ops.get_caps);
    129                
     129
    130130                caps |= dev->ops.get_caps(dev);
    131131        }
    132        
     132
    133133        async_answer_1(iid, EOK, caps);
    134134}
     
    143143                }
    144144        }
    145        
     145
    146146        if (frontbuf == NULL) {
    147147                async_answer_0(iid, ENOENT);
    148148                return NULL;
    149149        }
    150        
     150
    151151        return frontbuf;
    152152}
     
    159159                return;
    160160        }
    161        
     161
    162162        link_initialize(&frontbuf->link);
    163        
     163
    164164        ipc_callid_t callid;
    165165        if (!async_share_out_receive(&callid, &frontbuf->size,
     
    169169                return;
    170170        }
    171        
     171
    172172        errno_t rc = async_share_out_finalize(callid, &frontbuf->data);
    173173        if ((rc != EOK) || (frontbuf->data == AS_MAP_FAILED)) {
     
    176176                return;
    177177        }
    178        
     178
    179179        list_append(&frontbuf->link, &frontbufs);
    180180        async_answer_1(iid, EOK, (sysarg_t) frontbuf);
     
    186186        if (frontbuf == NULL)
    187187                return;
    188        
     188
    189189        list_remove(&frontbuf->link);
    190190        as_area_destroy(frontbuf->data);
    191191        free(frontbuf);
    192        
     192
    193193        async_answer_0(iid, EOK);
    194194}
     
    199199        if (frontbuf == NULL)
    200200                return;
    201        
     201
    202202        chargrid_t *buf = (chargrid_t *) frontbuf->data;
    203203        bool visible = chargrid_get_cursor_visibility(buf);
    204        
     204
    205205        sysarg_t col;
    206206        sysarg_t row;
    207207        chargrid_get_cursor(buf, &col, &row);
    208        
     208
    209209        list_foreach(outdevs, link, outdev_t, dev) {
    210210                assert(dev->ops.cursor_update);
    211                
     211
    212212                sysarg_t prev_col;
    213213                sysarg_t prev_row;
    214214                chargrid_get_cursor(dev->backbuf, &prev_col, &prev_row);
    215                
     215
    216216                chargrid_set_cursor(dev->backbuf, col, row);
    217217                chargrid_set_cursor_visibility(dev->backbuf, visible);
    218                
     218
    219219                dev->ops.cursor_update(dev, prev_col, prev_row, col, row,
    220220                    visible);
     
    222222
    223223        }
    224        
     224
    225225        async_answer_0(iid, EOK);
    226226}
     
    233233                    (console_style_t) IPC_GET_ARG1(*icall);
    234234        }
    235        
     235
    236236        async_answer_0(iid, EOK);
    237237}
     
    248248                    (console_color_attr_t) IPC_GET_ARG3(*icall);
    249249        }
    250        
     250
    251251        async_answer_0(iid, EOK);
    252252}
     
    259259                dev->attrs.val.rgb.fgcolor = IPC_GET_ARG2(*icall);
    260260        }
    261        
     261
    262262        async_answer_0(iid, EOK);
    263263}
     
    266266{
    267267        assert(dev->ops.char_update);
    268        
     268
    269269        sysarg_t top_row = chargrid_get_top_row(buf);
    270        
     270
    271271        if (dev->top_row == top_row)
    272272                return false;
    273        
     273
    274274        dev->top_row = top_row;
    275        
     275
    276276        for (sysarg_t y = 0; y < dev->rows; y++) {
    277277                for (sysarg_t x = 0; x < dev->cols; x++) {
     
    281281                            chargrid_charfield_at(dev->backbuf, x, y);
    282282                        bool update = false;
    283                        
     283
    284284                        if (front_field->ch != back_field->ch) {
    285285                                back_field->ch = front_field->ch;
    286286                                update = true;
    287287                        }
    288                        
     288
    289289                        if (!attrs_same(front_field->attrs, back_field->attrs)) {
    290290                                back_field->attrs = front_field->attrs;
    291291                                update = true;
    292292                        }
    293                        
     293
    294294                        front_field->flags &= ~CHAR_FLAG_DIRTY;
    295                        
     295
    296296                        if (update)
    297297                                dev->ops.char_update(dev, x, y);
    298298                }
    299299        }
    300        
     300
    301301        return true;
    302302}
     
    307307        if (frontbuf == NULL)
    308308                return;
    309        
     309
    310310        chargrid_t *buf = (chargrid_t *) frontbuf->data;
    311        
     311
    312312        list_foreach(outdevs, link, outdev_t, dev) {
    313313                assert(dev->ops.char_update);
    314                
     314
    315315                if (srv_update_scroll(dev, buf))
    316316                        continue;
    317                
     317
    318318                for (sysarg_t y = 0; y < dev->rows; y++) {
    319319                        for (sysarg_t x = 0; x < dev->cols; x++) {
     
    323323                                    chargrid_charfield_at(dev->backbuf, x, y);
    324324                                bool update = false;
    325                                
     325
    326326                                if ((front_field->flags & CHAR_FLAG_DIRTY) ==
    327327                                    CHAR_FLAG_DIRTY) {
     
    330330                                                update = true;
    331331                                        }
    332                                        
     332
    333333                                        if (!attrs_same(front_field->attrs,
    334334                                            back_field->attrs)) {
     
    336336                                                update = true;
    337337                                        }
    338                                        
     338
    339339                                        front_field->flags &= ~CHAR_FLAG_DIRTY;
    340340                                }
    341                                
     341
    342342                                if (update)
    343343                                        dev->ops.char_update(dev, x, y);
    344344                        }
    345345                }
    346                
     346
    347347                dev->ops.flush(dev);
    348348        }
    349        
    350        
     349
     350
    351351        async_answer_0(iid, EOK);
    352352}
     
    357357        if (frontbuf == NULL)
    358358                return;
    359        
     359
    360360        chargrid_t *buf = (chargrid_t *) frontbuf->data;
    361        
     361
    362362        list_foreach(outdevs, link, outdev_t, dev) {
    363363                assert(dev->ops.char_update);
    364                
     364
    365365                if (srv_update_scroll(dev, buf))
    366366                        continue;
    367                
     367
    368368                sysarg_t col = IPC_GET_ARG2(*icall);
    369369                sysarg_t row = IPC_GET_ARG3(*icall);
    370                
     370
    371371                sysarg_t cols = IPC_GET_ARG4(*icall);
    372372                sysarg_t rows = IPC_GET_ARG5(*icall);
    373                
     373
    374374                for (sysarg_t y = 0; y < rows; y++) {
    375375                        for (sysarg_t x = 0; x < cols; x++) {
     
    378378                                charfield_t *back_field =
    379379                                    chargrid_charfield_at(dev->backbuf, col + x, row + y);
    380                                
     380
    381381                                back_field->ch = front_field->ch;
    382382                                back_field->attrs = front_field->attrs;
     
    395395        /* Accept the connection */
    396396        async_answer_0(iid, EOK);
    397        
     397
    398398        while (true) {
    399399                ipc_call_t call;
    400400                ipc_callid_t callid = async_get_call(&call);
    401                
     401
    402402                if (!IPC_GET_IMETHOD(call)) {
    403403                        async_answer_0(callid, EOK);
    404404                        break;
    405405                }
    406                
     406
    407407                switch (IPC_GET_IMETHOD(call)) {
    408408                case OUTPUT_YIELD:
     
    418418                        srv_get_caps(callid, &call);
    419419                        break;
    420                
     420
    421421                case OUTPUT_FRONTBUF_CREATE:
    422422                        srv_frontbuf_create(callid, &call);
     
    425425                        srv_frontbuf_destroy(callid, &call);
    426426                        break;
    427                        
     427
    428428                case OUTPUT_CURSOR_UPDATE:
    429429                        srv_cursor_update(callid, &call);
     
    444444                        srv_damage(callid, &call);
    445445                        break;
    446                        
     446
    447447                default:
    448448                        async_answer_0(callid, EINVAL);
     
    462462                return 1;
    463463        }
    464        
     464
    465465        printf("%s: HelenOS output service\n", NAME);
    466        
     466
    467467        /* Register server */
    468468        async_set_fallback_port_handler(client_connection, NULL);
     
    472472                return rc;
    473473        }
    474        
     474
    475475        service_id_t service_id;
    476476        rc = loc_service_register(argv[1], &service_id);
     
    479479                return rc;
    480480        }
    481        
     481
    482482        if (!config_key_exists("console")) {
    483483                ega_init();
    484484        }
    485        
     485
    486486        chardev_init();
    487        
     487
    488488        printf("%s: Accepting connections\n", NAME);
    489489        task_retval(0);
    490490        async_manager();
    491        
     491
    492492        /* Never reached */
    493493        return 0;
  • uspace/srv/hid/output/output.h

    r3061bc1 ra35b458  
    4444        errno_t (*yield)(struct outdev *dev);
    4545        errno_t (*claim)(struct outdev *dev);
    46        
     46
    4747        void (*get_dimensions)(struct outdev *dev, sysarg_t *cols,
    4848            sysarg_t *rows);
    4949        console_caps_t (*get_caps)(struct outdev *dev);
    50        
     50
    5151        void (*cursor_update)(struct outdev *dev, sysarg_t prev_col,
    5252            sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible);
     
    5757typedef struct outdev {
    5858        link_t link;
    59        
     59
    6060        sysarg_t cols;
    6161        sysarg_t rows;
    6262        char_attrs_t attrs;
    63        
     63
    6464        chargrid_t *backbuf;
    6565        sysarg_t top_row;
    66        
     66
    6767        outdev_ops_t ops;
    6868        void *data;
  • uspace/srv/hid/output/port/ega.c

    r3061bc1 ra35b458  
    4747        sysarg_t cols;
    4848        sysarg_t rows;
    49        
     49
    5050        uint8_t style_normal;
    5151        uint8_t style_inverted;
    52        
     52
    5353        size_t size;
    5454        uint8_t *addr;
     
    6060{
    6161        uint8_t attr = 0;
    62        
     62
    6363        switch (attrs.type) {
    6464        case CHAR_ATTR_STYLE:
     
    8181                attr = ((attrs.val.index.bgcolor & 7) << 4) |
    8282                    (attrs.val.index.fgcolor & 7);
    83                
     83
    8484                if (attrs.val.index.attr & CATTR_BRIGHT)
    8585                        attr |= 0x08;
    86                
     86
    8787                break;
    8888        case CHAR_ATTR_RGB:
     
    9191                break;
    9292        }
    93        
     93
    9494        return attr;
    9595}
     
    105105{
    106106        uint8_t glyph;
    107        
     107
    108108        if (ascii_check(field->ch))
    109109                glyph = field->ch;
    110110        else
    111111                glyph = '?';
    112        
     112
    113113        uint8_t attr = attrs_attr(field->attrs);
    114        
     114
    115115        ega.addr[FB_POS(col, row)] = glyph;
    116116        ega.addr[FB_POS(col, row) + 1] = attr;
     
    143143        /* Cursor position */
    144144        uint16_t cursor = row * ega.cols + col;
    145        
     145
    146146        pio_write_8(EGA_IO_BASE, 0x0e);
    147147        pio_write_8(EGA_IO_BASE + 1, (cursor >> 8) & 0xff);
    148148        pio_write_8(EGA_IO_BASE, 0x0f);
    149149        pio_write_8(EGA_IO_BASE + 1, cursor & 0xff);
    150        
     150
    151151        /* Cursor visibility */
    152152        pio_write_8(EGA_IO_BASE, 0x0a);
    153153        uint8_t stat = pio_read_8(EGA_IO_BASE + 1);
    154        
     154
    155155        pio_write_8(EGA_IO_BASE, 0x0a);
    156        
     156
    157157        if (visible)
    158158                pio_write_8(EGA_IO_BASE + 1, stat & (~(1 << 5)));
     
    165165        charfield_t *field =
    166166            chargrid_charfield_at(dev->backbuf, col, row);
    167        
     167
    168168        draw_char(field, col, row);
    169169}
     
    189189        if (rc != EOK)
    190190                present = false;
    191        
     191
    192192        if (!present)
    193193                return ENOENT;
    194        
     194
    195195        sysarg_t kind;
    196196        rc = sysinfo_get_value("fb.kind", &kind);
    197197        if (rc != EOK)
    198198                kind = (sysarg_t) -1;
    199        
     199
    200200        if (kind != 2)
    201201                return EINVAL;
    202        
     202
    203203        sysarg_t paddr;
    204204        rc = sysinfo_get_value("fb.address.physical", &paddr);
    205205        if (rc != EOK)
    206206                return rc;
    207        
     207
    208208        rc = sysinfo_get_value("fb.width", &ega.cols);
    209209        if (rc != EOK)
    210210                return rc;
    211        
     211
    212212        rc = sysinfo_get_value("fb.height", &ega.rows);
    213213        if (rc != EOK)
    214214                return rc;
    215        
     215
    216216        rc = pio_enable((void*)EGA_IO_BASE, EGA_IO_SIZE, NULL);
    217217        if (rc != EOK)
    218218                return rc;
    219        
     219
    220220        ega.size = (ega.cols * ega.rows) << 1;
    221221        ega.addr = AS_AREA_ANY;
    222        
     222
    223223        rc = physmem_map(paddr,
    224224            ALIGN_UP(ega.size, PAGE_SIZE) >> PAGE_WIDTH,
     
    226226        if (rc != EOK)
    227227                return rc;
    228        
     228
    229229        sysarg_t blinking;
    230230        rc = sysinfo_get_value("fb.blinking", &blinking);
    231231        if (rc != EOK)
    232232                blinking = false;
    233        
     233
    234234        ega.style_normal = 0xf0;
    235235        ega.style_inverted = 0x0f;
    236        
     236
    237237        if (blinking) {
    238238                ega.style_normal &= 0x77;
    239239                ega.style_inverted &= 0x77;
    240240        }
    241        
     241
    242242        outdev_t *dev = outdev_register(&ega_ops, (void *) &ega);
    243243        if (dev == NULL) {
     
    245245                return EINVAL;
    246246        }
    247        
     247
    248248        return EOK;
    249249}
  • uspace/srv/hid/output/port/kfb.c

    r3061bc1 ra35b458  
    8787        size_t scanline;
    8888        visual_t visual;
    89        
     89
    9090        size_t size;
    9191        uint8_t *addr;
    92        
     92
    9393        pixel2visual_t pixel2visual;
    9494        visual2pixel_t visual2pixel;
    9595        visual_mask_t visual_mask;
    9696        size_t pixel_bytes;
    97        
     97
    9898        sysarg_t pointer_x;
    9999        sysarg_t pointer_y;
    100100        bool pointer_visible;
    101101        imgmap_t *pointer_imgmap;
    102        
     102
    103103        /*
    104104         * Pre-rendered mask for rendering
     
    106106         * visual.
    107107         */
    108        
     108
    109109        size_t glyph_scanline;
    110110        size_t glyph_bytes;
    111111        uint8_t *glyphs;
    112        
     112
    113113        uint8_t *backbuf;
    114114} kfb_t;
     
    135135        [COLOR_YELLOW]      = 0xf0f000,
    136136        [COLOR_WHITE]       = 0xf0f0f0,
    137        
     137
    138138        [COLOR_BLACK + 8]   = 0x000000,
    139139        [COLOR_BLUE + 8]    = 0x0000ff,
     
    150150        if ((x >= kfb.width) || (y >= kfb.height))
    151151                return;
    152        
     152
    153153        kfb.pixel2visual(kfb.addr + FB_POS(x, y), pixel);
    154154}
     
    158158        if ((x >= kfb.width) || (y >= kfb.height))
    159159                return 0;
    160        
     160
    161161        return kfb.visual2pixel(kfb.addr + FB_POS(x, y));
    162162}
     
    169169                                sysarg_t dx = kfb.pointer_x + x;
    170170                                sysarg_t dy = kfb.pointer_y + y;
    171                                
     171
    172172                                pixel_t pixel = get_pixel(dx, dy);
    173173                                imgmap_put_pixel(kfb.pointer_imgmap, x, y, pixel);
    174                                
     174
    175175                                size_t offset = y * ((POINTER_WIDTH - 1) / 8 + 1) + x / 8;
    176176                                bool visible = pointer_mask[offset] & (1 << (x % 8));
    177                                
     177
    178178                                if (visible) {
    179179                                        pixel = (pointer[offset] & (1 << (x % 8))) ?
     
    193193                                sysarg_t dx = kfb.pointer_x + x;
    194194                                sysarg_t dy = kfb.pointer_y + y;
    195                                
     195
    196196                                pixel_t pixel =
    197197                                    imgmap_get_pixel(kfb.pointer_imgmap, x, y);
     
    210210        if ((y1 >= y2) || (x1 >= x2))
    211211                return;
    212        
     212
    213213        uint8_t cbuf[4];
    214214        kfb.pixel2visual(cbuf, color);
    215        
     215
    216216        for (sysarg_t y = y1; y < y2; y++) {
    217217                uint8_t *dst = kfb.addr + FB_POS(x1, y);
    218                
     218
    219219                for (sysarg_t x = x1; x < x2; x++) {
    220220                        memcpy(dst, cbuf, kfb.pixel_bytes);
     
    290290{
    291291        size_t word_size = sizeof(unsigned long);
    292        
     292
    293293        /*
    294294         * Prepare a pair of words, one filled with foreground-color
     
    297297        unsigned long fg_buf;
    298298        unsigned long bg_buf;
    299        
     299
    300300        for (size_t i = 0; i < word_size / kfb.pixel_bytes; i++) {
    301301                kfb.pixel2visual(&((uint8_t *) &bg_buf)[i * kfb.pixel_bytes],
     
    304304                    fgcolor);
    305305        }
    306        
     306
    307307        /* Pointer to the current position in the mask. */
    308308        unsigned long *maskp =
    309309            (unsigned long *) &kfb.glyphs[GLYPH_POS(
    310310            fb_font_glyph(ch), 0, inverted)];
    311        
     311
    312312        /* Pointer to the current position on the screen. */
    313313        unsigned long *dst =
    314314            (unsigned long *) &kfb.addr[FB_POS(x, y)];
    315        
     315
    316316        /* Width of the character cell in words. */
    317317        size_t ww = FONT_WIDTH * kfb.pixel_bytes / word_size;
    318        
     318
    319319        /* Offset to add when moving to another screen scanline. */
    320320        size_t d_add = kfb.scanline - FONT_WIDTH * kfb.pixel_bytes;
    321        
     321
    322322        for (size_t yd = 0; yd < FONT_SCANLINES; yd++) {
    323323                /*
     
    329329                        *dst++ = (fg_buf & mask) | (bg_buf & ~mask);
    330330                }
    331                
     331
    332332                /* Move to the beginning of the next scanline of the cell. */
    333333                dst = (unsigned long *) ((uint8_t *) dst + d_add);
     
    353353        /* Character glyph */
    354354        uint16_t glyph = fb_font_glyph(ch);
    355        
     355
    356356        /* Pre-render the foreground and background color pixels. */
    357357        uint8_t fg_buf[4];
    358358        uint8_t bg_buf[4];
    359        
     359
    360360        if (inverted) {
    361361                kfb.pixel2visual(bg_buf, fgcolor);
     
    365365                kfb.pixel2visual(fg_buf, fgcolor);
    366366        }
    367        
     367
    368368        /* Pointer to the current position on the screen. */
    369369        uint8_t *dst = (uint8_t *) &kfb.addr[FB_POS(x, y)];
    370        
     370
    371371        /* Offset to add when moving to another screen scanline. */
    372372        size_t d_add = kfb.scanline - FONT_WIDTH * kfb.pixel_bytes;
    373        
     373
    374374        for (size_t yd = 0; yd < FONT_SCANLINES; yd++) {
    375375                /* Byte containing bits of the glyph scanline. */
    376376                uint8_t byte = fb_font[glyph][yd];
    377                
     377
    378378                for (size_t i = 0; i < FONT_WIDTH; i++) {
    379379                        /* Choose color based on the current bit. */
    380380                        uint8_t *src = (byte & 0x80) ? fg_buf : bg_buf;
    381                        
     381
    382382                        /* Copy the pixel. */
    383383                        for (size_t j = 0; j < kfb.pixel_bytes; j++)
    384384                                *dst++ = *src++;
    385                        
     385
    386386                        /* Move to the next bit. */
    387387                        byte <<= 1;
    388388                }
    389                
     389
    390390                /* Move to the beginning of the next scanline of the cell. */
    391391                dst += d_add;
     
    403403{
    404404        kfb_vp_t *kfb_vp = (kfb_vp_t *) vp->data;
    405        
     405
    406406        sysarg_t x = vp->x + COL2X(col);
    407407        sysarg_t y = vp->y + ROW2Y(row);
    408        
     408
    409409        charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row);
    410        
     410
    411411        pixel_t bgcolor = 0;
    412412        pixel_t fgcolor = 0;
    413413        attrs_rgb(field->attrs, &bgcolor, &fgcolor);
    414        
     414
    415415        bool inverted = (vp->cursor_flash) &&
    416416            screenbuffer_cursor_at(vp->backbuf, col, row);
    417        
     417
    418418        (*kfb_vp->draw_char)(x, y, inverted, field->ch, bgcolor, fgcolor);
    419419}
     
    427427                        return ENOMEM;
    428428        }
    429        
     429
    430430        for (sysarg_t y = 0; y < kfb.height; y++)
    431431                memcpy(kfb.backbuf + y * kfb.width * kfb.pixel_bytes,
    432432                    kfb.addr + FB_POS(0, y), kfb.width * kfb.pixel_bytes);
    433        
     433
    434434        return EOK;
    435435}
     
    439439        if (kfb.backbuf == NULL)
    440440                return ENOENT;
    441        
     441
    442442        for (sysarg_t y = 0; y < kfb.height; y++)
    443443                memcpy(kfb.addr + FB_POS(0, y),
    444444                    kfb.backbuf + y * kfb.width * kfb.pixel_bytes,
    445445                    kfb.width * kfb.pixel_bytes);
    446        
     446
    447447        return EOK;
    448448}
     
    452452{
    453453        pointer_hide();
    454        
     454
    455455        kfb.pointer_x = x;
    456456        kfb.pointer_y = y;
    457457        kfb.pointer_visible = visible;
    458        
     458
    459459        pointer_show();
    460460}
     
    479479        if (kfb_vp == NULL)
    480480                return ENOMEM;
    481        
     481
    482482        /*
    483483         * Conditions necessary to select aligned glyph
     
    489489         */
    490490        size_t word_size = sizeof(unsigned long);
    491        
     491
    492492        if (((word_size % kfb.pixel_bytes) == 0)
    493493            && ((FONT_WIDTH * kfb.pixel_bytes) % word_size == 0)
     
    497497        else
    498498                kfb_vp->draw_char = draw_char_fallback;
    499        
     499
    500500        vp->attrs.type = CHAR_ATTR_RGB;
    501501        vp->attrs.val.rgb.bgcolor = DEFAULT_BGCOLOR;
    502502        vp->attrs.val.rgb.fgcolor = DEFAULT_FGCOLOR;
    503503        vp->data = (void *) kfb_vp;
    504        
     504
    505505        return EOK;
    506506}
     
    514514{
    515515        pointer_hide();
    516        
     516
    517517        for (sysarg_t row = 0; row < vp->rows; row++) {
    518518                for (sysarg_t col = 0; col < vp->cols; col++) {
    519519                        charfield_t *field =
    520520                            screenbuffer_field_at(vp->backbuf, col, row);
    521                        
     521
    522522                        field->ch = 0;
    523523                        field->attrs = vp->attrs;
    524524                }
    525525        }
    526        
     526
    527527        pixel_t bgcolor = 0;
    528528        pixel_t fgcolor = 0;
    529529        attrs_rgb(vp->attrs, &bgcolor, &fgcolor);
    530        
     530
    531531        draw_filled_rect(vp->x, vp->y, vp->x + vp->width,
    532532            vp->y + vp->height, bgcolor);
    533        
     533
    534534        pointer_show();
    535535}
     
    569569{
    570570        pointer_hide();
    571        
     571
    572572        for (sysarg_t y = 0; y < height; y++) {
    573573                for (sysarg_t x = 0; x < width; x++) {
     
    576576                }
    577577        }
    578        
     578
    579579        pointer_show();
    580580}
     
    605605{
    606606        memset(kfb.glyphs, 0, sz);
    607        
     607
    608608        for (unsigned int glyph = 0; glyph < FONT_GLYPHS; glyph++) {
    609609                for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
     
    626626        if (rc != EOK)
    627627                present = false;
    628        
     628
    629629        if (!present)
    630630                return ENOENT;
    631        
     631
    632632        sysarg_t kind;
    633633        rc = sysinfo_get_value("fb.kind", &kind);
    634634        if (rc != EOK)
    635635                kind = (sysarg_t) -1;
    636        
     636
    637637        if (kind != 1)
    638638                return EINVAL;
    639        
     639
    640640        sysarg_t paddr;
    641641        rc = sysinfo_get_value("fb.address.physical", &paddr);
    642642        if (rc != EOK)
    643643                return rc;
    644        
     644
    645645        sysarg_t offset;
    646646        rc = sysinfo_get_value("fb.offset", &offset);
    647647        if (rc != EOK)
    648648                offset = 0;
    649        
     649
    650650        sysarg_t width;
    651651        rc = sysinfo_get_value("fb.width", &width);
    652652        if (rc != EOK)
    653653                return rc;
    654        
     654
    655655        sysarg_t height;
    656656        rc = sysinfo_get_value("fb.height", &height);
    657657        if (rc != EOK)
    658658                return rc;
    659        
     659
    660660        sysarg_t scanline;
    661661        rc = sysinfo_get_value("fb.scanline", &scanline);
    662662        if (rc != EOK)
    663663                return rc;
    664        
     664
    665665        sysarg_t visual;
    666666        rc = sysinfo_get_value("fb.visual", &visual);
    667667        if (rc != EOK)
    668668                return rc;
    669        
     669
    670670        kfb.width = width;
    671671        kfb.height = height;
     
    673673        kfb.scanline = scanline;
    674674        kfb.visual = visual;
    675        
     675
    676676        switch (visual) {
    677677        case VISUAL_INDIRECT_8:
     
    744744                return EINVAL;
    745745        }
    746        
     746
    747747        kfb.glyph_scanline = FONT_WIDTH * kfb.pixel_bytes;
    748748        kfb.glyph_bytes = kfb.glyph_scanline * FONT_SCANLINES;
    749        
     749
    750750        size_t sz = 2 * FONT_GLYPHS * kfb.glyph_bytes;
    751751        kfb.glyphs = (uint8_t *) malloc(sz);
    752752        if (kfb.glyphs == NULL)
    753753                return EINVAL;
    754        
     754
    755755        render_glyphs(sz);
    756        
     756
    757757        kfb.size = scanline * height;
    758        
     758
    759759        rc = physmem_map((void *) paddr + offset,
    760760            ALIGN_UP(kfb.size, PAGE_SIZE) >> PAGE_WIDTH,
     
    764764                return rc;
    765765        }
    766        
     766
    767767        kfb.pointer_x = 0;
    768768        kfb.pointer_y = 0;
     
    770770        kfb.pointer_imgmap = imgmap_create(POINTER_WIDTH, POINTER_HEIGHT,
    771771            VISUAL_RGB_0_8_8_8, IMGMAP_FLAG_NONE);
    772        
     772
    773773        kfb.backbuf = NULL;
    774        
     774
    775775        fbdev_t *dev = fbdev_register(&kfb_ops, (void *) &kfb);
    776776        if (dev == NULL) {
     
    779779                return EINVAL;
    780780        }
    781        
     781
    782782        return EOK;
    783783}
  • uspace/srv/hid/output/proto/vt100.c

    r3061bc1 ra35b458  
    7777{
    7878        char control[MAX_CONTROL];
    79        
     79
    8080        snprintf(control, MAX_CONTROL, "\033[%um", mode);
    8181        state->control_puts(control);
     
    8585{
    8686        char control[MAX_CONTROL];
    87        
     87
    8888        snprintf(control, MAX_CONTROL, "\033[%" PRIun ";%" PRIun "f",
    8989            row + 1, col + 1);
     
    123123                vt100_sgr(state, SGR_BGCOLOR + color_map[attrs.val.index.bgcolor & 7]);
    124124                vt100_sgr(state, SGR_FGCOLOR + color_map[attrs.val.index.fgcolor & 7]);
    125                
     125
    126126                if (attrs.val.index.attr & CATTR_BRIGHT)
    127127                        vt100_sgr(state, SGR_BOLD);
    128                
     128
    129129                break;
    130130        case CHAR_ATTR_RGB:
    131131                vt100_sgr(state, SGR_RESET);
    132                
     132
    133133                if (attrs.val.rgb.bgcolor <= attrs.val.rgb.fgcolor)
    134134                        vt100_sgr(state, SGR_REVERSE);
    135                
     135
    136136                break;
    137137        }
     
    145145        if (state == NULL)
    146146                return NULL;
    147        
     147
    148148        state->putchar = putchar_fn;
    149149        state->control_puts = control_puts_fn;
    150150        state->flush = flush_fn;
    151        
     151
    152152        state->cols = cols;
    153153        state->rows = rows;
    154        
     154
    155155        state->cur_col = (sysarg_t) -1;
    156156        state->cur_row = (sysarg_t) -1;
    157        
     157
    158158        state->cur_attrs.type = CHAR_ATTR_STYLE;
    159159        state->cur_attrs.val.style = STYLE_NORMAL;
    160        
     160
    161161        /* Initialize graphic rendition attributes */
    162162        vt100_sgr(state, SGR_RESET);
     
    195195        if ((col >= state->cols) || (row >= state->rows))
    196196                return;
    197        
     197
    198198        if ((col != state->cur_col) || (row != state->cur_row)) {
    199199                vt100_set_pos(state, col, row);
     
    223223        state->putchar(ch == 0 ? ' ' : ch);
    224224        state->cur_col++;
    225        
     225
    226226        if (state->cur_col >= state->cols) {
    227227                state->cur_row += state->cur_col / state->cols;
  • uspace/srv/hid/output/proto/vt100.h

    r3061bc1 ra35b458  
    4242        sysarg_t cols;
    4343        sysarg_t rows;
    44        
     44
    4545        sysarg_t cur_col;
    4646        sysarg_t cur_row;
    4747        char_attrs_t cur_attrs;
    48        
     48
    4949        vt100_putchar_t putchar;
    5050        vt100_control_puts_t control_puts;
Note: See TracChangeset for help on using the changeset viewer.