Lines Matching +full:cd +full:- +full:inverted

1 // SPDX-License-Identifier: GPL-2.0-or-later
38 while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) { in snd_pmac_screamer_wait()
40 if (! --timeout) { in snd_pmac_screamer_wait()
55 if (chip->model == PMAC_SCREAMER) in snd_pmac_awacs_write()
57 out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22)); in snd_pmac_awacs_write()
58 while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) { in snd_pmac_awacs_write()
59 if (! --timeout) { in snd_pmac_awacs_write()
70 chip->awacs_reg[reg] = val; in snd_pmac_awacs_write_reg()
83 if (chip->model != PMAC_SCREAMER) in screamer_recalibrate()
89 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in screamer_recalibrate()
90 if (chip->manufacturer == 0x1) in screamer_recalibrate()
94 chip->awacs_reg[1] | MASK_RECALIBRATE | in screamer_recalibrate()
96 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in screamer_recalibrate()
97 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in screamer_recalibrate()
110 chip->awacs_reg[1] &= ~MASK_SAMPLERATE; in snd_pmac_awacs_set_format()
111 chip->awacs_reg[1] |= chip->rate_index << 3; in snd_pmac_awacs_set_format()
112 snd_pmac_awacs_write_reg(chip, 1, chip->awacs_reg[1]); in snd_pmac_awacs_set_format()
120 * volumes: 0-15 stereo
125 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_volume()
126 uinfo->count = 2; in snd_pmac_awacs_info_volume()
127 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_volume()
128 uinfo->value.integer.max = 15; in snd_pmac_awacs_info_volume()
136 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_get_volume()
137 int lshift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_get_volume()
138 int inverted = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_get_volume() local
142 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_get_volume()
143 vol[0] = (chip->awacs_reg[reg] >> lshift) & 0xf; in snd_pmac_awacs_get_volume()
144 vol[1] = chip->awacs_reg[reg] & 0xf; in snd_pmac_awacs_get_volume()
145 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_get_volume()
146 if (inverted) { in snd_pmac_awacs_get_volume()
147 vol[0] = 0x0f - vol[0]; in snd_pmac_awacs_get_volume()
148 vol[1] = 0x0f - vol[1]; in snd_pmac_awacs_get_volume()
150 ucontrol->value.integer.value[0] = vol[0]; in snd_pmac_awacs_get_volume()
151 ucontrol->value.integer.value[1] = vol[1]; in snd_pmac_awacs_get_volume()
159 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_put_volume()
160 int lshift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_put_volume()
161 int inverted = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_put_volume() local
166 vol[0] = ucontrol->value.integer.value[0]; in snd_pmac_awacs_put_volume()
167 vol[1] = ucontrol->value.integer.value[1]; in snd_pmac_awacs_put_volume()
169 return -EINVAL; in snd_pmac_awacs_put_volume()
170 if (inverted) { in snd_pmac_awacs_put_volume()
171 vol[0] = 0x0f - vol[0]; in snd_pmac_awacs_put_volume()
172 vol[1] = 0x0f - vol[1]; in snd_pmac_awacs_put_volume()
176 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_put_volume()
177 oldval = chip->awacs_reg[reg]; in snd_pmac_awacs_put_volume()
183 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_put_volume()
202 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_get_switch()
203 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_get_switch()
204 int invert = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_get_switch()
208 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_get_switch()
209 val = (chip->awacs_reg[reg] >> shift) & 1; in snd_pmac_awacs_get_switch()
210 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_get_switch()
212 val = 1 - val; in snd_pmac_awacs_get_switch()
213 ucontrol->value.integer.value[0] = val; in snd_pmac_awacs_get_switch()
221 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_put_switch()
222 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_put_switch()
223 int invert = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_put_switch()
228 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_put_switch()
229 val = chip->awacs_reg[reg] & ~mask; in snd_pmac_awacs_put_switch()
230 if (ucontrol->value.integer.value[0] != invert) in snd_pmac_awacs_put_switch()
232 changed = chip->awacs_reg[reg] != val; in snd_pmac_awacs_put_switch()
235 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_put_switch()
264 * level = 0 - 14, 7 = 0 dB
268 amp->amp_tone[0] = bass; in awacs_amp_set_tone()
269 amp->amp_tone[1] = treble; in awacs_amp_set_tone()
271 bass = (14 - bass) + 8; in awacs_amp_set_tone()
273 treble = (14 - treble) + 8; in awacs_amp_set_tone()
278 * vol = 0 - 31 (attenuation), 32 = mute bit, stereo
283 if (do_check && amp->amp_vol[index][0] == lvol && in awacs_amp_set_vol()
284 amp->amp_vol[index][1] == rvol) in awacs_amp_set_vol()
288 amp->amp_vol[index][0] = lvol; in awacs_amp_set_vol()
289 amp->amp_vol[index][1] = rvol; in awacs_amp_set_vol()
294 * 0 = -79 dB, 79 = 0 dB, 99 = +20 dB
298 amp->amp_master = vol; in awacs_amp_set_master()
300 vol = 32 + (79 - vol); in awacs_amp_set_master()
302 vol = 32 - (vol - 79); in awacs_amp_set_master()
308 struct awacs_amp *amp = chip->mixer_data; in awacs_amp_free()
312 chip->mixer_data = NULL; in awacs_amp_free()
313 chip->mixer_free = NULL; in awacs_amp_free()
323 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_volume_amp()
324 uinfo->count = 2; in snd_pmac_awacs_info_volume_amp()
325 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_volume_amp()
326 uinfo->value.integer.max = 31; in snd_pmac_awacs_info_volume_amp()
334 int index = kcontrol->private_value; in snd_pmac_awacs_get_volume_amp()
335 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_volume_amp()
337 ucontrol->value.integer.value[0] = 31 - (amp->amp_vol[index][0] & 31); in snd_pmac_awacs_get_volume_amp()
338 ucontrol->value.integer.value[1] = 31 - (amp->amp_vol[index][1] & 31); in snd_pmac_awacs_get_volume_amp()
346 int index = kcontrol->private_value; in snd_pmac_awacs_put_volume_amp()
348 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_volume_amp()
350 vol[0] = (31 - (ucontrol->value.integer.value[0] & 31)) in snd_pmac_awacs_put_volume_amp()
351 | (amp->amp_vol[index][0] & 32); in snd_pmac_awacs_put_volume_amp()
352 vol[1] = (31 - (ucontrol->value.integer.value[1] & 31)) in snd_pmac_awacs_put_volume_amp()
353 | (amp->amp_vol[index][1] & 32); in snd_pmac_awacs_put_volume_amp()
361 int index = kcontrol->private_value; in snd_pmac_awacs_get_switch_amp()
362 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_switch_amp()
364 ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32) in snd_pmac_awacs_get_switch_amp()
366 ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32) in snd_pmac_awacs_get_switch_amp()
375 int index = kcontrol->private_value; in snd_pmac_awacs_put_switch_amp()
377 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_switch_amp()
379 vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32) in snd_pmac_awacs_put_switch_amp()
380 | (amp->amp_vol[index][0] & 31); in snd_pmac_awacs_put_switch_amp()
381 vol[1] = (ucontrol->value.integer.value[1] ? 0 : 32) in snd_pmac_awacs_put_switch_amp()
382 | (amp->amp_vol[index][1] & 31); in snd_pmac_awacs_put_switch_amp()
389 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_tone_amp()
390 uinfo->count = 1; in snd_pmac_awacs_info_tone_amp()
391 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_tone_amp()
392 uinfo->value.integer.max = 14; in snd_pmac_awacs_info_tone_amp()
400 int index = kcontrol->private_value; in snd_pmac_awacs_get_tone_amp()
401 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_tone_amp()
403 ucontrol->value.integer.value[0] = amp->amp_tone[index]; in snd_pmac_awacs_get_tone_amp()
411 int index = kcontrol->private_value; in snd_pmac_awacs_put_tone_amp()
412 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_tone_amp()
415 val = ucontrol->value.integer.value[0]; in snd_pmac_awacs_put_tone_amp()
417 return -EINVAL; in snd_pmac_awacs_put_tone_amp()
418 if (val != amp->amp_tone[index]) { in snd_pmac_awacs_put_tone_amp()
419 amp->amp_tone[index] = val; in snd_pmac_awacs_put_tone_amp()
420 awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); in snd_pmac_awacs_put_tone_amp()
429 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_master_amp()
430 uinfo->count = 1; in snd_pmac_awacs_info_master_amp()
431 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_master_amp()
432 uinfo->value.integer.max = 99; in snd_pmac_awacs_info_master_amp()
440 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_master_amp()
442 ucontrol->value.integer.value[0] = amp->amp_master; in snd_pmac_awacs_get_master_amp()
450 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_master_amp()
453 val = ucontrol->value.integer.value[0]; in snd_pmac_awacs_put_master_amp()
455 return -EINVAL; in snd_pmac_awacs_put_master_amp()
456 if (val != amp->amp_master) { in snd_pmac_awacs_put_master_amp()
457 amp->amp_master = val; in snd_pmac_awacs_put_master_amp()
458 awacs_amp_set_master(amp, amp->amp_master); in snd_pmac_awacs_put_master_amp()
483 .name = "Tone Control - Bass",
490 .name = "Tone Control - Treble",
531 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_screamer_mic_boost_info()
532 uinfo->count = 1; in snd_pmac_screamer_mic_boost_info()
533 uinfo->value.integer.min = 0; in snd_pmac_screamer_mic_boost_info()
534 uinfo->value.integer.max = 3; in snd_pmac_screamer_mic_boost_info()
545 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_get()
546 if (chip->awacs_reg[6] & MASK_MIC_BOOST) in snd_pmac_screamer_mic_boost_get()
548 if (chip->awacs_reg[0] & MASK_GAINLINE) in snd_pmac_screamer_mic_boost_get()
550 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_get()
551 ucontrol->value.integer.value[0] = val; in snd_pmac_screamer_mic_boost_get()
563 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_put()
564 val0 = chip->awacs_reg[0] & ~MASK_GAINLINE; in snd_pmac_screamer_mic_boost_put()
565 val6 = chip->awacs_reg[6] & ~MASK_MIC_BOOST; in snd_pmac_screamer_mic_boost_put()
566 if (ucontrol->value.integer.value[0] & 1) in snd_pmac_screamer_mic_boost_put()
568 if (ucontrol->value.integer.value[0] & 2) in snd_pmac_screamer_mic_boost_put()
570 if (val0 != chip->awacs_reg[0]) { in snd_pmac_screamer_mic_boost_put()
574 if (val6 != chip->awacs_reg[6]) { in snd_pmac_screamer_mic_boost_put()
578 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_put()
593 AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1),
595 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0),
603 AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1),
604 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
610 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
616 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
626 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
643 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
676 AWACS_SWITCH("CD Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0),
708 err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip)); in build_mixers()
721 snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); in awacs_restore_all_regs()
722 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in awacs_restore_all_regs()
723 snd_pmac_awacs_write_noreg(chip, 2, chip->awacs_reg[2]); in awacs_restore_all_regs()
724 snd_pmac_awacs_write_noreg(chip, 4, chip->awacs_reg[4]); in awacs_restore_all_regs()
725 if (chip->model == PMAC_SCREAMER) { in awacs_restore_all_regs()
726 snd_pmac_awacs_write_noreg(chip, 5, chip->awacs_reg[5]); in awacs_restore_all_regs()
727 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in awacs_restore_all_regs()
728 snd_pmac_awacs_write_noreg(chip, 7, chip->awacs_reg[7]); in awacs_restore_all_regs()
735 snd_pmac_awacs_write_noreg(chip, 1, (chip->awacs_reg[1] in snd_pmac_awacs_suspend()
745 chip->awacs_reg[1] & ~MASK_PAROUT); in snd_pmac_awacs_resume()
750 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_resume()
753 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in snd_pmac_awacs_resume()
757 if (chip->mixer_data) { in snd_pmac_awacs_resume()
758 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_resume()
760 amp->amp_vol[0][0], amp->amp_vol[0][1], 0); in snd_pmac_awacs_resume()
762 amp->amp_vol[1][0], amp->amp_vol[1][1], 0); in snd_pmac_awacs_resume()
763 awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); in snd_pmac_awacs_resume()
764 awacs_amp_set_master(amp, amp->amp_master); in snd_pmac_awacs_resume()
785 * auto-mute stuffs
789 return (in_le32(&chip->awacs->codec_stat) & chip->hp_stat_mask) ? 1 : 0; in snd_pmac_awacs_detect_headphone()
796 vol[0] = amp->amp_vol[index][0] & 31; in toggle_amp_mute()
797 vol[1] = amp->amp_vol[index][1] & 31; in toggle_amp_mute()
808 if (chip->auto_mute) { in snd_pmac_awacs_update_automute()
810 if (chip->mixer_data) { in snd_pmac_awacs_update_automute()
811 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_update_automute()
825 int reg = chip->awacs_reg[1] in snd_pmac_awacs_update_automute()
842 if (do_notify && reg == chip->awacs_reg[1]) in snd_pmac_awacs_update_automute()
847 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
848 &chip->master_sw_ctl->id); in snd_pmac_awacs_update_automute()
849 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
850 &chip->speaker_sw_ctl->id); in snd_pmac_awacs_update_automute()
851 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
852 &chip->hp_detect_ctl->id); in snd_pmac_awacs_update_automute()
879 * as start-up in snd_pmac_awacs_init()
881 chip->awacs_reg[0] = MASK_MUX_CD | 0xff | MASK_GAINLINE; in snd_pmac_awacs_init()
882 chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE; in snd_pmac_awacs_init()
884 if (chip->has_iic || chip->device_id == 0x5 || in snd_pmac_awacs_init()
885 /* chip->_device_id == 0x8 || */ in snd_pmac_awacs_init()
886 chip->device_id == 0xb) in snd_pmac_awacs_init()
887 chip->awacs_reg[1] |= MASK_PAROUT; in snd_pmac_awacs_init()
893 chip->awacs_reg[2] = vol; in snd_pmac_awacs_init()
894 chip->awacs_reg[4] = vol; in snd_pmac_awacs_init()
895 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_init()
897 chip->awacs_reg[5] = vol; in snd_pmac_awacs_init()
899 chip->awacs_reg[6] = MASK_MIC_BOOST; in snd_pmac_awacs_init()
900 chip->awacs_reg[7] = 0; in snd_pmac_awacs_init()
904 chip->manufacturer = (in_le32(&chip->awacs->codec_stat) >> 8) & 0xf; in snd_pmac_awacs_init()
907 chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; in snd_pmac_awacs_init()
909 if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { in snd_pmac_awacs_init()
912 return -ENOMEM; in snd_pmac_awacs_init()
913 chip->mixer_data = amp; in snd_pmac_awacs_init()
914 chip->mixer_free = awacs_amp_free; in snd_pmac_awacs_init()
923 if (chip->hp_stat_mask == 0) { in snd_pmac_awacs_init()
924 /* set headphone-jack detection bit */ in snd_pmac_awacs_init()
925 switch (chip->model) { in snd_pmac_awacs_init()
927 chip->hp_stat_mask = pm7500 || pm5500 ? MASK_HDPCONN in snd_pmac_awacs_init()
931 switch (chip->device_id) { in snd_pmac_awacs_init()
934 chip->hp_stat_mask = imac in snd_pmac_awacs_init()
942 chip->hp_stat_mask = MASK_LOCONN; in snd_pmac_awacs_init()
945 chip->hp_stat_mask = MASK_HDPCONN; in snd_pmac_awacs_init()
958 strcpy(chip->card->mixername, "PowerMac AWACS"); in snd_pmac_awacs_init()
966 else if (chip->model == PMAC_SCREAMER || pm5500) in snd_pmac_awacs_init()
987 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
995 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
1013 chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp || lombard) in snd_pmac_awacs_init()
1018 err = snd_ctl_add(chip->card, chip->master_sw_ctl); in snd_pmac_awacs_init()
1022 if (chip->mixer_data) { in snd_pmac_awacs_init()
1034 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw, in snd_pmac_awacs_init()
1036 err = snd_ctl_add(chip->card, chip->master_sw_ctl); in snd_pmac_awacs_init()
1039 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw, in snd_pmac_awacs_init()
1041 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1048 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
1053 chip->speaker_sw_ctl = snd_ctl_new1(imac1 in snd_pmac_awacs_init()
1058 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1067 chip->master_sw_ctl); in snd_pmac_awacs_init()
1071 chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1074 err = snd_ctl_add(chip->card, vmaster_sw); in snd_pmac_awacs_init()
1085 err = snd_ctl_add(chip->card, vmaster_vol); in snd_pmac_awacs_init()
1098 else if (chip->model == PMAC_SCREAMER) in snd_pmac_awacs_init()
1115 chip->set_format = snd_pmac_awacs_set_format; in snd_pmac_awacs_init()
1117 chip->suspend = snd_pmac_awacs_suspend; in snd_pmac_awacs_init()
1118 chip->resume = snd_pmac_awacs_resume; in snd_pmac_awacs_init()
1124 chip->detect_headphone = snd_pmac_awacs_detect_headphone; in snd_pmac_awacs_init()
1125 chip->update_automute = snd_pmac_awacs_update_automute; in snd_pmac_awacs_init()
1128 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_init()
1129 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in snd_pmac_awacs_init()
1130 snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); in snd_pmac_awacs_init()