pbus->no_vra = 1; /* we don't need VRA */  memset(&ac97, 0, sizeof(ac97)); ac97.private_data = emu; ac97.private_free = snd_emu10k1_mixer_free_ac97; ac97.scaps = AC97_SCAP_NO_SPDIF; if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) return err; 
int __devinit snd_emu10k1_mixer(emu10k1_t *emu,				int pcm_device, int multi_device){	int err, pcm;	snd_kcontrol_t *kctl;	snd_card_t *card = emu->card;	char **c;	static char *emu10k1_remove_ctls[] = {		/* no AC97 mono, surround, center/lfe */		"Master Mono Playback Switch",		"Master Mono Playback Volume",		"PCM Out Path & Mute",		"Mono Output Select",		"Surround Playback Switch",		"Surround Playback Volume",		"Center Playback Switch",		"Center Playback Volume",		"LFE Playback Switch",		"LFE Playback Volume",		NULL	};	static char *emu10k1_rename_ctls[] = {		"Surround Digital Playback Volume", "Surround Playback Volume",		"Center Digital Playback Volume", "Center Playback Volume",		"LFE Digital Playback Volume", "LFE Playback Volume",		NULL	};	static char *audigy_remove_ctls[] = {		/* Master/PCM controls on ac97 of Audigy has no effect */		"PCM Playback Switch",		"PCM Playback Volume",		"Master Mono Playback Switch",		"Master Mono Playback Volume",		"Master Playback Switch",		"Master Playback Volume",		"PCM Out Path & Mute",		"Mono Output Select",		/* remove unused AC97 capture controls */		"Capture Source",		"Capture Switch",		"Capture Volume",		"Mic Select",		"Video Playback Switch",		"Video Playback Volume",		"Mic Playback Switch",		"Mic Playback Volume",		NULL	};	static char *audigy_rename_ctls[] = {		/* use conventional names */		"Wave Playback Volume", "PCM Playback Volume",		/* "Wave Capture Volume", "PCM Capture Volume", */		"Wave Master Playback Volume", "Master Playback Volume",		"AMic Playback Volume", "Mic Playback Volume",		NULL	};	if (emu->card_capabilities->ac97_chip) {		ac97_bus_t *pbus;		ac97_template_t ac97;		static ac97_bus_ops_t ops = {			.write = snd_emu10k1_ac97_write,			.read = snd_emu10k1_ac97_read,		};		if ((err = snd_ac97_bus(emu->card, 0, &ops, NULL, &pbus)) < 0) {			if (emu->card_capabilities->ac97_chip == 1)				return err;			snd_printd(KERN_INFO "emu10k1: AC97 is optional on this board\n");			snd_printd(KERN_INFO"          Proceeding without ac97 mixers...\n");			goto no_ac97; /* FIXME: get rid of ugly gotos.. */		}		pbus->no_vra = 1; /* we don't need VRA */				memset(&ac97, 0, sizeof(ac97));		ac97.private_data = emu;		ac97.private_free = snd_emu10k1_mixer_free_ac97;		ac97.scaps = AC97_SCAP_NO_SPDIF;		if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0)			return err;		if (emu->audigy) {			/* set master volume to 0 dB */			snd_ac97_write(emu->ac97, AC97_MASTER, 0x0000);			/* set capture source to mic */			snd_ac97_write(emu->ac97, AC97_REC_SEL, 0x0000);			c = audigy_remove_ctls;		} else {			/*			 * Credits for cards based on STAC9758:			 *   James Courtier-Dutton <James@superbug.demon.co.uk>			 *   Voluspa <voluspa@comhem.se>			 */			if (emu->ac97->id == AC97_ID_STAC9758) {				emu->rear_ac97 = 1;				snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE|AC97SLOT_REAR_LEFT|AC97SLOT_REAR_RIGHT);			}			/* remove unused AC97 controls */			snd_ac97_write(emu->ac97, AC97_SURROUND_MASTER, 0x0202);			snd_ac97_write(emu->ac97, AC97_CENTER_LFE_MASTER, 0x0202);			c = emu10k1_remove_ctls;		}		for (; *c; c++)			remove_ctl(card, *c);	} else {	no_ac97:		if (emu->card_capabilities->ecard)			strcpy(emu->card->mixername, "EMU APS");		else if (emu->audigy)			strcpy(emu->card->mixername, "SB Audigy");		else			strcpy(emu->card->mixername, "Emu10k1");	}	if (emu->audigy)		c = audigy_rename_ctls;	else		c = emu10k1_rename_ctls;	for (; *c; c += 2)		rename_ctl(card, c[0], c[1]);	if ((kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL)		return -ENOMEM;	kctl->id.device = pcm_device;	if ((err = snd_ctl_add(card, kctl)))		return err;	if ((kctl = emu->ctl_send_volume = snd_ctl_new1(&snd_emu10k1_send_volume_control, emu)) == NULL)		return -ENOMEM;	kctl->id.device = pcm_device;	if ((err = snd_ctl_add(card, kctl)))		return err;	if ((kctl = emu->ctl_attn = snd_ctl_new1(&snd_emu10k1_attn_control, emu)) == NULL)		return -ENOMEM;	kctl->id.device = pcm_device;	if ((err = snd_ctl_add(card, kctl)))		return err;	if ((kctl = emu->ctl_efx_send_routing = snd_ctl_new1(&snd_emu10k1_efx_send_routing_control, emu)) == NULL)		return -ENOMEM;	kctl->id.device = multi_device;	if ((err = snd_ctl_add(card, kctl)))		return err;		if ((kctl = emu->ctl_efx_send_volume = snd_ctl_new1(&snd_emu10k1_efx_send_volume_control, emu)) == NULL)		return -ENOMEM;	kctl->id.device = multi_device;	if ((err = snd_ctl_add(card, kctl)))		return err;		if ((kctl = emu->ctl_efx_attn = snd_ctl_new1(&snd_emu10k1_efx_attn_control, emu)) == NULL)		return -ENOMEM;	kctl->id.device = multi_device;	if ((err = snd_ctl_add(card, kctl)))		return err;	/* initialize the routing and volume table for each pcm playback stream */	for (pcm = 0; pcm < 32; pcm++) {		emu10k1_pcm_mixer_t *mix;		int v;				mix = &emu->pcm_mixer[pcm];		mix->epcm = NULL;		for (v = 0; v < 4; v++)			mix->send_routing[0][v] = 				mix->send_routing[1][v] = 				mix->send_routing[2][v] = v;				memset(&mix->send_volume, 0, sizeof(mix->send_volume));		mix->send_volume[0][0] = mix->send_volume[0][1] =		mix->send_volume[1][0] = mix->send_volume[2][1] = 255;				mix->attn[0] = mix->attn[1] = mix->attn[2] = 0xffff;	}		/* initialize the routing and volume table for the multichannel playback stream */	for (pcm = 0; pcm < NUM_EFX_PLAYBACK; pcm++) {		emu10k1_pcm_mixer_t *mix;		int v;				mix = &emu->efx_pcm_mixer[pcm];		mix->epcm = NULL;		mix->send_routing[0][0] = pcm;		mix->send_routing[0][1] = (pcm == 0) ? 1 : 0;		for (v = 0; v < 2; v++)			mix->send_routing[0][2+v] = 13+v;		if (emu->audigy)			for (v = 0; v < 4; v++)				mix->send_routing[0][4+v] = 60+v;				memset(&mix->send_volume, 0, sizeof(mix->send_volume));		mix->send_volume[0][0]  = 255;				mix->attn[0] = 0xffff;	}		if (! emu->card_capabilities->ecard) { /* FIXME: APS has these controls? */		/* sb live! and audigy */		if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL)			return -ENOMEM;		if (!emu->audigy)			kctl->id.device = emu->pcm_efx->device;		if ((err = snd_ctl_add(card, kctl)))			return err;		if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu)) == NULL)			return -ENOMEM;		if (!emu->audigy)			kctl->id.device = emu->pcm_efx->device;		if ((err = snd_ctl_add(card, kctl)))			return err;	}	if (emu->audigy) {		if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL)			return -ENOMEM;		if ((err = snd_ctl_add(card, kctl)))			return err;#if 0		if ((kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu)) == NULL)			return -ENOMEM;		if ((err = snd_ctl_add(card, kctl)))			return err;#endif	} else if (! emu->card_capabilities->ecard) {		/* sb live! */		if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL)			return -ENOMEM;		if ((err = snd_ctl_add(card, kctl)))			return err;	}	if (emu->card_capabilities->ca0151_chip) { /* P16V */		if ((err = snd_p16v_mixer(emu)))			return err;	}			return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b150869369adafb7cc0cf65ea500f9f3c4bbf857/emumixer.c/buggy/sound/pci/emu10k1/emumixer.c