-
Notifications
You must be signed in to change notification settings - Fork 5.2k
sound/soc/bcm/bcm2708-i2s.c bug & fix, a request, and a question #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@hifiberry @koalo @hmbedded @iqaudio |
Hi, The second patch is trivial and will not induce regression. Regarding the question I can not say anything since I have never worked with the generic sound card. You might want to ask your question at freenode -> #alsa-soc. Greetings, |
Hi, the patch should not break any of our drivers as we set the bclk_ratio in the sound card driver. However I'm not really sure how these defaults work at all. Most sound chips will use 64xfs for 24 and 32 bit input data . Regards, |
If the codec supports a bclk_ratio of 60 and is accessed as slave, the audio quality will be improved since it is an integer divider of the clock frequency (Details: http://koalo.github.io/jamberry_thesis.pdf Section 5.5.2). I assume the difference is hard to recognize for most people, but that is not a valid argument if you want to deal with 24 bit on the Raspberry Pi. |
I agree on this, I just did not know a DAC chip that supports this. |
The simple-card driver does not use the set_bclk_ratio callback, 453 target_frequency = sampling_rate * bclk_ratio; At '40', for 24 bit data, ch2pos, flen, and fslen are too small. There is no way to transfer 48 bits of data in 40 i2s-bitclocks. At '60' i2s-bitclocks per frame, the 48 bits of data fits. However (opening up a can of worms, sigh) hifiberry's point is valid. Quoting Koala's paper: "The second solution utilizes the fact, that many audio codecs do not require a specific ratio of bit clock to frame sync as long as there are at most enough bit clock cycles within a frame sync cycle to contain the desired word length, and the bit clock frequency is not too high. The state of the data line in the remaining bits does not care as shown in Fig. 5.3.This leads to the uncommon number of 40 bit clock transitions per frame sync period resulting in a bit clock frequency of 40 · 48kHz = 1.92MHz.This can be generated form the 19.2MHz clock by an integer divider of 10. " Koala is using a 'feature' of the Philips i2s spec in order to allow the 19.2MHz oscillator to be used for a broader set of sampling frequency & data length combinations - by throwing in extra i2s-bitclocks after the required data_length bitclocks. Quoting Philips: "Serial data is transmitted in two’s complement with the MSB first. The MSB is transmitted first because the transmitter and receiver may have different word lengths. It isn’t necessary for the transmitter to know how many bits the receiver can handle, nor does the receiver need to know how many bits are being transmitted. (note the driver declares it supports SNDRV_PCM_RATE_8000_192000) For example, for 16 bit samples at 8000Hz, you need an i2s-bitclock of 2_16_8000=256000 clks/sec. 19200000/256000=75, so you can use the oscillator. But that is the ONLY sample rate that works. 19200000 / ({any of 16, 32, 48, 64, 96, 192k} * 32) is non-integral. However, if you say that you need 40 i2s-bitclocks per frame (to carry that 32 bits of data) then For 32 bit samples, you need 2_32_samplerate i2s-bitclocks. There is NO sample rate that works with the 19.2MHz oscillator. However, if you say the i2s bus should use 80 bitclocks to carry the 64 bits of data, then 8k, 16k, & 48k can use the oscillator. The other rates use the 500Mhz MASH clock For 24 bit samples, things get interesting.... GIven the above, why would I propose '60' rather than '50'? HOWEVER getting back to hifiberry's point, using unusual frame length values in order to allow use of the 19.2MHz clock makes me uncomfortable also, even though it seems permissible by the Philips spec. For example, the data sheet for my 24 bit capture device seems rather insistent that there are 64 bclks in a frame (though 60 worked). |
Plughplover, Daniel and I are using the TI PCM5122, Daniel also used the PCM5102 and a wolfson device for his digital out boards. Which device are you using so we can all look at the data sheets. Gordon
|
ADMP441 (aka INMP441) |
BTW, I don't know the lineage, but since |
In principle the patch for the bclk_ratio looks fine although I agree with @plughplover that 60 may not be the best number. I did some analysis to find out which values of bclk_ratio result in an integer divide from 19.2MHz for all of the 8k sampling frequency multiples [i.e. 19.2MHz/(bclk_ratio*fs)] and in fact there are only two numbers (up to 100) that work for all frequencies: 50 and 100. All other numbers result in some of the sampling frequencies being non integer and thus reverting to MASH mode. I therefore propose that we take this stage further and also change the bclk_ratios for 16 and 32 bit audio as follows: 16 bit: bclk_ratio = 50 This will result in all of the 8k frequency multiples running in integer mode and should therefore improve the sound quality for those that currently do not. I'd be happy to test this on the IQaudIO platform if it's generally thought to be a good idea? |
I don't know what was the reason for the XBMC problem, as we could not reproduce it outside XBMC. I don't think it comes from the bclk_ratio as this was always set in the driver to 64. But if somebody could test it, this would be great. BTW: While your MEMS microphone outputs 24bit data, with 61dbA SNR even 16bit are more than enough. |
I vote for 50, too, after I have reproduced your computations. |
I don't know the Linux kernel coding standards, but while preparing to do the edits for the '50' tests, it occurred to me that adding something like The question them becomes: For S16 / S24 / S32, do we build in 'strict' defaults of 32 / 64 / 64 (which make minimal use of 19.2MHz clock but likely compatible with broader range of devices) or 'loose' defaults of 40 / 50 / 80 (which make more use of that clock and remain consistent with the existing defaults), or the proposed 50 / 50 / 100 (to make maximal use of that clock)? I don't care which defaults are chosen if I can easily tweak them if needed, and it seems like the less risky path if the chosen defaults break something 'out there'. (btw, does editing a post cause it to be reposted to mailing list?) |
Tested '50'. It works for me for 24-bit capture. So I guess the consensus is: 1a) Proceed with the bug fix, and include an enhancement. 411 switch (params_format(params)) { This fixes the 'value to small' bug with 24 bit support, and enhances the default values to make maximal use of the 19.2MHz clock. 1b) Restore 24-bit audio playback support in bcm2708-i2s.c ONLY ref: 783 .playback = { 2a) Back-port this patch from 3.13 sound/soc/generic/simple-card.c to 3.12 tree 2b) Enable "ASOC Simple Sound card" as loadable module in default build Note: This is located in 'make menuconfig' here:
Note: there is no way to select this from 'make menuconfig' so I am hoping that the build gurus know of some way to simply enable it for the Raspian build. Thanks to everyone for the input! |
See: raspberrypi/linux#681 kernel: bcm2708_fb: Reduce dmesg spam See: raspberrypi/linux#685 kernel: Added driver for HiFiBerry Amp amplifier add-on board See: raspberrypi/linux#659 MMAL: Rebuilt with updated MMAL makefiles
See: raspberrypi/linux#681 kernel: bcm2708_fb: Reduce dmesg spam See: raspberrypi/linux#685 kernel: Added driver for HiFiBerry Amp amplifier add-on board See: raspberrypi/linux#659 MMAL: Rebuilt with updated MMAL makefiles
I believe latest firmware has the suggested changes (part from enabling SND_SOC_DMIC which only seems to exist as a part of OMAP). Can you test? |
I may be doing something wrong, or perhaps there is some change I unaware of but... I started with clean NOOBS v1.3.9 (3.12.22+) did (gtk-update-icon-cache:9044): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file '/usr/lib/arm-linux-gnueabihf/gdk-pixbuf-2.0/2.10.0/loaders.cache': No such file or directory I ignored this and then did sudo rpi-update The thing is, I can't find 'modules/3.12.28+/kernel/drivers/dma/bcm2708-dmaengine.ko' Poking around here https://github.com/Hexxeh/rpi-firmware/commits/master/modules So, before I invest more time: Am I doing something wrong? Is the 'dmaengine' module no longer needed for i2s? Or is it actually missing? PS - fyi - simple-card driver IS present. |
The module has been renamed. Can't remember the name, but you will find it if you look for dma modules. |
Examining this more closely |
Yup, appears it IS built into the kernel now. Incorporating items 1 and 2 are a big help! BTW, is there a schedule / target for when 3.12.28 will be considered 'done'? I have an enhancement to the i2s module in the works (and want to think about 3 some more). If closing it is not imminent, rolling the addition(s) into the final 3.12.28 might be appropriate... |
There is no deadline for 3.12.28 being done. Typically minor version bumps from upstream kernel occur quite regularly (interval is usually somewhere between a fortnight and a month). Submit your PR when it's ready. It may end up in a 3.12.28 or a 3.12.29 kernel, but that doesn't matter. |
Looks like the white noise in xbmc has returned after these changes: I think 4ba7ea9 will need to be reinstated unless someone can suggest a better fix? |
Florian, if xbmc only why block (if I read this right) 24bit support for everyone? Is that the suggested "fix"? So far we've had no reported issues with 24/96 or 24/192 playback. Gordon
|
Well it depends if the bug is in xbmc, the I2S audio driver or the HifiBerry driver. |
fwiw, http://www.raspberrypi.org/forums/viewtopic.php?p=614050#p614050 I agree that blocking this for everyone in the driver is not the correct approach. If something along those lines MUST be done, I suggest the more targeted approach I proposed a few posts earlier (see "1b"), which was to re-enable it in the i2s driver but leave it disabled in pcm5102a.c. (Have there have been xbmc reports against any other DACs?) However, while admittedly not knowing the specifics of how xbmc interfaces with alsa, can't they just put a constraint in .asoundrc until they track it down? Something along the lines of Finally, I took a quick look at the 5102a data sheet, the pcm5102a driver, and the hifiberry_dac driver, and while it looks ok, I couldn't help but wonder what would happen if this |
For now I've added 617139f to 3.16 branch (used in openelec build that had the bug report). I'll see if the original bug report is resolved and if any other I2S sound card users report an issue. |
In case my 'wondering' wasn't clear, with existing code 16/24/32 bit yields bclk 32/64/64 but with other call yields 32/48/64. According to page 14, both should work, but (hazarding a guess) if the board is using 'System Clock PLL Mode' (page 12) (i.e. synthesized sclk), well hmmm... fwiw, I also read ALL the threads that user linked to and frankly it isn't clear to me if their problem(s) are related to this specific issue. For example they are also having a problem 'aplay'ing 16 bit audio. |
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
See: raspberrypi/linux#681 kernel: bcm2708_fb: Reduce dmesg spam See: raspberrypi/linux#685 kernel: Added driver for HiFiBerry Amp amplifier add-on board See: raspberrypi/linux#659 MMAL: Rebuilt with updated MMAL makefiles
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
@popcornmix Difficult to track whether this is fixed from the comment above. Can it be closed? |
Yes I believe original issue was reported as solved here: #681 (comment) |
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
[ Upstream commit e78a761 ] Scheduling-clock interrupts can arrive late in the CPU-offline process, after idle entry and the subsequent call to cpuhp_report_idle_dead(). Once execution passes the call to rcu_report_dead(), RCU is ignoring the CPU, which results in lockdep complaints when the interrupt handler uses RCU: ------------------------------------------------------------------------ ============================= WARNING: suspicious RCU usage 5.2.0-rc1+ #681 Not tainted ----------------------------- kernel/sched/fair.c:9542 suspicious rcu_dereference_check() usage! other info that might help us debug this: RCU used illegally from offline CPU! rcu_scheduler_active = 2, debug_locks = 1 no locks held by swapper/5/0. stack backtrace: CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.2.0-rc1+ #681 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Bochs 01/01/2011 Call Trace: <IRQ> dump_stack+0x5e/0x8b trigger_load_balance+0xa8/0x390 ? tick_sched_do_timer+0x60/0x60 update_process_times+0x3b/0x50 tick_sched_handle+0x2f/0x40 tick_sched_timer+0x32/0x70 __hrtimer_run_queues+0xd3/0x3b0 hrtimer_interrupt+0x11d/0x270 ? sched_clock_local+0xc/0x74 smp_apic_timer_interrupt+0x79/0x200 apic_timer_interrupt+0xf/0x20 </IRQ> RIP: 0010:delay_tsc+0x22/0x50 Code: ff 0f 1f 80 00 00 00 00 65 44 8b 05 18 a7 11 48 0f ae e8 0f 31 48 89 d6 48 c1 e6 20 48 09 c6 eb 0e f3 90 65 8b 05 fe a6 11 48 <41> 39 c0 75 18 0f ae e8 0f 31 48 c1 e2 20 48 09 c2 48 89 d0 48 29 RSP: 0000:ffff8f92c0157ed0 EFLAGS: 00000212 ORIG_RAX: ffffffffffffff13 RAX: 0000000000000005 RBX: ffff8c861f356400 RCX: ffff8f92c0157e64 RDX: 000000321214c8cc RSI: 00000032120daa7f RDI: 0000000000260f15 RBP: 0000000000000005 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8c861ee18000 R15: ffff8c861ee18000 cpuhp_report_idle_dead+0x31/0x60 do_idle+0x1d5/0x200 ? _raw_spin_unlock_irqrestore+0x2d/0x40 cpu_startup_entry+0x14/0x20 start_secondary+0x151/0x170 secondary_startup_64+0xa4/0xb0 ------------------------------------------------------------------------ This happens rarely, but can be forced by happen more often by placing delays in cpuhp_report_idle_dead() following the call to rcu_report_dead(). With this in place, the following rcutorture scenario reproduces the problem within a few minutes: tools/testing/selftests/rcutorture/bin/kvm.sh --cpus 8 --duration 5 --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y" --configs "TREE04" This commit uses the crude but effective expedient of moving the disabling of interrupts within the idle loop to precede the cpu_is_offline() check. It also invokes tick_nohz_idle_stop_tick() instead of tick_nohz_idle_stop_tick_protected() to shut off the scheduling-clock interrupt. Signed-off-by: Peter Zijlstra <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> [ paulmck: Revert tick_nohz_idle_stop_tick_protected() removal, new callers. ] Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
[ Upstream commit e78a761 ] Scheduling-clock interrupts can arrive late in the CPU-offline process, after idle entry and the subsequent call to cpuhp_report_idle_dead(). Once execution passes the call to rcu_report_dead(), RCU is ignoring the CPU, which results in lockdep complaints when the interrupt handler uses RCU: ------------------------------------------------------------------------ ============================= WARNING: suspicious RCU usage 5.2.0-rc1+ #681 Not tainted ----------------------------- kernel/sched/fair.c:9542 suspicious rcu_dereference_check() usage! other info that might help us debug this: RCU used illegally from offline CPU! rcu_scheduler_active = 2, debug_locks = 1 no locks held by swapper/5/0. stack backtrace: CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.2.0-rc1+ #681 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Bochs 01/01/2011 Call Trace: <IRQ> dump_stack+0x5e/0x8b trigger_load_balance+0xa8/0x390 ? tick_sched_do_timer+0x60/0x60 update_process_times+0x3b/0x50 tick_sched_handle+0x2f/0x40 tick_sched_timer+0x32/0x70 __hrtimer_run_queues+0xd3/0x3b0 hrtimer_interrupt+0x11d/0x270 ? sched_clock_local+0xc/0x74 smp_apic_timer_interrupt+0x79/0x200 apic_timer_interrupt+0xf/0x20 </IRQ> RIP: 0010:delay_tsc+0x22/0x50 Code: ff 0f 1f 80 00 00 00 00 65 44 8b 05 18 a7 11 48 0f ae e8 0f 31 48 89 d6 48 c1 e6 20 48 09 c6 eb 0e f3 90 65 8b 05 fe a6 11 48 <41> 39 c0 75 18 0f ae e8 0f 31 48 c1 e2 20 48 09 c2 48 89 d0 48 29 RSP: 0000:ffff8f92c0157ed0 EFLAGS: 00000212 ORIG_RAX: ffffffffffffff13 RAX: 0000000000000005 RBX: ffff8c861f356400 RCX: ffff8f92c0157e64 RDX: 000000321214c8cc RSI: 00000032120daa7f RDI: 0000000000260f15 RBP: 0000000000000005 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8c861ee18000 R15: ffff8c861ee18000 cpuhp_report_idle_dead+0x31/0x60 do_idle+0x1d5/0x200 ? _raw_spin_unlock_irqrestore+0x2d/0x40 cpu_startup_entry+0x14/0x20 start_secondary+0x151/0x170 secondary_startup_64+0xa4/0xb0 ------------------------------------------------------------------------ This happens rarely, but can be forced by happen more often by placing delays in cpuhp_report_idle_dead() following the call to rcu_report_dead(). With this in place, the following rcutorture scenario reproduces the problem within a few minutes: tools/testing/selftests/rcutorture/bin/kvm.sh --cpus 8 --duration 5 --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y" --configs "TREE04" This commit uses the crude but effective expedient of moving the disabling of interrupts within the idle loop to precede the cpu_is_offline() check. It also invokes tick_nohz_idle_stop_tick() instead of tick_nohz_idle_stop_tick_protected() to shut off the scheduling-clock interrupt. Signed-off-by: Peter Zijlstra <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> [ paulmck: Revert tick_nohz_idle_stop_tick_protected() removal, new callers. ] Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
[ Upstream commit e78a761 ] Scheduling-clock interrupts can arrive late in the CPU-offline process, after idle entry and the subsequent call to cpuhp_report_idle_dead(). Once execution passes the call to rcu_report_dead(), RCU is ignoring the CPU, which results in lockdep complaints when the interrupt handler uses RCU: ------------------------------------------------------------------------ ============================= WARNING: suspicious RCU usage 5.2.0-rc1+ #681 Not tainted ----------------------------- kernel/sched/fair.c:9542 suspicious rcu_dereference_check() usage! other info that might help us debug this: RCU used illegally from offline CPU! rcu_scheduler_active = 2, debug_locks = 1 no locks held by swapper/5/0. stack backtrace: CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.2.0-rc1+ #681 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Bochs 01/01/2011 Call Trace: <IRQ> dump_stack+0x5e/0x8b trigger_load_balance+0xa8/0x390 ? tick_sched_do_timer+0x60/0x60 update_process_times+0x3b/0x50 tick_sched_handle+0x2f/0x40 tick_sched_timer+0x32/0x70 __hrtimer_run_queues+0xd3/0x3b0 hrtimer_interrupt+0x11d/0x270 ? sched_clock_local+0xc/0x74 smp_apic_timer_interrupt+0x79/0x200 apic_timer_interrupt+0xf/0x20 </IRQ> RIP: 0010:delay_tsc+0x22/0x50 Code: ff 0f 1f 80 00 00 00 00 65 44 8b 05 18 a7 11 48 0f ae e8 0f 31 48 89 d6 48 c1 e6 20 48 09 c6 eb 0e f3 90 65 8b 05 fe a6 11 48 <41> 39 c0 75 18 0f ae e8 0f 31 48 c1 e2 20 48 09 c2 48 89 d0 48 29 RSP: 0000:ffff8f92c0157ed0 EFLAGS: 00000212 ORIG_RAX: ffffffffffffff13 RAX: 0000000000000005 RBX: ffff8c861f356400 RCX: ffff8f92c0157e64 RDX: 000000321214c8cc RSI: 00000032120daa7f RDI: 0000000000260f15 RBP: 0000000000000005 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8c861ee18000 R15: ffff8c861ee18000 cpuhp_report_idle_dead+0x31/0x60 do_idle+0x1d5/0x200 ? _raw_spin_unlock_irqrestore+0x2d/0x40 cpu_startup_entry+0x14/0x20 start_secondary+0x151/0x170 secondary_startup_64+0xa4/0xb0 ------------------------------------------------------------------------ This happens rarely, but can be forced by happen more often by placing delays in cpuhp_report_idle_dead() following the call to rcu_report_dead(). With this in place, the following rcutorture scenario reproduces the problem within a few minutes: tools/testing/selftests/rcutorture/bin/kvm.sh --cpus 8 --duration 5 --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y" --configs "TREE04" This commit uses the crude but effective expedient of moving the disabling of interrupts within the idle loop to precede the cpu_is_offline() check. It also invokes tick_nohz_idle_stop_tick() instead of tick_nohz_idle_stop_tick_protected() to shut off the scheduling-clock interrupt. Signed-off-by: Peter Zijlstra <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> [ paulmck: Revert tick_nohz_idle_stop_tick_protected() removal, new callers. ] Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
rust: iomem: add `try_memcpy_fromio` method for `IoMem<T>`
While working on a simple i2s peripheral, I identified and fixed the bug alluded to here:
4ba7ea9
The fix is trivial; in this code
416 case SNDRV_PCM_FORMAT_S24_LE:
417 data_length = 24;
418 bclk_ratio = 40;
419 break;
change '40' to '60'
I can confirm that this fixes the problem for capture (my application), but as I don't have any i2s DACs I can't test it for playback. (However, I am 99% certain it also fixes that case). Of course, if/when this fix is incorporated, the afore-mentioned patch should also be backed out.
That is the bug & fix part. The request part:
My i2s peripheral uses the sound/soc/generic/simple-card.c ASoC card driver.
To use it, I must 'make menuconfig' and enable
Device drivers
Sound Card Support
Advanced Linux Sound Architecture
ALSA for SoC audio support
ASOC Simple sound card
as a loadable module, and also apply this trivial patch from 3.13
e244bb9
The request is that these two changes be incorporated into the current 3.12 branch for future 3.12.xx updates (ideally in conjunction with the bcm2708-i2s fix), subject to the answer to...
the question(s) part
My application also uses sound/soc/codecs/dmic.c in conjunction with generic/simple-card.c
Normally, Kconfig for a card driver would 'select' the codec driver(s), and on my dev sys I have added 'select SND_SOC_DMIC' to sound/soc/generic/Kconfig. But as simple-card is generic (as is dmic.c), that does not seem like the 'right thing to do'. How SHOULD this be handled? How would one get dmic included in the default raspberrypi distribution with (a patched) simple-card?
BTW, new account opened solely to post this. Have never mucked with github and forks and up/downstream and pulls and etc before, and frankly would prefer to focus my time elsewhere.
Thanks!
The text was updated successfully, but these errors were encountered: