Skip to contentSkip to conversation

overrun in case of record

DISCUSSION Rajeev kumar 4 participants 16 messages Sep 6, 2011 – Jan 12, 2012

lore
Share & tools
lore
#0 lore raw

Hello Mark

I am testing my audio driver on spear platform.During recording I am getting two issues.
1. Overrun issue
2. pcm_read error

I am using arecord for capturing data.
#arecord -f dat > t
overrun!!! (at least 32.949 ms long)

Overrun issue: The issue is only reproducible if we try to record for more than 40 sec.The strange part is that Instead of overrun condition generated,
it will record complete data for 10sec.(This is verified with the number of bytes recorded).
So could you please let me know whether this is an error condition or just a warning.

pcm_read error: For this I have seen a bug is locked in the bugzila(*Bug 472469* <show_bug.cgi?id=472469> -arecord: input/output error ). and the status is closed saying insufficient data. Could you please let me know what is the meaning of this bug? Is it like, data is not available in the buffer and pcm_read from the user space fails? But why this situation will
arise?

Best Regards
Rajeev

#1 lore raw
Quoted 11 lines · Rajeev kumar

I am using arecord for capturing data.
#arecord -f dat > t
overrun!!! (at least 32.949 ms long)

Overrun issue: The issue is only reproducible if we try to record for more than 40 sec.The strange part is that Instead of overrun condition generated,
it will record complete data for 10sec.(This is verified with the number of bytes recorded).
So could you please let me know whether this is an error condition or just a warning.

An overrun means that your driver is producing data faster than the application is reading it and ran out of buffer space. This may mean that you're running at the wrong sample rate, or it may mean that your system is just too slow to do recordings.

Quoted 7 lines

pcm_read error: For this I have seen a bug is locked in the bugzila(*Bug 472469* <show_bug.cgi?id=472469> -arecord: input/output error ). and the status is closed saying insufficient data. Could you please let me know what is the meaning of this bug? Is it like, data is not available in the buffer and pcm_read from the user space fails? But why this situation will
arise?

You'll need to investigate the bug.

#2 lore raw

Hello Mark

Quoted 10 lines · Mark Brown
Quoted 7 lines

pcm_read error: For this I have seen a bug is locked in the

Quoted 6 lines

bugzila(*Bug 472469*<show_bug.cgi?id=472469> -arecord: input/output error ). and the status is closed saying insufficient data. Could you please let me know what is the meaning of this bug? Is it like, data is not available in the buffer and pcm_read from the user space fails? But why this situation will
arise?

You'll need to investigate the bug.
.

I analyzed the bug and found that if I use arecord in non-blocking mode, it works fine.

#arecord -f dat --nonblock > t

Working in a non-blocking mode means there is no data available in ring buffer and returning -EAGAIN from the alsa, so application is wating for data to arrive in the ring buffer. Now it is not clear to me why this situation will arise?
I have checked the clock and all the clock are intact. The calculation for number of bytes received in a sec is correct.

Best Regards
Rajeev

#3 lore raw
Quoted 2 lines · Rajeev kumar

I analyzed the bug and found that if I use arecord in non-blocking mode, it works fine.

In theory, with a correct driver, using non-blocking mode should not make any difference.

All the symptoms indicate that the pointer callback and/or the calling of snd_pcm_period_elapsed is somehow wrong.

Regards,
Clemens

#4 lore raw

Exporting playback and capture capability to user space

In reply to Rajeev kumar

Hello Mark

I have a single codec with playback and capture capability. We are using it for different i2s controller. Below are the details for that.

case 1: I2S controller-1: with playback and capture capability case 2: I2S controller-2: with playback capability only case 3: I2S controller-3: with capture capability only.

We are registering all the I2S controller with there respective capability.

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices, capture device is also listed. This is true in case-1 but for case-2 and case-3 also it is showing the same behavior. According to my understanding it should not show the list of all devices i.e. in case of controller having playback capability it should show only playback devices not capture devices and vice versa. Please correct me if I am wrong.

So my questions are
1. How to separate playback and capture devices in case-2 and case-3. Are we need to register different codec for different i2s controller?

2. Is it codec capability only which is exported to user space ?

Best Regards
Rajeev

#5 lore raw

Re: Exporting playback and capture capability to user space

Quoted 2 lines · Rajeev kumar

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices, capture device is also listed. This is true in case-1 but

This is the intended behaviour, capture only PCMs are still PCMs.

#6 lore raw

Re: Exporting playback and capture capability to user space

In reply to Rajeev kumar

Hello Mark

Could you please help me by answering these questions?

