×

SM2518声音Linux漂流器

消耗积分:3 | 格式:pdf | 大小:75.39KB | 2021-04-21

万物死

分享资料个

This version (09 Sep 2019 10:17) was approved by Michael Hennerich.The Previously approved version (08 Jun 2016 20:14) is available.Diff

SSM2518 Sound CODEC Linux Driver

Supported Devices

Reference Circuits

Evaluation Boards

Source Code

Status

Source Mainlined?
git Yes

Files

Example device initialization

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.

21 Oct 2010 16:10

Declaring I2C devices

Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each I2C bus segment, and what address these devices are using. For this reason, the kernel code must instantiate I2C devices explicitly. There are different ways to achieve this, depending on the context and requirements. However the most common method is to declare the I2C devices by bus number.

This method is appropriate when the I2C bus is a system bus, as in many embedded systems, wherein each I2C bus has a number which is known in advance. It is thus possible to pre-declare the I2C devices 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

21 Oct 2010 16:10

The I2C address of the SSM2518 depends on the setting of the ADDR pin

ADDR I2C Address
0 0x34
1 0x36
static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
 
	[--snip--]
	{
		I2C_BOARD_INFO("ssm2518", 0x34),
	},
	[--snip--]
}
static int __init stamp_init(void)
{
	[--snip--]
	i2c_register_board_info(0, bfin_i2c_board_info,
				ARRAY_SIZE(bfin_i2c_board_info));
	[--snip--]
 
	return 0;
}
arch_initcall(board_init);

Devicetree

i2s: i2c@41600000 {
	compatible = "...;
	...

	#size-cells = <0>;
	#address-cells = <1>;
            
	ssm2518: ssm2518@34 {
		compatible = "adi,ssm2518";
		reg = <0x34>;
		gpios = <&gpio 5 0>;
	};
};

ASoC DAPM Widgets

Name Description
OUTL Output for Left Channel
OUTR Output for Right Channel

ALSA Controls

Name Description
Playback De-emphasis Switch Enable/Disable de-emphasis
Master Playback Volume DAC Volume Control
Master Playback Switch Unmutes/Mutes the DAC output
Amp Low Power Mode Switch Enables/Disables the lower power mode of the Amplifier
DAC Low Power Mode Switch Enables/Disables the lower power mode of the DAC
DRC Switch Enable/Disable Dynamic Range Control
DRC Limiter Switch Enable/Disable the DRC Limiter function
DRC Compressor Switch Enable/Disable the DRC Compressor function
DRC Expander Switch Enable/Disable the DRC Expander function
DRC Noise Gate Switch Enable/Disable the DRC Noise Gate function
DRC Limiter Threshold Volume DRC Limiter Threshold Setting. Relative to input
DRC Compressor Lower Threshold Volume DRC Compressor Lower Threshold Setting. Relative to input
DRC Expander Upper Threshold Volume DRC Expander Upper Threshold Setting. Relative to input
DRC Noise Gate Threshold Volume DRC Noise Gate Threshold Setting. Relative to input
DRC Upper Output Threshold Volume DRC Limiter Threshold Setting. Relative to input
DRC Lower Output Threshold Volume DRC Minimum Output Signal Amplitude Setting. This is the minimum output level produced by the DRC and is used to indicate the expander lower threshold, or output signal level when the input rises beyond the noise gate threshold
DRC Post Volume Post-DRC Gain Adjust Setting. This can be used to add additional gain after the DRC function to compensate for the overall reduction of system gain due to the DRC
DRC Peak Detector Attack Time DRC Peak Detector Attack Time
DRC Peak Detector Release Time DRC Peak Detector Release Time
DRC Attack Time DRC Attack Time. Used to smooth the gain curve at the thresholds (knees) of each DRC function
DRC Decay Time DRC Decay Time. Used to smooth the gain curve at the thresholds (knees) of each DRC function
DRC Hold Time DRC Normal Operation Hold Time. Used to prevent the gain curve calculation from increasing too quickly
DRC Noise Gate Hold Time
DRC RMS Averaging Time DRC RMS Detector Averaging Time. This is the averaging time for the rms level that is compared to the DRC thresholds

DAI configuration

The codec driver registers one DAI named “ssm2518-hifi”.

Supported DAI formats

