| OLD | NEW |
| 1 /* | 1 /* |
| 2 * File: sound/soc/codecs/ad1836.c | 2 * File: sound/soc/codecs/ad1836.c |
| 3 * Author: Barry Song <Barry.Song@analog.com> | 3 * Author: Barry Song <Barry.Song@analog.com> |
| 4 * | 4 * |
| 5 * Created: Aug 04 2009 | 5 * Created: Aug 04 2009 |
| 6 * Description: Driver for AD1836 sound chip | 6 * Description: Driver for AD1836 sound chip |
| 7 * | 7 * |
| 8 * Modified: | 8 * Modified: |
| 9 * Copyright 2009 Analog Devices Inc. | 9 * Copyright 2009 Analog Devices Inc. |
| 10 * | 10 * |
| 11 * Bugs: Enter bugs at http://blackfin.uclinux.org/ | 11 * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 12 * | 12 * |
| 13 * This program is free software; you can redistribute it and/or modify | 13 * This program is free software; you can redistribute it and/or modify |
| 14 * it under the terms of the GNU General Public License as published by | 14 * it under the terms of the GNU General Public License as published by |
| 15 * the Free Software Foundation; either version 2 of the License, or | 15 * the Free Software Foundation; either version 2 of the License, or |
| 16 * (at your option) any later version. | 16 * (at your option) any later version. |
| 17 */ | 17 */ |
| 18 | 18 |
| 19 #include <linux/init.h> | 19 #include <linux/init.h> |
| 20 #include <linux/slab.h> | 20 #include <linux/slab.h> |
| 21 #include <linux/module.h> | 21 #include <linux/module.h> |
| 22 #include <linux/kernel.h> | 22 #include <linux/kernel.h> |
| 23 #include <linux/device.h> | 23 #include <linux/device.h> |
| 24 #include <sound/core.h> | 24 #include <sound/core.h> |
| 25 #include <sound/pcm.h> | 25 #include <sound/pcm.h> |
| 26 #include <sound/pcm_params.h> | 26 #include <sound/pcm_params.h> |
| 27 #include <sound/initval.h> | 27 #include <sound/initval.h> |
| 28 #include <sound/soc.h> | 28 #include <sound/soc.h> |
| 29 #include <sound/tlv.h> | 29 #include <sound/tlv.h> |
| 30 #include <sound/soc-dapm.h> | |
| 31 #include <linux/spi/spi.h> | 30 #include <linux/spi/spi.h> |
| 32 #include "ad1836.h" | 31 #include "ad1836.h" |
| 33 | 32 |
| 34 /* codec private data */ | 33 /* codec private data */ |
| 35 struct ad1836_priv { | 34 struct ad1836_priv { |
| 36 enum snd_soc_control_type control_type; | 35 enum snd_soc_control_type control_type; |
| 37 void *control_data; | 36 void *control_data; |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 /* | 39 /* |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 .rates = SNDRV_PCM_RATE_48000, | 212 .rates = SNDRV_PCM_RATE_48000, |
| 214 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | | 213 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | |
| 215 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, | 214 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, |
| 216 }, | 215 }, |
| 217 .ops = &ad1836_dai_ops, | 216 .ops = &ad1836_dai_ops, |
| 218 }; | 217 }; |
| 219 | 218 |
| 220 static int ad1836_probe(struct snd_soc_codec *codec) | 219 static int ad1836_probe(struct snd_soc_codec *codec) |
| 221 { | 220 { |
| 222 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); | 221 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); |
| 222 struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 223 int ret = 0; | 223 int ret = 0; |
| 224 | 224 |
| 225 codec->control_data = ad1836->control_data; | 225 codec->control_data = ad1836->control_data; |
| 226 ret = snd_soc_codec_set_cache_io(codec, 4, 12, SND_SOC_SPI); | 226 ret = snd_soc_codec_set_cache_io(codec, 4, 12, SND_SOC_SPI); |
| 227 if (ret < 0) { | 227 if (ret < 0) { |
| 228 dev_err(codec->dev, "failed to set cache I/O: %d\n", | 228 dev_err(codec->dev, "failed to set cache I/O: %d\n", |
| 229 ret); | 229 ret); |
| 230 kfree(ad1836); | |
| 231 return ret; | 230 return ret; |
| 232 } | 231 } |
| 233 | 232 |
| 234 /* default setting for ad1836 */ | 233 /* default setting for ad1836 */ |
| 235 /* de-emphasis: 48kHz, power-on dac */ | 234 /* de-emphasis: 48kHz, power-on dac */ |
| 236 snd_soc_write(codec, AD1836_DAC_CTRL1, 0x300); | 235 snd_soc_write(codec, AD1836_DAC_CTRL1, 0x300); |
| 237 /* unmute dac channels */ | 236 /* unmute dac channels */ |
| 238 snd_soc_write(codec, AD1836_DAC_CTRL2, 0x0); | 237 snd_soc_write(codec, AD1836_DAC_CTRL2, 0x0); |
| 239 /* high-pass filter enable, power-on adc */ | 238 /* high-pass filter enable, power-on adc */ |
| 240 snd_soc_write(codec, AD1836_ADC_CTRL1, 0x100); | 239 snd_soc_write(codec, AD1836_ADC_CTRL1, 0x100); |
| 241 /* unmute adc channles, adc aux mode */ | 240 /* unmute adc channles, adc aux mode */ |
| 242 snd_soc_write(codec, AD1836_ADC_CTRL2, 0x180); | 241 snd_soc_write(codec, AD1836_ADC_CTRL2, 0x180); |
| 243 /* left/right diff:PGA/MUX */ | 242 /* left/right diff:PGA/MUX */ |
| 244 snd_soc_write(codec, AD1836_ADC_CTRL3, 0x3A); | 243 snd_soc_write(codec, AD1836_ADC_CTRL3, 0x3A); |
| 245 /* volume */ | 244 /* volume */ |
| 246 snd_soc_write(codec, AD1836_DAC_L1_VOL, 0x3FF); | 245 snd_soc_write(codec, AD1836_DAC_L1_VOL, 0x3FF); |
| 247 snd_soc_write(codec, AD1836_DAC_R1_VOL, 0x3FF); | 246 snd_soc_write(codec, AD1836_DAC_R1_VOL, 0x3FF); |
| 248 snd_soc_write(codec, AD1836_DAC_L2_VOL, 0x3FF); | 247 snd_soc_write(codec, AD1836_DAC_L2_VOL, 0x3FF); |
| 249 snd_soc_write(codec, AD1836_DAC_R2_VOL, 0x3FF); | 248 snd_soc_write(codec, AD1836_DAC_R2_VOL, 0x3FF); |
| 250 snd_soc_write(codec, AD1836_DAC_L3_VOL, 0x3FF); | 249 snd_soc_write(codec, AD1836_DAC_L3_VOL, 0x3FF); |
| 251 snd_soc_write(codec, AD1836_DAC_R3_VOL, 0x3FF); | 250 snd_soc_write(codec, AD1836_DAC_R3_VOL, 0x3FF); |
| 252 | 251 |
| 253 snd_soc_add_controls(codec, ad1836_snd_controls, | 252 snd_soc_add_controls(codec, ad1836_snd_controls, |
| 254 ARRAY_SIZE(ad1836_snd_controls)); | 253 ARRAY_SIZE(ad1836_snd_controls)); |
| 255 » snd_soc_dapm_new_controls(codec, ad1836_dapm_widgets, | 254 » snd_soc_dapm_new_controls(dapm, ad1836_dapm_widgets, |
| 256 ARRAY_SIZE(ad1836_dapm_widgets)); | 255 ARRAY_SIZE(ad1836_dapm_widgets)); |
| 257 » snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); | 256 » snd_soc_dapm_add_routes(dapm, audio_paths, ARRAY_SIZE(audio_paths)); |
| 258 | 257 |
| 259 return ret; | 258 return ret; |
| 260 } | 259 } |
| 261 | 260 |
| 262 /* power down chip */ | 261 /* power down chip */ |
| 263 static int ad1836_remove(struct snd_soc_codec *codec) | 262 static int ad1836_remove(struct snd_soc_codec *codec) |
| 264 { | 263 { |
| 265 /* reset clock control mode */ | 264 /* reset clock control mode */ |
| 266 u16 adc_ctrl2 = snd_soc_read(codec, AD1836_ADC_CTRL2); | 265 u16 adc_ctrl2 = snd_soc_read(codec, AD1836_ADC_CTRL2); |
| 267 adc_ctrl2 &= ~AD1836_ADC_SERFMT_MASK; | 266 adc_ctrl2 &= ~AD1836_ADC_SERFMT_MASK; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 329 |
| 331 static void __exit ad1836_exit(void) | 330 static void __exit ad1836_exit(void) |
| 332 { | 331 { |
| 333 spi_unregister_driver(&ad1836_spi_driver); | 332 spi_unregister_driver(&ad1836_spi_driver); |
| 334 } | 333 } |
| 335 module_exit(ad1836_exit); | 334 module_exit(ad1836_exit); |
| 336 | 335 |
| 337 MODULE_DESCRIPTION("ASoC ad1836 driver"); | 336 MODULE_DESCRIPTION("ASoC ad1836 driver"); |
| 338 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); | 337 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); |
| 339 MODULE_LICENSE("GPL"); | 338 MODULE_LICENSE("GPL"); |
| OLD | NEW |