YCN-
Posts: 233
Joined: Fri Jun 10, 2016 3:18 pm

Re: The I2S sound thread.

Mon Jun 19, 2017 2:34 pm

Hi y'all,

Does anyone has answer about this : viewtopic.php?f=38&t=186203&p=1175938#p1175938

It's a post I made about using PLLD to generate i2s clock. Does any one has advices? I made a new post since I was thinking that this could help someone even if it wasn't I2S related.

YCN-

StuartF
Posts: 23
Joined: Sun Feb 02, 2014 5:41 pm

Re: The I2S sound thread.

Tue Jun 27, 2017 6:17 pm

I'll reply in this thread as it is more relevant.
From the other thread..
I set MASH 1 , DIVI = 177 , DIVF = 158
This is for 44100 @ 32 bit stereo?
You have the correct DIVI, but the DIVF is not correct. How are you working DIVF out?

By my calc, DIVF should be 681 ( although it falls on an edge case so 682 could also be preferable ).

This gives the value 0x5A0B1277 for the PCMDIV register.

n.b. I have not verified this as I work @ 48K.

YCN-
Posts: 233
Joined: Fri Jun 10, 2016 3:18 pm

Re: The I2S sound thread.

Wed Jun 28, 2017 7:48 am

Thanks for the answer but if I fooled myself that way I will not even have a close frequency from the frequency I expect which I do have. I think you calculated with 19.2 MHz osc when I used 500MHz osc.

I calculate that way :

I need to have bck = 44100*32*2 = 2822400 Hz = 2.8224 MHz
I used PLLD = 500MHz since the 19.2MHz would give a higher jitter.
Then I did 500 / 2.8224 = 177,154195011
So DIVI = 177 and DIVF = 0.1541195011 * 1024 = 157.8183... I "rounded" it at 158.
That should give me : average_frequency = 500 / ( 177 + 158/1024) = 2,822398377 MHz
But I have BCK = 2.8242MHz which is not that bad but when it came to LRCK I got : 43.4503kHz instead of 44.1kHz
I don't think that this is really crucial since it give me a jitter of 20 uS for LRCK ( 1 / 44100 - 1/43450,3 = 20 uS) but I don't know if that will disturb the audio even if I don't think so.

You wont face this problem with 48kHz since you have a neat DIVI and DIVF with 19.2 MHz. I think it 6.25 so that is DIVI = 6 and DIVF = 256 which gives the (almost) perfect result.

YCN-

StuartF
Posts: 23
Joined: Sun Feb 02, 2014 5:41 pm

Re: The I2S sound thread.

Wed Jun 28, 2017 2:48 pm

So DIVI = 177 and DIVF = 0.1541195011 * 1024 = 157.8183... I "rounded" it at 158.
This is incorrect. This should be 4096. Although it says 1024 in the PCMCLK datasheet, it has been corrected
in the forums and is mentioned in the example source code.

pebo
Posts: 3
Joined: Thu Jul 06, 2017 6:52 pm
Location: near Bonn, Germany

Re: The I2S sound thread.

Thu Jul 06, 2017 7:16 pm

Hi

my homebrew CS5361 audio ADC board is working fine via an I2S to USB converter. I'd prefer using the onboard I2S on my rpi 3 instead of USB, however. I have read quite some postings here and elsewhere but I still do not know how to connect an I2S ADC (ADC is master, ADC settings done with DIP switches) to my rpi. Can someone here please provide guidance suitable for a beginner?

Peter

ammu
Posts: 1
Joined: Wed Jul 26, 2017 5:11 am

Re: STICKY: The I2S sound thread.

Thu Jul 27, 2017 4:45 am

Hi ,How to write a code for communication between raspberry pi and codec via pcm.?so now i need to write a pcm code by choice clk as a slave,need to generate fsync ,so on..so anybody please help me out ..

czyskows
Posts: 33
Joined: Sun Oct 07, 2012 5:42 am

Re: STICKY: The I2S sound thread.

Mon Aug 28, 2017 1:59 am

Hi, (@stefan_o and YCN-)

