hda_proc.c 21 KB

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