From patchwork Fri Oct 2 09:49:34 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: 4872 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6ED103F0B7 for ; Fri, 2 Oct 2026 11:49:53 +0200 (CEST) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49fff093efcsf72906065e9.1 for ; Fri, 02 Oct 2026 02:49:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1790934593; cv=pass; d=google.com; s=arc-20260327; b=BA7/U5jZ+VTgRWwVbYNmc78/zBi0wUpW+axDcXLRwbw99bommLj6BOiAJU9w7qbjg2 /GyfOzCP4VK+BVemAb4sWJ2jm68v5TRX2oUbPb4mvUQL3AO0rI+se9nImlSzKvswRqgS ew2Q+Y7cMyq00YmuDTJ6V2orLkXffZe6sFi7gcfUMgnTGu1TyGL5U5IqN5sr/29lIau8 XfDOuQCA8D4Vd0dvWG+Rhy1g9Br03YQEmeXya+RxL8fV2PrZ5Ip4LGShuXhF9nan77pR M++zwJTLVrT57R3QWoKypDFeJIqIGXnIBT2iLemogjOlrnTyWZXidKTbsYxLPh8007+9 SoqA== 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=m6XetCxifKpVnsglLHlvF3bIMdyjuVuhWWaQMRTZ/Zc=; fh=5otfGiKeW6DCsDdnThs/WVQCQZYr6+W7PqVE5368/E0=; b=VafM+f42jN4X4hkLzWU7N9+L0JOVhXXhZ0GEYNuXadQXTilYdSxQOOcOMOt3jNtbYa oNL7eqoeG9dAn4YvK6WUphtkRHF8IJ+CCsSYNhmclDyL1AmY2zfsCGomZoPXO0THJ4Jt plZkNTiQTWM8b0eBYzuZpEKGWMsdIn/H5ENH9GeMEsCwO1TUZGmmC91iMa3l8YBpUHho lPd+5eBUBzEaxAvb/TKpT14DOGdJ5n97tycD+9o8X6h68li5xOpfpiJpDQkRhdwCeCDB gpW41NQqL3wti0zEizlVzXHUxPNQSaZrUyxhw9w1cZqpr78nva2Hu+QP03TEYqGvOtKr Foxw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="KIAs6L/v"; 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=1790934593; x=1791539393; 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=m6XetCxifKpVnsglLHlvF3bIMdyjuVuhWWaQMRTZ/Zc=; b=aJT7ly5r6EtixWwy9DkplI3gkjiQmmS5TvRTO7OYKGmq1cqqbcRFLDjsukuDPOOsx/ 7z44s/pSGOGxMUwiTx0SE5w+L6bEAB8wtqG9c+N0MAWYoqqqIwNMBVggjBgu46+xBH+P h/bx+BvdJ2Ylguzv3s85fe7bnpfwwZzt36AOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790934593; x=1791539393; 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=m6XetCxifKpVnsglLHlvF3bIMdyjuVuhWWaQMRTZ/Zc=; b=E+Fyx9OUOAgyf+SA0yJnwfDbLBDgaBxjJjLWxTadOg6sfbae4EKb1BGfOkdgJ4R6Qc 8mYqMZE/7GCha33Z5Zr3l9vNDZ7d3iCQCKWCIgbcISZmXaIwO+6nbYhxAEKF9AsQA3/4 PNIRvN/pebTnHXqGIGkBiQnf5HWotvQALNvWuX9Xv8MvUZyuaQ79MQDzfdY/m9u4eCHL ojYyIrHdmmU/m7fYd6iBEFFnA/BZM46gJYGdTgUYWMyJ/W21uEPkxTX4LWIZj+qZzQxd iANY9w7a6YFK4BL5Rh4Mxky6h0yFJzvbBSm0CBBA/CF0DIQV1hGVYVfuQ3UpEbSnZMqT Bu8w== X-Forwarded-Encrypted: i=2; AKwUvBxsE35FIgQdAX9ErrUW7hd3ee29n4T3y9DgKvJOsF2zeKTHAIgo6zDSubAL5SaKmJGnGbNNpYwZQtPbrptG@patchwork.amarulasolutions.com X-Gm-Message-State: AFuF++n+GxyQrPj/Q1++2YdidWH4cOettvXbEzG315btCfIBC5p5iC9c eGql9qBehUSO45/dpBFo1gyZBiMLCUsHoWg46dlkBRycIP52ResiqKhc84BXeN5GQE40vaNY5fn h2Q== X-Received: by 2002:a05:600c:4e93:b0:4a0:1e68:d28d with SMTP id 5b1f17b1804b1-4a02756715fmr41415545e9.6.1790934593100; Fri, 02 Oct 2026 02:49:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="ATskLdfA+l/GUbWxR4xE441hHuPa8FWpukgjFdd5q3eug+P1Jg==" Received: by 2002:a05:600c:37cc:b0:49f:e8be:ed73 with SMTP id 5b1f17b1804b1-4a0285223c4ls7628405e9.0.-pod-prod-05-eu; Fri, 02 Oct 2026 02:49:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBy+LdnLpDUF9X2zOmNg5ftGDIYPgDPM9a7uj5Ms/11d5bjOjeF1RGRO4mWQJhHdlQlF4bhHTG5wIeM+oulp@amarulasolutions.com X-Received: by 2002:a05:600c:8716:b0:4a0:108:3b48 with SMTP id 5b1f17b1804b1-4a0275670ecmr41105485e9.7.1790934591446; Fri, 02 Oct 2026 02:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1790934591; cv=none; d=google.com; s=arc-20260327; b=qaa1vynpWXf9qe10xrysVcSECyccRIYaXiJ5MM7dHvJbW0gLv64Uj1f3xTGQinM0/x qI0RBptJFNCiMwkKOEP3D0gh9apl/LOvbE4xp/B8RJC1G0IPIAG7RAwRknRboXMNf/gz qrxCUzxWv5iL2YFmRh/GVmvSPVKqIjPbpOGCFT4HlbgzPur+ivS70Ne5tm8eItMatZeS 5XVU6pCduHfmBS7OvYgJ9osuiZUeDjFJxro+BTa+KPSg5Lec4Bw1ueG/neIKfkYiHteg Epc30Gq+mQnrsxeUjHRLg6vUNFMNCc3L7goA0cYmVjHwzozXD6KJ75psrIPcYElZOb0L nwRw== 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=+kxyHe5+dBmZDe1DRKIR8ryWuA79UzUnyxbJbLGqT9E=; fh=72OC9ewdHsShlrqMMwll0hv2KxF1z4gl+XigliZDeks=; b=mpNo/9m4zvYHnahOR58t0zYU6TXR/NKEisAa9DtMYUVGUUoKtaRin2uPiSY0LbLpG1 Uvp96f+8NYwI1vUoZS6f1VSVJlHFzSiRq0UkrpEWrljz8IWlgqaP+P8ZjmnNTHDA0uBx wuIVm2i1IVGbdH8S/EGChMAqCUpWNcUpS9b8fE8FEu/yafDKiUffCoKxPstioe8bZwVF Ws1PRq6XdBGHNy+A8cP9RjSMhERFkI0vULtYH7ORlByDHZB3BgP3Ky5+Ioyl6DIJcetc Agx6XM28JwOvwPbm1mkYC7avnM8aFuWdz82ZIqeLD58Nlbzkui5DnpKjCnW6tfFVrMKj EMxw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="KIAs6L/v"; 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 5b1f17b1804b1-4a0284c5e2bsor3729935e9.8.2026.10.02.02.49.51 for (Google Transport Security); Fri, 02 Oct 2026 02:49:51 -0700 (PDT) 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; AKwUvBw/fNQKqsM5hLHZEzkNEGtgR/oCJsNXWx3deveMMclrOzXrO62zJCRVWjdN8kf/58uxDymEYSnFxrCV9CHp@amarulasolutions.com X-Gm-Gg: AYBFou34apV370A2Gw9YdgptkukfTWgz64FpEk5Dn1eoT7Lqmzsfr/965vYTvgVMK2J iSs4UvtmC0NmS5X97YKbr3+xuymuAGoAev4UB6OKLeGZN2tmvpDcwCu88MBe0EWJH42XLVstpdf wnkRNuteYuZvp8g1HfDik7Wza2VvvJsZKvNBUe7fEPOFtG+Iu1ihnCewpozSENbhYH+eTwZwH7J qei3d6kywRW/u5nm9cA33+DPQ5xbS2WBkfG+lv05MNHCHtEjsAdiD6B3H2OvL2uWQveNK4eukGs wl676Ay88m2RyKIsI0V2zEdroGW8UNo6E5soI1Ju2+B8x6GF8BHWbxKAHsXbLOVtFUTxf8XS1dn 3VoA141CKhX2dqtHDRqgUx72x6v5qPIXSAGwT3M9CVKQkaRxsavhC96Q/cogE9hdR7d34fLrsun S9g3OTTMXG1Lu66nG+4ekQW43cShckKQQpHft3hGnPh8hiZNCNvAjE2Oste/P0CzvkRrlI6Q3Bc AY= X-Received: by 2002:a05:600c:8b88:b0:49c:cee0:f383 with SMTP id 5b1f17b1804b1-4a02757ebcdmr40187415e9.16.1790934590915; Fri, 02 Oct 2026 02:49:50 -0700 (PDT) Received: from localhost ([93.90.163.238]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a03ff0c2fbsm35194105e9.3.2026.10.02.02.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 02:49:50 -0700 (PDT) From: =?utf-8?q?Roman_Smr=C5=BE?= Date: Fri, 02 Oct 2026 11:49:34 +0200 Subject: [PATCH 5/5] ASoC: pcm179x: Add support for pcm1975 MIME-Version: 1.0 Message-Id: <20261002-work-v1-5-f0e53bc7331f@amarulasolutions.com> References: <20261002-work-v1-0-f0e53bc7331f@amarulasolutions.com> In-Reply-To: <20261002-work-v1-0-f0e53bc7331f@amarulasolutions.com> To: =?utf-8?q?Martin_Povi=C5=A1er?= , Lars-Peter Clausen , =?utf-8?q?Nuno_S=C3=A1?= , Peter Rosin , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shenghao Ding , Kevin Lu , Baojun Xu , Sen Wang , Jaroslav Kysela , Takashi Iwai Cc: patches@opensource.cirrus.com, linux-sound@vger.kernel.org, asahi@lists.linux.dev, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Roman_Smr=C5=BE?= , linux-amarula@amarulasolutions.com, Michael Trimarchi X-Mailer: b4 0.15.2 X-Original-Sender: roman@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="KIAs6L/v"; 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: , From: Michael Trimarchi 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 move to the common file: MODULE_DEVICE_TABLE() aliases a table that has to be defined in the same translation unit. Signed-off-by: Michael Trimarchi Signed-off-by: Roman Smrž --- sound/soc/codecs/pcm179x-i2c.c | 3 +- sound/soc/codecs/pcm179x-spi.c | 3 +- sound/soc/codecs/pcm179x.c | 62 ++++++++++++++++++++++++++++++++++++++---- sound/soc/codecs/pcm179x.h | 12 ++++++-- 4 files changed, 71 insertions(+), 9 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 e5e4b942acfc..2b487a4d7c82 100644 --- a/sound/soc/codecs/pcm179x-spi.c +++ b/sound/soc/codecs/pcm179x-spi.c @@ -31,7 +31,8 @@ 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); diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index c059e410cbbe..3ee781ff54f8 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,16 +94,53 @@ 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_I2S, 24, 5 }, + { SND_SOC_DAIFMT_I2S, 32, 4 }, +}; + +struct pcm179x_model { + u64 formats; + const struct pcm179x_fmt_table *fmt; + unsigned int num_fmt; +}; + +static const struct pcm179x_model pcm179x_models[] = { + [PCM1792A] = { PCM179X_FORMATS, pcm179x_fmt, ARRAY_SIZE(pcm179x_fmt) }, + [PCM1795] = { PCM1795_FORMATS, pcm1795_fmt, ARRAY_SIZE(pcm1795_fmt) }, + [PCM1796] = { PCM179X_FORMATS, 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; } +static int pcm179x_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct pcm179x_private *priv = snd_soc_component_get_drvdata(component); + u64 formats = pcm179x_models[priv->codec_model].formats; + + snd_pcm_hw_constraint_mask64(substream->runtime, + SNDRV_PCM_HW_PARAM_FORMAT, formats); + + return 0; +} + static int pcm179x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { @@ -149,6 +198,7 @@ static const u64 pcm179x_selectable_formats = SND_SOC_POSSIBLE_DAIFMT_RIGHT_J; static const struct snd_soc_dai_ops pcm179x_dai_ops = { + .startup = pcm179x_startup, .set_fmt = pcm179x_set_dai_fmt, .hw_params = pcm179x_hw_params, .mute_stream = pcm179x_mute, @@ -190,7 +240,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 +276,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..33971fa93546 100644 --- a/sound/soc/codecs/pcm179x.h +++ b/sound/soc/codecs/pcm179x.h @@ -8,8 +8,16 @@ #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) + +#define PCM1795_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE) extern const struct regmap_config pcm179x_regmap_config;