Best Regards
Rajeev

Quoted 30 lines · Rajeev kumar

Hello Mark

I have a single codec with playback and capture capability. We are using it for different i2s controller. Below are the details for that.

case 1: I2S controller-1: with playback and capture capability case 2: I2S controller-2: with playback capability only case 3: I2S controller-3: with capture capability only.

We are registering all the I2S controller with there respective capability.

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices, capture device is also listed. This is true in case-1 but for case-2 and case-3 also it is showing the same behavior. According to my understanding it should not show the list of all devices i.e. in case of controller having playback capability it should show only playback devices not capture devices and vice versa. Please correct me if I am wrong.

So my questions are
1. How to separate playback and capture devices in case-2 and case-3. Are we need to register different codec for different i2s controller?

2. Is it codec capability only which is exported to user space ?

Best Regards
Rajeev

#7 lore raw

Re: Exporting playback and capture capability to user space

Quoted 7 lines · Rajeev kumar

Hello Mark

Could you please help me by answering these questions?

Best Regards
Rajeev

Pls don't top-post!!

Quoted 20 lines · Rajeev kumar
Quoted 19 lines

Hello Mark

I have a single codec with playback and capture capability. We are using it for different i2s controller. Below are the details for that.

case 1: I2S controller-1: with playback and capture capability case 2: I2S controller-2: with playback capability only case 3: I2S controller-3: with capture capability only.

We are registering all the I2S controller with there respective capability.

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices, capture device is also listed. This is true in case-1 but for case-2 and case-3 also it is showing the same behavior. According to my understanding it should not show the list of all devices i.e. in case of controller having playback capability it should show only playback devices not capture devices and vice versa. Please correct me if I am wrong.

Quoted 3 lines
Quoted 3 lines

So my questions are
1. How to separate playback and capture devices in case-2 and case-3. Are we need to register different codec for different i2s controller?

How asoc builds this is based on dailinks you have provided. If for the device 2 and device 3 the cpu and codec dais support both playback and capture devices, it will go ahead and register these device. The fact that for device 2 and device 3 capture is also registered suggests me that your cpu dais are not correct.

Would help if you post your code, esp the codec, cpu dais and dialinks.

Signature · 1 line
~Vinod
#8 lore raw

Re: Exporting playback and capture capability to user space

Hello Vinod, Mark

Quoted 32 lines · Vinod Koul
Quoted 7 lines · Rajeev kumar

Hello Mark

Could you please help me by answering these questions?

Best Regards
Rajeev

Pls don't top-post!!

Quoted 20 lines · Rajeev kumar
Quoted 19 lines

Hello Mark

I have a single codec with playback and capture capability. We are using it for different i2s controller. Below are the details for that.

case 1: I2S controller-1: with playback and capture capability case 2: I2S controller-2: with playback capability only case 3: I2S controller-3: with capture capability only.

We are registering all the I2S controller with there respective capability.

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices, capture device is also listed. This is true in case-1 but for case-2 and case-3 also it is showing the same behavior. According to my understanding it should not show the list of all devices i.e. in case of controller having playback capability it should show only playback devices not capture devices and vice versa. Please correct me if I am wrong.

Quoted 3 lines
Quoted 3 lines

So my questions are
1. How to separate playback and capture devices in case-2 and case-3. Are we need to register different codec for different i2s controller?

Quoted 8 lines

How asoc builds this is based on dailinks you have provided. If for the device 2 and device 3 the cpu and codec dais support both playback and capture devices, it will go ahead and register these device. The fact that for device 2 and device 3 capture is also registered suggests me that your cpu dais are not correct.

Would help if you post your code, esp the codec, cpu dais and dialinks.

Codec dai:

static struct snd_soc_dai_driver sta529_dai = {
	.name = "sta529-audio",
	.playback = {
		.stream_name = "Playback",
		.channels_min = 2,
		.channels_max = 2,
		.rates = SPEAR_PCM_RATES,
		.formats = SPEAR_PCM_FORMAT,
	},
	.capture = {
		.stream_name = "Capture",
		.channels_min = 2,
		.channels_max = 2,
		.rates = SPEAR_PCM_RATES,
		.formats = SPEAR_PCM_FORMAT,
	},
	.ops	= &sta529_dai_ops,
};

cpu dai: In case of cpu dai, we are passing the playback and capture capability from the platform code and depending on the capability we are filling the cpu dai structure in probe function, like

if (cap & PLAY) {

	/* Fill Playback capability */
}
if (cap & RECORD) {
	/* Fill Capture capability */
}

