dio_clear_dma(&input_stream,&s3c2410iis_dma_in);
57 }
59 audio_dev_dsp = register_sound_dsp(&smdk2410_audio_fops, -1); //
-->sound_insert_unit(&chains[3], fops, dev, 3, 131,
"dsp", S_IWUSR | S_IRUSR, NULL);
60 audio_dev_mixer = register_sound_mixer(&smdk2410_mixer_fops, -1); //
-->sound_insert_unit(&chains[0], fops, dev, 0, 128,
"mixer", S_IRUSR | S_IWUSR, NULL);
61 ......
}
其中, /dev/dsp
设备节点,实现音频的输入输出
IIS
接口(由
chains[3]
数组获得)
/dev/mixer
设备节点,实现音量调节、高音等控制(由
chains[0]
数组获得)
audio_dev_dsp = register_sound_dsp(&smdk2410_audio_fops, -1);
audio_dev_mixer = register_sound_mixer(&smdk2410_mixer_fops, -1);注册了这两个设备节点和file_operation供上层驱动函数调用;
static struct sound_unit *chains[SOUND_STEP];
/*
* Allocations
* 0 *16 Mixers
* 1 *8 Sequencers
* 2 *16 Midi
* 3 *16 DSP
* 4 *16 SunDSP
* 5 *16 DSP16
* 6 -- sndstat (obsolete)
* 7 *16 unused
* 8 -- alternate sequencer (see above)
* 9 *16 raw synthesizer access
* 10 *16 unused
* 11 *16 unused
* 12 *16 unused
* 13 *16 unused
* 14 *16 unused
* 15 *16 unused
*/
接下来,看一次操作函数,源码程序:linux-2.6.22.6\sound\Sound_core.c,(也可从该源码看起,再看sound\soc\s3c24xx\s3c2410-uda1341.c程序
),
仅有一个
open
往后程序可得其他的操作函数:
static const struct file_operations soundcore_fops=
{
/* We must have an owner or the module locking fails */
.owner = THIS_MODULE,
.open = soundcore_open,
};
1 int soundcore_open(struct inode *inode, struct file *file)
2 {
3 int chain;
4 int unit = iminor(inode);
5 struct sound_unit *s;
6 const struct file_operations *new_fops = NULL;
7
8 chain=unit&0x0F;
9 if(chain==4 || chain==5) /* dsp/audio/dsp16 */
10 {
11 unit&=0xF0;
12 unit|=3;
13 chain=3;
14 }
15
16 spin_lock(&sound_loader_lock);
17 s = __look_for_unit(chain, unit);
18 if (s)
19 new_fops = fops_get(s->unit_fops);
20 if (!new_fops) {
21 spin_unlock(&sound_loader_lock);
22 request_module("sound-slot-%i", unit>>4);
23 request_module("sound-service-%i-%i", unit>>4, chain);
24 spin_lock(&sound_loader_lock);
25 s = __look_for_unit(chain, unit);
26 if (s)
27 new_fops = fops_get(s->unit_fops);
28 }
29 if (new_fops) {
30 int err = 0;
31 const struct file_operations *old_fops = file->f_op;
32 file->f_op = new_fops;
33 spin_unlock(&sound_loader_lock);
34 if(file->f_op->open)
35 err = file->f_op->open(inode,file);
36 if (err) {
37 fops_put(file->f_op);
38 file->f_op = fops_get(old_fops);
39 }
40 fops_put(old_fops);
41 return err;
42 }
43 spin_unlock(&sound_loader_lock);
44 return -ENODEV;
45 }
函数框架:app: open () // 假设主设备号为14
soundcore_open函数
--> int unit = iminor(inode);
s = __look_for_unit(chain, unit);
// 从chains数组里得到, 谁来设置这个数组? &nb