Merge remote-tracking branches 'asoc/topic/ak4613', 'asoc/topic/ak4642', 'asoc/topic/atmel', 'asoc/topic/cs35l34' and 'asoc/topic/cs35l35' into asoc-next
This commit is contained in:
@@ -94,6 +94,8 @@ struct ak4613_interface {
|
||||
struct ak4613_priv {
|
||||
struct mutex lock;
|
||||
const struct ak4613_interface *iface;
|
||||
struct snd_pcm_hw_constraint_list constraint;
|
||||
unsigned int sysclk;
|
||||
|
||||
unsigned int fmt;
|
||||
u8 oc;
|
||||
@@ -139,9 +141,7 @@ static const struct reg_default ak4613_reg[] = {
|
||||
#define AUDIO_IFACE(b, fmt) { b, SND_SOC_DAIFMT_##fmt }
|
||||
static const struct ak4613_interface ak4613_iface[] = {
|
||||
/* capture */ /* playback */
|
||||
[0] = { AUDIO_IFACE(24, LEFT_J), AUDIO_IFACE(16, RIGHT_J) },
|
||||
[1] = { AUDIO_IFACE(24, LEFT_J), AUDIO_IFACE(20, RIGHT_J) },
|
||||
[2] = { AUDIO_IFACE(24, LEFT_J), AUDIO_IFACE(24, RIGHT_J) },
|
||||
/* [0] - [2] are not supported */
|
||||
[3] = { AUDIO_IFACE(24, LEFT_J), AUDIO_IFACE(24, LEFT_J) },
|
||||
[4] = { AUDIO_IFACE(24, I2S), AUDIO_IFACE(24, I2S) },
|
||||
};
|
||||
@@ -254,6 +254,74 @@ static void ak4613_dai_shutdown(struct snd_pcm_substream *substream,
|
||||
mutex_unlock(&priv->lock);
|
||||
}
|
||||
|
||||
static void ak4613_hw_constraints(struct ak4613_priv *priv,
|
||||
struct snd_pcm_runtime *runtime)
|
||||
{
|
||||
static const unsigned int ak4613_rates[] = {
|
||||
32000,
|
||||
44100,
|
||||
48000,
|
||||
64000,
|
||||
88200,
|
||||
96000,
|
||||
176400,
|
||||
192000,
|
||||
};
|
||||
struct snd_pcm_hw_constraint_list *constraint = &priv->constraint;
|
||||
unsigned int fs;
|
||||
int i;
|
||||
|
||||
constraint->list = ak4613_rates;
|
||||
constraint->mask = 0;
|
||||
constraint->count = 0;
|
||||
|
||||
/*
|
||||
* Slave Mode
|
||||
* Normal: [32kHz, 48kHz] : 256fs,384fs or 512fs
|
||||
* Double: [64kHz, 96kHz] : 256fs
|
||||
* Quad : [128kHz,192kHz]: 128fs
|
||||
*
|
||||
* Master mode
|
||||
* Normal: [32kHz, 48kHz] : 256fs or 512fs
|
||||
* Double: [64kHz, 96kHz] : 256fs
|
||||
* Quad : [128kHz,192kHz]: 128fs
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(ak4613_rates); i++) {
|
||||
/* minimum fs on each range */
|
||||
fs = (ak4613_rates[i] <= 96000) ? 256 : 128;
|
||||
|
||||
if (priv->sysclk >= ak4613_rates[i] * fs)
|
||||
constraint->count = i + 1;
|
||||
}
|
||||
|
||||
snd_pcm_hw_constraint_list(runtime, 0,
|
||||
SNDRV_PCM_HW_PARAM_RATE, constraint);
|
||||
}
|
||||
|
||||
static int ak4613_dai_startup(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec);
|
||||
|
||||
priv->cnt++;
|
||||
|
||||
ak4613_hw_constraints(priv, substream->runtime);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec);
|
||||
|
||||
priv->sysclk = freq;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
@@ -262,11 +330,9 @@ static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
fmt &= SND_SOC_DAIFMT_FORMAT_MASK;
|
||||
|
||||
switch (fmt) {
|
||||
case SND_SOC_DAIFMT_RIGHT_J:
|
||||
case SND_SOC_DAIFMT_LEFT_J:
|
||||
case SND_SOC_DAIFMT_I2S:
|
||||
priv->fmt = fmt;
|
||||
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -286,13 +352,8 @@ static bool ak4613_dai_fmt_matching(const struct ak4613_interface *iface,
|
||||
if (fmts->fmt != fmt)
|
||||
return false;
|
||||
|
||||
if (fmt == SND_SOC_DAIFMT_RIGHT_J) {
|
||||
if (fmts->width != width)
|
||||
return false;
|
||||
} else {
|
||||
if (fmts->width < width)
|
||||
return false;
|
||||
}
|
||||
if (fmts->width != width)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -319,6 +380,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
|
||||
case 48000:
|
||||
ctrl2 = DFS_NORMAL_SPEED;
|
||||
break;
|
||||
case 64000:
|
||||
case 88200:
|
||||
case 96000:
|
||||
ctrl2 = DFS_DOUBLE_SPEED;
|
||||
@@ -358,7 +420,6 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
|
||||
if ((priv->iface == NULL) ||
|
||||
(priv->iface == iface)) {
|
||||
priv->iface = iface;
|
||||
priv->cnt++;
|
||||
ret = 0;
|
||||
}
|
||||
mutex_unlock(&priv->lock);
|
||||
@@ -407,7 +468,9 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
static const struct snd_soc_dai_ops ak4613_dai_ops = {
|
||||
.startup = ak4613_dai_startup,
|
||||
.shutdown = ak4613_dai_shutdown,
|
||||
.set_sysclk = ak4613_dai_set_sysclk,
|
||||
.set_fmt = ak4613_dai_set_fmt,
|
||||
.hw_params = ak4613_dai_hw_params,
|
||||
};
|
||||
@@ -420,8 +483,7 @@ static const struct snd_soc_dai_ops ak4613_dai_ops = {
|
||||
SNDRV_PCM_RATE_96000 |\
|
||||
SNDRV_PCM_RATE_176400 |\
|
||||
SNDRV_PCM_RATE_192000)
|
||||
#define AK4613_PCM_FMTBIT (SNDRV_PCM_FMTBIT_S16_LE |\
|
||||
SNDRV_PCM_FMTBIT_S24_LE)
|
||||
#define AK4613_PCM_FMTBIT (SNDRV_PCM_FMTBIT_S24_LE)
|
||||
|
||||
static struct snd_soc_dai_driver ak4613_dai = {
|
||||
.name = "ak4613-hifi",
|
||||
@@ -527,6 +589,7 @@ static int ak4613_i2c_probe(struct i2c_client *i2c,
|
||||
|
||||
priv->iface = NULL;
|
||||
priv->cnt = 0;
|
||||
priv->sysclk = 0;
|
||||
|
||||
mutex_init(&priv->lock);
|
||||
|
||||
|
Reference in New Issue
Block a user