aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2016-02-04 11:29:01 -0500
committerMark Brown <broonie@kernel.org>2016-02-05 08:15:32 -0500
commitd81221ff9406a3918084bfaed752894e82c5d44b (patch)
tree90f8b069348383aab3c0c46ce07dd664382e4c36
parent3a9686c4ba7eec9201c6e8793705d32f24748771 (diff)
ASoC: arizona: Add support for SNDRV_PCM_RATE_KNOT
The Arizona CODECs support several rates that do not have simple defines in ALSA. This patch adds support for SNDRV_PCM_RATE_KNOT so that users can open stream at these rates. As part of this we should always set constraints in arizona_startup, currently we only set the constraints if we already have a clock to limit rates to that family of sample rates. This patch updates this to set a constraint of all rates supported by the chip if we do not already know which family of rates to limit to. Finally we also reduce the list of rates supported in the constraints to only include those that are supported on current parts. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/arizona.c62
-rw-r--r--sound/soc/codecs/arizona.h2
-rw-r--r--sound/soc/codecs/cs47l24.c2
-rw-r--r--sound/soc/codecs/wm5102.c2
-rw-r--r--sound/soc/codecs/wm5110.c2
-rw-r--r--sound/soc/codecs/wm8997.c2
-rw-r--r--sound/soc/codecs/wm8998.c2
7 files changed, 23 insertions, 51 deletions
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 33143fe1de0b..a32cfb85f1ca 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1398,29 +1398,6 @@ static const int arizona_48k_bclk_rates[] = {
1398 24576000, 1398 24576000,
1399}; 1399};
1400 1400
1401static const unsigned int arizona_48k_rates[] = {
1402 12000,
1403 24000,
1404 48000,
1405 96000,
1406 192000,
1407 384000,
1408 768000,
1409 4000,
1410 8000,
1411 16000,
1412 32000,
1413 64000,
1414 128000,
1415 256000,
1416 512000,
1417};
1418
1419static const struct snd_pcm_hw_constraint_list arizona_48k_constraint = {
1420 .count = ARRAY_SIZE(arizona_48k_rates),
1421 .list = arizona_48k_rates,
1422};
1423
1424static const int arizona_44k1_bclk_rates[] = { 1401static const int arizona_44k1_bclk_rates[] = {
1425 -1, 1402 -1,
1426 44100, 1403 44100,
@@ -1443,22 +1420,7 @@ static const int arizona_44k1_bclk_rates[] = {
1443 22579200, 1420 22579200,
1444}; 1421};
1445 1422
1446static const unsigned int arizona_44k1_rates[] = { 1423static const unsigned int arizona_sr_vals[] = {
1447 11025,
1448 22050,
1449 44100,
1450 88200,
1451 176400,
1452 352800,
1453 705600,
1454};
1455
1456static const struct snd_pcm_hw_constraint_list arizona_44k1_constraint = {
1457 .count = ARRAY_SIZE(arizona_44k1_rates),
1458 .list = arizona_44k1_rates,
1459};
1460
1461static int arizona_sr_vals[] = {
1462 0, 1424 0,
1463 12000, 1425 12000,
1464 24000, 1426 24000,
@@ -1485,13 +1447,21 @@ static int arizona_sr_vals[] = {
1485 512000, 1447 512000,
1486}; 1448};
1487 1449
1450#define ARIZONA_48K_RATE_MASK 0x0F003E
1451#define ARIZONA_44K1_RATE_MASK 0x003E00
1452#define ARIZONA_RATE_MASK (ARIZONA_48K_RATE_MASK | ARIZONA_44K1_RATE_MASK)
1453
1454static const struct snd_pcm_hw_constraint_list arizona_constraint = {
1455 .count = ARRAY_SIZE(arizona_sr_vals),
1456 .list = arizona_sr_vals,
1457};
1458
1488static int arizona_startup(struct snd_pcm_substream *substream, 1459static int arizona_startup(struct snd_pcm_substream *substream,
1489 struct snd_soc_dai *dai) 1460 struct snd_soc_dai *dai)
1490{ 1461{
1491 struct snd_soc_codec *codec = dai->codec; 1462 struct snd_soc_codec *codec = dai->codec;
1492 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); 1463 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
1493 struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; 1464 struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1];
1494 const struct snd_pcm_hw_constraint_list *constraint;
1495 unsigned int base_rate; 1465 unsigned int base_rate;
1496 1466
1497 if (!substream->runtime) 1467 if (!substream->runtime)
@@ -1509,16 +1479,15 @@ static int arizona_startup(struct snd_pcm_substream *substream,
1509 } 1479 }
1510 1480
1511 if (base_rate == 0) 1481 if (base_rate == 0)
1512 return 0; 1482 dai_priv->constraint.mask = ARIZONA_RATE_MASK;
1513 1483 else if (base_rate % 8000)
1514 if (base_rate % 8000) 1484 dai_priv->constraint.mask = ARIZONA_44K1_RATE_MASK;
1515 constraint = &arizona_44k1_constraint;
1516 else 1485 else
1517 constraint = &arizona_48k_constraint; 1486 dai_priv->constraint.mask = ARIZONA_48K_RATE_MASK;
1518 1487
1519 return snd_pcm_hw_constraint_list(substream->runtime, 0, 1488 return snd_pcm_hw_constraint_list(substream->runtime, 0,
1520 SNDRV_PCM_HW_PARAM_RATE, 1489 SNDRV_PCM_HW_PARAM_RATE,
1521 constraint); 1490 &dai_priv->constraint);
1522} 1491}
1523 1492
1524static void arizona_wm5102_set_dac_comp(struct snd_soc_codec *codec, 1493static void arizona_wm5102_set_dac_comp(struct snd_soc_codec *codec,
@@ -1911,6 +1880,7 @@ int arizona_init_dai(struct arizona_priv *priv, int id)
1911 struct arizona_dai_priv *dai_priv = &priv->dai[id]; 1880 struct arizona_dai_priv *dai_priv = &priv->dai[id];
1912 1881
1913 dai_priv->clk = ARIZONA_CLK_SYSCLK; 1882 dai_priv->clk = ARIZONA_CLK_SYSCLK;
1883 dai_priv->constraint = arizona_constraint;
1914 1884
1915 return 0; 1885 return 0;
1916} 1886}
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 0c64a5731513..1ea8e4ecf8d4 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -68,6 +68,8 @@ struct wm_adsp;
68 68
69struct arizona_dai_priv { 69struct arizona_dai_priv {
70 int clk; 70 int clk;
71
72 struct snd_pcm_hw_constraint_list constraint;
71}; 73};
72 74
73struct arizona_priv { 75struct arizona_priv {
diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c
index b8d3cd031d7d..576087bda330 100644
--- a/sound/soc/codecs/cs47l24.c
+++ b/sound/soc/codecs/cs47l24.c
@@ -923,7 +923,7 @@ static int cs47l24_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
923 } 923 }
924} 924}
925 925
926#define CS47L24_RATES SNDRV_PCM_RATE_8000_192000 926#define CS47L24_RATES SNDRV_PCM_RATE_KNOT
927 927
928#define CS47L24_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 928#define CS47L24_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
929 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 929 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index aa1e96ab4bd2..a8b3e3f701f9 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -1738,7 +1738,7 @@ static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
1738 } 1738 }
1739} 1739}
1740 1740
1741#define WM5102_RATES SNDRV_PCM_RATE_8000_192000 1741#define WM5102_RATES SNDRV_PCM_RATE_KNOT
1742 1742
1743#define WM5102_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 1743#define WM5102_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1744 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 1744 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 92b6a6a564df..aa47955b68af 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -2024,7 +2024,7 @@ static int wm5110_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
2024 } 2024 }
2025} 2025}
2026 2026
2027#define WM5110_RATES SNDRV_PCM_RATE_8000_192000 2027#define WM5110_RATES SNDRV_PCM_RATE_KNOT
2028 2028
2029#define WM5110_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 2029#define WM5110_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
2030 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 2030 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c
index b4dba3a02aba..52d766efe14f 100644
--- a/sound/soc/codecs/wm8997.c
+++ b/sound/soc/codecs/wm8997.c
@@ -943,7 +943,7 @@ static int wm8997_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
943 } 943 }
944} 944}
945 945
946#define WM8997_RATES SNDRV_PCM_RATE_8000_192000 946#define WM8997_RATES SNDRV_PCM_RATE_KNOT
947 947
948#define WM8997_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 948#define WM8997_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
949 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 949 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
diff --git a/sound/soc/codecs/wm8998.c b/sound/soc/codecs/wm8998.c
index 7719bc509e50..012396074a8a 100644
--- a/sound/soc/codecs/wm8998.c
+++ b/sound/soc/codecs/wm8998.c
@@ -1170,7 +1170,7 @@ static const struct snd_soc_dapm_route wm8998_dapm_routes[] = {
1170 { "DRC1 Signal Activity", NULL, "DRC1R" }, 1170 { "DRC1 Signal Activity", NULL, "DRC1R" },
1171}; 1171};
1172 1172
1173#define WM8998_RATES SNDRV_PCM_RATE_8000_192000 1173#define WM8998_RATES SNDRV_PCM_RATE_KNOT
1174 1174
1175#define WM8998_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 1175#define WM8998_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1176 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 1176 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)