hda_proc.c 22 KB

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