static struct snd_soc_codec *rt3261_codec;
-#if 1
+#if 0
#define DBG(x...) printk(KERN_DEBUG x)
#else
#define DBG(x...)
{RT3261_OUTPUT , 0x8888},//unmute OUTVOLL/R
{RT3261_SPO_CLSD_RATIO , 0x0001},
{RT3261_I2S1_SDP , 0xd000},
+ {RT3261_GLB_CLK , 0x4000},//0424
+ //{0x90 , 0x636},//0424
+ {RT3261_CHARGE_PUMP , 0xe00},//0424
+ {RT3261_DEPOP_M3 , 0x636},//0424
+ {RT3261_DEPOP_M1 , 0x84},//0424
+ {RT3261_PWR_DIG1 , 0x8000},//0424
+ {RT3261_PWR_ANLG2 , 0x0800},
// huangcun 20130816 s
-#if 1
+#if 0
/*speaker*/
{RT3261_DSP_PATH2 , 0x0000},
{RT3261_PRIV_INDEX , 0x003f},//PR3d[14] = 0'b;
{RT3261_OUT_R3_MIXER, 0x01fd},
{RT3261_HPO_MIXER, 0xc000},
#endif
-#if 1
+#if 0
/*capture*/
{RT3261_IN1_IN2, 0x2080},//boost1 = 24db
{RT3261_REC_R2_MIXER, 0x007d},
{
return snd_soc_write(codec, RT3261_RESET, 0);
}
-
+#if 0
static unsigned int rt3261_read(struct snd_soc_codec *codec,
unsigned int reg)
{
val = codec->hw_read(codec, reg);
return val;
}
-
+#endif
static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value, const void *data, int len)
{
data[2] = value & 0xff;
DBG("rt3261_write 0x%x = 0x%x\n",reg,value);
+
return do_hw_write(codec, reg, value, data, 3);
}
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
- printk("%s\n", __FUNCTION__);
+ DBG("%s\n", __FUNCTION__);
ucontrol->value.integer.value[0] = rt3261->asrc_en;
return 0;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
- printk("%s\n", __FUNCTION__);
+ DBG("%s\n", __FUNCTION__);
if (rt3261->asrc_en == ucontrol->value.integer.value[0])
return 0;
rt3261->asrc_en = ucontrol->value.integer.value[0];
switch (rt3261->asrc_en) {
case RT3261_ASRC_DIS://disable ASRC
- printk("%s disable\n", __FUNCTION__);
+ DBG("%s disable\n", __FUNCTION__);
snd_soc_write(codec, RT3261_ASRC_1, 0x0);
snd_soc_write(codec, RT3261_ASRC_2, 0x0);
snd_soc_update_bits(codec, RT3261_GEN_CTRL1, 0x70, 0x0); //bard 8-29
break;
case RT3261_ASRC_EN://enable ASRC
- printk("%s enable\n", __FUNCTION__);
+ DBG("%s enable\n", __FUNCTION__);
snd_soc_write(codec, RT3261_ASRC_1, 0x9800);
snd_soc_write(codec, RT3261_ASRC_2, 0xF800);
snd_soc_update_bits(codec, RT3261_GEN_CTRL1, 0x70, 0x70); //bard 8-29
void rt3261_hp_amp_power(struct snd_soc_codec *codec, int on)
{
static int hp_amp_power_count;
- printk("rt3261_hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count);
+ DBG("rt3261_hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count);
// dump_reg(codec);
if(on) {
if(hp_amp_power_count <= 0) {
RT3261_PWR_I2S1, RT3261_PWR_I2S1);
/* depop parameters */
rt3261_index_update_bits(codec, RT3261_CHPUMP_INT_REG1,0x0700, 0x0200); //bard 12-6
+ snd_soc_write(codec, RT3261_DEPOP_M2, 0x3100); //bard 4-22
+ snd_soc_write(codec, RT3261_DEPOP_M1, 0x0009); //bard 4-22
+ msleep(50);
+/*
snd_soc_update_bits(codec, RT3261_DEPOP_M2,
RT3261_DEPOP_MASK, RT3261_DEPOP_MAN);
snd_soc_update_bits(codec, RT3261_DEPOP_M1,
RT3261_HP_CP_MASK | RT3261_HP_SG_MASK | RT3261_HP_CB_MASK,
RT3261_HP_CP_PU | RT3261_HP_SG_DIS | RT3261_HP_CB_PU);
+*/
rt3261_index_write(codec, RT3261_HP_DCC_INT1, 0x9f00);
/* headphone amp power on */
snd_soc_update_bits(codec, RT3261_PWR_ANLG1,
snd_soc_update_bits(codec, RT3261_PWR_ANLG1,
RT3261_PWR_HP_L | RT3261_PWR_HP_R | RT3261_PWR_HA , //bard 10-18
RT3261_PWR_HP_L | RT3261_PWR_HP_R | RT3261_PWR_HA); //bard 10-18
- msleep(50);
+ msleep(30); //bard 4-22
snd_soc_update_bits(codec, RT3261_PWR_ANLG1,
RT3261_PWR_FV1 | RT3261_PWR_FV2,
RT3261_PWR_FV1 | RT3261_PWR_FV2);
if(ucontrol->value.integer.value[0]) {
/* headphone unmute sequence */
+
snd_soc_update_bits(codec, RT3261_DEPOP_M3,
RT3261_CP_FQ1_MASK | RT3261_CP_FQ2_MASK | RT3261_CP_FQ3_MASK,
(RT3261_CP_FQ_192_KHZ << RT3261_CP_FQ1_SFT) |
snd_soc_update_bits(codec, RT3261_DEPOP_M1,
RT3261_RSTN_MASK | RT3261_HP_L_SMT_MASK | RT3261_HP_R_SMT_MASK,
RT3261_RSTN_DIS | RT3261_HP_L_SMT_EN | RT3261_HP_R_SMT_EN);
- snd_soc_update_bits(codec, RT3261_HP_VOL,
- RT3261_L_MUTE | RT3261_R_MUTE, 0);
- msleep(100);
+ //snd_soc_update_bits(codec, RT3261_HP_VOL,
+ // RT3261_L_MUTE | RT3261_R_MUTE, RT3261_L_MUTE | RT3261_R_MUTE);
+ msleep(60); //bard 4-22
snd_soc_update_bits(codec, RT3261_DEPOP_M1,
RT3261_HP_SG_MASK | RT3261_HP_L_SMT_MASK |
RT3261_HP_R_SMT_MASK, RT3261_HP_SG_DIS |
*/
snd_soc_update_bits(codec, RT3261_HP_VOL,
RT3261_L_MUTE | RT3261_R_MUTE, RT3261_L_MUTE | RT3261_R_MUTE);
- msleep(30);
+ msleep(60);
+/*
snd_soc_update_bits(codec, RT3261_DEPOP_M1,
RT3261_HP_R_SMT_MASK | RT3261_HP_L_SMT_MASK,
RT3261_HP_L_SMT_DIS | RT3261_HP_R_SMT_DIS);
+*/
}
return 0;
}
RT3261_L_VOL_SFT, RT3261_R_VOL_SFT, RT3261_VOL_RSCL_RANGE, 0,
rt3261_vol_rescale_get, rt3261_vol_rescale_put, out_vol_tlv),
/* Headphone Output Volume */
+/*
SOC_DOUBLE("HP Playback Switch", RT3261_HP_VOL,
RT3261_L_MUTE_SFT, RT3261_R_MUTE_SFT, 1, 1),
+*/
SOC_DOUBLE_EXT_TLV("Headphone Playback Volume", RT3261_HP_VOL,
RT3261_L_VOL_SFT, RT3261_R_VOL_SFT, RT3261_VOL_RSCL_RANGE, 0,
rt3261_vol_rescale_get, rt3261_vol_rescale_put, out_vol_tlv),
snd_soc_update_bits(codec, RT3261_DEPOP_M1,
RT3261_RSTN_MASK | RT3261_HP_L_SMT_MASK | RT3261_HP_R_SMT_MASK,
RT3261_RSTN_DIS | RT3261_HP_L_SMT_EN | RT3261_HP_R_SMT_EN);
+ //msleep(30);
snd_soc_update_bits(codec, RT3261_HP_VOL,
RT3261_L_MUTE | RT3261_R_MUTE, 0);
- msleep(100);
+ msleep(30); //bard 4-22
snd_soc_update_bits(codec, RT3261_DEPOP_M1,
RT3261_HP_SG_MASK | RT3261_HP_L_SMT_MASK |
RT3261_HP_R_SMT_MASK, RT3261_HP_SG_DIS |
RT3261_HP_L_SMT_EN | RT3261_HP_R_SMT_EN);
/*bard 10-18 r
snd_soc_update_bits(codec, RT3261_HP_CALIB_AMP_DET,
- RT3261_HPD_PS_MASK, RT3261_HPD_PS_DIS);
- msleep(90);
- */
+ RT3261_HPD_PS_MASK, RT3261_HPD_PS_DIS);*/
+ //msleep(90);
snd_soc_update_bits(codec, RT3261_HP_VOL,
RT3261_L_MUTE | RT3261_R_MUTE, RT3261_L_MUTE | RT3261_R_MUTE);
msleep(30);
snd_soc_update_bits(codec, RT3261_HP_VOL,
RT3261_L_MUTE | RT3261_R_MUTE,
RT3261_L_MUTE | RT3261_R_MUTE);
- msleep(90);
snd_soc_update_bits(codec, RT3261_DEPOP_M1,
RT3261_HP_CB_MASK, RT3261_HP_CB_PD);
- msleep(30);
//rt3261_index_update_bits(codec, RT3261_CHOP_DAC_ADC, 0x0200, 0x0);
snd_soc_update_bits(codec, RT3261_PWR_ANLG1,
RT3261_PWR_HP_L | RT3261_PWR_HP_R | RT3261_PWR_HA,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
-
switch (event) {
case SND_SOC_DAPM_POST_PMU:
rt3261_pmu_depop(codec);
SND_SOC_DAPM_PGA("INR VOL", RT3261_PWR_VOL,
RT3261_PWR_IN_R_BIT, 0, NULL, 0),
/* IN Mux */
+/*
SND_SOC_DAPM_MUX("INL Mux", SND_SOC_NOPM, 0, 0, &rt3261_inl_mux),
SND_SOC_DAPM_MUX("INR Mux", SND_SOC_NOPM, 0, 0, &rt3261_inr_mux),
+*/
/* REC Mixer */
SND_SOC_DAPM_MIXER("RECMIXL", RT3261_PWR_MIXER, RT3261_PWR_RM_L_BIT, 0,
rt3261_rec_l_mix, ARRAY_SIZE(rt3261_rec_l_mix)),
&rt3261_if2_adc_r_mux),
/* Digital Interface */
- SND_SOC_DAPM_SUPPLY("I2S1", RT3261_PWR_DIG1,
- RT3261_PWR_I2S1_BIT, 0, NULL, 0),
+ SND_SOC_DAPM_SUPPLY("I2S1", SND_SOC_NOPM,
+ 0, 0, NULL, 0),
SND_SOC_DAPM_PGA("IF1 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
SND_SOC_DAPM_PGA("IF1 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
SND_SOC_DAPM_PGA("IF1 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
if (freq == rt3261->sysclk && clk_id == rt3261->sysclk_src)
return 0;
+ snd_soc_update_bits(codec, RT3261_PWR_ANLG2, RT3261_PWR_PLL, RT3261_PWR_PLL);
switch (clk_id) {
case RT3261_SCLK_S_MCLK:
break;
case SND_SOC_BIAS_PREPARE:
- snd_soc_update_bits(codec, RT3261_HP_VOL,
- RT3261_L_MUTE | RT3261_R_MUTE, RT3261_L_MUTE | RT3261_R_MUTE); //bard 12-7
+ //snd_soc_update_bits(codec, RT3261_HP_VOL,
+ // RT3261_L_MUTE | RT3261_R_MUTE, RT3261_L_MUTE | RT3261_R_MUTE); //bard 12-7
snd_soc_update_bits(codec, RT3261_SPK_VOL,
RT3261_L_MUTE | RT3261_R_MUTE,
RT3261_L_MUTE | RT3261_R_MUTE);
break;
case SND_SOC_BIAS_OFF:
- snd_soc_write(codec, RT3261_DEPOP_M1, 0x0004);
- snd_soc_write(codec, RT3261_DEPOP_M2, 0x1100);
+ //snd_soc_write(codec, RT3261_DEPOP_M1, 0x0004);//bard 4-22 r
+ //snd_soc_write(codec, RT3261_DEPOP_M2, 0x1100);//bard 4-22 r
snd_soc_write(codec, RT3261_GEN_CTRL1, 0x3700);
snd_soc_write(codec, RT3261_PWR_DIG1, 0x0000);
snd_soc_write(codec, RT3261_PWR_DIG2, 0x0000);
{
struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
int ret;
-
+#ifdef RTK_IOCTL
+#if defined(CONFIG_SND_HWDEP) || defined(CONFIG_SND_HWDEP_MODULE)
+ struct rt_codec_ops *ioctl_ops = rt_codec_get_ioctl_ops();
+#endif
+#endif
#if defined (CONFIG_SND_SOC_RT3224)
pr_info("Codec driver version %s, in fact you choose rt3224, no dsp!\n", VERSION);
#else
}
#endif
- rt3261_reset(codec);
+ ret=rt3261_reset(codec);
+ if (ret < 0)
+ {
+ return -ENODEV;
+ }
snd_soc_update_bits(codec, RT3261_PWR_ANLG1,
RT3261_PWR_VREF1 | RT3261_PWR_MB |
RT3261_PWR_BG | RT3261_PWR_VREF2,
#ifdef RTK_IOCTL
#if defined(CONFIG_SND_HWDEP) || defined(CONFIG_SND_HWDEP_MODULE)
- struct rt_codec_ops *ioctl_ops = rt_codec_get_ioctl_ops();
ioctl_ops->index_write = rt3261_index_write;
ioctl_ops->index_read = rt3261_index_read;
ioctl_ops->index_update_bits = rt3261_index_update_bits;
return ret;
}
rt3261_codec = codec;
+
return 0;
}
int ret;
enum of_gpio_flags flags;
- printk("%s()\n", __FUNCTION__);
+ DBG("%s()\n", __FUNCTION__);
if (!node)
return -ENODEV;
rt3261->codec_en_gpio = of_get_named_gpio_flags(node, "codec-en-gpio", 0, &flags);
- if (rt3261->codec_en_gpio < 0) {
+ if (rt3261->codec_en_gpio <= 0) {
DBG("%s() Can not read property codec-en-gpio\n", __FUNCTION__);
} else {
ret = devm_gpio_request(dev, rt3261->codec_en_gpio, "codec_en_gpio");
{
struct rt3261_priv *rt3261;
int ret;
+ char reg;
- rt3261 = kzalloc(sizeof(struct rt3261_priv), GFP_KERNEL);
+ reg = RT3261_VENDOR_ID;
+ ret = i2c_master_recv(i2c, ®, 1);
+ if (ret < 0){
+ printk("rt3261 && rt3224 probe error\n");
+ return ret;
+ }
+
+ rt3261 = devm_kzalloc(&i2c->dev,sizeof(struct rt3261_priv), GFP_KERNEL);
if (NULL == rt3261)
return -ENOMEM;
-
rt3261->i2c = i2c;
ret = rt3261_parse_dt_property(&i2c->dev, rt3261);
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt3261,
rt3261_dai, ARRAY_SIZE(rt3261_dai));
- if (ret < 0)
- kfree(rt3261);
return ret;
}