1 #include <linux/console.h>
2 #include <linux/smp_lock.h>
3 #include <linux/types.h>
4 #include <linux/wait.h>
9 #define synthBufferSize 8192 /* currently 8K bytes */
11 static u_char synth_buffer
[synthBufferSize
]; /* guess what this is for! */
12 static u_char
*buff_in
= synth_buffer
;
13 static u_char
*buff_out
= synth_buffer
;
14 static u_char
*buffer_end
= synth_buffer
+synthBufferSize
-1;
16 /* These try to throttle applications by stopping the TTYs
17 * Note: we need to make sure that we will restart them eventually, which is
18 * usually not possible to do from the notifiers. TODO: it should be possible
19 * starting from linux 2.6.26.
21 * So we only stop when we know alive == 1 (else we discard the data anyway),
22 * and the alive synth will eventually call start_ttys from the thread context.
24 void speakup_start_ttys(void)
28 for (i
= 0; i
< MAX_NR_CONSOLES
; i
++) {
29 if (speakup_console
[i
] && speakup_console
[i
]->tty_stopped
)
31 if ((vc_cons
[i
].d
!= NULL
) && (vc_cons
[i
].d
->vc_tty
!= NULL
))
32 start_tty(vc_cons
[i
].d
->vc_tty
);
35 EXPORT_SYMBOL_GPL(speakup_start_ttys
);
37 static void speakup_stop_ttys(void)
41 for (i
= 0; i
< MAX_NR_CONSOLES
; i
++)
42 if ((vc_cons
[i
].d
!= NULL
) && (vc_cons
[i
].d
->vc_tty
!= NULL
))
43 stop_tty(vc_cons
[i
].d
->vc_tty
);
47 static int synth_buffer_free(void)
51 if (buff_in
>= buff_out
)
52 bytesFree
= synthBufferSize
- (buff_in
- buff_out
);
54 bytesFree
= buff_out
- buff_in
;
58 int synth_buffer_empty(void)
60 return (buff_in
== buff_out
);
62 EXPORT_SYMBOL_GPL(synth_buffer_empty
);
64 void synth_buffer_add(char ch
)
67 /* This makes sure that we won't stop TTYs if there is no synth
71 if (synth_buffer_free() <= 100) {
75 if (synth_buffer_free() <= 1)
78 if (buff_in
> buffer_end
)
79 buff_in
= synth_buffer
;
82 char synth_buffer_getc(void)
86 if (buff_out
== buff_in
)
89 if (buff_out
> buffer_end
)
90 buff_out
= synth_buffer
;
93 EXPORT_SYMBOL_GPL(synth_buffer_getc
);
95 char synth_buffer_peek(void)
97 if (buff_out
== buff_in
)
101 EXPORT_SYMBOL_GPL(synth_buffer_peek
);
103 void synth_buffer_clear(void)
105 buff_in
= buff_out
= synth_buffer
;
108 EXPORT_SYMBOL_GPL(synth_buffer_clear
);
This page took 0.039364 seconds and 5 git commands to generate.