| OLD | NEW |
| 1 /* | 1 /* |
| 2 * ak4671.c -- audio driver for AK4671 | 2 * ak4671.c -- audio driver for AK4671 |
| 3 * | 3 * |
| 4 * Copyright (C) 2009 Samsung Electronics Co.Ltd | 4 * Copyright (C) 2009 Samsung Electronics Co.Ltd |
| 5 * Author: Joonyoung Shim <jy0922.shim@samsung.com> | 5 * Author: Joonyoung Shim <jy0922.shim@samsung.com> |
| 6 * | 6 * |
| 7 * This program is free software; you can redistribute it and/or modify it | 7 * This program is free software; you can redistribute it and/or modify it |
| 8 * under the terms of the GNU General Public License as published by the | 8 * under the terms of the GNU General Public License as published by the |
| 9 * Free Software Foundation; either version 2 of the License, or (at your | 9 * Free Software Foundation; either version 2 of the License, or (at your |
| 10 * option) any later version. | 10 * option) any later version. |
| 11 * | 11 * |
| 12 */ | 12 */ |
| 13 | 13 |
| 14 #include <linux/module.h> | 14 #include <linux/module.h> |
| 15 #include <linux/init.h> | 15 #include <linux/init.h> |
| 16 #include <linux/i2c.h> | 16 #include <linux/i2c.h> |
| 17 #include <linux/delay.h> | 17 #include <linux/delay.h> |
| 18 #include <linux/slab.h> | 18 #include <linux/slab.h> |
| 19 #include <sound/soc.h> | 19 #include <sound/soc.h> |
| 20 #include <sound/soc-dapm.h> | |
| 21 #include <sound/initval.h> | 20 #include <sound/initval.h> |
| 22 #include <sound/tlv.h> | 21 #include <sound/tlv.h> |
| 23 | 22 |
| 24 #include "ak4671.h" | 23 #include "ak4671.h" |
| 25 | 24 |
| 26 | 25 |
| 27 /* codec private data */ | 26 /* codec private data */ |
| 28 struct ak4671_priv { | 27 struct ak4671_priv { |
| 29 enum snd_soc_control_type control_type; | 28 enum snd_soc_control_type control_type; |
| 30 void *control_data; | 29 void *control_data; |
| 31 u8 reg_cache[AK4671_CACHEREGNUM]; | |
| 32 }; | 30 }; |
| 33 | 31 |
| 34 /* ak4671 register cache & default register settings */ | 32 /* ak4671 register cache & default register settings */ |
| 35 static const u8 ak4671_reg[AK4671_CACHEREGNUM] = { | 33 static const u8 ak4671_reg[AK4671_CACHEREGNUM] = { |
| 36 0x00, /* AK4671_AD_DA_POWER_MANAGEMENT (0x00) */ | 34 0x00, /* AK4671_AD_DA_POWER_MANAGEMENT (0x00) */ |
| 37 0xf6, /* AK4671_PLL_MODE_SELECT0 (0x01) */ | 35 0xf6, /* AK4671_PLL_MODE_SELECT0 (0x01) */ |
| 38 0x00, /* AK4671_PLL_MODE_SELECT1 (0x02) */ | 36 0x00, /* AK4671_PLL_MODE_SELECT1 (0x02) */ |
| 39 0x02, /* AK4671_FORMAT_SELECT (0x03) */ | 37 0x02, /* AK4671_FORMAT_SELECT (0x03) */ |
| 40 0x00, /* AK4671_MIC_SIGNAL_SELECT (0x04) */ | 38 0x00, /* AK4671_MIC_SIGNAL_SELECT (0x04) */ |
| 41 0x55, /* AK4671_MIC_AMP_GAIN (0x05) */ | 39 0x55, /* AK4671_MIC_AMP_GAIN (0x05) */ |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 {"LOUT1 Mixer", "LINL4", "LIN4 Mixing Circuit"}, | 428 {"LOUT1 Mixer", "LINL4", "LIN4 Mixing Circuit"}, |
| 431 {"ROUT1 Mixer", "RINR4", "RIN4 Mixing Circuit"}, | 429 {"ROUT1 Mixer", "RINR4", "RIN4 Mixing Circuit"}, |
| 432 {"LOUT2 Mixer", "LINH4", "LIN4 Mixing Circuit"}, | 430 {"LOUT2 Mixer", "LINH4", "LIN4 Mixing Circuit"}, |
| 433 {"ROUT2 Mixer", "RINH4", "RIN4 Mixing Circuit"}, | 431 {"ROUT2 Mixer", "RINH4", "RIN4 Mixing Circuit"}, |
| 434 {"LOUT3 Mixer", "LINS4", "LIN4 Mixing Circuit"}, | 432 {"LOUT3 Mixer", "LINS4", "LIN4 Mixing Circuit"}, |
| 435 {"ROUT3 Mixer", "RINS4", "RIN4 Mixing Circuit"}, | 433 {"ROUT3 Mixer", "RINS4", "RIN4 Mixing Circuit"}, |
| 436 }; | 434 }; |
| 437 | 435 |
| 438 static int ak4671_add_widgets(struct snd_soc_codec *codec) | 436 static int ak4671_add_widgets(struct snd_soc_codec *codec) |
| 439 { | 437 { |
| 440 » snd_soc_dapm_new_controls(codec, ak4671_dapm_widgets, | 438 » struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 439 |
| 440 » snd_soc_dapm_new_controls(dapm, ak4671_dapm_widgets, |
| 441 ARRAY_SIZE(ak4671_dapm_widgets)); | 441 ARRAY_SIZE(ak4671_dapm_widgets)); |
| 442 | 442 » snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); |
| 443 » snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon)); | |
| 444 | 443 |
| 445 return 0; | 444 return 0; |
| 446 } | 445 } |
| 447 | 446 |
| 448 static int ak4671_hw_params(struct snd_pcm_substream *substream, | 447 static int ak4671_hw_params(struct snd_pcm_substream *substream, |
| 449 struct snd_pcm_hw_params *params, | 448 struct snd_pcm_hw_params *params, |
| 450 struct snd_soc_dai *dai) | 449 struct snd_soc_dai *dai) |
| 451 { | 450 { |
| 452 struct snd_soc_codec *codec = dai->codec; | 451 struct snd_soc_codec *codec = dai->codec; |
| 453 u8 fs; | 452 u8 fs; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 case SND_SOC_BIAS_PREPARE: | 594 case SND_SOC_BIAS_PREPARE: |
| 596 case SND_SOC_BIAS_STANDBY: | 595 case SND_SOC_BIAS_STANDBY: |
| 597 reg = snd_soc_read(codec, AK4671_AD_DA_POWER_MANAGEMENT); | 596 reg = snd_soc_read(codec, AK4671_AD_DA_POWER_MANAGEMENT); |
| 598 snd_soc_write(codec, AK4671_AD_DA_POWER_MANAGEMENT, | 597 snd_soc_write(codec, AK4671_AD_DA_POWER_MANAGEMENT, |
| 599 reg | AK4671_PMVCM); | 598 reg | AK4671_PMVCM); |
| 600 break; | 599 break; |
| 601 case SND_SOC_BIAS_OFF: | 600 case SND_SOC_BIAS_OFF: |
| 602 snd_soc_write(codec, AK4671_AD_DA_POWER_MANAGEMENT, 0x00); | 601 snd_soc_write(codec, AK4671_AD_DA_POWER_MANAGEMENT, 0x00); |
| 603 break; | 602 break; |
| 604 } | 603 } |
| 605 » codec->bias_level = level; | 604 » codec->dapm.bias_level = level; |
| 606 return 0; | 605 return 0; |
| 607 } | 606 } |
| 608 | 607 |
| 609 #define AK4671_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ | 608 #define AK4671_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ |
| 610 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ | 609 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ |
| 611 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ | 610 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ |
| 612 SNDRV_PCM_RATE_48000) | 611 SNDRV_PCM_RATE_48000) |
| 613 | 612 |
| 614 #define AK4671_FORMATS SNDRV_PCM_FMTBIT_S16_LE | 613 #define AK4671_FORMATS SNDRV_PCM_FMTBIT_S16_LE |
| 615 | 614 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 724 |
| 726 static void __exit ak4671_exit(void) | 725 static void __exit ak4671_exit(void) |
| 727 { | 726 { |
| 728 i2c_del_driver(&ak4671_i2c_driver); | 727 i2c_del_driver(&ak4671_i2c_driver); |
| 729 } | 728 } |
| 730 module_exit(ak4671_exit); | 729 module_exit(ak4671_exit); |
| 731 | 730 |
| 732 MODULE_DESCRIPTION("ASoC AK4671 codec driver"); | 731 MODULE_DESCRIPTION("ASoC AK4671 codec driver"); |
| 733 MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); | 732 MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); |
| 734 MODULE_LICENSE("GPL"); | 733 MODULE_LICENSE("GPL"); |
| OLD | NEW |