Please help! I2S wrong speed - Raspberry Pi Forums


please help!

include lots of detail can see i've done work, i'm asking how manually force alsa soc play particular settings on i2s, without having automatically detected soundcard driver! down automatic setup! want manual! :)


attached 12.288 mhz external crystal oscillator pi , changed codec's settings accordingly, , audio still playing fast. , apparently used enough current wifi stopped working. removed , went driving codec's master clock 19.2 mhz pi oscillator/2 = 9.6 mhz.

latest attempt restrict bcm2835-i2s.c allow 16 bits @ 44100 sps. suspected that, since i'm manually setting codec , alsa doesn't know codec expecting, resampling or changing something. here a440 tone generated audacity on pi, recorded being played pi codec (it looped, can't tell, indeed play 10 seconds of theoretical sound in 3-4 seconds). note periodic skipping sounds, dropouts, periodic, make me wonder if samples being delayed or skipped or something. record left side; in fact playing stereo, periodic skips seem not same on left , right.

i'm using carla's version of plugh's famous simple card loader, filenames match system. see below.
see below relevant section of edited version of bcm2835-i2s.c, can see i've instructed alsa use 44100/16 bits.

codec sgtl5000, in form of teensy audio adapter. thing i'm doing differently teensy default driver i'm using sgtl5000's internal pll divide 9.6 mhz clock; teensy default clocks provided teensy, i.e. slave mode sgtl5000. since other circuitry same teensy audio library default, i'm using default settings configure sgtl5000 except pll. datasheet says first set frequency of pll, power , vco up, instruct sgtl5000 use pll output clock source. setup file of teensy audio library except:
0x0032 = pll frequency, set correctly according datasheet
0x0030 = 0x45ff analog power setting, 5 means start pll , vco
0x0004 = 0x0007 meaning use pll clock source , sr 44100
0x0006 = 0x01b0 meaning 1. bit clock 32x fs; 2. sgtl5000 clock master; 3. 16 bits per sample; 4. i2s mode normal bit , frame polarity

in summary, codec expecting i2s @ 44100 sps, 16 bits, stereo, normal bit , frame polarity, , 32 bit clocks per lr clock. note have tried of possible combinations of these settings , never correct result. if double bit clock 64xfs, plays faster!

have complete control on codec expects soc; but, i'm using simple card loader, dummy status, don't know know alsa sending. uncertainty lies in alsa soc's i2s. thought resolve restricting dummy card 16 bits @ 44.1 k, makes no difference.

that, platform timing slave, don't need use bit clock ratio of 50, 32? still, audio playing 2.6667 times fast, , 50 not 2.6667 times 32. else wrong?

please help! i'm out of ideas!

if no 1 can me this, maybe offer info regarding getting asoc use sgtl5000 codec driver provided manufacturer; unfortunately, attempts carla/plugh's loader use driver instead of dummy failed. none of florian's examples in linux/sound/soc/bcm seem use separate codec driver, , it's bit unclear how use them models.

440 played fast on rpi codec:
http://irinasicharlie.com/rpi-audio/audio-from-pi.wav

bcm2835-i2s.c changed parts:

code: select all

static struct snd_soc_dai_driver bcm2835_i2s_dai = { 	.name	= "bcm2835-i2s", 	.probe	= bcm2835_i2s_dai_probe, 	.playback = { 		.channels_min = 2, 		.channels_max = 2, 		.rates =	sndrv_pcm_rate_44100, 		.formats =	sndrv_pcm_fmtbit_s16_le 		}, 	.capture = { 		.channels_min = 2, 		.channels_max = 2, 		.rates =	sndrv_pcm_rate_44100, 		.formats =	sndrv_pcm_fmtbit_s16_le 		}, 	.ops = &bcm2835_i2s_dai_ops, 	.symmetric_rates = 1 }; ................................. static struct snd_pcm_hardware bcm2835_pcm_hardware = { 	.info			= sndrv_pcm_info_interleaved | 				  sndrv_pcm_info_joint_duplex, 	.formats		= sndrv_pcm_fmtbit_s16_le, 	.period_bytes_min	= 32, 	.period_bytes_max	= 64 * page_size, 	.periods_min		= 2, 	.periods_max		= 255, 	.buffer_bytes_max	= 128 * page_size, }; 
loader:

code: select all

#include <linux/module.h> #include <linux/kernel.h> #include <linux/kmod.h> #include <linux/platform_device.h> #include <sound/simple_card.h>  void device_release_callback(struct device *dev) { /* nothing */ };  static struct asoc_simple_card_info snd_rpi_simple_card_info = { .card = "snd_rpi_simple_card", // -> snd_soc_card.name .name = "simple-card_codec_link", // -> snd_soc_dai_link.name .codec = "snd-soc-dummy", // "dmic-codec", // -> snd_soc_dai_link.codec_name // .platform = "bcm2708-i2s.0", // -> snd_soc_dai_link.platform_name .platform = "3f203000.i2s", .daifmt = snd_soc_daifmt_i2s | snd_soc_daifmt_nb_nf |snd_soc_daifmt_cbm_cfm, .cpu_dai = { //	 .name = "bcm2708-i2s.0", // -> snd_soc_dai_link.cpu_dai_name .name = "3f203000.i2s", // -> snd_soc_dai_link.cpu_dai_name //.fmt =  .sysclk = 0 }, .codec_dai = { .name = "snd-soc-dummy-dai", //"dmic-codec", // -> snd_soc_dai_link.codec_dai_name //.fmt = 0, .sysclk = 0 }, }; static struct platform_device snd_rpi_simple_card_device = { .name = "asoc-simple-card", //module alias .id = 0, .num_resources = 0, .dev = { .release = &device_release_callback, .platform_data = &snd_rpi_simple_card_info, // *hack alert* }, }; static struct platform_device snd_rpi_codec_device = { .name = "sgtl5000-codec", // "dmic-codec", //module alias .id = -1, .num_resources = 0, .dev = { .release = &device_release_callback, }, };  int hello_init(void) { const char *dmaengine = "bcm2708-dmaengine"; //module name int ret;  ret = request_module(dmaengine); pr_alert("request module load '%s': %d\n",dmaengine, ret);  //	ret = platform_device_register(&snd_rpi_codec_device); //	pr_alert("register platform device '%s': %d\n",snd_rpi_codec_device.name, ret);  ret = platform_device_register(&snd_rpi_simple_card_device); pr_alert("register platform device '%s': %d\n",snd_rpi_simple_card_device.name, ret);  pr_alert("hello world :)\n"); return 0; } void hello_exit(void) {// you'll have sudo modprobe -r card & codec drivers manually (first?) platform_device_unregister(&snd_rpi_simple_card_device); platform_device_unregister(&snd_rpi_codec_device); pr_alert("goodbye world!\n"); } module_init(hello_init); module_exit(hello_exit); module_description("asoc simple-card i2s setup"); module_author("plugh plover"); module_license("gpl v2"); [/code system info: [code] pi@raspberrypi:~ $ uname -r 4.4.7-rt16-v7+   pi@raspberrypi:~ $ cat /proc/asound/card0/pcm0p/sub0/hw_params  access: rw_interleaved format: s16_le subformat: std channels: 2 rate: 44100 (44100/1) period_size: 1102 buffer_size: 5510 pi@raspberrypi:~ $ cat /proc/asound/card0/pcm0p/sub0/info card: 0 device: 0 subdevice: 0 stream: playback id: simple-card_codec_link snd-soc-dummy-dai-0 name:  subname: subdevice #0 class: 0 subclass: 0 subdevices_count: 1 subdevices_avail: 0 pi@raspberrypi:~ $  
please me!

thanks!

-chuckk

nb play same a440 wave file using internal audio , plays @ correct speed , frequency! wrong using i2s.


raspberrypi



Comments