资源预览内容
第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
第9页 / 共24页
第10页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
/* wm8960.c - WM8960 ALSA SoC Audio driver* Copyright 2007-11 Wolfson Microelectronics, plc* Author: Liam Girdwood* This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License version 2 as* published by the Free Software Foundation.*/#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include wm8960.h/* R25 - Power 1 */#define WM8960_VMID_MASK 0x180#define WM8960_VREF 0x40/* R26 - Power 2 */#define WM8960_PWR2_LOUT1 0x40#define WM8960_PWR2_ROUT1 0x20#define WM8960_PWR2_OUT3 0x02/* R28 - Anti-pop 1 */#define WM8960_POBCTRL 0x80#define WM8960_BUFDCOPEN 0x10#define WM8960_BUFIOEN 0x08#define WM8960_SOFT_ST 0x04#define WM8960_HPSTBY 0x01/* R29 - Anti-pop 2 */#define WM8960_DISOP 0x40#define WM8960_DRES_MASK 0x30/* wm8960 register cache* We cant read the WM8960 register space when we are* using 2 wire for device control, so we cache them instead.*/static const u16 wm8960_regWM8960_CACHEREGNUM = 0x0097, 0x0097, 0x0000, 0x0000,0x0000, 0x0008, 0x0000, 0x000a,0x01c0, 0x0000, 0x00ff, 0x00ff,0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x007b, 0x0100, 0x0032,0x0000, 0x00c3, 0x00c3, 0x01c0,0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000,0x0100, 0x0100, 0x0050, 0x0050,0x0050, 0x0050, 0x0000, 0x0000,0x0000, 0x0000, 0x0040, 0x0000,0x0000, 0x0050, 0x0050, 0x0000,0x0002, 0x0037, 0x004d, 0x0080,0x0008, 0x0031, 0x0026, 0x00e9,;struct wm8960_priv enum snd_soc_control_type control_type;int (*set_bias_level)(struct snd_soc_codec *,enum snd_soc_bias_level level);struct snd_soc_dapm_widget *lout1;struct snd_soc_dapm_widget *rout1;struct snd_soc_dapm_widget *out3;bool deemph;int playback_fs;#define wm8960_reset(c) snd_soc_write(c, WM8960_RESET, 0)/* enumerated controls */static const char *wm8960_polarity = No Inversion, Left Inverted,Right Inverted, Stereo Inversion;static const char *wm8960_3d_upper_cutoff = High, Low;static const char *wm8960_3d_lower_cutoff = Low, High;static const char *wm8960_alcfunc = Off, Right, Left, Stereo;static const char *wm8960_alcmode = ALC, Limiter;static const struct soc_enum wm8960_enum = SOC_ENUM_SINGLE(WM8960_DACCTL1, 5, 4, wm8960_polarity),SOC_ENUM_SINGLE(WM8960_DACCTL2, 5, 4, wm8960_polarity),SOC_ENUM_SINGLE(WM8960_3D, 6, 2, wm8960_3d_upper_cutoff),SOC_ENUM_SINGLE(WM8960_3D, 5, 2, wm8960_3d_lower_cutoff),SOC_ENUM_SINGLE(WM8960_ALC1, 7, 4, wm8960_alcfunc),SOC_ENUM_SINGLE(WM8960_ALC3, 8, 2, wm8960_alcmode),;static const int deemph_settings = 0, 32000, 44100, 48000 ;static int wm8960_set_deemph(struct snd_soc_codec *codec)struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);int val, i, best;/* If were using deemphasis select the nearest available sample* rate.*/if (wm8960-deemph) best = 1;for (i = 2; i playback_fs) playback_fs)best = i;val = best dev, Set deemphasis %dn, val);return snd_soc_update_bits(codec, WM8960_DACCTL1,0x6, val);static int wm8960_get_deemph(struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol)struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);ucontrol-value.enumerated.item0 = wm8960-deemph;return 0;static int wm8960_put_deemph(struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol)struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);int deemph = ucontrol-value.enumerated.item0;if (deemph 1)return -EINVAL;wm8960-deemph = deemph;return wm8960_set_deemph(codec);static const DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 50, 0);static const DECLARE_TLV_DB_SCALE(dac_tlv, -12700, 50, 1);static const DECLARE_TLV_DB_SCALE(bypass_tlv, -2100, 300, 0);static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);static const struct snd_kcontrol_new wm8960_snd_controls = SOC_DOUBLE_R_TLV(Capture Volume, WM8960_LINVOL, WM8960_RINVOL,0, 63, 0, adc_tlv),SOC_DOUBLE_R(Capture Volume ZC Switch, WM8960_LINVOL, WM8960_RINVOL,6, 1, 0),SOC_DOUBLE_R(Capture Mute Switch, WM8960_LINVOL, WM8960_RINVOL,7, 1, 0),SOC_DOUBLE_R_TLV(Playback Volume, WM8960_LDAC, WM8960_RDAC,0, 255, 0, dac_tlv),SOC_DOUBLE_R_TLV(ADC Digital Volume, WM8960_LADC, WM8960_RADC,0, 255, 0, dac_tlv),SOC_DOUBLE_R_TLV(Headphone Playback Volume, WM8960_LOUT1, WM8960_ROUT1,0, 127, 0, out_tlv),SOC_DOUBLE_R(Headphone Playback ZC Switch, WM8960_LOUT1, WM8960_ROUT1,7, 1, 0),SOC_DOUBLE_R_TLV(Speaker Playback Volume, WM8960_LOUT2, WM8960_ROUT2,0, 127, 0, out_tlv),SOC_DOUBLE_R(Speaker Playback ZC Switch, WM8960_LOUT2, WM8960_ROUT2,7, 1, 0),SOC_SINGLE(Speaker DC Volume, WM8960_CLASSD3, 3, 5, 0),SOC_SINGLE(Speaker AC Volume, WM8960_CLASSD3, 0, 5, 0),SOC_SINGLE(PCM Playback -6dB Switch, WM8960_DACCTL1, 7, 1, 0),SOC_ENUM(ADC Polarity, wm8960_enum0),SOC_SINGLE(ADC High Pass Filter Swit
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号