From patchwork Fri Mar 2 14:31:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Scheel X-Patchwork-Id: 10254793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 698A06037F for ; Fri, 2 Mar 2018 14:31:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5304C289BA for ; Fri, 2 Mar 2018 14:31:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45918289BE; Fri, 2 Mar 2018 14:31:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E92E2289BB for ; Fri, 2 Mar 2018 14:31:19 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7B68E267403; Fri, 2 Mar 2018 15:31:18 +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 D91CF267408; Fri, 2 Mar 2018 15:31:15 +0100 (CET) Received: from web01.jusst.de (jusst.de [188.40.114.84]) by alsa0.perex.cz (Postfix) with ESMTP id 46C3A2673F4 for ; Fri, 2 Mar 2018 15:31:13 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by web01.jusst.de (Postfix) with ESMTP id 6CCFD1B01C59; Fri, 2 Mar 2018 15:31:13 +0100 (CET) Authentication-Results: web01.jusst.de (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=jusst.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=jusst.de; h= x-mailer:message-id:date:date:subject:subject:from:from; s= default; t=1520001073; x=1521815474; bh=lDXxj8xyB4zqBbVwFj4AQEwi 88cahVGnx33ADuCnhLQ=; b=FHz6OgvV40EhmW6loopwIpxXDNUKcECgxNRQU4cs ErvHVaOJGnsgFYU0BOjXEjM6N4X9dfpaJXWRa1BjpTp+Szf8XYVmed+gag8S6ZgN 1fduK17jmW69RZ1or0n6C8t4jayUpcoojD3pY0bGtBGNNQiwOeUltCAQqHdQ28md pZc= X-Virus-Scanned: Debian amavisd-new at web01.jusst.de Received: from web01.jusst.de ([127.0.0.1]) by localhost (web01.jusst.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id atd3WiXMRg36; Fri, 2 Mar 2018 15:31:13 +0100 (CET) Received: from julian-workstation.ms.jusst.de (p4FCA68EB.dip0.t-ipconnect.de [79.202.104.235]) (Authenticated sender: julian@jusst.de) by web01.jusst.de (Postfix) with ESMTPSA id ED6F51B01C3E; Fri, 2 Mar 2018 15:31:12 +0100 (CET) From: Julian Scheel To: alsa-devel@alsa-project.org Date: Fri, 2 Mar 2018 15:31:04 +0100 Message-Id: <20180302143104.22859-1-julian@jusst.de> X-Mailer: git-send-email 2.16.1 Cc: tiwai@suse.de, Julian Scheel Subject: [alsa-devel] [PATCH] speaker-test: Support S24_3LE sample 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 Implement support signed 24 bit samples, packed in 3 bytes. Signed-off-by: Julian Scheel --- speaker-test/speaker-test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c index 46b0589..dbee63f 100644 --- a/speaker-test/speaker-test.c +++ b/speaker-test/speaker-test.c @@ -284,6 +284,7 @@ static const int supported_formats[] = { SND_PCM_FORMAT_S16_LE, SND_PCM_FORMAT_S16_BE, SND_PCM_FORMAT_FLOAT_LE, + SND_PCM_FORMAT_S24_3LE, SND_PCM_FORMAT_S32_LE, SND_PCM_FORMAT_S32_BE, -1 @@ -341,6 +342,19 @@ static void generate_sine(uint8_t *frames, int channel, int count, double *_phas *samp_f++ = 0.0; } break; + case SND_PCM_FORMAT_S24_3LE: + if (chn==channel) { + res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * generator_scale * 0x7fffff; + ires = res; + *samp8++ = LE_INT(ires); + *samp8++ = LE_INT(ires) >> 8; + *samp8++ = LE_INT(ires) >> 16; + } else { + *samp8++ = 0; + *samp8++ = 0; + *samp8++ = 0; + } + break; case SND_PCM_FORMAT_S32_LE: if (chn==channel) { res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * generator_scale * 0x7fffffff; @@ -415,6 +429,19 @@ static void generate_pink_noise( uint8_t *frames, int channel, int count) { *samp16++ = 0; } break; + case SND_PCM_FORMAT_S24_3LE: + if (chn==channel) { + res = generate_pink_noise_sample(&pink) * generator_scale * 0x07fffff; + ires = res; + *samp8++ = LE_INT(ires); + *samp8++ = LE_INT(ires) >> 8; + *samp8++ = LE_INT(ires) >> 16; + } else { + *samp8++ = 0; + *samp8++ = 0; + *samp8++ = 0; + } + break; case SND_PCM_FORMAT_S32_LE: if (chn==channel) { res = generate_pink_noise_sample(&pink) * generator_scale * 0x07fffffff; @@ -482,6 +509,17 @@ static void generate_pattern(uint8_t *frames, int channel, int count, int *_patt *samp_f++ = 0.0; } break; + case SND_PCM_FORMAT_S24_3LE: + if (chn==channel) { + *samp8++ = LE_INT(pattern); + *samp8++ = LE_INT(pattern) >> 8; + *samp8++ = LE_INT(pattern) >> 16; + } else { + *samp8++ = 0; + *samp8++ = 0; + *samp8++ = 0; + } + break; case SND_PCM_FORMAT_S32_LE: if (chn==channel) { *samp32++ = LE_INT(pattern);