static int msm_compr_prepare(struct snd_pcm_substream *substream) { int ret = 0; pr_info("[AUD]%s, vol %d\n", __func__, compr_msm_global.volume); compr_set_volume(compr_msm_global.volume); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ret = msm_compr_playback_prepare(substream); else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) ret = EINVAL; return ret; }
static int msm_compr_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; struct compr_audio *compr; struct msm_audio *prtd; struct asm_softpause_params softpause = { .enable = SOFT_PAUSE_ENABLE, .period = SOFT_PAUSE_PERIOD, .step = SOFT_PAUSE_STEP, .rampingcurve = SOFT_PAUSE_CURVE_LINEAR, }; struct asm_softvolume_params softvol = { .period = SOFT_VOLUME_PERIOD, .step = SOFT_VOLUME_STEP, .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, }; int ret = 0; /* Capture path */ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) return -EINVAL; pr_debug("[AUD]%s\n", __func__); compr = kzalloc(sizeof(struct compr_audio), GFP_KERNEL); if (compr == NULL) { pr_err("[AUD]Failed to allocate memory for msm_audio\n"); return -ENOMEM; } prtd = &compr->prtd; prtd->substream = substream; prtd->audio_client = q6asm_audio_client_alloc( (app_cb)compr_event_handler, compr); if (!prtd->audio_client) { pr_info("[AUD]%s: Could not allocate memory\n", __func__); kfree(prtd); return -ENOMEM; } runtime->hw = msm_compr_hardware_playback; //HTC_AUD +++ /* * to invoke q6asm_open_write() before opening adm_open() * issue: LPASS cannot handle data stream properly when switching * from non-tunnel to tunnel mode * * the change fixes data format as MP3 which lost extensiblity * should be take care when new codecs supported */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ret = q6asm_open_write(prtd->audio_client, FORMAT_MP3); if (ret < 0) { pr_err("[AUD]%s: Session out open failed\n", __func__); q6asm_audio_client_free(prtd->audio_client); kfree(prtd); return -ENOMEM; } ret = q6asm_set_io_mode(prtd->audio_client, ASYNC_IO_MODE); if (ret < 0) { pr_err("[AUD]%s: Set IO mode failed\n", __func__); q6asm_audio_client_free(prtd->audio_client); kfree(prtd); return -ENOMEM; } } //HTC_AUD --- pr_info("[AUD]%s: session ID %d\n", __func__, prtd->audio_client->session); prtd->session_id = prtd->audio_client->session; msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->be_id, prtd->session_id, substream->stream); prtd->cmd_ack = 1; ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_sample_rates); if (ret < 0) pr_info("[AUD]snd_pcm_hw_constraint_list failed\n"); /* Ensure that buffer size is a multiple of period size */ ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) pr_info("[AUD]snd_pcm_hw_constraint_integer failed\n"); prtd->dsp_cnt = 0; atomic_set(&prtd->pending_buffer, 1); compr->codec = FORMAT_MP3; populate_codec_list(compr, runtime); runtime->private_data = compr; compr_msm_global.prtd = prtd; compr_set_volume(compr_msm_global.volume); ret = q6asm_set_softpause(compr_msm_global.prtd->audio_client, &softpause); if (ret < 0) pr_err("[AUD]%s: Send SoftPause Param failed ret=%d\n", __func__, ret); ret = q6asm_set_softvolume(compr_msm_global.prtd->audio_client, &softvol); if (ret < 0) pr_err("[AUD]%s: Send SoftVolume Param failed ret=%d\n", __func__, ret); return 0; }
static int msm_compr_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; struct compr_audio *compr; struct msm_audio *prtd; struct asm_softpause_params softpause = { .enable = SOFT_PAUSE_ENABLE, .period = SOFT_PAUSE_PERIOD, .step = SOFT_PAUSE_STEP, .rampingcurve = SOFT_PAUSE_CURVE_LINEAR, }; struct asm_softvolume_params softvol = { .period = SOFT_VOLUME_PERIOD, .step = SOFT_VOLUME_STEP, .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, }; int ret = 0; /* Capture path */ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) return -EINVAL; pr_debug("[AUD]%s\n", __func__); compr = kzalloc(sizeof(struct compr_audio), GFP_KERNEL); if (compr == NULL) { pr_err("[AUD]Failed to allocate memory for msm_audio\n"); return -ENOMEM; } prtd = &compr->prtd; prtd->substream = substream; prtd->audio_client = q6asm_audio_client_alloc( (app_cb)compr_event_handler, compr); if (!prtd->audio_client) { pr_info("[AUD]%s: Could not allocate memory\n", __func__); kfree(prtd); return -ENOMEM; } runtime->hw = msm_compr_hardware_playback; pr_info("[AUD]%s: session ID %d\n", __func__, prtd->audio_client->session); prtd->session_id = prtd->audio_client->session; msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->be_id, prtd->session_id, substream->stream); prtd->cmd_ack = 1; ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_sample_rates); if (ret < 0) pr_info("[AUD]snd_pcm_hw_constraint_list failed\n"); /* Ensure that buffer size is a multiple of period size */ ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) pr_info("[AUD]snd_pcm_hw_constraint_integer failed\n"); prtd->dsp_cnt = 0; atomic_set(&prtd->pending_buffer, 1); compr->codec = FORMAT_MP3; populate_codec_list(compr, runtime); runtime->private_data = compr; compr_msm_global.prtd = prtd; compr_set_volume(compr_msm_global.volume); ret = q6asm_set_softpause(compr_msm_global.prtd->audio_client, &softpause); if (ret < 0) pr_err("[AUD]%s: Send SoftPause Param failed ret=%d\n", __func__, ret); ret = q6asm_set_softvolume(compr_msm_global.prtd->audio_client, &softvol); if (ret < 0) pr_err("[AUD]%s: Send SoftVolume Param failed ret=%d\n", __func__, ret); return 0; }