From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796287918; b=xZJ8MBNxlTsLEIYb2F2XqPR9VAFBgIWcKGSLPpLuqwMoZDSWivUNmeUA4QuCC5tIqxZ1 3CFWaI23RKzx7EZMG/qTuiGsEzaEncq1BLbRGnqfnjAciJ+bTtjE6mhTT8Fkm0+4H+lcR F7Dd2lmlurm5Uk6dcImimlK3X8tyKu0Z/A7V/ALTQZlUU3mYBw1OjnYXUlc68QBp32zR4 W0UVxUje9P+2llinvPetoAwHB+ocPEq7GhhOlUwobNgxHnaQ5U4ijINdMjSwH3yR/vzgA mDCt/MAXspl9wnkC6gJcL7+JtIVl7lg7k+Sjali4wx01kO0gjJ7HZ15MmNs37AJHzEQ== 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-Forwarded-Encrypted: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=rRE13P5lzCMQAKrkr975otLEIAxShJQlvvSyLtcUeoB/FG5ROGHghvBiafONHSfGqIyB hZln/vZfvWOZVGcrqYP8mps+hK42YfTEXAiZ+IQ2D7aaNrcph1bvlvtl5xL9wzOpH9Alb fQ10N9q6bdaTvMPCq2CmduM289LXrjFIZoydqn/r0Q4ss/APz3FweAJYTsZm03TuH4iwE IYPc9dFT8UwGibqO6C1DGvrSKMdhu5Jy04PcogYhvCzVlSnhahHgWKnKEycWMoz97q2u5 CDAkxpmEX1e8QumXR4dgKXdb5dBc7ZqjTfGpZeKQvRq/HcU6GnzimE7GnaaXf6aRKhQ== 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=YqVw8xnR; arc=none smtp.remote-ip=209.85.221.44 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 36884606A695 for ; Thu, 3 Dec 2026 08:51:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 36884606A695 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=YqVw8xnR Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-48dfc0421d9so12572671f8f.1 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=vger.kernel.org; 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=YqVw8xnRpT5+a5tmR5tjr887u3/o7Xm+u13O7GPC870x5IjAOp6CyMcJu6NiseGk6j hELubrIz6eJBB6UkRnq8XK16DToZc1zFpsXiIzmFam22OmhLXzIq9w4wzX9tpYAYFsbZ Cny3WsWn9RH2pYVxN3VK9D+6u4/pjlB203rhk= 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=Q76PGaC9yRPOtoT9l6Ek/81ewEYfw48x4cruFMPLj9wXT77x8+MjIV5jPF14webhU7 DuAm1vOP4IBnZLi/8BH7Z52c9HZA8poh2BvDZIKcOvgJUfMdcmpsiYaapgwe1lQekLQa 8kqieVC+pO4wd9wA68CsdjXQDJUUq9oqf3d6C83fCxT2GigfPm25cyt5TaLeUgIo0/MV xI9qWAPMdIgRK9mYcGWEJiDz9uLw/naWGOD2HYmXH6/ylbotHLTcTdxXCSt3pyd1/7t3 5AdxcnlxFLmrmL7an/ZDxn5yBtqyYmlUzZHnVaJKtL3k0aIEQYFf87Eh5o4L3/nDpn4H jo4Q== X-Forwarded-Encrypted: i=1; AL+hErEsaf0E/xMvwhPAS+SL52BJFwELb/epRDdTkAuczASqJZo5TljBs3T2LbRv58Iv4Rvwu8KiV4esYjmF@vger.kernel.org X-Gm-Message-State: APuU4Z+z+6Hue/z2KEYCo8HbIMYLx+3OtyF4WvEgn3K890kOajwEKfsU UlVRAml6d8qOVQE9FK9qFLvNk7Cc4c8ZpQm9jpbA+CdZUX+mENMsGooQjk9vK4PKQyk= X-Gm-Gg: AZFdTZf06QK5vxFJ5p705ok7OwdqMGc5hBCKDnDPd0oX/4RnqGkubzQ25vwBLWL+6Vl byrGlRAUHLKGLrTkxXCnNziN1SrCJvT4/8uxzw2EQeZM0juUjtrv+LP7Hop1dvIcSLfRX4aETJk jibu0J0KviNryMrUqdjTo+tVhlIow2iO/tanL/DgeMk8B9wWJVDPRVMFm5PGogkKnDkk2iPdocX ieUaxDlF6aWRPB+HjT0nEolmMnpnKF9q68joY4S6A3nLJ8hKkWmyHbjmfFW0aQz2V2IMRYNMc0o Ojy5zU1kbba8MEquBr4H9T20cZYea7PwDeXS6/D3TuvsLL8n3B4L/2POCJaUqeTWoSyt8lhIQmz VZBVBLiloRvf0n13qd6wC5LG6FbbKCbiIGJgc95oXlVAqij3gmry6nXSGFvo7McaLDKJJL+p3Sr pfGGOYEFlEnWZrk29olbaeyHyYGh+AAQ/2GFoST2Z07tD6KQypiDYH5dipR+yza01UPAgeDnYbD HMT58K01FqudjVZH6nINFuGhfYwN4nRAfXXkzoPR29c26QHUuLYBio9PrPiN+LXlEd+itr72b65 WWzRuFTR6zPvtkvkLZVmmOGjA1l1uky3cXTgw30HnSCiTMCUwMSvbS1UbQAsEaxMJ+KVdj87Yxu kJjloYydS1g== 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: devicetree@vger.kernel.org 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