From patchwork Tue Apr 30 07:38:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Channaiah Vanitha (RBEI/ECF3)" X-Patchwork-Id: 10922985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A67C7933 for ; Tue, 30 Apr 2019 08:08:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97A5B288F3 for ; Tue, 30 Apr 2019 08:08:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B4A828925; Tue, 30 Apr 2019 08:08:29 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BBB07288F3 for ; Tue, 30 Apr 2019 08:08:28 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E047B1683; Tue, 30 Apr 2019 10:07:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E047B1683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1556611707; bh=Cw0q2A55oEKUy3C9UykNNYgZGIOW2XKM8RnIKd8mDAU=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=KFWYfQNu/RZVpI9f1vz8XIq/UYPYidBEfr3JvDUHFMryEgKy1MdNuxoweNKOn/kv4 /6lC/yxksa42HY2bbWSb7ySzGSGpz3/DVtvpvZQUxSBPaCPR7kqKSr9AJf/KB57vNl b2S/61ebqpfbRqoqA5kIpVazKC2kaq1cVV2hEgLA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AB17EF89721; Tue, 30 Apr 2019 10:05:57 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id CFE40F896F3; Tue, 30 Apr 2019 09:50:00 +0200 (CEST) Received: from de-out1.bosch-org.com (de-out1.bosch-org.com [139.15.230.186]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2C2D4F80C0D; Tue, 30 Apr 2019 09:49:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2C2D4F80C0D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=in.bosch.com header.i=@in.bosch.com header.b="M5fknlsm" Received: from si0vm1947.rbesz01.com (unknown [139.15.230.188]) by si0vms0217.rbdmz01.com (Postfix) with ESMTPS id 44tYb564zvz4f3kZX; Tue, 30 Apr 2019 09:49:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=in.bosch.com; s=2015-01-21; t=1556610593; bh=j9ghyqlcIsq1VvBEl8XAwe9fmi0UKdHNOBlJj7mLn+I=; l=10; h=From:From:Reply-To:Sender; b=M5fknlsmMHwPuGnZO1NhTL82zFeAZQryCWhMCeN1JIck4NPHJfuYHdxEUClnVTUiG bGCLgfzeH/ECcjWI0akJsABCMH4Hxe3rWdc++BxQLvCa9wkNddAVBGcMVut9ewO7YC LxvsUvxApMdHIhwribmiWxsiuHnmd8HU6P6OK0CM= Received: from fe0vm7918.rbesz01.com (unknown [10.58.172.176]) by si0vm1947.rbesz01.com (Postfix) with ESMTPS id 44tYb55lyvz6CjQSN; Tue, 30 Apr 2019 09:49:53 +0200 (CEST) X-AuditID: 0a3aad10-057ff70000007f88-5a-5cc7fe214cb6 Received: from si0vm1949.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm7918.rbesz01.com (SMG Outbound) with SMTP id 06.07.32648.12EF7CC5; Tue, 30 Apr 2019 09:49:53 +0200 (CEST) Received: from FE-HUB2000.de.bosch.com (fe-hub2000.de.bosch.com [10.4.103.109]) by si0vm1949.rbesz01.com (Postfix) with ESMTPS id 44tYb534ssz6CjZrX; Tue, 30 Apr 2019 09:49:53 +0200 (CEST) Received: from localhost.localdomain (10.47.103.61) by FE-HUB2000.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 15.1.1713.5; Tue, 30 Apr 2019 09:49:52 +0200 From: To: Date: Tue, 30 Apr 2019 13:08:39 +0530 Message-ID: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.47.103.61] X-Brightmail-Tracker: H4sIAAAAAAAAA22SbUxTVxzGe+69bU8LhxwuMP4r1cmdkMwXBuoiuo1sizOEJW4m+zBmE3eR C22klNxbCPCJublpRwLGYgpjRAT34stkRhdkC4SOQSBaFXxrgmwSSbC+EgWxm273rmD7Yd/+ 53n+v/PkPDmY5euNFuwod0tyuVgmGMyceePxJavTnw3ZsocvpOdeuuhnco9/V6fPPXSgmXmL ze96uMuQ3/LlUeMHzMfmN4qlMkeVJL+a94nZvutht76iPqP6YHsTV4cOv+RBJgx0HfTe7uQ8 yIx56mNgNnjaEDn0Ifjjq6ectsXTYwj+DBi02UAzYeDKA6MHYZxMrdAwSjSZpTLs+7qL0eYk ugPC17/VazNHM2DeN/6fTugWmPvCy0WCl0IwsJeN6Ikw3HyTi9wD0D89zUZ2loH3ik/fiBJa YtZaYtYOIuYISimRsquc6zfk5GbJRZJSm52TtcPlPIkiZdFudGakxI8oRkI8cd4bsvF6sUqp cfrRa5gRUkhJrSolFLmKa+yiYt8uV5ZJimAh1gsFNj7puaxUFjkdiuJwlfsRYFZIJvlDv9t4 UizW1EqyK4L5URrmhFRSit+38bRUdEs7JalCkhfd1zEWgGz4Sw1MlKVSqbrEUeZetIUlBOl0 Ov6FWCc2lsEmP1qL49XsD7UriFIhOhVH6QL+YgTnF9UoOoLWW1IJ+7fKUM21V5Y/T7VYCQgD Nj4lxoiSIXQVqb0lEaMGx6v/MJoHJE2rKHFBjEJrOlSGhszQOLYK+vZthd8e9CBo655F4D3R boDRnhYjnB1sNMGP9f0m6A0/MUHrjftmOHqnLQ6+n7kVBx3j38SD7+opAqd7xil0XpxMhqa9 Eykwf++zVDg1cgfg2I1AGgS7Bq3wT+iWFSY8j6xwvr8hXTumw2i442UYnphbDr11P2TA2csn V8C15smVMPBkajVMeHdnhdQqGbXK7W2DWpVu0f0/VS6o0bdZ6hCegrE2Dz3x0S90bGbjpuq5 gqW6+Z9DOHjp0JaAb2xl57mRgUz91szC9/LClwvfFZvyPj0cl1Agsbbba37yNhQG+G26oskj U8/W7n+lL/NAauv+8+fuVnVPv9O/hwQne/fMGDa/iR/Ptl4PL7/5+e52+PVptex6nFdprX97 nfho5yaBU+xizgpWVsR/ATOFMUcfBAAA X-Mailman-Approved-At: Tue, 30 Apr 2019 10:05:53 +0200 Cc: twischer@de.adit-jv.com, alsa-devel@alsa-project.org, Vanitha Channaiah Subject: [alsa-devel] [PATCH 1/5] pcm: direct: Add generic hw_ptr_alignment function for dmix, dshare and dsnoop X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vanitha Channaiah This patch is same as the fix in below commit commit 6b058fda9dce ("pcm: dmix: Add option to allow alignment of slave pointers") Signed-off-by: Vanitha Channaiah --- src/pcm/pcm_direct.c | 19 +++++++++++++++++++ src/pcm/pcm_direct.h | 8 ++++++++ src/pcm/pcm_dmix.c | 25 ++----------------------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 666a8ce..411a035 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -2040,3 +2040,22 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, return 0; } + +void snd_pcm_direct_reset_slave_ptr(snd_pcm_t *pcm, snd_pcm_direct_t *dmix) +{ + dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr; + + if (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_ROUNDUP || + (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO && + pcm->buffer_size <= pcm->period_size * 2)) + dmix->slave_appl_ptr = + ((dmix->slave_appl_ptr + dmix->slave_period_size - 1) / + dmix->slave_period_size) * dmix->slave_period_size; + else if (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_ROUNDDOWN || + (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO && + (dmix->slave_period_size * SEC_TO_MS) / + pcm->rate < LOW_LATENCY_PERIOD_TIME)) + dmix->slave_appl_ptr = dmix->slave_hw_ptr = + ((dmix->slave_hw_ptr / dmix->slave_period_size) * + dmix->slave_period_size); +} diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h index da5e280..a71aab1 100644 --- a/src/pcm/pcm_direct.h +++ b/src/pcm/pcm_direct.h @@ -24,6 +24,11 @@ #define DIRECT_IPC_SEMS 1 #define DIRECT_IPC_SEM_CLIENT 0 +/* Seconds representing in Milli seconds */ +#define SEC_TO_MS 1000 +/* slave_period time for low latency requirements in ms */ +#define LOW_LATENCY_PERIOD_TIME 10 + typedef void (mix_areas_t)(unsigned int size, volatile void *dst, void *src, @@ -257,6 +262,8 @@ struct snd_pcm_direct { snd1_pcm_direct_get_chmap #define snd_pcm_direct_set_chmap \ snd1_pcm_direct_set_chmap +#define snd_pcm_direct_reset_slave_ptr \ + snd1_pcm_direct_reset_slave_ptr int snd_pcm_direct_semaphore_create_or_connect(snd_pcm_direct_t *dmix); @@ -341,6 +348,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct); int snd_pcm_direct_client_chk_xrun(snd_pcm_direct_t *direct, snd_pcm_t *pcm); int snd_timer_async(snd_timer_t *timer, int sig, pid_t pid); struct timespec snd_pcm_hw_fast_tstamp(snd_pcm_t *pcm); +void snd_pcm_direct_reset_slave_ptr(snd_pcm_t *pcm, snd_pcm_direct_t *dmix); struct snd_pcm_direct_open_conf { key_t ipc_key; diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index c5592cd..dcde40d 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -55,9 +55,6 @@ const char *_snd_module_pcm_dmix = ""; #define STATE_RUN_PENDING 1024 #endif -#define SEC_TO_MS 1000 /* Seconds representing in Milli seconds */ -#define LOW_LATENCY_PERIOD_TIME 10 /* slave_period time for low latency requirements in ms */ - /* * */ @@ -560,30 +557,12 @@ static int snd_pcm_dmix_hwsync(snd_pcm_t *pcm) } } -static void reset_slave_ptr(snd_pcm_t *pcm, snd_pcm_direct_t *dmix) -{ - dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr; - - if (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_ROUNDUP || - (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO && - pcm->buffer_size <= pcm->period_size * 2)) - dmix->slave_appl_ptr = - ((dmix->slave_appl_ptr + dmix->slave_period_size - 1) - / dmix->slave_period_size) * dmix->slave_period_size; - else if (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_ROUNDDOWN || - (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO && - (dmix->slave_period_size * SEC_TO_MS) / pcm->rate < LOW_LATENCY_PERIOD_TIME)) - dmix->slave_appl_ptr = dmix->slave_hw_ptr = - ((dmix->slave_hw_ptr / dmix->slave_period_size) * - dmix->slave_period_size); -} - static int snd_pcm_dmix_reset(snd_pcm_t *pcm) { snd_pcm_direct_t *dmix = pcm->private_data; dmix->hw_ptr %= pcm->period_size; dmix->appl_ptr = dmix->last_appl_ptr = dmix->hw_ptr; - reset_slave_ptr(pcm, dmix); + snd_pcm_direct_reset_slave_ptr(pcm, dmix); return 0; } @@ -592,7 +571,7 @@ static int snd_pcm_dmix_start_timer(snd_pcm_t *pcm, snd_pcm_direct_t *dmix) int err; snd_pcm_hwsync(dmix->spcm); - reset_slave_ptr(pcm, dmix); + snd_pcm_direct_reset_slave_ptr(pcm, dmix); err = snd_timer_start(dmix->timer); if (err < 0) return err; From patchwork Tue Apr 30 07:38:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Channaiah Vanitha (RBEI/ECF3)" X-Patchwork-Id: 10922983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37384933 for ; Tue, 30 Apr 2019 08:07:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 284F4288E8 for ; Tue, 30 Apr 2019 08:07:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19B022891A; Tue, 30 Apr 2019 08:07:45 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5EEBF288E8 for ; Tue, 30 Apr 2019 08:07:43 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 901F61661; Tue, 30 Apr 2019 10:06:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 901F61661 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1556611661; bh=RaNbiYYzIqEvROvLCPHS8Cjsp8VYGXCuEngfXEey6kw=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mdeB7UF67mFPI7VExNt7Jx8zjKoL46iKFKToH8Rldsot2KvOHgFVv+YfcAcZl1xOD TxqlCthkS/zeolASeca3ICLCMpCAAASfJtZCmLsXBoLfHVxFGuxZgRQB3gakaMQb3C NtynxT0PsJguG9RikYNN33BVQKxouIQXtN5wXbYU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 60E29F896EC; Tue, 30 Apr 2019 10:05:56 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0EAA7F896E3; Tue, 30 Apr 2019 09:50:00 +0200 (CEST) Received: from de-out1.bosch-org.com (de-out1.bosch-org.com [139.15.230.186]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9FD21F8962C; Tue, 30 Apr 2019 09:49:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9FD21F8962C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=in.bosch.com header.i=@in.bosch.com header.b="iZs3jH4J" Received: from si0vm1947.rbesz01.com (unknown [139.15.230.188]) by fe0vms0187.rbdmz01.com (Postfix) with ESMTPS id 44tYb70M9vz1XLDR3; Tue, 30 Apr 2019 09:49:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=in.bosch.com; s=2015-01-21; t=1556610595; bh=j9ghyqlcIsq1VvBEl8XAwe9fmi0UKdHNOBlJj7mLn+I=; l=10; h=From:From:Reply-To:Sender; b=iZs3jH4JPBjhblPYfuJcXLx5MQQe23XN9SyIJSG2cQjAgpo35UNg/tKpgf/5Tw6XI JjYD3KAiGOa6vK0WJ+sjXxr6I23HF9xyIq7TujVfxxmBynzh+s1GHTF1DVUMMqGRAi 1gE0NHlw8jMR5e7kQp90N7Ly4Tfw2ADWsMtLXnlM= Received: from fe0vm7918.rbesz01.com (unknown [10.58.172.176]) by si0vm1947.rbesz01.com (Postfix) with ESMTPS id 44tYb7044Yz6CjQSQ; Tue, 30 Apr 2019 09:49:55 +0200 (CEST) X-AuditID: 0a3aad10-057ff70000007f88-62-5cc7fe2202b7 Received: from fe0vm1651.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm7918.rbesz01.com (SMG Outbound) with SMTP id 47.07.32648.22EF7CC5; Tue, 30 Apr 2019 09:49:54 +0200 (CEST) Received: from FE-HUB2000.de.bosch.com (unknown [10.4.103.109]) by fe0vm1651.rbesz01.com (Postfix) with ESMTPS id 44tYb64P3YzR7N; Tue, 30 Apr 2019 09:49:54 +0200 (CEST) Received: from localhost.localdomain (10.47.103.61) by FE-HUB2000.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 15.1.1713.5; Tue, 30 Apr 2019 09:49:53 +0200 From: To: Date: Tue, 30 Apr 2019 13:08:40 +0530 Message-ID: <1556609923-14093-2-git-send-email-vanitha.channaiah@in.bosch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> References: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> MIME-Version: 1.0 X-Originating-IP: [10.47.103.61] X-Brightmail-Tracker: H4sIAAAAAAAAA22Sf0wbZRzGee/646XybtejdV8KM3jLmBKH4HSCLMZoljCiYxr/2dJkHnK0 jf2Bd4UAxgQNk9GRsZlaCw5SlxCXwbSQOGCZqdxQ4saQsVllUwyKuh+AktbMbeq8crD2D/+5 fO/5Pp/3ee/JYZoN6y3Y4fYKopt3cjqDxvDUifWbuX/HrIXRUwXFly7IVPGJj5q0xUcDHdQz dFk49raurLOlV7+L2mPYViU4HXWC+OjTrxjs7zQv0TWyqX7o+BG6CXUZfSgdA/M4zF5u1/iQ AbNMkIKRX3v0PoSVlz4E/bSqK+Pd28N0AtAxeTAa/WPZY2JyoH2KJGSaEeHwB2EqMWcq87vf frZs1zAbYTLevjwTZif0h7q0au4DMD3RuqynMxUwHfXr1NidMHU+S7Ub4auOOY16PMDI1au0 iuaCPxrUHkJMZ4qtM8UWQtRxZK4WCutcT5YUFReIlYLUWFhU8KrHNYDUCpkhNHy2WkYMRlwG cS2OWVktXyc1uGT0BKY4M6luVKQ1lZ6qBjsv2feKtU5B4iwkZ7Lcymbek6XaSpdDkhwet4wA 05yJlI19YWVJFd/QKIgeFZNRNtZw64gNV1hZxsZ7hdcEoUYQV7elGHNASu4ogUZRsAn11Q6n d3XNrScoLS2NvT91kxpL4XQZbcEZSvbLiSOIVMO7JIdtBc9ScXZVTaJn0XN45OZsF81q3B63 YFlH6L8Vnkk47bXuezew5BDgRq2sOWWRPOU6mkZKh5lEn4AzlD81mQ0kO1GXcUVMQo/1KAwT xdA99CeCK0cPaiH+6WkdTJ3q1MOtCx/rIXg4gGG8+5ABji1duw9iLaNrIXJunIHgtXlW8UXM EFzsAOibnciGGV88B460ns+FT5Zu5ELkvZsPQtvvV/LgzPz4QzB/7uLDEPutKR/GvxnIh5n5 W49A/9yZzTAT/0l5+PcVwHddkUJY3O8vUSy3SyB0wFcKF79vfva6UiylFLu3+8tEsV7e+z/F rqjJr7M0oZ7tg/65l8j2hYk9uvwd24bX2Pt3Oy69UXFs8nO59PXy59+8IWnCur/KP+yLxQPy 1I79I9G1kYNtSz8HfjQNzs3eXbjzlkFPXsz7YaO5ecDwT93Jfb31vT0toRdMAxsu44xY6P1f 2rZk5U53h9O3brI4D3wdH/TY9BHX1oCxVTu5YOQ0kp0vyqdFif8Ps00rvUMEAAA= X-Mailman-Approved-At: Tue, 30 Apr 2019 10:05:53 +0200 Cc: twischer@de.adit-jv.com, alsa-devel@alsa-project.org, Vanitha Channaiah Subject: [alsa-devel] [PATCH 2/5] pcm: dshare: Added "hw_ptr_alignment" option in configuration for alignment of slave pointers X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vanitha Channaiah snd_pcm_wait() is waiting for longer time more than two periodic size as avail is less than avail_min by few frames. This is because the hw_ptr read from the kernel during snd_pcm_start() is not period aligned which is ahead of few frames. These changes are adaptation of same fix as given for dmix commit ("6b058fda9dce8f416774ae54975f5706f3f5a6da") ("pcm-dmix-Add-option-to-allow-alignment-of-slave-poin.patch") Signed-off-by: Vanitha Channaiah --- src/pcm/pcm_dshare.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c index f135b5d..45e2597 100644 --- a/src/pcm/pcm_dshare.c +++ b/src/pcm/pcm_dshare.c @@ -333,16 +333,16 @@ static int snd_pcm_dshare_reset(snd_pcm_t *pcm) snd_pcm_direct_t *dshare = pcm->private_data; dshare->hw_ptr %= pcm->period_size; dshare->appl_ptr = dshare->last_appl_ptr = dshare->hw_ptr; - dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr; + snd_pcm_direct_reset_slave_ptr(pcm, dshare); return 0; } -static int snd_pcm_dshare_start_timer(snd_pcm_direct_t *dshare) +static int snd_pcm_dshare_start_timer(snd_pcm_t *pcm, snd_pcm_direct_t *dshare) { int err; snd_pcm_hwsync(dshare->spcm); - dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr; + snd_pcm_direct_reset_slave_ptr(pcm, dshare); err = snd_timer_start(dshare->timer); if (err < 0) return err; @@ -364,7 +364,8 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm) else if (avail < 0) return 0; else { - if ((err = snd_pcm_dshare_start_timer(dshare)) < 0) + err = snd_pcm_dshare_start_timer(pcm, dshare); + if (err < 0) return err; snd_pcm_dshare_sync_area(pcm); } @@ -547,7 +548,8 @@ static snd_pcm_sframes_t snd_pcm_dshare_mmap_commit(snd_pcm_t *pcm, return 0; snd_pcm_mmap_appl_forward(pcm, size); if (dshare->state == STATE_RUN_PENDING) { - if ((err = snd_pcm_dshare_start_timer(dshare)) < 0) + err = snd_pcm_dshare_start_timer(pcm, dshare); + if (err < 0) return err; } else if (dshare->state == SND_PCM_STATE_RUNNING || dshare->state == SND_PCM_STATE_DRAINING) { @@ -755,6 +757,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, dshare->slowptr = opts->slowptr; dshare->max_periods = opts->max_periods; dshare->var_periodsize = opts->var_periodsize; + dshare->hw_ptr_alignment = opts->hw_ptr_alignment; dshare->sync_ptr = snd_pcm_dshare_sync_ptr; retry: From patchwork Tue Apr 30 07:38:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Channaiah Vanitha (RBEI/ECF3)" X-Patchwork-Id: 10922991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B58EF933 for ; Tue, 30 Apr 2019 08:09:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5480288E8 for ; Tue, 30 Apr 2019 08:09:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 986F62891A; Tue, 30 Apr 2019 08:09:08 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C8048288E8 for ; Tue, 30 Apr 2019 08:09:07 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0AAE41698; Tue, 30 Apr 2019 10:08:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0AAE41698 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1556611746; bh=yjWkufP2Di0Bbemdv1s1JjyFyCxT1geWEGlqBNw+qDI=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LCn6QOkx70+05TsUiK2FB00qZdgC252HQiYidT/CBheNHXJIiFCYcQsE4fc2HKNoF h0usy50yU0SQjnoITOcLGd5nQETZ4vFaiagPGMa2eGs+edXXGnHmI32tW/rEbk2hDE GAYFped4C2JYxRdDe8RTEcKdc1KmgnohiVPwQ4r4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EA138F80759; Tue, 30 Apr 2019 10:05:59 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2FB2F896FA; Tue, 30 Apr 2019 09:50:05 +0200 (CEST) Received: from de-out1.bosch-org.com (de-out1.bosch-org.com [139.15.230.186]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CAA21F896AA; Tue, 30 Apr 2019 09:49:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CAA21F896AA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=in.bosch.com header.i=@in.bosch.com header.b="llN9DBWi" Received: from fe0vm1650.rbesz01.com (unknown [139.15.230.188]) by fe0vms0186.rbdmz01.com (Postfix) with ESMTPS id 44tYb81Hdyz1XLFjP; Tue, 30 Apr 2019 09:49:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=in.bosch.com; s=2015-01-21; t=1556610596; bh=j9ghyqlcIsq1VvBEl8XAwe9fmi0UKdHNOBlJj7mLn+I=; l=10; h=From:From:Reply-To:Sender; b=llN9DBWiLpuHPAcMp5SVF+hWF8ILzOoNcRykdu0SBEMJd13C3k1npuEa0921mQnAi +K5Fb2xkpKdIAd+E4o9xSHeu8WH12sRPr0cLCFJquv1djbHPKB8aE76H5ID2u8h3dP s1Ni73DZRh7hrDwu3dSzp27IDQIajAu9zimTS3+c= Received: from fe0vm1740.rbesz01.com (unknown [10.58.172.176]) by fe0vm1650.rbesz01.com (Postfix) with ESMTPS id 44tYb811jPz1CC; Tue, 30 Apr 2019 09:49:56 +0200 (CEST) X-AuditID: 0a3aad14-cc5ff7000000410a-5e-5cc7fe232aba Received: from fe0vm1652.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm1740.rbesz01.com (SMG Outbound) with SMTP id 06.43.16650.32EF7CC5; Tue, 30 Apr 2019 09:49:56 +0200 (CEST) Received: from FE-HUB2000.de.bosch.com (fe-hub2000.de.bosch.com [10.4.103.109]) by fe0vm1652.rbesz01.com (Postfix) with ESMTPS id 44tYb76MkWz5fw; Tue, 30 Apr 2019 09:49:55 +0200 (CEST) Received: from localhost.localdomain (10.47.103.61) by FE-HUB2000.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 15.1.1713.5; Tue, 30 Apr 2019 09:49:54 +0200 From: To: Date: Tue, 30 Apr 2019 13:08:41 +0530 Message-ID: <1556609923-14093-3-git-send-email-vanitha.channaiah@in.bosch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> References: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> MIME-Version: 1.0 X-Originating-IP: [10.47.103.61] X-Brightmail-Tracker: H4sIAAAAAAAAA22Sf0wTZxjHee/646X2luMAfSzVyQ0ZGn+APyY6syxhJqjJmFuymK2JO8ZB G2iLdy1akhFYggbUIaZxpUgjLNNtrYowNmJEpagMAjLIxKANiWgMYMfQwUhkv+52YPvH/nve 7/N8nu/7fvNikrmsNWCLzcELNq6I1ehUuh0XVqxP+bvblD4VRJm/DAaJzAvny9WZTafriLfJ 7ObfP9dke4/6te8RH+l25vFFlhJe2PjWJzqz98GAtvj75MP9N94vR+eM1SgWA70Fep9Uomqk wwztIaCi/5haOVxF8GOFV6McAggaB3/VyoiGToWbw9NSjXECbYSaIUqWSVqA2vpmQq7jaRuE PJ1quVbRq6F1/gdSrin6XQjUv0CK80oYuVP1nx5L58DIsFsjr2SkmaH+5cp4HPTUPVYp6wE6 x8dJBV0F7mGP+iSivVFj3qixs4j4DiXm8+kl1oxtW9I3CLm8WJqeseFTu7UFKRkmtKP5YH4Q 0RixeqpwqtvEqLkS0WUNoq2YYBOp/FJJeiXXnucyc6L5gOAs4kXWQBl/3mNi4l/KojPXahFF i90WRIBJNoHK7r5lYqg8zlXKC3YFC6IkrGKXUQU4x8TQBZyDL+T5Yl5Y7L6JMQvU9nnJME7g C/jD+ZYix2KbXUGhmJgYZml0J9qWwLFBtBnrJW/vn9IKSizmrKKlYAFfruDMohpBe1EW7px7 2EAyKpvdxhuWUbv+knhanjQ7bS9vYDBSwN40MYlRjciWSTSCpAzjqU0yrJe+asQbqCQ5rrgF MQJt+lpi6It66Jq+gsDXPotgrGaWBPelRg3MtF3VQNfZSi0MXfFqwVN7GkOf76QO/GHfEvjm 2cQS+CrUoAd/IETD/cEvGfBMhBkYbapPkIjrieCZqgP4qbkDIBQ+Z4DAwztJ8M/khBFGq2eM 8PRRxUq49OzpKhjorEmGntE/UuBa+berYbylMhWO//YgFbrCfWnQd7dl7aQULCEFe8B3Ww7W wTn+J9gFNfI6Qzl6Z9dR/2R/bdyZIw1lm1ubLh7kP7a2VVWJj/a59q7zuQcKj7StX7N92xdj uOuG58WJ42MdH+52Zx27PvyGoz2UVXnw/P6l9/SHwrdeSzvBGAuT98/Nnrq9RtOdUpZzbfBV c8/OHTW9gTPO5y2Nrc45/2cVM2nrPtg6feiU6/Wyjt7n+y5nsCrRzGWsJQWR+xd/zXr/RAQA AA== X-Mailman-Approved-At: Tue, 30 Apr 2019 10:05:53 +0200 Cc: twischer@de.adit-jv.com, alsa-devel@alsa-project.org, Vanitha Channaiah Subject: [alsa-devel] [PATCH 3/5] pcm: dsnoop: Added "hw_ptr_alignment" option in configuration for slave pointer alignment X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vanitha Channaiah snd_pcm_wait() is waiting for longer time more than two periodic size as avail is less than avail_min by few frames. This is because the hw_ptr read from the kernel during snd_pcm_start() is not period aligned which is ahead of few (Nperiod + 1)frames. Signed-off-by: Vanitha Channaiah --- src/pcm/pcm_direct.c | 7 ++++--- src/pcm/pcm_dmix.c | 2 ++ src/pcm/pcm_dshare.c | 2 ++ src/pcm/pcm_dsnoop.c | 5 ++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 411a035..b56da85 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -2043,11 +2043,12 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, void snd_pcm_direct_reset_slave_ptr(snd_pcm_t *pcm, snd_pcm_direct_t *dmix) { - dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr; - + /* For buffer size less than two period size, the start position + * of slave app ptr is rounded up in order to avoid xruns + */ if (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_ROUNDUP || (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO && - pcm->buffer_size <= pcm->period_size * 2)) + pcm->buffer_size < pcm->period_size * 2)) dmix->slave_appl_ptr = ((dmix->slave_appl_ptr + dmix->slave_period_size - 1) / dmix->slave_period_size) * dmix->slave_period_size; diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index dcde40d..274726e 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -562,6 +562,7 @@ static int snd_pcm_dmix_reset(snd_pcm_t *pcm) snd_pcm_direct_t *dmix = pcm->private_data; dmix->hw_ptr %= pcm->period_size; dmix->appl_ptr = dmix->last_appl_ptr = dmix->hw_ptr; + dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr; snd_pcm_direct_reset_slave_ptr(pcm, dmix); return 0; } @@ -571,6 +572,7 @@ static int snd_pcm_dmix_start_timer(snd_pcm_t *pcm, snd_pcm_direct_t *dmix) int err; snd_pcm_hwsync(dmix->spcm); + dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr; snd_pcm_direct_reset_slave_ptr(pcm, dmix); err = snd_timer_start(dmix->timer); if (err < 0) diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c index 45e2597..3847645 100644 --- a/src/pcm/pcm_dshare.c +++ b/src/pcm/pcm_dshare.c @@ -333,6 +333,7 @@ static int snd_pcm_dshare_reset(snd_pcm_t *pcm) snd_pcm_direct_t *dshare = pcm->private_data; dshare->hw_ptr %= pcm->period_size; dshare->appl_ptr = dshare->last_appl_ptr = dshare->hw_ptr; + dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr; snd_pcm_direct_reset_slave_ptr(pcm, dshare); return 0; } @@ -342,6 +343,7 @@ static int snd_pcm_dshare_start_timer(snd_pcm_t *pcm, snd_pcm_direct_t *dshare) int err; snd_pcm_hwsync(dshare->spcm); + dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr; snd_pcm_direct_reset_slave_ptr(pcm, dshare); err = snd_timer_start(dshare->timer); if (err < 0) diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c index d08b624..2bbbc2d 100644 --- a/src/pcm/pcm_dsnoop.c +++ b/src/pcm/pcm_dsnoop.c @@ -278,6 +278,7 @@ static int snd_pcm_dsnoop_reset(snd_pcm_t *pcm) dsnoop->hw_ptr %= pcm->period_size; dsnoop->appl_ptr = dsnoop->hw_ptr; dsnoop->slave_appl_ptr = dsnoop->slave_hw_ptr; + snd_pcm_direct_reset_slave_ptr(pcm, dsnoop); return 0; } @@ -285,12 +286,13 @@ static int snd_pcm_dsnoop_start(snd_pcm_t *pcm) { snd_pcm_direct_t *dsnoop = pcm->private_data; int err; - + if (dsnoop->state != SND_PCM_STATE_PREPARED) return -EBADFD; snd_pcm_hwsync(dsnoop->spcm); snoop_timestamp(pcm); dsnoop->slave_appl_ptr = dsnoop->slave_hw_ptr; + snd_pcm_direct_reset_slave_ptr(pcm, dsnoop); err = snd_timer_start(dsnoop->timer); if (err < 0) return err; @@ -627,6 +629,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, dsnoop->max_periods = opts->max_periods; dsnoop->var_periodsize = opts->var_periodsize; dsnoop->sync_ptr = snd_pcm_dsnoop_sync_ptr; + dsnoop->hw_ptr_alignment = opts->hw_ptr_alignment; retry: if (first_instance) { From patchwork Tue Apr 30 07:38:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Channaiah Vanitha (RBEI/ECF3)" X-Patchwork-Id: 10922995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B31015A6 for ; Tue, 30 Apr 2019 08:09:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB67288E8 for ; Tue, 30 Apr 2019 08:09:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 010812891A; Tue, 30 Apr 2019 08:09:48 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 95A6A288E8 for ; Tue, 30 Apr 2019 08:09:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A68AD16AA; Tue, 30 Apr 2019 10:08:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A68AD16AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1556611785; bh=ZWfb7l6+OOQV7ho8QQfHejbcFoCBO1pjL6G4Er8wNNU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Qn6+USwCYQdcuR5r36UYWFBnTkisUPPjoT1DYRDCZeN+AYAllfirQGlhIeFukLGDp QjDg/giaS54xQWwPi1IfccWibitfnDHVsLV/9BVSRk/4hB2zIUwWZYaFtEFOax3QyD KGnKzFRsZrnTcog00EJv7WR6Gqn43IRpN8w5S2k8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DE89BF89728; Tue, 30 Apr 2019 10:06:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id B65ADF896F3; Tue, 30 Apr 2019 09:50:06 +0200 (CEST) Received: from de-out1.bosch-org.com (de-out1.bosch-org.com [139.15.230.186]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1B05CF80759; Tue, 30 Apr 2019 09:49:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1B05CF80759 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=in.bosch.com header.i=@in.bosch.com header.b="fcIjrztF" Received: from si0vm1947.rbesz01.com (unknown [139.15.230.188]) by si0vms0216.rbdmz01.com (Postfix) with ESMTPS id 44tYb93lrdz1XLG6y; Tue, 30 Apr 2019 09:49:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=in.bosch.com; s=2015-01-21; t=1556610597; bh=j9ghyqlcIsq1VvBEl8XAwe9fmi0UKdHNOBlJj7mLn+I=; l=10; h=From:From:Reply-To:Sender; b=fcIjrztFJIKf53dDzesf0ECDgFb8N/e7CWWNt9l0eKG/lK04a3ks5O0EVSXGBUqH4 Ry5S1VKApFzkNfozAHYYZKwKjYdsaVBQX5u/ILvK68t0pHSvJNG61jiCmp8+LPRh/l cKYyXX5o8z3uD0XezGyL1MboblXJ2JG7FHgccFy4= Received: from fe0vm7918.rbesz01.com (unknown [10.58.172.176]) by si0vm1947.rbesz01.com (Postfix) with ESMTPS id 44tYb93S87z6CjQSN; Tue, 30 Apr 2019 09:49:57 +0200 (CEST) X-AuditID: 0a3aad10-057ff70000007f88-7a-5cc7fe257b51 Received: from si0vm1949.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm7918.rbesz01.com (SMG Outbound) with SMTP id CA.07.32648.52EF7CC5; Tue, 30 Apr 2019 09:49:57 +0200 (CEST) Received: from FE-HUB2000.de.bosch.com (unknown [10.4.103.109]) by si0vm1949.rbesz01.com (Postfix) with ESMTPS id 44tYb91GsYz6CjZrT; Tue, 30 Apr 2019 09:49:57 +0200 (CEST) Received: from localhost.localdomain (10.47.103.61) by FE-HUB2000.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 15.1.1713.5; Tue, 30 Apr 2019 09:49:55 +0200 From: To: Date: Tue, 30 Apr 2019 13:08:42 +0530 Message-ID: <1556609923-14093-4-git-send-email-vanitha.channaiah@in.bosch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> References: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> MIME-Version: 1.0 X-Originating-IP: [10.47.103.61] X-Brightmail-Tracker: H4sIAAAAAAAAA22SWUwTaxTH+Wa6TCtDpkMLhwrGTESJiQiKUqUx8iRxJcGHm3ub4CDTJVIg M4UI3geuuS7FFW0MICJRXALiJeiDWyQUsbhAhGABNXUnWrE2Lrku1TiTgu2DL1/O9z/nd/75 /vkInD6l1BO2UgfHl7IljEItUy/vSFmQ+sNjyuh2aQwjQ27M0HGmRm44caQBW4nndX7Yrshr 3NWuzMf+VBuLuRJbJccvXLFJbW379BUvdyZsveC01qD3dC1SEUBlwVCvF9UiNUFT9Rh8HW2f uvyHoGnfMVn4cg5B6+RhhYQoqLlwwxtU1iKC0FLJcGCYlGSc4qHuaCcm1fHUcgg0/Y+kWkal wv2moEyqSWo91HV+U4adZ8H4oBOXahW1Aca9LoW0khZnhgeSwuMauNXwQhZeD9Dz6hUeRmeD y1svP4ioxqixxqixFoS1IZ2Zy6i0Zy/LNKTzRZxQnZGZvrnM3oXCGVKX0OXbZjeiCMTEkvaA x0TL2Uqhyu5GSwiM0ZHmalGKKyorrrKygrWQryjhBEZPJt9bbaLjf8lCRZHdJgi2slI3AgJn tGSep89Ek8VsVTXHl4UxN5pJyJhE0kJsMNGUhXVwWziunOOnuzkEwQC57JtoqOE5C7fVbCtx TLeZFBLFxMTQCdGdaFuMULnRYiJW9N4orSCFctYu2CxTeFIYp6fVCHobZesTSTwkMpTUtVaU /nLVJ5PA3DDRuqhGhPSjcSTmFk8qJThW/J4RPyBnShFppsQItOiUyFB7lPBocj+C5kufEAxf aVSCLzAQB2c7nsbBWI9TC3fvD+ug2/9dB4GWfxLh+PM3eghdfZkCvZP186D7zjXx6AnMg/62 ljRxuGs++Fw70iE0+jILgtv7l0DQPbAUvgydzwbfTrcBQo+bjfD5gc8IrYOnc+H8ufZc6A1e yQX/8brVsNfpWgO+04F1cLavMx++fGwt8IthYmKYhc03pTAdrOM3YU6pkdfpa9DsicV/36Ji 01o+P9Q+sL55xht3pxwiC9p2T9w5qc1burbh7bH9BSMXRrVY0scxY1/qeAGXv8Zs6orRvE4/ McNbH5Ln3Myp8GxL1fybpq1r+Gtwp/yD6kjWxXVzDM/0BssLz2VV75OOrMF39EChoWfjjJFV T/+YGPueMPd6bj8bSPAzMsHKZs7HeYH9CWjZ6io4BAAA X-Mailman-Approved-At: Tue, 30 Apr 2019 10:05:53 +0200 Cc: twischer@de.adit-jv.com, alsa-devel@alsa-project.org, Vanitha Channaiah Subject: [alsa-devel] [PATCH 4/5] pcm: restructuring sw params function X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vanitha Channaiah snd_pcm_sw_params() is reformatted by using _snd_pcm_sw_params_internal() function Signed-off-by: Vanitha Channaiah --- src/pcm/pcm.c | 12 +----------- src/pcm/pcm_local.h | 1 + src/pcm/pcm_params.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 3a71d79..f0db545 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -968,21 +968,11 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) } #endif __snd_pcm_lock(pcm); /* forced lock due to pcm field change */ - err = pcm->ops->sw_params(pcm->op_arg, params); + err = _snd_pcm_sw_params_internal(pcm, params); if (err < 0) { __snd_pcm_unlock(pcm); return err; } - pcm->tstamp_mode = params->tstamp_mode; - pcm->tstamp_type = params->tstamp_type; - pcm->period_step = params->period_step; - pcm->avail_min = params->avail_min; - pcm->period_event = sw_get_period_event(params); - pcm->start_threshold = params->start_threshold; - pcm->stop_threshold = params->stop_threshold; - pcm->silence_threshold = params->silence_threshold; - pcm->silence_size = params->silence_size; - pcm->boundary = params->boundary; __snd_pcm_unlock(pcm); return 0; } diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index d52229d..e103f72 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -661,6 +661,7 @@ static inline int muldiv_near(int a, int b, int c) return n; } +int _snd_pcm_sw_params_internal(snd_pcm_t *pcm, snd_pcm_sw_params_t *params); int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); int _snd_pcm_hw_params_internal(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); #undef _snd_pcm_hw_params diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 8826bc3..3ba05fb 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -2439,3 +2439,24 @@ int _snd_pcm_hw_params_internal(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) return 0; } +int _snd_pcm_sw_params_internal(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) +{ + int err; + + assert(pcm && params); + assert(pcm->setup); + err = pcm->ops->sw_params(pcm->op_arg, params); + if (err < 0) + return err; + pcm->tstamp_mode = params->tstamp_mode; + pcm->tstamp_type = params->tstamp_type; + pcm->period_step = params->period_step; + pcm->avail_min = params->avail_min; + pcm->period_event = sw_get_period_event(params); + pcm->start_threshold = params->start_threshold; + pcm->stop_threshold = params->stop_threshold; + pcm->silence_threshold = params->silence_threshold; + pcm->silence_size = params->silence_size; + pcm->boundary = params->boundary; + return 0; +} From patchwork Tue Apr 30 07:38:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Channaiah Vanitha (RBEI/ECF3)" X-Patchwork-Id: 10922997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FD60933 for ; Tue, 30 Apr 2019 08:10:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C2EB2856E for ; Tue, 30 Apr 2019 08:10:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C6E128739; Tue, 30 Apr 2019 08:10:21 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E9402856E for ; Tue, 30 Apr 2019 08:10:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9CFD016BA; Tue, 30 Apr 2019 10:09:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9CFD016BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1556611818; bh=Nc1RsfuVcvZYKrE6ysYDvS97ixbGJH3kJQrveXFwJHw=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pFN6GDSBZ2CIvnwSi3OygmpECC5w+XSCJeG8cAHD0UX7OBAU3q1cdYZswZOcFY1FN iTjsZvnu59AasBgfP1XtYKMY4lMv0+JL/qy0Tdz86CBtag3pKm27tThyeWc7s7Li1k /n6psrPi2xvY1LeebEiR6O2VI5eH1YJdC4WzNQ1A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A89BFF8972D; Tue, 30 Apr 2019 10:06:05 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id C6642F8962C; Tue, 30 Apr 2019 09:50:12 +0200 (CEST) Received: from de-out1.bosch-org.com (de-out1.bosch-org.com [139.15.230.186]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 04748F896F0; Tue, 30 Apr 2019 09:49:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 04748F896F0 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=in.bosch.com header.i=@in.bosch.com header.b="rwzXubel" Received: from fe0vm1650.rbesz01.com (unknown [139.15.230.188]) by si0vms0217.rbdmz01.com (Postfix) with ESMTPS id 44tYbB5FBhz4f3kZB; Tue, 30 Apr 2019 09:49:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=in.bosch.com; s=2015-01-21; t=1556610598; bh=j9ghyqlcIsq1VvBEl8XAwe9fmi0UKdHNOBlJj7mLn+I=; l=10; h=From:From:Reply-To:Sender; b=rwzXubelxUT9yPHohxc80uBaDvWXMMdmNgQ35dFvDZhPLl059/ZoyCG9rfWNbQJIV BXveWEh4CkxuuVMu0B7yrgOIhpRHVyFnuGnu/dmT2pJrsxA52vAlLncQh5fpjs0Kce pKIc1gmL9+VL8OyXUjBhMSm5rxMyi1VWGZ8a+nxg= Received: from fe0vm02900.rbesz01.com (unknown [10.58.172.176]) by fe0vm1650.rbesz01.com (Postfix) with ESMTPS id 44tYbB4yw6z1CT; Tue, 30 Apr 2019 09:49:58 +0200 (CEST) X-AuditID: 0a3aad0c-d19ff700000039d6-7a-5cc7fe26c224 Received: from si0vm1949.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm02900.rbesz01.com (SMG Outbound) with SMTP id 4E.9F.14806.62EF7CC5; Tue, 30 Apr 2019 09:49:58 +0200 (CEST) Received: from FE-HUB2000.de.bosch.com (unknown [10.4.103.109]) by si0vm1949.rbesz01.com (Postfix) with ESMTPS id 44tYbB2tpNz6CjZrN; Tue, 30 Apr 2019 09:49:58 +0200 (CEST) Received: from localhost.localdomain (10.47.103.61) by FE-HUB2000.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 15.1.1713.5; Tue, 30 Apr 2019 09:49:57 +0200 From: To: Date: Tue, 30 Apr 2019 13:08:43 +0530 Message-ID: <1556609923-14093-5-git-send-email-vanitha.channaiah@in.bosch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> References: <1556609923-14093-1-git-send-email-vanitha.channaiah@in.bosch.com> MIME-Version: 1.0 X-Originating-IP: [10.47.103.61] X-Brightmail-Tracker: H4sIAAAAAAAAA22SbUxTVxjHe25fOHRcvNxCeSig5o41mcFSUSe+Rk00xGSyLFkWtyZ6kUvb 0EJzbykvyUw1kSrxDSVoS2CbUXFuiDI+4FyC60BSNhat2tnZgVucIcRoM6jK5tu9Fmw/+OXk Of/n+T3/nH8OltNnUnTYWu3k+GrWxqjUCvWq7vzF+hfDJuPZvQtKbl73EyXdXW5lyck2L7Fe Xnphao+q1Of5NuUj4jP1mgrOZnVxfNG6HWpLePyA0nEpu/6vn5+q3OiyphmlYqCWwXPPblUz UmOa8hLwz2CfMn7pQbDvd68ifvkOQU/HiFxCVJQeBkPRlGaEcSaVB4eDpCTLKR5a2i8QUq2h qmDq/AGVVCuo9yA4GkBSTVJb4eiT7+Vx5/kQ/m3/6zqVKoNwqFUlraTFmeBoTnw8AwLee4r4 eoCfJiZm0YXQGjqhPIIoX9KYL2nsK0ScQ9pKzuiyG4tXGo0GvpwTGo1LDDtr7L0onmJaPxo6 ZfYjCiMmjXz8cNhEK1mX0GD3o+WYYLLIykZRSi+vqWiwsIJlO19r4wRGR+Zd22KiNW9kobbc bhUEa021HwGWM5lk6fCQiSYr2IZGjq+JY36UixVMNmnGZSaaMrNOrorjHBw/112NMQPkyv9F wwyeM3P1lVabc67N5JNIJpPR2uROsi2BU/1oKU4TvX3PxBWk4GDtgtU8i+fEcXpOTaAjaIUu m9z0XGQoqWuprX7jqssjgRk00VlJjQQ5iW4jMTcNWSzBaeIHTfgBmStFlDErJqDiUyJDncMQ 9edBoPMqgs7+GIIZzzUCzgbuKmDwcpsSIk/+U0H07xgJIU+UhumjVzQwvT+UCb/eCmZB38gD gKd3x3Lg4vhoLky+HMqH6J5DDMTctxh4NhB4V5zrLYCB8/cLIDLVooepYxG9pC2CsQeXCsVj phBOtMQWw1jrXgP86Bk3iKsOFsHtjgEjhPu/KZ4UsyTELLd3XpWydLLOt2Q5qyYep3Ojbcc/ Jv5t37yz8crSk1u6+j9tnrA9Gu/9ele46Q8fm15YIOua1/HBaVn69Ax+py76xZ2bYZ3/4nqv 1r3AUb/2E9kGRXSh9viNNVWudb/sWF4nTMdc+U1Fkb7wLvfkn7I7Ef3jug913fNevv/l503W smXBe4a21cir7QlsffjDxm29OQ5GIVjYJYvkvMC+AiZPUk45BAAA X-Mailman-Approved-At: Tue, 30 Apr 2019 10:05:53 +0200 Cc: twischer@de.adit-jv.com, alsa-devel@alsa-project.org, Vanitha Channaiah Subject: [alsa-devel] [PATCH 5/5] pcm: Update pcm->avail_min with needed_slave_avail_min, after reading unaligned frames X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vanitha Channaiah Issue: After partial read of unaligned frames, snd_pcm_wait() would block for the pcm->avail_min which would result in blocking of snd_pcm_wait() for longer periods i.e more than one period as specified by avail_min Fix: After reading unaligned frames, set the pcm->avail_min to the needed available frames so that snd_pcm_wait() blocks till needed available frames. Once needed available frames are read, set back the original pcm->avail_min Signed-off-by: Vanitha Channaiah --- src/pcm/pcm.c | 21 +++++++++++++++++++++ src/pcm/pcm_local.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index f0db545..f361eb1 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -973,6 +973,7 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) __snd_pcm_unlock(pcm); return err; } + pcm->original_avail_min = pcm->avail_min; __snd_pcm_unlock(pcm); return 0; } @@ -7267,6 +7268,17 @@ void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, snd_pcm_unlock(pcm); } +static void snd_pcm_set_avail_min(snd_pcm_t *pcm, snd_pcm_uframes_t avail) +{ + if (avail != pcm->avail_min) { + snd_pcm_sw_params_t swparams; + + snd_pcm_sw_params_current(pcm, &swparams); + swparams.avail_min = avail; + _snd_pcm_sw_params_internal(pcm, &swparams); + } +} + snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t size, snd_pcm_xfer_areas_func_t func) @@ -7274,6 +7286,7 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_ snd_pcm_uframes_t xfer = 0; snd_pcm_sframes_t err = 0; snd_pcm_state_t state; + snd_pcm_uframes_t needed_slave_avail_min = 0; if (size == 0) return 0; @@ -7332,6 +7345,14 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_ if (err < 0) break; frames = err; + pcm->unaligned_frames += frames; + pcm->unaligned_frames %= pcm->period_size; + if (pcm->unaligned_frames) { + needed_slave_avail_min = pcm->period_size - pcm->unaligned_frames; + snd_pcm_set_avail_min(pcm, needed_slave_avail_min); + } else { + snd_pcm_set_avail_min(pcm, pcm->original_avail_min); + } offset += frames; size -= frames; xfer += frames; diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index e103f72..3fdffb4 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -210,6 +210,8 @@ struct _snd_pcm { snd_pcm_tstamp_type_t tstamp_type; /* timestamp type */ unsigned int period_step; snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */ + snd_pcm_uframes_t unaligned_frames; + snd_pcm_uframes_t original_avail_min; int period_event; snd_pcm_uframes_t start_threshold; snd_pcm_uframes_t stop_threshold;