kernels/linux-2.4.0/drivers/sound/waveartist.c
/* Helper function to send and receive words
 * from WaveArtist.  It handles all the handshaking
 * and can send or receive multiple words.
 */
Helper function to send and receive words
from WaveArtist.  It handles all the handshaking
and can send or receive multiple words.
Helper function to send and receive words from WaveArtist . It handles all the handshaking and can send or receive multiple words .
static int
waveartist_cmd(wavnc_info *devc,
		int nr_cmd, unsigned int *cmd,
		int nr_resp, unsigned int *resp)
{
	unsigned int io_base = devc->hw.io_base;
	unsigned int timed_out = 0;
	unsigned int i;
	if (debug_flg & DEBUG_CMD) {
		printk("waveartist_cmd: cmd=");
		for (i = 0; i < nr_cmd; i++)
			printk("%04X ", cmd[i]);
		printk("\n");
	}
	if (inb(io_base + STATR) & CMD_RF) {
		int old_data;
		old_data = inw(io_base + CMDR);
		if (debug_flg & DEBUG_CMD)
			printk("flushed %04X...", old_data);
		udelay(10);
	}
	for (i = 0; !timed_out && i < nr_cmd; i++) {
		int count;
		for (count = 5000; count; count--)
			if (inb(io_base + STATR) & CMD_WE)
				break;
		if (!count)
			timed_out = 1;
		else
			outw(cmd[i], io_base + CMDR);
	}
	for (i = 0; !timed_out && i < nr_resp; i++) {
		int count;
		for (count = 5000; count; count--)
			if (inb(io_base + STATR) & CMD_RF)
				break;
		if (!count)
			timed_out = 1;
		else
			resp[i] = inw(io_base + CMDR);
	}
	if (debug_flg & DEBUG_CMD) {
		if (!timed_out) {
			printk("waveartist_cmd: resp=");
			for (i = 0; i < nr_resp; i++)
				printk("%04X ", resp[i]);
			printk("\n");
		} else
			printk("waveartist_cmd: timed out\n");
	}
	return timed_out ? 1 : 0;
}
static int waveartist_cmd ( wavnc_info * devc , int nr_cmd , unsigned int * cmd , int nr_resp , unsigned int * resp ) { unsigned int io_base = devc -> hw . io_base ; unsigned int timed_out = 0 ; unsigned int i ; if ( debug_flg & DEBUG_CMD ) { printk ( " " ) ; for ( i = 0 ; i < nr_cmd ; i ++ ) printk ( " " , cmd [ i ] ) ; printk ( " \n " ) ; } if ( inb ( io_base + STATR ) & CMD_RF ) { int old_data ; old_data = inw ( io_base + CMDR ) ; if ( debug_flg & DEBUG_CMD ) printk ( " " , old_data ) ; udelay ( 10 ) ; } for ( i = 0 ; ! timed_out && i < nr_cmd ; i ++ ) { int count ; for ( count = 5000 ; count ; count -- ) if ( inb ( io_base + STATR ) & CMD_WE ) break ; if ( ! count ) timed_out = 1 ; else outw ( cmd [ i ] , io_base + CMDR ) ; } for ( i = 0 ; ! timed_out && i < nr_resp ; i ++ ) { int count ; for ( count = 5000 ; count ; count -- ) if ( inb ( io_base + STATR ) & CMD_RF ) break ; if ( ! count ) timed_out = 1 ; else resp [ i ] = inw ( io_base + CMDR ) ; } if ( debug_flg & DEBUG_CMD ) { if ( ! timed_out ) { printk ( " " ) ; for ( i = 0 ; i < nr_resp ; i ++ ) printk ( " " , resp [ i ] ) ; printk ( " \n " ) ; } else printk ( " \n " ) ; } return timed_out ? 1 : 0 ; }
Helper function to send and receive words
 from WaveArtist.
Helper function to send and receive words from WaveArtist .
/* flush the port
		 */