dai links:

static struct snd_soc_dai_link spear_evb_dai[] = {
	 {
		.name		= "sta529-pcm0",
		.stream_name	= "I2S Playback",
		.cpu_dai_name	= "designware-i2s.0",
		.platform_name	= "spear-pcm-audio",
		.codec_dai_name	= "sta529-audio",
		.codec_name	= "sta529-codec.0-001a",
		.ops		= &sta529_ops,
	}, {
		.name		= "sta529-pcm1",
		.stream_name	= "I2S Capture",
		.cpu_dai_name	= "designware-i2s.1",
		.platform_name	= "spear-pcm-audio",
		.codec_dai_name	= "sta529-audio",
		.codec_name	= "sta529-codec.0-001a",
		.ops		= &sta529_ops,
	},
};
static struct snd_soc_card spear_snd_card = {
	.name		= "spear-evb",
	.dai_link	= spear_evb_dai,
	.num_links	= ARRAY_SIZE(spear_evb_dai),
};

Best Regards
~Rajeev

#9 lore raw

Re: Exporting playback and capture capability to user space

Quoted 5 lines · Rajeev kumar

static struct snd_soc_dai_driver sta529_dai = {

.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,

This looks wrong...

Quoted 3 lines

cpu dai: In case of cpu dai, we are passing the playback and capture capability from the platform code and depending on the capability we are filling the cpu dai structure in probe function, like

Why are you doing this? Your driver should export the capabilities of the hardware and let the machine driver pick any specific configuration that's needed.

#10 lore raw

Re: Exporting playback and capture capability to user space

Hello Mark

Quoted 10 lines · Mark Brown
Quoted 5 lines · Rajeev kumar

static struct snd_soc_dai_driver sta529_dai = {

.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,

This looks wrong...

Agreed, This should be STA529_RATES and STA529_FORMATS.

Quoted 8 lines
Quoted 3 lines

cpu dai: In case of cpu dai, we are passing the playback and capture capability from the platform code and depending on the capability we are filling the cpu dai structure in probe function, like

Why are you doing this? Your driver should export the capabilities of the hardware and let the machine driver pick any specific configuration that's needed.

This is needed because we have a single cpu driver for three different I2S controller having different capability(as I explained in the first mail.). So capabilities are passed from the platform code and get filled in the probe part of the i2s controller.

Best Regards
~Rajeev

#11 lore raw

Re: Exporting playback and capture capability to user space

In reply to Rajeev kumar

Hello Vinod,

Quoted 106 lines · Rajeev kumar

Hello Vinod, Mark

Quoted 37 lines · Vinod Koul
Quoted 7 lines · Rajeev kumar

Hello Mark

Could you please help me by answering these questions?

Best Regards
Rajeev

Pls don't top-post!!

Quoted 25 lines · Rajeev kumar
Quoted 24 lines

Hello Mark

I have a single codec with playback and capture capability. We are using
it for different i2s controller. Below are the details for that.

case 1: I2S controller-1: with playback and capture capability case 2: I2S controller-2: with playback capability only case 3: I2S controller-3: with capture capability only.

We are registering all the I2S controller with there respective capability.

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices,
capture device is also listed. This is true in case-1 but for case-2 and
case-3 also it is showing the same behavior. According to my understanding it should not show the list of all devices i.e. in case of
controller having playback capability it should show only playback devices not capture devices and vice versa. Please correct me if I am wrong.

Quoted 3 lines
Quoted 3 lines

So my questions are
1. How to separate playback and capture devices in case-2 and case-3. Are we need to register different codec for different i2s controller?

Quoted 8 lines

How asoc builds this is based on dailinks you have provided. If for the device 2 and device 3 the cpu and codec dais support both playback and capture devices, it will go ahead and register these device. The fact that for device 2 and device 3 capture is also registered suggests me that your cpu dais are not correct.

Would help if you post your code, esp the codec, cpu dais and dialinks.

Codec dai:

static struct snd_soc_dai_driver sta529_dai = {
.name = "sta529-audio",
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,
},
.capture = {
.stream_name = "Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,
},
.ops = &sta529_dai_ops,
};

cpu dai: In case of cpu dai, we are passing the playback and capture capability from the platform code and depending on the capability we are filling the cpu dai structure in probe function, like

if (cap & PLAY) {

/* Fill Playback capability */
}

if (cap & RECORD) {
/* Fill Capture capability */
}

dai links:

static struct snd_soc_dai_link spear_evb_dai[] = { {
.name = "sta529-pcm0",
.stream_name = "I2S Playback", .cpu_dai_name = "designware-i2s.0", .platform_name = "spear-pcm-audio", .codec_dai_name = "sta529-audio", .codec_name = "sta529-codec.0-001a",
.ops = &sta529_ops,
}, {
.name = "sta529-pcm1",
.stream_name = "I2S Capture", .cpu_dai_name = "designware-i2s.1", .platform_name = "spear-pcm-audio", .codec_dai_name = "sta529-audio", .codec_name = "sta529-codec.0-001a",
.ops = &sta529_ops,
},
};

Quoted 6 lines

static struct snd_soc_card spear_snd_card = {
.name = "spear-evb",
.dai_link = spear_evb_dai,
.num_links = ARRAY_SIZE(spear_evb_dai),
};

I had actually missed the last mail by mark. I dont know why? . So sorry for replying on the top of this mail.

Vinod, have you gone through the cpu_dai, codec_dai and dailink ? Could you please make any suggestion?

Best Regards
~Rajeev

Quoted 2 lines

Best Regards
~Rajeev

#12 lore raw

Re: Exporting playback and capture capability to user space

Quoted 4 lines · Rajeev kumar
Quoted 2 lines

cpu dai: In case of cpu dai, we are passing the playback and capture capability from the platform code and depending on the capability we

are

Quoted 1 line

filling the cpu dai structure in probe function, like

Unless we find what is being passed, its hard to comment.

As I said previously this will happen when you are reporting cpu dai wrongly, so hack there to fix your issue

Signature · 1 line
~Vinod
#13 lore raw

Re: Exporting playback and capture capability to user space

In reply to Rajeev kumar
Quoted 116 lines · Rajeev kumar

Hello Vinod,

Quoted 106 lines · Rajeev kumar

Hello Vinod, Mark

Quoted 37 lines · Vinod Koul
Quoted 7 lines · Rajeev kumar

Hello Mark

Could you please help me by answering these questions?

Best Regards
Rajeev

Pls don't top-post!!

Quoted 25 lines · Rajeev kumar
Quoted 24 lines

Hello Mark

I have a single codec with playback and capture capability. We are using
it for different i2s controller. Below are the details for that.

case 1: I2S controller-1: with playback and capture capability case 2: I2S controller-2: with playback capability only case 3: I2S controller-3: with capture capability only.

We are registering all the I2S controller with there respective capability.

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices,
capture device is also listed. This is true in case-1 but for case-2 and
case-3 also it is showing the same behavior. According to my understanding it should not show the list of all devices i.e. in case of
controller having playback capability it should show only playback devices not capture devices and vice versa. Please correct me if I am wrong.

Quoted 3 lines
Quoted 3 lines

So my questions are
1. How to separate playback and capture devices in case-2 and case-3. Are we need to register different codec for different i2s controller?

Quoted 8 lines

How asoc builds this is based on dailinks you have provided. If for the device 2 and device 3 the cpu and codec dais support both playback and capture devices, it will go ahead and register these device. The fact that for device 2 and device 3 capture is also registered suggests me that your cpu dais are not correct.

Would help if you post your code, esp the codec, cpu dais and dialinks.

Codec dai:

static struct snd_soc_dai_driver sta529_dai = {
.name = "sta529-audio",
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,
},
.capture = {
.stream_name = "Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,
},
.ops = &sta529_dai_ops,
};

