sound/soc/intel/atom/sst/sst_drv_interface.c

Source file repositories/reference/linux-study-clean/sound/soc/intel/atom/sst/sst_drv_interface.c

File Facts

System
Linux kernel
Corpus path
sound/soc/intel/atom/sst/sst_drv_interface.c
Extension
.c
Size
18129 bytes
Lines
690
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ret < 0) {
			dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret);
			return ret;
		}
		if ((ctx->sst_state == SST_RESET) && (usage_count == 1)) {
			ret = sst_load_fw(ctx);
			if (ret) {
				dev_err(dev, "FW download fail %d\n", ret);
				sst_set_fw_state_locked(ctx, SST_RESET);
				ret = sst_pm_runtime_put(ctx);
			}
		}
	} else {
		usage_count = GET_USAGE_COUNT(dev);
		dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
		return sst_pm_runtime_put(ctx);
	}
	return ret;
}

/*
 * sst_open_pcm_stream - Open PCM interface
 *
 * @str_param: parameters of pcm stream
 *
 * This function is called by MID sound card driver to open
 * a new pcm interface
 */
static int sst_open_pcm_stream(struct device *dev,
		struct snd_sst_params *str_param)
{
	int retval;
	struct intel_sst_drv *ctx = dev_get_drvdata(dev);

	if (!str_param)
		return -EINVAL;

	retval = sst_get_stream(ctx, str_param);
	if (retval > 0)
		ctx->stream_cnt++;
	else
		dev_err(ctx->dev, "sst_get_stream returned err %d\n", retval);

	return retval;
}

static int sst_cdev_open(struct device *dev,
		struct snd_sst_params *str_params, struct sst_compress_cb *cb)
{
	int str_id, retval;
	struct stream_info *stream;
	struct intel_sst_drv *ctx = dev_get_drvdata(dev);

	retval = pm_runtime_resume_and_get(ctx->dev);
	if (retval < 0)
		return retval;

	str_id = sst_get_stream(ctx, str_params);
	if (str_id > 0) {
		dev_dbg(dev, "stream allocated in sst_cdev_open %d\n", str_id);
		stream = &ctx->streams[str_id];
		stream->compr_cb = cb->compr_cb;
		stream->compr_cb_param = cb->param;
		stream->drain_notify = cb->drain_notify;
		stream->drain_cb_param = cb->drain_cb_param;
	} else {
		dev_err(dev, "stream encountered error during alloc %d\n", str_id);
		str_id = -EINVAL;
		sst_pm_runtime_put(ctx);
	}
	return str_id;
}

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;
	}

	retval = sst_free_stream(ctx, str_id);
	stream->compr_cb_param = NULL;
	stream->compr_cb = NULL;

	if (retval)

Annotation

Implementation Notes