Enscript Output

extractedLnx/linux-2.6.9/sound/isa/wavefront/wavefront_fx.c_snd_wavefront_fx_start.c

int __init
snd_wavefront_fx_start (snd_wavefront_t *dev)

{
	unsigned int i, j;

	/* Set all bits for all channels on the MOD unit to zero */
	/* XXX But why do this twice ? */

	for (j = 0; j < 2; j++) {
		for (i = 0x10; i <= 0xff; i++) {
	    
			if (!wavefront_fx_idle (dev)) {
				return (-1);
			}
	    
			outb (i, dev->fx_mod_addr);
			outb (0x0, dev->fx_mod_data);
		}
	}

	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x02, dev->fx_op);                        /* mute on */

	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x44, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x42, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x43, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x7c, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x7e, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x46, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x49, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x47, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x4a, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);

	/* either because of stupidity by TB's programmers, or because it
	   actually does something, rezero the MOD page.
	*/
	for (i = 0x10; i <= 0xff; i++) {
	
		if (!wavefront_fx_idle (dev)) {
			return (-1);
		}
	
		outb (i, dev->fx_mod_addr);
		outb (0x0, dev->fx_mod_data);
	}
	/* load page zero */

	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x00, dev->fx_dsp_page);
	outb (0x00, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_zero); i += 2) {
		outb (page_zero[i], dev->fx_dsp_msb);
		outb (page_zero[i+1], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	/* Now load page one */

	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x01, dev->fx_dsp_page);
	outb (0x00, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_one); i += 2) {
		outb (page_one[i], dev->fx_dsp_msb);
		outb (page_one[i+1], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x02, dev->fx_dsp_page);
	outb (0x00, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_two); i++) {
		outb (page_two[i], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x03, dev->fx_dsp_page);
	outb (0x00, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_three); i++) {
		outb (page_three[i], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x04, dev->fx_dsp_page);
	outb (0x00, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_four); i++) {
		outb (page_four[i], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	/* Load memory area (page six) */
    
	outb (FX_LSB_TRANSFER, dev->fx_lcr); 
	outb (0x06, dev->fx_dsp_page); 

	for (i = 0; i < sizeof (page_six); i += 3) {
		outb (page_six[i], dev->fx_dsp_addr);
		outb (page_six[i+1], dev->fx_dsp_msb);
		outb (page_six[i+2], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x07, dev->fx_dsp_page);
	outb (0x00, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_seven); i += 2) {
		outb (page_seven[i], dev->fx_dsp_msb);
		outb (page_seven[i+1], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	/* Now setup the MOD area. We do this algorithmically in order to
	   save a little data space. It could be done in the same fashion
	   as the "pages".
	*/

	for (i = 0x00; i <= 0x0f; i++) {
		outb (0x01, dev->fx_mod_addr);
		outb (i, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
		outb (0x02, dev->fx_mod_addr);
		outb (0x00, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0xb0; i <= 0xbf; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x20, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0xf0; i <= 0xff; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x20, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0x10; i <= 0x1d; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0xff, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (0x1e, dev->fx_mod_addr);
	outb (0x40, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	for (i = 0x1f; i <= 0x2d; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0xff, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (0x2e, dev->fx_mod_addr);
	outb (0x00, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	for (i = 0x2f; i <= 0x3e; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x00, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (0x3f, dev->fx_mod_addr);
	outb (0x20, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	for (i = 0x40; i <= 0x4d; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x00, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (0x4e, dev->fx_mod_addr);
	outb (0x0e, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x4f, dev->fx_mod_addr);
	outb (0x0e, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);


	for (i = 0x50; i <= 0x6b; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x00, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (0x6c, dev->fx_mod_addr);
	outb (0x40, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	outb (0x6d, dev->fx_mod_addr);
	outb (0x00, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	outb (0x6e, dev->fx_mod_addr);
	outb (0x40, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	outb (0x6f, dev->fx_mod_addr);
	outb (0x40, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	for (i = 0x70; i <= 0x7f; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0xc0, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	for (i = 0x80; i <= 0xaf; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x00, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0xc0; i <= 0xdd; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x00, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (0xde, dev->fx_mod_addr);
	outb (0x10, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0xdf, dev->fx_mod_addr);
	outb (0x10, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);

	for (i = 0xe0; i <= 0xef; i++) {
		outb (i, dev->fx_mod_addr);
		outb (0x00, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0x00; i <= 0x0f; i++) {
		outb (0x01, dev->fx_mod_addr);
		outb (i, dev->fx_mod_data);
		outb (0x02, dev->fx_mod_addr);
		outb (0x01, dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (0x02, dev->fx_op); /* mute on */

	/* Now set the coefficients and so forth for the programs above */

	for (i = 0; i < sizeof (coefficients); i += 4) {
		outb (coefficients[i], dev->fx_dsp_page);
		outb (coefficients[i+1], dev->fx_dsp_addr);
		outb (coefficients[i+2], dev->fx_dsp_msb);
		outb (coefficients[i+3], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	/* Some settings (?) that are too small to bundle into loops */

	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x1e, dev->fx_mod_addr);
	outb (0x14, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0xde, dev->fx_mod_addr);
	outb (0x20, dev->fx_mod_data);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0xdf, dev->fx_mod_addr);
	outb (0x20, dev->fx_mod_data);
    
	/* some more coefficients */

	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x06, dev->fx_dsp_page);
	outb (0x78, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x40, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x03, dev->fx_dsp_addr);
	outb (0x0f, dev->fx_dsp_msb);
	outb (0xff, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x0b, dev->fx_dsp_addr);
	outb (0x0f, dev->fx_dsp_msb);
	outb (0xff, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x02, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x0a, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x46, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
	if (!wavefront_fx_idle (dev)) return (-1);
	outb (0x07, dev->fx_dsp_page);
	outb (0x49, dev->fx_dsp_addr);
	outb (0x00, dev->fx_dsp_msb);
	outb (0x00, dev->fx_dsp_lsb);
    
	/* Now, for some strange reason, lets reload every page
	   and all the coefficients over again. I have *NO* idea
	   why this is done. I do know that no sound is produced
	   is this phase is omitted.
	*/

	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x00, dev->fx_dsp_page);  
	outb (0x10, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_zero_v2); i += 2) {
		outb (page_zero_v2[i], dev->fx_dsp_msb);
		outb (page_zero_v2[i+1], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x01, dev->fx_dsp_page);
	outb (0x10, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_one_v2); i += 2) {
		outb (page_one_v2[i], dev->fx_dsp_msb);
		outb (page_one_v2[i+1], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	if (!wavefront_fx_idle (dev)) return (-1);
	if (!wavefront_fx_idle (dev)) return (-1);
    
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x02, dev->fx_dsp_page);
	outb (0x10, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_two_v2); i++) {
		outb (page_two_v2[i], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x03, dev->fx_dsp_page);
	outb (0x10, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_three_v2); i++) {
		outb (page_three_v2[i], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x04, dev->fx_dsp_page);
	outb (0x10, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_four_v2); i++) {
		outb (page_four_v2[i], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}
    
	outb (FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x06, dev->fx_dsp_page);

	/* Page six v.2 is algorithmic */
    
	for (i = 0x10; i <= 0x3e; i += 2) {
		outb (i, dev->fx_dsp_addr);
		outb (0x00, dev->fx_dsp_msb);
		outb (0x00, dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
	outb (0x07, dev->fx_dsp_page);
	outb (0x10, dev->fx_dsp_addr);

	for (i = 0; i < sizeof (page_seven_v2); i += 2) {
		outb (page_seven_v2[i], dev->fx_dsp_msb);
		outb (page_seven_v2[i+1], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0x00; i < sizeof(mod_v2); i += 2) {
		outb (mod_v2[i], dev->fx_mod_addr);
		outb (mod_v2[i+1], dev->fx_mod_data);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0; i < sizeof (coefficients2); i += 4) {
		outb (coefficients2[i], dev->fx_dsp_page);
		outb (coefficients2[i+1], dev->fx_dsp_addr);
		outb (coefficients2[i+2], dev->fx_dsp_msb);
		outb (coefficients2[i+3], dev->fx_dsp_lsb);
		if (!wavefront_fx_idle (dev)) return (-1);
	}

	for (i = 0; i < sizeof (coefficients3); i += 2) {
		int x;

		outb (0x07, dev->fx_dsp_page);
		x = (i % 4) ? 0x4e : 0x4c;
		outb (x, dev->fx_dsp_addr);
		outb (coefficients3[i], dev->fx_dsp_msb);
		outb (coefficients3[i+1], dev->fx_dsp_lsb);
	}

	outb (0x00, dev->fx_op); /* mute off */
	if (!wavefront_fx_idle (dev)) return (-1);

	return (0);
}

Generated by GNU enscript 1.6.4.