Ignore:
File:
1 edited

Legend:

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

    rd31c3ea r28a5ebd  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
    32 * Copyright (c) 2006 Ondrej Palkovsky
    43 * Copyright (c) 2008 Martin Decky
     
    3837#include <errno.h>
    3938#include <io/chargrid.h>
    40 #include <vt/vt100.h>
    4139#include "../output.h"
     40#include "../proto/vt100.h"
    4241#include "serial.h"
    4342
    4443#define SERIAL_COLS  80
    4544#define SERIAL_ROWS  24
    46 
    47 static serial_putuchar_t serial_putuchar_fn;
    48 static serial_control_puts_t serial_control_puts_fn;
    49 static serial_flush_t serial_flush_fn;
    50 
    51 static void serial_vt_putuchar(void *, char32_t);
    52 static void serial_vt_control_puts(void *, const char *);
    53 static void serial_vt_flush(void *);
    54 
    55 static vt100_cb_t serial_vt_cb = {
    56         .putuchar = serial_vt_putuchar,
    57         .control_puts = serial_vt_control_puts,
    58         .flush = serial_vt_flush
    59 };
    6045
    6146/** Draw the character at the specified position.
     
    6752 *
    6853 */
    69 static void draw_char(vt100_t *state, charfield_t *field,
     54static void draw_char(vt100_state_t *state, charfield_t *field,
    7055    sysarg_t col, sysarg_t row)
    7156{
     
    7762static errno_t serial_yield(outdev_t *dev)
    7863{
    79         vt100_t *state = (vt100_t *) dev->data;
     64        vt100_state_t *state = (vt100_state_t *) dev->data;
    8065
    8166        return vt100_yield(state);
     
    8469static errno_t serial_claim(outdev_t *dev)
    8570{
    86         vt100_t *state = (vt100_t *) dev->data;
     71        vt100_state_t *state = (vt100_state_t *) dev->data;
    8772
    8873        return vt100_claim(state);
     
    9277    sysarg_t *rows)
    9378{
    94         vt100_t *state = (vt100_t *) dev->data;
     79        vt100_state_t *state = (vt100_state_t *) dev->data;
    9580
    9681        vt100_get_dimensions(state, cols, rows);
     
    9984static console_caps_t serial_get_caps(outdev_t *dev)
    10085{
    101         return (CONSOLE_CAP_CURSORCTL | CONSOLE_CAP_STYLE |
    102             CONSOLE_CAP_INDEXED | CONSOLE_CAP_RGB);
     86        return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED);
    10387}
    10488
     
    10690    sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible)
    10791{
    108         vt100_t *state = (vt100_t *) dev->data;
     92        vt100_state_t *state = (vt100_state_t *) dev->data;
    10993
    11094        vt100_goto(state, col, row);
     
    11498static void serial_char_update(outdev_t *dev, sysarg_t col, sysarg_t row)
    11599{
    116         vt100_t *state = (vt100_t *) dev->data;
     100        vt100_state_t *state = (vt100_state_t *) dev->data;
    117101        charfield_t *field =
    118102            chargrid_charfield_at(dev->backbuf, col, row);
     
    123107static void serial_flush(outdev_t *dev)
    124108{
    125         vt100_t *state = (vt100_t *) dev->data;
     109        vt100_state_t *state = (vt100_state_t *) dev->data;
    126110
    127111        vt100_flush(state);
     
    138122};
    139123
    140 errno_t serial_init(serial_putuchar_t putuchar_fn,
    141     serial_control_puts_t control_puts_fn, serial_flush_t flush_fn)
     124errno_t serial_init(vt100_putuchar_t putuchar_fn,
     125    vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn)
    142126{
    143         char_attrs_t attrs;
    144         vt100_t *vt100;
     127        vt100_state_t *state =
     128            vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putuchar_fn,
     129            control_puts_fn, flush_fn);
     130        if (state == NULL)
     131                return ENOMEM;
    145132
    146         serial_putuchar_fn = putuchar_fn;
    147         serial_control_puts_fn = control_puts_fn;
    148         serial_flush_fn = flush_fn;
    149 
    150         vt100 = vt100_create(NULL, SERIAL_COLS, SERIAL_ROWS, &serial_vt_cb);
    151         if (vt100 == NULL)
    152                 return ENOMEM;
    153         vt100->enable_rgb = true;
    154 
    155         vt100_cursor_visibility(vt100, false);
    156         attrs.type = CHAR_ATTR_STYLE;
    157         attrs.val.style = STYLE_NORMAL;
    158         vt100_set_attr(vt100, attrs);
    159         vt100_cls(vt100);
    160 
    161         outdev_t *dev = outdev_register(&serial_ops, vt100);
     133        outdev_t *dev = outdev_register(&serial_ops, state);
    162134        if (dev == NULL) {
    163                 vt100_destroy(vt100);
     135                vt100_state_destroy(state);
    164136                return ENOMEM;
    165137        }
     
    168140}
    169141
    170 static void serial_vt_putuchar(void *arg, char32_t c)
    171 {
    172         (void)arg;
    173         serial_putuchar_fn(c);
    174 }
    175 
    176 static void serial_vt_control_puts(void *arg, const char *str)
    177 {
    178         (void)arg;
    179         serial_control_puts_fn(str);
    180 }
    181 
    182 static void serial_vt_flush(void *arg)
    183 {
    184         (void)arg;
    185         serial_flush_fn();
    186 }
    187 
    188142/** @}
    189143 */
Note: See TracChangeset for help on using the changeset viewer.