[alsa-devel] snd_pcm_hardware structure
Hello,
I am developing a ALSA driver for the AtlasIII AC'97 Controller. The AC'97 Controller FIFO is arranged as 16 32-bit entries. My PCM data would be 16-bit samples and the driver will cater to 2-front channel audio. I have configured the snd_pcm_hardware members as follows: .formats = SNDDRV_PCM_FMTBIT_S16_LE .period_bytes_max = 4, .period_bytes_min = 64, As I would need a minimum of 4-byte sample to be transferred and the "period_bytes_max" value has been set considering the maximum size of the FIFO in bytes. Is my understanding correct in doing these settings?
Secondly, I am having slight problems in understanding the "snd_pcm_hardware" members periods_min and periods_max. Can anyone throw some more light on this in addition to what is explained in the "Writing an Audio Driver"?
Regards; Aadish
On 23 June 2010 18:22, Adish Kuvelker adkuvi@gmail.com wrote:
Hello,
I am developing a ALSA driver for the AtlasIII AC'97 Controller. The AC'97 Controller FIFO is arranged as 16 32-bit entries. My PCM data would be 16-bit samples and the driver will cater to 2-front channel audio. I have configured the snd_pcm_hardware members as follows: .formats = SNDDRV_PCM_FMTBIT_S16_LE .period_bytes_max = 4, .period_bytes_min = 64, As I would need a minimum of 4-byte sample to be transferred and the "period_bytes_max" value has been set considering the maximum size of the FIFO in bytes. Is my understanding correct in doing these settings?
Secondly, I am having slight problems in understanding the "snd_pcm_hardware" members periods_min and periods_max. Can anyone throw some more light on this in addition to what is explained in the "Writing an Audio Driver"?
max should = 64 min should = 4
periods_min and periods_max is dependent on when the sound card interrupts the CPU. So, if the CPU gets an interrupt once every 16 samples, then periods_min = periods_max = 1 If the sound card does not interrupt the CPU at all, you have to provide a method to notify the CPU when to next fill the FIFO.
Hello James, Thanks a lot....Just a typo error for the period_bytes_min and period_bytes_max in my mail.....
Now that my FIFO is 64 bytes and if I need an interrupt to the CPU for FIFO being half-empty (i.e 32 bytes = 16 16-bit samples), would it be right to set the periods_min = periods_max = 32?
Regards, Aadish
On Wed, Jun 23, 2010 at 11:15 PM, James Courtier-Dutton james.dutton@gmail.com wrote:
On 23 June 2010 18:22, Adish Kuvelker adkuvi@gmail.com wrote:
Hello,
I am developing a ALSA driver for the AtlasIII AC'97 Controller. The AC'97 Controller FIFO is arranged as 16 32-bit entries. My PCM data would be 16-bit samples and the driver will cater to 2-front channel audio. I have configured the snd_pcm_hardware members as follows: .formats = SNDDRV_PCM_FMTBIT_S16_LE .period_bytes_max = 4, .period_bytes_min = 64, As I would need a minimum of 4-byte sample to be transferred and the "period_bytes_max" value has been set considering the maximum size of the FIFO in bytes. Is my understanding correct in doing these settings?
Secondly, I am having slight problems in understanding the "snd_pcm_hardware" members periods_min and periods_max. Can anyone throw some more light on this in addition to what is explained in the "Writing an Audio Driver"?
max should = 64 min should = 4
periods_min and periods_max is dependent on when the sound card interrupts the CPU. So, if the CPU gets an interrupt once every 16 samples, then periods_min = periods_max = 1 If the sound card does not interrupt the CPU at all, you have to provide a method to notify the CPU when to next fill the FIFO.
On 23 June 2010 18:57, Adish Kuvelker adkuvi@gmail.com wrote:
Hello James, Thanks a lot....Just a typo error for the period_bytes_min and period_bytes_max in my mail.....
Now that my FIFO is 64 bytes and if I need an interrupt to the CPU for FIFO being half-empty (i.e 32 bytes = 16 16-bit samples), would it be right to set the periods_min = periods_max = 32?
No. The periods do not create the interrupt. Your sound hardware has to do the interrupt. When does you hardware do the interrupt?
yes...I know that my hardware will generate the interrupt and it will be at FIFO being half empty.
On Thu, Jun 24, 2010 at 12:17 AM, James Courtier-Dutton james.dutton@gmail.com wrote:
On 23 June 2010 18:57, Adish Kuvelker adkuvi@gmail.com wrote:
Hello James, Thanks a lot....Just a typo error for the period_bytes_min and period_bytes_max in my mail.....
Now that my FIFO is 64 bytes and if I need an interrupt to the CPU for FIFO being half-empty (i.e 32 bytes = 16 16-bit samples), would it be right to set the periods_min = periods_max = 32?
No. The periods do not create the interrupt. Your sound hardware has to do the interrupt. When does you hardware do the interrupt?
so I am thinking of sound hardware generating an interrupt at the FIFO having 32-bytes. In your first reply did you mean that periods_min = periods_max =1 would be the setting correponding to my hardware initializations to generate an interrupt after 16 16-bit samples having been transferred? So considering that the FIFO bank is of 64 bytes, what do you think would be the setting for periods_min and periods_max?
Regards; Aadish
On Thu, Jun 24, 2010 at 1:56 AM, Adish Kuvelker adkuvi@gmail.com wrote:
yes...I know that my hardware will generate the interrupt and it will be at FIFO being half empty.
On Thu, Jun 24, 2010 at 12:17 AM, James Courtier-Dutton james.dutton@gmail.com wrote:
On 23 June 2010 18:57, Adish Kuvelker adkuvi@gmail.com wrote:
Hello James, Thanks a lot....Just a typo error for the period_bytes_min and period_bytes_max in my mail.....
Now that my FIFO is 64 bytes and if I need an interrupt to the CPU for FIFO being half-empty (i.e 32 bytes = 16 16-bit samples), would it be right to set the periods_min = periods_max = 32?
No. The periods do not create the interrupt. Your sound hardware has to do the interrupt. When does you hardware do the interrupt?
On 23 June 2010 21:26, Adish Kuvelker adkuvi@gmail.com wrote:
yes...I know that my hardware will generate the interrupt and it will be at FIFO being half empty.
In that case the full buffer is 64, but you have the following parameters: .period_bytes_min = 4, .period_bytes_max = 32, .periods_min = 2, .periods_max = 2
A period is how far through the buffer one goes until an interrupt happens. So, if the interrupt happens one each half FIFO, one has two periods per buffer.
Kind Regards
James
Thanks a lot James
Regards; Aadish
On Thu, Jun 24, 2010 at 2:43 AM, James Courtier-Dutton james.dutton@gmail.com wrote:
On 23 June 2010 21:26, Adish Kuvelker adkuvi@gmail.com wrote:
yes...I know that my hardware will generate the interrupt and it will be at FIFO being half empty.
In that case the full buffer is 64, but you have the following parameters: .period_bytes_min = 4, .period_bytes_max = 32, .periods_min = 2, .periods_max = 2
A period is how far through the buffer one goes until an interrupt happens. So, if the interrupt happens one each half FIFO, one has two periods per buffer.
Kind Regards
James
participants (2)
-
Adish Kuvelker
-
James Courtier-Dutton