mixart_hwdep.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. * Driver for Digigram miXart soundcards
  3. *
  4. * DSP firmware management
  5. *
  6. * Copyright (c) 2003 by Digigram <alsa@digigram.com>
  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. #include <linux/interrupt.h>
  23. #include <linux/pci.h>
  24. #include <linux/firmware.h>
  25. #include <linux/vmalloc.h>
  26. #include <linux/slab.h>
  27. #include <linux/module.h>
  28. #include <linux/io.h>
  29. #include <sound/core.h>
  30. #include "mixart.h"
  31. #include "mixart_mixer.h"
  32. #include "mixart_core.h"
  33. #include "mixart_hwdep.h"
  34. /**
  35. * wait for a value on a peudo register, exit with a timeout
  36. *
  37. * @mgr: pointer to miXart manager structure
  38. * @offset: unsigned pseudo_register base + offset of value
  39. * @is_egal: wait for the equal value
  40. * @value: value
  41. * @timeout: timeout in centisenconds
  42. */
  43. static int mixart_wait_nice_for_register_value(struct mixart_mgr *mgr,
  44. u32 offset, int is_egal,
  45. u32 value, unsigned long timeout)
  46. {
  47. unsigned long end_time = jiffies + (timeout * HZ / 100);
  48. u32 read;
  49. do { /* we may take too long time in this loop.
  50. * so give controls back to kernel if needed.
  51. */
  52. cond_resched();
  53. read = readl_be( MIXART_MEM( mgr, offset ));
  54. if(is_egal) {
  55. if(read == value) return 0;
  56. }
  57. else { /* wait for different value */
  58. if(read != value) return 0;
  59. }
  60. } while ( time_after_eq(end_time, jiffies) );
  61. return -EBUSY;
  62. }
  63. /*
  64. structures needed to upload elf code packets
  65. */
  66. struct snd_mixart_elf32_ehdr {
  67. u8 e_ident[16];
  68. u16 e_type;
  69. u16 e_machine;
  70. u32 e_version;
  71. u32 e_entry;
  72. u32 e_phoff;
  73. u32 e_shoff;
  74. u32 e_flags;
  75. u16 e_ehsize;
  76. u16 e_phentsize;
  77. u16 e_phnum;
  78. u16 e_shentsize;
  79. u16 e_shnum;
  80. u16 e_shstrndx;
  81. };
  82. struct snd_mixart_elf32_phdr {
  83. u32 p_type;
  84. u32 p_offset;
  85. u32 p_vaddr;
  86. u32 p_paddr;
  87. u32 p_filesz;
  88. u32 p_memsz;
  89. u32 p_flags;
  90. u32 p_align;
  91. };
  92. static int mixart_load_elf(struct mixart_mgr *mgr, const struct firmware *dsp )
  93. {
  94. char elf32_magic_number[4] = {0x7f,'E','L','F'};
  95. struct snd_mixart_elf32_ehdr *elf_header;
  96. int i;
  97. elf_header = (struct snd_mixart_elf32_ehdr *)dsp->data;
  98. for( i=0; i<4; i++ )
  99. if ( elf32_magic_number[i] != elf_header->e_ident[i] )
  100. return -EINVAL;
  101. if( elf_header->e_phoff != 0 ) {
  102. struct snd_mixart_elf32_phdr elf_programheader;
  103. for( i=0; i < be16_to_cpu(elf_header->e_phnum); i++ ) {
  104. u32 pos = be32_to_cpu(elf_header->e_phoff) + (u32)(i * be16_to_cpu(elf_header->e_phentsize));
  105. memcpy( &elf_programheader, dsp->data + pos, sizeof(elf_programheader) );
  106. if(elf_programheader.p_type != 0) {
  107. if( elf_programheader.p_filesz != 0 ) {
  108. memcpy_toio( MIXART_MEM( mgr, be32_to_cpu(elf_programheader.p_vaddr)),
  109. dsp->data + be32_to_cpu( elf_programheader.p_offset ),
  110. be32_to_cpu( elf_programheader.p_filesz ));
  111. }
  112. }
  113. }
  114. }
  115. return 0;
  116. }
  117. /*
  118. * get basic information and init miXart
  119. */
  120. /* audio IDs for request to the board */
  121. #define MIXART_FIRST_ANA_AUDIO_ID 0
  122. #define MIXART_FIRST_DIG_AUDIO_ID 8
  123. static int mixart_enum_connectors(struct mixart_mgr *mgr)
  124. {
  125. u32 k;
  126. int err;
  127. struct mixart_msg request;
  128. struct mixart_enum_connector_resp *connector;
  129. struct mixart_audio_info_req *audio_info_req;
  130. struct mixart_audio_info_resp *audio_info;
  131. connector = kmalloc(sizeof(*connector), GFP_KERNEL);
  132. audio_info_req = kmalloc(sizeof(*audio_info_req), GFP_KERNEL);
  133. audio_info = kmalloc(sizeof(*audio_info), GFP_KERNEL);
  134. if (! connector || ! audio_info_req || ! audio_info) {
  135. err = -ENOMEM;
  136. goto __error;
  137. }
  138. audio_info_req->line_max_level = MIXART_FLOAT_P_22_0_TO_HEX;
  139. audio_info_req->micro_max_level = MIXART_FLOAT_M_20_0_TO_HEX;
  140. audio_info_req->cd_max_level = MIXART_FLOAT____0_0_TO_HEX;
  141. request.message_id = MSG_SYSTEM_ENUM_PLAY_CONNECTOR;
  142. request.uid = (struct mixart_uid){0,0}; /* board num = 0 */
  143. request.data = NULL;
  144. request.size = 0;
  145. err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector);
  146. if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) {
  147. dev_err(&mgr->pci->dev,
  148. "error MSG_SYSTEM_ENUM_PLAY_CONNECTOR\n");
  149. err = -EINVAL;
  150. goto __error;
  151. }
  152. for(k=0; k < connector->uid_count; k++) {
  153. struct mixart_pipe *pipe;
  154. if(k < MIXART_FIRST_DIG_AUDIO_ID) {
  155. pipe = &mgr->chip[k/2]->pipe_out_ana;
  156. } else {
  157. pipe = &mgr->chip[(k-MIXART_FIRST_DIG_AUDIO_ID)/2]->pipe_out_dig;
  158. }
  159. if(k & 1) {
  160. pipe->uid_right_connector = connector->uid[k]; /* odd */
  161. } else {
  162. pipe->uid_left_connector = connector->uid[k]; /* even */
  163. }
  164. /* dev_dbg(&mgr->pci->dev, "playback connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
  165. /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */
  166. request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO;
  167. request.uid = connector->uid[k];
  168. request.data = audio_info_req;
  169. request.size = sizeof(*audio_info_req);
  170. err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info);
  171. if( err < 0 ) {
  172. dev_err(&mgr->pci->dev,
  173. "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
  174. goto __error;
  175. }
  176. /*dev_dbg(&mgr->pci->dev, "play analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
  177. }
  178. request.message_id = MSG_SYSTEM_ENUM_RECORD_CONNECTOR;
  179. request.uid = (struct mixart_uid){0,0}; /* board num = 0 */
  180. request.data = NULL;
  181. request.size = 0;
  182. err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector);
  183. if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) {
  184. dev_err(&mgr->pci->dev,
  185. "error MSG_SYSTEM_ENUM_RECORD_CONNECTOR\n");
  186. err = -EINVAL;
  187. goto __error;
  188. }
  189. for(k=0; k < connector->uid_count; k++) {
  190. struct mixart_pipe *pipe;
  191. if(k < MIXART_FIRST_DIG_AUDIO_ID) {
  192. pipe = &mgr->chip[k/2]->pipe_in_ana;
  193. } else {
  194. pipe = &mgr->chip[(k-MIXART_FIRST_DIG_AUDIO_ID)/2]->pipe_in_dig;
  195. }
  196. if(k & 1) {
  197. pipe->uid_right_connector = connector->uid[k]; /* odd */
  198. } else {
  199. pipe->uid_left_connector = connector->uid[k]; /* even */
  200. }
  201. /* dev_dbg(&mgr->pci->dev, "capture connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
  202. /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */
  203. request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO;
  204. request.uid = connector->uid[k];
  205. request.data = audio_info_req;
  206. request.size = sizeof(*audio_info_req);
  207. err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info);
  208. if( err < 0 ) {
  209. dev_err(&mgr->pci->dev,
  210. "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
  211. goto __error;
  212. }
  213. /*dev_dbg(&mgr->pci->dev, "rec analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
  214. }
  215. err = 0;
  216. __error:
  217. kfree(connector);
  218. kfree(audio_info_req);
  219. kfree(audio_info);
  220. return err;
  221. }
  222. static int mixart_enum_physio(struct mixart_mgr *mgr)
  223. {
  224. u32 k;
  225. int err;
  226. struct mixart_msg request;
  227. struct mixart_uid get_console_mgr;
  228. struct mixart_return_uid console_mgr;
  229. struct mixart_uid_enumeration phys_io;
  230. /* get the uid for the console manager */
  231. get_console_mgr.object_id = 0;
  232. get_console_mgr.desc = MSG_CONSOLE_MANAGER | 0; /* cardindex = 0 */
  233. request.message_id = MSG_CONSOLE_GET_CLOCK_UID;
  234. request.uid = get_console_mgr;
  235. request.data = &get_console_mgr;
  236. request.size = sizeof(get_console_mgr);
  237. err = snd_mixart_send_msg(mgr, &request, sizeof(console_mgr), &console_mgr);
  238. if( (err < 0) || (console_mgr.error_code != 0) ) {
  239. dev_dbg(&mgr->pci->dev,
  240. "error MSG_CONSOLE_GET_CLOCK_UID : err=%x\n",
  241. console_mgr.error_code);
  242. return -EINVAL;
  243. }
  244. /* used later for clock issues ! */
  245. mgr->uid_console_manager = console_mgr.uid;
  246. request.message_id = MSG_SYSTEM_ENUM_PHYSICAL_IO;
  247. request.uid = (struct mixart_uid){0,0};
  248. request.data = &console_mgr.uid;
  249. request.size = sizeof(console_mgr.uid);
  250. err = snd_mixart_send_msg(mgr, &request, sizeof(phys_io), &phys_io);
  251. if( (err < 0) || ( phys_io.error_code != 0 ) ) {
  252. dev_err(&mgr->pci->dev,
  253. "error MSG_SYSTEM_ENUM_PHYSICAL_IO err(%x) error_code(%x)\n",
  254. err, phys_io.error_code);
  255. return -EINVAL;
  256. }
  257. /* min 2 phys io per card (analog in + analog out) */
  258. if (phys_io.nb_uid < MIXART_MAX_CARDS * 2)
  259. return -EINVAL;
  260. for(k=0; k<mgr->num_cards; k++) {
  261. mgr->chip[k]->uid_in_analog_physio = phys_io.uid[k];
  262. mgr->chip[k]->uid_out_analog_physio = phys_io.uid[phys_io.nb_uid/2 + k];
  263. }
  264. return 0;
  265. }
  266. static int mixart_first_init(struct mixart_mgr *mgr)
  267. {
  268. u32 k;
  269. int err;
  270. struct mixart_msg request;
  271. if((err = mixart_enum_connectors(mgr)) < 0) return err;
  272. if((err = mixart_enum_physio(mgr)) < 0) return err;
  273. /* send a synchro command to card (necessary to do this before first MSG_STREAM_START_STREAM_GRP_PACKET) */
  274. /* though why not here */
  275. request.message_id = MSG_SYSTEM_SEND_SYNCHRO_CMD;
  276. request.uid = (struct mixart_uid){0,0};
  277. request.data = NULL;
  278. request.size = 0;
  279. /* this command has no data. response is a 32 bit status */
  280. err = snd_mixart_send_msg(mgr, &request, sizeof(k), &k);
  281. if( (err < 0) || (k != 0) ) {
  282. dev_err(&mgr->pci->dev, "error MSG_SYSTEM_SEND_SYNCHRO_CMD\n");
  283. return err == 0 ? -EINVAL : err;
  284. }
  285. return 0;
  286. }
  287. /* firmware base addresses (when hard coded) */
  288. #define MIXART_MOTHERBOARD_XLX_BASE_ADDRESS 0x00600000
  289. static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmware *dsp)
  290. {
  291. int err, card_index;
  292. u32 status_xilinx, status_elf, status_daught;
  293. u32 val;
  294. /* read motherboard xilinx status */
  295. status_xilinx = readl_be( MIXART_MEM( mgr,MIXART_PSEUDOREG_MXLX_STATUS_OFFSET ));
  296. /* read elf status */
  297. status_elf = readl_be( MIXART_MEM( mgr,MIXART_PSEUDOREG_ELF_STATUS_OFFSET ));
  298. /* read daughterboard xilinx status */
  299. status_daught = readl_be( MIXART_MEM( mgr,MIXART_PSEUDOREG_DXLX_STATUS_OFFSET ));
  300. /* motherboard xilinx status 5 will say that the board is performing a reset */
  301. if (status_xilinx == 5) {
  302. dev_err(&mgr->pci->dev, "miXart is resetting !\n");
  303. return -EAGAIN; /* try again later */
  304. }
  305. switch (index) {
  306. case MIXART_MOTHERBOARD_XLX_INDEX:
  307. /* xilinx already loaded ? */
  308. if (status_xilinx == 4) {
  309. dev_dbg(&mgr->pci->dev, "xilinx is already loaded !\n");
  310. return 0;
  311. }
  312. /* the status should be 0 == "idle" */
  313. if (status_xilinx != 0) {
  314. dev_err(&mgr->pci->dev,
  315. "xilinx load error ! status = %d\n",
  316. status_xilinx);
  317. return -EIO; /* modprob -r may help ? */
  318. }
  319. /* check xilinx validity */
  320. if (((u32*)(dsp->data))[0] == 0xffffffff)
  321. return -EINVAL;
  322. if (dsp->size % 4)
  323. return -EINVAL;
  324. /* set xilinx status to copying */
  325. writel_be( 1, MIXART_MEM( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET ));
  326. /* setup xilinx base address */
  327. writel_be( MIXART_MOTHERBOARD_XLX_BASE_ADDRESS, MIXART_MEM( mgr,MIXART_PSEUDOREG_MXLX_BASE_ADDR_OFFSET ));
  328. /* setup code size for xilinx file */
  329. writel_be( dsp->size, MIXART_MEM( mgr, MIXART_PSEUDOREG_MXLX_SIZE_OFFSET ));
  330. /* copy xilinx code */
  331. memcpy_toio( MIXART_MEM( mgr, MIXART_MOTHERBOARD_XLX_BASE_ADDRESS), dsp->data, dsp->size);
  332. /* set xilinx status to copy finished */
  333. writel_be( 2, MIXART_MEM( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET ));
  334. /* return, because no further processing needed */
  335. return 0;
  336. case MIXART_MOTHERBOARD_ELF_INDEX:
  337. if (status_elf == 4) {
  338. dev_dbg(&mgr->pci->dev, "elf file already loaded !\n");
  339. return 0;
  340. }
  341. /* the status should be 0 == "idle" */
  342. if (status_elf != 0) {
  343. dev_err(&mgr->pci->dev,
  344. "elf load error ! status = %d\n",
  345. status_elf);
  346. return -EIO; /* modprob -r may help ? */
  347. }
  348. /* wait for xilinx status == 4 */
  349. err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET, 1, 4, 500); /* 5sec */
  350. if (err < 0) {
  351. dev_err(&mgr->pci->dev, "xilinx was not loaded or "
  352. "could not be started\n");
  353. return err;
  354. }
  355. /* init some data on the card */
  356. writel_be( 0, MIXART_MEM( mgr, MIXART_PSEUDOREG_BOARDNUMBER ) ); /* set miXart boardnumber to 0 */
  357. writel_be( 0, MIXART_MEM( mgr, MIXART_FLOWTABLE_PTR ) ); /* reset pointer to flow table on miXart */
  358. /* set elf status to copying */
  359. writel_be( 1, MIXART_MEM( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET ));
  360. /* process the copying of the elf packets */
  361. err = mixart_load_elf( mgr, dsp );
  362. if (err < 0) return err;
  363. /* set elf status to copy finished */
  364. writel_be( 2, MIXART_MEM( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET ));
  365. /* wait for elf status == 4 */
  366. err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET, 1, 4, 300); /* 3sec */
  367. if (err < 0) {
  368. dev_err(&mgr->pci->dev, "elf could not be started\n");
  369. return err;
  370. }
  371. /* miXart waits at this point on the pointer to the flow table */
  372. writel_be( (u32)mgr->flowinfo.addr, MIXART_MEM( mgr, MIXART_FLOWTABLE_PTR ) ); /* give pointer of flow table to miXart */
  373. return 0; /* return, another xilinx file has to be loaded before */
  374. case MIXART_AESEBUBOARD_XLX_INDEX:
  375. default:
  376. /* elf and xilinx should be loaded */
  377. if (status_elf != 4 || status_xilinx != 4) {
  378. dev_err(&mgr->pci->dev, "xilinx or elf not "
  379. "successfully loaded\n");
  380. return -EIO; /* modprob -r may help ? */
  381. }
  382. /* wait for daughter detection != 0 */
  383. err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET, 0, 0, 30); /* 300msec */
  384. if (err < 0) {
  385. dev_err(&mgr->pci->dev, "error starting elf file\n");
  386. return err;
  387. }
  388. /* the board type can now be retrieved */
  389. mgr->board_type = (DAUGHTER_TYPE_MASK & readl_be( MIXART_MEM( mgr, MIXART_PSEUDOREG_DBRD_TYPE_OFFSET)));
  390. if (mgr->board_type == MIXART_DAUGHTER_TYPE_NONE)
  391. break; /* no daughter board; the file does not have to be loaded, continue after the switch */
  392. /* only if aesebu daughter board presence (elf code must run) */
  393. if (mgr->board_type != MIXART_DAUGHTER_TYPE_AES )
  394. return -EINVAL;
  395. /* daughter should be idle */
  396. if (status_daught != 0) {
  397. dev_err(&mgr->pci->dev,
  398. "daughter load error ! status = %d\n",
  399. status_daught);
  400. return -EIO; /* modprob -r may help ? */
  401. }
  402. /* check daughterboard xilinx validity */
  403. if (((u32*)(dsp->data))[0] == 0xffffffff)
  404. return -EINVAL;
  405. if (dsp->size % 4)
  406. return -EINVAL;
  407. /* inform mixart about the size of the file */
  408. writel_be( dsp->size, MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_SIZE_OFFSET ));
  409. /* set daughterboard status to 1 */
  410. writel_be( 1, MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET ));
  411. /* wait for status == 2 */
  412. err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 2, 30); /* 300msec */
  413. if (err < 0) {
  414. dev_err(&mgr->pci->dev, "daughter board load error\n");
  415. return err;
  416. }
  417. /* get the address where to write the file */
  418. val = readl_be( MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET ));
  419. if (!val)
  420. return -EINVAL;
  421. /* copy daughterboard xilinx code */
  422. memcpy_toio( MIXART_MEM( mgr, val), dsp->data, dsp->size);
  423. /* set daughterboard status to 4 */
  424. writel_be( 4, MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET ));
  425. /* continue with init */
  426. break;
  427. } /* end of switch file index*/
  428. /* wait for daughter status == 3 */
  429. err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 3, 300); /* 3sec */
  430. if (err < 0) {
  431. dev_err(&mgr->pci->dev,
  432. "daughter board could not be initialised\n");
  433. return err;
  434. }
  435. /* init mailbox (communication with embedded) */
  436. snd_mixart_init_mailbox(mgr);
  437. /* first communication with embedded */
  438. err = mixart_first_init(mgr);
  439. if (err < 0) {
  440. dev_err(&mgr->pci->dev, "miXart could not be set up\n");
  441. return err;
  442. }
  443. /* create devices and mixer in accordance with HW options*/
  444. for (card_index = 0; card_index < mgr->num_cards; card_index++) {
  445. struct snd_mixart *chip = mgr->chip[card_index];
  446. if ((err = snd_mixart_create_pcm(chip)) < 0)
  447. return err;
  448. if (card_index == 0) {
  449. if ((err = snd_mixart_create_mixer(chip->mgr)) < 0)
  450. return err;
  451. }
  452. if ((err = snd_card_register(chip->card)) < 0)
  453. return err;
  454. }
  455. dev_dbg(&mgr->pci->dev,
  456. "miXart firmware downloaded and successfully set up\n");
  457. return 0;
  458. }
  459. int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
  460. {
  461. static char *fw_files[3] = {
  462. "miXart8.xlx", "miXart8.elf", "miXart8AES.xlx"
  463. };
  464. char path[32];
  465. const struct firmware *fw_entry;
  466. int i, err;
  467. for (i = 0; i < 3; i++) {
  468. sprintf(path, "mixart/%s", fw_files[i]);
  469. if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
  470. dev_err(&mgr->pci->dev,
  471. "miXart: can't load firmware %s\n", path);
  472. return -ENOENT;
  473. }
  474. /* fake hwdep dsp record */
  475. err = mixart_dsp_load(mgr, i, fw_entry);
  476. release_firmware(fw_entry);
  477. if (err < 0)
  478. return err;
  479. mgr->dsp_loaded |= 1 << i;
  480. }
  481. return 0;
  482. }
  483. MODULE_FIRMWARE("mixart/miXart8.xlx");
  484. MODULE_FIRMWARE("mixart/miXart8.elf");
  485. MODULE_FIRMWARE("mixart/miXart8AES.xlx");