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

1 // SPDX-License-Identifier: GPL-2.0-or-later
39 while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) { in snd_pmac_screamer_wait()
41 if (! --timeout) { in snd_pmac_screamer_wait()
42 dev_dbg(chip->card->dev, "%s timeout\n", __func__); in snd_pmac_screamer_wait()
56 if (chip->model == PMAC_SCREAMER) in snd_pmac_awacs_write()
58 out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22)); in snd_pmac_awacs_write()
59 while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) { in snd_pmac_awacs_write()
60 if (! --timeout) { in snd_pmac_awacs_write()
61 dev_dbg(chip->card->dev, "%s timeout\n", __func__); in snd_pmac_awacs_write()
71 chip->awacs_reg[reg] = val; in snd_pmac_awacs_write_reg()
84 if (chip->model != PMAC_SCREAMER) in screamer_recalibrate()
90 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in screamer_recalibrate()
91 if (chip->manufacturer == 0x1) in screamer_recalibrate()
95 chip->awacs_reg[1] | MASK_RECALIBRATE | in screamer_recalibrate()
97 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in screamer_recalibrate()
98 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in screamer_recalibrate()
111 chip->awacs_reg[1] &= ~MASK_SAMPLERATE; in snd_pmac_awacs_set_format()
112 chip->awacs_reg[1] |= chip->rate_index << 3; in snd_pmac_awacs_set_format()
113 snd_pmac_awacs_write_reg(chip, 1, chip->awacs_reg[1]); in snd_pmac_awacs_set_format()
121 * volumes: 0-15 stereo
126 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_volume()
127 uinfo->count = 2; in snd_pmac_awacs_info_volume()
128 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_volume()
129 uinfo->value.integer.max = 15; in snd_pmac_awacs_info_volume()
137 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_get_volume()
138 int lshift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_get_volume()
139 int inverted = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_get_volume() local
143 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_get_volume()
144 vol[0] = (chip->awacs_reg[reg] >> lshift) & 0xf; in snd_pmac_awacs_get_volume()
145 vol[1] = chip->awacs_reg[reg] & 0xf; in snd_pmac_awacs_get_volume()
146 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_get_volume()
147 if (inverted) { in snd_pmac_awacs_get_volume()
148 vol[0] = 0x0f - vol[0]; in snd_pmac_awacs_get_volume()
149 vol[1] = 0x0f - vol[1]; in snd_pmac_awacs_get_volume()
151 ucontrol->value.integer.value[0] = vol[0]; in snd_pmac_awacs_get_volume()
152 ucontrol->value.integer.value[1] = vol[1]; in snd_pmac_awacs_get_volume()
160 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_put_volume()
161 int lshift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_put_volume()
162 int inverted = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_put_volume() local
167 vol[0] = ucontrol->value.integer.value[0]; in snd_pmac_awacs_put_volume()
168 vol[1] = ucontrol->value.integer.value[1]; in snd_pmac_awacs_put_volume()
170 return -EINVAL; in snd_pmac_awacs_put_volume()
171 if (inverted) { in snd_pmac_awacs_put_volume()
172 vol[0] = 0x0f - vol[0]; in snd_pmac_awacs_put_volume()
173 vol[1] = 0x0f - vol[1]; in snd_pmac_awacs_put_volume()
177 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_put_volume()
178 oldval = chip->awacs_reg[reg]; in snd_pmac_awacs_put_volume()
184 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_put_volume()
203 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_get_switch()
204 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_get_switch()
205 int invert = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_get_switch()
209 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_get_switch()
210 val = (chip->awacs_reg[reg] >> shift) & 1; in snd_pmac_awacs_get_switch()
211 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_get_switch()
213 val = 1 - val; in snd_pmac_awacs_get_switch()
214 ucontrol->value.integer.value[0] = val; in snd_pmac_awacs_get_switch()
222 int reg = kcontrol->private_value & 0xff; in snd_pmac_awacs_put_switch()
223 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_pmac_awacs_put_switch()
224 int invert = (kcontrol->private_value >> 16) & 1; in snd_pmac_awacs_put_switch()
229 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_awacs_put_switch()
230 val = chip->awacs_reg[reg] & ~mask; in snd_pmac_awacs_put_switch()
231 if (ucontrol->value.integer.value[0] != invert) in snd_pmac_awacs_put_switch()
233 changed = chip->awacs_reg[reg] != val; in snd_pmac_awacs_put_switch()
236 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_awacs_put_switch()
265 * level = 0 - 14, 7 = 0 dB
269 amp->amp_tone[0] = bass; in awacs_amp_set_tone()
270 amp->amp_tone[1] = treble; in awacs_amp_set_tone()
272 bass = (14 - bass) + 8; in awacs_amp_set_tone()
274 treble = (14 - treble) + 8; in awacs_amp_set_tone()
279 * vol = 0 - 31 (attenuation), 32 = mute bit, stereo
284 if (do_check && amp->amp_vol[index][0] == lvol && in awacs_amp_set_vol()
285 amp->amp_vol[index][1] == rvol) in awacs_amp_set_vol()
289 amp->amp_vol[index][0] = lvol; in awacs_amp_set_vol()
290 amp->amp_vol[index][1] = rvol; in awacs_amp_set_vol()
295 * 0 = -79 dB, 79 = 0 dB, 99 = +20 dB
299 amp->amp_master = vol; in awacs_amp_set_master()
301 vol = 32 + (79 - vol); in awacs_amp_set_master()
303 vol = 32 - (vol - 79); in awacs_amp_set_master()
309 struct awacs_amp *amp = chip->mixer_data; in awacs_amp_free()
313 chip->mixer_data = NULL; in awacs_amp_free()
314 chip->mixer_free = NULL; in awacs_amp_free()
324 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_volume_amp()
325 uinfo->count = 2; in snd_pmac_awacs_info_volume_amp()
326 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_volume_amp()
327 uinfo->value.integer.max = 31; in snd_pmac_awacs_info_volume_amp()
335 int index = kcontrol->private_value; in snd_pmac_awacs_get_volume_amp()
336 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_volume_amp()
338 ucontrol->value.integer.value[0] = 31 - (amp->amp_vol[index][0] & 31); in snd_pmac_awacs_get_volume_amp()
339 ucontrol->value.integer.value[1] = 31 - (amp->amp_vol[index][1] & 31); in snd_pmac_awacs_get_volume_amp()
347 int index = kcontrol->private_value; in snd_pmac_awacs_put_volume_amp()
349 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_volume_amp()
351 vol[0] = (31 - (ucontrol->value.integer.value[0] & 31)) in snd_pmac_awacs_put_volume_amp()
352 | (amp->amp_vol[index][0] & 32); in snd_pmac_awacs_put_volume_amp()
353 vol[1] = (31 - (ucontrol->value.integer.value[1] & 31)) in snd_pmac_awacs_put_volume_amp()
354 | (amp->amp_vol[index][1] & 32); in snd_pmac_awacs_put_volume_amp()
362 int index = kcontrol->private_value; in snd_pmac_awacs_get_switch_amp()
363 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_switch_amp()
365 ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32) in snd_pmac_awacs_get_switch_amp()
367 ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32) in snd_pmac_awacs_get_switch_amp()
376 int index = kcontrol->private_value; in snd_pmac_awacs_put_switch_amp()
378 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_switch_amp()
380 vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32) in snd_pmac_awacs_put_switch_amp()
381 | (amp->amp_vol[index][0] & 31); in snd_pmac_awacs_put_switch_amp()
382 vol[1] = (ucontrol->value.integer.value[1] ? 0 : 32) in snd_pmac_awacs_put_switch_amp()
383 | (amp->amp_vol[index][1] & 31); in snd_pmac_awacs_put_switch_amp()
390 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_tone_amp()
391 uinfo->count = 1; in snd_pmac_awacs_info_tone_amp()
392 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_tone_amp()
393 uinfo->value.integer.max = 14; in snd_pmac_awacs_info_tone_amp()
401 int index = kcontrol->private_value; in snd_pmac_awacs_get_tone_amp()
402 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_tone_amp()
404 ucontrol->value.integer.value[0] = amp->amp_tone[index]; in snd_pmac_awacs_get_tone_amp()
412 int index = kcontrol->private_value; in snd_pmac_awacs_put_tone_amp()
413 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_tone_amp()
416 val = ucontrol->value.integer.value[0]; in snd_pmac_awacs_put_tone_amp()
418 return -EINVAL; in snd_pmac_awacs_put_tone_amp()
419 if (val != amp->amp_tone[index]) { in snd_pmac_awacs_put_tone_amp()
420 amp->amp_tone[index] = val; in snd_pmac_awacs_put_tone_amp()
421 awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); in snd_pmac_awacs_put_tone_amp()
430 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_awacs_info_master_amp()
431 uinfo->count = 1; in snd_pmac_awacs_info_master_amp()
432 uinfo->value.integer.min = 0; in snd_pmac_awacs_info_master_amp()
433 uinfo->value.integer.max = 99; in snd_pmac_awacs_info_master_amp()
441 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_get_master_amp()
443 ucontrol->value.integer.value[0] = amp->amp_master; in snd_pmac_awacs_get_master_amp()
451 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_put_master_amp()
454 val = ucontrol->value.integer.value[0]; in snd_pmac_awacs_put_master_amp()
456 return -EINVAL; in snd_pmac_awacs_put_master_amp()
457 if (val != amp->amp_master) { in snd_pmac_awacs_put_master_amp()
458 amp->amp_master = val; in snd_pmac_awacs_put_master_amp()
459 awacs_amp_set_master(amp, amp->amp_master); in snd_pmac_awacs_put_master_amp()
484 .name = "Tone Control - Bass",
491 .name = "Tone Control - Treble",
532 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_pmac_screamer_mic_boost_info()
533 uinfo->count = 1; in snd_pmac_screamer_mic_boost_info()
534 uinfo->value.integer.min = 0; in snd_pmac_screamer_mic_boost_info()
535 uinfo->value.integer.max = 3; in snd_pmac_screamer_mic_boost_info()
546 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_get()
547 if (chip->awacs_reg[6] & MASK_MIC_BOOST) in snd_pmac_screamer_mic_boost_get()
549 if (chip->awacs_reg[0] & MASK_GAINLINE) in snd_pmac_screamer_mic_boost_get()
551 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_get()
552 ucontrol->value.integer.value[0] = val; in snd_pmac_screamer_mic_boost_get()
564 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_put()
565 val0 = chip->awacs_reg[0] & ~MASK_GAINLINE; in snd_pmac_screamer_mic_boost_put()
566 val6 = chip->awacs_reg[6] & ~MASK_MIC_BOOST; in snd_pmac_screamer_mic_boost_put()
567 if (ucontrol->value.integer.value[0] & 1) in snd_pmac_screamer_mic_boost_put()
569 if (ucontrol->value.integer.value[0] & 2) in snd_pmac_screamer_mic_boost_put()
571 if (val0 != chip->awacs_reg[0]) { in snd_pmac_screamer_mic_boost_put()
575 if (val6 != chip->awacs_reg[6]) { in snd_pmac_screamer_mic_boost_put()
579 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_screamer_mic_boost_put()
594 AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1),
596 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0),
604 AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1),
605 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
611 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
617 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
627 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
644 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
677 AWACS_SWITCH("CD Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0),
709 err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip)); in build_mixers()
722 snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); in awacs_restore_all_regs()
723 snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); in awacs_restore_all_regs()
724 snd_pmac_awacs_write_noreg(chip, 2, chip->awacs_reg[2]); in awacs_restore_all_regs()
725 snd_pmac_awacs_write_noreg(chip, 4, chip->awacs_reg[4]); in awacs_restore_all_regs()
726 if (chip->model == PMAC_SCREAMER) { in awacs_restore_all_regs()
727 snd_pmac_awacs_write_noreg(chip, 5, chip->awacs_reg[5]); in awacs_restore_all_regs()
728 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in awacs_restore_all_regs()
729 snd_pmac_awacs_write_noreg(chip, 7, chip->awacs_reg[7]); in awacs_restore_all_regs()
736 snd_pmac_awacs_write_noreg(chip, 1, (chip->awacs_reg[1] in snd_pmac_awacs_suspend()
746 chip->awacs_reg[1] & ~MASK_PAROUT); in snd_pmac_awacs_resume()
751 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_resume()
754 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in snd_pmac_awacs_resume()
758 if (chip->mixer_data) { in snd_pmac_awacs_resume()
759 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_resume()
761 amp->amp_vol[0][0], amp->amp_vol[0][1], 0); in snd_pmac_awacs_resume()
763 amp->amp_vol[1][0], amp->amp_vol[1][1], 0); in snd_pmac_awacs_resume()
764 awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); in snd_pmac_awacs_resume()
765 awacs_amp_set_master(amp, amp->amp_master); in snd_pmac_awacs_resume()
786 * auto-mute stuffs
790 return (in_le32(&chip->awacs->codec_stat) & chip->hp_stat_mask) ? 1 : 0; in snd_pmac_awacs_detect_headphone()
797 vol[0] = amp->amp_vol[index][0] & 31; in toggle_amp_mute()
798 vol[1] = amp->amp_vol[index][1] & 31; in toggle_amp_mute()
809 if (chip->auto_mute) { in snd_pmac_awacs_update_automute()
811 if (chip->mixer_data) { in snd_pmac_awacs_update_automute()
812 struct awacs_amp *amp = chip->mixer_data; in snd_pmac_awacs_update_automute()
826 int reg = chip->awacs_reg[1] in snd_pmac_awacs_update_automute()
843 if (do_notify && reg == chip->awacs_reg[1]) in snd_pmac_awacs_update_automute()
848 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
849 &chip->master_sw_ctl->id); in snd_pmac_awacs_update_automute()
850 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
851 &chip->speaker_sw_ctl->id); in snd_pmac_awacs_update_automute()
852 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_pmac_awacs_update_automute()
853 &chip->hp_detect_ctl->id); in snd_pmac_awacs_update_automute()
880 * as start-up in snd_pmac_awacs_init()
882 chip->awacs_reg[0] = MASK_MUX_CD | 0xff | MASK_GAINLINE; in snd_pmac_awacs_init()
883 chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE; in snd_pmac_awacs_init()
885 if (chip->has_iic || chip->device_id == 0x5 || in snd_pmac_awacs_init()
886 /* chip->_device_id == 0x8 || */ in snd_pmac_awacs_init()
887 chip->device_id == 0xb) in snd_pmac_awacs_init()
888 chip->awacs_reg[1] |= MASK_PAROUT; in snd_pmac_awacs_init()
894 chip->awacs_reg[2] = vol; in snd_pmac_awacs_init()
895 chip->awacs_reg[4] = vol; in snd_pmac_awacs_init()
896 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_init()
898 chip->awacs_reg[5] = vol; in snd_pmac_awacs_init()
900 chip->awacs_reg[6] = MASK_MIC_BOOST; in snd_pmac_awacs_init()
901 chip->awacs_reg[7] = 0; in snd_pmac_awacs_init()
905 chip->manufacturer = (in_le32(&chip->awacs->codec_stat) >> 8) & 0xf; in snd_pmac_awacs_init()
908 chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; in snd_pmac_awacs_init()
910 if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { in snd_pmac_awacs_init()
913 return -ENOMEM; in snd_pmac_awacs_init()
914 chip->mixer_data = amp; in snd_pmac_awacs_init()
915 chip->mixer_free = awacs_amp_free; in snd_pmac_awacs_init()
924 if (chip->hp_stat_mask == 0) { in snd_pmac_awacs_init()
925 /* set headphone-jack detection bit */ in snd_pmac_awacs_init()
926 switch (chip->model) { in snd_pmac_awacs_init()
928 chip->hp_stat_mask = pm7500 || pm5500 ? MASK_HDPCONN in snd_pmac_awacs_init()
932 switch (chip->device_id) { in snd_pmac_awacs_init()
935 chip->hp_stat_mask = imac in snd_pmac_awacs_init()
943 chip->hp_stat_mask = MASK_LOCONN; in snd_pmac_awacs_init()
946 chip->hp_stat_mask = MASK_HDPCONN; in snd_pmac_awacs_init()
959 strcpy(chip->card->mixername, "PowerMac AWACS"); in snd_pmac_awacs_init()
967 else if (chip->model == PMAC_SCREAMER || pm5500) in snd_pmac_awacs_init()
988 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
996 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
1014 chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp || lombard) in snd_pmac_awacs_init()
1019 err = snd_ctl_add(chip->card, chip->master_sw_ctl); in snd_pmac_awacs_init()
1023 if (chip->mixer_data) { in snd_pmac_awacs_init()
1035 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw, in snd_pmac_awacs_init()
1037 err = snd_ctl_add(chip->card, chip->master_sw_ctl); in snd_pmac_awacs_init()
1040 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw, in snd_pmac_awacs_init()
1042 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1049 err = snd_ctl_add(chip->card, in snd_pmac_awacs_init()
1054 chip->speaker_sw_ctl = snd_ctl_new1(imac1 in snd_pmac_awacs_init()
1059 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1068 chip->master_sw_ctl); in snd_pmac_awacs_init()
1072 chip->speaker_sw_ctl); in snd_pmac_awacs_init()
1075 err = snd_ctl_add(chip->card, vmaster_sw); in snd_pmac_awacs_init()
1086 err = snd_ctl_add(chip->card, vmaster_vol); in snd_pmac_awacs_init()
1099 else if (chip->model == PMAC_SCREAMER) in snd_pmac_awacs_init()
1116 chip->set_format = snd_pmac_awacs_set_format; in snd_pmac_awacs_init()
1118 chip->suspend = snd_pmac_awacs_suspend; in snd_pmac_awacs_init()
1119 chip->resume = snd_pmac_awacs_resume; in snd_pmac_awacs_init()
1125 chip->detect_headphone = snd_pmac_awacs_detect_headphone; in snd_pmac_awacs_init()
1126 chip->update_automute = snd_pmac_awacs_update_automute; in snd_pmac_awacs_init()
1129 if (chip->model == PMAC_SCREAMER) { in snd_pmac_awacs_init()
1130 snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); in snd_pmac_awacs_init()
1131 snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); in snd_pmac_awacs_init()