Stefan, thanks for posting your drivers for the 4202! they've made a lot of things much clearer. I'm still confused though how you're using the gpio's - in particular, what you're doing with the FMT pins. Also, I'm not too clear on how you're setting your clocks - I see that you're using the FS0-2 pins to choose a sample rate, but it don't see how you're choosing the clock source. Does this happen in the BCM_I2S.c driver??? And if so, where in your code do you communicate with the clocks? In particular, if I wanted something from the 44.1 sample rate, how do I tell this to the BCM driver?

YCN-, I see that you've worked out the calculations for the sample rates, but where in my driver would I give these rates to the I2S driver?

I hope you guys are still around and watching this thread. It's been an immense help so far.

Thanks!

shrikantetc
Posts: 10
Joined: Mon Jul 17, 2017 5:54 am

Re: STICKY: The I2S sound thread.

Fri Sep 08, 2017 5:04 am

Hi ,

Can anybody help me with interfacing tlv320aic3254 or tlv320aic3120 with raspberry pi...?

the rpi Linux kernel main line doesn't have an entry for these IC's.



Thanks,
Shrikant

gorlapraveen
Posts: 1
Joined: Fri Sep 08, 2017 7:48 am

Re: STICKY: The I2S sound thread.

Fri Sep 08, 2017 7:54 am

Can Rf Daughter board such as [url] https://www.ettus.com/product/details/DBSRX2[/url ]from Ettus research with Raspbery pi GPIO for Receiving/Transmitting RF signals.

mjubes
Posts: 33
Joined: Thu Oct 01, 2015 8:17 am

Re: STICKY: The I2S sound thread.

Thu Sep 28, 2017 8:18 am

New Stretch OS

Does anybody know how this new version affect I2S issues. e.g. do I still need to include my-loader.ko to enable capture, or does it come with built in drivers for both in and out I2S

HiassofT
Posts: 28
Joined: Fri Jun 30, 2017 10:07 pm

Re: STICKY: The I2S sound thread.

Thu Sep 28, 2017 11:00 am

With the current Raspbian Stretch and Jessie kernels you just need to use a devicetree overlay like this one:

Code: Select all

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

    fragment@0 {
        target = <&sound>;
        __overlay__ {
            compatible = "simple-audio-card";
            simple-audio-card,name = "Dual";

            status="okay";

            capture_link: simple-audio-card,dai-link@0 {
                format = "i2s";

                r_cpu_dai: cpu {
                    sound-dai = <&i2s>;

/* example TDM slot configuration
                    dai-tdm-slot-num = <2>;
                    dai-tdm-slot-width = <32>;
*/
                };

                r_codec_dai: codec {
                    sound-dai = <&codec_in>;
                };
            };

            playback_link: simple-audio-card,dai-link@1 {
                format = "i2s";

                p_cpu_dai: cpu {
                    sound-dai = <&i2s>;

/* example TDM slot configuration
                    dai-tdm-slot-num = <2>;
                    dai-tdm-slot-width = <32>;
*/
                };

                p_codec_dai: codec {
                    sound-dai = <&codec_out>;
                };
            };
        };
    };

    fragment@1 {
        target-path = "/";
        __overlay__ {
            codec_out: spdif-transmitter {
                #address-cells = <0>;
                #size-cells = <0>;
                #sound-dai-cells = <0>;
                compatible = "linux,spdif-dit";
                status = "okay";
            };
            codec_in: spdif-receiver {
                #address-cells = <0>;
                #size-cells = <0>;
                #sound-dai-cells = <0>;
                compatible = "linux,spdif-dir";
                status = "okay";
            };
        };
    };

    fragment@2 {
        target = <&i2s>;
        __overlay__ {
            #sound-dai-cells = <0>;
            status = "okay";
        };
    };
};

/* compile with:
   dtc -@ -H epapr -O dtb -o dual.dtbo -Wno-unit_address_vs_reg dual.dts
*/
This overlay instantiates a generic I2S sound card with playback device hw:Dual,0 and capture device hw:Dual,1 using the upstream linux simple-audio-card, spdif-receiver and spdif-transmitter drivers. Despite their name the spdif drivers can also be used for 16 and 24 bit audio output.

Replace the generic spdif codecs with real ones (eg pcm5122) if needed.

If you need some fixed bclk ratio use the the tdm slot settings (the commented-out example in the overlay would set a fixed bclk ratio of 64 - 2 slots of 32 cycles each).

In addition to I2S left and right justified and DSP A and DSP B modes are available as well.

