hda_proc.c 22 KB

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