Linux-libre 3.10.98-gnu
[librecmc/linux-libre.git] / sound / drivers / vx / vx_hwdep.c
1 /*
2  * Driver for Digigram VX soundcards
3  *
4  * DSP firmware management
5  *
6  * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
7  *
8  *   This program is free software; you can redistribute it and/or modify
9  *   it under the terms of the GNU General Public License as published by
10  *   the Free Software Foundation; either version 2 of the License, or
11  *   (at your option) any later version.
12  *
13  *   This program is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  */
22
23 #include <linux/device.h>
24 #include <linux/firmware.h>
25 #include <linux/slab.h>
26 #include <linux/vmalloc.h>
27 #include <linux/module.h>
28 #include <sound/core.h>
29 #include <sound/hwdep.h>
30 #include <sound/vx_core.h>
31
32 /*(DEBLOBBED)*/
33
34 int snd_vx_setup_firmware(struct vx_core *chip)
35 {
36         static char *fw_files[VX_TYPE_NUMS][4] = {
37                 [VX_TYPE_BOARD] = {
38                         NULL, "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/",
39                 },
40                 [VX_TYPE_V2] = {
41                         NULL, "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/",
42                 },
43                 [VX_TYPE_MIC] = {
44                         NULL, "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/",
45                 },
46                 [VX_TYPE_VXPOCKET] = {
47                         "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/"
48                 },
49                 [VX_TYPE_VXP440] = {
50                         "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/"
51                 },
52         };
53
54         int i, err;
55
56         for (i = 0; i < 4; i++) {
57                 char path[32];
58                 const struct firmware *fw;
59                 if (! fw_files[chip->type][i])
60                         continue;
61                 sprintf(path, "vx/%s", fw_files[chip->type][i]);
62                 if (reject_firmware(&fw, path, chip->dev)) {
63                         snd_printk(KERN_ERR "vx: can't load firmware %s\n", path);
64                         return -ENOENT;
65                 }
66                 err = chip->ops->load_dsp(chip, i, fw);
67                 if (err < 0) {
68                         release_firmware(fw);
69                         return err;
70                 }
71                 if (i == 1)
72                         chip->chip_status |= VX_STAT_XILINX_LOADED;
73 #ifdef CONFIG_PM
74                 chip->firmware[i] = fw;
75 #else
76                 release_firmware(fw);
77 #endif
78         }
79
80         /* ok, we reached to the last one */
81         /* create the devices if not built yet */
82         if ((err = snd_vx_pcm_new(chip)) < 0)
83                 return err;
84
85         if ((err = snd_vx_mixer_new(chip)) < 0)
86                 return err;
87
88         if (chip->ops->add_controls)
89                 if ((err = chip->ops->add_controls(chip)) < 0)
90                         return err;
91
92         chip->chip_status |= VX_STAT_DEVICE_INIT;
93         chip->chip_status |= VX_STAT_CHIP_INIT;
94
95         return snd_card_register(chip->card);
96 }
97
98 /* exported */
99 void snd_vx_free_firmware(struct vx_core *chip)
100 {
101 #ifdef CONFIG_PM
102         int i;
103         for (i = 0; i < 4; i++)
104                 release_firmware(chip->firmware[i]);
105 #endif
106 }
107
108 EXPORT_SYMBOL(snd_vx_setup_firmware);
109 EXPORT_SYMBOL(snd_vx_free_firmware);