cpu dai: In case of cpu dai, we are passing the playback and capture capability from the platform code and depending on the capability we are filling the cpu dai structure in probe function, like

if (cap & PLAY) {

/* Fill Playback capability */
}

if (cap & RECORD) {
/* Fill Capture capability */
}

dai links:

static struct snd_soc_dai_link spear_evb_dai[] = { {
.name = "sta529-pcm0",
.stream_name = "I2S Playback", .cpu_dai_name = "designware-i2s.0", .platform_name = "spear-pcm-audio", .codec_dai_name = "sta529-audio", .codec_name = "sta529-codec.0-001a",
.ops = &sta529_ops,
}, {
.name = "sta529-pcm1",
.stream_name = "I2S Capture", .cpu_dai_name = "designware-i2s.1", .platform_name = "spear-pcm-audio", .codec_dai_name = "sta529-audio", .codec_name = "sta529-codec.0-001a",
.ops = &sta529_ops,
},
};

Quoted 6 lines

static struct snd_soc_card spear_snd_card = {
.name = "spear-evb",
.dai_link = spear_evb_dai,
.num_links = ARRAY_SIZE(spear_evb_dai),
};

Quoted 6 lines

I had actually missed the last mail by mark. I dont know why? . So sorry for replying on the top of this mail.

