Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2728409imm; Tue, 4 Sep 2018 09:04:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYykM2QTwpjirxYZAii57Mmyoi8CNxGjE8FtRBEqTklLIyjlle7XOnQqvplcoULDRsFAThC X-Received: by 2002:a63:2354:: with SMTP id u20-v6mr17449435pgm.122.1536077089031; Tue, 04 Sep 2018 09:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536077089; cv=none; d=google.com; s=arc-20160816; b=qyIPkmI80BWARdDGwAhF9o8tvMSQ/X2ddrhiRCGZJ/O+t0BHOmjVuawJnT0Zl8H/x/ FZ3F+i5pvcpl9q9Zo1FFqSF+ICXPS0iUDAb63uimEytAu3ZoW/M/KpdioeAgbjabCSzz puFRUXZoJPjB+wI5d5MrGuOOkEjRfn2apTiGXS6FNYr3UuZNo6Yjkm8VstIPKQDRh1HE 5NtyXgD8PPrYOBdbzN3XTNSdlTOhpMX8KSgTmPDL/4qs+1Yivh3e/OEr3lGS0bXjn/kk ibYVQvfofXeaUdUUF1yLiolt58wumuX81/wG2Ym8SkwMH3QRCT9YlW3rsXBI8ioR8QZk nWMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rMtGPkOH0/aywGFNyk9TNNlUZlPLpw28zylPDmPk55k=; b=dBFhRxL1TuiBdzF6GYI4BJgcM7WMUh3BkO3YETmwrpzvzOjg4yckxTCzc2QUe8LVEg EJEgk0+TE/oqVfhj5PSV80o91fiTZTltw6OZzC+fwaN9wxbxwnD5JhislFXFvcpI+Sro hzyyzne8N8QJdqsHLMcia1XVIU5vaHAiKF0VkQUBUxjuQ43i2NqIkPP4LPdpZXr6RAFL rhSnHjYSfCetHDDRmIalCEh5yBBy7r+kLe0EXL3LlDiQjvrfBdT5WdUErl6aQKo73GhI NHsM/6vU7RHIpKJCQuPrDsvCDADhs5rj/jFrBMUqwx05uxTwsb9G91Psq5UnKm+WAWd+ FwIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 74-v6si24330094pfz.160.2018.09.04.09.04.25; Tue, 04 Sep 2018 09:04:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728212AbeIDU1I (ORCPT + 99 others); Tue, 4 Sep 2018 16:27:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:50976 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727672AbeIDUYs (ORCPT ); Tue, 4 Sep 2018 16:24:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 032FBB0A4; Tue, 4 Sep 2018 15:59:02 +0000 (UTC) From: Takashi Iwai To: Greg Kroah-Hartman Cc: Eric Anholt , Stefan Wahren , linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/29] staging: bcm2835-audio: Fix incorrect draining handling Date: Tue, 4 Sep 2018 17:58:38 +0200 Message-Id: <20180904155858.8001-10-tiwai@suse.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904155858.8001-1-tiwai@suse.de> References: <20180904155858.8001-1-tiwai@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The handling of SNDRV_PCM_TRIGGER_STOP at the trigger callback is incorrect: when the STOP is issued, the driver is supposed to drop the stream immediately. Meanwhile bcm2835 driver checks the DRAINING state and tries to issue some different command. This patch straightens things a bit, dropping the incorrect state checks. The draining behavior would be still not perfect at this point, but will be improved in a later patch. Signed-off-by: Takashi Iwai --- .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index b4b9e90131bf..00c2abab4bba 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -153,7 +153,6 @@ static int snd_bcm2835_playback_open_generic( chip->alsa_stream[idx] = alsa_stream; chip->opened |= (1 << idx); - alsa_stream->draining = 1; out: mutex_unlock(&chip->audio_mutex); @@ -268,6 +267,7 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream) alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream); alsa_stream->period_size = snd_pcm_lib_period_bytes(substream); alsa_stream->pos = 0; + alsa_stream->draining = false; audio_debug("buffer_size=%d, period_size=%d pos=%d frame_bits=%d\n", alsa_stream->buffer_size, alsa_stream->period_size, @@ -312,21 +312,15 @@ static int snd_bcm2835_pcm_trigger(struct snd_pcm_substream *substream, int cmd) switch (cmd) { case SNDRV_PCM_TRIGGER_START: err = bcm2835_audio_start(alsa_stream); - if (!err) - alsa_stream->draining = 1; - else + if (err) audio_error(" Failed to START alsa device (%d)\n", err); break; + case SNDRV_PCM_TRIGGER_DRAIN: + alsa_stream->draining = true; + break; case SNDRV_PCM_TRIGGER_STOP: - if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { - audio_info("DRAINING\n"); - alsa_stream->draining = 1; - } else { - audio_info("DROPPING\n"); - alsa_stream->draining = 0; - } err = bcm2835_audio_stop(alsa_stream); - if (err != 0) + if (err) audio_error(" Failed to STOP alsa device (%d)\n", err); break; default: -- 2.18.0