Lines Matching +full:off +full:- +full:codec
1 // SPDX-License-Identifier: GPL-2.0-or-later
74 #define DESKTOP_EFX_FILE "ctefx-desktop.bin"
75 #define R3DI_EFX_FILE "ctefx-r3di.bin"
115 #define VNODES_COUNT (VNODE_END_NID - VNODE_START_NID)
126 #define OUT_EFFECTS_COUNT (OUT_EFFECT_END_NID - OUT_EFFECT_START_NID)
134 #define IN_EFFECTS_COUNT (IN_EFFECT_END_NID - IN_EFFECT_START_NID)
154 #define EFFECTS_COUNT (EFFECT_END_NID - EFFECT_START_NID)
163 * X-bass.
182 int params; /* number of default non-on/off params */
183 /*effect default values, 1st is on/off. */
223 { .name = "X-Bass",
304 #define TUNING_CTLS_COUNT (TUNING_CTL_END_NID - TUNING_CTL_START_NID)
600 * DSP reqs for handling full-range speakers/bass redirection. If a speaker is
604 * enabled. X-Bass must be disabled when using these.
609 /* Between 0x16-0x1a are the X-Bass reqs. */
763 { .name = "Low (16-31",
766 { .name = "Medium (32-149",
769 { .name = "High (150-600",
780 { .name = "Slow Roll Off",
786 { .name = "Fast Roll Off",
900 /* Tracker for the SPDIF-in path is bypassed/enabled */
918 /* Decode Loop (DSP->SRC->DSP) is disabled/enabled */
920 /* De-emphasis filter on DAC-1 disabled/enabled */
922 /* De-emphasis filter on DAC-2 disabled/enabled */
924 /* De-emphasis filter on DAC-3 disabled/enabled */
926 /* High-pass filter on ADC_B disabled/enabled */
928 /* High-pass filter on ADC_C disabled/enabled */
965 * sense given the fact the AE-5 uses it and has the ASI flag set.
1046 DSP_DOWNLOAD_FAILED = -1,
1129 /* AE-5 Control values */
1135 struct hda_codec *codec; member
1144 * AE-5 all use PCI region 2 to toggle GPIO and other currently unknown
1182 #define ca0132_quirk(spec) ((spec)->quirk)
1183 #define ca0132_use_pci_mmio(spec) ((spec)->use_pci_mmio)
1184 #define ca0132_use_alt_functions(spec) ((spec)->use_alt_functions)
1185 #define ca0132_use_alt_controls(spec) ((spec)->use_alt_controls)
1209 { 0x0b, 0x01017010 }, /* Port G -- Lineout FRONT L/R */
1213 { 0x0f, 0x0221701f }, /* Port A -- BackPanel HP */
1214 { 0x10, 0x01017012 }, /* Port D -- Center/LFE or FP Hp */
1215 { 0x11, 0x01017014 }, /* Port B -- LineMicIn2 / Rear L/R */
1216 { 0x12, 0x01a170f0 }, /* Port C -- LineIn1 */
1224 { 0x0b, 0x01047110 }, /* Port G -- Lineout FRONT L/R */
1225 { 0x0c, 0x414510f0 }, /* SPDIF Out 1 - Disabled*/
1227 { 0x0e, 0x41c520f0 }, /* SPDIF In - Disabled*/
1228 { 0x0f, 0x0122711f }, /* Port A -- BackPanel HP */
1229 { 0x10, 0x01017111 }, /* Port D -- Center/LFE */
1230 { 0x11, 0x01017114 }, /* Port B -- LineMicIn2 / Rear L/R */
1231 { 0x12, 0x01a271f0 }, /* Port C -- LineIn1 */
1239 { 0x0b, 0x01014110 }, /* Port G -- Lineout FRONT L/R */
1243 { 0x0f, 0x0221401f }, /* Port A -- BackPanel HP */
1244 { 0x10, 0x01016011 }, /* Port D -- Center/LFE or FP Hp */
1245 { 0x11, 0x01011014 }, /* Port B -- LineMicIn2 / Rear L/R */
1246 { 0x12, 0x02a090f0 }, /* Port C -- LineIn1 */
1252 /* Sound Blaster AE-5 pin configs taken from Windows Driver */
1254 { 0x0b, 0x01017010 }, /* Port G -- Lineout FRONT L/R */
1258 { 0x0f, 0x01017114 }, /* Port A -- Rear L/R. */
1259 { 0x10, 0x01017012 }, /* Port D -- Center/LFE or FP Hp */
1260 { 0x11, 0x012170ff }, /* Port B -- LineMicIn2 / Rear Headphone */
1261 { 0x12, 0x01a170f0 }, /* Port C -- LineIn1 */
1269 { 0x0b, 0x01014110 }, /* Port G -- Lineout FRONT L/R */
1273 { 0x0f, 0x0221401f }, /* Port A -- BackPanel HP */
1274 { 0x10, 0x01016011 }, /* Port D -- Center/LFE or FP Hp */
1275 { 0x11, 0x01011014 }, /* Port B -- LineMicIn2 / Rear L/R */
1276 { 0x12, 0x02a090f0 }, /* Port C -- LineIn1 */
1307 SND_PCI_QUIRK(0x1458, 0xA036, "Gigabyte GA-Z170X-Gaming 7", QUIRK_R3DI),
1312 SND_PCI_QUIRK(0x1102, 0x0051, "Sound Blaster AE-5", QUIRK_AE5),
1313 SND_PCI_QUIRK(0x1102, 0x0191, "Sound Blaster AE-5 Plus", QUIRK_AE5),
1314 SND_PCI_QUIRK(0x1102, 0x0081, "Sound Blaster AE-7", QUIRK_AE7),
1512 * CA0132 codec access
1514 static unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid, in codec_send_command() argument
1518 response = snd_hda_codec_read(codec, nid, 0, verb, parm); in codec_send_command()
1521 return ((response == -1) ? -1 : 0); in codec_send_command()
1524 static int codec_set_converter_format(struct hda_codec *codec, hda_nid_t nid, in codec_set_converter_format() argument
1527 return codec_send_command(codec, nid, VENDOR_CHIPIO_STREAM_FORMAT, in codec_set_converter_format()
1531 static int codec_set_converter_stream_channel(struct hda_codec *codec, in codec_set_converter_stream_channel() argument
1538 return codec_send_command(codec, nid, AC_VERB_SET_CHANNEL_STREAMID, in codec_set_converter_stream_channel()
1543 static int chipio_send(struct hda_codec *codec, in chipio_send() argument
1552 res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_send()
1559 return -EIO; in chipio_send()
1563 * Write chip address through the vendor widget -- NOT protected by the Mutex!
1565 static int chipio_write_address(struct hda_codec *codec, in chipio_write_address() argument
1568 struct ca0132_spec *spec = codec->spec; in chipio_write_address()
1571 if (spec->curr_chip_addx == chip_addx) in chipio_write_address()
1575 res = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_LOW, in chipio_write_address()
1578 if (res != -EIO) { in chipio_write_address()
1580 res = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_HIGH, in chipio_write_address()
1584 spec->curr_chip_addx = (res < 0) ? ~0U : chip_addx; in chipio_write_address()
1590 * Write data through the vendor widget -- NOT protected by the Mutex!
1592 static int chipio_write_data(struct hda_codec *codec, unsigned int data) in chipio_write_data() argument
1594 struct ca0132_spec *spec = codec->spec; in chipio_write_data()
1598 res = chipio_send(codec, VENDOR_CHIPIO_DATA_LOW, data & 0xffff); in chipio_write_data()
1600 if (res != -EIO) { in chipio_write_data()
1602 res = chipio_send(codec, VENDOR_CHIPIO_DATA_HIGH, in chipio_write_data()
1608 spec->curr_chip_addx = (res != -EIO) ? in chipio_write_data()
1609 (spec->curr_chip_addx + 4) : ~0U; in chipio_write_data()
1614 * Write multiple data through the vendor widget -- NOT protected by the Mutex!
1616 static int chipio_write_data_multiple(struct hda_codec *codec, in chipio_write_data_multiple() argument
1623 codec_dbg(codec, "chipio_write_data null ptr\n"); in chipio_write_data_multiple()
1624 return -EINVAL; in chipio_write_data_multiple()
1627 while ((count-- != 0) && (status == 0)) in chipio_write_data_multiple()
1628 status = chipio_write_data(codec, *data++); in chipio_write_data_multiple()
1635 * Read data through the vendor widget -- NOT protected by the Mutex!
1637 static int chipio_read_data(struct hda_codec *codec, unsigned int *data) in chipio_read_data() argument
1639 struct ca0132_spec *spec = codec->spec; in chipio_read_data()
1643 res = chipio_send(codec, VENDOR_CHIPIO_HIC_POST_READ, 0); in chipio_read_data()
1645 if (res != -EIO) { in chipio_read_data()
1647 res = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in chipio_read_data()
1650 if (res != -EIO) { in chipio_read_data()
1652 *data = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_read_data()
1659 spec->curr_chip_addx = (res != -EIO) ? in chipio_read_data()
1660 (spec->curr_chip_addx + 4) : ~0U; in chipio_read_data()
1668 static int chipio_write(struct hda_codec *codec, in chipio_write() argument
1671 struct ca0132_spec *spec = codec->spec; in chipio_write()
1674 mutex_lock(&spec->chipio_mutex); in chipio_write()
1677 err = chipio_write_address(codec, chip_addx); in chipio_write()
1681 err = chipio_write_data(codec, data); in chipio_write()
1686 mutex_unlock(&spec->chipio_mutex); in chipio_write()
1694 static int chipio_write_no_mutex(struct hda_codec *codec, in chipio_write_no_mutex() argument
1701 err = chipio_write_address(codec, chip_addx); in chipio_write_no_mutex()
1705 err = chipio_write_data(codec, data); in chipio_write_no_mutex()
1717 static int chipio_write_multiple(struct hda_codec *codec, in chipio_write_multiple() argument
1722 struct ca0132_spec *spec = codec->spec; in chipio_write_multiple()
1725 mutex_lock(&spec->chipio_mutex); in chipio_write_multiple()
1726 status = chipio_write_address(codec, chip_addx); in chipio_write_multiple()
1730 status = chipio_write_data_multiple(codec, data, count); in chipio_write_multiple()
1732 mutex_unlock(&spec->chipio_mutex); in chipio_write_multiple()
1741 static int chipio_read(struct hda_codec *codec, in chipio_read() argument
1744 struct ca0132_spec *spec = codec->spec; in chipio_read()
1747 mutex_lock(&spec->chipio_mutex); in chipio_read()
1750 err = chipio_write_address(codec, chip_addx); in chipio_read()
1754 err = chipio_read_data(codec, data); in chipio_read()
1759 mutex_unlock(&spec->chipio_mutex); in chipio_read()
1766 static void chipio_set_control_flag(struct hda_codec *codec, in chipio_set_control_flag() argument
1775 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_flag()
1782 static void chipio_set_control_param(struct hda_codec *codec, in chipio_set_control_param() argument
1785 struct ca0132_spec *spec = codec->spec; in chipio_set_control_param()
1790 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param()
1793 mutex_lock(&spec->chipio_mutex); in chipio_set_control_param()
1794 if (chipio_send(codec, VENDOR_CHIPIO_STATUS, 0) == 0) { in chipio_set_control_param()
1795 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param()
1798 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param()
1802 mutex_unlock(&spec->chipio_mutex); in chipio_set_control_param()
1809 static void chipio_set_control_param_no_mutex(struct hda_codec *codec, in chipio_set_control_param_no_mutex() argument
1816 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param_no_mutex()
1819 if (chipio_send(codec, VENDOR_CHIPIO_STATUS, 0) == 0) { in chipio_set_control_param_no_mutex()
1820 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param_no_mutex()
1823 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param_no_mutex()
1833 static void chipio_set_stream_source_dest(struct hda_codec *codec, in chipio_set_stream_source_dest() argument
1836 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_source_dest()
1838 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_source_dest()
1840 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_source_dest()
1847 static void chipio_set_stream_channels(struct hda_codec *codec, in chipio_set_stream_channels() argument
1850 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_channels()
1852 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_channels()
1859 static void chipio_set_stream_control(struct hda_codec *codec, in chipio_set_stream_control() argument
1862 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_control()
1864 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_control()
1871 static void chipio_get_stream_control(struct hda_codec *codec, in chipio_get_stream_control() argument
1874 chipio_set_control_param_no_mutex(codec, in chipio_get_stream_control()
1876 *enable = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_get_stream_control()
1884 static void chipio_set_conn_rate_no_mutex(struct hda_codec *codec, in chipio_set_conn_rate_no_mutex() argument
1887 chipio_set_control_param_no_mutex(codec, in chipio_set_conn_rate_no_mutex()
1889 chipio_set_control_param_no_mutex(codec, in chipio_set_conn_rate_no_mutex()
1896 static void chipio_set_conn_rate(struct hda_codec *codec, in chipio_set_conn_rate() argument
1899 chipio_set_control_param(codec, CONTROL_PARAM_CONN_POINT_ID, connid); in chipio_set_conn_rate()
1900 chipio_set_control_param(codec, CONTROL_PARAM_CONN_POINT_SAMPLE_RATE, in chipio_set_conn_rate()
1907 * 0x80-0xFF.
1909 static void chipio_8051_write_direct(struct hda_codec *codec, in chipio_8051_write_direct() argument
1915 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, verb, addr); in chipio_8051_write_direct()
1919 * Writes to the 8051's exram, which has 16-bits of address space.
1920 * Data at addresses 0x2000-0x7fff is mirrored to 0x8000-0xdfff.
1921 * Data at 0x8000-0xdfff can also be used as program memory for the 8051 by
1923 * 0xe000-0xffff is always mapped as program memory, with only 0xf000-0xffff
1926 static void chipio_8051_set_address(struct hda_codec *codec, unsigned int addr) in chipio_8051_set_address() argument
1930 /* Lower 8-bits. */ in chipio_8051_set_address()
1932 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_address()
1935 /* Upper 8-bits. */ in chipio_8051_set_address()
1937 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_address()
1941 static void chipio_8051_set_data(struct hda_codec *codec, unsigned int data) in chipio_8051_set_data() argument
1943 /* 8-bits of data. */ in chipio_8051_set_data()
1944 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_data()
1948 static unsigned int chipio_8051_get_data(struct hda_codec *codec) in chipio_8051_get_data() argument
1950 return snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_get_data()
1955 static void chipio_8051_set_data_pll(struct hda_codec *codec, unsigned int data) in chipio_8051_set_data_pll() argument
1957 /* 8-bits of data. */ in chipio_8051_set_data_pll()
1958 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_data_pll()
1962 static void chipio_8051_write_exram(struct hda_codec *codec, in chipio_8051_write_exram() argument
1965 struct ca0132_spec *spec = codec->spec; in chipio_8051_write_exram()
1967 mutex_lock(&spec->chipio_mutex); in chipio_8051_write_exram()
1969 chipio_8051_set_address(codec, addr); in chipio_8051_write_exram()
1970 chipio_8051_set_data(codec, data); in chipio_8051_write_exram()
1972 mutex_unlock(&spec->chipio_mutex); in chipio_8051_write_exram()
1975 static void chipio_8051_write_exram_no_mutex(struct hda_codec *codec, in chipio_8051_write_exram_no_mutex() argument
1978 chipio_8051_set_address(codec, addr); in chipio_8051_write_exram_no_mutex()
1979 chipio_8051_set_data(codec, data); in chipio_8051_write_exram_no_mutex()
1983 static void chipio_8051_read_exram(struct hda_codec *codec, in chipio_8051_read_exram() argument
1986 chipio_8051_set_address(codec, addr); in chipio_8051_read_exram()
1987 *data = chipio_8051_get_data(codec); in chipio_8051_read_exram()
1990 static void chipio_8051_write_pll_pmu(struct hda_codec *codec, in chipio_8051_write_pll_pmu() argument
1993 struct ca0132_spec *spec = codec->spec; in chipio_8051_write_pll_pmu()
1995 mutex_lock(&spec->chipio_mutex); in chipio_8051_write_pll_pmu()
1997 chipio_8051_set_address(codec, addr & 0xff); in chipio_8051_write_pll_pmu()
1998 chipio_8051_set_data_pll(codec, data); in chipio_8051_write_pll_pmu()
2000 mutex_unlock(&spec->chipio_mutex); in chipio_8051_write_pll_pmu()
2003 static void chipio_8051_write_pll_pmu_no_mutex(struct hda_codec *codec, in chipio_8051_write_pll_pmu_no_mutex() argument
2006 chipio_8051_set_address(codec, addr & 0xff); in chipio_8051_write_pll_pmu_no_mutex()
2007 chipio_8051_set_data_pll(codec, data); in chipio_8051_write_pll_pmu_no_mutex()
2013 static void chipio_enable_clocks(struct hda_codec *codec) in chipio_enable_clocks() argument
2015 struct ca0132_spec *spec = codec->spec; in chipio_enable_clocks()
2017 mutex_lock(&spec->chipio_mutex); in chipio_enable_clocks()
2019 chipio_8051_write_pll_pmu_no_mutex(codec, 0x00, 0xff); in chipio_enable_clocks()
2020 chipio_8051_write_pll_pmu_no_mutex(codec, 0x05, 0x0b); in chipio_enable_clocks()
2021 chipio_8051_write_pll_pmu_no_mutex(codec, 0x06, 0xff); in chipio_enable_clocks()
2023 mutex_unlock(&spec->chipio_mutex); in chipio_enable_clocks()
2029 static int dspio_send(struct hda_codec *codec, unsigned int reg, in dspio_send() argument
2037 res = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, reg, data); in dspio_send()
2043 return -EIO; in dspio_send()
2049 static void dspio_write_wait(struct hda_codec *codec) in dspio_write_wait() argument
2055 status = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, in dspio_write_wait()
2067 static int dspio_write(struct hda_codec *codec, unsigned int scp_data) in dspio_write() argument
2069 struct ca0132_spec *spec = codec->spec; in dspio_write()
2072 dspio_write_wait(codec); in dspio_write()
2074 mutex_lock(&spec->chipio_mutex); in dspio_write()
2075 status = dspio_send(codec, VENDOR_DSPIO_SCP_WRITE_DATA_LOW, in dspio_write()
2080 status = dspio_send(codec, VENDOR_DSPIO_SCP_WRITE_DATA_HIGH, in dspio_write()
2086 status = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, in dspio_write()
2089 mutex_unlock(&spec->chipio_mutex); in dspio_write()
2092 -EIO : 0; in dspio_write()
2098 static int dspio_write_multiple(struct hda_codec *codec, in dspio_write_multiple() argument
2105 return -EINVAL; in dspio_write_multiple()
2109 status = dspio_write(codec, *buffer++); in dspio_write_multiple()
2118 static int dspio_read(struct hda_codec *codec, unsigned int *data) in dspio_read() argument
2122 status = dspio_send(codec, VENDOR_DSPIO_SCP_POST_READ_DATA, 0); in dspio_read()
2123 if (status == -EIO) in dspio_read()
2126 status = dspio_send(codec, VENDOR_DSPIO_STATUS, 0); in dspio_read()
2127 if (status == -EIO || in dspio_read()
2129 return -EIO; in dspio_read()
2131 *data = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, in dspio_read()
2137 static int dspio_read_multiple(struct hda_codec *codec, unsigned int *buffer, in dspio_read_multiple() argument
2147 return -1; in dspio_read_multiple()
2151 status = dspio_read(codec, buffer++); in dspio_read_multiple()
2160 status = dspio_read(codec, &dummy); in dspio_read_multiple()
2230 static void dspio_clear_response_queue(struct hda_codec *codec) in dspio_clear_response_queue() argument
2238 status = dspio_read(codec, &dummy); in dspio_clear_response_queue()
2242 static int dspio_get_response_data(struct hda_codec *codec) in dspio_get_response_data() argument
2244 struct ca0132_spec *spec = codec->spec; in dspio_get_response_data()
2248 if (dspio_read(codec, &data) < 0) in dspio_get_response_data()
2249 return -EIO; in dspio_get_response_data()
2251 if ((data & 0x00ffffff) == spec->wait_scp_header) { in dspio_get_response_data()
2252 spec->scp_resp_header = data; in dspio_get_response_data()
2253 spec->scp_resp_count = data >> 27; in dspio_get_response_data()
2254 count = spec->wait_num_data; in dspio_get_response_data()
2255 dspio_read_multiple(codec, spec->scp_resp_data, in dspio_get_response_data()
2256 &spec->scp_resp_count, count); in dspio_get_response_data()
2260 return -EIO; in dspio_get_response_data()
2266 static int dspio_send_scp_message(struct hda_codec *codec, in dspio_send_scp_message() argument
2273 struct ca0132_spec *spec = codec->spec; in dspio_send_scp_message()
2294 return -EINVAL; in dspio_send_scp_message()
2298 return -EINVAL; in dspio_send_scp_message()
2300 spec->wait_scp_header = *((unsigned int *)send_buf); in dspio_send_scp_message()
2305 spec->wait_scp_header &= 0xffff0000; in dspio_send_scp_message()
2306 spec->wait_scp_header |= (resp_src_id << 8) | (resp_target_id); in dspio_send_scp_message()
2307 spec->wait_num_data = return_buf_size/sizeof(unsigned int) - 1; in dspio_send_scp_message()
2308 spec->wait_scp = 1; in dspio_send_scp_message()
2312 status = dspio_write_multiple(codec, (unsigned int *)send_buf, in dspio_send_scp_message()
2315 spec->wait_scp = 0; in dspio_send_scp_message()
2324 } while (spec->wait_scp && time_before(jiffies, timeout)); in dspio_send_scp_message()
2326 if (!spec->wait_scp) { in dspio_send_scp_message()
2328 memcpy(&ret_msg->hdr, &spec->scp_resp_header, 4); in dspio_send_scp_message()
2329 memcpy(&ret_msg->data, spec->scp_resp_data, in dspio_send_scp_message()
2330 spec->wait_num_data); in dspio_send_scp_message()
2331 *bytes_returned = (spec->scp_resp_count + 1) * 4; in dspio_send_scp_message()
2334 status = -EIO; in dspio_send_scp_message()
2336 spec->wait_scp = 0; in dspio_send_scp_message()
2343 * dspio_scp - Prepare and send the SCP message to DSP
2344 * @codec: the HDA codec
2356 static int dspio_scp(struct hda_codec *codec, in dspio_scp() argument
2370 return -EINVAL; in dspio_scp()
2373 codec_dbg(codec, "dspio_scp get but has no buffer\n"); in dspio_scp()
2374 return -EINVAL; in dspio_scp()
2378 codec_dbg(codec, "dspio_scp bad resp buf len parms\n"); in dspio_scp()
2379 return -EINVAL; in dspio_scp()
2391 status = dspio_send_scp_message(codec, (unsigned char *)&scp_send, in dspio_scp()
2396 codec_dbg(codec, "dspio_scp: send scp msg failed\n"); in dspio_scp()
2411 ret_size = (ret_bytes - sizeof(scp_reply.hdr)) in dspio_scp()
2415 codec_dbg(codec, "reply too long for buf\n"); in dspio_scp()
2416 return -EINVAL; in dspio_scp()
2418 codec_dbg(codec, "RetLen and HdrLen .NE.\n"); in dspio_scp()
2419 return -EINVAL; in dspio_scp()
2421 codec_dbg(codec, "NULL reply\n"); in dspio_scp()
2422 return -EINVAL; in dspio_scp()
2428 codec_dbg(codec, "reply ill-formed or errflag set\n"); in dspio_scp()
2429 return -EIO; in dspio_scp()
2438 static int dspio_set_param(struct hda_codec *codec, int mod_id, in dspio_set_param() argument
2441 return dspio_scp(codec, mod_id, src_id, req, SCP_SET, data, len, NULL, in dspio_set_param()
2445 static int dspio_set_uint_param(struct hda_codec *codec, int mod_id, in dspio_set_uint_param() argument
2448 return dspio_set_param(codec, mod_id, 0x20, req, &data, in dspio_set_uint_param()
2455 static int dspio_alloc_dma_chan(struct hda_codec *codec, unsigned int *dma_chan) in dspio_alloc_dma_chan() argument
2460 codec_dbg(codec, " dspio_alloc_dma_chan() -- begin\n"); in dspio_alloc_dma_chan()
2461 status = dspio_scp(codec, MASTERCONTROL, 0x20, in dspio_alloc_dma_chan()
2466 codec_dbg(codec, "dspio_alloc_dma_chan: SCP Failed\n"); in dspio_alloc_dma_chan()
2471 codec_dbg(codec, "no free dma channels to allocate\n"); in dspio_alloc_dma_chan()
2472 return -EBUSY; in dspio_alloc_dma_chan()
2475 codec_dbg(codec, "dspio_alloc_dma_chan: chan=%d\n", *dma_chan); in dspio_alloc_dma_chan()
2476 codec_dbg(codec, " dspio_alloc_dma_chan() -- complete\n"); in dspio_alloc_dma_chan()
2484 static int dspio_free_dma_chan(struct hda_codec *codec, unsigned int dma_chan) in dspio_free_dma_chan() argument
2489 codec_dbg(codec, " dspio_free_dma_chan() -- begin\n"); in dspio_free_dma_chan()
2490 codec_dbg(codec, "dspio_free_dma_chan: chan=%d\n", dma_chan); in dspio_free_dma_chan()
2492 status = dspio_scp(codec, MASTERCONTROL, 0x20, in dspio_free_dma_chan()
2497 codec_dbg(codec, "dspio_free_dma_chan: SCP Failed\n"); in dspio_free_dma_chan()
2501 codec_dbg(codec, " dspio_free_dma_chan() -- complete\n"); in dspio_free_dma_chan()
2509 static int dsp_set_run_state(struct hda_codec *codec) in dsp_set_run_state() argument
2515 err = chipio_read(codec, DSP_DBGCNTL_INST_OFFSET, &dbg_ctrl_reg); in dsp_set_run_state()
2525 err = chipio_write(codec, DSP_DBGCNTL_INST_OFFSET, in dsp_set_run_state()
2532 err = chipio_write(codec, DSP_DBGCNTL_INST_OFFSET, in dsp_set_run_state()
2544 static int dsp_reset(struct hda_codec *codec) in dsp_reset() argument
2549 codec_dbg(codec, "dsp_reset\n"); in dsp_reset()
2551 res = dspio_send(codec, VENDOR_DSPIO_DSP_INIT, 0); in dsp_reset()
2552 retry--; in dsp_reset()
2553 } while (res == -EIO && retry); in dsp_reset()
2556 codec_dbg(codec, "dsp_reset timeout\n"); in dsp_reset()
2557 return -EIO; in dsp_reset()
2587 static bool dsp_is_dma_active(struct hda_codec *codec, unsigned int dma_chan) in dsp_is_dma_active() argument
2591 chipio_read(codec, DSPDMAC_CHNLSTART_INST_OFFSET, &dma_chnlstart_reg); in dsp_is_dma_active()
2597 static int dsp_dma_setup_common(struct hda_codec *codec, in dsp_dma_setup_common() argument
2609 codec_dbg(codec, "-- dsp_dma_setup_common() -- Begin ---------\n"); in dsp_dma_setup_common()
2612 codec_dbg(codec, "dma chan num invalid\n"); in dsp_dma_setup_common()
2613 return -EINVAL; in dsp_dma_setup_common()
2616 if (dsp_is_dma_active(codec, dma_chan)) { in dsp_dma_setup_common()
2617 codec_dbg(codec, "dma already active\n"); in dsp_dma_setup_common()
2618 return -EBUSY; in dsp_dma_setup_common()
2624 codec_dbg(codec, "invalid chip addr\n"); in dsp_dma_setup_common()
2625 return -ENXIO; in dsp_dma_setup_common()
2631 codec_dbg(codec, " dsp_dma_setup_common() start reg pgm\n"); in dsp_dma_setup_common()
2634 status = chipio_read(codec, DSPDMAC_CHNLPROP_INST_OFFSET, in dsp_dma_setup_common()
2638 codec_dbg(codec, "read CHNLPROP Reg fail\n"); in dsp_dma_setup_common()
2641 codec_dbg(codec, "dsp_dma_setup_common() Read CHNLPROP\n"); in dsp_dma_setup_common()
2651 status = chipio_write(codec, DSPDMAC_CHNLPROP_INST_OFFSET, chnl_prop); in dsp_dma_setup_common()
2653 codec_dbg(codec, "write CHNLPROP Reg fail\n"); in dsp_dma_setup_common()
2656 codec_dbg(codec, " dsp_dma_setup_common() Write CHNLPROP\n"); in dsp_dma_setup_common()
2659 status = chipio_read(codec, DSPDMAC_ACTIVE_INST_OFFSET, in dsp_dma_setup_common()
2663 codec_dbg(codec, "read ACTIVE Reg fail\n"); in dsp_dma_setup_common()
2666 codec_dbg(codec, "dsp_dma_setup_common() Read ACTIVE\n"); in dsp_dma_setup_common()
2672 status = chipio_write(codec, DSPDMAC_ACTIVE_INST_OFFSET, active); in dsp_dma_setup_common()
2674 codec_dbg(codec, "write ACTIVE Reg fail\n"); in dsp_dma_setup_common()
2678 codec_dbg(codec, " dsp_dma_setup_common() Write ACTIVE\n"); in dsp_dma_setup_common()
2680 status = chipio_write(codec, DSPDMAC_AUDCHSEL_INST_OFFSET(dma_chan), in dsp_dma_setup_common()
2683 codec_dbg(codec, "write AUDCHSEL Reg fail\n"); in dsp_dma_setup_common()
2686 codec_dbg(codec, " dsp_dma_setup_common() Write AUDCHSEL\n"); in dsp_dma_setup_common()
2688 status = chipio_write(codec, DSPDMAC_IRQCNT_INST_OFFSET(dma_chan), in dsp_dma_setup_common()
2691 codec_dbg(codec, "write IRQCNT Reg fail\n"); in dsp_dma_setup_common()
2694 codec_dbg(codec, " dsp_dma_setup_common() Write IRQCNT\n"); in dsp_dma_setup_common()
2696 codec_dbg(codec, in dsp_dma_setup_common()
2702 codec_dbg(codec, "-- dsp_dma_setup_common() -- Complete ------\n"); in dsp_dma_setup_common()
2708 * Setup the DSP DMA per-transfer-specific registers
2710 static int dsp_dma_setup(struct hda_codec *codec, in dsp_dma_setup() argument
2725 const unsigned int max_dma_count = 1 << (DSPDMAC_XFRCNT_BCNT_HIBIT - in dsp_dma_setup()
2728 codec_dbg(codec, "-- dsp_dma_setup() -- Begin ---------\n"); in dsp_dma_setup()
2731 codec_dbg(codec, "count too big\n"); in dsp_dma_setup()
2732 return -EINVAL; in dsp_dma_setup()
2737 codec_dbg(codec, "invalid chip addr\n"); in dsp_dma_setup()
2738 return -ENXIO; in dsp_dma_setup()
2741 codec_dbg(codec, " dsp_dma_setup() start reg pgm\n"); in dsp_dma_setup()
2755 status = chipio_write(codec, DSPDMAC_DMACFG_INST_OFFSET(dma_chan), in dsp_dma_setup()
2758 codec_dbg(codec, "write DMACFG Reg fail\n"); in dsp_dma_setup()
2761 codec_dbg(codec, " dsp_dma_setup() Write DMACFG\n"); in dsp_dma_setup()
2763 adr_ofs = (count - 1) << (DSPDMAC_DSPADROFS_BOFS_LOBIT + in dsp_dma_setup()
2766 status = chipio_write(codec, DSPDMAC_DSPADROFS_INST_OFFSET(dma_chan), in dsp_dma_setup()
2769 codec_dbg(codec, "write DSPADROFS Reg fail\n"); in dsp_dma_setup()
2772 codec_dbg(codec, " dsp_dma_setup() Write DSPADROFS\n"); in dsp_dma_setup()
2774 base_cnt = (count - 1) << DSPDMAC_XFRCNT_BCNT_LOBIT; in dsp_dma_setup()
2776 cur_cnt = (count - 1) << DSPDMAC_XFRCNT_CCNT_LOBIT; in dsp_dma_setup()
2780 status = chipio_write(codec, in dsp_dma_setup()
2783 codec_dbg(codec, "write XFRCNT Reg fail\n"); in dsp_dma_setup()
2786 codec_dbg(codec, " dsp_dma_setup() Write XFRCNT\n"); in dsp_dma_setup()
2788 codec_dbg(codec, in dsp_dma_setup()
2793 codec_dbg(codec, "-- dsp_dma_setup() -- Complete ---------\n"); in dsp_dma_setup()
2801 static int dsp_dma_start(struct hda_codec *codec, in dsp_dma_start() argument
2807 codec_dbg(codec, "-- dsp_dma_start() -- Begin ---------\n"); in dsp_dma_start()
2810 status = chipio_read(codec, in dsp_dma_start()
2814 codec_dbg(codec, "read CHNLSTART reg fail\n"); in dsp_dma_start()
2817 codec_dbg(codec, "-- dsp_dma_start() Read CHNLSTART\n"); in dsp_dma_start()
2823 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET, in dsp_dma_start()
2826 codec_dbg(codec, "write CHNLSTART reg fail\n"); in dsp_dma_start()
2829 codec_dbg(codec, "-- dsp_dma_start() -- Complete ---------\n"); in dsp_dma_start()
2837 static int dsp_dma_stop(struct hda_codec *codec, in dsp_dma_stop() argument
2843 codec_dbg(codec, "-- dsp_dma_stop() -- Begin ---------\n"); in dsp_dma_stop()
2846 status = chipio_read(codec, in dsp_dma_stop()
2850 codec_dbg(codec, "read CHNLSTART reg fail\n"); in dsp_dma_stop()
2853 codec_dbg(codec, "-- dsp_dma_stop() Read CHNLSTART\n"); in dsp_dma_stop()
2858 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET, in dsp_dma_stop()
2861 codec_dbg(codec, "write CHNLSTART reg fail\n"); in dsp_dma_stop()
2864 codec_dbg(codec, "-- dsp_dma_stop() -- Complete ---------\n"); in dsp_dma_stop()
2870 * dsp_allocate_router_ports - Allocate router ports
2872 * @codec: the HDA codec
2880 static int dsp_allocate_router_ports(struct hda_codec *codec, in dsp_allocate_router_ports() argument
2890 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_allocate_router_ports()
2895 val |= (ports_per_channel - 1) << 4; in dsp_allocate_router_ports()
2896 val |= num_chans - 1; in dsp_allocate_router_ports()
2898 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in dsp_allocate_router_ports()
2902 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in dsp_allocate_router_ports()
2906 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_allocate_router_ports()
2910 res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in dsp_allocate_router_ports()
2921 static int dsp_free_router_ports(struct hda_codec *codec) in dsp_free_router_ports() argument
2925 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_free_router_ports()
2929 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in dsp_free_router_ports()
2933 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_free_router_ports()
2941 static int dsp_allocate_ports(struct hda_codec *codec, in dsp_allocate_ports() argument
2947 codec_dbg(codec, " dsp_allocate_ports() -- begin\n"); in dsp_allocate_ports()
2950 codec_dbg(codec, "bad rate multiple\n"); in dsp_allocate_ports()
2951 return -EINVAL; in dsp_allocate_ports()
2954 status = dsp_allocate_router_ports(codec, num_chans, in dsp_allocate_ports()
2957 codec_dbg(codec, " dsp_allocate_ports() -- complete\n"); in dsp_allocate_ports()
2962 static int dsp_allocate_ports_format(struct hda_codec *codec, in dsp_allocate_ports_format() argument
2973 codec_dbg(codec, "bad rate multiple\n"); in dsp_allocate_ports_format()
2974 return -EINVAL; in dsp_allocate_ports_format()
2979 return dsp_allocate_ports(codec, num_chans, rate_multi, port_map); in dsp_allocate_ports_format()
2985 static int dsp_free_ports(struct hda_codec *codec) in dsp_free_ports() argument
2989 codec_dbg(codec, " dsp_free_ports() -- begin\n"); in dsp_free_ports()
2991 status = dsp_free_router_ports(codec); in dsp_free_ports()
2993 codec_dbg(codec, "free router ports fail\n"); in dsp_free_ports()
2996 codec_dbg(codec, " dsp_free_ports() -- complete\n"); in dsp_free_ports()
3005 struct hda_codec *codec; member
3017 static int dma_convert_to_hda_format(struct hda_codec *codec, in dma_convert_to_hda_format() argument
3038 struct hda_codec *codec = dma->codec; in dma_reset() local
3039 struct ca0132_spec *spec = codec->spec; in dma_reset()
3042 if (dma->dmab->area) in dma_reset()
3043 snd_hda_codec_load_dsp_cleanup(codec, dma->dmab); in dma_reset()
3045 status = snd_hda_codec_load_dsp_prepare(codec, in dma_reset()
3046 dma->m_converter_format, in dma_reset()
3047 dma->buf_size, in dma_reset()
3048 dma->dmab); in dma_reset()
3051 spec->dsp_stream_id = status; in dma_reset()
3070 snd_hda_codec_load_dsp_trigger(dma->codec, cmd); in dma_set_state()
3076 return dma->dmab->bytes; in dma_get_buffer_size()
3081 return dma->dmab->area; in dma_get_buffer_addr()
3088 memcpy(dma->dmab->area, data, count); in dma_xfer()
3097 *format = dma->m_converter_format; in dma_get_converter_format()
3102 struct ca0132_spec *spec = dma->codec->spec; in dma_get_stream_id()
3104 return spec->dsp_stream_id; in dma_get_stream_id()
3119 return p->magic == g_magic_value; in is_valid()
3124 return g_chip_addr_magic_value == p->chip_addr; in is_hci_prog_list_seg()
3129 return p->count == 0; in is_last()
3134 return struct_size(p, data, p->count); in dsp_sizeof()
3153 static int dspxfr_hci_write(struct hda_codec *codec, in dspxfr_hci_write() argument
3160 if (fls == NULL || fls->chip_addr != g_chip_addr_magic_value) { in dspxfr_hci_write()
3161 codec_dbg(codec, "hci_write invalid params\n"); in dspxfr_hci_write()
3162 return -EINVAL; in dspxfr_hci_write()
3165 count = fls->count; in dspxfr_hci_write()
3166 data = (u32 *)(fls->data); in dspxfr_hci_write()
3168 status = chipio_write(codec, data[0], data[1]); in dspxfr_hci_write()
3170 codec_dbg(codec, "hci_write chipio failed\n"); in dspxfr_hci_write()
3173 count -= 2; in dspxfr_hci_write()
3180 * dspxfr_one_seg - Write a block of data into DSP code or data RAM using pre-allocated DMA engine.
3182 * @codec: the HDA codec
3184 * @reloc: Relocation address for loading single-segment overlays, or 0 for
3193 static int dspxfr_one_seg(struct hda_codec *codec, in dspxfr_one_seg() argument
3222 return -EINVAL; in dspxfr_one_seg()
3229 codec_dbg(codec, "hci_write\n"); in dspxfr_one_seg()
3230 return dspxfr_hci_write(codec, hci_write); in dspxfr_one_seg()
3234 codec_dbg(codec, "Invalid Params\n"); in dspxfr_one_seg()
3235 return -EINVAL; in dspxfr_one_seg()
3238 data = fls->data; in dspxfr_one_seg()
3239 chip_addx = fls->chip_addr; in dspxfr_one_seg()
3240 words_to_write = fls->count; in dspxfr_one_seg()
3243 return hci_write ? dspxfr_hci_write(codec, hci_write) : 0; in dspxfr_one_seg()
3250 codec_dbg(codec, "Invalid chip_addx Params\n"); in dspxfr_one_seg()
3251 return -EINVAL; in dspxfr_one_seg()
3260 codec_dbg(codec, "dma_engine buffer NULL\n"); in dspxfr_one_seg()
3261 return -EINVAL; in dspxfr_one_seg()
3273 codec_dbg(codec, "frmsz zero\n"); in dspxfr_one_seg()
3274 return -EINVAL; in dspxfr_one_seg()
3280 buffer_size_words -= buffer_size_words % hda_frame_size_words; in dspxfr_one_seg()
3281 codec_dbg(codec, in dspxfr_one_seg()
3288 codec_dbg(codec, "dspxfr_one_seg:failed\n"); in dspxfr_one_seg()
3289 return -EINVAL; in dspxfr_one_seg()
3298 words_to_write -= remainder_words; in dspxfr_one_seg()
3302 codec_dbg(codec, "dspxfr (seg loop)cnt=%u rs=%u remainder=%u\n", in dspxfr_one_seg()
3306 status = dsp_dma_stop(codec, dma_chan, ovly); in dspxfr_one_seg()
3309 status = dsp_dma_setup_common(codec, chip_addx, in dspxfr_one_seg()
3316 status = dsp_dma_setup(codec, chip_addx, in dspxfr_one_seg()
3320 status = dsp_dma_start(codec, dma_chan, ovly); in dspxfr_one_seg()
3323 if (!dsp_is_dma_active(codec, dma_chan)) { in dspxfr_one_seg()
3324 codec_dbg(codec, "dspxfr:DMA did not start\n"); in dspxfr_one_seg()
3325 return -EIO; in dspxfr_one_seg()
3331 status = chipio_write_multiple(codec, in dspxfr_one_seg()
3340 status = dspxfr_hci_write(codec, hci_write); in dspxfr_one_seg()
3348 dma_active = dsp_is_dma_active(codec, dma_chan); in dspxfr_one_seg()
3356 codec_dbg(codec, "+++++ DMA complete\n"); in dspxfr_one_seg()
3365 words_to_write -= run_size_words; in dspxfr_one_seg()
3369 status = chipio_write_multiple(codec, chip_addx_remainder, in dspxfr_one_seg()
3377 * dspxfr_image - Write the entire DSP image of a DSP code/data overlay to DSP memories
3379 * @codec: the HDA codec
3381 * @reloc: Relocation address for loading single-segment overlays, or 0 for
3389 static int dspxfr_image(struct hda_codec *codec, in dspxfr_image() argument
3396 struct ca0132_spec *spec = codec->spec; in dspxfr_image()
3406 return -EINVAL; in dspxfr_image()
3410 return -ENOMEM; in dspxfr_image()
3412 dma_engine->dmab = kzalloc(sizeof(*dma_engine->dmab), GFP_KERNEL); in dspxfr_image()
3413 if (!dma_engine->dmab) { in dspxfr_image()
3415 return -ENOMEM; in dspxfr_image()
3418 dma_engine->codec = codec; in dspxfr_image()
3419 dma_convert_to_hda_format(codec, sample_rate, channels, &hda_format); in dspxfr_image()
3420 dma_engine->m_converter_format = hda_format; in dspxfr_image()
3421 dma_engine->buf_size = (ovly ? DSP_DMA_WRITE_BUFLEN_OVLY : in dspxfr_image()
3426 status = codec_set_converter_format(codec, WIDGET_CHIP_CTRL, in dspxfr_image()
3430 codec_dbg(codec, "set converter format fail\n"); in dspxfr_image()
3434 status = snd_hda_codec_load_dsp_prepare(codec, in dspxfr_image()
3435 dma_engine->m_converter_format, in dspxfr_image()
3436 dma_engine->buf_size, in dspxfr_image()
3437 dma_engine->dmab); in dspxfr_image()
3440 spec->dsp_stream_id = status; in dspxfr_image()
3443 status = dspio_alloc_dma_chan(codec, &dma_chan); in dspxfr_image()
3445 codec_dbg(codec, "alloc dmachan fail\n"); in dspxfr_image()
3452 status = dsp_allocate_ports_format(codec, hda_format, in dspxfr_image()
3455 codec_dbg(codec, "alloc ports fail\n"); in dspxfr_image()
3460 status = codec_set_converter_stream_channel(codec, in dspxfr_image()
3463 codec_dbg(codec, "set stream chan fail\n"); in dspxfr_image()
3469 codec_dbg(codec, "FLS check fail\n"); in dspxfr_image()
3470 status = -EINVAL; in dspxfr_image()
3473 status = dspxfr_one_seg(codec, fls_data, reloc, in dspxfr_image()
3487 status = dsp_free_ports(codec); in dspxfr_image()
3492 status = codec_set_converter_stream_channel(codec, in dspxfr_image()
3497 dspio_free_dma_chan(codec, dma_chan); in dspxfr_image()
3499 if (dma_engine->dmab->area) in dspxfr_image()
3500 snd_hda_codec_load_dsp_cleanup(codec, dma_engine->dmab); in dspxfr_image()
3501 kfree(dma_engine->dmab); in dspxfr_image()
3510 static void dspload_post_setup(struct hda_codec *codec) in dspload_post_setup() argument
3512 struct ca0132_spec *spec = codec->spec; in dspload_post_setup()
3513 codec_dbg(codec, "---- dspload_post_setup ------\n"); in dspload_post_setup()
3516 chipio_write(codec, XRAM_XRAM_INST_OFFSET(0x18), 0x08080080); in dspload_post_setup()
3517 chipio_write(codec, XRAM_XRAM_INST_OFFSET(0x19), 0x3f800000); in dspload_post_setup()
3520 chipio_write(codec, XRAM_XRAM_INST_OFFSET(0x29), 0x00000002); in dspload_post_setup()
3525 * dspload_image - Download DSP from a DSP Image Fast Load structure.
3527 * @codec: the HDA codec
3530 * @reloc: Relocation address for loading single-segment overlays, or 0 for
3537 * linear, non-constant sized element array of structures, each of which
3542 static int dspload_image(struct hda_codec *codec, in dspload_image() argument
3553 codec_dbg(codec, "---- dspload_image begin ------\n"); in dspload_image()
3570 codec_dbg(codec, "Ready to program DMA\n"); in dspload_image()
3572 status = dsp_reset(codec); in dspload_image()
3577 codec_dbg(codec, "dsp_reset() complete\n"); in dspload_image()
3578 status = dspxfr_image(codec, fls, reloc, sample_rate, channels, in dspload_image()
3584 codec_dbg(codec, "dspxfr_image() complete\n"); in dspload_image()
3586 dspload_post_setup(codec); in dspload_image()
3587 status = dsp_set_run_state(codec); in dspload_image()
3590 codec_dbg(codec, "LOAD FINISHED\n"); in dspload_image()
3597 static bool dspload_is_loaded(struct hda_codec *codec) in dspload_is_loaded() argument
3602 status = chipio_read(codec, 0x40004, &data); in dspload_is_loaded()
3609 #define dspload_is_loaded(codec) false argument
3612 static bool dspload_wait_loaded(struct hda_codec *codec) in dspload_wait_loaded() argument
3617 if (dspload_is_loaded(codec)) { in dspload_wait_loaded()
3618 codec_info(codec, "ca0132 DSP downloaded and running\n"); in dspload_wait_loaded()
3624 codec_err(codec, "ca0132 failed to download DSP\n"); in dspload_wait_loaded()
3629 * ca0113 related functions. The ca0113 acts as the HDA bus for the pci-e
3635 * For cards with PCI-E region2 (Sound Blaster Z/ZxR, Recon3D, and AE-5)
3639 * AE-5 note: The AE-5 seems to use pins 2 and 3 to somehow set the color value
3640 * of the on-card LED. It seems to use pin 2 for data, then toggles 3 to on and
3641 * then off to send that bit.
3643 static void ca0113_mmio_gpio_set(struct hda_codec *codec, unsigned int gpio_pin, in ca0113_mmio_gpio_set() argument
3646 struct ca0132_spec *spec = codec->spec; in ca0113_mmio_gpio_set()
3652 writew(gpio_data, spec->mem_base + 0x320); in ca0113_mmio_gpio_set()
3656 * Special pci region2 commands that are only used by the AE-5. They follow
3661 * target-id, and value.
3663 static void ca0113_mmio_command_set(struct hda_codec *codec, unsigned int group, in ca0113_mmio_command_set() argument
3666 struct ca0132_spec *spec = codec->spec; in ca0113_mmio_command_set()
3669 writel(0x0000007e, spec->mem_base + 0x210); in ca0113_mmio_command_set()
3670 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set()
3671 writel(0x0000005a, spec->mem_base + 0x210); in ca0113_mmio_command_set()
3672 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set()
3673 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set()
3675 writel(0x00800005, spec->mem_base + 0x20c); in ca0113_mmio_command_set()
3676 writel(group, spec->mem_base + 0x804); in ca0113_mmio_command_set()
3678 writel(0x00800005, spec->mem_base + 0x20c); in ca0113_mmio_command_set()
3683 writel(write_val, spec->mem_base + 0x204); in ca0113_mmio_command_set()
3689 readl(spec->mem_base + 0x860); in ca0113_mmio_command_set()
3690 readl(spec->mem_base + 0x854); in ca0113_mmio_command_set()
3691 readl(spec->mem_base + 0x840); in ca0113_mmio_command_set()
3693 writel(0x00800004, spec->mem_base + 0x20c); in ca0113_mmio_command_set()
3694 writel(0x00000000, spec->mem_base + 0x210); in ca0113_mmio_command_set()
3695 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set()
3696 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set()
3702 static void ca0113_mmio_command_set_type2(struct hda_codec *codec, in ca0113_mmio_command_set_type2() argument
3705 struct ca0132_spec *spec = codec->spec; in ca0113_mmio_command_set_type2()
3708 writel(0x0000007e, spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3709 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3710 writel(0x0000005a, spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3711 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3712 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3714 writel(0x00800003, spec->mem_base + 0x20c); in ca0113_mmio_command_set_type2()
3715 writel(group, spec->mem_base + 0x804); in ca0113_mmio_command_set_type2()
3717 writel(0x00800005, spec->mem_base + 0x20c); in ca0113_mmio_command_set_type2()
3722 writel(write_val, spec->mem_base + 0x204); in ca0113_mmio_command_set_type2()
3724 readl(spec->mem_base + 0x860); in ca0113_mmio_command_set_type2()
3725 readl(spec->mem_base + 0x854); in ca0113_mmio_command_set_type2()
3726 readl(spec->mem_base + 0x840); in ca0113_mmio_command_set_type2()
3728 writel(0x00800004, spec->mem_base + 0x20c); in ca0113_mmio_command_set_type2()
3729 writel(0x00000000, spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3730 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3731 readl(spec->mem_base + 0x210); in ca0113_mmio_command_set_type2()
3742 static void ca0132_gpio_init(struct hda_codec *codec) in ca0132_gpio_init() argument
3744 struct ca0132_spec *spec = codec->spec; in ca0132_gpio_init()
3750 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in ca0132_gpio_init()
3751 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x53); in ca0132_gpio_init()
3752 snd_hda_codec_write(codec, 0x01, 0, 0x790, 0x23); in ca0132_gpio_init()
3755 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in ca0132_gpio_init()
3756 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x5B); in ca0132_gpio_init()
3765 static void ca0132_gpio_setup(struct hda_codec *codec) in ca0132_gpio_setup() argument
3767 struct ca0132_spec *spec = codec->spec; in ca0132_gpio_setup()
3771 snd_hda_codec_write(codec, 0x01, 0, in ca0132_gpio_setup()
3773 snd_hda_codec_write(codec, 0x01, 0, in ca0132_gpio_setup()
3775 snd_hda_codec_write(codec, 0x01, 0, in ca0132_gpio_setup()
3777 snd_hda_codec_write(codec, 0x01, 0, in ca0132_gpio_setup()
3781 snd_hda_codec_write(codec, 0x01, 0, in ca0132_gpio_setup()
3783 snd_hda_codec_write(codec, 0x01, 0, in ca0132_gpio_setup()
3785 snd_hda_codec_write(codec, 0x01, 0, in ca0132_gpio_setup()
3798 /* Bit 1 - Switch between front/rear mic. 0 = rear, 1 = front */
3800 /* Bit 2 - Switch between headphone/line out. 0 = Headphone, 1 = Line */
3835 static void r3di_gpio_mic_set(struct hda_codec *codec, in r3di_gpio_mic_set() argument
3841 cur_gpio = snd_hda_codec_read(codec, 0x01, 0, AC_VERB_GET_GPIO_DATA, 0); in r3di_gpio_mic_set()
3851 snd_hda_codec_write(codec, codec->core.afg, 0, in r3di_gpio_mic_set()
3855 static void r3di_gpio_dsp_status_set(struct hda_codec *codec, in r3di_gpio_dsp_status_set() argument
3861 cur_gpio = snd_hda_codec_read(codec, 0x01, 0, AC_VERB_GET_GPIO_DATA, 0); in r3di_gpio_dsp_status_set()
3866 snd_hda_codec_write(codec, codec->core.afg, 0, in r3di_gpio_dsp_status_set()
3873 snd_hda_codec_write(codec, codec->core.afg, 0, in r3di_gpio_dsp_status_set()
3880 snd_hda_codec_write(codec, codec->core.afg, 0, in r3di_gpio_dsp_status_set()
3888 struct hda_codec *codec, in ca0132_playback_pcm_prepare() argument
3893 struct ca0132_spec *spec = codec->spec; in ca0132_playback_pcm_prepare()
3895 snd_hda_codec_setup_stream(codec, spec->dacs[0], stream_tag, 0, format); in ca0132_playback_pcm_prepare()
3901 struct hda_codec *codec, in ca0132_playback_pcm_cleanup() argument
3904 struct ca0132_spec *spec = codec->spec; in ca0132_playback_pcm_cleanup()
3906 if (spec->dsp_state == DSP_DOWNLOADING) in ca0132_playback_pcm_cleanup()
3911 if (spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]) in ca0132_playback_pcm_cleanup()
3914 snd_hda_codec_cleanup_stream(codec, spec->dacs[0]); in ca0132_playback_pcm_cleanup()
3920 struct hda_codec *codec, in ca0132_playback_pcm_delay() argument
3923 struct ca0132_spec *spec = codec->spec; in ca0132_playback_pcm_delay()
3925 struct snd_pcm_runtime *runtime = substream->runtime; in ca0132_playback_pcm_delay()
3927 if (spec->dsp_state != DSP_DOWNLOADED) in ca0132_playback_pcm_delay()
3931 if (spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]) { in ca0132_playback_pcm_delay()
3932 if ((spec->effects_switch[SURROUND - EFFECT_START_NID]) || in ca0132_playback_pcm_delay()
3933 (spec->effects_switch[DIALOG_PLUS - EFFECT_START_NID])) in ca0132_playback_pcm_delay()
3938 if (spec->cur_out_type == SPEAKER_OUT) in ca0132_playback_pcm_delay()
3941 return (latency * runtime->rate) / 1000; in ca0132_playback_pcm_delay()
3948 struct hda_codec *codec, in ca0132_dig_playback_pcm_open() argument
3951 struct ca0132_spec *spec = codec->spec; in ca0132_dig_playback_pcm_open()
3952 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in ca0132_dig_playback_pcm_open()
3956 struct hda_codec *codec, in ca0132_dig_playback_pcm_prepare() argument
3961 struct ca0132_spec *spec = codec->spec; in ca0132_dig_playback_pcm_prepare()
3962 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in ca0132_dig_playback_pcm_prepare()
3967 struct hda_codec *codec, in ca0132_dig_playback_pcm_cleanup() argument
3970 struct ca0132_spec *spec = codec->spec; in ca0132_dig_playback_pcm_cleanup()
3971 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); in ca0132_dig_playback_pcm_cleanup()
3975 struct hda_codec *codec, in ca0132_dig_playback_pcm_close() argument
3978 struct ca0132_spec *spec = codec->spec; in ca0132_dig_playback_pcm_close()
3979 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in ca0132_dig_playback_pcm_close()
3986 struct hda_codec *codec, in ca0132_capture_pcm_prepare() argument
3991 snd_hda_codec_setup_stream(codec, hinfo->nid, in ca0132_capture_pcm_prepare()
3998 struct hda_codec *codec, in ca0132_capture_pcm_cleanup() argument
4001 struct ca0132_spec *spec = codec->spec; in ca0132_capture_pcm_cleanup()
4003 if (spec->dsp_state == DSP_DOWNLOADING) in ca0132_capture_pcm_cleanup()
4006 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in ca0132_capture_pcm_cleanup()
4011 struct hda_codec *codec, in ca0132_capture_pcm_delay() argument
4014 struct ca0132_spec *spec = codec->spec; in ca0132_capture_pcm_delay()
4016 struct snd_pcm_runtime *runtime = substream->runtime; in ca0132_capture_pcm_delay()
4018 if (spec->dsp_state != DSP_DOWNLOADED) in ca0132_capture_pcm_delay()
4021 if (spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID]) in ca0132_capture_pcm_delay()
4024 return (latency * runtime->rate) / 1000; in ca0132_capture_pcm_delay()
4088 * values -90 to 9. -90 is the lowest decibel value for both the ADC's and the
4136 * This table counts from float 10 to 1000, which is the range of the x-bass
4224 static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid, in tuning_ctl_set() argument
4233 snd_hda_power_up(codec); in tuning_ctl_set()
4234 dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20, in tuning_ctl_set()
4237 snd_hda_power_down(codec); in tuning_ctl_set()
4245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in tuning_ctl_get() local
4246 struct ca0132_spec *spec = codec->spec; in tuning_ctl_get()
4248 long *valp = ucontrol->value.integer.value; in tuning_ctl_get()
4249 int idx = nid - TUNING_CTL_START_NID; in tuning_ctl_get()
4251 *valp = spec->cur_ctl_vals[idx]; in tuning_ctl_get()
4259 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in voice_focus_ctl_info()
4260 uinfo->count = chs == 3 ? 2 : 1; in voice_focus_ctl_info()
4261 uinfo->value.integer.min = 20; in voice_focus_ctl_info()
4262 uinfo->value.integer.max = 180; in voice_focus_ctl_info()
4263 uinfo->value.integer.step = 1; in voice_focus_ctl_info()
4271 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in voice_focus_ctl_put() local
4272 struct ca0132_spec *spec = codec->spec; in voice_focus_ctl_put()
4274 long *valp = ucontrol->value.integer.value; in voice_focus_ctl_put()
4277 idx = nid - TUNING_CTL_START_NID; in voice_focus_ctl_put()
4279 if (spec->cur_ctl_vals[idx] == *valp) in voice_focus_ctl_put()
4282 spec->cur_ctl_vals[idx] = *valp; in voice_focus_ctl_put()
4284 idx = *valp - 20; in voice_focus_ctl_put()
4285 tuning_ctl_set(codec, nid, voice_focus_vals_lookup, idx); in voice_focus_ctl_put()
4294 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in mic_svm_ctl_info()
4295 uinfo->count = chs == 3 ? 2 : 1; in mic_svm_ctl_info()
4296 uinfo->value.integer.min = 0; in mic_svm_ctl_info()
4297 uinfo->value.integer.max = 100; in mic_svm_ctl_info()
4298 uinfo->value.integer.step = 1; in mic_svm_ctl_info()
4306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in mic_svm_ctl_put() local
4307 struct ca0132_spec *spec = codec->spec; in mic_svm_ctl_put()
4309 long *valp = ucontrol->value.integer.value; in mic_svm_ctl_put()
4312 idx = nid - TUNING_CTL_START_NID; in mic_svm_ctl_put()
4314 if (spec->cur_ctl_vals[idx] == *valp) in mic_svm_ctl_put()
4317 spec->cur_ctl_vals[idx] = *valp; in mic_svm_ctl_put()
4320 tuning_ctl_set(codec, nid, mic_svm_vals_lookup, idx); in mic_svm_ctl_put()
4329 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in equalizer_ctl_info()
4330 uinfo->count = chs == 3 ? 2 : 1; in equalizer_ctl_info()
4331 uinfo->value.integer.min = 0; in equalizer_ctl_info()
4332 uinfo->value.integer.max = 48; in equalizer_ctl_info()
4333 uinfo->value.integer.step = 1; in equalizer_ctl_info()
4341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in equalizer_ctl_put() local
4342 struct ca0132_spec *spec = codec->spec; in equalizer_ctl_put()
4344 long *valp = ucontrol->value.integer.value; in equalizer_ctl_put()
4347 idx = nid - TUNING_CTL_START_NID; in equalizer_ctl_put()
4349 if (spec->cur_ctl_vals[idx] == *valp) in equalizer_ctl_put()
4352 spec->cur_ctl_vals[idx] = *valp; in equalizer_ctl_put()
4355 tuning_ctl_set(codec, nid, equalizer_vals_lookup, idx); in equalizer_ctl_put()
4361 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(eq_db_scale, -2400, 100, 0);
4363 static int add_tuning_control(struct hda_codec *codec, in add_tuning_control() argument
4400 return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); in add_tuning_control()
4403 static int add_tuning_ctls(struct hda_codec *codec) in add_tuning_ctls() argument
4409 err = add_tuning_control(codec, in add_tuning_ctls()
4421 static void ca0132_init_tuning_defaults(struct hda_codec *codec) in ca0132_init_tuning_defaults() argument
4423 struct ca0132_spec *spec = codec->spec; in ca0132_init_tuning_defaults()
4426 /* Wedge Angle defaults to 30. 10 below is 30 - 20. 20 is min. */ in ca0132_init_tuning_defaults()
4427 spec->cur_ctl_vals[WEDGE_ANGLE - TUNING_CTL_START_NID] = 10; in ca0132_init_tuning_defaults()
4429 spec->cur_ctl_vals[SVM_LEVEL - TUNING_CTL_START_NID] = 74; in ca0132_init_tuning_defaults()
4433 spec->cur_ctl_vals[i] = 24; in ca0132_init_tuning_defaults()
4440 * If jack inserted, headphone will be selected, else built-in speakers
4443 static int ca0132_select_out(struct hda_codec *codec) in ca0132_select_out() argument
4445 struct ca0132_spec *spec = codec->spec; in ca0132_select_out()
4452 codec_dbg(codec, "ca0132_select_out\n"); in ca0132_select_out()
4454 snd_hda_power_up_pm(codec); in ca0132_select_out()
4456 auto_jack = spec->vnode_lswitch[VNID_HP_ASEL - VNODE_START_NID]; in ca0132_select_out()
4459 jack_present = snd_hda_jack_detect(codec, spec->unsol_tag_hp); in ca0132_select_out()
4462 spec->vnode_lswitch[VNID_HP_SEL - VNODE_START_NID]; in ca0132_select_out()
4465 spec->cur_out_type = HEADPHONE_OUT; in ca0132_select_out()
4467 spec->cur_out_type = SPEAKER_OUT; in ca0132_select_out()
4469 if (spec->cur_out_type == SPEAKER_OUT) { in ca0132_select_out()
4470 codec_dbg(codec, "ca0132_select_out speaker\n"); in ca0132_select_out()
4473 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); in ca0132_select_out()
4478 err = dspio_set_uint_param(codec, 0x8f, 0x00, tmp); in ca0132_select_out()
4483 snd_hda_codec_write(codec, spec->out_pins[1], 0, in ca0132_select_out()
4485 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4487 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4489 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4493 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0, in ca0132_select_out()
4495 snd_hda_set_pin_ctl(codec, spec->out_pins[1], in ca0132_select_out()
4498 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0, in ca0132_select_out()
4500 snd_hda_set_pin_ctl(codec, spec->out_pins[0], in ca0132_select_out()
4503 codec_dbg(codec, "ca0132_select_out hp\n"); in ca0132_select_out()
4506 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); in ca0132_select_out()
4511 err = dspio_set_uint_param(codec, 0x8f, 0x00, tmp); in ca0132_select_out()
4516 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4518 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4520 snd_hda_codec_write(codec, spec->out_pins[1], 0, in ca0132_select_out()
4522 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4526 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0, in ca0132_select_out()
4528 snd_hda_set_pin_ctl(codec, spec->out_pins[0], in ca0132_select_out()
4531 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0, in ca0132_select_out()
4533 snd_hda_set_pin_ctl(codec, spec->out_pins[1], in ca0132_select_out()
4538 snd_hda_power_down_pm(codec); in ca0132_select_out()
4543 static int ae5_headphone_gain_set(struct hda_codec *codec, long val);
4544 static int zxr_headphone_gain_set(struct hda_codec *codec, long val);
4545 static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val);
4547 static void ae5_mmio_select_out(struct hda_codec *codec) in ae5_mmio_select_out() argument
4549 struct ca0132_spec *spec = codec->spec; in ae5_mmio_select_out()
4559 ca0113_mmio_command_set(codec, out_cmds->group[i], in ae5_mmio_select_out()
4560 out_cmds->target[i], in ae5_mmio_select_out()
4561 out_cmds->vals[spec->cur_out_type][i]); in ae5_mmio_select_out()
4564 static int ca0132_alt_set_full_range_speaker(struct hda_codec *codec) in ca0132_alt_set_full_range_speaker() argument
4566 struct ca0132_spec *spec = codec->spec; in ca0132_alt_set_full_range_speaker()
4571 /* 2.0/4.0 setup has no LFE channel, so setting full-range does nothing. */ in ca0132_alt_set_full_range_speaker()
4572 if (spec->channel_cfg_val == SPEAKER_CHANNELS_4_0 in ca0132_alt_set_full_range_speaker()
4573 || spec->channel_cfg_val == SPEAKER_CHANNELS_2_0) in ca0132_alt_set_full_range_speaker()
4576 /* Set front L/R full range. Zero for full-range, one for redirection. */ in ca0132_alt_set_full_range_speaker()
4577 tmp = spec->speaker_range_val[0] ? FLOAT_ZERO : FLOAT_ONE; in ca0132_alt_set_full_range_speaker()
4578 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4583 /* When setting full-range rear, both rear and center/lfe are set. */ in ca0132_alt_set_full_range_speaker()
4584 tmp = spec->speaker_range_val[1] ? FLOAT_ZERO : FLOAT_ONE; in ca0132_alt_set_full_range_speaker()
4585 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4590 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4596 * Only the AE series cards set this value when setting full-range, in ca0132_alt_set_full_range_speaker()
4600 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4609 static int ca0132_alt_surround_set_bass_redirection(struct hda_codec *codec, in ca0132_alt_surround_set_bass_redirection() argument
4612 struct ca0132_spec *spec = codec->spec; in ca0132_alt_surround_set_bass_redirection()
4616 if (val && spec->channel_cfg_val != SPEAKER_CHANNELS_4_0 && in ca0132_alt_surround_set_bass_redirection()
4617 spec->channel_cfg_val != SPEAKER_CHANNELS_2_0) in ca0132_alt_surround_set_bass_redirection()
4622 err = dspio_set_uint_param(codec, 0x96, SPEAKER_BASS_REDIRECT, tmp); in ca0132_alt_surround_set_bass_redirection()
4628 tmp = float_xbass_xover_lookup[spec->xbass_xover_freq]; in ca0132_alt_surround_set_bass_redirection()
4629 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_surround_set_bass_redirection()
4642 static void ca0132_alt_select_out_get_quirk_data(struct hda_codec *codec, in ca0132_alt_select_out_get_quirk_data() argument
4645 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_out_get_quirk_data()
4658 static int ca0132_alt_select_out_quirk_set(struct hda_codec *codec) in ca0132_alt_select_out_quirk_set() argument
4662 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_out_quirk_set()
4666 ca0132_alt_select_out_get_quirk_data(codec, &quirk_data); in ca0132_alt_select_out_quirk_set()
4670 out_info = &quirk_data->out_set_info[spec->cur_out_type]; in ca0132_alt_select_out_quirk_set()
4671 if (quirk_data->is_ae_series) in ca0132_alt_select_out_quirk_set()
4672 ae5_mmio_select_out(codec); in ca0132_alt_select_out_quirk_set()
4674 if (out_info->has_hda_gpio) { in ca0132_alt_select_out_quirk_set()
4675 gpio_data = snd_hda_codec_read(codec, codec->core.afg, 0, in ca0132_alt_select_out_quirk_set()
4678 if (out_info->hda_gpio_set) in ca0132_alt_select_out_quirk_set()
4679 gpio_data |= (1 << out_info->hda_gpio_pin); in ca0132_alt_select_out_quirk_set()
4681 gpio_data &= ~(1 << out_info->hda_gpio_pin); in ca0132_alt_select_out_quirk_set()
4683 snd_hda_codec_write(codec, codec->core.afg, 0, in ca0132_alt_select_out_quirk_set()
4687 if (out_info->mmio_gpio_count) { in ca0132_alt_select_out_quirk_set()
4688 for (i = 0; i < out_info->mmio_gpio_count; i++) { in ca0132_alt_select_out_quirk_set()
4689 ca0113_mmio_gpio_set(codec, out_info->mmio_gpio_pin[i], in ca0132_alt_select_out_quirk_set()
4690 out_info->mmio_gpio_set[i]); in ca0132_alt_select_out_quirk_set()
4694 if (out_info->scp_cmds_count) { in ca0132_alt_select_out_quirk_set()
4695 for (i = 0; i < out_info->scp_cmds_count; i++) { in ca0132_alt_select_out_quirk_set()
4696 err = dspio_set_uint_param(codec, in ca0132_alt_select_out_quirk_set()
4697 out_info->scp_cmd_mid[i], in ca0132_alt_select_out_quirk_set()
4698 out_info->scp_cmd_req[i], in ca0132_alt_select_out_quirk_set()
4699 out_info->scp_cmd_val[i]); in ca0132_alt_select_out_quirk_set()
4705 chipio_set_control_param(codec, 0x0d, out_info->dac2port); in ca0132_alt_select_out_quirk_set()
4707 if (out_info->has_chipio_write) { in ca0132_alt_select_out_quirk_set()
4708 chipio_write(codec, out_info->chipio_write_addr, in ca0132_alt_select_out_quirk_set()
4709 out_info->chipio_write_data); in ca0132_alt_select_out_quirk_set()
4712 if (quirk_data->has_headphone_gain) { in ca0132_alt_select_out_quirk_set()
4713 if (spec->cur_out_type != HEADPHONE_OUT) { in ca0132_alt_select_out_quirk_set()
4714 if (quirk_data->is_ae_series) in ca0132_alt_select_out_quirk_set()
4715 ae5_headphone_gain_set(codec, 2); in ca0132_alt_select_out_quirk_set()
4717 zxr_headphone_gain_set(codec, 0); in ca0132_alt_select_out_quirk_set()
4719 if (quirk_data->is_ae_series) in ca0132_alt_select_out_quirk_set()
4720 ae5_headphone_gain_set(codec, in ca0132_alt_select_out_quirk_set()
4721 spec->ae5_headphone_gain_val); in ca0132_alt_select_out_quirk_set()
4723 zxr_headphone_gain_set(codec, in ca0132_alt_select_out_quirk_set()
4724 spec->zxr_gain_set); in ca0132_alt_select_out_quirk_set()
4731 static void ca0132_set_out_node_pincfg(struct hda_codec *codec, hda_nid_t nid, in ca0132_set_out_node_pincfg() argument
4736 pin_ctl = snd_hda_codec_read(codec, nid, 0, in ca0132_set_out_node_pincfg()
4741 snd_hda_set_pin_ctl(codec, nid, pin_ctl); in ca0132_set_out_node_pincfg()
4748 * mute switch is set to off. If the auto detect mute switch is enabled, it
4750 * It also adds the ability to auto-detect the front headphone port.
4752 static int ca0132_alt_select_out(struct hda_codec *codec) in ca0132_alt_select_out() argument
4754 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_out()
4760 hda_nid_t headphone_nid = spec->out_pins[1]; in ca0132_alt_select_out()
4762 codec_dbg(codec, "%s\n", __func__); in ca0132_alt_select_out()
4764 snd_hda_power_up_pm(codec); in ca0132_alt_select_out()
4766 auto_jack = spec->vnode_lswitch[VNID_HP_ASEL - VNODE_START_NID]; in ca0132_alt_select_out()
4774 jack_present = snd_hda_jack_detect(codec, spec->unsol_tag_hp) || in ca0132_alt_select_out()
4775 snd_hda_jack_detect(codec, spec->unsol_tag_front_hp); in ca0132_alt_select_out()
4778 spec->cur_out_type = HEADPHONE_OUT; in ca0132_alt_select_out()
4780 spec->cur_out_type = SPEAKER_OUT; in ca0132_alt_select_out()
4782 spec->cur_out_type = spec->out_enum_val; in ca0132_alt_select_out()
4784 outfx_set = spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]; in ca0132_alt_select_out()
4787 err = dspio_set_uint_param(codec, 0x96, SPEAKER_TUNING_MUTE, FLOAT_ONE); in ca0132_alt_select_out()
4791 if (ca0132_alt_select_out_quirk_set(codec) < 0) in ca0132_alt_select_out()
4794 switch (spec->cur_out_type) { in ca0132_alt_select_out()
4796 codec_dbg(codec, "%s speaker\n", __func__); in ca0132_alt_select_out()
4799 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_alt_select_out()
4803 ca0132_set_out_node_pincfg(codec, spec->out_pins[1], 0, 0); in ca0132_alt_select_out()
4804 /* Set front L-R to output. */ in ca0132_alt_select_out()
4805 ca0132_set_out_node_pincfg(codec, spec->out_pins[0], 1, 0); in ca0132_alt_select_out()
4807 ca0132_set_out_node_pincfg(codec, spec->out_pins[2], 1, 0); in ca0132_alt_select_out()
4809 ca0132_set_out_node_pincfg(codec, spec->out_pins[3], 1, 0); in ca0132_alt_select_out()
4816 if (!outfx_set && spec->channel_cfg_val == SPEAKER_CHANNELS_2_0) in ca0132_alt_select_out()
4819 tmp = speaker_channel_cfgs[spec->channel_cfg_val].val; in ca0132_alt_select_out()
4821 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); in ca0132_alt_select_out()
4827 codec_dbg(codec, "%s hp\n", __func__); in ca0132_alt_select_out()
4828 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_alt_select_out()
4832 ca0132_set_out_node_pincfg(codec, spec->out_pins[0], 0, 0); in ca0132_alt_select_out()
4833 ca0132_set_out_node_pincfg(codec, spec->out_pins[2], 0, 0); in ca0132_alt_select_out()
4834 ca0132_set_out_node_pincfg(codec, spec->out_pins[3], 0, 0); in ca0132_alt_select_out()
4837 if (snd_hda_jack_detect(codec, spec->unsol_tag_front_hp)) in ca0132_alt_select_out()
4838 headphone_nid = spec->out_pins[2]; in ca0132_alt_select_out()
4839 else if (snd_hda_jack_detect(codec, spec->unsol_tag_hp)) in ca0132_alt_select_out()
4840 headphone_nid = spec->out_pins[1]; in ca0132_alt_select_out()
4842 ca0132_set_out_node_pincfg(codec, headphone_nid, 1, 1); in ca0132_alt_select_out()
4845 err = dspio_set_uint_param(codec, 0x80, 0x04, FLOAT_ONE); in ca0132_alt_select_out()
4847 err = dspio_set_uint_param(codec, 0x80, 0x04, FLOAT_ZERO); in ca0132_alt_select_out()
4854 * If output effects are enabled, set the X-Bass effect value again to in ca0132_alt_select_out()
4859 ca0132_effects_set(codec, X_BASS, in ca0132_alt_select_out()
4860 spec->effects_switch[X_BASS - EFFECT_START_NID]); in ca0132_alt_select_out()
4863 err = dspio_set_uint_param(codec, 0x8f, 0x01, FLOAT_ZERO); in ca0132_alt_select_out()
4871 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_select_out()
4876 if (spec->cur_out_type == SPEAKER_OUT) in ca0132_alt_select_out()
4877 err = ca0132_alt_surround_set_bass_redirection(codec, in ca0132_alt_select_out()
4878 spec->bass_redirection_val); in ca0132_alt_select_out()
4880 err = ca0132_alt_surround_set_bass_redirection(codec, 0); in ca0132_alt_select_out()
4883 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_select_out()
4888 if (spec->cur_out_type == SPEAKER_OUT) { in ca0132_alt_select_out()
4889 err = ca0132_alt_set_full_range_speaker(codec); in ca0132_alt_select_out()
4895 snd_hda_power_down_pm(codec); in ca0132_alt_select_out()
4907 ca0132_alt_select_out(spec->codec); in ca0132_unsol_hp_delayed()
4909 ca0132_select_out(spec->codec); in ca0132_unsol_hp_delayed()
4911 jack = snd_hda_jack_tbl_get(spec->codec, spec->unsol_tag_hp); in ca0132_unsol_hp_delayed()
4913 jack->block_report = 0; in ca0132_unsol_hp_delayed()
4914 snd_hda_jack_report_sync(spec->codec); in ca0132_unsol_hp_delayed()
4918 static void ca0132_set_dmic(struct hda_codec *codec, int enable);
4919 static int ca0132_mic_boost_set(struct hda_codec *codec, long val);
4920 static void resume_mic1(struct hda_codec *codec, unsigned int oldval);
4921 static int stop_mic1(struct hda_codec *codec);
4922 static int ca0132_cvoice_switch_set(struct hda_codec *codec);
4923 static int ca0132_alt_mic_boost_set(struct hda_codec *codec, long val);
4928 static int ca0132_set_vipsource(struct hda_codec *codec, int val) in ca0132_set_vipsource() argument
4930 struct ca0132_spec *spec = codec->spec; in ca0132_set_vipsource()
4933 if (spec->dsp_state != DSP_DOWNLOADED) in ca0132_set_vipsource()
4936 /* if CrystalVoice if off, vipsource should be 0 */ in ca0132_set_vipsource()
4937 if (!spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID] || in ca0132_set_vipsource()
4939 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, 0); in ca0132_set_vipsource()
4940 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_set_vipsource()
4941 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_set_vipsource()
4942 if (spec->cur_mic_type == DIGITAL_MIC) in ca0132_set_vipsource()
4946 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_vipsource()
4948 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_set_vipsource()
4950 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_16_000); in ca0132_set_vipsource()
4951 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_16_000); in ca0132_set_vipsource()
4952 if (spec->cur_mic_type == DIGITAL_MIC) in ca0132_set_vipsource()
4956 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_vipsource()
4958 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_set_vipsource()
4960 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, val); in ca0132_set_vipsource()
4966 static int ca0132_alt_set_vipsource(struct hda_codec *codec, int val) in ca0132_alt_set_vipsource() argument
4968 struct ca0132_spec *spec = codec->spec; in ca0132_alt_set_vipsource()
4971 if (spec->dsp_state != DSP_DOWNLOADED) in ca0132_alt_set_vipsource()
4974 codec_dbg(codec, "%s\n", __func__); in ca0132_alt_set_vipsource()
4976 chipio_set_stream_control(codec, 0x03, 0); in ca0132_alt_set_vipsource()
4977 chipio_set_stream_control(codec, 0x04, 0); in ca0132_alt_set_vipsource()
4979 /* if CrystalVoice is off, vipsource should be 0 */ in ca0132_alt_set_vipsource()
4980 if (!spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID] || in ca0132_alt_set_vipsource()
4981 (val == 0) || spec->in_enum_val == REAR_LINE_IN) { in ca0132_alt_set_vipsource()
4982 codec_dbg(codec, "%s: off.", __func__); in ca0132_alt_set_vipsource()
4983 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, 0); in ca0132_alt_set_vipsource()
4986 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_alt_set_vipsource()
4988 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_set_vipsource()
4989 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_set_vipsource()
4991 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_set_vipsource()
4994 if (spec->in_enum_val == REAR_LINE_IN) in ca0132_alt_set_vipsource()
5003 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_set_vipsource()
5006 codec_dbg(codec, "%s: on.", __func__); in ca0132_alt_set_vipsource()
5007 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_16_000); in ca0132_alt_set_vipsource()
5008 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_16_000); in ca0132_alt_set_vipsource()
5010 chipio_set_conn_rate(codec, 0x0F, SR_16_000); in ca0132_alt_set_vipsource()
5012 if (spec->effects_switch[VOICE_FOCUS - EFFECT_START_NID]) in ca0132_alt_set_vipsource()
5016 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_set_vipsource()
5019 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_alt_set_vipsource()
5022 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, val); in ca0132_alt_set_vipsource()
5025 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_set_vipsource()
5026 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_set_vipsource()
5034 * If jack inserted, ext.mic will be selected, else built-in mic
5037 static int ca0132_select_mic(struct hda_codec *codec) in ca0132_select_mic() argument
5039 struct ca0132_spec *spec = codec->spec; in ca0132_select_mic()
5043 codec_dbg(codec, "ca0132_select_mic\n"); in ca0132_select_mic()
5045 snd_hda_power_up_pm(codec); in ca0132_select_mic()
5047 auto_jack = spec->vnode_lswitch[VNID_AMIC1_ASEL - VNODE_START_NID]; in ca0132_select_mic()
5050 jack_present = snd_hda_jack_detect(codec, spec->unsol_tag_amic1); in ca0132_select_mic()
5053 spec->vnode_lswitch[VNID_AMIC1_SEL - VNODE_START_NID]; in ca0132_select_mic()
5056 spec->cur_mic_type = LINE_MIC_IN; in ca0132_select_mic()
5058 spec->cur_mic_type = DIGITAL_MIC; in ca0132_select_mic()
5060 if (spec->cur_mic_type == DIGITAL_MIC) { in ca0132_select_mic()
5062 chipio_set_conn_rate(codec, MEM_CONNID_DMIC, SR_32_000); in ca0132_select_mic()
5063 ca0132_set_dmic(codec, 1); in ca0132_select_mic()
5064 ca0132_mic_boost_set(codec, 0); in ca0132_select_mic()
5066 ca0132_effects_set(codec, VOICE_FOCUS, in ca0132_select_mic()
5067 spec->effects_switch in ca0132_select_mic()
5068 [VOICE_FOCUS - EFFECT_START_NID]); in ca0132_select_mic()
5071 chipio_set_conn_rate(codec, MEM_CONNID_DMIC, SR_96_000); in ca0132_select_mic()
5072 ca0132_set_dmic(codec, 0); in ca0132_select_mic()
5073 ca0132_mic_boost_set(codec, spec->cur_mic_boost); in ca0132_select_mic()
5075 ca0132_effects_set(codec, VOICE_FOCUS, 0); in ca0132_select_mic()
5078 snd_hda_power_down_pm(codec); in ca0132_select_mic()
5086 * The front mic has no jack-detection, so the only way to switch to it
5089 static int ca0132_alt_select_in(struct hda_codec *codec) in ca0132_alt_select_in() argument
5091 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_in()
5094 codec_dbg(codec, "%s\n", __func__); in ca0132_alt_select_in()
5096 snd_hda_power_up_pm(codec); in ca0132_alt_select_in()
5098 chipio_set_stream_control(codec, 0x03, 0); in ca0132_alt_select_in()
5099 chipio_set_stream_control(codec, 0x04, 0); in ca0132_alt_select_in()
5101 spec->cur_mic_type = spec->in_enum_val; in ca0132_alt_select_in()
5103 switch (spec->cur_mic_type) { in ca0132_alt_select_in()
5108 ca0113_mmio_gpio_set(codec, 0, false); in ca0132_alt_select_in()
5115 r3di_gpio_mic_set(codec, R3DI_REAR_MIC); in ca0132_alt_select_in()
5119 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ca0132_alt_select_in()
5123 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ca0132_alt_select_in()
5125 chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, in ca0132_alt_select_in()
5127 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, in ca0132_alt_select_in()
5129 dspio_set_uint_param(codec, 0x80, 0x01, FLOAT_ZERO); in ca0132_alt_select_in()
5136 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_select_in()
5137 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_select_in()
5139 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_select_in()
5141 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_select_in()
5143 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_select_in()
5144 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_select_in()
5147 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5148 chipio_write(codec, 0x18B09C, 0x0000000C); in ca0132_alt_select_in()
5151 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5152 chipio_write(codec, 0x18B09C, 0x000000CC); in ca0132_alt_select_in()
5155 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5156 chipio_write(codec, 0x18B09C, 0x0000004C); in ca0132_alt_select_in()
5161 ca0132_alt_mic_boost_set(codec, spec->mic_boost_enum_val); in ca0132_alt_select_in()
5164 ca0132_mic_boost_set(codec, 0); in ca0132_alt_select_in()
5168 ca0113_mmio_gpio_set(codec, 0, false); in ca0132_alt_select_in()
5171 r3di_gpio_mic_set(codec, R3DI_REAR_MIC); in ca0132_alt_select_in()
5174 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ca0132_alt_select_in()
5177 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x3f); in ca0132_alt_select_in()
5178 chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, in ca0132_alt_select_in()
5180 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, in ca0132_alt_select_in()
5182 dspio_set_uint_param(codec, 0x80, 0x01, FLOAT_ZERO); in ca0132_alt_select_in()
5188 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_select_in()
5189 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_select_in()
5191 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_select_in()
5197 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_select_in()
5202 chipio_write(codec, 0x18B098, 0x00000000); in ca0132_alt_select_in()
5203 chipio_write(codec, 0x18B09C, 0x00000000); in ca0132_alt_select_in()
5208 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_select_in()
5209 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_select_in()
5215 ca0113_mmio_gpio_set(codec, 0, true); in ca0132_alt_select_in()
5216 ca0113_mmio_gpio_set(codec, 5, false); in ca0132_alt_select_in()
5220 r3di_gpio_mic_set(codec, R3DI_FRONT_MIC); in ca0132_alt_select_in()
5224 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x3f); in ca0132_alt_select_in()
5232 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_select_in()
5233 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_select_in()
5235 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_select_in()
5237 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_select_in()
5239 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_select_in()
5240 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_select_in()
5244 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5245 chipio_write(codec, 0x18B09C, 0x000000CC); in ca0132_alt_select_in()
5248 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5249 chipio_write(codec, 0x18B09C, 0x0000004C); in ca0132_alt_select_in()
5254 ca0132_alt_mic_boost_set(codec, spec->mic_boost_enum_val); in ca0132_alt_select_in()
5257 ca0132_cvoice_switch_set(codec); in ca0132_alt_select_in()
5259 snd_hda_power_down_pm(codec); in ca0132_alt_select_in()
5266 static bool ca0132_is_vnode_effective(struct hda_codec *codec, in ca0132_is_vnode_effective() argument
5270 struct ca0132_spec *spec = codec->spec; in ca0132_is_vnode_effective()
5275 nid = spec->shared_out_nid; in ca0132_is_vnode_effective()
5278 nid = spec->shared_mic_nid; in ca0132_is_vnode_effective()
5294 static int ca0132_voicefx_set(struct hda_codec *codec, int enable) in ca0132_voicefx_set() argument
5296 struct ca0132_spec *spec = codec->spec; in ca0132_voicefx_set()
5301 tmp = spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID] ? in ca0132_voicefx_set()
5307 dspio_set_uint_param(codec, ca0132_voicefx.mid, in ca0132_voicefx_set()
5316 static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val) in ca0132_effects_set() argument
5318 struct ca0132_spec *spec = codec->spec; in ca0132_effects_set()
5322 int idx = nid - EFFECT_START_NID; in ca0132_effects_set()
5329 /* if PE if off, turn off out effects. */ in ca0132_effects_set()
5330 if (!spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]) in ca0132_effects_set()
5332 if (spec->cur_out_type == SPEAKER_OUT && nid == X_BASS) { in ca0132_effects_set()
5333 channel_cfg = spec->channel_cfg_val; in ca0132_effects_set()
5342 /* if CrystalVoice if off, turn off in effects. */ in ca0132_effects_set()
5343 if (!spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID]) in ca0132_effects_set()
5346 /* Voice Focus applies to 2-ch Mic, Digital Mic */ in ca0132_effects_set()
5347 if ((nid == VOICE_FOCUS) && (spec->cur_mic_type != DIGITAL_MIC)) in ca0132_effects_set()
5352 && (spec->cur_mic_type != REAR_LINE_IN)) { in ca0132_effects_set()
5353 if (spec->effects_switch[CRYSTAL_VOICE - in ca0132_effects_set()
5356 if (spec->effects_switch[VOICE_FOCUS - in ca0132_effects_set()
5363 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_effects_set()
5371 && (spec->cur_mic_type != REAR_LINE_IN)) { in ca0132_effects_set()
5372 if (spec->effects_switch[CRYSTAL_VOICE - in ca0132_effects_set()
5374 if (spec->effects_switch[NOISE_REDUCTION - in ca0132_effects_set()
5382 dspio_set_uint_param(codec, 0x47, 0x00, tmp); in ca0132_effects_set()
5387 spec->in_enum_val == REAR_LINE_IN) in ca0132_effects_set()
5391 codec_dbg(codec, "ca0132_effect_set: nid=0x%x, val=%ld\n", in ca0132_effects_set()
5395 err = dspio_set_uint_param(codec, ca0132_effects[idx].mid, in ca0132_effects_set()
5405 * Turn on/off Playback Enhancements
5407 static int ca0132_pe_switch_set(struct hda_codec *codec) in ca0132_pe_switch_set() argument
5409 struct ca0132_spec *spec = codec->spec; in ca0132_pe_switch_set()
5413 codec_dbg(codec, "ca0132_pe_switch_set: val=%ld\n", in ca0132_pe_switch_set()
5414 spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]); in ca0132_pe_switch_set()
5417 ca0132_alt_select_out(codec); in ca0132_pe_switch_set()
5419 i = OUT_EFFECT_START_NID - EFFECT_START_NID; in ca0132_pe_switch_set()
5423 ret |= ca0132_effects_set(codec, nid, spec->effects_switch[i]); in ca0132_pe_switch_set()
5429 static int stop_mic1(struct hda_codec *codec) in stop_mic1() argument
5431 struct ca0132_spec *spec = codec->spec; in stop_mic1()
5432 unsigned int oldval = snd_hda_codec_read(codec, spec->adcs[0], 0, in stop_mic1()
5435 snd_hda_codec_write(codec, spec->adcs[0], 0, in stop_mic1()
5442 static void resume_mic1(struct hda_codec *codec, unsigned int oldval) in resume_mic1() argument
5444 struct ca0132_spec *spec = codec->spec; in resume_mic1()
5447 snd_hda_codec_write(codec, spec->adcs[0], 0, in resume_mic1()
5453 * Turn on/off CrystalVoice
5455 static int ca0132_cvoice_switch_set(struct hda_codec *codec) in ca0132_cvoice_switch_set() argument
5457 struct ca0132_spec *spec = codec->spec; in ca0132_cvoice_switch_set()
5462 codec_dbg(codec, "ca0132_cvoice_switch_set: val=%ld\n", in ca0132_cvoice_switch_set()
5463 spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID]); in ca0132_cvoice_switch_set()
5465 i = IN_EFFECT_START_NID - EFFECT_START_NID; in ca0132_cvoice_switch_set()
5469 ret |= ca0132_effects_set(codec, nid, spec->effects_switch[i]); in ca0132_cvoice_switch_set()
5472 ret |= ca0132_voicefx_set(codec, (spec->voicefx_val ? 1 : 0)); in ca0132_cvoice_switch_set()
5475 oldval = stop_mic1(codec); in ca0132_cvoice_switch_set()
5477 ret |= ca0132_alt_set_vipsource(codec, 1); in ca0132_cvoice_switch_set()
5479 ret |= ca0132_set_vipsource(codec, 1); in ca0132_cvoice_switch_set()
5480 resume_mic1(codec, oldval); in ca0132_cvoice_switch_set()
5484 static int ca0132_mic_boost_set(struct hda_codec *codec, long val) in ca0132_mic_boost_set() argument
5486 struct ca0132_spec *spec = codec->spec; in ca0132_mic_boost_set()
5490 ret = snd_hda_codec_amp_update(codec, spec->input_pins[0], 0, in ca0132_mic_boost_set()
5492 else /* off */ in ca0132_mic_boost_set()
5493 ret = snd_hda_codec_amp_update(codec, spec->input_pins[0], 0, in ca0132_mic_boost_set()
5499 static int ca0132_alt_mic_boost_set(struct hda_codec *codec, long val) in ca0132_alt_mic_boost_set() argument
5501 struct ca0132_spec *spec = codec->spec; in ca0132_alt_mic_boost_set()
5504 ret = snd_hda_codec_amp_update(codec, spec->input_pins[0], 0, in ca0132_alt_mic_boost_set()
5509 static int ae5_headphone_gain_set(struct hda_codec *codec, long val) in ae5_headphone_gain_set() argument
5514 ca0113_mmio_command_set(codec, 0x48, 0x11 + i, in ae5_headphone_gain_set()
5520 * gpio pin 1 is a relay that switches on/off, apparently setting the headphone
5523 static int zxr_headphone_gain_set(struct hda_codec *codec, long val) in zxr_headphone_gain_set() argument
5525 ca0113_mmio_gpio_set(codec, 1, val); in zxr_headphone_gain_set()
5533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_vnode_switch_set() local
5538 struct ca0132_spec *spec = codec->spec; in ca0132_vnode_switch_set()
5543 spec->vnode_lswitch[VNID_HP_ASEL - VNODE_START_NID]; in ca0132_vnode_switch_set()
5546 ca0132_alt_select_out(codec); in ca0132_vnode_switch_set()
5548 ca0132_select_out(codec); in ca0132_vnode_switch_set()
5555 spec->vnode_lswitch[VNID_AMIC1_ASEL - VNODE_START_NID]; in ca0132_vnode_switch_set()
5557 ca0132_select_mic(codec); in ca0132_vnode_switch_set()
5563 ca0132_alt_select_out(codec); in ca0132_vnode_switch_set()
5565 ca0132_select_out(codec); in ca0132_vnode_switch_set()
5570 ca0132_select_mic(codec); in ca0132_vnode_switch_set()
5575 effective = ca0132_is_vnode_effective(codec, nid, &shared_nid); in ca0132_vnode_switch_set()
5581 mutex_lock(&codec->control_mutex); in ca0132_vnode_switch_set()
5582 pval = kcontrol->private_value; in ca0132_vnode_switch_set()
5583 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(shared_nid, ch, in ca0132_vnode_switch_set()
5586 kcontrol->private_value = pval; in ca0132_vnode_switch_set()
5587 mutex_unlock(&codec->control_mutex); in ca0132_vnode_switch_set()
5594 static void ca0132_alt_bass_redirection_xover_set(struct hda_codec *codec, in ca0132_alt_bass_redirection_xover_set() argument
5597 snd_hda_power_up(codec); in ca0132_alt_bass_redirection_xover_set()
5599 dspio_set_param(codec, 0x96, 0x20, SPEAKER_BASS_REDIRECT_XOVER_FREQ, in ca0132_alt_bass_redirection_xover_set()
5602 snd_hda_power_down(codec); in ca0132_alt_bass_redirection_xover_set()
5614 static int ca0132_alt_slider_ctl_set(struct hda_codec *codec, hda_nid_t nid, in ca0132_alt_slider_ctl_set() argument
5628 snd_hda_power_up(codec); in ca0132_alt_slider_ctl_set()
5634 dspio_set_param(codec, ca0132_effects[i].mid, 0x20, in ca0132_alt_slider_ctl_set()
5636 &(lookup[idx - 1]), sizeof(unsigned int)); in ca0132_alt_slider_ctl_set()
5643 dspio_set_param(codec, ca0132_effects[i].mid, 0x20, in ca0132_alt_slider_ctl_set()
5648 snd_hda_power_down(codec); in ca0132_alt_slider_ctl_set()
5656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_xbass_xover_slider_ctl_get() local
5657 struct ca0132_spec *spec = codec->spec; in ca0132_alt_xbass_xover_slider_ctl_get()
5658 long *valp = ucontrol->value.integer.value; in ca0132_alt_xbass_xover_slider_ctl_get()
5662 *valp = spec->bass_redirect_xover_freq; in ca0132_alt_xbass_xover_slider_ctl_get()
5664 *valp = spec->xbass_xover_freq; in ca0132_alt_xbass_xover_slider_ctl_get()
5672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_slider_ctl_get() local
5673 struct ca0132_spec *spec = codec->spec; in ca0132_alt_slider_ctl_get()
5675 long *valp = ucontrol->value.integer.value; in ca0132_alt_slider_ctl_get()
5676 int idx = nid - OUT_EFFECT_START_NID; in ca0132_alt_slider_ctl_get()
5678 *valp = spec->fx_ctl_val[idx]; in ca0132_alt_slider_ctl_get()
5683 * The X-bass crossover starts at 10hz, so the min is 1. The
5689 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in ca0132_alt_xbass_xover_slider_info()
5690 uinfo->count = 1; in ca0132_alt_xbass_xover_slider_info()
5691 uinfo->value.integer.min = 1; in ca0132_alt_xbass_xover_slider_info()
5692 uinfo->value.integer.max = 100; in ca0132_alt_xbass_xover_slider_info()
5693 uinfo->value.integer.step = 1; in ca0132_alt_xbass_xover_slider_info()
5703 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in ca0132_alt_effect_slider_info()
5704 uinfo->count = chs == 3 ? 2 : 1; in ca0132_alt_effect_slider_info()
5705 uinfo->value.integer.min = 0; in ca0132_alt_effect_slider_info()
5706 uinfo->value.integer.max = 100; in ca0132_alt_effect_slider_info()
5707 uinfo->value.integer.step = 1; in ca0132_alt_effect_slider_info()
5715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_xbass_xover_slider_put() local
5716 struct ca0132_spec *spec = codec->spec; in ca0132_alt_xbass_xover_slider_put()
5718 long *valp = ucontrol->value.integer.value; in ca0132_alt_xbass_xover_slider_put()
5723 cur_val = &spec->bass_redirect_xover_freq; in ca0132_alt_xbass_xover_slider_put()
5725 cur_val = &spec->xbass_xover_freq; in ca0132_alt_xbass_xover_slider_put()
5735 ca0132_alt_bass_redirection_xover_set(codec, *cur_val); in ca0132_alt_xbass_xover_slider_put()
5737 ca0132_alt_slider_ctl_set(codec, nid, float_xbass_xover_lookup, idx); in ca0132_alt_xbass_xover_slider_put()
5745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_effect_slider_put() local
5746 struct ca0132_spec *spec = codec->spec; in ca0132_alt_effect_slider_put()
5748 long *valp = ucontrol->value.integer.value; in ca0132_alt_effect_slider_put()
5751 idx = nid - EFFECT_START_NID; in ca0132_alt_effect_slider_put()
5753 if (spec->fx_ctl_val[idx] == *valp) in ca0132_alt_effect_slider_put()
5756 spec->fx_ctl_val[idx] = *valp; in ca0132_alt_effect_slider_put()
5759 ca0132_alt_slider_ctl_set(codec, nid, float_zero_to_one_lookup, idx); in ca0132_alt_effect_slider_put()
5767 * only has off or full 30 dB, and didn't like making a volume slider that has
5768 * traditional 0-100 in alsamixer that goes in big steps. I like enum better.
5779 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ca0132_alt_mic_boost_info()
5780 uinfo->count = 1; in ca0132_alt_mic_boost_info()
5781 uinfo->value.enumerated.items = MIC_BOOST_NUM_OF_STEPS; in ca0132_alt_mic_boost_info()
5782 if (uinfo->value.enumerated.item >= MIC_BOOST_NUM_OF_STEPS) in ca0132_alt_mic_boost_info()
5783 uinfo->value.enumerated.item = MIC_BOOST_NUM_OF_STEPS - 1; in ca0132_alt_mic_boost_info()
5784 sprintf(namestr, "%d %s", (uinfo->value.enumerated.item * 10), sfx); in ca0132_alt_mic_boost_info()
5785 strcpy(uinfo->value.enumerated.name, namestr); in ca0132_alt_mic_boost_info()
5792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_mic_boost_get() local
5793 struct ca0132_spec *spec = codec->spec; in ca0132_alt_mic_boost_get()
5795 ucontrol->value.enumerated.item[0] = spec->mic_boost_enum_val; in ca0132_alt_mic_boost_get()
5802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_mic_boost_put() local
5803 struct ca0132_spec *spec = codec->spec; in ca0132_alt_mic_boost_put()
5804 int sel = ucontrol->value.enumerated.item[0]; in ca0132_alt_mic_boost_put()
5810 codec_dbg(codec, "ca0132_alt_mic_boost: boost=%d\n", in ca0132_alt_mic_boost_put()
5813 spec->mic_boost_enum_val = sel; in ca0132_alt_mic_boost_put()
5815 if (spec->in_enum_val != REAR_LINE_IN) in ca0132_alt_mic_boost_put()
5816 ca0132_alt_mic_boost_set(codec, spec->mic_boost_enum_val); in ca0132_alt_mic_boost_put()
5822 * Sound BlasterX AE-5 Headphone Gain Controls.
5831 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ae5_headphone_gain_info()
5832 uinfo->count = 1; in ae5_headphone_gain_info()
5833 uinfo->value.enumerated.items = AE5_HEADPHONE_GAIN_MAX; in ae5_headphone_gain_info()
5834 if (uinfo->value.enumerated.item >= AE5_HEADPHONE_GAIN_MAX) in ae5_headphone_gain_info()
5835 uinfo->value.enumerated.item = AE5_HEADPHONE_GAIN_MAX - 1; in ae5_headphone_gain_info()
5837 ae5_headphone_gain_presets[uinfo->value.enumerated.item].name, in ae5_headphone_gain_info()
5839 strcpy(uinfo->value.enumerated.name, namestr); in ae5_headphone_gain_info()
5846 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_headphone_gain_get() local
5847 struct ca0132_spec *spec = codec->spec; in ae5_headphone_gain_get()
5849 ucontrol->value.enumerated.item[0] = spec->ae5_headphone_gain_val; in ae5_headphone_gain_get()
5856 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_headphone_gain_put() local
5857 struct ca0132_spec *spec = codec->spec; in ae5_headphone_gain_put()
5858 int sel = ucontrol->value.enumerated.item[0]; in ae5_headphone_gain_put()
5864 codec_dbg(codec, "ae5_headphone_gain: boost=%d\n", in ae5_headphone_gain_put()
5867 spec->ae5_headphone_gain_val = sel; in ae5_headphone_gain_put()
5869 if (spec->out_enum_val == HEADPHONE_OUT) in ae5_headphone_gain_put()
5870 ae5_headphone_gain_set(codec, spec->ae5_headphone_gain_val); in ae5_headphone_gain_put()
5876 * Sound BlasterX AE-5 sound filter enumerated control.
5885 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ae5_sound_filter_info()
5886 uinfo->count = 1; in ae5_sound_filter_info()
5887 uinfo->value.enumerated.items = AE5_SOUND_FILTER_MAX; in ae5_sound_filter_info()
5888 if (uinfo->value.enumerated.item >= AE5_SOUND_FILTER_MAX) in ae5_sound_filter_info()
5889 uinfo->value.enumerated.item = AE5_SOUND_FILTER_MAX - 1; in ae5_sound_filter_info()
5891 ae5_filter_presets[uinfo->value.enumerated.item].name); in ae5_sound_filter_info()
5892 strcpy(uinfo->value.enumerated.name, namestr); in ae5_sound_filter_info()
5899 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_sound_filter_get() local
5900 struct ca0132_spec *spec = codec->spec; in ae5_sound_filter_get()
5902 ucontrol->value.enumerated.item[0] = spec->ae5_filter_val; in ae5_sound_filter_get()
5909 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_sound_filter_put() local
5910 struct ca0132_spec *spec = codec->spec; in ae5_sound_filter_put()
5911 int sel = ucontrol->value.enumerated.item[0]; in ae5_sound_filter_put()
5917 codec_dbg(codec, "ae5_sound_filter: %s\n", in ae5_sound_filter_put()
5920 spec->ae5_filter_val = sel; in ae5_sound_filter_put()
5922 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, in ae5_sound_filter_put()
5930 * front microphone has no auto-detect, and we need a way to set the rear
5931 * as line-in
5936 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ca0132_alt_input_source_info()
5937 uinfo->count = 1; in ca0132_alt_input_source_info()
5938 uinfo->value.enumerated.items = IN_SRC_NUM_OF_INPUTS; in ca0132_alt_input_source_info()
5939 if (uinfo->value.enumerated.item >= IN_SRC_NUM_OF_INPUTS) in ca0132_alt_input_source_info()
5940 uinfo->value.enumerated.item = IN_SRC_NUM_OF_INPUTS - 1; in ca0132_alt_input_source_info()
5941 strcpy(uinfo->value.enumerated.name, in ca0132_alt_input_source_info()
5942 in_src_str[uinfo->value.enumerated.item]); in ca0132_alt_input_source_info()
5949 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_input_source_get() local
5950 struct ca0132_spec *spec = codec->spec; in ca0132_alt_input_source_get()
5952 ucontrol->value.enumerated.item[0] = spec->in_enum_val; in ca0132_alt_input_source_get()
5959 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_input_source_put() local
5960 struct ca0132_spec *spec = codec->spec; in ca0132_alt_input_source_put()
5961 int sel = ucontrol->value.enumerated.item[0]; in ca0132_alt_input_source_put()
5965 * The AE-7 has no front microphone, so limit items to 2: rear mic and in ca0132_alt_input_source_put()
5966 * line-in. in ca0132_alt_input_source_put()
5974 codec_dbg(codec, "ca0132_alt_input_select: sel=%d, preset=%s\n", in ca0132_alt_input_source_put()
5977 spec->in_enum_val = sel; in ca0132_alt_input_source_put()
5979 ca0132_alt_select_in(codec); in ca0132_alt_input_source_put()
5988 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ca0132_alt_output_select_get_info()
5989 uinfo->count = 1; in ca0132_alt_output_select_get_info()
5990 uinfo->value.enumerated.items = NUM_OF_OUTPUTS; in ca0132_alt_output_select_get_info()
5991 if (uinfo->value.enumerated.item >= NUM_OF_OUTPUTS) in ca0132_alt_output_select_get_info()
5992 uinfo->value.enumerated.item = NUM_OF_OUTPUTS - 1; in ca0132_alt_output_select_get_info()
5993 strcpy(uinfo->value.enumerated.name, in ca0132_alt_output_select_get_info()
5994 out_type_str[uinfo->value.enumerated.item]); in ca0132_alt_output_select_get_info()
6001 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_output_select_get() local
6002 struct ca0132_spec *spec = codec->spec; in ca0132_alt_output_select_get()
6004 ucontrol->value.enumerated.item[0] = spec->out_enum_val; in ca0132_alt_output_select_get()
6011 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_output_select_put() local
6012 struct ca0132_spec *spec = codec->spec; in ca0132_alt_output_select_put()
6013 int sel = ucontrol->value.enumerated.item[0]; in ca0132_alt_output_select_put()
6020 codec_dbg(codec, "ca0132_alt_output_select: sel=%d, preset=%s\n", in ca0132_alt_output_select_put()
6023 spec->out_enum_val = sel; in ca0132_alt_output_select_put()
6025 auto_jack = spec->vnode_lswitch[VNID_HP_ASEL - VNODE_START_NID]; in ca0132_alt_output_select_put()
6028 ca0132_alt_select_out(codec); in ca0132_alt_output_select_put()
6039 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ca0132_alt_speaker_channel_cfg_get_info()
6040 uinfo->count = 1; in ca0132_alt_speaker_channel_cfg_get_info()
6041 uinfo->value.enumerated.items = items; in ca0132_alt_speaker_channel_cfg_get_info()
6042 if (uinfo->value.enumerated.item >= items) in ca0132_alt_speaker_channel_cfg_get_info()
6043 uinfo->value.enumerated.item = items - 1; in ca0132_alt_speaker_channel_cfg_get_info()
6044 strcpy(uinfo->value.enumerated.name, in ca0132_alt_speaker_channel_cfg_get_info()
6045 speaker_channel_cfgs[uinfo->value.enumerated.item].name); in ca0132_alt_speaker_channel_cfg_get_info()
6052 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_speaker_channel_cfg_get() local
6053 struct ca0132_spec *spec = codec->spec; in ca0132_alt_speaker_channel_cfg_get()
6055 ucontrol->value.enumerated.item[0] = spec->channel_cfg_val; in ca0132_alt_speaker_channel_cfg_get()
6062 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_speaker_channel_cfg_put() local
6063 struct ca0132_spec *spec = codec->spec; in ca0132_alt_speaker_channel_cfg_put()
6064 int sel = ucontrol->value.enumerated.item[0]; in ca0132_alt_speaker_channel_cfg_put()
6070 codec_dbg(codec, "ca0132_alt_speaker_channels: sel=%d, channels=%s\n", in ca0132_alt_speaker_channel_cfg_put()
6073 spec->channel_cfg_val = sel; in ca0132_alt_speaker_channel_cfg_put()
6075 if (spec->out_enum_val == SPEAKER_OUT) in ca0132_alt_speaker_channel_cfg_put()
6076 ca0132_alt_select_out(codec); in ca0132_alt_speaker_channel_cfg_put()
6092 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ca0132_alt_svm_setting_info()
6093 uinfo->count = 1; in ca0132_alt_svm_setting_info()
6094 uinfo->value.enumerated.items = NUM_OF_SVM_SETTINGS; in ca0132_alt_svm_setting_info()
6095 if (uinfo->value.enumerated.item >= NUM_OF_SVM_SETTINGS) in ca0132_alt_svm_setting_info()
6096 uinfo->value.enumerated.item = NUM_OF_SVM_SETTINGS - 1; in ca0132_alt_svm_setting_info()
6097 strcpy(uinfo->value.enumerated.name, in ca0132_alt_svm_setting_info()
6098 out_svm_set_enum_str[uinfo->value.enumerated.item]); in ca0132_alt_svm_setting_info()
6105 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_svm_setting_get() local
6106 struct ca0132_spec *spec = codec->spec; in ca0132_alt_svm_setting_get()
6108 ucontrol->value.enumerated.item[0] = spec->smart_volume_setting; in ca0132_alt_svm_setting_get()
6115 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_svm_setting_put() local
6116 struct ca0132_spec *spec = codec->spec; in ca0132_alt_svm_setting_put()
6117 int sel = ucontrol->value.enumerated.item[0]; in ca0132_alt_svm_setting_put()
6119 unsigned int idx = SMART_VOLUME - EFFECT_START_NID; in ca0132_alt_svm_setting_put()
6125 codec_dbg(codec, "ca0132_alt_svm_setting: sel=%d, preset=%s\n", in ca0132_alt_svm_setting_put()
6128 spec->smart_volume_setting = sel; in ca0132_alt_svm_setting_put()
6145 dspio_set_uint_param(codec, ca0132_effects[idx].mid, in ca0132_alt_svm_setting_put()
6156 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ca0132_alt_eq_preset_info()
6157 uinfo->count = 1; in ca0132_alt_eq_preset_info()
6158 uinfo->value.enumerated.items = items; in ca0132_alt_eq_preset_info()
6159 if (uinfo->value.enumerated.item >= items) in ca0132_alt_eq_preset_info()
6160 uinfo->value.enumerated.item = items - 1; in ca0132_alt_eq_preset_info()
6161 strcpy(uinfo->value.enumerated.name, in ca0132_alt_eq_preset_info()
6162 ca0132_alt_eq_presets[uinfo->value.enumerated.item].name); in ca0132_alt_eq_preset_info()
6169 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_eq_preset_get() local
6170 struct ca0132_spec *spec = codec->spec; in ca0132_alt_eq_preset_get()
6172 ucontrol->value.enumerated.item[0] = spec->eq_preset_val; in ca0132_alt_eq_preset_get()
6179 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_eq_preset_put() local
6180 struct ca0132_spec *spec = codec->spec; in ca0132_alt_eq_preset_put()
6182 int sel = ucontrol->value.enumerated.item[0]; in ca0132_alt_eq_preset_put()
6188 codec_dbg(codec, "%s: sel=%d, preset=%s\n", __func__, sel, in ca0132_alt_eq_preset_put()
6195 err = dspio_set_uint_param(codec, ca0132_alt_eq_enum.mid, in ca0132_alt_eq_preset_put()
6203 spec->eq_preset_val = sel; in ca0132_alt_eq_preset_put()
6213 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ca0132_voicefx_info()
6214 uinfo->count = 1; in ca0132_voicefx_info()
6215 uinfo->value.enumerated.items = items; in ca0132_voicefx_info()
6216 if (uinfo->value.enumerated.item >= items) in ca0132_voicefx_info()
6217 uinfo->value.enumerated.item = items - 1; in ca0132_voicefx_info()
6218 strcpy(uinfo->value.enumerated.name, in ca0132_voicefx_info()
6219 ca0132_voicefx_presets[uinfo->value.enumerated.item].name); in ca0132_voicefx_info()
6226 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_voicefx_get() local
6227 struct ca0132_spec *spec = codec->spec; in ca0132_voicefx_get()
6229 ucontrol->value.enumerated.item[0] = spec->voicefx_val; in ca0132_voicefx_get()
6236 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_voicefx_put() local
6237 struct ca0132_spec *spec = codec->spec; in ca0132_voicefx_put()
6239 int sel = ucontrol->value.enumerated.item[0]; in ca0132_voicefx_put()
6244 codec_dbg(codec, "ca0132_voicefx_put: sel=%d, preset=%s\n", in ca0132_voicefx_put()
6252 err = dspio_set_uint_param(codec, ca0132_voicefx.mid, in ca0132_voicefx_put()
6260 spec->voicefx_val = sel; in ca0132_voicefx_put()
6262 ca0132_voicefx_set(codec, (sel ? 1 : 0)); in ca0132_voicefx_put()
6271 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_switch_get() local
6272 struct ca0132_spec *spec = codec->spec; in ca0132_switch_get()
6275 long *valp = ucontrol->value.integer.value; in ca0132_switch_get()
6280 *valp = spec->vnode_lswitch[nid - VNODE_START_NID]; in ca0132_switch_get()
6284 *valp = spec->vnode_rswitch[nid - VNODE_START_NID]; in ca0132_switch_get()
6292 *valp = spec->effects_switch[nid - EFFECT_START_NID]; in ca0132_switch_get()
6297 if (nid == spec->input_pins[0]) { in ca0132_switch_get()
6298 *valp = spec->cur_mic_boost; in ca0132_switch_get()
6303 *valp = spec->zxr_gain_set; in ca0132_switch_get()
6308 *valp = spec->speaker_range_val[nid - SPEAKER_FULL_RANGE_FRONT]; in ca0132_switch_get()
6313 *valp = spec->bass_redirection_val; in ca0132_switch_get()
6323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_switch_put() local
6324 struct ca0132_spec *spec = codec->spec; in ca0132_switch_put()
6327 long *valp = ucontrol->value.integer.value; in ca0132_switch_put()
6330 codec_dbg(codec, "ca0132_switch_put: nid=0x%x, val=%ld\n", in ca0132_switch_put()
6333 snd_hda_power_up(codec); in ca0132_switch_put()
6337 spec->vnode_lswitch[nid - VNODE_START_NID] = *valp; in ca0132_switch_put()
6341 spec->vnode_rswitch[nid - VNODE_START_NID] = *valp; in ca0132_switch_put()
6350 spec->effects_switch[nid - EFFECT_START_NID] = *valp; in ca0132_switch_put()
6351 changed = ca0132_pe_switch_set(codec); in ca0132_switch_put()
6357 spec->effects_switch[nid - EFFECT_START_NID] = *valp; in ca0132_switch_put()
6358 changed = ca0132_cvoice_switch_set(codec); in ca0132_switch_put()
6365 spec->effects_switch[nid - EFFECT_START_NID] = *valp; in ca0132_switch_put()
6366 changed = ca0132_effects_set(codec, nid, *valp); in ca0132_switch_put()
6371 if (nid == spec->input_pins[0]) { in ca0132_switch_put()
6372 spec->cur_mic_boost = *valp; in ca0132_switch_put()
6374 if (spec->in_enum_val != REAR_LINE_IN) in ca0132_switch_put()
6375 changed = ca0132_mic_boost_set(codec, *valp); in ca0132_switch_put()
6378 if (spec->cur_mic_type != DIGITAL_MIC) in ca0132_switch_put()
6379 changed = ca0132_mic_boost_set(codec, *valp); in ca0132_switch_put()
6386 spec->zxr_gain_set = *valp; in ca0132_switch_put()
6387 if (spec->cur_out_type == HEADPHONE_OUT) in ca0132_switch_put()
6388 changed = zxr_headphone_gain_set(codec, *valp); in ca0132_switch_put()
6396 spec->speaker_range_val[nid - SPEAKER_FULL_RANGE_FRONT] = *valp; in ca0132_switch_put()
6397 if (spec->cur_out_type == SPEAKER_OUT) in ca0132_switch_put()
6398 ca0132_alt_set_full_range_speaker(codec); in ca0132_switch_put()
6404 spec->bass_redirection_val = *valp; in ca0132_switch_put()
6405 if (spec->cur_out_type == SPEAKER_OUT) in ca0132_switch_put()
6406 ca0132_alt_surround_set_bass_redirection(codec, *valp); in ca0132_switch_put()
6412 snd_hda_power_down(codec); in ca0132_switch_put()
6424 static void ca0132_alt_dsp_volume_put(struct hda_codec *codec, hda_nid_t nid) in ca0132_alt_dsp_volume_put() argument
6426 struct ca0132_spec *spec = codec->spec; in ca0132_alt_dsp_volume_put()
6435 lookup_val = spec->vnode_lvol[nid - VNODE_START_NID]; in ca0132_alt_dsp_volume_put()
6437 dspio_set_uint_param(codec, in ca0132_alt_dsp_volume_put()
6442 lookup_val = spec->vnode_rvol[nid - VNODE_START_NID]; in ca0132_alt_dsp_volume_put()
6444 dspio_set_uint_param(codec, in ca0132_alt_dsp_volume_put()
6449 dspio_set_uint_param(codec, in ca0132_alt_dsp_volume_put()
6457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_info() local
6458 struct ca0132_spec *spec = codec->spec; in ca0132_volume_info()
6468 nid = spec->shared_out_nid; in ca0132_volume_info()
6469 mutex_lock(&codec->control_mutex); in ca0132_volume_info()
6470 pval = kcontrol->private_value; in ca0132_volume_info()
6471 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(nid, ch, 0, dir); in ca0132_volume_info()
6473 kcontrol->private_value = pval; in ca0132_volume_info()
6474 mutex_unlock(&codec->control_mutex); in ca0132_volume_info()
6478 nid = spec->shared_mic_nid; in ca0132_volume_info()
6479 mutex_lock(&codec->control_mutex); in ca0132_volume_info()
6480 pval = kcontrol->private_value; in ca0132_volume_info()
6481 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(nid, ch, 0, dir); in ca0132_volume_info()
6483 kcontrol->private_value = pval; in ca0132_volume_info()
6484 mutex_unlock(&codec->control_mutex); in ca0132_volume_info()
6495 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_get() local
6496 struct ca0132_spec *spec = codec->spec; in ca0132_volume_get()
6499 long *valp = ucontrol->value.integer.value; in ca0132_volume_get()
6503 *valp = spec->vnode_lvol[nid - VNODE_START_NID]; in ca0132_volume_get()
6507 *valp = spec->vnode_rvol[nid - VNODE_START_NID]; in ca0132_volume_get()
6516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_put() local
6517 struct ca0132_spec *spec = codec->spec; in ca0132_volume_put()
6520 long *valp = ucontrol->value.integer.value; in ca0132_volume_put()
6527 spec->vnode_lvol[nid - VNODE_START_NID] = *valp; in ca0132_volume_put()
6531 spec->vnode_rvol[nid - VNODE_START_NID] = *valp; in ca0132_volume_put()
6536 effective = ca0132_is_vnode_effective(codec, nid, &shared_nid); in ca0132_volume_put()
6541 snd_hda_power_up(codec); in ca0132_volume_put()
6542 mutex_lock(&codec->control_mutex); in ca0132_volume_put()
6543 pval = kcontrol->private_value; in ca0132_volume_put()
6544 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(shared_nid, ch, in ca0132_volume_put()
6547 kcontrol->private_value = pval; in ca0132_volume_put()
6548 mutex_unlock(&codec->control_mutex); in ca0132_volume_put()
6549 snd_hda_power_down(codec); in ca0132_volume_put()
6563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_volume_put() local
6564 struct ca0132_spec *spec = codec->spec; in ca0132_alt_volume_put()
6567 long *valp = ucontrol->value.integer.value; in ca0132_alt_volume_put()
6582 spec->vnode_lvol[vnid - VNODE_START_NID] = *valp; in ca0132_alt_volume_put()
6586 spec->vnode_rvol[vnid - VNODE_START_NID] = *valp; in ca0132_alt_volume_put()
6590 snd_hda_power_up(codec); in ca0132_alt_volume_put()
6591 ca0132_alt_dsp_volume_put(codec, vnid); in ca0132_alt_volume_put()
6592 mutex_lock(&codec->control_mutex); in ca0132_alt_volume_put()
6594 mutex_unlock(&codec->control_mutex); in ca0132_alt_volume_put()
6595 snd_hda_power_down(codec); in ca0132_alt_volume_put()
6603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_tlv() local
6604 struct ca0132_spec *spec = codec->spec; in ca0132_volume_tlv()
6614 nid = spec->shared_out_nid; in ca0132_volume_tlv()
6615 mutex_lock(&codec->control_mutex); in ca0132_volume_tlv()
6616 pval = kcontrol->private_value; in ca0132_volume_tlv()
6617 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(nid, ch, 0, dir); in ca0132_volume_tlv()
6619 kcontrol->private_value = pval; in ca0132_volume_tlv()
6620 mutex_unlock(&codec->control_mutex); in ca0132_volume_tlv()
6624 nid = spec->shared_mic_nid; in ca0132_volume_tlv()
6625 mutex_lock(&codec->control_mutex); in ca0132_volume_tlv()
6626 pval = kcontrol->private_value; in ca0132_volume_tlv()
6627 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(nid, ch, 0, dir); in ca0132_volume_tlv()
6629 kcontrol->private_value = pval; in ca0132_volume_tlv()
6630 mutex_unlock(&codec->control_mutex); in ca0132_volume_tlv()
6639 static int ca0132_alt_add_effect_slider(struct hda_codec *codec, hda_nid_t nid, in ca0132_alt_add_effect_slider() argument
6666 return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); in ca0132_alt_add_effect_slider()
6674 static int add_fx_switch(struct hda_codec *codec, hda_nid_t nid, in add_fx_switch() argument
6677 struct ca0132_spec *spec = codec->spec; in add_fx_switch()
6690 return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); in add_fx_switch()
6693 static int add_voicefx(struct hda_codec *codec) in add_voicefx() argument
6701 return snd_hda_ctl_add(codec, VOICEFX, snd_ctl_new1(&knew, codec)); in add_voicefx()
6705 static int add_ca0132_alt_eq_presets(struct hda_codec *codec) in add_ca0132_alt_eq_presets() argument
6713 return snd_hda_ctl_add(codec, EQ_PRESET_ENUM, in add_ca0132_alt_eq_presets()
6714 snd_ctl_new1(&knew, codec)); in add_ca0132_alt_eq_presets()
6722 static int ca0132_alt_add_svm_enum(struct hda_codec *codec) in ca0132_alt_add_svm_enum() argument
6730 return snd_hda_ctl_add(codec, SMART_VOLUME_ENUM, in ca0132_alt_add_svm_enum()
6731 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_svm_enum()
6739 static int ca0132_alt_add_output_enum(struct hda_codec *codec) in ca0132_alt_add_output_enum() argument
6747 return snd_hda_ctl_add(codec, OUTPUT_SOURCE_ENUM, in ca0132_alt_add_output_enum()
6748 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_output_enum()
6756 static int ca0132_alt_add_speaker_channel_cfg_enum(struct hda_codec *codec) in ca0132_alt_add_speaker_channel_cfg_enum() argument
6764 return snd_hda_ctl_add(codec, SPEAKER_CHANNEL_CFG_ENUM, in ca0132_alt_add_speaker_channel_cfg_enum()
6765 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_speaker_channel_cfg_enum()
6773 static int ca0132_alt_add_front_full_range_switch(struct hda_codec *codec) in ca0132_alt_add_front_full_range_switch() argument
6776 CA0132_CODEC_MUTE_MONO("Full-Range Front Speakers", in ca0132_alt_add_front_full_range_switch()
6779 return snd_hda_ctl_add(codec, SPEAKER_FULL_RANGE_FRONT, in ca0132_alt_add_front_full_range_switch()
6780 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_front_full_range_switch()
6783 static int ca0132_alt_add_rear_full_range_switch(struct hda_codec *codec) in ca0132_alt_add_rear_full_range_switch() argument
6786 CA0132_CODEC_MUTE_MONO("Full-Range Rear Speakers", in ca0132_alt_add_rear_full_range_switch()
6789 return snd_hda_ctl_add(codec, SPEAKER_FULL_RANGE_REAR, in ca0132_alt_add_rear_full_range_switch()
6790 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_rear_full_range_switch()
6795 * channel on speakers that are set as not being full-range. On configurations
6797 * replacement for X-Bass on configurations with an LFE channel.
6799 static int ca0132_alt_add_bass_redirection_crossover(struct hda_codec *codec) in ca0132_alt_add_bass_redirection_crossover() argument
6811 return snd_hda_ctl_add(codec, BASS_REDIRECTION_XOVER, in ca0132_alt_add_bass_redirection_crossover()
6812 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_bass_redirection_crossover()
6815 static int ca0132_alt_add_bass_redirection_switch(struct hda_codec *codec) in ca0132_alt_add_bass_redirection_switch() argument
6822 return snd_hda_ctl_add(codec, BASS_REDIRECTION, in ca0132_alt_add_bass_redirection_switch()
6823 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_bass_redirection_switch()
6828 * because the front microphone has no auto-detect, and Line-in has to be set
6831 static int ca0132_alt_add_input_enum(struct hda_codec *codec) in ca0132_alt_add_input_enum() argument
6839 return snd_hda_ctl_add(codec, INPUT_SOURCE_ENUM, in ca0132_alt_add_input_enum()
6840 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_input_enum()
6845 * more control than the original mic boost, which is either full 30dB or off.
6847 static int ca0132_alt_add_mic_boost_enum(struct hda_codec *codec) in ca0132_alt_add_mic_boost_enum() argument
6855 return snd_hda_ctl_add(codec, MIC_BOOST_ENUM, in ca0132_alt_add_mic_boost_enum()
6856 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_mic_boost_enum()
6861 * Add headphone gain enumerated control for the AE-5. This switches between
6862 * three modes, low, medium, and high. When non-headphone outputs are selected,
6865 static int ae5_add_headphone_gain_enum(struct hda_codec *codec) in ae5_add_headphone_gain_enum() argument
6868 HDA_CODEC_MUTE_MONO("AE-5: Headphone Gain", in ae5_add_headphone_gain_enum()
6873 return snd_hda_ctl_add(codec, AE5_HEADPHONE_GAIN_ENUM, in ae5_add_headphone_gain_enum()
6874 snd_ctl_new1(&knew, codec)); in ae5_add_headphone_gain_enum()
6878 * Add sound filter enumerated control for the AE-5. This adds three different
6879 * settings: Slow Roll Off, Minimum Phase, and Fast Roll Off. From what I've
6882 static int ae5_add_sound_filter_enum(struct hda_codec *codec) in ae5_add_sound_filter_enum() argument
6885 HDA_CODEC_MUTE_MONO("AE-5: Sound Filter", in ae5_add_sound_filter_enum()
6890 return snd_hda_ctl_add(codec, AE5_SOUND_FILTER_ENUM, in ae5_add_sound_filter_enum()
6891 snd_ctl_new1(&knew, codec)); in ae5_add_sound_filter_enum()
6894 static int zxr_add_headphone_gain_switch(struct hda_codec *codec) in zxr_add_headphone_gain_switch() argument
6900 return snd_hda_ctl_add(codec, ZXR_HEADPHONE_GAIN, in zxr_add_headphone_gain_switch()
6901 snd_ctl_new1(&knew, codec)); in zxr_add_headphone_gain_switch()
6931 static void ca0132_alt_add_chmap_ctls(struct hda_codec *codec) in ca0132_alt_add_chmap_ctls() argument
6936 list_for_each_entry(pcm, &codec->pcm_list_head, list) { in ca0132_alt_add_chmap_ctls()
6938 &pcm->stream[SNDRV_PCM_STREAM_PLAYBACK]; in ca0132_alt_add_chmap_ctls()
6943 if (hinfo->channels_max == 6) { in ca0132_alt_add_chmap_ctls()
6944 err = snd_pcm_add_chmap_ctls(pcm->pcm, in ca0132_alt_add_chmap_ctls()
6946 elem, hinfo->channels_max, 0, &chmap); in ca0132_alt_add_chmap_ctls()
6948 codec_dbg(codec, "snd_pcm_add_chmap_ctls failed!"); in ca0132_alt_add_chmap_ctls()
6962 HDA_CODEC_VOLUME("Analog-Mic2 Capture Volume", 0x08, 0, HDA_INPUT),
6963 HDA_CODEC_MUTE("Analog-Mic2 Capture Switch", 0x08, 0, HDA_INPUT),
6966 CA0132_CODEC_MUTE_MONO("Mic1-Boost (30dB) Capture Switch",
6980 * Desktop specific control mixer. Removes auto-detect for mic, and adds
7024 static int ca0132_build_controls(struct hda_codec *codec) in ca0132_build_controls() argument
7026 struct ca0132_spec *spec = codec->spec; in ca0132_build_controls()
7031 for (i = 0; i < spec->num_mixers; i++) { in ca0132_build_controls()
7032 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); in ca0132_build_controls()
7038 snd_hda_set_vmaster_tlv(codec, spec->dacs[0], HDA_OUTPUT, in ca0132_build_controls()
7039 spec->tlv); in ca0132_build_controls()
7040 snd_hda_add_vmaster(codec, "Master Playback Volume", in ca0132_build_controls()
7041 spec->tlv, ca0132_alt_follower_pfxs, in ca0132_build_controls()
7043 err = __snd_hda_add_vmaster(codec, "Master Playback Switch", in ca0132_build_controls()
7046 true, 0, &spec->vmaster_mute.sw_kctl); in ca0132_build_controls()
7058 if (i == (ECHO_CANCELLATION - IN_EFFECT_START_NID + in ca0132_build_controls()
7063 err = add_fx_switch(codec, ca0132_effects[i].nid, in ca0132_build_controls()
7070 * If codec has use_alt_controls set to true, add effect level sliders, in ca0132_build_controls()
7075 err = ca0132_alt_add_svm_enum(codec); in ca0132_build_controls()
7079 err = add_ca0132_alt_eq_presets(codec); in ca0132_build_controls()
7083 err = add_fx_switch(codec, PLAY_ENHANCEMENT, in ca0132_build_controls()
7088 err = add_fx_switch(codec, CRYSTAL_VOICE, in ca0132_build_controls()
7093 num_sliders = OUT_EFFECTS_COUNT - 1; in ca0132_build_controls()
7095 err = ca0132_alt_add_effect_slider(codec, in ca0132_build_controls()
7103 err = ca0132_alt_add_effect_slider(codec, XBASS_XOVER, in ca0132_build_controls()
7104 "X-Bass Crossover", EFX_DIR_OUT); in ca0132_build_controls()
7109 err = add_fx_switch(codec, PLAY_ENHANCEMENT, in ca0132_build_controls()
7114 err = add_fx_switch(codec, CRYSTAL_VOICE, in ca0132_build_controls()
7119 err = add_voicefx(codec); in ca0132_build_controls()
7124 * If the codec uses alt_functions, you need the enumerated controls in ca0132_build_controls()
7129 err = ca0132_alt_add_output_enum(codec); in ca0132_build_controls()
7132 err = ca0132_alt_add_speaker_channel_cfg_enum(codec); in ca0132_build_controls()
7135 err = ca0132_alt_add_front_full_range_switch(codec); in ca0132_build_controls()
7138 err = ca0132_alt_add_rear_full_range_switch(codec); in ca0132_build_controls()
7141 err = ca0132_alt_add_bass_redirection_crossover(codec); in ca0132_build_controls()
7144 err = ca0132_alt_add_bass_redirection_switch(codec); in ca0132_build_controls()
7147 err = ca0132_alt_add_mic_boost_enum(codec); in ca0132_build_controls()
7152 * header on the card, and aux-in is handled by the DBPro board. in ca0132_build_controls()
7155 err = ca0132_alt_add_input_enum(codec); in ca0132_build_controls()
7164 err = ae5_add_headphone_gain_enum(codec); in ca0132_build_controls()
7167 err = ae5_add_sound_filter_enum(codec); in ca0132_build_controls()
7172 err = zxr_add_headphone_gain_switch(codec); in ca0132_build_controls()
7181 add_tuning_ctls(codec); in ca0132_build_controls()
7184 err = snd_hda_jack_add_kctls(codec, &spec->autocfg); in ca0132_build_controls()
7188 if (spec->dig_out) { in ca0132_build_controls()
7189 err = snd_hda_create_spdif_out_ctls(codec, spec->dig_out, in ca0132_build_controls()
7190 spec->dig_out); in ca0132_build_controls()
7193 err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); in ca0132_build_controls()
7196 /* spec->multiout.share_spdif = 1; */ in ca0132_build_controls()
7199 if (spec->dig_in) { in ca0132_build_controls()
7200 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in); in ca0132_build_controls()
7206 ca0132_alt_add_chmap_ctls(codec); in ca0132_build_controls()
7211 static int dbpro_build_controls(struct hda_codec *codec) in dbpro_build_controls() argument
7213 struct ca0132_spec *spec = codec->spec; in dbpro_build_controls()
7216 if (spec->dig_out) { in dbpro_build_controls()
7217 err = snd_hda_create_spdif_out_ctls(codec, spec->dig_out, in dbpro_build_controls()
7218 spec->dig_out); in dbpro_build_controls()
7223 if (spec->dig_in) { in dbpro_build_controls()
7224 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in); in dbpro_build_controls()
7275 static int ca0132_build_pcms(struct hda_codec *codec) in ca0132_build_pcms() argument
7277 struct ca0132_spec *spec = codec->spec; in ca0132_build_pcms()
7280 info = snd_hda_codec_pcm_new(codec, "CA0132 Analog"); in ca0132_build_pcms()
7282 return -ENOMEM; in ca0132_build_pcms()
7284 info->own_chmap = true; in ca0132_build_pcms()
7285 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap in ca0132_build_pcms()
7288 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ca0132_pcm_analog_playback; in ca0132_build_pcms()
7289 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dacs[0]; in ca0132_build_pcms()
7290 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = in ca0132_build_pcms()
7291 spec->multiout.max_channels; in ca0132_build_pcms()
7292 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ca0132_pcm_analog_capture; in ca0132_build_pcms()
7293 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 1; in ca0132_build_pcms()
7294 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adcs[0]; in ca0132_build_pcms()
7298 info = snd_hda_codec_pcm_new(codec, "CA0132 Analog Mic-In2"); in ca0132_build_pcms()
7300 return -ENOMEM; in ca0132_build_pcms()
7301 info->stream[SNDRV_PCM_STREAM_CAPTURE] = in ca0132_build_pcms()
7303 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 1; in ca0132_build_pcms()
7304 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adcs[1]; in ca0132_build_pcms()
7307 info = snd_hda_codec_pcm_new(codec, "CA0132 What U Hear"); in ca0132_build_pcms()
7309 return -ENOMEM; in ca0132_build_pcms()
7310 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ca0132_pcm_analog_capture; in ca0132_build_pcms()
7311 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 1; in ca0132_build_pcms()
7312 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adcs[2]; in ca0132_build_pcms()
7314 if (!spec->dig_out && !spec->dig_in) in ca0132_build_pcms()
7317 info = snd_hda_codec_pcm_new(codec, "CA0132 Digital"); in ca0132_build_pcms()
7319 return -ENOMEM; in ca0132_build_pcms()
7320 info->pcm_type = HDA_PCM_TYPE_SPDIF; in ca0132_build_pcms()
7321 if (spec->dig_out) { in ca0132_build_pcms()
7322 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = in ca0132_build_pcms()
7324 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dig_out; in ca0132_build_pcms()
7326 if (spec->dig_in) { in ca0132_build_pcms()
7327 info->stream[SNDRV_PCM_STREAM_CAPTURE] = in ca0132_build_pcms()
7329 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in; in ca0132_build_pcms()
7335 static int dbpro_build_pcms(struct hda_codec *codec) in dbpro_build_pcms() argument
7337 struct ca0132_spec *spec = codec->spec; in dbpro_build_pcms()
7340 info = snd_hda_codec_pcm_new(codec, "CA0132 Alt Analog"); in dbpro_build_pcms()
7342 return -ENOMEM; in dbpro_build_pcms()
7343 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ca0132_pcm_analog_capture; in dbpro_build_pcms()
7344 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 1; in dbpro_build_pcms()
7345 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adcs[0]; in dbpro_build_pcms()
7348 if (!spec->dig_out && !spec->dig_in) in dbpro_build_pcms()
7351 info = snd_hda_codec_pcm_new(codec, "CA0132 Digital"); in dbpro_build_pcms()
7353 return -ENOMEM; in dbpro_build_pcms()
7354 info->pcm_type = HDA_PCM_TYPE_SPDIF; in dbpro_build_pcms()
7355 if (spec->dig_out) { in dbpro_build_pcms()
7356 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = in dbpro_build_pcms()
7358 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dig_out; in dbpro_build_pcms()
7360 if (spec->dig_in) { in dbpro_build_pcms()
7361 info->stream[SNDRV_PCM_STREAM_CAPTURE] = in dbpro_build_pcms()
7363 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in; in dbpro_build_pcms()
7369 static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) in init_output() argument
7372 snd_hda_set_pin_ctl(codec, pin, PIN_HP); in init_output()
7373 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in init_output()
7374 snd_hda_codec_write(codec, pin, 0, in init_output()
7378 if (dac && (get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) in init_output()
7379 snd_hda_codec_write(codec, dac, 0, in init_output()
7383 static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) in init_input() argument
7386 snd_hda_set_pin_ctl(codec, pin, PIN_VREF80); in init_input()
7387 if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) in init_input()
7388 snd_hda_codec_write(codec, pin, 0, in init_input()
7392 if (adc && (get_wcaps(codec, adc) & AC_WCAP_IN_AMP)) { in init_input()
7393 snd_hda_codec_write(codec, adc, 0, AC_VERB_SET_AMP_GAIN_MUTE, in init_input()
7397 snd_hda_codec_amp_stereo(codec, adc, HDA_INPUT, 0, in init_input()
7399 snd_hda_codec_amp_stereo(codec, adc, HDA_INPUT, 0, in init_input()
7404 static void refresh_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir) in refresh_amp_caps() argument
7408 caps = snd_hda_param_read(codec, nid, dir == HDA_OUTPUT ? in refresh_amp_caps()
7410 snd_hda_override_amp_caps(codec, nid, dir, caps); in refresh_amp_caps()
7414 * Switch between Digital built-in mic and analog mic.
7416 static void ca0132_set_dmic(struct hda_codec *codec, int enable) in ca0132_set_dmic() argument
7418 struct ca0132_spec *spec = codec->spec; in ca0132_set_dmic()
7423 codec_dbg(codec, "ca0132_set_dmic: enable=%d\n", enable); in ca0132_set_dmic()
7425 oldval = stop_mic1(codec); in ca0132_set_dmic()
7426 ca0132_set_vipsource(codec, 0); in ca0132_set_dmic()
7428 /* set DMic input as 2-ch */ in ca0132_set_dmic()
7430 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_dmic()
7432 val = spec->dmic_ctl; in ca0132_set_dmic()
7434 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_set_dmic()
7437 if (!(spec->dmic_ctl & 0x20)) in ca0132_set_dmic()
7438 chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 1); in ca0132_set_dmic()
7442 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_dmic()
7444 val = spec->dmic_ctl; in ca0132_set_dmic()
7447 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_set_dmic()
7450 if (!(spec->dmic_ctl & 0x20)) in ca0132_set_dmic()
7451 chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 0); in ca0132_set_dmic()
7453 ca0132_set_vipsource(codec, 1); in ca0132_set_dmic()
7454 resume_mic1(codec, oldval); in ca0132_set_dmic()
7460 static void ca0132_init_dmic(struct hda_codec *codec) in ca0132_init_dmic() argument
7462 struct ca0132_spec *spec = codec->spec; in ca0132_init_dmic()
7470 * Bit 2-0: MPIO select in ca0132_init_dmic()
7472 * Bit 7-4: reserved in ca0132_init_dmic()
7475 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_init_dmic()
7479 * Bit 2-0: Data1 MPIO select in ca0132_init_dmic()
7481 * Bit 6-4: Data2 MPIO select in ca0132_init_dmic()
7485 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_init_dmic()
7488 /* Use Ch-0 and Ch-1. Rate is 48K, mode 1. Disable DMic first. in ca0132_init_dmic()
7489 * Bit 3-0: Channel mask in ca0132_init_dmic()
7500 spec->dmic_ctl = val; in ca0132_init_dmic()
7501 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_init_dmic()
7508 static void ca0132_init_analog_mic2(struct hda_codec *codec) in ca0132_init_analog_mic2() argument
7510 struct ca0132_spec *spec = codec->spec; in ca0132_init_analog_mic2()
7512 mutex_lock(&spec->chipio_mutex); in ca0132_init_analog_mic2()
7514 chipio_8051_write_exram_no_mutex(codec, 0x1920, 0x00); in ca0132_init_analog_mic2()
7515 chipio_8051_write_exram_no_mutex(codec, 0x192d, 0x00); in ca0132_init_analog_mic2()
7517 mutex_unlock(&spec->chipio_mutex); in ca0132_init_analog_mic2()
7520 static void ca0132_refresh_widget_caps(struct hda_codec *codec) in ca0132_refresh_widget_caps() argument
7522 struct ca0132_spec *spec = codec->spec; in ca0132_refresh_widget_caps()
7525 codec_dbg(codec, "ca0132_refresh_widget_caps.\n"); in ca0132_refresh_widget_caps()
7526 snd_hda_codec_update_widgets(codec); in ca0132_refresh_widget_caps()
7528 for (i = 0; i < spec->multiout.num_dacs; i++) in ca0132_refresh_widget_caps()
7529 refresh_amp_caps(codec, spec->dacs[i], HDA_OUTPUT); in ca0132_refresh_widget_caps()
7531 for (i = 0; i < spec->num_outputs; i++) in ca0132_refresh_widget_caps()
7532 refresh_amp_caps(codec, spec->out_pins[i], HDA_OUTPUT); in ca0132_refresh_widget_caps()
7534 for (i = 0; i < spec->num_inputs; i++) { in ca0132_refresh_widget_caps()
7535 refresh_amp_caps(codec, spec->adcs[i], HDA_INPUT); in ca0132_refresh_widget_caps()
7536 refresh_amp_caps(codec, spec->input_pins[i], HDA_INPUT); in ca0132_refresh_widget_caps()
7542 static void ca0132_alt_free_active_dma_channels(struct hda_codec *codec) in ca0132_alt_free_active_dma_channels() argument
7548 status = chipio_read(codec, DSPDMAC_CHNLSTART_MODULE_OFFSET, &tmp); in ca0132_alt_free_active_dma_channels()
7557 codec_dbg(codec, "%s: Failed to read active DSP DMA channel register.\n", in ca0132_alt_free_active_dma_channels()
7567 if (dsp_is_dma_active(codec, i)) { in ca0132_alt_free_active_dma_channels()
7568 status = dspio_free_dma_chan(codec, i); in ca0132_alt_free_active_dma_channels()
7570 codec_dbg(codec, "%s: Failed to free active DSP DMA channel %d.\n", in ca0132_alt_free_active_dma_channels()
7581 * cause of most of the no-audio on startup issues were due to improperly
7597 static void ca0132_alt_start_dsp_audio_streams(struct hda_codec *codec) in ca0132_alt_start_dsp_audio_streams() argument
7600 struct ca0132_spec *spec = codec->spec; in ca0132_alt_start_dsp_audio_streams()
7607 mutex_lock(&spec->chipio_mutex); in ca0132_alt_start_dsp_audio_streams()
7610 chipio_get_stream_control(codec, dsp_dma_stream_ids[i], &tmp); in ca0132_alt_start_dsp_audio_streams()
7613 chipio_set_stream_control(codec, in ca0132_alt_start_dsp_audio_streams()
7618 mutex_unlock(&spec->chipio_mutex); in ca0132_alt_start_dsp_audio_streams()
7625 ca0132_alt_free_active_dma_channels(codec); in ca0132_alt_start_dsp_audio_streams()
7627 mutex_lock(&spec->chipio_mutex); in ca0132_alt_start_dsp_audio_streams()
7630 chipio_set_stream_channels(codec, 0x0c, 6); in ca0132_alt_start_dsp_audio_streams()
7633 chipio_set_stream_control(codec, in ca0132_alt_start_dsp_audio_streams()
7640 mutex_unlock(&spec->chipio_mutex); in ca0132_alt_start_dsp_audio_streams()
7644 * The region of ChipIO memory from 0x190000-0x1903fc is a sort of 'audio
7646 * of an 8-bit destination, an 8-bit source, and an unknown 2-bit number
7647 * value. The 2-bit number value is seemingly 0 if inactive, 1 if active,
7654 * the region of exram memory from 0x1477-0x1575 has each byte represent an
7667 * 0x00-0x1f: HDA audio stream input/output ports.
7668 * 0x80-0xbf: Sample rate converter input/outputs. Only valid ports seem to
7669 * have the lower-nibble set to 0x1, 0x2, and 0x9.
7670 * 0xc0-0xdf: DSP DMA input/output ports. Dynamically assigned.
7671 * 0xe0-0xff: DAC/ADC audio input/output ports.
7687 static void chipio_remap_stream(struct hda_codec *codec, in chipio_remap_stream() argument
7693 chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id, in chipio_remap_stream()
7705 chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id, in chipio_remap_stream()
7714 codec_info(codec, "%s: Stream 0x%02x ports aren't allocated, remap failed!\n", in chipio_remap_stream()
7715 __func__, remap_data->stream_id); in chipio_remap_stream()
7719 /* Offset isn't in bytes, its in 32-bit words, so multiply it by 4. */ in chipio_remap_stream()
7723 for (i = 0; i < remap_data->count; i++) { in chipio_remap_stream()
7724 chipio_write_no_mutex(codec, in chipio_remap_stream()
7725 stream_offset + remap_data->offset[i], in chipio_remap_stream()
7726 remap_data->value[i]); in chipio_remap_stream()
7730 chipio_write_no_mutex(codec, 0x19042c, 0x00000001); in chipio_remap_stream()
7737 /* Non-zero values are floating point 0.000198. */
7742 /* Non-zero values are floating point 0.000220. */
7747 /* Non-zero values are floating point 0.000100. */
7754 static void ca0132_alt_init_speaker_tuning(struct hda_codec *codec) in ca0132_alt_init_speaker_tuning() argument
7756 struct ca0132_spec *spec = codec->spec; in ca0132_alt_init_speaker_tuning()
7777 dspio_set_uint_param(codec, 0x96, SPEAKER_TUNING_ENABLE_CENTER_EQ, tmp); in ca0132_alt_init_speaker_tuning()
7782 dspio_set_uint_param(codec, 0x96, i, tmp); in ca0132_alt_init_speaker_tuning()
7787 dspio_set_uint_param(codec, 0x96, i, tmp); in ca0132_alt_init_speaker_tuning()
7791 dspio_set_uint_param(codec, 0x96, in ca0132_alt_init_speaker_tuning()
7796 * Initialize mic for non-chromebook ca0132 implementations.
7798 static void ca0132_alt_init_analog_mics(struct hda_codec *codec) in ca0132_alt_init_analog_mics() argument
7800 struct ca0132_spec *spec = codec->spec; in ca0132_alt_init_analog_mics()
7804 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_init_analog_mics()
7805 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_init_analog_mics()
7807 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_init_analog_mics()
7811 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_init_analog_mics()
7814 chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, SR_96_000); in ca0132_alt_init_analog_mics()
7815 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, SR_96_000); in ca0132_alt_init_analog_mics()
7817 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_init_analog_mics()
7819 dspio_set_uint_param(codec, 0x80, 0x01, tmp); in ca0132_alt_init_analog_mics()
7828 static void sbz_connect_streams(struct hda_codec *codec) in sbz_connect_streams() argument
7830 struct ca0132_spec *spec = codec->spec; in sbz_connect_streams()
7832 mutex_lock(&spec->chipio_mutex); in sbz_connect_streams()
7834 codec_dbg(codec, "Connect Streams entered, mutex locked and loaded.\n"); in sbz_connect_streams()
7837 chipio_write_no_mutex(codec, 0x18a020, 0x00000043); in sbz_connect_streams()
7840 chipio_set_stream_source_dest(codec, 0x14, 0x48, 0x91); in sbz_connect_streams()
7841 chipio_set_conn_rate_no_mutex(codec, 0x48, SR_96_000); in sbz_connect_streams()
7842 chipio_set_conn_rate_no_mutex(codec, 0x91, SR_96_000); in sbz_connect_streams()
7843 chipio_set_stream_channels(codec, 0x14, 2); in sbz_connect_streams()
7844 chipio_set_stream_control(codec, 0x14, 1); in sbz_connect_streams()
7846 codec_dbg(codec, "Connect Streams exited, mutex released.\n"); in sbz_connect_streams()
7848 mutex_unlock(&spec->chipio_mutex); in sbz_connect_streams()
7857 static void sbz_chipio_startup_data(struct hda_codec *codec) in sbz_chipio_startup_data() argument
7860 struct ca0132_spec *spec = codec->spec; in sbz_chipio_startup_data()
7862 mutex_lock(&spec->chipio_mutex); in sbz_chipio_startup_data()
7863 codec_dbg(codec, "Startup Data entered, mutex locked and loaded.\n"); in sbz_chipio_startup_data()
7866 chipio_remap_stream(codec, &stream_remap_data[0]); in sbz_chipio_startup_data()
7884 chipio_remap_stream(codec, dsp_out_remap_data); in sbz_chipio_startup_data()
7886 codec_dbg(codec, "Startup Data exited, mutex released.\n"); in sbz_chipio_startup_data()
7887 mutex_unlock(&spec->chipio_mutex); in sbz_chipio_startup_data()
7890 static void ca0132_alt_dsp_initial_mic_setup(struct hda_codec *codec) in ca0132_alt_dsp_initial_mic_setup() argument
7892 struct ca0132_spec *spec = codec->spec; in ca0132_alt_dsp_initial_mic_setup()
7895 chipio_set_stream_control(codec, 0x03, 0); in ca0132_alt_dsp_initial_mic_setup()
7896 chipio_set_stream_control(codec, 0x04, 0); in ca0132_alt_dsp_initial_mic_setup()
7898 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_dsp_initial_mic_setup()
7899 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_dsp_initial_mic_setup()
7902 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_dsp_initial_mic_setup()
7904 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_dsp_initial_mic_setup()
7905 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_dsp_initial_mic_setup()
7909 chipio_write(codec, 0x18b098, 0x0000000c); in ca0132_alt_dsp_initial_mic_setup()
7910 chipio_write(codec, 0x18b09C, 0x0000000c); in ca0132_alt_dsp_initial_mic_setup()
7913 chipio_write(codec, 0x18b098, 0x0000000c); in ca0132_alt_dsp_initial_mic_setup()
7914 chipio_write(codec, 0x18b09c, 0x0000004c); in ca0132_alt_dsp_initial_mic_setup()
7921 static void ae5_post_dsp_register_set(struct hda_codec *codec) in ae5_post_dsp_register_set() argument
7923 struct ca0132_spec *spec = codec->spec; in ae5_post_dsp_register_set()
7925 chipio_8051_write_direct(codec, 0x93, 0x10); in ae5_post_dsp_register_set()
7926 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); in ae5_post_dsp_register_set()
7928 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7929 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7930 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7931 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7932 writeb(0x00, spec->mem_base + 0x100); in ae5_post_dsp_register_set()
7933 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7934 writeb(0x00, spec->mem_base + 0x100); in ae5_post_dsp_register_set()
7935 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7936 writeb(0x00, spec->mem_base + 0x100); in ae5_post_dsp_register_set()
7937 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7938 writeb(0x00, spec->mem_base + 0x100); in ae5_post_dsp_register_set()
7939 writeb(0xff, spec->mem_base + 0x304); in ae5_post_dsp_register_set()
7941 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x3f); in ae5_post_dsp_register_set()
7942 ca0113_mmio_command_set(codec, 0x30, 0x2d, 0x3f); in ae5_post_dsp_register_set()
7943 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_post_dsp_register_set()
7946 static void ae5_post_dsp_param_setup(struct hda_codec *codec) in ae5_post_dsp_param_setup() argument
7951 * AE-5's registry values in Windows. in ae5_post_dsp_param_setup()
7953 chipio_set_control_param(codec, 3, 0); in ae5_post_dsp_param_setup()
7956 * change colors on the external LED strip connected to the AE-5. in ae5_post_dsp_param_setup()
7958 chipio_set_control_flag(codec, CONTROL_FLAG_ASI_96KHZ, 1); in ae5_post_dsp_param_setup()
7960 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x724, 0x83); in ae5_post_dsp_param_setup()
7961 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae5_post_dsp_param_setup()
7963 chipio_8051_write_exram(codec, 0xfa92, 0x22); in ae5_post_dsp_param_setup()
7966 static void ae5_post_dsp_pll_setup(struct hda_codec *codec) in ae5_post_dsp_pll_setup() argument
7968 chipio_8051_write_pll_pmu(codec, 0x41, 0xc8); in ae5_post_dsp_pll_setup()
7969 chipio_8051_write_pll_pmu(codec, 0x45, 0xcc); in ae5_post_dsp_pll_setup()
7970 chipio_8051_write_pll_pmu(codec, 0x40, 0xcb); in ae5_post_dsp_pll_setup()
7971 chipio_8051_write_pll_pmu(codec, 0x43, 0xc7); in ae5_post_dsp_pll_setup()
7972 chipio_8051_write_pll_pmu(codec, 0x51, 0x8d); in ae5_post_dsp_pll_setup()
7975 static void ae5_post_dsp_stream_setup(struct hda_codec *codec) in ae5_post_dsp_stream_setup() argument
7977 struct ca0132_spec *spec = codec->spec; in ae5_post_dsp_stream_setup()
7979 mutex_lock(&spec->chipio_mutex); in ae5_post_dsp_stream_setup()
7981 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x81); in ae5_post_dsp_stream_setup()
7983 chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000); in ae5_post_dsp_stream_setup()
7985 chipio_set_stream_source_dest(codec, 0x5, 0x43, 0x0); in ae5_post_dsp_stream_setup()
7987 chipio_set_stream_source_dest(codec, 0x18, 0x9, 0xd0); in ae5_post_dsp_stream_setup()
7988 chipio_set_conn_rate_no_mutex(codec, 0xd0, SR_96_000); in ae5_post_dsp_stream_setup()
7989 chipio_set_stream_channels(codec, 0x18, 6); in ae5_post_dsp_stream_setup()
7990 chipio_set_stream_control(codec, 0x18, 1); in ae5_post_dsp_stream_setup()
7992 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 4); in ae5_post_dsp_stream_setup()
7994 chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7); in ae5_post_dsp_stream_setup()
7996 ca0113_mmio_command_set(codec, 0x48, 0x01, 0x80); in ae5_post_dsp_stream_setup()
7998 mutex_unlock(&spec->chipio_mutex); in ae5_post_dsp_stream_setup()
8001 static void ae5_post_dsp_startup_data(struct hda_codec *codec) in ae5_post_dsp_startup_data() argument
8003 struct ca0132_spec *spec = codec->spec; in ae5_post_dsp_startup_data()
8005 mutex_lock(&spec->chipio_mutex); in ae5_post_dsp_startup_data()
8007 chipio_write_no_mutex(codec, 0x189000, 0x0001f101); in ae5_post_dsp_startup_data()
8008 chipio_write_no_mutex(codec, 0x189004, 0x0001f101); in ae5_post_dsp_startup_data()
8009 chipio_write_no_mutex(codec, 0x189024, 0x00014004); in ae5_post_dsp_startup_data()
8010 chipio_write_no_mutex(codec, 0x189028, 0x0002000f); in ae5_post_dsp_startup_data()
8012 ca0113_mmio_command_set(codec, 0x48, 0x0a, 0x05); in ae5_post_dsp_startup_data()
8013 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 7); in ae5_post_dsp_startup_data()
8014 ca0113_mmio_command_set(codec, 0x48, 0x0b, 0x12); in ae5_post_dsp_startup_data()
8015 ca0113_mmio_command_set(codec, 0x48, 0x04, 0x00); in ae5_post_dsp_startup_data()
8016 ca0113_mmio_command_set(codec, 0x48, 0x06, 0x48); in ae5_post_dsp_startup_data()
8017 ca0113_mmio_command_set(codec, 0x48, 0x0a, 0x05); in ae5_post_dsp_startup_data()
8018 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_post_dsp_startup_data()
8019 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae5_post_dsp_startup_data()
8020 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae5_post_dsp_startup_data()
8021 ca0113_mmio_gpio_set(codec, 0, true); in ae5_post_dsp_startup_data()
8022 ca0113_mmio_gpio_set(codec, 1, true); in ae5_post_dsp_startup_data()
8023 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x80); in ae5_post_dsp_startup_data()
8025 chipio_write_no_mutex(codec, 0x18b03c, 0x00000012); in ae5_post_dsp_startup_data()
8027 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae5_post_dsp_startup_data()
8028 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae5_post_dsp_startup_data()
8030 mutex_unlock(&spec->chipio_mutex); in ae5_post_dsp_startup_data()
8033 static void ae7_post_dsp_setup_ports(struct hda_codec *codec) in ae7_post_dsp_setup_ports() argument
8035 struct ca0132_spec *spec = codec->spec; in ae7_post_dsp_setup_ports()
8037 mutex_lock(&spec->chipio_mutex); in ae7_post_dsp_setup_ports()
8040 chipio_remap_stream(codec, &stream_remap_data[1]); in ae7_post_dsp_setup_ports()
8042 ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00); in ae7_post_dsp_setup_ports()
8043 ca0113_mmio_command_set(codec, 0x48, 0x0d, 0x40); in ae7_post_dsp_setup_ports()
8044 ca0113_mmio_command_set(codec, 0x48, 0x17, 0x00); in ae7_post_dsp_setup_ports()
8045 ca0113_mmio_command_set(codec, 0x48, 0x19, 0x00); in ae7_post_dsp_setup_ports()
8046 ca0113_mmio_command_set(codec, 0x48, 0x11, 0xff); in ae7_post_dsp_setup_ports()
8047 ca0113_mmio_command_set(codec, 0x48, 0x12, 0xff); in ae7_post_dsp_setup_ports()
8048 ca0113_mmio_command_set(codec, 0x48, 0x13, 0xff); in ae7_post_dsp_setup_ports()
8049 ca0113_mmio_command_set(codec, 0x48, 0x14, 0x7f); in ae7_post_dsp_setup_ports()
8051 mutex_unlock(&spec->chipio_mutex); in ae7_post_dsp_setup_ports()
8054 static void ae7_post_dsp_asi_stream_setup(struct hda_codec *codec) in ae7_post_dsp_asi_stream_setup() argument
8056 struct ca0132_spec *spec = codec->spec; in ae7_post_dsp_asi_stream_setup()
8058 mutex_lock(&spec->chipio_mutex); in ae7_post_dsp_asi_stream_setup()
8060 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x81); in ae7_post_dsp_asi_stream_setup()
8061 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x00); in ae7_post_dsp_asi_stream_setup()
8063 chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000); in ae7_post_dsp_asi_stream_setup()
8065 chipio_set_stream_source_dest(codec, 0x05, 0x43, 0x00); in ae7_post_dsp_asi_stream_setup()
8066 chipio_set_stream_source_dest(codec, 0x18, 0x09, 0xd0); in ae7_post_dsp_asi_stream_setup()
8068 chipio_set_conn_rate_no_mutex(codec, 0xd0, SR_96_000); in ae7_post_dsp_asi_stream_setup()
8069 chipio_set_stream_channels(codec, 0x18, 6); in ae7_post_dsp_asi_stream_setup()
8070 chipio_set_stream_control(codec, 0x18, 1); in ae7_post_dsp_asi_stream_setup()
8072 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 4); in ae7_post_dsp_asi_stream_setup()
8074 mutex_unlock(&spec->chipio_mutex); in ae7_post_dsp_asi_stream_setup()
8077 static void ae7_post_dsp_pll_setup(struct hda_codec *codec) in ae7_post_dsp_pll_setup() argument
8088 chipio_8051_write_pll_pmu_no_mutex(codec, addr[i], data[i]); in ae7_post_dsp_pll_setup()
8091 static void ae7_post_dsp_asi_setup_ports(struct hda_codec *codec) in ae7_post_dsp_asi_setup_ports() argument
8093 struct ca0132_spec *spec = codec->spec; in ae7_post_dsp_asi_setup_ports()
8102 mutex_lock(&spec->chipio_mutex); in ae7_post_dsp_asi_setup_ports()
8104 chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7); in ae7_post_dsp_asi_setup_ports()
8106 chipio_write_no_mutex(codec, 0x189000, 0x0001f101); in ae7_post_dsp_asi_setup_ports()
8107 chipio_write_no_mutex(codec, 0x189004, 0x0001f101); in ae7_post_dsp_asi_setup_ports()
8108 chipio_write_no_mutex(codec, 0x189024, 0x00014004); in ae7_post_dsp_asi_setup_ports()
8109 chipio_write_no_mutex(codec, 0x189028, 0x0002000f); in ae7_post_dsp_asi_setup_ports()
8111 ae7_post_dsp_pll_setup(codec); in ae7_post_dsp_asi_setup_ports()
8112 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 7); in ae7_post_dsp_asi_setup_ports()
8115 ca0113_mmio_command_set(codec, 0x48, target[i], data[i]); in ae7_post_dsp_asi_setup_ports()
8117 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_post_dsp_asi_setup_ports()
8118 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae7_post_dsp_asi_setup_ports()
8119 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae7_post_dsp_asi_setup_ports()
8121 chipio_set_stream_source_dest(codec, 0x21, 0x64, 0x56); in ae7_post_dsp_asi_setup_ports()
8122 chipio_set_stream_channels(codec, 0x21, 2); in ae7_post_dsp_asi_setup_ports()
8123 chipio_set_conn_rate_no_mutex(codec, 0x56, SR_8_000); in ae7_post_dsp_asi_setup_ports()
8125 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_NODE_ID, 0x09); in ae7_post_dsp_asi_setup_ports()
8131 chipio_set_control_param_no_mutex(codec, 0x20, 0x21); in ae7_post_dsp_asi_setup_ports()
8133 chipio_write_no_mutex(codec, 0x18b038, 0x00000088); in ae7_post_dsp_asi_setup_ports()
8139 * know what data is being sent. Interestingly, the AE-5 seems to go in ae7_post_dsp_asi_setup_ports()
8141 * step, but the AE-7 does. in ae7_post_dsp_asi_setup_ports()
8144 ca0113_mmio_gpio_set(codec, 0, 1); in ae7_post_dsp_asi_setup_ports()
8145 ca0113_mmio_gpio_set(codec, 1, 1); in ae7_post_dsp_asi_setup_ports()
8147 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_post_dsp_asi_setup_ports()
8148 chipio_write_no_mutex(codec, 0x18b03c, 0x00000000); in ae7_post_dsp_asi_setup_ports()
8149 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae7_post_dsp_asi_setup_ports()
8150 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae7_post_dsp_asi_setup_ports()
8152 chipio_set_stream_source_dest(codec, 0x05, 0x43, 0x00); in ae7_post_dsp_asi_setup_ports()
8153 chipio_set_stream_source_dest(codec, 0x18, 0x09, 0xd0); in ae7_post_dsp_asi_setup_ports()
8155 chipio_set_conn_rate_no_mutex(codec, 0xd0, SR_96_000); in ae7_post_dsp_asi_setup_ports()
8156 chipio_set_stream_channels(codec, 0x18, 6); in ae7_post_dsp_asi_setup_ports()
8162 ae7_post_dsp_pll_setup(codec); in ae7_post_dsp_asi_setup_ports()
8163 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 7); in ae7_post_dsp_asi_setup_ports()
8165 mutex_unlock(&spec->chipio_mutex); in ae7_post_dsp_asi_setup_ports()
8173 static void ae7_post_dsp_asi_setup(struct hda_codec *codec) in ae7_post_dsp_asi_setup() argument
8175 chipio_8051_write_direct(codec, 0x93, 0x10); in ae7_post_dsp_asi_setup()
8177 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); in ae7_post_dsp_asi_setup()
8179 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_post_dsp_asi_setup()
8180 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae7_post_dsp_asi_setup()
8182 chipio_set_control_param(codec, 3, 3); in ae7_post_dsp_asi_setup()
8183 chipio_set_control_flag(codec, CONTROL_FLAG_ASI_96KHZ, 1); in ae7_post_dsp_asi_setup()
8185 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x724, 0x83); in ae7_post_dsp_asi_setup()
8186 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae7_post_dsp_asi_setup()
8187 snd_hda_codec_write(codec, 0x17, 0, 0x794, 0x00); in ae7_post_dsp_asi_setup()
8189 chipio_8051_write_exram(codec, 0xfa92, 0x22); in ae7_post_dsp_asi_setup()
8191 ae7_post_dsp_pll_setup(codec); in ae7_post_dsp_asi_setup()
8192 ae7_post_dsp_asi_stream_setup(codec); in ae7_post_dsp_asi_setup()
8194 chipio_8051_write_pll_pmu(codec, 0x43, 0xc7); in ae7_post_dsp_asi_setup()
8196 ae7_post_dsp_asi_setup_ports(codec); in ae7_post_dsp_asi_setup()
8202 static void ca0132_setup_defaults(struct hda_codec *codec) in ca0132_setup_defaults() argument
8204 struct ca0132_spec *spec = codec->spec; in ca0132_setup_defaults()
8209 if (spec->dsp_state != DSP_DOWNLOADED) in ca0132_setup_defaults()
8216 dspio_set_uint_param(codec, ca0132_effects[idx].mid, in ca0132_setup_defaults()
8224 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in ca0132_setup_defaults()
8227 dspio_set_uint_param(codec, 0x8f, 0x01, tmp); in ca0132_setup_defaults()
8231 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_setup_defaults()
8232 dspio_set_uint_param(codec, 0x80, 0x01, tmp); in ca0132_setup_defaults()
8236 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_setup_defaults()
8240 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in ca0132_setup_defaults()
8247 static void r3d_setup_defaults(struct hda_codec *codec) in r3d_setup_defaults() argument
8249 struct ca0132_spec *spec = codec->spec; in r3d_setup_defaults()
8254 if (spec->dsp_state != DSP_DOWNLOADED) in r3d_setup_defaults()
8257 ca0132_alt_init_analog_mics(codec); in r3d_setup_defaults()
8258 ca0132_alt_start_dsp_audio_streams(codec); in r3d_setup_defaults()
8262 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in r3d_setup_defaults()
8266 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in r3d_setup_defaults()
8267 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in r3d_setup_defaults()
8270 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in r3d_setup_defaults()
8273 r3di_gpio_dsp_status_set(codec, R3DI_DSP_DOWNLOADED); in r3d_setup_defaults()
8277 ca0113_mmio_gpio_set(codec, 2, false); in r3d_setup_defaults()
8278 ca0113_mmio_gpio_set(codec, 4, true); in r3d_setup_defaults()
8285 dspio_set_uint_param(codec, in r3d_setup_defaults()
8297 static void sbz_setup_defaults(struct hda_codec *codec) in sbz_setup_defaults() argument
8299 struct ca0132_spec *spec = codec->spec; in sbz_setup_defaults()
8304 if (spec->dsp_state != DSP_DOWNLOADED) in sbz_setup_defaults()
8307 ca0132_alt_init_analog_mics(codec); in sbz_setup_defaults()
8308 ca0132_alt_start_dsp_audio_streams(codec); in sbz_setup_defaults()
8309 sbz_connect_streams(codec); in sbz_setup_defaults()
8310 sbz_chipio_startup_data(codec); in sbz_setup_defaults()
8313 * Sets internal input loopback to off, used to have a switch to in sbz_setup_defaults()
8317 dspio_set_uint_param(codec, 0x37, 0x08, tmp); in sbz_setup_defaults()
8318 dspio_set_uint_param(codec, 0x37, 0x10, tmp); in sbz_setup_defaults()
8322 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in sbz_setup_defaults()
8326 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in sbz_setup_defaults()
8327 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in sbz_setup_defaults()
8330 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in sbz_setup_defaults()
8332 ca0132_alt_dsp_initial_mic_setup(codec); in sbz_setup_defaults()
8338 dspio_set_uint_param(codec, in sbz_setup_defaults()
8345 ca0132_alt_init_speaker_tuning(codec); in sbz_setup_defaults()
8349 * Setup default parameters for the Sound BlasterX AE-5 DSP.
8351 static void ae5_setup_defaults(struct hda_codec *codec) in ae5_setup_defaults() argument
8353 struct ca0132_spec *spec = codec->spec; in ae5_setup_defaults()
8358 if (spec->dsp_state != DSP_DOWNLOADED) in ae5_setup_defaults()
8361 ca0132_alt_init_analog_mics(codec); in ae5_setup_defaults()
8362 ca0132_alt_start_dsp_audio_streams(codec); in ae5_setup_defaults()
8366 dspio_set_uint_param(codec, 0x96, 0x29, tmp); in ae5_setup_defaults()
8367 dspio_set_uint_param(codec, 0x96, 0x2a, tmp); in ae5_setup_defaults()
8368 dspio_set_uint_param(codec, 0x80, 0x0d, tmp); in ae5_setup_defaults()
8369 dspio_set_uint_param(codec, 0x80, 0x0e, tmp); in ae5_setup_defaults()
8371 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae5_setup_defaults()
8372 ca0113_mmio_gpio_set(codec, 0, false); in ae5_setup_defaults()
8373 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ae5_setup_defaults()
8375 /* Internal loopback off */ in ae5_setup_defaults()
8377 dspio_set_uint_param(codec, 0x37, 0x08, tmp); in ae5_setup_defaults()
8378 dspio_set_uint_param(codec, 0x37, 0x10, tmp); in ae5_setup_defaults()
8382 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in ae5_setup_defaults()
8386 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in ae5_setup_defaults()
8387 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ae5_setup_defaults()
8390 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in ae5_setup_defaults()
8392 ca0132_alt_dsp_initial_mic_setup(codec); in ae5_setup_defaults()
8393 ae5_post_dsp_register_set(codec); in ae5_setup_defaults()
8394 ae5_post_dsp_param_setup(codec); in ae5_setup_defaults()
8395 ae5_post_dsp_pll_setup(codec); in ae5_setup_defaults()
8396 ae5_post_dsp_stream_setup(codec); in ae5_setup_defaults()
8397 ae5_post_dsp_startup_data(codec); in ae5_setup_defaults()
8403 dspio_set_uint_param(codec, in ae5_setup_defaults()
8410 ca0132_alt_init_speaker_tuning(codec); in ae5_setup_defaults()
8414 * Setup default parameters for the Sound Blaster AE-7 DSP.
8416 static void ae7_setup_defaults(struct hda_codec *codec) in ae7_setup_defaults() argument
8418 struct ca0132_spec *spec = codec->spec; in ae7_setup_defaults()
8423 if (spec->dsp_state != DSP_DOWNLOADED) in ae7_setup_defaults()
8426 ca0132_alt_init_analog_mics(codec); in ae7_setup_defaults()
8427 ca0132_alt_start_dsp_audio_streams(codec); in ae7_setup_defaults()
8428 ae7_post_dsp_setup_ports(codec); in ae7_setup_defaults()
8431 dspio_set_uint_param(codec, 0x96, in ae7_setup_defaults()
8433 dspio_set_uint_param(codec, 0x96, in ae7_setup_defaults()
8436 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae7_setup_defaults()
8439 dspio_set_uint_param(codec, 0x80, 0x0d, tmp); in ae7_setup_defaults()
8440 dspio_set_uint_param(codec, 0x80, 0x0e, tmp); in ae7_setup_defaults()
8442 ca0113_mmio_gpio_set(codec, 0, false); in ae7_setup_defaults()
8444 /* Internal loopback off */ in ae7_setup_defaults()
8446 dspio_set_uint_param(codec, 0x37, 0x08, tmp); in ae7_setup_defaults()
8447 dspio_set_uint_param(codec, 0x37, 0x10, tmp); in ae7_setup_defaults()
8451 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in ae7_setup_defaults()
8455 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in ae7_setup_defaults()
8456 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ae7_setup_defaults()
8459 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in ae7_setup_defaults()
8460 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ae7_setup_defaults()
8466 ca0132_alt_init_analog_mics(codec); in ae7_setup_defaults()
8468 ae7_post_dsp_asi_setup(codec); in ae7_setup_defaults()
8474 ca0113_mmio_gpio_set(codec, 0, true); in ae7_setup_defaults()
8475 ca0113_mmio_gpio_set(codec, 1, true); in ae7_setup_defaults()
8478 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x04); in ae7_setup_defaults()
8479 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x04); in ae7_setup_defaults()
8480 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x80); in ae7_setup_defaults()
8486 dspio_set_uint_param(codec, in ae7_setup_defaults()
8493 ca0132_alt_init_speaker_tuning(codec); in ae7_setup_defaults()
8499 static void ca0132_init_flags(struct hda_codec *codec) in ca0132_init_flags() argument
8501 struct ca0132_spec *spec = codec->spec; in ca0132_init_flags()
8504 chipio_set_control_flag(codec, CONTROL_FLAG_DSP_96KHZ, 1); in ca0132_init_flags()
8505 chipio_set_control_flag(codec, CONTROL_FLAG_DAC_96KHZ, 1); in ca0132_init_flags()
8506 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_B_96KHZ, 1); in ca0132_init_flags()
8507 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_C_96KHZ, 1); in ca0132_init_flags()
8508 chipio_set_control_flag(codec, CONTROL_FLAG_SRC_RATE_96KHZ, 1); in ca0132_init_flags()
8509 chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0); in ca0132_init_flags()
8510 chipio_set_control_flag(codec, CONTROL_FLAG_SPDIF2OUT, 0); in ca0132_init_flags()
8511 chipio_set_control_flag(codec, in ca0132_init_flags()
8513 chipio_set_control_flag(codec, in ca0132_init_flags()
8516 chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0); in ca0132_init_flags()
8517 chipio_set_control_flag(codec, in ca0132_init_flags()
8519 chipio_set_control_flag(codec, in ca0132_init_flags()
8521 chipio_set_control_flag(codec, in ca0132_init_flags()
8523 chipio_set_control_flag(codec, in ca0132_init_flags()
8525 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_C_HIGH_PASS, 1); in ca0132_init_flags()
8532 static void ca0132_init_params(struct hda_codec *codec) in ca0132_init_params() argument
8534 struct ca0132_spec *spec = codec->spec; in ca0132_init_params()
8537 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ca0132_init_params()
8538 chipio_set_conn_rate(codec, 0x0B, SR_48_000); in ca0132_init_params()
8539 chipio_set_control_param(codec, CONTROL_PARAM_SPDIF1_SOURCE, 0); in ca0132_init_params()
8540 chipio_set_control_param(codec, 0, 0); in ca0132_init_params()
8541 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, 0); in ca0132_init_params()
8544 chipio_set_control_param(codec, CONTROL_PARAM_PORTA_160OHM_GAIN, 6); in ca0132_init_params()
8545 chipio_set_control_param(codec, CONTROL_PARAM_PORTD_160OHM_GAIN, 6); in ca0132_init_params()
8548 static void ca0132_set_dsp_msr(struct hda_codec *codec, bool is96k) in ca0132_set_dsp_msr() argument
8550 chipio_set_control_flag(codec, CONTROL_FLAG_DSP_96KHZ, is96k); in ca0132_set_dsp_msr()
8551 chipio_set_control_flag(codec, CONTROL_FLAG_DAC_96KHZ, is96k); in ca0132_set_dsp_msr()
8552 chipio_set_control_flag(codec, CONTROL_FLAG_SRC_RATE_96KHZ, is96k); in ca0132_set_dsp_msr()
8553 chipio_set_control_flag(codec, CONTROL_FLAG_SRC_CLOCK_196MHZ, is96k); in ca0132_set_dsp_msr()
8554 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_B_96KHZ, is96k); in ca0132_set_dsp_msr()
8555 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_C_96KHZ, is96k); in ca0132_set_dsp_msr()
8557 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_set_dsp_msr()
8558 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_set_dsp_msr()
8559 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ca0132_set_dsp_msr()
8562 static bool ca0132_download_dsp_images(struct hda_codec *codec) in ca0132_download_dsp_images() argument
8565 struct ca0132_spec *spec = codec->spec; in ca0132_download_dsp_images()
8578 codec->card->dev) != 0) in ca0132_download_dsp_images()
8579 codec_dbg(codec, "Desktop firmware not found."); in ca0132_download_dsp_images()
8581 codec_dbg(codec, "Desktop firmware selected."); in ca0132_download_dsp_images()
8585 codec->card->dev) != 0) in ca0132_download_dsp_images()
8586 codec_dbg(codec, "Recon3Di alt firmware not detected."); in ca0132_download_dsp_images()
8588 codec_dbg(codec, "Recon3Di firmware selected."); in ca0132_download_dsp_images()
8595 * exists for your particular codec. in ca0132_download_dsp_images()
8598 codec_dbg(codec, "Default firmware selected."); in ca0132_download_dsp_images()
8600 codec->card->dev) != 0) in ca0132_download_dsp_images()
8604 dsp_os_image = (struct dsp_image_seg *)(fw_entry->data); in ca0132_download_dsp_images()
8605 if (dspload_image(codec, dsp_os_image, 0, 0, true, 0)) { in ca0132_download_dsp_images()
8606 codec_err(codec, "ca0132 DSP load image failed\n"); in ca0132_download_dsp_images()
8610 dsp_loaded = dspload_wait_loaded(codec); in ca0132_download_dsp_images()
8618 static void ca0132_download_dsp(struct hda_codec *codec) in ca0132_download_dsp() argument
8620 struct ca0132_spec *spec = codec->spec; in ca0132_download_dsp()
8626 if (spec->dsp_state == DSP_DOWNLOAD_FAILED) in ca0132_download_dsp()
8629 chipio_enable_clocks(codec); in ca0132_download_dsp()
8630 if (spec->dsp_state != DSP_DOWNLOADED) { in ca0132_download_dsp()
8631 spec->dsp_state = DSP_DOWNLOADING; in ca0132_download_dsp()
8633 if (!ca0132_download_dsp_images(codec)) in ca0132_download_dsp()
8634 spec->dsp_state = DSP_DOWNLOAD_FAILED; in ca0132_download_dsp()
8636 spec->dsp_state = DSP_DOWNLOADED; in ca0132_download_dsp()
8640 if (spec->dsp_state == DSP_DOWNLOADED && !ca0132_use_alt_functions(spec)) in ca0132_download_dsp()
8641 ca0132_set_dsp_msr(codec, true); in ca0132_download_dsp()
8644 static void ca0132_process_dsp_response(struct hda_codec *codec, in ca0132_process_dsp_response() argument
8647 struct ca0132_spec *spec = codec->spec; in ca0132_process_dsp_response()
8649 codec_dbg(codec, "ca0132_process_dsp_response\n"); in ca0132_process_dsp_response()
8650 snd_hda_power_up_pm(codec); in ca0132_process_dsp_response()
8651 if (spec->wait_scp) { in ca0132_process_dsp_response()
8652 if (dspio_get_response_data(codec) >= 0) in ca0132_process_dsp_response()
8653 spec->wait_scp = 0; in ca0132_process_dsp_response()
8656 dspio_clear_response_queue(codec); in ca0132_process_dsp_response()
8657 snd_hda_power_down_pm(codec); in ca0132_process_dsp_response()
8660 static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb) in hp_callback() argument
8662 struct ca0132_spec *spec = codec->spec; in hp_callback()
8665 /* Delay enabling the HP amp, to let the mic-detection in hp_callback()
8668 tbl = snd_hda_jack_tbl_get(codec, cb->nid); in hp_callback()
8670 tbl->block_report = 1; in hp_callback()
8671 schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500)); in hp_callback()
8674 static void amic_callback(struct hda_codec *codec, struct hda_jack_callback *cb) in amic_callback() argument
8676 struct ca0132_spec *spec = codec->spec; in amic_callback()
8679 ca0132_alt_select_in(codec); in amic_callback()
8681 ca0132_select_mic(codec); in amic_callback()
8684 static void ca0132_setup_unsol(struct hda_codec *codec) in ca0132_setup_unsol() argument
8686 struct ca0132_spec *spec = codec->spec; in ca0132_setup_unsol()
8687 snd_hda_jack_detect_enable_callback(codec, spec->unsol_tag_hp, hp_callback); in ca0132_setup_unsol()
8688 snd_hda_jack_detect_enable_callback(codec, spec->unsol_tag_amic1, in ca0132_setup_unsol()
8690 snd_hda_jack_detect_enable_callback(codec, UNSOL_TAG_DSP, in ca0132_setup_unsol()
8694 snd_hda_jack_detect_enable_callback(codec, in ca0132_setup_unsol()
8695 spec->unsol_tag_front_hp, hp_callback); in ca0132_setup_unsol()
8773 static void ca0132_init_chip(struct hda_codec *codec) in ca0132_init_chip() argument
8775 struct ca0132_spec *spec = codec->spec; in ca0132_init_chip()
8780 mutex_init(&spec->chipio_mutex); in ca0132_init_chip()
8789 chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0); in ca0132_init_chip()
8790 chipio_write_no_mutex(codec, 0x18b0a4, 0x000000c2); in ca0132_init_chip()
8792 snd_hda_codec_write(codec, codec->core.afg, 0, in ca0132_init_chip()
8794 snd_hda_codec_write(codec, codec->core.afg, 0, in ca0132_init_chip()
8798 spec->cur_out_type = SPEAKER_OUT; in ca0132_init_chip()
8800 spec->cur_mic_type = DIGITAL_MIC; in ca0132_init_chip()
8802 spec->cur_mic_type = REAR_MIC; in ca0132_init_chip()
8804 spec->cur_mic_boost = 0; in ca0132_init_chip()
8807 spec->vnode_lvol[i] = 0x5a; in ca0132_init_chip()
8808 spec->vnode_rvol[i] = 0x5a; in ca0132_init_chip()
8809 spec->vnode_lswitch[i] = 0; in ca0132_init_chip()
8810 spec->vnode_rswitch[i] = 0; in ca0132_init_chip()
8819 spec->effects_switch[i] = on ? 1 : 0; in ca0132_init_chip()
8823 * ca0132 codecs. Also sets x-bass crossover frequency to 80hz. in ca0132_init_chip()
8827 spec->speaker_range_val[0] = 1; in ca0132_init_chip()
8828 spec->speaker_range_val[1] = 1; in ca0132_init_chip()
8830 spec->xbass_xover_freq = 8; in ca0132_init_chip()
8832 spec->fx_ctl_val[i] = effect_slider_defaults[i]; in ca0132_init_chip()
8834 spec->bass_redirect_xover_freq = 8; in ca0132_init_chip()
8837 spec->voicefx_val = 0; in ca0132_init_chip()
8838 spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID] = 1; in ca0132_init_chip()
8839 spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID] = 0; in ca0132_init_chip()
8842 * The ZxR doesn't have a front panel header, and it's line-in is on in ca0132_init_chip()
8844 * to make sure that spec->in_enum_val is set properly. in ca0132_init_chip()
8847 spec->in_enum_val = REAR_MIC; in ca0132_init_chip()
8850 ca0132_init_tuning_defaults(codec); in ca0132_init_chip()
8858 static void r3di_gpio_shutdown(struct hda_codec *codec) in r3di_gpio_shutdown() argument
8860 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0x00); in r3di_gpio_shutdown()
8866 static void sbz_region2_exit(struct hda_codec *codec) in sbz_region2_exit() argument
8868 struct ca0132_spec *spec = codec->spec; in sbz_region2_exit()
8872 writeb(0x0, spec->mem_base + 0x100); in sbz_region2_exit()
8874 writeb(0xb3, spec->mem_base + 0x304); in sbz_region2_exit()
8876 ca0113_mmio_gpio_set(codec, 0, false); in sbz_region2_exit()
8877 ca0113_mmio_gpio_set(codec, 1, false); in sbz_region2_exit()
8878 ca0113_mmio_gpio_set(codec, 4, true); in sbz_region2_exit()
8879 ca0113_mmio_gpio_set(codec, 5, false); in sbz_region2_exit()
8880 ca0113_mmio_gpio_set(codec, 7, false); in sbz_region2_exit()
8883 static void sbz_set_pin_ctl_default(struct hda_codec *codec) in sbz_set_pin_ctl_default() argument
8888 snd_hda_codec_write(codec, 0x11, 0, in sbz_set_pin_ctl_default()
8892 snd_hda_codec_write(codec, pins[i], 0, in sbz_set_pin_ctl_default()
8896 static void ca0132_clear_unsolicited(struct hda_codec *codec) in ca0132_clear_unsolicited() argument
8902 snd_hda_codec_write(codec, pins[i], 0, in ca0132_clear_unsolicited()
8908 static void sbz_gpio_shutdown_commands(struct hda_codec *codec, int dir, in sbz_gpio_shutdown_commands() argument
8912 snd_hda_codec_write(codec, 0x01, 0, in sbz_gpio_shutdown_commands()
8915 snd_hda_codec_write(codec, 0x01, 0, in sbz_gpio_shutdown_commands()
8919 snd_hda_codec_write(codec, 0x01, 0, in sbz_gpio_shutdown_commands()
8923 static void zxr_dbpro_power_state_shutdown(struct hda_codec *codec) in zxr_dbpro_power_state_shutdown() argument
8929 snd_hda_codec_write(codec, pins[i], 0, in zxr_dbpro_power_state_shutdown()
8933 static void sbz_exit_chip(struct hda_codec *codec) in sbz_exit_chip() argument
8935 chipio_set_stream_control(codec, 0x03, 0); in sbz_exit_chip()
8936 chipio_set_stream_control(codec, 0x04, 0); in sbz_exit_chip()
8939 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, -1); in sbz_exit_chip()
8940 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x05); in sbz_exit_chip()
8941 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x01); in sbz_exit_chip()
8943 chipio_set_stream_control(codec, 0x14, 0); in sbz_exit_chip()
8944 chipio_set_stream_control(codec, 0x0C, 0); in sbz_exit_chip()
8946 chipio_set_conn_rate(codec, 0x41, SR_192_000); in sbz_exit_chip()
8947 chipio_set_conn_rate(codec, 0x91, SR_192_000); in sbz_exit_chip()
8949 chipio_write(codec, 0x18a020, 0x00000083); in sbz_exit_chip()
8951 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x03); in sbz_exit_chip()
8952 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x07); in sbz_exit_chip()
8953 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x06); in sbz_exit_chip()
8955 chipio_set_stream_control(codec, 0x0C, 0); in sbz_exit_chip()
8957 chipio_set_control_param(codec, 0x0D, 0x24); in sbz_exit_chip()
8959 ca0132_clear_unsolicited(codec); in sbz_exit_chip()
8960 sbz_set_pin_ctl_default(codec); in sbz_exit_chip()
8962 snd_hda_codec_write(codec, 0x0B, 0, in sbz_exit_chip()
8965 sbz_region2_exit(codec); in sbz_exit_chip()
8968 static void r3d_exit_chip(struct hda_codec *codec) in r3d_exit_chip() argument
8970 ca0132_clear_unsolicited(codec); in r3d_exit_chip()
8971 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in r3d_exit_chip()
8972 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x5b); in r3d_exit_chip()
8975 static void ae5_exit_chip(struct hda_codec *codec) in ae5_exit_chip() argument
8977 chipio_set_stream_control(codec, 0x03, 0); in ae5_exit_chip()
8978 chipio_set_stream_control(codec, 0x04, 0); in ae5_exit_chip()
8980 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ae5_exit_chip()
8981 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_exit_chip()
8982 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_exit_chip()
8983 ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00); in ae5_exit_chip()
8984 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x00); in ae5_exit_chip()
8985 ca0113_mmio_command_set(codec, 0x30, 0x2d, 0x00); in ae5_exit_chip()
8986 ca0113_mmio_gpio_set(codec, 0, false); in ae5_exit_chip()
8987 ca0113_mmio_gpio_set(codec, 1, false); in ae5_exit_chip()
8989 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in ae5_exit_chip()
8990 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x53); in ae5_exit_chip()
8992 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae5_exit_chip()
8994 chipio_set_stream_control(codec, 0x18, 0); in ae5_exit_chip()
8995 chipio_set_stream_control(codec, 0x0c, 0); in ae5_exit_chip()
8997 snd_hda_codec_write(codec, 0x01, 0, 0x724, 0x83); in ae5_exit_chip()
9000 static void ae7_exit_chip(struct hda_codec *codec) in ae7_exit_chip() argument
9002 chipio_set_stream_control(codec, 0x18, 0); in ae7_exit_chip()
9003 chipio_set_stream_source_dest(codec, 0x21, 0xc8, 0xc8); in ae7_exit_chip()
9004 chipio_set_stream_channels(codec, 0x21, 0); in ae7_exit_chip()
9005 chipio_set_control_param(codec, CONTROL_PARAM_NODE_ID, 0x09); in ae7_exit_chip()
9006 chipio_set_control_param(codec, 0x20, 0x01); in ae7_exit_chip()
9008 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae7_exit_chip()
9010 chipio_set_stream_control(codec, 0x18, 0); in ae7_exit_chip()
9011 chipio_set_stream_control(codec, 0x0c, 0); in ae7_exit_chip()
9013 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x00); in ae7_exit_chip()
9014 snd_hda_codec_write(codec, 0x15, 0, 0x724, 0x83); in ae7_exit_chip()
9015 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_exit_chip()
9016 ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00); in ae7_exit_chip()
9017 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x00); in ae7_exit_chip()
9018 ca0113_mmio_gpio_set(codec, 0, false); in ae7_exit_chip()
9019 ca0113_mmio_gpio_set(codec, 1, false); in ae7_exit_chip()
9020 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ae7_exit_chip()
9022 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in ae7_exit_chip()
9023 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x53); in ae7_exit_chip()
9026 static void zxr_exit_chip(struct hda_codec *codec) in zxr_exit_chip() argument
9028 chipio_set_stream_control(codec, 0x03, 0); in zxr_exit_chip()
9029 chipio_set_stream_control(codec, 0x04, 0); in zxr_exit_chip()
9030 chipio_set_stream_control(codec, 0x14, 0); in zxr_exit_chip()
9031 chipio_set_stream_control(codec, 0x0C, 0); in zxr_exit_chip()
9033 chipio_set_conn_rate(codec, 0x41, SR_192_000); in zxr_exit_chip()
9034 chipio_set_conn_rate(codec, 0x91, SR_192_000); in zxr_exit_chip()
9036 chipio_write(codec, 0x18a020, 0x00000083); in zxr_exit_chip()
9038 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in zxr_exit_chip()
9039 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x53); in zxr_exit_chip()
9041 ca0132_clear_unsolicited(codec); in zxr_exit_chip()
9042 sbz_set_pin_ctl_default(codec); in zxr_exit_chip()
9043 snd_hda_codec_write(codec, 0x0B, 0, AC_VERB_SET_EAPD_BTLENABLE, 0x00); in zxr_exit_chip()
9045 ca0113_mmio_gpio_set(codec, 5, false); in zxr_exit_chip()
9046 ca0113_mmio_gpio_set(codec, 2, false); in zxr_exit_chip()
9047 ca0113_mmio_gpio_set(codec, 3, false); in zxr_exit_chip()
9048 ca0113_mmio_gpio_set(codec, 0, false); in zxr_exit_chip()
9049 ca0113_mmio_gpio_set(codec, 4, true); in zxr_exit_chip()
9050 ca0113_mmio_gpio_set(codec, 0, true); in zxr_exit_chip()
9051 ca0113_mmio_gpio_set(codec, 5, true); in zxr_exit_chip()
9052 ca0113_mmio_gpio_set(codec, 2, false); in zxr_exit_chip()
9053 ca0113_mmio_gpio_set(codec, 3, false); in zxr_exit_chip()
9056 static void ca0132_exit_chip(struct hda_codec *codec) in ca0132_exit_chip() argument
9060 if (dspload_is_loaded(codec)) in ca0132_exit_chip()
9061 dsp_reset(codec); in ca0132_exit_chip()
9072 static void sbz_dsp_startup_check(struct hda_codec *codec) in sbz_dsp_startup_check() argument
9074 struct ca0132_spec *spec = codec->spec; in sbz_dsp_startup_check()
9081 if (spec->startup_check_entered) in sbz_dsp_startup_check()
9084 spec->startup_check_entered = true; in sbz_dsp_startup_check()
9087 chipio_read(codec, cur_address, &dsp_data_check[i]); in sbz_dsp_startup_check()
9095 codec_dbg(codec, "Startup Check: %d ", failure); in sbz_dsp_startup_check()
9097 codec_info(codec, "DSP not initialized properly. Attempting to fix."); in sbz_dsp_startup_check()
9104 codec_info(codec, "Reloading... Tries left: %d", reload); in sbz_dsp_startup_check()
9105 sbz_exit_chip(codec); in sbz_dsp_startup_check()
9106 spec->dsp_state = DSP_DOWNLOAD_INIT; in sbz_dsp_startup_check()
9107 codec->patch_ops.init(codec); in sbz_dsp_startup_check()
9110 chipio_read(codec, cur_address, &dsp_data_check[i]); in sbz_dsp_startup_check()
9117 reload--; in sbz_dsp_startup_check()
9121 codec_info(codec, "DSP fixed."); in sbz_dsp_startup_check()
9126 …codec_info(codec, "DSP failed to initialize properly. Either try a full shutdown or a suspend to c… in sbz_dsp_startup_check()
9137 static void ca0132_alt_vol_setup(struct hda_codec *codec) in ca0132_alt_vol_setup() argument
9139 snd_hda_codec_write(codec, 0x02, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9140 snd_hda_codec_write(codec, 0x02, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9141 snd_hda_codec_write(codec, 0x03, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9142 snd_hda_codec_write(codec, 0x03, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9143 snd_hda_codec_write(codec, 0x04, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9144 snd_hda_codec_write(codec, 0x04, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9145 snd_hda_codec_write(codec, 0x07, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9146 snd_hda_codec_write(codec, 0x07, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9152 static void sbz_pre_dsp_setup(struct hda_codec *codec) in sbz_pre_dsp_setup() argument
9154 struct ca0132_spec *spec = codec->spec; in sbz_pre_dsp_setup()
9156 writel(0x00820680, spec->mem_base + 0x01C); in sbz_pre_dsp_setup()
9157 writel(0x00820680, spec->mem_base + 0x01C); in sbz_pre_dsp_setup()
9159 chipio_write(codec, 0x18b0a4, 0x000000c2); in sbz_pre_dsp_setup()
9161 snd_hda_codec_write(codec, 0x11, 0, in sbz_pre_dsp_setup()
9165 static void r3d_pre_dsp_setup(struct hda_codec *codec) in r3d_pre_dsp_setup() argument
9167 chipio_write(codec, 0x18b0a4, 0x000000c2); in r3d_pre_dsp_setup()
9169 chipio_8051_write_exram(codec, 0x1c1e, 0x5b); in r3d_pre_dsp_setup()
9171 snd_hda_codec_write(codec, 0x11, 0, in r3d_pre_dsp_setup()
9175 static void r3di_pre_dsp_setup(struct hda_codec *codec) in r3di_pre_dsp_setup() argument
9177 chipio_write(codec, 0x18b0a4, 0x000000c2); in r3di_pre_dsp_setup()
9179 chipio_8051_write_exram(codec, 0x1c1e, 0x5b); in r3di_pre_dsp_setup()
9180 chipio_8051_write_exram(codec, 0x1920, 0x00); in r3di_pre_dsp_setup()
9181 chipio_8051_write_exram(codec, 0x1921, 0x40); in r3di_pre_dsp_setup()
9183 snd_hda_codec_write(codec, 0x11, 0, in r3di_pre_dsp_setup()
9192 static void zxr_pre_dsp_setup(struct hda_codec *codec) in zxr_pre_dsp_setup() argument
9198 chipio_write(codec, 0x189000, 0x0001f100); in zxr_pre_dsp_setup()
9200 chipio_write(codec, 0x18900c, 0x0001f100); in zxr_pre_dsp_setup()
9209 chipio_8051_write_exram(codec, 0xfa92, 0x22); in zxr_pre_dsp_setup()
9211 chipio_8051_write_pll_pmu(codec, 0x51, 0x98); in zxr_pre_dsp_setup()
9213 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x82); in zxr_pre_dsp_setup()
9214 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 3); in zxr_pre_dsp_setup()
9216 chipio_write(codec, 0x18902c, 0x00000000); in zxr_pre_dsp_setup()
9218 chipio_write(codec, 0x18902c, 0x00000003); in zxr_pre_dsp_setup()
9222 chipio_8051_write_pll_pmu(codec, addr[i], data[i]); in zxr_pre_dsp_setup()
9265 static void ca0132_mmio_init_sbz(struct hda_codec *codec) in ca0132_mmio_init_sbz() argument
9267 struct ca0132_spec *spec = codec->spec; in ca0132_mmio_init_sbz()
9273 writel(0x00000000, spec->mem_base + addr[i]); in ca0132_mmio_init_sbz()
9296 writel(tmp[i], spec->mem_base + addr[cur_addr + i]); in ca0132_mmio_init_sbz()
9312 writel(data[i], spec->mem_base + addr[cur_addr + i]); in ca0132_mmio_init_sbz()
9315 static void ca0132_mmio_init_ae5(struct hda_codec *codec) in ca0132_mmio_init_ae5() argument
9317 struct ca0132_spec *spec = codec->spec; in ca0132_mmio_init_ae5()
9326 writel(0x00000680, spec->mem_base + 0x1c); in ca0132_mmio_init_ae5()
9327 writel(0x00880680, spec->mem_base + 0x1c); in ca0132_mmio_init_ae5()
9332 * AE-7 shares all writes with the AE-5, except that it writes in ca0132_mmio_init_ae5()
9336 writel(0x00800001, spec->mem_base + addr[i]); in ca0132_mmio_init_ae5()
9340 writel(data[i], spec->mem_base + addr[i]); in ca0132_mmio_init_ae5()
9344 writel(0x00880680, spec->mem_base + 0x1c); in ca0132_mmio_init_ae5()
9347 static void ca0132_mmio_init(struct hda_codec *codec) in ca0132_mmio_init() argument
9349 struct ca0132_spec *spec = codec->spec; in ca0132_mmio_init()
9355 ca0132_mmio_init_sbz(codec); in ca0132_mmio_init()
9358 ca0132_mmio_init_ae5(codec); in ca0132_mmio_init()
9377 * eventually resets the codec with the 0x7ff verb. Not quite sure why it does
9380 static void ae5_register_set(struct hda_codec *codec) in ae5_register_set() argument
9382 struct ca0132_spec *spec = codec->spec; in ae5_register_set()
9390 chipio_8051_write_pll_pmu(codec, 0x41, 0xc8); in ae5_register_set()
9392 chipio_8051_write_direct(codec, 0x93, 0x10); in ae5_register_set()
9393 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); in ae5_register_set()
9406 writeb(tmp[i], spec->mem_base + addr[cur_addr]); in ae5_register_set()
9413 writeb(data[i], spec->mem_base + addr[cur_addr]); in ae5_register_set()
9416 writel(data[i], spec->mem_base + addr[cur_addr]); in ae5_register_set()
9418 writel(0x00800001, spec->mem_base + 0x20c); in ae5_register_set()
9421 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae5_register_set()
9422 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae5_register_set()
9424 ca0113_mmio_command_set(codec, 0x30, 0x2d, 0x3f); in ae5_register_set()
9427 chipio_8051_write_direct(codec, 0x90, 0x00); in ae5_register_set()
9428 chipio_8051_write_direct(codec, 0x90, 0x10); in ae5_register_set()
9431 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_register_set()
9439 static void ca0132_alt_init(struct hda_codec *codec) in ca0132_alt_init() argument
9441 struct ca0132_spec *spec = codec->spec; in ca0132_alt_init()
9443 ca0132_alt_vol_setup(codec); in ca0132_alt_init()
9447 codec_dbg(codec, "SBZ alt_init"); in ca0132_alt_init()
9448 ca0132_gpio_init(codec); in ca0132_alt_init()
9449 sbz_pre_dsp_setup(codec); in ca0132_alt_init()
9450 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9451 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9454 codec_dbg(codec, "R3DI alt_init"); in ca0132_alt_init()
9455 ca0132_gpio_init(codec); in ca0132_alt_init()
9456 ca0132_gpio_setup(codec); in ca0132_alt_init()
9457 r3di_gpio_dsp_status_set(codec, R3DI_DSP_DOWNLOADING); in ca0132_alt_init()
9458 r3di_pre_dsp_setup(codec); in ca0132_alt_init()
9459 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9460 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x6FF, 0xC4); in ca0132_alt_init()
9463 r3d_pre_dsp_setup(codec); in ca0132_alt_init()
9464 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9465 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9468 ca0132_gpio_init(codec); in ca0132_alt_init()
9469 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); in ca0132_alt_init()
9470 chipio_write(codec, 0x18b030, 0x00000020); in ca0132_alt_init()
9471 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9472 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9473 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ca0132_alt_init()
9476 ca0132_gpio_init(codec); in ca0132_alt_init()
9477 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); in ca0132_alt_init()
9478 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9479 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9480 chipio_write(codec, 0x18b008, 0x000000f8); in ca0132_alt_init()
9481 chipio_write(codec, 0x18b008, 0x000000f0); in ca0132_alt_init()
9482 chipio_write(codec, 0x18b030, 0x00000020); in ca0132_alt_init()
9483 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ca0132_alt_init()
9486 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); in ca0132_alt_init()
9487 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9488 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9489 zxr_pre_dsp_setup(codec); in ca0132_alt_init()
9496 static int ca0132_init(struct hda_codec *codec) in ca0132_init() argument
9498 struct ca0132_spec *spec = codec->spec; in ca0132_init()
9499 struct auto_pin_cfg *cfg = &spec->autocfg; in ca0132_init()
9505 * there's only two reasons for it. One, the codec has awaken from a in ca0132_init()
9513 if (spec->dsp_state == DSP_DOWNLOADED) { in ca0132_init()
9514 dsp_loaded = dspload_is_loaded(codec); in ca0132_init()
9516 spec->dsp_reload = true; in ca0132_init()
9517 spec->dsp_state = DSP_DOWNLOAD_INIT; in ca0132_init()
9520 sbz_dsp_startup_check(codec); in ca0132_init()
9525 if (spec->dsp_state != DSP_DOWNLOAD_FAILED) in ca0132_init()
9526 spec->dsp_state = DSP_DOWNLOAD_INIT; in ca0132_init()
9527 spec->curr_chip_addx = INVALID_CHIP_ADDRESS; in ca0132_init()
9530 ca0132_mmio_init(codec); in ca0132_init()
9532 snd_hda_power_up_pm(codec); in ca0132_init()
9535 ae5_register_set(codec); in ca0132_init()
9537 ca0132_init_params(codec); in ca0132_init()
9538 ca0132_init_flags(codec); in ca0132_init()
9540 snd_hda_sequence_write(codec, spec->base_init_verbs); in ca0132_init()
9543 ca0132_alt_init(codec); in ca0132_init()
9545 ca0132_download_dsp(codec); in ca0132_init()
9547 ca0132_refresh_widget_caps(codec); in ca0132_init()
9552 r3d_setup_defaults(codec); in ca0132_init()
9556 sbz_setup_defaults(codec); in ca0132_init()
9559 ae5_setup_defaults(codec); in ca0132_init()
9562 ae7_setup_defaults(codec); in ca0132_init()
9565 ca0132_setup_defaults(codec); in ca0132_init()
9566 ca0132_init_analog_mic2(codec); in ca0132_init()
9567 ca0132_init_dmic(codec); in ca0132_init()
9571 for (i = 0; i < spec->num_outputs; i++) in ca0132_init()
9572 init_output(codec, spec->out_pins[i], spec->dacs[0]); in ca0132_init()
9574 init_output(codec, cfg->dig_out_pins[0], spec->dig_out); in ca0132_init()
9576 for (i = 0; i < spec->num_inputs; i++) in ca0132_init()
9577 init_input(codec, spec->input_pins[i], spec->adcs[i]); in ca0132_init()
9579 init_input(codec, cfg->dig_in_pin, spec->dig_in); in ca0132_init()
9582 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_init()
9583 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in ca0132_init()
9585 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in ca0132_init()
9590 ca0132_gpio_setup(codec); in ca0132_init()
9592 snd_hda_sequence_write(codec, spec->spec_init_verbs); in ca0132_init()
9594 ca0132_alt_select_out(codec); in ca0132_init()
9595 ca0132_alt_select_in(codec); in ca0132_init()
9597 ca0132_select_out(codec); in ca0132_init()
9598 ca0132_select_mic(codec); in ca0132_init()
9601 snd_hda_jack_report_sync(codec); in ca0132_init()
9607 if (spec->dsp_reload) { in ca0132_init()
9608 spec->dsp_reload = false; in ca0132_init()
9609 ca0132_pe_switch_set(codec); in ca0132_init()
9612 snd_hda_power_down_pm(codec); in ca0132_init()
9617 static int dbpro_init(struct hda_codec *codec) in dbpro_init() argument
9619 struct ca0132_spec *spec = codec->spec; in dbpro_init()
9620 struct auto_pin_cfg *cfg = &spec->autocfg; in dbpro_init()
9623 init_output(codec, cfg->dig_out_pins[0], spec->dig_out); in dbpro_init()
9624 init_input(codec, cfg->dig_in_pin, spec->dig_in); in dbpro_init()
9626 for (i = 0; i < spec->num_inputs; i++) in dbpro_init()
9627 init_input(codec, spec->input_pins[i], spec->adcs[i]); in dbpro_init()
9632 static void ca0132_free(struct hda_codec *codec) in ca0132_free() argument
9634 struct ca0132_spec *spec = codec->spec; in ca0132_free()
9636 cancel_delayed_work_sync(&spec->unsol_hp_work); in ca0132_free()
9637 snd_hda_power_up(codec); in ca0132_free()
9640 sbz_exit_chip(codec); in ca0132_free()
9643 zxr_exit_chip(codec); in ca0132_free()
9646 r3d_exit_chip(codec); in ca0132_free()
9649 ae5_exit_chip(codec); in ca0132_free()
9652 ae7_exit_chip(codec); in ca0132_free()
9655 r3di_gpio_shutdown(codec); in ca0132_free()
9661 snd_hda_sequence_write(codec, spec->base_exit_verbs); in ca0132_free()
9662 ca0132_exit_chip(codec); in ca0132_free()
9664 snd_hda_power_down(codec); in ca0132_free()
9666 if (spec->mem_base) in ca0132_free()
9667 pci_iounmap(codec->bus->pci, spec->mem_base); in ca0132_free()
9669 kfree(spec->spec_init_verbs); in ca0132_free()
9670 kfree(codec->spec); in ca0132_free()
9673 static void dbpro_free(struct hda_codec *codec) in dbpro_free() argument
9675 struct ca0132_spec *spec = codec->spec; in dbpro_free()
9677 zxr_dbpro_power_state_shutdown(codec); in dbpro_free()
9679 kfree(spec->spec_init_verbs); in dbpro_free()
9680 kfree(codec->spec); in dbpro_free()
9684 static int ca0132_suspend(struct hda_codec *codec) in ca0132_suspend() argument
9686 struct ca0132_spec *spec = codec->spec; in ca0132_suspend()
9688 cancel_delayed_work_sync(&spec->unsol_hp_work); in ca0132_suspend()
9711 static void ca0132_config(struct hda_codec *codec) in ca0132_config() argument
9713 struct ca0132_spec *spec = codec->spec; in ca0132_config()
9715 spec->dacs[0] = 0x2; in ca0132_config()
9716 spec->dacs[1] = 0x3; in ca0132_config()
9717 spec->dacs[2] = 0x4; in ca0132_config()
9719 spec->multiout.dac_nids = spec->dacs; in ca0132_config()
9720 spec->multiout.num_dacs = 3; in ca0132_config()
9723 spec->multiout.max_channels = 2; in ca0132_config()
9725 spec->multiout.max_channels = 6; in ca0132_config()
9729 codec_dbg(codec, "%s: QUIRK_ALIENWARE applied.\n", __func__); in ca0132_config()
9730 snd_hda_apply_pincfgs(codec, alienware_pincfgs); in ca0132_config()
9733 codec_dbg(codec, "%s: QUIRK_SBZ applied.\n", __func__); in ca0132_config()
9734 snd_hda_apply_pincfgs(codec, sbz_pincfgs); in ca0132_config()
9737 codec_dbg(codec, "%s: QUIRK_ZXR applied.\n", __func__); in ca0132_config()
9738 snd_hda_apply_pincfgs(codec, zxr_pincfgs); in ca0132_config()
9741 codec_dbg(codec, "%s: QUIRK_R3D applied.\n", __func__); in ca0132_config()
9742 snd_hda_apply_pincfgs(codec, r3d_pincfgs); in ca0132_config()
9745 codec_dbg(codec, "%s: QUIRK_R3DI applied.\n", __func__); in ca0132_config()
9746 snd_hda_apply_pincfgs(codec, r3di_pincfgs); in ca0132_config()
9749 codec_dbg(codec, "%s: QUIRK_AE5 applied.\n", __func__); in ca0132_config()
9750 snd_hda_apply_pincfgs(codec, ae5_pincfgs); in ca0132_config()
9753 codec_dbg(codec, "%s: QUIRK_AE7 applied.\n", __func__); in ca0132_config()
9754 snd_hda_apply_pincfgs(codec, ae7_pincfgs); in ca0132_config()
9762 spec->num_outputs = 2; in ca0132_config()
9763 spec->out_pins[0] = 0x0b; /* speaker out */ in ca0132_config()
9764 spec->out_pins[1] = 0x0f; in ca0132_config()
9765 spec->shared_out_nid = 0x2; in ca0132_config()
9766 spec->unsol_tag_hp = 0x0f; in ca0132_config()
9768 spec->adcs[0] = 0x7; /* digital mic / analog mic1 */ in ca0132_config()
9769 spec->adcs[1] = 0x8; /* analog mic2 */ in ca0132_config()
9770 spec->adcs[2] = 0xa; /* what u hear */ in ca0132_config()
9772 spec->num_inputs = 3; in ca0132_config()
9773 spec->input_pins[0] = 0x12; in ca0132_config()
9774 spec->input_pins[1] = 0x11; in ca0132_config()
9775 spec->input_pins[2] = 0x13; in ca0132_config()
9776 spec->shared_mic_nid = 0x7; in ca0132_config()
9777 spec->unsol_tag_amic1 = 0x11; in ca0132_config()
9781 spec->num_outputs = 2; in ca0132_config()
9782 spec->out_pins[0] = 0x0B; /* Line out */ in ca0132_config()
9783 spec->out_pins[1] = 0x0F; /* Rear headphone out */ in ca0132_config()
9784 spec->out_pins[2] = 0x10; /* Front Headphone / Center/LFE*/ in ca0132_config()
9785 spec->out_pins[3] = 0x11; /* Rear surround */ in ca0132_config()
9786 spec->shared_out_nid = 0x2; in ca0132_config()
9787 spec->unsol_tag_hp = spec->out_pins[1]; in ca0132_config()
9788 spec->unsol_tag_front_hp = spec->out_pins[2]; in ca0132_config()
9790 spec->adcs[0] = 0x7; /* Rear Mic / Line-in */ in ca0132_config()
9791 spec->adcs[1] = 0x8; /* Front Mic, but only if no DSP */ in ca0132_config()
9792 spec->adcs[2] = 0xa; /* what u hear */ in ca0132_config()
9794 spec->num_inputs = 2; in ca0132_config()
9795 spec->input_pins[0] = 0x12; /* Rear Mic / Line-in */ in ca0132_config()
9796 spec->input_pins[1] = 0x13; /* What U Hear */ in ca0132_config()
9797 spec->shared_mic_nid = 0x7; in ca0132_config()
9798 spec->unsol_tag_amic1 = spec->input_pins[0]; in ca0132_config()
9801 spec->dig_out = 0x05; in ca0132_config()
9802 spec->multiout.dig_out_nid = spec->dig_out; in ca0132_config()
9803 spec->dig_in = 0x09; in ca0132_config()
9806 spec->num_outputs = 2; in ca0132_config()
9807 spec->out_pins[0] = 0x0B; /* Line out */ in ca0132_config()
9808 spec->out_pins[1] = 0x0F; /* Rear headphone out */ in ca0132_config()
9809 spec->out_pins[2] = 0x10; /* Center/LFE */ in ca0132_config()
9810 spec->out_pins[3] = 0x11; /* Rear surround */ in ca0132_config()
9811 spec->shared_out_nid = 0x2; in ca0132_config()
9812 spec->unsol_tag_hp = spec->out_pins[1]; in ca0132_config()
9813 spec->unsol_tag_front_hp = spec->out_pins[2]; in ca0132_config()
9815 spec->adcs[0] = 0x7; /* Rear Mic / Line-in */ in ca0132_config()
9816 spec->adcs[1] = 0x8; /* Not connected, no front mic */ in ca0132_config()
9817 spec->adcs[2] = 0xa; /* what u hear */ in ca0132_config()
9819 spec->num_inputs = 2; in ca0132_config()
9820 spec->input_pins[0] = 0x12; /* Rear Mic / Line-in */ in ca0132_config()
9821 spec->input_pins[1] = 0x13; /* What U Hear */ in ca0132_config()
9822 spec->shared_mic_nid = 0x7; in ca0132_config()
9823 spec->unsol_tag_amic1 = spec->input_pins[0]; in ca0132_config()
9826 spec->adcs[0] = 0x8; /* ZxR DBPro Aux In */ in ca0132_config()
9828 spec->num_inputs = 1; in ca0132_config()
9829 spec->input_pins[0] = 0x11; /* RCA Line-in */ in ca0132_config()
9831 spec->dig_out = 0x05; in ca0132_config()
9832 spec->multiout.dig_out_nid = spec->dig_out; in ca0132_config()
9834 spec->dig_in = 0x09; in ca0132_config()
9838 spec->num_outputs = 2; in ca0132_config()
9839 spec->out_pins[0] = 0x0B; /* Line out */ in ca0132_config()
9840 spec->out_pins[1] = 0x11; /* Rear headphone out */ in ca0132_config()
9841 spec->out_pins[2] = 0x10; /* Front Headphone / Center/LFE*/ in ca0132_config()
9842 spec->out_pins[3] = 0x0F; /* Rear surround */ in ca0132_config()
9843 spec->shared_out_nid = 0x2; in ca0132_config()
9844 spec->unsol_tag_hp = spec->out_pins[1]; in ca0132_config()
9845 spec->unsol_tag_front_hp = spec->out_pins[2]; in ca0132_config()
9847 spec->adcs[0] = 0x7; /* Rear Mic / Line-in */ in ca0132_config()
9848 spec->adcs[1] = 0x8; /* Front Mic, but only if no DSP */ in ca0132_config()
9849 spec->adcs[2] = 0xa; /* what u hear */ in ca0132_config()
9851 spec->num_inputs = 2; in ca0132_config()
9852 spec->input_pins[0] = 0x12; /* Rear Mic / Line-in */ in ca0132_config()
9853 spec->input_pins[1] = 0x13; /* What U Hear */ in ca0132_config()
9854 spec->shared_mic_nid = 0x7; in ca0132_config()
9855 spec->unsol_tag_amic1 = spec->input_pins[0]; in ca0132_config()
9858 spec->dig_out = 0x05; in ca0132_config()
9859 spec->multiout.dig_out_nid = spec->dig_out; in ca0132_config()
9862 spec->num_outputs = 2; in ca0132_config()
9863 spec->out_pins[0] = 0x0B; /* Line out */ in ca0132_config()
9864 spec->out_pins[1] = 0x0F; /* Rear headphone out */ in ca0132_config()
9865 spec->out_pins[2] = 0x10; /* Front Headphone / Center/LFE*/ in ca0132_config()
9866 spec->out_pins[3] = 0x11; /* Rear surround */ in ca0132_config()
9867 spec->shared_out_nid = 0x2; in ca0132_config()
9868 spec->unsol_tag_hp = spec->out_pins[1]; in ca0132_config()
9869 spec->unsol_tag_front_hp = spec->out_pins[2]; in ca0132_config()
9871 spec->adcs[0] = 0x07; /* Rear Mic / Line-in */ in ca0132_config()
9872 spec->adcs[1] = 0x08; /* Front Mic, but only if no DSP */ in ca0132_config()
9873 spec->adcs[2] = 0x0a; /* what u hear */ in ca0132_config()
9875 spec->num_inputs = 2; in ca0132_config()
9876 spec->input_pins[0] = 0x12; /* Rear Mic / Line-in */ in ca0132_config()
9877 spec->input_pins[1] = 0x13; /* What U Hear */ in ca0132_config()
9878 spec->shared_mic_nid = 0x7; in ca0132_config()
9879 spec->unsol_tag_amic1 = spec->input_pins[0]; in ca0132_config()
9882 spec->dig_out = 0x05; in ca0132_config()
9883 spec->multiout.dig_out_nid = spec->dig_out; in ca0132_config()
9886 spec->num_outputs = 2; in ca0132_config()
9887 spec->out_pins[0] = 0x0b; /* speaker out */ in ca0132_config()
9888 spec->out_pins[1] = 0x10; /* headphone out */ in ca0132_config()
9889 spec->shared_out_nid = 0x2; in ca0132_config()
9890 spec->unsol_tag_hp = spec->out_pins[1]; in ca0132_config()
9892 spec->adcs[0] = 0x7; /* digital mic / analog mic1 */ in ca0132_config()
9893 spec->adcs[1] = 0x8; /* analog mic2 */ in ca0132_config()
9894 spec->adcs[2] = 0xa; /* what u hear */ in ca0132_config()
9896 spec->num_inputs = 3; in ca0132_config()
9897 spec->input_pins[0] = 0x12; in ca0132_config()
9898 spec->input_pins[1] = 0x11; in ca0132_config()
9899 spec->input_pins[2] = 0x13; in ca0132_config()
9900 spec->shared_mic_nid = 0x7; in ca0132_config()
9901 spec->unsol_tag_amic1 = spec->input_pins[0]; in ca0132_config()
9904 spec->dig_out = 0x05; in ca0132_config()
9905 spec->multiout.dig_out_nid = spec->dig_out; in ca0132_config()
9906 spec->dig_in = 0x09; in ca0132_config()
9911 static int ca0132_prepare_verbs(struct hda_codec *codec) in ca0132_prepare_verbs() argument
9915 struct ca0132_spec *spec = codec->spec; in ca0132_prepare_verbs()
9917 spec->chip_init_verbs = ca0132_init_verbs0; in ca0132_prepare_verbs()
9923 spec->desktop_init_verbs = ca0132_init_verbs1; in ca0132_prepare_verbs()
9924 spec->spec_init_verbs = kcalloc(NUM_SPEC_VERBS, in ca0132_prepare_verbs()
9927 if (!spec->spec_init_verbs) in ca0132_prepare_verbs()
9928 return -ENOMEM; in ca0132_prepare_verbs()
9931 spec->spec_init_verbs[0].nid = 0x0b; in ca0132_prepare_verbs()
9932 spec->spec_init_verbs[0].param = 0x78D; in ca0132_prepare_verbs()
9933 spec->spec_init_verbs[0].verb = 0x00; in ca0132_prepare_verbs()
9937 spec->spec_init_verbs[2].nid = 0x0b; in ca0132_prepare_verbs()
9938 spec->spec_init_verbs[2].param = AC_VERB_SET_EAPD_BTLENABLE; in ca0132_prepare_verbs()
9939 spec->spec_init_verbs[2].verb = 0x02; in ca0132_prepare_verbs()
9941 spec->spec_init_verbs[3].nid = 0x10; in ca0132_prepare_verbs()
9942 spec->spec_init_verbs[3].param = 0x78D; in ca0132_prepare_verbs()
9943 spec->spec_init_verbs[3].verb = 0x02; in ca0132_prepare_verbs()
9945 spec->spec_init_verbs[4].nid = 0x10; in ca0132_prepare_verbs()
9946 spec->spec_init_verbs[4].param = AC_VERB_SET_EAPD_BTLENABLE; in ca0132_prepare_verbs()
9947 spec->spec_init_verbs[4].verb = 0x02; in ca0132_prepare_verbs()
9950 /* Terminator: spec->spec_init_verbs[NUM_SPEC_VERBS-1] */ in ca0132_prepare_verbs()
9956 * Sound Blaster Z cards. However, they have different HDA codec subsystem
9960 static void sbz_detect_quirk(struct hda_codec *codec) in sbz_detect_quirk() argument
9962 struct ca0132_spec *spec = codec->spec; in sbz_detect_quirk()
9964 switch (codec->core.subsystem_id) { in sbz_detect_quirk()
9966 spec->quirk = QUIRK_ZXR; in sbz_detect_quirk()
9969 spec->quirk = QUIRK_ZXR_DBPRO; in sbz_detect_quirk()
9972 spec->quirk = QUIRK_SBZ; in sbz_detect_quirk()
9977 static int patch_ca0132(struct hda_codec *codec) in patch_ca0132() argument
9983 codec_dbg(codec, "patch_ca0132\n"); in patch_ca0132()
9987 return -ENOMEM; in patch_ca0132()
9988 codec->spec = spec; in patch_ca0132()
9989 spec->codec = codec; in patch_ca0132()
9991 /* Detect codec quirk */ in patch_ca0132()
9992 quirk = snd_pci_quirk_lookup(codec->bus->pci, ca0132_quirks); in patch_ca0132()
9994 spec->quirk = quirk->value; in patch_ca0132()
9996 spec->quirk = QUIRK_NONE; in patch_ca0132()
9998 sbz_detect_quirk(codec); in patch_ca0132()
10001 codec->patch_ops = dbpro_patch_ops; in patch_ca0132()
10003 codec->patch_ops = ca0132_patch_ops; in patch_ca0132()
10005 codec->pcm_format_first = 1; in patch_ca0132()
10006 codec->no_sticky_stream = 1; in patch_ca0132()
10009 spec->dsp_state = DSP_DOWNLOAD_INIT; in patch_ca0132()
10010 spec->num_mixers = 1; in patch_ca0132()
10015 spec->mixers[0] = desktop_mixer; in patch_ca0132()
10016 snd_hda_codec_set_name(codec, "Sound Blaster Z"); in patch_ca0132()
10019 spec->mixers[0] = desktop_mixer; in patch_ca0132()
10020 snd_hda_codec_set_name(codec, "Sound Blaster ZxR"); in patch_ca0132()
10025 spec->mixers[0] = desktop_mixer; in patch_ca0132()
10026 snd_hda_codec_set_name(codec, "Recon3D"); in patch_ca0132()
10029 spec->mixers[0] = r3di_mixer; in patch_ca0132()
10030 snd_hda_codec_set_name(codec, "Recon3Di"); in patch_ca0132()
10033 spec->mixers[0] = desktop_mixer; in patch_ca0132()
10034 snd_hda_codec_set_name(codec, "Sound BlasterX AE-5"); in patch_ca0132()
10037 spec->mixers[0] = desktop_mixer; in patch_ca0132()
10038 snd_hda_codec_set_name(codec, "Sound Blaster AE-7"); in patch_ca0132()
10041 spec->mixers[0] = ca0132_mixer; in patch_ca0132()
10052 spec->use_alt_controls = true; in patch_ca0132()
10053 spec->use_alt_functions = true; in patch_ca0132()
10054 spec->use_pci_mmio = true; in patch_ca0132()
10057 spec->use_alt_controls = true; in patch_ca0132()
10058 spec->use_alt_functions = true; in patch_ca0132()
10059 spec->use_pci_mmio = false; in patch_ca0132()
10062 spec->use_alt_controls = false; in patch_ca0132()
10063 spec->use_alt_functions = false; in patch_ca0132()
10064 spec->use_pci_mmio = false; in patch_ca0132()
10069 if (spec->use_pci_mmio) { in patch_ca0132()
10070 spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20); in patch_ca0132()
10071 if (spec->mem_base == NULL) { in patch_ca0132()
10072 codec_warn(codec, "pci_iomap failed! Setting quirk to QUIRK_NONE."); in patch_ca0132()
10073 spec->quirk = QUIRK_NONE; in patch_ca0132()
10078 spec->base_init_verbs = ca0132_base_init_verbs; in patch_ca0132()
10079 spec->base_exit_verbs = ca0132_base_exit_verbs; in patch_ca0132()
10081 INIT_DELAYED_WORK(&spec->unsol_hp_work, ca0132_unsol_hp_delayed); in patch_ca0132()
10083 ca0132_init_chip(codec); in patch_ca0132()
10085 ca0132_config(codec); in patch_ca0132()
10087 err = ca0132_prepare_verbs(codec); in patch_ca0132()
10091 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); in patch_ca0132()
10095 ca0132_setup_unsol(codec); in patch_ca0132()
10100 ca0132_free(codec); in patch_ca0132()
10114 MODULE_DESCRIPTION("Creative Sound Core3D codec");