Commit 38d408f5 authored by Mark Brown's avatar Mark Brown

ASoC: Intel: avs: Machine board fixes

Merge series from Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>:

Series of adjustments to machine board files. Use fixed format in boards
that were not using one. Fix clock handling.
parents e5e7e398 6206b2e7
...@@ -117,6 +117,26 @@ static void avs_da7219_codec_exit(struct snd_soc_pcm_runtime *rtd) ...@@ -117,6 +117,26 @@ static void avs_da7219_codec_exit(struct snd_soc_pcm_runtime *rtd)
snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL); snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL);
} }
static int
avs_da7219_be_fixup(struct snd_soc_pcm_runtime *runrime, struct snd_pcm_hw_params *params)
{
struct snd_interval *rate, *channels;
struct snd_mask *fmt;
rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
/* The ADSP will convert the FE rate to 48k, stereo */
rate->min = rate->max = 48000;
channels->min = channels->max = 2;
/* set SSP0 to 24 bit */
snd_mask_none(fmt);
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
return 0;
}
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
struct snd_soc_dai_link **dai_link) struct snd_soc_dai_link **dai_link)
{ {
...@@ -148,6 +168,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in ...@@ -148,6 +168,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->num_platforms = 1; dl->num_platforms = 1;
dl->id = 0; dl->id = 0;
dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS; dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
dl->be_hw_params_fixup = avs_da7219_be_fixup;
dl->init = avs_da7219_codec_init; dl->init = avs_da7219_codec_init;
dl->exit = avs_da7219_codec_exit; dl->exit = avs_da7219_codec_exit;
dl->nonatomic = 1; dl->nonatomic = 1;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
...@@ -24,6 +25,26 @@ static const struct snd_soc_dapm_route card_base_routes[] = { ...@@ -24,6 +25,26 @@ static const struct snd_soc_dapm_route card_base_routes[] = {
{ "Spk", NULL, "Speaker" }, { "Spk", NULL, "Speaker" },
}; };
static int
avs_max98357a_be_fixup(struct snd_soc_pcm_runtime *runrime, struct snd_pcm_hw_params *params)
{
struct snd_interval *rate, *channels;
struct snd_mask *fmt;
rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
/* The ADSP will convert the FE rate to 48k, stereo */
rate->min = rate->max = 48000;
channels->min = channels->max = 2;
/* set SSP0 to 16 bit */
snd_mask_none(fmt);
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
return 0;
}
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
struct snd_soc_dai_link **dai_link) struct snd_soc_dai_link **dai_link)
{ {
...@@ -55,6 +76,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in ...@@ -55,6 +76,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->num_platforms = 1; dl->num_platforms = 1;
dl->id = 0; dl->id = 0;
dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS; dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
dl->be_hw_params_fixup = avs_max98357a_be_fixup;
dl->nonatomic = 1; dl->nonatomic = 1;
dl->no_pcm = 1; dl->no_pcm = 1;
dl->dpcm_playback = 1; dl->dpcm_playback = 1;
......
...@@ -33,15 +33,15 @@ avs_nau8825_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *co ...@@ -33,15 +33,15 @@ avs_nau8825_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *co
return -EINVAL; return -EINVAL;
} }
if (!SND_SOC_DAPM_EVENT_ON(event)) { if (SND_SOC_DAPM_EVENT_ON(event))
ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_MCLK, 24000000,
SND_SOC_CLOCK_IN);
else
ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN); ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN);
if (ret < 0) { if (ret < 0)
dev_err(card->dev, "set sysclk err = %d\n", ret); dev_err(card->dev, "Set sysclk failed: %d\n", ret);
return ret;
}
}
return 0; return ret;
} }
static const struct snd_kcontrol_new card_controls[] = { static const struct snd_kcontrol_new card_controls[] = {
......
...@@ -169,6 +169,27 @@ static const struct snd_soc_ops avs_rt5682_ops = { ...@@ -169,6 +169,27 @@ static const struct snd_soc_ops avs_rt5682_ops = {
.hw_params = avs_rt5682_hw_params, .hw_params = avs_rt5682_hw_params,
}; };
static int
avs_rt5682_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params)
{
struct snd_interval *rate, *channels;
struct snd_mask *fmt;
rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
/* The ADSP will convert the FE rate to 48k, stereo */
rate->min = rate->max = 48000;
channels->min = channels->max = 2;
/* set SSPN to 24 bit */
snd_mask_none(fmt);
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
return 0;
}
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
struct snd_soc_dai_link **dai_link) struct snd_soc_dai_link **dai_link)
{ {
...@@ -201,6 +222,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in ...@@ -201,6 +222,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->id = 0; dl->id = 0;
dl->init = avs_rt5682_codec_init; dl->init = avs_rt5682_codec_init;
dl->exit = avs_rt5682_codec_exit; dl->exit = avs_rt5682_codec_exit;
dl->be_hw_params_fixup = avs_rt5682_be_fixup;
dl->ops = &avs_rt5682_ops; dl->ops = &avs_rt5682_ops;
dl->nonatomic = 1; dl->nonatomic = 1;
dl->no_pcm = 1; dl->no_pcm = 1;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../../../codecs/nau8825.h" #include "../../../codecs/nau8825.h"
#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
#define SKL_SSM_CODEC_DAI "ssm4567-hifi" #define SKL_SSM_CODEC_DAI "ssm4567-hifi"
static struct snd_soc_codec_conf card_codec_conf[] = { static struct snd_soc_codec_conf card_codec_conf[] = {
...@@ -34,41 +33,11 @@ static const struct snd_kcontrol_new card_controls[] = { ...@@ -34,41 +33,11 @@ static const struct snd_kcontrol_new card_controls[] = {
SOC_DAPM_PIN_SWITCH("Right Speaker"), SOC_DAPM_PIN_SWITCH("Right Speaker"),
}; };
static int
platform_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *control, int event)
{
struct snd_soc_dapm_context *dapm = w->dapm;
struct snd_soc_card *card = dapm->card;
struct snd_soc_dai *codec_dai;
int ret;
codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
if (!codec_dai) {
dev_err(card->dev, "Codec dai not found\n");
return -EINVAL;
}
if (SND_SOC_DAPM_EVENT_ON(event)) {
ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_MCLK, 24000000,
SND_SOC_CLOCK_IN);
if (ret < 0)
dev_err(card->dev, "set sysclk err = %d\n", ret);
} else {
ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN);
if (ret < 0)
dev_err(card->dev, "set sysclk err = %d\n", ret);
}
return ret;
}
static const struct snd_soc_dapm_widget card_widgets[] = { static const struct snd_soc_dapm_widget card_widgets[] = {
SND_SOC_DAPM_SPK("Left Speaker", NULL), SND_SOC_DAPM_SPK("Left Speaker", NULL),
SND_SOC_DAPM_SPK("Right Speaker", NULL), SND_SOC_DAPM_SPK("Right Speaker", NULL),
SND_SOC_DAPM_SPK("DP1", NULL), SND_SOC_DAPM_SPK("DP1", NULL),
SND_SOC_DAPM_SPK("DP2", NULL), SND_SOC_DAPM_SPK("DP2", NULL),
SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, platform_clock_control,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
}; };
static const struct snd_soc_dapm_route card_base_routes[] = { static const struct snd_soc_dapm_route card_base_routes[] = {
......
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