42 snd_pmac_burgundy_extend_wait(
struct snd_pmac *chip)
58 snd_pmac_burgundy_wcw(
struct snd_pmac *chip,
unsigned addr,
unsigned val)
60 out_le32(&chip->
awacs->codec_ctrl, addr + 0x200c00 + (val & 0xff));
61 snd_pmac_burgundy_busy_wait(chip);
62 out_le32(&chip->
awacs->codec_ctrl, addr + 0x200d00 +((val>>8) & 0xff));
63 snd_pmac_burgundy_busy_wait(chip);
64 out_le32(&chip->
awacs->codec_ctrl, addr + 0x200e00 +((val>>16) & 0xff));
65 snd_pmac_burgundy_busy_wait(chip);
66 out_le32(&chip->
awacs->codec_ctrl, addr + 0x200f00 +((val>>24) & 0xff));
67 snd_pmac_burgundy_busy_wait(chip);
71 snd_pmac_burgundy_rcw(
struct snd_pmac *chip,
unsigned addr)
79 snd_pmac_burgundy_busy_wait(chip);
80 snd_pmac_burgundy_extend_wait(chip);
84 snd_pmac_burgundy_busy_wait(chip);
85 snd_pmac_burgundy_extend_wait(chip);
86 val += ((
in_le32(&chip->
awacs->codec_stat)>>4) & 0xff) <<8;
89 snd_pmac_burgundy_busy_wait(chip);
90 snd_pmac_burgundy_extend_wait(chip);
91 val += ((
in_le32(&chip->
awacs->codec_stat)>>4) & 0xff) <<16;
94 snd_pmac_burgundy_busy_wait(chip);
95 snd_pmac_burgundy_extend_wait(chip);
96 val += ((
in_le32(&chip->
awacs->codec_stat)>>4) & 0xff) <<24;
98 spin_unlock_irqrestore(&chip->
reg_lock, flags);
104 snd_pmac_burgundy_wcb(
struct snd_pmac *chip,
unsigned int addr,
107 out_le32(&chip->
awacs->codec_ctrl, addr + 0x300000 + (val & 0xff));
108 snd_pmac_burgundy_busy_wait(chip);
112 snd_pmac_burgundy_rcb(
struct snd_pmac *chip,
unsigned int addr)
120 snd_pmac_burgundy_busy_wait(chip);
121 snd_pmac_burgundy_extend_wait(chip);
124 spin_unlock_irqrestore(&chip->
reg_lock, flags);
129 #define BASE2ADDR(base) ((base) << 12)
130 #define ADDR2BASE(addr) ((addr) >> 12)
136 snd_pmac_burgundy_write_volume(
struct snd_pmac *chip,
unsigned int address,
139 int hardvolume, lvolume, rvolume;
141 if (volume[0] < 0 || volume[0] > 100 ||
142 volume[1] < 0 || volume[1] > 100)
147 hardvolume = lvolume + (rvolume << shift);
149 hardvolume |= hardvolume << 16;
151 snd_pmac_burgundy_wcw(chip, address, hardvolume);
155 snd_pmac_burgundy_read_volume(
struct snd_pmac *chip,
unsigned int address,
160 wvolume = snd_pmac_burgundy_rcw(chip, address);
162 volume[0] = wvolume & 0xff;
167 volume[1] = (wvolume >> shift) & 0xff;
174 static int snd_pmac_burgundy_info_volume(
struct snd_kcontrol *kcontrol,
184 static int snd_pmac_burgundy_get_volume(
struct snd_kcontrol *kcontrol,
190 snd_pmac_burgundy_read_volume(chip, addr,
191 ucontrol->
value.integer.value, shift);
195 static int snd_pmac_burgundy_put_volume(
struct snd_kcontrol *kcontrol,
203 snd_pmac_burgundy_write_volume(chip, addr,
204 ucontrol->
value.integer.value, shift);
205 snd_pmac_burgundy_read_volume(chip, addr, nvoices, shift);
206 return (nvoices[0] != ucontrol->
value.integer.value[0] ||
207 nvoices[1] != ucontrol->
value.integer.value[1]);
210 #define BURGUNDY_VOLUME_W(xname, xindex, addr, shift) \
211 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
212 .info = snd_pmac_burgundy_info_volume,\
213 .get = snd_pmac_burgundy_get_volume,\
214 .put = snd_pmac_burgundy_put_volume,\
215 .private_value = ((ADDR2BASE(addr) & 0xff) | ((shift) << 8)) }
221 snd_pmac_burgundy_write_volume_2b(
struct snd_pmac *chip,
unsigned int address,
222 long *volume,
int off)
224 int lvolume, rvolume;
230 snd_pmac_burgundy_wcb(chip, address + off, lvolume);
231 snd_pmac_burgundy_wcb(chip, address + off + 0x500, rvolume);
235 snd_pmac_burgundy_read_volume_2b(
struct snd_pmac *chip,
unsigned int address,
236 long *volume,
int off)
238 volume[0] = snd_pmac_burgundy_rcb(chip, address + off);
243 volume[1] = snd_pmac_burgundy_rcb(chip, address + off + 0x100);
250 static int snd_pmac_burgundy_info_volume_2b(
struct snd_kcontrol *kcontrol,
260 static int snd_pmac_burgundy_get_volume_2b(
struct snd_kcontrol *kcontrol,
266 snd_pmac_burgundy_read_volume_2b(chip, addr,
267 ucontrol->
value.integer.value, off);
271 static int snd_pmac_burgundy_put_volume_2b(
struct snd_kcontrol *kcontrol,
279 snd_pmac_burgundy_write_volume_2b(chip, addr,
280 ucontrol->
value.integer.value, off);
281 snd_pmac_burgundy_read_volume_2b(chip, addr, nvoices, off);
282 return (nvoices[0] != ucontrol->
value.integer.value[0] ||
283 nvoices[1] != ucontrol->
value.integer.value[1]);
286 #define BURGUNDY_VOLUME_2B(xname, xindex, addr, off) \
287 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
288 .info = snd_pmac_burgundy_info_volume_2b,\
289 .get = snd_pmac_burgundy_get_volume_2b,\
290 .put = snd_pmac_burgundy_put_volume_2b,\
291 .private_value = ((ADDR2BASE(addr) & 0xff) | ((off) << 8)) }
296 static int snd_pmac_burgundy_info_gain(
struct snd_kcontrol *kcontrol,
301 uinfo->
count = stereo + 1;
307 static int snd_pmac_burgundy_get_gain(
struct snd_kcontrol *kcontrol,
316 oval = snd_pmac_burgundy_rcb(chip, addr);
319 ucontrol->
value.integer.value[0] = oval & 0xf;
321 ucontrol->
value.integer.value[1] = (oval >> 4) & 0xf;
325 static int snd_pmac_burgundy_put_gain(
struct snd_kcontrol *kcontrol,
334 oval = snd_pmac_burgundy_rcb(chip, addr);
337 val = ucontrol->
value.integer.value[0];
339 val |= ucontrol->
value.integer.value[1] << 4;
341 val |= ucontrol->
value.integer.value[0] << 4;
344 snd_pmac_burgundy_wcb(chip, addr, val);
348 #define BURGUNDY_VOLUME_B(xname, xindex, addr, stereo, atten) \
349 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
350 .info = snd_pmac_burgundy_info_gain,\
351 .get = snd_pmac_burgundy_get_gain,\
352 .put = snd_pmac_burgundy_put_gain,\
353 .private_value = (ADDR2BASE(addr) | ((stereo) << 24) | ((atten) << 25)) }
358 static int snd_pmac_burgundy_info_switch_w(
struct snd_kcontrol *kcontrol,
363 uinfo->
count = stereo + 1;
369 static int snd_pmac_burgundy_get_switch_w(
struct snd_kcontrol *kcontrol,
377 int val = snd_pmac_burgundy_rcw(chip, addr);
378 ucontrol->
value.integer.value[0] = (val & lmask) ? 1 : 0;
380 ucontrol->
value.integer.value[1] = (val &
rmask) ? 1 : 0;
384 static int snd_pmac_burgundy_put_switch_w(
struct snd_kcontrol *kcontrol,
393 oval = snd_pmac_burgundy_rcw(chip, addr);
394 val = oval & ~(lmask | (stereo ? rmask : 0));
395 if (ucontrol->
value.integer.value[0])
397 if (stereo && ucontrol->
value.integer.value[1])
399 snd_pmac_burgundy_wcw(chip, addr, val);
403 #define BURGUNDY_SWITCH_W(xname, xindex, addr, lbit, rbit, stereo) \
404 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
405 .info = snd_pmac_burgundy_info_switch_w,\
406 .get = snd_pmac_burgundy_get_switch_w,\
407 .put = snd_pmac_burgundy_put_switch_w,\
408 .private_value = ((lbit) | ((rbit) << 8)\
409 | (ADDR2BASE(addr) << 16) | ((stereo) << 24)) }
414 static int snd_pmac_burgundy_info_switch_b(
struct snd_kcontrol *kcontrol,
419 uinfo->
count = stereo + 1;
425 static int snd_pmac_burgundy_get_switch_b(
struct snd_kcontrol *kcontrol,
433 int val = snd_pmac_burgundy_rcb(chip, addr);
434 ucontrol->
value.integer.value[0] = (val & lmask) ? 1 : 0;
436 ucontrol->
value.integer.value[1] = (val &
rmask) ? 1 : 0;
440 static int snd_pmac_burgundy_put_switch_b(
struct snd_kcontrol *kcontrol,
449 oval = snd_pmac_burgundy_rcb(chip, addr);
450 val = oval & ~(lmask |
rmask);
451 if (ucontrol->
value.integer.value[0])
453 if (stereo && ucontrol->
value.integer.value[1])
455 snd_pmac_burgundy_wcb(chip, addr, val);
459 #define BURGUNDY_SWITCH_B(xname, xindex, addr, lmask, rmask, stereo) \
460 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
461 .info = snd_pmac_burgundy_info_switch_b,\
462 .get = snd_pmac_burgundy_get_switch_b,\
463 .put = snd_pmac_burgundy_put_switch_b,\
464 .private_value = ((lmask) | ((rmask) << 8)\
465 | (ADDR2BASE(addr) << 16) | ((stereo) << 24)) }
498 static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __devinitdata = {
524 static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __devinitdata = {
540 static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac __devinitdata =
545 static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac __devinitdata =
550 static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __devinitdata =
554 static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __devinitdata =
558 static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __devinitdata =
562 static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac __devinitdata =
572 #ifdef PMAC_SUPPORT_AUTOMUTE
576 static int snd_pmac_burgundy_detect_headphone(
struct snd_pmac *chip)
581 static void snd_pmac_burgundy_update_automute(
struct snd_pmac *chip,
int do_notify)
586 reg = oreg = snd_pmac_burgundy_rcb(chip,
592 if (snd_pmac_burgundy_detect_headphone(chip))
600 if (do_notify && reg == oreg)
602 snd_pmac_burgundy_wcb(chip,
680 strcpy(chip->
card->mixername,
"PowerMac Burgundy");
682 for (i = 0; i <
ARRAY_SIZE(snd_pmac_burgundy_mixers); i++) {
688 for (i = 0; i < (imac ?
ARRAY_SIZE(snd_pmac_burgundy_mixers_imac)
689 :
ARRAY_SIZE(snd_pmac_burgundy_mixers_pmac)); i++) {
692 : &snd_pmac_burgundy_mixers_pmac[i], chip));
697 ? &snd_pmac_burgundy_master_sw_imac
698 : &snd_pmac_burgundy_master_sw_pmac, chip);
703 ? &snd_pmac_burgundy_line_sw_imac
704 : &snd_pmac_burgundy_line_sw_pmac, chip);
710 &snd_pmac_burgundy_hp_sw_imac, chip);
716 ? &snd_pmac_burgundy_speaker_sw_imac
717 : &snd_pmac_burgundy_speaker_sw_pmac, chip);
721 #ifdef PMAC_SUPPORT_AUTOMUTE
728 snd_pmac_burgundy_update_automute(chip, 0);