R32.3.1 tx2-4g: Please provide all registers and their values to make the audio work

going back into the source and removing all audio-routing except the one I am using.

Terry

That is strange. It must have been defined somewhere in the codec driver source you have. Can you use following in your codec driver and see the compiler warning goes away?
#undef PLL_16BICK_MODE
#undef PLL_32BICK_MODE
#undef PLL_64BICK_MODE
#undef PLL_MCLK_MODE
[/quote]

Any clue on this?

bad logic, I changed the & to | and it looks like it is working.

Terry

No. Don’t change to |. It would mean, if any of the config is not defined, then if condition passes and calls the ak4637_set_mcki(). But that is not what we want. All of those symbols must be undefined and then compiler should not throw any unused warning.

the mclk define is defined and set_mcki is being called with my changes.

Terry

I believe I have the driver working correctly in the set_mclki area.

What next. If you need scope outputs that will take me a while, I work from home and will have to set up something at work with wire and stuff, and I VPN and run the tests on a machine at work.

Terry

Please list the changes you made in codec driver.

BTW I was checking the controls and I find ‘ak4637ctl.txt’ file in the ZIP source you attached for codec earlier. It has mixer control settings that are needed for speaker path.

amixer --card 1 cset name="x PFDAC MUX" "SDTI"
amixer --card 1 cset name="x SPKLO MUX" "Speaker"
amixer --card 1 cset name="x SPKLO Mixer DACS" "1"

Please do above settings and then try running aplay with test.wav

I did a amixer -c 1 and looked at each one of those and they are set correctly.

ran aplay -Dplughw:1,0 ./test.wav no sound

Next?

is the aplay command correct? I get aplay -l

card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 0: ADMAIF1 CIF ADMAIF1-0
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 1: ADMAIF2 CIF ADMAIF2-1
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 2: ADMAIF3 CIF ADMAIF3-2
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 3: ADMAIF4 CIF ADMAIF4-3

amixer -c 1 output is in file.out
file.out (240.3 KB)

