From patchwork Wed Jul 1 20:40:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 6706611 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CD7299F2F0 for ; Wed, 1 Jul 2015 20:41:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECF8E20646 for ; Wed, 1 Jul 2015 20:41:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 8D2B62026D for ; Wed, 1 Jul 2015 20:41:36 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A43C2265473; Wed, 1 Jul 2015 22:41:34 +0200 (CEST) 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 BCEA126517F; Wed, 1 Jul 2015 22:41:27 +0200 (CEST) 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 A2F272651D5; Wed, 1 Jul 2015 22:41:25 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 4B39D26516E for ; Wed, 1 Jul 2015 22:41:18 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 01 Jul 2015 13:41:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,388,1432623600"; d="scan'208";a="738773882" Received: from gjlavell-mobl3.amr.corp.intel.com (HELO pbossart-mobl2.ger.corp.intel.com) ([10.252.8.159]) by fmsmga001.fm.intel.com with ESMTP; 01 Jul 2015 13:41:13 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Date: Wed, 1 Jul 2015 15:40:54 -0500 Message-Id: <1435783258-23730-2-git-send-email-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435783258-23730-1-git-send-email-pierre-louis.bossart@linux.intel.com> References: <1435783258-23730-1-git-send-email-pierre-louis.bossart@linux.intel.com> Cc: tiwai@suse.de, Pierre-Louis Bossart Subject: [alsa-devel] [PATCH v4 1/5] pcm: add helper functions to query timestamping capabilities 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 extend support to link, link_estimated and link_synchronized timestamp. wall-clock is deprecated Signed-off-by: Pierre-Louis Bossart --- include/pcm.h | 3 ++- src/pcm/pcm.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/pcm.h b/include/pcm.h index 0655e7f..2aa1eff 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -668,7 +668,8 @@ int snd_pcm_hw_params_is_half_duplex(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_is_joint_duplex(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_can_sync_start(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_can_disable_period_wakeup(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params); /* deprecated, use audio_ts_type */ +int snd_pcm_hw_params_supports_audio_ts_type(const snd_pcm_hw_params_t *params, int type); int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params, unsigned int *rate_num, unsigned int *rate_den); diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index bc18954..846d502 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -3190,12 +3190,45 @@ int snd_pcm_hw_params_can_disable_period_wakeup(const snd_pcm_hw_params_t *param */ int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params) { + /* deprecated */ + return snd_pcm_hw_params_supports_audio_ts_type(params, + SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT); +} + +/** + * \brief Check if hardware supports type of audio timestamps + * \param params Configuration space + * \param type Audio timestamp type + * \retval 0 Hardware doesn't support type of audio timestamps + * \retval 1 Hardware supports type of audio timestamps + * + * This function should only be called when the configuration space + * contains a single configuration. Call #snd_pcm_hw_params to choose + * a single configuration from the configuration space. + */ +int snd_pcm_hw_params_supports_audio_ts_type(const snd_pcm_hw_params_t *params, int type) +{ assert(params); if (CHECK_SANITY(params->info == ~0U)) { SNDMSG("invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } - return !!(params->info & SNDRV_PCM_INFO_HAS_WALL_CLOCK); + switch (type) { + case SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT: + return !!(params->info & SNDRV_PCM_INFO_HAS_WALL_CLOCK); /* deprecated */ + case SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT: + return 1; /* always supported, based on hw_ptr */ + case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK: + return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_ATIME); + case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ABSOLUTE: + return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_ABSOLUTE_ATIME); + case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ESTIMATED: + return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME); + case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED: + return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME); + default: + return 0; + } } /**