hda_proc.c 22 KB

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