diff options
Diffstat (limited to 'sound/pci/ac97/ac97_codec.c')
-rw-r--r-- | sound/pci/ac97/ac97_codec.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 3020ca2b602b..6108cdc5efb6 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
31 | #include <linux/mutex.h> | ||
31 | #include <sound/core.h> | 32 | #include <sound/core.h> |
32 | #include <sound/pcm.h> | 33 | #include <sound/pcm.h> |
33 | #include <sound/ac97_codec.h> | 34 | #include <sound/ac97_codec.h> |
@@ -296,11 +297,11 @@ void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned sh | |||
296 | { | 297 | { |
297 | if (!snd_ac97_valid_reg(ac97, reg)) | 298 | if (!snd_ac97_valid_reg(ac97, reg)) |
298 | return; | 299 | return; |
299 | down(&ac97->reg_mutex); | 300 | mutex_lock(&ac97->reg_mutex); |
300 | ac97->regs[reg] = value; | 301 | ac97->regs[reg] = value; |
301 | ac97->bus->ops->write(ac97, reg, value); | 302 | ac97->bus->ops->write(ac97, reg, value); |
302 | set_bit(reg, ac97->reg_accessed); | 303 | set_bit(reg, ac97->reg_accessed); |
303 | up(&ac97->reg_mutex); | 304 | mutex_unlock(&ac97->reg_mutex); |
304 | } | 305 | } |
305 | 306 | ||
306 | /** | 307 | /** |
@@ -321,14 +322,14 @@ int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short va | |||
321 | 322 | ||
322 | if (!snd_ac97_valid_reg(ac97, reg)) | 323 | if (!snd_ac97_valid_reg(ac97, reg)) |
323 | return -EINVAL; | 324 | return -EINVAL; |
324 | down(&ac97->reg_mutex); | 325 | mutex_lock(&ac97->reg_mutex); |
325 | change = ac97->regs[reg] != value; | 326 | change = ac97->regs[reg] != value; |
326 | if (change) { | 327 | if (change) { |
327 | ac97->regs[reg] = value; | 328 | ac97->regs[reg] = value; |
328 | ac97->bus->ops->write(ac97, reg, value); | 329 | ac97->bus->ops->write(ac97, reg, value); |
329 | } | 330 | } |
330 | set_bit(reg, ac97->reg_accessed); | 331 | set_bit(reg, ac97->reg_accessed); |
331 | up(&ac97->reg_mutex); | 332 | mutex_unlock(&ac97->reg_mutex); |
332 | return change; | 333 | return change; |
333 | } | 334 | } |
334 | 335 | ||
@@ -351,9 +352,9 @@ int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned sho | |||
351 | 352 | ||
352 | if (!snd_ac97_valid_reg(ac97, reg)) | 353 | if (!snd_ac97_valid_reg(ac97, reg)) |
353 | return -EINVAL; | 354 | return -EINVAL; |
354 | down(&ac97->reg_mutex); | 355 | mutex_lock(&ac97->reg_mutex); |
355 | change = snd_ac97_update_bits_nolock(ac97, reg, mask, value); | 356 | change = snd_ac97_update_bits_nolock(ac97, reg, mask, value); |
356 | up(&ac97->reg_mutex); | 357 | mutex_unlock(&ac97->reg_mutex); |
357 | return change; | 358 | return change; |
358 | } | 359 | } |
359 | 360 | ||
@@ -380,12 +381,12 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns | |||
380 | int change; | 381 | int change; |
381 | unsigned short old, new, cfg; | 382 | unsigned short old, new, cfg; |
382 | 383 | ||
383 | down(&ac97->page_mutex); | 384 | mutex_lock(&ac97->page_mutex); |
384 | old = ac97->spec.ad18xx.pcmreg[codec]; | 385 | old = ac97->spec.ad18xx.pcmreg[codec]; |
385 | new = (old & ~mask) | value; | 386 | new = (old & ~mask) | value; |
386 | change = old != new; | 387 | change = old != new; |
387 | if (change) { | 388 | if (change) { |
388 | down(&ac97->reg_mutex); | 389 | mutex_lock(&ac97->reg_mutex); |
389 | cfg = snd_ac97_read_cache(ac97, AC97_AD_SERIAL_CFG); | 390 | cfg = snd_ac97_read_cache(ac97, AC97_AD_SERIAL_CFG); |
390 | ac97->spec.ad18xx.pcmreg[codec] = new; | 391 | ac97->spec.ad18xx.pcmreg[codec] = new; |
391 | /* select single codec */ | 392 | /* select single codec */ |
@@ -397,9 +398,9 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns | |||
397 | /* select all codecs */ | 398 | /* select all codecs */ |
398 | ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG, | 399 | ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG, |
399 | cfg | 0x7000); | 400 | cfg | 0x7000); |
400 | up(&ac97->reg_mutex); | 401 | mutex_unlock(&ac97->reg_mutex); |
401 | } | 402 | } |
402 | up(&ac97->page_mutex); | 403 | mutex_unlock(&ac97->page_mutex); |
403 | return change; | 404 | return change; |
404 | } | 405 | } |
405 | 406 | ||
@@ -467,7 +468,7 @@ static int snd_ac97_page_save(struct snd_ac97 *ac97, int reg, struct snd_kcontro | |||
467 | (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 && | 468 | (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 && |
468 | (reg >= 0x60 && reg < 0x70)) { | 469 | (reg >= 0x60 && reg < 0x70)) { |
469 | unsigned short page = (kcontrol->private_value >> 26) & 0x0f; | 470 | unsigned short page = (kcontrol->private_value >> 26) & 0x0f; |
470 | down(&ac97->page_mutex); /* lock paging */ | 471 | mutex_lock(&ac97->page_mutex); /* lock paging */ |
471 | page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK; | 472 | page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK; |
472 | snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page); | 473 | snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page); |
473 | } | 474 | } |
@@ -478,7 +479,7 @@ static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save) | |||
478 | { | 479 | { |
479 | if (page_save >= 0) { | 480 | if (page_save >= 0) { |
480 | snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save); | 481 | snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save); |
481 | up(&ac97->page_mutex); /* unlock paging */ | 482 | mutex_unlock(&ac97->page_mutex); /* unlock paging */ |
482 | } | 483 | } |
483 | } | 484 | } |
484 | 485 | ||
@@ -674,12 +675,12 @@ static int snd_ac97_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ | |||
674 | { | 675 | { |
675 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); | 676 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); |
676 | 677 | ||
677 | down(&ac97->reg_mutex); | 678 | mutex_lock(&ac97->reg_mutex); |
678 | ucontrol->value.iec958.status[0] = ac97->spdif_status & 0xff; | 679 | ucontrol->value.iec958.status[0] = ac97->spdif_status & 0xff; |
679 | ucontrol->value.iec958.status[1] = (ac97->spdif_status >> 8) & 0xff; | 680 | ucontrol->value.iec958.status[1] = (ac97->spdif_status >> 8) & 0xff; |
680 | ucontrol->value.iec958.status[2] = (ac97->spdif_status >> 16) & 0xff; | 681 | ucontrol->value.iec958.status[2] = (ac97->spdif_status >> 16) & 0xff; |
681 | ucontrol->value.iec958.status[3] = (ac97->spdif_status >> 24) & 0xff; | 682 | ucontrol->value.iec958.status[3] = (ac97->spdif_status >> 24) & 0xff; |
682 | up(&ac97->reg_mutex); | 683 | mutex_unlock(&ac97->reg_mutex); |
683 | return 0; | 684 | return 0; |
684 | } | 685 | } |
685 | 686 | ||
@@ -718,7 +719,7 @@ static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ | |||
718 | } | 719 | } |
719 | } | 720 | } |
720 | 721 | ||
721 | down(&ac97->reg_mutex); | 722 | mutex_lock(&ac97->reg_mutex); |
722 | change = ac97->spdif_status != new; | 723 | change = ac97->spdif_status != new; |
723 | ac97->spdif_status = new; | 724 | ac97->spdif_status = new; |
724 | 725 | ||
@@ -746,7 +747,7 @@ static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ | |||
746 | snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ | 747 | snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ |
747 | } | 748 | } |
748 | } | 749 | } |
749 | up(&ac97->reg_mutex); | 750 | mutex_unlock(&ac97->reg_mutex); |
750 | 751 | ||
751 | return change; | 752 | return change; |
752 | } | 753 | } |
@@ -763,7 +764,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_ | |||
763 | 764 | ||
764 | value = (ucontrol->value.integer.value[0] & mask); | 765 | value = (ucontrol->value.integer.value[0] & mask); |
765 | 766 | ||
766 | down(&ac97->reg_mutex); | 767 | mutex_lock(&ac97->reg_mutex); |
767 | mask <<= shift; | 768 | mask <<= shift; |
768 | value <<= shift; | 769 | value <<= shift; |
769 | old = snd_ac97_read_cache(ac97, reg); | 770 | old = snd_ac97_read_cache(ac97, reg); |
@@ -777,7 +778,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_ | |||
777 | if (extst & AC97_EA_SPDIF) | 778 | if (extst & AC97_EA_SPDIF) |
778 | snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ | 779 | snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ |
779 | } | 780 | } |
780 | up(&ac97->reg_mutex); | 781 | mutex_unlock(&ac97->reg_mutex); |
781 | return change; | 782 | return change; |
782 | } | 783 | } |
783 | 784 | ||
@@ -888,10 +889,10 @@ static int snd_ac97_ad18xx_pcm_get_volume(struct snd_kcontrol *kcontrol, struct | |||
888 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); | 889 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); |
889 | int codec = kcontrol->private_value & 3; | 890 | int codec = kcontrol->private_value & 3; |
890 | 891 | ||
891 | down(&ac97->page_mutex); | 892 | mutex_lock(&ac97->page_mutex); |
892 | ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); | 893 | ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); |
893 | ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); | 894 | ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); |
894 | up(&ac97->page_mutex); | 895 | mutex_unlock(&ac97->page_mutex); |
895 | return 0; | 896 | return 0; |
896 | } | 897 | } |
897 | 898 | ||
@@ -1856,8 +1857,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, | |||
1856 | ac97->limited_regs = template->limited_regs; | 1857 | ac97->limited_regs = template->limited_regs; |
1857 | memcpy(ac97->reg_accessed, template->reg_accessed, sizeof(ac97->reg_accessed)); | 1858 | memcpy(ac97->reg_accessed, template->reg_accessed, sizeof(ac97->reg_accessed)); |
1858 | bus->codec[ac97->num] = ac97; | 1859 | bus->codec[ac97->num] = ac97; |
1859 | init_MUTEX(&ac97->reg_mutex); | 1860 | mutex_init(&ac97->reg_mutex); |
1860 | init_MUTEX(&ac97->page_mutex); | 1861 | mutex_init(&ac97->page_mutex); |
1861 | 1862 | ||
1862 | #ifdef CONFIG_PCI | 1863 | #ifdef CONFIG_PCI |
1863 | if (ac97->pci) { | 1864 | if (ac97->pci) { |