emuproc.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /*
  2. * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  3. * Creative Labs, Inc.
  4. * Routines for control of EMU10K1 chips / proc interface routines
  5. *
  6. * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
  7. * Added EMU 1010 support.
  8. *
  9. * BUGS:
  10. * --
  11. *
  12. * TODO:
  13. * --
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. *
  29. */
  30. #include <linux/slab.h>
  31. #include <linux/init.h>
  32. #include <sound/core.h>
  33. #include <sound/emu10k1.h>
  34. #include "p16v.h"
  35. static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu,
  36. struct snd_info_buffer *buffer,
  37. char *title,
  38. int status_reg,
  39. int rate_reg)
  40. {
  41. static char *clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" };
  42. static int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  43. static char *channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
  44. static char *emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" };
  45. unsigned int status, rate = 0;
  46. status = snd_emu10k1_ptr_read(emu, status_reg, 0);
  47. snd_iprintf(buffer, "\n%s\n", title);
  48. if (status != 0xffffffff) {
  49. snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no");
  50. snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no");
  51. snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no");
  52. snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]);
  53. snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6);
  54. snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8);
  55. snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy");
  56. snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16);
  57. snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]);
  58. snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]);
  59. snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]);
  60. if (rate_reg > 0) {
  61. rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
  62. snd_iprintf(buffer, "S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off");
  63. snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off");
  64. snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off");
  65. /* From ((Rate * 48000 ) / 262144); */
  66. snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11);
  67. }
  68. } else {
  69. snd_iprintf(buffer, "No signal detected.\n");
  70. }
  71. }
  72. static void snd_emu10k1_proc_read(struct snd_info_entry *entry,
  73. struct snd_info_buffer *buffer)
  74. {
  75. /* FIXME - output names are in emufx.c too */
  76. static char *creative_outs[32] = {
  77. /* 00 */ "AC97 Left",
  78. /* 01 */ "AC97 Right",
  79. /* 02 */ "Optical IEC958 Left",
  80. /* 03 */ "Optical IEC958 Right",
  81. /* 04 */ "Center",
  82. /* 05 */ "LFE",
  83. /* 06 */ "Headphone Left",
  84. /* 07 */ "Headphone Right",
  85. /* 08 */ "Surround Left",
  86. /* 09 */ "Surround Right",
  87. /* 10 */ "PCM Capture Left",
  88. /* 11 */ "PCM Capture Right",
  89. /* 12 */ "MIC Capture",
  90. /* 13 */ "AC97 Surround Left",
  91. /* 14 */ "AC97 Surround Right",
  92. /* 15 */ "???",
  93. /* 16 */ "???",
  94. /* 17 */ "Analog Center",
  95. /* 18 */ "Analog LFE",
  96. /* 19 */ "???",
  97. /* 20 */ "???",
  98. /* 21 */ "???",
  99. /* 22 */ "???",
  100. /* 23 */ "???",
  101. /* 24 */ "???",
  102. /* 25 */ "???",
  103. /* 26 */ "???",
  104. /* 27 */ "???",
  105. /* 28 */ "???",
  106. /* 29 */ "???",
  107. /* 30 */ "???",
  108. /* 31 */ "???"
  109. };
  110. static char *audigy_outs[64] = {
  111. /* 00 */ "Digital Front Left",
  112. /* 01 */ "Digital Front Right",
  113. /* 02 */ "Digital Center",
  114. /* 03 */ "Digital LEF",
  115. /* 04 */ "Headphone Left",
  116. /* 05 */ "Headphone Right",
  117. /* 06 */ "Digital Rear Left",
  118. /* 07 */ "Digital Rear Right",
  119. /* 08 */ "Front Left",
  120. /* 09 */ "Front Right",
  121. /* 10 */ "Center",
  122. /* 11 */ "LFE",
  123. /* 12 */ "???",
  124. /* 13 */ "???",
  125. /* 14 */ "Rear Left",
  126. /* 15 */ "Rear Right",
  127. /* 16 */ "AC97 Front Left",
  128. /* 17 */ "AC97 Front Right",
  129. /* 18 */ "ADC Capture Left",
  130. /* 19 */ "ADC Capture Right",
  131. /* 20 */ "???",
  132. /* 21 */ "???",
  133. /* 22 */ "???",
  134. /* 23 */ "???",
  135. /* 24 */ "???",
  136. /* 25 */ "???",
  137. /* 26 */ "???",
  138. /* 27 */ "???",
  139. /* 28 */ "???",
  140. /* 29 */ "???",
  141. /* 30 */ "???",
  142. /* 31 */ "???",
  143. /* 32 */ "FXBUS2_0",
  144. /* 33 */ "FXBUS2_1",
  145. /* 34 */ "FXBUS2_2",
  146. /* 35 */ "FXBUS2_3",
  147. /* 36 */ "FXBUS2_4",
  148. /* 37 */ "FXBUS2_5",
  149. /* 38 */ "FXBUS2_6",
  150. /* 39 */ "FXBUS2_7",
  151. /* 40 */ "FXBUS2_8",
  152. /* 41 */ "FXBUS2_9",
  153. /* 42 */ "FXBUS2_10",
  154. /* 43 */ "FXBUS2_11",
  155. /* 44 */ "FXBUS2_12",
  156. /* 45 */ "FXBUS2_13",
  157. /* 46 */ "FXBUS2_14",
  158. /* 47 */ "FXBUS2_15",
  159. /* 48 */ "FXBUS2_16",
  160. /* 49 */ "FXBUS2_17",
  161. /* 50 */ "FXBUS2_18",
  162. /* 51 */ "FXBUS2_19",
  163. /* 52 */ "FXBUS2_20",
  164. /* 53 */ "FXBUS2_21",
  165. /* 54 */ "FXBUS2_22",
  166. /* 55 */ "FXBUS2_23",
  167. /* 56 */ "FXBUS2_24",
  168. /* 57 */ "FXBUS2_25",
  169. /* 58 */ "FXBUS2_26",
  170. /* 59 */ "FXBUS2_27",
  171. /* 60 */ "FXBUS2_28",
  172. /* 61 */ "FXBUS2_29",
  173. /* 62 */ "FXBUS2_30",
  174. /* 63 */ "FXBUS2_31"
  175. };
  176. struct snd_emu10k1 *emu = entry->private_data;
  177. unsigned int val, val1;
  178. int nefx = emu->audigy ? 64 : 32;
  179. char **outputs = emu->audigy ? audigy_outs : creative_outs;
  180. int idx;
  181. snd_iprintf(buffer, "EMU10K1\n\n");
  182. snd_iprintf(buffer, "Card : %s\n",
  183. emu->audigy ? "Audigy" : (emu->card_capabilities->ecard ? "EMU APS" : "Creative"));
  184. snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
  185. snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2);
  186. snd_iprintf(buffer, "\n");
  187. snd_iprintf(buffer, "Effect Send Routing :\n");
  188. for (idx = 0; idx < NUM_G; idx++) {
  189. val = emu->audigy ?
  190. snd_emu10k1_ptr_read(emu, A_FXRT1, idx) :
  191. snd_emu10k1_ptr_read(emu, FXRT, idx);
  192. val1 = emu->audigy ?
  193. snd_emu10k1_ptr_read(emu, A_FXRT2, idx) :
  194. 0;
  195. if (emu->audigy) {
  196. snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i, ",
  197. idx,
  198. val & 0x3f,
  199. (val >> 8) & 0x3f,
  200. (val >> 16) & 0x3f,
  201. (val >> 24) & 0x3f);
  202. snd_iprintf(buffer, "E=%i, F=%i, G=%i, H=%i\n",
  203. val1 & 0x3f,
  204. (val1 >> 8) & 0x3f,
  205. (val1 >> 16) & 0x3f,
  206. (val1 >> 24) & 0x3f);
  207. } else {
  208. snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i\n",
  209. idx,
  210. (val >> 16) & 0x0f,
  211. (val >> 20) & 0x0f,
  212. (val >> 24) & 0x0f,
  213. (val >> 28) & 0x0f);
  214. }
  215. }
  216. snd_iprintf(buffer, "\nCaptured FX Outputs :\n");
  217. for (idx = 0; idx < nefx; idx++) {
  218. if (emu->efx_voices_mask[idx/32] & (1 << (idx%32)))
  219. snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]);
  220. }
  221. snd_iprintf(buffer, "\nAll FX Outputs :\n");
  222. for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++)
  223. snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]);
  224. }
  225. static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
  226. struct snd_info_buffer *buffer)
  227. {
  228. struct snd_emu10k1 *emu = entry->private_data;
  229. u32 value;
  230. u32 value2;
  231. u32 rate;
  232. if (emu->card_capabilities->emu_model) {
  233. snd_emu1010_fpga_read(emu, 0x38, &value);
  234. if ((value & 0x1) == 0) {
  235. snd_emu1010_fpga_read(emu, 0x2a, &value);
  236. snd_emu1010_fpga_read(emu, 0x2b, &value2);
  237. rate = 0x1770000 / (((value << 5) | value2)+1);
  238. snd_iprintf(buffer, "ADAT Locked : %u\n", rate);
  239. } else {
  240. snd_iprintf(buffer, "ADAT Unlocked\n");
  241. }
  242. snd_emu1010_fpga_read(emu, 0x20, &value);
  243. if ((value & 0x4) == 0) {
  244. snd_emu1010_fpga_read(emu, 0x28, &value);
  245. snd_emu1010_fpga_read(emu, 0x29, &value2);
  246. rate = 0x1770000 / (((value << 5) | value2)+1);
  247. snd_iprintf(buffer, "SPDIF Locked : %d\n", rate);
  248. } else {
  249. snd_iprintf(buffer, "SPDIF Unlocked\n");
  250. }
  251. } else {
  252. snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
  253. snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
  254. }
  255. #if 0
  256. val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
  257. snd_iprintf(buffer, "\nZoomed Video\n");
  258. snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off");
  259. snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
  260. #endif
  261. }
  262. static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry,
  263. struct snd_info_buffer *buffer)
  264. {
  265. static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
  266. struct snd_emu10k1 *emu = entry->private_data;
  267. unsigned int val, tmp, n;
  268. val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
  269. for (n = 0; n < 4; n++) {
  270. tmp = val >> (16 + (n*4));
  271. if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
  272. else snd_iprintf(buffer, "Channel %d: No input\n", n);
  273. }
  274. }
  275. static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry,
  276. struct snd_info_buffer *buffer)
  277. {
  278. u32 pc;
  279. struct snd_emu10k1 *emu = entry->private_data;
  280. snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
  281. snd_iprintf(buffer, " Code dump :\n");
  282. for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
  283. u32 low, high;
  284. low = snd_emu10k1_efx_read(emu, pc * 2);
  285. high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
  286. if (emu->audigy)
  287. snd_iprintf(buffer, " OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
  288. (high >> 24) & 0x0f,
  289. (high >> 12) & 0x7ff,
  290. (high >> 0) & 0x7ff,
  291. (low >> 12) & 0x7ff,
  292. (low >> 0) & 0x7ff,
  293. pc,
  294. high, low);
  295. else
  296. snd_iprintf(buffer, " OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
  297. (high >> 20) & 0x0f,
  298. (high >> 10) & 0x3ff,
  299. (high >> 0) & 0x3ff,
  300. (low >> 10) & 0x3ff,
  301. (low >> 0) & 0x3ff,
  302. pc,
  303. high, low);
  304. }
  305. }
  306. #define TOTAL_SIZE_GPR (0x100*4)
  307. #define A_TOTAL_SIZE_GPR (0x200*4)
  308. #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
  309. #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
  310. #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
  311. #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
  312. #define TOTAL_SIZE_CODE (0x200*8)
  313. #define A_TOTAL_SIZE_CODE (0x400*8)
  314. static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
  315. void *file_private_data,
  316. struct file *file, char __user *buf,
  317. size_t count, loff_t pos)
  318. {
  319. struct snd_emu10k1 *emu = entry->private_data;
  320. unsigned int offset;
  321. int tram_addr = 0;
  322. unsigned int *tmp;
  323. long res;
  324. unsigned int idx;
  325. if (!strcmp(entry->name, "fx8010_tram_addr")) {
  326. offset = TANKMEMADDRREGBASE;
  327. tram_addr = 1;
  328. } else if (!strcmp(entry->name, "fx8010_tram_data")) {
  329. offset = TANKMEMDATAREGBASE;
  330. } else if (!strcmp(entry->name, "fx8010_code")) {
  331. offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
  332. } else {
  333. offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
  334. }
  335. tmp = kmalloc(count + 8, GFP_KERNEL);
  336. if (!tmp)
  337. return -ENOMEM;
  338. for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
  339. unsigned int val;
  340. val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
  341. if (tram_addr && emu->audigy) {
  342. val >>= 11;
  343. val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
  344. }
  345. tmp[idx] = val;
  346. }
  347. if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
  348. res = -EFAULT;
  349. else
  350. res = count;
  351. kfree(tmp);
  352. return res;
  353. }
  354. static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
  355. struct snd_info_buffer *buffer)
  356. {
  357. struct snd_emu10k1 *emu = entry->private_data;
  358. struct snd_emu10k1_voice *voice;
  359. int idx;
  360. snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n");
  361. for (idx = 0; idx < NUM_G; idx++) {
  362. voice = &emu->voices[idx];
  363. snd_iprintf(buffer, "%i\t%i\t%i\t%i\t%i\t%i\n",
  364. idx,
  365. voice->use,
  366. voice->pcm,
  367. voice->efx,
  368. voice->synth,
  369. voice->midi);
  370. }
  371. }
  372. #ifdef CONFIG_SND_DEBUG
  373. static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
  374. struct snd_info_buffer *buffer)
  375. {
  376. struct snd_emu10k1 *emu = entry->private_data;
  377. u32 value;
  378. int i;
  379. snd_iprintf(buffer, "EMU1010 Registers:\n\n");
  380. for(i = 0; i < 0x40; i+=1) {
  381. snd_emu1010_fpga_read(emu, i, &value);
  382. snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
  383. }
  384. }
  385. static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
  386. struct snd_info_buffer *buffer)
  387. {
  388. struct snd_emu10k1 *emu = entry->private_data;
  389. unsigned long value;
  390. unsigned long flags;
  391. int i;
  392. snd_iprintf(buffer, "IO Registers:\n\n");
  393. for(i = 0; i < 0x40; i+=4) {
  394. spin_lock_irqsave(&emu->emu_lock, flags);
  395. value = inl(emu->port + i);
  396. spin_unlock_irqrestore(&emu->emu_lock, flags);
  397. snd_iprintf(buffer, "%02X: %08lX\n", i, value);
  398. }
  399. }
  400. static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
  401. struct snd_info_buffer *buffer)
  402. {
  403. struct snd_emu10k1 *emu = entry->private_data;
  404. unsigned long flags;
  405. char line[64];
  406. u32 reg, val;
  407. while (!snd_info_get_line(buffer, line, sizeof(line))) {
  408. if (sscanf(line, "%x %x", &reg, &val) != 2)
  409. continue;
  410. if (reg < 0x40 && val <= 0xffffffff) {
  411. spin_lock_irqsave(&emu->emu_lock, flags);
  412. outl(val, emu->port + (reg & 0xfffffffc));
  413. spin_unlock_irqrestore(&emu->emu_lock, flags);
  414. }
  415. }
  416. }
  417. static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
  418. unsigned int iobase,
  419. unsigned int reg,
  420. unsigned int chn)
  421. {
  422. unsigned long flags;
  423. unsigned int regptr, val;
  424. regptr = (reg << 16) | chn;
  425. spin_lock_irqsave(&emu->emu_lock, flags);
  426. outl(regptr, emu->port + iobase + PTR);
  427. val = inl(emu->port + iobase + DATA);
  428. spin_unlock_irqrestore(&emu->emu_lock, flags);
  429. return val;
  430. }
  431. static void snd_ptr_write(struct snd_emu10k1 *emu,
  432. unsigned int iobase,
  433. unsigned int reg,
  434. unsigned int chn,
  435. unsigned int data)
  436. {
  437. unsigned int regptr;
  438. unsigned long flags;
  439. regptr = (reg << 16) | chn;
  440. spin_lock_irqsave(&emu->emu_lock, flags);
  441. outl(regptr, emu->port + iobase + PTR);
  442. outl(data, emu->port + iobase + DATA);
  443. spin_unlock_irqrestore(&emu->emu_lock, flags);
  444. }
  445. static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
  446. struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
  447. {
  448. struct snd_emu10k1 *emu = entry->private_data;
  449. unsigned long value;
  450. int i,j;
  451. if (offset+length > 0xa0) {
  452. snd_iprintf(buffer, "Input values out of range\n");
  453. return;
  454. }
  455. snd_iprintf(buffer, "Registers 0x%x\n", iobase);
  456. for(i = offset; i < offset+length; i++) {
  457. snd_iprintf(buffer, "%02X: ",i);
  458. for (j = 0; j < voices; j++) {
  459. if(iobase == 0)
  460. value = snd_ptr_read(emu, 0, i, j);
  461. else
  462. value = snd_ptr_read(emu, 0x20, i, j);
  463. snd_iprintf(buffer, "%08lX ", value);
  464. }
  465. snd_iprintf(buffer, "\n");
  466. }
  467. }
  468. static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
  469. struct snd_info_buffer *buffer, int iobase)
  470. {
  471. struct snd_emu10k1 *emu = entry->private_data;
  472. char line[64];
  473. unsigned int reg, channel_id , val;
  474. while (!snd_info_get_line(buffer, line, sizeof(line))) {
  475. if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
  476. continue;
  477. if (reg < 0xa0 && val <= 0xffffffff && channel_id <= 3)
  478. snd_ptr_write(emu, iobase, reg, channel_id, val);
  479. }
  480. }
  481. static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
  482. struct snd_info_buffer *buffer)
  483. {
  484. snd_emu_proc_ptr_reg_write(entry, buffer, 0);
  485. }
  486. static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
  487. struct snd_info_buffer *buffer)
  488. {
  489. snd_emu_proc_ptr_reg_write(entry, buffer, 0x20);
  490. }
  491. static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
  492. struct snd_info_buffer *buffer)
  493. {
  494. snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
  495. }
  496. static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
  497. struct snd_info_buffer *buffer)
  498. {
  499. snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
  500. }
  501. static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
  502. struct snd_info_buffer *buffer)
  503. {
  504. snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
  505. }
  506. static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
  507. struct snd_info_buffer *buffer)
  508. {
  509. snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
  510. }
  511. static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
  512. struct snd_info_buffer * buffer)
  513. {
  514. snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
  515. }
  516. #endif
  517. static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
  518. .read = snd_emu10k1_fx8010_read,
  519. };
  520. int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
  521. {
  522. struct snd_info_entry *entry;
  523. #ifdef CONFIG_SND_DEBUG
  524. if (emu->card_capabilities->emu_model) {
  525. if (! snd_card_proc_new(emu->card, "emu1010_regs", &entry))
  526. snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read);
  527. }
  528. if (! snd_card_proc_new(emu->card, "io_regs", &entry)) {
  529. snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read);
  530. entry->c.text.write = snd_emu_proc_io_reg_write;
  531. entry->mode |= 0200;
  532. }
  533. if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) {
  534. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a);
  535. entry->c.text.write = snd_emu_proc_ptr_reg_write00;
  536. entry->mode |= 0200;
  537. }
  538. if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) {
  539. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b);
  540. entry->c.text.write = snd_emu_proc_ptr_reg_write00;
  541. entry->mode |= 0200;
  542. }
  543. if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) {
  544. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a);
  545. entry->c.text.write = snd_emu_proc_ptr_reg_write20;
  546. entry->mode |= 0200;
  547. }
  548. if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) {
  549. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b);
  550. entry->c.text.write = snd_emu_proc_ptr_reg_write20;
  551. entry->mode |= 0200;
  552. }
  553. if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) {
  554. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c);
  555. entry->c.text.write = snd_emu_proc_ptr_reg_write20;
  556. entry->mode |= 0200;
  557. }
  558. #endif
  559. if (! snd_card_proc_new(emu->card, "emu10k1", &entry))
  560. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read);
  561. if (emu->card_capabilities->emu10k2_chip) {
  562. if (! snd_card_proc_new(emu->card, "spdif-in", &entry))
  563. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read);
  564. }
  565. if (emu->card_capabilities->ca0151_chip) {
  566. if (! snd_card_proc_new(emu->card, "capture-rates", &entry))
  567. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read);
  568. }
  569. if (! snd_card_proc_new(emu->card, "voices", &entry))
  570. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read);
  571. if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
  572. entry->content = SNDRV_INFO_CONTENT_DATA;
  573. entry->private_data = emu;
  574. entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
  575. entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
  576. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  577. }
  578. if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
  579. entry->content = SNDRV_INFO_CONTENT_DATA;
  580. entry->private_data = emu;
  581. entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
  582. entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
  583. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  584. }
  585. if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
  586. entry->content = SNDRV_INFO_CONTENT_DATA;
  587. entry->private_data = emu;
  588. entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
  589. entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
  590. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  591. }
  592. if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
  593. entry->content = SNDRV_INFO_CONTENT_DATA;
  594. entry->private_data = emu;
  595. entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
  596. entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
  597. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  598. }
  599. if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) {
  600. entry->content = SNDRV_INFO_CONTENT_TEXT;
  601. entry->private_data = emu;
  602. entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
  603. entry->c.text.read = snd_emu10k1_proc_acode_read;
  604. }
  605. return 0;
  606. }