alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* ADAU1761 default register value problem
@ 2016-04-21 14:01 Ricard Wanderlof
  2016-04-26  8:21 ` Lars-Peter Clausen
  0 siblings, 1 reply; 8+ messages in thread
From: Ricard Wanderlof @ 2016-04-21 14:01 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: alsa-devel


Hi Lars,

A while ago I posted a question to the list regarding the default values 
set up for the ADAU1761 (and similar CODECs), but I didn't get a response. 
I really need to try and figure out a way forward here though so I'll 
bring this up again.

The problem I have is that the driver assumes that the CODEC has been 
initialized with the default register settings when the system boots. 
However, if the system has not been power cycled but just rebooted, this 
is not necessarily the case, as the CODEC has no external reset pin but 
derives its reset signal internally from the power level.

Furthermore, if the system upon reboot tries to set a register value to 
one of the default settings (for example as the result of a hw_params() 
call), then the regcache mechanism will disregard the write as it assumes 
the default value is already set, which is not necessarily the case.

As I see it the solution to this problem is simply not to assume anything 
about the register settings, so that the first write to a given register 
always takes effect.

I can work on a patch to accomplish this, however, since so much work 
apparently has been laid down in getting the default values into the 
driver in the first place, I'm assuming there's something more to the 
story that I'm missing, so I'd like to get a better grip on this before I 
dive in.

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 8+ messages in thread
* ADAU1761 default register value problem
@ 2016-03-29 13:58 Ricard Wanderlof
  0 siblings, 0 replies; 8+ messages in thread
From: Ricard Wanderlof @ 2016-03-29 13:58 UTC (permalink / raw)
  To: alsa-devel


I have a problem with the ADAU1761 (although the problem I would think 
would manifest itself with a veriety of codecs).

The register values are cached to minimize the number of writes needed, 
and there is a set of default values specified. However, this assumes that 
when the software boots the chip is always in the default state. This is 
not necessarily the case, because the chip has no external reset line and 
resets its internal state using an internal power-on-reset circuit, so if 
the system is rebooted without a power cycle, the regcache will contain 
the default values of the registers, whereas the actual registers in the 
chip will retain their previous values. Hence, if attempting to set a 
value in a register which is in fact identical to the default value, it 
will not be written, and the value that is currently in the register will 
remain. This can lead to all sorts of misconfigurations, depending on the 
previous state of the chip.

One way to fix this is simply to avoid setting up a set of default 
registers (looking at regcache.c, one way seems to be to omit setting the 
reg_defaults and num_reg_defaults members of the struct regmap_config 
during initialization, and instead setting num_reg_defaults_raw to the 
number of registers the chip has, but not setting reg_defaults_raw; I 
don't know if this is how it is intended to be used however). The regcache 
framework will then read all the register values from the chip and use 
them as the new defaults.

While this would seem to be technically correct, the question is if this 
is acceptable? A drawback is that there will be a lot of I2C or SPI 
accesses just to get the default values. Or should the caching behavior at 
startup be configured in some way, for instance via devicetree?

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-05-16 17:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-21 14:01 ADAU1761 default register value problem Ricard Wanderlof
2016-04-26  8:21 ` Lars-Peter Clausen
2016-05-03  8:16   ` Ricard Wanderlof
2016-05-11 15:16   ` Ricard Wanderlof
2016-05-13  8:20     ` Lars-Peter Clausen
2016-05-16 11:07       ` Ricard Wanderlof
2016-05-16 17:02         ` Lars-Peter Clausen
  -- strict thread matches above, loose matches on Subject: below --
2016-03-29 13:58 Ricard Wanderlof

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).