aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/ice1724.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ice1712/ice1724.c')
-rw-r--r--sound/pci/ice1712/ice1724.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 71f08c036019..fce616c2761f 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
33#include <linux/mutex.h>
33#include <sound/core.h> 34#include <sound/core.h>
34#include <sound/info.h> 35#include <sound/info.h>
35#include <sound/mpu401.h> 36#include <sound/mpu401.h>
@@ -487,7 +488,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
487 int i, chs; 488 int i, chs;
488 489
489 chs = params_channels(hw_params); 490 chs = params_channels(hw_params);
490 down(&ice->open_mutex); 491 mutex_lock(&ice->open_mutex);
491 /* mark surround channels */ 492 /* mark surround channels */
492 if (substream == ice->playback_pro_substream) { 493 if (substream == ice->playback_pro_substream) {
493 /* PDMA0 can be multi-channel up to 8 */ 494 /* PDMA0 can be multi-channel up to 8 */
@@ -495,7 +496,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
495 for (i = 0; i < chs; i++) { 496 for (i = 0; i < chs; i++) {
496 if (ice->pcm_reserved[i] && 497 if (ice->pcm_reserved[i] &&
497 ice->pcm_reserved[i] != substream) { 498 ice->pcm_reserved[i] != substream) {
498 up(&ice->open_mutex); 499 mutex_unlock(&ice->open_mutex);
499 return -EBUSY; 500 return -EBUSY;
500 } 501 }
501 ice->pcm_reserved[i] = substream; 502 ice->pcm_reserved[i] = substream;
@@ -510,7 +511,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
510 if (ice->playback_con_substream_ds[i] == substream) { 511 if (ice->playback_con_substream_ds[i] == substream) {
511 if (ice->pcm_reserved[i] && 512 if (ice->pcm_reserved[i] &&
512 ice->pcm_reserved[i] != substream) { 513 ice->pcm_reserved[i] != substream) {
513 up(&ice->open_mutex); 514 mutex_unlock(&ice->open_mutex);
514 return -EBUSY; 515 return -EBUSY;
515 } 516 }
516 ice->pcm_reserved[i] = substream; 517 ice->pcm_reserved[i] = substream;
@@ -518,7 +519,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
518 } 519 }
519 } 520 }
520 } 521 }
521 up(&ice->open_mutex); 522 mutex_unlock(&ice->open_mutex);
522 snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); 523 snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0);
523 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 524 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
524} 525}
@@ -528,12 +529,12 @@ static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream)
528 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 529 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
529 int i; 530 int i;
530 531
531 down(&ice->open_mutex); 532 mutex_lock(&ice->open_mutex);
532 /* unmark surround channels */ 533 /* unmark surround channels */
533 for (i = 0; i < 3; i++) 534 for (i = 0; i < 3; i++)
534 if (ice->pcm_reserved[i] == substream) 535 if (ice->pcm_reserved[i] == substream)
535 ice->pcm_reserved[i] = NULL; 536 ice->pcm_reserved[i] = NULL;
536 up(&ice->open_mutex); 537 mutex_unlock(&ice->open_mutex);
537 return snd_pcm_lib_free_pages(substream); 538 return snd_pcm_lib_free_pages(substream);
538} 539}
539 540
@@ -778,7 +779,7 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
778 snd_pcm_set_sync(substream); 779 snd_pcm_set_sync(substream);
779 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 780 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
780 set_rate_constraints(ice, substream); 781 set_rate_constraints(ice, substream);
781 down(&ice->open_mutex); 782 mutex_lock(&ice->open_mutex);
782 /* calculate the currently available channels */ 783 /* calculate the currently available channels */
783 for (chs = 0; chs < 3; chs++) { 784 for (chs = 0; chs < 3; chs++) {
784 if (ice->pcm_reserved[chs]) 785 if (ice->pcm_reserved[chs])
@@ -788,7 +789,7 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
788 runtime->hw.channels_max = chs; 789 runtime->hw.channels_max = chs;
789 if (chs > 2) /* channels must be even */ 790 if (chs > 2) /* channels must be even */
790 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2); 791 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2);
791 up(&ice->open_mutex); 792 mutex_unlock(&ice->open_mutex);
792 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 793 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
793 VT1724_BUFFER_ALIGN); 794 VT1724_BUFFER_ALIGN);
794 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 795 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
@@ -1128,13 +1129,13 @@ static int snd_vt1724_playback_indep_open(struct snd_pcm_substream *substream)
1128 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1129 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1129 struct snd_pcm_runtime *runtime = substream->runtime; 1130 struct snd_pcm_runtime *runtime = substream->runtime;
1130 1131
1131 down(&ice->open_mutex); 1132 mutex_lock(&ice->open_mutex);
1132 /* already used by PDMA0? */ 1133 /* already used by PDMA0? */
1133 if (ice->pcm_reserved[substream->number]) { 1134 if (ice->pcm_reserved[substream->number]) {
1134 up(&ice->open_mutex); 1135 mutex_unlock(&ice->open_mutex);
1135 return -EBUSY; /* FIXME: should handle blocking mode properly */ 1136 return -EBUSY; /* FIXME: should handle blocking mode properly */
1136 } 1137 }
1137 up(&ice->open_mutex); 1138 mutex_unlock(&ice->open_mutex);
1138 runtime->private_data = &vt1724_playback_dma_regs[substream->number]; 1139 runtime->private_data = &vt1724_playback_dma_regs[substream->number];
1139 ice->playback_con_substream_ds[substream->number] = substream; 1140 ice->playback_con_substream_ds[substream->number] = substream;
1140 runtime->hw = snd_vt1724_2ch_stereo; 1141 runtime->hw = snd_vt1724_2ch_stereo;
@@ -1978,12 +1979,12 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
1978{ 1979{
1979 unsigned char val; 1980 unsigned char val;
1980 1981
1981 down(&ice->i2c_mutex); 1982 mutex_lock(&ice->i2c_mutex);
1982 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR)); 1983 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
1983 outb(dev & ~VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR)); 1984 outb(dev & ~VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR));
1984 wait_i2c_busy(ice); 1985 wait_i2c_busy(ice);
1985 val = inb(ICEREG1724(ice, I2C_DATA)); 1986 val = inb(ICEREG1724(ice, I2C_DATA));
1986 up(&ice->i2c_mutex); 1987 mutex_unlock(&ice->i2c_mutex);
1987 //printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val); 1988 //printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
1988 return val; 1989 return val;
1989} 1990}
@@ -1991,14 +1992,14 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
1991void snd_vt1724_write_i2c(struct snd_ice1712 *ice, 1992void snd_vt1724_write_i2c(struct snd_ice1712 *ice,
1992 unsigned char dev, unsigned char addr, unsigned char data) 1993 unsigned char dev, unsigned char addr, unsigned char data)
1993{ 1994{
1994 down(&ice->i2c_mutex); 1995 mutex_lock(&ice->i2c_mutex);
1995 wait_i2c_busy(ice); 1996 wait_i2c_busy(ice);
1996 //printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data); 1997 //printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
1997 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR)); 1998 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
1998 outb(data, ICEREG1724(ice, I2C_DATA)); 1999 outb(data, ICEREG1724(ice, I2C_DATA));
1999 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR)); 2000 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR));
2000 wait_i2c_busy(ice); 2001 wait_i2c_busy(ice);
2001 up(&ice->i2c_mutex); 2002 mutex_unlock(&ice->i2c_mutex);
2002} 2003}
2003 2004
2004static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice, 2005static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
@@ -2229,9 +2230,9 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2229 } 2230 }
2230 ice->vt1724 = 1; 2231 ice->vt1724 = 1;
2231 spin_lock_init(&ice->reg_lock); 2232 spin_lock_init(&ice->reg_lock);
2232 init_MUTEX(&ice->gpio_mutex); 2233 mutex_init(&ice->gpio_mutex);
2233 init_MUTEX(&ice->open_mutex); 2234 mutex_init(&ice->open_mutex);
2234 init_MUTEX(&ice->i2c_mutex); 2235 mutex_init(&ice->i2c_mutex);
2235 ice->gpio.set_mask = snd_vt1724_set_gpio_mask; 2236 ice->gpio.set_mask = snd_vt1724_set_gpio_mask;
2236 ice->gpio.set_dir = snd_vt1724_set_gpio_dir; 2237 ice->gpio.set_dir = snd_vt1724_set_gpio_dir;
2237 ice->gpio.set_data = snd_vt1724_set_gpio_data; 2238 ice->gpio.set_data = snd_vt1724_set_gpio_data;