emuproc.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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 Caputre 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. tmp = (val >> 16) & 0x8;
  270. for (n = 0; n < 4; n++) {
  271. tmp = val >> (16 + (n*4));
  272. if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
  273. else snd_iprintf(buffer, "Channel %d: No input\n", n);
  274. }
  275. }
  276. static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry,
  277. struct snd_info_buffer *buffer)
  278. {
  279. u32 pc;
  280. struct snd_emu10k1 *emu = entry->private_data;
  281. snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
  282. snd_iprintf(buffer, " Code dump :\n");
  283. for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
  284. u32 low, high;
  285. low = snd_emu10k1_efx_read(emu, pc * 2);
  286. high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
  287. if (emu->audigy)
  288. snd_iprintf(buffer, " OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
  289. (high >> 24) & 0x0f,
  290. (high >> 12) & 0x7ff,
  291. (high >> 0) & 0x7ff,
  292. (low >> 12) & 0x7ff,
  293. (low >> 0) & 0x7ff,
  294. pc,
  295. high, low);
  296. else
  297. snd_iprintf(buffer, " OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
  298. (high >> 20) & 0x0f,
  299. (high >> 10) & 0x3ff,
  300. (high >> 0) & 0x3ff,
  301. (low >> 10) & 0x3ff,
  302. (low >> 0) & 0x3ff,
  303. pc,
  304. high, low);
  305. }
  306. }
  307. #define TOTAL_SIZE_GPR (0x100*4)
  308. #define A_TOTAL_SIZE_GPR (0x200*4)
  309. #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
  310. #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
  311. #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
  312. #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
  313. #define TOTAL_SIZE_CODE (0x200*8)
  314. #define A_TOTAL_SIZE_CODE (0x400*8)
  315. static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
  316. void *file_private_data,
  317. struct file *file, char __user *buf,
  318. size_t count, loff_t pos)
  319. {
  320. struct snd_emu10k1 *emu = entry->private_data;
  321. unsigned int offset;
  322. int tram_addr = 0;
  323. unsigned int *tmp;
  324. long res;
  325. unsigned int idx;
  326. if (!strcmp(entry->name, "fx8010_tram_addr")) {
  327. offset = TANKMEMADDRREGBASE;
  328. tram_addr = 1;
  329. } else if (!strcmp(entry->name, "fx8010_tram_data")) {
  330. offset = TANKMEMDATAREGBASE;
  331. } else if (!strcmp(entry->name, "fx8010_code")) {
  332. offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
  333. } else {
  334. offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
  335. }
  336. tmp = kmalloc(count + 8, GFP_KERNEL);
  337. if (!tmp)
  338. return -ENOMEM;
  339. for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
  340. unsigned int val;
  341. val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
  342. if (tram_addr && emu->audigy) {
  343. val >>= 11;
  344. val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
  345. }
  346. tmp[idx] = val;
  347. }
  348. if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
  349. res = -EFAULT;
  350. else
  351. res = count;
  352. kfree(tmp);
  353. return res;
  354. }
  355. static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
  356. struct snd_info_buffer *buffer)
  357. {
  358. struct snd_emu10k1 *emu = entry->private_data;
  359. struct snd_emu10k1_voice *voice;
  360. int idx;
  361. snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n");
  362. for (idx = 0; idx < NUM_G; idx++) {
  363. voice = &emu->voices[idx];
  364. snd_iprintf(buffer, "%i\t%i\t%i\t%i\t%i\t%i\n",
  365. idx,
  366. voice->use,
  367. voice->pcm,
  368. voice->efx,
  369. voice->synth,
  370. voice->midi);
  371. }
  372. }
  373. #ifdef CONFIG_SND_DEBUG
  374. static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
  375. struct snd_info_buffer *buffer)
  376. {
  377. struct snd_emu10k1 *emu = entry->private_data;
  378. u32 value;
  379. int i;
  380. snd_iprintf(buffer, "EMU1010 Registers:\n\n");
  381. for(i = 0; i < 0x40; i+=1) {
  382. snd_emu1010_fpga_read(emu, i, &value);
  383. snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
  384. }
  385. }
  386. static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
  387. struct snd_info_buffer *buffer)
  388. {
  389. struct snd_emu10k1 *emu = entry->private_data;
  390. unsigned long value;
  391. unsigned long flags;
  392. int i;
  393. snd_iprintf(buffer, "IO Registers:\n\n");
  394. for(i = 0; i < 0x40; i+=4) {
  395. spin_lock_irqsave(&emu->emu_lock, flags);
  396. value = inl(emu->port + i);
  397. spin_unlock_irqrestore(&emu->emu_lock, flags);
  398. snd_iprintf(buffer, "%02X: %08lX\n", i, value);
  399. }
  400. }
  401. static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
  402. struct snd_info_buffer *buffer)
  403. {
  404. struct snd_emu10k1 *emu = entry->private_data;
  405. unsigned long flags;
  406. char line[64];
  407. u32 reg, val;
  408. while (!snd_info_get_line(buffer, line, sizeof(line))) {
  409. if (sscanf(line, "%x %x", &reg, &val) != 2)
  410. continue;
  411. if (reg < 0x40 && val <= 0xffffffff) {
  412. spin_lock_irqsave(&emu->emu_lock, flags);
  413. outl(val, emu->port + (reg & 0xfffffffc));
  414. spin_unlock_irqrestore(&emu->emu_lock, flags);
  415. }
  416. }
  417. }
  418. static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
  419. unsigned int iobase,
  420. unsigned int reg,
  421. unsigned int chn)
  422. {
  423. unsigned long flags;
  424. unsigned int regptr, val;
  425. regptr = (reg << 16) | chn;
  426. spin_lock_irqsave(&emu->emu_lock, flags);
  427. outl(regptr, emu->port + iobase + PTR);
  428. val = inl(emu->port + iobase + DATA);
  429. spin_unlock_irqrestore(&emu->emu_lock, flags);
  430. return val;
  431. }
  432. static void snd_ptr_write(struct snd_emu10k1 *emu,
  433. unsigned int iobase,
  434. unsigned int reg,
  435. unsigned int chn,
  436. unsigned int data)
  437. {
  438. unsigned int regptr;
  439. unsigned long flags;
  440. regptr = (reg << 16) | chn;
  441. spin_lock_irqsave(&emu->emu_lock, flags);
  442. outl(regptr, emu->port + iobase + PTR);
  443. outl(data, emu->port + iobase + DATA);
  444. spin_unlock_irqrestore(&emu->emu_lock, flags);
  445. }
  446. static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
  447. struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
  448. {
  449. struct snd_emu10k1 *emu = entry->private_data;
  450. unsigned long value;
  451. int i,j;
  452. if (offset+length > 0xa0) {
  453. snd_iprintf(buffer, "Input values out of range\n");
  454. return;
  455. }
  456. snd_iprintf(buffer, "Registers 0x%x\n", iobase);
  457. for(i = offset; i < offset+length; i++) {
  458. snd_iprintf(buffer, "%02X: ",i);
  459. for (j = 0; j < voices; j++) {
  460. if(iobase == 0)
  461. value = snd_ptr_read(emu, 0, i, j);
  462. else
  463. value = snd_ptr_read(emu, 0x20, i, j);
  464. snd_iprintf(buffer, "%08lX ", value);
  465. }
  466. snd_iprintf(buffer, "\n");
  467. }
  468. }
  469. static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
  470. struct snd_info_buffer *buffer, int iobase)
  471. {
  472. struct snd_emu10k1 *emu = entry->private_data;
  473. char line[64];
  474. unsigned int reg, channel_id , val;
  475. while (!snd_info_get_line(buffer, line, sizeof(line))) {
  476. if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
  477. continue;
  478. if (reg < 0xa0 && val <= 0xffffffff && channel_id <= 3)
  479. snd_ptr_write(emu, iobase, reg, channel_id, val);
  480. }
  481. }
  482. static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
  483. struct snd_info_buffer *buffer)
  484. {
  485. snd_emu_proc_ptr_reg_write(entry, buffer, 0);
  486. }
  487. static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
  488. struct snd_info_buffer *buffer)
  489. {
  490. snd_emu_proc_ptr_reg_write(entry, buffer, 0x20);
  491. }
  492. static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
  493. struct snd_info_buffer *buffer)
  494. {
  495. snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
  496. }
  497. static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
  498. struct snd_info_buffer *buffer)
  499. {
  500. snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
  501. }
  502. static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
  503. struct snd_info_buffer *buffer)
  504. {
  505. snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
  506. }
  507. static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
  508. struct snd_info_buffer *buffer)
  509. {
  510. snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
  511. }
  512. static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
  513. struct snd_info_buffer * buffer)
  514. {
  515. snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
  516. }
  517. #endif
  518. static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
  519. .read = snd_emu10k1_fx8010_read,
  520. };
  521. int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
  522. {
  523. struct snd_info_entry *entry;
  524. #ifdef CONFIG_SND_DEBUG
  525. if (emu->card_capabilities->emu_model) {
  526. if (! snd_card_proc_new(emu->card, "emu1010_regs", &entry))
  527. snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read);
  528. }
  529. if (! snd_card_proc_new(emu->card, "io_regs", &entry)) {
  530. snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read);
  531. entry->c.text.write = snd_emu_proc_io_reg_write;
  532. entry->mode |= S_IWUSR;
  533. }
  534. if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) {
  535. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a);
  536. entry->c.text.write = snd_emu_proc_ptr_reg_write00;
  537. entry->mode |= S_IWUSR;
  538. }
  539. if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) {
  540. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b);
  541. entry->c.text.write = snd_emu_proc_ptr_reg_write00;
  542. entry->mode |= S_IWUSR;
  543. }
  544. if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) {
  545. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a);
  546. entry->c.text.write = snd_emu_proc_ptr_reg_write20;
  547. entry->mode |= S_IWUSR;
  548. }
  549. if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) {
  550. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b);
  551. entry->c.text.write = snd_emu_proc_ptr_reg_write20;
  552. entry->mode |= S_IWUSR;
  553. }
  554. if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) {
  555. snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c);
  556. entry->c.text.write = snd_emu_proc_ptr_reg_write20;
  557. entry->mode |= S_IWUSR;
  558. }
  559. #endif
  560. if (! snd_card_proc_new(emu->card, "emu10k1", &entry))
  561. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read);
  562. if (emu->card_capabilities->emu10k2_chip) {
  563. if (! snd_card_proc_new(emu->card, "spdif-in", &entry))
  564. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read);
  565. }
  566. if (emu->card_capabilities->ca0151_chip) {
  567. if (! snd_card_proc_new(emu->card, "capture-rates", &entry))
  568. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read);
  569. }
  570. if (! snd_card_proc_new(emu->card, "voices", &entry))
  571. snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read);
  572. if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
  573. entry->content = SNDRV_INFO_CONTENT_DATA;
  574. entry->private_data = emu;
  575. entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
  576. entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
  577. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  578. }
  579. if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
  580. entry->content = SNDRV_INFO_CONTENT_DATA;
  581. entry->private_data = emu;
  582. entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
  583. entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
  584. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  585. }
  586. if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
  587. entry->content = SNDRV_INFO_CONTENT_DATA;
  588. entry->private_data = emu;
  589. entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
  590. entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
  591. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  592. }
  593. if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
  594. entry->content = SNDRV_INFO_CONTENT_DATA;
  595. entry->private_data = emu;
  596. entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
  597. entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
  598. entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
  599. }
  600. if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) {
  601. entry->content = SNDRV_INFO_CONTENT_TEXT;
  602. entry->private_data = emu;
  603. entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
  604. entry->c.text.read = snd_emu10k1_proc_acode_read;
  605. }
  606. return 0;
  607. }