]> err.no Git - linux-2.6/blobdiff - sound/pci/cs46xx/dsp_spos.c
Documentation: correct values in MPC8548E SEC example node
[linux-2.6] / sound / pci / cs46xx / dsp_spos.c
index ac98917a1475e28bc310708033f104514b531e95..5c9711c0265c85eadd11a3958607ef0090f1220c 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#include <linux/mutex.h>
+
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/info.h>
@@ -235,7 +237,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip)
 
        if (ins->symbol_table.symbols == NULL) {
                cs46xx_dsp_spos_destroy(chip);
-               return NULL;
+               goto error;
        }
 
        ins->code.offset = 0;
@@ -244,7 +246,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip)
 
        if (ins->code.data == NULL) {
                cs46xx_dsp_spos_destroy(chip);
-               return NULL;
+               goto error;
        }
 
        ins->nscb = 0;
@@ -255,7 +257,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip)
 
        if (ins->modules == NULL) {
                cs46xx_dsp_spos_destroy(chip);
-               return NULL;
+               goto error;
        }
 
        /* default SPDIF input sample rate
@@ -278,6 +280,10 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip)
         /* left and right validity bits */ (1 << 13) | (1 << 12);
 
        return ins;
+
+error:
+       kfree(ins);
+       return NULL;
 }
 
 void  cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
@@ -287,7 +293,7 @@ void  cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
 
        snd_assert(ins != NULL, return);
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        for (i = 0; i < ins->nscb; ++i) {
                if (ins->scbs[i].deleted) continue;
 
@@ -298,7 +304,7 @@ void  cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
        vfree(ins->symbol_table.symbols);
        kfree(ins->modules);
        kfree(ins);
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 }
 
 int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module)
@@ -439,6 +445,7 @@ cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, int symb
 }
 
 
+#ifdef CONFIG_PROC_FS
 static struct dsp_symbol_entry *
 cs46xx_dsp_lookup_symbol_addr (struct snd_cs46xx * chip, u32 address, int symbol_type)
 {
@@ -496,7 +503,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry,
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
        int i,j;
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        snd_iprintf(buffer, "MODULES:\n");
        for ( i = 0; i < ins->nmodules; ++i ) {
                snd_iprintf(buffer, "\n%s:\n", ins->modules[i].module_name);
@@ -509,7 +516,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry,
                                    desc->segment_type,desc->offset, desc->size);
                }
        }
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 }
 
 static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry,
@@ -520,7 +527,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry,
        int i, j, col;
        void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        snd_iprintf(buffer, "TASK TREES:\n");
        for ( i = 0; i < ins->ntask; ++i) {
                snd_iprintf(buffer,"\n%04x %s:\n",ins->tasks[i].address,ins->tasks[i].task_name);
@@ -537,7 +544,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry,
        }
 
        snd_iprintf(buffer,"\n");  
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 }
 
 static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry,
@@ -547,7 +554,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry,
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
        int i;
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        snd_iprintf(buffer, "SCB's:\n");
        for ( i = 0; i < ins->nscb; ++i) {
                if (ins->scbs[i].deleted)
@@ -570,7 +577,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry,
        }
 
        snd_iprintf(buffer,"\n");
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 }
 
 static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry,
