hda_proc.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * Generic proc interface
  5. *
  6. * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
  7. *
  8. *
  9. * This driver 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 driver 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. #include <linux/init.h>
  24. #include <sound/core.h>
  25. #include "hda_codec.h"
  26. #include "hda_local.h"
  27. static const char *get_wid_type_name(unsigned int wid_value)
  28. {
  29. static char *names[16] = {
  30. [AC_WID_AUD_OUT] = "Audio Output",
  31. [AC_WID_AUD_IN] = "Audio Input",
  32. [AC_WID_AUD_MIX] = "Audio Mixer",
  33. [AC_WID_AUD_SEL] = "Audio Selector",
  34. [AC_WID_PIN] = "Pin Complex",
  35. [AC_WID_POWER] = "Power Widget",
  36. [AC_WID_VOL_KNB] = "Volume Knob Widget",
  37. [AC_WID_BEEP] = "Beep Generator Widget",
  38. [AC_WID_VENDOR] = "Vendor Defined Widget",
  39. };
  40. wid_value &= 0xf;
  41. if (names[wid_value])
  42. return names[wid_value];
  43. else
  44. return "UNKNOWN Widget";
  45. }
  46. static void print_amp_caps(struct snd_info_buffer *buffer,
  47. struct hda_codec *codec, hda_nid_t nid, int dir)
  48. {
  49. unsigned int caps;
  50. caps = snd_hda_param_read(codec, nid,
  51. dir == HDA_OUTPUT ?
  52. AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
  53. if (caps == -1 || caps == 0) {
  54. snd_iprintf(buffer, "N/A\n");
  55. return;
  56. }
  57. snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
  58. "mute=%x\n",
  59. caps & AC_AMPCAP_OFFSET,
  60. (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
  61. (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
  62. (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
  63. }
  64. static void print_amp_vals(struct snd_info_buffer *buffer,
  65. struct hda_codec *codec, hda_nid_t nid,
  66. int dir, int stereo, int indices)
  67. {
  68. unsigned int val;
  69. int i;
  70. dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
  71. for (i = 0; i < indices; i++) {
  72. snd_iprintf(buffer, " [");
  73. if (stereo) {
  74. val = snd_hda_codec_read(codec, nid, 0,
  75. AC_VERB_GET_AMP_GAIN_MUTE,
  76. AC_AMP_GET_LEFT | dir | i);
  77. snd_iprintf(buffer, "0x%02x ", val);
  78. }
  79. val = snd_hda_codec_read(codec, nid, 0,
  80. AC_VERB_GET_AMP_GAIN_MUTE,
  81. AC_AMP_GET_RIGHT | dir | i);
  82. snd_iprintf(buffer, "0x%02x]", val);
  83. }
  84. snd_iprintf(buffer, "\n");
  85. }
  86. static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
  87. {
  88. char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
  89. pcm &= AC_SUPPCM_RATES;
  90. snd_iprintf(buffer, " rates [0x%x]:", pcm);
  91. snd_print_pcm_rates(pcm, buf, sizeof(buf));
  92. snd_iprintf(buffer, "%s\n", buf);
  93. }
  94. static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
  95. {
  96. char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
  97. snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff);
  98. snd_print_pcm_bits(pcm, buf, sizeof(buf));
  99. snd_iprintf(buffer, "%s\n", buf);
  100. }
  101. static void print_pcm_formats(struct snd_info_buffer *buffer,
  102. unsigned int streams)
  103. {
  104. snd_iprintf(buffer, " formats [0x%x]:", streams & 0xf);
  105. if (streams & AC_SUPFMT_PCM)
  106. snd_iprintf(buffer, " PCM");
  107. if (streams & AC_SUPFMT_FLOAT32)
  108. snd_iprintf(buffer, " FLOAT");
  109. if (streams & AC_SUPFMT_AC3)
  110. snd_iprintf(buffer, " AC3");
  111. snd_iprintf(buffer, "\n");
  112. }
  113. static void print_pcm_caps(struct snd_info_buffer *buffer,
  114. struct hda_codec *codec, hda_nid_t nid)
  115. {
  116. unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM);
  117. unsigned int stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
  118. if (pcm == -1 || stream == -1) {
  119. snd_iprintf(buffer, "N/A\n");
  120. return;
  121. }
  122. print_pcm_rates(buffer, pcm);
  123. print_pcm_bits(buffer, pcm);
  124. print_pcm_formats(buffer, stream);
  125. }
  126. static const char *get_jack_connection(u32 cfg)
  127. {
  128. static char *names[16] = {
  129. "Unknown", "1/8", "1/4", "ATAPI",
  130. "RCA", "Optical","Digital", "Analog",
  131. "DIN", "XLR", "RJ11", "Comb",
  132. NULL, NULL, NULL, "Other"
  133. };
  134. cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT;
  135. if (names[cfg])
  136. return names[cfg];
  137. else
  138. return "UNKNOWN";
  139. }
  140. static const char *get_jack_color(u32 cfg)
  141. {
  142. static char *names[16] = {
  143. "Unknown", "Black", "Grey", "Blue",
  144. "Green", "Red", "Orange", "Yellow",
  145. "Purple", "Pink", NULL, NULL,
  146. NULL, NULL, "White", "Other",
  147. };
  148. cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
  149. if (names[cfg])
  150. return names[cfg];
  151. else
  152. return "UNKNOWN";
  153. }
  154. static void print_pin_caps(struct snd_info_buffer *buffer,
  155. struct hda_codec *codec, hda_nid_t nid,
  156. int *supports_vref)
  157. {
  158. static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
  159. unsigned int caps, val;
  160. caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
  161. snd_iprintf(buffer, " Pincap 0x%08x:", caps);
  162. if (caps & AC_PINCAP_IN)
  163. snd_iprintf(buffer, " IN");
  164. if (caps & AC_PINCAP_OUT)
  165. snd_iprintf(buffer, " OUT");
  166. if (caps & AC_PINCAP_HP_DRV)
  167. snd_iprintf(buffer, " HP");
  168. if (caps & AC_PINCAP_EAPD)
  169. snd_iprintf(buffer, " EAPD");
  170. if (caps & AC_PINCAP_PRES_DETECT)
  171. snd_iprintf(buffer, " Detect");
  172. if (caps & AC_PINCAP_BALANCE)
  173. snd_iprintf(buffer, " Balanced");
  174. if (caps & AC_PINCAP_HDMI) {
  175. /* Realtek uses this bit as a different meaning */
  176. if ((codec->vendor_id >> 16) == 0x10ec)
  177. snd_iprintf(buffer, " R/L");
  178. else
  179. snd_iprintf(buffer, " HDMI");
  180. }
  181. if (caps & AC_PINCAP_TRIG_REQ)
  182. snd_iprintf(buffer, " Trigger");
  183. if (caps & AC_PINCAP_IMP_SENSE)
  184. snd_iprintf(buffer, " ImpSense");
  185. snd_iprintf(buffer, "\n");
  186. if (caps & AC_PINCAP_VREF) {
  187. unsigned int vref =
  188. (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
  189. snd_iprintf(buffer, " Vref caps:");
  190. if (vref & AC_PINCAP_VREF_HIZ)
  191. snd_iprintf(buffer, " HIZ");
  192. if (vref & AC_PINCAP_VREF_50)
  193. snd_iprintf(buffer, " 50");
  194. if (vref & AC_PINCAP_VREF_GRD)
  195. snd_iprintf(buffer, " GRD");
  196. if (vref & AC_PINCAP_VREF_80)
  197. snd_iprintf(buffer, " 80");
  198. if (vref & AC_PINCAP_VREF_100)
  199. snd_iprintf(buffer, " 100");
  200. snd_iprintf(buffer, "\n");
  201. *supports_vref = 1;
  202. } else
  203. *supports_vref = 0;
  204. if (caps & AC_PINCAP_EAPD) {
  205. val = snd_hda_codec_read(codec, nid, 0,
  206. AC_VERB_GET_EAPD_BTLENABLE, 0);
  207. snd_iprintf(buffer, " EAPD 0x%x:", val);
  208. if (val & AC_EAPDBTL_BALANCED)
  209. snd_iprintf(buffer, " BALANCED");
  210. if (val & AC_EAPDBTL_EAPD)
  211. snd_iprintf(buffer, " EAPD");
  212. if (val & AC_EAPDBTL_LR_SWAP)
  213. snd_iprintf(buffer, " R/L");
  214. snd_iprintf(buffer, "\n");
  215. }
  216. caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
  217. snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
  218. jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
  219. snd_hda_get_jack_type(caps),
  220. snd_hda_get_jack_connectivity(caps),
  221. snd_hda_get_jack_location(caps));
  222. snd_iprintf(buffer, " Conn = %s, Color = %s\n",
  223. get_jack_connection(caps),
  224. get_jack_color(caps));
  225. /* Default association and sequence values refer to default grouping
  226. * of pin complexes and their sequence within the group. This is used
  227. * for priority and resource allocation.
  228. */
  229. snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n",
  230. (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
  231. caps & AC_DEFCFG_SEQUENCE);
  232. if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
  233. AC_DEFCFG_MISC_NO_PRESENCE) {
  234. /* Miscellaneous bit indicates external hardware does not
  235. * support presence detection even if the pin complex
  236. * indicates it is supported.
  237. */
  238. snd_iprintf(buffer, " Misc = NO_PRESENCE\n");
  239. }
  240. }
  241. static void print_pin_ctls(struct snd_info_buffer *buffer,
  242. struct hda_codec *codec, hda_nid_t nid,
  243. int supports_vref)
  244. {
  245. unsigned int pinctls;
  246. pinctls = snd_hda_codec_read(codec, nid, 0,
  247. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  248. snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
  249. if (pinctls & AC_PINCTL_IN_EN)
  250. snd_iprintf(buffer, " IN");
  251. if (pinctls & AC_PINCTL_OUT_EN)
  252. snd_iprintf(buffer, " OUT");
  253. if (pinctls & AC_PINCTL_HP_EN)
  254. snd_iprintf(buffer, " HP");
  255. if (supports_vref) {
  256. int vref = pinctls & AC_PINCTL_VREFEN;
  257. switch (vref) {
  258. case AC_PINCTL_VREF_HIZ:
  259. snd_iprintf(buffer, " VREF_HIZ");
  260. break;
  261. case AC_PINCTL_VREF_50:
  262. snd_iprintf(buffer, " VREF_50");
  263. break;
  264. case AC_PINCTL_VREF_GRD:
  265. snd_iprintf(buffer, " VREF_GRD");
  266. break;
  267. case AC_PINCTL_VREF_80:
  268. snd_iprintf(buffer, " VREF_80");
  269. break;
  270. case AC_PINCTL_VREF_100:
  271. snd_iprintf(buffer, " VREF_100");
  272. break;
  273. }
  274. }
  275. snd_iprintf(buffer, "\n");
  276. }
  277. static void print_vol_knob(struct snd_info_buffer *buffer,
  278. struct hda_codec *codec, hda_nid_t nid)
  279. {
  280. unsigned int cap = snd_hda_param_read(codec, nid,
  281. AC_PAR_VOL_KNB_CAP);
  282. snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ",
  283. (cap >> 7) & 1, cap & 0x7f);
  284. cap = snd_hda_codec_read(codec, nid, 0,
  285. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  286. snd_iprintf(buffer, "direct=%d, val=%d\n",
  287. (cap >> 7) & 1, cap & 0x7f);
  288. }
  289. static void print_audio_io(struct snd_info_buffer *buffer,
  290. struct hda_codec *codec, hda_nid_t nid,
  291. unsigned int wid_type)
  292. {
  293. int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
  294. snd_iprintf(buffer,
  295. " Converter: stream=%d, channel=%d\n",
  296. (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
  297. conv & AC_CONV_CHANNEL);
  298. if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
  299. int sdi = snd_hda_codec_read(codec, nid, 0,
  300. AC_VERB_GET_SDI_SELECT, 0);
  301. snd_iprintf(buffer, " SDI-Select: %d\n",
  302. sdi & AC_SDI_SELECT);
  303. }
  304. }
  305. static void print_digital_conv(struct snd_info_buffer *buffer,
  306. struct hda_codec *codec, hda_nid_t nid)
  307. {
  308. unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
  309. AC_VERB_GET_DIGI_CONVERT_1, 0);
  310. snd_iprintf(buffer, " Digital:");
  311. if (digi1 & AC_DIG1_ENABLE)
  312. snd_iprintf(buffer, " Enabled");
  313. if (digi1 & AC_DIG1_V)
  314. snd_iprintf(buffer, " Validity");
  315. if (digi1 & AC_DIG1_VCFG)
  316. snd_iprintf(buffer, " ValidityCfg");
  317. if (digi1 & AC_DIG1_EMPHASIS)
  318. snd_iprintf(buffer, " Preemphasis");
  319. if (digi1 & AC_DIG1_COPYRIGHT)
  320. snd_iprintf(buffer, " Copyright");
  321. if (digi1 & AC_DIG1_NONAUDIO)
  322. snd_iprintf(buffer, " Non-Audio");
  323. if (digi1 & AC_DIG1_PROFESSIONAL)
  324. snd_iprintf(buffer, " Pro");
  325. if (digi1 & AC_DIG1_LEVEL)
  326. snd_iprintf(buffer, " GenLevel");
  327. snd_iprintf(buffer, "\n");
  328. snd_iprintf(buffer, " Digital category: 0x%x\n",
  329. (digi1 >> 8) & AC_DIG2_CC);
  330. }
  331. static const char *get_pwr_state(u32 state)
  332. {
  333. static const char *buf[4] = {
  334. "D0", "D1", "D2", "D3"
  335. };
  336. if (state < 4)
  337. return buf[state];
  338. return "UNKNOWN";
  339. }
  340. static void print_power_state(struct snd_info_buffer *buffer,
  341. struct hda_codec *codec, hda_nid_t nid)
  342. {
  343. int pwr = snd_hda_codec_read(codec, nid, 0,
  344. AC_VERB_GET_POWER_STATE, 0);
  345. snd_iprintf(buffer, " Power: setting=%s, actual=%s\n",
  346. get_pwr_state(pwr & AC_PWRST_SETTING),
  347. get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
  348. AC_PWRST_ACTUAL_SHIFT));
  349. }
  350. static void print_unsol_cap(struct snd_info_buffer *buffer,
  351. struct hda_codec *codec, hda_nid_t nid)
  352. {
  353. int unsol = snd_hda_codec_read(codec, nid, 0,
  354. AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
  355. snd_iprintf(buffer,
  356. " Unsolicited: tag=%02x, enabled=%d\n",
  357. unsol & AC_UNSOL_TAG,
  358. (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
  359. }
  360. static void print_proc_caps(struct snd_info_buffer *buffer,
  361. struct hda_codec *codec, hda_nid_t nid)
  362. {
  363. unsigned int proc_caps = snd_hda_param_read(codec, nid,
  364. AC_PAR_PROC_CAP);
  365. snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
  366. proc_caps & AC_PCAP_BENIGN,
  367. (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
  368. }
  369. static void print_conn_list(struct snd_info_buffer *buffer,
  370. struct hda_codec *codec, hda_nid_t nid,
  371. unsigned int wid_type, hda_nid_t *conn,
  372. int conn_len)
  373. {
  374. int c, curr = -1;
  375. if (conn_len > 1 &&
  376. wid_type != AC_WID_AUD_MIX &&
  377. wid_type != AC_WID_VOL_KNB &&
  378. wid_type != AC_WID_POWER)
  379. curr = snd_hda_codec_read(codec, nid, 0,
  380. AC_VERB_GET_CONNECT_SEL, 0);
  381. snd_iprintf(buffer, " Connection: %d\n", conn_len);
  382. if (conn_len > 0) {
  383. snd_iprintf(buffer, " ");
  384. for (c = 0; c < conn_len; c++) {
  385. snd_iprintf(buffer, " 0x%02x", conn[c]);
  386. if (c == curr)
  387. snd_iprintf(buffer, "*");
  388. }
  389. snd_iprintf(buffer, "\n");
  390. }
  391. }
  392. static void print_gpio(struct snd_info_buffer *buffer,
  393. struct hda_codec *codec, hda_nid_t nid)
  394. {
  395. unsigned int gpio =
  396. snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
  397. unsigned int enable, direction, wake, unsol, sticky, data;
  398. int i, max;
  399. snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
  400. "unsolicited=%d, wake=%d\n",
  401. gpio & AC_GPIO_IO_COUNT,
  402. (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
  403. (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
  404. (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
  405. (gpio & AC_GPIO_WAKE) ? 1 : 0);
  406. max = gpio & AC_GPIO_IO_COUNT;
  407. if (!max || max > 8)
  408. return;
  409. enable = snd_hda_codec_read(codec, nid, 0,
  410. AC_VERB_GET_GPIO_MASK, 0);
  411. direction = snd_hda_codec_read(codec, nid, 0,
  412. AC_VERB_GET_GPIO_DIRECTION, 0);
  413. wake = snd_hda_codec_read(codec, nid, 0,
  414. AC_VERB_GET_GPIO_WAKE_MASK, 0);
  415. unsol = snd_hda_codec_read(codec, nid, 0,
  416. AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
  417. sticky = snd_hda_codec_read(codec, nid, 0,
  418. AC_VERB_GET_GPIO_STICKY_MASK, 0);
  419. data = snd_hda_codec_read(codec, nid, 0,
  420. AC_VERB_GET_GPIO_DATA, 0);
  421. for (i = 0; i < max; ++i)
  422. snd_iprintf(buffer,
  423. " IO[%d]: enable=%d, dir=%d, wake=%d, "
  424. "sticky=%d, data=%d, unsol=%d\n", i,
  425. (enable & (1<<i)) ? 1 : 0,
  426. (direction & (1<<i)) ? 1 : 0,
  427. (wake & (1<<i)) ? 1 : 0,
  428. (sticky & (1<<i)) ? 1 : 0,
  429. (data & (1<<i)) ? 1 : 0,
  430. (unsol & (1<<i)) ? 1 : 0);
  431. /* FIXME: add GPO and GPI pin information */
  432. }
  433. static void print_codec_info(struct snd_info_entry *entry,
  434. struct snd_info_buffer *buffer)
  435. {
  436. struct hda_codec *codec = entry->private_data;
  437. hda_nid_t nid;
  438. int i, nodes;
  439. snd_iprintf(buffer, "Codec: %s\n",
  440. codec->name ? codec->name : "Not Set");
  441. snd_iprintf(buffer, "Address: %d\n", codec->addr);
  442. snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id);
  443. snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
  444. snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
  445. snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
  446. if (codec->mfg)
  447. snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
  448. else
  449. snd_iprintf(buffer, "No Modem Function Group found\n");
  450. if (! codec->afg)
  451. return;
  452. snd_hda_power_up(codec);
  453. snd_iprintf(buffer, "Default PCM:\n");
  454. print_pcm_caps(buffer, codec, codec->afg);
  455. snd_iprintf(buffer, "Default Amp-In caps: ");
  456. print_amp_caps(buffer, codec, codec->afg, HDA_INPUT);
  457. snd_iprintf(buffer, "Default Amp-Out caps: ");
  458. print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT);
  459. nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
  460. if (! nid || nodes < 0) {
  461. snd_iprintf(buffer, "Invalid AFG subtree\n");
  462. snd_hda_power_down(codec);
  463. return;
  464. }
  465. print_gpio(buffer, codec, codec->afg);
  466. if (codec->proc_widget_hook)
  467. codec->proc_widget_hook(buffer, codec, codec->afg);
  468. for (i = 0; i < nodes; i++, nid++) {
  469. unsigned int wid_caps =
  470. snd_hda_param_read(codec, nid,
  471. AC_PAR_AUDIO_WIDGET_CAP);
  472. unsigned int wid_type =
  473. (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  474. hda_nid_t conn[HDA_MAX_CONNECTIONS];
  475. int conn_len = 0;
  476. snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
  477. get_wid_type_name(wid_type), wid_caps);
  478. if (wid_caps & AC_WCAP_STEREO) {
  479. unsigned int chans;
  480. chans = (wid_caps & AC_WCAP_CHAN_CNT_EXT) >> 13;
  481. chans = ((chans << 1) | 1) + 1;
  482. if (chans == 2)
  483. snd_iprintf(buffer, " Stereo");
  484. else
  485. snd_iprintf(buffer, " %d-Channels", chans);
  486. } else
  487. snd_iprintf(buffer, " Mono");
  488. if (wid_caps & AC_WCAP_DIGITAL)
  489. snd_iprintf(buffer, " Digital");
  490. if (wid_caps & AC_WCAP_IN_AMP)
  491. snd_iprintf(buffer, " Amp-In");
  492. if (wid_caps & AC_WCAP_OUT_AMP)
  493. snd_iprintf(buffer, " Amp-Out");
  494. if (wid_caps & AC_WCAP_STRIPE)
  495. snd_iprintf(buffer, " Stripe");
  496. if (wid_caps & AC_WCAP_LR_SWAP)
  497. snd_iprintf(buffer, " R/L");
  498. if (wid_caps & AC_WCAP_CP_CAPS)
  499. snd_iprintf(buffer, " CP");
  500. snd_iprintf(buffer, "\n");
  501. /* volume knob is a special widget that always have connection
  502. * list
  503. */
  504. if (wid_type == AC_WID_VOL_KNB)
  505. wid_caps |= AC_WCAP_CONN_LIST;
  506. if (wid_caps & AC_WCAP_CONN_LIST)
  507. conn_len = snd_hda_get_connections(codec, nid, conn,
  508. HDA_MAX_CONNECTIONS);
  509. if (wid_caps & AC_WCAP_IN_AMP) {
  510. snd_iprintf(buffer, " Amp-In caps: ");
  511. print_amp_caps(buffer, codec, nid, HDA_INPUT);
  512. snd_iprintf(buffer, " Amp-In vals: ");
  513. print_amp_vals(buffer, codec, nid, HDA_INPUT,
  514. wid_caps & AC_WCAP_STEREO,
  515. wid_type == AC_WID_PIN ? 1 : conn_len);
  516. }
  517. if (wid_caps & AC_WCAP_OUT_AMP) {
  518. snd_iprintf(buffer, " Amp-Out caps: ");
  519. print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
  520. snd_iprintf(buffer, " Amp-Out vals: ");
  521. if (wid_type == AC_WID_PIN &&
  522. codec->pin_amp_workaround)
  523. print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
  524. wid_caps & AC_WCAP_STEREO,
  525. conn_len);
  526. else
  527. print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
  528. wid_caps & AC_WCAP_STEREO, 1);
  529. }
  530. switch (wid_type) {
  531. case AC_WID_PIN: {
  532. int supports_vref;
  533. print_pin_caps(buffer, codec, nid, &supports_vref);
  534. print_pin_ctls(buffer, codec, nid, supports_vref);
  535. break;
  536. }
  537. case AC_WID_VOL_KNB:
  538. print_vol_knob(buffer, codec, nid);
  539. break;
  540. case AC_WID_AUD_OUT:
  541. case AC_WID_AUD_IN:
  542. print_audio_io(buffer, codec, nid, wid_type);
  543. if (wid_caps & AC_WCAP_DIGITAL)
  544. print_digital_conv(buffer, codec, nid);
  545. if (wid_caps & AC_WCAP_FORMAT_OVRD) {
  546. snd_iprintf(buffer, " PCM:\n");
  547. print_pcm_caps(buffer, codec, nid);
  548. }
  549. break;
  550. }
  551. if (wid_caps & AC_WCAP_UNSOL_CAP)
  552. print_unsol_cap(buffer, codec, nid);
  553. if (wid_caps & AC_WCAP_POWER)
  554. print_power_state(buffer, codec, nid);
  555. if (wid_caps & AC_WCAP_DELAY)
  556. snd_iprintf(buffer, " Delay: %d samples\n",
  557. (wid_caps & AC_WCAP_DELAY) >>
  558. AC_WCAP_DELAY_SHIFT);
  559. if (wid_caps & AC_WCAP_CONN_LIST)
  560. print_conn_list(buffer, codec, nid, wid_type,
  561. conn, conn_len);
  562. if (wid_caps & AC_WCAP_PROC_WID)
  563. print_proc_caps(buffer, codec, nid);
  564. if (codec->proc_widget_hook)
  565. codec->proc_widget_hook(buffer, codec, nid);
  566. }
  567. snd_hda_power_down(codec);
  568. }
  569. /*
  570. * create a proc read
  571. */
  572. int snd_hda_codec_proc_new(struct hda_codec *codec)
  573. {
  574. char name[32];
  575. struct snd_info_entry *entry;
  576. int err;
  577. snprintf(name, sizeof(name), "codec#%d", codec->addr);
  578. err = snd_card_proc_new(codec->bus->card, name, &entry);
  579. if (err < 0)
  580. return err;
  581. snd_info_set_text_ops(entry, codec, print_codec_info);
  582. return 0;
  583. }