All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Sameer Pujar <spujar@nvidia.com>
Cc: robh+dt@kernel.org, krzk+dt@kernel.org, thierry.reding@gmail.com,
	lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	jonathanh@nvidia.com, catalin.marinas@arm.com, will@kernel.org,
	alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/6] ASoC: tegra: Add Tegra186 based ASRC driver
Date: Mon, 28 Mar 2022 16:44:31 +0100	[thread overview]
Message-ID: <YkHX3/8BbXo4obWI@sirena.org.uk> (raw)
In-Reply-To: <1648447526-14523-3-git-send-email-spujar@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 2478 bytes --]

On Mon, Mar 28, 2022 at 11:35:22AM +0530, Sameer Pujar wrote:

> +	regcache_cache_only(asrc->regmap, false);
> +	regcache_sync(asrc->regmap);
> +
> +	/* Setup global registers */
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_SOFT_RESET, 0x1);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_SCRATCH_ADDR,
> +		     TEGRA186_ASRC_ARAM_START_ADDR);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_INT_MASK, 0x01);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_ENB,
> +		     TEGRA186_ASRC_GLOBAL_EN);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_INT_CLEAR, 0x01);

This seems weird - we resync the cache, then do a soft reset (which
presumably desyncs the cache) and then explicitly restore a bunch of
things (hopefully everything that was in the cached state?).  This is
certainly very much not idiomatic and looks worrying.  Are you sure that
the device is getting anything out of the register cache?

> +static int tegra186_asrc_put_ratio_source(struct snd_kcontrol *kcontrol,
> +					  struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct soc_enum *asrc_private =
> +		(struct soc_enum  *)kcontrol->private_value;
> +	struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
> +	struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt);
> +	unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE;
> +
> +	asrc->lane[id].ratio_source = ucontrol->value.enumerated.item[0];
> +
> +	regmap_update_bits(asrc->regmap, asrc_private->reg,
> +			   TEGRA186_ASRC_STREAM_RATIO_TYPE_MASK,
> +			   asrc->lane[id].ratio_source);
> +
> +	return 1;
> +}

This should only return 1 if the value actually changed, you can use
regmap_update_bits_check() to detect the change.  Current mixer-test
ought to spot this.

> +static const struct snd_kcontrol_new tegra186_asrc_controls[] = {
> +	/* Controls for integer part of ratio */
> +	SOC_SINGLE_EXT("Ratio1 Integer Part",
> +		       ASRC_STREAM_REG(TEGRA186_ASRC_RATIO_INT_PART, 0),
> +		       0, TEGRA186_ASRC_STREAM_RATIO_INT_PART_MASK, 0,
> +		       tegra186_asrc_get_ratio_int,
> +		       tegra186_asrc_put_ratio_int),

Can't the driver work out the ratios based on...

> +	/* Source of ratio provider */
> +	SOC_ENUM_EXT("Ratio1 Source", src_select1,
> +		     tegra186_asrc_get_ratio_source,
> +		     tegra186_asrc_put_ratio_source),

...the sources?  Or does it need to be configured before either side is
ready in which case this might be the best we can do for now.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@kernel.org>
To: Sameer Pujar <spujar@nvidia.com>
Cc: jonathanh@nvidia.com, devicetree@vger.kernel.org,
	alsa-devel@alsa-project.org, catalin.marinas@arm.com,
	tiwai@suse.com, lgirdwood@gmail.com, robh+dt@kernel.org,
	thierry.reding@gmail.com, linux-arm-kernel@lists.infradead.org,
	linux-tegra@vger.kernel.org, krzk+dt@kernel.org, will@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] ASoC: tegra: Add Tegra186 based ASRC driver
Date: Mon, 28 Mar 2022 16:44:31 +0100	[thread overview]
Message-ID: <YkHX3/8BbXo4obWI@sirena.org.uk> (raw)
In-Reply-To: <1648447526-14523-3-git-send-email-spujar@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 2478 bytes --]

On Mon, Mar 28, 2022 at 11:35:22AM +0530, Sameer Pujar wrote:

> +	regcache_cache_only(asrc->regmap, false);
> +	regcache_sync(asrc->regmap);
> +
> +	/* Setup global registers */
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_SOFT_RESET, 0x1);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_SCRATCH_ADDR,
> +		     TEGRA186_ASRC_ARAM_START_ADDR);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_INT_MASK, 0x01);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_ENB,
> +		     TEGRA186_ASRC_GLOBAL_EN);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_INT_CLEAR, 0x01);

This seems weird - we resync the cache, then do a soft reset (which
presumably desyncs the cache) and then explicitly restore a bunch of
things (hopefully everything that was in the cached state?).  This is
certainly very much not idiomatic and looks worrying.  Are you sure that
the device is getting anything out of the register cache?

> +static int tegra186_asrc_put_ratio_source(struct snd_kcontrol *kcontrol,
> +					  struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct soc_enum *asrc_private =
> +		(struct soc_enum  *)kcontrol->private_value;
> +	struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
> +	struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt);
> +	unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE;
> +
> +	asrc->lane[id].ratio_source = ucontrol->value.enumerated.item[0];
> +
> +	regmap_update_bits(asrc->regmap, asrc_private->reg,
> +			   TEGRA186_ASRC_STREAM_RATIO_TYPE_MASK,
> +			   asrc->lane[id].ratio_source);
> +
> +	return 1;
> +}

This should only return 1 if the value actually changed, you can use
regmap_update_bits_check() to detect the change.  Current mixer-test
ought to spot this.

