Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: sound/soc/codecs/ak4535.c

Issue 6577007: CHROMIUM: ASoC: Import entire upstream ASoC tree (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sound/soc/codecs/ad1980.c ('k') | sound/soc/codecs/ak4642.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * ak4535.c -- AK4535 ALSA Soc Audio driver 2 * ak4535.c -- AK4535 ALSA Soc Audio driver
3 * 3 *
4 * Copyright 2005 Openedhand Ltd. 4 * Copyright 2005 Openedhand Ltd.
5 * 5 *
6 * Author: Richard Purdie <richard@openedhand.com> 6 * Author: Richard Purdie <richard@openedhand.com>
7 * 7 *
8 * Based on wm8753.c by Liam Girdwood 8 * Based on wm8753.c by Liam Girdwood
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15 #include <linux/module.h> 15 #include <linux/module.h>
16 #include <linux/moduleparam.h> 16 #include <linux/moduleparam.h>
17 #include <linux/init.h> 17 #include <linux/init.h>
18 #include <linux/delay.h> 18 #include <linux/delay.h>
19 #include <linux/pm.h> 19 #include <linux/pm.h>
20 #include <linux/i2c.h> 20 #include <linux/i2c.h>
21 #include <linux/platform_device.h> 21 #include <linux/platform_device.h>
22 #include <linux/slab.h> 22 #include <linux/slab.h>
23 #include <sound/core.h> 23 #include <sound/core.h>
24 #include <sound/pcm.h> 24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h> 25 #include <sound/pcm_params.h>
26 #include <sound/soc.h> 26 #include <sound/soc.h>
27 #include <sound/soc-dapm.h>
28 #include <sound/initval.h> 27 #include <sound/initval.h>
29 28
30 #include "ak4535.h" 29 #include "ak4535.h"
31 30
32 #define AK4535_VERSION "0.3" 31 #define AK4535_VERSION "0.3"
33 32
34 /* codec private data */ 33 /* codec private data */
35 struct ak4535_priv { 34 struct ak4535_priv {
36 unsigned int sysclk; 35 unsigned int sysclk;
37 enum snd_soc_control_type control_type; 36 enum snd_soc_control_type control_type;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 {"Aux In", NULL, "AUX"}, 282 {"Aux In", NULL, "AUX"},
284 283
285 /* ADC */ 284 /* ADC */
286 {"ADC", NULL, "Input Mixer"}, 285 {"ADC", NULL, "Input Mixer"},
287 {"Input Mixer", "Mic Capture Switch", "Mic"}, 286 {"Input Mixer", "Mic Capture Switch", "Mic"},
288 {"Input Mixer", "Aux Capture Switch", "Aux In"}, 287 {"Input Mixer", "Aux Capture Switch", "Aux In"},
289 }; 288 };
290 289
291 static int ak4535_add_widgets(struct snd_soc_codec *codec) 290 static int ak4535_add_widgets(struct snd_soc_codec *codec)
292 { 291 {
293 » snd_soc_dapm_new_controls(codec, ak4535_dapm_widgets, 292 » struct snd_soc_dapm_context *dapm = &codec->dapm;
293
294 » snd_soc_dapm_new_controls(dapm, ak4535_dapm_widgets,
294 ARRAY_SIZE(ak4535_dapm_widgets)); 295 ARRAY_SIZE(ak4535_dapm_widgets));
295 296 » snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
296 » snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
297 297
298 return 0; 298 return 0;
299 } 299 }
300 300
301 static int ak4535_set_dai_sysclk(struct snd_soc_dai *codec_dai, 301 static int ak4535_set_dai_sysclk(struct snd_soc_dai *codec_dai,
302 int clk_id, unsigned int freq, int dir) 302 int clk_id, unsigned int freq, int dir)
303 { 303 {
304 struct snd_soc_codec *codec = codec_dai->codec; 304 struct snd_soc_codec *codec = codec_dai->codec;
305 struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec); 305 struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec);
306 306
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 /* use 32 fs for BCLK to save power */ 359 /* use 32 fs for BCLK to save power */
360 mode1 |= 0x4; 360 mode1 |= 0x4;
361 361
362 ak4535_write(codec, AK4535_MODE1, mode1); 362 ak4535_write(codec, AK4535_MODE1, mode1);
363 return 0; 363 return 0;
364 } 364 }
365 365
366 static int ak4535_mute(struct snd_soc_dai *dai, int mute) 366 static int ak4535_mute(struct snd_soc_dai *dai, int mute)
367 { 367 {
368 struct snd_soc_codec *codec = dai->codec; 368 struct snd_soc_codec *codec = dai->codec;
369 » u16 mute_reg = ak4535_read_reg_cache(codec, AK4535_DAC) & 0xffdf; 369 » u16 mute_reg = ak4535_read_reg_cache(codec, AK4535_DAC);
370 if (!mute) 370 if (!mute)
371 » » ak4535_write(codec, AK4535_DAC, mute_reg); 371 » » ak4535_write(codec, AK4535_DAC, mute_reg & ~0x20);
372 else 372 else
373 ak4535_write(codec, AK4535_DAC, mute_reg | 0x20); 373 ak4535_write(codec, AK4535_DAC, mute_reg | 0x20);
374 return 0; 374 return 0;
375 } 375 }
376 376
377 static int ak4535_set_bias_level(struct snd_soc_codec *codec, 377 static int ak4535_set_bias_level(struct snd_soc_codec *codec,
378 enum snd_soc_bias_level level) 378 enum snd_soc_bias_level level)
379 { 379 {
380 u16 i, mute_reg; 380 u16 i, mute_reg;
381 381
382 switch (level) { 382 switch (level) {
383 case SND_SOC_BIAS_ON: 383 case SND_SOC_BIAS_ON:
384 » » mute_reg = ak4535_read_reg_cache(codec, AK4535_DAC) & 0xffdf; 384 » » mute_reg = ak4535_read_reg_cache(codec, AK4535_DAC);
385 » » ak4535_write(codec, AK4535_DAC, mute_reg); 385 » » ak4535_write(codec, AK4535_DAC, mute_reg & ~0x20);
386 break; 386 break;
387 case SND_SOC_BIAS_PREPARE: 387 case SND_SOC_BIAS_PREPARE:
388 » » mute_reg = ak4535_read_reg_cache(codec, AK4535_DAC) & 0xffdf; 388 » » mute_reg = ak4535_read_reg_cache(codec, AK4535_DAC);
389 ak4535_write(codec, AK4535_DAC, mute_reg | 0x20); 389 ak4535_write(codec, AK4535_DAC, mute_reg | 0x20);
390 break; 390 break;
391 case SND_SOC_BIAS_STANDBY: 391 case SND_SOC_BIAS_STANDBY:
392 i = ak4535_read_reg_cache(codec, AK4535_PM1); 392 i = ak4535_read_reg_cache(codec, AK4535_PM1);
393 ak4535_write(codec, AK4535_PM1, i | 0x80); 393 ak4535_write(codec, AK4535_PM1, i | 0x80);
394 i = ak4535_read_reg_cache(codec, AK4535_PM2); 394 i = ak4535_read_reg_cache(codec, AK4535_PM2);
395 ak4535_write(codec, AK4535_PM2, i & (~0x80)); 395 ak4535_write(codec, AK4535_PM2, i & (~0x80));
396 break; 396 break;
397 case SND_SOC_BIAS_OFF: 397 case SND_SOC_BIAS_OFF:
398 i = ak4535_read_reg_cache(codec, AK4535_PM1); 398 i = ak4535_read_reg_cache(codec, AK4535_PM1);
399 ak4535_write(codec, AK4535_PM1, i & (~0x80)); 399 ak4535_write(codec, AK4535_PM1, i & (~0x80));
400 break; 400 break;
401 } 401 }
402 » codec->bias_level = level; 402 » codec->dapm.bias_level = level;
403 return 0; 403 return 0;
404 } 404 }
405 405
406 #define AK4535_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 406 #define AK4535_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
407 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ 407 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
408 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 408 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
409 409
410 static struct snd_soc_dai_ops ak4535_dai_ops = { 410 static struct snd_soc_dai_ops ak4535_dai_ops = {
411 .hw_params = ak4535_hw_params, 411 .hw_params = ak4535_hw_params,
412 .set_fmt = ak4535_set_dai_fmt, 412 .set_fmt = ak4535_set_dai_fmt,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 { 546 {
547 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 547 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
548 i2c_del_driver(&ak4535_i2c_driver); 548 i2c_del_driver(&ak4535_i2c_driver);
549 #endif 549 #endif
550 } 550 }
551 module_exit(ak4535_exit); 551 module_exit(ak4535_exit);
552 552
553 MODULE_DESCRIPTION("Soc AK4535 driver"); 553 MODULE_DESCRIPTION("Soc AK4535 driver");
554 MODULE_AUTHOR("Richard Purdie"); 554 MODULE_AUTHOR("Richard Purdie");
555 MODULE_LICENSE("GPL"); 555 MODULE_LICENSE("GPL");
OLDNEW
« no previous file with comments | « sound/soc/codecs/ad1980.c ('k') | sound/soc/codecs/ak4642.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698