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

Unverified Commit e8c768da authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'asoc/topic/sta529', 'asoc/topic/sti-sas',...

Merge remote-tracking branches 'asoc/topic/sta529', 'asoc/topic/sti-sas', 'asoc/topic/stm32', 'asoc/topic/sun4i' and 'asoc/topic/sun8i' into asoc-next
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -45,6 +45,12 @@ SAI subnodes Optional properties:
	This property sets SAI sub-block as slave of another SAI sub-block.
	Must contain the phandle and index of the sai sub-block providing
	the synchronization.
  - st,iec60958: support S/PDIF IEC6958 protocol for playback
	IEC60958 protocol is not available for capture.
	By default, custom protocol is assumed, meaning that protocol is
	configured according to protocol defined in related DAI link node,
	such as i2s, left justified, right justified, dsp and pdm protocols.
	Note: ac97 protocol is not supported by SAI driver

The device node should contain one 'port' child node with one child 'endpoint'
node, according to the bindings defined in Documentation/devicetree/bindings/
+31 −38
Original line number Diff line number Diff line
@@ -151,28 +151,28 @@ static const struct snd_kcontrol_new sta529_snd_controls[] = {
	SOC_ENUM("PWM Select", pwm_src),
};

static int sta529_set_bias_level(struct snd_soc_codec *codec, enum
static int sta529_set_bias_level(struct snd_soc_component *component, enum
		snd_soc_bias_level level)
{
	struct sta529 *sta529 = snd_soc_codec_get_drvdata(codec);
	struct sta529 *sta529 = snd_soc_component_get_drvdata(component);

	switch (level) {
	case SND_SOC_BIAS_ON:
	case SND_SOC_BIAS_PREPARE:
		snd_soc_update_bits(codec, STA529_FFXCFG0, POWER_CNTLMSAK,
		snd_soc_component_update_bits(component, STA529_FFXCFG0, POWER_CNTLMSAK,
				POWER_UP);
		snd_soc_update_bits(codec, STA529_MISC,	FFX_CLK_MSK,
		snd_soc_component_update_bits(component, STA529_MISC,	FFX_CLK_MSK,
				FFX_CLK_ENB);
		break;
	case SND_SOC_BIAS_STANDBY:
		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
			regcache_sync(sta529->regmap);
		snd_soc_update_bits(codec, STA529_FFXCFG0,
		snd_soc_component_update_bits(component, STA529_FFXCFG0,
					POWER_CNTLMSAK, POWER_STDBY);
		/* Making FFX output to zero */
		snd_soc_update_bits(codec, STA529_FFXCFG0, FFX_MASK,
		snd_soc_component_update_bits(component, STA529_FFXCFG0, FFX_MASK,
				FFX_OFF);
		snd_soc_update_bits(codec, STA529_MISC, FFX_CLK_MSK,
		snd_soc_component_update_bits(component, STA529_MISC, FFX_CLK_MSK,
				FFX_CLK_DIS);
		break;
	case SND_SOC_BIAS_OFF:
@@ -187,7 +187,7 @@ static int sta529_hw_params(struct snd_pcm_substream *substream,
		struct snd_pcm_hw_params *params,
		struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	int pdata, play_freq_val, record_freq_val;
	int bclk_to_fs_ratio;

@@ -205,7 +205,7 @@ static int sta529_hw_params(struct snd_pcm_substream *substream,
		bclk_to_fs_ratio = 2;
		break;
	default:
		dev_err(codec->dev, "Unsupported format\n");
		dev_err(component->dev, "Unsupported format\n");
		return -EINVAL;
	}

@@ -228,23 +228,23 @@ static int sta529_hw_params(struct snd_pcm_substream *substream,
		record_freq_val = 0;
		break;
	default:
		dev_err(codec->dev, "Unsupported rate\n");
		dev_err(component->dev, "Unsupported rate\n");
		return -EINVAL;
	}

	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
		snd_soc_update_bits(codec, STA529_S2PCFG1, PDATA_LEN_MSK,
		snd_soc_component_update_bits(component, STA529_S2PCFG1, PDATA_LEN_MSK,
				pdata << 6);
		snd_soc_update_bits(codec, STA529_S2PCFG1, BCLK_TO_FS_MSK,
		snd_soc_component_update_bits(component, STA529_S2PCFG1, BCLK_TO_FS_MSK,
				bclk_to_fs_ratio << 4);
		snd_soc_update_bits(codec, STA529_MISC, PLAY_FREQ_RANGE_MSK,
		snd_soc_component_update_bits(component, STA529_MISC, PLAY_FREQ_RANGE_MSK,
				play_freq_val << 4);
	} else {
		snd_soc_update_bits(codec, STA529_P2SCFG1, PDATA_LEN_MSK,
		snd_soc_component_update_bits(component, STA529_P2SCFG1, PDATA_LEN_MSK,
				pdata << 6);
		snd_soc_update_bits(codec, STA529_P2SCFG1, BCLK_TO_FS_MSK,
		snd_soc_component_update_bits(component, STA529_P2SCFG1, BCLK_TO_FS_MSK,
				bclk_to_fs_ratio << 4);
		snd_soc_update_bits(codec, STA529_MISC, CAP_FREQ_RANGE_MSK,
		snd_soc_component_update_bits(component, STA529_MISC, CAP_FREQ_RANGE_MSK,
				record_freq_val << 2);
	}

@@ -258,14 +258,14 @@ static int sta529_mute(struct snd_soc_dai *dai, int mute)
	if (mute)
		val |= CODEC_MUTE_VAL;

	snd_soc_update_bits(dai->codec, STA529_FFXCFG0, AUDIO_MUTE_MSK, val);
	snd_soc_component_update_bits(dai->component, STA529_FFXCFG0, AUDIO_MUTE_MSK, val);

	return 0;
}

static int sta529_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	u8 mode = 0;

	/* interface format */
@@ -283,7 +283,7 @@ static int sta529_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt)
		return -EINVAL;
	}

	snd_soc_update_bits(codec, STA529_S2PCFG0, DATA_FORMAT_MSK, mode);
	snd_soc_component_update_bits(component, STA529_S2PCFG0, DATA_FORMAT_MSK, mode);

	return 0;
}
@@ -313,14 +313,15 @@ static struct snd_soc_dai_driver sta529_dai = {
	.ops	= &sta529_dai_ops,
};

static const struct snd_soc_codec_driver sta529_codec_driver = {
static const struct snd_soc_component_driver sta529_component_driver = {
	.set_bias_level		= sta529_set_bias_level,
	.suspend_bias_off = true,

	.component_driver = {
	.controls		= sta529_snd_controls,
	.num_controls		= ARRAY_SIZE(sta529_snd_controls),
	},
	.suspend_bias_off	= 1,
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};

static const struct regmap_config sta529_regmap = {
@@ -354,21 +355,14 @@ static int sta529_i2c_probe(struct i2c_client *i2c,

	i2c_set_clientdata(i2c, sta529);

	ret = snd_soc_register_codec(&i2c->dev,
			&sta529_codec_driver, &sta529_dai, 1);
	ret = devm_snd_soc_register_component(&i2c->dev,
			&sta529_component_driver, &sta529_dai, 1);
	if (ret != 0)
		dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);

	return ret;
}

static int sta529_i2c_remove(struct i2c_client *client)
{
	snd_soc_unregister_codec(&client->dev);

	return 0;
}

static const struct i2c_device_id sta529_i2c_id[] = {
	{ "sta529", 0 },
	{ }
@@ -387,7 +381,6 @@ static struct i2c_driver sta529_i2c_driver = {
		.of_match_table = sta529_of_match,
	},
	.probe		= sta529_i2c_probe,
	.remove		= sta529_i2c_remove,
	.id_table	= sta529_i2c_id,
};

+40 −44
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ static int sti_sas_write_reg(void *context, unsigned int reg,
	return status;
}

static int  sti_sas_init_sas_registers(struct snd_soc_codec *codec,
static int  sti_sas_init_sas_registers(struct snd_soc_component *component,
				       struct sti_sas_data *data)
{
	int ret;
@@ -116,35 +116,35 @@ static int sti_sas_init_sas_registers(struct snd_soc_codec *codec,
	 */

	/* Initialise bi-phase formatter to disabled */
	ret = snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL,
	ret = snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL,
				  SPDIF_BIPHASE_ENABLE_MASK, 0);

	if (!ret)
		/* Initialise bi-phase formatter idle value to 0 */
		ret = snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL,
		ret = snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL,
					  SPDIF_BIPHASE_IDLE_MASK, 0);
	if (ret < 0) {
		dev_err(codec->dev, "Failed to update SPDIF registers\n");
		dev_err(component->dev, "Failed to update SPDIF registers\n");
		return ret;
	}

	/* Init DAC configuration */
	/* init configuration */
	ret =  snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
	ret =  snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
				   STIH407_DAC_STANDBY_MASK,
				   STIH407_DAC_STANDBY_MASK);

	if (!ret)
		ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
		ret = snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
					  STIH407_DAC_STANDBY_ANA_MASK,
					  STIH407_DAC_STANDBY_ANA_MASK);
	if (!ret)
		ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
		ret = snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
					  STIH407_DAC_SOFTMUTE_MASK,
					  STIH407_DAC_SOFTMUTE_MASK);

	if (ret < 0) {
		dev_err(codec->dev, "Failed to update DAC registers\n");
		dev_err(component->dev, "Failed to update DAC registers\n");
		return ret;
	}

@@ -158,7 +158,7 @@ static int sti_sas_dac_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
	/* Sanity check only */
	if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) {
		dev_err(dai->codec->dev,
		dev_err(dai->component->dev,
			"%s: ERROR: Unsupporter master mask 0x%x\n",
			__func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
		return -EINVAL;
@@ -183,14 +183,14 @@ static const struct snd_soc_dapm_route stih407_sas_route[] = {

static int stih407_sas_dac_mute(struct snd_soc_dai *dai, int mute, int stream)
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;

	if (mute) {
		return snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
		return snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
					    STIH407_DAC_SOFTMUTE_MASK,
					    STIH407_DAC_SOFTMUTE_MASK);
	} else {
		return snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
		return snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
					    STIH407_DAC_SOFTMUTE_MASK,
					    0);
	}
@@ -203,7 +203,7 @@ static int sti_sas_spdif_set_fmt(struct snd_soc_dai *dai,
				 unsigned int fmt)
{
	if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) {
		dev_err(dai->codec->dev,
		dev_err(dai->component->dev,
			"%s: ERROR: Unsupporter master mask 0x%x\n",
			__func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
		return -EINVAL;
@@ -221,19 +221,19 @@ static int sti_sas_spdif_set_fmt(struct snd_soc_dai *dai,
static int sti_sas_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
				 struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		return snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL,
		return snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL,
					    SPDIF_BIPHASE_ENABLE_MASK,
					    SPDIF_BIPHASE_ENABLE_MASK);
	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_SUSPEND:
		return snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL,
		return snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL,
					    SPDIF_BIPHASE_ENABLE_MASK,
					    0);
	default:
@@ -260,8 +260,8 @@ static bool sti_sas_volatile_register(struct device *dev, unsigned int reg)
static int sti_sas_set_sysclk(struct snd_soc_dai *dai, int clk_id,
			      unsigned int freq, int dir)
{
	struct snd_soc_codec *codec = dai->codec;
	struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev);
	struct snd_soc_component *component = dai->component;
	struct sti_sas_data *drvdata = dev_get_drvdata(component->dev);

	if (dir == SND_SOC_CLOCK_OUT)
		return 0;
@@ -285,20 +285,20 @@ static int sti_sas_set_sysclk(struct snd_soc_dai *dai, int clk_id,
static int sti_sas_prepare(struct snd_pcm_substream *substream,
			   struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev);
	struct snd_soc_component *component = dai->component;
	struct sti_sas_data *drvdata = dev_get_drvdata(component->dev);
	struct snd_pcm_runtime *runtime = substream->runtime;

	switch (dai->id) {
	case STI_SAS_DAI_SPDIF_OUT:
		if ((drvdata->spdif.mclk / runtime->rate) != 128) {
			dev_err(codec->dev, "unexpected mclk-fs ratio\n");
			dev_err(component->dev, "unexpected mclk-fs ratio\n");
			return -EINVAL;
		}
		break;
	case STI_SAS_DAI_ANALOG_OUT:
		if ((drvdata->dac.mclk / runtime->rate) != 256) {
			dev_err(codec->dev, "unexpected mclk-fs ratio\n");
			dev_err(component->dev, "unexpected mclk-fs ratio\n");
			return -EINVAL;
		}
		break;
@@ -375,29 +375,33 @@ static struct snd_soc_dai_driver sti_sas_dai[] = {
};

#ifdef CONFIG_PM_SLEEP
static int sti_sas_resume(struct snd_soc_codec *codec)
static int sti_sas_resume(struct snd_soc_component *component)
{
	struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev);
	struct sti_sas_data *drvdata = dev_get_drvdata(component->dev);

	return sti_sas_init_sas_registers(codec, drvdata);
	return sti_sas_init_sas_registers(component, drvdata);
}
#else
#define sti_sas_resume NULL
#endif

static int sti_sas_codec_probe(struct snd_soc_codec *codec)
static int sti_sas_component_probe(struct snd_soc_component *component)
{
	struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev);
	struct sti_sas_data *drvdata = dev_get_drvdata(component->dev);
	int ret;

	ret = sti_sas_init_sas_registers(codec, drvdata);
	ret = sti_sas_init_sas_registers(component, drvdata);

	return ret;
}

static struct snd_soc_codec_driver sti_sas_driver = {
	.probe = sti_sas_codec_probe,
static struct snd_soc_component_driver sti_sas_driver = {
	.probe			= sti_sas_component_probe,
	.resume			= sti_sas_resume,
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};

static const struct of_device_id sti_sas_dev_match[] = {
@@ -452,34 +456,26 @@ static int sti_sas_driver_probe(struct platform_device *pdev)
	sti_sas_dai[STI_SAS_DAI_ANALOG_OUT].ops = drvdata->dev_data->dac_ops;

	/* Set dapms*/
	sti_sas_driver.component_driver.dapm_widgets = drvdata->dev_data->dapm_widgets;
	sti_sas_driver.component_driver.num_dapm_widgets = drvdata->dev_data->num_dapm_widgets;
	sti_sas_driver.dapm_widgets = drvdata->dev_data->dapm_widgets;
	sti_sas_driver.num_dapm_widgets = drvdata->dev_data->num_dapm_widgets;

	sti_sas_driver.component_driver.dapm_routes = drvdata->dev_data->dapm_routes;
	sti_sas_driver.component_driver.num_dapm_routes = drvdata->dev_data->num_dapm_routes;
	sti_sas_driver.dapm_routes = drvdata->dev_data->dapm_routes;
	sti_sas_driver.num_dapm_routes = drvdata->dev_data->num_dapm_routes;

	/* Store context */
	dev_set_drvdata(&pdev->dev, drvdata);

	return snd_soc_register_codec(&pdev->dev, &sti_sas_driver,
	return devm_snd_soc_register_component(&pdev->dev, &sti_sas_driver,
					sti_sas_dai,
					ARRAY_SIZE(sti_sas_dai));
}

static int sti_sas_driver_remove(struct platform_device *pdev)
{
	snd_soc_unregister_codec(&pdev->dev);

	return 0;
}

static struct platform_driver sti_sas_platform_driver = {
	.driver = {
		.name = "sti-sas-codec",
		.of_match_table = sti_sas_dev_match,
	},
	.probe = sti_sas_driver_probe,
	.remove = sti_sas_driver_remove,
};

module_platform_driver(sti_sas_platform_driver);
+2 −0
Original line number Diff line number Diff line
@@ -30,10 +30,12 @@

static const struct stm32_sai_conf stm32_sai_conf_f4 = {
	.version = SAI_STM32F4,
	.has_spdif = false,
};

static const struct stm32_sai_conf stm32_sai_conf_h7 = {
	.version = SAI_STM32H7,
	.has_spdif = true,
};

static const struct of_device_id stm32_sai_ids[] = {
+2 −0
Original line number Diff line number Diff line
@@ -248,9 +248,11 @@ enum stm32_sai_version {
/**
 * struct stm32_sai_conf - SAI configuration
 * @version: SAI version
 * @has_spdif: SAI S/PDIF support flag
 */
struct stm32_sai_conf {
	int version;
	bool has_spdif;
};

/**
Loading