Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3538468pxb; Mon, 1 Mar 2021 12:42:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfRK3Saeo/RSltkk5P7d/b9zwBhqkSRzT26EI0GGH4fWvR9JP5WUx6j7UqB0/V/FGw97+c X-Received: by 2002:a17:906:33d9:: with SMTP id w25mr17226938eja.413.1614631339979; Mon, 01 Mar 2021 12:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614631339; cv=none; d=google.com; s=arc-20160816; b=TJnIdBLN/kTb0aX0QMCktpvexOg5sv/nNOxNm19iaaF7mAn0S2upA+gKSxiiqYs6IC ONZc4c7Lc7mj9Ip2akuhrHUN1viAdOUtZJ7OkRP2YXhpLe17EQQks/y99x3Jq5OWyM3P mO1mMue7UNM2Y4Y2gTa7hZwkgHksQCiuVRDe+H3m2KlqaFI5xVjLoqnET6FOiOKp/GXV W3P8R1NJPNjN78k/YPHIU1LAanzynfa0mIBHaWd4XO1XcHWzzX/tiWFC8bU2jpdVELCh x9kFggi7MW9IUmHmqGDVEbyTEzgESD4Iv8I+nhDNXJp4Ff0sjJxP2a79FiL2JjQAMQmu G5PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yFt99+jkLHtAbv1mI+Oa2C/S8Mv8DD1/Eu0lbQ0w6Jo=; b=UZJwKQxS6SimuxoteZi8qEZnbrKtnALp2H9AdSQA70YMKaJ+TcGn4QGbk8WUF6YZWO Dmf3lvf/JWMFnspj9RJv4bBlhsSrsxfGB+Wdi6Xdu3oAjIMmK1xgrXOJLyasq31p3Eal 7YiH+dgwldaZhdptK2fwzjGMOFjZW80CSCWzfg5DQsISWyZm0cFYcDszU7z+LczgLVQK VBXsfRKg0/1II2NrNivmBwhIgFMakIRBXQ75caUFUicPl/+NtV6Usb9ae6bqojMwyBRy ntld/edfCgERzCPG68U8PK85vEyKGPigUDmyBMFAWX+rZJaSf3MMRILfVoA2JSzrG+aA KY7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WLFQFxgA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si11710609ejj.217.2021.03.01.12.41.57; Mon, 01 Mar 2021 12:42:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WLFQFxgA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243691AbhCAUjF (ORCPT + 99 others); Mon, 1 Mar 2021 15:39:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:35318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237513AbhCARIV (ORCPT ); Mon, 1 Mar 2021 12:08:21 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85CFF64F89; Mon, 1 Mar 2021 16:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616878; bh=1K//8isw1juxlFVhKO+odgoTL/ejvfqUNdvt0tZ8fzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WLFQFxgAroesq993U8EkbOW4EtbJR4Lvht5UQEdnRrJ1LyeBTABl4ooPJWVZlugG8 OKqEib/Ltm8rNvd5Wpjrac1Pm22ZTlIRp76imO2IM5e09b+FG+vg1WNrVsU3A1IHYc zTKJflSluSJpbVZyZ5me4FVNUN0soMIxpD9mAeVI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Sebastian Reichel , Tony Lindgren , Mark Brown , Sasha Levin Subject: [PATCH 4.19 096/247] ASoC: cpcap: fix microphone timeslot mask Date: Mon, 1 Mar 2021 17:11:56 +0100 Message-Id: <20210301161036.378775226@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Reichel [ Upstream commit de5bfae2fd962a9da99f56382305ec7966a604b9 ] The correct mask is 0x1f8 (Bit 3-8), but due to missing BIT() 0xf (Bit 0-3) was set instead. This means setting of CPCAP_BIT_MIC1_RX_TIMESLOT0 (Bit 3) still worked (part of both masks). On the other hand the code does not properly clear the other MIC timeslot bits. I think this is not a problem, since they are probably initialized to 0 and not touched by the driver anywhere else. But the mask also contains some wrong bits, that will be cleared. Bit 0 (CPCAP_BIT_SMB_CDC) should be safe, since the driver enforces it to be 0 anyways. Bit 1-2 are CPCAP_BIT_FS_INV and CPCAP_BIT_CLK_INV. This means enabling audio recording forces the codec into SND_SOC_DAIFMT_NB_NF mode, which is obviously bad. The bug probably remained undetected, because there are not many use cases for routing microphone to the CPU on platforms using cpcap and user base is small. I do remember having some issues with bad sound quality when testing voice recording back when I wrote the driver. It probably was this bug. Fixes: f6cdf2d3445d ("ASoC: cpcap: new codec") Reported-by: Dan Carpenter Signed-off-by: Sebastian Reichel Reviewed-by: Tony Lindgren Link: https://lore.kernel.org/r/20210123172945.3958622-1-sre@kernel.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/cpcap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c index d7f05b384f1fb..1902689c5ea2c 100644 --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -1263,12 +1263,12 @@ static int cpcap_voice_hw_params(struct snd_pcm_substream *substream, if (direction == SNDRV_PCM_STREAM_CAPTURE) { mask = 0x0000; - mask |= CPCAP_BIT_MIC1_RX_TIMESLOT0; - mask |= CPCAP_BIT_MIC1_RX_TIMESLOT1; - mask |= CPCAP_BIT_MIC1_RX_TIMESLOT2; - mask |= CPCAP_BIT_MIC2_TIMESLOT0; - mask |= CPCAP_BIT_MIC2_TIMESLOT1; - mask |= CPCAP_BIT_MIC2_TIMESLOT2; + mask |= BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0); + mask |= BIT(CPCAP_BIT_MIC1_RX_TIMESLOT1); + mask |= BIT(CPCAP_BIT_MIC1_RX_TIMESLOT2); + mask |= BIT(CPCAP_BIT_MIC2_TIMESLOT0); + mask |= BIT(CPCAP_BIT_MIC2_TIMESLOT1); + mask |= BIT(CPCAP_BIT_MIC2_TIMESLOT2); val = 0x0000; if (channels >= 2) val = BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0); -- 2.27.0