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; int ret = 0; /* Capture path */ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) return -EINVAL; pr_debug("%s\n", __func__); compr = kzalloc(sizeof(struct compr_audio), GFP_KERNEL); if (compr == NULL) { pr_err("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("%s: Could not allocate memory\n", __func__); kfree(prtd); return -ENOMEM; } prtd->audio_client->perf_mode = false; runtime->hw = msm_compr_hardware_playback; pr_info("%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->audio_client->perf_mode, 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("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("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; return 0; }
static int msm_compr_open(struct snd_compr_stream *cstream) { struct snd_compr_runtime *runtime = cstream->runtime; struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct msm_compr_audio *prtd; struct msm_compr_pdata *pdata = snd_soc_platform_get_drvdata(rtd->platform); pr_debug("%s\n", __func__); prtd = kzalloc(sizeof(struct msm_compr_audio), GFP_KERNEL); if (prtd == NULL) { pr_err("Failed to allocate memory for msm_compr_audio\n"); return -ENOMEM; } prtd->cstream = cstream; pdata->cstream[rtd->dai_link->be_id] = cstream; pdata->audio_effects[rtd->dai_link->be_id] = kzalloc(sizeof(struct msm_compr_audio_effects), GFP_KERNEL); if (!pdata->audio_effects[rtd->dai_link->be_id]) { pr_err("%s: Could not allocate memory for effects\n", __func__); kfree(prtd); return -ENOMEM; } prtd->audio_client = q6asm_audio_client_alloc( (app_cb)compr_event_handler, prtd); if (!prtd->audio_client) { pr_err("%s: Could not allocate memory for client\n", __func__); kfree(pdata->audio_effects[rtd->dai_link->be_id]); kfree(prtd); return -ENOMEM; } pr_debug("%s: session ID %d\n", __func__, prtd->audio_client->session); prtd->audio_client->perf_mode = false; prtd->session_id = prtd->audio_client->session; prtd->codec = FORMAT_MP3; prtd->bytes_received = 0; prtd->copied_total = 0; prtd->byte_offset = 0; prtd->sample_rate = 44100; prtd->num_channels = 2; prtd->drain_ready = 0; prtd->last_buffer = 0; prtd->first_buffer = 1; prtd->partial_drain_delay = 0; memset(&prtd->gapless_state, 0, sizeof(struct msm_compr_gapless_state)); /* * Update the use_dsp_gapless_mode from gapless struture with the value * part of platform data. */ prtd->gapless_state.use_dsp_gapless_mode = pdata->use_dsp_gapless_mode; pr_debug("%s: gapless mode %d", __func__, pdata->use_dsp_gapless_mode); spin_lock_init(&prtd->lock); atomic_set(&prtd->eos, 0); atomic_set(&prtd->start, 0); atomic_set(&prtd->drain, 0); atomic_set(&prtd->xrun, 0); atomic_set(&prtd->close, 0); atomic_set(&prtd->wait_on_close, 0); atomic_set(&prtd->error, 0); init_waitqueue_head(&prtd->eos_wait); init_waitqueue_head(&prtd->drain_wait); init_waitqueue_head(&prtd->flush_wait); init_waitqueue_head(&prtd->close_wait); runtime->private_data = prtd; populate_codec_list(prtd); if (cstream->direction == SND_COMPRESS_PLAYBACK) { if (!atomic_cmpxchg(&pdata->audio_ocmem_req, 0, 1)) audio_ocmem_process_req(AUDIO, true); else atomic_inc(&pdata->audio_ocmem_req); pr_debug("%s: ocmem_req: %d\n", __func__, atomic_read(&pdata->audio_ocmem_req)); } else { pr_err("%s: Unsupported stream type", __func__); } 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; //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; }