so long,

Hias

mjubes
Posts: 33
Joined: Thu Oct 01, 2015 8:17 am

Re: STICKY: The I2S sound thread.

Sun Oct 01, 2017 6:57 am

Thanks for that, but forgive my ignorance about device trees as I can't get it to work. I have done the following;

* saved your text as dual.dtb
* compiled with the dtb line you suggested
* this generated 'dual.dtbo'
* which I saved in /boot/overlays/dual.dtbo
* then I edited /boot/config.txt to include:
dtoverlay=dual
dtoverlay=i2s-mmap
dtoverlay=rpi-dac
dtoverlay=snd-soc-rpi-dac
dtoverlay=snd-soc-core
dtoverlay=pcm1794a
dtoverlay=snd-soc-pcm1794a
dtoverlay=snd-soc-bcm2708-i2s
dtoverlay=bcm2708-i2s
dtoverlay=bcm2708-dmaengine

(all the other dtoverlays, I had before from using myloader.c)

* when reboot no hw 'Dual' port was created. What am I doing wrong?
thanks in adance

HiassofT
Posts: 28
Joined: Fri Jun 30, 2017 10:07 pm

Re: STICKY: The I2S sound thread.

Mon Oct 02, 2017 7:43 am

mjubes wrote:
Sun Oct 01, 2017 6:57 am
* then I edited /boot/config.txt to include:
dtoverlay=dual
dtoverlay=i2s-mmap
dtoverlay=rpi-dac
dtoverlay=snd-soc-rpi-dac
dtoverlay=snd-soc-core
dtoverlay=pcm1794a
dtoverlay=snd-soc-pcm1794a
dtoverlay=snd-soc-bcm2708-i2s
dtoverlay=bcm2708-i2s
dtoverlay=bcm2708-dmaengine

(all the other dtoverlays, I had before from using myloader.c)
Remove all dtoverlay lines except for dtoverlay=dual

so long,

Hias

mjubes
Posts: 33
Joined: Thu Oct 01, 2015 8:17 am

Re: STICKY: The I2S sound thread.

Tue Oct 03, 2017 7:08 am

>Remove all dtoverlay lines except for dtoverlay=dual

Thanks. That worked !!

Well, it worked for Fletch, not for Jessie, which still seems to need my-loader.ko

HiassofT
Posts: 28
Joined: Fri Jun 30, 2017 10:07 pm

Re: STICKY: The I2S sound thread.

Tue Oct 03, 2017 9:58 pm

mjubes wrote:
Tue Oct 03, 2017 7:08 am
Well, it worked for Fletch, not for Jessie, which still seems to need my-loader.ko
Ah, you're right, the kernel in Raspbian Jessie is too old - I had thought it had been updated as well.

In this case you can use "rpi-update" to get the latest kernel version - then the DT overlay will work on Jessie as well.

so long,

Hias

mjubes
Posts: 33
Joined: Thu Oct 01, 2015 8:17 am

Re: STICKY: The I2S sound thread.

Thu Oct 05, 2017 9:13 am

>Ah, you're right, the kernel in Raspbian Jessie is too old

Thanks. Just for information, it (sort of works) with Jessie and 4.9.28, but still needs my-loader.ko to be present!

CodyDowling
Posts: 2
Joined: Tue Sep 19, 2017 4:30 am

Re: STICKY: The I2S sound thread.

Tue Oct 31, 2017 10:09 am

Hello,

I have been working on getting I2S up and running on my rPi3B for quite a while now, and was just about 75% of the way through the instructions I found on this thread (Thank you so much!). But, then we transitioned from Jessie to Stretch and I am wondering if I am still on the right path. I am also wondering if perhaps somebody has already done what I am trying to do and I am making it much more difficult than it is. Here is what I am attempting to do:

Long Term: Pass generic I2S data to/from a connected TI evaluation board (provides a header for Bit Clock, L/R Clock, Serial Data In, Serial Data Out). Also want to pass generical I2C commands to the same board to control various IC's on the board. rPi3B will be master for both I2S and I2C. Ideally, I would like to directly set all I2S parameters easily from a GUI.

Short Term: I would be elated if I could just pass 44.1/16bit audio to/from rPi3B connected to a PSIA header on a TI evaluation board.

Should I simply step through the same procedure outlined in this thread or is there:

a) something about Raspbian Stretch that would make this process unecessary?
b) someone who has already made a generic overlay I could just "copy-n-paste" into the rPi3B to get up and running?

Thanks in advance!
Cody

orchardaudio
Posts: 25
Joined: Wed Feb 03, 2016 11:19 pm
Contact: Website Facebook Twitter

Re: STICKY: The I2S sound thread.

Mon Nov 06, 2017 5:41 pm

HiassofT wrote:
Thu Sep 28, 2017 11:00 am
With the current Raspbian Stretch and Jessie kernels you just need to use a devicetree overlay like this one:

Code: Select all

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

    fragment@0 {
        target = <&sound>;
        __overlay__ {
            compatible = "simple-audio-card";
            simple-audio-card,name = "Dual";

            status="okay";

            capture_link: simple-audio-card,dai-link@0 {
                format = "i2s";

                r_cpu_dai: cpu {
                    sound-dai = <&i2s>;

/* example TDM slot configuration
                    dai-tdm-slot-num = <2>;
                    dai-tdm-slot-width = <32>;
*/
                };

                r_codec_dai: codec {
                    sound-dai = <&codec_in>;
                };
            };

            playback_link: simple-audio-card,dai-link@1 {
                format = "i2s";

                p_cpu_dai: cpu {
                    sound-dai = <&i2s>;

/* example TDM slot configuration
                    dai-tdm-slot-num = <2>;
                    dai-tdm-slot-width = <32>;
*/
                };

                p_codec_dai: codec {
                    sound-dai = <&codec_out>;
                };
            };
        };
    };

    fragment@1 {
        target-path = "/";
        __overlay__ {
            codec_out: spdif-transmitter {
                #address-cells = <0>;
                #size-cells = <0>;
                #sound-dai-cells = <0>;
                compatible = "linux,spdif-dit";
                status = "okay";
            };
            codec_in: spdif-receiver {
                #address-cells = <0>;
                #size-cells = <0>;
                #sound-dai-cells = <0>;
                compatible = "linux,spdif-dir";
                status = "okay";
            };
        };
    };

    fragment@2 {
        target = <&i2s>;
        __overlay__ {
            #sound-dai-cells = <0>;
            status = "okay";
        };
    };
};

/* compile with:
   dtc -@ -H epapr -O dtb -o dual.dtbo -Wno-unit_address_vs_reg dual.dts
*/
This overlay instantiates a generic I2S sound card with playback device hw:Dual,0 and capture device hw:Dual,1 using the upstream linux simple-audio-card, spdif-receiver and spdif-transmitter drivers. Despite their name the spdif drivers can also be used for 16 and 24 bit audio output.

Replace the generic spdif codecs with real ones (eg pcm5122) if needed.

If you need some fixed bclk ratio use the the tdm slot settings (the commented-out example in the overlay would set a fixed bclk ratio of 64 - 2 slots of 32 cycles each).

In addition to I2S left and right justified and DSP A and DSP B modes are available as well.

so long,

Hias

How do I modify this overlay to use the PCM1794A codec instead of the standard spdif one?
~~Orchard Audio~~
How do you like them apples?
www.orchardaudio.com
www.facebook.com/orchardaudio

rpifans
Posts: 1
Joined: Mon Nov 13, 2017 5:02 am

Re: STICKY: The I2S sound thread.

Mon Nov 13, 2017 5:41 am

Hello,

Currently i'm working on reading I2S output from raspberry pi 3 using STM32F4 series.
I want the STM32F4 act as master to generate the BCK and LRCK to raspberry pi which is act as slave (as shown image below) for clocking synchronize purpose.
I2S image.PNG
I2S image.PNG (6.24 KiB) Viewed 268 times
May I know how to configure the raspberry pi 3 slave mode i2s? Is it thru /boot/config.txt or others method?
Sorry I am new to the raspberry pi.

Thanks.

Regards,
rpifans

HiassofT
Posts: 28
Joined: Fri Jun 30, 2017 10:07 pm

Re: STICKY: The I2S sound thread.

Mon Nov 13, 2017 1:22 pm

When using the "simple-card " driver you can use the frame-master and bitclock-master properties in DT. See https://github.com/raspberrypi/linux/bl ... e-card.txt

so long,

Hias

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 8 guests