Merge branch 'for-5.1' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-5.2
This commit is contained in:
commit
3863293a96
|
@ -2129,6 +2129,7 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|||
dev_err(dai->component->dev,
|
||||
"%s: ERROR: The device is either a master or a slave.\n",
|
||||
__func__);
|
||||
/* fall through */
|
||||
default:
|
||||
dev_err(dai->component->dev,
|
||||
"%s: ERROR: Unsupporter master mask 0x%x\n",
|
||||
|
|
|
@ -38,6 +38,9 @@ static void hdac_hda_dai_close(struct snd_pcm_substream *substream,
|
|||
struct snd_soc_dai *dai);
|
||||
static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
|
||||
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,
|
||||
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 = {
|
|||
.startup = hdac_hda_dai_open,
|
||||
.shutdown = hdac_hda_dai_close,
|
||||
.prepare = hdac_hda_dai_prepare,
|
||||
.hw_params = hdac_hda_dai_hw_params,
|
||||
.hw_free = hdac_hda_dai_hw_free,
|
||||
.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,
|
|||
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,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
|
@ -162,10 +199,9 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
|
|||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct hdac_hda_priv *hda_pvt;
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
struct hdac_device *hdev;
|
||||
struct hda_pcm_stream *hda_stream;
|
||||
struct hdac_hda_priv *hda_pvt;
|
||||
struct hdac_device *hdev;
|
||||
unsigned int format_val;
|
||||
struct hda_pcm *pcm;
|
||||
unsigned int stream;
|
||||
|
@ -179,19 +215,8 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
|
|||
|
||||
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];
|
||||
format_val = hda_pvt->pcm[dai->id].format_val[substream->stream];
|
||||
|
||||
ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream,
|
||||
stream, format_val, substream);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
struct hdac_hda_pcm {
|
||||
int stream_tag[2];
|
||||
unsigned int format_val[2];
|
||||
};
|
||||
|
||||
struct hdac_hda_priv {
|
||||
|
|
|
@ -484,9 +484,6 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream,
|
|||
params_width(params), params_rate(params),
|
||||
params_channels(params));
|
||||
|
||||
if (params_width(params) > 24)
|
||||
params->msbits = 24;
|
||||
|
||||
ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status,
|
||||
sizeof(hp.iec.status));
|
||||
if (ret < 0) {
|
||||
|
@ -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_daifmt cf = { 0 };
|
||||
int ret = 0;
|
||||
|
||||
dev_dbg(dai->dev, "%s()\n", __func__);
|
||||
|
||||
if (dai->id == DAI_ID_SPDIF) {
|
||||
cf.fmt = HDMI_SPDIF;
|
||||
} else {
|
||||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
cf.bit_clk_master = 1;
|
||||
cf.frame_clk_master = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFM:
|
||||
cf.frame_clk_master = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBM_CFS:
|
||||
cf.bit_clk_master = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFS:
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
if (dai->id == DAI_ID_SPDIF)
|
||||
return 0;
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
|
||||
case SND_SOC_DAIFMT_NB_NF:
|
||||
break;
|
||||
case SND_SOC_DAIFMT_NB_IF:
|
||||
cf.frame_clk_inv = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_IB_NF:
|
||||
cf.bit_clk_inv = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_IB_IF:
|
||||
cf.frame_clk_inv = 1;
|
||||
cf.bit_clk_inv = 1;
|
||||
break;
|
||||
}
|
||||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
cf.bit_clk_master = 1;
|
||||
cf.frame_clk_master = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFM:
|
||||
cf.frame_clk_master = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBM_CFS:
|
||||
cf.bit_clk_master = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFS:
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
|
||||
case SND_SOC_DAIFMT_I2S:
|
||||
cf.fmt = HDMI_I2S;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_DSP_A:
|
||||
cf.fmt = HDMI_DSP_A;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_DSP_B:
|
||||
cf.fmt = HDMI_DSP_B;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_RIGHT_J:
|
||||
cf.fmt = HDMI_RIGHT_J;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_LEFT_J:
|
||||
cf.fmt = HDMI_LEFT_J;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_AC97:
|
||||
cf.fmt = HDMI_AC97;
|
||||
break;
|
||||
default:
|
||||
dev_err(dai->dev, "Invalid DAI interface format\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
|
||||
case SND_SOC_DAIFMT_NB_NF:
|
||||
break;
|
||||
case SND_SOC_DAIFMT_NB_IF:
|
||||
cf.frame_clk_inv = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_IB_NF:
|
||||
cf.bit_clk_inv = 1;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_IB_IF:
|
||||
cf.frame_clk_inv = 1;
|
||||
cf.bit_clk_inv = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
|
||||
case SND_SOC_DAIFMT_I2S:
|
||||
cf.fmt = HDMI_I2S;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_DSP_A:
|
||||
cf.fmt = HDMI_DSP_A;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_DSP_B:
|
||||
cf.fmt = HDMI_DSP_B;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_RIGHT_J:
|
||||
cf.fmt = HDMI_RIGHT_J;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_LEFT_J:
|
||||
cf.fmt = HDMI_LEFT_J;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_AC97:
|
||||
cf.fmt = HDMI_AC97;
|
||||
break;
|
||||
default:
|
||||
dev_err(dai->dev, "Invalid DAI interface format\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hcp->daifmt[dai->id] = cf;
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
|||
i++;
|
||||
}
|
||||
|
||||
if (hcd->spdif)
|
||||
if (hcd->spdif) {
|
||||
hcp->daidrv[i] = hdmi_spdif_dai;
|
||||
hcp->daifmt[DAI_ID_SPDIF].fmt = HDMI_SPDIF;
|
||||
}
|
||||
|
||||
dev_set_drvdata(dev, hcp);
|
||||
|
||||
|
|
|
@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget nau8810_dapm_widgets[] = {
|
|||
SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
|
||||
NAU8810_MOUTMX_EN_SFT, 0, &nau8810_mono_mixer_controls[0],
|
||||
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),
|
||||
SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2,
|
||||
SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
|
||||
NAU8810_ADC_EN_SFT, 0),
|
||||
SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
|
||||
NAU8810_NSPK_EN_SFT, 0, NULL, 0),
|
||||
|
|
|
@ -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,
|
||||
NAU8824_ADCR_EN_SFT, 0),
|
||||
|
||||
SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi 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_OUT("AIFTX", "Capture", 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,
|
||||
NAU8824_DACL_EN_SFT, 0),
|
||||
|
@ -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)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = nau8824->dapm;
|
||||
|
@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824)
|
|||
/* Clear all interruption status */
|
||||
nau8824_int_status_clear_all(regmap);
|
||||
|
||||
snd_soc_dapm_disable_pin(dapm, "SAR");
|
||||
snd_soc_dapm_disable_pin(dapm, "MICBIAS");
|
||||
nau8824_dapm_disable_pin(nau8824, "SAR");
|
||||
nau8824_dapm_disable_pin(nau8824, "MICBIAS");
|
||||
snd_soc_dapm_sync(dapm);
|
||||
|
||||
/* Enable the insertion interruption, disable the ejection
|
||||
|
@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work)
|
|||
struct regmap *regmap = nau8824->regmap;
|
||||
int adc_value, event = 0, event_mask = 0;
|
||||
|
||||
snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
|
||||
snd_soc_dapm_force_enable_pin(dapm, "SAR");
|
||||
nau8824_dapm_enable_pin(nau8824, "MICBIAS");
|
||||
nau8824_dapm_enable_pin(nau8824, "SAR");
|
||||
snd_soc_dapm_sync(dapm);
|
||||
|
||||
msleep(100);
|
||||
|
@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work)
|
|||
if (adc_value < HEADSET_SARADC_THD) {
|
||||
event |= SND_JACK_HEADPHONE;
|
||||
|
||||
snd_soc_dapm_disable_pin(dapm, "SAR");
|
||||
snd_soc_dapm_disable_pin(dapm, "MICBIAS");
|
||||
nau8824_dapm_disable_pin(nau8824, "SAR");
|
||||
nau8824_dapm_disable_pin(nau8824, "MICBIAS");
|
||||
snd_soc_dapm_sync(dapm);
|
||||
} else {
|
||||
event |= SND_JACK_HEADSET;
|
||||
|
|
|
@ -910,13 +910,21 @@ static int rt5682_headset_detect(struct snd_soc_component *component,
|
|||
int jack_insert)
|
||||
{
|
||||
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;
|
||||
|
||||
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,
|
||||
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH);
|
||||
|
||||
|
@ -944,8 +952,10 @@ static int rt5682_headset_detect(struct snd_soc_component *component,
|
|||
rt5682_enable_push_button_irq(component, false);
|
||||
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
|
||||
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
|
||||
snd_soc_dapm_disable_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, 0);
|
||||
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
|
||||
RT5682_PWR_CBJ, 0);
|
||||
|
||||
rt5682->jack_type = 0;
|
||||
}
|
||||
|
@ -1198,7 +1208,7 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
|
|||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
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_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,
|
|||
|
||||
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;
|
||||
sft = RT5682_ADC_OSR_SFT;
|
||||
mask = RT5682_ADC_OSR_MASK;
|
||||
} else {
|
||||
else
|
||||
reg = RT5682_PLL_TRACK_2;
|
||||
sft = RT5682_DAC_OSR_SFT;
|
||||
mask = RT5682_DAC_OSR_MASK;
|
||||
}
|
||||
|
||||
snd_soc_component_update_bits(component, reg,
|
||||
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,
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1591,8 +1597,6 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = {
|
|||
0, NULL, 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),
|
||||
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 */
|
||||
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[] = {
|
|||
SND_SOC_DAPM_PGA("BST1 CBJ", SND_SOC_NOPM,
|
||||
0, 0, NULL, 0),
|
||||
|
||||
SND_SOC_DAPM_SUPPLY("CBJ Power", RT5682_PWR_ANLG_3,
|
||||
RT5682_PWR_CBJ_BIT, 0, NULL, 0),
|
||||
|
||||
/* REC Mixer */
|
||||
SND_SOC_DAPM_MIXER("RECMIX1L", SND_SOC_NOPM, 0, 0, rt5682_rec1_l_mix,
|
||||
ARRAY_SIZE(rt5682_rec1_l_mix)),
|
||||
|
@ -1792,17 +1793,13 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = {
|
|||
|
||||
/*Vref*/
|
||||
{"MICBIAS1", NULL, "Vref1"},
|
||||
{"MICBIAS1", NULL, "Vref2"},
|
||||
{"MICBIAS2", NULL, "Vref1"},
|
||||
{"MICBIAS2", NULL, "Vref2"},
|
||||
|
||||
{"CLKDET SYS", NULL, "CLKDET"},
|
||||
|
||||
{"IN1P", NULL, "LDO2"},
|
||||
|
||||
{"BST1 CBJ", NULL, "IN1P"},
|
||||
{"BST1 CBJ", NULL, "CBJ Power"},
|
||||
{"CBJ Power", NULL, "Vref2"},
|
||||
|
||||
{"RECMIX1L", "CBJ Switch", "BST1 CBJ"},
|
||||
{"RECMIX1L", NULL, "RECMIX1L Power"},
|
||||
|
@ -1912,9 +1909,7 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = {
|
|||
{"HP Amp", NULL, "Capless"},
|
||||
{"HP Amp", NULL, "Charge Pump"},
|
||||
{"HP Amp", NULL, "CLKDET SYS"},
|
||||
{"HP Amp", NULL, "CBJ Power"},
|
||||
{"HP Amp", NULL, "Vref1"},
|
||||
{"HP Amp", NULL, "Vref2"},
|
||||
{"HPOL Playback", "Switch", "HP Amp"},
|
||||
{"HPOR Playback", "Switch", "HP Amp"},
|
||||
{"HPOL", NULL, "HPOL Playback"},
|
||||
|
@ -2303,16 +2298,13 @@ static int rt5682_set_bias_level(struct snd_soc_component *component,
|
|||
switch (level) {
|
||||
case SND_SOC_BIAS_PREPARE:
|
||||
regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
|
||||
RT5682_PWR_MB | RT5682_PWR_BG,
|
||||
RT5682_PWR_MB | RT5682_PWR_BG);
|
||||
RT5682_PWR_BG, RT5682_PWR_BG);
|
||||
regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
|
||||
RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO,
|
||||
RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO);
|
||||
break;
|
||||
|
||||
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,
|
||||
RT5682_DIG_GATE_CTRL, RT5682_DIG_GATE_CTRL);
|
||||
break;
|
||||
|
@ -2320,7 +2312,7 @@ static int rt5682_set_bias_level(struct snd_soc_component *component,
|
|||
regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
|
||||
RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO, 0);
|
||||
regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
|
||||
RT5682_PWR_MB | RT5682_PWR_BG, 0);
|
||||
RT5682_PWR_BG, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2363,6 +2355,8 @@ static int rt5682_resume(struct snd_soc_component *component)
|
|||
regcache_cache_only(rt5682->regmap, false);
|
||||
regcache_sync(rt5682->regmap);
|
||||
|
||||
rt5682_irq(0, rt5682);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -1609,7 +1609,6 @@ static int aic3x_probe(struct snd_soc_component *component)
|
|||
struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
|
||||
int ret, i;
|
||||
|
||||
INIT_LIST_HEAD(&aic3x->list);
|
||||
aic3x->component = component;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
|
||||
|
@ -1873,6 +1872,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
|
|||
if (ret != 0)
|
||||
goto err_gpio;
|
||||
|
||||
INIT_LIST_HEAD(&aic3x->list);
|
||||
list_add(&aic3x->list, &reset_list);
|
||||
|
||||
return 0;
|
||||
|
@ -1889,6 +1889,8 @@ static int aic3x_i2c_remove(struct i2c_client *client)
|
|||
{
|
||||
struct aic3x_priv *aic3x = i2c_get_clientdata(client);
|
||||
|
||||
list_del(&aic3x->list);
|
||||
|
||||
if (gpio_is_valid(aic3x->gpio_reset) &&
|
||||
!aic3x_is_shared_reset(aic3x)) {
|
||||
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)
|
|||
struct hdac_stream *hstream;
|
||||
struct hdac_ext_stream *stream;
|
||||
struct hdac_ext_link *link;
|
||||
unsigned char stream_tag;
|
||||
|
||||
hstream = snd_hdac_get_stream(bus, params->stream,
|
||||
params->link_dma_id + 1);
|
||||
|
@ -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);
|
||||
|
||||
list_for_each_entry(link, &bus->hlink_list, list) {
|
||||
if (link->index == params->link_index)
|
||||
snd_hdac_ext_link_set_stream_id(link,
|
||||
hstream->stream_tag);
|
||||
stream_tag = hstream->stream_tag;
|
||||
if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||
list_for_each_entry(link, &bus->hlink_list, list) {
|
||||
if (link->index == params->link_index)
|
||||
snd_hdac_ext_link_set_stream_id(link,
|
||||
stream_tag);
|
||||
}
|
||||
}
|
||||
|
||||
stream->link_prepared = 1;
|
||||
|
@ -645,6 +649,7 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,
|
|||
struct hdac_ext_stream *link_dev =
|
||||
snd_soc_dai_get_dma_data(dai, substream);
|
||||
struct hdac_ext_link *link;
|
||||
unsigned char stream_tag;
|
||||
|
||||
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,
|
|||
if (!link)
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ enum bt_sco_state {
|
|||
BT_SCO_STATE_IDLE,
|
||||
BT_SCO_STATE_RUNNING,
|
||||
BT_SCO_STATE_ENDING,
|
||||
BT_SCO_STATE_LOOPBACK,
|
||||
};
|
||||
|
||||
enum bt_sco_direct {
|
||||
|
@ -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 &&
|
||||
bt->rx->state != BT_SCO_STATE_ENDING &&
|
||||
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",
|
||||
__func__, bt->rx->state, bt->tx->state);
|
||||
goto irq_handler_exit;
|
||||
|
@ -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_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 ||
|
||||
bt->rx->state == BT_SCO_STATE_ENDING) {
|
||||
if (bt->rx->xrun) {
|
||||
|
@ -1067,6 +1105,33 @@ static int btcvsd_band_set(struct snd_kcontrol *kcontrol,
|
|||
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,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
|
@ -1202,6 +1267,8 @@ static int btcvsd_tx_timestamp_get(struct snd_kcontrol *kcontrol,
|
|||
static const struct snd_kcontrol_new mtk_btcvsd_snd_controls[] = {
|
||||
SOC_ENUM_EXT("BTCVSD Band", btcvsd_enum[0],
|
||||
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,
|
||||
btcvsd_tx_mute_get, btcvsd_tx_mute_set),
|
||||
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)
|
|||
int m_sel_id = mck_div[mck_id].m_sel_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]);
|
||||
if (m_sel_id >= 0)
|
||||
clk_disable_unprepare(afe_priv->clk[m_sel_id]);
|
||||
|
|
|
@ -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[] = {
|
||||
{ "Playback Mixer", NULL, "Primary" },
|
||||
{ "Playback Mixer", NULL, "Secondary" },
|
||||
{ "Playback Mixer", NULL, "Primary Playback" },
|
||||
{ "Playback Mixer", NULL, "Secondary Playback" },
|
||||
|
||||
{ "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 = {
|
||||
|
@ -1155,7 +1155,8 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv,
|
|||
int num_dais)
|
||||
{
|
||||
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 i2s_dai *dai;
|
||||
int i;
|
||||
|
@ -1201,6 +1202,7 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv,
|
|||
dai_drv->capture.channels_max = 2;
|
||||
dai_drv->capture.rates = i2s_dai_data->pcm_rates;
|
||||
dai_drv->capture.formats = SAMSUNG_I2S_FMTS;
|
||||
dai_drv->capture.stream_name = "Primary Capture";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -91,11 +91,11 @@ static int odroid_card_be_hw_params(struct snd_pcm_substream *substream,
|
|||
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
|
||||
* 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);
|
||||
if (ret < 0)
|
||||
|
|
|
@ -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-gen2", .data = (void *)RSND_GEN2 },
|
||||
{ .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);
|
||||
|
|
|
@ -607,6 +607,8 @@ struct rsnd_priv {
|
|||
#define RSND_GEN1 (1 << 0)
|
||||
#define RSND_GEN2 (2 << 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()
|
||||
|
@ -679,6 +681,9 @@ struct rsnd_priv {
|
|||
#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_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_set(p, f) ((p)->flags |= (f))
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "rsnd.h"
|
||||
#include <linux/sys_soc.h>
|
||||
|
||||
#define SRC_NAME "src"
|
||||
|
||||
|
@ -189,18 +188,12 @@ static const u32 chan222222[] = {
|
|||
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,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
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 use_src = 0;
|
||||
u32 fin, fout;
|
||||
|
@ -307,7 +300,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
|
|||
/*
|
||||
* E3 need to overwrite
|
||||
*/
|
||||
if (soc)
|
||||
if (rsnd_is_e3(priv))
|
||||
switch (rsnd_mod_id(mod)) {
|
||||
case 0:
|
||||
case 4:
|
||||
|
|
|
@ -2797,6 +2797,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
|
|||
|
||||
ret = soc_init_dai_link(card, link);
|
||||
if (ret) {
|
||||
soc_cleanup_platform(card);
|
||||
dev_err(card->dev, "ASoC: failed to init link %s\n",
|
||||
link->name);
|
||||
mutex_unlock(&client_mutex);
|
||||
|
|
|
@ -954,10 +954,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
|
|||
codec_params = *params;
|
||||
|
||||
/* 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,
|
||||
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,
|
||||
codec_dai->rx_mask);
|
||||
|
||||
|
@ -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_dpcm *dpcm;
|
||||
unsigned long flags;
|
||||
|
||||
/* only add new dpcms */
|
||||
for_each_dpcm_be(fe, stream, dpcm) {
|
||||
|
@ -1228,10 +1232,10 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
|
|||
dpcm->fe = fe;
|
||||
be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
|
||||
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_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",
|
||||
stream ? "capture" : "playback", fe->dai_link->name,
|
||||
|
@ -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)
|
||||
{
|
||||
struct snd_soc_dpcm *dpcm, *d;
|
||||
unsigned long flags;
|
||||
|
||||
for_each_dpcm_be_safe(fe, stream, dpcm, d) {
|
||||
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)
|
|||
#ifdef CONFIG_DEBUG_FS
|
||||
debugfs_remove(dpcm->debugfs_state);
|
||||
#endif
|
||||
spin_lock(&fe->card->dpcm_lock);
|
||||
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
|
||||
list_del(&dpcm->list_be);
|
||||
list_del(&dpcm->list_fe);
|
||||
spin_unlock(&fe->card->dpcm_lock);
|
||||
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
|
||||
kfree(dpcm);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
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)
|
||||
dpcm->be->dpcm[stream].runtime_update =
|
||||
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,
|
||||
|
@ -2577,6 +2583,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
|
|||
struct snd_soc_dpcm *dpcm;
|
||||
enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
|
||||
int ret;
|
||||
unsigned long flags;
|
||||
|
||||
dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n",
|
||||
stream ? "capture" : "playback", fe->dai_link->name);
|
||||
|
@ -2646,13 +2653,13 @@ close:
|
|||
dpcm_be_dai_shutdown(fe, stream);
|
||||
disconnect:
|
||||
/* 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) {
|
||||
struct snd_soc_pcm_runtime *be = dpcm->be;
|
||||
if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
|
||||
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
|
||||
}
|
||||
spin_unlock(&fe->card->dpcm_lock);
|
||||
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -3230,8 +3237,9 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
|
|||
struct snd_soc_dpcm *dpcm;
|
||||
int state;
|
||||
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) {
|
||||
|
||||
if (dpcm->fe == fe)
|
||||
|
@ -3245,7 +3253,7 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
|
|||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock(&fe->card->dpcm_lock);
|
||||
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
|
||||
|
||||
/* it's safe to free/stop this BE DAI */
|
||||
return ret;
|
||||
|
@ -3262,8 +3270,9 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
|
|||
struct snd_soc_dpcm *dpcm;
|
||||
int state;
|
||||
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) {
|
||||
|
||||
if (dpcm->fe == fe)
|
||||
|
@ -3278,7 +3287,7 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
|
|||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock(&fe->card->dpcm_lock);
|
||||
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
|
||||
|
||||
/* it's safe to change hw_params */
|
||||
return ret;
|
||||
|
@ -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_soc_dpcm *dpcm;
|
||||
ssize_t offset = 0;
|
||||
unsigned long flags;
|
||||
|
||||
/* FE state */
|
||||
offset += snprintf(buf + offset, size - offset,
|
||||
|
@ -3347,7 +3357,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
|
|||
goto out;
|
||||
}
|
||||
|
||||
spin_lock(&fe->card->dpcm_lock);
|
||||
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
|
||||
for_each_dpcm_be(fe, stream, dpcm) {
|
||||
struct snd_soc_pcm_runtime *be = dpcm->be;
|
||||
params = &dpcm->hw_params;
|
||||
|
@ -3368,7 +3378,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
|
|||
params_channels(params),
|
||||
params_rate(params));
|
||||
}
|
||||
spin_unlock(&fe->card->dpcm_lock);
|
||||
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
|
||||
out:
|
||||
return offset;
|
||||
}
|
||||
|
|
|
@ -278,7 +278,6 @@ static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg)
|
|||
case STM32_I2S_CFG2_REG:
|
||||
case STM32_I2S_IER_REG:
|
||||
case STM32_I2S_SR_REG:
|
||||
case STM32_I2S_TXDR_REG:
|
||||
case STM32_I2S_RXDR_REG:
|
||||
case STM32_I2S_CGFR_REG:
|
||||
return true;
|
||||
|
@ -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)
|
||||
{
|
||||
switch (reg) {
|
||||
case STM32_I2S_TXDR_REG:
|
||||
case STM32_I2S_SR_REG:
|
||||
case STM32_I2S_RXDR_REG:
|
||||
return true;
|
||||
default:
|
||||
|
|
|
@ -105,6 +105,7 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
|
|||
if (!pdev) {
|
||||
dev_err(&sai_client->pdev->dev,
|
||||
"Device not found for node %pOFn\n", np_provider);
|
||||
of_node_put(np_provider);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -113,19 +114,20 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
|
|||
dev_err(&sai_client->pdev->dev,
|
||||
"SAI sync provider data not found\n");
|
||||
ret = -EINVAL;
|
||||
goto out_put_dev;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Configure sync client */
|
||||
ret = stm32_sai_sync_conf_client(sai_client, synci);
|
||||
if (ret < 0)
|
||||
goto out_put_dev;
|
||||
goto error;
|
||||
|
||||
/* Configure sync provider */
|
||||
ret = stm32_sai_sync_conf_provider(sai_provider, synco);
|
||||
|
||||
out_put_dev:
|
||||
error:
|
||||
put_device(&pdev->dev);
|
||||
of_node_put(np_provider);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,9 @@
|
|||
* @slot_mask: rx or tx active slots mask. set at init or at runtime
|
||||
* @data_size: PCM data width. corresponds to PCM substream width.
|
||||
* @spdif_frm_cnt: S/PDIF playback frame counter
|
||||
* @snd_aes_iec958: iec958 data
|
||||
* @iec958: iec958 data
|
||||
* @ctrl_lock: control lock
|
||||
* @irq_lock: prevent race condition with IRQ
|
||||
*/
|
||||
struct stm32_sai_sub_data {
|
||||
struct platform_device *pdev;
|
||||
|
@ -133,6 +134,7 @@ struct stm32_sai_sub_data {
|
|||
unsigned int spdif_frm_cnt;
|
||||
struct snd_aes_iec958 iec958;
|
||||
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 {
|
||||
|
@ -474,8 +476,10 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
|
|||
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);
|
||||
spin_unlock(&sai->irq_lock);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
@ -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);
|
||||
int imr, cr2, ret;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&sai->irq_lock, flags);
|
||||
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);
|
||||
if (ret < 0) {
|
||||
|
@ -898,7 +913,7 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai,
|
|||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
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;
|
||||
unsigned int rate = params_rate(params);
|
||||
|
||||
|
@ -943,13 +958,19 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai,
|
|||
} else {
|
||||
if (sai->mclk_rate) {
|
||||
mclk_ratio = sai->mclk_rate / rate;
|
||||
if ((mclk_ratio != 512) &&
|
||||
(mclk_ratio != 256)) {
|
||||
if (mclk_ratio == 512) {
|
||||
cr1 = SAI_XCR1_OSR;
|
||||
} else if (mclk_ratio != 256) {
|
||||
dev_err(cpu_dai->dev,
|
||||
"Wrong mclk ratio %d\n",
|
||||
mclk_ratio);
|
||||
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,
|
||||
sai->mclk_rate);
|
||||
if (div < 0)
|
||||
|
@ -1051,6 +1072,7 @@ static void stm32_sai_shutdown(struct snd_pcm_substream *substream,
|
|||
struct snd_soc_dai *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);
|
||||
|
||||
|
@ -1061,18 +1083,21 @@ static void stm32_sai_shutdown(struct snd_pcm_substream *substream,
|
|||
|
||||
clk_rate_exclusive_put(sai->sai_mclk);
|
||||
|
||||
spin_lock_irqsave(&sai->irq_lock, flags);
|
||||
sai->substream = NULL;
|
||||
spin_unlock_irqrestore(&sai->irq_lock, flags);
|
||||
}
|
||||
|
||||
static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_soc_dai *cpu_dai)
|
||||
{
|
||||
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)) {
|
||||
dev_dbg(&sai->pdev->dev, "%s: register iec controls", __func__);
|
||||
return snd_ctl_add(rtd->pcm->card,
|
||||
snd_ctl_new1(&iec958_ctls, sai));
|
||||
knew.device = rtd->pcm->device;
|
||||
return snd_ctl_add(rtd->pcm->card, snd_ctl_new1(&knew, sai));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -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)
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -1111,8 +1136,10 @@ static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai)
|
|||
/* Configure synchronization */
|
||||
if (sai->sync == SAI_SYNC_EXTERNAL) {
|
||||
/* Configure synchro client and provider */
|
||||
sai->pdata->set_sync(sai->pdata, sai->np_sync_provider,
|
||||
sai->synco, sai->synci);
|
||||
ret = sai->pdata->set_sync(sai->pdata, sai->np_sync_provider,
|
||||
sai->synco, sai->synci);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
cr1_mask |= SAI_XCR1_SYNCEN_MASK;
|
||||
|
@ -1424,6 +1451,7 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
|
|||
|
||||
sai->pdev = pdev;
|
||||
mutex_init(&sai->ctrl_lock);
|
||||
spin_lock_init(&sai->irq_lock);
|
||||
platform_set_drvdata(pdev, sai);
|
||||
|
||||
sai->pdata = dev_get_drvdata(pdev->dev.parent);
|
||||
|
|
Loading…
Reference in New Issue