blob: 21ddd7d9ea1fe0303e5910b7de3019b9851e8bda [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_TTY_FLIP_H
2#define _LINUX_TTY_FLIP_H
3
Peter Hurley7bfe0b72013-06-15 09:36:08 -04004extern int tty_buffer_space_avail(struct tty_port *port);
Jiri Slaby227434f2013-01-03 15:53:01 +01005extern int tty_buffer_request_room(struct tty_port *port, size_t size);
Jiri Slaby2f693352013-01-03 15:53:02 +01006extern int tty_insert_flip_string_flags(struct tty_port *port,
7 const unsigned char *chars, const char *flags, size_t size);
8extern int tty_insert_flip_string_fixed_flag(struct tty_port *port,
9 const unsigned char *chars, char flag, size_t size);
10extern int tty_prepare_flip_string(struct tty_port *port,
11 unsigned char **chars, size_t size);
12extern int tty_prepare_flip_string_flags(struct tty_port *port,
13 unsigned char **chars, char **flags, size_t size);
Jiri Slaby2e124b42013-01-03 15:53:06 +010014extern void tty_flip_buffer_push(struct tty_port *port);
Jiri Slaby6732c8b2013-01-03 15:53:07 +010015void tty_schedule_flip(struct tty_port *port);
Alan Cox33f0f882006-01-09 20:54:13 -080016
Jiri Slaby92a19f92013-01-03 15:53:03 +010017static inline int tty_insert_flip_char(struct tty_port *port,
Andrew Mortone1a25092006-04-10 22:54:05 -070018 unsigned char ch, char flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
Jiri Slaby92a19f92013-01-03 15:53:03 +010020 struct tty_buffer *tb = port->buf.tail;
Paul Fulghum33b37a32006-06-28 04:26:49 -070021 if (tb && tb->used < tb->size) {
Peter Hurley1fc359f2013-06-15 09:36:01 -040022 *flag_buf_ptr(tb, tb->used) = flag;
23 *char_buf_ptr(tb, tb->used++) = ch;
Alan Cox33f0f882006-01-09 20:54:13 -080024 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 }
Jiri Slaby92a19f92013-01-03 15:53:03 +010026 return tty_insert_flip_string_flags(port, &ch, &flag, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027}
28
Jiri Slaby05c7cd32013-01-03 15:53:04 +010029static inline int tty_insert_flip_string(struct tty_port *port,
30 const unsigned char *chars, size_t size)
Alan Cox2832fc12010-02-18 16:43:54 +000031{
Jiri Slaby05c7cd32013-01-03 15:53:04 +010032 return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size);
Alan Cox2832fc12010-02-18 16:43:54 +000033}
34
Peter Hurleya7c8d582013-06-15 09:36:15 -040035extern void tty_buffer_lock_exclusive(struct tty_port *port);
36extern void tty_buffer_unlock_exclusive(struct tty_port *port);
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#endif /* _LINUX_TTY_FLIP_H */