@@ -760,7 +767,6 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
        if ((entry = snd_info_create_card_entry(card, "dsp", card->proc_root)) != NULL) {
                entry->content = SNDRV_INFO_CONTENT_TEXT;
                entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
-               entry->c.text.read_size = 512;
       
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
@@ -777,7 +783,6 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
                entry->content = SNDRV_INFO_CONTENT_TEXT;
                entry->private_data = chip;
                entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
-               entry->c.text.read_size = 512;
                entry->c.text.read = cs46xx_dsp_proc_symbol_table_read;
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
@@ -790,7 +795,6 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
                entry->content = SNDRV_INFO_CONTENT_TEXT;
                entry->private_data = chip;
                entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
-               entry->c.text.read_size = 512;
                entry->c.text.read = cs46xx_dsp_proc_modules_read;
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
@@ -803,7 +807,6 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
                entry->content = SNDRV_INFO_CONTENT_TEXT;
                entry->private_data = chip;
                entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
-               entry->c.text.read_size = 512;
                entry->c.text.read = cs46xx_dsp_proc_parameter_dump_read;
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
@@ -816,7 +819,6 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
                entry->content = SNDRV_INFO_CONTENT_TEXT;
                entry->private_data = chip;
                entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
-               entry->c.text.read_size = 512;
                entry->c.text.read = cs46xx_dsp_proc_sample_dump_read;
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
@@ -829,7 +831,6 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
                entry->content = SNDRV_INFO_CONTENT_TEXT;
                entry->private_data = chip;
                entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
-               entry->c.text.read_size = 512;
                entry->c.text.read = cs46xx_dsp_proc_task_tree_read;
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
@@ -842,7 +843,6 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
                entry->content = SNDRV_INFO_CONTENT_TEXT;
                entry->private_data = chip;
                entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
-               entry->c.text.read_size = 1024;
                entry->c.text.read = cs46xx_dsp_proc_scb_read;
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
@@ -851,14 +851,14 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
        }
        ins->proc_scb_info_entry = entry;
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        /* register/update SCB's entries on proc */
        for (i = 0; i < ins->nscb; ++i) {
                if (ins->scbs[i].deleted) continue;
 
                cs46xx_dsp_proc_register_scb_desc (chip, (ins->scbs + i));
        }
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }
@@ -898,12 +898,12 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip)
                ins->proc_task_info_entry = NULL;
        }
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        for (i = 0; i < ins->nscb; ++i) {
                if (ins->scbs[i].deleted) continue;
                cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) );
        }
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        if (ins->proc_dsp_dir) {
                snd_info_unregister (ins->proc_dsp_dir);
@@ -912,6 +912,7 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip)
 
        return 0;
 }
+#endif /* CONFIG_PROC_FS */
 
 static int debug_tree;
 static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data,
@@ -1692,7 +1693,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip)
        snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL);
        snd_assert (ins->spdif_in_src != NULL,return -EINVAL);
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
 
        if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED) ) {
                /* time countdown enable */
@@ -1736,7 +1737,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip)
 
        /* monitor state */
        ins->spdif_status_in = 1;
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }
@@ -1748,7 +1749,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip)
        snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL);
        snd_assert (ins->spdif_in_src != NULL,return -EINVAL);  
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
 
        /* Remove the asynchronous receiver SCB */
        cs46xx_dsp_remove_scb (chip,ins->asynch_rx_scb);
@@ -1758,7 +1759,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip)
 
        /* monitor state */
        ins->spdif_status_in = 0;
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        /* restore amplifier */
        chip->active_ctrl(chip, -1);
@@ -1774,10 +1775,10 @@ int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip)
        snd_assert (ins->pcm_input == NULL,return -EINVAL);
        snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL);
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR,
                                                   "PCMSerialInput_Wave");
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }
@@ -1788,10 +1789,10 @@ int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip)
 
        snd_assert (ins->pcm_input != NULL,return -EINVAL);
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        cs46xx_dsp_remove_scb (chip,ins->pcm_input);
        ins->pcm_input = NULL;
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }
@@ -1803,10 +1804,10 @@ int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip)
        snd_assert (ins->adc_input == NULL,return -EINVAL);
        snd_assert (ins->codec_in_scb != NULL,return -EINVAL);
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR,
                                                  "PCMSerialInput_ADC");
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }
@@ -1817,10 +1818,10 @@ int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip)
 
        snd_assert (ins->adc_input != NULL,return -EINVAL);
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        cs46xx_dsp_remove_scb (chip,ins->adc_input);
        ins->adc_input = NULL;
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }
@@ -1867,7 +1868,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right)
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
        struct dsp_scb_descriptor * scb; 
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
        
        /* main output */
        scb = ins->master_mix_scb->sub_list_ptr;
@@ -1886,7 +1887,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right)
        ins->dac_volume_left = left;
        ins->dac_volume_right = right;
 
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }
@@ -1895,7 +1896,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right)
 {
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       down(&chip->spos_mutex);
+       mutex_lock(&chip->spos_mutex);
 
        if (ins->asynch_rx_scb != NULL)
                cs46xx_dsp_scb_set_volume (chip,ins->asynch_rx_scb,
@@ -1904,7 +1905,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right)
        ins->spdif_input_volume_left = left;
        ins->spdif_input_volume_right = right;
 
-       up(&chip->spos_mutex);
+       mutex_unlock(&chip->spos_mutex);
 
        return 0;
 }