blob: c28dd523f96e655fcd89dd4bcb4ab200255cbb54 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_TTY_FLIP_H
2#define _LINUX_TTY_FLIP_H
3
Peter Hurley4d18e6ef2013-11-22 12:09:55 -05004extern int tty_buffer_set_limit(struct tty_port *port, int limit);
Peter Hurley7bfe0b72013-06-15 09:36:08 -04005extern int tty_buffer_space_avail(struct tty_port *port);
Jiri Slaby227434f2013-01-03 15:53:01 +01006extern int tty_buffer_request_room(struct tty_port *port, size_t size);
Jiri Slaby2f693352013-01-03 15:53:02 +01007extern int tty_insert_flip_string_flags(struct tty_port *port,
8 const unsigned char *chars, const char *flags, size_t size);
9extern int tty_insert_flip_string_fixed_flag(struct tty_port *port,
10 const unsigned char *chars, char flag, size_t size);
11extern int tty_prepare_flip_string(struct tty_port *port,
12 unsigned char **chars, size_t size);
Jiri Slaby2e124b42013-01-03 15:53:06 +010013extern void tty_flip_buffer_push(struct tty_port *port);
Jiri Slaby6732c8b2013-01-03 15:53:07 +010014void tty_schedule_flip(struct tty_port *port);
Alan Cox33f0f882006-01-09 20:54:13 -080015
Jiri Slaby92a19f92013-01-03 15:53:03 +010016static inline int tty_insert_flip_char(struct tty_port *port,
Andrew Mortone1a25092006-04-10 22:54:05 -070017 unsigned char ch, char flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018{
Jiri Slaby92a19f92013-01-03 15:53:03 +010019 struct tty_buffer *tb = port->buf.tail;
Peter Hurleyacc0f672013-12-09 09:23:52 -050020 int change;
21
22 change = (tb->flags & TTYB_NORMAL) && (flag != TTY_NORMAL);
23 if (!change && tb->used < tb->size) {
24 if (~tb->flags & TTYB_NORMAL)
25 *flag_buf_ptr(tb, tb->used) = flag;
Peter Hurley1fc359f2013-06-15 09:36:01 -040026 *char_buf_ptr(tb, tb->used++) = ch;
Alan Cox33f0f882006-01-09 20:54:13 -080027 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 }
Jiri Slaby92a19f92013-01-03 15:53:03 +010029 return tty_insert_flip_string_flags(port, &ch, &flag, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
31
Jiri Slaby05c7cd32013-01-03 15:53:04 +010032static inline int tty_insert_flip_string(struct tty_port *port,
33 const unsigned char *chars, size_t size)
Alan Cox2832fc12010-02-18 16:43:54 +000034{
Jiri Slaby05c7cd32013-01-03 15:53:04 +010035 return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size);
Alan Cox2832fc12010-02-18 16:43:54 +000036}
37
Peter Hurleya7c8d582013-06-15 09:36:15 -040038extern void tty_buffer_lock_exclusive(struct tty_port *port);
39extern void tty_buffer_unlock_exclusive(struct tty_port *port);
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#endif /* _LINUX_TTY_FLIP_H */