From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796287918; b=X7BsX+1CbhbjvL5Hi6LlwE6nV9i2Uq9EuLwmBdQGBWk0l3dSjumJwoFdcINK/+/W6jiG Uerbco1e91BOemm/rHzNkDToBlpcrJPV9YiyXIS4r1KERki1U3+NZ06OzLL8+d9jwK5s0 ehQVSYgHGUGbWF397CTMA8MOoCgCJFLYAbD2FwrXtJYRxJdL4B3xVeuOSHdIQVR23cCWj b1KpvVf4JCtMa78IkAbzV12Od8IpiXvcwvHTWSR0wqtN+cEbsGJouZGQg46nJ1nOm+3sw b/FwnprAqAlXwQ4Ah0kMjLWamBejPbWzVIKASICfbF3LAIkKIEn2HtidManbjkdpmZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796287918; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: References:In-Reply-To:To:Cc:X-Mailer; bh=OggV6K9aHyQXsw0SwogKTFMGuvmMZWbt7+y3Hxy6A1k=; b=w3PELTNPiPkthUC2y6hQ49FHt+3o/OEvykI+8IGnjauJ1cY7carr7jkPVJvUVTHGwx/U Z8HWB/NlvtR6IWyJUSYS0AqnKjwFFswhb2EUaK5z+cMHvPIIoXTcWFmP7gQfhkjRWA8Xk GjjC/83PtnrHbh/v5/8qyWQO8Ik2y7/AuJVEdfxgti17wrR/hCBdkl08GMpfqdzrulrrF FOOH9OvQZpnRx1IUYGALW4DsjBiB3yHkMGWGjf+vKlZztMpAqepeFOzRTlhB8kOgAx3Bq Js2NBRt1SL+84/ibGTSbXy9hXLYThVLqJBx4IBWeDYuCSDd7Pg23culd69WqoFX3Jag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=CRrcy22v; arc=none smtp.remote-ip=209.85.221.49 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AE69606A698 for ; Thu, 3 Dec 2026 08:51:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3AE69606A698 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=CRrcy22v Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-4c4b8e58cfeso3318740f8f.3 for ; Thu, 03 Dec 2026 00:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1796287917; x=1796892717; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OggV6K9aHyQXsw0SwogKTFMGuvmMZWbt7+y3Hxy6A1k=; b=CRrcy22v/C5RzVeYQ/Cl0Ax0pu2B7zNsKUeVjj2vu4Hx2b4Q1EMrQfXJoy0XgpD1rb 4LLHdGkco0vUzIm9BlwO6UuK1LMOgmj5njvvu/CY0IUboyls9/IOZAlxfCKUtU0T+Mll gJBSCJXPbsQ3MBvlyVGM6cudTHTgCGkoivvXA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796287917; x=1796892717; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OggV6K9aHyQXsw0SwogKTFMGuvmMZWbt7+y3Hxy6A1k=; b=sbUpMx1As2yVhVXaLDXOetyUG//TlR3se3cEHnjdslLjHd/ki/hRecFu9JIVCFw9xf 7O1zW69ufM5IPZ0EVgq+7Ki4Be6a6aTDyg/9tc5zHRu8Ob4laNEV21cMuF8S8w3ePHr0 WNCcDTtqZXJNkyT13E/38zatu6GdgA50sOAkEivqOC8jNQ/SgKZ5KR975lRC+u8M8Cd5 vk75C4CVRQuJPNvlZFgASIVu9galis0/aJrzAwOgByVZsL8vM8Qp4xBhLoTrjiBGME9v HhOClw3GErdvUTxy9wkHYjNAOJIHdi5h7ao79X3/GReHUsBzEWG28AwUpTeNeHy5aeBO xV0w== X-Gm-Message-State: APuU4Z/u9HNhkNHzaJDm3lQZqsHpzQa2C4UrenrgnHVqgpeVVG8vKch7 gLP7M+nBaUnPiWyVMwvDNVIVPXairl+8BW3guOQUikmZAhzi/COLAbPtV6dBcd9aNEI= X-Gm-Gg: AZFdTZfYTQmgSFC/W7/ENOA2LuJyRg0DqNQdQ5zYg+hUpd/AEUPYStGw+SJ0cr5u9M9 fM7K9jZHiL7FOz3VF+PwvFHYi8sIl/F/vQxFyxrwLj9NBzoYktwH6xUa5riTNB7NSdzZYgaxmeM SLvIm6ISR6rrbeuZZ99oD5Y4N2Ao/YsTAM1VHTFhruzyavNafkzsDgojvYWz1UokEJ/8fUlcMqd sBWArvUZTxqUHornKxizhyosAKTxSZ0gLZNyIie7rme52gDD5w9j5lPsEsmH9jKrKg5mpuwU+Ye 6FX1cGy/owCY5xL/HmAGWMM1uj6JxsbYZTrKFn8aY0Ip3w0ceqUgc/VeRG7WyuBXj+Q1/BHC9DK qR7ze8PyWJE3w9HY4Pl9wHPmr6Y+KfXFsD3ECcWc4LbcEBkr1MhjZ64myLLJjCOqb+lEcBc0iqU Z3Bnq/cqgHZgREKnqfyCKoxJWoj2+N+kATy629JdJfIen5Cvr9hh+gC2APi5FylAL4+eREioUSs xueNQT62c+LFV7+B752mhpTkQhgqRNsXiKN+toGZN8ypBnpqnsBRheTgVAE25IiKkSepwcXGTnl ugpA7XJVF7ax2VklSAOuBPK/cQ1CoPijkcqyU7IhI94GspiuTXYC/vQO+rezH6Gh/gFXQvZXYMk BDGDh6vGGvw== X-Received: by 2002:a05:6000:2c0e:b0:48c:58d5:30fb with SMTP id ffacd0b85a97d-4abad5ac62emr86099438f8f.5.1796287916779; Thu, 03 Dec 2026 00:51:56 -0800 (PST) Received: from localhost (dynamic-2a00-1028-8382-0206-0000-0000-0000-0a68.ipv6.o2.cz. [2a00:1028:8382:206::a68]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ceabeb4c7esm4614661f8f.18.2026.12.03.00.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 00:51:56 -0800 (PST) From: =?utf-8?q?Roman_Smr=C5=BE?= Date: Thu, 03 Dec 2026 09:51:32 +0100 Subject: [PATCH v3 5/5] ASoC: pcm179x: Add support for pcm1975 X-Mailing-List: asahi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20261203-work-v3-5-e8a96f1c44e8@amarulasolutions.com> References: <20261203-work-v3-0-e8a96f1c44e8@amarulasolutions.com> In-Reply-To: <20261203-work-v3-0-e8a96f1c44e8@amarulasolutions.com> To: Peter Rosin , =?utf-8?q?Martin_Povi=C5=A1er?= , Lars-Peter Clausen , =?utf-8?q?Nuno_S=C3=A1?= , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shenghao Ding , Kevin Lu , Baojun Xu , Sen Wang , Jaroslav Kysela , Takashi Iwai Cc: asahi@lists.linux.dev, linux-sound@vger.kernel.org, patches@opensource.cirrus.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com, =?utf-8?q?Roman_Smr=C5=BE?= X-Mailer: b4 0.16.0 The PCM1795 is register compatible with the PCM1792A, but it encodes two of the register 18 FMT[2:0] values differently: code 001 selects 32-bit standard data instead of 20-bit, and code 100 selects 32-bit I2S instead of 16-bit I2S. It has no 20-bit format at all. The PCM1796 shares the PCM1792A encoding. The model is read with device_get_match_data(), so each bus driver carries the model in its own of_device_id table. The tables cannot be moved to the common file: MODULE_DEVICE_TABLE() aliases a table that has to be defined in the same translation unit. Signed-off-by: Roman Smrž --- sound/soc/codecs/pcm179x-i2c.c | 3 ++- sound/soc/codecs/pcm179x-spi.c | 6 ++++-- sound/soc/codecs/pcm179x.c | 48 +++++++++++++++++++++++++++++++++++++----- sound/soc/codecs/pcm179x.h | 10 +++++++-- 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c index e81e20fadadf..751f4b74647a 100644 --- a/sound/soc/codecs/pcm179x-i2c.c +++ b/sound/soc/codecs/pcm179x-i2c.c @@ -32,7 +32,8 @@ static int pcm179x_i2c_probe(struct i2c_client *client) #ifdef CONFIG_OF static const struct of_device_id pcm179x_of_match[] = { { .compatible = "ti,pcm1792a", }, - { .compatible = "ti,pcm1796", }, + { .compatible = "ti,pcm1795", .data = (void *)PCM1795, }, + { .compatible = "ti,pcm1796", .data = (void *)PCM1796, }, { } }; MODULE_DEVICE_TABLE(of, pcm179x_of_match); diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c index 4b873f2986c7..c1b8a995f2ab 100644 --- a/sound/soc/codecs/pcm179x-spi.c +++ b/sound/soc/codecs/pcm179x-spi.c @@ -31,14 +31,16 @@ static int pcm179x_spi_probe(struct spi_device *spi) static const struct of_device_id pcm179x_of_match[] __maybe_unused = { { .compatible = "ti,pcm1792a", }, - { .compatible = "ti,pcm1796" }, + { .compatible = "ti,pcm1795", .data = (void *)PCM1795, }, + { .compatible = "ti,pcm1796", .data = (void *)PCM1796, }, { } }; MODULE_DEVICE_TABLE(of, pcm179x_of_match); static const struct spi_device_id pcm179x_spi_ids[] = { { "pcm1792a", 0 }, - { "pcm1796", 0 }, + { "pcm1795", PCM1795 }, + { "pcm1796", PCM1796 }, { "pcm179x", 0 }, { }, }; diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index 559ecaa32f59..8b21a141f665 100644 --- a/sound/soc/codecs/pcm179x.c +++ b/sound/soc/codecs/pcm179x.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "pcm179x.h" @@ -63,6 +64,7 @@ struct pcm179x_private { struct regmap *regmap; unsigned int format; unsigned int rate; + enum pcm179x_type codec_model; }; struct pcm179x_fmt_table { @@ -71,7 +73,17 @@ struct pcm179x_fmt_table { unsigned int value; /* FMT[2:0] */ }; -static const struct pcm179x_fmt_table pcm1792a_fmt[] = { +/* + * Register 18 FMT[2:0] is not encoded the same way by every model: value 001 + * and value 100 are 20-bit and 16-bit I2S on the PCM1792A/PCM1796 but 32-bit + * and 32-bit I2S on the PCM1795, and neither model has a 32-bit + * left-justified mode. + * + * The PCM1792A/PCM1796 have no 32-bit format at all, so a 32-bit container + * keeps the 24-bit value and is clocked out as 24-bit data, as this driver has + * always done. Only the PCM1795 has real 32-bit formats. + */ +static const struct pcm179x_fmt_table pcm179x_fmt[] = { { SND_SOC_DAIFMT_RIGHT_J, 16, 0 }, { SND_SOC_DAIFMT_RIGHT_J, 24, 2 }, { SND_SOC_DAIFMT_RIGHT_J, 32, 2 }, @@ -82,12 +94,36 @@ static const struct pcm179x_fmt_table pcm1792a_fmt[] = { { SND_SOC_DAIFMT_I2S, 32, 5 }, }; +static const struct pcm179x_fmt_table pcm1795_fmt[] = { + { SND_SOC_DAIFMT_RIGHT_J, 16, 0 }, + { SND_SOC_DAIFMT_RIGHT_J, 24, 2 }, + { SND_SOC_DAIFMT_RIGHT_J, 32, 1 }, + { SND_SOC_DAIFMT_LEFT_J, 24, 3 }, + { SND_SOC_DAIFMT_LEFT_J, 32, 3 }, + { SND_SOC_DAIFMT_I2S, 24, 5 }, + { SND_SOC_DAIFMT_I2S, 32, 4 }, +}; + +struct pcm179x_model { + const struct pcm179x_fmt_table *fmt; + unsigned int num_fmt; +}; + +static const struct pcm179x_model pcm179x_models[] = { + [PCM1792A] = { pcm179x_fmt, ARRAY_SIZE(pcm179x_fmt) }, + [PCM1795] = { pcm1795_fmt, ARRAY_SIZE(pcm1795_fmt) }, + [PCM1796] = { pcm179x_fmt, ARRAY_SIZE(pcm179x_fmt) }, +}; + static int pcm179x_fmt_value(struct pcm179x_private *priv, unsigned int fmt, unsigned int width) { - for (unsigned int i = 0; i < ARRAY_SIZE(pcm1792a_fmt); i++) - if (pcm1792a_fmt[i].fmt == fmt && pcm1792a_fmt[i].width == width) - return pcm1792a_fmt[i].value; + const struct pcm179x_model *model = &pcm179x_models[priv->codec_model]; + const struct pcm179x_fmt_table *fmt_tbl = model->fmt; + + for (unsigned int i = 0; i < model->num_fmt; i++) + if (fmt_tbl[i].fmt == fmt && fmt_tbl[i].width == width) + return fmt_tbl[i].value; return -EINVAL; } @@ -191,7 +227,7 @@ static struct snd_soc_dai_driver pcm179x_dai = { .rates = SNDRV_PCM_RATE_CONTINUOUS, .rate_min = 10000, .rate_max = 200000, - .formats = PCM1792A_FORMATS, }, + .formats = PCM179X_FORMATS, }, .ops = &pcm179x_dai_ops, }; @@ -226,6 +262,8 @@ int pcm179x_common_init(struct device *dev, struct regmap *regmap) if (!pcm179x) return -ENOMEM; + pcm179x->codec_model = + (enum pcm179x_type)(uintptr_t)device_get_match_data(dev); pcm179x->regmap = regmap; dev_set_drvdata(dev, pcm179x); diff --git a/sound/soc/codecs/pcm179x.h b/sound/soc/codecs/pcm179x.h index 0039ca8ee742..a2188425d163 100644 --- a/sound/soc/codecs/pcm179x.h +++ b/sound/soc/codecs/pcm179x.h @@ -8,8 +8,14 @@ #ifndef __PCM179X_H__ #define __PCM179X_H__ -#define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ - SNDRV_PCM_FMTBIT_S16_LE) +enum pcm179x_type { + PCM1792A, + PCM1795, + PCM1796, +}; + +#define PCM179X_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_S16_LE) extern const struct regmap_config pcm179x_regmap_config; -- 2.56.1