From patchwork Fri Nov 21 14:04:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jussi Laako X-Patchwork-Id: 5355591 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 27F40C11AC for ; Fri, 21 Nov 2014 15:21:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 390AE20160 for ; Fri, 21 Nov 2014 15:21:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id CD5A620108 for ; Fri, 21 Nov 2014 15:21:06 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EB69D2608C7; Fri, 21 Nov 2014 16:21:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5892E265E3F; Fri, 21 Nov 2014 16:10:44 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id E2571265E40; Fri, 21 Nov 2014 16:10:42 +0100 (CET) Received: from mail.sonarnerd.net (rankki.sonarnerd.net [83.145.240.118]) by alsa0.perex.cz (Postfix) with ESMTP id 25E2C2666BE for ; Fri, 21 Nov 2014 15:05:12 +0100 (CET) Received: from porkkala.uworld (porkkala.uworld [192.168.74.2]) by mail.sonarnerd.net (Postfix) with ESMTP id E11C81966A0A; Fri, 21 Nov 2014 16:05:11 +0200 (EET) From: Jussi Laako To: alsa-devel@alsa-project.org Date: Fri, 21 Nov 2014 16:04:47 +0200 Message-Id: <1416578687-12950-2-git-send-email-jussi@sonarnerd.net> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416578687-12950-1-git-send-email-jussi@sonarnerd.net> References: <1416578687-12950-1-git-send-email-jussi@sonarnerd.net> Cc: tiwai@suse.de, Jussi Laako Subject: [alsa-devel] [PATCH] alsa-lib: Fix DSD sample format endianess and add big-endian format X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds big-endian DSD sample format and fixes return value of DSD formats for snd_pcm_format_little_endian(). Signed-off-by: Jussi Laako --- include/pcm.h | 6 +++++- include/sound/asound.h | 4 +++- src/pcm/pcm.c | 4 ++++ src/pcm/pcm_misc.c | 17 ++++++++++++++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/include/pcm.h b/include/pcm.h index db88ad5..0655e7f 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -213,7 +213,11 @@ typedef enum _snd_pcm_format { SND_PCM_FORMAT_DSD_U16_LE, /* Direct Stream Digital (DSD) in 4-byte samples (x32) */ SND_PCM_FORMAT_DSD_U32_LE, - SND_PCM_FORMAT_LAST = SND_PCM_FORMAT_DSD_U32_LE, + /* Direct Stream Digital (DSD) in 2-byte samples (x16) */ + SND_PCM_FORMAT_DSD_U16_BE, + /* Direct Stream Digital (DSD) in 4-byte samples (x32) */ + SND_PCM_FORMAT_DSD_U32_BE, + SND_PCM_FORMAT_LAST = SND_PCM_FORMAT_DSD_U32_BE, #if __BYTE_ORDER == __LITTLE_ENDIAN /** Signed 16 bit CPU endian */ diff --git a/include/sound/asound.h b/include/sound/asound.h index 6ee5867..941d32f 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -220,7 +220,9 @@ typedef int __bitwise snd_pcm_format_t; #define SNDRV_PCM_FORMAT_DSD_U8 ((__force snd_pcm_format_t) 48) /* DSD, 1-byte samples DSD (x8) */ #define SNDRV_PCM_FORMAT_DSD_U16_LE ((__force snd_pcm_format_t) 49) /* DSD, 2-byte samples DSD (x16), little endian */ #define SNDRV_PCM_FORMAT_DSD_U32_LE ((__force snd_pcm_format_t) 50) /* DSD, 4-byte samples DSD (x32), little endian */ -#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_LE +#define SNDRV_PCM_FORMAT_DSD_U16_BE ((__force snd_pcm_format_t) 51) /* DSD, 2-byte samples DSD (x16), big endian */ +#define SNDRV_PCM_FORMAT_DSD_U32_BE ((__force snd_pcm_format_t) 52) /* DSD, 4-byte samples DSD (x32), big endian */ +#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_BE #ifdef SNDRV_LITTLE_ENDIAN #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 4a7be6c..3904256 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -1566,6 +1566,8 @@ static const char *const snd_pcm_format_names[] = { FORMAT(DSD_U8), FORMAT(DSD_U16_LE), FORMAT(DSD_U32_LE), + FORMAT(DSD_U16_BE), + FORMAT(DSD_U32_BE), }; static const char *const snd_pcm_format_aliases[SND_PCM_FORMAT_LAST+1] = { @@ -1626,6 +1628,8 @@ static const char *const snd_pcm_format_descriptions[] = { FORMATD(DSD_U8, "Direct Stream Digital, 1-byte (x8), oldest bit in MSB"), FORMATD(DSD_U16_LE, "Direct Stream Digital, 2-byte (x16), little endian, oldest bits in MSB"), FORMATD(DSD_U32_LE, "Direct Stream Digital, 4-byte (x32), little endian, oldest bits in MSB"), + FORMATD(DSD_U16_BE, "Direct Stream Digital, 2-byte (x16), big endian, oldest bits in MSB"), + FORMATD(DSD_U32_BE, "Direct Stream Digital, 4-byte (x32), big endian, oldest bits in MSB"), }; static const char *const snd_pcm_type_names[] = { diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index 9272179..5870f82 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -65,6 +65,8 @@ int snd_pcm_format_signed(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_DSD_U8: case SNDRV_PCM_FORMAT_DSD_U16_LE: case SNDRV_PCM_FORMAT_DSD_U32_LE: + case SNDRV_PCM_FORMAT_DSD_U16_BE: + case SNDRV_PCM_FORMAT_DSD_U32_BE: return 0; default: return -EINVAL; @@ -137,6 +139,8 @@ int snd_pcm_format_little_endian(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_U24_3LE: case SNDRV_PCM_FORMAT_U20_3LE: case SNDRV_PCM_FORMAT_U18_3LE: + case SNDRV_PCM_FORMAT_DSD_U16_LE: + case SNDRV_PCM_FORMAT_DSD_U32_LE: return 1; case SNDRV_PCM_FORMAT_S16_BE: case SNDRV_PCM_FORMAT_U16_BE: @@ -153,9 +157,8 @@ int snd_pcm_format_little_endian(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_U24_3BE: case SNDRV_PCM_FORMAT_U20_3BE: case SNDRV_PCM_FORMAT_U18_3BE: - case SNDRV_PCM_FORMAT_DSD_U8: - case SNDRV_PCM_FORMAT_DSD_U16_LE: - case SNDRV_PCM_FORMAT_DSD_U32_LE: + case SNDRV_PCM_FORMAT_DSD_U16_BE: + case SNDRV_PCM_FORMAT_DSD_U32_BE: return 0; default: return -EINVAL; @@ -208,6 +211,7 @@ int snd_pcm_format_width(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_U16_LE: case SNDRV_PCM_FORMAT_U16_BE: case SNDRV_PCM_FORMAT_DSD_U16_LE: + case SNDRV_PCM_FORMAT_DSD_U16_BE: return 16; case SNDRV_PCM_FORMAT_S18_3LE: case SNDRV_PCM_FORMAT_S18_3BE: @@ -235,6 +239,7 @@ int snd_pcm_format_width(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_FLOAT_LE: case SNDRV_PCM_FORMAT_FLOAT_BE: case SNDRV_PCM_FORMAT_DSD_U32_LE: + case SNDRV_PCM_FORMAT_DSD_U32_BE: return 32; case SNDRV_PCM_FORMAT_FLOAT64_LE: case SNDRV_PCM_FORMAT_FLOAT64_BE: @@ -269,6 +274,7 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_U16_LE: case SNDRV_PCM_FORMAT_U16_BE: case SNDRV_PCM_FORMAT_DSD_U16_LE: + case SNDRV_PCM_FORMAT_DSD_U16_BE: return 16; case SNDRV_PCM_FORMAT_S18_3LE: case SNDRV_PCM_FORMAT_S18_3BE: @@ -296,6 +302,7 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE: case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE: case SNDRV_PCM_FORMAT_DSD_U32_LE: + case SNDRV_PCM_FORMAT_DSD_U32_BE: return 32; case SNDRV_PCM_FORMAT_FLOAT64_LE: case SNDRV_PCM_FORMAT_FLOAT64_BE: @@ -328,6 +335,7 @@ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) case SNDRV_PCM_FORMAT_U16_LE: case SNDRV_PCM_FORMAT_U16_BE: case SNDRV_PCM_FORMAT_DSD_U16_LE: + case SNDRV_PCM_FORMAT_DSD_U16_BE: return samples * 2; case SNDRV_PCM_FORMAT_S18_3LE: case SNDRV_PCM_FORMAT_S18_3BE: @@ -353,6 +361,7 @@ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) case SNDRV_PCM_FORMAT_FLOAT_LE: case SNDRV_PCM_FORMAT_FLOAT_BE: case SNDRV_PCM_FORMAT_DSD_U32_LE: + case SNDRV_PCM_FORMAT_DSD_U32_BE: return samples * 4; case SNDRV_PCM_FORMAT_FLOAT64_LE: case SNDRV_PCM_FORMAT_FLOAT64_BE: @@ -400,6 +409,8 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format) case SNDRV_PCM_FORMAT_DSD_U8: case SNDRV_PCM_FORMAT_DSD_U16_LE: case SNDRV_PCM_FORMAT_DSD_U32_LE: + case SNDRV_PCM_FORMAT_DSD_U16_BE: + case SNDRV_PCM_FORMAT_DSD_U32_BE: return 0x6969696969696969ULL; #ifdef SNDRV_LITTLE_ENDIAN case SNDRV_PCM_FORMAT_U16_LE: