psyxche
Posts: 2
Joined: Sat Aug 31, 2019 11:45 pm

Using two audio devices in device tree

Sat Aug 31, 2019 11:50 pm

Hello, I'm been planning a project utilizing a Fe-Pi V2 and Justboom DAC HAT. However, I've come into a slump on trying to have the Raspberry Pi, specifically alsamixer, recognize both audio devices. With dtoverlay on config.txt, I can have either card recognized by itself, but not both. Is there anything I can do to try and have both cards recognized?

Thank you.

Peakoverload
Posts: 43
Joined: Mon Jul 01, 2019 10:24 am
Location: West Sussex, England

Re: Using two audio devices in device tree

Tue Sep 03, 2019 9:16 am

I'm not familiar with either board and am a total newbie so I may be completely wrong but I had the exact problem using different devices and found on here that it is because you can only have one I2C device. If you try to install two, they conflict with each other and only one will work.

User avatar
rpdom
Posts: 15365
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Using two audio devices in device tree

Tue Sep 03, 2019 10:47 am

You can have many i2c devices as long as they have different addresses. There are around 126 addresses available on each i2c bus.

To check if you have an address conflict, try connecting just one board at a time and run

Code: Select all

i2cdetect -y 1
You will get output similar to this

Code: Select all

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- 75 -- --
In this case the device is using address 75.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2433
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Using two audio devices in device tree

Tue Sep 03, 2019 11:27 am

The likely problem with using two audio devices is the fact that the audio overlays all(?) place the definition of the sound card in the same DT node - /soc/sound - so each additional overlay overwrites any predecessors, at least partially. There's no technical reason why this should be the case, it just seemed tidier at the time rather than have each overlay choose its own place, and it wasn't envisioned that multiple cards would be used together.

To solve the problem you would need a custom version of one of the overlays - instead of:

Code: Select all

		target = <&sound>;
		__overlay__ {
			...
		};
you would need something like:

Code: Select all

		target-path = "/soc";
		__overlay__ {
			sound2 {
				...
			}
		};
where the body of the fragment has been wrapped in a new "sound2" node.

You may find there are runtime restrictions that mean you can't use more than one device at a time - there is only one I2S bus and controller after all - but there isn't much we can do about that.

psyxche
Posts: 2
Joined: Sat Aug 31, 2019 11:45 pm

Re: Using two audio devices in device tree

Sun Nov 03, 2019 4:06 am

Hey PhilE, thank you for the help. Just to confirm, I would need to change the .dtbo file of one of the devices (say the justboom-dac.dtbo file) to:

Code: Select all

           
           
fragment@0 {
                #target = < 0xffffffff >;
                target-path = "/soc";

                __overlay__ {
                        sound2 {
                                status = "okay";
                        };
                };
        };

        fragment@1 {
                #target = < 0xffffffff >;
                target-path = "/soc";

                __overlay__ {
                        sound2 {
                                #address-cells = < 0x01 >;
                                #size-cells = < 0x00 >;
                                status = "okay";

                                pcm5122@4d {
                                        #sound-dai-cells = < 0x00 >;
                                        compatible = "ti,pcm5122";
                                        reg = < 0x4d >;
                                        AVDD-supply = < 0xffffffff >;
                                        DVDD-supply = < 0xffffffff >;
                                        CPVDD-supply = < 0xffffffff >;
                                        status = "okay";
                                };
                        };
                };
        };

        fragment@2 {
                #target = < 0xffffffff >;
                target-path = "/soc";

                __overlay__ {
                        sound2 {
                                compatible = "justboom,justboom-dac";
                                i2s-controller = < 0xffffffff >;
                                status = "okay";
                                phandle = < 0x01 >;
                        };
                };
        };

                        
Then I would just need to compile the new dts file to dtbo and then copy it to /boot/overlays, correct?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2433
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Using two audio devices in device tree

Sun Nov 03, 2019 9:16 pm

Don't decompile overlays - the source code is available in our linux repo (https://github.com/raspberrypi/linux/tr ... s/overlays). Apart from that, the overlay looks confused - you've taken fragments that used to target the i2s label, /soc and the i2c label (but you can't tell that because the compilation step removes the labels) and modified them to only target /soc.

grael
Posts: 1
Joined: Fri Mar 27, 2015 1:09 pm

Re: Using two audio devices in device tree

Sun Nov 03, 2019 9:31 pm

Generaly speaking, you can't use 2 boards using the same i2s (not i2c) interface pins on Rasberry pi header.
Maybe two totaly passive hat dac COULD share the same output, but anyway, you can't have two independent outputs

Return to “Device Tree”