hda_proc.c 21 KB

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