hda_proc.c 20 KB

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