Commit 3863293a authored by Mark Brown's avatar Mark Brown

Merge branch 'for-5.1' of...

Merge branch 'for-5.1' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-5.2
parents 4346a745 1c5b6a27
...@@ -2129,6 +2129,7 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2129,6 +2129,7 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
dev_err(dai->component->dev, dev_err(dai->component->dev,
"%s: ERROR: The device is either a master or a slave.\n", "%s: ERROR: The device is either a master or a slave.\n",
__func__); __func__);
/* fall through */
default: default:
dev_err(dai->component->dev, dev_err(dai->component->dev,
"%s: ERROR: Unsupporter master mask 0x%x\n", "%s: ERROR: Unsupporter master mask 0x%x\n",
......
...@@ -38,6 +38,9 @@ static void hdac_hda_dai_close(struct snd_pcm_substream *substream, ...@@ -38,6 +38,9 @@ static void hdac_hda_dai_close(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai); struct snd_soc_dai *dai);
static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream, static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai); struct snd_soc_dai *dai);
static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream, static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai); struct snd_soc_dai *dai);
static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
...@@ -50,6 +53,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = { ...@@ -50,6 +53,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = {
.startup = hdac_hda_dai_open, .startup = hdac_hda_dai_open,
.shutdown = hdac_hda_dai_close, .shutdown = hdac_hda_dai_close,
.prepare = hdac_hda_dai_prepare, .prepare = hdac_hda_dai_prepare,
.hw_params = hdac_hda_dai_hw_params,
.hw_free = hdac_hda_dai_hw_free, .hw_free = hdac_hda_dai_hw_free,
.set_tdm_slot = hdac_hda_dai_set_tdm_slot, .set_tdm_slot = hdac_hda_dai_set_tdm_slot,
}; };
...@@ -139,6 +143,39 @@ static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, ...@@ -139,6 +143,39 @@ static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
return 0; return 0;
} }
static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct hdac_hda_priv *hda_pvt;
unsigned int format_val;
unsigned int maxbps;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
maxbps = dai->driver->playback.sig_bits;
else
maxbps = dai->driver->capture.sig_bits;
hda_pvt = snd_soc_component_get_drvdata(component);
format_val = snd_hdac_calc_stream_format(params_rate(params),
params_channels(params),
params_format(params),
maxbps,
0);
if (!format_val) {
dev_err(dai->dev,
"invalid format_val, rate=%d, ch=%d, format=%d, maxbps=%d\n",
params_rate(params), params_channels(params),
params_format(params), maxbps);
return -EINVAL;
}
hda_pvt->pcm[dai->id].format_val[substream->stream] = format_val;
return 0;
}
static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream, static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
...@@ -162,10 +199,9 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream, ...@@ -162,10 +199,9 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
struct hda_pcm_stream *hda_stream;
struct hdac_hda_priv *hda_pvt; struct hdac_hda_priv *hda_pvt;
struct snd_pcm_runtime *runtime = substream->runtime;
struct hdac_device *hdev; struct hdac_device *hdev;
struct hda_pcm_stream *hda_stream;
unsigned int format_val; unsigned int format_val;
struct hda_pcm *pcm; struct hda_pcm *pcm;
unsigned int stream; unsigned int stream;
...@@ -179,19 +215,8 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream, ...@@ -179,19 +215,8 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
hda_stream = &pcm->stream[substream->stream]; hda_stream = &pcm->stream[substream->stream];
format_val = snd_hdac_calc_stream_format(runtime->rate,
runtime->channels,
runtime->format,
hda_stream->maxbps,
0);
if (!format_val) {
dev_err(&hdev->dev,
"invalid format_val, rate=%d, ch=%d, format=%d\n",
runtime->rate, runtime->channels, runtime->format);
return -EINVAL;
}
stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream]; stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream];
format_val = hda_pvt->pcm[dai->id].format_val[substream->stream];
ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream, ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream,
stream, format_val, substream); stream, format_val, substream);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
struct hdac_hda_pcm { struct hdac_hda_pcm {
int stream_tag[2]; int stream_tag[2];
unsigned int format_val[2];
}; };
struct hdac_hda_priv { struct hdac_hda_priv {
......
...@@ -484,9 +484,6 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, ...@@ -484,9 +484,6 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream,
params_width(params), params_rate(params), params_width(params), params_rate(params),
params_channels(params)); params_channels(params));
if (params_width(params) > 24)
params->msbits = 24;
ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status, ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status,
sizeof(hp.iec.status)); sizeof(hp.iec.status));
if (ret < 0) { if (ret < 0) {
...@@ -529,73 +526,71 @@ static int hdmi_codec_set_fmt(struct snd_soc_dai *dai, ...@@ -529,73 +526,71 @@ static int hdmi_codec_set_fmt(struct snd_soc_dai *dai,
{ {
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
struct hdmi_codec_daifmt cf = { 0 }; struct hdmi_codec_daifmt cf = { 0 };
int ret = 0;
dev_dbg(dai->dev, "%s()\n", __func__); dev_dbg(dai->dev, "%s()\n", __func__);
if (dai->id == DAI_ID_SPDIF) { if (dai->id == DAI_ID_SPDIF)
cf.fmt = HDMI_SPDIF; return 0;
} else {
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
cf.bit_clk_master = 1; cf.bit_clk_master = 1;
cf.frame_clk_master = 1; cf.frame_clk_master = 1;
break; break;
case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBS_CFM:
cf.frame_clk_master = 1; cf.frame_clk_master = 1;
break; break;
case SND_SOC_DAIFMT_CBM_CFS: case SND_SOC_DAIFMT_CBM_CFS:
cf.bit_clk_master = 1; cf.bit_clk_master = 1;
break; break;
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
switch (fmt & SND_SOC_DAIFMT_INV_MASK) { switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF: case SND_SOC_DAIFMT_NB_NF:
break; break;
case SND_SOC_DAIFMT_NB_IF: case SND_SOC_DAIFMT_NB_IF:
cf.frame_clk_inv = 1; cf.frame_clk_inv = 1;
break; break;
case SND_SOC_DAIFMT_IB_NF: case SND_SOC_DAIFMT_IB_NF:
cf.bit_clk_inv = 1; cf.bit_clk_inv = 1;
break; break;
case SND_SOC_DAIFMT_IB_IF: case SND_SOC_DAIFMT_IB_IF:
cf.frame_clk_inv = 1; cf.frame_clk_inv = 1;
cf.bit_clk_inv = 1; cf.bit_clk_inv = 1;
break; break;
} }
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
cf.fmt = HDMI_I2S; cf.fmt = HDMI_I2S;
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
cf.fmt = HDMI_DSP_A; cf.fmt = HDMI_DSP_A;
break; break;
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
cf.fmt = HDMI_DSP_B; cf.fmt = HDMI_DSP_B;
break; break;
case SND_SOC_DAIFMT_RIGHT_J: case SND_SOC_DAIFMT_RIGHT_J:
cf.fmt = HDMI_RIGHT_J; cf.fmt = HDMI_RIGHT_J;
break; break;
case SND_SOC_DAIFMT_LEFT_J: case SND_SOC_DAIFMT_LEFT_J:
cf.fmt = HDMI_LEFT_J; cf.fmt = HDMI_LEFT_J;
break; break;
case SND_SOC_DAIFMT_AC97: case SND_SOC_DAIFMT_AC97:
cf.fmt = HDMI_AC97; cf.fmt = HDMI_AC97;
break; break;
default: default:
dev_err(dai->dev, "Invalid DAI interface format\n"); dev_err(dai->dev, "Invalid DAI interface format\n");
return -EINVAL; return -EINVAL;
}
} }
hcp->daifmt[dai->id] = cf; hcp->daifmt[dai->id] = cf;
return ret; return 0;
} }
static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute)
...@@ -792,8 +787,10 @@ static int hdmi_codec_probe(struct platform_device *pdev) ...@@ -792,8 +787,10 @@ static int hdmi_codec_probe(struct platform_device *pdev)
i++; i++;
} }
if (hcd->spdif) if (hcd->spdif) {
hcp->daidrv[i] = hdmi_spdif_dai; hcp->daidrv[i] = hdmi_spdif_dai;
hcp->daifmt[DAI_ID_SPDIF].fmt = HDMI_SPDIF;
}
dev_set_drvdata(dev, hcp); dev_set_drvdata(dev, hcp);
......
...@@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget nau8810_dapm_widgets[] = { ...@@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget nau8810_dapm_widgets[] = {
SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3, SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
NAU8810_MOUTMX_EN_SFT, 0, &nau8810_mono_mixer_controls[0], NAU8810_MOUTMX_EN_SFT, 0, &nau8810_mono_mixer_controls[0],
ARRAY_SIZE(nau8810_mono_mixer_controls)), ARRAY_SIZE(nau8810_mono_mixer_controls)),
SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3, SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3,
NAU8810_DAC_EN_SFT, 0), NAU8810_DAC_EN_SFT, 0),
SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2, SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
NAU8810_ADC_EN_SFT, 0), NAU8810_ADC_EN_SFT, 0),
SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3, SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
NAU8810_NSPK_EN_SFT, 0, NULL, 0), NAU8810_NSPK_EN_SFT, 0, NULL, 0),
......
...@@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = { ...@@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = {
SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2, SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2,
NAU8824_ADCR_EN_SFT, 0), NAU8824_ADCR_EN_SFT, 0),
SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC, SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC,
NAU8824_DACL_EN_SFT, 0), NAU8824_DACL_EN_SFT, 0),
...@@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap *regmap) ...@@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap *regmap)
} }
} }
static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
{
struct snd_soc_dapm_context *dapm = nau8824->dapm;
const char *prefix = dapm->component->name_prefix;
char prefixed_pin[80];
if (prefix) {
snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
prefix, pin);
snd_soc_dapm_disable_pin(dapm, prefixed_pin);
} else {
snd_soc_dapm_disable_pin(dapm, pin);
}
}
static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
{
struct snd_soc_dapm_context *dapm = nau8824->dapm;
const char *prefix = dapm->component->name_prefix;
char prefixed_pin[80];
if (prefix) {
snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
prefix, pin);
snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
} else {
snd_soc_dapm_force_enable_pin(dapm, pin);
}
}
static void nau8824_eject_jack(struct nau8824 *nau8824) static void nau8824_eject_jack(struct nau8824 *nau8824)
{ {
struct snd_soc_dapm_context *dapm = nau8824->dapm; struct snd_soc_dapm_context *dapm = nau8824->dapm;
...@@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824) ...@@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824)
/* Clear all interruption status */ /* Clear all interruption status */
nau8824_int_status_clear_all(regmap); nau8824_int_status_clear_all(regmap);
snd_soc_dapm_disable_pin(dapm, "SAR"); nau8824_dapm_disable_pin(nau8824, "SAR");
snd_soc_dapm_disable_pin(dapm, "MICBIAS"); nau8824_dapm_disable_pin(nau8824, "MICBIAS");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
/* Enable the insertion interruption, disable the ejection /* Enable the insertion interruption, disable the ejection
...@@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work) ...@@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work)
struct regmap *regmap = nau8824->regmap; struct regmap *regmap = nau8824->regmap;
int adc_value, event = 0, event_mask = 0; int adc_value, event = 0, event_mask = 0;
snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); nau8824_dapm_enable_pin(nau8824, "MICBIAS");
snd_soc_dapm_force_enable_pin(dapm, "SAR"); nau8824_dapm_enable_pin(nau8824, "SAR");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
msleep(100); msleep(100);
...@@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work) ...@@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work)
if (adc_value < HEADSET_SARADC_THD) { if (adc_value < HEADSET_SARADC_THD) {
event |= SND_JACK_HEADPHONE; event |= SND_JACK_HEADPHONE;
snd_soc_dapm_disable_pin(dapm, "SAR"); nau8824_dapm_disable_pin(nau8824, "SAR");
snd_soc_dapm_disable_pin(dapm, "MICBIAS"); nau8824_dapm_disable_pin(nau8824, "MICBIAS");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
} else { } else {
event |= SND_JACK_HEADSET; event |= SND_JACK_HEADSET;
......
...@@ -910,13 +910,21 @@ static int rt5682_headset_detect(struct snd_soc_component *component, ...@@ -910,13 +910,21 @@ static int rt5682_headset_detect(struct snd_soc_component *component,
int jack_insert) int jack_insert)
{ {
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
unsigned int val, count; unsigned int val, count;
if (jack_insert) { if (jack_insert) {
snd_soc_dapm_force_enable_pin(dapm, "CBJ Power");
snd_soc_dapm_sync(dapm); snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
RT5682_PWR_VREF2 | RT5682_PWR_MB,
RT5682_PWR_VREF2 | RT5682_PWR_MB);
snd_soc_component_update_bits(component,
RT5682_PWR_ANLG_1, RT5682_PWR_FV2, 0);
usleep_range(15000, 20000);
snd_soc_component_update_bits(component,
RT5682_PWR_ANLG_1, RT5682_PWR_FV2, RT5682_PWR_FV2);
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
RT5682_PWR_CBJ, RT5682_PWR_CBJ);
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH); RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH);
...@@ -944,8 +952,10 @@ static int rt5682_headset_detect(struct snd_soc_component *component, ...@@ -944,8 +952,10 @@ static int rt5682_headset_detect(struct snd_soc_component *component,
rt5682_enable_push_button_irq(component, false); rt5682_enable_push_button_irq(component, false);
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW); RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
snd_soc_dapm_disable_pin(dapm, "CBJ Power"); snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
snd_soc_dapm_sync(dapm); RT5682_PWR_VREF2 | RT5682_PWR_MB, 0);
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
RT5682_PWR_CBJ, 0);
rt5682->jack_type = 0; rt5682->jack_type = 0;
} }
...@@ -1198,7 +1208,7 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w, ...@@ -1198,7 +1208,7 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
struct snd_soc_component *component = struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm); snd_soc_dapm_to_component(w->dapm);
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
int ref, val, reg, sft, mask, idx = -EINVAL; int ref, val, reg, idx = -EINVAL;
static const int div_f[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48}; static const int div_f[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48};
static const int div_o[] = {1, 2, 4, 6, 8, 12, 16, 24, 32, 48}; static const int div_o[] = {1, 2, 4, 6, 8, 12, 16, 24, 32, 48};
...@@ -1212,15 +1222,10 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w, ...@@ -1212,15 +1222,10 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
idx = rt5682_div_sel(rt5682, ref, div_f, ARRAY_SIZE(div_f)); idx = rt5682_div_sel(rt5682, ref, div_f, ARRAY_SIZE(div_f));
if (w->shift == RT5682_PWR_ADC_S1F_BIT) { if (w->shift == RT5682_PWR_ADC_S1F_BIT)
reg = RT5682_PLL_TRACK_3; reg = RT5682_PLL_TRACK_3;
sft = RT5682_ADC_OSR_SFT; else
mask = RT5682_ADC_OSR_MASK;
} else {
reg = RT5682_PLL_TRACK_2; reg = RT5682_PLL_TRACK_2;
sft = RT5682_DAC_OSR_SFT;
mask = RT5682_DAC_OSR_MASK;
}
snd_soc_component_update_bits(component, reg, snd_soc_component_update_bits(component, reg,
RT5682_FILTER_CLK_DIV_MASK, idx << RT5682_FILTER_CLK_DIV_SFT); RT5682_FILTER_CLK_DIV_MASK, idx << RT5682_FILTER_CLK_DIV_SFT);
...@@ -1232,7 +1237,8 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w, ...@@ -1232,7 +1237,8 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
} }
snd_soc_component_update_bits(component, RT5682_ADDA_CLK_1, snd_soc_component_update_bits(component, RT5682_ADDA_CLK_1,
mask, idx << sft); RT5682_ADC_OSR_MASK | RT5682_DAC_OSR_MASK,
(idx << RT5682_ADC_OSR_SFT) | (idx << RT5682_DAC_OSR_SFT));
return 0; return 0;
} }
...@@ -1591,8 +1597,6 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = { ...@@ -1591,8 +1597,6 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = {
0, NULL, 0), 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("Vref1", RT5682_PWR_ANLG_1, RT5682_PWR_VREF1_BIT, 0, SND_SOC_DAPM_SUPPLY("Vref1", RT5682_PWR_ANLG_1, RT5682_PWR_VREF1_BIT, 0,
rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_SUPPLY("Vref2", RT5682_PWR_ANLG_1, RT5682_PWR_VREF2_BIT, 0,
rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
/* ASRC */ /* ASRC */
SND_SOC_DAPM_SUPPLY_S("DAC STO1 ASRC", 1, RT5682_PLL_TRACK_1, SND_SOC_DAPM_SUPPLY_S("DAC STO1 ASRC", 1, RT5682_PLL_TRACK_1,
...@@ -1627,9 +1631,6 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = { ...@@ -1627,9 +1631,6 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = {
SND_SOC_DAPM_PGA("BST1 CBJ", SND_SOC_NOPM, SND_SOC_DAPM_PGA("BST1 CBJ", SND_SOC_NOPM,
0, 0, NULL, 0), 0, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("CBJ Power", RT5682_PWR_ANLG_3,
RT5682_PWR_CBJ_BIT, 0, NULL, 0),
/* REC Mixer */ /* REC Mixer */
SND_SOC_DAPM_MIXER("RECMIX1L", SND_SOC_NOPM, 0, 0, rt5682_rec1_l_mix, SND_SOC_DAPM_MIXER("RECMIX1L", SND_SOC_NOPM, 0, 0, rt5682_rec1_l_mix,
ARRAY_SIZE(rt5682_rec1_l_mix)), ARRAY_SIZE(rt5682_rec1_l_mix)),
...@@ -1792,17 +1793,13 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = { ...@@ -1792,17 +1793,13 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = {
/*Vref*/ /*Vref*/
{"MICBIAS1", NULL, "Vref1"}, {"MICBIAS1", NULL, "Vref1"},
{"MICBIAS1", NULL, "Vref2"},
{"MICBIAS2", NULL, "Vref1"}, {"MICBIAS2", NULL, "Vref1"},
{"MICBIAS2", NULL, "Vref2"},
{"CLKDET SYS", NULL, "CLKDET"}, {"CLKDET SYS", NULL, "CLKDET"},
{"IN1P", NULL, "LDO2"}, {"IN1P", NULL, "LDO2"},
{"BST1 CBJ", NULL, "IN1P"}, {"BST1 CBJ", NULL, "IN1P"},
{"BST1 CBJ", NULL, "CBJ Power"},
{"CBJ Power", NULL, "Vref2"},
{"RECMIX1L", "CBJ Switch", "BST1 CBJ"}, {"RECMIX1L", "CBJ Switch", "BST1 CBJ"},
{"RECMIX1L", NULL, "RECMIX1L Power"}, {"RECMIX1L", NULL, "RECMIX1L Power"},
...@@ -1912,9 +1909,7 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = { ...@@ -1912,9 +1909,7 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = {
{"HP Amp", NULL, "Capless"}, {"HP Amp", NULL, "Capless"},
{"HP Amp", NULL, "Charge Pump"}, {"HP Amp", NULL, "Charge Pump"},
{"HP Amp", NULL, "CLKDET SYS"}, {"HP Amp", NULL, "CLKDET SYS"},
{"HP Amp", NULL, "CBJ Power"},
{"HP Amp", NULL, "Vref1"}, {"HP Amp", NULL, "Vref1"},
{"HP Amp", NULL, "Vref2"},
{"HPOL Playback", "Switch", "HP Amp"}, {"HPOL Playback", "Switch", "HP Amp"},
{"HPOR Playback", "Switch", "HP Amp"}, {"HPOR Playback", "Switch", "HP Amp"},
{"HPOL", NULL, "HPOL Playback"}, {"HPOL", NULL, "HPOL Playback"},
...@@ -2303,16 +2298,13 @@ static int rt5682_set_bias_level(struct snd_soc_component *component, ...@@ -2303,16 +2298,13 @@ static int rt5682_set_bias_level(struct snd_soc_component *component,
switch (level) { switch (level) {
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1, regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
RT5682_PWR_MB | RT5682_PWR_BG, RT5682_PWR_BG, RT5682_PWR_BG);
RT5682_PWR_MB | RT5682_PWR_BG);
regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1, regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO, RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO,
RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO); RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO);
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
RT5682_PWR_MB, RT5682_PWR_MB);
regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1, regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
RT5682_DIG_GATE_CTRL, RT5682_DIG_GATE_CTRL); RT5682_DIG_GATE_CTRL, RT5682_DIG_GATE_CTRL);
break; break;
...@@ -2320,7 +2312,7 @@ static int rt5682_set_bias_level(struct snd_soc_component *component, ...@@ -2320,7 +2312,7 @@ static int rt5682_set_bias_level(struct snd_soc_component *component,
regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1, regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO, 0); RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO, 0);
regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1, regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
RT5682_PWR_MB | RT5682_PWR_BG, 0); RT5682_PWR_BG, 0);
break; break;
default: default:
...@@ -2363,6 +2355,8 @@ static int rt5682_resume(struct snd_soc_component *component) ...@@ -2363,6 +2355,8 @@ static int rt5682_resume(struct snd_soc_component *component)
regcache_cache_only(rt5682->regmap, false); regcache_cache_only(rt5682->regmap, false);
regcache_sync(rt5682->regmap); regcache_sync(rt5682->regmap);
rt5682_irq(0, rt5682);
return 0; return 0;
} }
#else #else
......
...@@ -1609,7 +1609,6 @@ static int aic3x_probe(struct snd_soc_component *component) ...@@ -1609,7 +1609,6 @@ static int aic3x_probe(struct snd_soc_component *component)
struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
int ret, i; int ret, i;
INIT_LIST_HEAD(&aic3x->list);
aic3x->component = component; aic3x->component = component;
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
...@@ -1873,6 +1872,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, ...@@ -1873,6 +1872,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
if (ret != 0) if (ret != 0)
goto err_gpio; goto err_gpio;
INIT_LIST_HEAD(&aic3x->list);
list_add(&aic3x->list, &reset_list); list_add(&aic3x->list, &reset_list);
return 0; return 0;
...@@ -1889,6 +1889,8 @@ static int aic3x_i2c_remove(struct i2c_client *client) ...@@ -1889,6 +1889,8 @@ static int aic3x_i2c_remove(struct i2c_client *client)
{ {
struct aic3x_priv *aic3x = i2c_get_clientdata(client); struct aic3x_priv *aic3x = i2c_get_clientdata(client);
list_del(&aic3x->list);
if (gpio_is_valid(aic3x->gpio_reset) && if (gpio_is_valid(aic3x->gpio_reset) &&
!aic3x_is_shared_reset(aic3x)) { !aic3x_is_shared_reset(aic3x)) {
gpio_set_value(aic3x->gpio_reset, 0); gpio_set_value(aic3x->gpio_reset, 0);
......
...@@ -181,6 +181,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) ...@@ -181,6 +181,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
struct hdac_stream *hstream; struct hdac_stream *hstream;
struct hdac_ext_stream *stream; struct hdac_ext_stream *stream;
struct hdac_ext_link *link; struct hdac_ext_link *link;
unsigned char stream_tag;
hstream = snd_hdac_get_stream(bus, params->stream, hstream = snd_hdac_get_stream(bus, params->stream,
params->link_dma_id + 1); params->link_dma_id + 1);
...@@ -199,10 +200,13 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) ...@@ -199,10 +200,13 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
snd_hdac_ext_link_stream_setup(stream, format_val); snd_hdac_ext_link_stream_setup(stream, format_val);
list_for_each_entry(link, &bus->hlink_list, list) { stream_tag = hstream->stream_tag;
if (link->index == params->link_index) if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
snd_hdac_ext_link_set_stream_id(link, list_for_each_entry(link, &bus->hlink_list, list) {
hstream->stream_tag); if (link->index == params->link_index)
snd_hdac_ext_link_set_stream_id(link,
stream_tag);
}
} }
stream->link_prepared = 1; stream->link_prepared = 1;
...@@ -645,6 +649,7 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream, ...@@ -645,6 +649,7 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,
struct hdac_ext_stream *link_dev = struct hdac_ext_stream *link_dev =
snd_soc_dai_get_dma_data(dai, substream); snd_soc_dai_get_dma_data(dai, substream);
struct hdac_ext_link *link; struct hdac_ext_link *link;
unsigned char stream_tag;
dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
...@@ -654,7 +659,11 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream, ...@@ -654,7 +659,11 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,
if (!link) if (!link)
return -EINVAL; return -EINVAL;
snd_hdac_ext_link_clear_stream_id(link, hdac_stream(link_dev)->stream_tag); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
stream_tag = hdac_stream(link_dev)->stream_tag;
snd_hdac_ext_link_clear_stream_id(link, stream_tag);
}
snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK); snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
return 0; return 0;
} }
......
...@@ -49,6 +49,7 @@ enum bt_sco_state { ...@@ -49,6 +49,7 @@ enum bt_sco_state {
BT_SCO_STATE_IDLE, BT_SCO_STATE_IDLE,
BT_SCO_STATE_RUNNING, BT_SCO_STATE_RUNNING,
BT_SCO_STATE_ENDING, BT_SCO_STATE_ENDING,
BT_SCO_STATE_LOOPBACK,
}; };
enum bt_sco_direct { enum bt_sco_direct {
...@@ -486,7 +487,8 @@ static irqreturn_t mtk_btcvsd_snd_irq_handler(int irq_id, void *dev) ...@@ -486,7 +487,8 @@ static irqreturn_t mtk_btcvsd_snd_irq_handler(int irq_id, void *dev)
if (bt->rx->state != BT_SCO_STATE_RUNNING && if (bt->rx->state != BT_SCO_STATE_RUNNING &&
bt->rx->state != BT_SCO_STATE_ENDING && bt->rx->state != BT_SCO_STATE_ENDING &&
bt->tx->state != BT_SCO_STATE_RUNNING && bt->tx->state != BT_SCO_STATE_RUNNING &&
bt->tx->state != BT_SCO_STATE_ENDING) { bt->tx->state != BT_SCO_STATE_ENDING &&
bt->tx->state != BT_SCO_STATE_LOOPBACK) {
dev_warn(bt->dev, "%s(), in idle state: rx->state: %d, tx->state: %d\n", dev_warn(bt->dev, "%s(), in idle state: rx->state: %d, tx->state: %d\n",
__func__, bt->rx->state, bt->tx->state); __func__, bt->rx->state, bt->tx->state);
goto irq_handler_exit; goto irq_handler_exit;
...@@ -512,6 +514,42 @@ static irqreturn_t mtk_btcvsd_snd_irq_handler(int irq_id, void *dev) ...@@ -512,6 +514,42 @@ static irqreturn_t mtk_btcvsd_snd_irq_handler(int irq_id, void *dev)
buf_cnt_tx = btsco_packet_info[packet_type][2]; buf_cnt_tx = btsco_packet_info[packet_type][2];
buf_cnt_rx = btsco_packet_info[packet_type][3]; buf_cnt_rx = btsco_packet_info[packet_type][3];
if (bt->tx->state == BT_SCO_STATE_LOOPBACK) {
u8 *src, *dst;
unsigned long connsys_addr_rx, ap_addr_rx;
unsigned long connsys_addr_tx, ap_addr_tx;
connsys_addr_rx = *bt->bt_reg_pkt_r;
ap_addr_rx = (unsigned long)bt->bt_sram_bank2_base +
(connsys_addr_rx & 0xFFFF);
connsys_addr_tx = *bt->bt_reg_pkt_w;
ap_addr_tx = (unsigned long)bt->bt_sram_bank2_base +
(connsys_addr_tx & 0xFFFF);
if (connsys_addr_tx == 0xdeadfeed ||
connsys_addr_rx == 0xdeadfeed) {
/* bt return 0xdeadfeed if read reg during bt sleep */
dev_warn(bt->dev, "%s(), connsys_addr_tx == 0xdeadfeed\n",
__func__);
goto irq_handler_exit;
}
src = (u8 *)ap_addr_rx;
dst = (u8 *)ap_addr_tx;
mtk_btcvsd_snd_data_transfer(BT_SCO_DIRECT_BT2ARM, src,
bt->tx->temp_packet_buf,
packet_length,
packet_num);
mtk_btcvsd_snd_data_transfer(BT_SCO_DIRECT_ARM2BT,
bt->tx->temp_packet_buf, dst,
packet_length,
packet_num);
bt->rx->rw_cnt++;
bt->tx->rw_cnt++;
}
if (bt->rx->state == BT_SCO_STATE_RUNNING || if (bt->rx->state == BT_SCO_STATE_RUNNING ||
bt->rx->state == BT_SCO_STATE_ENDING) { bt->rx->state == BT_SCO_STATE_ENDING) {
if (bt->rx->xrun) { if (bt->rx->xrun) {
...@@ -1067,6 +1105,33 @@ static int btcvsd_band_set(struct snd_kcontrol *kcontrol, ...@@ -1067,6 +1105,33 @@ static int btcvsd_band_set(struct snd_kcontrol *kcontrol,
return 0; return 0;
} }
static int btcvsd_loopback_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt);
bool lpbk_en = bt->tx->state == BT_SCO_STATE_LOOPBACK;
ucontrol->value.integer.value[0] = lpbk_en;
return 0;
}
static int btcvsd_loopback_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt);
if (ucontrol->value.integer.value[0]) {
mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_LOOPBACK);
mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_LOOPBACK);
} else {
mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_RUNNING);
mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_RUNNING);
}
return 0;
}
static int btcvsd_tx_mute_get(struct snd_kcontrol *kcontrol, static int btcvsd_tx_mute_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
...@@ -1202,6 +1267,8 @@ static int btcvsd_tx_timestamp_get(struct snd_kcontrol *kcontrol, ...@@ -1202,6 +1267,8 @@ static int btcvsd_tx_timestamp_get(struct snd_kcontrol *kcontrol,
static const struct snd_kcontrol_new mtk_btcvsd_snd_controls[] = { static const struct snd_kcontrol_new mtk_btcvsd_snd_controls[] = {
SOC_ENUM_EXT("BTCVSD Band", btcvsd_enum[0], SOC_ENUM_EXT("BTCVSD Band", btcvsd_enum[0],
btcvsd_band_get, btcvsd_band_set), btcvsd_band_get, btcvsd_band_set),
SOC_SINGLE_BOOL_EXT("BTCVSD Loopback Switch", 0,
btcvsd_loopback_get, btcvsd_loopback_set),
SOC_SINGLE_BOOL_EXT("BTCVSD Tx Mute Switch", 0, SOC_SINGLE_BOOL_EXT("BTCVSD Tx Mute Switch", 0,
btcvsd_tx_mute_get, btcvsd_tx_mute_set), btcvsd_tx_mute_get, btcvsd_tx_mute_set),
SOC_SINGLE_BOOL_EXT("BTCVSD Tx Irq Received Switch", 0, SOC_SINGLE_BOOL_EXT("BTCVSD Tx Irq Received Switch", 0,
......
...@@ -605,6 +605,10 @@ void mt8183_mck_disable(struct mtk_base_afe *afe, int mck_id) ...@@ -605,6 +605,10 @@ void mt8183_mck_disable(struct mtk_base_afe *afe, int mck_id)
int m_sel_id = mck_div[mck_id].m_sel_id; int m_sel_id = mck_div[mck_id].m_sel_id;
int div_clk_id = mck_div[mck_id].div_clk_id; int div_clk_id = mck_div[mck_id].div_clk_id;
/* i2s5 mck not support */
if (mck_id == MT8183_I2S5_MCK)
return;
clk_disable_unprepare(afe_priv->clk[div_clk_id]); clk_disable_unprepare(afe_priv->clk[div_clk_id]);
if (m_sel_id >= 0) if (m_sel_id >= 0)
clk_disable_unprepare(afe_priv->clk[m_sel_id]); clk_disable_unprepare(afe_priv->clk[m_sel_id]);
......
...@@ -1130,11 +1130,11 @@ static const struct snd_soc_dapm_widget samsung_i2s_widgets[] = { ...@@ -1130,11 +1130,11 @@ static const struct snd_soc_dapm_widget samsung_i2s_widgets[] = {
}; };
static const struct snd_soc_dapm_route samsung_i2s_dapm_routes[] = { static const struct snd_soc_dapm_route samsung_i2s_dapm_routes[] = {
{ "Playback Mixer", NULL, "Primary" }, { "Playback Mixer", NULL, "Primary Playback" },
{ "Playback Mixer", NULL, "Secondary" }, { "Playback Mixer", NULL, "Secondary Playback" },
{ "Mixer DAI TX", NULL, "Playback Mixer" }, { "Mixer DAI TX", NULL, "Playback Mixer" },
{ "Playback Mixer", NULL, "Mixer DAI RX" }, { "Primary Capture", NULL, "Mixer DAI RX" },
}; };
static const struct snd_soc_component_driver samsung_i2s_component = { static const struct snd_soc_component_driver samsung_i2s_component = {
...@@ -1155,7 +1155,8 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv, ...@@ -1155,7 +1155,8 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv,
int num_dais) int num_dais)
{ {
static const char *dai_names[] = { "samsung-i2s", "samsung-i2s-sec" }; static const char *dai_names[] = { "samsung-i2s", "samsung-i2s-sec" };
static const char *stream_names[] = { "Primary", "Secondary" }; static const char *stream_names[] = { "Primary Playback",
"Secondary Playback" };
struct snd_soc_dai_driver *dai_drv; struct snd_soc_dai_driver *dai_drv;
struct i2s_dai *dai; struct i2s_dai *dai;
int i; int i;
...@@ -1201,6 +1202,7 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv, ...@@ -1201,6 +1202,7 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv,
dai_drv->capture.channels_max = 2; dai_drv->capture.channels_max = 2;
dai_drv->capture.rates = i2s_dai_data->pcm_rates; dai_drv->capture.rates = i2s_dai_data->pcm_rates;
dai_drv->capture.formats = SAMSUNG_I2S_FMTS; dai_drv->capture.formats = SAMSUNG_I2S_FMTS;
dai_drv->capture.stream_name = "Primary Capture";
return 0; return 0;
} }
......
...@@ -91,11 +91,11 @@ static int odroid_card_be_hw_params(struct snd_pcm_substream *substream, ...@@ -91,11 +91,11 @@ static int odroid_card_be_hw_params(struct snd_pcm_substream *substream,
return ret; return ret;
/* /*
* We add 1 to the rclk_freq value in order to avoid too low clock * We add 2 to the rclk_freq value in order to avoid too low clock
* frequency values due to the EPLL output frequency not being exact * frequency values due to the EPLL output frequency not being exact
* multiple of the audio sampling rate. * multiple of the audio sampling rate.
*/ */
rclk_freq = params_rate(params) * rfs + 1; rclk_freq = params_rate(params) * rfs + 2;
ret = clk_set_rate(priv->sclk_i2s, rclk_freq); ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
if (ret < 0) if (ret < 0)
......
...@@ -110,6 +110,8 @@ static const struct of_device_id rsnd_of_match[] = { ...@@ -110,6 +110,8 @@ static const struct of_device_id rsnd_of_match[] = {
{ .compatible = "renesas,rcar_sound-gen1", .data = (void *)RSND_GEN1 }, { .compatible = "renesas,rcar_sound-gen1", .data = (void *)RSND_GEN1 },
{ .compatible = "renesas,rcar_sound-gen2", .data = (void *)RSND_GEN2 }, { .compatible = "renesas,rcar_sound-gen2", .data = (void *)RSND_GEN2 },
{ .compatible = "renesas,rcar_sound-gen3", .data = (void *)RSND_GEN3 }, { .compatible = "renesas,rcar_sound-gen3", .data = (void *)RSND_GEN3 },
/* Special Handling */
{ .compatible = "renesas,rcar_sound-r8a77990", .data = (void *)(RSND_GEN3 | RSND_SOC_E) },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, rsnd_of_match); MODULE_DEVICE_TABLE(of, rsnd_of_match);
......
...@@ -607,6 +607,8 @@ struct rsnd_priv { ...@@ -607,6 +607,8 @@ struct rsnd_priv {
#define RSND_GEN1 (1 << 0) #define RSND_GEN1 (1 << 0)
#define RSND_GEN2 (2 << 0) #define RSND_GEN2 (2 << 0)
#define RSND_GEN3 (3 << 0) #define RSND_GEN3 (3 << 0)
#define RSND_SOC_MASK (0xFF << 4)
#define RSND_SOC_E (1 << 4) /* E1/E2/E3 */
/* /*
* below value will be filled on rsnd_gen_probe() * below value will be filled on rsnd_gen_probe()
...@@ -679,6 +681,9 @@ struct rsnd_priv { ...@@ -679,6 +681,9 @@ struct rsnd_priv {
#define rsnd_is_gen1(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN1) #define rsnd_is_gen1(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN1)
#define rsnd_is_gen2(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN2) #define rsnd_is_gen2(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN2)
#define rsnd_is_gen3(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN3) #define rsnd_is_gen3(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN3)
#define rsnd_is_e3(priv) (((priv)->flags & \
(RSND_GEN_MASK | RSND_SOC_MASK)) == \
(RSND_GEN3 | RSND_SOC_E))
#define rsnd_flags_has(p, f) ((p)->flags & (f)) #define rsnd_flags_has(p, f) ((p)->flags & (f))
#define rsnd_flags_set(p, f) ((p)->flags |= (f)) #define rsnd_flags_set(p, f) ((p)->flags |= (f))
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include "rsnd.h" #include "rsnd.h"
#include <linux/sys_soc.h>
#define SRC_NAME "src" #define SRC_NAME "src"
...@@ -189,18 +188,12 @@ static const u32 chan222222[] = { ...@@ -189,18 +188,12 @@ static const u32 chan222222[] = {
0x00000006, /* 1 to 2 */ 0x00000006, /* 1 to 2 */
}; };
static const struct soc_device_attribute ov_soc[] = {
{ .soc_id = "r8a77990" }, /* E3 */
{ /* sentinel */ }
};
static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
struct rsnd_mod *mod) struct rsnd_mod *mod)
{ {
struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
struct device *dev = rsnd_priv_to_dev(priv); struct device *dev = rsnd_priv_to_dev(priv);
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
const struct soc_device_attribute *soc = soc_device_match(ov_soc);
int is_play = rsnd_io_is_play(io); int is_play = rsnd_io_is_play(io);
int use_src = 0; int use_src = 0;
u32 fin, fout; u32 fin, fout;
...@@ -307,7 +300,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, ...@@ -307,7 +300,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
/* /*
* E3 need to overwrite * E3 need to overwrite
*/ */
if (soc) if (rsnd_is_e3(priv))
switch (rsnd_mod_id(mod)) { switch (rsnd_mod_id(mod)) {
case 0: case 0:
case 4: case 4:
......
...@@ -2797,6 +2797,7 @@ int snd_soc_register_card(struct snd_soc_card *card) ...@@ -2797,6 +2797,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
ret = soc_init_dai_link(card, link); ret = soc_init_dai_link(card, link);
if (ret) { if (ret) {
soc_cleanup_platform(card);
dev_err(card->dev, "ASoC: failed to init link %s\n", dev_err(card->dev, "ASoC: failed to init link %s\n",
link->name); link->name);
mutex_unlock(&client_mutex); mutex_unlock(&client_mutex);
......
...@@ -954,10 +954,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -954,10 +954,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
codec_params = *params; codec_params = *params;
/* fixup params based on TDM slot masks */ /* fixup params based on TDM slot masks */
if (codec_dai->tx_mask) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
codec_dai->tx_mask)
soc_pcm_codec_params_fixup(&codec_params, soc_pcm_codec_params_fixup(&codec_params,
codec_dai->tx_mask); codec_dai->tx_mask);
if (codec_dai->rx_mask)
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
codec_dai->rx_mask)
soc_pcm_codec_params_fixup(&codec_params, soc_pcm_codec_params_fixup(&codec_params,
codec_dai->rx_mask); codec_dai->rx_mask);
...@@ -1213,6 +1216,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, ...@@ -1213,6 +1216,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
struct snd_soc_pcm_runtime *be, int stream) struct snd_soc_pcm_runtime *be, int stream)
{ {
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
unsigned long flags;
/* only add new dpcms */ /* only add new dpcms */
for_each_dpcm_be(fe, stream, dpcm) { for_each_dpcm_be(fe, stream, dpcm) {
...@@ -1228,10 +1232,10 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, ...@@ -1228,10 +1232,10 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
dpcm->fe = fe; dpcm->fe = fe;
be->dpcm[stream].runtime = fe->dpcm[stream].runtime; be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW; dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW;
spin_lock(&fe->card->dpcm_lock); spin_lock_irqsave(&fe->card->dpcm_lock, flags);
list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients);
list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients);
spin_unlock(&fe->card->dpcm_lock); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
stream ? "capture" : "playback", fe->dai_link->name, stream ? "capture" : "playback", fe->dai_link->name,
...@@ -1277,6 +1281,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, ...@@ -1277,6 +1281,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe,
void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
{ {
struct snd_soc_dpcm *dpcm, *d; struct snd_soc_dpcm *dpcm, *d;
unsigned long flags;
for_each_dpcm_be_safe(fe, stream, dpcm, d) { for_each_dpcm_be_safe(fe, stream, dpcm, d) {
dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n",
...@@ -1296,10 +1301,10 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -1296,10 +1301,10 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
debugfs_remove(dpcm->debugfs_state); debugfs_remove(dpcm->debugfs_state);
#endif #endif
spin_lock(&fe->card->dpcm_lock); spin_lock_irqsave(&fe->card->dpcm_lock, flags);
list_del(&dpcm->list_be); list_del(&dpcm->list_be);
list_del(&dpcm->list_fe); list_del(&dpcm->list_fe);
spin_unlock(&fe->card->dpcm_lock); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
kfree(dpcm); kfree(dpcm);
} }
} }
...@@ -1551,12 +1556,13 @@ int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, ...@@ -1551,12 +1556,13 @@ int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream)
{ {
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
unsigned long flags;
spin_lock(&fe->card->dpcm_lock); spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_be(fe, stream, dpcm) for_each_dpcm_be(fe, stream, dpcm)
dpcm->be->dpcm[stream].runtime_update = dpcm->be->dpcm[stream].runtime_update =
SND_SOC_DPCM_UPDATE_NO; SND_SOC_DPCM_UPDATE_NO;
spin_unlock(&fe->card->dpcm_lock); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
} }
static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe, static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe,
...@@ -2577,6 +2583,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2577,6 +2583,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
int ret; int ret;
unsigned long flags;
dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n",
stream ? "capture" : "playback", fe->dai_link->name); stream ? "capture" : "playback", fe->dai_link->name);
...@@ -2646,13 +2653,13 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2646,13 +2653,13 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
dpcm_be_dai_shutdown(fe, stream); dpcm_be_dai_shutdown(fe, stream);
disconnect: disconnect:
/* disconnect any non started BEs */ /* disconnect any non started BEs */
spin_lock(&fe->card->dpcm_lock); spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_be(fe, stream, dpcm) { for_each_dpcm_be(fe, stream, dpcm) {
struct snd_soc_pcm_runtime *be = dpcm->be; struct snd_soc_pcm_runtime *be = dpcm->be;
if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
} }
spin_unlock(&fe->card->dpcm_lock); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
return ret; return ret;
} }
...@@ -3230,8 +3237,9 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, ...@@ -3230,8 +3237,9 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
int state; int state;
int ret = 1; int ret = 1;
unsigned long flags;
spin_lock(&fe->card->dpcm_lock); spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_fe(be, stream, dpcm) { for_each_dpcm_fe(be, stream, dpcm) {
if (dpcm->fe == fe) if (dpcm->fe == fe)
...@@ -3245,7 +3253,7 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, ...@@ -3245,7 +3253,7 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
break; break;
} }
} }
spin_unlock(&fe->card->dpcm_lock); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
/* it's safe to free/stop this BE DAI */ /* it's safe to free/stop this BE DAI */
return ret; return ret;
...@@ -3262,8 +3270,9 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, ...@@ -3262,8 +3270,9 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
int state; int state;
int ret = 1; int ret = 1;
unsigned long flags;
spin_lock(&fe->card->dpcm_lock); spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_fe(be, stream, dpcm) { for_each_dpcm_fe(be, stream, dpcm) {
if (dpcm->fe == fe) if (dpcm->fe == fe)
...@@ -3278,7 +3287,7 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, ...@@ -3278,7 +3287,7 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
break; break;
} }
} }
spin_unlock(&fe->card->dpcm_lock); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
/* it's safe to change hw_params */ /* it's safe to change hw_params */
return ret; return ret;
...@@ -3320,6 +3329,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, ...@@ -3320,6 +3329,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params;
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
ssize_t offset = 0; ssize_t offset = 0;
unsigned long flags;
/* FE state */ /* FE state */
offset += snprintf(buf + offset, size - offset, offset += snprintf(buf + offset, size - offset,
...@@ -3347,7 +3357,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, ...@@ -3347,7 +3357,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
goto out; goto out;
} }
spin_lock(&fe->card->dpcm_lock); spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_be(fe, stream, dpcm) { for_each_dpcm_be(fe, stream, dpcm) {
struct snd_soc_pcm_runtime *be = dpcm->be; struct snd_soc_pcm_runtime *be = dpcm->be;
params = &dpcm->hw_params; params = &dpcm->hw_params;
...@@ -3368,7 +3378,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, ...@@ -3368,7 +3378,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
params_channels(params), params_channels(params),
params_rate(params)); params_rate(params));
} }
spin_unlock(&fe->card->dpcm_lock); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
out: out:
return offset; return offset;
} }
......
...@@ -278,7 +278,6 @@ static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg) ...@@ -278,7 +278,6 @@ static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg)
case STM32_I2S_CFG2_REG: case STM32_I2S_CFG2_REG:
case STM32_I2S_IER_REG: case STM32_I2S_IER_REG:
case STM32_I2S_SR_REG: case STM32_I2S_SR_REG:
case STM32_I2S_TXDR_REG:
case STM32_I2S_RXDR_REG: case STM32_I2S_RXDR_REG:
case STM32_I2S_CGFR_REG: case STM32_I2S_CGFR_REG:
return true; return true;
...@@ -290,7 +289,7 @@ static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg) ...@@ -290,7 +289,7 @@ static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg)
static bool stm32_i2s_volatile_reg(struct device *dev, unsigned int reg) static bool stm32_i2s_volatile_reg(struct device *dev, unsigned int reg)
{ {
switch (reg) { switch (reg) {
case STM32_I2S_TXDR_REG: case STM32_I2S_SR_REG:
case STM32_I2S_RXDR_REG: case STM32_I2S_RXDR_REG:
return true; return true;
default: default:
......
...@@ -105,6 +105,7 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client, ...@@ -105,6 +105,7 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
if (!pdev) { if (!pdev) {
dev_err(&sai_client->pdev->dev, dev_err(&sai_client->pdev->dev,
"Device not found for node %pOFn\n", np_provider); "Device not found for node %pOFn\n", np_provider);
of_node_put(np_provider);
return -ENODEV; return -ENODEV;
} }
...@@ -113,19 +114,20 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client, ...@@ -113,19 +114,20 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
dev_err(&sai_client->pdev->dev, dev_err(&sai_client->pdev->dev,
"SAI sync provider data not found\n"); "SAI sync provider data not found\n");
ret = -EINVAL; ret = -EINVAL;
goto out_put_dev; goto error;
} }
/* Configure sync client */ /* Configure sync client */
ret = stm32_sai_sync_conf_client(sai_client, synci); ret = stm32_sai_sync_conf_client(sai_client, synci);
if (ret < 0) if (ret < 0)
goto out_put_dev; goto error;
/* Configure sync provider */ /* Configure sync provider */
ret = stm32_sai_sync_conf_provider(sai_provider, synco); ret = stm32_sai_sync_conf_provider(sai_provider, synco);
out_put_dev: error:
put_device(&pdev->dev); put_device(&pdev->dev);
of_node_put(np_provider);
return ret; return ret;
} }
......
...@@ -100,8 +100,9 @@ ...@@ -100,8 +100,9 @@
* @slot_mask: rx or tx active slots mask. set at init or at runtime * @slot_mask: rx or tx active slots mask. set at init or at runtime
* @data_size: PCM data width. corresponds to PCM substream width. * @data_size: PCM data width. corresponds to PCM substream width.
* @spdif_frm_cnt: S/PDIF playback frame counter * @spdif_frm_cnt: S/PDIF playback frame counter
* @snd_aes_iec958: iec958 data * @iec958: iec958 data
* @ctrl_lock: control lock * @ctrl_lock: control lock
* @irq_lock: prevent race condition with IRQ
*/ */
struct stm32_sai_sub_data { struct stm32_sai_sub_data {
struct platform_device *pdev; struct platform_device *pdev;
...@@ -133,6 +134,7 @@ struct stm32_sai_sub_data { ...@@ -133,6 +134,7 @@ struct stm32_sai_sub_data {
unsigned int spdif_frm_cnt; unsigned int spdif_frm_cnt;
struct snd_aes_iec958 iec958; struct snd_aes_iec958 iec958;
struct mutex ctrl_lock; /* protect resources accessed by controls */ struct mutex ctrl_lock; /* protect resources accessed by controls */
spinlock_t irq_lock; /* used to prevent race condition with IRQ */
}; };
enum stm32_sai_fifo_th { enum stm32_sai_fifo_th {
...@@ -474,8 +476,10 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid) ...@@ -474,8 +476,10 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
status = SNDRV_PCM_STATE_XRUN; status = SNDRV_PCM_STATE_XRUN;
} }
if (status != SNDRV_PCM_STATE_RUNNING) spin_lock(&sai->irq_lock);
if (status != SNDRV_PCM_STATE_RUNNING && sai->substream)
snd_pcm_stop_xrun(sai->substream); snd_pcm_stop_xrun(sai->substream);
spin_unlock(&sai->irq_lock);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -679,8 +683,19 @@ static int stm32_sai_startup(struct snd_pcm_substream *substream, ...@@ -679,8 +683,19 @@ static int stm32_sai_startup(struct snd_pcm_substream *substream,
{ {
struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
int imr, cr2, ret; int imr, cr2, ret;
unsigned long flags;
spin_lock_irqsave(&sai->irq_lock, flags);
sai->substream = substream; sai->substream = substream;
spin_unlock_irqrestore(&sai->irq_lock, flags);
if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
snd_pcm_hw_constraint_mask64(substream->runtime,
SNDRV_PCM_HW_PARAM_FORMAT,
SNDRV_PCM_FMTBIT_S32_LE);
snd_pcm_hw_constraint_single(substream->runtime,
SNDRV_PCM_HW_PARAM_CHANNELS, 2);
}
ret = clk_prepare_enable(sai->sai_ck); ret = clk_prepare_enable(sai->sai_ck);
if (ret < 0) { if (ret < 0) {
...@@ -898,7 +913,7 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai, ...@@ -898,7 +913,7 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
int div = 0; int div = 0, cr1 = 0;
int sai_clk_rate, mclk_ratio, den; int sai_clk_rate, mclk_ratio, den;
unsigned int rate = params_rate(params); unsigned int rate = params_rate(params);
...@@ -943,13 +958,19 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai, ...@@ -943,13 +958,19 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai,
} else { } else {
if (sai->mclk_rate) { if (sai->mclk_rate) {
mclk_ratio = sai->mclk_rate / rate; mclk_ratio = sai->mclk_rate / rate;
if ((mclk_ratio != 512) && if (mclk_ratio == 512) {
(mclk_ratio != 256)) { cr1 = SAI_XCR1_OSR;
} else if (mclk_ratio != 256) {
dev_err(cpu_dai->dev, dev_err(cpu_dai->dev,
"Wrong mclk ratio %d\n", "Wrong mclk ratio %d\n",
mclk_ratio); mclk_ratio);
return -EINVAL; return -EINVAL;
} }
regmap_update_bits(sai->regmap,
STM_SAI_CR1_REGX,
SAI_XCR1_OSR, cr1);
div = stm32_sai_get_clk_div(sai, sai_clk_rate, div = stm32_sai_get_clk_div(sai, sai_clk_rate,
sai->mclk_rate); sai->mclk_rate);
if (div < 0) if (div < 0)
...@@ -1051,6 +1072,7 @@ static void stm32_sai_shutdown(struct snd_pcm_substream *substream, ...@@ -1051,6 +1072,7 @@ static void stm32_sai_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai) struct snd_soc_dai *cpu_dai)
{ {
struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
unsigned long flags;
regmap_update_bits(sai->regmap, STM_SAI_IMR_REGX, SAI_XIMR_MASK, 0); regmap_update_bits(sai->regmap, STM_SAI_IMR_REGX, SAI_XIMR_MASK, 0);
...@@ -1061,18 +1083,21 @@ static void stm32_sai_shutdown(struct snd_pcm_substream *substream, ...@@ -1061,18 +1083,21 @@ static void stm32_sai_shutdown(struct snd_pcm_substream *substream,
clk_rate_exclusive_put(sai->sai_mclk); clk_rate_exclusive_put(sai->sai_mclk);
spin_lock_irqsave(&sai->irq_lock, flags);
sai->substream = NULL; sai->substream = NULL;
spin_unlock_irqrestore(&sai->irq_lock, flags);
} }
static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd, static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *cpu_dai) struct snd_soc_dai *cpu_dai)
{ {
struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev);
struct snd_kcontrol_new knew = iec958_ctls;
if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
dev_dbg(&sai->pdev->dev, "%s: register iec controls", __func__); dev_dbg(&sai->pdev->dev, "%s: register iec controls", __func__);
return snd_ctl_add(rtd->pcm->card, knew.device = rtd->pcm->device;
snd_ctl_new1(&iec958_ctls, sai)); return snd_ctl_add(rtd->pcm->card, snd_ctl_new1(&knew, sai));
} }
return 0; return 0;
...@@ -1081,7 +1106,7 @@ static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd, ...@@ -1081,7 +1106,7 @@ static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd,
static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai) static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai)
{ {
struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev);
int cr1 = 0, cr1_mask; int cr1 = 0, cr1_mask, ret;
sai->cpu_dai = cpu_dai; sai->cpu_dai = cpu_dai;
...@@ -1111,8 +1136,10 @@ static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai) ...@@ -1111,8 +1136,10 @@ static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai)
/* Configure synchronization */ /* Configure synchronization */
if (sai->sync == SAI_SYNC_EXTERNAL) { if (sai->sync == SAI_SYNC_EXTERNAL) {
/* Configure synchro client and provider */ /* Configure synchro client and provider */
sai->pdata->set_sync(sai->pdata, sai->np_sync_provider, ret = sai->pdata->set_sync(sai->pdata, sai->np_sync_provider,
sai->synco, sai->synci); sai->synco, sai->synci);
if (ret)
return ret;
} }
cr1_mask |= SAI_XCR1_SYNCEN_MASK; cr1_mask |= SAI_XCR1_SYNCEN_MASK;
...@@ -1424,6 +1451,7 @@ static int stm32_sai_sub_probe(struct platform_device *pdev) ...@@ -1424,6 +1451,7 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
sai->pdev = pdev; sai->pdev = pdev;
mutex_init(&sai->ctrl_lock); mutex_init(&sai->ctrl_lock);
spin_lock_init(&sai->irq_lock);
platform_set_drvdata(pdev, sai); platform_set_drvdata(pdev, sai);
sai->pdata = dev_get_drvdata(pdev->dev.parent); sai->pdata = dev_get_drvdata(pdev->dev.parent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment