Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sound/soc/codecs/max98373-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ static bool max98373_readable_register(struct device *dev, unsigned int reg)
static bool max98373_volatile_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case MAX98373_R203E_AMP_PATH_GAIN:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I really don't understand this. If this is a hardware register that can change on its own, then it needs to be volatile.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is based on comments "I agree to remove AMP_PATH_GAIN from volatile register list" from Ryans. @ryans-lee , can you explain this ? thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm this register is non-volatile.

case MAX98373_R2054_MEAS_ADC_PVDD_CH_READBACK:
case MAX98373_R2055_MEAS_ADC_THERM_CH_READBACK:
case MAX98373_R20B6_BDE_CUR_STATE_READBACK:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, AMP_PATH_GAIN I can understand, but "MEAS_ADC_*" seems like really volatile data. OTOH, exposing volatile regs directly as kcontrols does not seem like a good idea. Not sure what the right solution is... reading incorrect temperature readings does not sound good either.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, @ryans-lee could you help to check this ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTOH, exposing volatile regs directly as kcontrols does not seem like a good idea. Not sure what the right solution is... reading incorrect temperature readings does not sound good either.

Agree. Maybe "ADC PVDD" and "ADC TEMP" are for special purpose. And it makes sense that we can't get the value in suspended.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is correct? Isn't the issue more that we expose some registers that should not be shown to users, or if they are shown the put/get routines should include a pm_runtime_get_sync/put_autosuspend?. It'd be odd to change the nature of regmap registers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree to remove AMP_PATH_GAIN from volatile register list, but 0x2054, 0x2055 and 0x2086 are real volatile registers to update amp ADC values. Amp driver will return only cached value instead of reading actual value from h/w if these registers are removed from the volatile list. PVDD level and amp temperature are changing over time and it is being used for speaker calibration application running in user space. Reading ADC values while amp is suspended is not expected operation since amp is likely powered off in this state. Adding pm get_sync/auto suspend into put/get routine makes sense to me.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryans-lee thanks for you idea and patch. Today I only have very limited time to access our device with your patch and found one issue. the "compnent->suspend" is only set for S3 sleep, not for runtime suspend. I modify it to "if (snd_soc_dapm_get_bias_level(&component->dapm) != SND_SOC_BIAS_OFF)", but I have to test it on device to confirm it.

+static int max98373_adc_get(struct snd_kcontrol *kcontrol,
+                           struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+       struct max98373_priv *max98373 =
+               snd_soc_component_get_drvdata(component);
+       struct soc_mixer_control *mc =
+               (struct soc_mixer_control *)kcontrol->private_value;
+       int reg = 0;
+
+       if (!component->suspend)
+               regmap_read(max98373->regmap, mc->reg, &reg);
+       ucontrol->value.integer.value[0] = reg;
+
+       return 0;
+}

Expand Down