hw_rule
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 ?
- 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.
- How many stupid bugs are there ? :)
Bye.
-------------------------------------------------------
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
At 08 May 2003 23:19:28 +0000,
Quoted 35 lines · Giuliano Pochini
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_tch;printk("Rule f=%x %x %x\n", f->bits[0], f->bits[1], f->bits[2]); memset(&ch, 0, sizeof(ch));//
S32_BEis mono onlyif (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_LEsupports any number of channels.
return(0);
}
Quoted 4 lines
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.
Quoted 2 lines
- 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.
Quoted 1 line
- 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
Takashi Iwai ha scritto:
Quoted 11 lines
At 08 May 2003 23:19:28 +0000,
Quoted 4 lines · Giuliano Pochini
- 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.
Not exactly: openmin/openmax are the flags that, when set to true, means that min/max are not valid value of the numeric interval.
They're sensible only for non integer intervals.
As an example the interval 44100.1 - 48000.4 is represented as an interval 44100 - 48001 with both boundaries open.
Signature · 12 lines
Abramo Bagnara mailto:[email protected] Opera Unica Phone: +39.546.656023 Via Emilia Interna, 140 48014 Castel Bolognese (RA) - Italy ------------------------------------------------------- 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
Quoted 5 lines · Takashi Iwai
Quoted 1 line
- How many stupid bugs are there ? :)
i see only subtle issues.
it's better to usesnd_interval_any()instead ofmemset(). the resultantinterval_twould accept all values.
Done, tnx.
rme9652.c::snd_rme9652_hw_rule_*() functions do not initialize the structures. They may fail, unless I'm missing something.
Quoted 3 lines
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.
Yes, of course.
Bye.
-------------------------------------------------------
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