From patchwork Fri Oct 2 09:03:08 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: 4867 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 493E53FA1E for ; Fri, 2 Oct 2026 11:03:24 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-486f9d150c3sf4448040f8f.3 for ; Fri, 02 Oct 2026 02:03:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1790931804; cv=pass; d=google.com; s=arc-20260327; b=HTPAAEEoaVtCb9PeU29kfO7JMasBdobKsWF5r3ySx6MG7tERPCjSDa4yJU43WcV552 paeo1eymWg80Sz9fixG6anyBqnq37rEvgvc0OF956FuGRjUVok3maaQS2N00jNq7iLQ3 oFc+5WpS8A0xLIGKDfDtFxLfFbtxb9L6KdOEFJmFxUyYxncbU/aB9vKXxeAKxEchiRnC k9qzUhr7R65w7R3GvpCGJ0vJJjW2jsR1fBABbUXG3TWUTYQ4wXiG7DFqGYeLn+vlhg5t cQwstz4uSnXXyr53tkLFS0nAXxRIBawTVx4caJNsQ5ihBKa5K6PP1e0qsR+qlzeBrbxB pRWg== 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:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iRo5DLmHHa+yViPkM/pP1D4Qt7S8fxQHKZA5e92dw58=; fh=lwHXaoCbzR/N/iWIpi5g3l5i7lFYQioTpOEio5KejGQ=; b=H1/olTtS8YbP4XfKCEYF9bS7scfQ65ihpcMfreXlMEXj4NT6qif2H+oaMh/ghwvWlO 4tPaSNK8uMqasqmYlypBGfRLFrvcd4YkAj/bP1oxKU0EO7vyNM2Xts//QCA1PF/VjTC/ 0Lb7X2Mf/WDMJKY40mnaEIW/PHVIVFec29AWsczXp8bEHE4qB9U2CV+oIR/X8Rqrf4we 9Yv/r051wuW1Jv8af5266wczFrYJ/QQaGtIGpN5LH1LYkLBcj/0/DqrYzS/5xnQibxxJ 4YXD9ul+dK2MBFHtVTv5ZPdnKhdBP9HrK7/9EtDnzneZIV4K72tliwnFPXuuL9Bh9Xvf iHKg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Nzkiv7dT; 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=1790931804; x=1791536604; 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:content-transfer-encoding:content-type :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=iRo5DLmHHa+yViPkM/pP1D4Qt7S8fxQHKZA5e92dw58=; b=PQo62BGHU8ezpy/Bollu1RZoIY6+bfbBSLMKeP6w4/G01RdMJI2vb3z3X5yEYNSKfx 6dGmQEqHnb09bC5Xz7gX0XutIMpZMgd9vXSTWz3QRMUkIEam/UrK2ANIOsd4QuJ+vYqV R/Sp3OB/tKP2sQF0634MscxFRMAMmFf+Dz0j8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790931804; x=1791536604; 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 :content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=iRo5DLmHHa+yViPkM/pP1D4Qt7S8fxQHKZA5e92dw58=; b=udf7yneoe+VwR0me74z2TZqGZXk0tbA0iNLqAuYkVWJ7snsV4y8F7X7KaYFVJHm8ii R7OslQzzeA7xvFiMCoOuja9+H7VC5cE1n5Lqf+60eisESot9LL/j0BCygHQqL7GFOw6o 6G4A+qMWnE2RinoVfJkMk4i/P02goT2J2uygYhYd87H57ycAYjbRzlPw87AHhkgC+Vhq SA+E13GwjtOH4xXp2pVR+XX9JKvLVcnvo9F9xTNBmBom+ffqYUrq143F/lcsOcC+0QIp p2/WR99KyYhpWqRBLk/NVkJDtkzH5Jb1Ooq4soa6hbPUSsJtmkT+Zrd+4K22z8cMPQwo iM8g== X-Forwarded-Encrypted: i=2; AKwUvBwyJ74uvMz6ZJUKFI3nR8moAr0jLd5YlTaWxxI/uK7W6WmSgcWjuBYDFY1JlDUHt/xZC2oqCeJET8wgljvy@patchwork.amarulasolutions.com X-Gm-Message-State: AFq9FYKM2R+Djq8LhIJQA6KiCYntwfqiVhohWxAY64ArAOe3H6aM8Jy4 Boj1XubHsnSR8GouucBepHz3Z1tSOVHzv/sLi0sPkv+UXks0nQbjI6hCYux0vTarmY8YBhdUkEo GHQ== X-Received: by 2002:a5d:64ca:0:b0:488:83f7:6352 with SMTP id ffacd0b85a97d-48b126f542emr3883090f8f.4.1790931803820; Fri, 02 Oct 2026 02:03:23 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="ATskLdfKAU89QhESLfBhAAEONhV3dLQNW78SQ5ST3naWOfqNMA==" Received: by 2002:a05:6000:41c8:b0:487:8b9:6ae8 with SMTP id ffacd0b85a97d-48b12f1dcc8ls691855f8f.1.-pod-prod-01-eu; Fri, 02 Oct 2026 02:03:22 -0700 (PDT) X-Received: by 2002:a05:6000:25f6:b0:487:34a:5a3e with SMTP id ffacd0b85a97d-48b126f5980mr4019037f8f.3.1790931802216; Fri, 02 Oct 2026 02:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1790931802; cv=none; d=google.com; s=arc-20260327; b=cvoQImS1N+aBv7XXQk7BlM3xYCT7JvDNEgOUfn1uRs0vCXE194+o3l/VTuetnuXOKO 5WoJxvqZktxFbMF/B0BP8WUKH9I0wMR/nywS3TJ6YZzM1UXk2A8t9cCU9C6T/t+QUOf2 zaEztUhbuiX3bFWc5+aJxg6hQG2bZGWS2x7qhfAcdOwBLWLnCFBLsk9a6morFn+U7Zns OLeZfNNCjCYqctx/79BmzUTZahl7axWT7Z6ZBuF2DwJCaR9GhUtBpBHWMudlBWRdHz8e NyLeMRpDGOJQMiGuLNCgW1bhxYHHNXKCU+XLODSPRlcVLFRqjyI1VYPIbpKZN/HGMpVx 4rFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=y7LVHZ782vxWTYdguCArrgg2Q3BtjHmVCh5M53XTyZk=; fh=RgNGXAbhvmjHczy+aYsRzpqS2cUHsizymhtRQpplgnI=; b=ffgC8aL8TBjbFyW/AXB1sP0hqVPKhaDk7Q2/6ebVYy8RNPC0dg+fJBB+jk1DUPP20z 1TvGMKmJL6T7nQLRavuLCXoLL6Na/7WK69zMNg7529/MrfU6Ecj1ZkPkbhcK0s/IRAzz UgD5OAowbCDPoJzNVeTu1BuqrpOH8UliborbQ0EkO8eHCq4XUhbcry6NWL9Oyl5z0yx1 YJbjYktmJh+yQP1+rLMsY1WNP3KlqYDgsLUAUgA9lZ7yD9PAmzuWZVkrMb+04HOLztVj 5getIOXTjFkte9ctdi7a3wFM1/6dNp7WY9tdtUugTeNwzkeTZuLQp/b1ZqsK647a2ue8 hCqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Nzkiv7dT; 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-48b29123f6csor253923f8f.4.2026.10.02.02.03.22 for (Google Transport Security); Fri, 02 Oct 2026 02:03:22 -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-Gm-Gg: AYBFou2fmAeYKuqPK6QoJGsvSGlKLRF0HPCWPajQTsW4coK2WhJj3SlbJjA6JbEaW4Q ReKwBUuzv0NCJuju325Npxix8JkTX1mSj5KIaojx6K/rJZw5amx6SNIl9z600/patXoMsYZDjgx tY5t6fCoX4yVfvpFAYMgA1UkofqujRcWno322W99FWtV2g+STrZdO/0nKQDvxmUUUv9kyl9WxMt zOg8uDzdOVW4K17ABBrBLPY9ZZmxlUigdoP2AN492y6wmUEjKzgUOm4aCQcCREsdwlzTmQKwwcl 6o35iSTMMwly0gRcPv3dMMVkwMAeNQOF0ZH72KUvLDhYxkicHuXnqT5RE3Tk7zoL7xreQT5LVYz zREghGFGwl3cpI+KUHY4Wgiur2O5bxw1Eh5AR4LDx2nPr2e8uDzDTl7+sQY4ACwyBYomNORxS4d PDnur6j9Vha5+tFGNJ8n2+x/HmJ8+Oi63Zce6X0fvGQqudbjRVCFZqtPGMdKa3wn1HPVHc9W618 2xPnq/N6B5d/w== X-Received: by 2002:a5d:64e2:0:b0:487:22c6:a623 with SMTP id ffacd0b85a97d-48b126f5975mr3748808f8f.8.1790931801583; Fri, 02 Oct 2026 02:03:21 -0700 (PDT) Received: from localhost ([93.90.163.238]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48b380f04f8sm4100819f8f.9.2026.10.02.02.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 02:03:21 -0700 (PDT) From: =?utf-8?q?Roman_Smr=C5=BE?= To: linux-amarula@amarulasolutions.com Cc: Michael Trimarchi , =?utf-8?q?Roman_Smr?= =?utf-8?q?=C5=BE?= Subject: [PATCH 5/5] ASoC: pcm179x: Add support for pcm1975 Date: Fri, 2 Oct 2026 11:03:08 +0200 Message-ID: <20261002090308.941453-6-roman@amarulasolutions.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261002090308.941453-1-roman@amarulasolutions.com> References: <20261002090308.941453-1-roman@amarulasolutions.com> MIME-Version: 1.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=Nzkiv7dT; 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ž Reviewed-by: Dario Binacchi --- 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;