Changeset 8565a42 in mainline for uspace/srv/hid/rfb


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/srv/hid/rfb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/rfb/main.c

    r3061bc1 r8565a42  
    7878{
    7979        fibril_mutex_lock(&rfb.lock);
    80        
     80
    8181        if (x0 + width > rfb.width || y0 + height > rfb.height) {
    8282                fibril_mutex_unlock(&rfb.lock);
    8383                return EINVAL;
    8484        }
    85        
     85
    8686        /* TODO update surface_t and use it */
    8787        if (!rfb.damage_valid) {
     
    112112                }
    113113        }
    114        
     114
    115115        pixelmap_t *map = &vs->cells;
    116        
     116
    117117        for (sysarg_t y = y0; y < height + y0; ++y) {
    118118                for (sysarg_t x = x0; x < width + x0; ++x) {
     
    122122                }
    123123        }
    124        
     124
    125125        fibril_mutex_unlock(&rfb.lock);
    126126        return EOK;
     
    161161
    162162        const char *rfb_name = argv[1];
    163        
     163
    164164        char *endptr;
    165165        unsigned long width = strtoul(argv[2], &endptr, 0);
     
    169169                return 1;
    170170        }
    171        
     171
    172172        unsigned long height = strtoul(argv[3], &endptr, 0);
    173173        if (*endptr != 0) {
     
    176176                return 1;
    177177        }
    178        
     178
    179179        unsigned long port = 5900;
    180180        if (argc > 4) {
     
    186186                }
    187187        }
    188        
     188
    189189        rfb_init(&rfb, width, height, rfb_name);
    190        
     190
    191191        vis = malloc(sizeof(visualizer_t));
    192192        if (vis == NULL) {
     
    194194                return 3;
    195195        }
    196        
     196
    197197        graph_init_visualizer(vis);
    198        
     198
    199199        pixel_mode.mode.index = 0;
    200200        pixel_mode.mode.version = 0;
     
    207207        pixel_mode.mode.cell_aspect.height = 1;
    208208        pixel_mode.mode.cell_visual.pixel_visual = VISUAL_RGB_8_8_8;
    209        
     209
    210210        link_initialize(&pixel_mode.link);
    211211        list_append(&pixel_mode.link, &vis->modes);
    212        
     212
    213213        vis->def_mode_idx = 0;
    214        
     214
    215215        vis->ops = rfb_ops;
    216216        vis->dev_ctx = NULL;
     
    232232
    233233        service_id_t service_id;
    234        
     234
    235235        rc = loc_service_register(service_name, &service_id);
    236236        if (rc != EOK) {
     
    238238                return rc;
    239239        }
    240        
     240
    241241        free(service_name);
    242242
     
    247247                return 1;
    248248        }
    249        
     249
    250250        rc = loc_service_add_to_cat(service_id, visualizer_category);
    251251        if (rc != EOK) {
     
    253253                return 1;
    254254        }
    255        
     255
    256256        rc = rfb_listen(&rfb, port);
    257257        if (rc != EOK) {
     
    259259                return 2;
    260260        }
    261        
     261
    262262        printf("%s: Accepting connections\n", NAME);
    263263        task_retval(0);
  • uspace/srv/hid/rfb/rfb.c

    r3061bc1 r8565a42  
    7070                rbuf_out = 0;
    7171                rbuf_in = 0;
    72                
     72
    7373                rc = tcp_conn_recv_wait(conn, rbuf, BUFFER_SIZE, &nrecv);
    7474                if (rc != EOK)
    7575                        return rc;
    76                
     76
    7777                rbuf_in = nrecv;
    7878        }
    79        
     79
    8080        *c = rbuf[rbuf_out++];
    8181        return EOK;
     
    177177        memset(rfb, 0, sizeof(rfb_t));
    178178        fibril_mutex_initialize(&rfb->lock);
    179        
     179
    180180        rfb_pixel_format_t *pf = &rfb->pixel_format;
    181181        pf->bpp = 32;
     
    189189        pf->g_shift = 8;
    190190        pf->b_shift = 16;
    191        
     191
    192192        rfb->name = str_dup(name);
    193193        rfb->supports_trle = false;
    194        
     194
    195195        return rfb_set_size(rfb, width, height);
    196196}
     
    209209        rfb->width = width;
    210210        rfb->height = height;
    211        
     211
    212212        /* Fill with white */
    213213        memset(rfb->framebuffer.data, 255, new_size);
    214        
     214
    215215        return EOK;
    216216}
     
    242242                }
    243243        }
    244        
     244
    245245        if (first_free_index != -1) {
    246246                rfb->palette[first_free_index] = PIXEL(255, RED(pixel), GREEN(pixel),
     
    250250                return;
    251251        }
    252        
     252
    253253        /* TODO find nearest color index. We are lazy so return index 0 for now */
    254254        *buf = 0;
     
    262262        pix |= rfb_scale_channel(GREEN(pixel), pf->g_max) << pf->g_shift;
    263263        pix |= rfb_scale_channel(BLUE(pixel), pf->b_max) << pf->b_shift;
    264        
     264
    265265        if (pf->bpp == 8) {
    266266                uint8_t pix8 = pix;
     
    317317        size_t size = sizeof(rfb_set_color_map_entries_t) +
    318318            rfb->palette_used * sizeof(rfb_color_map_entry_t);
    319        
     319
    320320        void *buf = malloc(size);
    321321        if (buf == NULL)
    322322                return NULL;
    323        
     323
    324324        void *pos = buf;
    325        
     325
    326326        rfb_set_color_map_entries_t *scme = pos;
    327327        scme->message_type = RFB_SMSG_SET_COLOR_MAP_ENTRIES;
     
    330330        rfb_set_color_map_entries_to_be(scme, scme);
    331331        pos += sizeof(rfb_set_color_map_entries_t);
    332        
     332
    333333        rfb_color_map_entry_t *entries = pos;
    334334        for (unsigned i = 0; i < rfb->palette_used; i++) {
     
    338338                rfb_color_map_entry_to_be(&entries[i], &entries[i]);
    339339        }
    340        
     340
    341341        *psize = size;
    342342        return buf;
     
    347347        size_t pixel_size = rfb->pixel_format.bpp / 8;
    348348        size_t size = (rect->width * rect->height * pixel_size);
    349        
     349
    350350        if (buf == NULL)
    351351                return size;
    352        
     352
    353353        for (uint16_t y = 0; y < rect->height; y++) {
    354354                for (uint16_t x = 0; x < rect->width; x++) {
     
    359359                }
    360360        }
    361        
     361
    362362        return size;
    363363}
     
    376376        ctx->size = pixel_format->bpp / 8;
    377377        ctx->compress_type = COMP_NONE;
    378        
     378
    379379        if (pixel_format->bpp == 32 && pixel_format->depth <= 24) {
    380380                uint32_t mask = 0;
     
    382382                mask |= pixel_format->g_max << pixel_format->g_shift;
    383383                mask |= pixel_format->b_max << pixel_format->b_shift;
    384                
     384
    385385                if (pixel_format->big_endian) {
    386386                        mask = host2uint32_t_be(mask);
     
    389389                        mask = host2uint32_t_le(mask);
    390390                }
    391                
     391
    392392                uint8_t *mask_data = (uint8_t *) &mask;
    393393                if (mask_data[0] == 0) {
     
    407407        uint8_t data[4];
    408408        rfb_encode_pixel(rfb, data, pixel);
    409        
     409
    410410        switch (cpixel->compress_type) {
    411411        case COMP_NONE:
     
    424424        if (buf == NULL)
    425425                return size;
    426        
     426
    427427        for (uint16_t y = tile->y; y < tile->y + tile->height; y++) {
    428428                for (uint16_t x = tile->x; x < tile->x + tile->width; x++) {
     
    431431                }
    432432        }
    433        
     433
    434434        return size;
    435435}
     
    446446                }
    447447        }
    448        
     448
    449449        /* OK, encode it */
    450450        if (buf)
     
    458458        cpixel_ctx_t cpixel;
    459459        cpixel_context_init(&cpixel, &rfb->pixel_format);
    460        
     460
    461461        size_t size = 0;
    462462        for (uint16_t y = 0; y < rect->height; y += 16) {
     
    468468                                .height = (y + 16 <= rect->height ? 16 : rect->height - y)
    469469                        };
    470                        
     470
    471471                        size += 1;
    472472                        uint8_t *tile_enctype_ptr = buf;
    473473                        if (buf)
    474474                                buf +=  1;
    475                        
     475
    476476                        uint8_t tile_enctype = RFB_TILE_ENCODING_SOLID;
    477477                        size_t tile_size;
     
    482482                                tile_enctype = RFB_TILE_ENCODING_RAW;
    483483                        }
    484                        
     484
    485485                        if (buf) {
    486486                                *tile_enctype_ptr = tile_enctype;
     
    502502                rfb->damage_rect.height = rfb->height;
    503503        }
    504        
     504
    505505
    506506        /* We send only single raw rectangle right now */
     
    509509            rfb_rect_encode_raw(rfb, &rfb->damage_rect, NULL)
    510510            ;
    511        
     511
    512512        void *buf = malloc(buf_size);
    513513        if (buf == NULL) {
     
    516516        }
    517517        memset(buf, 0, buf_size);
    518        
     518
    519519        void *pos = buf;
    520520        rfb_framebuffer_update_t *fbu = buf;
     
    523523        rfb_framebuffer_update_to_be(fbu, fbu);
    524524        pos += sizeof(rfb_framebuffer_update_t);
    525        
     525
    526526        rfb_rectangle_t *rect = pos;
    527527        pos += sizeof(rfb_rectangle_t);
    528        
     528
    529529        *rect = rfb->damage_rect;
    530        
     530
    531531        if (rfb->supports_trle) {
    532532                rect->enctype = RFB_ENCODING_TRLE;
     
    538538        }
    539539        rfb_rectangle_to_be(rect, rect);
    540        
     540
    541541        rfb->damage_valid = false;
    542        
     542
    543543        size_t send_palette_size = 0;
    544544        void *send_palette = NULL;
    545        
     545
    546546        if (!rfb->pixel_format.true_color) {
    547547                send_palette = rfb_send_palette_message(rfb, &send_palette_size);
     
    552552                }
    553553        }
    554        
     554
    555555        fibril_mutex_unlock(&rfb->lock);
    556        
     556
    557557        if (!rfb->pixel_format.true_color) {
    558558                errno_t rc = tcp_conn_send(conn, send_palette, send_palette_size);
     
    562562                }
    563563        }
    564        
     564
    565565        errno_t rc = tcp_conn_send(conn, buf, buf_size);
    566566        free(buf);
    567        
     567
    568568        return rc;
    569569}
     
    605605                return;
    606606        }
    607        
     607
    608608        char client_version[12];
    609609        rc = recv_chars(conn, client_version, 12);
     
    613613                return;
    614614        }
    615        
     615
    616616        if (memcmp(client_version, "RFB 003.008\n", 12) != 0) {
    617617                log_msg(LOG_DEFAULT, LVL_WARN, "Client version is not RFB 3.8");
    618618                return;
    619619        }
    620        
     620
    621621        /* Security handshake
    622622         * 1 security type supported, which is 1 - None
     
    631631                return;
    632632        }
    633        
     633
    634634        char selected_sec_type = 0;
    635635        rc = recv_char(conn, &selected_sec_type);
     
    651651                return;
    652652        }
    653        
     653
    654654        /* Client init */
    655655        char shared_flag;
     
    660660                return;
    661661        }
    662        
     662
    663663        /* Server init */
    664664        fibril_mutex_lock(&rfb->lock);
     
    684684                return;
    685685        }
    686        
     686
    687687        while (true) {
    688688                char message_type = 0;
     
    693693                        return;
    694694                }
    695                
     695
    696696                rfb_set_pixel_format_t spf;
    697697                rfb_set_encodings_t se;
     
    765765        inet_ep_t ep;
    766766        errno_t rc;
    767        
     767
    768768        rc = tcp_create(&tcp);
    769769        if (rc != EOK) {
     
    771771                goto error;
    772772        }
    773        
     773
    774774        inet_ep_init(&ep);
    775775        ep.port = port;
    776        
     776
    777777        rc = tcp_listener_create(tcp, &ep, &listen_cb, rfb, &conn_cb, rfb,
    778778            &lst);
     
    781781                goto error;
    782782        }
    783        
     783
    784784        rfb->tcp = tcp;
    785785        rfb->lst = lst;
    786        
     786
    787787        return EOK;
    788788error:
Note: See TracChangeset for help on using the changeset viewer.