Name Supported by driver Description
SND_SOC_DAIFMT_I2S yes I2S mode
SND_SOC_DAIFMT_RIGHT_J yes Right Justified mode
SND_SOC_DAIFMT_LEFT_J yes Left Justified mode
SND_SOC_DAIFMT_DSP_A yes data MSB after FRM LRC
SND_SOC_DAIFMT_DSP_B yes data MSB during FRM LRC
SND_SOC_DAIFMT_AC97 no AC97 mode
SND_SOC_DAIFMT_PDM no 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

Supported SYSCLK rates

The CODECs system clock can be configured for various input rates. When configuring the codec system clock use SSM2518_SYSCLK for the clock id.

The following list contains the supported system clock rates and their resulting sample-rates.

SYSCLK Supported sample-rates
2048000, 4096000, 8192000, 8192000, 3200000, 6400000, 12800000 8kHz, 16kHz, 32kHz
2822000, 5644800, 11289600, 16934400, 22579200, 33868800, 4410000, 8820000, 17640000 11.025kHz, 22.05kHz, 44.1kHz
3072000, 6144000, 38864000, 4800000, 9600000, 19200000 12kHz, 24kHz, 48kHz, 96kHz
12288000, 16384000, 24576000 8kHz, 12kHz, 16kHz, 24kHz, 32kHz, 48kHz, 96kHz

SYSCLK configuration

To configure the devices sysclk the snd_soc_codec_set_sysclk() function can be used. It needs to be called at least once before playback starts. The clk_id parameter must always be SSM2518_SYSCLK and the dir parameter must always be SND_SOC_CLOCK_IN. The freq can be set to any of the frequencies above. The system clock can either be taken from the external MCLK or the BCLK. In case the system clock is taken from the BCLK the BCLK needs to be applied to the MCLK pin and the BLCK can be left unconnected. To use the MCLK as the system clock source the source parameter should to be set to SSM2518_SYSCLK_SRC_MCLK, to use the BCLK it should be set to SSM2518_SYSCLK_SRC_BCLK

#define SSM2518_SYSCLK 0 
 
enum ssm2518_sysclk_src {
    SSM2518_SYSCLK_SRC_MCLK = 0,
    SSM2518_SYSCLK_SRC_BCLK = 1,
};
Starting with Kernel v4.18 snd_soc_codec_set_sysclk interface was removed. Instead snd_soc_component_set_sysclk should be used

TDM configuration

If you want to use the SSM2518 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().

  • tx_mask must have exactly two bits set. The most upper bit will be the slot of right channel, the most lower bit will be the slot left channel. E.g. 0x3 means the left channel will be at slot 0 and the right channel will be at slot 1 in the TDM stream.
  • rx_mask must be 0.
  • slots must be either 1, 2, 4, 8 or 16
  • width must be either 16, 24, 32

Example:

static int ssm2518_link_init(struct snd_soc_pcm_runtime *rtd)
{
    int ret;
 
    ret = snd_soc_dai_set_tdm_slot(rtd->codec_dai, 0x0c, 0x00, 8, 32);
    if (ret < 0)
        return ret;
 
    return 0;
}
 
static struct snd_soc_dai_link ssm2518_dai_link = {
    ...,
    .init = ssm2518_link_init,
};

Example DAI configuration

#include "../codecs/ssm2518.h"
 
static int pmod_amp3_init(struct snd_soc_pcm_runtime *rtd)
{
    return snd_soc_codec_set_sysclk(rtd->codec, SSM2518_SYSCLK,
                SSM2518_SYSCLK_SRC_MCLK, 12288000, SND_SOC_CLOCK_IN);
}
 
static const struct snd_soc_dapm_widget pmod_amp3_widgets[] = {
    SND_SOC_DAPM_SPK("Speaker Out", NULL),
};
 
static const struct snd_soc_dapm_route pmod_amp3_routes[] = {
    { "Speaker Out", NULL, "OUTL" },
    { "Speaker Out", NULL, "OUTR" },
};
 
static struct snd_soc_dai_link pmod_amp3_dai_link = {
    .name = "ssm2518",
    .stream_name = "ssm2518",
    .codec_dai_name = "ssm2518-hifi",
    .dai_fmt = SND_SOC_DAIFMT_I2S |
            SND_SOC_DAIFMT_NB_NF |
            SND_SOC_DAIFMT_CBS_CFS,
    .init = pmod_amp3_init,
};
 
