void aic3254_set_mode(int config, int mode) { mutex_lock(&lock); spi_aic3254_prevent_sleep(); switch (config) { case AIC3254_CONFIG_TX: /* TX */ pr_aud_info("%s: AIC3254_CONFIG_TX mode = %d\n", __func__, mode); aic3254_tx_config(mode); aic3254_tx_mode = mode; break; case AIC3254_CONFIG_RX: /* RX */ pr_aud_info("%s: AIC3254_CONFIG_RX mode = %d\n", __func__, mode); aic3254_rx_config(mode); if (mode == FM_OUT_SPEAKER) aic3254_tx_config(FM_IN_SPEAKER); else if (mode == FM_OUT_HEADSET) aic3254_tx_config(FM_IN_HEADSET); aic3254_rx_mode = mode; break; } aic3254_powerdown(); spi_aic3254_allow_sleep(); mutex_unlock(&lock); }
void aic3254_set_mode(int config, int mode) { pr_aud_info("%s: aic3254_set_mode %d mode = %d\n", __func__, config, mode); mutex_lock(&lock); switch (config) { case AIC3254_CONFIG_TX: /* TX */ aic3254_tx_config(mode); aic3254_tx_mode = mode; break; case AIC3254_CONFIG_RX: /* RX */ aic3254_rx_config(mode); if (mode == FM_OUT_SPEAKER) aic3254_tx_config(FM_IN_SPEAKER); else if (mode == FM_OUT_HEADSET) aic3254_tx_config(FM_IN_HEADSET); else if (mode == DOWNLINK_OFF && (mode == FM_OUT_HEADSET || mode == FM_OUT_HEADSET)) aic3254_tx_config(POWER_OFF); aic3254_rx_mode = mode; break; } aic3254_powerdown(); mutex_unlock(&lock); }
void aic3254_force_powerdown(void) { aic3254_rx_config(DOWNLINK_OFF); aic3254_rx_mode = DOWNLINK_OFF; aic3254_tx_config(UPLINK_OFF); aic3254_tx_mode = UPLINK_OFF; aic3254_powerdown(); }
static int aic3254_set_config(int config_tbl, int idx, int en) { int rc = 0, len = 0; int64_t t1, t2; #if defined(CONFIG_ARCH_MSM7X30) struct ecodec_aic3254_state *drv = &codec_clk; #endif mutex_lock(&lock); spi_aic3254_prevent_sleep(); #if defined(CONFIG_ARCH_MSM7X30) if (drv->enabled == 0) { /* enable MI2S RX master block */ /* enable MI2S RX bit clock */ clk_enable(drv->rx_mclk); clk_enable(drv->rx_sclk); pr_aud_info("%s: enable CLK\n", __func__); drv->enabled = 1; } #endif switch (config_tbl) { case AIC3254_CONFIG_TX: /* TX */ pr_aud_info("%s: enable tx\n", __func__); if (en) { if (ctl_ops->tx_amp_enable) ctl_ops->tx_amp_enable(0); aic3254_tx_config(idx); aic3254_tx_mode = idx; if (ctl_ops->tx_amp_enable) ctl_ops->tx_amp_enable(1); } else { aic3254_tx_config(UPLINK_OFF); aic3254_tx_mode = UPLINK_OFF; } break; case AIC3254_CONFIG_RX: /* RX */ pr_aud_info("%s: enable rx\n", __func__); if (en) { if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(0); aic3254_rx_config(idx); aic3254_rx_mode = idx; if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(1); } else { aic3254_rx_config(DOWNLINK_OFF); aic3254_rx_mode = DOWNLINK_OFF; } break; case AIC3254_CONFIG_MEDIA: if (aic3254_minidsp == NULL) { rc = -EFAULT; break; } len = (aic3254_minidsp[idx][0].reg << 8) | aic3254_minidsp[idx][0].data; pr_aud_info("%s: configure miniDSP index(%d) len = %d ++\n", __func__, idx, len); pr_aud_info("%s: rx mode %d, tx mode %d\n", __func__, aic3254_rx_mode, aic3254_tx_mode); t1 = ktime_to_ms(ktime_get()); if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(0); /* step 1: power off first */ if (aic3254_rx_mode != DOWNLINK_OFF) aic3254_rx_config(DOWNLINK_OFF); /* step 2: config DSP */ aic3254_config(&aic3254_minidsp[idx][1], len); /* step 3: switch back to original path */ if (aic3254_rx_mode != DOWNLINK_OFF) aic3254_rx_config(aic3254_rx_mode); if (aic3254_tx_mode != UPLINK_OFF) aic3254_tx_config(aic3254_tx_mode); t2 = ktime_to_ms(ktime_get())-t1; if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(1); pr_aud_info("%s: configure miniDSP index(%d) time: %lldms --\n", __func__, idx, (t2)); break; } spi_aic3254_allow_sleep(); mutex_unlock(&lock); return rc; }
static int aic3254_set_config(int config_tbl, int idx, int en) { int len; struct ecodec_aic3254_state *drv = &codec_clk; pr_aud_info("%s: table(0x%X) index(%d)\n", __func__, config_tbl, idx); wake_lock(&drv->idlelock); #if defined(CONFIG_ARCH_MSM7X30) if (drv->enabled == 0) { /* enable MI2S RX master block */ /* enable MI2S RX bit clock */ clk_enable(drv->rx_mclk); clk_enable(drv->rx_sclk); printk("%s: enable CLK\n", __func__); drv->enabled = 1; } #endif switch (config_tbl) { case AIC3254_CONFIG_TX: /* TX */ pr_aud_info("%s: enable tx\n", __func__); if (en) { if (ctl_ops->tx_amp_enable) ctl_ops->tx_amp_enable(0); aic3254_tx_config(idx); aic3254_tx_mode = idx; if (ctl_ops->tx_amp_enable) ctl_ops->tx_amp_enable(1); } else { aic3254_tx_config(UPLINK_OFF); aic3254_tx_mode = UPLINK_OFF; } break; case AIC3254_CONFIG_RX: /* RX */ pr_aud_info("%s: enable rx\n", __func__); if (en) { if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(0); aic3254_rx_config(idx); aic3254_rx_mode = idx; if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(1); } else { aic3254_rx_config(DOWNLINK_OFF); aic3254_rx_mode = DOWNLINK_OFF; } break; case AIC3254_CONFIG_MEDIA: if (aic3254_minidsp == NULL) return -EFAULT; len = (aic3254_minidsp[idx][0].reg << 8) | aic3254_minidsp[idx][0].data; pr_aud_info("%s: miniDSP command len = %d\n", __func__, len); pr_aud_info("%s: rx mode %d, tx mode %d\n", __func__, aic3254_rx_mode, aic3254_tx_mode); if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(0); /* step 1: power off first */ if (aic3254_rx_mode != DOWNLINK_OFF) aic3254_rx_config(DOWNLINK_OFF); /* step 2: config DSP */ aic3254_config(&aic3254_minidsp[idx][1], len); /* step 3: switch back to original path */ if (aic3254_rx_mode != DOWNLINK_OFF) aic3254_rx_config(aic3254_rx_mode); if (aic3254_tx_mode != UPLINK_OFF) aic3254_tx_config(aic3254_tx_mode); if (ctl_ops->rx_amp_enable) ctl_ops->rx_amp_enable(1); pr_aud_info("%s: configure minidsp done\n", __func__); break; } wake_unlock(&drv->idlelock); return 0; }