ac97_proc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /*
  2. * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  3. * Universal interface for Audio Codec '97
  4. *
  5. * For more details look to AC '97 component specification revision 2.2
  6. * by Intel Corporation (http://developer.intel.com).
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <sound/driver.h>
  25. #include <linux/slab.h>
  26. #include <sound/core.h>
  27. #include <sound/ac97_codec.h>
  28. #include <sound/asoundef.h>
  29. #include "ac97_local.h"
  30. #include "ac97_id.h"
  31. /*
  32. * proc interface
  33. */
  34. static void snd_ac97_proc_read_functions(ac97_t *ac97, snd_info_buffer_t *buffer)
  35. {
  36. int header = 0, function;
  37. unsigned short info, sense_info;
  38. static const char *function_names[12] = {
  39. "Master Out", "AUX Out", "Center/LFE Out", "SPDIF Out",
  40. "Phone In", "Mic 1", "Mic 2", "Line In", "CD In", "Video In",
  41. "Aux In", "Mono Out"
  42. };
  43. static const char *locations[8] = {
  44. "Rear I/O Panel", "Front Panel", "Motherboard", "Dock/External",
  45. "reserved", "reserved", "reserved", "NC/unused"
  46. };
  47. for (function = 0; function < 12; ++function) {
  48. snd_ac97_write(ac97, AC97_FUNC_SELECT, function << 1);
  49. info = snd_ac97_read(ac97, AC97_FUNC_INFO);
  50. if (!(info & 0x0001))
  51. continue;
  52. if (!header) {
  53. snd_iprintf(buffer, "\n Gain Inverted Buffer delay Location\n");
  54. header = 1;
  55. }
  56. sense_info = snd_ac97_read(ac97, AC97_SENSE_INFO);
  57. snd_iprintf(buffer, "%-17s: %3d.%d dBV %c %2d/fs %s\n",
  58. function_names[function],
  59. (info & 0x8000 ? -1 : 1) * ((info & 0x7000) >> 12) * 3 / 2,
  60. ((info & 0x0800) >> 11) * 5,
  61. info & 0x0400 ? 'X' : '-',
  62. (info & 0x03e0) >> 5,
  63. locations[sense_info >> 13]);
  64. }
  65. }
  66. static void snd_ac97_proc_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, int subidx)
  67. {
  68. char name[64];
  69. unsigned short val, tmp, ext, mext;
  70. static const char *spdif_slots[4] = { " SPDIF=3/4", " SPDIF=7/8", " SPDIF=6/9", " SPDIF=10/11" };
  71. static const char *spdif_rates[4] = { " Rate=44.1kHz", " Rate=res", " Rate=48kHz", " Rate=32kHz" };
  72. static const char *spdif_rates_cs4205[4] = { " Rate=48kHz", " Rate=44.1kHz", " Rate=res", " Rate=res" };
  73. static const char *double_rate_slots[4] = { "10/11", "7/8", "reserved", "reserved" };
  74. snd_ac97_get_name(NULL, ac97->id, name, 0);
  75. snd_iprintf(buffer, "%d-%d/%d: %s\n\n", ac97->addr, ac97->num, subidx, name);
  76. if ((ac97->scaps & AC97_SCAP_AUDIO) == 0)
  77. goto __modem;
  78. if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
  79. val = snd_ac97_read(ac97, AC97_INT_PAGING);
  80. snd_ac97_update_bits(ac97, AC97_INT_PAGING,
  81. AC97_PAGE_MASK, AC97_PAGE_1);
  82. tmp = snd_ac97_read(ac97, AC97_CODEC_CLASS_REV);
  83. snd_iprintf(buffer, "Revision : 0x%02x\n", tmp & 0xff);
  84. snd_iprintf(buffer, "Compat. Class : 0x%02x\n", (tmp >> 8) & 0x1f);
  85. snd_iprintf(buffer, "Subsys. Vendor ID: 0x%04x\n",
  86. snd_ac97_read(ac97, AC97_PCI_SVID));
  87. snd_iprintf(buffer, "Subsys. ID : 0x%04x\n\n",
  88. snd_ac97_read(ac97, AC97_PCI_SID));
  89. snd_ac97_update_bits(ac97, AC97_INT_PAGING,
  90. AC97_PAGE_MASK, val & AC97_PAGE_MASK);
  91. }
  92. // val = snd_ac97_read(ac97, AC97_RESET);
  93. val = ac97->caps;
  94. snd_iprintf(buffer, "Capabilities :%s%s%s%s%s%s\n",
  95. val & AC97_BC_DEDICATED_MIC ? " -dedicated MIC PCM IN channel-" : "",
  96. val & AC97_BC_RESERVED1 ? " -reserved1-" : "",
  97. val & AC97_BC_BASS_TREBLE ? " -bass & treble-" : "",
  98. val & AC97_BC_SIM_STEREO ? " -simulated stereo-" : "",
  99. val & AC97_BC_HEADPHONE ? " -headphone out-" : "",
  100. val & AC97_BC_LOUDNESS ? " -loudness-" : "");
  101. tmp = ac97->caps & AC97_BC_DAC_MASK;
  102. snd_iprintf(buffer, "DAC resolution : %s%s%s%s\n",
  103. tmp == AC97_BC_16BIT_DAC ? "16-bit" : "",
  104. tmp == AC97_BC_18BIT_DAC ? "18-bit" : "",
  105. tmp == AC97_BC_20BIT_DAC ? "20-bit" : "",
  106. tmp == AC97_BC_DAC_MASK ? "???" : "");
  107. tmp = ac97->caps & AC97_BC_ADC_MASK;
  108. snd_iprintf(buffer, "ADC resolution : %s%s%s%s\n",
  109. tmp == AC97_BC_16BIT_ADC ? "16-bit" : "",
  110. tmp == AC97_BC_18BIT_ADC ? "18-bit" : "",
  111. tmp == AC97_BC_20BIT_ADC ? "20-bit" : "",
  112. tmp == AC97_BC_ADC_MASK ? "???" : "");
  113. snd_iprintf(buffer, "3D enhancement : %s\n",
  114. snd_ac97_stereo_enhancements[(val >> 10) & 0x1f]);
  115. snd_iprintf(buffer, "\nCurrent setup\n");
  116. val = snd_ac97_read(ac97, AC97_MIC);
  117. snd_iprintf(buffer, "Mic gain : %s [%s]\n", val & 0x0040 ? "+20dB" : "+0dB", ac97->regs[AC97_MIC] & 0x0040 ? "+20dB" : "+0dB");
  118. val = snd_ac97_read(ac97, AC97_GENERAL_PURPOSE);
  119. snd_iprintf(buffer, "POP path : %s 3D\n"
  120. "Sim. stereo : %s\n"
  121. "3D enhancement : %s\n"
  122. "Loudness : %s\n"
  123. "Mono output : %s\n"
  124. "Mic select : %s\n"
  125. "ADC/DAC loopback : %s\n",
  126. val & 0x8000 ? "post" : "pre",
  127. val & 0x4000 ? "on" : "off",
  128. val & 0x2000 ? "on" : "off",
  129. val & 0x1000 ? "on" : "off",
  130. val & 0x0200 ? "Mic" : "MIX",
  131. val & 0x0100 ? "Mic2" : "Mic1",
  132. val & 0x0080 ? "on" : "off");
  133. if (ac97->ext_id & AC97_EI_DRA)
  134. snd_iprintf(buffer, "Double rate slots: %s\n",
  135. double_rate_slots[(val >> 10) & 3]);
  136. ext = snd_ac97_read(ac97, AC97_EXTENDED_ID);
  137. if (ext == 0)
  138. goto __modem;
  139. snd_iprintf(buffer, "Extended ID : codec=%i rev=%i%s%s%s%s DSA=%i%s%s%s%s\n",
  140. (ext & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT,
  141. (ext & AC97_EI_REV_MASK) >> AC97_EI_REV_SHIFT,
  142. ext & AC97_EI_AMAP ? " AMAP" : "",
  143. ext & AC97_EI_LDAC ? " LDAC" : "",
  144. ext & AC97_EI_SDAC ? " SDAC" : "",
  145. ext & AC97_EI_CDAC ? " CDAC" : "",
  146. (ext & AC97_EI_DACS_SLOT_MASK) >> AC97_EI_DACS_SLOT_SHIFT,
  147. ext & AC97_EI_VRM ? " VRM" : "",
  148. ext & AC97_EI_SPDIF ? " SPDIF" : "",
  149. ext & AC97_EI_DRA ? " DRA" : "",
  150. ext & AC97_EI_VRA ? " VRA" : "");
  151. val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
  152. snd_iprintf(buffer, "Extended status :%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
  153. val & AC97_EA_PRL ? " PRL" : "",
  154. val & AC97_EA_PRK ? " PRK" : "",
  155. val & AC97_EA_PRJ ? " PRJ" : "",
  156. val & AC97_EA_PRI ? " PRI" : "",
  157. val & AC97_EA_SPCV ? " SPCV" : "",
  158. val & AC97_EA_MDAC ? " MADC" : "",
  159. val & AC97_EA_LDAC ? " LDAC" : "",
  160. val & AC97_EA_SDAC ? " SDAC" : "",
  161. val & AC97_EA_CDAC ? " CDAC" : "",
  162. ext & AC97_EI_SPDIF ? spdif_slots[(val & AC97_EA_SPSA_SLOT_MASK) >> AC97_EA_SPSA_SLOT_SHIFT] : "",
  163. val & AC97_EA_VRM ? " VRM" : "",
  164. val & AC97_EA_SPDIF ? " SPDIF" : "",
  165. val & AC97_EA_DRA ? " DRA" : "",
  166. val & AC97_EA_VRA ? " VRA" : "");
  167. if (ext & AC97_EI_VRA) { /* VRA */
  168. val = snd_ac97_read(ac97, AC97_PCM_FRONT_DAC_RATE);
  169. snd_iprintf(buffer, "PCM front DAC : %iHz\n", val);
  170. if (ext & AC97_EI_SDAC) {
  171. val = snd_ac97_read(ac97, AC97_PCM_SURR_DAC_RATE);
  172. snd_iprintf(buffer, "PCM Surr DAC : %iHz\n", val);
  173. }
  174. if (ext & AC97_EI_LDAC) {
  175. val = snd_ac97_read(ac97, AC97_PCM_LFE_DAC_RATE);
  176. snd_iprintf(buffer, "PCM LFE DAC : %iHz\n", val);
  177. }
  178. val = snd_ac97_read(ac97, AC97_PCM_LR_ADC_RATE);
  179. snd_iprintf(buffer, "PCM ADC : %iHz\n", val);
  180. }
  181. if (ext & AC97_EI_VRM) {
  182. val = snd_ac97_read(ac97, AC97_PCM_MIC_ADC_RATE);
  183. snd_iprintf(buffer, "PCM MIC ADC : %iHz\n", val);
  184. }
  185. if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF)) {
  186. if (ac97->flags & AC97_CS_SPDIF)
  187. val = snd_ac97_read(ac97, AC97_CSR_SPDIF);
  188. else
  189. val = snd_ac97_read(ac97, AC97_SPDIF);
  190. snd_iprintf(buffer, "SPDIF Control :%s%s%s%s Category=0x%x Generation=%i%s%s%s\n",
  191. val & AC97_SC_PRO ? " PRO" : " Consumer",
  192. val & AC97_SC_NAUDIO ? " Non-audio" : " PCM",
  193. val & AC97_SC_COPY ? "" : " Copyright",
  194. val & AC97_SC_PRE ? " Preemph50/15" : "",
  195. (val & AC97_SC_CC_MASK) >> AC97_SC_CC_SHIFT,
  196. (val & AC97_SC_L) >> 11,
  197. (ac97->flags & AC97_CS_SPDIF) ?
  198. spdif_rates_cs4205[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT] :
  199. spdif_rates[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT],
  200. (ac97->flags & AC97_CS_SPDIF) ?
  201. (val & AC97_SC_DRS ? " Validity" : "") :
  202. (val & AC97_SC_DRS ? " DRS" : ""),
  203. (ac97->flags & AC97_CS_SPDIF) ?
  204. (val & AC97_SC_V ? " Enabled" : "") :
  205. (val & AC97_SC_V ? " Validity" : ""));
  206. /* ALC650 specific*/
  207. if ((ac97->id & 0xfffffff0) == 0x414c4720 &&
  208. (snd_ac97_read(ac97, AC97_ALC650_CLOCK) & 0x01)) {
  209. val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2);
  210. if (val & AC97_ALC650_CLOCK_LOCK) {
  211. val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS1);
  212. snd_iprintf(buffer, "SPDIF In Status :%s%s%s%s Category=0x%x Generation=%i",
  213. val & AC97_ALC650_PRO ? " PRO" : " Consumer",
  214. val & AC97_ALC650_NAUDIO ? " Non-audio" : " PCM",
  215. val & AC97_ALC650_COPY ? "" : " Copyright",
  216. val & AC97_ALC650_PRE ? " Preemph50/15" : "",
  217. (val & AC97_ALC650_CC_MASK) >> AC97_ALC650_CC_SHIFT,
  218. (val & AC97_ALC650_L) >> 15);
  219. val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2);
  220. snd_iprintf(buffer, "%s Accuracy=%i%s%s\n",
  221. spdif_rates[(val & AC97_ALC650_SPSR_MASK) >> AC97_ALC650_SPSR_SHIFT],
  222. (val & AC97_ALC650_CLOCK_ACCURACY) >> AC97_ALC650_CLOCK_SHIFT,
  223. (val & AC97_ALC650_CLOCK_LOCK ? " Locked" : " Unlocked"),
  224. (val & AC97_ALC650_V ? " Validity?" : ""));
  225. } else {
  226. snd_iprintf(buffer, "SPDIF In Status : Not Locked\n");
  227. }
  228. }
  229. }
  230. if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
  231. val = snd_ac97_read(ac97, AC97_INT_PAGING);
  232. snd_ac97_update_bits(ac97, AC97_INT_PAGING,
  233. AC97_PAGE_MASK, AC97_PAGE_1);
  234. snd_ac97_proc_read_functions(ac97, buffer);
  235. snd_ac97_update_bits(ac97, AC97_INT_PAGING,
  236. AC97_PAGE_MASK, val & AC97_PAGE_MASK);
  237. }
  238. __modem:
  239. mext = snd_ac97_read(ac97, AC97_EXTENDED_MID);
  240. if (mext == 0)
  241. return;
  242. snd_iprintf(buffer, "Extended modem ID: codec=%i%s%s%s%s%s\n",
  243. (mext & AC97_MEI_ADDR_MASK) >> AC97_MEI_ADDR_SHIFT,
  244. mext & AC97_MEI_CID2 ? " CID2" : "",
  245. mext & AC97_MEI_CID1 ? " CID1" : "",
  246. mext & AC97_MEI_HANDSET ? " HSET" : "",
  247. mext & AC97_MEI_LINE2 ? " LIN2" : "",
  248. mext & AC97_MEI_LINE1 ? " LIN1" : "");
  249. val = snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS);
  250. snd_iprintf(buffer, "Modem status :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
  251. val & AC97_MEA_GPIO ? " GPIO" : "",
  252. val & AC97_MEA_MREF ? " MREF" : "",
  253. val & AC97_MEA_ADC1 ? " ADC1" : "",
  254. val & AC97_MEA_DAC1 ? " DAC1" : "",
  255. val & AC97_MEA_ADC2 ? " ADC2" : "",
  256. val & AC97_MEA_DAC2 ? " DAC2" : "",
  257. val & AC97_MEA_HADC ? " HADC" : "",
  258. val & AC97_MEA_HDAC ? " HDAC" : "",
  259. val & AC97_MEA_PRA ? " PRA(GPIO)" : "",
  260. val & AC97_MEA_PRB ? " PRB(res)" : "",
  261. val & AC97_MEA_PRC ? " PRC(ADC1)" : "",
  262. val & AC97_MEA_PRD ? " PRD(DAC1)" : "",
  263. val & AC97_MEA_PRE ? " PRE(ADC2)" : "",
  264. val & AC97_MEA_PRF ? " PRF(DAC2)" : "",
  265. val & AC97_MEA_PRG ? " PRG(HADC)" : "",
  266. val & AC97_MEA_PRH ? " PRH(HDAC)" : "");
  267. if (mext & AC97_MEI_LINE1) {
  268. val = snd_ac97_read(ac97, AC97_LINE1_RATE);
  269. snd_iprintf(buffer, "Line1 rate : %iHz\n", val);
  270. }
  271. if (mext & AC97_MEI_LINE2) {
  272. val = snd_ac97_read(ac97, AC97_LINE2_RATE);
  273. snd_iprintf(buffer, "Line2 rate : %iHz\n", val);
  274. }
  275. if (mext & AC97_MEI_HANDSET) {
  276. val = snd_ac97_read(ac97, AC97_HANDSET_RATE);
  277. snd_iprintf(buffer, "Headset rate : %iHz\n", val);
  278. }
  279. }
  280. static void snd_ac97_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
  281. {
  282. ac97_t *ac97 = entry->private_data;
  283. down(&ac97->page_mutex);
  284. if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
  285. int idx;
  286. for (idx = 0; idx < 3; idx++)
  287. if (ac97->spec.ad18xx.id[idx]) {
  288. /* select single codec */
  289. snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
  290. ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]);
  291. snd_ac97_proc_read_main(ac97, buffer, idx);
  292. snd_iprintf(buffer, "\n\n");
  293. }
  294. /* select all codecs */
  295. snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
  296. snd_iprintf(buffer, "\nAD18XX configuration\n");
  297. snd_iprintf(buffer, "Unchained : 0x%04x,0x%04x,0x%04x\n",
  298. ac97->spec.ad18xx.unchained[0],
  299. ac97->spec.ad18xx.unchained[1],
  300. ac97->spec.ad18xx.unchained[2]);
  301. snd_iprintf(buffer, "Chained : 0x%04x,0x%04x,0x%04x\n",
  302. ac97->spec.ad18xx.chained[0],
  303. ac97->spec.ad18xx.chained[1],
  304. ac97->spec.ad18xx.chained[2]);
  305. } else {
  306. snd_ac97_proc_read_main(ac97, buffer, 0);
  307. }
  308. up(&ac97->page_mutex);
  309. }
  310. #ifdef CONFIG_SND_DEBUG
  311. /* direct register write for debugging */
  312. static void snd_ac97_proc_regs_write(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
  313. {
  314. ac97_t *ac97 = entry->private_data;
  315. char line[64];
  316. unsigned int reg, val;
  317. down(&ac97->page_mutex);
  318. while (!snd_info_get_line(buffer, line, sizeof(line))) {
  319. if (sscanf(line, "%x %x", &reg, &val) != 2)
  320. continue;
  321. /* register must be even */
  322. if (reg < 0x80 && (reg & 1) == 0 && val <= 0xffff)
  323. snd_ac97_write_cache(ac97, reg, val);
  324. }
  325. up(&ac97->page_mutex);
  326. }
  327. #endif
  328. static void snd_ac97_proc_regs_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, int subidx)
  329. {
  330. int reg, val;
  331. for (reg = 0; reg < 0x80; reg += 2) {
  332. val = snd_ac97_read(ac97, reg);
  333. snd_iprintf(buffer, "%i:%02x = %04x\n", subidx, reg, val);
  334. }
  335. }
  336. static void snd_ac97_proc_regs_read(snd_info_entry_t *entry,
  337. snd_info_buffer_t * buffer)
  338. {
  339. ac97_t *ac97 = entry->private_data;
  340. down(&ac97->page_mutex);
  341. if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
  342. int idx;
  343. for (idx = 0; idx < 3; idx++)
  344. if (ac97->spec.ad18xx.id[idx]) {
  345. /* select single codec */
  346. snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
  347. ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]);
  348. snd_ac97_proc_regs_read_main(ac97, buffer, idx);
  349. }
  350. /* select all codecs */
  351. snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
  352. } else {
  353. snd_ac97_proc_regs_read_main(ac97, buffer, 0);
  354. }
  355. up(&ac97->page_mutex);
  356. }
  357. void snd_ac97_proc_init(ac97_t * ac97)
  358. {
  359. snd_info_entry_t *entry;
  360. char name[32];
  361. const char *prefix;
  362. if (ac97->bus->proc == NULL)
  363. return;
  364. prefix = ac97_is_audio(ac97) ? "ac97" : "mc97";
  365. sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num);
  366. if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) {
  367. snd_info_set_text_ops(entry, ac97, 1024, snd_ac97_proc_read);
  368. if (snd_info_register(entry) < 0) {
  369. snd_info_free_entry(entry);
  370. entry = NULL;
  371. }
  372. }
  373. ac97->proc = entry;
  374. sprintf(name, "%s#%d-%d+regs", prefix, ac97->addr, ac97->num);
  375. if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) {
  376. snd_info_set_text_ops(entry, ac97, 1024, snd_ac97_proc_regs_read);
  377. #ifdef CONFIG_SND_DEBUG
  378. entry->mode |= S_IWUSR;
  379. entry->c.text.write_size = 1024;
  380. entry->c.text.write = snd_ac97_proc_regs_write;
  381. #endif
  382. if (snd_info_register(entry) < 0) {
  383. snd_info_free_entry(entry);
  384. entry = NULL;
  385. }
  386. }
  387. ac97->proc_regs = entry;
  388. }
  389. void snd_ac97_proc_done(ac97_t * ac97)
  390. {
  391. if (ac97->proc_regs) {
  392. snd_info_unregister(ac97->proc_regs);
  393. ac97->proc_regs = NULL;
  394. }
  395. if (ac97->proc) {
  396. snd_info_unregister(ac97->proc);
  397. ac97->proc = NULL;
  398. }
  399. }
  400. void snd_ac97_bus_proc_init(ac97_bus_t * bus)
  401. {
  402. snd_info_entry_t *entry;
  403. char name[32];
  404. sprintf(name, "codec97#%d", bus->num);
  405. if ((entry = snd_info_create_card_entry(bus->card, name, bus->card->proc_root)) != NULL) {
  406. entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
  407. if (snd_info_register(entry) < 0) {
  408. snd_info_free_entry(entry);
  409. entry = NULL;
  410. }
  411. }
  412. bus->proc = entry;
  413. }
  414. void snd_ac97_bus_proc_done(ac97_bus_t * bus)
  415. {
  416. if (bus->proc) {
  417. snd_info_unregister(bus->proc);
  418. bus->proc = NULL;
  419. }
  420. }