static struct snd_soc_card pmod_amp3_card = {
    .name = "PMOD AMP3 SSM2518",
    .owner = THIS_MODULE,
    .dai_link = &pmod_amp3_dai_link,
    .num_links = 1,
    .dapm_widgets = pmod_amp3_widgets,
    .num_dapm_widgets = ARRAY_SIZE(pmod_amp3_widgets),
    .dapm_routes = pmod_amp3_routes,
    .num_dapm_routes = ARRAY_SIZE(pmod_amp3_routes),
    .fully_routed = true,
};

More information

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !

'+ '

'+ '

'+ ''+ '
'+ ''+ ''+ '
'+ ''+ '' ); $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code ==5){ $(pop_this).attr('href',"/login/index.html"); return false } if(data.code == 2){ //跳转到VIP升级页面 window.location.href="//m.obk20.com/vip/index?aid=" + webid return false } //是会员 if (data.code > 0) { $('body').append(htmlSetNormalDownload); var getWidth=$("#poplayer").width(); $("#poplayer").css("margin-left","-"+getWidth/2+"px"); $('#tips').html(data.msg) $('.download_confirm').click(function(){ $('#dialog').remove(); }) } else { var down_url = $('#vipdownload').attr('data-url'); isBindAnalysisForm(pop_this, down_url, 1) } }); }); //是否开通VIP $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code == 2 || data.code ==5){ //跳转到VIP升级页面 $('#vipdownload>span').text("开通VIP 免费下载") return false }else{ // 待续费 if(data.code == 3) { vipExpiredInfo.ifVipExpired = true vipExpiredInfo.vipExpiredDate = data.data.endoftime } $('#vipdownload .icon-vip-tips').remove() $('#vipdownload>span').text("VIP免积分下载") } }); }).on("click",".download_cancel",function(){ $('#dialog').remove(); }) var setWeixinShare={};//定义默认的微信分享信息,页面如果要自定义分享,直接更改此变量即可 if(window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'){ var d={ title:'SM2518声音Linux漂流器',//标题 desc:$('[name=description]').attr("content"), //描述 imgUrl:'https://'+location.host+'/static/images/ele-logo.png',// 分享图标,默认是logo link:'',//链接 type:'',// 分享类型,music、video或link,不填默认为link dataUrl:'',//如果type是music或video,则要提供数据链接,默认为空 success:'', // 用户确认分享后执行的回调函数 cancel:''// 用户取消分享后执行的回调函数 } setWeixinShare=$.extend(d,setWeixinShare); $.ajax({ url:"//www.obk20.com/app/wechat/index.php?s=Home/ShareConfig/index", data:"share_url="+encodeURIComponent(location.href)+"&format=jsonp&domain=m", type:'get', dataType:'jsonp', success:function(res){ if(res.status!="successed"){ return false; } $.getScript('https://res.wx.qq.com/open/js/jweixin-1.0.0.js',function(result,status){ if(status!="success"){ return false; } var getWxCfg=res.data; wx.config({ //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId:getWxCfg.appId, // 必填,公众号的唯一标识 timestamp:getWxCfg.timestamp, // 必填,生成签名的时间戳 nonceStr:getWxCfg.nonceStr, // 必填,生成签名的随机串 signature:getWxCfg.signature,// 必填,签名,见附录1 jsApiList:['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function(){ //获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 wx.onMenuShareTimeline({ title: setWeixinShare.title, // 分享标题 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享给朋友”按钮点击状态及自定义分享内容接口 wx.onMenuShareAppMessage({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 type: setWeixinShare.type, // 分享类型,music、video或link,不填默认为link dataUrl: setWeixinShare.dataUrl, // 如果type是music或video,则要提供数据链接,默认为空 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ”按钮点击状态及自定义分享内容接口 wx.onMenuShareQQ({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 wx.onMenuShareWeibo({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 wx.onMenuShareQZone({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); }); }); } }); } function openX_ad(posterid, htmlid, width, height) { if ($(htmlid).length > 0) { var randomnumber = Math.random(); var now_url = encodeURIComponent(window.location.href); var ga = document.createElement('iframe'); ga.src = 'https://www1.elecfans.com/www/delivery/myafr.php?target=_blank&cb=' + randomnumber + '&zoneid=' + posterid+'&prefer='+now_url; ga.width = width; ga.height = height; ga.frameBorder = 0; ga.scrolling = 'no'; var s = $(htmlid).append(ga); } } openX_ad(828, '#berry-300', 300, 250);