OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From 60e945e3c654aae415773a500b021914461ae928 Mon Sep 17 00:00:00 2001 |
2 | From: Matthias Reichl <hias@horus.com> |
||
3 | Date: Thu, 22 Feb 2018 11:55:06 +0100 |
||
4 | Subject: [PATCH 229/454] ASoC: pcm512x: implement set_tdm_slot interface |
||
5 | |||
6 | PCM512x can accept data padded with additional BCLK cycles |
||
7 | but the driver currently lacks an interface to configure this. |
||
8 | |||
9 | This leads to the problem that S24_LE format in master mode |
||
10 | can result in non-integer clock divisors and pcm512x running |
||
11 | at a rather off rate. |
||
12 | |||
13 | For example 48kHz with 48fs BCLK and SCLK at 24.576MHz uses |
||
14 | a divisor of 10 (rounded down from 10.6666) and results in a |
||
15 | 51.2kHz LRCLK. With 64fs BCLK a divisor of 8 is used and |
||
16 | LRCLK runs at exactly 48kHz. |
||
17 | |||
18 | Fix this by providing a minimal set_tdm_slot implementation |
||
19 | so machine drivers can optionally configure custom BCLK ratios. |
||
20 | |||
21 | Signed-off-by: Matthias Reichl <hias@horus.com> |
||
22 | --- |
||
23 | sound/soc/codecs/pcm512x.c | 28 +++++++++++++++++++++++++++- |
||
24 | 1 file changed, 27 insertions(+), 1 deletion(-) |
||
25 | |||
26 | --- a/sound/soc/codecs/pcm512x.c |
||
27 | +++ b/sound/soc/codecs/pcm512x.c |
||
28 | @@ -53,6 +53,7 @@ struct pcm512x_priv { |
||
29 | unsigned long overclock_pll; |
||
30 | unsigned long overclock_dac; |
||
31 | unsigned long overclock_dsp; |
||
32 | + int lrclk_div; |
||
33 | }; |
||
34 | |||
35 | /* |
||
36 | @@ -851,7 +852,10 @@ static int pcm512x_set_dividers(struct s |
||
37 | int fssp; |
||
38 | int gpio; |
||
39 | |||
40 | - lrclk_div = snd_soc_params_to_frame_size(params); |
||
41 | + if (pcm512x->lrclk_div) |
||
42 | + lrclk_div = pcm512x->lrclk_div; |
||
43 | + else |
||
44 | + lrclk_div = snd_soc_params_to_frame_size(params); |
||
45 | if (lrclk_div == 0) { |
||
46 | dev_err(dev, "No LRCLK?\n"); |
||
47 | return -EINVAL; |
||
48 | @@ -1319,10 +1323,32 @@ static int pcm512x_set_fmt(struct snd_so |
||
49 | return 0; |
||
50 | } |
||
51 | |||
52 | +static int pcm512x_set_tdm_slot(struct snd_soc_dai *dai, |
||
53 | + unsigned int tx_mask, unsigned int rx_mask, |
||
54 | + int slots, int width) |
||
55 | +{ |
||
56 | + struct snd_soc_codec *codec = dai->codec; |
||
57 | + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); |
||
58 | + |
||
59 | + switch (slots) { |
||
60 | + case 0: |
||
61 | + pcm512x->lrclk_div = 0; |
||
62 | + return 0; |
||
63 | + case 2: |
||
64 | + if (tx_mask != 0x03 || rx_mask != 0x03) |
||
65 | + return -EINVAL; |
||
66 | + pcm512x->lrclk_div = slots * width; |
||
67 | + return 0; |
||
68 | + default: |
||
69 | + return -EINVAL; |
||
70 | + } |
||
71 | +} |
||
72 | + |
||
73 | static const struct snd_soc_dai_ops pcm512x_dai_ops = { |
||
74 | .startup = pcm512x_dai_startup, |
||
75 | .hw_params = pcm512x_hw_params, |
||
76 | .set_fmt = pcm512x_set_fmt, |
||
77 | + .set_tdm_slot = pcm512x_set_tdm_slot, |
||
78 | }; |
||
79 | |||
80 | static struct snd_soc_dai_driver pcm512x_dai = { |