Lines Matching +full:speed +full:- +full:set
1 /* termios.c - fake termios interface using sgtty interface
35 * to the name. Don't bother with the low speeds - Minix does not support
44 static _PROTOTYPE( int tc_to_sg_speed, (speed_t speed) );
45 static _PROTOTYPE( speed_t sg_to_tc_speed, (int speed) );
48 /* The speed get/set functions could be macros in the Minix implementation
49 * because there are speed fields in the structure with no fancy packing
58 return termios_p->c_ispeed;
64 return termios_p->c_ospeed;
67 speed_t cfsetispeed(termios_p, speed) in cfsetispeed() argument
69 speed_t speed;
71 termios_p->c_ispeed = speed;
75 speed_t cfsetospeed(termios_p, speed) in cfsetospeed() argument
77 speed_t speed;
79 termios_p->c_ospeed = speed;
83 static speed_t sg_to_tc_speed(speed) in sg_to_tc_speed() argument
84 int speed; in sg_to_tc_speed()
86 /* The speed encodings in sgtty.h and termios.h are different. Both are
90 switch (speed) {
114 default: return (speed_t)-1;
118 static int tc_to_sg_speed(speed) in tc_to_sg_speed() argument
119 speed_t speed; in tc_to_sg_speed()
121 /* Don't use a switch here in case the compiler is 16-bit and doesn't
125 if (speed == 0) return 0;
126 if (speed == 110) return B110;
127 if (speed == 200) return B200;
128 if (speed == 300) return B300;
129 if (speed == 600) return B600;
130 if (speed == 1200) return B1200;
131 if (speed == 1800) return B1800;
132 if (speed == 2400) return B2400;
133 if (speed == 4800) return B4800;
134 if (speed == 9600) return B9600;
135 if (speed == 19200) return B19200;
137 if (speed == 28800) return B28800;
140 if (speed == 38400) return B38400;
143 if (speed == 57600) return B57600;
146 if (speed == 115200) return B115200;
148 return -1;
161 return -1;
167 * ICRNL: set if CRMOD is set and not RAW (CRMOD also controls output)
177 termios_p->c_iflag = IGNBRK;
180 termios_p->c_iflag |= IXON;
183 termios_p->c_iflag |= ICRNL;
188 * OPOST: set if CRMOD or XTABS is set
192 termios_p->c_oflag = sgbuf.sg_flags & (CRMOD | XTABS);
193 if (termios_p->c_oflag)
195 termios_p->c_oflag |= OPOST;
199 * ECHO: set if ECHO is set
200 * ECHOE: set if ECHO is set (ERASE echoed as error-corecting backspace)
201 * ECHOK: set if ECHO is set ('\n' echoed after KILL char)
202 * ECHONL: forced off ('\n' not echoed when ECHO isn't set)
203 * ICANON: set if neither CBREAK nor RAW
205 * ISIG: set if not RAW
209 termios_p->c_lflag = 0;
212 termios_p->c_lflag |= T_ECHO | ECHOE | ECHOK;
216 termios_p->c_lflag |= ISIG;
219 termios_p->c_lflag |= ICANON;
224 * CLOCAL: forced on (ignore modem status lines - not quite right)
226 * CSIZE: CS5-CS8 correspond directly to BITS5-BITS8
227 * CSTOPB: set for B110 (driver will generate 2 stop-bits than)
229 * PARENB: set if EVENP or ODDP is set
230 * PARODD: set if ODDP is set
232 termios_p->c_cflag = CLOCAL | CREAD;
235 case BITS5: termios_p->c_cflag |= CS5; break;
236 case BITS6: termios_p->c_cflag |= CS6; break;
237 case BITS7: termios_p->c_cflag |= CS7; break;
238 case BITS8: termios_p->c_cflag |= CS8; break;
242 termios_p->c_cflag |= PARENB | PARODD;
246 termios_p->c_cflag |= PARENB;
250 termios_p->c_cflag |= CSTOPB;
257 * Otherwise it would be very suprisingly not to be able to set
260 termios_p->c_ospeed =
261 termios_p->c_ispeed =
267 termios_p->c_cc[VEOF] = tcbuf.t_eofc;
268 termios_p->c_cc[VEOL] = tcbuf.t_brkc;
269 termios_p->c_cc[VERASE] = sgbuf.sg_erase;
270 termios_p->c_cc[VINTR] = tcbuf.t_intrc;
271 termios_p->c_cc[VKILL] = sgbuf.sg_kill;
272 termios_p->c_cc[VQUIT] = tcbuf.t_quitc;
273 termios_p->c_cc[VSTART] = tcbuf.t_startc;
274 termios_p->c_cc[VSTOP] = tcbuf.t_stopc;
275 termios_p->c_cc[VMIN] = 1;
276 termios_p->c_cc[VTIME] = 0;
277 termios_p->c_cc[VSUSP] = 0;
291 /* Posix 1003.1-1988 page 135 says:
292 * Attempts to set unsupported baud rates shall be ignored, and it is
293 * implementation-defined whether an error is returned by any or all of
300 if ((termios_p->c_ispeed != 0 && termios_p->c_ispeed != termios_p->c_ospeed)
301 || (sgspeed = tc_to_sg_speed(termios_p->c_ospeed)) < 0)
304 return -1;
325 if (termios_p->c_oflag & OPOST)
330 if (termios_p->c_oflag & XTABS)
336 if (termios_p->c_iflag & ICRNL)
338 /* We couldn't do it better :-(. */
342 if (termios_p->c_lflag & T_ECHO)
346 if (!(termios_p->c_lflag & ICANON))
348 if (termios_p->c_lflag & ISIG)
358 switch (termios_p->c_cflag & CSIZE)
365 if (termios_p->c_cflag & PARENB)
367 if (termios_p->c_cflag & PARODD)
377 sgbuf.sg_erase = termios_p->c_cc[VERASE];
378 sgbuf.sg_kill = termios_p->c_cc[VKILL];
380 tcbuf.t_intrc = termios_p->c_cc[VINTR];
381 tcbuf.t_quitc = termios_p->c_cc[VQUIT];
382 tcbuf.t_startc = termios_p->c_cc[VSTART];
383 tcbuf.t_stopc = termios_p->c_cc[VSTOP];
384 tcbuf.t_eofc = termios_p->c_cc[VEOF];
385 tcbuf.t_brkc = termios_p->c_cc[VEOL];
389 -1 : 0;