emuproc.c 21 KB

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