hda_proc.c 19 KB

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