Lines Matching refs:chip
48 static void snd_pmac_screamer_wait(struct snd_pmac *chip) in snd_pmac_screamer_wait() argument
51 while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) { in snd_pmac_screamer_wait()
64 snd_pmac_awacs_write(struct snd_pmac *chip, int val) in snd_pmac_awacs_write() argument
68 if (chip->model == PMAC_SCREAMER) in snd_pmac_awacs_write()
69 snd_pmac_screamer_wait(chip); in snd_pmac_awacs_write()
70 out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22)); in snd_pmac_awacs_write()
71 while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) { in snd_pmac_awacs_write()
80 snd_pmac_awacs_write_reg(struct snd_pmac *chip, int reg, int val) in snd_pmac_awacs_write_reg() argument
82 snd_pmac_awacs_write(chip, val | (reg << 12)); in snd_pmac_awacs_write_reg()
83 chip->awacs_reg[reg] = val; in snd_pmac_awacs_write_reg()
87 snd_pmac_awacs_write_noreg(struct snd_pmac *chip, int reg, int val) in snd_pmac_awacs_write_noreg() argument
89 snd_pmac_awacs_write(chip, val | (reg << 12)); in snd_pmac_awacs_write_noreg()
94 static void screamer_recalibrate(struct snd_pmac *chip) in screamer_recalibrate() argument
96 if (chip->model != PMAC_SCREAMER) in screamer_recalibrate()
102 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in screamer_recalibrate()
103 if (chip->manufacturer == 0x1) in screamer_recalibrate()
106 snd_pmac_awacs_write_noreg(chip, 1, in screamer_recalibrate()
107 chip->awacs_reg[1] | MASK_RECALIBRATE | in screamer_recalibrate()
109 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in screamer_recalibrate()
110 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in screamer_recalibrate()
114 #define screamer_recalibrate(chip) /* NOP */ argument
121 static void snd_pmac_awacs_set_format(struct snd_pmac *chip) in snd_pmac_awacs_set_format() argument
123 chip->awacs_reg[1] &= ~MASK_SAMPLERATE; in snd_pmac_awacs_set_format()
124 chip->awacs_reg[1] |= chip->rate_index << 3; in snd_pmac_awacs_set_format()
125 snd_pmac_awacs_write_reg(chip, 1, chip->awacs_reg[1]); in snd_pmac_awacs_set_format()
148 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_get_volume() local
155 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_get_volume()
156 vol[0] = (chip->awacs_reg[reg] >> lshift) & 0xf; in snd_pmac_awacs_get_volume()
157 vol[1] = chip->awacs_reg[reg] & 0xf; in snd_pmac_awacs_get_volume()
158 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_get_volume()
171 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_put_volume() local
189 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_put_volume()
190 oldval = chip->awacs_reg[reg]; in snd_pmac_awacs_put_volume()
195 snd_pmac_awacs_write_reg(chip, reg, val); in snd_pmac_awacs_put_volume()
196 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_put_volume()
214 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_get_switch() local
221 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_get_switch()
222 val = (chip->awacs_reg[reg] >> shift) & 1; in snd_pmac_awacs_get_switch()
223 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_get_switch()
233 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_put_switch() local
241 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_put_switch()
242 val = chip->awacs_reg[reg] & ~mask; in snd_pmac_awacs_put_switch()
245 changed = chip->awacs_reg[reg] != val; in snd_pmac_awacs_put_switch()
247 snd_pmac_awacs_write_reg(chip, reg, val); in snd_pmac_awacs_put_switch()
248 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_put_switch()
319 static void awacs_amp_free(struct snd_pmac *chip) in awacs_amp_free() argument
321 struct awacs_amp *amp = chip->mixer_data; in awacs_amp_free()
325 chip->mixer_data = NULL; in awacs_amp_free()
326 chip->mixer_free = NULL; in awacs_amp_free()
346 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_get_volume_amp() local
348 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_volume_amp()
358 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_put_volume_amp() local
361 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_volume_amp()
373 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_get_switch_amp() local
375 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_switch_amp()
387 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_put_switch_amp() local
390 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_switch_amp()
412 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_get_tone_amp() local
414 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_tone_amp()
423 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_put_tone_amp() local
425 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_tone_amp()
452 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_get_master_amp() local
453 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_master_amp()
462 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_awacs_put_master_amp() local
463 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_master_amp()
554 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_screamer_mic_boost_get() local
558 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_get()
559 if (chip->awacs_reg[6] & MASK_MIC_BOOST) in snd_pmac_screamer_mic_boost_get()
561 if (chip->awacs_reg[0] & MASK_GAINLINE) in snd_pmac_screamer_mic_boost_get()
563 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_get()
571 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in snd_pmac_screamer_mic_boost_put() local
576 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_put()
577 val0 = chip->awacs_reg[0] & ~MASK_GAINLINE; in snd_pmac_screamer_mic_boost_put()
578 val6 = chip->awacs_reg[6] & ~MASK_MIC_BOOST; in snd_pmac_screamer_mic_boost_put()
583 if (val0 != chip->awacs_reg[0]) { in snd_pmac_screamer_mic_boost_put()
584 snd_pmac_awacs_write_reg(chip, 0, val0); in snd_pmac_screamer_mic_boost_put()
587 if (val6 != chip->awacs_reg[6]) { in snd_pmac_screamer_mic_boost_put()
588 snd_pmac_awacs_write_reg(chip, 6, val6); in snd_pmac_screamer_mic_boost_put()
591 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_put()
715 static int build_mixers(struct snd_pmac *chip, int nums, in build_mixers() argument
721 err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip)); in build_mixers()
732 static void awacs_restore_all_regs(struct snd_pmac *chip) in awacs_restore_all_regs() argument
734 snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); in awacs_restore_all_regs()
735 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in awacs_restore_all_regs()
736 snd_pmac_awacs_write_noreg(chip, 2, chip->awacs_reg[2]); in awacs_restore_all_regs()
737 snd_pmac_awacs_write_noreg(chip, 4, chip->awacs_reg[4]); in awacs_restore_all_regs()
738 if (chip->model == PMAC_SCREAMER) { in awacs_restore_all_regs()
739 snd_pmac_awacs_write_noreg(chip, 5, chip->awacs_reg[5]); in awacs_restore_all_regs()
740 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in awacs_restore_all_regs()
741 snd_pmac_awacs_write_noreg(chip, 7, chip->awacs_reg[7]); in awacs_restore_all_regs()
746 static void snd_pmac_awacs_suspend(struct snd_pmac *chip) in snd_pmac_awacs_suspend() argument
748 snd_pmac_awacs_write_noreg(chip, 1, (chip->awacs_reg[1] in snd_pmac_awacs_suspend()
752 static void snd_pmac_awacs_resume(struct snd_pmac *chip) in snd_pmac_awacs_resume() argument
757 snd_pmac_awacs_write_reg(chip, 1, in snd_pmac_awacs_resume()
758 chip->awacs_reg[1] & ~MASK_PAROUT); in snd_pmac_awacs_resume()
762 awacs_restore_all_regs(chip); in snd_pmac_awacs_resume()
763 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_resume()
766 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in snd_pmac_awacs_resume()
768 screamer_recalibrate(chip); in snd_pmac_awacs_resume()
770 if (chip->mixer_data) { in snd_pmac_awacs_resume()
771 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_resume()
800 static int snd_pmac_awacs_detect_headphone(struct snd_pmac *chip) in snd_pmac_awacs_detect_headphone() argument
802 return (in_le32(&chip->awacs->codec_stat) & chip->hp_stat_mask) ? 1 : 0; in snd_pmac_awacs_detect_headphone()
819 static void snd_pmac_awacs_update_automute(struct snd_pmac *chip, int do_notify) in snd_pmac_awacs_update_automute() argument
821 if (chip->auto_mute) { in snd_pmac_awacs_update_automute()
823 if (chip->mixer_data) { in snd_pmac_awacs_update_automute()
824 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_update_automute()
826 if (snd_pmac_awacs_detect_headphone(chip)) { in snd_pmac_awacs_update_automute()
838 int reg = chip->awacs_reg[1] in snd_pmac_awacs_update_automute()
847 if (snd_pmac_awacs_detect_headphone(chip)) in snd_pmac_awacs_update_automute()
855 if (do_notify && reg == chip->awacs_reg[1]) in snd_pmac_awacs_update_automute()
857 snd_pmac_awacs_write_reg(chip, 1, reg); in snd_pmac_awacs_update_automute()
860 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
861 &chip->master_sw_ctl->id); in snd_pmac_awacs_update_automute()
862 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
863 &chip->speaker_sw_ctl->id); in snd_pmac_awacs_update_automute()
864 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
865 &chip->hp_detect_ctl->id); in snd_pmac_awacs_update_automute()
876 snd_pmac_awacs_init(struct snd_pmac *chip) in snd_pmac_awacs_init() argument
894 chip->awacs_reg[0] = MASK_MUX_CD | 0xff | MASK_GAINLINE; in snd_pmac_awacs_init()
895 chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE; in snd_pmac_awacs_init()
897 if (chip->has_iic || chip->device_id == 0x5 || in snd_pmac_awacs_init()
899 chip->device_id == 0xb) in snd_pmac_awacs_init()
900 chip->awacs_reg[1] |= MASK_PAROUT; in snd_pmac_awacs_init()
906 chip->awacs_reg[2] = vol; in snd_pmac_awacs_init()
907 chip->awacs_reg[4] = vol; in snd_pmac_awacs_init()
908 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_init()
910 chip->awacs_reg[5] = vol; in snd_pmac_awacs_init()
912 chip->awacs_reg[6] = MASK_MIC_BOOST; in snd_pmac_awacs_init()
913 chip->awacs_reg[7] = 0; in snd_pmac_awacs_init()
916 awacs_restore_all_regs(chip); in snd_pmac_awacs_init()
917 chip->manufacturer = (in_le32(&chip->awacs->codec_stat) >> 8) & 0xf; in snd_pmac_awacs_init()
918 screamer_recalibrate(chip); in snd_pmac_awacs_init()
920 chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; in snd_pmac_awacs_init()
922 if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { in snd_pmac_awacs_init()
926 chip->mixer_data = amp; in snd_pmac_awacs_init()
927 chip->mixer_free = awacs_amp_free; in snd_pmac_awacs_init()
936 if (chip->hp_stat_mask == 0) { in snd_pmac_awacs_init()
938 switch (chip->model) { in snd_pmac_awacs_init()
940 chip->hp_stat_mask = pm7500 || pm5500 ? MASK_HDPCONN in snd_pmac_awacs_init()
944 switch (chip->device_id) { in snd_pmac_awacs_init()
947 chip->hp_stat_mask = imac in snd_pmac_awacs_init()
955 chip->hp_stat_mask = MASK_LOCONN; in snd_pmac_awacs_init()
958 chip->hp_stat_mask = MASK_HDPCONN; in snd_pmac_awacs_init()
971 strcpy(chip->card->mixername, "PowerMac AWACS"); in snd_pmac_awacs_init()
973 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers), in snd_pmac_awacs_init()
979 else if (chip->model == PMAC_SCREAMER || pm5500) in snd_pmac_awacs_init()
980 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2), in snd_pmac_awacs_init()
983 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers2), in snd_pmac_awacs_init()
988 err = build_mixers(chip, in snd_pmac_awacs_init()
995 err = build_mixers(chip, in snd_pmac_awacs_init()
999 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
1001 chip))); in snd_pmac_awacs_init()
1003 err = build_mixers(chip, in snd_pmac_awacs_init()
1007 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
1009 chip))); in snd_pmac_awacs_init()
1012 err = build_mixers(chip, in snd_pmac_awacs_init()
1016 err = build_mixers(chip, in snd_pmac_awacs_init()
1020 err = build_mixers(chip, in snd_pmac_awacs_init()
1025 chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp || lombard) in snd_pmac_awacs_init()
1029 : &snd_pmac_awacs_master_sw, chip); in snd_pmac_awacs_init()
1030 err = snd_ctl_add(chip->card, chip->master_sw_ctl); in snd_pmac_awacs_init()
1034 if (chip->mixer_data) { in snd_pmac_awacs_init()
1041 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_amp_vol), in snd_pmac_awacs_init()
1046 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw, in snd_pmac_awacs_init()
1047 chip); in snd_pmac_awacs_init()
1048 err = snd_ctl_add(chip->card, chip->master_sw_ctl); in snd_pmac_awacs_init()
1051 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw, in snd_pmac_awacs_init()
1052 chip); in snd_pmac_awacs_init()
1053 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1060 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
1062 chip))); in snd_pmac_awacs_init()
1065 chip->speaker_sw_ctl = snd_ctl_new1(imac1 in snd_pmac_awacs_init()
1069 : &snd_pmac_awacs_speaker_sw, chip); in snd_pmac_awacs_init()
1070 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1079 chip->master_sw_ctl); in snd_pmac_awacs_init()
1083 chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1086 err = snd_ctl_add(chip->card, vmaster_sw); in snd_pmac_awacs_init()
1097 err = snd_ctl_add(chip->card, vmaster_vol); in snd_pmac_awacs_init()
1103 err = build_mixers(chip, in snd_pmac_awacs_init()
1107 err = build_mixers(chip, in snd_pmac_awacs_init()
1110 else if (chip->model == PMAC_SCREAMER) in snd_pmac_awacs_init()
1111 err = build_mixers(chip, in snd_pmac_awacs_init()
1115 err = build_mixers(chip, in snd_pmac_awacs_init()
1119 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mic_boost), in snd_pmac_awacs_init()
1127 chip->set_format = snd_pmac_awacs_set_format; in snd_pmac_awacs_init()
1129 chip->suspend = snd_pmac_awacs_suspend; in snd_pmac_awacs_init()
1130 chip->resume = snd_pmac_awacs_resume; in snd_pmac_awacs_init()
1133 err = snd_pmac_add_automute(chip); in snd_pmac_awacs_init()
1136 chip->detect_headphone = snd_pmac_awacs_detect_headphone; in snd_pmac_awacs_init()
1137 chip->update_automute = snd_pmac_awacs_update_automute; in snd_pmac_awacs_init()
1138 snd_pmac_awacs_update_automute(chip, 0); /* update the status only */ in snd_pmac_awacs_init()
1140 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_init()
1141 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in snd_pmac_awacs_init()
1142 snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); in snd_pmac_awacs_init()