All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Padmanabhan Rajanbabu <p.rajanbabu@samsung.com>,
	'Mark Brown' <broonie@kernel.org>
Cc: lgirdwood@gmail.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, s.nawrocki@samsung.com,
	perex@perex.cz, tiwai@suse.com, pankaj.dubey@samsung.com,
	alim.akhtar@samsung.com, rcsekar@samsung.com,
	aswani.reddy@samsung.com, alsa-devel@alsa-project.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCH 2/6] ASoC: samsung: i2s: configure PSR from sound card
Date: Sun, 23 Oct 2022 09:12:33 -0400	[thread overview]
Message-ID: <909abf31-91d9-159b-baef-6ffcfc3e07b2@linaro.org> (raw)
In-Reply-To: <04a101d8e523$30804b80$9180e280$@samsung.com>

On 21/10/2022 04:00, Padmanabhan Rajanbabu wrote:
>> It's not clear to me why the solution here is to move the configuration to
> the
>> sound card rather than to improve the I2S driver to be able to cope with
>> whatever the restrictions are on the PSR in these systems - it seems more
>> cumbersome for system integrators, especially since you've not documented
>> the issues or how to configure it.  Could you expand on what the
> constraints
>> are here and why it's not possible for the driver to figure things out
> (given
>> some quirk information)?
> 
> Thank you for reviewing the patch.
> 
> In Samsung I2S CPU controller, to derive the frame clock, we are supposed to
> configure the PSR and RFS internal dividers. i.e.
> 
> OPCLK -> PSR -> RCLK -> RFS -> Frame clock
> 
> Where:
> OPCLK - Operational clock
> PSR - Operational clock prescaler
> RCLK - Root Clock (derived from OPCLK based on PSR)
> RFS - Root frequency selection (divider)
> Frame clock - Sample frequency (derived from RCLK based on RFS)
> 
> Ultimately,
> 
> PSR = OPCLK / Frame clock / RFS
> 
> Unlike other platforms utilizing Samsung CPU DAI, FSD SoC has a limitation
> on
> operational clock, where the clock frequency is fixed (66 MHz) and cannot be
> modified. 
> 
> Assuming that an userspace application wants perform playback @44100 Hz
> and assuming that RFS divider value is configured as 256, the PSR value will
> yield to
> 
> 66 MHz / 44.1 KHz / 256 = 5
> 
> However if HW uses PSR = 5 to derive the frame clock from operational clock,
> then
> 
> RCLK = OPCLK / PSR = 66 MHz / 5 = 13.2 MHz
> Frame clock = RCLK / RFS = 13.2 MHz / 256 = 51562 Hz
> 
> The actual frame clock derived based on PSR is now different from what user
> application has intended. The situation did not improve even if the RFS is
> swept throughout the entire valid range.
> 
> We can overcome this scenario to an extent if we can get a flexibility to
> Configure both PSR as well as RFS.
> 
> i.e. to achieve frame clock of 44100 Hz, if PSR  = 23 and RFS = 64
> then frame clock = 66 MHz / 23 / 64 = 44836 Hz 
> 
> Although the sample frequency is not precise, it is very much closer to the
> Intended frequency, when compared to that of the existing solution. Since
> this
> scenario is specific to FSD SoC and has no changes in the Samsung I2S CPU
> DAI,
> the configuration is being done from the sound card of FSD SoC during
> hw_params.
> 
> Please let me know if you think this scenario can be approached in any other
> way possible, rather than configuring from sound card.

Entire new driver for this, instead of improving existing Samsung
drivers... no, it is no the way. If you followed this approach you would
send 20 drivers for each "specific" quirk difference.

Best regards,
Krzysztof


WARNING: multiple messages have this Message-ID (diff)
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Padmanabhan Rajanbabu <p.rajanbabu@samsung.com>,
	'Mark Brown' <broonie@kernel.org>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	linux-samsung-soc@vger.kernel.org,
	krzysztof.kozlowski+dt@linaro.org, rcsekar@samsung.com,
	aswani.reddy@samsung.com, pankaj.dubey@samsung.com,
	tiwai@suse.com, lgirdwood@gmail.com, robh+dt@kernel.org,
	alim.akhtar@samsung.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] ASoC: samsung: i2s: configure PSR from sound card
Date: Sun, 23 Oct 2022 09:12:33 -0400	[thread overview]
Message-ID: <909abf31-91d9-159b-baef-6ffcfc3e07b2@linaro.org> (raw)
In-Reply-To: <04a101d8e523$30804b80$9180e280$@samsung.com>

