blob: 3f821e98af0f877ff1a5b5cc65b387a5c85932bd [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;
Paul Fulghum33b37a32006-06-28 04:26:49 -070020 if (tb && tb->used < tb->size) {
Peter Hurley1fc359f2013-06-15 09:36:01 -040021 *flag_buf_ptr(tb, tb->used) = flag;
22 *char_buf_ptr(tb, tb->used++) = ch;
Alan Cox33f0f882006-01-09 20:54:13 -080023 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 }
Jiri Slaby92a19f92013-01-03 15:53:03 +010025 return tty_insert_flip_string_flags(port, &ch, &flag, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026}
27
Jiri Slaby05c7cd32013-01-03 15:53:04 +010028static inline int tty_insert_flip_string(struct tty_port *port,
29 const unsigned char *chars, size_t size)
Alan Cox2832fc12010-02-18 16:43:54 +000030{
Jiri Slaby05c7cd32013-01-03 15:53:04 +010031 return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size);
Alan Cox2832fc12010-02-18 16:43:54 +000032}
33
Peter Hurleya7c8d582013-06-15 09:36:15 -040034extern void tty_buffer_lock_exclusive(struct tty_port *port);
35extern void tty_buffer_unlock_exclusive(struct tty_port *port);
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#endif /* _LINUX_TTY_FLIP_H */