alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Moise Gergaud <moise.gergaud@st.com>
To: arnaud.pouliquen@st.com, alsa-devel@alsa-project.org,
	broonie@kernel.org, lgirdwood@gmail.com, tiwai@suse.de
Subject: [PATCH v2 5/7] ASoC: sti: helper functions to fix tdm runtime params
Date: Thu, 7 Apr 2016 11:25:34 +0200	[thread overview]
Message-ID: <1460021136-27822-6-git-send-email-moise.gergaud@st.com> (raw)
In-Reply-To: <1460021136-27822-1-git-send-email-moise.gergaud@st.com>

Signed-off-by: Moise Gergaud <moise.gergaud@st.com>
Acked-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 sound/soc/sti/sti_uniperif.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/sti/uniperif.h     |  6 ++++++
 2 files changed, 52 insertions(+)

diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c
index 0c2474c..d49bade 100644
--- a/sound/soc/sti/sti_uniperif.c
+++ b/sound/soc/sti/sti_uniperif.c
@@ -59,6 +59,52 @@ int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
 	return 0;
 }
 
+int sti_uniperiph_fix_tdm_chan(struct snd_pcm_hw_params *params,
+			       struct snd_pcm_hw_rule *rule)
+{
+	struct uniperif *uni = rule->private;
+	struct snd_interval t;
+
+	t.min = uni->tdm_slot.avail_slots;
+	t.max = uni->tdm_slot.avail_slots;
+	t.openmin = 0;
+	t.openmax = 0;
+	t.integer = 0;
+
+	return snd_interval_refine(hw_param_interval(params, rule->var), &t);
+}
+
+int sti_uniperiph_fix_tdm_format(struct snd_pcm_hw_params *params,
+				 struct snd_pcm_hw_rule *rule)
+{
+	struct uniperif *uni = rule->private;
+	struct snd_mask *maskp = hw_param_mask(params, rule->var);
+	u64 format;
+
+	switch (uni->tdm_slot.slot_width) {
+	case 16:
+		format = SNDRV_PCM_FMTBIT_S16_LE;
+		break;
+	case 32:
+		format = SNDRV_PCM_FMTBIT_S32_LE;
+		break;
+	default:
+		dev_err(uni->dev, "format not supported: %d bits\n",
+			uni->tdm_slot.slot_width);
+		return -EINVAL;
+	}
+
+	maskp->bits[0] &= (u_int32_t)format;
+	maskp->bits[1] &= (u_int32_t)(format >> 32);
+	/* clear remaining indexes */
+	memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX - 64) / 8);
+
+	if (!maskp->bits[0] && !maskp->bits[1])
+		return -EINVAL;
+
+	return 0;
+}
+
 int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni,
 				   unsigned int *word_pos)
 {
diff --git a/sound/soc/sti/uniperif.h b/sound/soc/sti/uniperif.h
index fb8e427..17d5d10 100644
--- a/sound/soc/sti/uniperif.h
+++ b/sound/soc/sti/uniperif.h
@@ -1396,4 +1396,10 @@ int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
 int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni,
 				   unsigned int *word_pos);
 
+int sti_uniperiph_fix_tdm_chan(struct snd_pcm_hw_params *params,
+			       struct snd_pcm_hw_rule *rule);
+
+int sti_uniperiph_fix_tdm_format(struct snd_pcm_hw_params *params,
+				 struct snd_pcm_hw_rule *rule);
+
 #endif
-- 
1.9.1

  parent reply	other threads:[~2016-04-07  9:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07  9:25 [PATCH v2 0/7] ASoC: sti: unip tdm mode Moise Gergaud
2016-04-07  9:25 ` [PATCH v2 1/7] ASoC: sti: macro for uniperif tdm regs access Moise Gergaud
2016-04-12  2:01   ` Applied "ASoC: sti: macro for uniperif tdm regs access" to the asoc tree Mark Brown
2016-04-07  9:25 ` [PATCH v2 2/7] ASoC: sti: rename unip player type into common player & reader type Moise Gergaud
2016-04-12  2:01   ` Applied "ASoC: sti: rename unip player type into common player & reader type" to the asoc tree Mark Brown
2016-04-07  9:25 ` [PATCH v2 3/7] ASoC: sti: define tdm type & default tdm hw config Moise Gergaud
2016-04-12  2:00   ` Applied "ASoC: sti: define tdm type & default tdm hw config" to the asoc tree Mark Brown
2016-04-07  9:25 ` [PATCH v2 4/7] ASoC: sti: helper functions for unip tdm slots configuration Moise Gergaud
2016-04-12  6:31   ` Applied "ASoC: sti: helper functions for unip tdm slots configuration" to the asoc tree Mark Brown
2016-04-07  9:25 ` Moise Gergaud [this message]
2016-04-12  6:31   ` Applied "ASoC: sti: helper functions to fix tdm runtime params" " Mark Brown
2016-04-07  9:25 ` [PATCH v2 6/7] ASoC: sti: unip player tdm mode Moise Gergaud
2016-04-12  6:31   ` Applied "ASoC: sti: unip player tdm mode" to the asoc tree Mark Brown
2016-04-07  9:25 ` [PATCH v2 7/7] ASoC: sti: unip reader tdm mode Moise Gergaud
2016-04-12  6:30   ` Applied "ASoC: sti: unip reader tdm mode" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460021136-27822-6-git-send-email-moise.gergaud@st.com \
    --to=moise.gergaud@st.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnaud.pouliquen@st.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).