hda_proc.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. unsigned int digi2 = snd_hda_codec_read(codec, nid, 0,
  348. AC_VERB_GET_DIGI_CONVERT_2, 0);
  349. snd_iprintf(buffer, " Digital:");
  350. if (digi1 & AC_DIG1_ENABLE)
  351. snd_iprintf(buffer, " Enabled");
  352. if (digi1 & AC_DIG1_V)
  353. snd_iprintf(buffer, " Validity");
  354. if (digi1 & AC_DIG1_VCFG)
  355. snd_iprintf(buffer, " ValidityCfg");
  356. if (digi1 & AC_DIG1_EMPHASIS)
  357. snd_iprintf(buffer, " Preemphasis");
  358. if (digi1 & AC_DIG1_COPYRIGHT)
  359. snd_iprintf(buffer, " Copyright");
  360. if (digi1 & AC_DIG1_NONAUDIO)
  361. snd_iprintf(buffer, " Non-Audio");
  362. if (digi1 & AC_DIG1_PROFESSIONAL)
  363. snd_iprintf(buffer, " Pro");
  364. if (digi1 & AC_DIG1_LEVEL)
  365. snd_iprintf(buffer, " GenLevel");
  366. snd_iprintf(buffer, "\n");
  367. snd_iprintf(buffer, " Digital category: 0x%x\n", digi2 & AC_DIG2_CC);
  368. }
  369. static const char *get_pwr_state(u32 state)
  370. {
  371. static const char *buf[4] = {
  372. "D0", "D1", "D2", "D3"
  373. };
  374. if (state < 4)
  375. return buf[state];
  376. return "UNKNOWN";
  377. }
  378. static void print_power_state(struct snd_info_buffer *buffer,
  379. struct hda_codec *codec, hda_nid_t nid)
  380. {
  381. int pwr = snd_hda_codec_read(codec, nid, 0,
  382. AC_VERB_GET_POWER_STATE, 0);
  383. snd_iprintf(buffer, " Power: setting=%s, actual=%s\n",
  384. get_pwr_state(pwr & AC_PWRST_SETTING),
  385. get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
  386. AC_PWRST_ACTUAL_SHIFT));
  387. }
  388. static void print_unsol_cap(struct snd_info_buffer *buffer,
  389. struct hda_codec *codec, hda_nid_t nid)
  390. {
  391. int unsol = snd_hda_codec_read(codec, nid, 0,
  392. AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
  393. snd_iprintf(buffer,
  394. " Unsolicited: tag=%02x, enabled=%d\n",
  395. unsol & AC_UNSOL_TAG,
  396. (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
  397. }
  398. static void print_proc_caps(struct snd_info_buffer *buffer,
  399. struct hda_codec *codec, hda_nid_t nid)
  400. {
  401. unsigned int proc_caps = snd_hda_param_read(codec, nid,
  402. AC_PAR_PROC_CAP);
  403. snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
  404. proc_caps & AC_PCAP_BENIGN,
  405. (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
  406. }
  407. static void print_conn_list(struct snd_info_buffer *buffer,
  408. struct hda_codec *codec, hda_nid_t nid,
  409. unsigned int wid_type, hda_nid_t *conn,
  410. int conn_len)
  411. {
  412. int c, curr = -1;
  413. if (conn_len > 1 && wid_type != AC_WID_AUD_MIX)
  414. curr = snd_hda_codec_read(codec, nid, 0,
  415. AC_VERB_GET_CONNECT_SEL, 0);
  416. snd_iprintf(buffer, " Connection: %d\n", conn_len);
  417. if (conn_len > 0) {
  418. snd_iprintf(buffer, " ");
  419. for (c = 0; c < conn_len; c++) {
  420. snd_iprintf(buffer, " 0x%02x", conn[c]);
  421. if (c == curr)
  422. snd_iprintf(buffer, "*");
  423. }
  424. snd_iprintf(buffer, "\n");
  425. }
  426. }
  427. static void print_realtek_coef(struct snd_info_buffer *buffer,
  428. struct hda_codec *codec, hda_nid_t nid)
  429. {
  430. int coeff = snd_hda_codec_read(codec, nid, 0,
  431. AC_VERB_GET_PROC_COEF, 0);
  432. snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
  433. coeff = snd_hda_codec_read(codec, nid, 0,
  434. AC_VERB_GET_COEF_INDEX, 0);
  435. snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
  436. }
  437. static void print_gpio(struct snd_info_buffer *buffer,
  438. struct hda_codec *codec, hda_nid_t nid)
  439. {
  440. unsigned int gpio =
  441. snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
  442. unsigned int enable, direction, wake, unsol, sticky, data;
  443. int i, max;
  444. snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
  445. "unsolicited=%d, wake=%d\n",
  446. gpio & AC_GPIO_IO_COUNT,
  447. (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
  448. (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
  449. (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
  450. (gpio & AC_GPIO_WAKE) ? 1 : 0);
  451. max = gpio & AC_GPIO_IO_COUNT;
  452. enable = snd_hda_codec_read(codec, nid, 0,
  453. AC_VERB_GET_GPIO_MASK, 0);
  454. direction = snd_hda_codec_read(codec, nid, 0,
  455. AC_VERB_GET_GPIO_DIRECTION, 0);
  456. wake = snd_hda_codec_read(codec, nid, 0,
  457. AC_VERB_GET_GPIO_WAKE_MASK, 0);
  458. unsol = snd_hda_codec_read(codec, nid, 0,
  459. AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
  460. sticky = snd_hda_codec_read(codec, nid, 0,
  461. AC_VERB_GET_GPIO_STICKY_MASK, 0);
  462. data = snd_hda_codec_read(codec, nid, 0,
  463. AC_VERB_GET_GPIO_DATA, 0);
  464. for (i = 0; i < max; ++i)
  465. snd_iprintf(buffer,
  466. " IO[%d]: enable=%d, dir=%d, wake=%d, "
  467. "sticky=%d, data=%d\n", i,
  468. (enable & (1<<i)) ? 1 : 0,
  469. (direction & (1<<i)) ? 1 : 0,
  470. (wake & (1<<i)) ? 1 : 0,
  471. (sticky & (1<<i)) ? 1 : 0,
  472. (data & (1<<i)) ? 1 : 0);
  473. /* FIXME: add GPO and GPI pin information */
  474. }
  475. static void print_codec_info(struct snd_info_entry *entry,
  476. struct snd_info_buffer *buffer)
  477. {
  478. struct hda_codec *codec = entry->private_data;
  479. char buf[32];
  480. hda_nid_t nid;
  481. int i, nodes;
  482. snd_hda_get_codec_name(codec, buf, sizeof(buf));
  483. snd_iprintf(buffer, "Codec: %s\n", buf);
  484. snd_iprintf(buffer, "Address: %d\n", codec->addr);
  485. snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
  486. snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
  487. snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
  488. if (codec->mfg)
  489. snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
  490. else
  491. snd_iprintf(buffer, "No Modem Function Group found\n");
  492. if (! codec->afg)
  493. return;
  494. snd_hda_power_up(codec);
  495. snd_iprintf(buffer, "Default PCM:\n");
  496. print_pcm_caps(buffer, codec, codec->afg);
  497. snd_iprintf(buffer, "Default Amp-In caps: ");
  498. print_amp_caps(buffer, codec, codec->afg, HDA_INPUT);
  499. snd_iprintf(buffer, "Default Amp-Out caps: ");
  500. print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT);
  501. nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
  502. if (! nid || nodes < 0) {
  503. snd_iprintf(buffer, "Invalid AFG subtree\n");
  504. snd_hda_power_down(codec);
  505. return;
  506. }
  507. print_gpio(buffer, codec, codec->afg);
  508. for (i = 0; i < nodes; i++, nid++) {
  509. unsigned int wid_caps =
  510. snd_hda_param_read(codec, nid,
  511. AC_PAR_AUDIO_WIDGET_CAP);
  512. unsigned int wid_type =
  513. (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  514. hda_nid_t conn[HDA_MAX_CONNECTIONS];
  515. int conn_len = 0;
  516. snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
  517. get_wid_type_name(wid_type), wid_caps);
  518. if (wid_caps & AC_WCAP_STEREO)
  519. snd_iprintf(buffer, " Stereo");
  520. else
  521. snd_iprintf(buffer, " Mono");
  522. if (wid_caps & AC_WCAP_DIGITAL)
  523. snd_iprintf(buffer, " Digital");
  524. if (wid_caps & AC_WCAP_IN_AMP)
  525. snd_iprintf(buffer, " Amp-In");
  526. if (wid_caps & AC_WCAP_OUT_AMP)
  527. snd_iprintf(buffer, " Amp-Out");
  528. if (wid_caps & AC_WCAP_STRIPE)
  529. snd_iprintf(buffer, " Stripe");
  530. if (wid_caps & AC_WCAP_LR_SWAP)
  531. snd_iprintf(buffer, " R/L");
  532. snd_iprintf(buffer, "\n");
  533. /* volume knob is a special widget that always have connection
  534. * list
  535. */
  536. if (wid_type == AC_WID_VOL_KNB)
  537. wid_caps |= AC_WCAP_CONN_LIST;
  538. if (wid_caps & AC_WCAP_CONN_LIST)
  539. conn_len = snd_hda_get_connections(codec, nid, conn,
  540. HDA_MAX_CONNECTIONS);
  541. if (wid_caps & AC_WCAP_IN_AMP) {
  542. snd_iprintf(buffer, " Amp-In caps: ");
  543. print_amp_caps(buffer, codec, nid, HDA_INPUT);
  544. snd_iprintf(buffer, " Amp-In vals: ");
  545. print_amp_vals(buffer, codec, nid, HDA_INPUT,
  546. wid_caps & AC_WCAP_STEREO,
  547. wid_type == AC_WID_PIN ? 1 : conn_len);
  548. }
  549. if (wid_caps & AC_WCAP_OUT_AMP) {
  550. snd_iprintf(buffer, " Amp-Out caps: ");
  551. print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
  552. snd_iprintf(buffer, " Amp-Out vals: ");
  553. print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
  554. wid_caps & AC_WCAP_STEREO, 1);
  555. }
  556. switch (wid_type) {
  557. case AC_WID_PIN: {
  558. int supports_vref;
  559. print_pin_caps(buffer, codec, nid, &supports_vref);
  560. print_pin_ctls(buffer, codec, nid, supports_vref);
  561. break;
  562. }
  563. case AC_WID_VOL_KNB:
  564. print_vol_knob(buffer, codec, nid);
  565. break;
  566. case AC_WID_AUD_OUT:
  567. case AC_WID_AUD_IN:
  568. print_audio_io(buffer, codec, nid, wid_type);
  569. if (wid_caps & AC_WCAP_DIGITAL)
  570. print_digital_conv(buffer, codec, nid);
  571. if (wid_caps & AC_WCAP_FORMAT_OVRD) {
  572. snd_iprintf(buffer, " PCM:\n");
  573. print_pcm_caps(buffer, codec, nid);
  574. }
  575. break;
  576. }
  577. if (wid_caps & AC_WCAP_UNSOL_CAP)
  578. print_unsol_cap(buffer, codec, nid);
  579. if (wid_caps & AC_WCAP_POWER)
  580. print_power_state(buffer, codec, nid);
  581. if (wid_caps & AC_WCAP_DELAY)
  582. snd_iprintf(buffer, " Delay: %d samples\n",
  583. (wid_caps & AC_WCAP_DELAY) >>
  584. AC_WCAP_DELAY_SHIFT);
  585. if (wid_caps & AC_WCAP_CONN_LIST)
  586. print_conn_list(buffer, codec, nid, wid_type,
  587. conn, conn_len);
  588. if (wid_caps & AC_WCAP_PROC_WID)
  589. print_proc_caps(buffer, codec, nid);
  590. /* NID 0x20 == Realtek Define Registers */
  591. if (codec->vendor_id == 0x10ec && nid == 0x20)
  592. print_realtek_coef(buffer, codec, nid);
  593. }
  594. snd_hda_power_down(codec);
  595. }
  596. /*
  597. * create a proc read
  598. */
  599. int snd_hda_codec_proc_new(struct hda_codec *codec)
  600. {
  601. char name[32];
  602. struct snd_info_entry *entry;
  603. int err;
  604. snprintf(name, sizeof(name), "codec#%d", codec->addr);
  605. err = snd_card_proc_new(codec->bus->card, name, &entry);
  606. if (err < 0)
  607. return err;
  608. snd_info_set_text_ops(entry, codec, print_codec_info);
  609. return 0;
  610. }