From patchwork Thu Feb 2 17:02:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9552547 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 66C93602F0 for ; Thu, 2 Feb 2017 17:07:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B3DA1FFC9 for ; Thu, 2 Feb 2017 17:07:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F4092849C; Thu, 2 Feb 2017 17:07:13 +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 CD9431FFC9 for ; Thu, 2 Feb 2017 17:07:11 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2FD502675F6; Thu, 2 Feb 2017 18:03:32 +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 294A02675C7; Thu, 2 Feb 2017 18:03:24 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id A69C32668E2 for ; Thu, 2 Feb 2017 18:03:16 +0100 (CET) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DA6BCADAC; Thu, 2 Feb 2017 17:03:13 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Thu, 2 Feb 2017 18:02:30 +0100 Message-Id: <20170202170307.24484-18-tiwai@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170202170307.24484-1-tiwai@suse.de> References: <20170202170307.24484-1-tiwai@suse.de> Cc: Pierre-Louis Bossart , Jerome Anand Subject: [alsa-devel] [PATCH 16/53] ALSA: x86: Move the global underrun_count to struct snd_intelhad 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 The last one is in intel_hdmi_audio.c, underrun_count: this can be embedded in snd_intelhad object. Signed-off-by: Takashi Iwai --- sound/x86/intel_hdmi_audio.c | 15 +++++++-------- sound/x86/intel_hdmi_audio.h | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index ed9db2ebe9cf..e08691110a48 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c @@ -40,7 +40,6 @@ /*standard module options for ALSA. This module supports only one card*/ static int hdmi_card_index = SNDRV_DEFAULT_IDX1; static char *hdmi_card_id = SNDRV_DEFAULT_STR1; -static int underrun_count; module_param_named(index, hdmi_card_index, int, 0444); MODULE_PARM_DESC(index, @@ -969,7 +968,7 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream) intelhaddata = snd_pcm_substream_chip(substream); had_stream = intelhaddata->private_data; runtime = substream->runtime; - underrun_count = 0; + intelhaddata->underrun_count = 0; pm_runtime_get(intelhaddata->dev); @@ -1376,19 +1375,19 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer( AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH), &t); if ((t == 0) || (t == ((u32)-1L))) { - underrun_count++; + intelhaddata->underrun_count++; pr_debug("discovered buffer done for buf %d, count = %d\n", - buf_id, underrun_count); + buf_id, intelhaddata->underrun_count); - if (underrun_count > (HAD_MIN_PERIODS/2)) { + if (intelhaddata->underrun_count > (HAD_MIN_PERIODS/2)) { pr_debug("assume audio_codec_reset, underrun = %d - do xrun\n", - underrun_count); - underrun_count = 0; + intelhaddata->underrun_count); + intelhaddata->underrun_count = 0; return SNDRV_PCM_POS_XRUN; } } else { /* Reset Counter */ - underrun_count = 0; + intelhaddata->underrun_count = 0; } t = intelhaddata->buf_info[buf_id].buf_size - t; diff --git a/sound/x86/intel_hdmi_audio.h b/sound/x86/intel_hdmi_audio.h index 110d1d083000..da0a927d37fe 100644 --- a/sound/x86/intel_hdmi_audio.h +++ b/sound/x86/intel_hdmi_audio.h @@ -119,6 +119,7 @@ struct had_pvt_data { * @chmap: holds channel map info * @audio_reg_base: hdmi audio register base offset * @hw_silence: flag indicates SoC support for HW silence/Keep alive + * @underrun_count: PCM stream underrun counter */ struct snd_intelhad { struct snd_card *card; @@ -142,6 +143,7 @@ struct snd_intelhad { unsigned int *audio_reg_base; unsigned int audio_cfg_offset; bool hw_silence; + int underrun_count; }; int had_event_handler(enum had_event_type event_type, void *data);