Skip to content

Commit

Permalink
pcm: Add MSBITS_20 and MSBITS_24 subformat options
Browse files Browse the repository at this point in the history
Improve granularity of format selection for S32/U32 formats by adding
masks representing 20 and 24 most significant bits.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
  • Loading branch information
crojewsk-intel committed Aug 4, 2023
1 parent 663139f commit d4ddeab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion include/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ typedef enum _snd_pcm_subformat {
SND_PCM_SUBFORMAT_UNKNOWN = -1,
/** Standard */
SND_PCM_SUBFORMAT_STD = 0,
SND_PCM_SUBFORMAT_LAST = SND_PCM_SUBFORMAT_STD
/** 20 most significant bits **/
SND_PCM_SUBFORMAT_MSBITS_20 = 1,
/** 24 most significant bits **/
SND_PCM_SUBFORMAT_MSBITS_24 = 2,
SND_PCM_SUBFORMAT_LAST = SND_PCM_SUBFORMAT_MSBITS_24
} snd_pcm_subformat_t;

/** PCM state */
Expand Down
4 changes: 3 additions & 1 deletion include/sound/uapi/asound.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ typedef int __bitwise snd_pcm_format_t;

typedef int __bitwise snd_pcm_subformat_t;
#define SNDRV_PCM_SUBFORMAT_STD ((snd_pcm_subformat_t) 0)
#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD
#define SNDRV_PCM_SUBFORMAT_MSBITS_20 ((snd_pcm_subformat_t) 1)
#define SNDRV_PCM_SUBFORMAT_MSBITS_24 ((snd_pcm_subformat_t) 2)
#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_MSBITS_24

#define SNDRV_PCM_INFO_MMAP 0x00000001 /* hardware supports mmap */
#define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 /* period data are valid during transfer */
Expand Down
4 changes: 4 additions & 0 deletions src/pcm/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2061,10 +2061,14 @@ static const char *const snd_pcm_type_names[] = {

static const char *const snd_pcm_subformat_names[] = {
SUBFORMAT(STD),
SUBFORMAT(MSBITS_20),
SUBFORMAT(MSBITS_24),
};

static const char *const snd_pcm_subformat_descriptions[] = {
SUBFORMATD(STD, "Standard"),
SUBFORMATD(MSBITS_20, "20 most significant bits"),
SUBFORMATD(MSBITS_24, "24 most significant bits"),
};

static const char *const snd_pcm_start_mode_names[] = {
Expand Down
4 changes: 3 additions & 1 deletion src/pcm/pcm_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,9 @@ static const snd_mask_t refine_masks[SND_PCM_HW_PARAM_LAST_MASK - SND_PCM_HW_PAR
},
[SND_PCM_HW_PARAM_SUBFORMAT - SND_PCM_HW_PARAM_FIRST_MASK] = {
.bits = {
PCM_BIT(SNDRV_PCM_SUBFORMAT_STD)
PCM_BIT(SNDRV_PCM_SUBFORMAT_STD),
PCM_BIT(SNDRV_PCM_SUBFORMAT_MSBITS_20),
PCM_BIT(SNDRV_PCM_SUBFORMAT_MSBITS_24)
},
},
};
Expand Down

0 comments on commit d4ddeab

Please sign in to comment.