Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp643058pxb; Sat, 6 Mar 2021 11:32:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBhGJ+JLoSjc8+4AuP5HWwe5np+MAocRBmnN1zNQcmm8flLFzH1CVOVaXX/MlHsqxD2WXB X-Received: by 2002:a17:906:aed6:: with SMTP id me22mr8129522ejb.146.1615059143897; Sat, 06 Mar 2021 11:32:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615059143; cv=none; d=google.com; s=arc-20160816; b=uKpTTnkL66oF8PFIuM4JLkN6VW72h6Q7tzcYGhYAJNB+1XByZTWvZgBI/ln3JORu/7 kAD1DxpdpvnDBG6ORSEfYeumkE4MXpCy9MkfROYLac+OdUHaV2xKcmwjf+r6mNOiDxkG 6M512n0itoWN52ZCF4cxGsoJfusOugvazVvPUd3wGvHQBOx0qzGwfXq/YGJfKW5y3i12 MlUMmG6F54A8SWobiXXZQ4IVnkIzixpA/RyqT2BKQz+ULLickICjRethqh0IjK851OeW EA7L23lGKPjsmJjUwwGmCc/5szB1NHlFnzE2iK0URmzXfv0nVe22O3hm1HiWtT+NcL5K 4OMw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g+uVrj2vk3sLaGnylrZQrietKgfFQiATKUhtVSUm6hU=; b=NUPp8Qv2Z0M4ECbGSEJe9hWUJDGv0OHDrYHKxERfs3U21Rmf8VyDlFgzdpx7F/G2OE JUA6LiZwftNczrkOQtcUgqdd7S5r8BCtHLwguR6GJvcuBNpnxRrCfPWXznr6F57ka8AG ERs4WeRe+KIM9uY0V/jYH5sxCz+gXXm8pw3xlxBvEbylBN7g8BgGn77ubvZP4jC0r4Yb eIKKhJ81Wx62QBQto1zjXiWvTQHMYvmrEmhcJOSQBD7za6fQhqCJ3JGrsx6SI5fCZpC8 wNqVzQxMja2lezseQCbG2GKeOg/1OETxRlregMEFgW2ydUOhyRwA++5QWk7Z7ltqvqo0 S3vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=S2Ti0THz; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si4128323edb.607.2021.03.06.11.32.01; Sat, 06 Mar 2021 11:32:23 -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=@cirrus.com header.s=PODMain02222019 header.b=S2Ti0THz; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231550AbhCFTOb (ORCPT + 99 others); Sat, 6 Mar 2021 14:14:31 -0500 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:39008 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231384AbhCFTOR (ORCPT ); Sat, 6 Mar 2021 14:14:17 -0500 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 126J6uDH011401; Sat, 6 Mar 2021 13:13:31 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=g+uVrj2vk3sLaGnylrZQrietKgfFQiATKUhtVSUm6hU=; b=S2Ti0THzBudjUhQc61iZP2AsjFFxWkaCujjJfYB+RWj9tRwN86RiV/3RwYsB8aZAWjp4 AVIceIyrTyunCqmnfQo/5UxRNzIOaQP8vSzEaSQHMYDRmmK/NVWM1e9G730BWNQ6llN4 VQ2PX72oNfjcZCfGtmj/seUwu6EHIX+8tSFhfIvhA6Qckih3RW/m5FaR018C5ePd6SVH foq+lEIo6iEbm9gGFYxP97drYFm6ENC4FRojH+dJEX9TbOi16v1vu+W0XZQDN7OBrKf+ IVV7GGJzp/tWiS8+pKeTPtIzBmW29xnpID6ww7derkGu00pfJ16+U3/0K+Rwwh3Y/9XW hw== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 3748198d06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Sat, 06 Mar 2021 13:13:31 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 6 Mar 2021 18:56:26 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Sat, 6 Mar 2021 18:56:26 +0000 Received: from mail1.cirrus.com (unknown [198.61.64.35]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id AFD7211CF; Sat, 6 Mar 2021 18:56:21 +0000 (UTC) From: Lucas Tanure To: James Schulman , David Rhodes , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai CC: , , , Lucas Tanure Subject: [PATCH v3 02/15] ASoC: cs42l42: Fix channel width support Date: Sat, 6 Mar 2021 18:55:40 +0000 Message-ID: <20210306185553.62053-3-tanureal@opensource.cirrus.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210306185553.62053-1-tanureal@opensource.cirrus.com> References: <20210306185553.62053-1-tanureal@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 adultscore=0 spamscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103060119 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the hard coded 32 bits width and replace with the correct width calculated by params_width. Signed-off-by: Lucas Tanure --- Changes in v3: - No changes Changes in v2: - No changes sound/soc/codecs/cs42l42.c | 47 ++++++++++++++++++-------------------- sound/soc/codecs/cs42l42.h | 1 - 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index df0d5fec0287a..4f9ad95479292 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -691,24 +691,6 @@ static int cs42l42_pll_config(struct snd_soc_component *component) CS42L42_CLK_OASRC_SEL_MASK, CS42L42_CLK_OASRC_SEL_12 << CS42L42_CLK_OASRC_SEL_SHIFT); - /* channel 1 on low LRCLK, 32 bit */ - snd_soc_component_update_bits(component, - CS42L42_ASP_RX_DAI0_CH1_AP_RES, - CS42L42_ASP_RX_CH_AP_MASK | - CS42L42_ASP_RX_CH_RES_MASK, - (CS42L42_ASP_RX_CH_AP_LOW << - CS42L42_ASP_RX_CH_AP_SHIFT) | - (CS42L42_ASP_RX_CH_RES_32 << - CS42L42_ASP_RX_CH_RES_SHIFT)); - /* Channel 2 on high LRCLK, 32 bit */ - snd_soc_component_update_bits(component, - CS42L42_ASP_RX_DAI0_CH2_AP_RES, - CS42L42_ASP_RX_CH_AP_MASK | - CS42L42_ASP_RX_CH_RES_MASK, - (CS42L42_ASP_RX_CH_AP_HI << - CS42L42_ASP_RX_CH_AP_SHIFT) | - (CS42L42_ASP_RX_CH_RES_32 << - CS42L42_ASP_RX_CH_RES_SHIFT)); if (pll_ratio_table[i].mclk_src_sel == 0) { /* Pass the clock straight through */ snd_soc_component_update_bits(component, @@ -824,14 +806,29 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); - int retval; + unsigned int width = (params_width(params) / 8) - 1; + unsigned int val = 0; cs42l42->srate = params_rate(params); - cs42l42->swidth = params_width(params); - retval = cs42l42_pll_config(component); + switch(substream->stream) { + case SNDRV_PCM_STREAM_PLAYBACK: + val |= width << CS42L42_ASP_RX_CH_RES_SHIFT; + /* channel 1 on low LRCLK */ + snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH1_AP_RES, + CS42L42_ASP_RX_CH_AP_MASK | + CS42L42_ASP_RX_CH_RES_MASK, val); + /* Channel 2 on high LRCLK */ + val |= CS42L42_ASP_RX_CH_AP_HI << CS42L42_ASP_RX_CH_AP_SHIFT; + snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH2_AP_RES, + CS42L42_ASP_RX_CH_AP_MASK | + CS42L42_ASP_RX_CH_RES_MASK, val); + break; + default: + break; + } - return retval; + return cs42l42_pll_config(component); } static int cs42l42_set_sysclk(struct snd_soc_dai *dai, @@ -896,9 +893,9 @@ static int cs42l42_mute(struct snd_soc_dai *dai, int mute, int direction) return 0; } -#define CS42L42_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE | \ - SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE | \ - SNDRV_PCM_FMTBIT_S32_LE) +#define CS42L42_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ + SNDRV_PCM_FMTBIT_S24_LE |\ + SNDRV_PCM_FMTBIT_S32_LE ) static const struct snd_soc_dai_ops cs42l42_ops = { diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h index 1f0d67c95a9ad..9b017b76828a4 100644 --- a/sound/soc/codecs/cs42l42.h +++ b/sound/soc/codecs/cs42l42.h @@ -757,7 +757,6 @@ struct cs42l42_private { struct completion pdn_done; u32 sclk; u32 srate; - u32 swidth; u8 plug_state; u8 hs_type; u8 ts_inv; -- 2.30.1