diff options
Diffstat (limited to 'sound/pci/es1968.c')
-rw-r--r-- | sound/pci/es1968.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 3747a436f0cd..dd465a186e11 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c | |||
@@ -100,9 +100,12 @@ | |||
100 | #include <linux/interrupt.h> | 100 | #include <linux/interrupt.h> |
101 | #include <linux/init.h> | 101 | #include <linux/init.h> |
102 | #include <linux/pci.h> | 102 | #include <linux/pci.h> |
103 | #include <linux/dma-mapping.h> | ||
103 | #include <linux/slab.h> | 104 | #include <linux/slab.h> |
104 | #include <linux/gameport.h> | 105 | #include <linux/gameport.h> |
105 | #include <linux/moduleparam.h> | 106 | #include <linux/moduleparam.h> |
107 | #include <linux/mutex.h> | ||
108 | |||
106 | #include <sound/core.h> | 109 | #include <sound/core.h> |
107 | #include <sound/pcm.h> | 110 | #include <sound/pcm.h> |
108 | #include <sound/mpu401.h> | 111 | #include <sound/mpu401.h> |
@@ -569,7 +572,7 @@ struct es1968 { | |||
569 | u16 maestro_map[32]; | 572 | u16 maestro_map[32]; |
570 | int bobclient; /* active timer instancs */ | 573 | int bobclient; /* active timer instancs */ |
571 | int bob_freq; /* timer frequency */ | 574 | int bob_freq; /* timer frequency */ |
572 | struct semaphore memory_mutex; /* memory lock */ | 575 | struct mutex memory_mutex; /* memory lock */ |
573 | 576 | ||
574 | /* APU states */ | 577 | /* APU states */ |
575 | unsigned char apu[NR_APUS]; | 578 | unsigned char apu[NR_APUS]; |
@@ -1356,13 +1359,13 @@ static int calc_available_memory_size(struct es1968 *chip) | |||
1356 | struct list_head *p; | 1359 | struct list_head *p; |
1357 | int max_size = 0; | 1360 | int max_size = 0; |
1358 | 1361 | ||
1359 | down(&chip->memory_mutex); | 1362 | mutex_lock(&chip->memory_mutex); |
1360 | list_for_each(p, &chip->buf_list) { | 1363 | list_for_each(p, &chip->buf_list) { |
1361 | struct esm_memory *buf = list_entry(p, struct esm_memory, list); | 1364 | struct esm_memory *buf = list_entry(p, struct esm_memory, list); |
1362 | if (buf->empty && buf->buf.bytes > max_size) | 1365 | if (buf->empty && buf->buf.bytes > max_size) |
1363 | max_size = buf->buf.bytes; | 1366 | max_size = buf->buf.bytes; |
1364 | } | 1367 | } |
1365 | up(&chip->memory_mutex); | 1368 | mutex_unlock(&chip->memory_mutex); |
1366 | if (max_size >= 128*1024) | 1369 | if (max_size >= 128*1024) |
1367 | max_size = 127*1024; | 1370 | max_size = 127*1024; |
1368 | return max_size; | 1371 | return max_size; |
@@ -1375,20 +1378,20 @@ static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size) | |||
1375 | struct list_head *p; | 1378 | struct list_head *p; |
1376 | 1379 | ||
1377 | size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN; | 1380 | size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN; |
1378 | down(&chip->memory_mutex); | 1381 | mutex_lock(&chip->memory_mutex); |
1379 | list_for_each(p, &chip->buf_list) { | 1382 | list_for_each(p, &chip->buf_list) { |
1380 | buf = list_entry(p, struct esm_memory, list); | 1383 | buf = list_entry(p, struct esm_memory, list); |
1381 | if (buf->empty && buf->buf.bytes >= size) | 1384 | if (buf->empty && buf->buf.bytes >= size) |
1382 | goto __found; | 1385 | goto __found; |
1383 | } | 1386 | } |
1384 | up(&chip->memory_mutex); | 1387 | mutex_unlock(&chip->memory_mutex); |
1385 | return NULL; | 1388 | return NULL; |
1386 | 1389 | ||
1387 | __found: | 1390 | __found: |
1388 | if (buf->buf.bytes > size) { | 1391 | if (buf->buf.bytes > size) { |
1389 | struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); | 1392 | struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); |
1390 | if (chunk == NULL) { | 1393 | if (chunk == NULL) { |
1391 | up(&chip->memory_mutex); | 1394 | mutex_unlock(&chip->memory_mutex); |
1392 | return NULL; | 1395 | return NULL; |
1393 | } | 1396 | } |
1394 | chunk->buf = buf->buf; | 1397 | chunk->buf = buf->buf; |
@@ -1400,7 +1403,7 @@ __found: | |||
1400 | list_add(&chunk->list, &buf->list); | 1403 | list_add(&chunk->list, &buf->list); |
1401 | } | 1404 | } |
1402 | buf->empty = 0; | 1405 | buf->empty = 0; |
1403 | up(&chip->memory_mutex); | 1406 | mutex_unlock(&chip->memory_mutex); |
1404 | return buf; | 1407 | return buf; |
1405 | } | 1408 | } |
1406 | 1409 | ||
@@ -1409,7 +1412,7 @@ static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf) | |||
1409 | { | 1412 | { |
1410 | struct esm_memory *chunk; | 1413 | struct esm_memory *chunk; |
1411 | 1414 | ||
1412 | down(&chip->memory_mutex); | 1415 | mutex_lock(&chip->memory_mutex); |
1413 | buf->empty = 1; | 1416 | buf->empty = 1; |
1414 | if (buf->list.prev != &chip->buf_list) { | 1417 | if (buf->list.prev != &chip->buf_list) { |
1415 | chunk = list_entry(buf->list.prev, struct esm_memory, list); | 1418 | chunk = list_entry(buf->list.prev, struct esm_memory, list); |
@@ -1428,7 +1431,7 @@ static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf) | |||
1428 | kfree(chunk); | 1431 | kfree(chunk); |
1429 | } | 1432 | } |
1430 | } | 1433 | } |
1431 | up(&chip->memory_mutex); | 1434 | mutex_unlock(&chip->memory_mutex); |
1432 | } | 1435 | } |
1433 | 1436 | ||
1434 | static void snd_es1968_free_dmabuf(struct es1968 *chip) | 1437 | static void snd_es1968_free_dmabuf(struct es1968 *chip) |
@@ -2559,8 +2562,8 @@ static int __devinit snd_es1968_create(struct snd_card *card, | |||
2559 | if ((err = pci_enable_device(pci)) < 0) | 2562 | if ((err = pci_enable_device(pci)) < 0) |
2560 | return err; | 2563 | return err; |
2561 | /* check, if we can restrict PCI DMA transfers to 28 bits */ | 2564 | /* check, if we can restrict PCI DMA transfers to 28 bits */ |
2562 | if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || | 2565 | if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || |
2563 | pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { | 2566 | pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { |
2564 | snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); | 2567 | snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); |
2565 | pci_disable_device(pci); | 2568 | pci_disable_device(pci); |
2566 | return -ENXIO; | 2569 | return -ENXIO; |
@@ -2579,7 +2582,7 @@ static int __devinit snd_es1968_create(struct snd_card *card, | |||
2579 | INIT_LIST_HEAD(&chip->buf_list); | 2582 | INIT_LIST_HEAD(&chip->buf_list); |
2580 | INIT_LIST_HEAD(&chip->substream_list); | 2583 | INIT_LIST_HEAD(&chip->substream_list); |
2581 | spin_lock_init(&chip->ac97_lock); | 2584 | spin_lock_init(&chip->ac97_lock); |
2582 | init_MUTEX(&chip->memory_mutex); | 2585 | mutex_init(&chip->memory_mutex); |
2583 | tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip); | 2586 | tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip); |
2584 | chip->card = card; | 2587 | chip->card = card; |
2585 | chip->pci = pci; | 2588 | chip->pci = pci; |