hda_proc.c 22 KB

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