This patch modifies ak4642 driver to output both headphone/stereo-line in same time.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/ak4642.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 50da176..f30e434 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -75,6 +75,7 @@ /* PW_MGMT1*/ #define PMVCM (1 << 6) /* VCOM Power Management */ #define PMMIN (1 << 5) /* MIN Input Power Management */ +#define PMLO (1 << 3) /* Stereo Line Out Power Management */ #define PMDAC (1 << 2) /* DAC Power Management */ #define PMADL (1 << 0) /* MIC Amp Lch and ADC Lch Power Management */
@@ -98,6 +99,9 @@ #define PMMP (1 << 2) /* MPWR pin Power Management */ #define MGAIN0 (1 << 0) /* MIC amp gain*/
+/* SG_SL2 */ +#define LOPS (1 << 6) /* Stereo Line Output Power-Save Mode */ + /* TIMER */ #define ZTM(param) ((param & 0x3) << 4) /* ALC Zoro Crossing TimeOut */ #define WTM(param) (((param & 0x4) << 4) | ((param & 0x3) << 2)) @@ -130,10 +134,13 @@ #define FS_MASK (FS0 | FS1 | FS2 | FS3)
/* MD_CTL3 */ -#define BST1 (1 << 3) +#define DEM0 (1 << 0) /* De-emphasis Frequency Select */ +#define BST1 (1 << 3) /* Bass Boost Function Select */ +#define DVOLC (1 << 4) /* Output Digital Volume Control Mode Select */
/* MD_CTL4 */ -#define DACH (1 << 0) +#define DACH (1 << 0) /* Switch Control from DAC to Headphone-Amp */ +#define IVOLC (1 << 3) /* Input Digital Volume Control Mode Select */
/* * Playback Volume (table 39) @@ -241,21 +248,31 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
if (is_play) { /* - * start headphone output + * start output + * - headphone + * - stereo line * * PLL, Master Mode * Audio I/F Format :MSB justified (ADC & DAC) - * Bass Boost Level : Middle + * Digital Volume : -8dB + * Bass Boost Level : Middle + * LOVL=MINL bits : 0 * * This operation came from example code of * "ASAHI KASEI AK4642" (japanese) manual p97. + * "ASAHI KASEI AK4642" (japanese) manual p98. + * */ snd_soc_update_bits(codec, MD_CTL4, DACH, DACH); snd_soc_update_bits(codec, MD_CTL3, BST1, BST1); + snd_soc_update_bits(codec, SG_SL1, DACL | MGAIN0, DACL); ak4642_write(codec, L_IVC, 0x91); /* volume */ ak4642_write(codec, R_IVC, 0x91); /* volume */ - snd_soc_update_bits(codec, PW_MGMT1, PMVCM | PMMIN | PMDAC, - PMVCM | PMMIN | PMDAC); + snd_soc_update_bits(codec, SG_SL2, LOPS, LOPS); + snd_soc_update_bits(codec, PW_MGMT1, + PMVCM | PMMIN | PMLO | PMDAC, + PMVCM | PMMIN | PMLO | PMDAC); + snd_soc_update_bits(codec, SG_SL2, LOPS, 0); snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, PMHP); snd_soc_update_bits(codec, PW_MGMT2, HPMTN, HPMTN); } else { @@ -272,7 +289,9 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, * This operation came from example code of * "ASAHI KASEI AK4642" (japanese) manual p94. */ - ak4642_write(codec, SG_SL1, PMMP | MGAIN0); + snd_soc_update_bits(codec, SG_SL1, + PMMP | MGAIN0, + PMMP | MGAIN0); ak4642_write(codec, TIMER, ZTM(0x3) | WTM(0x3)); ak4642_write(codec, ALC_CTL1, ALC | LMTH0); snd_soc_update_bits(codec, PW_MGMT1, PMVCM | PMADL, @@ -290,12 +309,19 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_codec *codec = dai->codec;
if (is_play) { - /* stop headphone output */ + /* + * stop output + * - headphone + * - stereo line + */ + snd_soc_update_bits(codec, SG_SL2, LOPS, LOPS); snd_soc_update_bits(codec, PW_MGMT2, HPMTN, 0); snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, 0); - snd_soc_update_bits(codec, PW_MGMT1, PMMIN | PMDAC, 0); + snd_soc_update_bits(codec, PW_MGMT1, PMMIN | PMLO | PMDAC, 0); snd_soc_update_bits(codec, MD_CTL3, BST1, 0); snd_soc_update_bits(codec, MD_CTL4, DACH, 0); + snd_soc_update_bits(codec, SG_SL1, DACL, 0); + snd_soc_update_bits(codec, SG_SL2, LOPS, 0); } else { /* stop stereo input */ snd_soc_update_bits(codec, PW_MGMT1, PMADL, 0);