On 21/10/2022 04:00, Padmanabhan Rajanbabu wrote:
>> It's not clear to me why the solution here is to move the configuration to
> the
>> sound card rather than to improve the I2S driver to be able to cope with
>> whatever the restrictions are on the PSR in these systems - it seems more
>> cumbersome for system integrators, especially since you've not documented
>> the issues or how to configure it.  Could you expand on what the
> constraints
>> are here and why it's not possible for the driver to figure things out
> (given
>> some quirk information)?
> 
> Thank you for reviewing the patch.
> 
> In Samsung I2S CPU controller, to derive the frame clock, we are supposed to
> configure the PSR and RFS internal dividers. i.e.
> 
> OPCLK -> PSR -> RCLK -> RFS -> Frame clock
> 
> Where:
> OPCLK - Operational clock
> PSR - Operational clock prescaler
> RCLK - Root Clock (derived from OPCLK based on PSR)
> RFS - Root frequency selection (divider)
> Frame clock - Sample frequency (derived from RCLK based on RFS)
> 
> Ultimately,
> 
> PSR = OPCLK / Frame clock / RFS
> 
> Unlike other platforms utilizing Samsung CPU DAI, FSD SoC has a limitation
> on
> operational clock, where the clock frequency is fixed (66 MHz) and cannot be
> modified. 
> 
> Assuming that an userspace application wants perform playback @44100 Hz
> and assuming that RFS divider value is configured as 256, the PSR value will
> yield to
> 
> 66 MHz / 44.1 KHz / 256 = 5
> 
> However if HW uses PSR = 5 to derive the frame clock from operational clock,
> then
> 
> RCLK = OPCLK / PSR = 66 MHz / 5 = 13.2 MHz
> Frame clock = RCLK / RFS = 13.2 MHz / 256 = 51562 Hz
> 
> The actual frame clock derived based on PSR is now different from what user
> application has intended. The situation did not improve even if the RFS is
> swept throughout the entire valid range.
> 
> We can overcome this scenario to an extent if we can get a flexibility to
> Configure both PSR as well as RFS.
> 
> i.e. to achieve frame clock of 44100 Hz, if PSR  = 23 and RFS = 64
> then frame clock = 66 MHz / 23 / 64 = 44836 Hz 
> 
> Although the sample frequency is not precise, it is very much closer to the
> Intended frequency, when compared to that of the existing solution. Since
> this
> scenario is specific to FSD SoC and has no changes in the Samsung I2S CPU
> DAI,
> the configuration is being done from the sound card of FSD SoC during
> hw_params.
> 
> Please let me know if you think this scenario can be approached in any other
> way possible, rather than configuring from sound card.

Entire new driver for this, instead of improving existing Samsung
drivers... no, it is no the way. If you followed this approach you would
send 20 drivers for each "specific" quirk difference.