git diff sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.c
diff --git a/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.c b/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.c
index 4e7756ea9…0e30df379 100644
— a/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.c
+++ b/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.c
@@ -1429,7 +1429,7 @@ static int ak4637_hw_params(struct snd_pcm_substream *substream,

    ak4637->fs2 = params_rate(params);

-#if (!defined(PLL_16BICK_MODE) & !defined(PLL_32BICK_MODE) & !defined(PLL_64BICK_MODE) & !defined(PLL_MCLK_MODE))
+#if (!defined(PLL_16BICK_MODE) | !defined(PLL_32BICK_MODE) | !defined(PLL_64BICK_MODE) | !defined(PLL_MCLK_MODE))^M
ak4637_set_mcki(codec, ak4637->fs2, ak4637->rclk);
#endif

@@ -1467,7 +1467,7 @@ static int ak4637_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,

    ak4637->rclk = freq;

-#if (!defined(PLL_16BICK_MODE) & !defined(PLL_32BICK_MODE) & !defined(PLL_64BICK_MODE) & !defined(PLL_MCLK_MODE))
+#if (!defined(PLL_16BICK_MODE) | !defined(PLL_32BICK_MODE) | !defined(PLL_64BICK_MODE) | !defined(PLL_MCLK_MODE))^M
ak4637_set_mcki(codec, ak4637->fs2, ak4637->rclk);
#endif

git diff sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.h
diff --git a/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.h b/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.h
index db88278cf…7e3147bfa 100644
— a/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.h
+++ b/sources/kernel/kernel-4.9/sound/soc/codecs/ak4637.h
@@ -20,9 +20,9 @@

#define AK4637_PCM_BCKP // BICK Pos edge setting for PCM format

-//#define PLL_16BICK_MODE
-//#define PLL_32BICK_MODE
-//#define PLL_64BICK_MODE
+#undef PLL_16BICK_MODE^M
+#undef PLL_32BICK_MODE^M
+#undef PLL_64BICK_MODE^M
#define PLL_MCLK_MODE

#define AK4637_00_POWER_MANAGEMENT1 0x00

Terry

Scopes would be good to confirm that clocks are actually coming and have the right frequencies. Please do attach the snapshots.

If you are using below command, then it is fine.
aplay -Dhw:1,0 ./test.wav

Once you run above, the console will wait for 30 seconds for aplay to finish. I hope you are seeing this behavior.

aplay takes 30 seconds on either HDMI or ak4637

anything else we can do without the scope output?

Terry

The codec driver changes you made does not appear right to me. You can’t just make that warning to go away. We are trying to check codec in slave mode and clock is supplied by Tegra. So that mode should be used by codec. See below code snippet in driver. Attempt is to see if “pll = AK4637_EXT_SLAVE” configuration works.

#ifdef PLL_16BICK_MODE
	pll = AK4637_PLL_BICK16;
#else
#ifdef PLL_32BICK_MODE
	pll = AK4637_PLL_BICK32;
#else
#ifdef PLL_64BICK_MODE
	pll = AK4637_PLL_BICK64;
#else
#ifdef PLL_MCLK_MODE
	pll = AK4637_PLL_MCLK_FREQ;	//user select
#else
	pll = AK4637_EXT_SLAVE;
#endif
#endif
#endif
#endif

Don’t use | instead of &. I mentioned this previously.

#undef PLL_MCLK_MODE → use this and see if compiler warning goes away.

You are correct, undef PLL_MCLK_MODE will also have a problem, so you want pll = AK4637_EXT_SLAVE; and the set_mcki called. I will change the code to do that.

Terry

Yes, I also find the same understanding in the document present in your ZIP source. Idea is to try see if “External Slave Mode” works.

~ Clock Mode ~
[External Slave Mode]
//#define PLL_16BICK_MODE
//#define PLL_32BICK_MODE
//#define PLL_64BICK_MODE
//#define PLL_MCLK_MODE

external slave mode set, and no sound

Terry

I am not sure what else could be wrong then. Time to get oscilloscope snapshots (you can capture separate snapshots with and without your audio card connected) and you need to capture after starting aplay.

Meanwhile you get that setup ready. Can you confirm/check on following?

  • Do you see following print now, when you start aplay?
    ak4637_set_mcki fs=**48000** rclk=12288000

  • Enable all debug prints inside codec driver and give me kernel log. You need to uncomment below line in codec driver source file.
    //#define AK4637_DEBUG //used at debug mode

  • Can you try increasing the playback volume?

    numid=865,iface=MIXER,name='x Speaker Output Volume'
    ; type=INTEGER,access=rw---R--,values=1,min=0,max=3,step=0
    : values=0
    | dBminmax-min=6.40dB,max=14.90dB
    

You can use following control: amixer --card 1 cset name="x Speaker Output Volume" "3"

Also make sure speakers are actually connected to your board.

Attach your codec driver, Tegra machine driver, DT and if any other changes you made. I can cross check and see if it is setup as we have discussed earlier.

Hi Terry,

Any updates?
If you are still facing the issue, please update as suggested in previous comment.

Thanks.

My hardware guy says the mclk and sclk look good, what is the fclk suppose to do?

I have been gathering info, could you look at this and give an input?

is there device tree or amixer things for fclk?

keepThisFile (29.7 KB)

Thanks,
Terry

@spujar can you help with this? I added ak4637,pdn-gpio and tried to read the gpio for init, I got this

Read PDN pin from device tree ffffffc0ec605418
[ 2.123747] ------------[ cut here ]------------
[ 2.123766] WARNING: CPU: 2 PID: 1 at drivers/gpio/gpiolib-of.c:462 of_gpio_simple_xlate+0x6c/0x90
[ 2.123770] Modules linked in:

[ 2.123789] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.9.140-tegra #221
[ 2.123794] Hardware name: lightning (DT)
[ 2.123800] task: ffffffc0f1310000 task.stack: ffffffc0f1318000
[ 2.123808] PC is at of_gpio_simple_xlate+0x6c/0x90
[ 2.123818] LR is at of_gpiochip_match_node_and_xlate+0x58/0x70
[ 2.123826] pc : [] lr : [] pstate: 204000c5
[ 2.123830] sp : ffffffc0f131b900
[ 2.123835] x29: ffffffc0f131b900 x28: 0000000000000000
[ 2.123848] x27: 0000000000000000 x26: ffffffc0ec75a000
[ 2.123860] x25: ffffffc0ed9d1600 x24: 0000000000000040
[ 2.123871] x23: ffffff800a16e000 x22: ffffff80084c9bc8
[ 2.123881] x21: 0000000000000000 x20: ffffffc0efa3e098
[ 2.123892] x19: ffffffc0f131b9d0 x18: 0000000000000030
[ 2.123903] x17: 0000000000000006 x16: 0000000000000000
[ 2.123913] x15: ffffffffffffffff x14: ffffff800a127260
[ 2.123924] x13: 0000000000000000 x12: 0000000000000004
[ 2.123934] x11: 0000000000000018 x10: 0101010101010101
[ 2.123945] x9 : 0000000000000003 x8 : 7f7f7f7f7f7f7f7f
[ 2.123969] x7 : 2c626274ff726b6b x6 : 000000807663632d
[ 2.123983] x5 : 2d63637600000000 x4 : ffffffc0f131b9e0
[ 2.123994] x3 : ffffff80084c9c38 x2 : 0000000000000000
[ 2.124004] x1 : 0000000000000001 x0 : 0000000000000002

[ 2.124022] —[ end trace 57e7c413966639cd ]—

Call trace:
[ 2.124036] [] of_gpio_simple_xlate+0x6c/0x90
[ 2.124044] [] of_gpiochip_match_node_and_xlate+0x58/0x70
[ 2.124051] [] gpiochip_find+0x74/0xa8
[ 2.124060] [] of_get_named_gpiod_flags+0xc0/0x138
[ 2.124068] [] of_get_named_gpio_flags+0x3c/0x58
[ 2.124082] [] ak4637_probe+0x234/0x290
[ 2.124091] [] snd_soc_codec_drv_probe+0x28/0x38
[ 2.124100] [] soc_probe_component+0x250/0x370
[ 2.124107] [] snd_soc_instantiate_card+0x374/0xbb8
[ 2.124115] [] snd_soc_register_card+0x164/0x210
[ 2.124126] [] tegra_machine_driver_probe+0x320/0x440
[ 2.124137] [] platform_drv_probe+0x60/0xc0
[ 2.124144] [] driver_probe_device+0xd8/0x408
[ 2.124152] [] __driver_attach+0xdc/0x128
[ 2.124164] [] bus_for_each_dev+0x5c/0xa8
[ 2.124171] [] driver_attach+0x30/0x40
[ 2.124178] [] bus_add_driver+0x20c/0x2a8
[ 2.124184] [] driver_register+0x6c/0x110
[ 2.124192] [] __platform_driver_register+0x5c/0x68
[ 2.124201] [] tegra_asoc_machine_driver_init+0x18/0x20
[ 2.124207] mmc2: hw tuning done …
[ 2.124218] [] do_one_initcall+0x44/0x130
[ 2.124228] [] kernel_init_freeable+0x1a0/0x244
[ 2.124238] [] kernel_init+0x18/0x108
[ 2.124245] [] ret_from_fork+0x10/0x40

Any pointers to how to fix this?

Thanks,
Terry