aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/pontis.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ice1712/pontis.c')
-rw-r--r--sound/pci/ice1712/pontis.c86
1 files changed, 44 insertions, 42 deletions
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 0dccd7707a4b..d23fb3fc2133 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -27,6 +27,8 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mutex.h>
31
30#include <sound/core.h> 32#include <sound/core.h>
31#include <sound/info.h> 33#include <sound/info.h>
32 34
@@ -124,13 +126,13 @@ static int wm_dac_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
124 unsigned short val; 126 unsigned short val;
125 int i; 127 int i;
126 128
127 down(&ice->gpio_mutex); 129 mutex_lock(&ice->gpio_mutex);
128 for (i = 0; i < 2; i++) { 130 for (i = 0; i < 2; i++) {
129 val = wm_get(ice, WM_DAC_ATTEN_L + i) & 0xff; 131 val = wm_get(ice, WM_DAC_ATTEN_L + i) & 0xff;
130 val = val > DAC_MIN ? (val - DAC_MIN) : 0; 132 val = val > DAC_MIN ? (val - DAC_MIN) : 0;
131 ucontrol->value.integer.value[i] = val; 133 ucontrol->value.integer.value[i] = val;
132 } 134 }
133 up(&ice->gpio_mutex); 135 mutex_unlock(&ice->gpio_mutex);
134 return 0; 136 return 0;
135} 137}
136 138
@@ -140,7 +142,7 @@ static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
140 unsigned short oval, nval; 142 unsigned short oval, nval;
141 int i, idx, change = 0; 143 int i, idx, change = 0;
142 144
143 down(&ice->gpio_mutex); 145 mutex_lock(&ice->gpio_mutex);
144 for (i = 0; i < 2; i++) { 146 for (i = 0; i < 2; i++) {
145 nval = ucontrol->value.integer.value[i]; 147 nval = ucontrol->value.integer.value[i];
146 nval = (nval ? (nval + DAC_MIN) : 0) & 0xff; 148 nval = (nval ? (nval + DAC_MIN) : 0) & 0xff;
@@ -152,7 +154,7 @@ static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
152 change = 1; 154 change = 1;
153 } 155 }
154 } 156 }
155 up(&ice->gpio_mutex); 157 mutex_unlock(&ice->gpio_mutex);
156 return change; 158 return change;
157} 159}
158 160
@@ -179,13 +181,13 @@ static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
179 unsigned short val; 181 unsigned short val;
180 int i; 182 int i;
181 183
182 down(&ice->gpio_mutex); 184 mutex_lock(&ice->gpio_mutex);
183 for (i = 0; i < 2; i++) { 185 for (i = 0; i < 2; i++) {
184 val = wm_get(ice, WM_ADC_ATTEN_L + i) & 0xff; 186 val = wm_get(ice, WM_ADC_ATTEN_L + i) & 0xff;
185 val = val > ADC_MIN ? (val - ADC_MIN) : 0; 187 val = val > ADC_MIN ? (val - ADC_MIN) : 0;
186 ucontrol->value.integer.value[i] = val; 188 ucontrol->value.integer.value[i] = val;
187 } 189 }
188 up(&ice->gpio_mutex); 190 mutex_unlock(&ice->gpio_mutex);
189 return 0; 191 return 0;
190} 192}
191 193
@@ -195,7 +197,7 @@ static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
195 unsigned short ovol, nvol; 197 unsigned short ovol, nvol;
196 int i, idx, change = 0; 198 int i, idx, change = 0;
197 199
198 down(&ice->gpio_mutex); 200 mutex_lock(&ice->gpio_mutex);
199 for (i = 0; i < 2; i++) { 201 for (i = 0; i < 2; i++) {
200 nvol = ucontrol->value.integer.value[i]; 202 nvol = ucontrol->value.integer.value[i];
201 nvol = nvol ? (nvol + ADC_MIN) : 0; 203 nvol = nvol ? (nvol + ADC_MIN) : 0;
@@ -206,7 +208,7 @@ static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
206 change = 1; 208 change = 1;
207 } 209 }
208 } 210 }
209 up(&ice->gpio_mutex); 211 mutex_unlock(&ice->gpio_mutex);
210 return change; 212 return change;
211} 213}
212 214
@@ -227,9 +229,9 @@ static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
227 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 229 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
228 int bit = kcontrol->private_value; 230 int bit = kcontrol->private_value;
229 231
230 down(&ice->gpio_mutex); 232 mutex_lock(&ice->gpio_mutex);
231 ucontrol->value.integer.value[0] = (wm_get(ice, WM_ADC_MUX) & (1 << bit)) ? 1 : 0; 233 ucontrol->value.integer.value[0] = (wm_get(ice, WM_ADC_MUX) & (1 << bit)) ? 1 : 0;
232 up(&ice->gpio_mutex); 234 mutex_unlock(&ice->gpio_mutex);
233 return 0; 235 return 0;
234} 236}
235 237
@@ -240,7 +242,7 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
240 unsigned short oval, nval; 242 unsigned short oval, nval;
241 int change; 243 int change;
242 244
243 down(&ice->gpio_mutex); 245 mutex_lock(&ice->gpio_mutex);
244 nval = oval = wm_get(ice, WM_ADC_MUX); 246 nval = oval = wm_get(ice, WM_ADC_MUX);
245 if (ucontrol->value.integer.value[0]) 247 if (ucontrol->value.integer.value[0])
246 nval |= (1 << bit); 248 nval |= (1 << bit);
@@ -250,7 +252,7 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
250 if (change) { 252 if (change) {
251 wm_put(ice, WM_ADC_MUX, nval); 253 wm_put(ice, WM_ADC_MUX, nval);
252 } 254 }
253 up(&ice->gpio_mutex); 255 mutex_unlock(&ice->gpio_mutex);
254 return 0; 256 return 0;
255} 257}
256 258
@@ -270,9 +272,9 @@ static int wm_bypass_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
270{ 272{
271 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 273 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
272 274
273 down(&ice->gpio_mutex); 275 mutex_lock(&ice->gpio_mutex);
274 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0; 276 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0;
275 up(&ice->gpio_mutex); 277 mutex_unlock(&ice->gpio_mutex);
276 return 0; 278 return 0;
277} 279}
278 280
@@ -282,7 +284,7 @@ static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
282 unsigned short val, oval; 284 unsigned short val, oval;
283 int change = 0; 285 int change = 0;
284 286
285 down(&ice->gpio_mutex); 287 mutex_lock(&ice->gpio_mutex);
286 val = oval = wm_get(ice, WM_OUT_MUX); 288 val = oval = wm_get(ice, WM_OUT_MUX);
287 if (ucontrol->value.integer.value[0]) 289 if (ucontrol->value.integer.value[0])
288 val |= 0x04; 290 val |= 0x04;
@@ -292,7 +294,7 @@ static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
292 wm_put(ice, WM_OUT_MUX, val); 294 wm_put(ice, WM_OUT_MUX, val);
293 change = 1; 295 change = 1;
294 } 296 }
295 up(&ice->gpio_mutex); 297 mutex_unlock(&ice->gpio_mutex);
296 return change; 298 return change;
297} 299}
298 300
@@ -312,9 +314,9 @@ static int wm_chswap_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
312{ 314{
313 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 315 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
314 316
315 down(&ice->gpio_mutex); 317 mutex_lock(&ice->gpio_mutex);
316 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL1) & 0xf0) != 0x90; 318 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL1) & 0xf0) != 0x90;
317 up(&ice->gpio_mutex); 319 mutex_unlock(&ice->gpio_mutex);
318 return 0; 320 return 0;
319} 321}
320 322
@@ -324,7 +326,7 @@ static int wm_chswap_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
324 unsigned short val, oval; 326 unsigned short val, oval;
325 int change = 0; 327 int change = 0;
326 328
327 down(&ice->gpio_mutex); 329 mutex_lock(&ice->gpio_mutex);
328 oval = wm_get(ice, WM_DAC_CTRL1); 330 oval = wm_get(ice, WM_DAC_CTRL1);
329 val = oval & 0x0f; 331 val = oval & 0x0f;
330 if (ucontrol->value.integer.value[0]) 332 if (ucontrol->value.integer.value[0])
@@ -336,7 +338,7 @@ static int wm_chswap_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
336 wm_put_nocache(ice, WM_DAC_CTRL1, val); 338 wm_put_nocache(ice, WM_DAC_CTRL1, val);
337 change = 1; 339 change = 1;
338 } 340 }
339 up(&ice->gpio_mutex); 341 mutex_unlock(&ice->gpio_mutex);
340 return change; 342 return change;
341} 343}
342 344
@@ -449,9 +451,9 @@ static int cs_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
449{ 451{
450 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 452 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
451 453
452 down(&ice->gpio_mutex); 454 mutex_lock(&ice->gpio_mutex);
453 ucontrol->value.enumerated.item[0] = ice->gpio.saved[0]; 455 ucontrol->value.enumerated.item[0] = ice->gpio.saved[0];
454 up(&ice->gpio_mutex); 456 mutex_unlock(&ice->gpio_mutex);
455 return 0; 457 return 0;
456} 458}
457 459
@@ -461,14 +463,14 @@ static int cs_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
461 unsigned char val; 463 unsigned char val;
462 int change = 0; 464 int change = 0;
463 465
464 down(&ice->gpio_mutex); 466 mutex_lock(&ice->gpio_mutex);
465 if (ucontrol->value.enumerated.item[0] != ice->gpio.saved[0]) { 467 if (ucontrol->value.enumerated.item[0] != ice->gpio.saved[0]) {
466 ice->gpio.saved[0] = ucontrol->value.enumerated.item[0] & 3; 468 ice->gpio.saved[0] = ucontrol->value.enumerated.item[0] & 3;
467 val = 0x80 | (ice->gpio.saved[0] << 3); 469 val = 0x80 | (ice->gpio.saved[0] << 3);
468 spi_write(ice, CS_DEV, 0x04, val); 470 spi_write(ice, CS_DEV, 0x04, val);
469 change = 1; 471 change = 1;
470 } 472 }
471 up(&ice->gpio_mutex); 473 mutex_unlock(&ice->gpio_mutex);
472 return 0; 474 return 0;
473} 475}
474 476
@@ -488,10 +490,10 @@ static int pontis_gpio_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_e
488static int pontis_gpio_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 490static int pontis_gpio_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
489{ 491{
490 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 492 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
491 down(&ice->gpio_mutex); 493 mutex_lock(&ice->gpio_mutex);
492 /* 4-7 reserved */ 494 /* 4-7 reserved */
493 ucontrol->value.integer.value[0] = (~ice->gpio.write_mask & 0xffff) | 0x00f0; 495 ucontrol->value.integer.value[0] = (~ice->gpio.write_mask & 0xffff) | 0x00f0;
494 up(&ice->gpio_mutex); 496 mutex_unlock(&ice->gpio_mutex);
495 return 0; 497 return 0;
496} 498}
497 499
@@ -500,22 +502,22 @@ static int pontis_gpio_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
500 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 502 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
501 unsigned int val; 503 unsigned int val;
502 int changed; 504 int changed;
503 down(&ice->gpio_mutex); 505 mutex_lock(&ice->gpio_mutex);
504 /* 4-7 reserved */ 506 /* 4-7 reserved */
505 val = (~ucontrol->value.integer.value[0] & 0xffff) | 0x00f0; 507 val = (~ucontrol->value.integer.value[0] & 0xffff) | 0x00f0;
506 changed = val != ice->gpio.write_mask; 508 changed = val != ice->gpio.write_mask;
507 ice->gpio.write_mask = val; 509 ice->gpio.write_mask = val;
508 up(&ice->gpio_mutex); 510 mutex_unlock(&ice->gpio_mutex);
509 return changed; 511 return changed;
510} 512}
511 513
512static int pontis_gpio_dir_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 514static int pontis_gpio_dir_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
513{ 515{
514 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 516 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
515 down(&ice->gpio_mutex); 517 mutex_lock(&ice->gpio_mutex);
516 /* 4-7 reserved */ 518 /* 4-7 reserved */
517 ucontrol->value.integer.value[0] = ice->gpio.direction & 0xff0f; 519 ucontrol->value.integer.value[0] = ice->gpio.direction & 0xff0f;
518 up(&ice->gpio_mutex); 520 mutex_unlock(&ice->gpio_mutex);
519 return 0; 521 return 0;
520} 522}
521 523
@@ -524,23 +526,23 @@ static int pontis_gpio_dir_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
524 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 526 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
525 unsigned int val; 527 unsigned int val;
526 int changed; 528 int changed;
527 down(&ice->gpio_mutex); 529 mutex_lock(&ice->gpio_mutex);
528 /* 4-7 reserved */ 530 /* 4-7 reserved */
529 val = ucontrol->value.integer.value[0] & 0xff0f; 531 val = ucontrol->value.integer.value[0] & 0xff0f;
530 changed = (val != ice->gpio.direction); 532 changed = (val != ice->gpio.direction);
531 ice->gpio.direction = val; 533 ice->gpio.direction = val;
532 up(&ice->gpio_mutex); 534 mutex_unlock(&ice->gpio_mutex);
533 return changed; 535 return changed;
534} 536}
535 537
536static int pontis_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 538static int pontis_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
537{ 539{
538 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 540 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
539 down(&ice->gpio_mutex); 541 mutex_lock(&ice->gpio_mutex);
540 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); 542 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
541 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask); 543 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
542 ucontrol->value.integer.value[0] = snd_ice1712_gpio_read(ice) & 0xffff; 544 ucontrol->value.integer.value[0] = snd_ice1712_gpio_read(ice) & 0xffff;
543 up(&ice->gpio_mutex); 545 mutex_unlock(&ice->gpio_mutex);
544 return 0; 546 return 0;
545} 547}
546 548
@@ -549,7 +551,7 @@ static int pontis_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
549 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 551 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
550 unsigned int val, nval; 552 unsigned int val, nval;
551 int changed = 0; 553 int changed = 0;
552 down(&ice->gpio_mutex); 554 mutex_lock(&ice->gpio_mutex);
553 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); 555 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
554 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask); 556 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
555 val = snd_ice1712_gpio_read(ice) & 0xffff; 557 val = snd_ice1712_gpio_read(ice) & 0xffff;
@@ -558,7 +560,7 @@ static int pontis_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
558 snd_ice1712_gpio_write(ice, nval); 560 snd_ice1712_gpio_write(ice, nval);
559 changed = 1; 561 changed = 1;
560 } 562 }
561 up(&ice->gpio_mutex); 563 mutex_unlock(&ice->gpio_mutex);
562 return changed; 564 return changed;
563} 565}
564 566
@@ -651,14 +653,14 @@ static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buf
651 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 653 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
652 char line[64]; 654 char line[64];
653 unsigned int reg, val; 655 unsigned int reg, val;
654 down(&ice->gpio_mutex); 656 mutex_lock(&ice->gpio_mutex);
655 while (!snd_info_get_line(buffer, line, sizeof(line))) { 657 while (!snd_info_get_line(buffer, line, sizeof(line))) {
656 if (sscanf(line, "%x %x", &reg, &val) != 2) 658 if (sscanf(line, "%x %x", &reg, &val) != 2)
657 continue; 659 continue;
658 if (reg <= 0x17 && val <= 0xffff) 660 if (reg <= 0x17 && val <= 0xffff)
659 wm_put(ice, reg, val); 661 wm_put(ice, reg, val);
660 } 662 }
661 up(&ice->gpio_mutex); 663 mutex_unlock(&ice->gpio_mutex);
662} 664}
663 665
664static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 666static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
@@ -666,12 +668,12 @@ static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff
666 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 668 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
667 int reg, val; 669 int reg, val;
668 670
669 down(&ice->gpio_mutex); 671 mutex_lock(&ice->gpio_mutex);
670 for (reg = 0; reg <= 0x17; reg++) { 672 for (reg = 0; reg <= 0x17; reg++) {
671 val = wm_get(ice, reg); 673 val = wm_get(ice, reg);
672 snd_iprintf(buffer, "%02x = %04x\n", reg, val); 674 snd_iprintf(buffer, "%02x = %04x\n", reg, val);
673 } 675 }
674 up(&ice->gpio_mutex); 676 mutex_unlock(&ice->gpio_mutex);
675} 677}
676 678
677static void wm_proc_init(struct snd_ice1712 *ice) 679static void wm_proc_init(struct snd_ice1712 *ice)
@@ -690,14 +692,14 @@ static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff
690 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 692 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
691 int reg, val; 693 int reg, val;
692 694
693 down(&ice->gpio_mutex); 695 mutex_lock(&ice->gpio_mutex);
694 for (reg = 0; reg <= 0x26; reg++) { 696 for (reg = 0; reg <= 0x26; reg++) {
695 val = spi_read(ice, CS_DEV, reg); 697 val = spi_read(ice, CS_DEV, reg);
696 snd_iprintf(buffer, "%02x = %02x\n", reg, val); 698 snd_iprintf(buffer, "%02x = %02x\n", reg, val);
697 } 699 }
698 val = spi_read(ice, CS_DEV, 0x7f); 700 val = spi_read(ice, CS_DEV, 0x7f);
699 snd_iprintf(buffer, "%02x = %02x\n", 0x7f, val); 701 snd_iprintf(buffer, "%02x = %02x\n", 0x7f, val);
700 up(&ice->gpio_mutex); 702 mutex_unlock(&ice->gpio_mutex);
701} 703}
702 704
703static void cs_proc_init(struct snd_ice1712 *ice) 705static void cs_proc_init(struct snd_ice1712 *ice)