hda_proc.c 22 KB

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