18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 48c2ecf20Sopenharmony_ci * Universal interface for Audio Codec '97 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * For more details look to AC '97 component specification revision 2.2 78c2ecf20Sopenharmony_ci * by Intel Corporation (http://developer.intel.com). 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/mutex.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <sound/core.h> 138c2ecf20Sopenharmony_ci#include <sound/ac97_codec.h> 148c2ecf20Sopenharmony_ci#include <sound/asoundef.h> 158c2ecf20Sopenharmony_ci#include "ac97_local.h" 168c2ecf20Sopenharmony_ci#include "ac97_id.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* 198c2ecf20Sopenharmony_ci * proc interface 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic void snd_ac97_proc_read_functions(struct snd_ac97 *ac97, struct snd_info_buffer *buffer) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci int header = 0, function; 258c2ecf20Sopenharmony_ci unsigned short info, sense_info; 268c2ecf20Sopenharmony_ci static const char *function_names[12] = { 278c2ecf20Sopenharmony_ci "Master Out", "AUX Out", "Center/LFE Out", "SPDIF Out", 288c2ecf20Sopenharmony_ci "Phone In", "Mic 1", "Mic 2", "Line In", "CD In", "Video In", 298c2ecf20Sopenharmony_ci "Aux In", "Mono Out" 308c2ecf20Sopenharmony_ci }; 318c2ecf20Sopenharmony_ci static const char *locations[8] = { 328c2ecf20Sopenharmony_ci "Rear I/O Panel", "Front Panel", "Motherboard", "Dock/External", 338c2ecf20Sopenharmony_ci "reserved", "reserved", "reserved", "NC/unused" 348c2ecf20Sopenharmony_ci }; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci for (function = 0; function < 12; ++function) { 378c2ecf20Sopenharmony_ci snd_ac97_write(ac97, AC97_FUNC_SELECT, function << 1); 388c2ecf20Sopenharmony_ci info = snd_ac97_read(ac97, AC97_FUNC_INFO); 398c2ecf20Sopenharmony_ci if (!(info & 0x0001)) 408c2ecf20Sopenharmony_ci continue; 418c2ecf20Sopenharmony_ci if (!header) { 428c2ecf20Sopenharmony_ci snd_iprintf(buffer, "\n Gain Inverted Buffer delay Location\n"); 438c2ecf20Sopenharmony_ci header = 1; 448c2ecf20Sopenharmony_ci } 458c2ecf20Sopenharmony_ci sense_info = snd_ac97_read(ac97, AC97_SENSE_INFO); 468c2ecf20Sopenharmony_ci snd_iprintf(buffer, "%-17s: %3d.%d dBV %c %2d/fs %s\n", 478c2ecf20Sopenharmony_ci function_names[function], 488c2ecf20Sopenharmony_ci (info & 0x8000 ? -1 : 1) * ((info & 0x7000) >> 12) * 3 / 2, 498c2ecf20Sopenharmony_ci ((info & 0x0800) >> 11) * 5, 508c2ecf20Sopenharmony_ci info & 0x0400 ? 'X' : '-', 518c2ecf20Sopenharmony_ci (info & 0x03e0) >> 5, 528c2ecf20Sopenharmony_ci locations[sense_info >> 13]); 538c2ecf20Sopenharmony_ci } 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistatic const char *snd_ac97_stereo_enhancements[] = 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci /* 0 */ "No 3D Stereo Enhancement", 598c2ecf20Sopenharmony_ci /* 1 */ "Analog Devices Phat Stereo", 608c2ecf20Sopenharmony_ci /* 2 */ "Creative Stereo Enhancement", 618c2ecf20Sopenharmony_ci /* 3 */ "National Semi 3D Stereo Enhancement", 628c2ecf20Sopenharmony_ci /* 4 */ "YAMAHA Ymersion", 638c2ecf20Sopenharmony_ci /* 5 */ "BBE 3D Stereo Enhancement", 648c2ecf20Sopenharmony_ci /* 6 */ "Crystal Semi 3D Stereo Enhancement", 658c2ecf20Sopenharmony_ci /* 7 */ "Qsound QXpander", 668c2ecf20Sopenharmony_ci /* 8 */ "Spatializer 3D Stereo Enhancement", 678c2ecf20Sopenharmony_ci /* 9 */ "SRS 3D Stereo Enhancement", 688c2ecf20Sopenharmony_ci /* 10 */ "Platform Tech 3D Stereo Enhancement", 698c2ecf20Sopenharmony_ci /* 11 */ "AKM 3D Audio", 708c2ecf20Sopenharmony_ci /* 12 */ "Aureal Stereo Enhancement", 718c2ecf20Sopenharmony_ci /* 13 */ "Aztech 3D Enhancement", 728c2ecf20Sopenharmony_ci /* 14 */ "Binaura 3D Audio Enhancement", 738c2ecf20Sopenharmony_ci /* 15 */ "ESS Technology Stereo Enhancement", 748c2ecf20Sopenharmony_ci /* 16 */ "Harman International VMAx", 758c2ecf20Sopenharmony_ci /* 17 */ "Nvidea/IC Ensemble/KS Waves 3D Stereo Enhancement", 768c2ecf20Sopenharmony_ci /* 18 */ "Philips Incredible Sound", 778c2ecf20Sopenharmony_ci /* 19 */ "Texas Instruments 3D Stereo Enhancement", 788c2ecf20Sopenharmony_ci /* 20 */ "VLSI Technology 3D Stereo Enhancement", 798c2ecf20Sopenharmony_ci /* 21 */ "TriTech 3D Stereo Enhancement", 808c2ecf20Sopenharmony_ci /* 22 */ "Realtek 3D Stereo Enhancement", 818c2ecf20Sopenharmony_ci /* 23 */ "Samsung 3D Stereo Enhancement", 828c2ecf20Sopenharmony_ci /* 24 */ "Wolfson Microelectronics 3D Enhancement", 838c2ecf20Sopenharmony_ci /* 25 */ "Delta Integration 3D Enhancement", 848c2ecf20Sopenharmony_ci /* 26 */ "SigmaTel 3D Enhancement", 858c2ecf20Sopenharmony_ci /* 27 */ "IC Ensemble/KS Waves", 868c2ecf20Sopenharmony_ci /* 28 */ "Rockwell 3D Stereo Enhancement", 878c2ecf20Sopenharmony_ci /* 29 */ "Reserved 29", 888c2ecf20Sopenharmony_ci /* 30 */ "Reserved 30", 898c2ecf20Sopenharmony_ci /* 31 */ "Reserved 31" 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistatic void snd_ac97_proc_read_main(struct snd_ac97 *ac97, struct snd_info_buffer *buffer, int subidx) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci char name[64]; 958c2ecf20Sopenharmony_ci unsigned short val, tmp, ext, mext; 968c2ecf20Sopenharmony_ci static const char *spdif_slots[4] = { " SPDIF=3/4", " SPDIF=7/8", " SPDIF=6/9", " SPDIF=10/11" }; 978c2ecf20Sopenharmony_ci static const char *spdif_rates[4] = { " Rate=44.1kHz", " Rate=res", " Rate=48kHz", " Rate=32kHz" }; 988c2ecf20Sopenharmony_ci static const char *spdif_rates_cs4205[4] = { " Rate=48kHz", " Rate=44.1kHz", " Rate=res", " Rate=res" }; 998c2ecf20Sopenharmony_ci static const char *double_rate_slots[4] = { "10/11", "7/8", "reserved", "reserved" }; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci snd_ac97_get_name(NULL, ac97->id, name, 0); 1028c2ecf20Sopenharmony_ci snd_iprintf(buffer, "%d-%d/%d: %s\n\n", ac97->addr, ac97->num, subidx, name); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci if ((ac97->scaps & AC97_SCAP_AUDIO) == 0) 1058c2ecf20Sopenharmony_ci goto __modem; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci snd_iprintf(buffer, "PCI Subsys Vendor: 0x%04x\n", 1088c2ecf20Sopenharmony_ci ac97->subsystem_vendor); 1098c2ecf20Sopenharmony_ci snd_iprintf(buffer, "PCI Subsys Device: 0x%04x\n\n", 1108c2ecf20Sopenharmony_ci ac97->subsystem_device); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Flags: %x\n", ac97->flags); 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) { 1158c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_INT_PAGING); 1168c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_INT_PAGING, 1178c2ecf20Sopenharmony_ci AC97_PAGE_MASK, AC97_PAGE_1); 1188c2ecf20Sopenharmony_ci tmp = snd_ac97_read(ac97, AC97_CODEC_CLASS_REV); 1198c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Revision : 0x%02x\n", tmp & 0xff); 1208c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Compat. Class : 0x%02x\n", (tmp >> 8) & 0x1f); 1218c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Subsys. Vendor ID: 0x%04x\n", 1228c2ecf20Sopenharmony_ci snd_ac97_read(ac97, AC97_PCI_SVID)); 1238c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Subsys. ID : 0x%04x\n\n", 1248c2ecf20Sopenharmony_ci snd_ac97_read(ac97, AC97_PCI_SID)); 1258c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_INT_PAGING, 1268c2ecf20Sopenharmony_ci AC97_PAGE_MASK, val & AC97_PAGE_MASK); 1278c2ecf20Sopenharmony_ci } 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci // val = snd_ac97_read(ac97, AC97_RESET); 1308c2ecf20Sopenharmony_ci val = ac97->caps; 1318c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Capabilities :%s%s%s%s%s%s\n", 1328c2ecf20Sopenharmony_ci val & AC97_BC_DEDICATED_MIC ? " -dedicated MIC PCM IN channel-" : "", 1338c2ecf20Sopenharmony_ci val & AC97_BC_RESERVED1 ? " -reserved1-" : "", 1348c2ecf20Sopenharmony_ci val & AC97_BC_BASS_TREBLE ? " -bass & treble-" : "", 1358c2ecf20Sopenharmony_ci val & AC97_BC_SIM_STEREO ? " -simulated stereo-" : "", 1368c2ecf20Sopenharmony_ci val & AC97_BC_HEADPHONE ? " -headphone out-" : "", 1378c2ecf20Sopenharmony_ci val & AC97_BC_LOUDNESS ? " -loudness-" : ""); 1388c2ecf20Sopenharmony_ci tmp = ac97->caps & AC97_BC_DAC_MASK; 1398c2ecf20Sopenharmony_ci snd_iprintf(buffer, "DAC resolution : %s%s%s%s\n", 1408c2ecf20Sopenharmony_ci tmp == AC97_BC_16BIT_DAC ? "16-bit" : "", 1418c2ecf20Sopenharmony_ci tmp == AC97_BC_18BIT_DAC ? "18-bit" : "", 1428c2ecf20Sopenharmony_ci tmp == AC97_BC_20BIT_DAC ? "20-bit" : "", 1438c2ecf20Sopenharmony_ci tmp == AC97_BC_DAC_MASK ? "???" : ""); 1448c2ecf20Sopenharmony_ci tmp = ac97->caps & AC97_BC_ADC_MASK; 1458c2ecf20Sopenharmony_ci snd_iprintf(buffer, "ADC resolution : %s%s%s%s\n", 1468c2ecf20Sopenharmony_ci tmp == AC97_BC_16BIT_ADC ? "16-bit" : "", 1478c2ecf20Sopenharmony_ci tmp == AC97_BC_18BIT_ADC ? "18-bit" : "", 1488c2ecf20Sopenharmony_ci tmp == AC97_BC_20BIT_ADC ? "20-bit" : "", 1498c2ecf20Sopenharmony_ci tmp == AC97_BC_ADC_MASK ? "???" : ""); 1508c2ecf20Sopenharmony_ci snd_iprintf(buffer, "3D enhancement : %s\n", 1518c2ecf20Sopenharmony_ci snd_ac97_stereo_enhancements[(val >> 10) & 0x1f]); 1528c2ecf20Sopenharmony_ci snd_iprintf(buffer, "\nCurrent setup\n"); 1538c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_MIC); 1548c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Mic gain : %s [%s]\n", val & 0x0040 ? "+20dB" : "+0dB", ac97->regs[AC97_MIC] & 0x0040 ? "+20dB" : "+0dB"); 1558c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_GENERAL_PURPOSE); 1568c2ecf20Sopenharmony_ci snd_iprintf(buffer, "POP path : %s 3D\n" 1578c2ecf20Sopenharmony_ci "Sim. stereo : %s\n" 1588c2ecf20Sopenharmony_ci "3D enhancement : %s\n" 1598c2ecf20Sopenharmony_ci "Loudness : %s\n" 1608c2ecf20Sopenharmony_ci "Mono output : %s\n" 1618c2ecf20Sopenharmony_ci "Mic select : %s\n" 1628c2ecf20Sopenharmony_ci "ADC/DAC loopback : %s\n", 1638c2ecf20Sopenharmony_ci val & 0x8000 ? "post" : "pre", 1648c2ecf20Sopenharmony_ci val & 0x4000 ? "on" : "off", 1658c2ecf20Sopenharmony_ci val & 0x2000 ? "on" : "off", 1668c2ecf20Sopenharmony_ci val & 0x1000 ? "on" : "off", 1678c2ecf20Sopenharmony_ci val & 0x0200 ? "Mic" : "MIX", 1688c2ecf20Sopenharmony_ci val & 0x0100 ? "Mic2" : "Mic1", 1698c2ecf20Sopenharmony_ci val & 0x0080 ? "on" : "off"); 1708c2ecf20Sopenharmony_ci if (ac97->ext_id & AC97_EI_DRA) 1718c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Double rate slots: %s\n", 1728c2ecf20Sopenharmony_ci double_rate_slots[(val >> 10) & 3]); 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci ext = snd_ac97_read(ac97, AC97_EXTENDED_ID); 1758c2ecf20Sopenharmony_ci if (ext == 0) 1768c2ecf20Sopenharmony_ci goto __modem; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Extended ID : codec=%i rev=%i%s%s%s%s DSA=%i%s%s%s%s\n", 1798c2ecf20Sopenharmony_ci (ext & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT, 1808c2ecf20Sopenharmony_ci (ext & AC97_EI_REV_MASK) >> AC97_EI_REV_SHIFT, 1818c2ecf20Sopenharmony_ci ext & AC97_EI_AMAP ? " AMAP" : "", 1828c2ecf20Sopenharmony_ci ext & AC97_EI_LDAC ? " LDAC" : "", 1838c2ecf20Sopenharmony_ci ext & AC97_EI_SDAC ? " SDAC" : "", 1848c2ecf20Sopenharmony_ci ext & AC97_EI_CDAC ? " CDAC" : "", 1858c2ecf20Sopenharmony_ci (ext & AC97_EI_DACS_SLOT_MASK) >> AC97_EI_DACS_SLOT_SHIFT, 1868c2ecf20Sopenharmony_ci ext & AC97_EI_VRM ? " VRM" : "", 1878c2ecf20Sopenharmony_ci ext & AC97_EI_SPDIF ? " SPDIF" : "", 1888c2ecf20Sopenharmony_ci ext & AC97_EI_DRA ? " DRA" : "", 1898c2ecf20Sopenharmony_ci ext & AC97_EI_VRA ? " VRA" : ""); 1908c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS); 1918c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Extended status :%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", 1928c2ecf20Sopenharmony_ci val & AC97_EA_PRL ? " PRL" : "", 1938c2ecf20Sopenharmony_ci val & AC97_EA_PRK ? " PRK" : "", 1948c2ecf20Sopenharmony_ci val & AC97_EA_PRJ ? " PRJ" : "", 1958c2ecf20Sopenharmony_ci val & AC97_EA_PRI ? " PRI" : "", 1968c2ecf20Sopenharmony_ci val & AC97_EA_SPCV ? " SPCV" : "", 1978c2ecf20Sopenharmony_ci val & AC97_EA_MDAC ? " MADC" : "", 1988c2ecf20Sopenharmony_ci val & AC97_EA_LDAC ? " LDAC" : "", 1998c2ecf20Sopenharmony_ci val & AC97_EA_SDAC ? " SDAC" : "", 2008c2ecf20Sopenharmony_ci val & AC97_EA_CDAC ? " CDAC" : "", 2018c2ecf20Sopenharmony_ci ext & AC97_EI_SPDIF ? spdif_slots[(val & AC97_EA_SPSA_SLOT_MASK) >> AC97_EA_SPSA_SLOT_SHIFT] : "", 2028c2ecf20Sopenharmony_ci val & AC97_EA_VRM ? " VRM" : "", 2038c2ecf20Sopenharmony_ci val & AC97_EA_SPDIF ? " SPDIF" : "", 2048c2ecf20Sopenharmony_ci val & AC97_EA_DRA ? " DRA" : "", 2058c2ecf20Sopenharmony_ci val & AC97_EA_VRA ? " VRA" : ""); 2068c2ecf20Sopenharmony_ci if (ext & AC97_EI_VRA) { /* VRA */ 2078c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_PCM_FRONT_DAC_RATE); 2088c2ecf20Sopenharmony_ci snd_iprintf(buffer, "PCM front DAC : %iHz\n", val); 2098c2ecf20Sopenharmony_ci if (ext & AC97_EI_SDAC) { 2108c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_PCM_SURR_DAC_RATE); 2118c2ecf20Sopenharmony_ci snd_iprintf(buffer, "PCM Surr DAC : %iHz\n", val); 2128c2ecf20Sopenharmony_ci } 2138c2ecf20Sopenharmony_ci if (ext & AC97_EI_LDAC) { 2148c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_PCM_LFE_DAC_RATE); 2158c2ecf20Sopenharmony_ci snd_iprintf(buffer, "PCM LFE DAC : %iHz\n", val); 2168c2ecf20Sopenharmony_ci } 2178c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_PCM_LR_ADC_RATE); 2188c2ecf20Sopenharmony_ci snd_iprintf(buffer, "PCM ADC : %iHz\n", val); 2198c2ecf20Sopenharmony_ci } 2208c2ecf20Sopenharmony_ci if (ext & AC97_EI_VRM) { 2218c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_PCM_MIC_ADC_RATE); 2228c2ecf20Sopenharmony_ci snd_iprintf(buffer, "PCM MIC ADC : %iHz\n", val); 2238c2ecf20Sopenharmony_ci } 2248c2ecf20Sopenharmony_ci if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF) || 2258c2ecf20Sopenharmony_ci (ac97->id == AC97_ID_YMF743)) { 2268c2ecf20Sopenharmony_ci if (ac97->flags & AC97_CS_SPDIF) 2278c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_CSR_SPDIF); 2288c2ecf20Sopenharmony_ci else if (ac97->id == AC97_ID_YMF743) { 2298c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_YMF7X3_DIT_CTRL); 2308c2ecf20Sopenharmony_ci val = 0x2000 | (val & 0xff00) >> 4 | (val & 0x38) >> 2; 2318c2ecf20Sopenharmony_ci } else 2328c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_SPDIF); 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci snd_iprintf(buffer, "SPDIF Control :%s%s%s%s Category=0x%x Generation=%i%s%s%s\n", 2358c2ecf20Sopenharmony_ci val & AC97_SC_PRO ? " PRO" : " Consumer", 2368c2ecf20Sopenharmony_ci val & AC97_SC_NAUDIO ? " Non-audio" : " PCM", 2378c2ecf20Sopenharmony_ci val & AC97_SC_COPY ? "" : " Copyright", 2388c2ecf20Sopenharmony_ci val & AC97_SC_PRE ? " Preemph50/15" : "", 2398c2ecf20Sopenharmony_ci (val & AC97_SC_CC_MASK) >> AC97_SC_CC_SHIFT, 2408c2ecf20Sopenharmony_ci (val & AC97_SC_L) >> 11, 2418c2ecf20Sopenharmony_ci (ac97->flags & AC97_CS_SPDIF) ? 2428c2ecf20Sopenharmony_ci spdif_rates_cs4205[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT] : 2438c2ecf20Sopenharmony_ci spdif_rates[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT], 2448c2ecf20Sopenharmony_ci (ac97->flags & AC97_CS_SPDIF) ? 2458c2ecf20Sopenharmony_ci (val & AC97_SC_DRS ? " Validity" : "") : 2468c2ecf20Sopenharmony_ci (val & AC97_SC_DRS ? " DRS" : ""), 2478c2ecf20Sopenharmony_ci (ac97->flags & AC97_CS_SPDIF) ? 2488c2ecf20Sopenharmony_ci (val & AC97_SC_V ? " Enabled" : "") : 2498c2ecf20Sopenharmony_ci (val & AC97_SC_V ? " Validity" : "")); 2508c2ecf20Sopenharmony_ci /* ALC650 specific*/ 2518c2ecf20Sopenharmony_ci if ((ac97->id & 0xfffffff0) == 0x414c4720 && 2528c2ecf20Sopenharmony_ci (snd_ac97_read(ac97, AC97_ALC650_CLOCK) & 0x01)) { 2538c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2); 2548c2ecf20Sopenharmony_ci if (val & AC97_ALC650_CLOCK_LOCK) { 2558c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS1); 2568c2ecf20Sopenharmony_ci snd_iprintf(buffer, "SPDIF In Status :%s%s%s%s Category=0x%x Generation=%i", 2578c2ecf20Sopenharmony_ci val & AC97_ALC650_PRO ? " PRO" : " Consumer", 2588c2ecf20Sopenharmony_ci val & AC97_ALC650_NAUDIO ? " Non-audio" : " PCM", 2598c2ecf20Sopenharmony_ci val & AC97_ALC650_COPY ? "" : " Copyright", 2608c2ecf20Sopenharmony_ci val & AC97_ALC650_PRE ? " Preemph50/15" : "", 2618c2ecf20Sopenharmony_ci (val & AC97_ALC650_CC_MASK) >> AC97_ALC650_CC_SHIFT, 2628c2ecf20Sopenharmony_ci (val & AC97_ALC650_L) >> 15); 2638c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2); 2648c2ecf20Sopenharmony_ci snd_iprintf(buffer, "%s Accuracy=%i%s%s\n", 2658c2ecf20Sopenharmony_ci spdif_rates[(val & AC97_ALC650_SPSR_MASK) >> AC97_ALC650_SPSR_SHIFT], 2668c2ecf20Sopenharmony_ci (val & AC97_ALC650_CLOCK_ACCURACY) >> AC97_ALC650_CLOCK_SHIFT, 2678c2ecf20Sopenharmony_ci (val & AC97_ALC650_CLOCK_LOCK ? " Locked" : " Unlocked"), 2688c2ecf20Sopenharmony_ci (val & AC97_ALC650_V ? " Validity?" : "")); 2698c2ecf20Sopenharmony_ci } else { 2708c2ecf20Sopenharmony_ci snd_iprintf(buffer, "SPDIF In Status : Not Locked\n"); 2718c2ecf20Sopenharmony_ci } 2728c2ecf20Sopenharmony_ci } 2738c2ecf20Sopenharmony_ci } 2748c2ecf20Sopenharmony_ci if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) { 2758c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_INT_PAGING); 2768c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_INT_PAGING, 2778c2ecf20Sopenharmony_ci AC97_PAGE_MASK, AC97_PAGE_1); 2788c2ecf20Sopenharmony_ci snd_ac97_proc_read_functions(ac97, buffer); 2798c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_INT_PAGING, 2808c2ecf20Sopenharmony_ci AC97_PAGE_MASK, val & AC97_PAGE_MASK); 2818c2ecf20Sopenharmony_ci } 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci __modem: 2858c2ecf20Sopenharmony_ci mext = snd_ac97_read(ac97, AC97_EXTENDED_MID); 2868c2ecf20Sopenharmony_ci if (mext == 0) 2878c2ecf20Sopenharmony_ci return; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Extended modem ID: codec=%i%s%s%s%s%s\n", 2908c2ecf20Sopenharmony_ci (mext & AC97_MEI_ADDR_MASK) >> AC97_MEI_ADDR_SHIFT, 2918c2ecf20Sopenharmony_ci mext & AC97_MEI_CID2 ? " CID2" : "", 2928c2ecf20Sopenharmony_ci mext & AC97_MEI_CID1 ? " CID1" : "", 2938c2ecf20Sopenharmony_ci mext & AC97_MEI_HANDSET ? " HSET" : "", 2948c2ecf20Sopenharmony_ci mext & AC97_MEI_LINE2 ? " LIN2" : "", 2958c2ecf20Sopenharmony_ci mext & AC97_MEI_LINE1 ? " LIN1" : ""); 2968c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS); 2978c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Modem status :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", 2988c2ecf20Sopenharmony_ci val & AC97_MEA_GPIO ? " GPIO" : "", 2998c2ecf20Sopenharmony_ci val & AC97_MEA_MREF ? " MREF" : "", 3008c2ecf20Sopenharmony_ci val & AC97_MEA_ADC1 ? " ADC1" : "", 3018c2ecf20Sopenharmony_ci val & AC97_MEA_DAC1 ? " DAC1" : "", 3028c2ecf20Sopenharmony_ci val & AC97_MEA_ADC2 ? " ADC2" : "", 3038c2ecf20Sopenharmony_ci val & AC97_MEA_DAC2 ? " DAC2" : "", 3048c2ecf20Sopenharmony_ci val & AC97_MEA_HADC ? " HADC" : "", 3058c2ecf20Sopenharmony_ci val & AC97_MEA_HDAC ? " HDAC" : "", 3068c2ecf20Sopenharmony_ci val & AC97_MEA_PRA ? " PRA(GPIO)" : "", 3078c2ecf20Sopenharmony_ci val & AC97_MEA_PRB ? " PRB(res)" : "", 3088c2ecf20Sopenharmony_ci val & AC97_MEA_PRC ? " PRC(ADC1)" : "", 3098c2ecf20Sopenharmony_ci val & AC97_MEA_PRD ? " PRD(DAC1)" : "", 3108c2ecf20Sopenharmony_ci val & AC97_MEA_PRE ? " PRE(ADC2)" : "", 3118c2ecf20Sopenharmony_ci val & AC97_MEA_PRF ? " PRF(DAC2)" : "", 3128c2ecf20Sopenharmony_ci val & AC97_MEA_PRG ? " PRG(HADC)" : "", 3138c2ecf20Sopenharmony_ci val & AC97_MEA_PRH ? " PRH(HDAC)" : ""); 3148c2ecf20Sopenharmony_ci if (mext & AC97_MEI_LINE1) { 3158c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_LINE1_RATE); 3168c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Line1 rate : %iHz\n", val); 3178c2ecf20Sopenharmony_ci } 3188c2ecf20Sopenharmony_ci if (mext & AC97_MEI_LINE2) { 3198c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_LINE2_RATE); 3208c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Line2 rate : %iHz\n", val); 3218c2ecf20Sopenharmony_ci } 3228c2ecf20Sopenharmony_ci if (mext & AC97_MEI_HANDSET) { 3238c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, AC97_HANDSET_RATE); 3248c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Headset rate : %iHz\n", val); 3258c2ecf20Sopenharmony_ci } 3268c2ecf20Sopenharmony_ci} 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cistatic void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 3298c2ecf20Sopenharmony_ci{ 3308c2ecf20Sopenharmony_ci struct snd_ac97 *ac97 = entry->private_data; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci mutex_lock(&ac97->page_mutex); 3338c2ecf20Sopenharmony_ci if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86 3348c2ecf20Sopenharmony_ci int idx; 3358c2ecf20Sopenharmony_ci for (idx = 0; idx < 3; idx++) 3368c2ecf20Sopenharmony_ci if (ac97->spec.ad18xx.id[idx]) { 3378c2ecf20Sopenharmony_ci /* select single codec */ 3388c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 3398c2ecf20Sopenharmony_ci ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]); 3408c2ecf20Sopenharmony_ci snd_ac97_proc_read_main(ac97, buffer, idx); 3418c2ecf20Sopenharmony_ci snd_iprintf(buffer, "\n\n"); 3428c2ecf20Sopenharmony_ci } 3438c2ecf20Sopenharmony_ci /* select all codecs */ 3448c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000); 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci snd_iprintf(buffer, "\nAD18XX configuration\n"); 3478c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Unchained : 0x%04x,0x%04x,0x%04x\n", 3488c2ecf20Sopenharmony_ci ac97->spec.ad18xx.unchained[0], 3498c2ecf20Sopenharmony_ci ac97->spec.ad18xx.unchained[1], 3508c2ecf20Sopenharmony_ci ac97->spec.ad18xx.unchained[2]); 3518c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Chained : 0x%04x,0x%04x,0x%04x\n", 3528c2ecf20Sopenharmony_ci ac97->spec.ad18xx.chained[0], 3538c2ecf20Sopenharmony_ci ac97->spec.ad18xx.chained[1], 3548c2ecf20Sopenharmony_ci ac97->spec.ad18xx.chained[2]); 3558c2ecf20Sopenharmony_ci } else { 3568c2ecf20Sopenharmony_ci snd_ac97_proc_read_main(ac97, buffer, 0); 3578c2ecf20Sopenharmony_ci } 3588c2ecf20Sopenharmony_ci mutex_unlock(&ac97->page_mutex); 3598c2ecf20Sopenharmony_ci} 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_DEBUG 3628c2ecf20Sopenharmony_ci/* direct register write for debugging */ 3638c2ecf20Sopenharmony_cistatic void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 3648c2ecf20Sopenharmony_ci{ 3658c2ecf20Sopenharmony_ci struct snd_ac97 *ac97 = entry->private_data; 3668c2ecf20Sopenharmony_ci char line[64]; 3678c2ecf20Sopenharmony_ci unsigned int reg, val; 3688c2ecf20Sopenharmony_ci mutex_lock(&ac97->page_mutex); 3698c2ecf20Sopenharmony_ci while (!snd_info_get_line(buffer, line, sizeof(line))) { 3708c2ecf20Sopenharmony_ci if (sscanf(line, "%x %x", ®, &val) != 2) 3718c2ecf20Sopenharmony_ci continue; 3728c2ecf20Sopenharmony_ci /* register must be even */ 3738c2ecf20Sopenharmony_ci if (reg < 0x80 && (reg & 1) == 0 && val <= 0xffff) 3748c2ecf20Sopenharmony_ci snd_ac97_write_cache(ac97, reg, val); 3758c2ecf20Sopenharmony_ci } 3768c2ecf20Sopenharmony_ci mutex_unlock(&ac97->page_mutex); 3778c2ecf20Sopenharmony_ci} 3788c2ecf20Sopenharmony_ci#endif 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_cistatic void snd_ac97_proc_regs_read_main(struct snd_ac97 *ac97, struct snd_info_buffer *buffer, int subidx) 3818c2ecf20Sopenharmony_ci{ 3828c2ecf20Sopenharmony_ci int reg, val; 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci for (reg = 0; reg < 0x80; reg += 2) { 3858c2ecf20Sopenharmony_ci val = snd_ac97_read(ac97, reg); 3868c2ecf20Sopenharmony_ci snd_iprintf(buffer, "%i:%02x = %04x\n", subidx, reg, val); 3878c2ecf20Sopenharmony_ci } 3888c2ecf20Sopenharmony_ci} 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistatic void snd_ac97_proc_regs_read(struct snd_info_entry *entry, 3918c2ecf20Sopenharmony_ci struct snd_info_buffer *buffer) 3928c2ecf20Sopenharmony_ci{ 3938c2ecf20Sopenharmony_ci struct snd_ac97 *ac97 = entry->private_data; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci mutex_lock(&ac97->page_mutex); 3968c2ecf20Sopenharmony_ci if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci int idx; 3998c2ecf20Sopenharmony_ci for (idx = 0; idx < 3; idx++) 4008c2ecf20Sopenharmony_ci if (ac97->spec.ad18xx.id[idx]) { 4018c2ecf20Sopenharmony_ci /* select single codec */ 4028c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 4038c2ecf20Sopenharmony_ci ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]); 4048c2ecf20Sopenharmony_ci snd_ac97_proc_regs_read_main(ac97, buffer, idx); 4058c2ecf20Sopenharmony_ci } 4068c2ecf20Sopenharmony_ci /* select all codecs */ 4078c2ecf20Sopenharmony_ci snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000); 4088c2ecf20Sopenharmony_ci } else { 4098c2ecf20Sopenharmony_ci snd_ac97_proc_regs_read_main(ac97, buffer, 0); 4108c2ecf20Sopenharmony_ci } 4118c2ecf20Sopenharmony_ci mutex_unlock(&ac97->page_mutex); 4128c2ecf20Sopenharmony_ci} 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_civoid snd_ac97_proc_init(struct snd_ac97 * ac97) 4158c2ecf20Sopenharmony_ci{ 4168c2ecf20Sopenharmony_ci struct snd_info_entry *entry; 4178c2ecf20Sopenharmony_ci char name[32]; 4188c2ecf20Sopenharmony_ci const char *prefix; 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci if (ac97->bus->proc == NULL) 4218c2ecf20Sopenharmony_ci return; 4228c2ecf20Sopenharmony_ci prefix = ac97_is_audio(ac97) ? "ac97" : "mc97"; 4238c2ecf20Sopenharmony_ci sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num); 4248c2ecf20Sopenharmony_ci entry = snd_info_create_card_entry(ac97->bus->card, name, 4258c2ecf20Sopenharmony_ci ac97->bus->proc); 4268c2ecf20Sopenharmony_ci if (entry) 4278c2ecf20Sopenharmony_ci snd_info_set_text_ops(entry, ac97, snd_ac97_proc_read); 4288c2ecf20Sopenharmony_ci ac97->proc = entry; 4298c2ecf20Sopenharmony_ci sprintf(name, "%s#%d-%d+regs", prefix, ac97->addr, ac97->num); 4308c2ecf20Sopenharmony_ci entry = snd_info_create_card_entry(ac97->bus->card, name, 4318c2ecf20Sopenharmony_ci ac97->bus->proc); 4328c2ecf20Sopenharmony_ci if (entry) { 4338c2ecf20Sopenharmony_ci snd_info_set_text_ops(entry, ac97, snd_ac97_proc_regs_read); 4348c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_DEBUG 4358c2ecf20Sopenharmony_ci entry->mode |= 0200; 4368c2ecf20Sopenharmony_ci entry->c.text.write = snd_ac97_proc_regs_write; 4378c2ecf20Sopenharmony_ci#endif 4388c2ecf20Sopenharmony_ci } 4398c2ecf20Sopenharmony_ci ac97->proc_regs = entry; 4408c2ecf20Sopenharmony_ci} 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_civoid snd_ac97_proc_done(struct snd_ac97 * ac97) 4438c2ecf20Sopenharmony_ci{ 4448c2ecf20Sopenharmony_ci snd_info_free_entry(ac97->proc_regs); 4458c2ecf20Sopenharmony_ci ac97->proc_regs = NULL; 4468c2ecf20Sopenharmony_ci snd_info_free_entry(ac97->proc); 4478c2ecf20Sopenharmony_ci ac97->proc = NULL; 4488c2ecf20Sopenharmony_ci} 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_civoid snd_ac97_bus_proc_init(struct snd_ac97_bus * bus) 4518c2ecf20Sopenharmony_ci{ 4528c2ecf20Sopenharmony_ci struct snd_info_entry *entry; 4538c2ecf20Sopenharmony_ci char name[32]; 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci sprintf(name, "codec97#%d", bus->num); 4568c2ecf20Sopenharmony_ci entry = snd_info_create_card_entry(bus->card, name, 4578c2ecf20Sopenharmony_ci bus->card->proc_root); 4588c2ecf20Sopenharmony_ci if (entry) 4598c2ecf20Sopenharmony_ci entry->mode = S_IFDIR | 0555; 4608c2ecf20Sopenharmony_ci bus->proc = entry; 4618c2ecf20Sopenharmony_ci} 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_civoid snd_ac97_bus_proc_done(struct snd_ac97_bus * bus) 4648c2ecf20Sopenharmony_ci{ 4658c2ecf20Sopenharmony_ci snd_info_free_entry(bus->proc); 4668c2ecf20Sopenharmony_ci bus->proc = NULL; 4678c2ecf20Sopenharmony_ci} 468