diff mbox

[06/13] ASoC: rsnd-dpcm-card: add .be_hw_params_fixup support for convert rate

Message ID 87twxpr8pm.wl%kuninori.morimoto.gx@renesas.com
State Needs Review / ACK, archived
Headers show

Checks

Context Check Description
robh/checkpatch warning total: 1 errors, 0 warnings, 0 lines checked
robh/patch-applied success

Commit Message

Kuninori Morimoto March 13, 2015, 1:24 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current rsnd-dpcm-card is supporting DPCM FE/BE sound card.
This patch adds .be_hw_params_fixup and enabled sampling convert rate.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../bindings/sound/renesas,rsnd-dpcm-card.txt      |  1 +
 sound/soc/sh/rcar/rsnd-dpcm-card.c                 | 27 ++++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd-dpcm-card.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd-dpcm-card.txt
index c79fe72..23b45d7 100644
--- a/Documentation/devicetree/bindings/sound/renesas,rsnd-dpcm-card.txt
+++ b/Documentation/devicetree/bindings/sound/renesas,rsnd-dpcm-card.txt
@@ -30,6 +30,7 @@  Optional subnode properties:
 					  dai-link uses bit clock inversion.
 - frame-inversion			: bool property. Add this if the
 					  dai-link uses frame clock inversion.
+- convert-rate				: platform specified sampling rate convert
 
 Required CPU/CODEC subnodes properties:
 
diff --git a/sound/soc/sh/rcar/rsnd-dpcm-card.c b/sound/soc/sh/rcar/rsnd-dpcm-card.c
index f3e70bf..1470af3 100644
--- a/sound/soc/sh/rcar/rsnd-dpcm-card.c
+++ b/sound/soc/sh/rcar/rsnd-dpcm-card.c
@@ -36,6 +36,7 @@  struct rdpcm_card_data {
 		struct rdpcm_dai cpu_dai;
 		struct rdpcm_dai codec_dai;
 	} dai_props[RDPCM_FB_NUM];
+	u32 convert_rate;
 	struct snd_soc_dai_link dai_link[RDPCM_FB_NUM];
 };
 
@@ -127,6 +128,21 @@  static int rdpcm_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 	return 0;
 }
 
+static int rdpcm_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+					 struct snd_pcm_hw_params *params)
+{
+	struct rdpcm_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
+	struct snd_interval *rate = hw_param_interval(params,
+						      SNDRV_PCM_HW_PARAM_RATE);
+
+	if (!priv->convert_rate)
+		return 0;
+
+	rate->min = rate->max = priv->convert_rate;
+
+	return 0;
+}
+
 static int
 rdpcm_card_sub_parse_of(struct device_node *np,
 			struct rdpcm_dai *dai,
@@ -319,6 +335,9 @@  static int rdpcm_card_dai_link_of(struct device_node *node,
 	dai_link->ops = &rdpcm_card_ops;
 	dai_link->init = rdpcm_card_dai_init;
 
+	if (idx == IDX_CODEC)
+		dai_link->be_hw_params_fixup = rdpcm_card_be_hw_params_fixup;
+
 	dev_dbg(dev, "\tname : %s\n", dai_link->stream_name);
 	dev_dbg(dev, "\tcpu : %s / %04x / %d\n",
 		dai_link->cpu_dai_name,
@@ -369,8 +388,12 @@  static int rdpcm_card_parse_of(struct device_node *node,
 			return ret;
 	}
 
-	dev_dbg(dev, "New rsnd-dpcm-card: %s\n", priv->snd_card.name ?
-		priv->snd_card.name : "");
+	/* sampling rate convert */
+	of_property_read_u32(node, "convert-rate", &priv->convert_rate);
+
+	dev_dbg(dev, "New rsnd-dpcm-card: %s (%d)\n",
+		priv->snd_card.name ? priv->snd_card.name : "",
+		priv->convert_rate);
 
 	/* FE/BE */
 	for (i = 0; i < RDPCM_FB_NUM; i++) {