Vinod, have you gone through the cpu_dai, codec_dai and dailink ? Could you please make any suggestion?

Ping

Quoted 8 lines

Best Regards
~Rajeev

Quoted 2 lines

Best Regards
~Rajeev

#14 lore raw

Re: Exporting playback and capture capability to user space

Hello Mark

Quoted 117 lines · Rajeev kumar
Quoted 116 lines · Rajeev kumar

Hello Vinod,

Quoted 112 lines · Rajeev kumar

Hello Vinod, Mark

Quoted 37 lines · Vinod Koul
Quoted 7 lines · Rajeev kumar

Hello Mark

Could you please help me by answering these questions?

Best Regards
Rajeev

Pls don't top-post!!

Quoted 25 lines · Rajeev kumar
Quoted 24 lines

Hello Mark

I have a single codec with playback and capture capability. We are using
it for different i2s controller. Below are the details for that.

case 1: I2S controller-1: with playback and capture capability case 2: I2S controller-2: with playback capability only case 3: I2S controller-3: with capture capability only.

We are registering all the I2S controller with there respective capability.

In command 'aplay -l' or 'cat /proc/asound/pcm', among playback devices,
capture device is also listed. This is true in case-1 but for case-2 and
case-3 also it is showing the same behavior. According to my understanding it should not show the list of all devices i.e. in case of
controller having playback capability it should show only playback devices not capture devices and vice versa. Please correct me if I am wrong.

Quoted 3 lines
Quoted 3 lines

So my questions are
1. How to separate playback and capture devices in case-2 and case-3. Are we need to register different codec for different i2s controller?

Quoted 8 lines

How asoc builds this is based on dailinks you have provided. If for the device 2 and device 3 the cpu and codec dais support both playback and capture devices, it will go ahead and register these device. The fact that for device 2 and device 3 capture is also registered suggests me that your cpu dais are not correct.

Would help if you post your code, esp the codec, cpu dais and dialinks.

Codec dai:

static struct snd_soc_dai_driver sta529_dai = {
.name = "sta529-audio",
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,
},
.capture = {
.stream_name = "Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SPEAR_PCM_RATES,
.formats = SPEAR_PCM_FORMAT,
},
.ops = &sta529_dai_ops,
};

cpu dai: In case of cpu dai, we are passing the playback and capture capability from the platform code and depending on the capability we are filling the cpu dai structure in probe function, like

if (cap & PLAY) {

/* Fill Playback capability */
}

if (cap & RECORD) {
/* Fill Capture capability */
}

dai links:

static struct snd_soc_dai_link spear_evb_dai[] = { {
.name = "sta529-pcm0",
.stream_name = "I2S Playback", .cpu_dai_name = "designware-i2s.0", .platform_name = "spear-pcm-audio", .codec_dai_name = "sta529-audio", .codec_name = "sta529-codec.0-001a",
.ops = &sta529_ops,
}, {
.name = "sta529-pcm1",
.stream_name = "I2S Capture", .cpu_dai_name = "designware-i2s.1", .platform_name = "spear-pcm-audio", .codec_dai_name = "sta529-audio", .codec_name = "sta529-codec.0-001a",
.ops = &sta529_ops,
},
};

static struct snd_soc_card spear_snd_card = {
.name = "spear-evb",
.dai_link = spear_evb_dai,
.num_links = ARRAY_SIZE(spear_evb_dai),
};

Quoted 9 lines
Quoted 6 lines

I had actually missed the last mail by mark. I dont know why? . So sorry for replying on the top of this mail.

Vinod, have you gone through the cpu_dai, codec_dai and dailink ? Could you please make any suggestion?

Ping

The o/p of the cat /proc/asound/pcm does not depends on the &ing of the capability of i2s controller and codec. I was going through the soc-core.c and it seems that the capability exposed to user space only depends on the codec. If codec has both playback and capture capability ,then in user space both will be exported and hence cat /proc/asound/pcm will show two different devices one for playback and other for capture. In case codec has only playback capability, the o/p of the cat /proc/asound/pcm will contain only playback device.

So in case of three different i2s controller with different capability, separate codec are required.

Please correct me if I am wrong.

Best Regards
Rajeev

Quoted 9 lines
Quoted 8 lines

Best Regards
~Rajeev

Quoted 2 lines

Best Regards
~Rajeev

#15 lore raw

Re: Exporting playback and capture capability to user space

In reply to Rajeev kumar
Quoted 1 line · Rajeev kumar

Could you please help me by answering these questions?

I replied to your mail on the day it was originally posted.