aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorRisto Suominen <Risto.Suominen@gmail.com>2008-04-16 13:45:31 -0400
committerTakashi Iwai <tiwai@suse.de>2008-04-24 06:00:38 -0400
commit44deee129c9af3759d3e5e772b82012742dc57a0 (patch)
treed6469a00b5d5c34712879ed76e868e60f014deeb /sound
parent7ae44cfa7ab29b277691327e8de790d7b880722f (diff)
[ALSA] snd-powermac: Burgundy mixers for B&W and iMac
Add mixer controls and correct headphone detection bits for PowerMac G3 B&W and iMac G3 Tray-loading, both having Burgundy chipset. Signed-off-by: Risto Suominen <Risto.Suominen@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/ppc/burgundy.c433
-rw-r--r--sound/ppc/burgundy.h31
2 files changed, 381 insertions, 83 deletions
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c
index 1a545ac0de04..f0c12a97fdbc 100644
--- a/sound/ppc/burgundy.c
+++ b/sound/ppc/burgundy.c
@@ -211,17 +211,156 @@ static int snd_pmac_burgundy_put_volume(struct snd_kcontrol *kcontrol,
211 nvoices[1] != ucontrol->value.integer.value[1]); 211 nvoices[1] != ucontrol->value.integer.value[1]);
212} 212}
213 213
214#define BURGUNDY_VOLUME(xname, xindex, addr, shift) \ 214#define BURGUNDY_VOLUME_W(xname, xindex, addr, shift) \
215{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ 215{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
216 .info = snd_pmac_burgundy_info_volume,\ 216 .info = snd_pmac_burgundy_info_volume,\
217 .get = snd_pmac_burgundy_get_volume,\ 217 .get = snd_pmac_burgundy_get_volume,\
218 .put = snd_pmac_burgundy_put_volume,\ 218 .put = snd_pmac_burgundy_put_volume,\
219 .private_value = ((ADDR2BASE(addr) & 0xff) | ((shift) << 8)) } 219 .private_value = ((ADDR2BASE(addr) & 0xff) | ((shift) << 8)) }
220 220
221/* lineout/speaker */ 221/*
222 * Burgundy volume: 0 - 100, stereo, 2-byte reg
223 */
224static void
225snd_pmac_burgundy_write_volume_2b(struct snd_pmac *chip, unsigned int address,
226 long *volume, int off)
227{
228 int lvolume, rvolume;
229
230 off |= off << 2;
231 lvolume = volume[0] ? volume[0] + BURGUNDY_VOLUME_OFFSET : 0;
232 rvolume = volume[1] ? volume[1] + BURGUNDY_VOLUME_OFFSET : 0;
233
234 snd_pmac_burgundy_wcb(chip, address + off, lvolume);
235 snd_pmac_burgundy_wcb(chip, address + off + 0x500, rvolume);
236}
237
238static void
239snd_pmac_burgundy_read_volume_2b(struct snd_pmac *chip, unsigned int address,
240 long *volume, int off)
241{
242 volume[0] = snd_pmac_burgundy_rcb(chip, address + off);
243 if (volume[0] >= BURGUNDY_VOLUME_OFFSET)
244 volume[0] -= BURGUNDY_VOLUME_OFFSET;
245 else
246 volume[0] = 0;
247 volume[1] = snd_pmac_burgundy_rcb(chip, address + off + 0x100);
248 if (volume[1] >= BURGUNDY_VOLUME_OFFSET)
249 volume[1] -= BURGUNDY_VOLUME_OFFSET;
250 else
251 volume[1] = 0;
252}
253
254static int snd_pmac_burgundy_info_volume_2b(struct snd_kcontrol *kcontrol,
255 struct snd_ctl_elem_info *uinfo)
256{
257 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
258 uinfo->count = 2;
259 uinfo->value.integer.min = 0;
260 uinfo->value.integer.max = 100;
261 return 0;
262}
263
264static int snd_pmac_burgundy_get_volume_2b(struct snd_kcontrol *kcontrol,
265 struct snd_ctl_elem_value *ucontrol)
266{
267 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
268 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
269 int off = kcontrol->private_value & 0x300;
270 snd_pmac_burgundy_read_volume_2b(chip, addr,
271 ucontrol->value.integer.value, off);
272 return 0;
273}
274
275static int snd_pmac_burgundy_put_volume_2b(struct snd_kcontrol *kcontrol,
276 struct snd_ctl_elem_value *ucontrol)
277{
278 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
279 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
280 int off = kcontrol->private_value & 0x300;
281 long nvoices[2];
282
283 snd_pmac_burgundy_write_volume_2b(chip, addr,
284 ucontrol->value.integer.value, off);
285 snd_pmac_burgundy_read_volume_2b(chip, addr, nvoices, off);
286 return (nvoices[0] != ucontrol->value.integer.value[0] ||
287 nvoices[1] != ucontrol->value.integer.value[1]);
288}
289
290#define BURGUNDY_VOLUME_2B(xname, xindex, addr, off) \
291{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
292 .info = snd_pmac_burgundy_info_volume_2b,\
293 .get = snd_pmac_burgundy_get_volume_2b,\
294 .put = snd_pmac_burgundy_put_volume_2b,\
295 .private_value = ((ADDR2BASE(addr) & 0xff) | ((off) << 8)) }
296
297/*
298 * Burgundy gain/attenuation: 0 - 15, mono/stereo, byte reg
299 */
300static int snd_pmac_burgundy_info_gain(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_info *uinfo)
302{
303 int stereo = (kcontrol->private_value >> 24) & 1;
304 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
305 uinfo->count = stereo + 1;
306 uinfo->value.integer.min = 0;
307 uinfo->value.integer.max = 15;
308 return 0;
309}
222 310
223static int snd_pmac_burgundy_info_switch_out(struct snd_kcontrol *kcontrol, 311static int snd_pmac_burgundy_get_gain(struct snd_kcontrol *kcontrol,
224 struct snd_ctl_elem_info *uinfo) 312 struct snd_ctl_elem_value *ucontrol)
313{
314 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
315 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
316 int stereo = (kcontrol->private_value >> 24) & 1;
317 int atten = (kcontrol->private_value >> 25) & 1;
318 int oval;
319
320 oval = snd_pmac_burgundy_rcb(chip, addr);
321 if (atten)
322 oval = ~oval & 0xff;
323 ucontrol->value.integer.value[0] = oval & 0xf;
324 if (stereo)
325 ucontrol->value.integer.value[1] = (oval >> 4) & 0xf;
326 return 0;
327}
328
329static int snd_pmac_burgundy_put_gain(struct snd_kcontrol *kcontrol,
330 struct snd_ctl_elem_value *ucontrol)
331{
332 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
333 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
334 int stereo = (kcontrol->private_value >> 24) & 1;
335 int atten = (kcontrol->private_value >> 25) & 1;
336 int oval, val;
337
338 oval = snd_pmac_burgundy_rcb(chip, addr);
339 if (atten)
340 oval = ~oval & 0xff;
341 val = ucontrol->value.integer.value[0];
342 if (stereo)
343 val |= ucontrol->value.integer.value[1] << 4;
344 else
345 val |= ucontrol->value.integer.value[0] << 4;
346 if (atten)
347 val = ~val & 0xff;
348 snd_pmac_burgundy_wcb(chip, addr, val);
349 return val != oval;
350}
351
352#define BURGUNDY_VOLUME_B(xname, xindex, addr, stereo, atten) \
353{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
354 .info = snd_pmac_burgundy_info_gain,\
355 .get = snd_pmac_burgundy_get_gain,\
356 .put = snd_pmac_burgundy_put_gain,\
357 .private_value = (ADDR2BASE(addr) | ((stereo) << 24) | ((atten) << 25)) }
358
359/*
360 * Burgundy switch: 0/1, mono/stereo, word reg
361 */
362static int snd_pmac_burgundy_info_switch_w(struct snd_kcontrol *kcontrol,
363 struct snd_ctl_elem_info *uinfo)
225{ 364{
226 int stereo = (kcontrol->private_value >> 24) & 1; 365 int stereo = (kcontrol->private_value >> 24) & 1;
227 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 366 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
@@ -231,111 +370,207 @@ static int snd_pmac_burgundy_info_switch_out(struct snd_kcontrol *kcontrol,
231 return 0; 370 return 0;
232} 371}
233 372
234static int snd_pmac_burgundy_get_switch_out(struct snd_kcontrol *kcontrol, 373static int snd_pmac_burgundy_get_switch_w(struct snd_kcontrol *kcontrol,
235 struct snd_ctl_elem_value *ucontrol) 374 struct snd_ctl_elem_value *ucontrol)
236{ 375{
237 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 376 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
238 int lmask = kcontrol->private_value & 0xff; 377 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
239 int rmask = (kcontrol->private_value >> 8) & 0xff; 378 int lmask = 1 << (kcontrol->private_value & 0xff);
379 int rmask = 1 << ((kcontrol->private_value >> 8) & 0xff);
240 int stereo = (kcontrol->private_value >> 24) & 1; 380 int stereo = (kcontrol->private_value >> 24) & 1;
241 int val = snd_pmac_burgundy_rcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); 381 int val = snd_pmac_burgundy_rcw(chip, addr);
242 ucontrol->value.integer.value[0] = (val & lmask) ? 1 : 0; 382 ucontrol->value.integer.value[0] = (val & lmask) ? 1 : 0;
243 if (stereo) 383 if (stereo)
244 ucontrol->value.integer.value[1] = (val & rmask) ? 1 : 0; 384 ucontrol->value.integer.value[1] = (val & rmask) ? 1 : 0;
245 return 0; 385 return 0;
246} 386}
247 387
248static int snd_pmac_burgundy_put_switch_out(struct snd_kcontrol *kcontrol, 388static int snd_pmac_burgundy_put_switch_w(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol) 389 struct snd_ctl_elem_value *ucontrol)
250{ 390{
251 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 391 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
252 int lmask = kcontrol->private_value & 0xff; 392 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
253 int rmask = (kcontrol->private_value >> 8) & 0xff; 393 int lmask = 1 << (kcontrol->private_value & 0xff);
394 int rmask = 1 << ((kcontrol->private_value >> 8) & 0xff);
254 int stereo = (kcontrol->private_value >> 24) & 1; 395 int stereo = (kcontrol->private_value >> 24) & 1;
255 int val, oval; 396 int val, oval;
256 oval = snd_pmac_burgundy_rcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); 397 oval = snd_pmac_burgundy_rcw(chip, addr);
257 val = oval & ~(lmask | rmask); 398 val = oval & ~(lmask | (stereo ? rmask : 0));
258 if (ucontrol->value.integer.value[0]) 399 if (ucontrol->value.integer.value[0])
259 val |= lmask; 400 val |= lmask;
260 if (stereo && ucontrol->value.integer.value[1]) 401 if (stereo && ucontrol->value.integer.value[1])
261 val |= rmask; 402 val |= rmask;
262 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, val); 403 snd_pmac_burgundy_wcw(chip, addr, val);
263 return val != oval; 404 return val != oval;
264} 405}
265 406
266#define BURGUNDY_OUTPUT_SWITCH(xname, xindex, lmask, rmask, stereo) \ 407#define BURGUNDY_SWITCH_W(xname, xindex, addr, lbit, rbit, stereo) \
267{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ 408{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
268 .info = snd_pmac_burgundy_info_switch_out,\ 409 .info = snd_pmac_burgundy_info_switch_w,\
269 .get = snd_pmac_burgundy_get_switch_out,\ 410 .get = snd_pmac_burgundy_get_switch_w,\
270 .put = snd_pmac_burgundy_put_switch_out,\ 411 .put = snd_pmac_burgundy_put_switch_w,\
271 .private_value = ((lmask) | ((rmask) << 8) | ((stereo) << 24)) } 412 .private_value = ((lbit) | ((rbit) << 8)\
272 413 | (ADDR2BASE(addr) << 16) | ((stereo) << 24)) }
273/* line/speaker output volume */ 414
274static int snd_pmac_burgundy_info_volume_out(struct snd_kcontrol *kcontrol, 415/*
275 struct snd_ctl_elem_info *uinfo) 416 * Burgundy switch: 0/1, mono/stereo, byte reg, bit mask
417 */
418static int snd_pmac_burgundy_info_switch_b(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_info *uinfo)
276{ 420{
277 int stereo = (kcontrol->private_value >> 24) & 1; 421 int stereo = (kcontrol->private_value >> 24) & 1;
278 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 422 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
279 uinfo->count = stereo + 1; 423 uinfo->count = stereo + 1;
280 uinfo->value.integer.min = 0; 424 uinfo->value.integer.min = 0;
281 uinfo->value.integer.max = 15; 425 uinfo->value.integer.max = 1;
282 return 0; 426 return 0;
283} 427}
284 428
285static int snd_pmac_burgundy_get_volume_out(struct snd_kcontrol *kcontrol, 429static int snd_pmac_burgundy_get_switch_b(struct snd_kcontrol *kcontrol,
286 struct snd_ctl_elem_value *ucontrol) 430 struct snd_ctl_elem_value *ucontrol)
287{ 431{
288 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 432 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
289 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); 433 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
434 int lmask = kcontrol->private_value & 0xff;
435 int rmask = (kcontrol->private_value >> 8) & 0xff;
290 int stereo = (kcontrol->private_value >> 24) & 1; 436 int stereo = (kcontrol->private_value >> 24) & 1;
291 int oval; 437 int val = snd_pmac_burgundy_rcb(chip, addr);
292 438 ucontrol->value.integer.value[0] = (val & lmask) ? 1 : 0;
293 oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff;
294 ucontrol->value.integer.value[0] = oval & 0xf;
295 if (stereo) 439 if (stereo)
296 ucontrol->value.integer.value[1] = (oval >> 4) & 0xf; 440 ucontrol->value.integer.value[1] = (val & rmask) ? 1 : 0;
297 return 0; 441 return 0;
298} 442}
299 443
300static int snd_pmac_burgundy_put_volume_out(struct snd_kcontrol *kcontrol, 444static int snd_pmac_burgundy_put_switch_b(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_value *ucontrol) 445 struct snd_ctl_elem_value *ucontrol)
302{ 446{
303 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 447 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
304 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); 448 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
449 int lmask = kcontrol->private_value & 0xff;
450 int rmask = (kcontrol->private_value >> 8) & 0xff;
305 int stereo = (kcontrol->private_value >> 24) & 1; 451 int stereo = (kcontrol->private_value >> 24) & 1;
306 unsigned int oval, val; 452 int val, oval;
307 453 oval = snd_pmac_burgundy_rcb(chip, addr);
308 oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff; 454 val = oval & ~(lmask | rmask);
309 val = ucontrol->value.integer.value[0] & 15; 455 if (ucontrol->value.integer.value[0])
310 if (stereo) 456 val |= lmask;
311 val |= (ucontrol->value.integer.value[1] & 15) << 4; 457 if (stereo && ucontrol->value.integer.value[1])
312 else 458 val |= rmask;
313 val |= val << 4;
314 val = ~val & 0xff;
315 snd_pmac_burgundy_wcb(chip, addr, val); 459 snd_pmac_burgundy_wcb(chip, addr, val);
316 return val != oval; 460 return val != oval;
317} 461}
318 462
319#define BURGUNDY_OUTPUT_VOLUME(xname, xindex, addr, stereo) \ 463#define BURGUNDY_SWITCH_B(xname, xindex, addr, lmask, rmask, stereo) \
320{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ 464{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
321 .info = snd_pmac_burgundy_info_volume_out,\ 465 .info = snd_pmac_burgundy_info_switch_b,\
322 .get = snd_pmac_burgundy_get_volume_out,\ 466 .get = snd_pmac_burgundy_get_switch_b,\
323 .put = snd_pmac_burgundy_put_volume_out,\ 467 .put = snd_pmac_burgundy_put_switch_b,\
324 .private_value = (ADDR2BASE(addr) | ((stereo) << 24)) } 468 .private_value = ((lmask) | ((rmask) << 8)\
469 | (ADDR2BASE(addr) << 16) | ((stereo) << 24)) }
325 470
471/*
472 * Burgundy mixers
473 */
326static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = { 474static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = {
327 BURGUNDY_VOLUME("Master Playback Volume", 0, MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8), 475 BURGUNDY_VOLUME_W("Master Playback Volume", 0,
328 BURGUNDY_VOLUME("Line Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLLINE, 16), 476 MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8),
329 BURGUNDY_VOLUME("CD Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLCD, 16), 477 BURGUNDY_VOLUME_W("CD Capture Volume", 0,
330 BURGUNDY_VOLUME("Mic Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLMIC, 16), 478 MASK_ADDR_BURGUNDY_VOLCD, 16),
331 BURGUNDY_OUTPUT_VOLUME("PC Speaker Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENHP, 0), 479 BURGUNDY_VOLUME_2B("Input Capture Volume", 0,
332 /*BURGUNDY_OUTPUT_VOLUME("PCM Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1),*/ 480 MASK_ADDR_BURGUNDY_VOLMIX01, 2),
333 BURGUNDY_OUTPUT_VOLUME("Headphone Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1), 481 BURGUNDY_VOLUME_2B("Mixer Playback Volume", 0,
334}; 482 MASK_ADDR_BURGUNDY_VOLMIX23, 0),
335static struct snd_kcontrol_new snd_pmac_burgundy_master_sw __initdata = 483 BURGUNDY_VOLUME_B("CD Gain Capture Volume", 0,
336BURGUNDY_OUTPUT_SWITCH("Headphone Playback Switch", 0, BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); 484 MASK_ADDR_BURGUNDY_GAINCD, 1, 0),
337static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw __initdata = 485 BURGUNDY_SWITCH_W("Master Capture Switch", 0,
338BURGUNDY_OUTPUT_SWITCH("PC Speaker Playback Switch", 0, BURGUNDY_OUTPUT_INTERN, 0, 0); 486 MASK_ADDR_BURGUNDY_OUTPUTENABLES, 24, 0, 0),
487 BURGUNDY_SWITCH_W("CD Capture Switch", 0,
488 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 0, 16, 1),
489 BURGUNDY_SWITCH_W("CD Playback Switch", 0,
490 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 0, 16, 1),
491/* BURGUNDY_SWITCH_W("Loop Capture Switch", 0,
492 * MASK_ADDR_BURGUNDY_CAPTURESELECTS, 8, 24, 1),
493 * BURGUNDY_SWITCH_B("Mixer out Capture Switch", 0,
494 * MASK_ADDR_BURGUNDY_HOSTIFAD, 0x02, 0, 0),
495 * BURGUNDY_SWITCH_B("Mixer Capture Switch", 0,
496 * MASK_ADDR_BURGUNDY_HOSTIFAD, 0x01, 0, 0),
497 * BURGUNDY_SWITCH_B("PCM out Capture Switch", 0,
498 * MASK_ADDR_BURGUNDY_HOSTIFEH, 0x02, 0, 0),
499 */ BURGUNDY_SWITCH_B("PCM Capture Switch", 0,
500 MASK_ADDR_BURGUNDY_HOSTIFEH, 0x01, 0, 0)
501};
502static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __initdata = {
503 BURGUNDY_VOLUME_W("Line in Capture Volume", 0,
504 MASK_ADDR_BURGUNDY_VOLLINE, 16),
505 BURGUNDY_VOLUME_W("Mic Capture Volume", 0,
506 MASK_ADDR_BURGUNDY_VOLMIC, 16),
507 BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0,
508 MASK_ADDR_BURGUNDY_GAINLINE, 1, 0),
509 BURGUNDY_VOLUME_B("Mic Gain Capture Volume", 0,
510 MASK_ADDR_BURGUNDY_GAINMIC, 1, 0),
511 BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0,
512 MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1),
513 BURGUNDY_VOLUME_B("Line out Playback Volume", 0,
514 MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1, 1),
515 BURGUNDY_VOLUME_B("Headphone Playback Volume", 0,
516 MASK_ADDR_BURGUNDY_ATTENHP, 1, 1),
517 BURGUNDY_SWITCH_W("Line in Capture Switch", 0,
518 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 1, 17, 1),
519 BURGUNDY_SWITCH_W("Mic Capture Switch", 0,
520 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 2, 18, 1),
521 BURGUNDY_SWITCH_W("Line in Playback Switch", 0,
522 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 1, 17, 1),
523 BURGUNDY_SWITCH_W("Mic Playback Switch", 0,
524 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 2, 18, 1),
525 BURGUNDY_SWITCH_B("Mic Boost Capture Switch", 0,
526 MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1)
527};
528static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __initdata = {
529 BURGUNDY_VOLUME_W("Line in Capture Volume", 0,
530 MASK_ADDR_BURGUNDY_VOLMIC, 16),
531 BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0,
532 MASK_ADDR_BURGUNDY_GAINMIC, 1, 0),
533 BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0,
534 MASK_ADDR_BURGUNDY_ATTENMONO, 0, 1),
535 BURGUNDY_VOLUME_B("Line out Playback Volume", 0,
536 MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1),
537 BURGUNDY_SWITCH_W("Line in Capture Switch", 0,
538 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 2, 18, 1),
539 BURGUNDY_SWITCH_W("Line in Playback Switch", 0,
540 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 2, 18, 1),
541/* BURGUNDY_SWITCH_B("Line in Boost Capture Switch", 0,
542 * MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) */
543};
544static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac __initdata =
545BURGUNDY_SWITCH_B("Master Playback Switch", 0,
546 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
547 BURGUNDY_OUTPUT_LEFT | BURGUNDY_LINEOUT_LEFT | BURGUNDY_HP_LEFT,
548 BURGUNDY_OUTPUT_RIGHT | BURGUNDY_LINEOUT_RIGHT | BURGUNDY_HP_RIGHT, 1);
549static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac __initdata =
550BURGUNDY_SWITCH_B("Master Playback Switch", 0,
551 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
552 BURGUNDY_OUTPUT_INTERN
553 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
554static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __initdata =
555BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0,
556 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
557 BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
558static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __initdata =
559BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0,
560 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
561 BURGUNDY_OUTPUT_INTERN, 0, 0);
562static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __initdata =
563BURGUNDY_SWITCH_B("Line out Playback Switch", 0,
564 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
565 BURGUNDY_LINEOUT_LEFT, BURGUNDY_LINEOUT_RIGHT, 1);
566static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac __initdata =
567BURGUNDY_SWITCH_B("Line out Playback Switch", 0,
568 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
569 BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
570static struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac __initdata =
571BURGUNDY_SWITCH_B("Headphone Playback Switch", 0,
572 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
573 BURGUNDY_HP_LEFT, BURGUNDY_HP_RIGHT, 1);
339 574
340 575
341#ifdef PMAC_SUPPORT_AUTOMUTE 576#ifdef PMAC_SUPPORT_AUTOMUTE
@@ -350,16 +585,26 @@ static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip)
350static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) 585static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify)
351{ 586{
352 if (chip->auto_mute) { 587 if (chip->auto_mute) {
588 int imac = machine_is_compatible("iMac");
353 int reg, oreg; 589 int reg, oreg;
354 reg = oreg = snd_pmac_burgundy_rcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); 590 reg = oreg = snd_pmac_burgundy_rcb(chip,
355 reg &= ~(BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT | BURGUNDY_OUTPUT_INTERN); 591 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES);
592 reg &= imac ? ~(BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT
593 | BURGUNDY_HP_LEFT | BURGUNDY_HP_RIGHT)
594 : ~(BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT
595 | BURGUNDY_OUTPUT_INTERN);
356 if (snd_pmac_burgundy_detect_headphone(chip)) 596 if (snd_pmac_burgundy_detect_headphone(chip))
357 reg |= BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT; 597 reg |= imac ? (BURGUNDY_HP_LEFT | BURGUNDY_HP_RIGHT)
598 : (BURGUNDY_OUTPUT_LEFT
599 | BURGUNDY_OUTPUT_RIGHT);
358 else 600 else
359 reg |= BURGUNDY_OUTPUT_INTERN; 601 reg |= imac ? (BURGUNDY_OUTPUT_LEFT
602 | BURGUNDY_OUTPUT_RIGHT)
603 : (BURGUNDY_OUTPUT_INTERN);
360 if (do_notify && reg == oreg) 604 if (do_notify && reg == oreg)
361 return; 605 return;
362 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, reg); 606 snd_pmac_burgundy_wcb(chip,
607 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, reg);
363 if (do_notify) { 608 if (do_notify) {
364 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 609 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
365 &chip->master_sw_ctl->id); 610 &chip->master_sw_ctl->id);
@@ -378,6 +623,7 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti
378 */ 623 */
379int __init snd_pmac_burgundy_init(struct snd_pmac *chip) 624int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
380{ 625{
626 int imac = machine_is_compatible("iMac");
381 int i, err; 627 int i, err;
382 628
383 /* Checks to see the chip is alive and kicking */ 629 /* Checks to see the chip is alive and kicking */
@@ -386,7 +632,7 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
386 return 1; 632 return 1;
387 } 633 }
388 634
389 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_OUTPUTENABLES, 635 snd_pmac_burgundy_wcw(chip, MASK_ADDR_BURGUNDY_OUTPUTENABLES,
390 DEF_BURGUNDY_OUTPUTENABLES); 636 DEF_BURGUNDY_OUTPUTENABLES);
391 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 637 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
392 DEF_BURGUNDY_MORE_OUTPUTENABLES); 638 DEF_BURGUNDY_MORE_OUTPUTENABLES);
@@ -396,7 +642,8 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
396 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL21, 642 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL21,
397 DEF_BURGUNDY_INPSEL21); 643 DEF_BURGUNDY_INPSEL21);
398 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL3, 644 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL3,
399 DEF_BURGUNDY_INPSEL3); 645 imac ? DEF_BURGUNDY_INPSEL3_IMAC
646 : DEF_BURGUNDY_INPSEL3_PMAC);
400 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINCD, 647 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINCD,
401 DEF_BURGUNDY_GAINCD); 648 DEF_BURGUNDY_GAINCD);
402 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINLINE, 649 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINLINE,
@@ -422,23 +669,55 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
422 snd_pmac_burgundy_wcw(chip, MASK_ADDR_BURGUNDY_VOLMIC, 669 snd_pmac_burgundy_wcw(chip, MASK_ADDR_BURGUNDY_VOLMIC,
423 DEF_BURGUNDY_VOLMIC); 670 DEF_BURGUNDY_VOLMIC);
424 671
425 if (chip->hp_stat_mask == 0) 672 if (chip->hp_stat_mask == 0) {
426 /* set headphone-jack detection bit */ 673 /* set headphone-jack detection bit */
427 chip->hp_stat_mask = 0x04; 674 if (imac)
428 675 chip->hp_stat_mask = BURGUNDY_HPDETECT_IMAC_UPPER
676 | BURGUNDY_HPDETECT_IMAC_LOWER
677 | BURGUNDY_HPDETECT_IMAC_SIDE;
678 else
679 chip->hp_stat_mask = BURGUNDY_HPDETECT_PMAC_BACK;
680 }
429 /* 681 /*
430 * build burgundy mixers 682 * build burgundy mixers
431 */ 683 */
432 strcpy(chip->card->mixername, "PowerMac Burgundy"); 684 strcpy(chip->card->mixername, "PowerMac Burgundy");
433 685
434 for (i = 0; i < ARRAY_SIZE(snd_pmac_burgundy_mixers); i++) { 686 for (i = 0; i < ARRAY_SIZE(snd_pmac_burgundy_mixers); i++) {
435 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_pmac_burgundy_mixers[i], chip))) < 0) 687 err = snd_ctl_add(chip->card,
688 snd_ctl_new1(&snd_pmac_burgundy_mixers[i], chip));
689 if (err < 0)
690 return err;
691 }
692 for (i = 0; i < (imac ? ARRAY_SIZE(snd_pmac_burgundy_mixers_imac)
693 : ARRAY_SIZE(snd_pmac_burgundy_mixers_pmac)); i++) {
694 err = snd_ctl_add(chip->card,
695 snd_ctl_new1(imac ? &snd_pmac_burgundy_mixers_imac[i]
696 : &snd_pmac_burgundy_mixers_pmac[i], chip));
697 if (err < 0)
436 return err; 698 return err;
437 } 699 }
438 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_burgundy_master_sw, chip); 700 chip->master_sw_ctl = snd_ctl_new1(imac
701 ? &snd_pmac_burgundy_master_sw_imac
702 : &snd_pmac_burgundy_master_sw_pmac, chip);
439 if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0) 703 if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0)
440 return err; 704 return err;
441 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_burgundy_speaker_sw, chip); 705 chip->master_sw_ctl = snd_ctl_new1(imac
706 ? &snd_pmac_burgundy_line_sw_imac
707 : &snd_pmac_burgundy_line_sw_pmac, chip);
708 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
709 if (err < 0)
710 return err;
711 if (imac) {
712 chip->master_sw_ctl = snd_ctl_new1(
713 &snd_pmac_burgundy_hp_sw_imac, chip);
714 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
715 if (err < 0)
716 return err;
717 }
718 chip->speaker_sw_ctl = snd_ctl_new1(imac
719 ? &snd_pmac_burgundy_speaker_sw_imac
720 : &snd_pmac_burgundy_speaker_sw_pmac, chip);
442 if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0) 721 if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0)
443 return err; 722 return err;
444#ifdef PMAC_SUPPORT_AUTOMUTE 723#ifdef PMAC_SUPPORT_AUTOMUTE
diff --git a/sound/ppc/burgundy.h b/sound/ppc/burgundy.h
index ebb457a8342c..7a7f9cf3d299 100644
--- a/sound/ppc/burgundy.h
+++ b/sound/ppc/burgundy.h
@@ -22,6 +22,7 @@
22#ifndef __BURGUNDY_H 22#ifndef __BURGUNDY_H
23#define __BURGUNDY_H 23#define __BURGUNDY_H
24 24
25#define MASK_ADDR_BURGUNDY_INPBOOST (0x10 << 12)
25#define MASK_ADDR_BURGUNDY_INPSEL21 (0x11 << 12) 26#define MASK_ADDR_BURGUNDY_INPSEL21 (0x11 << 12)
26#define MASK_ADDR_BURGUNDY_INPSEL3 (0x12 << 12) 27#define MASK_ADDR_BURGUNDY_INPSEL3 (0x12 << 12)
27 28
@@ -35,7 +36,10 @@
35#define MASK_ADDR_BURGUNDY_VOLCH3 (0x22 << 12) 36#define MASK_ADDR_BURGUNDY_VOLCH3 (0x22 << 12)
36#define MASK_ADDR_BURGUNDY_VOLCH4 (0x23 << 12) 37#define MASK_ADDR_BURGUNDY_VOLCH4 (0x23 << 12)
37 38
39#define MASK_ADDR_BURGUNDY_CAPTURESELECTS (0x2A << 12)
38#define MASK_ADDR_BURGUNDY_OUTPUTSELECTS (0x2B << 12) 40#define MASK_ADDR_BURGUNDY_OUTPUTSELECTS (0x2B << 12)
41#define MASK_ADDR_BURGUNDY_VOLMIX01 (0x2D << 12)
42#define MASK_ADDR_BURGUNDY_VOLMIX23 (0x2E << 12)
39#define MASK_ADDR_BURGUNDY_OUTPUTENABLES (0x2F << 12) 43#define MASK_ADDR_BURGUNDY_OUTPUTENABLES (0x2F << 12)
40 44
41#define MASK_ADDR_BURGUNDY_MASTER_VOLUME (0x30 << 12) 45#define MASK_ADDR_BURGUNDY_MASTER_VOLUME (0x30 << 12)
@@ -45,6 +49,10 @@
45#define MASK_ADDR_BURGUNDY_ATTENSPEAKER (0x62 << 12) 49#define MASK_ADDR_BURGUNDY_ATTENSPEAKER (0x62 << 12)
46#define MASK_ADDR_BURGUNDY_ATTENLINEOUT (0x63 << 12) 50#define MASK_ADDR_BURGUNDY_ATTENLINEOUT (0x63 << 12)
47#define MASK_ADDR_BURGUNDY_ATTENHP (0x64 << 12) 51#define MASK_ADDR_BURGUNDY_ATTENHP (0x64 << 12)
52#define MASK_ADDR_BURGUNDY_ATTENMONO (0x65 << 12)
53
54#define MASK_ADDR_BURGUNDY_HOSTIFAD (0x78 << 12)
55#define MASK_ADDR_BURGUNDY_HOSTIFEH (0x79 << 12)
48 56
49#define MASK_ADDR_BURGUNDY_VOLCD (MASK_ADDR_BURGUNDY_VOLCH1) 57#define MASK_ADDR_BURGUNDY_VOLCD (MASK_ADDR_BURGUNDY_VOLCH1)
50#define MASK_ADDR_BURGUNDY_VOLLINE (MASK_ADDR_BURGUNDY_VOLCH2) 58#define MASK_ADDR_BURGUNDY_VOLLINE (MASK_ADDR_BURGUNDY_VOLCH2)
@@ -59,21 +67,22 @@
59 67
60/* These are all default values for the burgundy */ 68/* These are all default values for the burgundy */
61#define DEF_BURGUNDY_INPSEL21 (0xAA) 69#define DEF_BURGUNDY_INPSEL21 (0xAA)
62#define DEF_BURGUNDY_INPSEL3 (0x0A) 70#define DEF_BURGUNDY_INPSEL3_IMAC (0x0A)
71#define DEF_BURGUNDY_INPSEL3_PMAC (0x05)
63 72
64#define DEF_BURGUNDY_GAINCD (0x33) 73#define DEF_BURGUNDY_GAINCD (0x33)
65#define DEF_BURGUNDY_GAINLINE (0x44) 74#define DEF_BURGUNDY_GAINLINE (0x44)
66#define DEF_BURGUNDY_GAINMIC (0x44) 75#define DEF_BURGUNDY_GAINMIC (0x44)
67#define DEF_BURGUNDY_GAINMODEM (0x06) 76#define DEF_BURGUNDY_GAINMODEM (0x06)
68 77
69/* Remember: lowest volume here is 0x9b */ 78/* Remember: lowest volume here is 0x9B (155) */
70#define DEF_BURGUNDY_VOLCD (0xCCCCCCCC) 79#define DEF_BURGUNDY_VOLCD (0xCCCCCCCC)
71#define DEF_BURGUNDY_VOLLINE (0x00000000) 80#define DEF_BURGUNDY_VOLLINE (0x00000000)
72#define DEF_BURGUNDY_VOLMIC (0x00000000) 81#define DEF_BURGUNDY_VOLMIC (0x00000000)
73#define DEF_BURGUNDY_VOLMODEM (0xCCCCCCCC) 82#define DEF_BURGUNDY_VOLMODEM (0xCCCCCCCC)
74 83
75#define DEF_BURGUNDY_OUTPUTSELECTS (0x010f010f) 84#define DEF_BURGUNDY_OUTPUTSELECTS (0x010F010F)
76#define DEF_BURGUNDY_OUTPUTENABLES (0x0A) 85#define DEF_BURGUNDY_OUTPUTENABLES (0x0100000A)
77 86
78/* #define DEF_BURGUNDY_MASTER_VOLUME (0xFFFFFFFF) */ /* too loud */ 87/* #define DEF_BURGUNDY_MASTER_VOLUME (0xFFFFFFFF) */ /* too loud */
79#define DEF_BURGUNDY_MASTER_VOLUME (0xDDDDDDDD) 88#define DEF_BURGUNDY_MASTER_VOLUME (0xDDDDDDDD)
@@ -84,12 +93,22 @@
84#define DEF_BURGUNDY_ATTENLINEOUT (0xCC) 93#define DEF_BURGUNDY_ATTENLINEOUT (0xCC)
85#define DEF_BURGUNDY_ATTENHP (0xCC) 94#define DEF_BURGUNDY_ATTENHP (0xCC)
86 95
87/* OUTPUTENABLES bits */ 96/* MORE_OUTPUTENABLES bits */
88#define BURGUNDY_OUTPUT_LEFT 0x02 97#define BURGUNDY_OUTPUT_LEFT 0x02
89#define BURGUNDY_OUTPUT_RIGHT 0x04 98#define BURGUNDY_OUTPUT_RIGHT 0x04
99#define BURGUNDY_LINEOUT_LEFT 0x08
100#define BURGUNDY_LINEOUT_RIGHT 0x10
101#define BURGUNDY_HP_LEFT 0x20
102#define BURGUNDY_HP_RIGHT 0x40
90#define BURGUNDY_OUTPUT_INTERN 0x80 103#define BURGUNDY_OUTPUT_INTERN 0x80
91 104
92/* volume offset */ 105/* Headphone detection bits */
106#define BURGUNDY_HPDETECT_PMAC_BACK 0x04
107#define BURGUNDY_HPDETECT_IMAC_SIDE 0x04
108#define BURGUNDY_HPDETECT_IMAC_UPPER 0x08
109#define BURGUNDY_HPDETECT_IMAC_LOWER 0x01
110
111/* Volume offset */
93#define BURGUNDY_VOLUME_OFFSET 155 112#define BURGUNDY_VOLUME_OFFSET 155
94 113
95#endif /* __BURGUNDY_H */ 114#endif /* __BURGUNDY_H */