设为首页 加入收藏

TOP

十七、S3C2440 音频解码芯片WM8976声卡驱动移植、madplay测试(二)
2019-09-01 23:08:19 】 浏览:114
Tags:十七 S3C2440 音频 解码 芯片 WM8976 声卡驱动 移植 madplay 测试
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

首页 上一页 1 2 3 4 5 6 下一页 尾页 2/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇linux中服务环境的搭建 下一篇浅谈TCP IP协议栈(二)IP地址

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目