#ifdef CONFIG_PMAC_PBOOK 
#ifdef CONFIG_PM 
snd_pmac_awacs_init(pmac_t *chip){	int err, vol;	/* looks like MASK_GAINLINE triggers something, so we set here	 * as start-up	 */	chip->awacs_reg[0] = MASK_MUX_CD | 0xff | MASK_GAINLINE;	chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE;	/* FIXME: Only machines with external SRS module need MASK_PAROUT */	if (chip->has_iic || chip->device_id == 0x5 ||	    /*chip->_device_id == 0x8 || */	    chip->device_id == 0xb)		chip->awacs_reg[1] |= MASK_PAROUT;	/* get default volume from nvram */	// vol = (~nvram_read_byte(0x1308) & 7) << 1;	// vol = ((pmac_xpram_read( 8 ) & 7 ) << 1 );	vol = 0x0f; /* no, on alsa, muted as default */	vol = vol + (vol << 6);	chip->awacs_reg[2] = vol;	chip->awacs_reg[4] = vol;	if (chip->model == PMAC_SCREAMER) {		chip->awacs_reg[5] = vol; /* FIXME: screamer has loopthru vol control */		chip->awacs_reg[6] = MASK_MIC_BOOST; /* FIXME: maybe should be vol << 3 for PCMCIA speaker */		chip->awacs_reg[7] = 0;	}	awacs_restore_all_regs(chip);	chip->manufacturer = (in_le32(&chip->awacs->codec_stat) >> 8) & 0xf;	screamer_recalibrate(chip);	chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf;#ifdef PMAC_AMP_AVAIL	if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) {		awacs_amp_t *amp = kmalloc(sizeof(*amp), GFP_KERNEL);		if (! amp)			return -ENOMEM;		chip->mixer_data = amp;		memset(amp, 0, sizeof(*amp));		chip->mixer_free = awacs_amp_free;		awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */		awacs_amp_set_vol(amp, 1, 63, 63, 0);		awacs_amp_set_tone(amp, 7, 7); /* 0 dB */		awacs_amp_set_master(amp, 79); /* 0 dB */	}#endif /* PMAC_AMP_AVAIL */	if (chip->hp_stat_mask == 0) {		/* set headphone-jack detection bit */		switch (chip->model) {		case PMAC_AWACS:			chip->hp_stat_mask = 0x04;			break;		case PMAC_SCREAMER:			switch (chip->device_id) {			case 0x08:				/* 1 = side jack, 2 = front jack */				chip->hp_stat_mask = 0x03;				break;			case 0x00:			case 0x05:				chip->hp_stat_mask = 0x04;				break;			default:				chip->hp_stat_mask = 0x08;				break;			}			break;		default:			snd_BUG();			break;		}	}	/*	 * build mixers	 */	strcpy(chip->card->mixername, "PowerMac AWACS");	if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers),				snd_pmac_awacs_mixers)) < 0)		return err;	if (chip->model == PMAC_SCREAMER)		err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2),				   snd_pmac_screamer_mixers2);	else		err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers2),				   snd_pmac_awacs_mixers2);	if (err < 0)		return err;	chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_master_sw, chip);	if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0)		return err;#ifdef PMAC_AMP_AVAIL	if (chip->mixer_data) {		/* use amplifier.  the signal is connected from route A		 * to the amp.  the amp has its headphone and speaker		 * volumes and mute switches, so we use them instead of		 * screamer registers.		 * in this case, it seems the route C is not used.		 */		if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_amp_vol),					snd_pmac_awacs_amp_vol)) < 0)			return err;		/* overwrite */		chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw, chip);		if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0)			return err;		chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw, chip);		if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0)			return err;	} else#endif /* PMAC_AMP_AVAIL */	{		/* route A = headphone, route C = speaker */		if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_speaker_vol),					snd_pmac_awacs_speaker_vol)) < 0)			return err;		chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_speaker_sw, chip);		if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0)			return err;	}	if (chip->model == PMAC_SCREAMER) {		if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mic_boost),					snd_pmac_screamer_mic_boost)) < 0)			return err;	} else {		if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mic_boost),					snd_pmac_awacs_mic_boost)) < 0)			return err;	}	/*	 * set lowlevel callbacks	 */	chip->set_format = snd_pmac_awacs_set_format;#ifdef CONFIG_PMAC_PBOOK	chip->suspend = snd_pmac_awacs_suspend;	chip->resume = snd_pmac_awacs_resume;#endif#ifdef PMAC_SUPPORT_AUTOMUTE	if ((err = snd_pmac_add_automute(chip)) < 0)		return err;	chip->detect_headphone = snd_pmac_awacs_detect_headphone;	chip->update_automute = snd_pmac_awacs_update_automute;	snd_pmac_awacs_update_automute(chip, 0); /* update the status only */#endif	if (chip->model == PMAC_SCREAMER) {		snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]);		snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]);	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/8c8709334cec803368a432a33e0f2e116d48fe07/awacs.c/buggy/sound/ppc/awacs.c