欢迎来到天天文库
浏览记录
ID:47105412
大小:197.00 KB
页数:36页
时间:2019-08-04
《Linux声卡驱动分析》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Linuxsoc声卡构架分析(DMA)以S3C2440为例进行分析,对应的文件linux-2.6.32.2/sound/soc/s3c24xx/s3c24xx_uda134x.c其中module_init入口内容为:357staticint__inits3c24xx_uda134x_init(void)358{359returnplatform_driver_register(&s3c24xx_uda134x_driver);360}359行是一个平台驱动的注册函数,注册的驱动是s3c24xx_uda134x_driver。内容如下:348statics
2、tructplatform_drivers3c24xx_uda134x_driver={349.probe=s3c24xx_uda134x_probe,350.remove=s3c24xx_uda134x_remove,351.driver={352.name="s3c24xx_uda134x",353.owner=THIS_MODULE,354},355};由上面的name="s3c24xx_uda134x"可知,这个驱动对应的平台设备早在系统启动时在dev_init中注册进来了,所以接下来的事情就是直接调用probe方法。290staticints3
3、c24xx_uda134x_probe(structplatform_device*pdev)291{292intret;293294printk(KERN_INFO"S3C24XX_UDA134XSoCAudiodriver");295296s3c24xx_uda134x_l3_pins=pdev->dev.platform_data;297if(s3c24xx_uda134x_l3_pins==NULL){298printk(KERN_ERR"S3C24XX_UDA134XSoCAudio:"299"unabletofindplatformdat
4、a");300return-ENODEV;301}302s3c24xx_uda134x.power=s3c24xx_uda134x_l3_pins->power;303s3c24xx_uda134x.model=s3c24xx_uda134x_l3_pins->model;304305if(s3c24xx_uda134x_setup_pin(s3c24xx_uda134x_l3_pins->l3_data,306"data")<0)307return-EBUSY;308if(s3c24xx_uda134x_setup_pin(s3c24xx_uda1
5、34x_l3_pins->l3_clk,309"clk")<0){310gpio_free(s3c24xx_uda134x_l3_pins->l3_data);311return-EBUSY;312}313if(s3c24xx_uda134x_setup_pin(s3c24xx_uda134x_l3_pins->l3_mode,314"mode")<0){315gpio_free(s3c24xx_uda134x_l3_pins->l3_data);316gpio_free(s3c24xx_uda134x_l3_pins->l3_clk);317retur
6、n-EBUSY;318}319320s3c24xx_uda134x_snd_device=platform_device_alloc("soc-audio",-1);321if(!s3c24xx_uda134x_snd_device){322printk(KERN_ERR"S3C24XX_UDA134XSoCAudio:"323"Unabletoregister");324return-ENOMEM;325}326327platform_set_drvdata(s3c24xx_uda134x_snd_device,328&s3c24xx_uda134
7、x_snd_devdata);329s3c24xx_uda134x_snd_devdata.dev=&s3c24xx_uda134x_snd_device->dev;330ret=platform_device_add(s3c24xx_uda134x_snd_device);331if(ret){332printk(KERN_ERR"S3C24XX_UDA134XSoCAudio:Unabletoadd");333platform_device_put(s3c24xx_uda134x_snd_device);334}335336returnret;3
8、37}305-318行就是设置udal34x要用的gpio引脚的功能。320-3
此文档下载收益归作者所有