aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/ak4642.c69
-rw-r--r--sound/soc/sh/fsi-ak4642.c4
2 files changed, 49 insertions, 24 deletions
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index d5bd4cae73a1..3452bd752739 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -80,6 +80,17 @@
80 80
81#define AK4642_CACHEREGNUM 0x25 81#define AK4642_CACHEREGNUM 0x25
82 82
83/* PW_MGMT2 */
84#define HPMTN (1 << 6)
85#define PMHPL (1 << 5)
86#define PMHPR (1 << 4)
87#define MS (1 << 3) /* master/slave select */
88#define MCKO (1 << 1)
89#define PMPLL (1 << 0)
90
91#define PMHP_MASK (PMHPL | PMHPR)
92#define PMHP PMHP_MASK
93
83/* MD_CTL1 */ 94/* MD_CTL1 */
84#define PLL3 (1 << 7) 95#define PLL3 (1 << 7)
85#define PLL2 (1 << 6) 96#define PLL2 (1 << 6)
@@ -87,6 +98,9 @@
87#define PLL0 (1 << 4) 98#define PLL0 (1 << 4)
88#define PLL_MASK (PLL3 | PLL2 | PLL1 | PLL0) 99#define PLL_MASK (PLL3 | PLL2 | PLL1 | PLL0)
89 100
101#define BCKO_MASK (1 << 3)
102#define BCKO_64 BCKO_MASK
103
90struct snd_soc_codec_device soc_codec_dev_ak4642; 104struct snd_soc_codec_device soc_codec_dev_ak4642;
91 105
92/* codec private data */ 106/* codec private data */
@@ -188,9 +202,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
188 * 202 *
189 * This operation came from example code of 203 * This operation came from example code of
190 * "ASAHI KASEI AK4642" (japanese) manual p97. 204 * "ASAHI KASEI AK4642" (japanese) manual p97.
191 *
192 * Example code use 0x39, 0x79 value for 0x01 address,
193 * But we need MCKO (0x02) bit now
194 */ 205 */
195 ak4642_write(codec, 0x05, 0x27); 206 ak4642_write(codec, 0x05, 0x27);
196 ak4642_write(codec, 0x0f, 0x09); 207 ak4642_write(codec, 0x0f, 0x09);
@@ -200,8 +211,8 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
200 ak4642_write(codec, 0x0a, 0x28); 211 ak4642_write(codec, 0x0a, 0x28);
201 ak4642_write(codec, 0x0d, 0x28); 212 ak4642_write(codec, 0x0d, 0x28);
202 ak4642_write(codec, 0x00, 0x64); 213 ak4642_write(codec, 0x00, 0x64);
203 ak4642_write(codec, 0x01, 0x3b); /* + MCKO bit */ 214 snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, PMHP);
204 ak4642_write(codec, 0x01, 0x7b); /* + MCKO bit */ 215 snd_soc_update_bits(codec, PW_MGMT2, HPMTN, HPMTN);
205 } else { 216 } else {
206 /* 217 /*
207 * start stereo input 218 * start stereo input
@@ -238,8 +249,8 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream,
238 249
239 if (is_play) { 250 if (is_play) {
240 /* stop headphone output */ 251 /* stop headphone output */
241 ak4642_write(codec, 0x01, 0x3b); 252 snd_soc_update_bits(codec, PW_MGMT2, HPMTN, 0);
242 ak4642_write(codec, 0x01, 0x0b); 253 snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, 0);
243 ak4642_write(codec, 0x00, 0x40); 254 ak4642_write(codec, 0x00, 0x40);
244 ak4642_write(codec, 0x0e, 0x11); 255 ak4642_write(codec, 0x0e, 0x11);
245 ak4642_write(codec, 0x0f, 0x08); 256 ak4642_write(codec, 0x0f, 0x08);
@@ -284,10 +295,37 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
284 return 0; 295 return 0;
285} 296}
286 297
298static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
299{
300 struct snd_soc_codec *codec = dai->codec;
301 u8 data;
302 u8 bcko;
303
304 data = MCKO | PMPLL; /* use MCKO */
305 bcko = 0;
306
307 /* set master/slave audio interface */
308 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
309 case SND_SOC_DAIFMT_CBM_CFM:
310 data |= MS;
311 bcko = BCKO_64;
312 break;
313 case SND_SOC_DAIFMT_CBS_CFS:
314 break;
315 default:
316 return -EINVAL;
317 }
318 snd_soc_update_bits(codec, PW_MGMT2, MS, data);
319 snd_soc_update_bits(codec, MD_CTL1, BCKO_MASK, bcko);
320
321 return 0;
322}
323
287static struct snd_soc_dai_ops ak4642_dai_ops = { 324static struct snd_soc_dai_ops ak4642_dai_ops = {
288 .startup = ak4642_dai_startup, 325 .startup = ak4642_dai_startup,
289 .shutdown = ak4642_dai_shutdown, 326 .shutdown = ak4642_dai_shutdown,
290 .set_sysclk = ak4642_dai_set_sysclk, 327 .set_sysclk = ak4642_dai_set_sysclk,
328 .set_fmt = ak4642_dai_set_fmt,
291}; 329};
292 330
293struct snd_soc_dai ak4642_dai = { 331struct snd_soc_dai ak4642_dai = {
@@ -366,23 +404,6 @@ static int ak4642_init(struct ak4642_priv *ak4642)
366 goto reg_cache_err; 404 goto reg_cache_err;
367 } 405 }
368 406
369 /*
370 * clock setting
371 *
372 * Audio I/F Format: MSB justified (ADC & DAC)
373 * BICK frequency at Master Mode: 64fs
374 * MCKO: Enable
375 * Sampling Frequency: 44.1kHz
376 *
377 * This operation came from example code of
378 * "ASAHI KASEI AK4642" (japanese) manual p89.
379 *
380 * please fix-me
381 */
382 ak4642_write(codec, 0x01, 0x08);
383 ak4642_write(codec, 0x05, 0x27);
384 ak4642_write(codec, 0x04, 0x0a);
385
386 return ret; 407 return ret;
387 408
388reg_cache_err: 409reg_cache_err:
diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c
index c0207dc524b8..be018542314e 100644
--- a/sound/soc/sh/fsi-ak4642.c
+++ b/sound/soc/sh/fsi-ak4642.c
@@ -26,6 +26,10 @@ static int fsi_ak4642_dai_init(struct snd_soc_codec *codec)
26{ 26{
27 int ret; 27 int ret;
28 28
29 ret = snd_soc_dai_set_fmt(&ak4642_dai, SND_SOC_DAIFMT_CBM_CFM);
30 if (ret < 0)
31 return ret;
32
29 ret = snd_soc_dai_set_sysclk(&ak4642_dai, 0, 11289600, 0); 33 ret = snd_soc_dai_set_sysclk(&ak4642_dai, 0, 11289600, 0);
30 34
31 return ret; 35 return ret;