Skip to content

Commit

Permalink
Support I2S 768kHz
Browse files Browse the repository at this point in the history
  • Loading branch information
blue777 committed Jan 30, 2018
1 parent 8ea2682 commit 6ca18e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
8 changes: 6 additions & 2 deletions linux_4.14.0_20171212/include/sound/pcm.h
Expand Up @@ -133,6 +133,8 @@ struct snd_pcm_ops {
#define SNDRV_PCM_RATE_192000 (1<<12) /* 192000Hz */
#define SNDRV_PCM_RATE_352800 (1<<13) /* 352800Hz */
#define SNDRV_PCM_RATE_384000 (1<<14) /* 384000Hz */
#define SNDRV_PCM_RATE_705600 (1<<15) /* 705600Hz */
#define SNDRV_PCM_RATE_768000 (1<<16) /* 768000Hz */

#define SNDRV_PCM_RATE_CONTINUOUS (1<<30) /* continuous range */
#define SNDRV_PCM_RATE_KNOT (1<<31) /* supports more non-continuos rates */
Expand All @@ -146,8 +148,10 @@ struct snd_pcm_ops {
#define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
SNDRV_PCM_RATE_192000)
#define SNDRV_PCM_RATE_8000_384000 (SNDRV_PCM_RATE_8000_192000 |\
SNDRV_PCM_RATE_352800 |\
SNDRV_PCM_RATE_384000)
SNDRV_PCM_RATE_352800 | SNDRV_PCM_RATE_384000)
#define SNDRV_PCM_RATE_8000_768000 (SNDRV_PCM_RATE_8000_384000 |\
SNDRV_PCM_RATE_705600 | SNDRV_PCM_RATE_768000)

#define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
#define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8)
#define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8)
Expand Down
4 changes: 2 additions & 2 deletions linux_4.14.0_20171212/sound/core/pcm_native.c
Expand Up @@ -2092,14 +2092,14 @@ static int snd_pcm_hw_rule_sample_bits(struct snd_pcm_hw_params *params,
return snd_interval_refine(hw_param_interval(params, rule->var), &t);
}

#if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_384000 != 1 << 14
#if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_768000 != 1 << 16
#error "Change this table"
#endif

static const unsigned int rates[] = {
5512, 8000, 11025, 16000, 22050, 32000, 44100,
48000, 64000, 88200, 96000, 176400, 192000,
352800, 384000
352800, 384000, 705600, 768000
};

const struct snd_pcm_hw_constraint_list snd_pcm_known_rates = {
Expand Down
2 changes: 1 addition & 1 deletion linux_4.14.0_20171212/sound/soc/codecs/pcm5102a.c
Expand Up @@ -25,7 +25,7 @@ static struct snd_soc_dai_driver pcm5102a_dai = {
.playback = {
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_384000,
.rates = SNDRV_PCM_RATE_8000_768000,
.formats = SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE
Expand Down
15 changes: 11 additions & 4 deletions linux_4.14.0_20171212/sound/soc/sunxi/sun8i-i2s.c
Expand Up @@ -250,6 +250,13 @@ static int sun8i_i2s_set_clock(struct priv *priv, unsigned long rate)
else
freq = 22579200;
div = freq / 2 / PCM_LRCK_PERIOD / rate;

if( div == 0 )
{
freq *= 2;
div = 1;
}

if (priv->type == SOC_A83T)
div /= 2; /* bclk_div==0 => mclk/2 */
for (i = 0; i < ARRAY_SIZE(div_tb) - 1; i++)
Expand Down Expand Up @@ -747,9 +754,9 @@ static struct snd_soc_dai_driver sun8i_i2s_dai = {
.stream_name = "Playback",
.channels_min = 1,
.channels_max = 8,
.rates = SNDRV_PCM_RATE_8000_384000 | SNDRV_PCM_RATE_KNOT,
.rates = SNDRV_PCM_RATE_8000_768000 | SNDRV_PCM_RATE_KNOT,
.rate_min = 8000,
.rate_max = 384000,
.rate_max = 768000,
.formats = I2S_FORMATS,
},
.ops = &sun8i_i2s_dai_ops,
Expand All @@ -767,9 +774,9 @@ static const struct snd_pcm_hardware sun8i_i2s_pcm_hardware = {
SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME,
.formats = I2S_FORMATS,
.rates = SNDRV_PCM_RATE_8000_384000 | SNDRV_PCM_RATE_KNOT,
.rates = SNDRV_PCM_RATE_8000_768000 | SNDRV_PCM_RATE_KNOT,
.rate_min = 8000,
.rate_max = 384000,
.rate_max = 768000,
.channels_min = 1,
.channels_max = 8,
.buffer_bytes_max = 1024 * 1024,
Expand Down

0 comments on commit 6ca18e9

Please sign in to comment.