1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 3 * PMac Burgundy lowlevel functions 4 * 5 * Copyright (c) by Takashi Iwai <tiwai@suse.d 6 * code based on dmasound.c. 7 */ 8 9 #include <linux/io.h> 10 #include <linux/init.h> 11 #include <linux/delay.h> 12 #include <linux/of.h> 13 #include <sound/core.h> 14 #include "pmac.h" 15 #include "burgundy.h" 16 17 18 /* Waits for busy flag to clear */ 19 static inline void 20 snd_pmac_burgundy_busy_wait(struct snd_pmac *c 21 { 22 int timeout = 50; 23 while ((in_le32(&chip->awacs->codec_ct 24 udelay(1); 25 if (timeout < 0) 26 printk(KERN_DEBUG "burgundy_bu 27 } 28 29 static inline void 30 snd_pmac_burgundy_extend_wait(struct snd_pmac 31 { 32 int timeout; 33 timeout = 50; 34 while (!(in_le32(&chip->awacs->codec_s 35 udelay(1); 36 if (timeout < 0) 37 printk(KERN_DEBUG "burgundy_ex 38 timeout = 50; 39 while ((in_le32(&chip->awacs->codec_st 40 udelay(1); 41 if (timeout < 0) 42 printk(KERN_DEBUG "burgundy_ex 43 } 44 45 static void 46 snd_pmac_burgundy_wcw(struct snd_pmac *chip, u 47 { 48 out_le32(&chip->awacs->codec_ctrl, add 49 snd_pmac_burgundy_busy_wait(chip); 50 out_le32(&chip->awacs->codec_ctrl, add 51 snd_pmac_burgundy_busy_wait(chip); 52 out_le32(&chip->awacs->codec_ctrl, add 53 snd_pmac_burgundy_busy_wait(chip); 54 out_le32(&chip->awacs->codec_ctrl, add 55 snd_pmac_burgundy_busy_wait(chip); 56 } 57 58 static unsigned 59 snd_pmac_burgundy_rcw(struct snd_pmac *chip, u 60 { 61 unsigned val = 0; 62 unsigned long flags; 63 64 spin_lock_irqsave(&chip->reg_lock, fla 65 66 out_le32(&chip->awacs->codec_ctrl, add 67 snd_pmac_burgundy_busy_wait(chip); 68 snd_pmac_burgundy_extend_wait(chip); 69 val += (in_le32(&chip->awacs->codec_st 70 71 out_le32(&chip->awacs->codec_ctrl, add 72 snd_pmac_burgundy_busy_wait(chip); 73 snd_pmac_burgundy_extend_wait(chip); 74 val += ((in_le32(&chip->awacs->codec_s 75 76 out_le32(&chip->awacs->codec_ctrl, add 77 snd_pmac_burgundy_busy_wait(chip); 78 snd_pmac_burgundy_extend_wait(chip); 79 val += ((in_le32(&chip->awacs->codec_s 80 81 out_le32(&chip->awacs->codec_ctrl, add 82 snd_pmac_burgundy_busy_wait(chip); 83 snd_pmac_burgundy_extend_wait(chip); 84 val += ((in_le32(&chip->awacs->codec_s 85 86 spin_unlock_irqrestore(&chip->reg_lock 87 88 return val; 89 } 90 91 static void 92 snd_pmac_burgundy_wcb(struct snd_pmac *chip, u 93 unsigned int val) 94 { 95 out_le32(&chip->awacs->codec_ctrl, add 96 snd_pmac_burgundy_busy_wait(chip); 97 } 98 99 static unsigned 100 snd_pmac_burgundy_rcb(struct snd_pmac *chip, u 101 { 102 unsigned val = 0; 103 unsigned long flags; 104 105 spin_lock_irqsave(&chip->reg_lock, fla 106 107 out_le32(&chip->awacs->codec_ctrl, add 108 snd_pmac_burgundy_busy_wait(chip); 109 snd_pmac_burgundy_extend_wait(chip); 110 val += (in_le32(&chip->awacs->codec_st 111 112 spin_unlock_irqrestore(&chip->reg_lock 113 114 return val; 115 } 116 117 #define BASE2ADDR(base) ((base) << 12) 118 #define ADDR2BASE(addr) ((addr) >> 12) 119 120 /* 121 * Burgundy volume: 0 - 100, stereo, word reg 122 */ 123 static void 124 snd_pmac_burgundy_write_volume(struct snd_pmac 125 long *volume, i 126 { 127 int hardvolume, lvolume, rvolume; 128 129 if (volume[0] < 0 || volume[0] > 100 | 130 volume[1] < 0 || volume[1] > 100) 131 return; /* -EINVAL */ 132 lvolume = volume[0] ? volume[0] + BURG 133 rvolume = volume[1] ? volume[1] + BURG 134 135 hardvolume = lvolume + (rvolume << shi 136 if (shift == 8) 137 hardvolume |= hardvolume << 16 138 139 snd_pmac_burgundy_wcw(chip, address, h 140 } 141 142 static void 143 snd_pmac_burgundy_read_volume(struct snd_pmac 144 long *volume, in 145 { 146 int wvolume; 147 148 wvolume = snd_pmac_burgundy_rcw(chip, 149 150 volume[0] = wvolume & 0xff; 151 if (volume[0] >= BURGUNDY_VOLUME_OFFSE 152 volume[0] -= BURGUNDY_VOLUME_O 153 else 154 volume[0] = 0; 155 volume[1] = (wvolume >> shift) & 0xff; 156 if (volume[1] >= BURGUNDY_VOLUME_OFFSE 157 volume[1] -= BURGUNDY_VOLUME_O 158 else 159 volume[1] = 0; 160 } 161 162 static int snd_pmac_burgundy_info_volume(struc 163 struc 164 { 165 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTE 166 uinfo->count = 2; 167 uinfo->value.integer.min = 0; 168 uinfo->value.integer.max = 100; 169 return 0; 170 } 171 172 static int snd_pmac_burgundy_get_volume(struct 173 struct 174 { 175 struct snd_pmac *chip = snd_kcontrol_c 176 unsigned int addr = BASE2ADDR(kcontrol 177 int shift = (kcontrol->private_value > 178 snd_pmac_burgundy_read_volume(chip, ad 179 ucontrol 180 return 0; 181 } 182 183 static int snd_pmac_burgundy_put_volume(struct 184 struct 185 { 186 struct snd_pmac *chip = snd_kcontrol_c 187 unsigned int addr = BASE2ADDR(kcontrol 188 int shift = (kcontrol->private_value > 189 long nvoices[2]; 190 191 snd_pmac_burgundy_write_volume(chip, a 192 ucontro 193 snd_pmac_burgundy_read_volume(chip, ad 194 return (nvoices[0] != ucontrol->value. 195 nvoices[1] != ucontrol->value. 196 } 197 198 #define BURGUNDY_VOLUME_W(xname, xindex, addr, 199 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 200 .info = snd_pmac_burgundy_info_volume,\ 201 .get = snd_pmac_burgundy_get_volume,\ 202 .put = snd_pmac_burgundy_put_volume,\ 203 .private_value = ((ADDR2BASE(addr) & 0xff) | 204 205 /* 206 * Burgundy volume: 0 - 100, stereo, 2-byte re 207 */ 208 static void 209 snd_pmac_burgundy_write_volume_2b(struct snd_p 210 long *volume 211 { 212 int lvolume, rvolume; 213 214 off |= off << 2; 215 lvolume = volume[0] ? volume[0] + BURG 216 rvolume = volume[1] ? volume[1] + BURG 217 218 snd_pmac_burgundy_wcb(chip, address + 219 snd_pmac_burgundy_wcb(chip, address + 220 } 221 222 static void 223 snd_pmac_burgundy_read_volume_2b(struct snd_pm 224 long *volume, 225 { 226 volume[0] = snd_pmac_burgundy_rcb(chip 227 if (volume[0] >= BURGUNDY_VOLUME_OFFSE 228 volume[0] -= BURGUNDY_VOLUME_O 229 else 230 volume[0] = 0; 231 volume[1] = snd_pmac_burgundy_rcb(chip 232 if (volume[1] >= BURGUNDY_VOLUME_OFFSE 233 volume[1] -= BURGUNDY_VOLUME_O 234 else 235 volume[1] = 0; 236 } 237 238 static int snd_pmac_burgundy_info_volume_2b(st 239 st 240 { 241 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTE 242 uinfo->count = 2; 243 uinfo->value.integer.min = 0; 244 uinfo->value.integer.max = 100; 245 return 0; 246 } 247 248 static int snd_pmac_burgundy_get_volume_2b(str 249 str 250 { 251 struct snd_pmac *chip = snd_kcontrol_c 252 unsigned int addr = BASE2ADDR(kcontrol 253 int off = kcontrol->private_value & 0x 254 snd_pmac_burgundy_read_volume_2b(chip, 255 ucontrol->value.intege 256 return 0; 257 } 258 259 static int snd_pmac_burgundy_put_volume_2b(str 260 str 261 { 262 struct snd_pmac *chip = snd_kcontrol_c 263 unsigned int addr = BASE2ADDR(kcontrol 264 int off = kcontrol->private_value & 0x 265 long nvoices[2]; 266 267 snd_pmac_burgundy_write_volume_2b(chip 268 ucontrol->value.intege 269 snd_pmac_burgundy_read_volume_2b(chip, 270 return (nvoices[0] != ucontrol->value. 271 nvoices[1] != ucontrol->value. 272 } 273 274 #define BURGUNDY_VOLUME_2B(xname, xindex, addr 275 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 276 .info = snd_pmac_burgundy_info_volume_2b,\ 277 .get = snd_pmac_burgundy_get_volume_2b,\ 278 .put = snd_pmac_burgundy_put_volume_2b,\ 279 .private_value = ((ADDR2BASE(addr) & 0xff) | 280 281 /* 282 * Burgundy gain/attenuation: 0 - 15, mono/ste 283 */ 284 static int snd_pmac_burgundy_info_gain(struct 285 struct 286 { 287 int stereo = (kcontrol->private_value 288 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTE 289 uinfo->count = stereo + 1; 290 uinfo->value.integer.min = 0; 291 uinfo->value.integer.max = 15; 292 return 0; 293 } 294 295 static int snd_pmac_burgundy_get_gain(struct s 296 struct s 297 { 298 struct snd_pmac *chip = snd_kcontrol_c 299 unsigned int addr = BASE2ADDR(kcontrol 300 int stereo = (kcontrol->private_value 301 int atten = (kcontrol->private_value > 302 int oval; 303 304 oval = snd_pmac_burgundy_rcb(chip, add 305 if (atten) 306 oval = ~oval & 0xff; 307 ucontrol->value.integer.value[0] = ova 308 if (stereo) 309 ucontrol->value.integer.value[ 310 return 0; 311 } 312 313 static int snd_pmac_burgundy_put_gain(struct s 314 struct s 315 { 316 struct snd_pmac *chip = snd_kcontrol_c 317 unsigned int addr = BASE2ADDR(kcontrol 318 int stereo = (kcontrol->private_value 319 int atten = (kcontrol->private_value > 320 int oval, val; 321 322 oval = snd_pmac_burgundy_rcb(chip, add 323 if (atten) 324 oval = ~oval & 0xff; 325 val = ucontrol->value.integer.value[0] 326 if (stereo) 327 val |= ucontrol->value.integer 328 else 329 val |= ucontrol->value.integer 330 if (atten) 331 val = ~val & 0xff; 332 snd_pmac_burgundy_wcb(chip, addr, val) 333 return val != oval; 334 } 335 336 #define BURGUNDY_VOLUME_B(xname, xindex, addr, 337 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 338 .info = snd_pmac_burgundy_info_gain,\ 339 .get = snd_pmac_burgundy_get_gain,\ 340 .put = snd_pmac_burgundy_put_gain,\ 341 .private_value = (ADDR2BASE(addr) | ((stereo 342 343 /* 344 * Burgundy switch: 0/1, mono/stereo, word reg 345 */ 346 static int snd_pmac_burgundy_info_switch_w(str 347 str 348 { 349 int stereo = (kcontrol->private_value 350 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOL 351 uinfo->count = stereo + 1; 352 uinfo->value.integer.min = 0; 353 uinfo->value.integer.max = 1; 354 return 0; 355 } 356 357 static int snd_pmac_burgundy_get_switch_w(stru 358 stru 359 { 360 struct snd_pmac *chip = snd_kcontrol_c 361 unsigned int addr = BASE2ADDR((kcontro 362 int lmask = 1 << (kcontrol->private_va 363 int rmask = 1 << ((kcontrol->private_v 364 int stereo = (kcontrol->private_value 365 int val = snd_pmac_burgundy_rcw(chip, 366 ucontrol->value.integer.value[0] = (va 367 if (stereo) 368 ucontrol->value.integer.value[ 369 return 0; 370 } 371 372 static int snd_pmac_burgundy_put_switch_w(stru 373 stru 374 { 375 struct snd_pmac *chip = snd_kcontrol_c 376 unsigned int addr = BASE2ADDR((kcontro 377 int lmask = 1 << (kcontrol->private_va 378 int rmask = 1 << ((kcontrol->private_v 379 int stereo = (kcontrol->private_value 380 int val, oval; 381 oval = snd_pmac_burgundy_rcw(chip, add 382 val = oval & ~(lmask | (stereo ? rmask 383 if (ucontrol->value.integer.value[0]) 384 val |= lmask; 385 if (stereo && ucontrol->value.integer. 386 val |= rmask; 387 snd_pmac_burgundy_wcw(chip, addr, val) 388 return val != oval; 389 } 390 391 #define BURGUNDY_SWITCH_W(xname, xindex, addr, 392 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 393 .info = snd_pmac_burgundy_info_switch_w,\ 394 .get = snd_pmac_burgundy_get_switch_w,\ 395 .put = snd_pmac_burgundy_put_switch_w,\ 396 .private_value = ((lbit) | ((rbit) << 8)\ 397 | (ADDR2BASE(addr) << 16) | (( 398 399 /* 400 * Burgundy switch: 0/1, mono/stereo, byte reg 401 */ 402 static int snd_pmac_burgundy_info_switch_b(str 403 str 404 { 405 int stereo = (kcontrol->private_value 406 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOL 407 uinfo->count = stereo + 1; 408 uinfo->value.integer.min = 0; 409 uinfo->value.integer.max = 1; 410 return 0; 411 } 412 413 static int snd_pmac_burgundy_get_switch_b(stru 414 stru 415 { 416 struct snd_pmac *chip = snd_kcontrol_c 417 unsigned int addr = BASE2ADDR((kcontro 418 int lmask = kcontrol->private_value & 419 int rmask = (kcontrol->private_value > 420 int stereo = (kcontrol->private_value 421 int val = snd_pmac_burgundy_rcb(chip, 422 ucontrol->value.integer.value[0] = (va 423 if (stereo) 424 ucontrol->value.integer.value[ 425 return 0; 426 } 427 428 static int snd_pmac_burgundy_put_switch_b(stru 429 stru 430 { 431 struct snd_pmac *chip = snd_kcontrol_c 432 unsigned int addr = BASE2ADDR((kcontro 433 int lmask = kcontrol->private_value & 434 int rmask = (kcontrol->private_value > 435 int stereo = (kcontrol->private_value 436 int val, oval; 437 oval = snd_pmac_burgundy_rcb(chip, add 438 val = oval & ~(lmask | rmask); 439 if (ucontrol->value.integer.value[0]) 440 val |= lmask; 441 if (stereo && ucontrol->value.integer. 442 val |= rmask; 443 snd_pmac_burgundy_wcb(chip, addr, val) 444 return val != oval; 445 } 446 447 #define BURGUNDY_SWITCH_B(xname, xindex, addr, 448 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 449 .info = snd_pmac_burgundy_info_switch_b,\ 450 .get = snd_pmac_burgundy_get_switch_b,\ 451 .put = snd_pmac_burgundy_put_switch_b,\ 452 .private_value = ((lmask) | ((rmask) << 8)\ 453 | (ADDR2BASE(addr) << 16) | (( 454 455 /* 456 * Burgundy mixers 457 */ 458 static const struct snd_kcontrol_new snd_pmac_ 459 BURGUNDY_VOLUME_W("Master Playback Vol 460 MASK_ADDR_BURGUNDY_MAS 461 BURGUNDY_VOLUME_W("CD Capture Volume", 462 MASK_ADDR_BURGUNDY_VOL 463 BURGUNDY_VOLUME_2B("Input Capture Volu 464 MASK_ADDR_BURGUNDY_VOL 465 BURGUNDY_VOLUME_2B("Mixer Playback Vol 466 MASK_ADDR_BURGUNDY_VOL 467 BURGUNDY_VOLUME_B("CD Gain Capture Vol 468 MASK_ADDR_BURGUNDY_GAI 469 BURGUNDY_SWITCH_W("Master Capture Swit 470 MASK_ADDR_BURGUNDY_OUT 471 BURGUNDY_SWITCH_W("CD Capture Switch", 472 MASK_ADDR_BURGUNDY_CAP 473 BURGUNDY_SWITCH_W("CD Playback Switch" 474 MASK_ADDR_BURGUNDY_OUT 475 /* BURGUNDY_SWITCH_W("Loop Capture Switch 476 * MASK_ADDR_BURGUNDY_CAPTURESELE 477 * BURGUNDY_SWITCH_B("Mixer out Capture S 478 * MASK_ADDR_BURGUNDY_HOSTIFAD, 0 479 * BURGUNDY_SWITCH_B("Mixer Capture Switc 480 * MASK_ADDR_BURGUNDY_HOSTIFAD, 0 481 * BURGUNDY_SWITCH_B("PCM out Capture Swi 482 * MASK_ADDR_BURGUNDY_HOSTIFEH, 0 483 */ BURGUNDY_SWITCH_B("PCM Capture Switch" 484 MASK_ADDR_BURGUNDY_HOS 485 }; 486 static const struct snd_kcontrol_new snd_pmac_ 487 BURGUNDY_VOLUME_W("Line in Capture Vol 488 MASK_ADDR_BURGUNDY_VOL 489 BURGUNDY_VOLUME_W("Mic Capture Volume" 490 MASK_ADDR_BURGUNDY_VOL 491 BURGUNDY_VOLUME_B("Line in Gain Captur 492 MASK_ADDR_BURGUNDY_GAI 493 BURGUNDY_VOLUME_B("Mic Gain Capture Vo 494 MASK_ADDR_BURGUNDY_GAI 495 BURGUNDY_VOLUME_B("Speaker Playback Vo 496 MASK_ADDR_BURGUNDY_ATT 497 BURGUNDY_VOLUME_B("Line out Playback V 498 MASK_ADDR_BURGUNDY_ATT 499 BURGUNDY_VOLUME_B("Headphone Playback 500 MASK_ADDR_BURGUNDY_ATT 501 BURGUNDY_SWITCH_W("Line in Capture Swi 502 MASK_ADDR_BURGUNDY_CAP 503 BURGUNDY_SWITCH_W("Mic Capture Switch" 504 MASK_ADDR_BURGUNDY_CAP 505 BURGUNDY_SWITCH_W("Line in Playback Sw 506 MASK_ADDR_BURGUNDY_OUT 507 BURGUNDY_SWITCH_W("Mic Playback Switch 508 MASK_ADDR_BURGUNDY_OUT 509 BURGUNDY_SWITCH_B("Mic Boost Capture S 510 MASK_ADDR_BURGUNDY_INP 511 }; 512 static const struct snd_kcontrol_new snd_pmac_ 513 BURGUNDY_VOLUME_W("Line in Capture Vol 514 MASK_ADDR_BURGUNDY_VOL 515 BURGUNDY_VOLUME_B("Line in Gain Captur 516 MASK_ADDR_BURGUNDY_GAI 517 BURGUNDY_VOLUME_B("Speaker Playback Vo 518 MASK_ADDR_BURGUNDY_ATT 519 BURGUNDY_VOLUME_B("Line out Playback V 520 MASK_ADDR_BURGUNDY_ATT 521 BURGUNDY_SWITCH_W("Line in Capture Swi 522 MASK_ADDR_BURGUNDY_CAP 523 BURGUNDY_SWITCH_W("Line in Playback Sw 524 MASK_ADDR_BURGUNDY_OUT 525 /* BURGUNDY_SWITCH_B("Line in Boost Captu 526 * MASK_ADDR_BURGUNDY_INPBOOST, 0 527 }; 528 static const struct snd_kcontrol_new snd_pmac_ 529 BURGUNDY_SWITCH_B("Master Playback Switch", 0, 530 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 531 BURGUNDY_OUTPUT_LEFT | BURGUNDY_LINEOU 532 BURGUNDY_OUTPUT_RIGHT | BURGUNDY_LINEO 533 static const struct snd_kcontrol_new snd_pmac_ 534 BURGUNDY_SWITCH_B("Master Playback Switch", 0, 535 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 536 BURGUNDY_OUTPUT_INTERN 537 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPU 538 static const struct snd_kcontrol_new snd_pmac_ 539 BURGUNDY_SWITCH_B("Speaker Playback Switch", 0 540 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 541 BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_ 542 static const struct snd_kcontrol_new snd_pmac_ 543 BURGUNDY_SWITCH_B("Speaker Playback Switch", 0 544 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 545 BURGUNDY_OUTPUT_INTERN, 0, 0); 546 static const struct snd_kcontrol_new snd_pmac_ 547 BURGUNDY_SWITCH_B("Line out Playback Switch", 548 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 549 BURGUNDY_LINEOUT_LEFT, BURGUNDY_LINEOU 550 static const struct snd_kcontrol_new snd_pmac_ 551 BURGUNDY_SWITCH_B("Line out Playback Switch", 552 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 553 BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_ 554 static const struct snd_kcontrol_new snd_pmac_ 555 BURGUNDY_SWITCH_B("Headphone Playback Switch", 556 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 557 BURGUNDY_HP_LEFT, BURGUNDY_HP_RIGHT, 1 558 559 560 #ifdef PMAC_SUPPORT_AUTOMUTE 561 /* 562 * auto-mute stuffs 563 */ 564 static int snd_pmac_burgundy_detect_headphone( 565 { 566 return (in_le32(&chip->awacs->codec_st 567 } 568 569 static void snd_pmac_burgundy_update_automute( 570 { 571 if (chip->auto_mute) { 572 int imac = of_machine_is_compa 573 int reg, oreg; 574 reg = oreg = snd_pmac_burgundy 575 MASK_ADDR_BURG 576 reg &= imac ? ~(BURGUNDY_OUTPU 577 | BURGUNDY_HP_ 578 : ~(BURGUNDY_OUTPUT_LE 579 | BURGUNDY_OUT 580 if (snd_pmac_burgundy_detect_h 581 reg |= imac ? (BURGUND 582 : (BURGUNDY_OU 583 | BURG 584 else 585 reg |= imac ? (BURGUND 586 | BURG 587 : (BURGUNDY_OU 588 if (do_notify && reg == oreg) 589 return; 590 snd_pmac_burgundy_wcb(chip, 591 MASK_ADDR_BURG 592 if (do_notify) { 593 snd_ctl_notify(chip->c 594 &chip-> 595 snd_ctl_notify(chip->c 596 &chip-> 597 snd_ctl_notify(chip->c 598 &chip-> 599 } 600 } 601 } 602 #endif /* PMAC_SUPPORT_AUTOMUTE */ 603 604 605 /* 606 * initialize burgundy 607 */ 608 int snd_pmac_burgundy_init(struct snd_pmac *ch 609 { 610 int imac = of_machine_is_compatible("i 611 int i, err; 612 613 /* Checks to see the chip is alive and 614 if ((in_le32(&chip->awacs->codec_ctrl) 615 printk(KERN_WARNING "pmac burg 616 return 1; 617 } 618 619 snd_pmac_burgundy_wcw(chip, MASK_ADDR_ 620 DEF_BURGUNDY_OUTPUT 621 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 622 DEF_BURGUNDY_MORE_O 623 snd_pmac_burgundy_wcw(chip, MASK_ADDR_ 624 DEF_BURGUNDY_OUTPUT 625 626 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 627 DEF_BURGUNDY_INPSEL 628 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 629 imac ? DEF_BURGUNDY 630 : DEF_BURGUNDY_INPS 631 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 632 DEF_BURGUNDY_GAINCD 633 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 634 DEF_BURGUNDY_GAINLI 635 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 636 DEF_BURGUNDY_GAINMI 637 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 638 DEF_BURGUNDY_GAINMO 639 640 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 641 DEF_BURGUNDY_ATTENS 642 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 643 DEF_BURGUNDY_ATTENL 644 snd_pmac_burgundy_wcb(chip, MASK_ADDR_ 645 DEF_BURGUNDY_ATTENH 646 647 snd_pmac_burgundy_wcw(chip, MASK_ADDR_ 648 DEF_BURGUNDY_MASTER 649 snd_pmac_burgundy_wcw(chip, MASK_ADDR_ 650 DEF_BURGUNDY_VOLCD) 651 snd_pmac_burgundy_wcw(chip, MASK_ADDR_ 652 DEF_BURGUNDY_VOLLIN 653 snd_pmac_burgundy_wcw(chip, MASK_ADDR_ 654 DEF_BURGUNDY_VOLMIC 655 656 if (chip->hp_stat_mask == 0) { 657 /* set headphone-jack detectio 658 if (imac) 659 chip->hp_stat_mask = B 660 | BURGUNDY_HPD 661 | BURGUNDY_HPD 662 else 663 chip->hp_stat_mask = B 664 } 665 /* 666 * build burgundy mixers 667 */ 668 strcpy(chip->card->mixername, "PowerMa 669 670 for (i = 0; i < ARRAY_SIZE(snd_pmac_bu 671 err = snd_ctl_add(chip->card, 672 snd_ctl_new1(&snd_pmac_bur 673 if (err < 0) 674 return err; 675 } 676 for (i = 0; i < (imac ? ARRAY_SIZE(snd 677 : ARRAY_SIZE(snd_pmac_ 678 err = snd_ctl_add(chip->card, 679 snd_ctl_new1(imac ? &snd_p 680 : &snd_pmac_burgundy_mixer 681 if (err < 0) 682 return err; 683 } 684 chip->master_sw_ctl = snd_ctl_new1(ima 685 ? &snd_pmac_burgundy_m 686 : &snd_pmac_burgundy_m 687 err = snd_ctl_add(chip->card, chip->ma 688 if (err < 0) 689 return err; 690 chip->master_sw_ctl = snd_ctl_new1(ima 691 ? &snd_pmac_burgundy_l 692 : &snd_pmac_burgundy_l 693 err = snd_ctl_add(chip->card, chip->ma 694 if (err < 0) 695 return err; 696 if (imac) { 697 chip->master_sw_ctl = snd_ctl_ 698 &snd_pmac_burg 699 err = snd_ctl_add(chip->card, 700 if (err < 0) 701 return err; 702 } 703 chip->speaker_sw_ctl = snd_ctl_new1(im 704 ? &snd_pmac_burgundy_s 705 : &snd_pmac_burgundy_s 706 err = snd_ctl_add(chip->card, chip->sp 707 if (err < 0) 708 return err; 709 #ifdef PMAC_SUPPORT_AUTOMUTE 710 err = snd_pmac_add_automute(chip); 711 if (err < 0) 712 return err; 713 714 chip->detect_headphone = snd_pmac_burg 715 chip->update_automute = snd_pmac_burgu 716 snd_pmac_burgundy_update_automute(chip 717 #endif 718 719 return 0; 720 } 721
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.