1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
32MODULE_FIRMWARE("vx/bx_1_vxp.b56");
33MODULE_FIRMWARE("vx/bx_1_vp4.b56");
34MODULE_FIRMWARE("vx/x1_1_vx2.xlx");
35MODULE_FIRMWARE("vx/x1_2_v22.xlx");
36MODULE_FIRMWARE("vx/x1_1_vxp.xlx");
37MODULE_FIRMWARE("vx/x1_1_vp4.xlx");
38MODULE_FIRMWARE("vx/bd56002.boot");
39MODULE_FIRMWARE("vx/bd563v2.boot");
40MODULE_FIRMWARE("vx/bd563s3.boot");
41MODULE_FIRMWARE("vx/l_1_vx2.d56");
42MODULE_FIRMWARE("vx/l_1_v22.d56");
43MODULE_FIRMWARE("vx/l_1_vxp.d56");
44MODULE_FIRMWARE("vx/l_1_vp4.d56");
45
46int snd_vx_setup_firmware(struct vx_core *chip)
47{
48 static char *fw_files[VX_TYPE_NUMS][4] = {
49 [VX_TYPE_BOARD] = {
50 NULL, "x1_1_vx2.xlx", "bd56002.boot", "l_1_vx2.d56",
51 },
52 [VX_TYPE_V2] = {
53 NULL, "x1_2_v22.xlx", "bd563v2.boot", "l_1_v22.d56",
54 },
55 [VX_TYPE_MIC] = {
56 NULL, "x1_2_v22.xlx", "bd563v2.boot", "l_1_v22.d56",
57 },
58 [VX_TYPE_VXPOCKET] = {
59 "bx_1_vxp.b56", "x1_1_vxp.xlx", "bd563s3.boot", "l_1_vxp.d56"
60 },
61 [VX_TYPE_VXP440] = {
62 "bx_1_vp4.b56", "x1_1_vp4.xlx", "bd563s3.boot", "l_1_vp4.d56"
63 },
64 };
65
66 int i, err;
67
68 for (i = 0; i < 4; i++) {
69 char path[32];
70 const struct firmware *fw;
71 if (! fw_files[chip->type][i])
72 continue;
73 sprintf(path, "vx/%s", fw_files[chip->type][i]);
74 if (request_firmware(&fw, path, chip->dev)) {
75 snd_printk(KERN_ERR "vx: can't load firmware %s\n", path);
76 return -ENOENT;
77 }
78 err = chip->ops->load_dsp(chip, i, fw);
79 if (err < 0) {
80 release_firmware(fw);
81 return err;
82 }
83 if (i == 1)
84 chip->chip_status |= VX_STAT_XILINX_LOADED;
85#ifdef CONFIG_PM
86 chip->firmware[i] = fw;
87#else
88 release_firmware(fw);
89#endif
90 }
91
92
93
94 if ((err = snd_vx_pcm_new(chip)) < 0)
95 return err;
96
97 if ((err = snd_vx_mixer_new(chip)) < 0)
98 return err;
99
100 if (chip->ops->add_controls)
101 if ((err = chip->ops->add_controls(chip)) < 0)
102 return err;
103
104 chip->chip_status |= VX_STAT_DEVICE_INIT;
105 chip->chip_status |= VX_STAT_CHIP_INIT;
106
107 return snd_card_register(chip->card);
108}
109
110
111void snd_vx_free_firmware(struct vx_core *chip)
112{
113#ifdef CONFIG_PM
114 int i;
115 for (i = 0; i < 4; i++)
116 release_firmware(chip->firmware[i]);
117#endif
118}
119
120EXPORT_SYMBOL(snd_vx_setup_firmware);
121EXPORT_SYMBOL(snd_vx_free_firmware);
122