All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Giuliano Pochini <pochini@shiny.it>
Cc: alsa-devel <alsa-devel@lists.sourceforge.net>
Subject: Re: hw_rule
Date: Fri, 09 May 2003 16:27:43 +0200	[thread overview]
Message-ID: <s5hbrycb3fk.wl@alsa2.suse.de> (raw)
In-Reply-To: <1052435969.2728.15.camel@Jay>

At 08 May 2003 23:19:28 +0000,
Giuliano Pochini wrote:
> 
> 
> I wrote this rule:
> 
> 
> static int hw_rule_format_set_channels(snd_pcm_hw_params_t *params,
> snd_pcm_hw_rule_t *rule) {
>   snd_interval_t *c=hw_param_interval(params,
> SNDRV_PCM_HW_PARAM_CHANNELS);
>   snd_mask_t *f=hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
>   snd_interval_t ch;
> 
>   printk("Rule f=%x %x %x\n", f->bits[0], f->bits[1], f->bits[2]);
>   memset(&ch, 0, sizeof(ch));
> 
>   // S32_BE is mono only
>   if (f->bits[0]==SNDRV_PCM_FMTBIT_S32_BE) {
>     ch.min=1;
>     ch.max=1;
>     ch.integer=1;
>     return(snd_interval_refine(c, &ch));
>   }
>   // U8 and S16_LE are stereo only
>   if (f->bits[0]==SNDRV_PCM_FMTBIT_U8 ||
>       f->bits[0]==SNDRV_PCM_FMTBIT_S16_LE) {
>     ch.min=2;
>     ch.max=2;
>     ch.integer=1;
>     return(snd_interval_refine(c, &ch));
>   }
>   // S32_LE supports any number of channels.
>   return(0);
> }
> 
> 
> It seems to work, but since it's based on other drivers (no docs...),
> there are some thing I don't know:
> - Is f->bits[0] correct ?  All formats supported by the card are < 31. I
> suppose formats >=32 go in bits[1], isn't it ?

yes.  but over 32 is rarely used.

> - what are ch.openmin, openmax, empty ?  They are taken into account
> because if I don't clear the structure the rule doesn't work anymore.

openmin/openmax are the minimum and maximum value but the
configuration cannot be exactly these values.
empty is set if the configuration is empty.

> - How many stupid bugs are there ? :)

i see only subtle issues.
it's better to use snd_interval_any() instead of memset().
the resultant interval_t would accept all values.

the constraint for the another direction would be needed, too,
that is, the constraint for the channels which checks the acceptable
formats from the current values.


ciao,

Takashi


-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com

  reply	other threads:[~2003-05-09 14:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-08 23:19 hw_rule Giuliano Pochini
2003-05-09 14:27 ` Takashi Iwai [this message]
2003-05-09 17:04   ` hw_rule Abramo Bagnara
2003-05-10 11:59   ` hw_rule Giuliano Pochini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hbrycb3fk.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=pochini@shiny.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.