> +static const struct snd_kcontrol_new tegra186_asrc_controls[] = {
> +	/* Controls for integer part of ratio */
> +	SOC_SINGLE_EXT("Ratio1 Integer Part",
> +		       ASRC_STREAM_REG(TEGRA186_ASRC_RATIO_INT_PART, 0),
> +		       0, TEGRA186_ASRC_STREAM_RATIO_INT_PART_MASK, 0,
> +		       tegra186_asrc_get_ratio_int,
> +		       tegra186_asrc_put_ratio_int),

Can't the driver work out the ratios based on...

> +	/* Source of ratio provider */
> +	SOC_ENUM_EXT("Ratio1 Source", src_select1,
> +		     tegra186_asrc_get_ratio_source,
> +		     tegra186_asrc_put_ratio_source),

...the sources?  Or does it need to be configured before either side is
ready in which case this might be the best we can do for now.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@kernel.org>
To: Sameer Pujar <spujar@nvidia.com>
Cc: robh+dt@kernel.org, krzk+dt@kernel.org, thierry.reding@gmail.com,
	lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	jonathanh@nvidia.com, catalin.marinas@arm.com, will@kernel.org,
	alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/6] ASoC: tegra: Add Tegra186 based ASRC driver
Date: Mon, 28 Mar 2022 16:44:31 +0100	[thread overview]
Message-ID: <YkHX3/8BbXo4obWI@sirena.org.uk> (raw)
In-Reply-To: <1648447526-14523-3-git-send-email-spujar@nvidia.com>


[-- Attachment #1.1: Type: text/plain, Size: 2478 bytes --]

On Mon, Mar 28, 2022 at 11:35:22AM +0530, Sameer Pujar wrote:

> +	regcache_cache_only(asrc->regmap, false);
> +	regcache_sync(asrc->regmap);
> +
> +	/* Setup global registers */
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_SOFT_RESET, 0x1);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_SCRATCH_ADDR,
> +		     TEGRA186_ASRC_ARAM_START_ADDR);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_INT_MASK, 0x01);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_ENB,
> +		     TEGRA186_ASRC_GLOBAL_EN);
> +	regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_INT_CLEAR, 0x01);

This seems weird - we resync the cache, then do a soft reset (which
presumably desyncs the cache) and then explicitly restore a bunch of
things (hopefully everything that was in the cached state?).  This is
certainly very much not idiomatic and looks worrying.  Are you sure that
the device is getting anything out of the register cache?

> +static int tegra186_asrc_put_ratio_source(struct snd_kcontrol *kcontrol,
> +					  struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct soc_enum *asrc_private =
> +		(struct soc_enum  *)kcontrol->private_value;
> +	struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
> +	struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt);
> +	unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE;
> +
> +	asrc->lane[id].ratio_source = ucontrol->value.enumerated.item[0];
> +
> +	regmap_update_bits(asrc->regmap, asrc_private->reg,
> +			   TEGRA186_ASRC_STREAM_RATIO_TYPE_MASK,
> +			   asrc->lane[id].ratio_source);
> +
> +	return 1;
> +}

This should only return 1 if the value actually changed, you can use
regmap_update_bits_check() to detect the change.  Current mixer-test
ought to spot this.

> +static const struct snd_kcontrol_new tegra186_asrc_controls[] = {
> +	/* Controls for integer part of ratio */
> +	SOC_SINGLE_EXT("Ratio1 Integer Part",
> +		       ASRC_STREAM_REG(TEGRA186_ASRC_RATIO_INT_PART, 0),
> +		       0, TEGRA186_ASRC_STREAM_RATIO_INT_PART_MASK, 0,
> +		       tegra186_asrc_get_ratio_int,
> +		       tegra186_asrc_put_ratio_int),

Can't the driver work out the ratios based on...

> +	/* Source of ratio provider */
> +	SOC_ENUM_EXT("Ratio1 Source", src_select1,
> +		     tegra186_asrc_get_ratio_source,
> +		     tegra186_asrc_put_ratio_source),

...the sources?  Or does it need to be configured before either side is
ready in which case this might be the best we can do for now.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-03-28 15:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28  6:05 [PATCH 0/6] ASRC support on Tegra186 and later Sameer Pujar
2022-03-28  6:05 ` Sameer Pujar
2022-03-28  6:05 ` Sameer Pujar
2022-03-28  6:05 ` [PATCH 1/6] ASoC: tegra: Add binding doc for ASRC module Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05 ` [PATCH 2/6] ASoC: tegra: Add Tegra186 based ASRC driver Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28 15:44   ` Mark Brown [this message]
2022-03-28 15:44     ` Mark Brown
2022-03-28 15:44     ` Mark Brown
2022-03-29  8:32     ` Sameer Pujar
2022-03-29 11:30       ` Mark Brown
2022-03-29 11:30         ` Mark Brown
2022-03-29 11:30         ` Mark Brown
2022-03-28  6:05 ` [PATCH 3/6] ASoC: tegra: AHUB routes for ASRC module Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05 ` [PATCH 4/6] arm64: defconfig: Build Tegra " Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05 ` [PATCH 5/6] arm64: tegra: Add ASRC device on Tegra186 and later Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05 ` [PATCH 6/6] arm64: tegra: Enable ASRC on various platforms Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar
2022-03-28  6:05   ` Sameer Pujar

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=YkHX3/8BbXo4obWI@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=spujar@nvidia.com \
    --cc=thierry.reding@gmail.com \
    --cc=tiwai@suse.com \
    --cc=will@kernel.org \
    /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.