Hi,
I am trying to drive pcm3060 to work on our circuit diagram based on NX core board, but I have some troubles with the device tree and the machine driver.
The phenomenon I encountered is:
On the Ubuntu Setting tool interface, I can hear the sound output when I click the left and right channels of stereo sound test and click the mono sound test. As follows:
But when I play the audio file through the command line, the pineline is established, but no sound is heard.
The shell command is:
GST_DEBUG=3 gst-launch-1.0 filesrc location=~/test.wav ! wavparse ! alsasink device=hw:2,0
The message printed by the terminal as follows:
Setting pipeline to PAUSED ...
0:00:02.150928031 9818 0x5583abe070 WARN basesrc gstbasesrc.c:3583:gst_base_src_start_complete:<filesrc0> pad not activated yet
Pipeline is PREROLLING ...
0:00:02.151942471 9818 0x5583ab9ad0 FIXME default gstutils.c:3981:gst_pad_create_stream_id_internal:<wavparse0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:02.369465112 9818 0x5583ab9ad0 WARN alsa conf.c:4886:parse_args: alsalib error: Parameter DEV must be an integer
0:00:02.369530393 9818 0x5583ab9ad0 WARN alsa conf.c:4991:snd_config_expand: alsalib error: Parse arguments error: Invalid argument
0:00:02.369559513 9818 0x5583ab9ad0 WARN alsa pcm.c:2495:snd_pcm_open_noupdate: alsalib error: Unknown PCM hw:2,0:{AES0 0x02 AES1 0x82 AES2 0x00 AES3 0x02}
0:00:02.373202615 9818 0x5583ab9ad0 WARN alsa pcm_hw.c:1250:snd_pcm_hw_get_chmap: alsalib error: Cannot read Channel Map ctl
: No such file or directory
0:00:02.375902062 9818 0x7f7c02fed0 WARN audiosink gstaudiosink.c:218:audioringbuffer_thread_func:<alsasink0> failed to set thread priority
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstAudioSinkClock
Got EOS from element "pipeline0".
Execution ended after 0:00:10.126101083
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
Another shell command is:
aplay -D plughw:2,0 test.wav
The message printed by the terminal as follows:
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
No sound output can be heard when running the above two commands.
I have added the Codec node at i2c@31e0000 and modified the codec dai link and audio-routing at sound node as follows:
hdr40_i2c1 = "/i2c@31e0000";
hdr40_i2c1: pcm3060: pcm3060@47 {
compatible = "ti,pcm3060";
reg = <0x47>;
ti,out-single-ended = "true";
};
sound {
nvidia,audio-routing =
"x Headphone", "x OUTL",
"x Headphone", "x OUTR",
"x INL", "x Mic",
"x INR", "x Mic",
"y Headphone", "y OUT",
"y IN", "y Mic",
"z Headphone", "z OUT",
"z IN", "z Mic",
"m Headphone", "m OUT",
"m IN", "m Mic",
"n Headphone", "n OUT",
"n IN", "n Mic",
"o Headphone", "o OUT",
"o IN", "o Mic",
"a IN", "a Mic",
"b IN", "b Mic",
"c IN", "c Mic",
"d IN", "d Mic",
"d1 Headphone", "d1 OUT",
"d2 Headphone", "d2 OUT";
nvidia,dai-link-5 {
link-name = "pcm3060-codec";
cpu-dai = <&tegra_i2s5>;
codec-dai = <&pcm3060>;
cpu-dai-name = "I2S5";
codec-dai-name = "pcm3060-dac", "pcm3060-adc";
format = "i2s";
bit-format = "s16_le";
srate = <0xbb80>;
num-channel = <0x2>;
ignore_suspend;
name-prefix = "x";
status = "okay";
};
};
And the machine driver was updated as follows:
rtd = snd_soc_get_pcm_runtime(card, "pcm3060-codec");
if (rtd) {
dai_params =
(struct snd_soc_pcm_stream *)rtd->dai_link->params;
dai_params->rate_min = srate;
dai_params->channels_min = channels;
dai_params->formats = formats;
err = snd_soc_dai_set_sysclk(rtd->codec_dai, 0, aud_mclk, SND_SOC_CLOCK_IN);
if (err) {
dev_err(card->dev, "failed to set pcm3060 sysclk!\n");
return err;
}
}
static int tegra_machine_pcm3060_init(struct snd_soc_pcm_runtime *rtd)
{
return 0;
}
static int codec_init(struct tegra_machine *machine)
{
struct snd_soc_dai_link *dai_links = machine->asoc->dai_links;
unsigned int num_links = machine->asoc->num_links, i;
if (!dai_links || !num_links)
return -EINVAL;
for (i = 0; i < num_links; i++) {
if (!dai_links[i].name)
continue;
if (strstr(dai_links[i].name, "rt565x-playback") ||
strstr(dai_links[i].name, "rt565x-codec-sysclk-bclk1"))
dai_links[i].init = tegra_machine_rt565x_init;
else if (strstr(dai_links[i].name, "fe-pi-audio-z-v2"))
dai_links[i].init = tegra_machine_fepi_init;
else if (strstr(dai_links[i].name, "respeaker-4-mic-array"))
dai_links[i].init = tegra_machine_respeaker_init;
else if (strstr(dai_links[i].name, "pcm3060-codec")){
dai_links[i].init = tegra_machine_pcm3060_init;
}
}
return 0;
}
The codec driver pcm3060_drv.c and kern.log as follows:
pcm3060_drv and kern_log.rar (80.6 KB)
Before I run the pipeline, the following configuration has been modified:
amixer -c jetsonxaviernxa cset name="I2S5 codec master mode" "cbm-cfm"
amixer -c jetsonxaviernxa cset name="I2S5 Mux" ADMAIF1
amixer -c jetsonxaviernxa cset name="ADMAIF1 Mux" I2S5
amixer -c jetsonxaviernxa cset name="x Master Capture Switch" on
amixer -c jetsonxaviernxa cset name="x Master Playback Switch" on
The driver pcm3060_drv.c is based on kernel 5.1, while our project is based on kernel 4.9. In order to adapt the driver to our project, a line is commented out in the driver as follows:
static const struct snd_soc_component_driver pcm3060_soc_comp_driver = {
.controls = pcm3060_dapm_controls,
.num_controls = ARRAY_SIZE(pcm3060_dapm_controls),
.dapm_widgets = pcm3060_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(pcm3060_dapm_widgets),
.dapm_routes = pcm3060_dapm_map,
.num_dapm_routes = ARRAY_SIZE(pcm3060_dapm_map),
//.endianness = 1,
};
I doubt whether this line is the cause of the problem, or whether there are other errors in my driver and dts.
Thanks.