From patchwork Thu Dec 3 08:51:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roman_Smr=C5=BE?= X-Patchwork-Id: 5139 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2F26D40D70 for ; Thu, 3 Dec 2026 09:51:59 +0100 (CET) Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48e0af48c18sf8651922f8f.2 for ; Thu, 03 Dec 2026 00:51:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1796287919; cv=pass; d=google.com; s=arc-20260327; b=B1pibzh+OwuMqstHvtXi/narTMptbilnuxo+m/sN8FBVfMC7GeYtDzp+QeYwNLu7VD xyY5ePfce/8xQfkPMhIkceVstmfR99neNe8LzY/LFoLRmRs3OOh7wxIxN9Uzl/2CdG2C BnHI6yFmLX60BUfqp5eyUdn5KftQF43Oaqe8yZpan31wVZP6IkpOjCs74GJNBp86rK59 IyK48byyAFhDbUoP5JZbRIhokMITZT29ZJE3zbIk59udtc8M9HJenG6Zwy0YdS0+ALT6 r6SA5NA/t215crGcb2P495jie7bEerP/s+D6HQ3GKb6u0DVletigCrTTlUuYHZajAVQR 5rLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=k/bqe2Awgh5FCB01CLN8vEmFfaNuwNQlBQl2SDQ9gUc=; fh=UrB+6R2T9iBEZ5WMBskiEeloJ0dqpmYZohGdwBELGWA=; b=P/9Q2tbXl+Jw4M7osSenRDrmfF6x49mewIT85xOUQ8LiEHzXKvHlFwOrkE25xuQenU zGjkgdZ+7M3SxnNIeqTY0AE39fbcTMdJbiFrtD4g8u4D6uCUJ0qe5EdhrSPj9QZaHy5+ /g29xoewViJwtgx1jzs4zXBMMGwJFsJ4MssyoowFBA6twjRbJETw7Fv41dbHORnd8cAA K1wm6sKU9ApKptxUEQJHY8X5RR9InffbDjZ26C51+Q5u9Cf3LF5eTX47wnaeCW2FIXHJ LdAWOCPb1E0N2hU38aAKPVvRax5lzK/DKeavT5jOCRZgYrdNXX6w7Jy7fqGHuseYtsKS +7fw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=o0qQ9Zxx; spf=pass (google.com: domain of roman@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=roman@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1796287919; x=1796892719; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender: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=k/bqe2Awgh5FCB01CLN8vEmFfaNuwNQlBQl2SDQ9gUc=; b=SZQGv5HsUmRGETFEBxTV4Iw9MD66JQKrVRSv5uHofyBuaeKxBGiCGNdyNaTJ8jxLb5 qmlUv6sOdnARM0ojpHuX8w6Bno8YgbmcH50Vo+yymO8J8yAJXOeZymrveaV7d9ml9pQ1 CjrGKQvsnRKfU8KFKThBPbTp+0WzllJP2sm1Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796287919; x=1796892719; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:cc:to :in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=k/bqe2Awgh5FCB01CLN8vEmFfaNuwNQlBQl2SDQ9gUc=; b=Mldckl8sPT/acww+MBnU22Y+wPub0N3dniBjlL6f0n5ocoeCywHn7R44Ich5lzazxz LZ4Th2wvqy1wtymmZJRUZaE/WNAxWOlQ3DMkAh7Oz0pQ67TRs5KaAP0FDFx6kZQOQHB0 Zv6+vWnwjHwcxZ2IOK+cXW3xeWwZ7oUfHGHUKpgFjBDMgi1CkvFqsVdwERBFc1x7ZdlG 8XbUoRQzqKMfu7jEgZholZOMnGq5RjjkSTP7Al81h758VKcPmre5Je/0SYs/Sjqsa5uq xM8Z/+HzM2v3gVSE6VqjhI+5U3jV4AInifw11jI2oiQlKDH1qSX3l35TsxzSD9g8III4 +fWA== X-Forwarded-Encrypted: i=2; AL+hErFXdN+LyINhq3oFDuk13f9zVEtqC1V69oGkeKM7FCVrRF4nQfiF1WqvWh88v4+SgjRCseCzX0RIcPvYQxqc@patchwork.amarulasolutions.com X-Gm-Message-State: APuU4Z8F/CxUatcq2YrOH9m+vZXg+x783Ac1iIQZ5exewjJ1BWjzmRYF rv+7rJSJQexm6gidTg8uA9CN2XiDBnzzE9KBQJsFjAdbTeIjehl0LxqUcxzAiocCFyec2Q== X-Received: by 2002:a05:6000:4705:b0:4a9:3fba:5eef with SMTP id ffacd0b85a97d-4abb5db6cd8mr79692037f8f.24.1796287918760; Thu, 03 Dec 2026 00:51:58 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com; h="ATskLdfqkv06EdYnTQz0KDGr2EBof92GCnu+aomaZqIlcwXNGA==" Received: by 2002:adf:e199:0:b0:48e:20ed:2762 with SMTP id ffacd0b85a97d-4abbb7ced4cls10066756f8f.2.-pod-prod-05-eu; Thu, 03 Dec 2026 00:51:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGS2L0+sgNsMgZeiOTQ/BVXMHFzZGr3GxKlLIBUM+0UuoaS5/WsjmD64SxUiedE4Fz1ES8SkVqz861/54LJ@amarulasolutions.com X-Received: by 2002:a05:6000:4381:b0:4a7:e4c7:2795 with SMTP id ffacd0b85a97d-4bb965c79f4mr51925243f8f.36.1796287917135; Thu, 03 Dec 2026 00:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796287917; cv=none; d=google.com; s=arc-20260327; b=XqmpDV5fd29uTTUo1iA1mgBvnhX/ltGu1vIw1aXRW+wQhIJbZECcpMKBLZr3elU32z i253tqPnBpWZV9QBuLvAUiPtIqzuk5SSuOU1Kgdy/QR0mI70FRM/R+prW2vcvGEQeiI5 pbzOGj31eyoqtkcWC+KdLl0+qssJQEgCuB+qvh4bF99RbSqAeZjj53WNshFEYKqnNRZk 5K6+nQtYNto+d4C2ly7K54M4w9zhycJf29CLweGEwI4+WB+Rwsvw+1JcPXyj5zpC8kb3 Md7wwIJlE4KiD0JF/d51KmDkjBIp51SGxZbUz4wXXceyL2oSkO9HMETS9g91JYtMwC6h aLgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=OggV6K9aHyQXsw0SwogKTFMGuvmMZWbt7+y3Hxy6A1k=; fh=IrOkdlNAGxHmtCbZOUio1tQAEFVpnBbvlpNFoRROwjo=; b=r1sKnLXttqVu9wX2reuHty/v+XMe2UKcFnSAkBVV5GeTEpbwqgKQYyzVo9l61K0O6Y RItJyFzJjcH0rhGz+2jK0icrpDqn0hEBYJgeb2UthunJxgOsossGntmXOiFDj+C+01Ez PUq9Gy0TGRDfGpTfA4Udl4WdNOA3wiuDxBLG/as1KWa96n2mU5qMhZUJtm4NqMgUPuRF DY4oJknWzkJDHk7RwoWejDpvfA57i7Zn6nCy9EU9VhIk9dslgPTo4tMAv2suAJdjyb4G G2j7l766RcfrteAvDGfiXwgpOUlANiF12qoFNBw9U+e+kQg3B/9GChPunmy/KbUYgC5x D4Sg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=o0qQ9Zxx; spf=pass (google.com: domain of roman@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=roman@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-4ab60a51db7sor7563256f8f.11.2026.12.03.00.51.57 for (Google Transport Security); Thu, 03 Dec 2026 00:51:57 -0800 (PST) Received-SPF: pass (google.com: domain of roman@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AL+hErE7dfn34T/xtJhMjCxu0ZlNvM9wQAY/ycwRXGBkNpo3Q+wNUTbmSDFJifcXYC4yF8yFkAN9UD14B58ry3ux@amarulasolutions.com X-Gm-Gg: AZFdTZdWXfmfRaXYBSO7JlP622sfpXaW0qSkEVtJmuqTq+Grf7rFC6uM2mxFYmhWvbc yEvTgZqMAr8OyznqvP/57Pz2378KmJdN/JAkDqnpe0nXfbm/1ZlldF+gTY1vw1P2q1s6XUrLx0Z 8CqxRAVs3M9FiyVmBIhXJhFiJnfj+A1rxJpNIUnuM3f7Wk5Z96Z/JJ0VvfeqFjvi52yIeU6OZy1 l0MqO50Jx+IeWx9/KKQsmqqWfZO+tQ1ViuEtHzDFj93zvtnK3NFfWqFabAj94nAJuYDvIP+iGDq /XFsYY9FO/sz8/yjQ50v1wVyRJqfHhVI+JkbBnAqxSfCN1N0RzgU2fOxJqyy8G0+6HIa+XkFLjq JgKmWPJJ4qiJ5ccFxGb+sDKt7xm0DmWj+Hv/Slh61UuaUhGj7jEn6hWOL4tcsPf12Sc0RCbeHLm 78isLdBshsscGg+XtPxqzAmbwPnKWVwTebO7srJWikOiuDCmmx9F2pF/r8qae1yA3dyUnkioVwG 7riEKbByYI8IBMUEH3tCRZxlX3er/YSS7ClCucMIHrnfTXgka61sexNBHU9k6AVgyskqiU+XBpU KRLohtFoaXlJSaekWziNgopastGcKD1FCJbquut4eJVOm7Z8Ma0Y9O50CREt7ty79arQT3H4uim bvnUTlFLjxQ== 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 MIME-Version: 1.0 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 X-Original-Sender: roman@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=o0qQ9Zxx; spf=pass (google.com: domain of roman@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=roman@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;