hda_proc.c 20 KB

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