Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 132807
b: refs/heads/master
c: db04e2c
h: refs/heads/master
i:
  132805: c22b25d
  132803: cafe62b
  132799: fd7171e
v: v3
  • Loading branch information
Peter Ujfalusi authored and Mark Brown committed Jan 27, 2009
1 parent 2a33644 commit 0954f16
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3fc93030e5a792fdd0da3321487f5cbfd1143c2b
refs/heads/master: db04e2c58a65364218b89f1372b4b3b78d206423
43 changes: 17 additions & 26 deletions trunk/sound/soc/codecs/twl4030.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = {
0x00, /* this register not used */
0x93, /* REG_CODEC_MODE (0x1) */
0x91, /* REG_CODEC_MODE (0x1) */
0xc3, /* REG_OPTION (0x2) */
0x00, /* REG_UNKNOWN (0x3) */
0x00, /* REG_MICBIAS_CTL (0x4) */
Expand Down Expand Up @@ -154,26 +154,17 @@ static int twl4030_write(struct snd_soc_codec *codec,
return twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg);
}

static void twl4030_clear_codecpdz(struct snd_soc_codec *codec)
static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable)
{
u8 mode;

mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE);
twl4030_write(codec, TWL4030_REG_CODEC_MODE,
mode & ~TWL4030_CODECPDZ);
if (enable)
mode |= TWL4030_CODECPDZ;
else
mode &= ~TWL4030_CODECPDZ;

/* REVISIT: this delay is present in TI sample drivers */
/* but there seems to be no TRM requirement for it */
udelay(10);
}

static void twl4030_set_codecpdz(struct snd_soc_codec *codec)
{
u8 mode;

mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE);
twl4030_write(codec, TWL4030_REG_CODEC_MODE,
mode | TWL4030_CODECPDZ);
twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);

/* REVISIT: this delay is present in TI sample drivers */
/* but there seems to be no TRM requirement for it */
Expand All @@ -185,7 +176,7 @@ static void twl4030_init_chip(struct snd_soc_codec *codec)
int i;

/* clear CODECPDZ prior to setting register defaults */
twl4030_clear_codecpdz(codec);
twl4030_codec_enable(codec, 0);

/* set all audio section registers to reasonable defaults */
for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++)
Expand Down Expand Up @@ -895,7 +886,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec)
int i = 0;

/* set CODECPDZ to turn on codec */
twl4030_set_codecpdz(codec);
twl4030_codec_enable(codec, 1);

/* initiate offset cancellation */
anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL);
Expand All @@ -922,8 +913,8 @@ static void twl4030_power_up(struct snd_soc_codec *codec)
regmisc1 | TWL4030_SMOOTH_ANAVOL_EN);

/* toggle CODECPDZ as per TRM */
twl4030_clear_codecpdz(codec);
twl4030_set_codecpdz(codec);
twl4030_codec_enable(codec, 0);
twl4030_codec_enable(codec, 1);

/* program anti-pop with bias ramp delay */
popn = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET);
Expand Down Expand Up @@ -952,7 +943,7 @@ static void twl4030_power_down(struct snd_soc_codec *codec)
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn);

/* power down */
twl4030_clear_codecpdz(codec);
twl4030_codec_enable(codec, 0);
}

static int twl4030_set_bias_level(struct snd_soc_codec *codec,
Expand Down Expand Up @@ -1030,7 +1021,7 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream,
if (mode != old_mode) {
/* change rate and set CODECPDZ */
twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
twl4030_set_codecpdz(codec);
twl4030_codec_enable(codec, 1);
}

/* sample size */
Expand All @@ -1053,13 +1044,13 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream,
if (format != old_format) {

/* clear CODECPDZ before changing format (codec requirement) */
twl4030_clear_codecpdz(codec);
twl4030_codec_enable(codec, 0);

/* change format */
twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);

/* set CODECPDZ afterwards */
twl4030_set_codecpdz(codec);
twl4030_codec_enable(codec, 1);
}
return 0;
}
Expand Down Expand Up @@ -1129,13 +1120,13 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai,
if (format != old_format) {

/* clear CODECPDZ before changing format (codec requirement) */
twl4030_clear_codecpdz(codec);
twl4030_codec_enable(codec, 0);

/* change format */
twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);

/* set CODECPDZ afterwards */
twl4030_set_codecpdz(codec);
twl4030_codec_enable(codec, 1);
}

return 0;
Expand Down

0 comments on commit 0954f16

Please sign in to comment.