Skip to content

Commit 823dbb6

Browse files
maciejsszmigierotiwai
authored andcommitted
ALSA: pcm: add SNDRV_PCM_FORMAT_{S,U}20
This format is similar to existing SNDRV_PCM_FORMAT_{S,U}20_3 that keep 20-bit PCM samples in 3 bytes, however i.MX6 platform SSI FIFO does not allow 3-byte accesses (including DMA) so a 4-byte (more conventional) format is needed for it. Signed-off-by: Maciej S. Szmigiero <[email protected]> Reviewed-by: Takashi Sakamoto <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 4fbd8d1 commit 823dbb6

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

include/sound/pcm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ struct snd_pcm_ops {
169169
#define SNDRV_PCM_FMTBIT_IMA_ADPCM _SNDRV_PCM_FMTBIT(IMA_ADPCM)
170170
#define SNDRV_PCM_FMTBIT_MPEG _SNDRV_PCM_FMTBIT(MPEG)
171171
#define SNDRV_PCM_FMTBIT_GSM _SNDRV_PCM_FMTBIT(GSM)
172+
#define SNDRV_PCM_FMTBIT_S20_LE _SNDRV_PCM_FMTBIT(S20_LE)
173+
#define SNDRV_PCM_FMTBIT_U20_LE _SNDRV_PCM_FMTBIT(U20_LE)
174+
#define SNDRV_PCM_FMTBIT_S20_BE _SNDRV_PCM_FMTBIT(S20_BE)
175+
#define SNDRV_PCM_FMTBIT_U20_BE _SNDRV_PCM_FMTBIT(U20_BE)
172176
#define SNDRV_PCM_FMTBIT_SPECIAL _SNDRV_PCM_FMTBIT(SPECIAL)
173177
#define SNDRV_PCM_FMTBIT_S24_3LE _SNDRV_PCM_FMTBIT(S24_3LE)
174178
#define SNDRV_PCM_FMTBIT_U24_3LE _SNDRV_PCM_FMTBIT(U24_3LE)
@@ -202,6 +206,8 @@ struct snd_pcm_ops {
202206
#define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_LE
203207
#define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_LE
204208
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
209+
#define SNDRV_PCM_FMTBIT_S20 SNDRV_PCM_FMTBIT_S20_LE
210+
#define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_LE
205211
#endif
206212
#ifdef SNDRV_BIG_ENDIAN
207213
#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_BE
@@ -213,6 +219,8 @@ struct snd_pcm_ops {
213219
#define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_BE
214220
#define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_BE
215221
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE
222+
#define SNDRV_PCM_FMTBIT_S20 SNDRV_PCM_FMTBIT_S20_BE
223+
#define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_BE
216224
#endif
217225

218226
struct snd_pcm_file {

include/sound/soc-dai.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct snd_compr_stream;
102102
SNDRV_PCM_FMTBIT_S16_BE |\
103103
SNDRV_PCM_FMTBIT_S20_3LE |\
104104
SNDRV_PCM_FMTBIT_S20_3BE |\
105+
SNDRV_PCM_FMTBIT_S20_LE |\
106+
SNDRV_PCM_FMTBIT_S20_BE |\
105107
SNDRV_PCM_FMTBIT_S24_3LE |\
106108
SNDRV_PCM_FMTBIT_S24_3BE |\
107109
SNDRV_PCM_FMTBIT_S32_LE |\

include/uapi/sound/asound.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ typedef int __bitwise snd_pcm_format_t;
214214
#define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22)
215215
#define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23)
216216
#define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24)
217+
#define SNDRV_PCM_FORMAT_S20_LE ((__force snd_pcm_format_t) 25) /* in four bytes, LSB justified */
218+
#define SNDRV_PCM_FORMAT_S20_BE ((__force snd_pcm_format_t) 26) /* in four bytes, LSB justified */
219+
#define SNDRV_PCM_FORMAT_U20_LE ((__force snd_pcm_format_t) 27) /* in four bytes, LSB justified */
220+
#define SNDRV_PCM_FORMAT_U20_BE ((__force snd_pcm_format_t) 28) /* in four bytes, LSB justified */
221+
/* gap in the numbering for a future standard linear format */
217222
#define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31)
218223
#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) /* in three bytes */
219224
#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) /* in three bytes */
@@ -248,6 +253,8 @@ typedef int __bitwise snd_pcm_format_t;
248253
#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE
249254
#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE
250255
#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
256+
#define SNDRV_PCM_FORMAT_S20 SNDRV_PCM_FORMAT_S20_LE
257+
#define SNDRV_PCM_FORMAT_U20 SNDRV_PCM_FORMAT_U20_LE
251258
#endif
252259
#ifdef SNDRV_BIG_ENDIAN
253260
#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE
@@ -259,6 +266,8 @@ typedef int __bitwise snd_pcm_format_t;
259266
#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE
260267
#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE
261268
#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE
269+
#define SNDRV_PCM_FORMAT_S20 SNDRV_PCM_FORMAT_S20_BE
270+
#define SNDRV_PCM_FORMAT_U20 SNDRV_PCM_FORMAT_U20_BE
262271
#endif
263272

264273
typedef int __bitwise snd_pcm_subformat_t;

sound/core/pcm_misc.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,30 @@ static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
163163
.width = 32, .phys = 32, .le = 0, .signd = 0,
164164
.silence = { 0x69, 0x69, 0x69, 0x69 },
165165
},
166-
/* FIXME: the following three formats are not defined properly yet */
166+
/* FIXME: the following two formats are not defined properly yet */
167167
[SNDRV_PCM_FORMAT_MPEG] = {
168168
.le = -1, .signd = -1,
169169
},
170170
[SNDRV_PCM_FORMAT_GSM] = {
171171
.le = -1, .signd = -1,
172172
},
173+
[SNDRV_PCM_FORMAT_S20_LE] = {
174+
.width = 20, .phys = 32, .le = 1, .signd = 1,
175+
.silence = {},
176+
},
177+
[SNDRV_PCM_FORMAT_S20_BE] = {
178+
.width = 20, .phys = 32, .le = 0, .signd = 1,
179+
.silence = {},
180+
},
181+
[SNDRV_PCM_FORMAT_U20_LE] = {
182+
.width = 20, .phys = 32, .le = 1, .signd = 0,
183+
.silence = { 0x00, 0x00, 0x08, 0x00 },
184+
},
185+
[SNDRV_PCM_FORMAT_U20_BE] = {
186+
.width = 20, .phys = 32, .le = 0, .signd = 0,
187+
.silence = { 0x00, 0x08, 0x00, 0x00 },
188+
},
189+
/* FIXME: the following format is not defined properly yet */
173190
[SNDRV_PCM_FORMAT_SPECIAL] = {
174191
.le = -1, .signd = -1,
175192
},

0 commit comments

Comments
 (0)