* Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc?
@ 2010-12-28 7:20 Philip Chu
2010-12-28 7:31 ` Jassi Brar
0 siblings, 1 reply; 6+ messages in thread
From: Philip Chu @ 2010-12-28 7:20 UTC (permalink / raw)
To: alsa-devel@alsa-project.org
Hi all ALSA experts,
I am seeing a weird behavior of ALSA API lib 1.0.23, i.e., when I use SND_PCM_FORMAT_S32_LE, I am seeing that the data format is still configured as SND_PCM_FORMAT_S16_LE and passed to kernel driver layer.
The code I am using is shown below:
====================================================================================
snd_pcm_t *capture_handle;
rc = snd_pcm_open(&capture_handle, devName, SND_PCM_STREAM_CAPTURE, 0 /*SND_PCM_NONBLOCK*/); /* */
if (rc < 0) {
fprintf(stderr, "unable to open pcm device: %s\n", snd_strerror(rc));
exit(1);
}
/* Allocate a hardware parameters object. */
snd_pcm_hw_params_malloc(&hw_params);
/* Fill it in with default values. */
snd_pcm_hw_params_any(capture_handle, hw_params);
/* Set the desired hardware parameters. */
/* Interleaved mode 2-channel*/
snd_pcm_hw_params_set_access(capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED); /* each frame left->right->left->right */
/* Signed 32-bit little-endian format */
snd_pcm_hw_params_set_format(capture_handle, hw_params, SND_PCM_FORMAT_S32_LE);
//snd_pcm_hw_params_set_format(HANDLE(direction), hw_params, SND_PCM_FORMAT_S16_LE);
/* Two channels (stereo) */
if( (rc=snd_pcm_hw_params_set_channels(capture_handle, hw_params, 2))<0) {
fprintf(stderr, "cannot set channel count 2\n");
exit(1);
}
int sample_rate = rate; /* The sample rate is 50000 */
snd_pcm_hw_params_set_rate_near(capture_handle, hw_params, &sample_rate, &dir);
if (sample_rate != rate) {
fprintf(stderr, "The rate %d Hz is not supported by your hardware.\n ==> Using %d Hz instead.\n", rate, sample_rate);
}
frames = 32;
/* Set period size to 32 frames. */
snd_pcm_hw_params_set_period_size_near(capture_handle, hw_params, &frames, &dir);
int periods = 2; /* Number of periods */
snd_pcm_uframes_t buffersize = periods*frames; /* Periodsize (bytes) */
/* Set buffer size (in frames). The resulting latency is given by */
/* latency = periodsize * periods / (rate * bytes_per_frame) */
if (snd_pcm_hw_params_set_buffer_size(capture_handle, hw_params, buffersize) < 0) { /* 2 period as buffer size*/
fprintf(stderr, "Error setting buffersize.\n");
return(-1);
}
/* Write the parameters to the driver */
rc = snd_pcm_hw_params(capture_handle, hw_params); /* call into kernel snd_pcm_common_ioctl1 */
if (rc < 0) {
fprintf(stderr, "unable to set hw parameters: %s\n", snd_strerror(rc));
exit(1);
}
Unsigned long buffer[1024];
memset(buffer, 0x0, sizeof(buffer)); /* Pre-set the data */
/* Start data transmission now */
/* Returns the number of frames actually written. */
snd_pcm_prepare(capture_handle); /* Need this if there are too many printf lines to interrupt the process */
/* Start receiving data from FPGA now */
/* Returns the number of frames actually read. */
rc = snd_pcm_readi(handle, buffer, frames);
The data read back looks like 0x????0000, which only has half content of 32-bit format.
Is there anything wrong with my code?
Any help will be appreciated.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc?
2010-12-28 7:20 Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc? Philip Chu
@ 2010-12-28 7:31 ` Jassi Brar
2010-12-28 7:35 ` Philip Chu
0 siblings, 1 reply; 6+ messages in thread
From: Jassi Brar @ 2010-12-28 7:31 UTC (permalink / raw)
To: Philip Chu; +Cc: alsa-devel@alsa-project.org
On Tue, Dec 28, 2010 at 4:20 PM, Philip Chu <Philip.Chu@logicpd.com> wrote:
> Hi all ALSA experts,
>
> I am seeing a weird behavior of ALSA API lib 1.0.23, i.e., when I use SND_PCM_FORMAT_S32_LE, I am seeing that the data format is still configured as SND_PCM_FORMAT_S16_LE and passed to kernel driver layer.
Perhaps your hardware doesn't support S32_LE, and your application
uses 'plughw' ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc?
2010-12-28 7:31 ` Jassi Brar
@ 2010-12-28 7:35 ` Philip Chu
2010-12-28 14:02 ` Peter Ujfalusi
0 siblings, 1 reply; 6+ messages in thread
From: Philip Chu @ 2010-12-28 7:35 UTC (permalink / raw)
To: Jassi Brar; +Cc: alsa-devel@alsa-project.org
Thanks for your reply.
Yes I am using plughw - "plughw:0,0" and OMAP3530 Torpedo board. And I am attaching my own sound card driver on McBSP 3.
Philip
-----Original Message-----
From: Jassi Brar [mailto:jassisinghbrar@gmail.com]
Sent: Tuesday, December 28, 2010 2:31 AM
To: Philip Chu
Cc: alsa-devel@alsa-project.org
Subject: Re: [alsa-devel] Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc?
On Tue, Dec 28, 2010 at 4:20 PM, Philip Chu <Philip.Chu@logicpd.com> wrote:
> Hi all ALSA experts,
>
> I am seeing a weird behavior of ALSA API lib 1.0.23, i.e., when I use SND_PCM_FORMAT_S32_LE, I am seeing that the data format is still configured as SND_PCM_FORMAT_S16_LE and passed to kernel driver layer.
Perhaps your hardware doesn't support S32_LE, and your application
uses 'plughw' ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc?
2010-12-28 7:35 ` Philip Chu
@ 2010-12-28 14:02 ` Peter Ujfalusi
2010-12-28 16:22 ` Philip Chu
0 siblings, 1 reply; 6+ messages in thread
From: Peter Ujfalusi @ 2010-12-28 14:02 UTC (permalink / raw)
To: ext Philip Chu; +Cc: alsa-devel@alsa-project.org, Jassi Brar
On 12/28/2010 09:35 AM, ext Philip Chu wrote:
> Thanks for your reply.
>
> Yes I am using plughw - "plughw:0,0" and OMAP3530 Torpedo board. And I am attaching my own sound card driver on McBSP 3.
The OMAP McBSP DAI has support for S32_LE format.
I have added S32_LE/24 support for the twl4030 codec, and it
is working fine.
I think your codec driver does not support the S32_LE format.
--
Péter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc?
2010-12-28 14:02 ` Peter Ujfalusi
@ 2010-12-28 16:22 ` Philip Chu
2010-12-28 16:46 ` Peter Ujfalusi
0 siblings, 1 reply; 6+ messages in thread
From: Philip Chu @ 2010-12-28 16:22 UTC (permalink / raw)
To: Peter Ujfalusi; +Cc: alsa-devel@alsa-project.org, Jassi Brar
I also added S32_LE support for twl4030 codec. But the thing is, the user land ALSA API is still asking for S16_LE (observed from the pcm_native.c from kernel) even when I am using SND_PCM_FORMAT_S32_LE in my application code as shown in my 1st post.
Philip
-----Original Message-----
From: Peter Ujfalusi [mailto:peter.ujfalusi@nokia.com]
Sent: Tuesday, December 28, 2010 9:03 AM
To: Philip Chu
Cc: Jassi Brar; alsa-devel@alsa-project.org
Subject: Re: [alsa-devel] Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc?
On 12/28/2010 09:35 AM, ext Philip Chu wrote:
> Thanks for your reply.
>
> Yes I am using plughw - "plughw:0,0" and OMAP3530 Torpedo board. And I am attaching my own sound card driver on McBSP 3.
The OMAP McBSP DAI has support for S32_LE format.
I have added S32_LE/24 support for the twl4030 codec, and it
is working fine.
I think your codec driver does not support the S32_LE format.
--
Péter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-12-28 16:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-28 7:20 Why is SND_PCM_FORMAT_S32_LE not able to be set and passed to Linux Kernel Asoc? Philip Chu
2010-12-28 7:31 ` Jassi Brar
2010-12-28 7:35 ` Philip Chu
2010-12-28 14:02 ` Peter Ujfalusi
2010-12-28 16:22 ` Philip Chu
2010-12-28 16:46 ` Peter Ujfalusi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.