Skip to content

Commit ef7a4f9

Browse files
zonquetiwai
authored andcommitted
ALSA: add DSD formats
This patch adds two formats for Direct Stream Digital (DSD), a pulse-density encoding format which is described here: https://en.wikipedia.org/wiki/Direct_Stream_Digital DSD operates on 2.8, 5.6 or 11.2MHz sample rates and as a 1-bit stream. The two new types added by this patch describe streams that are capable of handling DSD samples in DOP format as 8-bit or in 16-bit (or at a x8 or x16 data rate, respectively). DSD itself specifies samples in *bit*, while DOP and ALSA handle them as *bytes*. Hence, a factor of 8 or 16 has to be applied for the sample rare configuration, according to the following table: configured hardware 176.4KHz 352.8kHz 705.6KHz <---- sample rate 8-bit 2.8MHz 5.6MHz 16-bit 2.8Mhz 5.6MHz 11.2MHz `-----------------------------' actual DSD sample rates Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent d5657ec commit ef7a4f9

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎include/sound/pcm.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ struct snd_pcm_ops {
181181
#define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B)
182182
#define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40)
183183
#define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B)
184+
#define SNDRV_PCM_FMTBIT_DSD_U8 _SNDRV_PCM_FMTBIT(DSD_U8)
185+
#define SNDRV_PCM_FMTBIT_DSD_U16_LE _SNDRV_PCM_FMTBIT(DSD_U16_LE)
184186

185187
#ifdef SNDRV_LITTLE_ENDIAN
186188
#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE

‎include/uapi/sound/asound.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ typedef int __bitwise snd_pcm_format_t;
214214
#define SNDRV_PCM_FORMAT_G723_24_1B ((__force snd_pcm_format_t) 45) /* 1 sample in 1 byte */
215215
#define SNDRV_PCM_FORMAT_G723_40 ((__force snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */
216216
#define SNDRV_PCM_FORMAT_G723_40_1B ((__force snd_pcm_format_t) 47) /* 1 sample in 1 byte */
217-
#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_G723_40_1B
217+
#define SNDRV_PCM_FORMAT_DSD_U8 ((__force snd_pcm_format_t) 48) /* DSD, 1-byte samples DSD (x8) */
218+
#define SNDRV_PCM_FORMAT_DSD_U16_LE ((__force snd_pcm_format_t) 49) /* DSD, 2-byte samples DSD (x16), little endian */
219+
#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U16_LE
218220

219221
#ifdef SNDRV_LITTLE_ENDIAN
220222
#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE

‎sound/core/pcm.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ static char *snd_pcm_format_names[] = {
209209
FORMAT(G723_24_1B),
210210
FORMAT(G723_40),
211211
FORMAT(G723_40_1B),
212+
FORMAT(DSD_U8),
213+
FORMAT(DSD_U16_LE),
212214
};
213215

214216
const char *snd_pcm_format_name(snd_pcm_format_t format)

‎sound/core/pcm_misc.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
140140
.width = 5, .phys = 5, .le = -1, .signd = -1,
141141
.silence = {},
142142
},
143+
[SNDRV_PCM_FORMAT_DSD_U8] = {
144+
.width = 8, .phys = 8, .le = 1, .signd = 0,
145+
.silence = {},
146+
},
147+
[SNDRV_PCM_FORMAT_DSD_U16_LE] = {
148+
.width = 16, .phys = 16, .le = 1, .signd = 0,
149+
.silence = {},
150+
},
143151
/* FIXME: the following three formats are not defined properly yet */
144152
[SNDRV_PCM_FORMAT_MPEG] = {
145153
.le = -1, .signd = -1,

0 commit comments

Comments
 (0)