Function | File |
---|---|
driver | sound/soc/codecs/ssm4567.c |
include | sound/soc/codecs/ssm4567.h |
For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.
For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.
UnlikePCIorUSBdevices,I2Cdevices are not enumerated at the hardware level. Instead, the software must know which devices are connected on eachI2Cbus segment, and what address these devices are using. For this reason, the kernel code must instantiateI2Cdevices explicitly. There are different ways to achieve this, depending on the context and requirements. However the most common method is to declare theI2Cdevices by bus number.
This method is appropriate when theI2Cbus is a system bus, as in many embedded systems, wherein eachI2Cbus has a number which is known in advance. It is thus possible to pre-declare theI2Cdevices that inhabit this bus. This is done with an array of struct i2c_board_info, which is registered by calling i2c_register_board_info().
So, to enable such a driver one need only edit the board support file by adding an appropriate entry to i2c_board_info.
For more information see:Documentation/i2c/instantiating-devices
TheI2Caddress of the SSM4567 depends on the setting of the ADDR pin.
ADDR | I2CAddress |
---|---|
0 | 0x34 |
1 | 0x35 |
staticstructi2c_board_info __initdata bfin_i2c_board_info[]={[--snip--]{I2C_BOARD_INFO("ssm4567",0x34),},[--snip--]}
staticint__init stamp_init(void){[--snip--]i2c_register_board_info(0,bfin_i2c_board_info,ARRAY_SIZE(bfin_i2c_board_info));[--snip--]return0;}arch_initcall(board_init);
i2s: i2c@41600000 { compatible = "...; ... #size-cells = <0>; #address-cells = <1>; ssm4567: ssm4567@34 { compatible = "adi,ssm4567"; reg = <0x34>; }; };
Name | Description |
---|---|
OUT | Class-D Amplifier Output |
Name | Description |
---|---|
DAC High Pass Filter Switch | Enables/Disables the high-pass filter for the DAC |
DAC Low Power Switch | Enables/Disables low-power mode of the DAC |
Master Playback Volume | Digital output volume control. |
Low-EMI Switch | Enables/Disables low EMI mode. |
Limiter Mode | Mode the output limiter is using. |
Limiter Attack Rate | Attack rate of the output limiter. |
Limiter Release Rate | Release rate of the output limiter. |
Limiter Attack Threshold | Attack threshold for the output limiter. |
Amplifier Boost Switch | Enables/Disables the output amplifier booster |
The amplifier driver registers one DAIs, one for each serial port. The DAI is named“ssm4567-hifi”
Name | Supported by driver | Description |
---|---|---|
SND_SOC_DAIFMT_I2S | yes | I2S mode |
SND_SOC_DAIFMT_RIGHT_J | no | Right Justified mode |
SND_SOC_DAIFMT_LEFT_J | yes | Left Justified mode |
SND_SOC_DAIFMT_DSP_A | yes | dataMSBafter FRM LRC |
SND_SOC_DAIFMT_DSP_B | yes | dataMSBduring FRM LRC |
SND_SOC_DAIFMT_AC97 | no | AC97 mode |
SND_SOC_DAIFMT_PDM | yes | Pulse density modulation |
SND_SOC_DAIFMT_NB_NF | yes | Normal bit- and frameclock |
SND_SOC_DAIFMT_NB_IF | yes | Normal bitclock, inverted frameclock |
SND_SOC_DAIFMT_IB_NF | yes | Inverted frameclock, normal bitclock |
SND_SOC_DAIFMT_IB_IF | yes | Inverted bit- and frameclock |
SND_SOC_DAIFMT_CBM_CFM | no | Codec bit- and frameclock master |
SND_SOC_DAIFMT_CBS_CFM | no | Codec bitclock slave, frameclock master |
SND_SOC_DAIFMT_CBM_CFS | no | Codec bitclock master, frameclock slave |
SND_SOC_DAIFMT_CBS_CFS | yes | Codec bit- and frameclock slave |
If you want to use the SSM4567 in TDM mode you can configure it using snd_soc_dai_set_tdm_slot() from you ASoC board driver.
The following restrictions apply to the parameters of snd_soc_dai_set_tdm_slot().
Example:
staticintssm4567_link_init(structsnd_soc_pcm_runtime*rtd){intret;ret=snd_soc_dai_set_tdm_slot(rtd->codec_dai,0x01,0x01,8,32);if(ret<0)returnret;return0;}staticstructsnd_soc_dai_link ssm4567_dai_link={...,.init=ssm4567_link_init,};
staticconststructsnd_soc_dapm_widget ssm4567_zed_widgets[]={SND_SOC_DAPM_SPK("Speaker",NULL),};staticconststructsnd_soc_dapm_route ssm4567_zed_routes[]={{"Speaker",NULL,"OUT"},};staticstructsnd_soc_dai_link ssm4567_zed_dai_link={.name="ssm4567",.stream_name="ssm4567",.codec_dai_name="ssm4567-hifi",.dai_fmt=SND_SOC_DAIFMT_DSP_A|SND_SOC_DAIFMT_NB_NF|SND_SOC_DAIFMT_CBS_CFS,.init=ssm4567_zed_init,};staticstructsnd_soc_card ssm4567_zed_card={.name="ZED SSM4567",.owner=THIS_MODULE,.dai_link=&zed_ssm4567_dai_link,.num_links=1,.dapm_widgets=zed_ssm4567_widgets,.num_dapm_widgets=ARRAY_SIZE(zed_ssm4567_widgets),.dapm_routes=zed_ssm4567_routes,.num_dapm_routes=ARRAY_SIZE(zed_ssm4567_routes),.fully_routed=true,};
This example shows how to setup a ASoC board driver for a system with two SSM4567, one driving the left speaker and the other driving the right speaker. In this example the left SSM4567 is atI2Caddress 0x34 (ADDR=0) and the right SSM4567 is at I2S address 0x35 (ADDR=1).
Note support for multiple CODECs on a single DAI link requires Linux v3.17 or higher.
staticintssm4567_link_init(structsnd_soc_pcm_runtime*rtd){intret;/* Slot 0 for left */ret=snd_soc_dai_set_tdm_slot(rtd->codec_dais[0],0x01,0x01,2,32);if(ret<0)returnret;/* Slot 2 for right */ret=snd_soc_dai_set_tdm_slot(rtd->codec_dais[1],0x02,0x02,2,32);if(ret<0)returnret;return0;}staticconststructsnd_soc_dapm_widget ssm4567_zed_widgets[]={SND_SOC_DAPM_SPK("Left Speaker",NULL),SND_SOC_DAPM_SPK("Right Speaker",NULL),};staticconststructsnd_soc_dapm_route ssm4567_zed_routes[]={{"Left Speaker",NULL,"Left OUT"},{"Right Speaker",NULL,"Right OUT"},};staticconstsnd_soc_dai_link_component ssm4567_zed_codec_components[]={{/* Left */.name="ssm4567.0-0034",.codec_dai_name="ssm4567-hifi",},{/* Right */.name="ssm4567.0-0035",.codec_dai_name="ssm4567-hifi",},};/* Assign prefix to avoid name conflicts */staticconststructsnd_soc_codec_conf ssm4567_zed_codec_conf[]={{.dev_name="ssm4567.0-0034",.name_prefix="Left",},{.dev_name="ssm4567.0-0035",.name_prefix="Right",},};staticstructsnd_soc_dai_link ssm4567_zed_dai_link={.name="ssm4567",.stream_name="ssm4567",.codecs=ssm4567_zed_codec_components,.num_codecs=ARRAY_SIZE(ssm4567_zed_codec_components),.codec_conf=ssm4567_zed_codec_conf,.num_configs=ARRAY_SIZE(ssm4567_zed_codec_conf),.dai_fmt=SND_SOC_DAIFMT_DSP_A|SND_SOC_DAIFMT_NB_NF|SND_SOC_DAIFMT_CBS_CFS,.init=ssm4567_link_init,};staticstructsnd_soc_card ssm4567_zed_card={.name="ZED SSM4567",.owner=THIS_MODULE,.dai_link=&zed_ssm4567_dai_link,.num_links=1,.dapm_widgets=zed_ssm4567_widgets,.num_dapm_widgets=ARRAY_SIZE(zed_ssm4567_widgets),.dapm_routes=zed_ssm4567_routes,.num_dapm_routes=ARRAY_SIZE(zed_ssm4567_routes),.fully_routed=true,};
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表德赢Vwin官网 网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。举报投诉
全部0条评论
快来发表一下你的评论吧 !