Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Stephen Gordon <gordoste@iinet.net.au>
To: Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
	Baojun Xu <baojun.xu@ti.com>, Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: linux-sound@vger.kernel.org
Subject: [PATCH v2] ASoC: pcm3168a: Add option to force clock consumer
Date: Fri, 6 Dec 2024 22:54:43 +1100	[thread overview]
Message-ID: <5011ceef-5100-441d-b169-dabba135d27f@iinet.net.au> (raw)
In-Reply-To: <ea504848-eeb1-4e8e-bbf2-394114802c20@iinet.net.au>

Hi,

Resending with signoff tag and including linux-sound on CC.

Scenario is that DAC's clock pins are tied to ADC's clock pins, with
codec acting as clock producer for the I2S bus, and the CPU has a single
pair of I2S clock pins used for both playback and capture.


                                  ,-------------------
---------            ------------| LRCK     DAC
      LRCK|-------+--/     -------| BCK   (producer)  C
CPU      |       |       /       |                   O
       BCK|-------|---+--/        | ----------------  D
consumer |       \   |           |                   E
---------         ---------------| LRCK     ADC      C
                      `-----------| BCK    (consumer)
                                  `--------------------

Both DAI links will have codec acting as a clock producer, but we need

to configure the codec so that only one of ADC/DAC drives the lines.


Add DT options to support this configuration. adc-force-cons/dac-force-cons

cause the corresponding component to be configured in consumer mode.


Signed-off-by: Stephen Gordon <gordoste@iinet.net.au>




diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index 9d6431338..1a4cf8d63 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -61,6 +61,7 @@ struct pcm3168a_priv {
         struct clk *scki;
         struct gpio_desc *gpio_rst;
         unsigned long sysclk;
+       bool adc_fc, dac_fc; // Force clock consumer mode

         struct pcm3168a_io_params io_params[2];
         struct snd_soc_dai_driver dai_drv[2];
@@ -479,6 +480,12 @@ static int pcm3168a_hw_params(struct 
snd_pcm_substream *substream,
                 ms = 0;
         }

+       // Force clock consumer mode if needed
+       if (pcm3168a->adc_fc && dai->id == PCM3168A_DAI_ADC)
+               ms = 0;
+       if (pcm3168a->dac_fc && dai->id == PCM3168A_DAI_DAC)
+               ms = 0;
+
         format = io_params->format;

         if (io_params->slot_width)
@@ -757,6 +764,15 @@ int pcm3168a_probe(struct device *dev, struct 
regmap *regmap)

         pcm3168a->sysclk = clk_get_rate(pcm3168a->scki);

+       adc_fc = false;
+       dac_fc = false;
+       if (dev->of_node) {
+               pcm3168a->adc_fc = of_property_read_bool(dev->of_node,
+                               "adc-force-cons");
+               pcm3168a->dac_fc = of_property_read_bool(dev->of_node,
+                               "dac-force-cons");
+       }
+
         for (i = 0; i < ARRAY_SIZE(pcm3168a->supplies); i++)
                 pcm3168a->supplies[i].supply = pcm3168a_supply_names[i];






  reply	other threads:[~2024-12-06 11:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03 12:01 [PATCH] ASoC: pcm3168a: Add option to force clock consumer Stephen Gordon
2024-12-06 11:54 ` Stephen Gordon [this message]
2024-12-06 12:07   ` [PATCH v2] " Mark Brown
2024-12-06 12:22   ` Mark Brown
2024-12-06 13:16     ` Stephen Gordon
2024-12-06 14:13       ` Mark Brown
2024-12-07  1:52         ` Stephen Gordon
2024-12-09  1:58           ` Kuninori Morimoto
2024-12-09 12:12             ` Stephen Gordon
2024-12-10  2:40               ` Kuninori Morimoto
2024-12-12  1:54                 ` Stephen Gordon
2024-12-13  5:10                   ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5011ceef-5100-441d-b169-dabba135d27f@iinet.net.au \
    --to=gordoste@iinet.net.au \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=shenghao-ding@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox