diff options
Diffstat (limited to 'sound/pci/cs46xx/dsp_spos.c')
| -rw-r--r-- | sound/pci/cs46xx/dsp_spos.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index 445a448949e7..f407d2a5ce3b 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
| 29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
| 30 | #include <linux/vmalloc.h> | 30 | #include <linux/vmalloc.h> |
| 31 | #include <linux/mutex.h> | ||
| 32 | |||
| 31 | #include <sound/core.h> | 33 | #include <sound/core.h> |
| 32 | #include <sound/control.h> | 34 | #include <sound/control.h> |
| 33 | #include <sound/info.h> | 35 | #include <sound/info.h> |
| @@ -235,7 +237,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) | |||
| 235 | 237 | ||
| 236 | if (ins->symbol_table.symbols == NULL) { | 238 | if (ins->symbol_table.symbols == NULL) { |
| 237 | cs46xx_dsp_spos_destroy(chip); | 239 | cs46xx_dsp_spos_destroy(chip); |
| 238 | return NULL; | 240 | goto error; |
| 239 | } | 241 | } |
| 240 | 242 | ||
| 241 | ins->code.offset = 0; | 243 | ins->code.offset = 0; |
| @@ -244,7 +246,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) | |||
| 244 | 246 | ||
| 245 | if (ins->code.data == NULL) { | 247 | if (ins->code.data == NULL) { |
| 246 | cs46xx_dsp_spos_destroy(chip); | 248 | cs46xx_dsp_spos_destroy(chip); |
| 247 | return NULL; | 249 | goto error; |
| 248 | } | 250 | } |
| 249 | 251 | ||
| 250 | ins->nscb = 0; | 252 | ins->nscb = 0; |
| @@ -255,7 +257,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) | |||
| 255 | 257 | ||
| 256 | if (ins->modules == NULL) { | 258 | if (ins->modules == NULL) { |
| 257 | cs46xx_dsp_spos_destroy(chip); | 259 | cs46xx_dsp_spos_destroy(chip); |
| 258 | return NULL; | 260 | goto error; |
| 259 | } | 261 | } |
| 260 | 262 | ||
| 261 | /* default SPDIF input sample rate | 263 | /* default SPDIF input sample rate |
| @@ -278,6 +280,10 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) | |||
| 278 | /* left and right validity bits */ (1 << 13) | (1 << 12); | 280 | /* left and right validity bits */ (1 << 13) | (1 << 12); |
| 279 | 281 | ||
| 280 | return ins; | 282 | return ins; |
| 283 | |||
| 284 | error: | ||
| 285 | kfree(ins); | ||
| 286 | return NULL; | ||
| 281 | } | 287 | } |
| 282 | 288 | ||
| 283 | void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) | 289 | void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) |
| @@ -287,7 +293,7 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) | |||
| 287 | 293 | ||
| 288 | snd_assert(ins != NULL, return); | 294 | snd_assert(ins != NULL, return); |
| 289 | 295 | ||
| 290 | down(&chip->spos_mutex); | 296 | mutex_lock(&chip->spos_mutex); |
| 291 | for (i = 0; i < ins->nscb; ++i) { | 297 | for (i = 0; i < ins->nscb; ++i) { |
| 292 | if (ins->scbs[i].deleted) continue; | 298 | if (ins->scbs[i].deleted) continue; |
| 293 | 299 | ||
| @@ -298,7 +304,7 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) | |||
| 298 | vfree(ins->symbol_table.symbols); | 304 | vfree(ins->symbol_table.symbols); |
| 299 | kfree(ins->modules); | 305 | kfree(ins->modules); |
| 300 | kfree(ins); | 306 | kfree(ins); |
| 301 | up(&chip->spos_mutex); | 307 | mutex_unlock(&chip->spos_mutex); |
| 302 | } | 308 | } |
| 303 | 309 | ||
| 304 | int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module) | 310 | int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module) |
| @@ -497,7 +503,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry, | |||
| 497 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 503 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
| 498 | int i,j; | 504 | int i,j; |
| 499 | 505 | ||
| 500 | down(&chip->spos_mutex); | 506 | mutex_lock(&chip->spos_mutex); |
| 501 | snd_iprintf(buffer, "MODULES:\n"); | 507 | snd_iprintf(buffer, "MODULES:\n"); |
| 502 | for ( i = 0; i < ins->nmodules; ++i ) { | 508 | for ( i = 0; i < ins->nmodules; ++i ) { |
| 503 | snd_iprintf(buffer, "\n%s:\n", ins->modules[i].module_name); | 509 | snd_iprintf(buffer, "\n%s:\n", ins->modules[i].module_name); |
| @@ -510,7 +516,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry, | |||
| 510 | desc->segment_type,desc->offset, desc->size); | 516 | desc->segment_type,desc->offset, desc->size); |
| 511 | } | 517 | } |
| 512 | } | 518 | } |
| 513 | up(&chip->spos_mutex); | 519 | mutex_unlock(&chip->spos_mutex); |
| 514 | } | 520 | } |
| 515 | 521 | ||
| 516 | static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, | 522 | static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, |
| @@ -521,7 +527,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, | |||
| 521 | int i, j, col; | 527 | int i, j, col; |
| 522 | void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; | 528 | void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; |
| 523 | 529 | ||
| 524 | down(&chip->spos_mutex); | 530 | mutex_lock(&chip->spos_mutex); |
| 525 | snd_iprintf(buffer, "TASK TREES:\n"); | 531 | snd_iprintf(buffer, "TASK TREES:\n"); |
| 526 | for ( i = 0; i < ins->ntask; ++i) { | 532 | for ( i = 0; i < ins->ntask; ++i) { |
| 527 | snd_iprintf(buffer,"\n%04x %s:\n",ins->tasks[i].address,ins->tasks[i].task_name); | 533 | snd_iprintf(buffer,"\n%04x %s:\n",ins->tasks[i].address,ins->tasks[i].task_name); |
| @@ -538,7 +544,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, | |||
| 538 | } | 544 | } |
| 539 | 545 | ||
| 540 | snd_iprintf(buffer,"\n"); | 546 | snd_iprintf(buffer,"\n"); |
| 541 | up(&chip->spos_mutex); | 547 | mutex_unlock(&chip->spos_mutex); |
| 542 | } | 548 | } |
| 543 | 549 | ||
| 544 | static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, | 550 | static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, |
| @@ -548,7 +554,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, | |||
| 548 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 554 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
| 549 | int i; | 555 | int i; |
| 550 | 556 | ||
| 551 | down(&chip->spos_mutex); | 557 | mutex_lock(&chip->spos_mutex); |
| 552 | snd_iprintf(buffer, "SCB's:\n"); | 558 | snd_iprintf(buffer, "SCB's:\n"); |
| 553 | for ( i = 0; i < ins->nscb; ++i) { | 559 | for ( i = 0; i < ins->nscb; ++i) { |
| 554 | if (ins->scbs[i].deleted) | 560 | if (ins->scbs[i].deleted) |
| @@ -571,7 +577,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, | |||
| 571 | } | 577 | } |
| 572 | 578 | ||
| 573 | snd_iprintf(buffer,"\n"); | 579 | snd_iprintf(buffer,"\n"); |
| 574 | up(&chip->spos_mutex); | 580 | mutex_unlock(&chip->spos_mutex); |
| 575 | } | 581 | } |
| 576 | 582 | ||
| 577 | static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, | 583 | static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, |
| @@ -852,14 +858,14 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip) | |||
| 852 | } | 858 | } |
| 853 | ins->proc_scb_info_entry = entry; | 859 | ins->proc_scb_info_entry = entry; |
| 854 | 860 | ||
| 855 | down(&chip->spos_mutex); | 861 | mutex_lock(&chip->spos_mutex); |
| 856 | /* register/update SCB's entries on proc */ | 862 | /* register/update SCB's entries on proc */ |
| 857 | for (i = 0; i < ins->nscb; ++i) { | 863 | for (i = 0; i < ins->nscb; ++i) { |
| 858 | if (ins->scbs[i].deleted) continue; | 864 | if (ins->scbs[i].deleted) continue; |
| 859 | 865 | ||
| 860 | cs46xx_dsp_proc_register_scb_desc (chip, (ins->scbs + i)); | 866 | cs46xx_dsp_proc_register_scb_desc (chip, (ins->scbs + i)); |
| 861 | } | 867 | } |
| 862 | up(&chip->spos_mutex); | 868 | mutex_unlock(&chip->spos_mutex); |
| 863 | 869 | ||
| 864 | return 0; | 870 | return 0; |
| 865 | } | 871 | } |
| @@ -899,12 +905,12 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip) | |||
| 899 | ins->proc_task_info_entry = NULL; | 905 | ins->proc_task_info_entry = NULL; |
| 900 | } | 906 | } |
| 901 | 907 | ||
| 902 | down(&chip->spos_mutex); | 908 | mutex_lock(&chip->spos_mutex); |
| 903 | for (i = 0; i < ins->nscb; ++i) { | 909 | for (i = 0; i < ins->nscb; ++i) { |
| 904 | if (ins->scbs[i].deleted) continue; | 910 | if (ins->scbs[i].deleted) continue; |
| 905 | cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); | 911 | cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); |
| 906 | } | 912 | } |
| 907 | up(&chip->spos_mutex); | 913 | mutex_unlock(&chip->spos_mutex); |
| 908 | 914 | ||
| 909 | if (ins->proc_dsp_dir) { | 915 | if (ins->proc_dsp_dir) { |
| 910 | snd_info_unregister (ins->proc_dsp_dir); | 916 | snd_info_unregister (ins->proc_dsp_dir); |
| @@ -1694,7 +1700,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip) | |||
| 1694 | snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL); | 1700 | snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL); |
| 1695 | snd_assert (ins->spdif_in_src != NULL,return -EINVAL); | 1701 | snd_assert (ins->spdif_in_src != NULL,return -EINVAL); |
| 1696 | 1702 | ||
| 1697 | down(&chip->spos_mutex); | 1703 | mutex_lock(&chip->spos_mutex); |
| 1698 | 1704 | ||
| 1699 | if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED) ) { | 1705 | if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED) ) { |
| 1700 | /* time countdown enable */ | 1706 | /* time countdown enable */ |
| @@ -1738,7 +1744,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip) | |||
| 1738 | 1744 | ||
| 1739 | /* monitor state */ | 1745 | /* monitor state */ |
| 1740 | ins->spdif_status_in = 1; | 1746 | ins->spdif_status_in = 1; |
| 1741 | up(&chip->spos_mutex); | 1747 | mutex_unlock(&chip->spos_mutex); |
| 1742 | 1748 | ||
| 1743 | return 0; | 1749 | return 0; |
| 1744 | } | 1750 | } |
| @@ -1750,7 +1756,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip) | |||
| 1750 | snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); | 1756 | snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); |
| 1751 | snd_assert (ins->spdif_in_src != NULL,return -EINVAL); | 1757 | snd_assert (ins->spdif_in_src != NULL,return -EINVAL); |
| 1752 | 1758 | ||
| 1753 | down(&chip->spos_mutex); | 1759 | mutex_lock(&chip->spos_mutex); |
| 1754 | 1760 | ||
| 1755 | /* Remove the asynchronous receiver SCB */ | 1761 | /* Remove the asynchronous receiver SCB */ |
| 1756 | cs46xx_dsp_remove_scb (chip,ins->asynch_rx_scb); | 1762 | cs46xx_dsp_remove_scb (chip,ins->asynch_rx_scb); |
| @@ -1760,7 +1766,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip) | |||
| 1760 | 1766 | ||
| 1761 | /* monitor state */ | 1767 | /* monitor state */ |
| 1762 | ins->spdif_status_in = 0; | 1768 | ins->spdif_status_in = 0; |
| 1763 | up(&chip->spos_mutex); | 1769 | mutex_unlock(&chip->spos_mutex); |
| 1764 | 1770 | ||
| 1765 | /* restore amplifier */ | 1771 | /* restore amplifier */ |
| 1766 | chip->active_ctrl(chip, -1); | 1772 | chip->active_ctrl(chip, -1); |
| @@ -1776,10 +1782,10 @@ int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip) | |||
| 1776 | snd_assert (ins->pcm_input == NULL,return -EINVAL); | 1782 | snd_assert (ins->pcm_input == NULL,return -EINVAL); |
| 1777 | snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); | 1783 | snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); |
| 1778 | 1784 | ||
| 1779 | down(&chip->spos_mutex); | 1785 | mutex_lock(&chip->spos_mutex); |
| 1780 | ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, | 1786 | ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, |
| 1781 | "PCMSerialInput_Wave"); | 1787 | "PCMSerialInput_Wave"); |
| 1782 | up(&chip->spos_mutex); | 1788 | mutex_unlock(&chip->spos_mutex); |
| 1783 | 1789 | ||
| 1784 | return 0; | 1790 | return 0; |
| 1785 | } | 1791 | } |
| @@ -1790,10 +1796,10 @@ int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip) | |||
| 1790 | 1796 | ||
| 1791 | snd_assert (ins->pcm_input != NULL,return -EINVAL); | 1797 | snd_assert (ins->pcm_input != NULL,return -EINVAL); |
| 1792 | 1798 | ||
| 1793 | down(&chip->spos_mutex); | 1799 | mutex_lock(&chip->spos_mutex); |
| 1794 | cs46xx_dsp_remove_scb (chip,ins->pcm_input); | 1800 | cs46xx_dsp_remove_scb (chip,ins->pcm_input); |
| 1795 | ins->pcm_input = NULL; | 1801 | ins->pcm_input = NULL; |
| 1796 | up(&chip->spos_mutex); | 1802 | mutex_unlock(&chip->spos_mutex); |
| 1797 | 1803 | ||
| 1798 | return 0; | 1804 | return 0; |
| 1799 | } | 1805 | } |
| @@ -1805,10 +1811,10 @@ int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip) | |||
| 1805 | snd_assert (ins->adc_input == NULL,return -EINVAL); | 1811 | snd_assert (ins->adc_input == NULL,return -EINVAL); |
| 1806 | snd_assert (ins->codec_in_scb != NULL,return -EINVAL); | 1812 | snd_assert (ins->codec_in_scb != NULL,return -EINVAL); |
| 1807 | 1813 | ||
| 1808 | down(&chip->spos_mutex); | 1814 | mutex_lock(&chip->spos_mutex); |
| 1809 | ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, | 1815 | ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, |
| 1810 | "PCMSerialInput_ADC"); | 1816 | "PCMSerialInput_ADC"); |
| 1811 | up(&chip->spos_mutex); | 1817 | mutex_unlock(&chip->spos_mutex); |
| 1812 | 1818 | ||
| 1813 | return 0; | 1819 | return 0; |
| 1814 | } | 1820 | } |
| @@ -1819,10 +1825,10 @@ int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip) | |||
| 1819 | 1825 | ||
| 1820 | snd_assert (ins->adc_input != NULL,return -EINVAL); | 1826 | snd_assert (ins->adc_input != NULL,return -EINVAL); |
| 1821 | 1827 | ||
| 1822 | down(&chip->spos_mutex); | 1828 | mutex_lock(&chip->spos_mutex); |
| 1823 | cs46xx_dsp_remove_scb (chip,ins->adc_input); | 1829 | cs46xx_dsp_remove_scb (chip,ins->adc_input); |
| 1824 | ins->adc_input = NULL; | 1830 | ins->adc_input = NULL; |
| 1825 | up(&chip->spos_mutex); | 1831 | mutex_unlock(&chip->spos_mutex); |
| 1826 | 1832 | ||
| 1827 | return 0; | 1833 | return 0; |
| 1828 | } | 1834 | } |
| @@ -1869,7 +1875,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right) | |||
| 1869 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 1875 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
| 1870 | struct dsp_scb_descriptor * scb; | 1876 | struct dsp_scb_descriptor * scb; |
| 1871 | 1877 | ||
| 1872 | down(&chip->spos_mutex); | 1878 | mutex_lock(&chip->spos_mutex); |
| 1873 | 1879 | ||
| 1874 | /* main output */ | 1880 | /* main output */ |
| 1875 | scb = ins->master_mix_scb->sub_list_ptr; | 1881 | scb = ins->master_mix_scb->sub_list_ptr; |
| @@ -1888,7 +1894,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right) | |||
| 1888 | ins->dac_volume_left = left; | 1894 | ins->dac_volume_left = left; |
| 1889 | ins->dac_volume_right = right; | 1895 | ins->dac_volume_right = right; |
| 1890 | 1896 | ||
| 1891 | up(&chip->spos_mutex); | 1897 | mutex_unlock(&chip->spos_mutex); |
| 1892 | 1898 | ||
| 1893 | return 0; | 1899 | return 0; |
| 1894 | } | 1900 | } |
| @@ -1897,7 +1903,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right) | |||
| 1897 | { | 1903 | { |
| 1898 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 1904 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
| 1899 | 1905 | ||
| 1900 | down(&chip->spos_mutex); | 1906 | mutex_lock(&chip->spos_mutex); |
| 1901 | 1907 | ||
| 1902 | if (ins->asynch_rx_scb != NULL) | 1908 | if (ins->asynch_rx_scb != NULL) |
| 1903 | cs46xx_dsp_scb_set_volume (chip,ins->asynch_rx_scb, | 1909 | cs46xx_dsp_scb_set_volume (chip,ins->asynch_rx_scb, |
| @@ -1906,7 +1912,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right) | |||
| 1906 | ins->spdif_input_volume_left = left; | 1912 | ins->spdif_input_volume_left = left; |
| 1907 | ins->spdif_input_volume_right = right; | 1913 | ins->spdif_input_volume_right = right; |
| 1908 | 1914 | ||
| 1909 | up(&chip->spos_mutex); | 1915 | mutex_unlock(&chip->spos_mutex); |
| 1910 | 1916 | ||
| 1911 | return 0; | 1917 | return 0; |
| 1912 | } | 1918 | } |
