Changeset a35b458 in mainline for kernel/genarch/src/fb/fb.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/fb/fb.c

    r3061bc1 ra35b458  
    8484typedef struct {
    8585        SPINLOCK_DECLARE(lock);
    86        
     86
    8787        parea_t parea;
    88        
     88
    8989        uint8_t *addr;
    9090        uint16_t *backbuf;
    9191        uint8_t *glyphs;
    9292        uint8_t *bgscan;
    93        
     93
    9494        rgb_conv_t rgb_conv;
    95        
     95
    9696        unsigned int xres;
    9797        unsigned int yres;
    98        
     98
    9999        /** Number of rows that fit on framebuffer */
    100100        unsigned int rowtrim;
    101        
     101
    102102        unsigned int scanline;
    103103        unsigned int glyphscanline;
    104        
     104
    105105        unsigned int pixelbytes;
    106106        unsigned int glyphbytes;
    107107        unsigned int bgscanbytes;
    108        
     108
    109109        /** Number of columns in the backbuffer */
    110110        unsigned int cols;
    111111        /** Number of rows in the backbuffer */
    112112        unsigned int rows;
    113        
     113
    114114        /** Starting row in the cyclic backbuffer */
    115115        unsigned int start_row;
    116        
     116
    117117        /** Top-most visible row (relative to start_row) */
    118118        unsigned int offset_row;
    119        
     119
    120120        /** Current backbuffer position */
    121121        unsigned int position;
     
    236236        if (!overlay)
    237237                instance->backbuf[BB_POS(instance, col, row)] = glyph;
    238        
     238
    239239        /* Do not output if the framebuffer is used by user space */
    240240        if ((instance->parea.mapped) && (!console_override))
    241241                return;
    242        
     242
    243243        /* Check whether the glyph should be visible */
    244244        if (row < instance->offset_row)
    245245                return;
    246        
     246
    247247        unsigned int rel_row = row - instance->offset_row;
    248248        if (rel_row >= instance->rowtrim)
    249249                return;
    250        
     250
    251251        unsigned int x = COL2X(col);
    252252        unsigned int y = ROW2Y(rel_row);
    253        
     253
    254254        for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++)
    255255                memcpy(&instance->addr[FB_POS(instance, x, y + yd)],
     
    267267                        unsigned int y = ROW2Y(rel_row);
    268268                        unsigned int row = rel_row + instance->offset_row;
    269                        
     269
    270270                        for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) {
    271271                                unsigned int x;
    272272                                unsigned int col;
    273                                
     273
    274274                                for (col = 0, x = 0; col < instance->cols;
    275275                                    col++, x += FONT_WIDTH) {
    276276                                        uint16_t glyph;
    277                                        
     277
    278278                                        if (row < instance->rows - 1) {
    279279                                                if (instance->backbuf[BB_POS(instance, col, row)] ==
    280280                                                    instance->backbuf[BB_POS(instance, col, row + 1)])
    281281                                                        continue;
    282                                                
     282
    283283                                                glyph = instance->backbuf[BB_POS(instance, col, row + 1)];
    284284                                        } else
    285285                                                glyph = 0;
    286                                        
     286
    287287                                        memcpy(&instance->addr[FB_POS(instance, x, y + yd)],
    288288                                            &instance->glyphs[GLYPH_POS(instance, glyph, yd)],
     
    292292                }
    293293        }
    294        
     294
    295295        /*
    296296         * Implement backbuffer scrolling by wrapping around
    297297         * the cyclic buffer.
    298298         */
    299        
     299
    300300        instance->start_row++;
    301301        if (instance->start_row == instance->rows)
    302302                instance->start_row = 0;
    303        
     303
    304304        memsetw(&instance->backbuf[BB_POS(instance, 0, instance->rows - 1)],
    305305            instance->cols, 0);
     
    310310        unsigned int col = instance->position % instance->cols;
    311311        unsigned int row = instance->position / instance->cols;
    312        
     312
    313313        glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, true);
    314314}
     
    318318        unsigned int col = instance->position % instance->cols;
    319319        unsigned int row = instance->position / instance->cols;
    320        
     320
    321321        glyph_draw(instance, instance->backbuf[BB_POS(instance, col, row)],
    322322            col, row, true);
     
    333333        /* Prerender glyphs */
    334334        uint16_t glyph;
    335        
     335
    336336        for (glyph = 0; glyph < FONT_GLYPHS; glyph++) {
    337337                uint32_t fg_color;
    338                
     338
    339339                if (glyph == FONT_GLYPHS - 1)
    340340                        fg_color = INV_COLOR;
    341341                else
    342342                        fg_color = FG_COLOR;
    343                
     343
    344344                unsigned int y;
    345                
     345
    346346                for (y = 0; y < FONT_SCANLINES; y++) {
    347347                        unsigned int x;
    348                        
     348
    349349                        for (x = 0; x < FONT_WIDTH; x++) {
    350350                                void *dst =
     
    357357                }
    358358        }
    359        
     359
    360360        /* Prerender background scanline */
    361361        unsigned int x;
    362        
     362
    363363        for (x = 0; x < instance->xres; x++)
    364364                instance->rgb_conv(&instance->bgscan[x * instance->pixelbytes], BG_COLOR);
     
    370370                unsigned int y = ROW2Y(rel_row);
    371371                unsigned int row = rel_row + instance->offset_row;
    372                
     372
    373373                for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) {
    374374                        unsigned int x;
    375375                        unsigned int col;
    376                        
     376
    377377                        for (col = 0, x = 0; col < instance->cols;
    378378                            col++, x += FONT_WIDTH) {
     
    385385                }
    386386        }
    387        
     387
    388388        if (COL2X(instance->cols) < instance->xres) {
    389389                unsigned int y;
    390390                unsigned int size =
    391391                    (instance->xres - COL2X(instance->cols)) * instance->pixelbytes;
    392                
     392
    393393                for (y = 0; y < instance->yres; y++)
    394394                        memcpy(&instance->addr[FB_POS(instance, COL2X(instance->cols), y)],
    395395                            instance->bgscan, size);
    396396        }
    397        
     397
    398398        if (ROW2Y(instance->rowtrim) < instance->yres) {
    399399                unsigned int y;
    400                
     400
    401401                for (y = ROW2Y(instance->rowtrim); y < instance->yres; y++)
    402402                        memcpy(&instance->addr[FB_POS(instance, 0, y)],
     
    414414        fb_instance_t *instance = (fb_instance_t *) dev->data;
    415415        spinlock_lock(&instance->lock);
    416        
     416
    417417        switch (ch) {
    418418        case '\n':
     
    446446                instance->position++;
    447447        }
    448        
     448
    449449        if (instance->position >= instance->cols * instance->rows) {
    450450                instance->position -= instance->cols;
    451451                screen_scroll(instance);
    452452        }
    453        
     453
    454454        cursor_put(instance);
    455        
     455
    456456        spinlock_unlock(&instance->lock);
    457457}
     
    464464        fb_instance_t *instance = (fb_instance_t *) dev->data;
    465465        spinlock_lock(&instance->lock);
    466        
     466
    467467        if (instance->offset_row >= instance->rowtrim / 2)
    468468                instance->offset_row -= instance->rowtrim / 2;
    469469        else
    470470                instance->offset_row = 0;
    471        
     471
    472472        fb_redraw_internal(instance);
    473473        cursor_put(instance);
    474        
     474
    475475        spinlock_unlock(&instance->lock);
    476476}
     
    483483        fb_instance_t *instance = (fb_instance_t *) dev->data;
    484484        spinlock_lock(&instance->lock);
    485        
     485
    486486        if (instance->offset_row + instance->rowtrim / 2 <=
    487487            instance->rows - instance->rowtrim)
     
    489489        else
    490490                instance->offset_row = instance->rows - instance->rowtrim;
    491        
     491
    492492        fb_redraw_internal(instance);
    493493        cursor_put(instance);
    494        
     494
    495495        spinlock_unlock(&instance->lock);
    496496}
     
    502502{
    503503        fb_instance_t *instance = (fb_instance_t *) dev->data;
    504        
     504
    505505        spinlock_lock(&instance->lock);
    506506        fb_redraw_internal(instance);
     
    517517        assert(props->y > 0);
    518518        assert(props->scan > 0);
    519        
     519
    520520        rgb_conv_t rgb_conv;
    521521        unsigned int pixelbytes;
    522        
     522
    523523        switch (props->visual) {
    524524        case VISUAL_INDIRECT_8:
     
    570570                return NULL;
    571571        }
    572        
     572
    573573        outdev_t *fbdev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
    574574        if (!fbdev)
    575575                return NULL;
    576        
     576
    577577        fb_instance_t *instance = malloc(sizeof(fb_instance_t), FRAME_ATOMIC);
    578578        if (!instance) {
     
    580580                return NULL;
    581581        }
    582        
     582
    583583        outdev_initialize("fbdev", fbdev, &fbdev_ops);
    584584        fbdev->data = instance;
    585        
     585
    586586        spinlock_initialize(&instance->lock, "*fb.instance.lock");
    587        
     587
    588588        instance->rgb_conv = rgb_conv;
    589589        instance->pixelbytes = pixelbytes;
     
    591591        instance->yres = props->y;
    592592        instance->scanline = props->scan;
    593        
     593
    594594        instance->rowtrim = Y2ROW(instance->yres);
    595        
     595
    596596        instance->cols = X2COL(instance->xres);
    597597        instance->rows = FB_PAGES * instance->rowtrim;
    598        
     598
    599599        instance->start_row = instance->rows - instance->rowtrim;
    600600        instance->offset_row = instance->start_row;
    601601        instance->position = instance->start_row * instance->cols;
    602        
     602
    603603        instance->glyphscanline = FONT_WIDTH * instance->pixelbytes;
    604604        instance->glyphbytes = ROW2Y(instance->glyphscanline);
    605605        instance->bgscanbytes = instance->xres * instance->pixelbytes;
    606        
     606
    607607        size_t fbsize = instance->scanline * instance->yres;
    608608        size_t bbsize = instance->cols * instance->rows * sizeof(uint16_t);
    609609        size_t glyphsize = FONT_GLYPHS * instance->glyphbytes;
    610        
     610
    611611        instance->addr = (uint8_t *) km_map((uintptr_t) props->addr, fbsize,
    612612            PAGE_WRITE | PAGE_NOT_CACHEABLE);
     
    617617                return NULL;
    618618        }
    619        
     619
    620620        instance->backbuf = (uint16_t *) malloc(bbsize, 0);
    621621        if (!instance->backbuf) {
     
    625625                return NULL;
    626626        }
    627        
     627
    628628        instance->glyphs = (uint8_t *) malloc(glyphsize, 0);
    629629        if (!instance->glyphs) {
     
    634634                return NULL;
    635635        }
    636        
     636
    637637        instance->bgscan = malloc(instance->bgscanbytes, 0);
    638638        if (!instance->bgscan) {
     
    644644                return NULL;
    645645        }
    646        
     646
    647647        memsetw(instance->backbuf, instance->cols * instance->rows, 0);
    648648        glyphs_render(instance);
    649        
     649
    650650        link_initialize(&instance->parea.link);
    651651        instance->parea.pbase = props->addr;
     
    654654        instance->parea.mapped = false;
    655655        ddi_parea_register(&instance->parea);
    656        
     656
    657657        if (!fb_exported) {
    658658                /*
     
    668668                sysinfo_set_item_val("fb.visual", NULL, props->visual);
    669669                sysinfo_set_item_val("fb.address.physical", NULL, props->addr);
    670                
     670
    671671                fb_exported = true;
    672672        }
    673        
     673
    674674        fb_redraw(fbdev);
    675675        return fbdev;
Note: See TracChangeset for help on using the changeset viewer.