/* must be called with audio->lock held */ static int audevrc_in_enable(struct audio_evrc_in *audio) { struct audmgr_config cfg; int rc; if (audio->enabled) return 0; cfg.tx_rate = audio->samp_rate; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; cfg.codec = RPC_AUD_DEF_CODEC_EVRC; cfg.snd_method = RPC_SND_METHOD_MIDI; if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) { rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; if (audpreproc_enable(audio->enc_id, &audpre_dsp_event, audio)) { MM_ERR("msm_adsp_enable(audpreproc) failed\n"); audmgr_disable(&audio->audmgr); return -ENODEV; } /*update aurec session info in audpreproc layer*/ audio->session_info.session_id = audio->enc_id; audio->session_info.sampling_freq = convert_samp_index(audio->samp_rate); audpreproc_update_audrec_info(&audio->session_info); } if (msm_adsp_enable(audio->audrec)) { if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) { audpreproc_disable(audio->enc_id, audio); audmgr_disable(&audio->audmgr); } MM_ERR("msm_adsp_enable(audrec) failed\n"); return -ENODEV; } audio->enabled = 1; audevrc_in_dsp_enable(audio, 1); return 0; }
int afe_config_rmc_block(struct acdb_rmc_block *acdb_rmc) { struct afe_cmd_cfg_rmc cmd; struct msm_afe_state *afe = &the_afe_state; int rc = 0; int i = 0; unsigned short *ptrmem = (unsigned short *)&cmd; MM_DBG(" configure rmc block\n"); mutex_lock(&afe->lock); if (!afe->in_use && !afe->mod) { /* enable afe */ rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe); if (rc < 0) { MM_DBG("%s: failed to get AFETASK module\n", __func__); goto error_adsp_get; } rc = msm_adsp_enable(afe->mod); if (rc < 0) goto error_adsp_enable; } memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = AFE_CMD_CFG_RMC_PARAMS; cmd.rmc_mode = acdb_rmc->rmc_enable; cmd.rmc_ipw_length_ms = acdb_rmc->rmc_ipw_length_ms; cmd.rmc_peak_length_ms = acdb_rmc->rmc_peak_length_ms; cmd.rmc_init_pulse_length_ms = acdb_rmc->rmc_init_pulse_length_ms; cmd.rmc_total_int_length_ms = acdb_rmc->rmc_total_int_length_ms; cmd.rmc_rampupdn_length_ms = acdb_rmc->rmc_rampupdn_length_ms; cmd.rmc_delay_length_ms = acdb_rmc->rmc_delay_length_ms; cmd.rmc_detect_start_threshdb = acdb_rmc->rmc_detect_start_threshdb; cmd.rmc_init_pulse_threshdb = acdb_rmc->rmc_init_pulse_threshdb; for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); afe_send_queue(afe, &cmd, sizeof(cmd)); mutex_unlock(&afe->lock); return rc; error_adsp_enable: msm_adsp_put(afe->mod); afe->mod = NULL; error_adsp_get: mutex_unlock(&afe->lock); return rc; }
static int audpcm_in_enable(struct audio_in *audio) { struct audmgr_config cfg; int rc; if (audio->enabled) return 0; cfg.tx_rate = audio->samp_rate; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_MIDI; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; if (audpreproc_enable(audio->enc_id, &audpre_dsp_event, audio)) { MM_AUD_ERR("audrec: msm_adsp_enable(audpre) failed\n"); audmgr_disable(&audio->audmgr); return -ENODEV; } if (msm_adsp_enable(audio->audrec)) { audpreproc_disable(audio->enc_id, audio); audmgr_disable(&audio->audmgr); MM_AUD_ERR("audrec: msm_adsp_enable(audrec) failed\n"); return -ENODEV; } audio->enabled = 1; audpcm_in_dsp_enable(audio, 1); audio->session_info.session_id = audio->enc_id; audio->session_info.sampling_freq = convert_samp_index(audio->samp_rate); audpreproc_update_audrec_info(&audio->session_info); return 0; }
/* must be called with audio->lock held */ static int audpcm_in_enable(struct audio_in *audio) { if (audio->enabled) return 0; if (audpreproc_enable(audio->enc_id, &audpreproc_dsp_event, audio)) { MM_AUD_ERR("msm_adsp_enable(audpreproc) failed\n"); return -ENODEV; } if (msm_adsp_enable(audio->audrec)) { MM_AUD_ERR("msm_adsp_enable(audrec) failed\n"); audpreproc_disable(audio->enc_id, audio); return -ENODEV; } audio->enabled = 1; audpcm_in_enc_config(audio, 1); return 0; }
int afe_config_aux_codec(int pcm_ctl_value, int aux_codec_intf_value, int data_format_pad) { struct afe_cmd_aux_codec_config cmd; struct msm_afe_state *afe = &the_afe_state; int rc = 0; MM_DBG(" configure aux codec \n"); mutex_lock(&afe->lock); if (!afe->in_use && !afe->aux_conf_flag) { /* enable afe */ rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe); if (rc < 0) { MM_ERR("%s: failed to get AFETASK module\n", __func__); goto error_adsp_get; } rc = msm_adsp_enable(afe->mod); if (rc < 0) goto error_adsp_enable; } afe->aux_conf_flag = 1; memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = AFE_CMD_AUX_CODEC_CONFIG_CMD; cmd.dma_path_ctl = 0; cmd.pcm_ctl = pcm_ctl_value; cmd.eight_khz_int_mode = 0; cmd.aux_codec_intf_ctl = aux_codec_intf_value; cmd.data_format_padding_info = data_format_pad; afe_send_queue(afe, &cmd, sizeof(cmd)); mutex_unlock(&afe->lock); return rc; error_adsp_enable: msm_adsp_put(afe->mod); afe->mod = NULL; error_adsp_get: mutex_unlock(&afe->lock); return rc; }
int afe_config_fm_codec(int fm_enable, uint16_t source) { struct afe_cmd_fm_codec_config cmd; struct msm_afe_state *afe = &the_afe_state; int rc = 0; int i = 0; unsigned short *ptrmem = (unsigned short *)&cmd; MM_INFO(" configure fm codec\n"); mutex_lock(&afe->lock); if (!afe->in_use) { /* enable afe */ rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe); if (rc < 0) { MM_ERR("%s: failed to get AFETASK module\n", __func__); goto error_adsp_get; } rc = msm_adsp_enable(afe->mod); if (rc < 0) goto error_adsp_enable; } memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = AFE_CMD_FM_RX_ROUTING_CMD; cmd.enable = fm_enable; cmd.device_id = source; for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); afe_send_queue(afe, &cmd, sizeof(cmd)); mutex_unlock(&afe->lock); return rc; error_adsp_enable: msm_adsp_put(afe->mod); afe->mod = NULL; error_adsp_get: mutex_unlock(&afe->lock); return rc; }
int afe_config_fm_calibration_gain(uint16_t device_id, uint16_t calibration_gain) { struct afe_cmd_fm_calibgain_config cmd; struct msm_afe_state *afe = &the_afe_state; int rc = 0; MM_INFO("Configure for rx device = 0x%4x, gain = 0x%4x\n", device_id, calibration_gain); mutex_lock(&afe->lock); if (!afe->in_use) { /* enable afe */ rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe); if (rc < 0) { MM_ERR("%s: failed to get AFETASK module\n", __func__); goto error_adsp_get; } rc = msm_adsp_enable(afe->mod); if (rc < 0) goto error_adsp_enable; } memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = AFE_CMD_FM_CALIBRATION_GAIN_CMD; cmd.device_id = device_id; cmd.calibration_gain = calibration_gain; afe_send_queue(afe, &cmd, sizeof(cmd)); mutex_unlock(&afe->lock); return rc; error_adsp_enable: msm_adsp_put(afe->mod); afe->mod = NULL; error_adsp_get: mutex_unlock(&afe->lock); return rc; }
/*ADD 0010850: Ext Codec PCM Loopback support*/ int afe_config_ext_pcm_loopback(uint16_t enable) { struct afe_ext_loopback_cmd_cfg cmd; struct msm_afe_state *afe = &the_afe_state; int rc = 0; MM_INFO(" configure ext pcm loopback %d\n",enable); mutex_lock(&afe->lock); if (!afe->in_use) { /* enable afe */ rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe); if (rc < 0) { MM_ERR("%s: failed to get AFETASK module\n", __func__); goto error_adsp_get; } rc = msm_adsp_enable(afe->mod); if (rc < 0) goto error_adsp_enable; } memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = AFE_CMD_EXT_PCM_LOOPBACK_CMD; cmd.en = enable; cmd.src_id = QDSP5_DEVICE_AUX_CODEC_TX; cmd.des_id = QDSP5_DEVICE_AUX_CODEC_RX; cmd.reserved = 0; afe_send_queue(afe, &cmd, sizeof(cmd)); mutex_unlock(&afe->lock); return rc; error_adsp_enable: msm_adsp_put(afe->mod); error_adsp_get: mutex_unlock(&afe->lock); return rc; }
/* must be called with audio->lock held */ static int audio_enable(struct audio *audio) { struct audmgr_config cfg; int rc; pr_info("audio_aac_enable()\n"); if (audio->enabled) return 0; audio->out_tail = 0; audio->out_needed = 0; cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK; cfg.codec = RPC_AUD_DEF_CODEC_AAC; cfg.snd_method = RPC_SND_METHOD_MIDI; audio_prevent_sleep(audio); audio->audmgr.cb = audio_aac_audmgr_cb; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) { pr_err("audio_aac: audmgr_enable() failed\n"); audio_allow_sleep(audio); return rc; } rc = msm_adsp_get("AUDPLAY0TASK", &audio->audplay, &audplay_aac_adsp_ops, audio); if (rc) { pr_err("audio_aac:" " failed to get audplay0 dsp module\n"); goto err_get_adsp; } if (msm_adsp_enable(audio->audplay)) { pr_err("audio_aac:" " msm_adsp_enable(audplay) failed\n"); goto err_enable_adsp; } if (audpp_enable(audio->dec_id, audio_dsp_event, audio_modem_event, audio)) { pr_err("audio_aac: audpp_enable() failed\n"); goto err_enable_audpp; } atomic_set(&audio->image_swap, 0); audio->enabled = 1; htc_pwrsink_audio_set(PWRSINK_AUDIO_AAC, 100); return 0; err_enable_audpp: msm_adsp_disable(audio->audplay); err_enable_adsp: msm_adsp_put(audio->audplay); err_get_adsp: audmgr_disable(&audio->audmgr); audio_allow_sleep(audio); return -ENODEV; }