From patchwork Thu Dec 18 07:36:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang, Libin" X-Patchwork-Id: 5511401 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 D6FDFBEEA8 for ; Thu, 18 Dec 2014 07:41:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 174A8209FD for ; Thu, 18 Dec 2014 07:41:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 17128209E1 for ; Thu, 18 Dec 2014 07:41:14 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id DE2A2261691; Thu, 18 Dec 2014 08:41:12 +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=-0.1 required=5.0 tests=BAYES_00, SUBJ_OBFU_PUNCT_MANY, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id AA92C261528; Thu, 18 Dec 2014 08:41:05 +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 64CC02614AF; Thu, 18 Dec 2014 08:41:04 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id 6CC992604BC for ; Thu, 18 Dec 2014 08:40:55 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 17 Dec 2014 23:39:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,599,1413270000"; d="scan'208";a="656169526" Received: from younglee-grantley.sh.intel.com ([10.239.159.85]) by orsmga002.jf.intel.com with ESMTP; 17 Dec 2014 23:40:52 -0800 From: libin.yang@intel.com To: tiwai@suse.de, broonie@kernel.org, alsa-devel@alsa-project.org Date: Thu, 18 Dec 2014 15:36:03 +0800 Message-Id: <1418888164-41117-1-git-send-email-libin.yang@intel.com> X-Mailer: git-send-email 1.9.1 Cc: liam.r.girdwood@linux.intel.com, libin.yang@intel.com Subject: [alsa-devel] [PATCH 1/2] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger 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: Libin Yang Add SNDRV_PCM_TRIGGER_DRAIN trigger for pcm drain. Some audio devices require notification of drain events in order to properly drain and shutdown an audio stream. Signed-off-by: Libin Yang --- include/sound/pcm.h | 1 + sound/core/pcm_native.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 8bb00a2..bb77aa3 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -109,6 +109,7 @@ struct snd_pcm_ops { #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4 #define SNDRV_PCM_TRIGGER_SUSPEND 5 #define SNDRV_PCM_TRIGGER_RESUME 6 +#define SNDRV_PCM_TRIGGER_DRAIN 7 #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 166d59c..15fe682 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1517,6 +1517,11 @@ static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + + if (substream->runtime->trigger_master == substream) + substream->ops->trigger(substream, + SNDRV_PCM_TRIGGER_DRAIN); + switch (runtime->status->state) { case SNDRV_PCM_STATE_PREPARED: /* start playback stream if possible */