11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _LINUX_TTY_FLIP_H
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _LINUX_TTY_FLIP_H
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
44d18e6eff81e1d4d81d0942d5b7e96904b3b32dfPeter Hurleyextern int tty_buffer_set_limit(struct tty_port *port, int limit);
57bfe0b7116be207cf2204ae06335cc89d8f8ee02Peter Hurleyextern int tty_buffer_space_avail(struct tty_port *port);
6227434f8986c3827a1faedd1feb437acd6285315Jiri Slabyextern int tty_buffer_request_room(struct tty_port *port, size_t size);
72f69335710884ae6112fc8196ebe29b5cda7b79bJiri Slabyextern int tty_insert_flip_string_flags(struct tty_port *port,
82f69335710884ae6112fc8196ebe29b5cda7b79bJiri Slaby		const unsigned char *chars, const char *flags, size_t size);
92f69335710884ae6112fc8196ebe29b5cda7b79bJiri Slabyextern int tty_insert_flip_string_fixed_flag(struct tty_port *port,
102f69335710884ae6112fc8196ebe29b5cda7b79bJiri Slaby		const unsigned char *chars, char flag, size_t size);
112f69335710884ae6112fc8196ebe29b5cda7b79bJiri Slabyextern int tty_prepare_flip_string(struct tty_port *port,
122f69335710884ae6112fc8196ebe29b5cda7b79bJiri Slaby		unsigned char **chars, size_t size);
132e124b4a390ca85325fae75764bef92f0547fa25Jiri Slabyextern void tty_flip_buffer_push(struct tty_port *port);
146732c8bb8671acbdac6cdc93dd72ddd581dd5e25Jiri Slabyvoid tty_schedule_flip(struct tty_port *port);
1533f0f88f1c51ae5c2d593d26960c760ea154c2e2Alan Cox
1692a19f9cec9a80ad93c06e115822deb729e2c6adJiri Slabystatic inline int tty_insert_flip_char(struct tty_port *port,
17e1a2509023785bd3199ac068ab80155aeba01265Andrew Morton					unsigned char ch, char flag)
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
1992a19f9cec9a80ad93c06e115822deb729e2c6adJiri Slaby	struct tty_buffer *tb = port->buf.tail;
20acc0f67f307f52f7aec1cffdc40a786c15dd21d9Peter Hurley	int change;
21acc0f67f307f52f7aec1cffdc40a786c15dd21d9Peter Hurley
22acc0f67f307f52f7aec1cffdc40a786c15dd21d9Peter Hurley	change = (tb->flags & TTYB_NORMAL) && (flag != TTY_NORMAL);
23acc0f67f307f52f7aec1cffdc40a786c15dd21d9Peter Hurley	if (!change && tb->used < tb->size) {
24acc0f67f307f52f7aec1cffdc40a786c15dd21d9Peter Hurley		if (~tb->flags & TTYB_NORMAL)
25acc0f67f307f52f7aec1cffdc40a786c15dd21d9Peter Hurley			*flag_buf_ptr(tb, tb->used) = flag;
261fc359fc3ea72314cc3ebdfa94c60e020c152cd2Peter Hurley		*char_buf_ptr(tb, tb->used++) = ch;
2733f0f88f1c51ae5c2d593d26960c760ea154c2e2Alan Cox		return 1;
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
2992a19f9cec9a80ad93c06e115822deb729e2c6adJiri Slaby	return tty_insert_flip_string_flags(port, &ch, &flag, 1);
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3205c7cd39907184328f48d3e7899f9cdd653ad336Jiri Slabystatic inline int tty_insert_flip_string(struct tty_port *port,
3305c7cd39907184328f48d3e7899f9cdd653ad336Jiri Slaby		const unsigned char *chars, size_t size)
342832fc11f1360668482beec06dbcd631ae5f0cf1Alan Cox{
3505c7cd39907184328f48d3e7899f9cdd653ad336Jiri Slaby	return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size);
362832fc11f1360668482beec06dbcd631ae5f0cf1Alan Cox}
372832fc11f1360668482beec06dbcd631ae5f0cf1Alan Cox
38a7c8d58c79853adeebf0a1ddc9c63e433b4d97f1Peter Hurleyextern void tty_buffer_lock_exclusive(struct tty_port *port);
39a7c8d58c79853adeebf0a1ddc9c63e433b4d97f1Peter Hurleyextern void tty_buffer_unlock_exclusive(struct tty_port *port);
40a7c8d58c79853adeebf0a1ddc9c63e433b4d97f1Peter Hurley
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* _LINUX_TTY_FLIP_H */
42