为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > cs4344 DAC驱动程序

cs4344 DAC驱动程序

2022-12-22 1页 doc 12KB 19阅读

用户头像 个人认证

is_017931

热爱锻炼

举报
cs4344 DAC驱动程序/**sound/soc/codecs/cs4344.cCS4344--SoCaudiodriver*Thisprogramisfreesoftware;youcanredistributeitand/ormodifyitunderthetermsoftheGNUGeneralPublicLicenseversion2aspublishedbytheFreeSoftwareFoundation.**/includeinclude#include#include#include#include#include#include#i...
cs4344 DAC驱动程序
/**sound/soc/codecs/cs4344.cCS4344--SoCaudiodriver*Thisprogramisfreesoftware;youcanredistributeitand/ormodifyitunderthetermsoftheGNUGeneralPublicLicenseversion2aspublishedbytheFreeSoftwareFoundation.**/includeinclude#include#include#include#include#include#include#include#include#includeinclude#include#defineAUDIO_NAME"CS4344"#ifdefCS4344_DEBUG#definedbg(format,arg...)\printk(KERN_DEBUGAUDIO_NAME":"format"\n",##arg)#else#definedbg(format,arg...)do{}while(0)#endif#defineerr(format,arg...)\printk(KERN_ERRAUDIO_NAME":"format"\n",##arg)#defineinfo(format,arg...)\printk(KERN_INFOAUDIO_NAME":"format"\n",##arg)#definewarn(format,arg...)\printk(KERN_WARNINGAUDIO_NAME":"format"\n",##arg)/*TherearenosoftwarecontrolsforDACsotheyneedtobefaked*/#defineCS4344_DUMMY_CTRL0x00/*DACChannelDummyControl*/staticstructstructsnd_soc_codec*cs4344_codec=NULL;snd_kcontrol_newcs4344_snd_controls[]={SOC_SINGLE("Control",CS4344_DUMMY_CTRL,0,0xFF,1)};staticunsignedintcs4344_read_reg(structsnd_soc_codec*codec,unsignedintreg){return0;}staticintcs4344_write_reg(structsnd_soc_codec*codec,unsignedintreg,unsignedintvalue){return0;}staticintcs4344_pcm_hw_params(structsnd_pcm_substream*substream,structsnd_pcm_hw_params*params){return0;}staticintcs4344_mute(structsnd_soc_dai*dai,intmute){return0;}staticintcs4344_set_dai_fmt(structsnd_soc_dai*codec_dai,unsignedintfmt){return0;}staticintcs4344_set_dai_sysclk(structsnd_soc_dai*codec_dai,intclk_id,unsignedintfreq,intdir){return0;}#defineCS4344_RATES(SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_22050|SNDRV_PCM_RATE_44100|\SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)#defineCS4344_FORMATS(SNDRV_PCM_FMTBIT_S16_LE|SNDRV_PCM_FMTBIT_S20_3LE|\SNDRV_PCM_FMTBIT_S24_LE)staticstructsnd_soc_dai_opscs4344_dai_ops={.hw_params=cs4344_pcm_hw_params,.set_fmt=cs4344_set_dai_fmt,};structsnd_soc_daics4344_dai={.name="CS4344”,.playback={.stream_name="Playback",.channels_min=1,.channels_max=2,.rates=CS4344_RATES,.formats=CS4344_FORMATS,},.ops=&cs4344_dai_ops,};EXPORT_SYMBOL_GPL(cs4344_dai);staticintcs4344_suspend(structplatform_device*pdev,pm_message_tstate){return0;}staticintcs4344_resume(structplatform_device*pdev){return0;}staticintcs4344_soc_probe(structplatform_device*pdev){structsnd_soc_device*socdev=platform_get_drvdata(pdev);structsnd_soc_codec*codec=cs4344_codec;intret=0;inti=0;printk("******startedcs4344******\n");BUG_ON(cs4344_codec==NULL);socdev->card->codec=cs4344_codec;/*registerpcms*/ret=snd_soc_new_pcms(socdev,SNDRV_DEFAULT_IDX1,SNDRV_DEFAULT_STR1);if(ret<0){printk(KERN_ERR"cs4344:failedtocreatepcms\n");gotopcm_err;}for(i=0;icard,kctrl);if(ret<0){printk(KERN_ERR"cs4344:failedtoaddcontrol\n");gotocard_err;}}returnret;card_err:snd_soc_free_pcms(socdev);snd_soc_dapm_free(socdev);pcm_err:returnret;}staticintcs4344_probe(structplatform_device*pdev){structsnd_soc_codec*codec=NULL;intret=-1;unsignedchar*cs4344_dummy_reg=NULL;codec=kzalloc(sizeof(structsnd_soc_codec),GFP_KERNEL);if(codec==NULL)return-ENOMEM;codec->dev=&pdev->dev;mutex_init(&codec->mutex);INIT_LIST_HEAD(&codec->dapm_widgets);INIT_LIST_HEAD(&codec->dapm_paths);codec->name="cs4344";codec->owner=THIS_MODULE;codec->read=cs4344_read_reg;codec->write=cs4344_write_reg;codec->dai=&cs4344_dai;/*allocateafakeregistercache*/cs4344_dummy_reg=kmalloc(PAGE_SIZE,GFP_KERNEL);if(!cs4344_dummy_reg){dev_err(codec->dev,"cs4344:failedtoallocateregistercache");gotoerror;}codec->reg_cache_size=PAGE_SIZE;codec->reg_cache=cs4344_dummy_reg;cs4344_codec=codec;ret=snd_soc_register_codec(codec);if(ret!=0){dev_err(codec->dev,"Failedtoregistercodec:%d\n",ret);gotoerr_codec;}ret=snd_soc_register_dai(&cs4344_dai);if(ret!=0){dev_err(codec->dev,"FailedtoregisterDAIs:%d\n",ret);gotoerr_dai;}returnret;errdai:errcodec:error:BUG();//TODOADDreturnret;}staticintcs4344_remove(structplatform_device*pdev){/*can'tturnoffdevice*/return0;}staticintcs4344_soc_remove(structplatform_device*pdev){structsnd_soc_device*socdev=platform_get_drvdata(pdev);snd_soc_free_pcms(socdev);snd_soc_dapm_free(socdev);return0;}structsnd_soc_codec_devicesoc_codec_dev_cs4344={.probe=cs4344_soc_probe,.remove=cs4344_soc_remove,.suspend=cs4344_suspend,.resume=cs4344_resume,};staticstructplatform_drivercs4344_device={.probe=cs4344_probe,.remove=cs4344_remove,.driver={.name="cs4344"}};staticint__initcs4344_mod_init(void){returnplatform_driver_register(&cs4344_device);}staticvoid__exitcs4344_exit(void){platform_driver_unregister(&cs4344_device);}module_init(cs4344_mod_init);module_exit(cs4344_exit);EXPORT_SYMBOL_GPL(soc_codec_dev_cs4344);MODULE_DESCRIPTION("ASoCCS4344driver");MODULE_AUTHOR("MarkF.Brown");MODULE_LICENSE("GPL");
/
本文档为【cs4344 DAC驱动程序】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索