[alsa-devel] snd_pcm_hardware_t.info question

Takashi Iwai tiwai at suse.de
Wed Apr 18 19:01:52 CEST 2007


At Wed, 18 Apr 2007 07:14:42 -0700 (PDT),
Ciaccia wrote:
> 
> Takashi,
> I look through the code, I found some interesting
> examples...
> 
> Instead of defining a 2 as a min number of channel,
> could I use the following code?
> 
> static int ep93xx_ioctl(struct snd_pcm_substream
> *substream, unsigned int cmd, void *arg)
> {
> 	if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO )
> 	{
> 		struct snd_pcm_channel_info *info=arg;
> 		info->offset = 0;
> 		info->first = info->channel * 32;
> 		info->step = 64;
> 		return 0;
> 	}
> 
>     return snd_pcm_lib_ioctl(substream, cmd, arg);
> }
> 
> Would that work? Or should I always support stereo
> even when not needed?

Yes, this would work.  But, I'm not sure whether all apps work well
with this setting because this feature is used by only few drivers.
So, I recommend first try to use the stereo only, then try this after
that.


Takashi

> Ciao
> Andrea
> 
> --- Takashi Iwai <tiwai at suse.de> wrote:
> 
> > At Tue, 17 Apr 2007 04:36:28 -0700 (PDT),
> > Ciaccia wrote:
> > > 
> > > Hi Takashi,
> > > Thanks for your explanation. My request was not
> > clear,
> > > since my understanding of ALSA is lacking and I
> > need
> > > to understand more...
> > > 
> > > The driver I currently have is here:
> > > http://www.pecore.ch/test/ep93xx-i2s.c.txt
> > > 
> > > It's really messy, it performs all the format
> > > conversions in the driver (they could be done in
> > the
> > > alsa-lib) and it lacks some functionalities, so I
> > > would like to make it shorter, better and more
> > > readable.
> > > 
> > > The driver does not currently define
> > > SNDRV_PCM_INFO_MMAP and the memory is copied in
> > the
> > > copy callback. I would like to delete the copy
> > > callback (which is not really used), since the
> > samples
> > > could be written directly to the dma buffer by
> > > alsa-lib.
> > > 
> > > How does alsa-lib know how to store the samples in
> > the
> > > dma-buffer?
> > 
> > Based on the information the driver gives: access,
> > formats, channels,
> > etc.
> > 
> > > How does alsa-lib know that the samples
> > > are interleaved,
> > 
> > access has SNDRV_PCM_ACCESS_{MMAP|RW}_INTERLEAVED.
> > 
> > > occupy 32 bits each one (even if the
> > > format is 24 bits) and that the left channel
> > samples
> > > are at index #0 and the left ones at index #1?
> > 
> > formats has SNDRV_PCM_FMTBIT_S16_{LE|BE}.
> > 
> > >  Or that
> > > between two consecutive samples in mono there
> > should
> > > be a 4 bytes gap?
> > 
> > It's possible to support a non-standard stream like
> > that, but it's a
> > bit complicated.  So, I recommend not to support
> > this first
> > (i.e. channels_max = channels_min = 2).  Then
> > alsa-lib will copy the
> > mono stream automatically to stereo.
> > 
> > 
> > Takashi
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


More information about the Alsa-devel mailing list