static void serial_update_parameters(SerialState *s)

{

    int speed, parity, data_bits, stop_bits, frame_size;

    QEMUSerialSetParams ssp;



    if (s->divider == 0)

        return;



    /* Start bit. */

    frame_size = 1;

    if (s->lcr & 0x08) {

        /* Parity bit. */

        frame_size++;

        if (s->lcr & 0x10)

            parity = 'E';

        else

            parity = 'O';

    } else {

            parity = 'N';

    }

    if (s->lcr & 0x04)

        stop_bits = 2;

    else

        stop_bits = 1;



    data_bits = (s->lcr & 0x03) + 5;

    frame_size += data_bits + stop_bits;

    speed = s->baudbase / s->divider;

    ssp.speed = speed;

    ssp.parity = parity;

    ssp.data_bits = data_bits;

    ssp.stop_bits = stop_bits;

    s->char_transmit_time =  (NANOSECONDS_PER_SECOND / speed) * frame_size;

    qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);



    DPRINTF("speed=%d parity=%c data=%d stop=%d\n",

           speed, parity, data_bits, stop_bits);

}
