Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee084a06 authored by Meng Wang's avatar Meng Wang Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: Change platform driver to component driver



snd_soc_platform_driver is removed in kernel-4.19.
Update snd_soc_platform_driver to snd_soc_component_driver.

Change-Id: I434b6fd173d1f4365a610d9164342d5d04d6c5bc
Signed-off-by: default avatarMeng Wang <mengw@codeaurora.org>
parent 6463cdbf
Loading
Loading
Loading
Loading
+173 −57
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@
#include "msm-pcm-routing-v2.h"
#include "msm-qti-pp-config.h"

#define DRV_NAME "msm-compress-q6-v2"

#define DSP_PP_BUFFERING_IN_MSEC	25
#define PARTIAL_DRAIN_ACK_EARLY_BY_MSEC	150
#define MP3_OUTPUT_FRAME_SZ		1152
@@ -346,6 +348,7 @@ static int msm_compr_set_volume(struct snd_compr_stream *cstream,
	uint32_t avg_vol, gain_list[VOLUME_CONTROL_MAX_CHANNELS];
	uint32_t num_channels;
	struct snd_soc_pcm_runtime *rtd;
	struct snd_soc_component *component = NULL;
	struct msm_compr_pdata *pdata;
	bool use_default = true;
	u8 *chmap = NULL;
@@ -358,12 +361,13 @@ static int msm_compr_set_volume(struct snd_compr_stream *cstream,
	}
	rtd = cstream->private_data;
	prtd = cstream->runtime->private_data;
	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);

	if (!rtd || !rtd->platform || !prtd || !prtd->audio_client) {
	if (!rtd || !component || !prtd || !prtd->audio_client) {
		pr_err("%s: invalid rtd, prtd or audio client", __func__);
		return rc;
	}
	pdata = snd_soc_platform_get_drvdata(rtd->platform);
	pdata = snd_soc_component_get_drvdata(component);

	if (prtd->compr_passthr != LEGACY_PCM) {
		pr_debug("%s: No volume config for passthrough %d\n",
@@ -952,8 +956,8 @@ static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream,
	struct snd_compr_runtime *runtime = cstream->runtime;
	struct msm_compr_audio *prtd = runtime->private_data;
	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
	struct msm_compr_pdata *pdata =
			snd_soc_platform_get_drvdata(rtd->platform);
	struct snd_soc_component *component =NULL;
	struct msm_compr_pdata *pdata = NULL;
	struct asm_aac_cfg aac_cfg;
	struct asm_wma_cfg wma_cfg;
	struct asm_wmapro_cfg wma_pro_cfg;
@@ -974,6 +978,13 @@ static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream,
	pr_debug("%s: use_gapless_codec_options %d\n",
			__func__, use_gapless_codec_options);

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}
	pdata = snd_soc_component_get_drvdata(component);

	if (use_gapless_codec_options)
		codec_options = &(prtd->gapless_state.codec_options);
	else
@@ -1598,11 +1609,17 @@ static int msm_compr_playback_open(struct snd_compr_stream *cstream)
{
	struct snd_compr_runtime *runtime = cstream->runtime;
	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
	struct snd_soc_component *component = NULL;
	struct msm_compr_audio *prtd = NULL;
	struct msm_compr_pdata *pdata =
			snd_soc_platform_get_drvdata(rtd->platform);
	struct msm_compr_pdata *pdata = NULL;

	pr_debug("%s\n", __func__);
	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}
	pdata = snd_soc_component_get_drvdata(component);
	if (pdata->is_in_use[rtd->dai_link->id] == true) {
		pr_err("%s: %s is already in use, err: %d\n",
			__func__, rtd->dai_link->cpu_dai_name, -EBUSY);
@@ -1699,13 +1716,23 @@ static int msm_compr_capture_open(struct snd_compr_stream *cstream)
{
	struct snd_compr_runtime *runtime = cstream->runtime;
	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
	struct snd_soc_component *component = NULL;
	struct msm_compr_audio *prtd;
	struct msm_compr_pdata *pdata =
			snd_soc_platform_get_drvdata(rtd->platform);
	struct msm_compr_pdata *pdata = NULL;

	pr_debug("%s\n", __func__);
	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}
	pdata = snd_soc_component_get_drvdata(component);
	if (!pdata) {
		pr_err("%s: pdata is NULL\n", __func__);
		return -EINVAL;
	}
	prtd = kzalloc(sizeof(struct msm_compr_audio), GFP_KERNEL);
	if (prtd == NULL) {
	if (!prtd) {
		pr_err("Failed to allocate memory for msm_compr_audio\n");
		return -ENOMEM;
	}
@@ -1766,6 +1793,7 @@ static int msm_compr_playback_free(struct snd_compr_stream *cstream)
	struct snd_compr_runtime *runtime;
	struct msm_compr_audio *prtd;
	struct snd_soc_pcm_runtime *soc_prtd;
	struct snd_soc_component *component = NULL;
	struct msm_compr_pdata *pdata;
	struct audio_client *ac;
	int dir = IN, ret = 0, stream_id;
@@ -1780,8 +1808,9 @@ static int msm_compr_playback_free(struct snd_compr_stream *cstream)
	}
	runtime = cstream->runtime;
	soc_prtd = cstream->private_data;
	if (!runtime || !soc_prtd || !(soc_prtd->platform)) {
		pr_err("%s runtime or soc_prtd or platform is null\n",
	component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
	if (!runtime || !soc_prtd || !component) {
		pr_err("%s runtime or soc_prtd or component is null\n",
			__func__);
		return 0;
	}
@@ -1792,7 +1821,7 @@ static int msm_compr_playback_free(struct snd_compr_stream *cstream)
	}
	prtd->cmd_interrupt = 1;
	wake_up(&prtd->drain_wait);
	pdata = snd_soc_platform_get_drvdata(soc_prtd->platform);
	pdata = snd_soc_component_get_drvdata(component);
	ac = prtd->audio_client;
	if (!pdata || !ac) {
		pr_err("%s pdata or ac is null\n", __func__);
@@ -1867,6 +1896,7 @@ static int msm_compr_capture_free(struct snd_compr_stream *cstream)
	struct snd_compr_runtime *runtime;
	struct msm_compr_audio *prtd;
	struct snd_soc_pcm_runtime *soc_prtd;
	struct snd_soc_component *component = NULL;
	struct msm_compr_pdata *pdata;
	struct audio_client *ac;
	int dir = OUT, stream_id;
@@ -1879,8 +1909,9 @@ static int msm_compr_capture_free(struct snd_compr_stream *cstream)
	}
	runtime = cstream->runtime;
	soc_prtd = cstream->private_data;
	if (!runtime || !soc_prtd || !(soc_prtd->platform)) {
		pr_err("%s runtime or soc_prtd or platform is null\n",
	component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
	if (!runtime || !soc_prtd || !component) {
		pr_err("%s runtime or soc_prtd or component is null\n",
			__func__);
		return 0;
	}
@@ -1889,7 +1920,7 @@ static int msm_compr_capture_free(struct snd_compr_stream *cstream)
		pr_err("%s prtd is null\n", __func__);
		return 0;
	}
	pdata = snd_soc_platform_get_drvdata(soc_prtd->platform);
	pdata = snd_soc_component_get_drvdata(component);
	ac = prtd->audio_client;
	if (!pdata || !ac) {
		pr_err("%s pdata or ac is null\n", __func__);
@@ -2207,9 +2238,9 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
	struct snd_compr_runtime *runtime = cstream->runtime;
	struct msm_compr_audio *prtd = runtime->private_data;
	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
	struct msm_compr_pdata *pdata =
			snd_soc_platform_get_drvdata(rtd->platform);
	uint32_t *volume = pdata->volume[rtd->dai_link->id];
	struct snd_soc_component *component = NULL;
	struct msm_compr_pdata *pdata = NULL;
	uint32_t *volume = NULL;
	struct audio_client *ac = prtd->audio_client;
	unsigned long fe_id = rtd->dai_link->id;
	int rc = 0;
@@ -2219,6 +2250,18 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
	uint32_t stream_index;
	uint16_t bits_per_sample = 16;

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}
	pdata = snd_soc_component_get_drvdata(component);
	if (!pdata) {
		pr_err("%s: pdata is NULL\n", __func__);
		return -EINVAL;
	}
	volume = pdata->volume[rtd->dai_link->id];

	spin_lock_irqsave(&prtd->lock, flags);
	if (atomic_read(&prtd->error)) {
		pr_err("%s Got RESET EVENTS notification, return immediately",
@@ -2676,6 +2719,7 @@ static int msm_compr_pointer(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 = runtime->private_data;
	struct snd_soc_component *component = NULL;
	struct msm_compr_pdata *pdata = NULL;
	struct snd_compr_tstamp tstamp;
	uint64_t timestamp = 0;
@@ -2683,7 +2727,17 @@ static int msm_compr_pointer(struct snd_compr_stream *cstream,
	unsigned long flags;
	uint32_t gapless_transition;

	pdata = snd_soc_platform_get_drvdata(rtd->platform);
	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}
	pdata = snd_soc_component_get_drvdata(component);
	if (!pdata) {
		pr_err("%s: pdata is NULL\n", __func__);
		return -EINVAL;
	}

	pr_debug("%s\n", __func__);
	memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp));

@@ -3906,7 +3960,7 @@ static const struct snd_kcontrol_new msm_compr_gapless_controls[] = {
			msm_compr_gapless_put),
};

static int msm_compr_probe(struct snd_soc_platform *platform)
static int msm_compr_probe(struct snd_soc_component *component)
{
	struct msm_compr_pdata *pdata;
	int i;
@@ -3919,7 +3973,7 @@ static int msm_compr_probe(struct snd_soc_platform *platform)
	if (!pdata)
		return -ENOMEM;

	snd_soc_platform_set_drvdata(platform, pdata);
	snd_soc_component_set_drvdata(component, pdata);

	for (i = 0; i < MSM_FRONTEND_DAI_MAX; i++) {
		pdata->volume[i][0] = COMPRESSED_LR_VOL_MAX_STEPS;
@@ -3931,10 +3985,10 @@ static int msm_compr_probe(struct snd_soc_platform *platform)
		pdata->is_in_use[i] = false;
	}

	snd_soc_add_platform_controls(platform, msm_compr_gapless_controls,
	snd_soc_add_component_controls(component, msm_compr_gapless_controls,
				      ARRAY_SIZE(msm_compr_gapless_controls));

	rc =  of_property_read_string(platform->dev->of_node,
	rc =  of_property_read_string(component->dev->of_node,
		"qcom,adsp-version", &qdsp_version);
	if (!rc) {
		if (!strcmp(qdsp_version, "MDSP 1.2"))
@@ -4018,6 +4072,7 @@ static int msm_compr_channel_map_info(struct snd_kcontrol *kcontrol,

static int msm_compr_add_volume_control(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = "Compress Playback";
	const char *deviceNo       = "NN";
	const char *suffix         = "Volume";
@@ -4041,6 +4096,12 @@ static int msm_compr_add_volume_control(struct snd_soc_pcm_runtime *rtd)
		pr_err("%s NULL rtd\n", __func__);
		return 0;
	}
	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return 0;
	}

	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
		 __func__, rtd->dai_link->name, rtd->dai_link->id,
		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
@@ -4056,7 +4117,7 @@ static int msm_compr_add_volume_control(struct snd_soc_pcm_runtime *rtd)
	fe_volume_control[0].name = mixer_str;
	fe_volume_control[0].private_value = rtd->dai_link->id;
	pr_debug("Registering new mixer ctl %s", mixer_str);
	snd_soc_add_platform_controls(rtd->platform, fe_volume_control,
	snd_soc_add_component_controls(component, fe_volume_control,
				      ARRAY_SIZE(fe_volume_control));
	kfree(mixer_str);
	return 0;
@@ -4064,6 +4125,7 @@ static int msm_compr_add_volume_control(struct snd_soc_pcm_runtime *rtd)

static int msm_compr_add_audio_effects_control(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = "Audio Effects Config";
	const char *deviceNo       = "NN";
	char *mixer_str = NULL;
@@ -4080,12 +4142,17 @@ static int msm_compr_add_audio_effects_control(struct snd_soc_pcm_runtime *rtd)
		}
	};


	if (!rtd) {
		pr_err("%s NULL rtd\n", __func__);
		return 0;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return 0;
	}

	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
		 __func__, rtd->dai_link->name, rtd->dai_link->id,
		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
@@ -4101,7 +4168,7 @@ static int msm_compr_add_audio_effects_control(struct snd_soc_pcm_runtime *rtd)
	fe_audio_effects_config_control[0].name = mixer_str;
	fe_audio_effects_config_control[0].private_value = rtd->dai_link->id;
	pr_debug("Registering new mixer ctl %s\n", mixer_str);
	snd_soc_add_platform_controls(rtd->platform,
	snd_soc_add_component_controls(component,
				fe_audio_effects_config_control,
				ARRAY_SIZE(fe_audio_effects_config_control));
	kfree(mixer_str);
@@ -4111,6 +4178,7 @@ static int msm_compr_add_audio_effects_control(struct snd_soc_pcm_runtime *rtd)
static int msm_compr_add_query_audio_effect_control(
					struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = "Query Audio Effect Param";
	const char *deviceNo       = "NN";
	char *mixer_str = NULL;
@@ -4130,6 +4198,13 @@ static int msm_compr_add_query_audio_effect_control(
		pr_err("%s NULL rtd\n", __func__);
		return 0;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return 0;
	}

	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
		 __func__, rtd->dai_link->name, rtd->dai_link->id,
		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
@@ -4143,7 +4218,7 @@ static int msm_compr_add_query_audio_effect_control(
	fe_query_audio_effect_control[0].name = mixer_str;
	fe_query_audio_effect_control[0].private_value = rtd->dai_link->id;
	pr_debug("%s: registering new mixer ctl %s\n", __func__, mixer_str);
	snd_soc_add_platform_controls(rtd->platform,
	snd_soc_add_component_controls(component,
				fe_query_audio_effect_control,
				ARRAY_SIZE(fe_query_audio_effect_control));
	kfree(mixer_str);
@@ -4153,6 +4228,7 @@ static int msm_compr_add_query_audio_effect_control(
static int msm_compr_add_audio_adsp_stream_cmd_control(
			struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = DSP_STREAM_CMD;
	const char *deviceNo = "NN";
	char *mixer_str = NULL;
@@ -4170,23 +4246,26 @@ static int msm_compr_add_audio_adsp_stream_cmd_control(

	if (!rtd) {
		pr_err("%s NULL rtd\n", __func__);
		ret = -EINVAL;
		goto done;
		return -EINVAL;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}

	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
	if (!mixer_str) {
		ret = -ENOMEM;
		goto done;
	}
	if (!mixer_str)
		return -ENOMEM;

	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
	fe_audio_adsp_stream_cmd_config_control[0].name = mixer_str;
	fe_audio_adsp_stream_cmd_config_control[0].private_value =
				rtd->dai_link->id;
	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
	ret = snd_soc_add_platform_controls(rtd->platform,
	ret = snd_soc_add_component_controls(component,
		fe_audio_adsp_stream_cmd_config_control,
		ARRAY_SIZE(fe_audio_adsp_stream_cmd_config_control));
	if (ret < 0)
@@ -4201,6 +4280,7 @@ static int msm_compr_add_audio_adsp_stream_cmd_control(
static int msm_compr_add_audio_adsp_stream_callback_control(
			struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
	const char *deviceNo = "NN";
	char *mixer_str = NULL;
@@ -4224,6 +4304,12 @@ static int msm_compr_add_audio_adsp_stream_callback_control(
		goto done;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}

	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
	if (!mixer_str) {
@@ -4236,7 +4322,7 @@ static int msm_compr_add_audio_adsp_stream_callback_control(
	fe_audio_adsp_callback_config_control[0].private_value =
					rtd->dai_link->id;
	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
	ret = snd_soc_add_platform_controls(rtd->platform,
	ret = snd_soc_add_component_controls(component,
			fe_audio_adsp_callback_config_control,
			ARRAY_SIZE(fe_audio_adsp_callback_config_control));
	if (ret < 0) {
@@ -4264,6 +4350,7 @@ static int msm_compr_add_audio_adsp_stream_callback_control(
static int msm_compr_add_dec_runtime_params_control(
						struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name	= "Audio Stream";
	const char *deviceNo		= "NN";
	const char *suffix		= "Dec Params";
@@ -4286,6 +4373,12 @@ static int msm_compr_add_dec_runtime_params_control(
		return 0;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return 0;
	}

	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
		 __func__, rtd->dai_link->name, rtd->dai_link->id,
		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
@@ -4303,7 +4396,7 @@ static int msm_compr_add_dec_runtime_params_control(
	fe_dec_params_control[0].name = mixer_str;
	fe_dec_params_control[0].private_value = rtd->dai_link->id;
	pr_debug("Registering new mixer ctl %s", mixer_str);
	snd_soc_add_platform_controls(rtd->platform,
	snd_soc_add_component_controls(component,
				      fe_dec_params_control,
				      ARRAY_SIZE(fe_dec_params_control));
	kfree(mixer_str);
@@ -4312,6 +4405,7 @@ static int msm_compr_add_dec_runtime_params_control(

static int msm_compr_add_app_type_cfg_control(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *playback_mixer_ctl_name	= "Audio Stream";
	const char *capture_mixer_ctl_name	= "Audio Stream Capture";
	const char *deviceNo		= "NN";
@@ -4335,6 +4429,12 @@ static int msm_compr_add_app_type_cfg_control(struct snd_soc_pcm_runtime *rtd)
		return 0;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return 0;
	}

	pr_debug("%s: added new compr FE ctl with name %s, id %d, cpu dai %s, device no %d\n",
		__func__, rtd->dai_link->name, rtd->dai_link->id,
			rtd->dai_link->cpu_dai_name, rtd->pcm->device);
@@ -4372,7 +4472,7 @@ static int msm_compr_add_app_type_cfg_control(struct snd_soc_pcm_runtime *rtd)
					 msm_compr_capture_app_type_cfg_get;
	}
	pr_debug("Registering new mixer ctl %s", mixer_str);
	snd_soc_add_platform_controls(rtd->platform,
	snd_soc_add_component_controls(component,
				fe_app_type_cfg_control,
				ARRAY_SIZE(fe_app_type_cfg_control));
	kfree(mixer_str);
@@ -4381,6 +4481,7 @@ static int msm_compr_add_app_type_cfg_control(struct snd_soc_pcm_runtime *rtd)

static int msm_compr_add_channel_map_control(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = "Playback Channel Map";
	const char *deviceNo       = "NN";
	char *mixer_str = NULL;
@@ -4403,6 +4504,12 @@ static int msm_compr_add_channel_map_control(struct snd_soc_pcm_runtime *rtd)
		return -EINVAL;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}

	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
		 __func__, rtd->dai_link->name, rtd->dai_link->id,
		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
@@ -4418,11 +4525,11 @@ static int msm_compr_add_channel_map_control(struct snd_soc_pcm_runtime *rtd)
	fe_channel_map_control[0].name = mixer_str;
	fe_channel_map_control[0].private_value = rtd->dai_link->id;
	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
	snd_soc_add_platform_controls(rtd->platform,
	snd_soc_add_component_controls(component,
				fe_channel_map_control,
				ARRAY_SIZE(fe_channel_map_control));

	pdata = snd_soc_platform_get_drvdata(rtd->platform);
	pdata = snd_soc_component_get_drvdata(component);
	pdata->ch_map[rtd->dai_link->id] =
		 kzalloc(sizeof(struct msm_compr_ch_map), GFP_KERNEL);
	if (!pdata->ch_map[rtd->dai_link->id]) {
@@ -4437,6 +4544,7 @@ static int msm_compr_add_channel_map_control(struct snd_soc_pcm_runtime *rtd)

static int msm_compr_add_io_fd_cmd_control(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = "Playback ION FD";
	const char *deviceNo = "NN";
	char *mixer_str = NULL;
@@ -4454,22 +4562,25 @@ static int msm_compr_add_io_fd_cmd_control(struct snd_soc_pcm_runtime *rtd)

	if (!rtd) {
		pr_err("%s NULL rtd\n", __func__);
		ret = -EINVAL;
		goto done;
		return -EINVAL;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}

	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
	if (!mixer_str) {
		ret = -ENOMEM;
		goto done;
	}
	if (!mixer_str)
		return -ENOMEM;

	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
	fe_ion_fd_config_control[0].name = mixer_str;
	fe_ion_fd_config_control[0].private_value = rtd->dai_link->id;
	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
	ret = snd_soc_add_platform_controls(rtd->platform,
	ret = snd_soc_add_component_controls(component,
				fe_ion_fd_config_control,
				ARRAY_SIZE(fe_ion_fd_config_control));
	if (ret < 0)
@@ -4482,6 +4593,7 @@ static int msm_compr_add_io_fd_cmd_control(struct snd_soc_pcm_runtime *rtd)

static int msm_compr_add_event_ack_cmd_control(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_component *component = NULL;
	const char *mixer_ctl_name = "Playback Event Ack";
	const char *deviceNo = "NN";
	char *mixer_str = NULL;
@@ -4499,22 +4611,25 @@ static int msm_compr_add_event_ack_cmd_control(struct snd_soc_pcm_runtime *rtd)

	if (!rtd) {
		pr_err("%s NULL rtd\n", __func__);
		ret = -EINVAL;
		goto done;
		return -EINVAL;
	}

	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	if (!component) {
		pr_err("%s: component is NULL\n", __func__);
		return -EINVAL;
	}

	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
	if (!mixer_str) {
		ret = -ENOMEM;
		goto done;
	}
	if (!mixer_str)
		return -ENOMEM;

	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
	fe_event_ack_config_control[0].name = mixer_str;
	fe_event_ack_config_control[0].private_value = rtd->dai_link->id;
	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
	ret = snd_soc_add_platform_controls(rtd->platform,
	ret = snd_soc_add_component_controls(component,
				fe_event_ack_config_control,
				ARRAY_SIZE(fe_event_ack_config_control));
	if (ret < 0)
@@ -4593,7 +4708,8 @@ static struct snd_compr_ops msm_compr_ops = {
	.get_codec_caps		= msm_compr_get_codec_caps,
};

static struct snd_soc_platform_driver msm_soc_platform = {
static struct snd_soc_component_driver msm_soc_component = {
	.name		= DRV_NAME,
	.probe		= msm_compr_probe,
	.compr_ops	= &msm_compr_ops,
	.pcm_new	= msm_compr_new,
@@ -4603,13 +4719,13 @@ static int msm_compr_dev_probe(struct platform_device *pdev)
{

	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
	return snd_soc_register_platform(&pdev->dev,
					&msm_soc_platform);
	return snd_soc_register_component(&pdev->dev,
					&msm_soc_component, NULL, 0);
}

static int msm_compr_remove(struct platform_device *pdev)
{
	snd_soc_unregister_platform(&pdev->dev);
	snd_soc_unregister_component(&pdev->dev);
	return 0;
}

+27 −21
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include "msm-slim-dma.h"
#include "codecs/cpe_core.h"

#define DRV_NAME "msm-cpe-lsm"

#define SAMPLE_RATE_48KHZ 48000
#define SAMPLE_RATE_16KHZ 16000
#define LSM_VOICE_WAKEUP_APP_V2 2
@@ -3202,55 +3204,57 @@ static int msm_cpe_lsm_copy(struct snd_pcm_substream *substream, int a,
}

/*
 * msm_asoc_cpe_lsm_probe: ASoC framework for lsm platform driver
 * @platform: platform registered with ASoC core
 * msm_asoc_cpe_lsm_probe: ASoC framework for lsm component driver
 * @component: component registered with ASoC core
 *
 * Allocate the private data for this platform and obtain the ops for
 * Allocate the private data for this component and obtain the ops for
 * lsm and afe modules from underlying driver. Also find the codec
 * for this platform as specified by machine driver for ASoC framework.
 * for this component as specified by machine driver for ASoC framework.
 */
static int msm_asoc_cpe_lsm_probe(struct snd_soc_platform *platform)
static int msm_asoc_cpe_lsm_probe(struct snd_soc_component *component)
{
	struct snd_soc_card *card;
	struct snd_soc_pcm_runtime *rtd;
	struct snd_soc_codec *codec;
	struct cpe_priv *cpe_priv;
	struct snd_soc_component *component_rtd = NULL;
	const struct snd_kcontrol_new *kcontrol;
	bool found_runtime = false;
	const char *cpe_dev_id = "qcom,msm-cpe-lsm-id";
	u32 port_id = 0;
	int ret = 0;

	if (!platform || !platform->component.card) {
		pr_err("%s: Invalid platform or card\n",
	if (!component || !component->card) {
		pr_err("%s: Invalid component or card\n",
			__func__);
		return -EINVAL;
	}

	card = platform->component.card;
	card = component->card;

	/* Match platform to codec */
	/* Match component to codec */
	list_for_each_entry(rtd, &card->rtd_list, list) {
		if (!rtd->platform)
		component_rtd = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
		if (!component_rtd)
			continue;
		if (!strcmp(rtd->platform->component.name,
			    platform->component.name)) {
		if (!strcmp(component_rtd->name,
			    component->name)) {
			found_runtime = true;
			break;
		}
	}

	if (!found_runtime) {
		dev_err(platform->dev,
			"%s: Failed to find runtime for platform\n",
		dev_err(component->dev,
			"%s: Failed to find runtime for component\n",
			__func__);
		return -EINVAL;
	}

	ret = of_property_read_u32(platform->dev->of_node, cpe_dev_id,
	ret = of_property_read_u32(component->dev->of_node, cpe_dev_id,
				  &port_id);
	if (ret) {
		dev_dbg(platform->dev,
		dev_dbg(component->dev,
			"%s: missing 0x%x in dt node\n", __func__, port_id);
		port_id = 1;
	}
@@ -3267,7 +3271,7 @@ static int msm_asoc_cpe_lsm_probe(struct snd_soc_platform *platform)
	wcd_cpe_get_lsm_ops(&cpe_priv->lsm_ops);
	wcd_cpe_get_afe_ops(&cpe_priv->afe_ops);

	snd_soc_platform_set_drvdata(platform, cpe_priv);
	snd_soc_component_set_drvdata(component, cpe_priv);
	kcontrol = &msm_cpe_kcontrols[0];
	snd_ctl_add(card->snd_card, snd_ctl_new1(kcontrol, cpe_priv));
	return 0;
@@ -3285,7 +3289,8 @@ static const struct snd_pcm_ops msm_cpe_lsm_ops = {
	.compat_ioctl = msm_cpe_lsm_ioctl_compat,
};

static struct snd_soc_platform_driver msm_soc_cpe_platform = {
static struct snd_soc_component_driver msm_soc_cpe_component = {
	.name = DRV_NAME,
	.ops = &msm_cpe_lsm_ops,
	.probe = msm_asoc_cpe_lsm_probe,
};
@@ -3299,8 +3304,9 @@ static struct snd_soc_platform_driver msm_soc_cpe_platform = {
static int msm_cpe_lsm_probe(struct platform_device *pdev)
{

	return snd_soc_register_platform(&pdev->dev,
					 &msm_soc_cpe_platform);
	return snd_soc_register_component(&pdev->dev,
					  &msm_soc_cpe_component,
					  NULL, 0);
}

/*
@@ -3311,7 +3317,7 @@ static int msm_cpe_lsm_probe(struct platform_device *pdev)
 */
static int msm_cpe_lsm_remove(struct platform_device *pdev)
{
	snd_soc_unregister_platform(&pdev->dev);
	snd_soc_unregister_commponent(&pdev->dev);
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ int msm_dolby_dap_init(int port_id, int copp_idx, int channels,
	return 0;
}
void msm_dolby_dap_deinit(int port_id) { }
void msm_dolby_dap_add_controls(struct snd_soc_platform *platform) { }
void msm_dolby_dap_add_controls(struct snd_soc_component *component) { }
int dolby_dap_set_custom_stereo_onoff(int port_id, int copp_idx,
				      bool is_custom_stereo_enabled)
{
+8 −4
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
#include <dsp/q6lsm.h>
#include "msm-pcm-routing-v2.h"

#define DRV_NAME "msm-lsm-client"

#define CAPTURE_MIN_NUM_PERIODS     2
#define CAPTURE_MAX_NUM_PERIODS     8
#define CAPTURE_MAX_PERIOD_SIZE     61440
@@ -2932,14 +2934,15 @@ static int msm_asoc_lsm_new(struct snd_soc_pcm_runtime *rtd)
	return ret;
}

static int msm_asoc_lsm_probe(struct snd_soc_platform *platform)
static int msm_asoc_lsm_probe(struct snd_soc_component *component)
{
	pr_debug("enter %s\n", __func__);

	return 0;
}

static struct snd_soc_platform_driver msm_soc_platform = {
static struct snd_soc_component_driver msm_soc_component = {
	.name		= DRV_NAME,
	.ops		= &msm_lsm_ops,
	.pcm_new	= msm_asoc_lsm_new,
	.probe		= msm_asoc_lsm_probe,
@@ -2948,12 +2951,13 @@ static struct snd_soc_platform_driver msm_soc_platform = {
static int msm_lsm_probe(struct platform_device *pdev)
{

	return snd_soc_register_platform(&pdev->dev, &msm_soc_platform);
	return snd_soc_register_component(&pdev->dev, &msm_soc_component,
					  NULL, 0);
}

static int msm_lsm_remove(struct platform_device *pdev)
{
	snd_soc_unregister_platform(&pdev->dev);
	snd_soc_unregister_component(&pdev->dev);

	return 0;
}
+8 −5
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#include <dsp/q6adm-v2.h>
#include "msm-pcm-afe-v2.h"

#define DRV_NAME "msm-pcm-afe-v2"

#define MIN_PLAYBACK_PERIOD_SIZE (128 * 2)
#define MAX_PLAYBACK_PERIOD_SIZE (128 * 2 * 2 * 6)
#define MIN_PLAYBACK_NUM_PERIODS (4)
@@ -854,13 +856,14 @@ static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
	return ret;
}

static int msm_afe_afe_probe(struct snd_soc_platform *platform)
static int msm_afe_afe_probe(struct snd_soc_component *component)
{
	pr_debug("%s\n", __func__);
	return 0;
}

static struct snd_soc_platform_driver msm_soc_platform = {
static struct snd_soc_component_driver msm_soc_component = {
	.name		= DRV_NAME,
	.ops		= &msm_afe_ops,
	.pcm_new	= msm_asoc_pcm_new,
	.probe		= msm_afe_afe_probe,
@@ -870,14 +873,14 @@ static int msm_afe_probe(struct platform_device *pdev)
{

	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
	return snd_soc_register_platform(&pdev->dev,
				   &msm_soc_platform);
	return snd_soc_register_component(&pdev->dev,
				   &msm_soc_component, NULL, 0);
}

static int msm_afe_remove(struct platform_device *pdev)
{
	pr_debug("%s\n", __func__);
	snd_soc_unregister_platform(&pdev->dev);
	snd_soc_unregister_component(&pdev->dev);
	return 0;
}
static const struct of_device_id msm_pcm_afe_dt_match[] = {
Loading