Unverified Commit 233d2c4a authored by Mark Brown's avatar Mark Brown
Browse files

Clean ups and preparation for IPC abstraction in the SOF driver

Merge series from Ranjani Sridharan <ranjani.sridharan@linux.intel.com>:

In preparation for adding support for the new IPC version that has been
introduced in the SOF firmware, this patch set includes some clean ups
and necessary modifications to commonly used functions that will be
re-used across different IPC-specific code.
parents efb1a2d3 f535880b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -116,4 +116,9 @@ struct sof_ipc_dai_config {
	};
} __packed;

struct sof_dai_private_data {
	struct sof_ipc_comp_dai *comp_dai;
	struct sof_ipc_dai_config *dai_config;
};

#endif
+0 −8
Original line number Diff line number Diff line
@@ -87,9 +87,6 @@ struct sof_ipc_comp {
 */
#define SOF_BUF_UNDERRUN_PERMITTED	BIT(1)

/* the UUID size in bytes, shared between FW and host */
#define SOF_UUID_SIZE	16

/* create new component buffer - SOF_IPC_TPLG_BUFFER_NEW */
struct sof_ipc_buffer {
	struct sof_ipc_comp comp;
@@ -303,9 +300,4 @@ enum sof_event_types {
	SOF_KEYWORD_DETECT_DAPM_EVENT,
};

/* extended data struct for UUID components */
struct sof_ipc_comp_ext {
	uint8_t uuid[SOF_UUID_SIZE];
}  __packed;

#endif
+21 −6
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ static struct sof_ipc_dai_config *hda_dai_update_config(struct snd_soc_dapm_widg
							int channel)
{
	struct snd_sof_widget *swidget = w->dobj.private;
	struct sof_dai_private_data *private;
	struct sof_ipc_dai_config *config;
	struct snd_sof_dai *sof_dai;

@@ -175,12 +176,19 @@ static struct sof_ipc_dai_config *hda_dai_update_config(struct snd_soc_dapm_widg

	sof_dai = swidget->private;

	if (!sof_dai || !sof_dai->dai_config) {
		dev_err(swidget->scomp->dev, "error: No config for DAI %s\n", w->name);
	if (!sof_dai || !sof_dai->private) {
		dev_err(swidget->scomp->dev, "%s: No private data for DAI %s\n", __func__,
			w->name);
		return NULL;
	}

	config = &sof_dai->dai_config[sof_dai->current_config];
	private = sof_dai->private;
	if (!private->dai_config) {
		dev_err(swidget->scomp->dev, "%s: No config for DAI %s\n", __func__, w->name);
		return NULL;
	}

	config = &private->dai_config[sof_dai->current_config];

	/* update config with stream tag */
	config->hda.link_dma_ch = channel;
@@ -294,6 +302,7 @@ static int hda_link_dai_config_pause_push_ipc(struct snd_soc_dapm_widget *w)
	struct snd_sof_widget *swidget = w->dobj.private;
	struct snd_soc_component *component = swidget->scomp;
	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
	struct sof_dai_private_data *private;
	struct sof_ipc_dai_config *config;
	struct snd_sof_dai *sof_dai;
	struct sof_ipc_reply reply;
@@ -301,12 +310,18 @@ static int hda_link_dai_config_pause_push_ipc(struct snd_soc_dapm_widget *w)

	sof_dai = swidget->private;

	if (!sof_dai || !sof_dai->dai_config) {
		dev_err(sdev->dev, "No config for DAI %s\n", w->name);
	if (!sof_dai || !sof_dai->private) {
		dev_err(sdev->dev, "%s: No private data for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

	private = sof_dai->private;
	if (!private->dai_config) {
		dev_err(sdev->dev, "%s: No config for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

	config = &sof_dai->dai_config[sof_dai->current_config];
	config = &private->dai_config[sof_dai->current_config];

	/* set PAUSE command flag */
	config->flags = FIELD_PREP(SOF_DAI_CONFIG_FLAGS_CMD_MASK, SOF_DAI_CONFIG_FLAGS_PAUSE);
+30 −9
Original line number Diff line number Diff line
@@ -47,14 +47,21 @@ int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w, unsigned int quirk_
	struct snd_soc_component *component = swidget->scomp;
	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
	struct sof_ipc_dai_config *config;
	struct sof_dai_private_data *private;
	struct snd_sof_dai *sof_dai;
	struct sof_ipc_reply reply;
	int ret;

	sof_dai = swidget->private;

	if (!sof_dai || !sof_dai->dai_config) {
		dev_err(sdev->dev, "No config for DAI %s\n", w->name);
	if (!sof_dai || !sof_dai->private) {
		dev_err(sdev->dev, "%s: No private data for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

	private = sof_dai->private;
	if (!private->dai_config) {
		dev_err(sdev->dev, "%s: No config for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

@@ -65,7 +72,7 @@ int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w, unsigned int quirk_
			return ret;
	}

	config = &sof_dai->dai_config[sof_dai->current_config];
	config = &private->dai_config[sof_dai->current_config];

	/*
	 * For static pipelines, the DAI widget would already be set up and calling
@@ -101,6 +108,7 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_f
	struct snd_sof_widget *swidget = w->dobj.private;
	struct snd_soc_component *component = swidget->scomp;
	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
	struct sof_dai_private_data *private;
	struct sof_ipc_dai_config *config;
	struct snd_sof_dai *sof_dai;
	struct sof_ipc_reply reply;
@@ -108,8 +116,14 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_f

	sof_dai = swidget->private;

	if (!sof_dai || !sof_dai->dai_config) {
		dev_err(sdev->dev, "error: No config to free DAI %s\n", w->name);
	if (!sof_dai || !sof_dai->private) {
		dev_err(sdev->dev, "%s: No private data for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

	private = sof_dai->private;
	if (!private->dai_config) {
		dev_err(sdev->dev, "%s: No config for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

@@ -117,7 +131,7 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_f
	if (!sof_dai->configured)
		return 0;

	config = &sof_dai->dai_config[sof_dai->current_config];
	config = &private->dai_config[sof_dai->current_config];

	/* set HW_FREE flag along with any quirks */
	config->flags = SOF_DAI_CONFIG_FLAGS_HW_FREE |
@@ -154,6 +168,7 @@ static int sdw_dai_config_ipc(struct snd_sof_dev *sdev,
			      int link_id, int alh_stream_id, int dai_id, bool setup)
{
	struct snd_sof_widget *swidget = w->dobj.private;
	struct sof_dai_private_data *private;
	struct sof_ipc_dai_config *config;
	struct snd_sof_dai *sof_dai;

@@ -164,12 +179,18 @@ static int sdw_dai_config_ipc(struct snd_sof_dev *sdev,

	sof_dai = swidget->private;

	if (!sof_dai || !sof_dai->dai_config) {
		dev_err(sdev->dev, "error: No config for DAI %s\n", w->name);
	if (!sof_dai || !sof_dai->private) {
		dev_err(sdev->dev, "%s: No private data for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

	private = sof_dai->private;
	if (!private->dai_config) {
		dev_err(sdev->dev, "%s: No config for DAI %s\n", __func__, w->name);
		return -EINVAL;
	}

	config = &sof_dai->dai_config[sof_dai->current_config];
	config = &private->dai_config[sof_dai->current_config];

	/* update config with link and stream ID */
	config->dai_index = (link_id << 8) | dai_id;
+0 −12
Original line number Diff line number Diff line
@@ -27,18 +27,6 @@ static void ipc_stream_message(struct snd_sof_dev *sdev, void *msg_buf);
 * IPC message Tx/Rx message handling.
 */

/* SOF generic IPC data */
struct snd_sof_ipc {
	struct snd_sof_dev *sdev;

	/* protects messages and the disable flag */
	struct mutex tx_mutex;
	/* disables further sending of ipc's */
	bool disable_ipc_tx;

	struct snd_sof_ipc_msg msg;
};

struct sof_ipc_ctrl_data_params {
	size_t msg_bytes;
	size_t hdr_bytes;
Loading