Sound pops

Материал из Toshiba AC100 wiki
Перейти к: навигация, поиск

This page is about how to remove pops on ac100 (tegra2 + alc5632 codec)

Other boards and theory

Ways to suppress click and pop for class D amplifiers

aSoC: msm8610: fix speaker amp pop issue

Some logs

NOTE: replace http://stuw.narod.ru/ with https://dl.dropboxusercontent.com/u/40761340/www/

07:19 < stuw> marvin24, It was my fault, I removed this patch by mistake buring backport. I will check diff between 3.0 and for-next.
07:20 < stuw> PaulFertser, good morning and thanks for your checks :)
07:22 < PaulFertser> stuw: hey, good morning :)
07:25 < PaulFertser> stuw: btw, the pop is still there ;)
07:25 < PaulFertser> One theory is that it's emitted by the amp whenever it's turned on.
07:25 < PaulFertser> But i'm yet to verify it.
07:27 < stuw> PaulFertser, If amplifier is enabled only once at start, than pop
07:27 < stuw> is not related to it. Because I hear pops when mute/unmute DAC2SPK
07:27 < PaulFertser> Also, the amp boasts a de-pop circuity. It shouldn't be enabled all the time i think, it should be handled by the DAPM instead.
07:27 < PaulFertser> Hm, i hear pops even when the Speaker is muted and only headphones are connected.
07:28 < stuw> hmm )
07:28 < PaulFertser> (the amp's de-pop is fully integrated and automatic, it should work just fine)
07:30 < stuw> interesting, will we hear pops without codec (and probably board sound) driver at all...
07:56 < gildean> iirc there was a pop even with android

20:51 < PaulFertser> stuw_: leonro: Couldn't hear any pops neither during playback nor silence, so paz00_mute() and paz00_unmute() aren't guilty.

20:52 < marvin24_DT> leonro, stuw_: do you know what's so special with MIC12SPK switch?
20:52 < marvin24_DT> first, muting/unmuting it creates a "pop"
20:52 < marvin24_DT> I didn't saw this for any other switch
20:53 < marvin24_DT> correction: unmuting create a pop
20:53 < stuw_> marvin24_DT: probably MIC12SPK  enables speaker routes. especially if you have headphones connected
20:53 < marvin24_DT> secondly, unmuting takes a ~1 second
20:54 < stuw_> very long IMHO
20:54 < marvin24_DT> ok, 0.5 secs
20:54 < marvin24_DT> but no other switch shows this behaviour
20:54 < marvin24_DT> stuw_: I have all volumes set to zero
20:54 < marvin24_DT> and everything muted
20:55 < marvin24_DT> still "pop"
20:56 < PaulFertser> marvin24_DT: if you check full DAPM state before and after you'll most probably see the speaker route gets activated.
20:56 < PaulFertser> marvin24_DT: and mute controls that are coupled with the volume controls do not have any effect on it.
20:56 < stuw_> looks like pops are generated when codec goes from one state to another or something like that
21:18 < marvin24_DT> I hoped something like this would mute/unmute the speaker on demand: http://sprunge.us/ZWFf
21:18 < marvin24_DT> and thus avoid the pop
21:19 < marvin24_DT> but it seems it is connected to the wrong event
21:20 < stuw_> is this function called ?
21:21   >>> [email protected]
21:21 < stuw_> * muting_func
21:21 < marvin24_DT> stuw_: yes
21:22 < marvin24_DT> but only on switching DAC2SPK
21:22 < marvin24_DT> I thought it gets called on playback/stop
21:22 < marvin24_DT> to save some energy
21:22 < marvin24_DT> maybe we can add another event somewhere else?
21:24 < stuw_> this event called before and after playback later. I removed function with debug message during backport
21:25 < stuw_> maybe I'm wrong, but I pretty sure it called previously
21:26 < marvin24_DT> no, and it is only called when all others are muted ...
21:26 < marvin24_DT> correction: only call when MIC12SPK is muted
21:27 < marvin24_DT> again this one ...
21:27 < marvin24_DT> something is strange here
21:27 < stuw_> yep
21:31   <   [email protected] [Ping timeout: 252 seconds]
21:34   >>> [email protected]
21:36 < marvin24_DT> ok, now it switches as expected (with MIC12SPK muted)
21:36 < marvin24_DT> playback -> amp on
21:36 < marvin24_DT> stop -> amp off (after 2 secs or so)
21:37 < marvin24_DT> but still the "pop", I guess amp should come up a bit later

22:32 < marvin24_DT> any reason why we shouldn't enable zero-cross detection on codec power-up?
22:32   <   [email protected] [Ping timeout: 244 seconds]
22:36 < leonro> marvin24_DT: it seems from the description, what we need to enable it
22:36 < marvin24_DT> I added it to the power_depop
22:36 < marvin24_DT> but unfortunately, no change :-(
22:36   <   [email protected] [Quit: Leaving.]
22:37 < leonro> marvin24_DT: how did you set it?
22:39 < marvin24_DT> update_bits 0x4040 on spk_vol  and hp_vol
22:39 < marvin24_DT> there is also smt_trig ...
22:40 < marvin24_DT> in reg misc ctrl (0x5e)
22:41 < leonro> on spk you need only 0x4000
22:42 < marvin24_DT> oh, right
22:44 < marvin24_DT> but what about smt_trig in ctrl? "Enable mute-unmute de-pop"
22:44   >>> [email protected]
22:44 < leonro> 8.20. Reg-3Ah: Power Management Addition 1
22:44 < leonro> All Zero Cross Detect Power Down
22:45 < leonro> by default it is disabled
22:46 < stuw_> I tried zcd later with no effect
22:48 < leonro> did you try together power with spk_vol ?
22:49 < marvin24_DT> doing now
22:49 < marvin24_DT> 0
22:49   <   [email protected] [Ping timeout: 252 seconds]
22:49 < leonro> marvin24_DT: we have alc5632_mute function, did you see it?
22:50 < marvin24_DT> reg?
22:51 < leonro>  989         .digital_mute = alc5632_mute,
22:51 < marvin24_DT> at least the pop during playback vanished
22:52 < leonro> http://lxr.free-electrons.com/source/include/sound/soc-dai.h#L153
23:01 < marvin24_DT> leonro: isn't there some equivalent for the board file?
23:01 < marvin24_DT> I cannot controll the gpio from the codec so easily

21:31 < marvin24_DT> hi stuw_
21:31 < marvin24_DT> I added the nvec gpio to 3.0-exp
21:31 < marvin24_DT> and enabled it in the board driver
21:31 < marvin24_DT> but no luck yet with un-poping
21:33   <   Alex[sp3dev][email protected] [Ping timeout: 252 seconds]
21:34   >>> Alex[sp3dev][email protected]
21:43 < stuw_> marvin24_DT: hi. did you push the changes?
21:45 < stuw_> marvin24_DT: is it difficult to control enable/disable amp using sys or debugfs?
21:46 < stuw_> The idea is to disable amp manually and check pops
21:51 < marvin24_DT> stuw_: it is easy
21:51 < marvin24_DT> just export the gpio
21:51 < marvin24_DT> echo 230 > /sys/class/gpio/export
21:51 < marvin24_DT> or so
21:54   <   [email protected] [Ping timeout: 276 seconds]
21:55   >>> [email protected]
21:56 < marvin24_DT> arr, you need to comment out the request/free gpio calls in the board driver
21:57   <   [email protected]:e35:2ec9:4b20:21f:d0ff:fede:376b [Quit: Quitte]
22:27 < stuw_> marvin24_DT: amp was not enabled by default on my system. As a result speakers doesn't work. Also I can't hear any pops.
22:29 < marvin24_DT> oh
22:29   <   [email protected] [Ping timeout: 244 seconds]
22:30 < marvin24_DT> stuw_: did you enabled the nvec_gpio driver?
22:30 < stuw_> ummm. no, I didn't do anything.
22:31 < marvin24_DT> but you compile the 3.0-exp tree ?
22:31 < stuw_> yes
22:31 < marvin24_DT> it should have ask you if you want to enable the gpio driver
22:32 < marvin24_DT> drivers/staging/nvec/nvec_gpio.c
22:32 < stuw_> hmm, no, make paz00_defconfig && make
22:32 < stuw_> no questions
22:32 < marvin24_DT> git branch wrong?
22:33 < stuw_> maybe ) will recheck
22:33 < marvin24_DT> chromeos-ac100-3.0-exp
22:33 < marvin24_DT> you should have a commit like 6c31b18c093d0be04bf3c182fbd44ac7d4995151
22:36   >>> [email protected]
22:37   >>> [email protected]
22:38 < stuw_> I've checked out branch once again. Recompiling. Still no question...
22:41 < marvin24_DT> do you have the commit above?
22:41   >>> [email protected]
22:42 < stuw_> yes
22:42 < marvin24_DT> grep NVEC_GPIO .config
22:42 < stuw_> commit 6c31b18c093d0be04bf3c182fbd44ac7d4995151
22:42 < stuw_> Author: Marc Dietrich <[email protected]>
22:42 < stuw_> Date:   Thu Mar 22 20:48:09 2012 +0100
22:42 < marvin24_DT> yep
22:42 < stuw_> # CONFIG_NVEC_GPIO is not set
22:42 < stuw_> )
22:42 < marvin24_DT> bad
22:43 < marvin24_DT> possible that defconfig just defaults to NO here
22:43 < marvin24_DT> make oldconfig does it better
22:44 < stuw_> I've edited .config manually
22:52 < stuw_> amp is on, and pops are still here :(
22:54 < marvin24_DT> yes
22:54 < marvin24_DT> the codec switches the amp on too soon I guess
22:54 < marvin24_DT> and even worse, it never switches it off!
22:57 < stuw_> btw,  are 0 and 2 correct values for gpio (message -->  nvec nvec.0: gpio 0 set to value <x>) ?
23:01   <   [email protected] [Quit: Leaving]
23:03 < marvin24_DT> stuw_: yes, it is "rounded" to 1
23:06 < Alex[sp3dev]> actually i've seen once (i don't remember but it was tegra with cros 2.6.38) that gpio_set_value with value==5 caused errors. better 'cast to bool' each time
23:09   <   [email protected] [Ping timeout: 260 seconds]
23:09 < marvin24_DT> well, we use if (value) ...
23:09 < marvin24_DT> so there should be no problem
23:10 < Alex[sp3dev]> ok than.
23:11 < marvin24_DT> it just depends on the driver
23:11 < marvin24_DT> and luckily, we have our own ;-)
23:11   <   panda|[email protected]:5c0:1000:a::164b [Ping timeout: 245 seconds]
23:14 < marvin24_DT> stuw_: btw, I tried http://pastebin.com/xgHEhJfj to move the mute/unmute on codec power state change
...
23:16 < stuw_> marvin24_DT: and the result is... )
23:17 < marvin24_DT> pop!
...
23:30 < stuw_> marvin24_DT: how to change exported gpio state ?
23:31 < marvin24_DT> cd /sys/class/gpio/gpiochip230
23:31 < marvin24_DT> eh, wrong
23:31   <   [email protected] [Ping timeout: 245 seconds]
23:31 < marvin24_DT> there should be a gpio230 dir in  /sys/class/gpio
23:32 < stuw_> yes
23:32 < marvin24_DT> echo 0 > gpio230/value should disable the amp
23:32 < stuw_> ok, thanks.
23:34 < stuw_> O_o I hear pops when enabling amp
23:36 < marvin24_DT> mmh, maybe we should enable it earlier so the codec can make a soft start
23:36 < stuw_> codec is disabled, amp generates pops itself
23:36 < marvin24_DT> urg
23:36 < marvin24_DT> how did you disable the codec?
23:36 < stuw_> I mean no audio playback
23:36 < stuw_> codec should be powered off
23:37 < marvin24_DT> yes, but it isn't ...
23:37 < marvin24_DT> if it would, the amp should also switch off
23:37 < marvin24_DT> EVENT_ON = 0
23:38 < marvin24_DT> als check /sys/kernel/debug/asoc/alc.../.../bias_level
23:38 < stuw_> I removed gpio initialization from board driver
23:38 < marvin24_DT>  you can toggle the gpio even without reserving it
23:38 < marvin24_DT> e.g. with gpio_request
23:39 < marvin24_DT> gpio_set_value should still work
23:39 < marvin24_DT> if you mute the MIC12SPK mixer
23:39 < marvin24_DT> the codec powers off
23:39 < stuw_> I just wanted to be sure amp is under my control only
23:40 < marvin24_DT> ok
23:41 < stuw_> hmm, looks like there is no pop during playback.
23:42 < marvin24_DT> yes, because I enabled zerocross detection
23:42 < marvin24_DT> before there was a pop during every playback
23:43 < stuw_> no, without manual control I heared pops
23:44 < marvin24_DT> mmh
23:44 < marvin24_DT> I thought I heard some effect here with zero cross enabled
23:45 < stuw_> first impression is that you didn't change all zcd regs
23:45   marvin24_DT is on 3.1 kernel now, which has no sound yet
23:45 < marvin24_DT> oh, I forgot some?
23:45 < marvin24_DT> there is hp and spk
23:46 < stuw_> at least zcd power
23:46 < marvin24_DT> mmh, that sounds important
23:47   <   [email protected]:470:8656:0:214:1eff:fefd:905 [Ping timeout: 245 seconds]
23:47 < stuw_> wait a second, I'll post my old patch for zcd
23:48 < stuw_> I had no changes with enabled zcd
23:49 < stuw_> http://stuw.narod.ru/ac100/patches/zcd.patch
23:50 < stuw_> it's very old and contains some unrelated changes %)
23:52   >>> [email protected]:470:8656:0:214:1eff:fefd:905
23:53 < marvin24_DT> stuw_: wouldn't it be enough to just enable pow_zcd
23:53   >>> [email protected]
23:54 < stuw_> marvin24_DT: I don't know (
23:54   marvin24_DT tries
23:56   >>> [email protected]
--- Day changed Sat Mar 24 2012
00:02   <   [email protected] [Remote host closed the connection]
00:03   >>> [email protected]
00:04 < marvin24_DT> mmh, no change
14:49 < stuw_> marvin24_DT: hi. I checked few cases. 1) There is little pop if amp is enabled when codec is disabled. 2) There is a loud pop if codec is enabled when amp is powered on. 3) There is no pop if amp is enabled during playback.
14:50 < stuw_> I used file with a "silence" (arecord with disabled mics)
14:52 < stuw_> PaulFertser: hi. ^ it could be interested for you too :)
...
15:54 < marvin24_DT> stuw_: it is possible that we cannot fix it because it may be a hw bug (see case 1)
15:54 < marvin24_DT> maybe we need to solder a resistor to gnd to the amp input
15:55 < stuw_> marvin24_DT: case 3 is a target IMHO
15:56 < marvin24_DT> I think it could be caused by some kind of "static" charge on the amp input lines
15:57 < marvin24_DT> if you playback (case 3) this is discharged by the oscillating input signal
15:58 < marvin24_DT> we could try to mimic this by playing something before the amp is swithed on
15:59 < marvin24_DT> but maybe this gets to complicated and is not worth the effort
16:00 < gordan> For those of you who aren't on the mailing list, RedSleeve public alpha is now available: http://www.redsleeve.org
16:01 < marvin24_DT> stuw_: wm codecs have a "discharge bit" for this as it seems
16:01   >>> [email protected]
16:01 < marvin24_DT> check sound/soc/codecs/wm8990.c for example
...
16:25 < stuw_> marvin24_DT: looks like we have not anything similar to "discharge bit" :(
16:25 < stuw_> *don't have
16:25 < marvin24_DT> yeah, I tired to add some msleeps here and there
16:25 < marvin24_DT> but no change
16:26 < marvin24_DT> maybe we just power up the device in the wrong order and the wrong timing
16:26 < marvin24_DT> asking someone at realtek may be the only way to get this right
16:27 < marvin24_DT> I'm more concerned about the fact that the codec only moves into standby when mic12spk is muted
...
16:35 < PaulFertser> stuw_: but have you tried to "enable internal amp, wait 0.5s, enable external amp" as a power-on and "disable external amp, disable internal amp" as a power-off sequences?
16:35 < marvin24_DT> ninny: cat /proc/cmdline
16:36 < stuw_> PaulFertser: no, I enable/disable external amp manually and I can't handle this case without kernel modification.
16:36 < stuw_> <marvin24_DT> I'm more concerned about the fact that the codec only moves into standby when mic12spk is mutedc <- this is realy strange
16:37   <   [email protected] [Ping timeout: 264 seconds]
16:37 < stuw_> Headset Mic is Off, but MICBIAS1 is On
16:37 < PaulFertser> stuw_: i guess that sequence should eliminate the pop and of course it needs kernel modifications in the end.
16:37 < marvin24_DT> when muted, the amp is switched on/off automaticly
16:37 < marvin24_DT> otherwise it is only switched on during boot
...
20:42 < stuw_> marvin24_DT, PaulFertser,  http://pastebin.com/sqMHiwDA
# starting playback ...
[  132.536870] alc5632_mute: mute: 1
[  132.588433] alc5632_mute: mute: 1
[  132.596162] alc5632_set_bias_level: BIAS_PREPARE
[  132.602183] tegra-alc5632 tegra-alc5632.0: event: 2, EVENT_ON: 2, EVENT_OFF: 0
[  132.611274] nvec nvec.0: gpio 0 set to value 2
[  132.615568] alc5632_set_bias_level: BIAS_ON
[  133.116885] alc5632_mute: mute: 0
# interrupting
[  155.686285] alc5632_mute: mute: 1
[  160.696965] alc5632_set_bias_level: BIAS_PREPARE
[  160.701299] tegra-alc5632 tegra-alc5632.0: event: 4, EVENT_ON: 0, EVENT_OFF: 4
[  160.710285] nvec nvec.0: gpio 0 set to value 0
[  160.715452] alc5632_set_bias_level: BIAS_STANDBY
20:43 < marvin24_DT> stuw_: is this with MIC12SPK muted?
20:44 < PaulFertser> stuw_: but i'm suggesting to first enable everything except for the external amp and only then to enable external amp.
20:44 < stuw_> marvin24_DT: yes
20:45 < marvin24_DT> I think there is no call-back to the board driver after BIAS_ON
20:45 < MaDMaLKaV> just to be sure, if my tablet had partitions encrypted , bctdump would not be able to work against a bct partition dump right?
20:46 < stuw_> there is alc5632_mute call. also I
20:46 < stuw_> I'm trying to move enable_depop to prepare stage
20:48 < marvin24_DT> stuw_: I also tried this, but didn't changed anything
20:48 < marvin24_DT> the mute call-back is in the codec driver - isn't it?
20:49 < stuw_> yes. it is
20:57 < marvin24_DT> mmh, maybe ok to just hack the gpio toggle into the codec driver
20:58 < stuw_> lets try, maybe it will not help us :))
21:06 < stuw_> I've added 0.5 sec sleep to muting_func (0.5 before amp on, and 0.5 after amp off). It's better, but it is still no perfect.
21:13 < marvin24_DT> stuw_: what does bit 15 of reg 5e mean (This bit have to be disable before play back & record)
21:13 < marvin24_DT> I mean beside the broken english
21:17   <   [email protected]:5c0:1000:a::653 [Ping timeout: 245 seconds]
21:25   >>> [email protected]
21:28   <   [email protected] [Ping timeout: 248 seconds]
21:28 < PaulFertser> stuw_: ah, so 0.5s makes a difference, that's probably nice.
21:30 < marvin24_DT> there is a dapm_pop_time in /sys to play with these things
21:31   >>> [email protected]:5c0:1000:a::1a95
21:47 < stuw_> marvin24_DT: I don't know what is Fast Vref
21:47 < stuw_> if we don't touch it, probobly we should
21:47 < marvin24_DT> I'm more confused about if it should be enabled or disabled (bit value versus Fast Vref state)
21:48 < marvin24_DT> well, I try it
21:50 < marvin24_DT> I tried to disable strong amp (bit 12 of 1c), no succ
21:52   <   [email protected] []
21:58 < marvin24_DT> ok, disable fast vref, no change
22:14 < cloudy> during operation I can hear a clicking from the speakers, like the sound card is initializing, but every time it tries to make a sound. It is somewhat irritating. Are you having experiencing something similar?
22:15 < PaulFertser> Ohoho, we all are
22:16 < cloudy> PaulFertser, interesting. Do you know what that is?
22:16 < PaulFertser> cloudy: yes, i do, i've investigated that _a lot_.
22:17 < cloudy> PaulFertser, so what is your take on it?
22:17 < PaulFertser> cloudy: i'm sure that's the "pop" emitted by the mixer IC every time it turns on its internal amp because its low-R output is connected to a high-Z input of an external amp.
22:18 < PaulFertser> cloudy: so it could be eliminated by turning on the external amp _after_ the internal amp of the mixer IC is turned on. But implementing this idea requires some quite some ASoC knowledge or spending considerable time, so i'm afraid nobody's done that yet.
22:18 < PaulFertser> I'm not sure what others think about this though, probably i'm not up-to-date on the issue.
22:19 < cloudy> sounds tricky
22:19 < marvin24_DT> well, codec already can switch on/off external amp
22:20 < marvin24_DT> the question is only timing ...
22:20 < marvin24_DT> (or where to plug the event)
22:21 < PaulFertser> marvin24_DT: have you already found the right hook in ASoC?
22:21 < marvin24_DT> the asoc hook wasn't the problem
22:21 < marvin24_DT> you need just add a function backcall to the board driver
22:21 < marvin24_DT> the nvec gpio controller was more difficult
22:22 < marvin24_DT> eh, ok, no so difficult, but tricky
22:22 < gomiboy> anyone tried the armhf video drivers from nvidia? Are they worth it / stable for everyday use?
22:22 < marvin24_DT> PaulFertser: see my 3.0-exp branch
22:22 < PaulFertser> marvin24_DT: will do, thanks!
22:22 < cloudy> gomiboy, where can I get them from to try?
22:23 < cloudy> marvin24_DT, what is your 3.0-exp branch?
22:23 < marvin24_DT> http://developer.nvidia.com/content/linux-tegra-hardfp-pack-released
22:23 < marvin24_DT> cloudy: some experimental kernel patches from me
22:24 < cloudy> marvin24_DT, addressing the poping sound?
22:24 < marvin24_DT> well, that was the idea ...
22:24 < marvin24_DT> but, well, didn't worked so far
22:24   <   [email protected] [Ping timeout: 246 seconds]
22:24 < marvin24_DT> but we save some power now by disabling the external amp
22:24 < cloudy> currently I am running 3.0.27-1-ac100 #1 - is there something newer?
22:25 < cloudy> marvin24_DT, can you still hear something?
22:25 < marvin24_DT> cloudy: no
22:25 < PaulFertser> marvin24_DT: do you have any explanation about why it didn't work?
22:25 < marvin24_DT> cloudy: yes (for the 2nd question)
22:25 < marvin24_DT> PaulFertser: wrong timing I guess
22:26 < marvin24_DT> the codec switches off the external amp ~2 secs after playback stops
22:26 < marvin24_DT> and on, mmh, maybe a little bit to early
22:26 < PaulFertser> marvin24_DT: switching off is not an issue. But switching on should be done with a delay, yes.
22:27 < marvin24_DT> I have no idea how to do this
22:28 < marvin24_DT> (in a sane way of course)
22:29 < PaulFertser> broonie should know
16:57 < marvin24_DT> stuw: echo 100 > dapm_pop_time
16:58 < marvin24_DT> bye bye popeye
16:59 < marvin24_DT> or better 200 or so
16:59 < stuw> marvin24_DT: woohoo! )
17:00 < marvin24_DT> yeah, but that's only for debugging AFAIK
17:02 < stuw> In any case it is good to know it's possible to avoid pops :)
17:08 < marvin24_DT> seems we need to hook into some stream event
Oct 02 20:00:46 <leonro>	stuw: мне больше не с кем на эту тему говорить :)
Oct 02 20:02:46 <leonro>	stuw: я нашел, какой бит делает шелчок
Oct 02 20:05:14 <stuw>	leonro, ну колись тогда ) я весь внимание
Oct 02 20:05:44 <leonro>	как и ожидалось это усилок спикера
Oct 02 20:06:13 <leonro>	8.16. Reg-26h: Power Down Control/Status
Oct 02 20:06:34 <leonro>	бит - 15
Oct 02 20:07:34 <stuw>	leonro, у меня 4 минуты (мне надо будет домой бежать). я буду дома в районе через 2 часа примерно, можешь писать, я логи почитаю.
Oct 02 20:07:52 <stuw>	leonro, ок. Какие идеи?
Oct 02 20:07:59 <leonro>	прикол в том, что я делал мьют всему тракту, и все равно не помогло
Oct 02 20:08:32 <stuw>	leonro, а без музыки если включить этот бит есть щелчек?
Oct 02 20:08:37 <leonro>	stuw: если будет сегодня время, напиши мне на мейл, я подойду к компу
Oct 02 20:08:49 <leonro>	а пока я здесь напишу
Oct 02 20:08:50 <stuw>	leonro, марвин куда-то вставлял слип, чтобы от щелчка избавиться
Oct 02 20:08:59 <stuw>	leonro, ок
Oct 02 20:09:06 <leonro>	нихрена
Oct 02 20:09:26 <stuw>	т.е. щелчка нет, когда не включено проигрывание?
Oct 02 20:09:28 <leonro>	этот слип не для того
Oct 02 20:09:55 <stuw>	leonro, слип против щелчка не был закомичен
Oct 02 20:10:05 <leonro>	шелчок есть когда кодек заходит в слип мод
Oct 02 20:10:14 <leonro>	точнее выходит из него
Oct 02 20:10:27 <leonro>	это управление питанием делает
Oct 02 20:11:08 <leonro>	на каждый выход внутренние усилки сыключаются
Oct 02 20:11:51 <leonro>	а при пробуждении (не путать со стендбаем, это другое) включается
Oct 02 20:12:26 <stuw>	leonro, можно попробовать заранее включить усилок, а потом проигрывание
Oct 02 20:12:42 *	stuw убежал
Oct 02 20:13:11 <leonro>	короче первая проблемма - это что мьют всего тракта (DAC, PGA, VOL) не помогает
Oct 02 20:13:50 <leonro>	а насчет порядка включения, он тоже важен:
Oct 02 20:14:12 <leonro>	1. DAC
Oct 02 20:14:17 <leonro>	2. Mixers
Oct 02 20:14:25 <leonro>	3. Output PGA
Oct 02 20:14:39 <leonro>	4. Unmute
Oct 02 20:15:03 <leonro>	я так делал, это не помогло :(
Oct 02 20:15:55 <leonro>	Вторая проблемма, это то что я читал ко который тошиба выдала, и там они пользуются кодеком от волфсон
Oct 02 20:16:02 <leonro>	не знаю почему
Oct 02 20:16:27 <savalik>	leonro: а усилки идут прямо перед динамиками?
Oct 02 20:17:18 <leonro>	да, поетому и жажен порядок
Oct 02 20:17:24 <leonro>	важен
Oct 02 20:17:39 <leonro>	чтобы не было глитча
Oct 02 20:19:08 <leonro>	как вариант можно всегда оставлять питание на кодек
Oct 02 20:19:31 <leonro>	и тогда останется шелчок только при включени
Oct 02 20:19:54 <leonro>	при проигрывании не будет шелчка
Oct 02 20:20:00 <leonro>	ну это в теории
Oct 02 20:20:03 <savalik>	эм..а щелчек разве не от самих усилков идет?
Oct 02 20:20:17 <leonro>	от его включения
Oct 02 20:20:30 <leonro>	если он будет всегда включен, тогда не будет
Oct 02 20:21:11 <savalik>	это по питанию мелочь ведь наверняка? )
Oct 02 20:21:49 <leonro>	ну э
Oct 02 20:21:53 <leonro>	это костыль
Oct 02 20:22:11 <leonro>	сделяем если не решим по другому
Oct 02 20:22:21 <savalik>	а еще есть теории как сделать по другому? )
Oct 02 20:22:23 <leonro>	но должен быть нормальный путь
Oct 02 20:23:29 <leonro>	я уже пробовал вариантов 4, поэтому и хотел посовещатся
Oct 02 20:24:24 <leonro>	сорри, я на клавиатуре букву щи не могу найти
Oct 02 20:24:52 <leonro>	поэтому все только шекотка, шелчок и шетка :)
21:21 < leonro> marvin24: stuw : I tried to implment arune's register dump, no luck I still have a pop
21:24 < woglinde> hm
21:26 <*> Joins[#ac100] ->popey [[email protected]/member/popey]
21:26 < stuw_> lenios, where is this dump ?
21:26 < leonro> http://arune.se/temp/ac100/
21:28 < leonro> stuw_: http://paste.ubuntu.com/1269755/
21:31 <*> Joins[#ac100] ->woglinde_ [[email protected]]
21:32 < stuw_> leonro, I'm not absolutely sure, but BIAS_STANDBY is used before power codec off.
21:32 < woglinde_> i think the pop was on android too
21:32 < stuw_> digital mute, prepare, spk amp on, bias on, digital umute - power on
21:32 < woglinde_> what is digital mute?
21:33 < stuw_> digital mute, prepare, spk amp off, standby
21:33 < leonro> stuw_: BIAS_STANDBY is called in probe
21:33 <*> Quits ->woglinde [[email protected]] [Ping timeout: 248 seconds]
21:34 < stuw_> digital mute = alc5632_mute call (https://gitorious.org/~marvin24/ac100/marvin24s-kernel/blobs/320f9c956ff7d759fc7a0917f987ff8d09d84fa2/sound/soc/codecs/alc5632.c#line902)
21:34 < leonro> woglinde_: are you sure ? we don't have android here to test it
21:35 < stuw_> leonro, maybe, but it gets only start pop. IMHO playback pop is more important
21:36 < leonro> stuw_: I added printk to digital mute, we are not calling it at all
21:37 <*> Joins[#ac100] ->mase_76 [[email protected]]
21:37 < stuw_> hmmm, when I checked it (long ago) alc5632_mute was used
21:37 <*> Quits ->mase76 [[email protected]] [Ping timeout: 256 seconds]
21:37 < leonro> stuw_: i'm checking it again
21:40 <*> Joins[#ac100] ->tilmann [[email protected]]
21:43 < leonro> stuw_: and here comes result:
21:43 < leonro> 1.BIAS_STANDBY
21:43 < leonro> 2.BIAS_PREPARE
21:43 < leonro> 3.BIAS_ON
21:43 < leonro> 4. digital mute - mute ==1
21:44 < leonro> many times. digital mute - mute ==1
21:44 < leonro> a couple of times. digital mute - mute ==~
21:44 < leonro> 0
21:45 < leonro> and digital mute called after we heard pop
21:49 < stuw_> mute == 1 - is mute, mute == 0 - is unmute. In current implementation it's used for hp only
21:50 < leonro>  888 static int alc5632_mute(struct snd_soc_dai *dai, int mute)
21:50 < leonro>  889 {
21:50 < leonro>  890         struct snd_soc_codec *codec = dai->codec;
21:50 < leonro>  891         u16 hp_mute = ALC5632_MISC_HP_DEPOP_MUTE_L
21:50 < leonro>  892                                                 |ALC5632_MISC_HP_DEPOP_MUTE_R;
21:50 < leonro>  893         u16 mute_reg = snd_soc_read(codec, ALC5632_MISC_CTRL) & ~hp_mute;
21:50 < leonro>  894
21:50 < leonro>  895         printk(KERN_ERR "alc: digital mute %d\n", mute);
21:51 < leonro> i added printk to every digital_mute call
21:51 < stuw_> i believe you )
21:51 < leonro> we are calling to digitalmute after we finished power management stuff
21:52 < leonro> also it can be asily asoc bug
21:52 < leonro> we have very old asoc implmentation
21:52 < stuw_> I always thought it should be (mute, power on, unmute)
21:53 < stuw_> leonro, did you try to use vref register bits to avoid pops ?
21:54 < leonro> yes, in my previous life, before weekends
22:01 <*> Joins[#ac100] ->gomiboy [[email protected]]
22:10 < leonro> stuw_: I tried again to enable vref before spk amp, no luck
22:23 <*> Quits ->Snark [[email protected]:e35:2ec9:4b20:21f:d0ff:fede:376b] [Quit: Quitte]
22:25 < stuw_> leonro, btw, looks like there is 3 (or even 4) bits for vref. 5e:15, 3c:13, 26:11 and maybe 26:10
22:26 < marvin24> stuw_: urg, did I broke sound with the speaker gpio?
22:26 < marvin24> leonro: using dapm_pop_time eliminates pop after playback
22:26 < marvin24> but not before
22:27 < leonro> ahh, I concentrated on pop before playback
22:27 < leonro> and I don't have pop after playback ata ll
22:27 < leonro> at all
22:28 < ogra_> it surely gets noticeable if you have gnash and no adblock installed :)
22:28 < leonro> marvin24: i don't think, you broke nothin
22:28 < marvin24> it's a bit quieter
22:29 < leonro> ogra_: I'm testing it on ubuntu boot sound.
22:29 < marvin24> [18:47:00] <mase76> tegra-alc5632 tegra-alc5632.0: cannot get spk_en gpio
22:29 < marvin24> [18:47:11] <mase76> tegra-alc5632 tegra-alc5632.0: asoc: failed to init ALC5632: -22
22:29 < stuw_> marvin24, don't know. sound returned back when mase_76 enabled nvec_paz00 (it was disabled for him)
22:29 < marvin24> ah, ok, I changed the config option
22:30 < marvin24> so if you miss it, you won't get sound
22:30 < leonro> what is the branch, do I need to base my trials ?
22:30 < marvin24> either for-next or l4t-r16-ac100
22:30 < leonro> or in normal english
22:30 < leonro> which branch do I need to use ?
22:31 < marvin24> leonro: ^^^^
22:31 < marvin24> use my git tree with the branches above
22:31 < marvin24> I think l4t-r16-ac100 is best for now
22:31 < marvin24> because for-next maybe a bit difficult to get running
22:31 < leonro> is chromeos-ac100-3.0 branch still relevant ?
22:32 < ogra_> 3.0 ?
22:32 < ogra_> surely not
22:32 < marvin24> leonro: that's from the midage
22:32 < ogra_> we're so 3.1 now
22:32 < leonro> great, thanl you stuw_ :))
22:32 < leonro> It was a stuw_ suggestion
22:33 < stuw_> pops are independent to kernel :)
22:33 < leonro> yes, but we want to eliminate asoc problems
22:36 < leonro> does l4t-r16-ac100 work with dissplay ? I don't have serial console
22:37 < stuw_> sure it does
22:37 < stuw_> even for-next works
22:40 < leonro> Great job, my congratuloations to all of you :)
22:41 < stuw_> btw, leonro, I updated my tool for codec manipulation (stuw.narod.ru/ac100/tools) It is possible to set/clear signle register with it.

Research

pop_time

16:57 < marvin24_DT> stuw: echo 100 > dapm_pop_time
16:58 < marvin24_DT> bye bye popeye

There is two interesting functions: pop_wait and pop_dbg. So we can try to set codec->card->pop_time in alc5632_probe.

alc5623

alc5623 datasheet contains note: "Note: Refer to the ALC5623 application note for detailed de-pop sequence information." alc5623 power on depop sequence

0x3a 8 (Power on Softgen) - on
0x3e 15 (Main Bias Analog Circuit), 1 (MIC1 AD Boost + AD Differential Mixer) - on
0x5e 9 (Enable Depop Mode 2 of HP_Out) - on
sleep 500 ms
0x3c 13 (VREF of All Analog Circuits), 10 (Power DAC Reference Circuit (Vref+/Vref-)) - on
0x3a 10 (MICBIAS1 Short Current Detector Control), 8 (Power on Softgen),
     6 (Power on Headphone Depop Buffer), 5 (Headphone Output Amplifier Buffer),
     4 (Headphone Enhance Output Buffer) - on
0x5e 9 (Enable Depop Mode 2 of HP_Out) - off

alc5632 datasheet de-pop

Reg-5Eh

en_dp1_hp   9 R/W 0’h Enable depop mode1 of Headphone 0: Disable 1: Enable
en_dp2_hp   8 R/W 0’h Enable depop mode2 of Headphone 0: Disable 1: Enable
en_smt_hp_l 7 R/W 0’h Enable Headphone L mute-unmute de-pop 0: Disable 1: Enable
en_smt_hp_r 6 R/W 0’h Enable Headphone R mute-unmute de-pop 0: Disable 1: Enable
smt_trig    5 R/W 0’h Enable mute-unmute de-pop 0: Disable 1: Enable


android 2.2 dump analysis

https://dl.dropboxusercontent.com/u/40761340/www/ac100/sound/bootlog-android2.2-i2c-audio.txt

# 00 Reset
# 3c Power on speaker amp in 3c
# 26 Power on all in 26 (ro to 0)
# 3c Power on VREF (VREF is on in 5e by default)
# 34 Configure i2s as slave
# 14 Unmute MIC1
# 0c Set DAC volume
# 22 Set mic boost
# 10 Mute routes from mics to hp, spk, mono
# 62 Set DAC clocks
# 3a Power on main i2s
# 3a Power on mic1 bias detection
# 26 Power on all in 26 (ro to 1)
# 1c Set lsab_amp_sel = 1 Weak Amp
# 3a Power on main bias in 3a
# 12 Set record volume
# 24 Set digital boost
# 1c Set mixer: spk (HP Mixer), amp type (Weak Amp), spk out (RP ?)  
# 02 Set speaker volume
# 04 Set headphones volume
# 3c Power on: pow_adc_l, pow_adc_r, pow_adc_rec_l, pow_adc_rec_r
# 14 Mute MIC1
# 3c Power off: pow_adc_l, pow_adc_r, pow_adc_rec_l, pow_adc_rec_r
# 5e Enable depop for speakers and headphones
# 04 Keep hp muted
# 5e Disable depop for speakers and headphones
# 5e Disable depop
# 02 Keep speakers muted
# 3c Power on pow_hp_l_mix, pow_hp_r_mix
# 3a Power on pow_dacl2mixer, pow_dacr2mixer, pow_dac_ref
# 3c Power on pow_dac_l, pow_dac_r
# 3c Power on pow_spk_mix
# 3e Power on pow_spk_l_vol, pow_spk_r_vol
# 02 Speaker volume unmute
### 200 MS ###
# 5e Enable depop for speakers and headphones
# 04 keep hp muted
# 3a Power off pow_dacl2mixer, pow_dacr2mixer, pow_dac_ref
# 3c Power off pow_dac_l, pow_dac_r
# 3c Power off pow_hp_l_mix, pow_hp_r_mix
# 5e Disable  depop for speakers and headphones
# 5e Disable depop
# 02 Mute speakers volume
# 3e Power off pow_spk_l_vol, pow_spk_r_vol
# 3c Power off pow_spk_mix, pow_mono_mix
# 3a Power off pow_spk_amp
# 24 Disable dmic_en, dmic_pre_filter_en,   Mute dmic_adcl_mute_ctrl, dmic_adcr_mute_ctrl
# 3a Power off pow_main_bias
# 5e Enable depop
# 5e Disable depop
# 5e Disable depop

functions trace

by leonro (printk.patch)

[    4.050974] alc: nvec_event_init
[    4.054148] alc: nvec_event_probe
[    4.204550] alc: nvec_event_notifier, event_type=5
[    4.208376] alc: nvec_event_notifier, event_type=5
[    4.212196] alc: nvec_event_notifier, event_type=5
[    4.220769] alc: nvec_event_notifier, event_type=5
[    4.224585] alc: nvec_event_notifier, event_type=1
[    4.228396] alc: nvec_event_notifier, event_type=1
[   11.935367] alc: alc5632_i2c_probe
[   12.003394] alc: tegra_alc5632_modinit
[   12.092606] alc: tegra_alc5632_probe
[   12.106127] alc: alc5632_probe
[   12.120161] alc: alc5632_set_bias_level SND_SOC_BIAS_STANDBY
[   12.164142] alc: tegra_alc5632_asoc_init
[   12.198357] alc: alc5632_set_bias_level SND_SOC_BIAS_PREPARE
[   12.216057] alc: alc5632_set_bias_level SND_SOC_BIAS_ON
[   12.743720] asoc: alc5632-hifi <-> tegra20-i2s.0 mapping ok
[   12.753916] input: tegra-alc5632 Headset Jack as /devices/platform/tegra-alc5632.0/sound/card0/input7
[   12.856581] alc: tegra_alc5632_event_int_spk, event=2
[   12.872099] alc: gpio 0 set to value 2
[   12.892352] alc: nvec_event_notifier, event_type=13
[   23.833399] alc: tegra_alc5632_asoc_hw_params
[   23.840741] alc: alc5632_set_dai_fmt
[   23.848536] alc: alc5632_set_dai_sysclk freq=22579200
[   23.856367] alc: alc5632_pcm_hw_params
[   23.866481] alc: alc5632_mute, mute=0
[   23.873745] alc: alc5632_mute, mute=0
[   23.907263] alc: tegra_alc5632_asoc_hw_params
[   23.914224] alc: alc5632_set_dai_fmt
[   23.922043] alc: alc5632_set_dai_sysclk freq=22579200
[   23.929834] alc: alc5632_pcm_hw_params
[   23.937260] alc: alc5632_mute, mute=0
[   23.944239] alc: alc5632_mute, mute=0
[   23.983085] alc: tegra_alc5632_hw_free
[   23.989589] alc: tegra_alc5632_hw_free
[   24.002642] alc: tegra_alc5632_asoc_hw_params
[   24.009558] alc: alc5632_set_dai_fmt
[   24.017420] alc: alc5632_set_dai_sysclk freq=22579200
[   24.025260] alc: alc5632_pcm_hw_params
[   24.032849] alc: alc5632_mute, mute=0
[   24.039775] alc: alc5632_mute, mute=0
[   24.066454] alc: tegra_alc5632_hw_free
[   24.073010] alc: tegra_alc5632_hw_free
[   24.080091] alc: tegra_alc5632_hw_free
[   24.086653] alc: tegra_alc5632_hw_free
[   24.093283] alc: alc5632_mute, mute=1
[   24.101545] alc: tegra_alc5632_asoc_hw_params
[   24.108465] alc: alc5632_set_dai_fmt
[   24.116339] alc: alc5632_set_dai_sysclk freq=22579200
[   24.124176] alc: alc5632_pcm_hw_params
[   24.161134] alc: alc5632_mute, mute=0
[   24.168091] alc: alc5632_mute, mute=0
[   24.196228] alc: tegra_alc5632_asoc_hw_params
[   24.203213] alc: alc5632_set_dai_fmt
[   24.211025] alc: alc5632_set_dai_sysclk freq=22579200
[   24.218855] alc: alc5632_pcm_hw_params
[   24.228190] alc: alc5632_mute, mute=0
[   24.235196] alc: alc5632_mute, mute=0
[   24.241819] alc: tegra_alc5632_hw_free
[   24.248433] alc: tegra_alc5632_hw_free
[   24.257180] alc: tegra_alc5632_asoc_hw_params
[   24.264148] alc: alc5632_set_dai_fmt
[   24.271971] alc: alc5632_set_dai_sysclk freq=22579200
[   24.279760] alc: alc5632_pcm_hw_params
[   24.301217] alc: alc5632_mute, mute=0
[   24.308166] alc: alc5632_mute, mute=0
[   24.314828] alc: tegra_alc5632_hw_free
[   24.321378] alc: tegra_alc5632_hw_free
[   24.328436] alc: tegra_alc5632_hw_free
[   24.335008] alc: tegra_alc5632_hw_free
[   24.350396] alc: alc5632_mute, mute=1
[   24.364774] alc: tegra_alc5632_asoc_hw_params
[   24.371750] alc: alc5632_set_dai_fmt
[   24.379555] alc: alc5632_set_dai_sysclk freq=22579200
[   24.387370] alc: alc5632_pcm_hw_params
[   24.400603] alc: alc5632_mute, mute=0
[   24.407515] alc: alc5632_mute, mute=0
[   24.414122] alc: tegra_alc5632_hw_free
[   24.420667] alc: tegra_alc5632_hw_free
[   24.436745] alc: tegra_alc5632_asoc_hw_params
[   24.443714] alc: alc5632_set_dai_fmt
[   24.451509] alc: alc5632_set_dai_sysclk freq=22579200
[   24.459335] alc: alc5632_pcm_hw_params
[   24.478146] alc: alc5632_mute, mute=0
[   24.490818] alc: alc5632_mute, mute=0
[   24.497437] alc: tegra_alc5632_hw_free
[   24.504000] alc: tegra_alc5632_hw_free
[   24.525180] alc: tegra_alc5632_asoc_hw_params
[   24.532151] alc: alc5632_set_dai_fmt
[   24.539956] alc: alc5632_set_dai_sysclk freq=22579200
[   24.547788] alc: alc5632_pcm_hw_params
[   24.561297] alc: alc5632_mute, mute=0
[   24.568224] alc: alc5632_mute, mute=0
[   25.202142] alc: tegra_alc5632_asoc_hw_params
[   25.209066] alc: alc5632_set_dai_fmt
[   25.216910] alc: alc5632_set_dai_sysclk freq=22579200
[   25.224744] alc: alc5632_pcm_hw_params
[   25.232264] alc: alc5632_mute, mute=0
[   25.239201] alc: alc5632_mute, mute=0
[   30.466917] alc: tegra_alc5632_hw_free
[   30.473493] alc: tegra_alc5632_hw_free
[   38.910826] alc: tegra_alc5632_hw_free
[   38.917366] alc: tegra_alc5632_hw_free
[   38.924013] alc: alc5632_mute, mute=1