Best regards,
Krzysztof


  parent reply	other threads:[~2022-10-23 13:13 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20221014104843epcas5p47f6daaad2e67e0c9eedd68c2256c025b@epcas5p4.samsung.com>
2022-10-14 10:21 ` [PATCH 0/6] ASoC: samsung: fsd: audio support for FSD SoC Padmanabhan Rajanbabu
2022-10-14 10:21   ` Padmanabhan Rajanbabu
     [not found]   ` <CGME20221014104850epcas5p1a707b9d407a0947c3519077cf7fca5ff@epcas5p1.samsung.com>
2022-10-14 10:21     ` [PATCH 1/6] ASoC: samsung: i2s: TDM Support for CPU DAI driver Padmanabhan Rajanbabu
2022-10-14 10:21       ` Padmanabhan Rajanbabu
     [not found]   ` <CGME20221014104857epcas5p2a275a1d606ca066227228d13bcf5b120@epcas5p2.samsung.com>
2022-10-14 10:21     ` [PATCH 2/6] ASoC: samsung: i2s: configure PSR from sound card Padmanabhan Rajanbabu
2022-10-14 10:21       ` Padmanabhan Rajanbabu
2022-10-14 12:02       ` Mark Brown
2022-10-14 12:02         ` Mark Brown
2022-10-21  8:00         ` Padmanabhan Rajanbabu
2022-10-21  8:00           ` Padmanabhan Rajanbabu
2022-10-21 11:53           ` Mark Brown
2022-10-21 11:53             ` Mark Brown
2022-11-08  5:23             ` Padmanabhan Rajanbabu
2022-11-08  5:23               ` Padmanabhan Rajanbabu
2022-11-09 17:38               ` Mark Brown
2022-11-09 17:38                 ` Mark Brown
2023-01-03  4:55                 ` Padmanabhan Rajanbabu
2023-01-03  4:55                   ` Padmanabhan Rajanbabu
2022-10-23 13:12           ` Krzysztof Kozlowski [this message]
2022-10-23 13:12             ` Krzysztof Kozlowski
     [not found]   ` <CGME20221014104901epcas5p1a61ea81c3b1640bd8a064633c0b1e40d@epcas5p1.samsung.com>
2022-10-14 10:21     ` [PATCH 3/6] dt-bindings: sound: Add sound card bindings for Tesla FSD Padmanabhan Rajanbabu
2022-10-14 10:21       ` Padmanabhan Rajanbabu
2022-10-14 15:13       ` Rob Herring
2022-10-14 15:13         ` Rob Herring
2022-10-21  8:44         ` Padmanabhan Rajanbabu
2022-10-21  8:44           ` Padmanabhan Rajanbabu
2022-10-22 16:48           ` Krzysztof Kozlowski
2022-10-22 16:48             ` Krzysztof Kozlowski
2022-11-08  5:33             ` Padmanabhan Rajanbabu
2022-11-08  5:33               ` Padmanabhan Rajanbabu
2022-11-08 10:36               ` Krzysztof Kozlowski
2022-11-08 10:36                 ` Krzysztof Kozlowski
     [not found]   ` <CGME20221014104904epcas5p4f458182cc9ac9c223d9a25566f3dd300@epcas5p4.samsung.com>
2022-10-14 10:21     ` [PATCH 4/6] ASoC: samsung: fsd: Add FSD soundcard driver Padmanabhan Rajanbabu
2022-10-14 10:21       ` Padmanabhan Rajanbabu
2022-10-14 12:23       ` Mark Brown
2022-10-14 12:23         ` Mark Brown
2022-10-21  8:09         ` Padmanabhan Rajanbabu
2022-10-21  8:09           ` Padmanabhan Rajanbabu
2022-10-16 15:18       ` Krzysztof Kozlowski
2022-10-16 15:18         ` Krzysztof Kozlowski
2022-10-21  9:04         ` Padmanabhan Rajanbabu
2022-10-21  9:04           ` Padmanabhan Rajanbabu
     [not found]   ` <CGME20221014104911epcas5p394100ff6ed53be32c4d64c7e23e48833@epcas5p3.samsung.com>
2022-10-14 10:21     ` [PATCH 5/6] arm64: dts: fsd: Add I2S DAI node for Tesla FSD Padmanabhan Rajanbabu
2022-10-14 10:21       ` Padmanabhan Rajanbabu
2022-10-14 13:24       ` Alim Akhtar
2022-10-14 13:24         ` Alim Akhtar
2022-10-21  8:09         ` Padmanabhan Rajanbabu
2022-10-21  8:09           ` Padmanabhan Rajanbabu
2022-10-16 15:14       ` Krzysztof Kozlowski
2022-10-16 15:14         ` Krzysztof Kozlowski
2022-10-21  8:49         ` Padmanabhan Rajanbabu
2022-10-21  8:49           ` Padmanabhan Rajanbabu
2022-10-21 13:01           ` Krzysztof Kozlowski
2022-10-21 13:01             ` Krzysztof Kozlowski
2022-11-08  5:26             ` Padmanabhan Rajanbabu
2022-11-08  5:26               ` Padmanabhan Rajanbabu
     [not found]   ` <CGME20221014104915epcas5p12414b87ea127b2d5bf521556bf841b00@epcas5p1.samsung.com>
2022-10-14 10:21     ` [PATCH 6/6] arm64: dts: fsd: Add sound card " Padmanabhan Rajanbabu
2022-10-14 10:21       ` Padmanabhan Rajanbabu
2022-10-14 13:29       ` Alim Akhtar
2022-10-14 13:29         ` Alim Akhtar
2022-10-21  8:12         ` Padmanabhan Rajanbabu
2022-10-21  8:12           ` Padmanabhan Rajanbabu
2022-10-21 12:53           ` Krzysztof Kozlowski
2022-10-21 12:53             ` Krzysztof Kozlowski
2022-11-08  5:25             ` Padmanabhan Rajanbabu
2022-11-08  5:25               ` Padmanabhan Rajanbabu

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=909abf31-91d9-159b-baef-6ffcfc3e07b2@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=alim.akhtar@samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=aswani.reddy@samsung.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=p.rajanbabu@samsung.com \
    --cc=pankaj.dubey@samsung.com \
    --cc=perex@perex.cz \
    --cc=rcsekar@samsung.com \
    --cc=robh+dt@kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.