Lines Matching full:codec

1135 	struct hda_codec *codec;  member
1513 * CA0132 codec access
1515 static unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid, in codec_send_command() argument
1519 response = snd_hda_codec_read(codec, nid, 0, verb, parm); in codec_send_command()
1525 static int codec_set_converter_format(struct hda_codec *codec, hda_nid_t nid, in codec_set_converter_format() argument
1528 return codec_send_command(codec, nid, VENDOR_CHIPIO_STREAM_FORMAT, in codec_set_converter_format()
1532 static int codec_set_converter_stream_channel(struct hda_codec *codec, in codec_set_converter_stream_channel() argument
1539 return codec_send_command(codec, nid, AC_VERB_SET_CHANNEL_STREAMID, in codec_set_converter_stream_channel()
1544 static int chipio_send(struct hda_codec *codec, in chipio_send() argument
1553 res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_send()
1566 static int chipio_write_address(struct hda_codec *codec, in chipio_write_address() argument
1569 struct ca0132_spec *spec = codec->spec; in chipio_write_address()
1576 res = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_LOW, in chipio_write_address()
1581 res = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_HIGH, in chipio_write_address()
1593 static int chipio_write_data(struct hda_codec *codec, unsigned int data) in chipio_write_data() argument
1595 struct ca0132_spec *spec = codec->spec; in chipio_write_data()
1599 res = chipio_send(codec, VENDOR_CHIPIO_DATA_LOW, data & 0xffff); in chipio_write_data()
1603 res = chipio_send(codec, VENDOR_CHIPIO_DATA_HIGH, in chipio_write_data()
1617 static int chipio_write_data_multiple(struct hda_codec *codec, in chipio_write_data_multiple() argument
1624 codec_dbg(codec, "chipio_write_data null ptr\n"); in chipio_write_data_multiple()
1629 status = chipio_write_data(codec, *data++); in chipio_write_data_multiple()
1638 static int chipio_read_data(struct hda_codec *codec, unsigned int *data) in chipio_read_data() argument
1640 struct ca0132_spec *spec = codec->spec; in chipio_read_data()
1644 res = chipio_send(codec, VENDOR_CHIPIO_HIC_POST_READ, 0); in chipio_read_data()
1648 res = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in chipio_read_data()
1653 *data = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_read_data()
1669 static int chipio_write(struct hda_codec *codec, in chipio_write() argument
1672 struct ca0132_spec *spec = codec->spec; in chipio_write()
1678 err = chipio_write_address(codec, chip_addx); in chipio_write()
1682 err = chipio_write_data(codec, data); in chipio_write()
1695 static int chipio_write_no_mutex(struct hda_codec *codec, in chipio_write_no_mutex() argument
1702 err = chipio_write_address(codec, chip_addx); in chipio_write_no_mutex()
1706 err = chipio_write_data(codec, data); in chipio_write_no_mutex()
1718 static int chipio_write_multiple(struct hda_codec *codec, in chipio_write_multiple() argument
1723 struct ca0132_spec *spec = codec->spec; in chipio_write_multiple()
1727 status = chipio_write_address(codec, chip_addx); in chipio_write_multiple()
1731 status = chipio_write_data_multiple(codec, data, count); in chipio_write_multiple()
1742 static int chipio_read(struct hda_codec *codec, in chipio_read() argument
1745 struct ca0132_spec *spec = codec->spec; in chipio_read()
1751 err = chipio_write_address(codec, chip_addx); in chipio_read()
1755 err = chipio_read_data(codec, data); in chipio_read()
1767 static void chipio_set_control_flag(struct hda_codec *codec, in chipio_set_control_flag() argument
1776 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_flag()
1783 static void chipio_set_control_param(struct hda_codec *codec, in chipio_set_control_param() argument
1786 struct ca0132_spec *spec = codec->spec; in chipio_set_control_param()
1791 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param()
1795 if (chipio_send(codec, VENDOR_CHIPIO_STATUS, 0) == 0) { in chipio_set_control_param()
1796 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param()
1799 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param()
1810 static void chipio_set_control_param_no_mutex(struct hda_codec *codec, in chipio_set_control_param_no_mutex() argument
1817 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param_no_mutex()
1820 if (chipio_send(codec, VENDOR_CHIPIO_STATUS, 0) == 0) { in chipio_set_control_param_no_mutex()
1821 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param_no_mutex()
1824 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_set_control_param_no_mutex()
1834 static void chipio_set_stream_source_dest(struct hda_codec *codec, in chipio_set_stream_source_dest() argument
1837 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_source_dest()
1839 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_source_dest()
1841 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_source_dest()
1848 static void chipio_set_stream_channels(struct hda_codec *codec, in chipio_set_stream_channels() argument
1851 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_channels()
1853 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_channels()
1860 static void chipio_set_stream_control(struct hda_codec *codec, in chipio_set_stream_control() argument
1863 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_control()
1865 chipio_set_control_param_no_mutex(codec, in chipio_set_stream_control()
1872 static void chipio_get_stream_control(struct hda_codec *codec, in chipio_get_stream_control() argument
1875 chipio_set_control_param_no_mutex(codec, in chipio_get_stream_control()
1877 *enable = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_get_stream_control()
1885 static void chipio_set_conn_rate_no_mutex(struct hda_codec *codec, in chipio_set_conn_rate_no_mutex() argument
1888 chipio_set_control_param_no_mutex(codec, in chipio_set_conn_rate_no_mutex()
1890 chipio_set_control_param_no_mutex(codec, in chipio_set_conn_rate_no_mutex()
1897 static void chipio_set_conn_rate(struct hda_codec *codec, in chipio_set_conn_rate() argument
1900 chipio_set_control_param(codec, CONTROL_PARAM_CONN_POINT_ID, connid); in chipio_set_conn_rate()
1901 chipio_set_control_param(codec, CONTROL_PARAM_CONN_POINT_SAMPLE_RATE, in chipio_set_conn_rate()
1910 static void chipio_8051_write_direct(struct hda_codec *codec, in chipio_8051_write_direct() argument
1916 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, verb, addr); in chipio_8051_write_direct()
1927 static void chipio_8051_set_address(struct hda_codec *codec, unsigned int addr) in chipio_8051_set_address() argument
1933 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_address()
1938 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_address()
1942 static void chipio_8051_set_data(struct hda_codec *codec, unsigned int data) in chipio_8051_set_data() argument
1945 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_data()
1949 static unsigned int chipio_8051_get_data(struct hda_codec *codec) in chipio_8051_get_data() argument
1951 return snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_get_data()
1956 static void chipio_8051_set_data_pll(struct hda_codec *codec, unsigned int data) in chipio_8051_set_data_pll() argument
1959 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in chipio_8051_set_data_pll()
1963 static void chipio_8051_write_exram(struct hda_codec *codec, in chipio_8051_write_exram() argument
1966 struct ca0132_spec *spec = codec->spec; in chipio_8051_write_exram()
1970 chipio_8051_set_address(codec, addr); in chipio_8051_write_exram()
1971 chipio_8051_set_data(codec, data); in chipio_8051_write_exram()
1976 static void chipio_8051_write_exram_no_mutex(struct hda_codec *codec, in chipio_8051_write_exram_no_mutex() argument
1979 chipio_8051_set_address(codec, addr); in chipio_8051_write_exram_no_mutex()
1980 chipio_8051_set_data(codec, data); in chipio_8051_write_exram_no_mutex()
1984 static void chipio_8051_read_exram(struct hda_codec *codec, in chipio_8051_read_exram() argument
1987 chipio_8051_set_address(codec, addr); in chipio_8051_read_exram()
1988 *data = chipio_8051_get_data(codec); in chipio_8051_read_exram()
1991 static void chipio_8051_write_pll_pmu(struct hda_codec *codec, in chipio_8051_write_pll_pmu() argument
1994 struct ca0132_spec *spec = codec->spec; in chipio_8051_write_pll_pmu()
1998 chipio_8051_set_address(codec, addr & 0xff); in chipio_8051_write_pll_pmu()
1999 chipio_8051_set_data_pll(codec, data); in chipio_8051_write_pll_pmu()
2004 static void chipio_8051_write_pll_pmu_no_mutex(struct hda_codec *codec, in chipio_8051_write_pll_pmu_no_mutex() argument
2007 chipio_8051_set_address(codec, addr & 0xff); in chipio_8051_write_pll_pmu_no_mutex()
2008 chipio_8051_set_data_pll(codec, data); in chipio_8051_write_pll_pmu_no_mutex()
2014 static void chipio_enable_clocks(struct hda_codec *codec) in chipio_enable_clocks() argument
2016 struct ca0132_spec *spec = codec->spec; in chipio_enable_clocks()
2020 chipio_8051_write_pll_pmu_no_mutex(codec, 0x00, 0xff); in chipio_enable_clocks()
2021 chipio_8051_write_pll_pmu_no_mutex(codec, 0x05, 0x0b); in chipio_enable_clocks()
2022 chipio_8051_write_pll_pmu_no_mutex(codec, 0x06, 0xff); in chipio_enable_clocks()
2030 static int dspio_send(struct hda_codec *codec, unsigned int reg, in dspio_send() argument
2038 res = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, reg, data); in dspio_send()
2050 static void dspio_write_wait(struct hda_codec *codec) in dspio_write_wait() argument
2056 status = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, in dspio_write_wait()
2068 static int dspio_write(struct hda_codec *codec, unsigned int scp_data) in dspio_write() argument
2070 struct ca0132_spec *spec = codec->spec; in dspio_write()
2073 dspio_write_wait(codec); in dspio_write()
2076 status = dspio_send(codec, VENDOR_DSPIO_SCP_WRITE_DATA_LOW, in dspio_write()
2081 status = dspio_send(codec, VENDOR_DSPIO_SCP_WRITE_DATA_HIGH, in dspio_write()
2087 status = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, in dspio_write()
2099 static int dspio_write_multiple(struct hda_codec *codec, in dspio_write_multiple() argument
2110 status = dspio_write(codec, *buffer++); in dspio_write_multiple()
2119 static int dspio_read(struct hda_codec *codec, unsigned int *data) in dspio_read() argument
2123 status = dspio_send(codec, VENDOR_DSPIO_SCP_POST_READ_DATA, 0); in dspio_read()
2127 status = dspio_send(codec, VENDOR_DSPIO_STATUS, 0); in dspio_read()
2132 *data = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, in dspio_read()
2138 static int dspio_read_multiple(struct hda_codec *codec, unsigned int *buffer, in dspio_read_multiple() argument
2152 status = dspio_read(codec, buffer++); in dspio_read_multiple()
2161 status = dspio_read(codec, &dummy); in dspio_read_multiple()
2231 static void dspio_clear_response_queue(struct hda_codec *codec) in dspio_clear_response_queue() argument
2239 status = dspio_read(codec, &dummy); in dspio_clear_response_queue()
2243 static int dspio_get_response_data(struct hda_codec *codec) in dspio_get_response_data() argument
2245 struct ca0132_spec *spec = codec->spec; in dspio_get_response_data()
2249 if (dspio_read(codec, &data) < 0) in dspio_get_response_data()
2256 dspio_read_multiple(codec, spec->scp_resp_data, in dspio_get_response_data()
2267 static int dspio_send_scp_message(struct hda_codec *codec, in dspio_send_scp_message() argument
2274 struct ca0132_spec *spec = codec->spec; in dspio_send_scp_message()
2313 status = dspio_write_multiple(codec, (unsigned int *)send_buf, in dspio_send_scp_message()
2345 * @codec: the HDA codec
2357 static int dspio_scp(struct hda_codec *codec, in dspio_scp() argument
2374 codec_dbg(codec, "dspio_scp get but has no buffer\n"); in dspio_scp()
2379 codec_dbg(codec, "dspio_scp bad resp buf len parms\n"); in dspio_scp()
2392 status = dspio_send_scp_message(codec, (unsigned char *)&scp_send, in dspio_scp()
2397 codec_dbg(codec, "dspio_scp: send scp msg failed\n"); in dspio_scp()
2416 codec_dbg(codec, "reply too long for buf\n"); in dspio_scp()
2419 codec_dbg(codec, "RetLen and HdrLen .NE.\n"); in dspio_scp()
2422 codec_dbg(codec, "NULL reply\n"); in dspio_scp()
2429 codec_dbg(codec, "reply ill-formed or errflag set\n"); in dspio_scp()
2439 static int dspio_set_param(struct hda_codec *codec, int mod_id, in dspio_set_param() argument
2442 return dspio_scp(codec, mod_id, src_id, req, SCP_SET, data, len, NULL, in dspio_set_param()
2446 static int dspio_set_uint_param(struct hda_codec *codec, int mod_id, in dspio_set_uint_param() argument
2449 return dspio_set_param(codec, mod_id, 0x20, req, &data, in dspio_set_uint_param()
2456 static int dspio_alloc_dma_chan(struct hda_codec *codec, unsigned int *dma_chan) in dspio_alloc_dma_chan() argument
2461 codec_dbg(codec, " dspio_alloc_dma_chan() -- begin\n"); in dspio_alloc_dma_chan()
2462 status = dspio_scp(codec, MASTERCONTROL, 0x20, in dspio_alloc_dma_chan()
2467 codec_dbg(codec, "dspio_alloc_dma_chan: SCP Failed\n"); in dspio_alloc_dma_chan()
2472 codec_dbg(codec, "no free dma channels to allocate\n"); in dspio_alloc_dma_chan()
2476 codec_dbg(codec, "dspio_alloc_dma_chan: chan=%d\n", *dma_chan); in dspio_alloc_dma_chan()
2477 codec_dbg(codec, " dspio_alloc_dma_chan() -- complete\n"); in dspio_alloc_dma_chan()
2485 static int dspio_free_dma_chan(struct hda_codec *codec, unsigned int dma_chan) in dspio_free_dma_chan() argument
2490 codec_dbg(codec, " dspio_free_dma_chan() -- begin\n"); in dspio_free_dma_chan()
2491 codec_dbg(codec, "dspio_free_dma_chan: chan=%d\n", dma_chan); in dspio_free_dma_chan()
2493 status = dspio_scp(codec, MASTERCONTROL, 0x20, in dspio_free_dma_chan()
2498 codec_dbg(codec, "dspio_free_dma_chan: SCP Failed\n"); in dspio_free_dma_chan()
2502 codec_dbg(codec, " dspio_free_dma_chan() -- complete\n"); in dspio_free_dma_chan()
2510 static int dsp_set_run_state(struct hda_codec *codec) in dsp_set_run_state() argument
2516 err = chipio_read(codec, DSP_DBGCNTL_INST_OFFSET, &dbg_ctrl_reg); in dsp_set_run_state()
2526 err = chipio_write(codec, DSP_DBGCNTL_INST_OFFSET, in dsp_set_run_state()
2533 err = chipio_write(codec, DSP_DBGCNTL_INST_OFFSET, in dsp_set_run_state()
2545 static int dsp_reset(struct hda_codec *codec) in dsp_reset() argument
2550 codec_dbg(codec, "dsp_reset\n"); in dsp_reset()
2552 res = dspio_send(codec, VENDOR_DSPIO_DSP_INIT, 0); in dsp_reset()
2557 codec_dbg(codec, "dsp_reset timeout\n"); in dsp_reset()
2588 static bool dsp_is_dma_active(struct hda_codec *codec, unsigned int dma_chan) in dsp_is_dma_active() argument
2592 chipio_read(codec, DSPDMAC_CHNLSTART_INST_OFFSET, &dma_chnlstart_reg); in dsp_is_dma_active()
2598 static int dsp_dma_setup_common(struct hda_codec *codec, in dsp_dma_setup_common() argument
2610 codec_dbg(codec, "-- dsp_dma_setup_common() -- Begin ---------\n"); in dsp_dma_setup_common()
2613 codec_dbg(codec, "dma chan num invalid\n"); in dsp_dma_setup_common()
2617 if (dsp_is_dma_active(codec, dma_chan)) { in dsp_dma_setup_common()
2618 codec_dbg(codec, "dma already active\n"); in dsp_dma_setup_common()
2625 codec_dbg(codec, "invalid chip addr\n"); in dsp_dma_setup_common()
2632 codec_dbg(codec, " dsp_dma_setup_common() start reg pgm\n"); in dsp_dma_setup_common()
2635 status = chipio_read(codec, DSPDMAC_CHNLPROP_INST_OFFSET, in dsp_dma_setup_common()
2639 codec_dbg(codec, "read CHNLPROP Reg fail\n"); in dsp_dma_setup_common()
2642 codec_dbg(codec, "dsp_dma_setup_common() Read CHNLPROP\n"); in dsp_dma_setup_common()
2652 status = chipio_write(codec, DSPDMAC_CHNLPROP_INST_OFFSET, chnl_prop); in dsp_dma_setup_common()
2654 codec_dbg(codec, "write CHNLPROP Reg fail\n"); in dsp_dma_setup_common()
2657 codec_dbg(codec, " dsp_dma_setup_common() Write CHNLPROP\n"); in dsp_dma_setup_common()
2660 status = chipio_read(codec, DSPDMAC_ACTIVE_INST_OFFSET, in dsp_dma_setup_common()
2664 codec_dbg(codec, "read ACTIVE Reg fail\n"); in dsp_dma_setup_common()
2667 codec_dbg(codec, "dsp_dma_setup_common() Read ACTIVE\n"); in dsp_dma_setup_common()
2673 status = chipio_write(codec, DSPDMAC_ACTIVE_INST_OFFSET, active); in dsp_dma_setup_common()
2675 codec_dbg(codec, "write ACTIVE Reg fail\n"); in dsp_dma_setup_common()
2679 codec_dbg(codec, " dsp_dma_setup_common() Write ACTIVE\n"); in dsp_dma_setup_common()
2681 status = chipio_write(codec, DSPDMAC_AUDCHSEL_INST_OFFSET(dma_chan), in dsp_dma_setup_common()
2684 codec_dbg(codec, "write AUDCHSEL Reg fail\n"); in dsp_dma_setup_common()
2687 codec_dbg(codec, " dsp_dma_setup_common() Write AUDCHSEL\n"); in dsp_dma_setup_common()
2689 status = chipio_write(codec, DSPDMAC_IRQCNT_INST_OFFSET(dma_chan), in dsp_dma_setup_common()
2692 codec_dbg(codec, "write IRQCNT Reg fail\n"); in dsp_dma_setup_common()
2695 codec_dbg(codec, " dsp_dma_setup_common() Write IRQCNT\n"); in dsp_dma_setup_common()
2697 codec_dbg(codec, in dsp_dma_setup_common()
2703 codec_dbg(codec, "-- dsp_dma_setup_common() -- Complete ------\n"); in dsp_dma_setup_common()
2711 static int dsp_dma_setup(struct hda_codec *codec, in dsp_dma_setup() argument
2729 codec_dbg(codec, "-- dsp_dma_setup() -- Begin ---------\n"); in dsp_dma_setup()
2732 codec_dbg(codec, "count too big\n"); in dsp_dma_setup()
2738 codec_dbg(codec, "invalid chip addr\n"); in dsp_dma_setup()
2742 codec_dbg(codec, " dsp_dma_setup() start reg pgm\n"); in dsp_dma_setup()
2756 status = chipio_write(codec, DSPDMAC_DMACFG_INST_OFFSET(dma_chan), in dsp_dma_setup()
2759 codec_dbg(codec, "write DMACFG Reg fail\n"); in dsp_dma_setup()
2762 codec_dbg(codec, " dsp_dma_setup() Write DMACFG\n"); in dsp_dma_setup()
2767 status = chipio_write(codec, DSPDMAC_DSPADROFS_INST_OFFSET(dma_chan), in dsp_dma_setup()
2770 codec_dbg(codec, "write DSPADROFS Reg fail\n"); in dsp_dma_setup()
2773 codec_dbg(codec, " dsp_dma_setup() Write DSPADROFS\n"); in dsp_dma_setup()
2781 status = chipio_write(codec, in dsp_dma_setup()
2784 codec_dbg(codec, "write XFRCNT Reg fail\n"); in dsp_dma_setup()
2787 codec_dbg(codec, " dsp_dma_setup() Write XFRCNT\n"); in dsp_dma_setup()
2789 codec_dbg(codec, in dsp_dma_setup()
2794 codec_dbg(codec, "-- dsp_dma_setup() -- Complete ---------\n"); in dsp_dma_setup()
2802 static int dsp_dma_start(struct hda_codec *codec, in dsp_dma_start() argument
2808 codec_dbg(codec, "-- dsp_dma_start() -- Begin ---------\n"); in dsp_dma_start()
2811 status = chipio_read(codec, in dsp_dma_start()
2815 codec_dbg(codec, "read CHNLSTART reg fail\n"); in dsp_dma_start()
2818 codec_dbg(codec, "-- dsp_dma_start() Read CHNLSTART\n"); in dsp_dma_start()
2824 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET, in dsp_dma_start()
2827 codec_dbg(codec, "write CHNLSTART reg fail\n"); in dsp_dma_start()
2830 codec_dbg(codec, "-- dsp_dma_start() -- Complete ---------\n"); in dsp_dma_start()
2838 static int dsp_dma_stop(struct hda_codec *codec, in dsp_dma_stop() argument
2844 codec_dbg(codec, "-- dsp_dma_stop() -- Begin ---------\n"); in dsp_dma_stop()
2847 status = chipio_read(codec, in dsp_dma_stop()
2851 codec_dbg(codec, "read CHNLSTART reg fail\n"); in dsp_dma_stop()
2854 codec_dbg(codec, "-- dsp_dma_stop() Read CHNLSTART\n"); in dsp_dma_stop()
2859 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET, in dsp_dma_stop()
2862 codec_dbg(codec, "write CHNLSTART reg fail\n"); in dsp_dma_stop()
2865 codec_dbg(codec, "-- dsp_dma_stop() -- Complete ---------\n"); in dsp_dma_stop()
2873 * @codec: the HDA codec
2881 static int dsp_allocate_router_ports(struct hda_codec *codec, in dsp_allocate_router_ports() argument
2891 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_allocate_router_ports()
2899 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in dsp_allocate_router_ports()
2903 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in dsp_allocate_router_ports()
2907 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_allocate_router_ports()
2911 res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, in dsp_allocate_router_ports()
2922 static int dsp_free_router_ports(struct hda_codec *codec) in dsp_free_router_ports() argument
2926 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_free_router_ports()
2930 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in dsp_free_router_ports()
2934 status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); in dsp_free_router_ports()
2942 static int dsp_allocate_ports(struct hda_codec *codec, in dsp_allocate_ports() argument
2948 codec_dbg(codec, " dsp_allocate_ports() -- begin\n"); in dsp_allocate_ports()
2951 codec_dbg(codec, "bad rate multiple\n"); in dsp_allocate_ports()
2955 status = dsp_allocate_router_ports(codec, num_chans, in dsp_allocate_ports()
2958 codec_dbg(codec, " dsp_allocate_ports() -- complete\n"); in dsp_allocate_ports()
2963 static int dsp_allocate_ports_format(struct hda_codec *codec, in dsp_allocate_ports_format() argument
2974 codec_dbg(codec, "bad rate multiple\n"); in dsp_allocate_ports_format()
2980 return dsp_allocate_ports(codec, num_chans, rate_multi, port_map); in dsp_allocate_ports_format()
2986 static int dsp_free_ports(struct hda_codec *codec) in dsp_free_ports() argument
2990 codec_dbg(codec, " dsp_free_ports() -- begin\n"); in dsp_free_ports()
2992 status = dsp_free_router_ports(codec); in dsp_free_ports()
2994 codec_dbg(codec, "free router ports fail\n"); in dsp_free_ports()
2997 codec_dbg(codec, " dsp_free_ports() -- complete\n"); in dsp_free_ports()
3006 struct hda_codec *codec; member
3018 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()
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()
3070 snd_hda_codec_load_dsp_trigger(dma->codec, cmd); in dma_set_state()
3102 struct ca0132_spec *spec = dma->codec->spec; in dma_get_stream_id()
3153 static int dspxfr_hci_write(struct hda_codec *codec, in dspxfr_hci_write() argument
3161 codec_dbg(codec, "hci_write invalid params\n"); 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()
3182 * @codec: the HDA codec
3193 static int dspxfr_one_seg(struct hda_codec *codec, in dspxfr_one_seg() argument
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()
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()
3260 codec_dbg(codec, "dma_engine buffer NULL\n"); in dspxfr_one_seg()
3273 codec_dbg(codec, "frmsz zero\n"); 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()
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()
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()
3369 status = chipio_write_multiple(codec, chip_addx_remainder, in dspxfr_one_seg()
3379 * @codec: the HDA codec
3389 static int dspxfr_image(struct hda_codec *codec, in dspxfr_image() argument
3396 struct ca0132_spec *spec = codec->spec; 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()
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()
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()
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()
3500 snd_hda_codec_load_dsp_cleanup(codec, 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()
3527 * @codec: the HDA codec
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()
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()
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()
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()
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()
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()
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()
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()
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()
4224 static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid, in tuning_ctl_set() argument
4235 snd_hda_power_up(codec); in tuning_ctl_set()
4236 dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20, in tuning_ctl_set()
4239 snd_hda_power_down(codec); in tuning_ctl_set()
4247 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in tuning_ctl_get() local
4248 struct ca0132_spec *spec = codec->spec; in tuning_ctl_get()
4273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in voice_focus_ctl_put() local
4274 struct ca0132_spec *spec = codec->spec; in voice_focus_ctl_put()
4287 tuning_ctl_set(codec, nid, voice_focus_vals_lookup, idx); in voice_focus_ctl_put()
4308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in mic_svm_ctl_put() local
4309 struct ca0132_spec *spec = codec->spec; in mic_svm_ctl_put()
4322 tuning_ctl_set(codec, nid, mic_svm_vals_lookup, idx); in mic_svm_ctl_put()
4343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in equalizer_ctl_put() local
4344 struct ca0132_spec *spec = codec->spec; in equalizer_ctl_put()
4357 tuning_ctl_set(codec, nid, equalizer_vals_lookup, idx); in equalizer_ctl_put()
4365 static int add_tuning_control(struct hda_codec *codec, in add_tuning_control() argument
4402 return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); in add_tuning_control()
4405 static int add_tuning_ctls(struct hda_codec *codec) in add_tuning_ctls() argument
4411 err = add_tuning_control(codec, in add_tuning_ctls()
4423 static void ca0132_init_tuning_defaults(struct hda_codec *codec) in ca0132_init_tuning_defaults() argument
4425 struct ca0132_spec *spec = codec->spec; in ca0132_init_tuning_defaults()
4445 static int ca0132_select_out(struct hda_codec *codec) in ca0132_select_out() argument
4447 struct ca0132_spec *spec = codec->spec; in ca0132_select_out()
4454 codec_dbg(codec, "ca0132_select_out\n"); in ca0132_select_out()
4456 snd_hda_power_up_pm(codec); in ca0132_select_out()
4461 jack_present = snd_hda_jack_detect(codec, spec->unsol_tag_hp); in ca0132_select_out()
4472 codec_dbg(codec, "ca0132_select_out speaker\n"); in ca0132_select_out()
4475 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); in ca0132_select_out()
4480 err = dspio_set_uint_param(codec, 0x8f, 0x00, tmp); in ca0132_select_out()
4485 snd_hda_codec_write(codec, spec->out_pins[1], 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()
4491 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4495 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0, in ca0132_select_out()
4497 snd_hda_set_pin_ctl(codec, spec->out_pins[1], in ca0132_select_out()
4500 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0, in ca0132_select_out()
4502 snd_hda_set_pin_ctl(codec, spec->out_pins[0], in ca0132_select_out()
4505 codec_dbg(codec, "ca0132_select_out hp\n"); in ca0132_select_out()
4508 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); in ca0132_select_out()
4513 err = dspio_set_uint_param(codec, 0x8f, 0x00, tmp); 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[0], 0, in ca0132_select_out()
4522 snd_hda_codec_write(codec, spec->out_pins[1], 0, in ca0132_select_out()
4524 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_select_out()
4528 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0, in ca0132_select_out()
4530 snd_hda_set_pin_ctl(codec, spec->out_pins[0], in ca0132_select_out()
4533 pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0, in ca0132_select_out()
4535 snd_hda_set_pin_ctl(codec, spec->out_pins[1], in ca0132_select_out()
4540 snd_hda_power_down_pm(codec); in ca0132_select_out()
4545 static int ae5_headphone_gain_set(struct hda_codec *codec, long val);
4546 static int zxr_headphone_gain_set(struct hda_codec *codec, long val);
4547 static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val);
4549 static void ae5_mmio_select_out(struct hda_codec *codec) in ae5_mmio_select_out() argument
4551 struct ca0132_spec *spec = codec->spec; in ae5_mmio_select_out()
4561 ca0113_mmio_command_set(codec, out_cmds->group[i], in ae5_mmio_select_out()
4566 static int ca0132_alt_set_full_range_speaker(struct hda_codec *codec) in ca0132_alt_set_full_range_speaker() argument
4568 struct ca0132_spec *spec = codec->spec; in ca0132_alt_set_full_range_speaker()
4580 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4587 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4592 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4602 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_set_full_range_speaker()
4611 static int ca0132_alt_surround_set_bass_redirection(struct hda_codec *codec, in ca0132_alt_surround_set_bass_redirection() argument
4614 struct ca0132_spec *spec = codec->spec; in ca0132_alt_surround_set_bass_redirection()
4624 err = dspio_set_uint_param(codec, 0x96, SPEAKER_BASS_REDIRECT, tmp); in ca0132_alt_surround_set_bass_redirection()
4631 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_surround_set_bass_redirection()
4644 static void ca0132_alt_select_out_get_quirk_data(struct hda_codec *codec, in ca0132_alt_select_out_get_quirk_data() argument
4647 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_out_get_quirk_data()
4660 static int ca0132_alt_select_out_quirk_set(struct hda_codec *codec) in ca0132_alt_select_out_quirk_set() argument
4664 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_out_quirk_set()
4668 ca0132_alt_select_out_get_quirk_data(codec, &quirk_data); in ca0132_alt_select_out_quirk_set()
4674 ae5_mmio_select_out(codec); in ca0132_alt_select_out_quirk_set()
4677 gpio_data = snd_hda_codec_read(codec, codec->core.afg, 0, in ca0132_alt_select_out_quirk_set()
4685 snd_hda_codec_write(codec, codec->core.afg, 0, in ca0132_alt_select_out_quirk_set()
4691 ca0113_mmio_gpio_set(codec, out_info->mmio_gpio_pin[i], in ca0132_alt_select_out_quirk_set()
4698 err = dspio_set_uint_param(codec, in ca0132_alt_select_out_quirk_set()
4707 chipio_set_control_param(codec, 0x0d, out_info->dac2port); in ca0132_alt_select_out_quirk_set()
4710 chipio_write(codec, out_info->chipio_write_addr, in ca0132_alt_select_out_quirk_set()
4717 ae5_headphone_gain_set(codec, 2); in ca0132_alt_select_out_quirk_set()
4719 zxr_headphone_gain_set(codec, 0); in ca0132_alt_select_out_quirk_set()
4722 ae5_headphone_gain_set(codec, in ca0132_alt_select_out_quirk_set()
4725 zxr_headphone_gain_set(codec, in ca0132_alt_select_out_quirk_set()
4733 static void ca0132_set_out_node_pincfg(struct hda_codec *codec, hda_nid_t nid, in ca0132_set_out_node_pincfg() argument
4738 pin_ctl = snd_hda_codec_read(codec, nid, 0, in ca0132_set_out_node_pincfg()
4743 snd_hda_set_pin_ctl(codec, nid, pin_ctl); in ca0132_set_out_node_pincfg()
4754 static int ca0132_alt_select_out(struct hda_codec *codec) in ca0132_alt_select_out() argument
4756 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_out()
4764 codec_dbg(codec, "%s\n", __func__); in ca0132_alt_select_out()
4766 snd_hda_power_up_pm(codec); in ca0132_alt_select_out()
4776 jack_present = snd_hda_jack_detect(codec, spec->unsol_tag_hp) || in ca0132_alt_select_out()
4777 snd_hda_jack_detect(codec, spec->unsol_tag_front_hp); in ca0132_alt_select_out()
4789 err = dspio_set_uint_param(codec, 0x96, SPEAKER_TUNING_MUTE, FLOAT_ONE); in ca0132_alt_select_out()
4793 if (ca0132_alt_select_out_quirk_set(codec) < 0) in ca0132_alt_select_out()
4798 codec_dbg(codec, "%s speaker\n", __func__); in ca0132_alt_select_out()
4801 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_alt_select_out()
4805 ca0132_set_out_node_pincfg(codec, spec->out_pins[1], 0, 0); in ca0132_alt_select_out()
4807 ca0132_set_out_node_pincfg(codec, spec->out_pins[0], 1, 0); in ca0132_alt_select_out()
4809 ca0132_set_out_node_pincfg(codec, spec->out_pins[2], 1, 0); in ca0132_alt_select_out()
4811 ca0132_set_out_node_pincfg(codec, spec->out_pins[3], 1, 0); in ca0132_alt_select_out()
4823 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); in ca0132_alt_select_out()
4829 codec_dbg(codec, "%s hp\n", __func__); in ca0132_alt_select_out()
4830 snd_hda_codec_write(codec, spec->out_pins[0], 0, in ca0132_alt_select_out()
4834 ca0132_set_out_node_pincfg(codec, spec->out_pins[0], 0, 0); in ca0132_alt_select_out()
4835 ca0132_set_out_node_pincfg(codec, spec->out_pins[2], 0, 0); in ca0132_alt_select_out()
4836 ca0132_set_out_node_pincfg(codec, spec->out_pins[3], 0, 0); in ca0132_alt_select_out()
4839 if (snd_hda_jack_detect(codec, spec->unsol_tag_front_hp)) in ca0132_alt_select_out()
4841 else if (snd_hda_jack_detect(codec, spec->unsol_tag_hp)) in ca0132_alt_select_out()
4844 ca0132_set_out_node_pincfg(codec, headphone_nid, 1, 1); in ca0132_alt_select_out()
4847 err = dspio_set_uint_param(codec, 0x80, 0x04, FLOAT_ONE); in ca0132_alt_select_out()
4849 err = dspio_set_uint_param(codec, 0x80, 0x04, FLOAT_ZERO); in ca0132_alt_select_out()
4861 ca0132_effects_set(codec, X_BASS, in ca0132_alt_select_out()
4865 err = dspio_set_uint_param(codec, 0x8f, 0x01, FLOAT_ZERO); in ca0132_alt_select_out()
4873 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_select_out()
4879 err = ca0132_alt_surround_set_bass_redirection(codec, in ca0132_alt_select_out()
4882 err = ca0132_alt_surround_set_bass_redirection(codec, 0); in ca0132_alt_select_out()
4885 err = dspio_set_uint_param(codec, 0x96, in ca0132_alt_select_out()
4891 err = ca0132_alt_set_full_range_speaker(codec); in ca0132_alt_select_out()
4897 snd_hda_power_down_pm(codec); in ca0132_alt_select_out()
4909 ca0132_alt_select_out(spec->codec); in ca0132_unsol_hp_delayed()
4911 ca0132_select_out(spec->codec); in ca0132_unsol_hp_delayed()
4913 jack = snd_hda_jack_tbl_get(spec->codec, spec->unsol_tag_hp); in ca0132_unsol_hp_delayed()
4916 snd_hda_jack_report_sync(spec->codec); in ca0132_unsol_hp_delayed()
4920 static void ca0132_set_dmic(struct hda_codec *codec, int enable);
4921 static int ca0132_mic_boost_set(struct hda_codec *codec, long val);
4922 static void resume_mic1(struct hda_codec *codec, unsigned int oldval);
4923 static int stop_mic1(struct hda_codec *codec);
4924 static int ca0132_cvoice_switch_set(struct hda_codec *codec);
4925 static int ca0132_alt_mic_boost_set(struct hda_codec *codec, long val);
4930 static int ca0132_set_vipsource(struct hda_codec *codec, int val) in ca0132_set_vipsource() argument
4932 struct ca0132_spec *spec = codec->spec; in ca0132_set_vipsource()
4941 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, 0); in ca0132_set_vipsource()
4942 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_set_vipsource()
4943 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_set_vipsource()
4948 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_vipsource()
4950 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_set_vipsource()
4952 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_16_000); in ca0132_set_vipsource()
4953 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_16_000); in ca0132_set_vipsource()
4958 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_vipsource()
4960 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_set_vipsource()
4962 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, val); in ca0132_set_vipsource()
4968 static int ca0132_alt_set_vipsource(struct hda_codec *codec, int val) in ca0132_alt_set_vipsource() argument
4970 struct ca0132_spec *spec = codec->spec; in ca0132_alt_set_vipsource()
4976 codec_dbg(codec, "%s\n", __func__); in ca0132_alt_set_vipsource()
4978 chipio_set_stream_control(codec, 0x03, 0); in ca0132_alt_set_vipsource()
4979 chipio_set_stream_control(codec, 0x04, 0); in ca0132_alt_set_vipsource()
4984 codec_dbg(codec, "%s: off.", __func__); in ca0132_alt_set_vipsource()
4985 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, 0); in ca0132_alt_set_vipsource()
4988 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_alt_set_vipsource()
4990 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_set_vipsource()
4991 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_set_vipsource()
4993 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_set_vipsource()
5005 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_set_vipsource()
5008 codec_dbg(codec, "%s: on.", __func__); in ca0132_alt_set_vipsource()
5009 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_16_000); in ca0132_alt_set_vipsource()
5010 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_16_000); in ca0132_alt_set_vipsource()
5012 chipio_set_conn_rate(codec, 0x0F, SR_16_000); in ca0132_alt_set_vipsource()
5018 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_set_vipsource()
5021 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_alt_set_vipsource()
5024 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, val); in ca0132_alt_set_vipsource()
5027 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_set_vipsource()
5028 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_set_vipsource()
5039 static int ca0132_select_mic(struct hda_codec *codec) in ca0132_select_mic() argument
5041 struct ca0132_spec *spec = codec->spec; in ca0132_select_mic()
5045 codec_dbg(codec, "ca0132_select_mic\n"); in ca0132_select_mic()
5047 snd_hda_power_up_pm(codec); in ca0132_select_mic()
5052 jack_present = snd_hda_jack_detect(codec, spec->unsol_tag_amic1); in ca0132_select_mic()
5064 chipio_set_conn_rate(codec, MEM_CONNID_DMIC, SR_32_000); in ca0132_select_mic()
5065 ca0132_set_dmic(codec, 1); in ca0132_select_mic()
5066 ca0132_mic_boost_set(codec, 0); in ca0132_select_mic()
5068 ca0132_effects_set(codec, VOICE_FOCUS, in ca0132_select_mic()
5073 chipio_set_conn_rate(codec, MEM_CONNID_DMIC, SR_96_000); in ca0132_select_mic()
5074 ca0132_set_dmic(codec, 0); in ca0132_select_mic()
5075 ca0132_mic_boost_set(codec, spec->cur_mic_boost); in ca0132_select_mic()
5077 ca0132_effects_set(codec, VOICE_FOCUS, 0); in ca0132_select_mic()
5080 snd_hda_power_down_pm(codec); in ca0132_select_mic()
5091 static int ca0132_alt_select_in(struct hda_codec *codec) in ca0132_alt_select_in() argument
5093 struct ca0132_spec *spec = codec->spec; in ca0132_alt_select_in()
5096 codec_dbg(codec, "%s\n", __func__); in ca0132_alt_select_in()
5098 snd_hda_power_up_pm(codec); in ca0132_alt_select_in()
5100 chipio_set_stream_control(codec, 0x03, 0); in ca0132_alt_select_in()
5101 chipio_set_stream_control(codec, 0x04, 0); in ca0132_alt_select_in()
5110 ca0113_mmio_gpio_set(codec, 0, false); in ca0132_alt_select_in()
5117 r3di_gpio_mic_set(codec, R3DI_REAR_MIC); in ca0132_alt_select_in()
5121 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ca0132_alt_select_in()
5125 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ca0132_alt_select_in()
5127 chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, in ca0132_alt_select_in()
5129 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, in ca0132_alt_select_in()
5131 dspio_set_uint_param(codec, 0x80, 0x01, FLOAT_ZERO); in ca0132_alt_select_in()
5138 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_select_in()
5139 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_select_in()
5141 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_select_in()
5143 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_select_in()
5145 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_select_in()
5146 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_select_in()
5149 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5150 chipio_write(codec, 0x18B09C, 0x0000000C); in ca0132_alt_select_in()
5153 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5154 chipio_write(codec, 0x18B09C, 0x000000CC); in ca0132_alt_select_in()
5157 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5158 chipio_write(codec, 0x18B09C, 0x0000004C); in ca0132_alt_select_in()
5163 ca0132_alt_mic_boost_set(codec, spec->mic_boost_enum_val); in ca0132_alt_select_in()
5166 ca0132_mic_boost_set(codec, 0); in ca0132_alt_select_in()
5170 ca0113_mmio_gpio_set(codec, 0, false); in ca0132_alt_select_in()
5173 r3di_gpio_mic_set(codec, R3DI_REAR_MIC); in ca0132_alt_select_in()
5176 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ca0132_alt_select_in()
5179 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x3f); in ca0132_alt_select_in()
5180 chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, in ca0132_alt_select_in()
5182 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, in ca0132_alt_select_in()
5184 dspio_set_uint_param(codec, 0x80, 0x01, FLOAT_ZERO); in ca0132_alt_select_in()
5190 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_select_in()
5191 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_select_in()
5193 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_select_in()
5199 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_select_in()
5204 chipio_write(codec, 0x18B098, 0x00000000); in ca0132_alt_select_in()
5205 chipio_write(codec, 0x18B09C, 0x00000000); in ca0132_alt_select_in()
5210 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_select_in()
5211 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_select_in()
5217 ca0113_mmio_gpio_set(codec, 0, true); in ca0132_alt_select_in()
5218 ca0113_mmio_gpio_set(codec, 5, false); in ca0132_alt_select_in()
5222 r3di_gpio_mic_set(codec, R3DI_FRONT_MIC); in ca0132_alt_select_in()
5226 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x3f); in ca0132_alt_select_in()
5234 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_select_in()
5235 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_select_in()
5237 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_select_in()
5239 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_select_in()
5241 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_select_in()
5242 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_select_in()
5246 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5247 chipio_write(codec, 0x18B09C, 0x000000CC); in ca0132_alt_select_in()
5250 chipio_write(codec, 0x18B098, 0x0000000C); in ca0132_alt_select_in()
5251 chipio_write(codec, 0x18B09C, 0x0000004C); in ca0132_alt_select_in()
5256 ca0132_alt_mic_boost_set(codec, spec->mic_boost_enum_val); in ca0132_alt_select_in()
5259 ca0132_cvoice_switch_set(codec); in ca0132_alt_select_in()
5261 snd_hda_power_down_pm(codec); in ca0132_alt_select_in()
5268 static bool ca0132_is_vnode_effective(struct hda_codec *codec, in ca0132_is_vnode_effective() argument
5272 struct ca0132_spec *spec = codec->spec; in ca0132_is_vnode_effective()
5296 static int ca0132_voicefx_set(struct hda_codec *codec, int enable) in ca0132_voicefx_set() argument
5298 struct ca0132_spec *spec = codec->spec; in ca0132_voicefx_set()
5309 dspio_set_uint_param(codec, ca0132_voicefx.mid, in ca0132_voicefx_set()
5318 static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val) in ca0132_effects_set() argument
5320 struct ca0132_spec *spec = codec->spec; in ca0132_effects_set()
5365 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_effects_set()
5384 dspio_set_uint_param(codec, 0x47, 0x00, tmp); in ca0132_effects_set()
5393 codec_dbg(codec, "ca0132_effect_set: nid=0x%x, val=%ld\n", in ca0132_effects_set()
5397 err = dspio_set_uint_param(codec, ca0132_effects[idx].mid, in ca0132_effects_set()
5409 static int ca0132_pe_switch_set(struct hda_codec *codec) in ca0132_pe_switch_set() argument
5411 struct ca0132_spec *spec = codec->spec; in ca0132_pe_switch_set()
5415 codec_dbg(codec, "ca0132_pe_switch_set: val=%ld\n", in ca0132_pe_switch_set()
5419 ca0132_alt_select_out(codec); in ca0132_pe_switch_set()
5425 ret |= ca0132_effects_set(codec, nid, spec->effects_switch[i]); in ca0132_pe_switch_set()
5431 static int stop_mic1(struct hda_codec *codec) in stop_mic1() argument
5433 struct ca0132_spec *spec = codec->spec; in stop_mic1()
5434 unsigned int oldval = snd_hda_codec_read(codec, spec->adcs[0], 0, in stop_mic1()
5437 snd_hda_codec_write(codec, spec->adcs[0], 0, in stop_mic1()
5444 static void resume_mic1(struct hda_codec *codec, unsigned int oldval) in resume_mic1() argument
5446 struct ca0132_spec *spec = codec->spec; in resume_mic1()
5449 snd_hda_codec_write(codec, spec->adcs[0], 0, in resume_mic1()
5457 static int ca0132_cvoice_switch_set(struct hda_codec *codec) in ca0132_cvoice_switch_set() argument
5459 struct ca0132_spec *spec = codec->spec; in ca0132_cvoice_switch_set()
5464 codec_dbg(codec, "ca0132_cvoice_switch_set: val=%ld\n", in ca0132_cvoice_switch_set()
5471 ret |= ca0132_effects_set(codec, nid, spec->effects_switch[i]); in ca0132_cvoice_switch_set()
5474 ret |= ca0132_voicefx_set(codec, (spec->voicefx_val ? 1 : 0)); in ca0132_cvoice_switch_set()
5477 oldval = stop_mic1(codec); in ca0132_cvoice_switch_set()
5479 ret |= ca0132_alt_set_vipsource(codec, 1); in ca0132_cvoice_switch_set()
5481 ret |= ca0132_set_vipsource(codec, 1); in ca0132_cvoice_switch_set()
5482 resume_mic1(codec, oldval); in ca0132_cvoice_switch_set()
5486 static int ca0132_mic_boost_set(struct hda_codec *codec, long val) in ca0132_mic_boost_set() argument
5488 struct ca0132_spec *spec = codec->spec; in ca0132_mic_boost_set()
5492 ret = snd_hda_codec_amp_update(codec, spec->input_pins[0], 0, in ca0132_mic_boost_set()
5495 ret = snd_hda_codec_amp_update(codec, spec->input_pins[0], 0, in ca0132_mic_boost_set()
5501 static int ca0132_alt_mic_boost_set(struct hda_codec *codec, long val) in ca0132_alt_mic_boost_set() argument
5503 struct ca0132_spec *spec = codec->spec; in ca0132_alt_mic_boost_set()
5506 ret = snd_hda_codec_amp_update(codec, spec->input_pins[0], 0, in ca0132_alt_mic_boost_set()
5511 static int ae5_headphone_gain_set(struct hda_codec *codec, long val) in ae5_headphone_gain_set() argument
5516 ca0113_mmio_command_set(codec, 0x48, 0x11 + i, in ae5_headphone_gain_set()
5525 static int zxr_headphone_gain_set(struct hda_codec *codec, long val) in zxr_headphone_gain_set() argument
5527 ca0113_mmio_gpio_set(codec, 1, val); in zxr_headphone_gain_set()
5535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_vnode_switch_set() local
5540 struct ca0132_spec *spec = codec->spec; in ca0132_vnode_switch_set()
5548 ca0132_alt_select_out(codec); in ca0132_vnode_switch_set()
5550 ca0132_select_out(codec); in ca0132_vnode_switch_set()
5559 ca0132_select_mic(codec); in ca0132_vnode_switch_set()
5565 ca0132_alt_select_out(codec); in ca0132_vnode_switch_set()
5567 ca0132_select_out(codec); in ca0132_vnode_switch_set()
5572 ca0132_select_mic(codec); in ca0132_vnode_switch_set()
5577 effective = ca0132_is_vnode_effective(codec, nid, &shared_nid); in ca0132_vnode_switch_set()
5583 mutex_lock(&codec->control_mutex); in ca0132_vnode_switch_set()
5589 mutex_unlock(&codec->control_mutex); in ca0132_vnode_switch_set()
5596 static void ca0132_alt_bass_redirection_xover_set(struct hda_codec *codec, in ca0132_alt_bass_redirection_xover_set() argument
5599 snd_hda_power_up(codec); in ca0132_alt_bass_redirection_xover_set()
5601 dspio_set_param(codec, 0x96, 0x20, SPEAKER_BASS_REDIRECT_XOVER_FREQ, in ca0132_alt_bass_redirection_xover_set()
5604 snd_hda_power_down(codec); in ca0132_alt_bass_redirection_xover_set()
5616 static int ca0132_alt_slider_ctl_set(struct hda_codec *codec, hda_nid_t nid, in ca0132_alt_slider_ctl_set() argument
5630 snd_hda_power_up(codec); in ca0132_alt_slider_ctl_set()
5636 dspio_set_param(codec, ca0132_effects[i].mid, 0x20, in ca0132_alt_slider_ctl_set()
5645 dspio_set_param(codec, ca0132_effects[i].mid, 0x20, in ca0132_alt_slider_ctl_set()
5650 snd_hda_power_down(codec); in ca0132_alt_slider_ctl_set()
5658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_xbass_xover_slider_ctl_get() local
5659 struct ca0132_spec *spec = codec->spec; in ca0132_alt_xbass_xover_slider_ctl_get()
5674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_slider_ctl_get() local
5675 struct ca0132_spec *spec = codec->spec; in ca0132_alt_slider_ctl_get()
5717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_xbass_xover_slider_put() local
5718 struct ca0132_spec *spec = codec->spec; in ca0132_alt_xbass_xover_slider_put()
5737 ca0132_alt_bass_redirection_xover_set(codec, *cur_val); in ca0132_alt_xbass_xover_slider_put()
5739 ca0132_alt_slider_ctl_set(codec, nid, float_xbass_xover_lookup, idx); in ca0132_alt_xbass_xover_slider_put()
5747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_effect_slider_put() local
5748 struct ca0132_spec *spec = codec->spec; in ca0132_alt_effect_slider_put()
5761 ca0132_alt_slider_ctl_set(codec, nid, float_zero_to_one_lookup, idx); in ca0132_alt_effect_slider_put()
5794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_mic_boost_get() local
5795 struct ca0132_spec *spec = codec->spec; in ca0132_alt_mic_boost_get()
5804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_mic_boost_put() local
5805 struct ca0132_spec *spec = codec->spec; in ca0132_alt_mic_boost_put()
5812 codec_dbg(codec, "ca0132_alt_mic_boost: boost=%d\n", in ca0132_alt_mic_boost_put()
5818 ca0132_alt_mic_boost_set(codec, spec->mic_boost_enum_val); in ca0132_alt_mic_boost_put()
5848 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_headphone_gain_get() local
5849 struct ca0132_spec *spec = codec->spec; in ae5_headphone_gain_get()
5858 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_headphone_gain_put() local
5859 struct ca0132_spec *spec = codec->spec; in ae5_headphone_gain_put()
5866 codec_dbg(codec, "ae5_headphone_gain: boost=%d\n", in ae5_headphone_gain_put()
5872 ae5_headphone_gain_set(codec, spec->ae5_headphone_gain_val); in ae5_headphone_gain_put()
5901 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_sound_filter_get() local
5902 struct ca0132_spec *spec = codec->spec; in ae5_sound_filter_get()
5911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ae5_sound_filter_put() local
5912 struct ca0132_spec *spec = codec->spec; in ae5_sound_filter_put()
5919 codec_dbg(codec, "ae5_sound_filter: %s\n", in ae5_sound_filter_put()
5924 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, in ae5_sound_filter_put()
5951 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_input_source_get() local
5952 struct ca0132_spec *spec = codec->spec; in ca0132_alt_input_source_get()
5961 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_input_source_put() local
5962 struct ca0132_spec *spec = codec->spec; in ca0132_alt_input_source_put()
5976 codec_dbg(codec, "ca0132_alt_input_select: sel=%d, preset=%s\n", in ca0132_alt_input_source_put()
5981 ca0132_alt_select_in(codec); in ca0132_alt_input_source_put()
6003 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_output_select_get() local
6004 struct ca0132_spec *spec = codec->spec; in ca0132_alt_output_select_get()
6013 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_output_select_put() local
6014 struct ca0132_spec *spec = codec->spec; in ca0132_alt_output_select_put()
6022 codec_dbg(codec, "ca0132_alt_output_select: sel=%d, preset=%s\n", in ca0132_alt_output_select_put()
6030 ca0132_alt_select_out(codec); in ca0132_alt_output_select_put()
6054 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_speaker_channel_cfg_get() local
6055 struct ca0132_spec *spec = codec->spec; in ca0132_alt_speaker_channel_cfg_get()
6064 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_speaker_channel_cfg_put() local
6065 struct ca0132_spec *spec = codec->spec; in ca0132_alt_speaker_channel_cfg_put()
6072 codec_dbg(codec, "ca0132_alt_speaker_channels: sel=%d, channels=%s\n", in ca0132_alt_speaker_channel_cfg_put()
6078 ca0132_alt_select_out(codec); in ca0132_alt_speaker_channel_cfg_put()
6107 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_svm_setting_get() local
6108 struct ca0132_spec *spec = codec->spec; in ca0132_alt_svm_setting_get()
6117 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_svm_setting_put() local
6118 struct ca0132_spec *spec = codec->spec; in ca0132_alt_svm_setting_put()
6127 codec_dbg(codec, "ca0132_alt_svm_setting: sel=%d, preset=%s\n", in ca0132_alt_svm_setting_put()
6147 dspio_set_uint_param(codec, ca0132_effects[idx].mid, in ca0132_alt_svm_setting_put()
6171 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_eq_preset_get() local
6172 struct ca0132_spec *spec = codec->spec; in ca0132_alt_eq_preset_get()
6181 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_eq_preset_put() local
6182 struct ca0132_spec *spec = codec->spec; in ca0132_alt_eq_preset_put()
6190 codec_dbg(codec, "%s: sel=%d, preset=%s\n", __func__, sel, in ca0132_alt_eq_preset_put()
6197 err = dspio_set_uint_param(codec, ca0132_alt_eq_enum.mid, in ca0132_alt_eq_preset_put()
6228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_voicefx_get() local
6229 struct ca0132_spec *spec = codec->spec; in ca0132_voicefx_get()
6238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_voicefx_put() local
6239 struct ca0132_spec *spec = codec->spec; in ca0132_voicefx_put()
6246 codec_dbg(codec, "ca0132_voicefx_put: sel=%d, preset=%s\n", in ca0132_voicefx_put()
6254 err = dspio_set_uint_param(codec, ca0132_voicefx.mid, in ca0132_voicefx_put()
6264 ca0132_voicefx_set(codec, (sel ? 1 : 0)); in ca0132_voicefx_put()
6273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_switch_get() local
6274 struct ca0132_spec *spec = codec->spec; in ca0132_switch_get()
6325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_switch_put() local
6326 struct ca0132_spec *spec = codec->spec; in ca0132_switch_put()
6332 codec_dbg(codec, "ca0132_switch_put: nid=0x%x, val=%ld\n", in ca0132_switch_put()
6335 snd_hda_power_up(codec); in ca0132_switch_put()
6353 changed = ca0132_pe_switch_set(codec); in ca0132_switch_put()
6360 changed = ca0132_cvoice_switch_set(codec); in ca0132_switch_put()
6368 changed = ca0132_effects_set(codec, nid, *valp); in ca0132_switch_put()
6377 changed = ca0132_mic_boost_set(codec, *valp); in ca0132_switch_put()
6381 changed = ca0132_mic_boost_set(codec, *valp); in ca0132_switch_put()
6390 changed = zxr_headphone_gain_set(codec, *valp); in ca0132_switch_put()
6400 ca0132_alt_set_full_range_speaker(codec); in ca0132_switch_put()
6408 ca0132_alt_surround_set_bass_redirection(codec, *valp); in ca0132_switch_put()
6414 snd_hda_power_down(codec); in ca0132_switch_put()
6426 static void ca0132_alt_dsp_volume_put(struct hda_codec *codec, hda_nid_t nid) in ca0132_alt_dsp_volume_put() argument
6428 struct ca0132_spec *spec = codec->spec; in ca0132_alt_dsp_volume_put()
6439 dspio_set_uint_param(codec, in ca0132_alt_dsp_volume_put()
6446 dspio_set_uint_param(codec, in ca0132_alt_dsp_volume_put()
6451 dspio_set_uint_param(codec, in ca0132_alt_dsp_volume_put()
6459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_info() local
6460 struct ca0132_spec *spec = codec->spec; in ca0132_volume_info()
6471 mutex_lock(&codec->control_mutex); in ca0132_volume_info()
6476 mutex_unlock(&codec->control_mutex); in ca0132_volume_info()
6481 mutex_lock(&codec->control_mutex); in ca0132_volume_info()
6486 mutex_unlock(&codec->control_mutex); in ca0132_volume_info()
6497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_get() local
6498 struct ca0132_spec *spec = codec->spec; in ca0132_volume_get()
6518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_put() local
6519 struct ca0132_spec *spec = codec->spec; in ca0132_volume_put()
6538 effective = ca0132_is_vnode_effective(codec, nid, &shared_nid); in ca0132_volume_put()
6543 snd_hda_power_up(codec); in ca0132_volume_put()
6544 mutex_lock(&codec->control_mutex); in ca0132_volume_put()
6550 mutex_unlock(&codec->control_mutex); in ca0132_volume_put()
6551 snd_hda_power_down(codec); in ca0132_volume_put()
6565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_alt_volume_put() local
6566 struct ca0132_spec *spec = codec->spec; in ca0132_alt_volume_put()
6592 snd_hda_power_up(codec); in ca0132_alt_volume_put()
6593 ca0132_alt_dsp_volume_put(codec, vnid); in ca0132_alt_volume_put()
6594 mutex_lock(&codec->control_mutex); in ca0132_alt_volume_put()
6596 mutex_unlock(&codec->control_mutex); in ca0132_alt_volume_put()
6597 snd_hda_power_down(codec); in ca0132_alt_volume_put()
6605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ca0132_volume_tlv() local
6606 struct ca0132_spec *spec = codec->spec; in ca0132_volume_tlv()
6617 mutex_lock(&codec->control_mutex); in ca0132_volume_tlv()
6622 mutex_unlock(&codec->control_mutex); in ca0132_volume_tlv()
6627 mutex_lock(&codec->control_mutex); in ca0132_volume_tlv()
6632 mutex_unlock(&codec->control_mutex); in ca0132_volume_tlv()
6641 static int ca0132_alt_add_effect_slider(struct hda_codec *codec, hda_nid_t nid, in ca0132_alt_add_effect_slider() argument
6668 return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); in ca0132_alt_add_effect_slider()
6676 static int add_fx_switch(struct hda_codec *codec, hda_nid_t nid, in add_fx_switch() argument
6679 struct ca0132_spec *spec = codec->spec; in add_fx_switch()
6692 return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); in add_fx_switch()
6695 static int add_voicefx(struct hda_codec *codec) in add_voicefx() argument
6703 return snd_hda_ctl_add(codec, VOICEFX, snd_ctl_new1(&knew, codec)); in add_voicefx()
6707 static int add_ca0132_alt_eq_presets(struct hda_codec *codec) in add_ca0132_alt_eq_presets() argument
6715 return snd_hda_ctl_add(codec, EQ_PRESET_ENUM, in add_ca0132_alt_eq_presets()
6716 snd_ctl_new1(&knew, codec)); in add_ca0132_alt_eq_presets()
6724 static int ca0132_alt_add_svm_enum(struct hda_codec *codec) in ca0132_alt_add_svm_enum() argument
6732 return snd_hda_ctl_add(codec, SMART_VOLUME_ENUM, in ca0132_alt_add_svm_enum()
6733 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_svm_enum()
6741 static int ca0132_alt_add_output_enum(struct hda_codec *codec) in ca0132_alt_add_output_enum() argument
6749 return snd_hda_ctl_add(codec, OUTPUT_SOURCE_ENUM, in ca0132_alt_add_output_enum()
6750 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_output_enum()
6758 static int ca0132_alt_add_speaker_channel_cfg_enum(struct hda_codec *codec) in ca0132_alt_add_speaker_channel_cfg_enum() argument
6766 return snd_hda_ctl_add(codec, SPEAKER_CHANNEL_CFG_ENUM, in ca0132_alt_add_speaker_channel_cfg_enum()
6767 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_speaker_channel_cfg_enum()
6775 static int ca0132_alt_add_front_full_range_switch(struct hda_codec *codec) in ca0132_alt_add_front_full_range_switch() argument
6781 return snd_hda_ctl_add(codec, SPEAKER_FULL_RANGE_FRONT, in ca0132_alt_add_front_full_range_switch()
6782 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_front_full_range_switch()
6785 static int ca0132_alt_add_rear_full_range_switch(struct hda_codec *codec) in ca0132_alt_add_rear_full_range_switch() argument
6791 return snd_hda_ctl_add(codec, SPEAKER_FULL_RANGE_REAR, in ca0132_alt_add_rear_full_range_switch()
6792 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_rear_full_range_switch()
6801 static int ca0132_alt_add_bass_redirection_crossover(struct hda_codec *codec) in ca0132_alt_add_bass_redirection_crossover() argument
6813 return snd_hda_ctl_add(codec, BASS_REDIRECTION_XOVER, in ca0132_alt_add_bass_redirection_crossover()
6814 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_bass_redirection_crossover()
6817 static int ca0132_alt_add_bass_redirection_switch(struct hda_codec *codec) in ca0132_alt_add_bass_redirection_switch() argument
6824 return snd_hda_ctl_add(codec, BASS_REDIRECTION, in ca0132_alt_add_bass_redirection_switch()
6825 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_bass_redirection_switch()
6833 static int ca0132_alt_add_input_enum(struct hda_codec *codec) in ca0132_alt_add_input_enum() argument
6841 return snd_hda_ctl_add(codec, INPUT_SOURCE_ENUM, in ca0132_alt_add_input_enum()
6842 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_input_enum()
6849 static int ca0132_alt_add_mic_boost_enum(struct hda_codec *codec) in ca0132_alt_add_mic_boost_enum() argument
6857 return snd_hda_ctl_add(codec, MIC_BOOST_ENUM, in ca0132_alt_add_mic_boost_enum()
6858 snd_ctl_new1(&knew, codec)); in ca0132_alt_add_mic_boost_enum()
6867 static int ae5_add_headphone_gain_enum(struct hda_codec *codec) in ae5_add_headphone_gain_enum() argument
6875 return snd_hda_ctl_add(codec, AE5_HEADPHONE_GAIN_ENUM, in ae5_add_headphone_gain_enum()
6876 snd_ctl_new1(&knew, codec)); in ae5_add_headphone_gain_enum()
6884 static int ae5_add_sound_filter_enum(struct hda_codec *codec) in ae5_add_sound_filter_enum() argument
6892 return snd_hda_ctl_add(codec, AE5_SOUND_FILTER_ENUM, in ae5_add_sound_filter_enum()
6893 snd_ctl_new1(&knew, codec)); in ae5_add_sound_filter_enum()
6896 static int zxr_add_headphone_gain_switch(struct hda_codec *codec) in zxr_add_headphone_gain_switch() argument
6902 return snd_hda_ctl_add(codec, ZXR_HEADPHONE_GAIN, in zxr_add_headphone_gain_switch()
6903 snd_ctl_new1(&knew, codec)); in zxr_add_headphone_gain_switch()
6933 static void ca0132_alt_add_chmap_ctls(struct hda_codec *codec) in ca0132_alt_add_chmap_ctls() argument
6938 list_for_each_entry(pcm, &codec->pcm_list_head, list) { in ca0132_alt_add_chmap_ctls()
6950 codec_dbg(codec, "snd_pcm_add_chmap_ctls failed!"); in ca0132_alt_add_chmap_ctls()
7026 static int ca0132_build_controls(struct hda_codec *codec) in ca0132_build_controls() argument
7028 struct ca0132_spec *spec = codec->spec; in ca0132_build_controls()
7034 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); in ca0132_build_controls()
7040 snd_hda_set_vmaster_tlv(codec, spec->dacs[0], HDA_OUTPUT, in ca0132_build_controls()
7042 snd_hda_add_vmaster(codec, "Master Playback Volume", in ca0132_build_controls()
7045 err = __snd_hda_add_vmaster(codec, "Master Playback Switch", in ca0132_build_controls()
7065 err = add_fx_switch(codec, ca0132_effects[i].nid, in ca0132_build_controls()
7072 * If codec has use_alt_controls set to true, add effect level sliders, in ca0132_build_controls()
7077 err = ca0132_alt_add_svm_enum(codec); in ca0132_build_controls()
7081 err = add_ca0132_alt_eq_presets(codec); in ca0132_build_controls()
7085 err = add_fx_switch(codec, PLAY_ENHANCEMENT, in ca0132_build_controls()
7090 err = add_fx_switch(codec, CRYSTAL_VOICE, in ca0132_build_controls()
7097 err = ca0132_alt_add_effect_slider(codec, in ca0132_build_controls()
7105 err = ca0132_alt_add_effect_slider(codec, XBASS_XOVER, in ca0132_build_controls()
7111 err = add_fx_switch(codec, PLAY_ENHANCEMENT, in ca0132_build_controls()
7116 err = add_fx_switch(codec, CRYSTAL_VOICE, in ca0132_build_controls()
7121 err = add_voicefx(codec); in ca0132_build_controls()
7126 * If the codec uses alt_functions, you need the enumerated controls in ca0132_build_controls()
7131 err = ca0132_alt_add_output_enum(codec); in ca0132_build_controls()
7134 err = ca0132_alt_add_speaker_channel_cfg_enum(codec); in ca0132_build_controls()
7137 err = ca0132_alt_add_front_full_range_switch(codec); in ca0132_build_controls()
7140 err = ca0132_alt_add_rear_full_range_switch(codec); in ca0132_build_controls()
7143 err = ca0132_alt_add_bass_redirection_crossover(codec); in ca0132_build_controls()
7146 err = ca0132_alt_add_bass_redirection_switch(codec); in ca0132_build_controls()
7149 err = ca0132_alt_add_mic_boost_enum(codec); in ca0132_build_controls()
7157 err = ca0132_alt_add_input_enum(codec); in ca0132_build_controls()
7166 err = ae5_add_headphone_gain_enum(codec); in ca0132_build_controls()
7169 err = ae5_add_sound_filter_enum(codec); in ca0132_build_controls()
7174 err = zxr_add_headphone_gain_switch(codec); in ca0132_build_controls()
7183 add_tuning_ctls(codec); in ca0132_build_controls()
7186 err = snd_hda_jack_add_kctls(codec, &spec->autocfg); in ca0132_build_controls()
7191 err = snd_hda_create_spdif_out_ctls(codec, spec->dig_out, in ca0132_build_controls()
7195 err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); in ca0132_build_controls()
7202 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in); in ca0132_build_controls()
7208 ca0132_alt_add_chmap_ctls(codec); in ca0132_build_controls()
7213 static int dbpro_build_controls(struct hda_codec *codec) in dbpro_build_controls() argument
7215 struct ca0132_spec *spec = codec->spec; in dbpro_build_controls()
7219 err = snd_hda_create_spdif_out_ctls(codec, spec->dig_out, in dbpro_build_controls()
7226 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in); in dbpro_build_controls()
7277 static int ca0132_build_pcms(struct hda_codec *codec) in ca0132_build_pcms() argument
7279 struct ca0132_spec *spec = codec->spec; in ca0132_build_pcms()
7282 info = snd_hda_codec_pcm_new(codec, "CA0132 Analog"); in ca0132_build_pcms()
7300 info = snd_hda_codec_pcm_new(codec, "CA0132 Analog Mic-In2"); in ca0132_build_pcms()
7309 info = snd_hda_codec_pcm_new(codec, "CA0132 What U Hear"); in ca0132_build_pcms()
7319 info = snd_hda_codec_pcm_new(codec, "CA0132 Digital"); in ca0132_build_pcms()
7337 static int dbpro_build_pcms(struct hda_codec *codec) in dbpro_build_pcms() argument
7339 struct ca0132_spec *spec = codec->spec; in dbpro_build_pcms()
7342 info = snd_hda_codec_pcm_new(codec, "CA0132 Alt Analog"); in dbpro_build_pcms()
7353 info = snd_hda_codec_pcm_new(codec, "CA0132 Digital"); in dbpro_build_pcms()
7371 static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) in init_output() argument
7374 snd_hda_set_pin_ctl(codec, pin, PIN_HP); in init_output()
7375 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in init_output()
7376 snd_hda_codec_write(codec, pin, 0, in init_output()
7380 if (dac && (get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) in init_output()
7381 snd_hda_codec_write(codec, dac, 0, in init_output()
7385 static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) in init_input() argument
7388 snd_hda_set_pin_ctl(codec, pin, PIN_VREF80); in init_input()
7389 if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) in init_input()
7390 snd_hda_codec_write(codec, pin, 0, in init_input()
7394 if (adc && (get_wcaps(codec, adc) & AC_WCAP_IN_AMP)) { in init_input()
7395 snd_hda_codec_write(codec, adc, 0, AC_VERB_SET_AMP_GAIN_MUTE, in init_input()
7399 snd_hda_codec_amp_stereo(codec, adc, HDA_INPUT, 0, in init_input()
7401 snd_hda_codec_amp_stereo(codec, adc, HDA_INPUT, 0, in init_input()
7406 static void refresh_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir) in refresh_amp_caps() argument
7410 caps = snd_hda_param_read(codec, nid, dir == HDA_OUTPUT ? in refresh_amp_caps()
7412 snd_hda_override_amp_caps(codec, nid, dir, caps); in refresh_amp_caps()
7418 static void ca0132_set_dmic(struct hda_codec *codec, int enable) in ca0132_set_dmic() argument
7420 struct ca0132_spec *spec = codec->spec; in ca0132_set_dmic()
7425 codec_dbg(codec, "ca0132_set_dmic: enable=%d\n", enable); in ca0132_set_dmic()
7427 oldval = stop_mic1(codec); in ca0132_set_dmic()
7428 ca0132_set_vipsource(codec, 0); in ca0132_set_dmic()
7432 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_dmic()
7436 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_set_dmic()
7440 chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 1); in ca0132_set_dmic()
7444 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_set_dmic()
7449 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_set_dmic()
7453 chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 0); in ca0132_set_dmic()
7455 ca0132_set_vipsource(codec, 1); in ca0132_set_dmic()
7456 resume_mic1(codec, oldval); in ca0132_set_dmic()
7462 static void ca0132_init_dmic(struct hda_codec *codec) in ca0132_init_dmic() argument
7464 struct ca0132_spec *spec = codec->spec; in ca0132_init_dmic()
7477 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_init_dmic()
7487 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_init_dmic()
7503 snd_hda_codec_write(codec, spec->input_pins[0], 0, in ca0132_init_dmic()
7510 static void ca0132_init_analog_mic2(struct hda_codec *codec) in ca0132_init_analog_mic2() argument
7512 struct ca0132_spec *spec = codec->spec; in ca0132_init_analog_mic2()
7516 chipio_8051_write_exram_no_mutex(codec, 0x1920, 0x00); in ca0132_init_analog_mic2()
7517 chipio_8051_write_exram_no_mutex(codec, 0x192d, 0x00); in ca0132_init_analog_mic2()
7522 static void ca0132_refresh_widget_caps(struct hda_codec *codec) in ca0132_refresh_widget_caps() argument
7524 struct ca0132_spec *spec = codec->spec; in ca0132_refresh_widget_caps()
7527 codec_dbg(codec, "ca0132_refresh_widget_caps.\n"); in ca0132_refresh_widget_caps()
7528 snd_hda_codec_update_widgets(codec); in ca0132_refresh_widget_caps()
7531 refresh_amp_caps(codec, spec->dacs[i], HDA_OUTPUT); in ca0132_refresh_widget_caps()
7534 refresh_amp_caps(codec, spec->out_pins[i], HDA_OUTPUT); in ca0132_refresh_widget_caps()
7537 refresh_amp_caps(codec, spec->adcs[i], HDA_INPUT); in ca0132_refresh_widget_caps()
7538 refresh_amp_caps(codec, spec->input_pins[i], HDA_INPUT); in ca0132_refresh_widget_caps()
7544 static void ca0132_alt_free_active_dma_channels(struct hda_codec *codec) in ca0132_alt_free_active_dma_channels() argument
7550 status = chipio_read(codec, DSPDMAC_CHNLSTART_MODULE_OFFSET, &tmp); in ca0132_alt_free_active_dma_channels()
7559 codec_dbg(codec, "%s: Failed to read active DSP DMA channel register.\n", in ca0132_alt_free_active_dma_channels()
7569 if (dsp_is_dma_active(codec, i)) { in ca0132_alt_free_active_dma_channels()
7570 status = dspio_free_dma_chan(codec, i); in ca0132_alt_free_active_dma_channels()
7572 codec_dbg(codec, "%s: Failed to free active DSP DMA channel %d.\n", in ca0132_alt_free_active_dma_channels()
7599 static void ca0132_alt_start_dsp_audio_streams(struct hda_codec *codec) in ca0132_alt_start_dsp_audio_streams() argument
7602 struct ca0132_spec *spec = codec->spec; in ca0132_alt_start_dsp_audio_streams()
7612 chipio_get_stream_control(codec, dsp_dma_stream_ids[i], &tmp); in ca0132_alt_start_dsp_audio_streams()
7615 chipio_set_stream_control(codec, in ca0132_alt_start_dsp_audio_streams()
7627 ca0132_alt_free_active_dma_channels(codec); in ca0132_alt_start_dsp_audio_streams()
7632 chipio_set_stream_channels(codec, 0x0c, 6); in ca0132_alt_start_dsp_audio_streams()
7635 chipio_set_stream_control(codec, in ca0132_alt_start_dsp_audio_streams()
7689 static void chipio_remap_stream(struct hda_codec *codec, in chipio_remap_stream() argument
7695 chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id, in chipio_remap_stream()
7707 chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id, in chipio_remap_stream()
7716 codec_info(codec, "%s: Stream 0x%02x ports aren't allocated, remap failed!\n", in chipio_remap_stream()
7726 chipio_write_no_mutex(codec, in chipio_remap_stream()
7732 chipio_write_no_mutex(codec, 0x19042c, 0x00000001); in chipio_remap_stream()
7756 static void ca0132_alt_init_speaker_tuning(struct hda_codec *codec) in ca0132_alt_init_speaker_tuning() argument
7758 struct ca0132_spec *spec = codec->spec; in ca0132_alt_init_speaker_tuning()
7779 dspio_set_uint_param(codec, 0x96, SPEAKER_TUNING_ENABLE_CENTER_EQ, tmp); in ca0132_alt_init_speaker_tuning()
7784 dspio_set_uint_param(codec, 0x96, i, tmp); in ca0132_alt_init_speaker_tuning()
7789 dspio_set_uint_param(codec, 0x96, i, tmp); in ca0132_alt_init_speaker_tuning()
7793 dspio_set_uint_param(codec, 0x96, in ca0132_alt_init_speaker_tuning()
7800 static void ca0132_alt_init_analog_mics(struct hda_codec *codec) in ca0132_alt_init_analog_mics() argument
7802 struct ca0132_spec *spec = codec->spec; in ca0132_alt_init_analog_mics()
7806 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_init_analog_mics()
7807 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_init_analog_mics()
7809 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_init_analog_mics()
7813 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_init_analog_mics()
7816 chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, SR_96_000); in ca0132_alt_init_analog_mics()
7817 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, SR_96_000); in ca0132_alt_init_analog_mics()
7819 chipio_set_conn_rate(codec, 0x0F, SR_96_000); in ca0132_alt_init_analog_mics()
7821 dspio_set_uint_param(codec, 0x80, 0x01, tmp); in ca0132_alt_init_analog_mics()
7830 static void sbz_connect_streams(struct hda_codec *codec) in sbz_connect_streams() argument
7832 struct ca0132_spec *spec = codec->spec; in sbz_connect_streams()
7836 codec_dbg(codec, "Connect Streams entered, mutex locked and loaded.\n"); in sbz_connect_streams()
7839 chipio_write_no_mutex(codec, 0x18a020, 0x00000043); in sbz_connect_streams()
7842 chipio_set_stream_source_dest(codec, 0x14, 0x48, 0x91); in sbz_connect_streams()
7843 chipio_set_conn_rate_no_mutex(codec, 0x48, SR_96_000); in sbz_connect_streams()
7844 chipio_set_conn_rate_no_mutex(codec, 0x91, SR_96_000); in sbz_connect_streams()
7845 chipio_set_stream_channels(codec, 0x14, 2); in sbz_connect_streams()
7846 chipio_set_stream_control(codec, 0x14, 1); in sbz_connect_streams()
7848 codec_dbg(codec, "Connect Streams exited, mutex released.\n"); in sbz_connect_streams()
7859 static void sbz_chipio_startup_data(struct hda_codec *codec) in sbz_chipio_startup_data() argument
7862 struct ca0132_spec *spec = codec->spec; in sbz_chipio_startup_data()
7865 codec_dbg(codec, "Startup Data entered, mutex locked and loaded.\n"); in sbz_chipio_startup_data()
7868 chipio_remap_stream(codec, &stream_remap_data[0]); in sbz_chipio_startup_data()
7886 chipio_remap_stream(codec, dsp_out_remap_data); in sbz_chipio_startup_data()
7888 codec_dbg(codec, "Startup Data exited, mutex released.\n"); in sbz_chipio_startup_data()
7892 static void ca0132_alt_dsp_initial_mic_setup(struct hda_codec *codec) in ca0132_alt_dsp_initial_mic_setup() argument
7894 struct ca0132_spec *spec = codec->spec; in ca0132_alt_dsp_initial_mic_setup()
7897 chipio_set_stream_control(codec, 0x03, 0); in ca0132_alt_dsp_initial_mic_setup()
7898 chipio_set_stream_control(codec, 0x04, 0); in ca0132_alt_dsp_initial_mic_setup()
7900 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_alt_dsp_initial_mic_setup()
7901 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_alt_dsp_initial_mic_setup()
7904 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_alt_dsp_initial_mic_setup()
7906 chipio_set_stream_control(codec, 0x03, 1); in ca0132_alt_dsp_initial_mic_setup()
7907 chipio_set_stream_control(codec, 0x04, 1); in ca0132_alt_dsp_initial_mic_setup()
7911 chipio_write(codec, 0x18b098, 0x0000000c); in ca0132_alt_dsp_initial_mic_setup()
7912 chipio_write(codec, 0x18b09C, 0x0000000c); in ca0132_alt_dsp_initial_mic_setup()
7915 chipio_write(codec, 0x18b098, 0x0000000c); in ca0132_alt_dsp_initial_mic_setup()
7916 chipio_write(codec, 0x18b09c, 0x0000004c); in ca0132_alt_dsp_initial_mic_setup()
7923 static void ae5_post_dsp_register_set(struct hda_codec *codec) in ae5_post_dsp_register_set() argument
7925 struct ca0132_spec *spec = codec->spec; in ae5_post_dsp_register_set()
7927 chipio_8051_write_direct(codec, 0x93, 0x10); in ae5_post_dsp_register_set()
7928 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); in ae5_post_dsp_register_set()
7943 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x3f); in ae5_post_dsp_register_set()
7944 ca0113_mmio_command_set(codec, 0x30, 0x2d, 0x3f); in ae5_post_dsp_register_set()
7945 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_post_dsp_register_set()
7948 static void ae5_post_dsp_param_setup(struct hda_codec *codec) in ae5_post_dsp_param_setup() argument
7955 chipio_set_control_param(codec, 3, 0); in ae5_post_dsp_param_setup()
7960 chipio_set_control_flag(codec, CONTROL_FLAG_ASI_96KHZ, 1); in ae5_post_dsp_param_setup()
7962 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x724, 0x83); in ae5_post_dsp_param_setup()
7963 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae5_post_dsp_param_setup()
7965 chipio_8051_write_exram(codec, 0xfa92, 0x22); in ae5_post_dsp_param_setup()
7968 static void ae5_post_dsp_pll_setup(struct hda_codec *codec) in ae5_post_dsp_pll_setup() argument
7970 chipio_8051_write_pll_pmu(codec, 0x41, 0xc8); in ae5_post_dsp_pll_setup()
7971 chipio_8051_write_pll_pmu(codec, 0x45, 0xcc); in ae5_post_dsp_pll_setup()
7972 chipio_8051_write_pll_pmu(codec, 0x40, 0xcb); in ae5_post_dsp_pll_setup()
7973 chipio_8051_write_pll_pmu(codec, 0x43, 0xc7); in ae5_post_dsp_pll_setup()
7974 chipio_8051_write_pll_pmu(codec, 0x51, 0x8d); in ae5_post_dsp_pll_setup()
7977 static void ae5_post_dsp_stream_setup(struct hda_codec *codec) in ae5_post_dsp_stream_setup() argument
7979 struct ca0132_spec *spec = codec->spec; in ae5_post_dsp_stream_setup()
7983 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x81); in ae5_post_dsp_stream_setup()
7985 chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000); in ae5_post_dsp_stream_setup()
7987 chipio_set_stream_source_dest(codec, 0x5, 0x43, 0x0); in ae5_post_dsp_stream_setup()
7989 chipio_set_stream_source_dest(codec, 0x18, 0x9, 0xd0); in ae5_post_dsp_stream_setup()
7990 chipio_set_conn_rate_no_mutex(codec, 0xd0, SR_96_000); in ae5_post_dsp_stream_setup()
7991 chipio_set_stream_channels(codec, 0x18, 6); in ae5_post_dsp_stream_setup()
7992 chipio_set_stream_control(codec, 0x18, 1); in ae5_post_dsp_stream_setup()
7994 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 4); in ae5_post_dsp_stream_setup()
7996 chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7); in ae5_post_dsp_stream_setup()
7998 ca0113_mmio_command_set(codec, 0x48, 0x01, 0x80); in ae5_post_dsp_stream_setup()
8003 static void ae5_post_dsp_startup_data(struct hda_codec *codec) in ae5_post_dsp_startup_data() argument
8005 struct ca0132_spec *spec = codec->spec; in ae5_post_dsp_startup_data()
8009 chipio_write_no_mutex(codec, 0x189000, 0x0001f101); in ae5_post_dsp_startup_data()
8010 chipio_write_no_mutex(codec, 0x189004, 0x0001f101); in ae5_post_dsp_startup_data()
8011 chipio_write_no_mutex(codec, 0x189024, 0x00014004); in ae5_post_dsp_startup_data()
8012 chipio_write_no_mutex(codec, 0x189028, 0x0002000f); in ae5_post_dsp_startup_data()
8014 ca0113_mmio_command_set(codec, 0x48, 0x0a, 0x05); in ae5_post_dsp_startup_data()
8015 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 7); in ae5_post_dsp_startup_data()
8016 ca0113_mmio_command_set(codec, 0x48, 0x0b, 0x12); in ae5_post_dsp_startup_data()
8017 ca0113_mmio_command_set(codec, 0x48, 0x04, 0x00); in ae5_post_dsp_startup_data()
8018 ca0113_mmio_command_set(codec, 0x48, 0x06, 0x48); in ae5_post_dsp_startup_data()
8019 ca0113_mmio_command_set(codec, 0x48, 0x0a, 0x05); in ae5_post_dsp_startup_data()
8020 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_post_dsp_startup_data()
8021 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae5_post_dsp_startup_data()
8022 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae5_post_dsp_startup_data()
8023 ca0113_mmio_gpio_set(codec, 0, true); in ae5_post_dsp_startup_data()
8024 ca0113_mmio_gpio_set(codec, 1, true); in ae5_post_dsp_startup_data()
8025 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x80); in ae5_post_dsp_startup_data()
8027 chipio_write_no_mutex(codec, 0x18b03c, 0x00000012); in ae5_post_dsp_startup_data()
8029 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae5_post_dsp_startup_data()
8030 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae5_post_dsp_startup_data()
8035 static void ae7_post_dsp_setup_ports(struct hda_codec *codec) in ae7_post_dsp_setup_ports() argument
8037 struct ca0132_spec *spec = codec->spec; in ae7_post_dsp_setup_ports()
8042 chipio_remap_stream(codec, &stream_remap_data[1]); in ae7_post_dsp_setup_ports()
8044 ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00); in ae7_post_dsp_setup_ports()
8045 ca0113_mmio_command_set(codec, 0x48, 0x0d, 0x40); in ae7_post_dsp_setup_ports()
8046 ca0113_mmio_command_set(codec, 0x48, 0x17, 0x00); in ae7_post_dsp_setup_ports()
8047 ca0113_mmio_command_set(codec, 0x48, 0x19, 0x00); in ae7_post_dsp_setup_ports()
8048 ca0113_mmio_command_set(codec, 0x48, 0x11, 0xff); in ae7_post_dsp_setup_ports()
8049 ca0113_mmio_command_set(codec, 0x48, 0x12, 0xff); in ae7_post_dsp_setup_ports()
8050 ca0113_mmio_command_set(codec, 0x48, 0x13, 0xff); in ae7_post_dsp_setup_ports()
8051 ca0113_mmio_command_set(codec, 0x48, 0x14, 0x7f); in ae7_post_dsp_setup_ports()
8056 static void ae7_post_dsp_asi_stream_setup(struct hda_codec *codec) in ae7_post_dsp_asi_stream_setup() argument
8058 struct ca0132_spec *spec = codec->spec; in ae7_post_dsp_asi_stream_setup()
8062 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x81); in ae7_post_dsp_asi_stream_setup()
8063 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x00); in ae7_post_dsp_asi_stream_setup()
8065 chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000); in ae7_post_dsp_asi_stream_setup()
8067 chipio_set_stream_source_dest(codec, 0x05, 0x43, 0x00); in ae7_post_dsp_asi_stream_setup()
8068 chipio_set_stream_source_dest(codec, 0x18, 0x09, 0xd0); in ae7_post_dsp_asi_stream_setup()
8070 chipio_set_conn_rate_no_mutex(codec, 0xd0, SR_96_000); in ae7_post_dsp_asi_stream_setup()
8071 chipio_set_stream_channels(codec, 0x18, 6); in ae7_post_dsp_asi_stream_setup()
8072 chipio_set_stream_control(codec, 0x18, 1); in ae7_post_dsp_asi_stream_setup()
8074 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 4); in ae7_post_dsp_asi_stream_setup()
8079 static void ae7_post_dsp_pll_setup(struct hda_codec *codec) in ae7_post_dsp_pll_setup() argument
8090 chipio_8051_write_pll_pmu_no_mutex(codec, addr[i], data[i]); in ae7_post_dsp_pll_setup()
8093 static void ae7_post_dsp_asi_setup_ports(struct hda_codec *codec) in ae7_post_dsp_asi_setup_ports() argument
8095 struct ca0132_spec *spec = codec->spec; in ae7_post_dsp_asi_setup_ports()
8106 chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7); in ae7_post_dsp_asi_setup_ports()
8108 chipio_write_no_mutex(codec, 0x189000, 0x0001f101); in ae7_post_dsp_asi_setup_ports()
8109 chipio_write_no_mutex(codec, 0x189004, 0x0001f101); in ae7_post_dsp_asi_setup_ports()
8110 chipio_write_no_mutex(codec, 0x189024, 0x00014004); in ae7_post_dsp_asi_setup_ports()
8111 chipio_write_no_mutex(codec, 0x189028, 0x0002000f); in ae7_post_dsp_asi_setup_ports()
8113 ae7_post_dsp_pll_setup(codec); in ae7_post_dsp_asi_setup_ports()
8114 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 7); in ae7_post_dsp_asi_setup_ports()
8117 ca0113_mmio_command_set(codec, 0x48, target[i], data[i]); in ae7_post_dsp_asi_setup_ports()
8119 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_post_dsp_asi_setup_ports()
8120 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae7_post_dsp_asi_setup_ports()
8121 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae7_post_dsp_asi_setup_ports()
8123 chipio_set_stream_source_dest(codec, 0x21, 0x64, 0x56); in ae7_post_dsp_asi_setup_ports()
8124 chipio_set_stream_channels(codec, 0x21, 2); in ae7_post_dsp_asi_setup_ports()
8125 chipio_set_conn_rate_no_mutex(codec, 0x56, SR_8_000); in ae7_post_dsp_asi_setup_ports()
8127 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_NODE_ID, 0x09); in ae7_post_dsp_asi_setup_ports()
8133 chipio_set_control_param_no_mutex(codec, 0x20, 0x21); in ae7_post_dsp_asi_setup_ports()
8135 chipio_write_no_mutex(codec, 0x18b038, 0x00000088); in ae7_post_dsp_asi_setup_ports()
8146 ca0113_mmio_gpio_set(codec, 0, 1); in ae7_post_dsp_asi_setup_ports()
8147 ca0113_mmio_gpio_set(codec, 1, 1); in ae7_post_dsp_asi_setup_ports()
8149 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_post_dsp_asi_setup_ports()
8150 chipio_write_no_mutex(codec, 0x18b03c, 0x00000000); in ae7_post_dsp_asi_setup_ports()
8151 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x00); in ae7_post_dsp_asi_setup_ports()
8152 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x00); in ae7_post_dsp_asi_setup_ports()
8154 chipio_set_stream_source_dest(codec, 0x05, 0x43, 0x00); in ae7_post_dsp_asi_setup_ports()
8155 chipio_set_stream_source_dest(codec, 0x18, 0x09, 0xd0); in ae7_post_dsp_asi_setup_ports()
8157 chipio_set_conn_rate_no_mutex(codec, 0xd0, SR_96_000); in ae7_post_dsp_asi_setup_ports()
8158 chipio_set_stream_channels(codec, 0x18, 6); in ae7_post_dsp_asi_setup_ports()
8164 ae7_post_dsp_pll_setup(codec); in ae7_post_dsp_asi_setup_ports()
8165 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 7); in ae7_post_dsp_asi_setup_ports()
8175 static void ae7_post_dsp_asi_setup(struct hda_codec *codec) in ae7_post_dsp_asi_setup() argument
8177 chipio_8051_write_direct(codec, 0x93, 0x10); in ae7_post_dsp_asi_setup()
8179 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); in ae7_post_dsp_asi_setup()
8181 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_post_dsp_asi_setup()
8182 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae7_post_dsp_asi_setup()
8184 chipio_set_control_param(codec, 3, 3); in ae7_post_dsp_asi_setup()
8185 chipio_set_control_flag(codec, CONTROL_FLAG_ASI_96KHZ, 1); in ae7_post_dsp_asi_setup()
8187 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x724, 0x83); in ae7_post_dsp_asi_setup()
8188 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae7_post_dsp_asi_setup()
8189 snd_hda_codec_write(codec, 0x17, 0, 0x794, 0x00); in ae7_post_dsp_asi_setup()
8191 chipio_8051_write_exram(codec, 0xfa92, 0x22); in ae7_post_dsp_asi_setup()
8193 ae7_post_dsp_pll_setup(codec); in ae7_post_dsp_asi_setup()
8194 ae7_post_dsp_asi_stream_setup(codec); in ae7_post_dsp_asi_setup()
8196 chipio_8051_write_pll_pmu(codec, 0x43, 0xc7); in ae7_post_dsp_asi_setup()
8198 ae7_post_dsp_asi_setup_ports(codec); in ae7_post_dsp_asi_setup()
8204 static void ca0132_setup_defaults(struct hda_codec *codec) in ca0132_setup_defaults() argument
8206 struct ca0132_spec *spec = codec->spec; in ca0132_setup_defaults()
8218 dspio_set_uint_param(codec, ca0132_effects[idx].mid, in ca0132_setup_defaults()
8226 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in ca0132_setup_defaults()
8229 dspio_set_uint_param(codec, 0x8f, 0x01, tmp); in ca0132_setup_defaults()
8233 dspio_set_uint_param(codec, 0x80, 0x00, tmp); in ca0132_setup_defaults()
8234 dspio_set_uint_param(codec, 0x80, 0x01, tmp); in ca0132_setup_defaults()
8238 dspio_set_uint_param(codec, 0x80, 0x05, tmp); in ca0132_setup_defaults()
8242 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in ca0132_setup_defaults()
8249 static void r3d_setup_defaults(struct hda_codec *codec) in r3d_setup_defaults() argument
8251 struct ca0132_spec *spec = codec->spec; in r3d_setup_defaults()
8259 ca0132_alt_init_analog_mics(codec); in r3d_setup_defaults()
8260 ca0132_alt_start_dsp_audio_streams(codec); in r3d_setup_defaults()
8264 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in r3d_setup_defaults()
8268 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in r3d_setup_defaults()
8269 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in r3d_setup_defaults()
8272 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in r3d_setup_defaults()
8275 r3di_gpio_dsp_status_set(codec, R3DI_DSP_DOWNLOADED); in r3d_setup_defaults()
8279 ca0113_mmio_gpio_set(codec, 2, false); in r3d_setup_defaults()
8280 ca0113_mmio_gpio_set(codec, 4, true); in r3d_setup_defaults()
8287 dspio_set_uint_param(codec, in r3d_setup_defaults()
8299 static void sbz_setup_defaults(struct hda_codec *codec) in sbz_setup_defaults() argument
8301 struct ca0132_spec *spec = codec->spec; in sbz_setup_defaults()
8309 ca0132_alt_init_analog_mics(codec); in sbz_setup_defaults()
8310 ca0132_alt_start_dsp_audio_streams(codec); in sbz_setup_defaults()
8311 sbz_connect_streams(codec); in sbz_setup_defaults()
8312 sbz_chipio_startup_data(codec); in sbz_setup_defaults()
8319 dspio_set_uint_param(codec, 0x37, 0x08, tmp); in sbz_setup_defaults()
8320 dspio_set_uint_param(codec, 0x37, 0x10, tmp); in sbz_setup_defaults()
8324 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in sbz_setup_defaults()
8328 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in sbz_setup_defaults()
8329 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in sbz_setup_defaults()
8332 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in sbz_setup_defaults()
8334 ca0132_alt_dsp_initial_mic_setup(codec); in sbz_setup_defaults()
8340 dspio_set_uint_param(codec, in sbz_setup_defaults()
8347 ca0132_alt_init_speaker_tuning(codec); in sbz_setup_defaults()
8353 static void ae5_setup_defaults(struct hda_codec *codec) in ae5_setup_defaults() argument
8355 struct ca0132_spec *spec = codec->spec; in ae5_setup_defaults()
8363 ca0132_alt_init_analog_mics(codec); in ae5_setup_defaults()
8364 ca0132_alt_start_dsp_audio_streams(codec); in ae5_setup_defaults()
8368 dspio_set_uint_param(codec, 0x96, 0x29, tmp); in ae5_setup_defaults()
8369 dspio_set_uint_param(codec, 0x96, 0x2a, tmp); in ae5_setup_defaults()
8370 dspio_set_uint_param(codec, 0x80, 0x0d, tmp); in ae5_setup_defaults()
8371 dspio_set_uint_param(codec, 0x80, 0x0e, tmp); in ae5_setup_defaults()
8373 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae5_setup_defaults()
8374 ca0113_mmio_gpio_set(codec, 0, false); in ae5_setup_defaults()
8375 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ae5_setup_defaults()
8379 dspio_set_uint_param(codec, 0x37, 0x08, tmp); in ae5_setup_defaults()
8380 dspio_set_uint_param(codec, 0x37, 0x10, tmp); in ae5_setup_defaults()
8384 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in ae5_setup_defaults()
8388 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in ae5_setup_defaults()
8389 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ae5_setup_defaults()
8392 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in ae5_setup_defaults()
8394 ca0132_alt_dsp_initial_mic_setup(codec); in ae5_setup_defaults()
8395 ae5_post_dsp_register_set(codec); in ae5_setup_defaults()
8396 ae5_post_dsp_param_setup(codec); in ae5_setup_defaults()
8397 ae5_post_dsp_pll_setup(codec); in ae5_setup_defaults()
8398 ae5_post_dsp_stream_setup(codec); in ae5_setup_defaults()
8399 ae5_post_dsp_startup_data(codec); in ae5_setup_defaults()
8405 dspio_set_uint_param(codec, in ae5_setup_defaults()
8412 ca0132_alt_init_speaker_tuning(codec); in ae5_setup_defaults()
8418 static void ae7_setup_defaults(struct hda_codec *codec) in ae7_setup_defaults() argument
8420 struct ca0132_spec *spec = codec->spec; in ae7_setup_defaults()
8428 ca0132_alt_init_analog_mics(codec); in ae7_setup_defaults()
8429 ca0132_alt_start_dsp_audio_streams(codec); in ae7_setup_defaults()
8430 ae7_post_dsp_setup_ports(codec); in ae7_setup_defaults()
8433 dspio_set_uint_param(codec, 0x96, in ae7_setup_defaults()
8435 dspio_set_uint_param(codec, 0x96, in ae7_setup_defaults()
8438 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae7_setup_defaults()
8441 dspio_set_uint_param(codec, 0x80, 0x0d, tmp); in ae7_setup_defaults()
8442 dspio_set_uint_param(codec, 0x80, 0x0e, tmp); in ae7_setup_defaults()
8444 ca0113_mmio_gpio_set(codec, 0, false); in ae7_setup_defaults()
8448 dspio_set_uint_param(codec, 0x37, 0x08, tmp); in ae7_setup_defaults()
8449 dspio_set_uint_param(codec, 0x37, 0x10, tmp); in ae7_setup_defaults()
8453 dspio_set_uint_param(codec, 0x96, 0x3C, tmp); in ae7_setup_defaults()
8457 dspio_set_uint_param(codec, 0x31, 0x00, tmp); in ae7_setup_defaults()
8458 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ae7_setup_defaults()
8461 dspio_set_uint_param(codec, 0x32, 0x00, tmp); in ae7_setup_defaults()
8462 ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); in ae7_setup_defaults()
8468 ca0132_alt_init_analog_mics(codec); in ae7_setup_defaults()
8470 ae7_post_dsp_asi_setup(codec); in ae7_setup_defaults()
8476 ca0113_mmio_gpio_set(codec, 0, true); in ae7_setup_defaults()
8477 ca0113_mmio_gpio_set(codec, 1, true); in ae7_setup_defaults()
8480 ca0113_mmio_command_set(codec, 0x48, 0x0f, 0x04); in ae7_setup_defaults()
8481 ca0113_mmio_command_set(codec, 0x48, 0x10, 0x04); in ae7_setup_defaults()
8482 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x80); in ae7_setup_defaults()
8488 dspio_set_uint_param(codec, in ae7_setup_defaults()
8495 ca0132_alt_init_speaker_tuning(codec); in ae7_setup_defaults()
8501 static void ca0132_init_flags(struct hda_codec *codec) in ca0132_init_flags() argument
8503 struct ca0132_spec *spec = codec->spec; in ca0132_init_flags()
8506 chipio_set_control_flag(codec, CONTROL_FLAG_DSP_96KHZ, 1); in ca0132_init_flags()
8507 chipio_set_control_flag(codec, CONTROL_FLAG_DAC_96KHZ, 1); in ca0132_init_flags()
8508 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_B_96KHZ, 1); in ca0132_init_flags()
8509 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_C_96KHZ, 1); in ca0132_init_flags()
8510 chipio_set_control_flag(codec, CONTROL_FLAG_SRC_RATE_96KHZ, 1); in ca0132_init_flags()
8511 chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0); in ca0132_init_flags()
8512 chipio_set_control_flag(codec, CONTROL_FLAG_SPDIF2OUT, 0); in ca0132_init_flags()
8513 chipio_set_control_flag(codec, in ca0132_init_flags()
8515 chipio_set_control_flag(codec, in ca0132_init_flags()
8518 chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0); 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, in ca0132_init_flags()
8527 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_C_HIGH_PASS, 1); in ca0132_init_flags()
8534 static void ca0132_init_params(struct hda_codec *codec) in ca0132_init_params() argument
8536 struct ca0132_spec *spec = codec->spec; in ca0132_init_params()
8539 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ca0132_init_params()
8540 chipio_set_conn_rate(codec, 0x0B, SR_48_000); in ca0132_init_params()
8541 chipio_set_control_param(codec, CONTROL_PARAM_SPDIF1_SOURCE, 0); in ca0132_init_params()
8542 chipio_set_control_param(codec, 0, 0); in ca0132_init_params()
8543 chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, 0); in ca0132_init_params()
8546 chipio_set_control_param(codec, CONTROL_PARAM_PORTA_160OHM_GAIN, 6); in ca0132_init_params()
8547 chipio_set_control_param(codec, CONTROL_PARAM_PORTD_160OHM_GAIN, 6); in ca0132_init_params()
8550 static void ca0132_set_dsp_msr(struct hda_codec *codec, bool is96k) in ca0132_set_dsp_msr() argument
8552 chipio_set_control_flag(codec, CONTROL_FLAG_DSP_96KHZ, is96k); in ca0132_set_dsp_msr()
8553 chipio_set_control_flag(codec, CONTROL_FLAG_DAC_96KHZ, is96k); in ca0132_set_dsp_msr()
8554 chipio_set_control_flag(codec, CONTROL_FLAG_SRC_RATE_96KHZ, is96k); in ca0132_set_dsp_msr()
8555 chipio_set_control_flag(codec, CONTROL_FLAG_SRC_CLOCK_196MHZ, is96k); in ca0132_set_dsp_msr()
8556 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_B_96KHZ, is96k); in ca0132_set_dsp_msr()
8557 chipio_set_control_flag(codec, CONTROL_FLAG_ADC_C_96KHZ, is96k); in ca0132_set_dsp_msr()
8559 chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); in ca0132_set_dsp_msr()
8560 chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); in ca0132_set_dsp_msr()
8561 chipio_set_conn_rate(codec, MEM_CONNID_WUH, SR_48_000); in ca0132_set_dsp_msr()
8564 static bool ca0132_download_dsp_images(struct hda_codec *codec) in ca0132_download_dsp_images() argument
8567 struct ca0132_spec *spec = codec->spec; in ca0132_download_dsp_images()
8580 codec->card->dev) != 0) in ca0132_download_dsp_images()
8581 codec_dbg(codec, "Desktop firmware not found."); in ca0132_download_dsp_images()
8583 codec_dbg(codec, "Desktop firmware selected."); in ca0132_download_dsp_images()
8587 codec->card->dev) != 0) in ca0132_download_dsp_images()
8588 codec_dbg(codec, "Recon3Di alt firmware not detected."); in ca0132_download_dsp_images()
8590 codec_dbg(codec, "Recon3Di firmware selected."); in ca0132_download_dsp_images()
8597 * exists for your particular codec. in ca0132_download_dsp_images()
8600 codec_dbg(codec, "Default firmware selected."); in ca0132_download_dsp_images()
8602 codec->card->dev) != 0) in ca0132_download_dsp_images()
8607 if (dspload_image(codec, dsp_os_image, 0, 0, true, 0)) { in ca0132_download_dsp_images()
8608 codec_err(codec, "ca0132 DSP load image failed\n"); in ca0132_download_dsp_images()
8612 dsp_loaded = dspload_wait_loaded(codec); in ca0132_download_dsp_images()
8620 static void ca0132_download_dsp(struct hda_codec *codec) in ca0132_download_dsp() argument
8622 struct ca0132_spec *spec = codec->spec; in ca0132_download_dsp()
8631 chipio_enable_clocks(codec); in ca0132_download_dsp()
8635 if (!ca0132_download_dsp_images(codec)) in ca0132_download_dsp()
8643 ca0132_set_dsp_msr(codec, true); in ca0132_download_dsp()
8646 static void ca0132_process_dsp_response(struct hda_codec *codec, in ca0132_process_dsp_response() argument
8649 struct ca0132_spec *spec = codec->spec; in ca0132_process_dsp_response()
8651 codec_dbg(codec, "ca0132_process_dsp_response\n"); in ca0132_process_dsp_response()
8652 snd_hda_power_up_pm(codec); in ca0132_process_dsp_response()
8654 if (dspio_get_response_data(codec) >= 0) in ca0132_process_dsp_response()
8658 dspio_clear_response_queue(codec); in ca0132_process_dsp_response()
8659 snd_hda_power_down_pm(codec); in ca0132_process_dsp_response()
8662 static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb) in hp_callback() argument
8664 struct ca0132_spec *spec = codec->spec; in hp_callback()
8670 tbl = snd_hda_jack_tbl_get(codec, cb->nid); in hp_callback()
8676 static void amic_callback(struct hda_codec *codec, struct hda_jack_callback *cb) in amic_callback() argument
8678 struct ca0132_spec *spec = codec->spec; in amic_callback()
8681 ca0132_alt_select_in(codec); in amic_callback()
8683 ca0132_select_mic(codec); in amic_callback()
8686 static void ca0132_setup_unsol(struct hda_codec *codec) in ca0132_setup_unsol() argument
8688 struct ca0132_spec *spec = codec->spec; in ca0132_setup_unsol()
8689 snd_hda_jack_detect_enable_callback(codec, spec->unsol_tag_hp, hp_callback); in ca0132_setup_unsol()
8690 snd_hda_jack_detect_enable_callback(codec, spec->unsol_tag_amic1, in ca0132_setup_unsol()
8692 snd_hda_jack_detect_enable_callback(codec, UNSOL_TAG_DSP, in ca0132_setup_unsol()
8696 snd_hda_jack_detect_enable_callback(codec, in ca0132_setup_unsol()
8775 static void ca0132_init_chip(struct hda_codec *codec) in ca0132_init_chip() argument
8777 struct ca0132_spec *spec = codec->spec; in ca0132_init_chip()
8791 chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0); in ca0132_init_chip()
8792 chipio_write_no_mutex(codec, 0x18b0a4, 0x000000c2); in ca0132_init_chip()
8794 snd_hda_codec_write(codec, codec->core.afg, 0, in ca0132_init_chip()
8796 snd_hda_codec_write(codec, codec->core.afg, 0, in ca0132_init_chip()
8852 ca0132_init_tuning_defaults(codec); in ca0132_init_chip()
8860 static void r3di_gpio_shutdown(struct hda_codec *codec) in r3di_gpio_shutdown() argument
8862 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0x00); in r3di_gpio_shutdown()
8868 static void sbz_region2_exit(struct hda_codec *codec) in sbz_region2_exit() argument
8870 struct ca0132_spec *spec = codec->spec; in sbz_region2_exit()
8878 ca0113_mmio_gpio_set(codec, 0, false); in sbz_region2_exit()
8879 ca0113_mmio_gpio_set(codec, 1, false); in sbz_region2_exit()
8880 ca0113_mmio_gpio_set(codec, 4, true); in sbz_region2_exit()
8881 ca0113_mmio_gpio_set(codec, 5, false); in sbz_region2_exit()
8882 ca0113_mmio_gpio_set(codec, 7, false); in sbz_region2_exit()
8885 static void sbz_set_pin_ctl_default(struct hda_codec *codec) in sbz_set_pin_ctl_default() argument
8890 snd_hda_codec_write(codec, 0x11, 0, in sbz_set_pin_ctl_default()
8894 snd_hda_codec_write(codec, pins[i], 0, in sbz_set_pin_ctl_default()
8898 static void ca0132_clear_unsolicited(struct hda_codec *codec) in ca0132_clear_unsolicited() argument
8904 snd_hda_codec_write(codec, pins[i], 0, in ca0132_clear_unsolicited()
8910 static void sbz_gpio_shutdown_commands(struct hda_codec *codec, int dir, in sbz_gpio_shutdown_commands() argument
8914 snd_hda_codec_write(codec, 0x01, 0, in sbz_gpio_shutdown_commands()
8917 snd_hda_codec_write(codec, 0x01, 0, in sbz_gpio_shutdown_commands()
8921 snd_hda_codec_write(codec, 0x01, 0, in sbz_gpio_shutdown_commands()
8925 static void zxr_dbpro_power_state_shutdown(struct hda_codec *codec) in zxr_dbpro_power_state_shutdown() argument
8931 snd_hda_codec_write(codec, pins[i], 0, in zxr_dbpro_power_state_shutdown()
8935 static void sbz_exit_chip(struct hda_codec *codec) in sbz_exit_chip() argument
8937 chipio_set_stream_control(codec, 0x03, 0); in sbz_exit_chip()
8938 chipio_set_stream_control(codec, 0x04, 0); in sbz_exit_chip()
8941 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, -1); in sbz_exit_chip()
8942 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x05); in sbz_exit_chip()
8943 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x01); in sbz_exit_chip()
8945 chipio_set_stream_control(codec, 0x14, 0); in sbz_exit_chip()
8946 chipio_set_stream_control(codec, 0x0C, 0); in sbz_exit_chip()
8948 chipio_set_conn_rate(codec, 0x41, SR_192_000); in sbz_exit_chip()
8949 chipio_set_conn_rate(codec, 0x91, SR_192_000); in sbz_exit_chip()
8951 chipio_write(codec, 0x18a020, 0x00000083); in sbz_exit_chip()
8953 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x03); in sbz_exit_chip()
8954 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x07); in sbz_exit_chip()
8955 sbz_gpio_shutdown_commands(codec, 0x07, 0x07, 0x06); in sbz_exit_chip()
8957 chipio_set_stream_control(codec, 0x0C, 0); in sbz_exit_chip()
8959 chipio_set_control_param(codec, 0x0D, 0x24); in sbz_exit_chip()
8961 ca0132_clear_unsolicited(codec); in sbz_exit_chip()
8962 sbz_set_pin_ctl_default(codec); in sbz_exit_chip()
8964 snd_hda_codec_write(codec, 0x0B, 0, in sbz_exit_chip()
8967 sbz_region2_exit(codec); in sbz_exit_chip()
8970 static void r3d_exit_chip(struct hda_codec *codec) in r3d_exit_chip() argument
8972 ca0132_clear_unsolicited(codec); in r3d_exit_chip()
8973 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in r3d_exit_chip()
8974 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x5b); in r3d_exit_chip()
8977 static void ae5_exit_chip(struct hda_codec *codec) in ae5_exit_chip() argument
8979 chipio_set_stream_control(codec, 0x03, 0); in ae5_exit_chip()
8980 chipio_set_stream_control(codec, 0x04, 0); in ae5_exit_chip()
8982 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ae5_exit_chip()
8983 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_exit_chip()
8984 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_exit_chip()
8985 ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00); in ae5_exit_chip()
8986 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x00); in ae5_exit_chip()
8987 ca0113_mmio_command_set(codec, 0x30, 0x2d, 0x00); in ae5_exit_chip()
8988 ca0113_mmio_gpio_set(codec, 0, false); in ae5_exit_chip()
8989 ca0113_mmio_gpio_set(codec, 1, false); in ae5_exit_chip()
8991 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in ae5_exit_chip()
8992 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x53); in ae5_exit_chip()
8994 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae5_exit_chip()
8996 chipio_set_stream_control(codec, 0x18, 0); in ae5_exit_chip()
8997 chipio_set_stream_control(codec, 0x0c, 0); in ae5_exit_chip()
8999 snd_hda_codec_write(codec, 0x01, 0, 0x724, 0x83); in ae5_exit_chip()
9002 static void ae7_exit_chip(struct hda_codec *codec) in ae7_exit_chip() argument
9004 chipio_set_stream_control(codec, 0x18, 0); in ae7_exit_chip()
9005 chipio_set_stream_source_dest(codec, 0x21, 0xc8, 0xc8); in ae7_exit_chip()
9006 chipio_set_stream_channels(codec, 0x21, 0); in ae7_exit_chip()
9007 chipio_set_control_param(codec, CONTROL_PARAM_NODE_ID, 0x09); in ae7_exit_chip()
9008 chipio_set_control_param(codec, 0x20, 0x01); in ae7_exit_chip()
9010 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); in ae7_exit_chip()
9012 chipio_set_stream_control(codec, 0x18, 0); in ae7_exit_chip()
9013 chipio_set_stream_control(codec, 0x0c, 0); in ae7_exit_chip()
9015 ca0113_mmio_command_set(codec, 0x30, 0x2b, 0x00); in ae7_exit_chip()
9016 snd_hda_codec_write(codec, 0x15, 0, 0x724, 0x83); in ae7_exit_chip()
9017 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae7_exit_chip()
9018 ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00); in ae7_exit_chip()
9019 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x00); in ae7_exit_chip()
9020 ca0113_mmio_gpio_set(codec, 0, false); in ae7_exit_chip()
9021 ca0113_mmio_gpio_set(codec, 1, false); in ae7_exit_chip()
9022 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ae7_exit_chip()
9024 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in ae7_exit_chip()
9025 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x53); in ae7_exit_chip()
9028 static void zxr_exit_chip(struct hda_codec *codec) in zxr_exit_chip() argument
9030 chipio_set_stream_control(codec, 0x03, 0); in zxr_exit_chip()
9031 chipio_set_stream_control(codec, 0x04, 0); in zxr_exit_chip()
9032 chipio_set_stream_control(codec, 0x14, 0); in zxr_exit_chip()
9033 chipio_set_stream_control(codec, 0x0C, 0); in zxr_exit_chip()
9035 chipio_set_conn_rate(codec, 0x41, SR_192_000); in zxr_exit_chip()
9036 chipio_set_conn_rate(codec, 0x91, SR_192_000); in zxr_exit_chip()
9038 chipio_write(codec, 0x18a020, 0x00000083); in zxr_exit_chip()
9040 snd_hda_codec_write(codec, 0x01, 0, 0x793, 0x00); in zxr_exit_chip()
9041 snd_hda_codec_write(codec, 0x01, 0, 0x794, 0x53); in zxr_exit_chip()
9043 ca0132_clear_unsolicited(codec); in zxr_exit_chip()
9044 sbz_set_pin_ctl_default(codec); in zxr_exit_chip()
9045 snd_hda_codec_write(codec, 0x0B, 0, AC_VERB_SET_EAPD_BTLENABLE, 0x00); in zxr_exit_chip()
9047 ca0113_mmio_gpio_set(codec, 5, false); in zxr_exit_chip()
9048 ca0113_mmio_gpio_set(codec, 2, false); in zxr_exit_chip()
9049 ca0113_mmio_gpio_set(codec, 3, false); in zxr_exit_chip()
9050 ca0113_mmio_gpio_set(codec, 0, false); in zxr_exit_chip()
9051 ca0113_mmio_gpio_set(codec, 4, true); in zxr_exit_chip()
9052 ca0113_mmio_gpio_set(codec, 0, true); in zxr_exit_chip()
9053 ca0113_mmio_gpio_set(codec, 5, true); in zxr_exit_chip()
9054 ca0113_mmio_gpio_set(codec, 2, false); in zxr_exit_chip()
9055 ca0113_mmio_gpio_set(codec, 3, false); in zxr_exit_chip()
9058 static void ca0132_exit_chip(struct hda_codec *codec) in ca0132_exit_chip() argument
9062 if (dspload_is_loaded(codec)) in ca0132_exit_chip()
9063 dsp_reset(codec); in ca0132_exit_chip()
9074 static void sbz_dsp_startup_check(struct hda_codec *codec) in sbz_dsp_startup_check() argument
9076 struct ca0132_spec *spec = codec->spec; in sbz_dsp_startup_check()
9089 chipio_read(codec, cur_address, &dsp_data_check[i]); in sbz_dsp_startup_check()
9097 codec_dbg(codec, "Startup Check: %d ", failure); in sbz_dsp_startup_check()
9099 codec_info(codec, "DSP not initialized properly. Attempting to fix."); in sbz_dsp_startup_check()
9106 codec_info(codec, "Reloading... Tries left: %d", reload); in sbz_dsp_startup_check()
9107 sbz_exit_chip(codec); in sbz_dsp_startup_check()
9109 codec->patch_ops.init(codec); in sbz_dsp_startup_check()
9112 chipio_read(codec, cur_address, &dsp_data_check[i]); in sbz_dsp_startup_check()
9123 codec_info(codec, "DSP fixed."); in sbz_dsp_startup_check()
9128 …codec_info(codec, "DSP failed to initialize properly. Either try a full shutdown or a suspend to c… in sbz_dsp_startup_check()
9139 static void ca0132_alt_vol_setup(struct hda_codec *codec) in ca0132_alt_vol_setup() argument
9141 snd_hda_codec_write(codec, 0x02, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9142 snd_hda_codec_write(codec, 0x02, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9143 snd_hda_codec_write(codec, 0x03, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9144 snd_hda_codec_write(codec, 0x03, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9145 snd_hda_codec_write(codec, 0x04, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9146 snd_hda_codec_write(codec, 0x04, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9147 snd_hda_codec_write(codec, 0x07, 0, 0x797, 0x00); in ca0132_alt_vol_setup()
9148 snd_hda_codec_write(codec, 0x07, 0, 0x798, 0x00); in ca0132_alt_vol_setup()
9154 static void sbz_pre_dsp_setup(struct hda_codec *codec) in sbz_pre_dsp_setup() argument
9156 struct ca0132_spec *spec = codec->spec; in sbz_pre_dsp_setup()
9161 chipio_write(codec, 0x18b0a4, 0x000000c2); in sbz_pre_dsp_setup()
9163 snd_hda_codec_write(codec, 0x11, 0, in sbz_pre_dsp_setup()
9167 static void r3d_pre_dsp_setup(struct hda_codec *codec) in r3d_pre_dsp_setup() argument
9169 chipio_write(codec, 0x18b0a4, 0x000000c2); in r3d_pre_dsp_setup()
9171 chipio_8051_write_exram(codec, 0x1c1e, 0x5b); in r3d_pre_dsp_setup()
9173 snd_hda_codec_write(codec, 0x11, 0, in r3d_pre_dsp_setup()
9177 static void r3di_pre_dsp_setup(struct hda_codec *codec) in r3di_pre_dsp_setup() argument
9179 chipio_write(codec, 0x18b0a4, 0x000000c2); in r3di_pre_dsp_setup()
9181 chipio_8051_write_exram(codec, 0x1c1e, 0x5b); in r3di_pre_dsp_setup()
9182 chipio_8051_write_exram(codec, 0x1920, 0x00); in r3di_pre_dsp_setup()
9183 chipio_8051_write_exram(codec, 0x1921, 0x40); in r3di_pre_dsp_setup()
9185 snd_hda_codec_write(codec, 0x11, 0, in r3di_pre_dsp_setup()
9194 static void zxr_pre_dsp_setup(struct hda_codec *codec) in zxr_pre_dsp_setup() argument
9200 chipio_write(codec, 0x189000, 0x0001f100); in zxr_pre_dsp_setup()
9202 chipio_write(codec, 0x18900c, 0x0001f100); in zxr_pre_dsp_setup()
9211 chipio_8051_write_exram(codec, 0xfa92, 0x22); in zxr_pre_dsp_setup()
9213 chipio_8051_write_pll_pmu(codec, 0x51, 0x98); in zxr_pre_dsp_setup()
9215 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x82); in zxr_pre_dsp_setup()
9216 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 3); in zxr_pre_dsp_setup()
9218 chipio_write(codec, 0x18902c, 0x00000000); in zxr_pre_dsp_setup()
9220 chipio_write(codec, 0x18902c, 0x00000003); in zxr_pre_dsp_setup()
9224 chipio_8051_write_pll_pmu(codec, addr[i], data[i]); in zxr_pre_dsp_setup()
9267 static void ca0132_mmio_init_sbz(struct hda_codec *codec) in ca0132_mmio_init_sbz() argument
9269 struct ca0132_spec *spec = codec->spec; in ca0132_mmio_init_sbz()
9317 static void ca0132_mmio_init_ae5(struct hda_codec *codec) in ca0132_mmio_init_ae5() argument
9319 struct ca0132_spec *spec = codec->spec; in ca0132_mmio_init_ae5()
9349 static void ca0132_mmio_init(struct hda_codec *codec) in ca0132_mmio_init() argument
9351 struct ca0132_spec *spec = codec->spec; in ca0132_mmio_init()
9357 ca0132_mmio_init_sbz(codec); in ca0132_mmio_init()
9360 ca0132_mmio_init_ae5(codec); in ca0132_mmio_init()
9379 * eventually resets the codec with the 0x7ff verb. Not quite sure why it does
9382 static void ae5_register_set(struct hda_codec *codec) in ae5_register_set() argument
9384 struct ca0132_spec *spec = codec->spec; in ae5_register_set()
9392 chipio_8051_write_pll_pmu(codec, 0x41, 0xc8); in ae5_register_set()
9394 chipio_8051_write_direct(codec, 0x93, 0x10); in ae5_register_set()
9395 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); in ae5_register_set()
9423 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); in ae5_register_set()
9424 ca0113_mmio_command_set(codec, 0x30, 0x2e, 0x3f); in ae5_register_set()
9426 ca0113_mmio_command_set(codec, 0x30, 0x2d, 0x3f); in ae5_register_set()
9429 chipio_8051_write_direct(codec, 0x90, 0x00); in ae5_register_set()
9430 chipio_8051_write_direct(codec, 0x90, 0x10); in ae5_register_set()
9433 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); in ae5_register_set()
9441 static void ca0132_alt_init(struct hda_codec *codec) in ca0132_alt_init() argument
9443 struct ca0132_spec *spec = codec->spec; in ca0132_alt_init()
9445 ca0132_alt_vol_setup(codec); in ca0132_alt_init()
9449 codec_dbg(codec, "SBZ alt_init"); in ca0132_alt_init()
9450 ca0132_gpio_init(codec); in ca0132_alt_init()
9451 sbz_pre_dsp_setup(codec); in ca0132_alt_init()
9452 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9453 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9456 codec_dbg(codec, "R3DI alt_init"); in ca0132_alt_init()
9457 ca0132_gpio_init(codec); in ca0132_alt_init()
9458 ca0132_gpio_setup(codec); in ca0132_alt_init()
9459 r3di_gpio_dsp_status_set(codec, R3DI_DSP_DOWNLOADING); in ca0132_alt_init()
9460 r3di_pre_dsp_setup(codec); in ca0132_alt_init()
9461 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9462 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x6FF, 0xC4); in ca0132_alt_init()
9465 r3d_pre_dsp_setup(codec); in ca0132_alt_init()
9466 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9467 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9470 ca0132_gpio_init(codec); in ca0132_alt_init()
9471 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); in ca0132_alt_init()
9472 chipio_write(codec, 0x18b030, 0x00000020); in ca0132_alt_init()
9473 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9474 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9475 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ca0132_alt_init()
9478 ca0132_gpio_init(codec); in ca0132_alt_init()
9479 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); in ca0132_alt_init()
9480 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9481 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9482 chipio_write(codec, 0x18b008, 0x000000f8); in ca0132_alt_init()
9483 chipio_write(codec, 0x18b008, 0x000000f0); in ca0132_alt_init()
9484 chipio_write(codec, 0x18b030, 0x00000020); in ca0132_alt_init()
9485 ca0113_mmio_command_set(codec, 0x30, 0x32, 0x3f); in ca0132_alt_init()
9488 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); in ca0132_alt_init()
9489 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_alt_init()
9490 snd_hda_sequence_write(codec, spec->desktop_init_verbs); in ca0132_alt_init()
9491 zxr_pre_dsp_setup(codec); in ca0132_alt_init()
9498 static int ca0132_init(struct hda_codec *codec) in ca0132_init() argument
9500 struct ca0132_spec *spec = codec->spec; in ca0132_init()
9507 * there's only two reasons for it. One, the codec has awaken from a in ca0132_init()
9516 dsp_loaded = dspload_is_loaded(codec); in ca0132_init()
9522 sbz_dsp_startup_check(codec); in ca0132_init()
9532 ca0132_mmio_init(codec); in ca0132_init()
9534 snd_hda_power_up_pm(codec); in ca0132_init()
9537 ae5_register_set(codec); in ca0132_init()
9539 ca0132_init_params(codec); in ca0132_init()
9540 ca0132_init_flags(codec); in ca0132_init()
9542 snd_hda_sequence_write(codec, spec->base_init_verbs); in ca0132_init()
9545 ca0132_alt_init(codec); in ca0132_init()
9547 ca0132_download_dsp(codec); in ca0132_init()
9549 ca0132_refresh_widget_caps(codec); in ca0132_init()
9554 r3d_setup_defaults(codec); in ca0132_init()
9558 sbz_setup_defaults(codec); in ca0132_init()
9561 ae5_setup_defaults(codec); in ca0132_init()
9564 ae7_setup_defaults(codec); in ca0132_init()
9567 ca0132_setup_defaults(codec); in ca0132_init()
9568 ca0132_init_analog_mic2(codec); in ca0132_init()
9569 ca0132_init_dmic(codec); in ca0132_init()
9574 init_output(codec, spec->out_pins[i], spec->dacs[0]); in ca0132_init()
9576 init_output(codec, cfg->dig_out_pins[0], spec->dig_out); in ca0132_init()
9579 init_input(codec, spec->input_pins[i], spec->adcs[i]); in ca0132_init()
9581 init_input(codec, cfg->dig_in_pin, spec->dig_in); in ca0132_init()
9584 snd_hda_sequence_write(codec, spec->chip_init_verbs); in ca0132_init()
9585 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in ca0132_init()
9587 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, in ca0132_init()
9592 ca0132_gpio_setup(codec); in ca0132_init()
9594 snd_hda_sequence_write(codec, spec->spec_init_verbs); in ca0132_init()
9596 ca0132_alt_select_out(codec); in ca0132_init()
9597 ca0132_alt_select_in(codec); in ca0132_init()
9599 ca0132_select_out(codec); in ca0132_init()
9600 ca0132_select_mic(codec); in ca0132_init()
9603 snd_hda_jack_report_sync(codec); in ca0132_init()
9611 ca0132_pe_switch_set(codec); in ca0132_init()
9614 snd_hda_power_down_pm(codec); in ca0132_init()
9619 static int dbpro_init(struct hda_codec *codec) in dbpro_init() argument
9621 struct ca0132_spec *spec = codec->spec; in dbpro_init()
9625 init_output(codec, cfg->dig_out_pins[0], spec->dig_out); in dbpro_init()
9626 init_input(codec, cfg->dig_in_pin, spec->dig_in); in dbpro_init()
9629 init_input(codec, spec->input_pins[i], spec->adcs[i]); in dbpro_init()
9634 static void ca0132_free(struct hda_codec *codec) in ca0132_free() argument
9636 struct ca0132_spec *spec = codec->spec; in ca0132_free()
9639 snd_hda_power_up(codec); in ca0132_free()
9642 sbz_exit_chip(codec); in ca0132_free()
9645 zxr_exit_chip(codec); in ca0132_free()
9648 r3d_exit_chip(codec); in ca0132_free()
9651 ae5_exit_chip(codec); in ca0132_free()
9654 ae7_exit_chip(codec); in ca0132_free()
9657 r3di_gpio_shutdown(codec); in ca0132_free()
9663 snd_hda_sequence_write(codec, spec->base_exit_verbs); in ca0132_free()
9664 ca0132_exit_chip(codec); in ca0132_free()
9666 snd_hda_power_down(codec); in ca0132_free()
9669 pci_iounmap(codec->bus->pci, spec->mem_base); in ca0132_free()
9672 kfree(codec->spec); in ca0132_free()
9675 static void dbpro_free(struct hda_codec *codec) in dbpro_free() argument
9677 struct ca0132_spec *spec = codec->spec; in dbpro_free()
9679 zxr_dbpro_power_state_shutdown(codec); in dbpro_free()
9682 kfree(codec->spec); in dbpro_free()
9685 static int ca0132_suspend(struct hda_codec *codec) in ca0132_suspend() argument
9687 struct ca0132_spec *spec = codec->spec; in ca0132_suspend()
9709 static void ca0132_config(struct hda_codec *codec) in ca0132_config() argument
9711 struct ca0132_spec *spec = codec->spec; in ca0132_config()
9727 codec_dbg(codec, "%s: QUIRK_ALIENWARE applied.\n", __func__); in ca0132_config()
9728 snd_hda_apply_pincfgs(codec, alienware_pincfgs); in ca0132_config()
9731 codec_dbg(codec, "%s: QUIRK_SBZ applied.\n", __func__); in ca0132_config()
9732 snd_hda_apply_pincfgs(codec, sbz_pincfgs); in ca0132_config()
9735 codec_dbg(codec, "%s: QUIRK_ZXR applied.\n", __func__); in ca0132_config()
9736 snd_hda_apply_pincfgs(codec, zxr_pincfgs); in ca0132_config()
9739 codec_dbg(codec, "%s: QUIRK_R3D applied.\n", __func__); in ca0132_config()
9740 snd_hda_apply_pincfgs(codec, r3d_pincfgs); in ca0132_config()
9743 codec_dbg(codec, "%s: QUIRK_R3DI applied.\n", __func__); in ca0132_config()
9744 snd_hda_apply_pincfgs(codec, r3di_pincfgs); in ca0132_config()
9747 codec_dbg(codec, "%s: QUIRK_AE5 applied.\n", __func__); in ca0132_config()
9748 snd_hda_apply_pincfgs(codec, ae5_pincfgs); in ca0132_config()
9751 codec_dbg(codec, "%s: QUIRK_AE7 applied.\n", __func__); in ca0132_config()
9752 snd_hda_apply_pincfgs(codec, ae7_pincfgs); in ca0132_config()
9909 static int ca0132_prepare_verbs(struct hda_codec *codec) in ca0132_prepare_verbs() argument
9913 struct ca0132_spec *spec = codec->spec; in ca0132_prepare_verbs()
9954 * Sound Blaster Z cards. However, they have different HDA codec subsystem
9958 static void sbz_detect_quirk(struct hda_codec *codec) in sbz_detect_quirk() argument
9960 struct ca0132_spec *spec = codec->spec; in sbz_detect_quirk()
9962 switch (codec->core.subsystem_id) { in sbz_detect_quirk()
9975 static int patch_ca0132(struct hda_codec *codec) in patch_ca0132() argument
9981 codec_dbg(codec, "patch_ca0132\n"); in patch_ca0132()
9986 codec->spec = spec; in patch_ca0132()
9987 spec->codec = codec; in patch_ca0132()
9989 /* Detect codec quirk */ in patch_ca0132()
9990 quirk = snd_pci_quirk_lookup(codec->bus->pci, ca0132_quirks); in patch_ca0132()
9996 sbz_detect_quirk(codec); in patch_ca0132()
9999 codec->patch_ops = dbpro_patch_ops; in patch_ca0132()
10001 codec->patch_ops = ca0132_patch_ops; in patch_ca0132()
10003 codec->pcm_format_first = 1; in patch_ca0132()
10004 codec->no_sticky_stream = 1; in patch_ca0132()
10014 snd_hda_codec_set_name(codec, "Sound Blaster Z"); in patch_ca0132()
10018 snd_hda_codec_set_name(codec, "Sound Blaster ZxR"); in patch_ca0132()
10024 snd_hda_codec_set_name(codec, "Recon3D"); in patch_ca0132()
10028 snd_hda_codec_set_name(codec, "Recon3Di"); in patch_ca0132()
10032 snd_hda_codec_set_name(codec, "Sound BlasterX AE-5"); in patch_ca0132()
10036 snd_hda_codec_set_name(codec, "Sound Blaster AE-7"); in patch_ca0132()
10068 spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20); in patch_ca0132()
10070 codec_warn(codec, "pci_iomap failed! Setting quirk to QUIRK_NONE."); in patch_ca0132()
10081 ca0132_init_chip(codec); in patch_ca0132()
10083 ca0132_config(codec); in patch_ca0132()
10085 err = ca0132_prepare_verbs(codec); in patch_ca0132()
10089 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); in patch_ca0132()
10093 ca0132_setup_unsol(codec); in patch_ca0132()
10098 ca0132_free(codec); in patch_ca0132()
10112 MODULE_DESCRIPTION("Creative Sound Core3D codec");