hda_proc.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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, " 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[] = {
  403. "D0", "D1", "D2", "D3", "D3cold"
  404. };
  405. if (state < ARRAY_SIZE(buf))
  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 != -1)
  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",
  429. get_pwr_state(pwr & AC_PWRST_SETTING),
  430. get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
  431. AC_PWRST_ACTUAL_SHIFT));
  432. if (pwr & AC_PWRST_ERROR)
  433. snd_iprintf(buffer, ", Error");
  434. if (pwr & AC_PWRST_CLK_STOP_OK)
  435. snd_iprintf(buffer, ", Clock-stop-OK");
  436. if (pwr & AC_PWRST_SETTING_RESET)
  437. snd_iprintf(buffer, ", Setting-reset");
  438. snd_iprintf(buffer, "\n");
  439. }
  440. static void print_unsol_cap(struct snd_info_buffer *buffer,
  441. struct hda_codec *codec, hda_nid_t nid)
  442. {
  443. int unsol = snd_hda_codec_read(codec, nid, 0,
  444. AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
  445. snd_iprintf(buffer,
  446. " Unsolicited: tag=%02x, enabled=%d\n",
  447. unsol & AC_UNSOL_TAG,
  448. (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
  449. }
  450. static void print_proc_caps(struct snd_info_buffer *buffer,
  451. struct hda_codec *codec, hda_nid_t nid)
  452. {
  453. unsigned int proc_caps = snd_hda_param_read(codec, nid,
  454. AC_PAR_PROC_CAP);
  455. snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
  456. proc_caps & AC_PCAP_BENIGN,
  457. (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
  458. }
  459. static void print_conn_list(struct snd_info_buffer *buffer,
  460. struct hda_codec *codec, hda_nid_t nid,
  461. unsigned int wid_type, hda_nid_t *conn,
  462. int conn_len)
  463. {
  464. int c, curr = -1;
  465. if (conn_len > 1 &&
  466. wid_type != AC_WID_AUD_MIX &&
  467. wid_type != AC_WID_VOL_KNB &&
  468. wid_type != AC_WID_POWER)
  469. curr = snd_hda_codec_read(codec, nid, 0,
  470. AC_VERB_GET_CONNECT_SEL, 0);
  471. snd_iprintf(buffer, " Connection: %d\n", conn_len);
  472. if (conn_len > 0) {
  473. snd_iprintf(buffer, " ");
  474. for (c = 0; c < conn_len; c++) {
  475. snd_iprintf(buffer, " 0x%02x", conn[c]);
  476. if (c == curr)
  477. snd_iprintf(buffer, "*");
  478. }
  479. snd_iprintf(buffer, "\n");
  480. }
  481. }
  482. static void print_gpio(struct snd_info_buffer *buffer,
  483. struct hda_codec *codec, hda_nid_t nid)
  484. {
  485. unsigned int gpio =
  486. snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
  487. unsigned int enable, direction, wake, unsol, sticky, data;
  488. int i, max;
  489. snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
  490. "unsolicited=%d, wake=%d\n",
  491. gpio & AC_GPIO_IO_COUNT,
  492. (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
  493. (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
  494. (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
  495. (gpio & AC_GPIO_WAKE) ? 1 : 0);
  496. max = gpio & AC_GPIO_IO_COUNT;
  497. if (!max || max > 8)
  498. return;
  499. enable = snd_hda_codec_read(codec, nid, 0,
  500. AC_VERB_GET_GPIO_MASK, 0);
  501. direction = snd_hda_codec_read(codec, nid, 0,
  502. AC_VERB_GET_GPIO_DIRECTION, 0);
  503. wake = snd_hda_codec_read(codec, nid, 0,
  504. AC_VERB_GET_GPIO_WAKE_MASK, 0);
  505. unsol = snd_hda_codec_read(codec, nid, 0,
  506. AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
  507. sticky = snd_hda_codec_read(codec, nid, 0,
  508. AC_VERB_GET_GPIO_STICKY_MASK, 0);
  509. data = snd_hda_codec_read(codec, nid, 0,
  510. AC_VERB_GET_GPIO_DATA, 0);
  511. for (i = 0; i < max; ++i)
  512. snd_iprintf(buffer,
  513. " IO[%d]: enable=%d, dir=%d, wake=%d, "
  514. "sticky=%d, data=%d, unsol=%d\n", i,
  515. (enable & (1<<i)) ? 1 : 0,
  516. (direction & (1<<i)) ? 1 : 0,
  517. (wake & (1<<i)) ? 1 : 0,
  518. (sticky & (1<<i)) ? 1 : 0,
  519. (data & (1<<i)) ? 1 : 0,
  520. (unsol & (1<<i)) ? 1 : 0);
  521. /* FIXME: add GPO and GPI pin information */
  522. print_nid_array(buffer, codec, nid, &codec->mixers);
  523. print_nid_array(buffer, codec, nid, &codec->nids);
  524. }
  525. static void print_codec_info(struct snd_info_entry *entry,
  526. struct snd_info_buffer *buffer)
  527. {
  528. struct hda_codec *codec = entry->private_data;
  529. hda_nid_t nid;
  530. int i, nodes;
  531. snd_iprintf(buffer, "Codec: ");
  532. if (codec->vendor_name && codec->chip_name)
  533. snd_iprintf(buffer, "%s %s\n",
  534. codec->vendor_name, codec->chip_name);
  535. else
  536. snd_iprintf(buffer, "Not Set\n");
  537. snd_iprintf(buffer, "Address: %d\n", codec->addr);
  538. if (codec->afg)
  539. snd_iprintf(buffer, "AFG Function Id: 0x%x (unsol %u)\n",
  540. codec->afg_function_id, codec->afg_unsol);
  541. if (codec->mfg)
  542. snd_iprintf(buffer, "MFG Function Id: 0x%x (unsol %u)\n",
  543. codec->mfg_function_id, codec->mfg_unsol);
  544. snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
  545. snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
  546. snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
  547. if (codec->mfg)
  548. snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
  549. else
  550. snd_iprintf(buffer, "No Modem Function Group found\n");
  551. if (! codec->afg)
  552. return;
  553. snd_hda_power_up(codec);
  554. snd_iprintf(buffer, "Default PCM:\n");
  555. print_pcm_caps(buffer, codec, codec->afg);
  556. snd_iprintf(buffer, "Default Amp-In caps: ");
  557. print_amp_caps(buffer, codec, codec->afg, HDA_INPUT);
  558. snd_iprintf(buffer, "Default Amp-Out caps: ");
  559. print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT);
  560. nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
  561. if (! nid || nodes < 0) {
  562. snd_iprintf(buffer, "Invalid AFG subtree\n");
  563. snd_hda_power_down(codec);
  564. return;
  565. }
  566. print_gpio(buffer, codec, codec->afg);
  567. if (codec->proc_widget_hook)
  568. codec->proc_widget_hook(buffer, codec, codec->afg);
  569. for (i = 0; i < nodes; i++, nid++) {
  570. unsigned int wid_caps =
  571. snd_hda_param_read(codec, nid,
  572. AC_PAR_AUDIO_WIDGET_CAP);
  573. unsigned int wid_type = get_wcaps_type(wid_caps);
  574. hda_nid_t conn[HDA_MAX_CONNECTIONS];
  575. int conn_len = 0;
  576. snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
  577. get_wid_type_name(wid_type), wid_caps);
  578. if (wid_caps & AC_WCAP_STEREO) {
  579. unsigned int chans = get_wcaps_channels(wid_caps);
  580. if (chans == 2)
  581. snd_iprintf(buffer, " Stereo");
  582. else
  583. snd_iprintf(buffer, " %d-Channels", chans);
  584. } else
  585. snd_iprintf(buffer, " Mono");
  586. if (wid_caps & AC_WCAP_DIGITAL)
  587. snd_iprintf(buffer, " Digital");
  588. if (wid_caps & AC_WCAP_IN_AMP)
  589. snd_iprintf(buffer, " Amp-In");
  590. if (wid_caps & AC_WCAP_OUT_AMP)
  591. snd_iprintf(buffer, " Amp-Out");
  592. if (wid_caps & AC_WCAP_STRIPE)
  593. snd_iprintf(buffer, " Stripe");
  594. if (wid_caps & AC_WCAP_LR_SWAP)
  595. snd_iprintf(buffer, " R/L");
  596. if (wid_caps & AC_WCAP_CP_CAPS)
  597. snd_iprintf(buffer, " CP");
  598. snd_iprintf(buffer, "\n");
  599. print_nid_array(buffer, codec, nid, &codec->mixers);
  600. print_nid_array(buffer, codec, nid, &codec->nids);
  601. print_nid_pcms(buffer, codec, nid);
  602. /* volume knob is a special widget that always have connection
  603. * list
  604. */
  605. if (wid_type == AC_WID_VOL_KNB)
  606. wid_caps |= AC_WCAP_CONN_LIST;
  607. if (wid_caps & AC_WCAP_CONN_LIST)
  608. conn_len = snd_hda_get_raw_connections(codec, nid, conn,
  609. HDA_MAX_CONNECTIONS);
  610. if (wid_caps & AC_WCAP_IN_AMP) {
  611. snd_iprintf(buffer, " Amp-In caps: ");
  612. print_amp_caps(buffer, codec, nid, HDA_INPUT);
  613. snd_iprintf(buffer, " Amp-In vals: ");
  614. if (wid_type == AC_WID_PIN ||
  615. (codec->single_adc_amp &&
  616. wid_type == AC_WID_AUD_IN))
  617. print_amp_vals(buffer, codec, nid, HDA_INPUT,
  618. wid_caps & AC_WCAP_STEREO,
  619. 1);
  620. else
  621. print_amp_vals(buffer, codec, nid, HDA_INPUT,
  622. wid_caps & AC_WCAP_STEREO,
  623. conn_len);
  624. }
  625. if (wid_caps & AC_WCAP_OUT_AMP) {
  626. snd_iprintf(buffer, " Amp-Out caps: ");
  627. print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
  628. snd_iprintf(buffer, " Amp-Out vals: ");
  629. if (wid_type == AC_WID_PIN &&
  630. codec->pin_amp_workaround)
  631. print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
  632. wid_caps & AC_WCAP_STEREO,
  633. conn_len);
  634. else
  635. print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
  636. wid_caps & AC_WCAP_STEREO, 1);
  637. }
  638. switch (wid_type) {
  639. case AC_WID_PIN: {
  640. int supports_vref;
  641. print_pin_caps(buffer, codec, nid, &supports_vref);
  642. print_pin_ctls(buffer, codec, nid, supports_vref);
  643. break;
  644. }
  645. case AC_WID_VOL_KNB:
  646. print_vol_knob(buffer, codec, nid);
  647. break;
  648. case AC_WID_AUD_OUT:
  649. case AC_WID_AUD_IN:
  650. print_audio_io(buffer, codec, nid, wid_type);
  651. if (wid_caps & AC_WCAP_DIGITAL)
  652. print_digital_conv(buffer, codec, nid);
  653. if (wid_caps & AC_WCAP_FORMAT_OVRD) {
  654. snd_iprintf(buffer, " PCM:\n");
  655. print_pcm_caps(buffer, codec, nid);
  656. }
  657. break;
  658. }
  659. if (wid_caps & AC_WCAP_UNSOL_CAP)
  660. print_unsol_cap(buffer, codec, nid);
  661. if (wid_caps & AC_WCAP_POWER)
  662. print_power_state(buffer, codec, nid);
  663. if (wid_caps & AC_WCAP_DELAY)
  664. snd_iprintf(buffer, " Delay: %d samples\n",
  665. (wid_caps & AC_WCAP_DELAY) >>
  666. AC_WCAP_DELAY_SHIFT);
  667. if (wid_caps & AC_WCAP_CONN_LIST)
  668. print_conn_list(buffer, codec, nid, wid_type,
  669. conn, conn_len);
  670. if (wid_caps & AC_WCAP_PROC_WID)
  671. print_proc_caps(buffer, codec, nid);
  672. if (codec->proc_widget_hook)
  673. codec->proc_widget_hook(buffer, codec, nid);
  674. }
  675. snd_hda_power_down(codec);
  676. }
  677. /*
  678. * create a proc read
  679. */
  680. int snd_hda_codec_proc_new(struct hda_codec *codec)
  681. {
  682. char name[32];
  683. struct snd_info_entry *entry;
  684. int err;
  685. snprintf(name, sizeof(name), "codec#%d", codec->addr);
  686. err = snd_card_proc_new(codec->bus->card, name, &entry);
  687. if (err < 0)
  688. return err;
  689. snd_info_set_text_ops(entry, codec, print_codec_info);
  690. return 0;
  691. }