From patchwork Fri Oct 16 10:33:58 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: 4881 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4DEFD3F0B7 for ; Fri, 16 Oct 2026 12:34:25 +0200 (CEST) Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4a1af80b913sf39088505e9.2 for ; Fri, 16 Oct 2026 03:34:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1792146865; cv=pass; d=google.com; s=arc-20260327; b=C39b6/CsbkEFZ/a//SRaRTiYx0dX3ORZT+wt+D64T//bBKk3QO+FZaE2wt83KGGMTX jcQlKHrOCPw3wUBqpPRIFYhHeGT7ygx7w+8W7R3OWJlu610idpkuj50cEj5T/f8qZUEn 3Bcd5PCLXm2YXpnRRLx/7k+687dvKKknuv1nyOjh8b/BDuD2QgogvftSwm9GTONon62C ydMSo6dH0LR6cEWnxUvIR0KhBHXjxFmsTkvGjXgtEJi8pr+vKU1rmpJrlKWmQYi9QDWE 45+TlOo9vQALKHYI3X4e0mcWxC88iCQJC6UhzE0ID6s7akyVzzCw3U+z5kphLFI7vk6C 6zmA== 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=5VXTTKw3viTjLVzmk5aV/Pt49h6h5yOsYWOFZIBJ8vc=; fh=Wh5vboILyb0kqfZMCS7Yc2rNFip3XLOEYU3LMv+KvSM=; b=gDdlx1conTfQS4YUkrsc8UlsAOIsJnTIV02ZVtAnJUqDUJROm/WK7g3Dz6bEEMGUqY tJFVhD+CMGJ/AgFG4/ClheJggwk5F3Z147SIGdB859h6okv3f+/lxo9bH5ztN7WWvWD4 tlYsHh4x4XenZ/g38q4wrxKPmbFxdtjgiqOOncRhmPZWoQJkbtleAG7bHAa3d+7atXCD QyWWuWoxdrVub1E1BiAY1tDt7Er5LSUdez2mL5jrsTwkMuHBeXnj8lERDsFp6gMxFj/Q VI1dhv2cZAmXQm7EQYVjsMqjtRo46tF9bApvEooecSFTehu+wtjWsVXX2hPNaTJ7Srsz UiCA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho6ZArh7; 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=1792146865; x=1792751665; 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=5VXTTKw3viTjLVzmk5aV/Pt49h6h5yOsYWOFZIBJ8vc=; b=lCRvn3LGJvJDFotrLSNqAHSo/F2xtRR0DD9wYJet/hEa82DYTpZ9BIXShLSDnyfYM0 aH7gADN5CsK9pZ/MHms/pHbg6DjY1XMuofCAGZCTxfOUCjpxzhZy8/wtXM05bR784Gdv wa9Ewfe6yTdX+tAGfeqaaS4Jv2JVKdGxYCZSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792146865; x=1792751665; 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=5VXTTKw3viTjLVzmk5aV/Pt49h6h5yOsYWOFZIBJ8vc=; b=Y8z25oZYwWdtYqc/6Uvmm9oPKzZC4vuuiNHGNQSP9sM7+vBtDxHj3MFczAW83hPOLv jGttLPiibe9cpbPXhguuaOc29Rp5z5ZWOLnx0KRJhqTamlAXJTKxwPff+qlXrDeY++yr x9urZRdWOCB8+umgvd17vO9gAB8BywBTl5wE/d33xYXthE0Di6dBvvk3T3/m/uDLor8I kAPrg6xPyUNqdVVJd10Ry/E8cpRsdtDhZZHjbuUUnmnNoFZKNXVE8VRpyIrTKNUvzSCm ey79qS9UKTeeGPPAGcULfmMHRvNd44u/AHri32ekVBBGPz8uBDNn/l9xWz+fU/3ifHY/ s+dQ== X-Forwarded-Encrypted: i=2; AKwUvBzu2k/42FKhnG9n5e/g/qyXXMcJJE2+E4iNVS4mhxcLB3+m/AYKOVDNmQbqdnMwJSkBqIOqyLPhCHy+rYKO@patchwork.amarulasolutions.com X-Gm-Message-State: AFq9FYIyOACdSJV/hV/O3rydbWoZM2y4tstzJoOS4KZ7cECHtC2QT3Lk U9wTdKgiDM8MVD3Mkhz0G3mstasIY475XTFIpsLwswaT55gQsBD0lLi0wFdgL264QdZIzw== X-Received: by 2002:a05:600c:6994:b0:49c:dada:30b7 with SMTP id 5b1f17b1804b1-4a18e446f3bmr437746085e9.2.1792146864975; Fri, 16 Oct 2026 03:34:24 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="ATskLde2HaOq1t7PSVa7zcpE0emkHdgzczpwnaiNBj5mGXtLJw==" Received: by 2002:a05:600c:3b9d:b0:49f:cd53:b9e7 with SMTP id 5b1f17b1804b1-4a1c78f2badls12778895e9.2.-pod-prod-05-eu; Fri, 16 Oct 2026 03:34:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBzRSpMh9TzL2hjLqBMEfJnednCA0JWHRlb3+KL+LPzvocbywXz/SQJ1Czxqpb5+eXVxkEreEn9NoTl/5b/A@amarulasolutions.com X-Received: by 2002:a05:600c:4454:b0:4a1:d41b:5060 with SMTP id 5b1f17b1804b1-4a1d41b51d2mr3379825e9.22.1792146863434; Fri, 16 Oct 2026 03:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1792146863; cv=none; d=google.com; s=arc-20260327; b=FUujkbfR5hmWnlVXnSfgMkDLQggAIHWPgZJeTGy09NRJpJY1L0AHbmyS0sJeNQzeuL FEj5m63ohTQbIUot8ggjxHOo25bZ8n1qx2PKIoK0025vdi/t9tQFOFyVQvShzTRtTmmR QAcN/Pqe9WfDUkGtNJasSPTu//6lhFOwGThH1ogjWPqEQLtB5hpZd5gX8GV1cneSb4fI bz4xsnJzDzlnmcK38YAj0PxPgdcoMe0VORv1qCenJdm+HWdRWZlUHS1LeiodqfAkZ40R SONA+ArjO+FOUXlOoZOsjVcqB3OUQbgqwuhwDQKWyoRBRNWSdqqQItJMomMlnBhdIkJ1 vA5g== 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=N4mHzpuyPPiZCfg7+PuclKsw29LzPIuraVJuXhPzW54=; fh=B/X3kr/iwANU+r4Cdt7FVvfVWG8WiVFXnXiP87QF9Qs=; b=pHtj6VOYE25KNm2w1trLDLY0FAYclWo3BifJoukoeJsZdHau3r37t2IMeLG5WnUHtk fJISnqwyALv7m1JgEmkAzITt/6fgQ61tSa7FW/mWCqwORJbw7GiGnroi1GJoHT0nk0II hawoC4kLACL3UOpyP3jGzQTOD9xFSf72UHMx3nS51J1SQr/bY4kaCWsCJ3XcS6b4ZSza BktD+p4ujBHytguCGOC23zAwvr7lOMnrSgRPb9JEITMsWZuCfUC2k6O6+kH5Zw74H+oT 39IG9YofdwnF6FibXvgSoP7OoNk6ZmUHXi8DWEK9nevw7qM6YwEaYw9ip2AUUOjSF/PV 9LYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho6ZArh7; 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-4a1c8a89b4esor3322155e9.2.2026.10.16.03.34.23 for (Google Transport Security); Fri, 16 Oct 2026 03:34:23 -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; AKwUvBy17tKrOTLqICmng4XWzXXA4/t9GMXi83Y0aZt2hWeY14cZk3JboFB4funOGGMoeGtNDbxpGp6cmz78VGwG@amarulasolutions.com X-Gm-Gg: AYBFou0L5OI7szxZ+kkec92vxVJZMV2MXgyEwjxj9JxbYedlx7WO1pi+/ZY8yVqd3RB Zzq4f9gJLkVbyywiy81XT29hzxYYQRrGde+viF9uE/AOkj3I8LxzhytGTewmAqerod8FtPYFDpO ensmupYIofIBmL9ksl1OyC2jY2zI/ogiPK8yvz9XsyAZ6HRYw3VrJDI/G0kTGj6snWhPtVGcqtK lTRyfbu/oQnCb3899RPab/4aEwKs7uQZedZwZEwQwVbJ+xroaCRWUjh3PZSl+IRZF3i2H0+OHBF j17HpOfxvEvkUpYQe54UjPT8PR9+EyfWnvhKPOLBm1UVn0IF/LjfVTU9+mTqlR3/pgxQzQIf/Pw n6kaY4f/uQj1rUr/8k5+qZUqViVIX7lOuQog1OsN4lmmj/gfmTOicQJIp0TIgVLXWUX9ilYzNz0 awNQAEITAfFCN0VbvpwSy3PndIQT6hazDBtsMZ2cnXVUK6Fi5Ha8N0wNSO6HSO43GqbcQ0gqWgj +w3SqZxC+ec5E0pPiqefRLlr4RSVT6dg9fNf8i9Ke1SVMZOfPk/qpQ= X-Received: by 2002:a05:600c:350b:b0:4a1:ad01:f8dc with SMTP id 5b1f17b1804b1-4a1ad01f924mr232327175e9.21.1792146860670; Fri, 16 Oct 2026 03:34:20 -0700 (PDT) Received: from localhost (dynamic-2a00-1028-8382-0206-0000-0000-0000-0bc0.ipv6.o2.cz. [2a00:1028:8382:206::bc0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1bd9b35a6sm132651465e9.6.2026.10.16.03.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2026 03:34:20 -0700 (PDT) From: =?utf-8?q?Roman_Smr=C5=BE?= Date: Fri, 16 Oct 2026 12:33:58 +0200 Subject: [PATCH v2 5/5] ASoC: pcm179x: Add support for pcm1975 MIME-Version: 1.0 Message-Id: <20261016-work-v2-5-9340b9555fbb@amarulasolutions.com> References: <20261016-work-v2-0-9340b9555fbb@amarulasolutions.com> In-Reply-To: <20261016-work-v2-0-9340b9555fbb@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, Michael Trimarchi , =?utf-8?q?Roman_Smr?= =?utf-8?q?=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=ho6ZArh7; 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ž --- Changes in v2: - Added missing entry to spi_ids. --- sound/soc/codecs/pcm179x-i2c.c | 3 +- sound/soc/codecs/pcm179x-spi.c | 4 ++- sound/soc/codecs/pcm179x.c | 62 ++++++++++++++++++++++++++++++++++++++---- sound/soc/codecs/pcm179x.h | 12 ++++++-- 4 files changed, 72 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 4b873f2986c7..a6c6ac1eb97b 100644 --- a/sound/soc/codecs/pcm179x-spi.c +++ b/sound/soc/codecs/pcm179x-spi.c @@ -31,13 +31,15 @@ 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 }, + { "pcm1795", 0 }, { "pcm1796", 0 }, { "pcm179x", 0 }, { }, diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index fae5de318b6e..8e9b9e98c8df 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) { @@ -150,6 +199,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, @@ -191,7 +241,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, }; @@ -227,6 +277,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;