Blame view
sound/ppc/awacs.c
31.3 KB
1a59d1b8e treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 |
/* * PMac AWACS lowlevel functions * * Copyright (c) by Takashi Iwai <tiwai@suse.de> * code based on dmasound.c. |
1da177e4c Linux-2.6.12-rc2 |
7 |
*/ |
6cbbfe1c8 ALSA: Include lin... |
8 |
#include <linux/io.h> |
1da177e4c Linux-2.6.12-rc2 |
9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <asm/nvram.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/slab.h> #include <sound/core.h> #include "pmac.h" #ifdef CONFIG_ADB_CUDA #define PMAC_AMP_AVAIL #endif #ifdef PMAC_AMP_AVAIL |
65b29f503 [ALSA] Remove xxx... |
22 |
struct awacs_amp { |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 |
unsigned char amp_master; unsigned char amp_vol[2][2]; unsigned char amp_tone[2]; |
65b29f503 [ALSA] Remove xxx... |
26 |
}; |
1da177e4c Linux-2.6.12-rc2 |
27 28 29 30 |
#define CHECK_CUDA_AMP() (sys_ctrler == SYS_CTRLER_CUDA) #endif /* PMAC_AMP_AVAIL */ |
65b29f503 [ALSA] Remove xxx... |
31 |
static void snd_pmac_screamer_wait(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
{ long timeout = 2000; while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) { mdelay(1); if (! --timeout) { snd_printd("snd_pmac_screamer_wait timeout "); break; } } } /* * write AWACS register */ static void |
65b29f503 [ALSA] Remove xxx... |
48 |
snd_pmac_awacs_write(struct snd_pmac *chip, int val) |
1da177e4c Linux-2.6.12-rc2 |
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
{ long timeout = 5000000; if (chip->model == PMAC_SCREAMER) snd_pmac_screamer_wait(chip); out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22)); while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) { if (! --timeout) { snd_printd("snd_pmac_awacs_write timeout "); break; } } } static void |
65b29f503 [ALSA] Remove xxx... |
65 |
snd_pmac_awacs_write_reg(struct snd_pmac *chip, int reg, int val) |
1da177e4c Linux-2.6.12-rc2 |
66 67 68 69 70 71 |
{ snd_pmac_awacs_write(chip, val | (reg << 12)); chip->awacs_reg[reg] = val; } static void |
65b29f503 [ALSA] Remove xxx... |
72 |
snd_pmac_awacs_write_noreg(struct snd_pmac *chip, int reg, int val) |
1da177e4c Linux-2.6.12-rc2 |
73 74 75 |
{ snd_pmac_awacs_write(chip, val | (reg << 12)); } |
8c8709334 [PATCH] ppc32: Re... |
76 |
#ifdef CONFIG_PM |
1da177e4c Linux-2.6.12-rc2 |
77 |
/* Recalibrate chip */ |
65b29f503 [ALSA] Remove xxx... |
78 |
static void screamer_recalibrate(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
79 80 81 82 83 84 85 86 87 88 |
{ if (chip->model != PMAC_SCREAMER) return; /* Sorry for the horrible delays... I hope to get that improved * by making the whole PM process asynchronous in a future version */ snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); if (chip->manufacturer == 0x1) /* delay for broken crystal part */ |
989a0b248 [ALSA] Fix-up sle... |
89 |
msleep(750); |
1da177e4c Linux-2.6.12-rc2 |
90 |
snd_pmac_awacs_write_noreg(chip, 1, |
65b29f503 [ALSA] Remove xxx... |
91 92 |
chip->awacs_reg[1] | MASK_RECALIBRATE | MASK_CMUTE | MASK_AMUTE); |
1da177e4c Linux-2.6.12-rc2 |
93 94 95 96 97 98 99 100 101 102 103 104 |
snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); } #else #define screamer_recalibrate(chip) /* NOP */ #endif /* * additional callback to set the pcm format */ |
65b29f503 [ALSA] Remove xxx... |
105 |
static void snd_pmac_awacs_set_format(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
106 107 108 109 110 111 112 113 114 115 116 117 118 |
{ chip->awacs_reg[1] &= ~MASK_SAMPLERATE; chip->awacs_reg[1] |= chip->rate_index << 3; snd_pmac_awacs_write_reg(chip, 1, chip->awacs_reg[1]); } /* * AWACS volume callbacks */ /* * volumes: 0-15 stereo */ |
65b29f503 [ALSA] Remove xxx... |
119 120 |
static int snd_pmac_awacs_info_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4c Linux-2.6.12-rc2 |
121 122 123 124 125 126 127 |
{ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; uinfo->value.integer.min = 0; uinfo->value.integer.max = 15; return 0; } |
7ae44cfa7 [ALSA] snd-powerm... |
128 |
|
65b29f503 [ALSA] Remove xxx... |
129 130 |
static int snd_pmac_awacs_get_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
131 |
{ |
65b29f503 [ALSA] Remove xxx... |
132 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
int reg = kcontrol->private_value & 0xff; int lshift = (kcontrol->private_value >> 8) & 0xff; int inverted = (kcontrol->private_value >> 16) & 1; unsigned long flags; int vol[2]; spin_lock_irqsave(&chip->reg_lock, flags); vol[0] = (chip->awacs_reg[reg] >> lshift) & 0xf; vol[1] = chip->awacs_reg[reg] & 0xf; spin_unlock_irqrestore(&chip->reg_lock, flags); if (inverted) { vol[0] = 0x0f - vol[0]; vol[1] = 0x0f - vol[1]; } ucontrol->value.integer.value[0] = vol[0]; ucontrol->value.integer.value[1] = vol[1]; return 0; } |
65b29f503 [ALSA] Remove xxx... |
151 152 |
static int snd_pmac_awacs_put_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
153 |
{ |
65b29f503 [ALSA] Remove xxx... |
154 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
155 156 157 158 159 |
int reg = kcontrol->private_value & 0xff; int lshift = (kcontrol->private_value >> 8) & 0xff; int inverted = (kcontrol->private_value >> 16) & 1; int val, oldval; unsigned long flags; |
d4079ac49 [ALSA] powermac -... |
160 |
unsigned int vol[2]; |
1da177e4c Linux-2.6.12-rc2 |
161 162 163 |
vol[0] = ucontrol->value.integer.value[0]; vol[1] = ucontrol->value.integer.value[1]; |
d4079ac49 [ALSA] powermac -... |
164 165 |
if (vol[0] > 0x0f || vol[1] > 0x0f) return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
if (inverted) { vol[0] = 0x0f - vol[0]; vol[1] = 0x0f - vol[1]; } vol[0] &= 0x0f; vol[1] &= 0x0f; spin_lock_irqsave(&chip->reg_lock, flags); oldval = chip->awacs_reg[reg]; val = oldval & ~(0xf | (0xf << lshift)); val |= vol[0] << lshift; val |= vol[1]; if (oldval != val) snd_pmac_awacs_write_reg(chip, reg, val); spin_unlock_irqrestore(&chip->reg_lock, flags); return oldval != reg; } #define AWACS_VOLUME(xname, xreg, xshift, xinverted) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ .info = snd_pmac_awacs_info_volume, \ .get = snd_pmac_awacs_get_volume, \ .put = snd_pmac_awacs_put_volume, \ .private_value = (xreg) | ((xshift) << 8) | ((xinverted) << 16) } /* * mute master/ogain for AWACS: mono */ |
65b29f503 [ALSA] Remove xxx... |
194 195 |
static int snd_pmac_awacs_get_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
196 |
{ |
65b29f503 [ALSA] Remove xxx... |
197 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int invert = (kcontrol->private_value >> 16) & 1; int val; unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); val = (chip->awacs_reg[reg] >> shift) & 1; spin_unlock_irqrestore(&chip->reg_lock, flags); if (invert) val = 1 - val; ucontrol->value.integer.value[0] = val; return 0; } |
65b29f503 [ALSA] Remove xxx... |
212 213 |
static int snd_pmac_awacs_put_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
214 |
{ |
65b29f503 [ALSA] Remove xxx... |
215 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int invert = (kcontrol->private_value >> 16) & 1; int mask = 1 << shift; int val, changed; unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); val = chip->awacs_reg[reg] & ~mask; if (ucontrol->value.integer.value[0] != invert) val |= mask; changed = chip->awacs_reg[reg] != val; if (changed) snd_pmac_awacs_write_reg(chip, reg, val); spin_unlock_irqrestore(&chip->reg_lock, flags); return changed; } #define AWACS_SWITCH(xname, xreg, xshift, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ .info = snd_pmac_boolean_mono_info, \ .get = snd_pmac_awacs_get_switch, \ .put = snd_pmac_awacs_put_switch, \ .private_value = (xreg) | ((xshift) << 8) | ((xinvert) << 16) } #ifdef PMAC_AMP_AVAIL /* * controls for perch/whisper extension cards, e.g. G3 desktop * * TDA7433 connected via i2c address 0x45 (= 0x8a), * accessed through cuda */ static void awacs_set_cuda(int reg, int val) { struct adb_request req; |
7ae44cfa7 [ALSA] snd-powerm... |
252 253 |
cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x8a, reg, val); |
1da177e4c Linux-2.6.12-rc2 |
254 255 256 257 258 259 260 |
while (! req.complete) cuda_poll(); } /* * level = 0 - 14, 7 = 0 dB */ |
65b29f503 [ALSA] Remove xxx... |
261 |
static void awacs_amp_set_tone(struct awacs_amp *amp, int bass, int treble) |
1da177e4c Linux-2.6.12-rc2 |
262 263 264 265 266 267 268 269 270 271 272 273 274 |
{ amp->amp_tone[0] = bass; amp->amp_tone[1] = treble; if (bass > 7) bass = (14 - bass) + 8; if (treble > 7) treble = (14 - treble) + 8; awacs_set_cuda(2, (bass << 4) | treble); } /* * vol = 0 - 31 (attenuation), 32 = mute bit, stereo */ |
7ae44cfa7 [ALSA] snd-powerm... |
275 276 |
static int awacs_amp_set_vol(struct awacs_amp *amp, int index, int lvol, int rvol, int do_check) |
1da177e4c Linux-2.6.12-rc2 |
277 278 |
{ if (do_check && amp->amp_vol[index][0] == lvol && |
7ae44cfa7 [ALSA] snd-powerm... |
279 |
amp->amp_vol[index][1] == rvol) |
1da177e4c Linux-2.6.12-rc2 |
280 281 282 283 284 285 286 287 288 289 290 |
return 0; awacs_set_cuda(3 + index, lvol); awacs_set_cuda(5 + index, rvol); amp->amp_vol[index][0] = lvol; amp->amp_vol[index][1] = rvol; return 1; } /* * 0 = -79 dB, 79 = 0 dB, 99 = +20 dB */ |
65b29f503 [ALSA] Remove xxx... |
291 |
static void awacs_amp_set_master(struct awacs_amp *amp, int vol) |
1da177e4c Linux-2.6.12-rc2 |
292 293 294 295 296 297 298 299 |
{ amp->amp_master = vol; if (vol <= 79) vol = 32 + (79 - vol); else vol = 32 - (vol - 79); awacs_set_cuda(1, vol); } |
65b29f503 [ALSA] Remove xxx... |
300 |
static void awacs_amp_free(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
301 |
{ |
65b29f503 [ALSA] Remove xxx... |
302 |
struct awacs_amp *amp = chip->mixer_data; |
5e246b850 ALSA: Kill snd_as... |
303 304 |
if (!amp) return; |
1da177e4c Linux-2.6.12-rc2 |
305 306 307 308 309 310 311 312 313 |
kfree(amp); chip->mixer_data = NULL; chip->mixer_free = NULL; } /* * mixer controls */ |
65b29f503 [ALSA] Remove xxx... |
314 315 |
static int snd_pmac_awacs_info_volume_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4c Linux-2.6.12-rc2 |
316 317 318 319 320 321 322 |
{ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; uinfo->value.integer.min = 0; uinfo->value.integer.max = 31; return 0; } |
7ae44cfa7 [ALSA] snd-powerm... |
323 |
|
65b29f503 [ALSA] Remove xxx... |
324 325 |
static int snd_pmac_awacs_get_volume_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
326 |
{ |
65b29f503 [ALSA] Remove xxx... |
327 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
328 |
int index = kcontrol->private_value; |
65b29f503 [ALSA] Remove xxx... |
329 |
struct awacs_amp *amp = chip->mixer_data; |
5e246b850 ALSA: Kill snd_as... |
330 |
|
1da177e4c Linux-2.6.12-rc2 |
331 332 333 334 |
ucontrol->value.integer.value[0] = 31 - (amp->amp_vol[index][0] & 31); ucontrol->value.integer.value[1] = 31 - (amp->amp_vol[index][1] & 31); return 0; } |
65b29f503 [ALSA] Remove xxx... |
335 336 |
static int snd_pmac_awacs_put_volume_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
337 |
{ |
65b29f503 [ALSA] Remove xxx... |
338 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
339 340 |
int index = kcontrol->private_value; int vol[2]; |
65b29f503 [ALSA] Remove xxx... |
341 |
struct awacs_amp *amp = chip->mixer_data; |
1da177e4c Linux-2.6.12-rc2 |
342 |
|
7ae44cfa7 [ALSA] snd-powerm... |
343 344 345 346 |
vol[0] = (31 - (ucontrol->value.integer.value[0] & 31)) | (amp->amp_vol[index][0] & 32); vol[1] = (31 - (ucontrol->value.integer.value[1] & 31)) | (amp->amp_vol[index][1] & 32); |
1da177e4c Linux-2.6.12-rc2 |
347 348 |
return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1); } |
65b29f503 [ALSA] Remove xxx... |
349 350 |
static int snd_pmac_awacs_get_switch_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
351 |
{ |
65b29f503 [ALSA] Remove xxx... |
352 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
353 |
int index = kcontrol->private_value; |
65b29f503 [ALSA] Remove xxx... |
354 |
struct awacs_amp *amp = chip->mixer_data; |
5e246b850 ALSA: Kill snd_as... |
355 |
|
7ae44cfa7 [ALSA] snd-powerm... |
356 357 358 359 |
ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32) ? 0 : 1; ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32) ? 0 : 1; |
1da177e4c Linux-2.6.12-rc2 |
360 361 |
return 0; } |
65b29f503 [ALSA] Remove xxx... |
362 363 |
static int snd_pmac_awacs_put_switch_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
364 |
{ |
65b29f503 [ALSA] Remove xxx... |
365 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
366 367 |
int index = kcontrol->private_value; int vol[2]; |
65b29f503 [ALSA] Remove xxx... |
368 |
struct awacs_amp *amp = chip->mixer_data; |
1da177e4c Linux-2.6.12-rc2 |
369 |
|
7ae44cfa7 [ALSA] snd-powerm... |
370 371 372 373 |
vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32) | (amp->amp_vol[index][0] & 31); vol[1] = (ucontrol->value.integer.value[1] ? 0 : 32) | (amp->amp_vol[index][1] & 31); |
1da177e4c Linux-2.6.12-rc2 |
374 375 |
return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1); } |
65b29f503 [ALSA] Remove xxx... |
376 377 |
static int snd_pmac_awacs_info_tone_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4c Linux-2.6.12-rc2 |
378 379 380 381 382 383 384 |
{ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; uinfo->value.integer.min = 0; uinfo->value.integer.max = 14; return 0; } |
7ae44cfa7 [ALSA] snd-powerm... |
385 |
|
65b29f503 [ALSA] Remove xxx... |
386 387 |
static int snd_pmac_awacs_get_tone_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
388 |
{ |
65b29f503 [ALSA] Remove xxx... |
389 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
390 |
int index = kcontrol->private_value; |
65b29f503 [ALSA] Remove xxx... |
391 |
struct awacs_amp *amp = chip->mixer_data; |
5e246b850 ALSA: Kill snd_as... |
392 |
|
1da177e4c Linux-2.6.12-rc2 |
393 394 395 |
ucontrol->value.integer.value[0] = amp->amp_tone[index]; return 0; } |
65b29f503 [ALSA] Remove xxx... |
396 397 |
static int snd_pmac_awacs_put_tone_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
398 |
{ |
65b29f503 [ALSA] Remove xxx... |
399 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
400 |
int index = kcontrol->private_value; |
65b29f503 [ALSA] Remove xxx... |
401 |
struct awacs_amp *amp = chip->mixer_data; |
d4079ac49 [ALSA] powermac -... |
402 |
unsigned int val; |
5e246b850 ALSA: Kill snd_as... |
403 |
|
d4079ac49 [ALSA] powermac -... |
404 405 406 407 408 |
val = ucontrol->value.integer.value[0]; if (val > 14) return -EINVAL; if (val != amp->amp_tone[index]) { amp->amp_tone[index] = val; |
1da177e4c Linux-2.6.12-rc2 |
409 410 411 412 413 |
awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); return 1; } return 0; } |
65b29f503 [ALSA] Remove xxx... |
414 415 |
static int snd_pmac_awacs_info_master_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4c Linux-2.6.12-rc2 |
416 417 418 419 420 421 422 |
{ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; uinfo->value.integer.min = 0; uinfo->value.integer.max = 99; return 0; } |
7ae44cfa7 [ALSA] snd-powerm... |
423 |
|
65b29f503 [ALSA] Remove xxx... |
424 425 |
static int snd_pmac_awacs_get_master_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
426 |
{ |
65b29f503 [ALSA] Remove xxx... |
427 428 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct awacs_amp *amp = chip->mixer_data; |
5e246b850 ALSA: Kill snd_as... |
429 |
|
1da177e4c Linux-2.6.12-rc2 |
430 431 432 |
ucontrol->value.integer.value[0] = amp->amp_master; return 0; } |
65b29f503 [ALSA] Remove xxx... |
433 434 |
static int snd_pmac_awacs_put_master_amp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
435 |
{ |
65b29f503 [ALSA] Remove xxx... |
436 437 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct awacs_amp *amp = chip->mixer_data; |
d4079ac49 [ALSA] powermac -... |
438 |
unsigned int val; |
5e246b850 ALSA: Kill snd_as... |
439 |
|
d4079ac49 [ALSA] powermac -... |
440 441 442 443 444 |
val = ucontrol->value.integer.value[0]; if (val > 99) return -EINVAL; if (val != amp->amp_master) { amp->amp_master = val; |
1da177e4c Linux-2.6.12-rc2 |
445 446 447 448 449 450 451 452 |
awacs_amp_set_master(amp, amp->amp_master); return 1; } return 0; } #define AMP_CH_SPK 0 #define AMP_CH_HD 1 |
c031b0cc7 ALSA: ppc: Consti... |
453 |
static const struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] = { |
1da177e4c Linux-2.6.12-rc2 |
454 |
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
ad1cd7450 ALSA: rename "PC ... |
455 |
.name = "Speaker Playback Volume", |
1da177e4c Linux-2.6.12-rc2 |
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
.info = snd_pmac_awacs_info_volume_amp, .get = snd_pmac_awacs_get_volume_amp, .put = snd_pmac_awacs_put_volume_amp, .private_value = AMP_CH_SPK, }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Playback Volume", .info = snd_pmac_awacs_info_volume_amp, .get = snd_pmac_awacs_get_volume_amp, .put = snd_pmac_awacs_put_volume_amp, .private_value = AMP_CH_HD, }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Tone Control - Bass", .info = snd_pmac_awacs_info_tone_amp, .get = snd_pmac_awacs_get_tone_amp, .put = snd_pmac_awacs_put_tone_amp, .private_value = 0, }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Tone Control - Treble", .info = snd_pmac_awacs_info_tone_amp, .get = snd_pmac_awacs_get_tone_amp, .put = snd_pmac_awacs_put_tone_amp, .private_value = 1, }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Amp Master Playback Volume", .info = snd_pmac_awacs_info_master_amp, .get = snd_pmac_awacs_get_master_amp, .put = snd_pmac_awacs_put_master_amp, }, }; |
905e46acd ALSA: declare snd... |
489 |
static const struct snd_kcontrol_new snd_pmac_awacs_amp_hp_sw = { |
1da177e4c Linux-2.6.12-rc2 |
490 491 492 493 494 495 496 |
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Playback Switch", .info = snd_pmac_boolean_stereo_info, .get = snd_pmac_awacs_get_switch_amp, .put = snd_pmac_awacs_put_switch_amp, .private_value = AMP_CH_HD, }; |
905e46acd ALSA: declare snd... |
497 |
static const struct snd_kcontrol_new snd_pmac_awacs_amp_spk_sw = { |
1da177e4c Linux-2.6.12-rc2 |
498 |
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
ad1cd7450 ALSA: rename "PC ... |
499 |
.name = "Speaker Playback Switch", |
1da177e4c Linux-2.6.12-rc2 |
500 501 502 503 504 505 506 507 508 509 510 511 |
.info = snd_pmac_boolean_stereo_info, .get = snd_pmac_awacs_get_switch_amp, .put = snd_pmac_awacs_put_switch_amp, .private_value = AMP_CH_SPK, }; #endif /* PMAC_AMP_AVAIL */ /* * mic boost for screamer */ |
65b29f503 [ALSA] Remove xxx... |
512 513 |
static int snd_pmac_screamer_mic_boost_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4c Linux-2.6.12-rc2 |
514 515 516 517 |
{ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; uinfo->value.integer.min = 0; |
a8c2a6bf4 [ALSA] snd-powerm... |
518 |
uinfo->value.integer.max = 3; |
1da177e4c Linux-2.6.12-rc2 |
519 520 |
return 0; } |
65b29f503 [ALSA] Remove xxx... |
521 522 |
static int snd_pmac_screamer_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
523 |
{ |
65b29f503 [ALSA] Remove xxx... |
524 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
a8c2a6bf4 [ALSA] snd-powerm... |
525 |
int val = 0; |
1da177e4c Linux-2.6.12-rc2 |
526 527 528 529 |
unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); if (chip->awacs_reg[6] & MASK_MIC_BOOST) |
a8c2a6bf4 [ALSA] snd-powerm... |
530 531 532 |
val |= 2; if (chip->awacs_reg[0] & MASK_GAINLINE) val |= 1; |
1da177e4c Linux-2.6.12-rc2 |
533 534 535 536 |
spin_unlock_irqrestore(&chip->reg_lock, flags); ucontrol->value.integer.value[0] = val; return 0; } |
65b29f503 [ALSA] Remove xxx... |
537 538 |
static int snd_pmac_screamer_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
539 |
{ |
65b29f503 [ALSA] Remove xxx... |
540 |
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
541 542 543 544 545 546 547 |
int changed = 0; int val0, val6; unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); val0 = chip->awacs_reg[0] & ~MASK_GAINLINE; val6 = chip->awacs_reg[6] & ~MASK_MIC_BOOST; |
a8c2a6bf4 [ALSA] snd-powerm... |
548 |
if (ucontrol->value.integer.value[0] & 1) |
1da177e4c Linux-2.6.12-rc2 |
549 |
val0 |= MASK_GAINLINE; |
a8c2a6bf4 [ALSA] snd-powerm... |
550 551 |
if (ucontrol->value.integer.value[0] & 2) val6 |= MASK_MIC_BOOST; |
1da177e4c Linux-2.6.12-rc2 |
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
if (val0 != chip->awacs_reg[0]) { snd_pmac_awacs_write_reg(chip, 0, val0); changed = 1; } if (val6 != chip->awacs_reg[6]) { snd_pmac_awacs_write_reg(chip, 6, val6); changed = 1; } spin_unlock_irqrestore(&chip->reg_lock, flags); return changed; } /* * lists of mixer elements */ |
c031b0cc7 ALSA: ppc: Consti... |
567 |
static const struct snd_kcontrol_new snd_pmac_awacs_mixers[] = { |
1da177e4c Linux-2.6.12-rc2 |
568 |
AWACS_SWITCH("Master Capture Switch", 1, SHIFT_LOOPTHRU, 0), |
a8c2a6bf4 [ALSA] snd-powerm... |
569 570 571 |
AWACS_VOLUME("Master Capture Volume", 0, 4, 0), /* AWACS_SWITCH("Unknown Playback Switch", 6, SHIFT_PAROUT0, 0), */ }; |
c031b0cc7 ALSA: ppc: Consti... |
572 |
static const struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] = { |
a8c2a6bf4 [ALSA] snd-powerm... |
573 574 575 576 577 |
AWACS_VOLUME("Master Playback Volume", 2, 6, 1), AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
578 |
static const struct snd_kcontrol_new snd_pmac_screamer_mixers_lo[] = { |
a8c2a6bf4 [ALSA] snd-powerm... |
579 |
AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), |
dca7c7417 ALSA: Add vmaster... |
580 |
}; |
c031b0cc7 ALSA: ppc: Consti... |
581 |
static const struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] = { |
dca7c7417 ALSA: Add vmaster... |
582 |
AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), |
a8c2a6bf4 [ALSA] snd-powerm... |
583 584 |
AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
585 |
static const struct snd_kcontrol_new snd_pmac_screamer_mixers_g4agp[] = { |
4dbf95ba6 ALSA: snd-powerma... |
586 587 588 589 590 |
AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), AWACS_VOLUME("Master Playback Volume", 5, 6, 1), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
591 |
static const struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] = { |
a8c2a6bf4 [ALSA] snd-powerm... |
592 593 594 595 |
AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
596 |
static const struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac5500[] = { |
dca7c7417 ALSA: Add vmaster... |
597 598 |
AWACS_VOLUME("Headphone Playback Volume", 2, 6, 1), }; |
c031b0cc7 ALSA: ppc: Consti... |
599 |
static const struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] = { |
a8c2a6bf4 [ALSA] snd-powerm... |
600 |
AWACS_VOLUME("Master Playback Volume", 2, 6, 1), |
1da177e4c Linux-2.6.12-rc2 |
601 602 603 604 605 606 |
AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), }; /* FIXME: is this correct order? * screamer (powerbook G3 pismo) seems to have different bits... */ |
c031b0cc7 ALSA: ppc: Consti... |
607 |
static const struct snd_kcontrol_new snd_pmac_awacs_mixers2[] = { |
1da177e4c Linux-2.6.12-rc2 |
608 609 610 |
AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_LINE, 0), AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_MIC, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
611 |
static const struct snd_kcontrol_new snd_pmac_screamer_mixers2[] = { |
1da177e4c Linux-2.6.12-rc2 |
612 613 614 |
AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
615 |
static const struct snd_kcontrol_new snd_pmac_awacs_mixers2_pmac5500[] = { |
dca7c7417 ALSA: Add vmaster... |
616 617 |
AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
618 |
static const struct snd_kcontrol_new snd_pmac_awacs_master_sw = |
1da177e4c Linux-2.6.12-rc2 |
619 |
AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1); |
c031b0cc7 ALSA: ppc: Consti... |
620 |
static const struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac = |
a8c2a6bf4 [ALSA] snd-powerm... |
621 |
AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1); |
c031b0cc7 ALSA: ppc: Consti... |
622 |
static const struct snd_kcontrol_new snd_pmac_awacs_master_sw_pmac5500 = |
dca7c7417 ALSA: Add vmaster... |
623 |
AWACS_SWITCH("Headphone Playback Switch", 1, SHIFT_HDMUTE, 1); |
c031b0cc7 ALSA: ppc: Consti... |
624 |
static const struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] = { |
a8c2a6bf4 [ALSA] snd-powerm... |
625 |
AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0), |
1da177e4c Linux-2.6.12-rc2 |
626 |
}; |
c031b0cc7 ALSA: ppc: Consti... |
627 |
static const struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] = { |
1da177e4c Linux-2.6.12-rc2 |
628 |
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
a8c2a6bf4 [ALSA] snd-powerm... |
629 |
.name = "Mic Boost Capture Volume", |
1da177e4c Linux-2.6.12-rc2 |
630 631 632 633 634 |
.info = snd_pmac_screamer_mic_boost_info, .get = snd_pmac_screamer_mic_boost_get, .put = snd_pmac_screamer_mic_boost_put, }, }; |
c031b0cc7 ALSA: ppc: Consti... |
635 |
static const struct snd_kcontrol_new snd_pmac_awacs_mic_boost_pmac7500[] = |
a8c2a6bf4 [ALSA] snd-powerm... |
636 637 638 |
{ AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
639 |
static const struct snd_kcontrol_new snd_pmac_screamer_mic_boost_beige[] = |
a8c2a6bf4 [ALSA] snd-powerm... |
640 641 642 643 |
{ AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), AWACS_SWITCH("CD Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
644 |
static const struct snd_kcontrol_new snd_pmac_screamer_mic_boost_imac[] = |
a8c2a6bf4 [ALSA] snd-powerm... |
645 646 647 648 |
{ AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), AWACS_SWITCH("Mic Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), }; |
c031b0cc7 ALSA: ppc: Consti... |
649 |
static const struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] = { |
ad1cd7450 ALSA: rename "PC ... |
650 |
AWACS_VOLUME("Speaker Playback Volume", 4, 6, 1), |
1da177e4c Linux-2.6.12-rc2 |
651 |
}; |
a8c2a6bf4 [ALSA] snd-powerm... |
652 |
|
c031b0cc7 ALSA: ppc: Consti... |
653 |
static const struct snd_kcontrol_new snd_pmac_awacs_speaker_sw = |
ad1cd7450 ALSA: rename "PC ... |
654 |
AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); |
1da177e4c Linux-2.6.12-rc2 |
655 |
|
c031b0cc7 ALSA: ppc: Consti... |
656 |
static const struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 = |
ad1cd7450 ALSA: rename "PC ... |
657 |
AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_PAROUT1, 1); |
030b655b0 ALSA: snd-powerma... |
658 |
|
c031b0cc7 ALSA: ppc: Consti... |
659 |
static const struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 = |
ad1cd7450 ALSA: rename "PC ... |
660 |
AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_PAROUT1, 0); |
a8c2a6bf4 [ALSA] snd-powerm... |
661 |
|
1da177e4c Linux-2.6.12-rc2 |
662 663 664 665 |
/* * add new mixer elements to the card */ |
7ae44cfa7 [ALSA] snd-powerm... |
666 |
static int build_mixers(struct snd_pmac *chip, int nums, |
c031b0cc7 ALSA: ppc: Consti... |
667 |
const struct snd_kcontrol_new *mixers) |
1da177e4c Linux-2.6.12-rc2 |
668 669 670 671 |
{ int i, err; for (i = 0; i < nums; i++) { |
7ae44cfa7 [ALSA] snd-powerm... |
672 673 |
err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip)); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
674 675 676 677 678 679 680 681 682 |
return err; } return 0; } /* * restore all registers */ |
65b29f503 [ALSA] Remove xxx... |
683 |
static void awacs_restore_all_regs(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
684 685 686 687 688 689 690 691 692 693 694 |
{ snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); snd_pmac_awacs_write_noreg(chip, 2, chip->awacs_reg[2]); snd_pmac_awacs_write_noreg(chip, 4, chip->awacs_reg[4]); if (chip->model == PMAC_SCREAMER) { snd_pmac_awacs_write_noreg(chip, 5, chip->awacs_reg[5]); snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); snd_pmac_awacs_write_noreg(chip, 7, chip->awacs_reg[7]); } } |
8c8709334 [PATCH] ppc32: Re... |
695 |
#ifdef CONFIG_PM |
65b29f503 [ALSA] Remove xxx... |
696 |
static void snd_pmac_awacs_suspend(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
697 698 699 700 |
{ snd_pmac_awacs_write_noreg(chip, 1, (chip->awacs_reg[1] | MASK_AMUTE | MASK_CMUTE)); } |
65b29f503 [ALSA] Remove xxx... |
701 |
static void snd_pmac_awacs_resume(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
702 |
{ |
71a157e8e of: add 'of_' pre... |
703 704 |
if (of_machine_is_compatible("PowerBook3,1") || of_machine_is_compatible("PowerBook3,2")) { |
989a0b248 [ALSA] Fix-up sle... |
705 |
msleep(100); |
1da177e4c Linux-2.6.12-rc2 |
706 707 |
snd_pmac_awacs_write_reg(chip, 1, chip->awacs_reg[1] & ~MASK_PAROUT); |
989a0b248 [ALSA] Fix-up sle... |
708 |
msleep(300); |
1da177e4c Linux-2.6.12-rc2 |
709 710 711 712 713 714 715 716 717 718 719 |
} awacs_restore_all_regs(chip); if (chip->model == PMAC_SCREAMER) { /* reset power bits in reg 6 */ mdelay(5); snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); } screamer_recalibrate(chip); #ifdef PMAC_AMP_AVAIL if (chip->mixer_data) { |
65b29f503 [ALSA] Remove xxx... |
720 |
struct awacs_amp *amp = chip->mixer_data; |
7ae44cfa7 [ALSA] snd-powerm... |
721 722 723 724 |
awacs_amp_set_vol(amp, 0, amp->amp_vol[0][0], amp->amp_vol[0][1], 0); awacs_amp_set_vol(amp, 1, amp->amp_vol[1][0], amp->amp_vol[1][1], 0); |
1da177e4c Linux-2.6.12-rc2 |
725 726 727 728 729 |
awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); awacs_amp_set_master(amp, amp->amp_master); } #endif } |
8c8709334 [PATCH] ppc32: Re... |
730 |
#endif /* CONFIG_PM */ |
1da177e4c Linux-2.6.12-rc2 |
731 |
|
71a157e8e of: add 'of_' pre... |
732 733 734 735 736 737 738 739 740 741 |
#define IS_PM7500 (of_machine_is_compatible("AAPL,7500") \ || of_machine_is_compatible("AAPL,8500") \ || of_machine_is_compatible("AAPL,9500")) #define IS_PM5500 (of_machine_is_compatible("AAPL,e411")) #define IS_BEIGE (of_machine_is_compatible("AAPL,Gossamer")) #define IS_IMAC1 (of_machine_is_compatible("PowerMac2,1")) #define IS_IMAC2 (of_machine_is_compatible("PowerMac2,2") \ || of_machine_is_compatible("PowerMac4,1")) #define IS_G4AGP (of_machine_is_compatible("PowerMac3,1")) #define IS_LOMBARD (of_machine_is_compatible("PowerBook1,1")) |
a8c2a6bf4 [ALSA] snd-powerm... |
742 |
|
030b655b0 ALSA: snd-powerma... |
743 |
static int imac1, imac2; |
a8c2a6bf4 [ALSA] snd-powerm... |
744 |
|
1da177e4c Linux-2.6.12-rc2 |
745 746 747 748 |
#ifdef PMAC_SUPPORT_AUTOMUTE /* * auto-mute stuffs */ |
65b29f503 [ALSA] Remove xxx... |
749 |
static int snd_pmac_awacs_detect_headphone(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
750 751 752 753 754 |
{ return (in_le32(&chip->awacs->codec_stat) & chip->hp_stat_mask) ? 1 : 0; } #ifdef PMAC_AMP_AVAIL |
65b29f503 [ALSA] Remove xxx... |
755 |
static int toggle_amp_mute(struct awacs_amp *amp, int index, int mute) |
1da177e4c Linux-2.6.12-rc2 |
756 757 758 759 760 761 762 763 764 765 766 |
{ int vol[2]; vol[0] = amp->amp_vol[index][0] & 31; vol[1] = amp->amp_vol[index][1] & 31; if (mute) { vol[0] |= 32; vol[1] |= 32; } return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1); } #endif |
65b29f503 [ALSA] Remove xxx... |
767 |
static void snd_pmac_awacs_update_automute(struct snd_pmac *chip, int do_notify) |
1da177e4c Linux-2.6.12-rc2 |
768 769 770 771 |
{ if (chip->auto_mute) { #ifdef PMAC_AMP_AVAIL if (chip->mixer_data) { |
65b29f503 [ALSA] Remove xxx... |
772 |
struct awacs_amp *amp = chip->mixer_data; |
1da177e4c Linux-2.6.12-rc2 |
773 774 775 776 777 778 779 780 781 782 783 784 785 |
int changed; if (snd_pmac_awacs_detect_headphone(chip)) { changed = toggle_amp_mute(amp, AMP_CH_HD, 0); changed |= toggle_amp_mute(amp, AMP_CH_SPK, 1); } else { changed = toggle_amp_mute(amp, AMP_CH_HD, 1); changed |= toggle_amp_mute(amp, AMP_CH_SPK, 0); } if (do_notify && ! changed) return; } else #endif { |
a8c2a6bf4 [ALSA] snd-powerm... |
786 787 |
int reg = chip->awacs_reg[1] | (MASK_HDMUTE | MASK_SPKMUTE); |
030b655b0 ALSA: snd-powerma... |
788 789 790 791 |
if (imac1) { reg &= ~MASK_SPKMUTE; reg |= MASK_PAROUT1; } else if (imac2) { |
a8c2a6bf4 [ALSA] snd-powerm... |
792 793 794 |
reg &= ~MASK_SPKMUTE; reg &= ~MASK_PAROUT1; } |
1da177e4c Linux-2.6.12-rc2 |
795 796 |
if (snd_pmac_awacs_detect_headphone(chip)) reg &= ~MASK_HDMUTE; |
030b655b0 ALSA: snd-powerma... |
797 798 799 |
else if (imac1) reg &= ~MASK_PAROUT1; else if (imac2) |
a8c2a6bf4 [ALSA] snd-powerm... |
800 |
reg |= MASK_PAROUT1; |
1da177e4c Linux-2.6.12-rc2 |
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 |
else reg &= ~MASK_SPKMUTE; if (do_notify && reg == chip->awacs_reg[1]) return; snd_pmac_awacs_write_reg(chip, 1, reg); } if (do_notify) { snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_sw_ctl->id); snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->speaker_sw_ctl->id); snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hp_detect_ctl->id); } } } #endif /* PMAC_SUPPORT_AUTOMUTE */ /* * initialize chip */ |
15afafc25 ALSA: ppc: remove... |
823 |
int |
65b29f503 [ALSA] Remove xxx... |
824 |
snd_pmac_awacs_init(struct snd_pmac *chip) |
1da177e4c Linux-2.6.12-rc2 |
825 |
{ |
a8c2a6bf4 [ALSA] snd-powerm... |
826 |
int pm7500 = IS_PM7500; |
b0a8a8fd1 ALSA: powermac - ... |
827 |
int pm5500 = IS_PM5500; |
a8c2a6bf4 [ALSA] snd-powerm... |
828 |
int beige = IS_BEIGE; |
4dbf95ba6 ALSA: snd-powerma... |
829 |
int g4agp = IS_G4AGP; |
573934bc0 ALSA: powermac - ... |
830 |
int lombard = IS_LOMBARD; |
030b655b0 ALSA: snd-powerma... |
831 |
int imac; |
1da177e4c Linux-2.6.12-rc2 |
832 |
int err, vol; |
dca7c7417 ALSA: Add vmaster... |
833 834 |
struct snd_kcontrol *vmaster_sw, *vmaster_vol; struct snd_kcontrol *master_vol, *speaker_vol; |
1da177e4c Linux-2.6.12-rc2 |
835 |
|
030b655b0 ALSA: snd-powerma... |
836 837 838 |
imac1 = IS_IMAC1; imac2 = IS_IMAC2; imac = imac1 || imac2; |
1da177e4c Linux-2.6.12-rc2 |
839 840 841 842 843 844 845 |
/* looks like MASK_GAINLINE triggers something, so we set here * as start-up */ chip->awacs_reg[0] = MASK_MUX_CD | 0xff | MASK_GAINLINE; chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE; /* FIXME: Only machines with external SRS module need MASK_PAROUT */ if (chip->has_iic || chip->device_id == 0x5 || |
7ae44cfa7 [ALSA] snd-powerm... |
846 |
/* chip->_device_id == 0x8 || */ |
1da177e4c Linux-2.6.12-rc2 |
847 848 849 850 851 852 853 854 855 856 |
chip->device_id == 0xb) chip->awacs_reg[1] |= MASK_PAROUT; /* get default volume from nvram */ // vol = (~nvram_read_byte(0x1308) & 7) << 1; // vol = ((pmac_xpram_read( 8 ) & 7 ) << 1 ); vol = 0x0f; /* no, on alsa, muted as default */ vol = vol + (vol << 6); chip->awacs_reg[2] = vol; chip->awacs_reg[4] = vol; if (chip->model == PMAC_SCREAMER) { |
7ae44cfa7 [ALSA] snd-powerm... |
857 858 859 860 |
/* FIXME: screamer has loopthru vol control */ chip->awacs_reg[5] = vol; /* FIXME: maybe should be vol << 3 for PCMCIA speaker */ chip->awacs_reg[6] = MASK_MIC_BOOST; |
1da177e4c Linux-2.6.12-rc2 |
861 862 863 864 865 866 867 868 869 870 |
chip->awacs_reg[7] = 0; } awacs_restore_all_regs(chip); chip->manufacturer = (in_le32(&chip->awacs->codec_stat) >> 8) & 0xf; screamer_recalibrate(chip); chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; #ifdef PMAC_AMP_AVAIL if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { |
59feddb25 [ALSA] Conversion... |
871 |
struct awacs_amp *amp = kzalloc(sizeof(*amp), GFP_KERNEL); |
1da177e4c Linux-2.6.12-rc2 |
872 873 874 |
if (! amp) return -ENOMEM; chip->mixer_data = amp; |
1da177e4c Linux-2.6.12-rc2 |
875 |
chip->mixer_free = awacs_amp_free; |
7ae44cfa7 [ALSA] snd-powerm... |
876 877 |
/* mute and zero vol */ awacs_amp_set_vol(amp, 0, 63, 63, 0); |
1da177e4c Linux-2.6.12-rc2 |
878 879 880 881 882 883 884 885 886 887 |
awacs_amp_set_vol(amp, 1, 63, 63, 0); awacs_amp_set_tone(amp, 7, 7); /* 0 dB */ awacs_amp_set_master(amp, 79); /* 0 dB */ } #endif /* PMAC_AMP_AVAIL */ if (chip->hp_stat_mask == 0) { /* set headphone-jack detection bit */ switch (chip->model) { case PMAC_AWACS: |
b0a8a8fd1 ALSA: powermac - ... |
888 |
chip->hp_stat_mask = pm7500 || pm5500 ? MASK_HDPCONN |
a8c2a6bf4 [ALSA] snd-powerm... |
889 |
: MASK_LOCONN; |
1da177e4c Linux-2.6.12-rc2 |
890 891 892 893 |
break; case PMAC_SCREAMER: switch (chip->device_id) { case 0x08: |
a8c2a6bf4 [ALSA] snd-powerm... |
894 895 896 897 898 899 |
case 0x0B: chip->hp_stat_mask = imac ? MASK_LOCONN_IMAC | MASK_HDPLCONN_IMAC | MASK_HDPRCONN_IMAC : MASK_HDPCONN; |
1da177e4c Linux-2.6.12-rc2 |
900 901 902 |
break; case 0x00: case 0x05: |
a8c2a6bf4 [ALSA] snd-powerm... |
903 |
chip->hp_stat_mask = MASK_LOCONN; |
1da177e4c Linux-2.6.12-rc2 |
904 905 |
break; default: |
a8c2a6bf4 [ALSA] snd-powerm... |
906 |
chip->hp_stat_mask = MASK_HDPCONN; |
1da177e4c Linux-2.6.12-rc2 |
907 908 909 910 911 912 913 914 915 916 917 918 919 |
break; } break; default: snd_BUG(); break; } } /* * build mixers */ strcpy(chip->card->mixername, "PowerMac AWACS"); |
7ae44cfa7 [ALSA] snd-powerm... |
920 921 922 |
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers), snd_pmac_awacs_mixers); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
923 |
return err; |
4dbf95ba6 ALSA: snd-powerma... |
924 |
if (beige || g4agp) |
a8c2a6bf4 [ALSA] snd-powerm... |
925 |
; |
b0a8a8fd1 ALSA: powermac - ... |
926 |
else if (chip->model == PMAC_SCREAMER || pm5500) |
1da177e4c Linux-2.6.12-rc2 |
927 928 |
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2), snd_pmac_screamer_mixers2); |
a8c2a6bf4 [ALSA] snd-powerm... |
929 |
else if (!pm7500) |
1da177e4c Linux-2.6.12-rc2 |
930 931 932 933 |
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers2), snd_pmac_awacs_mixers2); if (err < 0) return err; |
dca7c7417 ALSA: Add vmaster... |
934 935 936 937 938 939 940 |
if (pm5500) { err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers2_pmac5500), snd_pmac_awacs_mixers2_pmac5500); if (err < 0) return err; } |
b268c34e5 ALSA: ppc/awacs: ... |
941 |
master_vol = NULL; |
a8c2a6bf4 [ALSA] snd-powerm... |
942 943 944 945 |
if (pm7500) err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers_pmac7500), snd_pmac_awacs_mixers_pmac7500); |
dca7c7417 ALSA: Add vmaster... |
946 947 948 949 |
else if (pm5500) err = snd_ctl_add(chip->card, (master_vol = snd_ctl_new1(snd_pmac_awacs_mixers_pmac5500, chip))); |
a8c2a6bf4 [ALSA] snd-powerm... |
950 951 952 953 |
else if (beige) err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers_beige), snd_pmac_screamer_mixers_beige); |
dca7c7417 ALSA: Add vmaster... |
954 955 956 957 958 959 |
else if (imac || lombard) { err = snd_ctl_add(chip->card, (master_vol = snd_ctl_new1(snd_pmac_screamer_mixers_lo, chip))); if (err < 0) return err; |
a8c2a6bf4 [ALSA] snd-powerm... |
960 961 962 |
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers_imac), snd_pmac_screamer_mixers_imac); |
dca7c7417 ALSA: Add vmaster... |
963 |
} else if (g4agp) |
4dbf95ba6 ALSA: snd-powerma... |
964 965 966 |
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers_g4agp), snd_pmac_screamer_mixers_g4agp); |
a8c2a6bf4 [ALSA] snd-powerm... |
967 968 969 970 971 972 |
else err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers_pmac), snd_pmac_awacs_mixers_pmac); if (err < 0) return err; |
573934bc0 ALSA: powermac - ... |
973 |
chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp || lombard) |
a8c2a6bf4 [ALSA] snd-powerm... |
974 |
? &snd_pmac_awacs_master_sw_imac |
dca7c7417 ALSA: Add vmaster... |
975 976 |
: pm5500 ? &snd_pmac_awacs_master_sw_pmac5500 |
a8c2a6bf4 [ALSA] snd-powerm... |
977 |
: &snd_pmac_awacs_master_sw, chip); |
7ae44cfa7 [ALSA] snd-powerm... |
978 979 |
err = snd_ctl_add(chip->card, chip->master_sw_ctl); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
980 981 982 983 984 985 986 987 988 |
return err; #ifdef PMAC_AMP_AVAIL if (chip->mixer_data) { /* use amplifier. the signal is connected from route A * to the amp. the amp has its headphone and speaker * volumes and mute switches, so we use them instead of * screamer registers. * in this case, it seems the route C is not used. */ |
7ae44cfa7 [ALSA] snd-powerm... |
989 990 991 |
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_amp_vol), snd_pmac_awacs_amp_vol); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
992 993 |
return err; /* overwrite */ |
7ae44cfa7 [ALSA] snd-powerm... |
994 995 996 997 |
chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw, chip); err = snd_ctl_add(chip->card, chip->master_sw_ctl); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
998 |
return err; |
7ae44cfa7 [ALSA] snd-powerm... |
999 1000 1001 1002 |
chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw, chip); err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
1003 1004 1005 1006 1007 |
return err; } else #endif /* PMAC_AMP_AVAIL */ { /* route A = headphone, route C = speaker */ |
dca7c7417 ALSA: Add vmaster... |
1008 1009 1010 |
err = snd_ctl_add(chip->card, (speaker_vol = snd_ctl_new1(snd_pmac_awacs_speaker_vol, chip))); |
7ae44cfa7 [ALSA] snd-powerm... |
1011 |
if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
1012 |
return err; |
030b655b0 ALSA: snd-powerma... |
1013 1014 1015 1016 |
chip->speaker_sw_ctl = snd_ctl_new1(imac1 ? &snd_pmac_awacs_speaker_sw_imac1 : imac2 ? &snd_pmac_awacs_speaker_sw_imac2 |
a8c2a6bf4 [ALSA] snd-powerm... |
1017 |
: &snd_pmac_awacs_speaker_sw, chip); |
7ae44cfa7 [ALSA] snd-powerm... |
1018 1019 |
err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
1020 1021 |
return err; } |
dca7c7417 ALSA: Add vmaster... |
1022 1023 1024 |
if (pm5500 || imac || lombard) { vmaster_sw = snd_ctl_make_virtual_master( "Master Playback Switch", (unsigned int *) NULL); |
9ab0cb309 ALSA: Replace the... |
1025 1026 |
err = snd_ctl_add_follower_uncached(vmaster_sw, chip->master_sw_ctl); |
dca7c7417 ALSA: Add vmaster... |
1027 1028 |
if (err < 0) return err; |
9ab0cb309 ALSA: Replace the... |
1029 1030 |
err = snd_ctl_add_follower_uncached(vmaster_sw, chip->speaker_sw_ctl); |
dca7c7417 ALSA: Add vmaster... |
1031 1032 1033 1034 1035 1036 1037 |
if (err < 0) return err; err = snd_ctl_add(chip->card, vmaster_sw); if (err < 0) return err; vmaster_vol = snd_ctl_make_virtual_master( "Master Playback Volume", (unsigned int *) NULL); |
9ab0cb309 ALSA: Replace the... |
1038 |
err = snd_ctl_add_follower(vmaster_vol, master_vol); |
dca7c7417 ALSA: Add vmaster... |
1039 1040 |
if (err < 0) return err; |
9ab0cb309 ALSA: Replace the... |
1041 |
err = snd_ctl_add_follower(vmaster_vol, speaker_vol); |
dca7c7417 ALSA: Add vmaster... |
1042 1043 1044 1045 1046 1047 |
if (err < 0) return err; err = snd_ctl_add(chip->card, vmaster_vol); if (err < 0) return err; } |
4dbf95ba6 ALSA: snd-powerma... |
1048 |
if (beige || g4agp) |
a8c2a6bf4 [ALSA] snd-powerm... |
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 |
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mic_boost_beige), snd_pmac_screamer_mic_boost_beige); else if (imac) err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mic_boost_imac), snd_pmac_screamer_mic_boost_imac); else if (chip->model == PMAC_SCREAMER) err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mic_boost), snd_pmac_screamer_mic_boost); else if (pm7500) err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mic_boost_pmac7500), snd_pmac_awacs_mic_boost_pmac7500); else err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mic_boost), snd_pmac_awacs_mic_boost); if (err < 0) return err; |
1da177e4c Linux-2.6.12-rc2 |
1069 1070 1071 1072 1073 |
/* * set lowlevel callbacks */ chip->set_format = snd_pmac_awacs_set_format; |
8c8709334 [PATCH] ppc32: Re... |
1074 |
#ifdef CONFIG_PM |
1da177e4c Linux-2.6.12-rc2 |
1075 1076 1077 1078 |
chip->suspend = snd_pmac_awacs_suspend; chip->resume = snd_pmac_awacs_resume; #endif #ifdef PMAC_SUPPORT_AUTOMUTE |
7ae44cfa7 [ALSA] snd-powerm... |
1079 1080 |
err = snd_pmac_add_automute(chip); if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
return err; chip->detect_headphone = snd_pmac_awacs_detect_headphone; chip->update_automute = snd_pmac_awacs_update_automute; snd_pmac_awacs_update_automute(chip, 0); /* update the status only */ #endif if (chip->model == PMAC_SCREAMER) { snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); } return 0; } |