Lines Matching +full:convert +full:- +full:rate
1 // SPDX-License-Identifier: GPL-2.0
14 * Routine which returns the baud rate of the tty
49 * Convert termios baud rate data into a speed. This should be called
52 * function but should use ->c_[io]speed directly as they are updated.
61 cbaud = termios->c_cflag & CBAUD; in tty_termios_baud_rate()
66 return termios->c_ospeed; in tty_termios_baud_rate()
72 termios->c_cflag &= ~CBAUDEX; in tty_termios_baud_rate()
84 * Convert termios baud rate data into a speed. This should be called
87 * function but should use ->c_[io]speed directly as they are updated.
95 unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD; in tty_termios_input_baud_rate()
102 return termios->c_ispeed; in tty_termios_input_baud_rate()
108 termios->c_cflag &= ~(CBAUDEX << IBSHIFT); in tty_termios_input_baud_rate()
145 int ifound = -1, ofound = -1; in tty_termios_encode_baud_rate()
152 termios->c_ispeed = ibaud; in tty_termios_encode_baud_rate()
153 termios->c_ospeed = obaud; in tty_termios_encode_baud_rate()
156 if ((termios->c_cflag >> IBSHIFT) & CBAUD) in tty_termios_encode_baud_rate()
162 digesting non-exact replies so fuzz a bit */ in tty_termios_encode_baud_rate()
164 if ((termios->c_cflag & CBAUD) == BOTHER) { in tty_termios_encode_baud_rate()
169 if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER) in tty_termios_encode_baud_rate()
172 termios->c_cflag &= ~CBAUD; in tty_termios_encode_baud_rate()
174 termios->c_cflag &= ~(CBAUD << IBSHIFT); in tty_termios_encode_baud_rate()
178 * Our goal is to find a close match to the standard baud rate in tty_termios_encode_baud_rate()
179 * returned. Walk the baud rate table and if we get a very close in tty_termios_encode_baud_rate()
185 if (obaud - oclose <= baud_table[i] && in tty_termios_encode_baud_rate()
187 termios->c_cflag |= baud_bits[i]; in tty_termios_encode_baud_rate()
190 if (ibaud - iclose <= baud_table[i] && in tty_termios_encode_baud_rate()
199 termios->c_cflag |= (baud_bits[i] << IBSHIFT); in tty_termios_encode_baud_rate()
210 if (ofound == -1) in tty_termios_encode_baud_rate()
211 termios->c_cflag |= BOTHER; in tty_termios_encode_baud_rate()
214 if (ifound == -1 && (ibaud != obaud || ibinput)) in tty_termios_encode_baud_rate()
215 termios->c_cflag |= (BOTHER << IBSHIFT); in tty_termios_encode_baud_rate()
217 if (ifound == -1 || ofound == -1) in tty_termios_encode_baud_rate()
224 * tty_encode_baud_rate - set baud rate of the tty
225 * @ibaud: input baud rate
226 * @obaud: output baud rate
235 tty_termios_encode_baud_rate(&tty->termios, ibaud, obaud); in tty_encode_baud_rate()