serial-u16550.c (1da177e4c3f41524e886b7f1b8a0c1fc7321cac2) serial-u16550.c (77933d7276ee8fa0e2947641941a6f7a100a327b)
1/*
2 * serial.c
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>,
4 * Isaku Yamahata <yamahata@private.email.ne.jp>,
5 * George Hansper <ghansper@apana.org.au>,
6 * Hannu Savolainen
7 *
8 * This code is based on the code from ALSA 0.5.9, but heavily rewritten.

--- 154 unchanged lines hidden (view full) ---

163 // wait timer
164 unsigned int timer_running:1;
165 struct timer_list buffer_timer;
166
167} snd_uart16550_t;
168
169static snd_card_t *snd_serial_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
170
1/*
2 * serial.c
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>,
4 * Isaku Yamahata <yamahata@private.email.ne.jp>,
5 * George Hansper <ghansper@apana.org.au>,
6 * Hannu Savolainen
7 *
8 * This code is based on the code from ALSA 0.5.9, but heavily rewritten.

--- 154 unchanged lines hidden (view full) ---

163 // wait timer
164 unsigned int timer_running:1;
165 struct timer_list buffer_timer;
166
167} snd_uart16550_t;
168
169static snd_card_t *snd_serial_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
170
171inline static void snd_uart16550_add_timer(snd_uart16550_t *uart)
171static inline void snd_uart16550_add_timer(snd_uart16550_t *uart)
172{
173 if (! uart->timer_running) {
174 /* timer 38600bps * 10bit * 16byte */
175 uart->buffer_timer.expires = jiffies + (HZ+255)/256;
176 uart->timer_running = 1;
177 add_timer(&uart->buffer_timer);
178 }
179}
180
172{
173 if (! uart->timer_running) {
174 /* timer 38600bps * 10bit * 16byte */
175 uart->buffer_timer.expires = jiffies + (HZ+255)/256;
176 uart->timer_running = 1;
177 add_timer(&uart->buffer_timer);
178 }
179}
180
181inline static void snd_uart16550_del_timer(snd_uart16550_t *uart)
181static inline void snd_uart16550_del_timer(snd_uart16550_t *uart)
182{
183 if (uart->timer_running) {
184 del_timer(&uart->buffer_timer);
185 uart->timer_running = 0;
186 }
187}
188
189/* This macro is only used in snd_uart16550_io_loop */
182{
183 if (uart->timer_running) {
184 del_timer(&uart->buffer_timer);
185 uart->timer_running = 0;
186 }
187}
188
189/* This macro is only used in snd_uart16550_io_loop */
190inline static void snd_uart16550_buffer_output(snd_uart16550_t *uart)
190static inline void snd_uart16550_buffer_output(snd_uart16550_t *uart)
191{
192 unsigned short buff_out = uart->buff_out;
193 if( uart->buff_in_count > 0 ) {
194 outb(uart->tx_buff[buff_out], uart->base + UART_TX);
195 uart->fifo_count++;
196 buff_out++;
197 buff_out &= TX_BUFF_MASK;
198 uart->buff_out = buff_out;

--- 375 unchanged lines hidden (view full) ---

574 uart->filemode &= ~SERIAL_MODE_OUTPUT_OPEN;
575 uart->midi_output[substream->number] = NULL;
576 if (uart->filemode == SERIAL_MODE_NOT_OPENED)
577 snd_uart16550_do_close(uart);
578 spin_unlock_irqrestore(&uart->open_lock, flags);
579 return 0;
580};
581
191{
192 unsigned short buff_out = uart->buff_out;
193 if( uart->buff_in_count > 0 ) {
194 outb(uart->tx_buff[buff_out], uart->base + UART_TX);
195 uart->fifo_count++;
196 buff_out++;
197 buff_out &= TX_BUFF_MASK;
198 uart->buff_out = buff_out;

--- 375 unchanged lines hidden (view full) ---

574 uart->filemode &= ~SERIAL_MODE_OUTPUT_OPEN;
575 uart->midi_output[substream->number] = NULL;
576 if (uart->filemode == SERIAL_MODE_NOT_OPENED)
577 snd_uart16550_do_close(uart);
578 spin_unlock_irqrestore(&uart->open_lock, flags);
579 return 0;
580};
581
582inline static int snd_uart16550_buffer_can_write( snd_uart16550_t *uart, int Num )
582static inline int snd_uart16550_buffer_can_write( snd_uart16550_t *uart, int Num )
583{
584 if( uart->buff_in_count + Num < TX_BUFF_SIZE )
585 return 1;
586 else
587 return 0;
588}
589
583{
584 if( uart->buff_in_count + Num < TX_BUFF_SIZE )
585 return 1;
586 else
587 return 0;
588}
589
590inline static int snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned char byte)
590static inline int snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned char byte)
591{
592 unsigned short buff_in = uart->buff_in;
593 if( uart->buff_in_count < TX_BUFF_SIZE ) {
594 uart->tx_buff[buff_in] = byte;
595 buff_in++;
596 buff_in &= TX_BUFF_MASK;
597 uart->buff_in = buff_in;
598 uart->buff_in_count++;

--- 392 unchanged lines hidden ---
591{
592 unsigned short buff_in = uart->buff_in;
593 if( uart->buff_in_count < TX_BUFF_SIZE ) {
594 uart->tx_buff[buff_in] = byte;
595 buff_in++;
596 buff_in &= TX_BUFF_MASK;
597 uart->buff_in = buff_in;
598 uart->buff_in_count++;

--- 392 unchanged lines hidden ---