From patchwork Tue Jan 30 09:33:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Periyasamy X-Patchwork-Id: 10191481 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 2DBBE601A0 for ; Tue, 30 Jan 2018 09:40:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BE3420121 for ; Tue, 30 Jan 2018 09:40:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1B7128956; Tue, 30 Jan 2018 09:40:31 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham 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 1177D27853 for ; Tue, 30 Jan 2018 09:40:31 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 1EE5D26752D; Tue, 30 Jan 2018 10:40:25 +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 55A11267530; Tue, 30 Jan 2018 10:40:24 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by alsa0.perex.cz (Postfix) with ESMTP id AB20C267523 for ; Tue, 30 Jan 2018 10:40:20 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2018 01:40:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,434,1511856000"; d="scan'208";a="199891206" Received: from mtbf-optiplex-9010.iind.intel.com ([10.223.96.13]) by fmsmga006.fm.intel.com with ESMTP; 30 Jan 2018 01:40:16 -0800 From: Sriram Periyasamy To: ALSA ML , Takashi Iwai Date: Tue, 30 Jan 2018 15:03:28 +0530 Message-Id: <1517304808-16649-1-git-send-email-sriramx.periyasamy@intel.com> X-Mailer: git-send-email 2.7.4 Cc: Patches Audio , Sriram Periyasamy , Ramesh Babu Subject: [alsa-devel] [alsa-lib] [PATCH] pcm: add set and get methods for no-rewind flag 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 From: Ramesh Babu Add functions to set/get no-rewind flag Signed-off-by: Ramesh Babu Signed-off-by: Sriram Periyasamy --- include/pcm.h | 2 ++ include/sound/asound.h | 1 + src/pcm/pcm.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/pcm/pcm_local.h | 1 + 4 files changed, 44 insertions(+) diff --git a/include/pcm.h b/include/pcm.h index 2619c8cd8bd4..8c0b19c106b0 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -805,6 +805,8 @@ int snd_pcm_hw_params_set_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *par int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val); int snd_pcm_hw_params_set_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val); +int snd_pcm_hw_params_set_no_rewind(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); +int snd_pcm_hw_params_get_no_rewind(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val); int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir); int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir); diff --git a/include/sound/asound.h b/include/sound/asound.h index 6041cab27a23..35fd50ec5395 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -375,6 +375,7 @@ typedef int snd_pcm_hw_param_t; #define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */ #define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER (1<<1) /* export buffer */ #define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP (1<<2) /* disable period wakeups */ +#define SNDRV_PCM_HW_PARAMS_NO_REWINDS (1<<3) /* disable rewinds */ struct snd_interval { unsigned int min, max; diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 69d7d66500ea..c7041be47be6 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -4763,6 +4763,46 @@ int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *par } /** + * \brief Configure no-rewind flag through configuration space + * \param pcm PCM handle + * \param params Configuration space + * \param val 0 = disable (default), 1 = enable (default) no-rewind flag + * \return Zero on success, otherwise a negative error code. + * + * This function can be called to inform driver about application uses rewind or not + * + * Based on no-rewind flag, underlying driver could take decision on buffering scheme. + */ + +/* TODO: Invert the logic with function name set_rewind */ +int snd_pcm_hw_params_set_no_rewind(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) +{ + assert(pcm && params); + + if (val) { + params->flags |= SND_PCM_HW_PARAMS_NO_REWINDS; + } else + params->flags &= ~SND_PCM_HW_PARAMS_NO_REWINDS; + params->rmask = ~0; + + return snd_pcm_hw_refine(pcm, params); +} + +/** + * \brief Extract no-rewind flag from a configuration space + * \param pcm PCM handle + * \param params Configuration space + * \param val 0 = disabled, 1 = enabled no-rewind flag + * \return Zero on success, otherwise a negative error code. + */ +int snd_pcm_hw_params_get_no_rewind(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val) +{ + assert(pcm && params && val); + *val = params->flags & SND_PCM_HW_PARAMS_NO_REWINDS ? 0 : 1; + return 0; +} + +/** * \brief Extract period time from a configuration space * \param params Configuration space * \param val Returned approximate period duration in us diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 3d95e1749169..91479cabff88 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -103,6 +103,7 @@ #define SND_PCM_HW_PARAMS_NORESAMPLE SNDRV_PCM_HW_PARAMS_NORESAMPLE #define SND_PCM_HW_PARAMS_EXPORT_BUFFER SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER #define SND_PCM_HW_PARAMS_NO_PERIOD_WAKEUP SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP +#define SND_PCM_HW_PARAMS_NO_REWINDS SNDRV_PCM_HW_PARAMS_NO_REWINDS #define SND_PCM_INFO_MONOTONIC 0x80000000