ASoC: sti: unip tdm mode
Subsystems (3)
v2 cover ASoC: sti: unip tdm mode
This patchset is V2 of "ASoC: sti: tdm: uni tdm mode" V2 consists of splitting the V1 patch into 7 patches.
Moise Gergaud (7):
ASoC: sti: macro for uniperif tdm regs access
ASoC: sti: rename unip player type into common player & reader type
ASoC: sti: define tdm type & default tdm hw config
ASoC: sti: helper functions for unip tdm slots configuration
ASoC: sti: helper functions to fix tdm runtime params
ASoC: sti: unip player tdm mode
ASoC: sti: unip reader tdm mode
sound/soc/sti/sti_uniperif.c | 144 ++++++++++++++++++++++++- sound/soc/sti/uniperif.h | 197 +++++++++++++++++++++++++++++++++- sound/soc/sti/uniperif_player.c | 140 +++++++++++++++++------- sound/soc/sti/uniperif_reader.c | 229 +++++++++++++++++++++++++++++----------- 4 files changed, 606 insertions(+), 104 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/7 ASoC: sti: macro for uniperif tdm regs access
--- sound/soc/sti/uniperif.h | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+)
sound/soc/sti/uniperif.h +112 -0
@@ -1101,6 +1101,118 @@ UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip), value)/* +* UNIPERIF_TDM_ENABLE +*/ +#define UNIPERIF_TDM_ENABLE_OFFSET (ip) 0x0118 +#define GET_UNIPERIF_TDM_ENABLE (ip) \ + readl_relaxed(ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip)) +#define SET_UNIPERIF_TDM_ENABLE (ip, value) \ + writel_relaxed(value, ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip)) + +/* TDM_ENABLE */ +#define UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT (ip) 0x0 +#define UNIPERIF_TDM_ENABLE_EN_TDM_MASK (ip) 0x1 +#define GET_UNIPERIF_TDM_ENABLE_EN_TDM (ip) \ + GET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_ENABLE_OFFSET(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip)) +#define SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_ENABLE_OFFSET(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 1) +#define SET_UNIPERIF_TDM_ENABLE_TDM_DISABLE (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_ENABLE_OFFSET(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 0) + +/* +* UNIPERIF_TDM_FS_REF_FREQ +*/ +#define UNIPERIF_TDM_FS_REF_FREQ_OFFSET (ip) 0x011c +#define GET_UNIPERIF_TDM_FS_REF_FREQ (ip) \ + readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ (ip, value) \ + writel_relaxed(value, ip->base + \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip)) + +/* REF_FREQ */ +#define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT (ip) 0x0 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ (ip) 0 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ (ip) 1 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ (ip) 2 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ (ip) 3 +#define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK (ip) 0x3 +#define GET_UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ (ip) \ + GET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_8KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_16KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_32KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_48KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip)) + +/* +* UNIPERIF_TDM_FS_REF_DIV +*/ +#define UNIPERIF_TDM_FS_REF_DIV_OFFSET (ip) 0x0120 +#define GET_UNIPERIF_TDM_FS_REF_DIV (ip) \ + readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip)) +#define SET_UNIPERIF_TDM_FS_REF_DIV (ip, value) \ + writel_relaxed(value, ip->base + \ + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip)) + +/* NUM_TIMESLOT */ +#define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT (ip) 0x0 +#define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK (ip) 0xff +#define GET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT (ip) \ + GET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip)) +#define SET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT (ip, value) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip), value) + +/* +* UNIPERIF_TDM_WORD_POS_X_Y +* 32 bits of UNIPERIF_TDM_WORD_POS_X_Y register shall be set in 1 shot +*/ +#define UNIPERIF_TDM_WORD_POS_1_2_OFFSET (ip) 0x013c +#define UNIPERIF_TDM_WORD_POS_3_4_OFFSET (ip) 0x0140 +#define UNIPERIF_TDM_WORD_POS_5_6_OFFSET (ip) 0x0144 +#define UNIPERIF_TDM_WORD_POS_7_8_OFFSET (ip) 0x0148 +#define GET_UNIPERIF_TDM_WORD_POS (ip, words) \ + readl_relaxed(ip->base + UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip)) +#define SET_UNIPERIF_TDM_WORD_POS (ip, words, value) \ + writel_relaxed(value, ip->base + \ + UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip)) +/* * uniperipheral IP capabilities */
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: sti: macro for uniperif tdm regs access" to the asoc tree
The patch
ASoC: sti: macro for uniperif tdm regs access
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
38535e8e6962405b7d8a365f2f367f62bca98565Mon Sep 17 00:00:00 2001
From: Moise Gergaud <[email protected]>
Date: Thu, 7 Apr 2016 11:25:30 +0200
Subject: [PATCH] ASoC: sti: macro for uniperif tdm regs access
--- sound/soc/sti/uniperif.h | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+)
sound/soc/sti/uniperif.h +112 -0
@@ -1101,6 +1101,118 @@ UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip), value)/* +* UNIPERIF_TDM_ENABLE +*/ +#define UNIPERIF_TDM_ENABLE_OFFSET (ip) 0x0118 +#define GET_UNIPERIF_TDM_ENABLE (ip) \ + readl_relaxed(ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip)) +#define SET_UNIPERIF_TDM_ENABLE (ip, value) \ + writel_relaxed(value, ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip)) + +/* TDM_ENABLE */ +#define UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT (ip) 0x0 +#define UNIPERIF_TDM_ENABLE_EN_TDM_MASK (ip) 0x1 +#define GET_UNIPERIF_TDM_ENABLE_EN_TDM (ip) \ + GET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_ENABLE_OFFSET(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip)) +#define SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_ENABLE_OFFSET(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 1) +#define SET_UNIPERIF_TDM_ENABLE_TDM_DISABLE (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_ENABLE_OFFSET(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \ + UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 0) + +/* +* UNIPERIF_TDM_FS_REF_FREQ +*/ +#define UNIPERIF_TDM_FS_REF_FREQ_OFFSET (ip) 0x011c +#define GET_UNIPERIF_TDM_FS_REF_FREQ (ip) \ + readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ (ip, value) \ + writel_relaxed(value, ip->base + \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip)) + +/* REF_FREQ */ +#define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT (ip) 0x0 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ (ip) 0 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ (ip) 1 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ (ip) 2 +#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ (ip) 3 +#define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK (ip) 0x3 +#define GET_UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ (ip) \ + GET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_8KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_16KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_32KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip)) +#define SET_UNIPERIF_TDM_FS_REF_FREQ_48KHZ (ip) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \ + VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip)) + +/* +* UNIPERIF_TDM_FS_REF_DIV +*/ +#define UNIPERIF_TDM_FS_REF_DIV_OFFSET (ip) 0x0120 +#define GET_UNIPERIF_TDM_FS_REF_DIV (ip) \ + readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip)) +#define SET_UNIPERIF_TDM_FS_REF_DIV (ip, value) \ + writel_relaxed(value, ip->base + \ + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip)) + +/* NUM_TIMESLOT */ +#define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT (ip) 0x0 +#define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK (ip) 0xff +#define GET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT (ip) \ + GET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip)) +#define SET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT (ip, value) \ + SET_UNIPERIF_REG(ip, \ + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \ + UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip), value) + +/* +* UNIPERIF_TDM_WORD_POS_X_Y +* 32 bits of UNIPERIF_TDM_WORD_POS_X_Y register shall be set in 1 shot +*/ +#define UNIPERIF_TDM_WORD_POS_1_2_OFFSET (ip) 0x013c +#define UNIPERIF_TDM_WORD_POS_3_4_OFFSET (ip) 0x0140 +#define UNIPERIF_TDM_WORD_POS_5_6_OFFSET (ip) 0x0144 +#define UNIPERIF_TDM_WORD_POS_7_8_OFFSET (ip) 0x0148 +#define GET_UNIPERIF_TDM_WORD_POS (ip, words) \ + readl_relaxed(ip->base + UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip)) +#define SET_UNIPERIF_TDM_WORD_POS (ip, words, value) \ + writel_relaxed(value, ip->base + \ + UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip)) +/* * uniperipheral IP capabilities */
Signature · 1 line
2.8.0.rc3
PATCH v2 2/7 ASoC: sti: rename unip player type into common player & reader type
In reply to Moise Gergaud--- sound/soc/sti/uniperif.h | 19 ++++++++++++++----- sound/soc/sti/uniperif_player.c | 31 +++++++++++-------------------- 2 files changed, 25 insertions(+), 25 deletions(-)
sound/soc/sti/uniperif.h +14 -5
@@ -1219,6 +1219,15 @@#define UNIPERIF_FIFO_SIZE 70/* FIFO is 70 cells deep */ #define UNIPERIF_FIFO_FRAMES 4/* FDMA trigger limit in frames */ +#define UNIPERIF_TYPE_IS_HDMI (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_HDMI) +#define UNIPERIF_TYPE_IS_PCM (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_PCM) +#define UNIPERIF_TYPE_IS_SPDIF (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_SPDIF) +#define UNIPERIF_TYPE_IS_IEC958 (p) \ + (UNIPERIF_TYPE_IS_HDMI(p) || \ + UNIPERIF_TYPE_IS_SPDIF(p))/* * Uniperipheral IP revisions */
@@ -1237,10 +1246,10 @@ enum uniperif_version { };enum uniperif_type { -SND_ST_UNIPERIF_PLAYER_TYPE_NONE , -SND_ST_UNIPERIF_PLAYER_TYPE_HDMI , -SND_ST_UNIPERIF_PLAYER_TYPE_PCM , -SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF +SND_ST_UNIPERIF_TYPE_NONE , +SND_ST_UNIPERIF_TYPE_HDMI , +SND_ST_UNIPERIF_TYPE_PCM , +SND_ST_UNIPERIF_TYPE_SPDIF };enum uniperif_state {
@@ -1259,7 +1268,7 @@ enum uniperif_iec958_encoding_mode {struct uniperif_info {int id;/* instance value of the uniperipheral IP */ -enum uniperif_type player_type; +enum uniperif_type type;int underflow_enabled;/* Underflow recovery mode */ };
sound/soc/sti/uniperif_player.c +11 -20
@@ -26,15 +26,6 @@/* * Driver specific types. */ -#define UNIPERIF_PLAYER_TYPE_IS_HDMI (p) \ - ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_HDMI) -#define UNIPERIF_PLAYER_TYPE_IS_PCM (p) \ - ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_PCM) -#define UNIPERIF_PLAYER_TYPE_IS_SPDIF (p) \ - ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF) -#define UNIPERIF_PLAYER_TYPE_IS_IEC958 (p) \ - (UNIPERIF_PLAYER_TYPE_IS_HDMI(p) || \ - UNIPERIF_PLAYER_TYPE_IS_SPDIF(p))#define UNIPERIF_PLAYER_CLK_ADJ_MIN -999999#define UNIPERIF_PLAYER_CLK_ADJ_MAX 1000000
@@ -738,14 +729,14 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT (player, trigger_limit);/* Uniperipheral setup depends on player type */ -switch (player->info->player_type) { -case SND_ST_UNIPERIF_PLAYER_TYPE_HDMI : +switch (player->info->type) { +case SND_ST_UNIPERIF_TYPE_HDMI : ret =uni_player_prepare_iec958 (player, runtime);break ; -case SND_ST_UNIPERIF_PLAYER_TYPE_PCM : +case SND_ST_UNIPERIF_TYPE_PCM : ret =uni_player_prepare_pcm (player, runtime);break ; -case SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF : +case SND_ST_UNIPERIF_TYPE_SPDIF : ret =uni_player_prepare_iec958 (player, runtime);break ;default :
@@ -852,8 +843,8 @@ static int uni_player_start(struct uniperif *player)* will not take affect and hang the player. */ if (player->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ) -if (UNIPERIF_PLAYER_TYPE_IS_IEC958 (player)) -SET_UNIPERIF_CTRL_SPDIF_FMT_ON (player); +if (UNIPERIF_TYPE_IS_IEC958 (player)) +SET_UNIPERIF_CTRL_SPDIF_FMT_ON (player);/* Force channel status update (no update if clk disable) */ if (player->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 )
@@ -1012,13 +1003,13 @@ static int uni_player_parse_dt(struct platform_device *pdev, }if (strcasecmp (mode,"hdmi" ) ==0 ) - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_HDMI ; + info->type =SND_ST_UNIPERIF_TYPE_HDMI ;else if (strcasecmp (mode,"pcm" ) ==0 ) - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_PCM ; + info->type =SND_ST_UNIPERIF_TYPE_PCM ;else if (strcasecmp (mode,"spdif" ) ==0 ) - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF ; + info->type =SND_ST_UNIPERIF_TYPE_SPDIF ;else - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_NONE ; + info->type =SND_ST_UNIPERIF_TYPE_NONE ;/* Save the info structure */ player->info = info;
@@ -1087,7 +1078,7 @@ int uni_player_init(struct platform_device *pdev,SET_UNIPERIF_CTRL_SPDIF_LAT_OFF (player);SET_UNIPERIF_CONFIG_IDLE_MOD_DISABLE (player); -if (UNIPERIF_PLAYER_TYPE_IS_IEC958 (player)) { +if (UNIPERIF_TYPE_IS_IEC958 (player)) {/* Set default iec958 status bits */ /* Consumer, PCM, copyright, 2ch, mode 0 */
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: sti: rename unip player type into common player & reader type" to the asoc tree
The patch
ASoC: sti: rename unip player type into common player & reader type
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
5295a0dc31d5261ff64406ece25e8d9e91530d2eMon Sep 17 00:00:00 2001
From: Moise Gergaud <[email protected]>
Date: Thu, 7 Apr 2016 11:25:31 +0200
Subject: [PATCH] ASoC: sti: rename unip player type into common player &
reader type
--- sound/soc/sti/uniperif.h | 19 ++++++++++++++----- sound/soc/sti/uniperif_player.c | 31 +++++++++++-------------------- 2 files changed, 25 insertions(+), 25 deletions(-)
sound/soc/sti/uniperif.h +14 -5
@@ -1219,6 +1219,15 @@#define UNIPERIF_FIFO_SIZE 70/* FIFO is 70 cells deep */ #define UNIPERIF_FIFO_FRAMES 4/* FDMA trigger limit in frames */ +#define UNIPERIF_TYPE_IS_HDMI (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_HDMI) +#define UNIPERIF_TYPE_IS_PCM (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_PCM) +#define UNIPERIF_TYPE_IS_SPDIF (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_SPDIF) +#define UNIPERIF_TYPE_IS_IEC958 (p) \ + (UNIPERIF_TYPE_IS_HDMI(p) || \ + UNIPERIF_TYPE_IS_SPDIF(p))/* * Uniperipheral IP revisions */
@@ -1237,10 +1246,10 @@ enum uniperif_version { };enum uniperif_type { -SND_ST_UNIPERIF_PLAYER_TYPE_NONE , -SND_ST_UNIPERIF_PLAYER_TYPE_HDMI , -SND_ST_UNIPERIF_PLAYER_TYPE_PCM , -SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF +SND_ST_UNIPERIF_TYPE_NONE , +SND_ST_UNIPERIF_TYPE_HDMI , +SND_ST_UNIPERIF_TYPE_PCM , +SND_ST_UNIPERIF_TYPE_SPDIF };enum uniperif_state {
@@ -1259,7 +1268,7 @@ enum uniperif_iec958_encoding_mode {struct uniperif_info {int id;/* instance value of the uniperipheral IP */ -enum uniperif_type player_type; +enum uniperif_type type;int underflow_enabled;/* Underflow recovery mode */ };
sound/soc/sti/uniperif_player.c +11 -20
@@ -26,15 +26,6 @@/* * Driver specific types. */ -#define UNIPERIF_PLAYER_TYPE_IS_HDMI (p) \ - ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_HDMI) -#define UNIPERIF_PLAYER_TYPE_IS_PCM (p) \ - ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_PCM) -#define UNIPERIF_PLAYER_TYPE_IS_SPDIF (p) \ - ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF) -#define UNIPERIF_PLAYER_TYPE_IS_IEC958 (p) \ - (UNIPERIF_PLAYER_TYPE_IS_HDMI(p) || \ - UNIPERIF_PLAYER_TYPE_IS_SPDIF(p))#define UNIPERIF_PLAYER_CLK_ADJ_MIN -999999#define UNIPERIF_PLAYER_CLK_ADJ_MAX 1000000
@@ -738,14 +729,14 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT (player, trigger_limit);/* Uniperipheral setup depends on player type */ -switch (player->info->player_type) { -case SND_ST_UNIPERIF_PLAYER_TYPE_HDMI : +switch (player->info->type) { +case SND_ST_UNIPERIF_TYPE_HDMI : ret =uni_player_prepare_iec958 (player, runtime);break ; -case SND_ST_UNIPERIF_PLAYER_TYPE_PCM : +case SND_ST_UNIPERIF_TYPE_PCM : ret =uni_player_prepare_pcm (player, runtime);break ; -case SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF : +case SND_ST_UNIPERIF_TYPE_SPDIF : ret =uni_player_prepare_iec958 (player, runtime);break ;default :
@@ -852,8 +843,8 @@ static int uni_player_start(struct uniperif *player)* will not take affect and hang the player. */ if (player->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ) -if (UNIPERIF_PLAYER_TYPE_IS_IEC958 (player)) -SET_UNIPERIF_CTRL_SPDIF_FMT_ON (player); +if (UNIPERIF_TYPE_IS_IEC958 (player)) +SET_UNIPERIF_CTRL_SPDIF_FMT_ON (player);/* Force channel status update (no update if clk disable) */ if (player->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 )
@@ -1012,13 +1003,13 @@ static int uni_player_parse_dt(struct platform_device *pdev, }if (strcasecmp (mode,"hdmi" ) ==0 ) - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_HDMI ; + info->type =SND_ST_UNIPERIF_TYPE_HDMI ;else if (strcasecmp (mode,"pcm" ) ==0 ) - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_PCM ; + info->type =SND_ST_UNIPERIF_TYPE_PCM ;else if (strcasecmp (mode,"spdif" ) ==0 ) - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF ; + info->type =SND_ST_UNIPERIF_TYPE_SPDIF ;else - info->player_type =SND_ST_UNIPERIF_PLAYER_TYPE_NONE ; + info->type =SND_ST_UNIPERIF_TYPE_NONE ;/* Save the info structure */ player->info = info;
@@ -1087,7 +1078,7 @@ int uni_player_init(struct platform_device *pdev,SET_UNIPERIF_CTRL_SPDIF_LAT_OFF (player);SET_UNIPERIF_CONFIG_IDLE_MOD_DISABLE (player); -if (UNIPERIF_PLAYER_TYPE_IS_IEC958 (player)) { +if (UNIPERIF_TYPE_IS_IEC958 (player)) {/* Set default iec958 status bits */ /* Consumer, PCM, copyright, 2ch, mode 0 */
Signature · 1 line
2.8.0.rc3
PATCH v2 3/7 ASoC: sti: define tdm type & default tdm hw config
In reply to Moise Gergaud--- sound/soc/sti/uniperif.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
sound/soc/sti/uniperif.h +27 -1
@@ -1228,6 +1228,9 @@#define UNIPERIF_TYPE_IS_IEC958 (p) \ (UNIPERIF_TYPE_IS_HDMI(p) || \ UNIPERIF_TYPE_IS_SPDIF(p)) +#define UNIPERIF_TYPE_IS_TDM (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_TDM) +/* * Uniperipheral IP revisions */
@@ -1249,7 +1252,8 @@ enum uniperif_type {SND_ST_UNIPERIF_TYPE_NONE ,SND_ST_UNIPERIF_TYPE_HDMI ,SND_ST_UNIPERIF_TYPE_PCM , -SND_ST_UNIPERIF_TYPE_SPDIF +SND_ST_UNIPERIF_TYPE_SPDIF , +SND_ST_UNIPERIF_TYPE_TDM }; enum uniperif_state {
@@ -1330,6 +1334,28 @@ struct sti_uniperiph_data {struct sti_uniperiph_dai dai_data; }; +static const struct snd_pcm_hardware uni_tdm_hw = { + .info =SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_BLOCK_TRANSFER | +SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_MMAP | +SNDRV_PCM_INFO_MMAP_VALID , + + .formats =SNDRV_PCM_FMTBIT_S32_LE |SNDRV_PCM_FMTBIT_S16_LE , + + .rates =SNDRV_PCM_RATE_CONTINUOUS , + .rate_min =8000 , + .rate_max =48000 , + + .channels_min =1 , + .channels_max =32 , + + .periods_min =2 , + .periods_max =10 , + + .period_bytes_min =128 , + .period_bytes_max =64 *PAGE_SIZE , + .buffer_bytes_max =256 *PAGE_SIZE +}; +/* uniperiph player*/ int uni_player_init (struct platform_device *pdev,struct uniperif *uni_player);
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: sti: define tdm type & default tdm hw config" to the asoc tree
The patch
ASoC: sti: define tdm type & default tdm hw config
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
9a00a3e9fea1ea5affa7bea971299d3a5832daadMon Sep 17 00:00:00 2001
From: Moise Gergaud <[email protected]>
Date: Thu, 7 Apr 2016 11:25:32 +0200
Subject: [PATCH] ASoC: sti: define tdm type & default tdm hw config
--- sound/soc/sti/uniperif.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
sound/soc/sti/uniperif.h +27 -1
@@ -1228,6 +1228,9 @@#define UNIPERIF_TYPE_IS_IEC958 (p) \ (UNIPERIF_TYPE_IS_HDMI(p) || \ UNIPERIF_TYPE_IS_SPDIF(p)) +#define UNIPERIF_TYPE_IS_TDM (p) \ + ((p)->info->type == SND_ST_UNIPERIF_TYPE_TDM) +/* * Uniperipheral IP revisions */
@@ -1249,7 +1252,8 @@ enum uniperif_type {SND_ST_UNIPERIF_TYPE_NONE ,SND_ST_UNIPERIF_TYPE_HDMI ,SND_ST_UNIPERIF_TYPE_PCM , -SND_ST_UNIPERIF_TYPE_SPDIF +SND_ST_UNIPERIF_TYPE_SPDIF , +SND_ST_UNIPERIF_TYPE_TDM }; enum uniperif_state {
@@ -1330,6 +1334,28 @@ struct sti_uniperiph_data {struct sti_uniperiph_dai dai_data; }; +static const struct snd_pcm_hardware uni_tdm_hw = { + .info =SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_BLOCK_TRANSFER | +SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_MMAP | +SNDRV_PCM_INFO_MMAP_VALID , + + .formats =SNDRV_PCM_FMTBIT_S32_LE |SNDRV_PCM_FMTBIT_S16_LE , + + .rates =SNDRV_PCM_RATE_CONTINUOUS , + .rate_min =8000 , + .rate_max =48000 , + + .channels_min =1 , + .channels_max =32 , + + .periods_min =2 , + .periods_max =10 , + + .period_bytes_min =128 , + .period_bytes_max =64 *PAGE_SIZE , + .buffer_bytes_max =256 *PAGE_SIZE +}; +/* uniperiph player*/ int uni_player_init (struct platform_device *pdev,struct uniperif *uni_player);
Signature · 1 line
2.8.0.rc3
PATCH v2 4/7 ASoC: sti: helper functions for unip tdm slots configuration
In reply to Moise Gergaud- sti_uniperiph_set_tdm_slot: store tdm slot config in unip context
- sti_uniperiph_get_tdm_word_pos: configure unip tdm slots pos regs
--- sound/soc/sti/sti_uniperif.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sti/uniperif.h | 23 +++++++++++ 2 files changed, 113 insertions(+)
sound/soc/sti/sti_uniperif.c +90 -0
@@ -11,6 +11,96 @@#include "uniperif.h" /* +* User frame size shall be 2, 4, 6 or 8 32-bits words length +* (i.e. 8, 16, 24 or 32 bytes) +* This constraint comes from allowed values for +* UNIPERIF_I2S_FMT_NUM_CH register +*/ +#define UNIPERIF_MAX_FRAME_SZ 0x20 +#define UNIPERIF_ALLOWED_FRAME_SZ (0x08 | 0x10 | 0x18 | UNIPERIF_MAX_FRAME_SZ) + +int sti_uniperiph_set_tdm_slot (struct snd_soc_dai *dai,unsigned int tx_mask, +unsigned int rx_mask,int slots, +int slot_width) +{ +struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); +struct uniperif *uni = priv->dai_data.uni; +int i, frame_size, avail_slots; + +if (!UNIPERIF_TYPE_IS_TDM (uni)) { +dev_err (uni->dev,"cpu dai not in tdm mode\n" ); +return -EINVAL ; + } + +/* store info in unip context */ + uni->tdm_slot.slots = slots; + uni->tdm_slot.slot_width = slot_width; +/* unip is unidirectionnal */ + uni->tdm_slot.mask = (tx_mask !=0 ) ? tx_mask : rx_mask; + +/* number of available timeslots */ +for (i =0 , avail_slots =0 ; i < uni->tdm_slot.slots; i++) { +if ((uni->tdm_slot.mask >> i) &0x01 ) + avail_slots++; + } + uni->tdm_slot.avail_slots = avail_slots; + +/* frame size in bytes */ + frame_size = uni->tdm_slot.avail_slots * uni->tdm_slot.slot_width /8 ; + +/* check frame size is allowed */ +if ((frame_size >UNIPERIF_MAX_FRAME_SZ ) || + (frame_size & ~(int )UNIPERIF_ALLOWED_FRAME_SZ )) { +dev_err (uni->dev,"frame size not allowed: %d bytes\n" , + frame_size); +return -EINVAL ; + } + +return 0 ; +} + +int sti_uniperiph_get_tdm_word_pos (struct uniperif *uni, +unsigned int *word_pos) +{ +int slot_width = uni->tdm_slot.slot_width /8 ; +int slots_num = uni->tdm_slot.slots; +unsigned int slots_mask = uni->tdm_slot.mask; +int i, j, k; +unsigned int word16_pos[4 ]; + +/* word16_pos: +* word16_pos[0] = WORDX_LSB +* word16_pos[1] = WORDX_MSB, +* word16_pos[2] = WORDX+1_LSB +* word16_pos[3] = WORDX+1_MSB +*/ + +/* set unip word position */ +for (i =0 , j =0 , k =0 ; (i < slots_num) && (k <WORD_MAX ); i++) { +if ((slots_mask >> i) &0x01 ) { + word16_pos[j] = i * slot_width; + +if (slot_width ==4 ) { + word16_pos[j +1 ] = word16_pos[j] +2 ; + j++; + } + j++; + +if (j >3 ) { + word_pos[k] = word16_pos[1 ] | + (word16_pos[0 ] <<8 ) | + (word16_pos[3 ] <<16 ) | + (word16_pos[2 ] <<24 ); + j =0 ; + k++; + } + } + } + +return 0 ; +} + +/* * sti_uniperiph_dai_create_ctrl * This function is used to create Ctrl associated to DAI but also pcm device. * Request is done by front end to associate ctrl with pcm device id
sound/soc/sti/uniperif.h +23 -0
@@ -1270,6 +1270,14 @@ enum uniperif_iec958_encoding_mode {UNIPERIF_IEC958_ENCODING_MODE_ENCODED }; +enum uniperif_word_pos { +WORD_1_2 , +WORD_3_4 , +WORD_5_6 , +WORD_7_8 , +WORD_MAX +}; +struct uniperif_info {int id;/* instance value of the uniperipheral IP */ enum uniperif_type type;
@@ -1281,6 +1289,13 @@ struct uniperif_iec958_settings {struct snd_aes_iec958 iec958; }; +struct dai_tdm_slot { +unsigned int mask; +int slots; +int slot_width; +unsigned int avail_slots; +}; +struct uniperif {/* System information */ struct uniperif_info *info;
@@ -1317,6 +1332,7 @@ struct uniperif {/* dai properties */ unsigned int daifmt; +struct dai_tdm_slot tdm_slot;/* DAI callbacks */ const struct snd_soc_dai_ops *dai_ops;
@@ -1373,4 +1389,11 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); +int sti_uniperiph_set_tdm_slot (struct snd_soc_dai *dai,unsigned int tx_mask, +unsigned int rx_mask,int slots, +int slot_width); + +int sti_uniperiph_get_tdm_word_pos (struct uniperif *uni, +unsigned int *word_pos); +#endif
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: sti: helper functions for unip tdm slots configuration" to the asoc tree
The patch
ASoC: sti: helper functions for unip tdm slots configuration
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
44f948bdb175bf326911c9ba0e47389918161ce5Mon Sep 17 00:00:00 2001
From: Moise Gergaud <[email protected]>
Date: Thu, 7 Apr 2016 11:25:33 +0200
Subject: [PATCH] ASoC: sti: helper functions for unip tdm slots configuration
- sti_uniperiph_set_tdm_slot: store tdm slot config in unip context
- sti_uniperiph_get_tdm_word_pos: configure unip tdm slots pos regs
--- sound/soc/sti/sti_uniperif.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sti/uniperif.h | 23 +++++++++++ 2 files changed, 113 insertions(+)
sound/soc/sti/sti_uniperif.c +90 -0
@@ -11,6 +11,96 @@#include "uniperif.h" /* +* User frame size shall be 2, 4, 6 or 8 32-bits words length +* (i.e. 8, 16, 24 or 32 bytes) +* This constraint comes from allowed values for +* UNIPERIF_I2S_FMT_NUM_CH register +*/ +#define UNIPERIF_MAX_FRAME_SZ 0x20 +#define UNIPERIF_ALLOWED_FRAME_SZ (0x08 | 0x10 | 0x18 | UNIPERIF_MAX_FRAME_SZ) + +int sti_uniperiph_set_tdm_slot (struct snd_soc_dai *dai,unsigned int tx_mask, +unsigned int rx_mask,int slots, +int slot_width) +{ +struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); +struct uniperif *uni = priv->dai_data.uni; +int i, frame_size, avail_slots; + +if (!UNIPERIF_TYPE_IS_TDM (uni)) { +dev_err (uni->dev,"cpu dai not in tdm mode\n" ); +return -EINVAL ; + } + +/* store info in unip context */ + uni->tdm_slot.slots = slots; + uni->tdm_slot.slot_width = slot_width; +/* unip is unidirectionnal */ + uni->tdm_slot.mask = (tx_mask !=0 ) ? tx_mask : rx_mask; + +/* number of available timeslots */ +for (i =0 , avail_slots =0 ; i < uni->tdm_slot.slots; i++) { +if ((uni->tdm_slot.mask >> i) &0x01 ) + avail_slots++; + } + uni->tdm_slot.avail_slots = avail_slots; + +/* frame size in bytes */ + frame_size = uni->tdm_slot.avail_slots * uni->tdm_slot.slot_width /8 ; + +/* check frame size is allowed */ +if ((frame_size >UNIPERIF_MAX_FRAME_SZ ) || + (frame_size & ~(int )UNIPERIF_ALLOWED_FRAME_SZ )) { +dev_err (uni->dev,"frame size not allowed: %d bytes\n" , + frame_size); +return -EINVAL ; + } + +return 0 ; +} + +int sti_uniperiph_get_tdm_word_pos (struct uniperif *uni, +unsigned int *word_pos) +{ +int slot_width = uni->tdm_slot.slot_width /8 ; +int slots_num = uni->tdm_slot.slots; +unsigned int slots_mask = uni->tdm_slot.mask; +int i, j, k; +unsigned int word16_pos[4 ]; + +/* word16_pos: +* word16_pos[0] = WORDX_LSB +* word16_pos[1] = WORDX_MSB, +* word16_pos[2] = WORDX+1_LSB +* word16_pos[3] = WORDX+1_MSB +*/ + +/* set unip word position */ +for (i =0 , j =0 , k =0 ; (i < slots_num) && (k <WORD_MAX ); i++) { +if ((slots_mask >> i) &0x01 ) { + word16_pos[j] = i * slot_width; + +if (slot_width ==4 ) { + word16_pos[j +1 ] = word16_pos[j] +2 ; + j++; + } + j++; + +if (j >3 ) { + word_pos[k] = word16_pos[1 ] | + (word16_pos[0 ] <<8 ) | + (word16_pos[3 ] <<16 ) | + (word16_pos[2 ] <<24 ); + j =0 ; + k++; + } + } + } + +return 0 ; +} + +/* * sti_uniperiph_dai_create_ctrl * This function is used to create Ctrl associated to DAI but also pcm device. * Request is done by front end to associate ctrl with pcm device id
sound/soc/sti/uniperif.h +23 -0
@@ -1270,6 +1270,14 @@ enum uniperif_iec958_encoding_mode {UNIPERIF_IEC958_ENCODING_MODE_ENCODED }; +enum uniperif_word_pos { +WORD_1_2 , +WORD_3_4 , +WORD_5_6 , +WORD_7_8 , +WORD_MAX +}; +struct uniperif_info {int id;/* instance value of the uniperipheral IP */ enum uniperif_type type;
@@ -1281,6 +1289,13 @@ struct uniperif_iec958_settings {struct snd_aes_iec958 iec958; }; +struct dai_tdm_slot { +unsigned int mask; +int slots; +int slot_width; +unsigned int avail_slots; +}; +struct uniperif {/* System information */ struct uniperif_info *info;
@@ -1317,6 +1332,7 @@ struct uniperif {/* dai properties */ unsigned int daifmt; +struct dai_tdm_slot tdm_slot;/* DAI callbacks */ const struct snd_soc_dai_ops *dai_ops;
@@ -1373,4 +1389,11 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); +int sti_uniperiph_set_tdm_slot (struct snd_soc_dai *dai,unsigned int tx_mask, +unsigned int rx_mask,int slots, +int slot_width); + +int sti_uniperiph_get_tdm_word_pos (struct uniperif *uni, +unsigned int *word_pos); +#endif
Signature · 1 line
2.8.0.rc3
PATCH v2 5/7 ASoC: sti: helper functions to fix tdm runtime params
In reply to Moise Gergaud--- sound/soc/sti/sti_uniperif.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sti/uniperif.h | 6 ++++++ 2 files changed, 52 insertions(+)
sound/soc/sti/sti_uniperif.c +46 -0
@@ -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) {
sound/soc/sti/uniperif.h +6 -0
@@ -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
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: sti: helper functions to fix tdm runtime params" to the asoc tree
The patch
ASoC: sti: helper functions to fix tdm runtime params
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
72199787662612a7747248f8b56bc5d42694538fMon Sep 17 00:00:00 2001
From: Moise Gergaud <[email protected]>
Date: Thu, 7 Apr 2016 11:25:34 +0200
Subject: [PATCH] ASoC: sti: helper functions to fix tdm runtime params
--- sound/soc/sti/sti_uniperif.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sti/uniperif.h | 6 ++++++ 2 files changed, 52 insertions(+)
sound/soc/sti/sti_uniperif.c +46 -0
@@ -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) {
sound/soc/sti/uniperif.h +6 -0
@@ -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
Signature · 1 line
2.8.0.rc3
PATCH v2 6/7 ASoC: sti: unip player tdm mode
In reply to Moise Gergaudhere are the changes to enable player tdm mode:
- When TDM_ENABLE is set to 1, the i2s format should be automatically configured. Unfortunately this is not the case (HW bug). Then, we shall force DATA_SIZE setting.
- Compute the transfer size for tdm mode: transfer size = user frame size
- Manage tdm slots configuration given in DT.
- Don't use mclk-fs when unip in tdm mode; use tdm slot config to compute frame size and to set mclk rate.
- Refine the hw param (channels & format) according to tdm slot config.
--- sound/soc/sti/sti_uniperif.c | 8 ++- sound/soc/sti/uniperif.h | 11 ++++ sound/soc/sti/uniperif_player.c | 109 +++++++++++++++++++++++++++++++++------- 3 files changed, 110 insertions(+), 18 deletions(-)
sound/soc/sti/sti_uniperif.c +7 -1
@@ -181,10 +181,16 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { + struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai); +struct uniperif *uni = priv->dai_data.uni;struct snd_dmaengine_dai_dma_data *dma_data;int transfer_size; - transfer_size =params_channels (params) *UNIPERIF_FIFO_FRAMES ; +if (uni->info->type ==SND_ST_UNIPERIF_TYPE_TDM ) +/* transfer size = user frame size (in 32-bits FIFO cell) */ + transfer_size =snd_soc_params_to_frame_size (params) /32 ; +else + transfer_size =params_channels (params) *UNIPERIF_FIFO_FRAMES ; dma_data =snd_soc_dai_get_dma_data (dai, substream); dma_data->maxburst = transfer_size;
sound/soc/sti/uniperif.h +11 -0
@@ -1389,6 +1389,17 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); +static inline int sti_uniperiph_get_user_frame_size ( +struct snd_pcm_runtime *runtime) +{ +return (runtime->channels *snd_pcm_format_width (runtime->format) /8 ); +} + +static inline int sti_uniperiph_get_unip_tdm_frame_size (struct uniperif *uni) +{ +return (uni->tdm_slot.slots * uni->tdm_slot.slot_width /8 ); +} +int sti_uniperiph_set_tdm_slot (struct snd_soc_dai *dai,unsigned int tx_mask,unsigned int rx_mask,int slots,int slot_width);
sound/soc/sti/uniperif_player.c +92 -17
180 lines not on this page · raw message
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: sti: unip player tdm mode" to the asoc tree
The patch
ASoC: sti: unip player tdm mode
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
8d8b1e2eddaef25ca0a18500dd9425638f1cfd02Mon Sep 17 00:00:00 2001
From: Moise Gergaud <[email protected]>
Date: Thu, 7 Apr 2016 11:25:35 +0200
Subject: [PATCH] ASoC: sti: unip player tdm mode
here are the changes to enable player tdm mode:
- When TDM_ENABLE is set to 1, the i2s format should be automatically configured. Unfortunately this is not the case (HW bug). Then, we shall force DATA_SIZE setting.
- Compute the transfer size for tdm mode: transfer size = user frame size
- Manage tdm slots configuration given in DT.
- Don't use mclk-fs when unip in tdm mode; use tdm slot config to compute frame size and to set mclk rate.
- Refine the hw param (channels & format) according to tdm slot config.
--- sound/soc/sti/sti_uniperif.c | 8 ++- sound/soc/sti/uniperif.h | 11 ++++ sound/soc/sti/uniperif_player.c | 109 +++++++++++++++++++++++++++++++++------- 3 files changed, 110 insertions(+), 18 deletions(-)
sound/soc/sti/sti_uniperif.c +7 -1
@@ -181,10 +181,16 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { + struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai); +struct uniperif *uni = priv->dai_data.uni;struct snd_dmaengine_dai_dma_data *dma_data;int transfer_size; - transfer_size =params_channels (params) *UNIPERIF_FIFO_FRAMES ; +if (uni->info->type ==SND_ST_UNIPERIF_TYPE_TDM ) +/* transfer size = user frame size (in 32-bits FIFO cell) */ + transfer_size =snd_soc_params_to_frame_size (params) /32 ; +else + transfer_size =params_channels (params) *UNIPERIF_FIFO_FRAMES ; dma_data =snd_soc_dai_get_dma_data (dai, substream); dma_data->maxburst = transfer_size;
sound/soc/sti/uniperif.h +11 -0
@@ -1389,6 +1389,17 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); +static inline int sti_uniperiph_get_user_frame_size ( +struct snd_pcm_runtime *runtime) +{ +return (runtime->channels *snd_pcm_format_width (runtime->format) /8 ); +} + +static inline int sti_uniperiph_get_unip_tdm_frame_size (struct uniperif *uni) +{ +return (uni->tdm_slot.slots * uni->tdm_slot.slot_width /8 ); +} +int sti_uniperiph_set_tdm_slot (struct snd_soc_dai *dai,unsigned int tx_mask,unsigned int rx_mask,int slots,int slot_width);
sound/soc/sti/uniperif_player.c +92 -17
180 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3
PATCH v2 7/7 ASoC: sti: unip reader tdm mode
In reply to Moise GergaudHere are the changes to enable reader tdm mode:
- When TDM_ENABLE is set to 1, the i2s format should be automatically configured. Unfortunately this is not the case (HW bug). Then, we shall force DATA_SIZE setting.
- Compute the transfer size for tdm mode: transfer size = user frame size
- Manage tdm slots configuration given in DT.
- Refine the hw param (channels & format) according to tdm slot config.
--- sound/soc/sti/uniperif_reader.c | 229 +++++++++++++++++++++++++++++----------- 1 file changed, 168 insertions(+), 61 deletions(-)
sound/soc/sti/uniperif_reader.c +168 -61
@@ -73,55 +73,10 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)return ret; } -static int uni_reader_prepare (struct snd_pcm_substream *substream, -struct snd_soc_dai *dai) +static int uni_reader_prepare_pcm (struct snd_pcm_runtime *runtime, +struct uniperif *reader) { -struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); -struct uniperif *reader = priv->dai_data.uni; -struct snd_pcm_runtime *runtime = substream->runtime; -int transfer_size, trigger_limit;int slot_width; -int count =10 ; - -/* The reader should be stopped */ -if (reader->state !=UNIPERIF_STATE_STOPPED ) { -dev_err (reader->dev,"%s: invalid reader state %d" , __func__, - reader->state); -return -EINVAL ; - } - -/* Calculate transfer size (in fifo cells and bytes) for frame count */ - transfer_size = runtime->channels *UNIPERIF_FIFO_FRAMES ; - -/* Calculate number of empty cells available before asserting DREQ */ -if (reader->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ) - trigger_limit =UNIPERIF_FIFO_SIZE - transfer_size; -else -/* -* Since SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 -* FDMA_TRIGGER_LIMIT also controls when the state switches -* from OFF or STANDBY to AUDIO DATA. -*/ - trigger_limit = transfer_size; - -/* Trigger limit must be an even number */ -if ((!trigger_limit %2 ) || - (trigger_limit !=1 && transfer_size %2 ) || - (trigger_limit >UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK (reader))) { -dev_err (reader->dev,"invalid trigger limit %d" , trigger_limit); -return -EINVAL ; - } - -SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT (reader, trigger_limit); - -switch (reader->daifmt &SND_SOC_DAIFMT_INV_MASK ) { -case SND_SOC_DAIFMT_IB_IF : -case SND_SOC_DAIFMT_NB_IF : -SET_UNIPERIF_I2S_FMT_LR_POL_HIG (reader); -break ; -default : -SET_UNIPERIF_I2S_FMT_LR_POL_LOW (reader); - }/* Force slot width to 32 in I2S mode */ if ((reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK)
@@ -173,6 +128,109 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,return -EINVAL ; } +/* Number of channels must be even */ +if ((runtime->channels %2 ) || (runtime->channels <2 ) || + (runtime->channels >10 )) { +dev_err (reader->dev,"%s: invalid nb of channels" , __func__); +return -EINVAL ; + } + +SET_UNIPERIF_I2S_FMT_NUM_CH (reader, runtime->channels /2 ); +SET_UNIPERIF_I2S_FMT_ORDER_MSB (reader); + +return 0 ; +} + +static int uni_reader_prepare_tdm (struct snd_pcm_runtime *runtime, +struct uniperif *reader) +{ +int frame_size;/* user tdm frame size in bytes */ +/* default unip TDM_WORD_POS_X_Y */ +unsigned int word_pos[4 ] = { +0x04060002 ,0x0C0E080A ,0x14161012 ,0x1C1E181A }; + + frame_size =sti_uniperiph_get_user_frame_size (runtime); + +/* fix 16/0 format */ +SET_UNIPERIF_CONFIG_MEM_FMT_16_0 (reader); +SET_UNIPERIF_I2S_FMT_DATA_SIZE_32 (reader); + +/* number of words inserted on the TDM line */ +SET_UNIPERIF_I2S_FMT_NUM_CH (reader, frame_size /4 /2 ); + +SET_UNIPERIF_I2S_FMT_ORDER_MSB (reader); +SET_UNIPERIF_I2S_FMT_ALIGN_LEFT (reader); +SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE (reader); + +/* +* set the timeslots allocation for words in FIFO +* +* HW bug: (LSB word < MSB word) => this config is not possible +* So if we want (LSB word < MSB) word, then it shall be +* handled by user +*/ +sti_uniperiph_get_tdm_word_pos (reader, word_pos); + SET_UNIPERIF_TDM_WORD_POS(reader, 1_2, word_pos[WORD_1_2]); + SET_UNIPERIF_TDM_WORD_POS(reader, 3_4, word_pos[WORD_3_4]); + SET_UNIPERIF_TDM_WORD_POS(reader, 5_6, word_pos[WORD_5_6]); + SET_UNIPERIF_TDM_WORD_POS(reader, 7_8, word_pos[WORD_7_8]); + +return 0 ; +} + +static int uni_reader_prepare (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); +struct uniperif *reader = priv->dai_data.uni; +struct snd_pcm_runtime *runtime = substream->runtime; +int transfer_size, trigger_limit, ret; +int count =10 ; + +/* The reader should be stopped */ +if (reader->state !=UNIPERIF_STATE_STOPPED ) { +dev_err (reader->dev,"%s: invalid reader state %d" , __func__, + reader->state); +return -EINVAL ; + } + +/* Calculate transfer size (in fifo cells and bytes) for frame count */ +if (reader->info->type ==SND_ST_UNIPERIF_TYPE_TDM ) { +/* transfer size = unip frame size (in 32 bits FIFO cell) */ + transfer_size = +sti_uniperiph_get_user_frame_size (runtime) /4 ; + }else { + transfer_size = runtime->channels *UNIPERIF_FIFO_FRAMES ; + } + +/* Calculate number of empty cells available before asserting DREQ */ +if (reader->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ) + trigger_limit =UNIPERIF_FIFO_SIZE - transfer_size; +else +/* +* Since SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 +* FDMA_TRIGGER_LIMIT also controls when the state switches +* from OFF or STANDBY to AUDIO DATA. +*/ + trigger_limit = transfer_size; + +/* Trigger limit must be an even number */ +if ((!trigger_limit %2 ) || + (trigger_limit !=1 && transfer_size %2 ) || + (trigger_limit >UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK (reader))) { +dev_err (reader->dev,"invalid trigger limit %d" , trigger_limit); +return -EINVAL ; + } + +SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT (reader, trigger_limit); + +if (UNIPERIF_TYPE_IS_TDM (reader)) + ret =uni_reader_prepare_tdm (runtime, reader); +else + ret =uni_reader_prepare_pcm (runtime, reader); +if (ret) +return ret; +switch (reader->daifmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_I2S :SET_UNIPERIF_I2S_FMT_ALIGN_LEFT (reader);
@@ -191,21 +249,26 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,return -EINVAL ; } -SET_UNIPERIF_I2S_FMT_ORDER_MSB (reader); - -/* Data clocking (changing) on the rising edge */ -SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING (reader); - -/* Number of channels must be even */ - -if ((runtime->channels %2 ) || (runtime->channels <2 ) || - (runtime->channels >10 )) { -dev_err (reader->dev,"%s: invalid nb of channels" , __func__); -return -EINVAL ; +/* Data clocking (changing) on the rising/falling edge */ +switch (reader->daifmt &SND_SOC_DAIFMT_INV_MASK ) { +case SND_SOC_DAIFMT_NB_NF : +SET_UNIPERIF_I2S_FMT_LR_POL_LOW (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING (reader); +break ; +case SND_SOC_DAIFMT_NB_IF : +SET_UNIPERIF_I2S_FMT_LR_POL_HIG (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING (reader); +break ; +case SND_SOC_DAIFMT_IB_NF : +SET_UNIPERIF_I2S_FMT_LR_POL_LOW (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING (reader); +break ; +case SND_SOC_DAIFMT_IB_IF : +SET_UNIPERIF_I2S_FMT_LR_POL_HIG (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING (reader); +break ; } -SET_UNIPERIF_I2S_FMT_NUM_CH (reader, runtime->channels /2 ); -/* Clear any pending interrupts */ SET_UNIPERIF_ITS_BCLR (reader,GET_UNIPERIF_ITS (reader));
@@ -293,6 +356,32 @@ static int uni_reader_trigger(struct snd_pcm_substream *substream, } } +static int uni_reader_startup (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); +struct uniperif *reader = priv->dai_data.uni; +int ret; + +if (!UNIPERIF_TYPE_IS_TDM (reader)) +return 0 ; + +/* refine hw constraint in tdm mode */ + ret =snd_pcm_hw_rule_add (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_CHANNELS , + sti_uniperiph_fix_tdm_chan, + reader,SNDRV_PCM_HW_PARAM_CHANNELS , +-1 ); +if (ret <0 ) +return ret; + +return snd_pcm_hw_rule_add (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_FORMAT , + sti_uniperiph_fix_tdm_format, + reader,SNDRV_PCM_HW_PARAM_FORMAT , +-1 ); +} +static void uni_reader_shutdown (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {
@@ -310,6 +399,7 @@ static int uni_reader_parse_dt(struct platform_device *pdev, {struct uniperif_info *info;struct device_node *node = pdev->dev.of_node; +const char *mode;/* Allocate memory for the info structure */ info =devm_kzalloc (&pdev->dev,sizeof (*info),GFP_KERNEL );
@@ -322,6 +412,17 @@ static int uni_reader_parse_dt(struct platform_device *pdev,return -EINVAL ; } +/* Read the device mode property */ +if (of_property_read_string (node,"st,mode" , &mode)) { +dev_err (&pdev->dev,"uniperipheral mode not defined" ); +return -EINVAL ; + } + +if (strcasecmp (mode,"tdm" ) ==0 ) + info->type =SND_ST_UNIPERIF_TYPE_TDM ; +else + info->type =SND_ST_UNIPERIF_TYPE_PCM ; +/* Save the info structure */ reader->info = info;
@@ -329,11 +430,13 @@ static int uni_reader_parse_dt(struct platform_device *pdev, }static const struct snd_soc_dai_ops uni_reader_dai_ops = { + .startup = uni_reader_startup, .shutdown = uni_reader_shutdown, .prepare = uni_reader_prepare, .trigger = uni_reader_trigger, .hw_params = sti_uniperiph_dai_hw_params, .set_fmt = sti_uniperiph_dai_set_fmt, + .set_tdm_slot = sti_uniperiph_set_tdm_slot }; int uni_reader_init(struct platform_device *pdev,
@@ -343,7 +446,6 @@ int uni_reader_init(struct platform_device *pdev, reader->dev = &pdev->dev; reader->state =UNIPERIF_STATE_STOPPED ; - reader->hw = &uni_reader_pcm_hw; reader->dai_ops = &uni_reader_dai_ops; ret =uni_reader_parse_dt (pdev, reader);
@@ -352,6 +454,11 @@ int uni_reader_init(struct platform_device *pdev,return ret; } +if (UNIPERIF_TYPE_IS_TDM (reader)) + reader->hw = &uni_tdm_hw; +else + reader->hw = &uni_reader_pcm_hw; + ret =devm_request_irq (&pdev->dev, reader->irq, uni_reader_irq_handler,IRQF_SHARED ,dev_name (&pdev->dev), reader);
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: sti: unip reader tdm mode" to the asoc tree
The patch
ASoC: sti: unip reader tdm mode
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
82d4eb91ab1912cb9e8751b9aa0875af2ae36db2Mon Sep 17 00:00:00 2001
From: Moise Gergaud <[email protected]>
Date: Thu, 7 Apr 2016 11:25:36 +0200
Subject: [PATCH] ASoC: sti: unip reader tdm mode
Here are the changes to enable reader tdm mode:
- When TDM_ENABLE is set to 1, the i2s format should be automatically configured. Unfortunately this is not the case (HW bug). Then, we shall force DATA_SIZE setting.
- Compute the transfer size for tdm mode: transfer size = user frame size
- Manage tdm slots configuration given in DT.
- Refine the hw param (channels & format) according to tdm slot config.
--- sound/soc/sti/uniperif_reader.c | 229 +++++++++++++++++++++++++++++----------- 1 file changed, 168 insertions(+), 61 deletions(-)
sound/soc/sti/uniperif_reader.c +168 -61
@@ -73,55 +73,10 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)return ret; } -static int uni_reader_prepare (struct snd_pcm_substream *substream, -struct snd_soc_dai *dai) +static int uni_reader_prepare_pcm (struct snd_pcm_runtime *runtime, +struct uniperif *reader) { -struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); -struct uniperif *reader = priv->dai_data.uni; -struct snd_pcm_runtime *runtime = substream->runtime; -int transfer_size, trigger_limit;int slot_width; -int count =10 ; - -/* The reader should be stopped */ -if (reader->state !=UNIPERIF_STATE_STOPPED ) { -dev_err (reader->dev,"%s: invalid reader state %d" , __func__, - reader->state); -return -EINVAL ; - } - -/* Calculate transfer size (in fifo cells and bytes) for frame count */ - transfer_size = runtime->channels *UNIPERIF_FIFO_FRAMES ; - -/* Calculate number of empty cells available before asserting DREQ */ -if (reader->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ) - trigger_limit =UNIPERIF_FIFO_SIZE - transfer_size; -else -/* -* Since SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 -* FDMA_TRIGGER_LIMIT also controls when the state switches -* from OFF or STANDBY to AUDIO DATA. -*/ - trigger_limit = transfer_size; - -/* Trigger limit must be an even number */ -if ((!trigger_limit %2 ) || - (trigger_limit !=1 && transfer_size %2 ) || - (trigger_limit >UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK (reader))) { -dev_err (reader->dev,"invalid trigger limit %d" , trigger_limit); -return -EINVAL ; - } - -SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT (reader, trigger_limit); - -switch (reader->daifmt &SND_SOC_DAIFMT_INV_MASK ) { -case SND_SOC_DAIFMT_IB_IF : -case SND_SOC_DAIFMT_NB_IF : -SET_UNIPERIF_I2S_FMT_LR_POL_HIG (reader); -break ; -default : -SET_UNIPERIF_I2S_FMT_LR_POL_LOW (reader); - }/* Force slot width to 32 in I2S mode */ if ((reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK)
@@ -173,6 +128,109 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,return -EINVAL ; } +/* Number of channels must be even */ +if ((runtime->channels %2 ) || (runtime->channels <2 ) || + (runtime->channels >10 )) { +dev_err (reader->dev,"%s: invalid nb of channels" , __func__); +return -EINVAL ; + } + +SET_UNIPERIF_I2S_FMT_NUM_CH (reader, runtime->channels /2 ); +SET_UNIPERIF_I2S_FMT_ORDER_MSB (reader); + +return 0 ; +} + +static int uni_reader_prepare_tdm (struct snd_pcm_runtime *runtime, +struct uniperif *reader) +{ +int frame_size;/* user tdm frame size in bytes */ +/* default unip TDM_WORD_POS_X_Y */ +unsigned int word_pos[4 ] = { +0x04060002 ,0x0C0E080A ,0x14161012 ,0x1C1E181A }; + + frame_size =sti_uniperiph_get_user_frame_size (runtime); + +/* fix 16/0 format */ +SET_UNIPERIF_CONFIG_MEM_FMT_16_0 (reader); +SET_UNIPERIF_I2S_FMT_DATA_SIZE_32 (reader); + +/* number of words inserted on the TDM line */ +SET_UNIPERIF_I2S_FMT_NUM_CH (reader, frame_size /4 /2 ); + +SET_UNIPERIF_I2S_FMT_ORDER_MSB (reader); +SET_UNIPERIF_I2S_FMT_ALIGN_LEFT (reader); +SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE (reader); + +/* +* set the timeslots allocation for words in FIFO +* +* HW bug: (LSB word < MSB word) => this config is not possible +* So if we want (LSB word < MSB) word, then it shall be +* handled by user +*/ +sti_uniperiph_get_tdm_word_pos (reader, word_pos); + SET_UNIPERIF_TDM_WORD_POS(reader, 1_2, word_pos[WORD_1_2]); + SET_UNIPERIF_TDM_WORD_POS(reader, 3_4, word_pos[WORD_3_4]); + SET_UNIPERIF_TDM_WORD_POS(reader, 5_6, word_pos[WORD_5_6]); + SET_UNIPERIF_TDM_WORD_POS(reader, 7_8, word_pos[WORD_7_8]); + +return 0 ; +} + +static int uni_reader_prepare (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); +struct uniperif *reader = priv->dai_data.uni; +struct snd_pcm_runtime *runtime = substream->runtime; +int transfer_size, trigger_limit, ret; +int count =10 ; + +/* The reader should be stopped */ +if (reader->state !=UNIPERIF_STATE_STOPPED ) { +dev_err (reader->dev,"%s: invalid reader state %d" , __func__, + reader->state); +return -EINVAL ; + } + +/* Calculate transfer size (in fifo cells and bytes) for frame count */ +if (reader->info->type ==SND_ST_UNIPERIF_TYPE_TDM ) { +/* transfer size = unip frame size (in 32 bits FIFO cell) */ + transfer_size = +sti_uniperiph_get_user_frame_size (runtime) /4 ; + }else { + transfer_size = runtime->channels *UNIPERIF_FIFO_FRAMES ; + } + +/* Calculate number of empty cells available before asserting DREQ */ +if (reader->ver <SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ) + trigger_limit =UNIPERIF_FIFO_SIZE - transfer_size; +else +/* +* Since SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 +* FDMA_TRIGGER_LIMIT also controls when the state switches +* from OFF or STANDBY to AUDIO DATA. +*/ + trigger_limit = transfer_size; + +/* Trigger limit must be an even number */ +if ((!trigger_limit %2 ) || + (trigger_limit !=1 && transfer_size %2 ) || + (trigger_limit >UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK (reader))) { +dev_err (reader->dev,"invalid trigger limit %d" , trigger_limit); +return -EINVAL ; + } + +SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT (reader, trigger_limit); + +if (UNIPERIF_TYPE_IS_TDM (reader)) + ret =uni_reader_prepare_tdm (runtime, reader); +else + ret =uni_reader_prepare_pcm (runtime, reader); +if (ret) +return ret; +switch (reader->daifmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_I2S :SET_UNIPERIF_I2S_FMT_ALIGN_LEFT (reader);
@@ -191,21 +249,26 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,return -EINVAL ; } -SET_UNIPERIF_I2S_FMT_ORDER_MSB (reader); - -/* Data clocking (changing) on the rising edge */ -SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING (reader); - -/* Number of channels must be even */ - -if ((runtime->channels %2 ) || (runtime->channels <2 ) || - (runtime->channels >10 )) { -dev_err (reader->dev,"%s: invalid nb of channels" , __func__); -return -EINVAL ; +/* Data clocking (changing) on the rising/falling edge */ +switch (reader->daifmt &SND_SOC_DAIFMT_INV_MASK ) { +case SND_SOC_DAIFMT_NB_NF : +SET_UNIPERIF_I2S_FMT_LR_POL_LOW (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING (reader); +break ; +case SND_SOC_DAIFMT_NB_IF : +SET_UNIPERIF_I2S_FMT_LR_POL_HIG (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING (reader); +break ; +case SND_SOC_DAIFMT_IB_NF : +SET_UNIPERIF_I2S_FMT_LR_POL_LOW (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING (reader); +break ; +case SND_SOC_DAIFMT_IB_IF : +SET_UNIPERIF_I2S_FMT_LR_POL_HIG (reader); +SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING (reader); +break ; } -SET_UNIPERIF_I2S_FMT_NUM_CH (reader, runtime->channels /2 ); -/* Clear any pending interrupts */ SET_UNIPERIF_ITS_BCLR (reader,GET_UNIPERIF_ITS (reader));
@@ -293,6 +356,32 @@ static int uni_reader_trigger(struct snd_pcm_substream *substream, } } +static int uni_reader_startup (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct sti_uniperiph_data *priv =snd_soc_dai_get_drvdata (dai); +struct uniperif *reader = priv->dai_data.uni; +int ret; + +if (!UNIPERIF_TYPE_IS_TDM (reader)) +return 0 ; + +/* refine hw constraint in tdm mode */ + ret =snd_pcm_hw_rule_add (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_CHANNELS , + sti_uniperiph_fix_tdm_chan, + reader,SNDRV_PCM_HW_PARAM_CHANNELS , +-1 ); +if (ret <0 ) +return ret; + +return snd_pcm_hw_rule_add (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_FORMAT , + sti_uniperiph_fix_tdm_format, + reader,SNDRV_PCM_HW_PARAM_FORMAT , +-1 ); +} +static void uni_reader_shutdown (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {
@@ -310,6 +399,7 @@ static int uni_reader_parse_dt(struct platform_device *pdev, {struct uniperif_info *info;struct device_node *node = pdev->dev.of_node; +const char *mode;/* Allocate memory for the info structure */ info =devm_kzalloc (&pdev->dev,sizeof (*info),GFP_KERNEL );
@@ -322,6 +412,17 @@ static int uni_reader_parse_dt(struct platform_device *pdev,return -EINVAL ; } +/* Read the device mode property */ +if (of_property_read_string (node,"st,mode" , &mode)) { +dev_err (&pdev->dev,"uniperipheral mode not defined" ); +return -EINVAL ; + } + +if (strcasecmp (mode,"tdm" ) ==0 ) + info->type =SND_ST_UNIPERIF_TYPE_TDM ; +else + info->type =SND_ST_UNIPERIF_TYPE_PCM ; +/* Save the info structure */ reader->info = info;
@@ -329,11 +430,13 @@ static int uni_reader_parse_dt(struct platform_device *pdev, }static const struct snd_soc_dai_ops uni_reader_dai_ops = { + .startup = uni_reader_startup, .shutdown = uni_reader_shutdown, .prepare = uni_reader_prepare, .trigger = uni_reader_trigger, .hw_params = sti_uniperiph_dai_hw_params, .set_fmt = sti_uniperiph_dai_set_fmt, + .set_tdm_slot = sti_uniperiph_set_tdm_slot }; int uni_reader_init(struct platform_device *pdev,
@@ -343,7 +446,6 @@ int uni_reader_init(struct platform_device *pdev, reader->dev = &pdev->dev; reader->state =UNIPERIF_STATE_STOPPED ; - reader->hw = &uni_reader_pcm_hw; reader->dai_ops = &uni_reader_dai_ops; ret =uni_reader_parse_dt (pdev, reader);
@@ -352,6 +454,11 @@ int uni_reader_init(struct platform_device *pdev,return ret; } +if (UNIPERIF_TYPE_IS_TDM (reader)) + reader->hw = &uni_tdm_hw; +else + reader->hw = &uni_reader_pcm_hw; + ret =devm_request_irq (&pdev->dev, reader->irq, uni_reader_irq_handler,IRQF_SHARED ,dev_name (&pdev->dev), reader);
Signature · 1 line
2.8.0.rc3