]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/cx88/cx88-core.c
V4L/DVB (3266): Fix NICAM buzz on analog sound
[linux-2.6-omap-h63xx.git] / drivers / media / video / cx88 / cx88-core.c
index 194446f28c55c366b82a4f91f38222d0c5c9edfa..3720f24a25cf751744c0b389c856f6c5857d884b 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
+#include <linux/mutex.h>
 
 #include "cx88.h"
 #include <media/v4l2-common.h>
@@ -75,7 +76,7 @@ MODULE_PARM_DESC(nocomb,"disable comb filter");
 
 static unsigned int cx88_devcount;
 static LIST_HEAD(cx88_devlist);
-static DECLARE_MUTEX(devlist);
+static DEFINE_MUTEX(devlist);
 
 #define NO_SYNC_LINE (-1U)
 
@@ -786,12 +787,14 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
 
 int cx88_start_audio_dma(struct cx88_core *core)
 {
+       /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */
+       int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4;
        /* setup fifo + format */
-       cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
-       cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
+       cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], bpl, 0);
+       cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], bpl, 0);
 
-       cx_write(MO_AUDD_LNGTH,    128); /* fifo bpl size */
-       cx_write(MO_AUDR_LNGTH,    128); /* fifo bpl size */
+       cx_write(MO_AUDD_LNGTH, bpl); /* fifo bpl size */
+       cx_write(MO_AUDR_LNGTH, bpl); /* fifo bpl size */
 
        /* start dma */
        cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */
@@ -1036,7 +1039,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
        struct list_head *item;
        int i;
 
-       down(&devlist);
+       mutex_lock(&devlist);
        list_for_each(item,&cx88_devlist) {
                core = list_entry(item, struct cx88_core, devlist);
                if (pci->bus->number != core->pci_bus)
@@ -1047,7 +1050,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
                if (0 != get_ressources(core,pci))
                        goto fail_unlock;
                atomic_inc(&core->refcount);
-               up(&devlist);
+               mutex_unlock(&devlist);
                return core;
        }
        core = kzalloc(sizeof(*core),GFP_KERNEL);
@@ -1122,13 +1125,13 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
        cx88_card_setup(core);
        cx88_ir_init(core,pci);
 
-       up(&devlist);
+       mutex_unlock(&devlist);
        return core;
 
 fail_free:
        kfree(core);
 fail_unlock:
-       up(&devlist);
+       mutex_unlock(&devlist);
        return NULL;
 }
 
@@ -1140,14 +1143,14 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
        if (!atomic_dec_and_test(&core->refcount))
                return;
 
-       down(&devlist);
+       mutex_lock(&devlist);
        cx88_ir_fini(core);
        if (0 == core->i2c_rc)
                i2c_bit_del_bus(&core->i2c_adap);
        list_del(&core->devlist);
        iounmap(core->lmmio);
        cx88_devcount--;
-       up(&devlist);
+       mutex_unlock(&devlist);
        kfree(core);
 }