void free_stream_context(unsigned int str_id) { struct stream_info *stream; if (!sst_validate_strid(str_id)) { /* str_id is valid, so stream is alloacted */ stream = &sst_drv_ctx->streams[str_id]; if (sst_free_stream(str_id)) sst_clean_stream(&sst_drv_ctx->streams[str_id]); if (stream->ops == STREAM_OPS_PLAYBACK || stream->ops == STREAM_OPS_PLAYBACK_DRM) { sst_drv_ctx->pb_streams--; if (sst_drv_ctx->pci_id == SST_MFLD_PCI_ID) sst_drv_ctx->scard_ops->power_down_pmic_pb( stream->device); else { if (sst_drv_ctx->pb_streams == 0) sst_drv_ctx->scard_ops-> power_down_pmic_pb(stream->device); } } else if (stream->ops == STREAM_OPS_CAPTURE) { sst_drv_ctx->cp_streams--; if (sst_drv_ctx->cp_streams == 0) sst_drv_ctx->scard_ops->power_down_pmic_cp( stream->device); } if (sst_drv_ctx->pb_streams == 0 && sst_drv_ctx->cp_streams == 0) sst_drv_ctx->scard_ops->power_down_pmic(); } }
static int sst_cdev_close(struct device *dev, unsigned int str_id) { int retval; struct stream_info *stream; struct intel_sst_drv *ctx = dev_get_drvdata(dev); stream = get_stream_info(ctx, str_id); if (!stream) { dev_err(dev, "stream info is NULL for str %d!!!\n", str_id); return -EINVAL; } if (stream->status == STREAM_RESET) { dev_dbg(dev, "stream in reset state...\n"); stream->status = STREAM_UN_INIT; retval = 0; goto put; } retval = sst_free_stream(ctx, str_id); put: stream->compr_cb_param = NULL; stream->compr_cb = NULL; if (retval) dev_err(dev, "free stream returned err %d\n", retval); dev_dbg(dev, "End\n"); return retval; }
int free_stream_context(struct intel_sst_drv *ctx, unsigned int str_id) { struct stream_info *stream; int ret = 0; stream = get_stream_info(ctx, str_id); if (stream) { /* str_id is valid, so stream is alloacted */ ret = sst_free_stream(ctx, str_id); if (ret) sst_clean_stream(&ctx->streams[str_id]); return ret; } else { dev_err(ctx->dev, "we tried to free stream context %d which was freed!!!\n", str_id); } return ret; }
int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) { struct snd_sst_alloc_mrfld alloc_param; struct snd_sst_params *str_params; struct snd_sst_tstamp fw_tstamp; struct stream_info *str_info; struct snd_sst_alloc_response *response; unsigned int str_id, pipe_id, task_id; int i, num_ch, ret = 0; void *data = NULL; dev_dbg(sst_drv_ctx->dev, "Enter\n"); BUG_ON(!params); str_params = (struct snd_sst_params *)params; memset(&alloc_param, 0, sizeof(alloc_param)); alloc_param.operation = str_params->ops; alloc_param.codec_type = str_params->codec; alloc_param.sg_count = str_params->aparams.sg_count; alloc_param.ring_buf_info[0].addr = str_params->aparams.ring_buf_info[0].addr; alloc_param.ring_buf_info[0].size = str_params->aparams.ring_buf_info[0].size; alloc_param.frag_size = str_params->aparams.frag_size; memcpy(&alloc_param.codec_params, &str_params->sparams, sizeof(struct snd_sst_stream_params)); /* * fill channel map params for multichannel support. * Ideally channel map should be received from upper layers * for multichannel support. * Currently hardcoding as per FW reqm. */ num_ch = sst_get_num_channel(str_params); for (i = 0; i < 8; i++) { if (i < num_ch) alloc_param.codec_params.uc.pcm_params.channel_map[i] = i; else alloc_param.codec_params.uc.pcm_params.channel_map[i] = 0xFF; } str_id = str_params->stream_id; str_info = get_stream_info(sst_drv_ctx, str_id); if (str_info == NULL) { dev_err(sst_drv_ctx->dev, "get stream info returned null\n"); return -EINVAL; } pipe_id = str_params->device_type; task_id = str_params->task; sst_drv_ctx->streams[str_id].pipe_id = pipe_id; sst_drv_ctx->streams[str_id].task_id = task_id; sst_drv_ctx->streams[str_id].num_ch = num_ch; if (sst_drv_ctx->info.lpe_viewpt_rqd) alloc_param.ts = sst_drv_ctx->info.mailbox_start + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); else alloc_param.ts = sst_drv_ctx->mailbox_add + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); dev_dbg(sst_drv_ctx->dev, "alloc tstamp location = 0x%x\n", alloc_param.ts); dev_dbg(sst_drv_ctx->dev, "assigned pipe id 0x%x to task %d\n", pipe_id, task_id); /* allocate device type context */ sst_init_stream(&sst_drv_ctx->streams[str_id], alloc_param.codec_type, str_id, alloc_param.operation, 0); dev_info(sst_drv_ctx->dev, "Alloc for str %d pipe %#x\n", str_id, pipe_id); ret = sst_prepare_and_post_msg(sst_drv_ctx, task_id, IPC_CMD, IPC_IA_ALLOC_STREAM_MRFLD, pipe_id, sizeof(alloc_param), &alloc_param, data, true, true, false, true); if (ret < 0) { dev_err(sst_drv_ctx->dev, "FW alloc failed ret %d\n", ret); /* alloc failed, so reset the state to uninit */ str_info->status = STREAM_UN_INIT; str_id = ret; } else if (data) { response = (struct snd_sst_alloc_response *)data; ret = response->str_type.result; if (!ret) goto out; dev_err(sst_drv_ctx->dev, "FW alloc failed ret %d\n", ret); if (ret == SST_ERR_STREAM_IN_USE) { dev_err(sst_drv_ctx->dev, "FW not in clean state, send free for:%d\n", str_id); sst_free_stream(sst_drv_ctx, str_id); } str_id = -ret; } out: kfree(data); return str_id; }