| OLD | NEW |
| 1 /* | 1 /* |
| 2 * max98088.c -- MAX98088 ALSA SoC Audio driver | 2 * max98088.c -- MAX98088 ALSA SoC Audio driver |
| 3 * | 3 * |
| 4 * Copyright 2010 Maxim Integrated Products | 4 * Copyright 2010 Maxim Integrated Products |
| 5 * | 5 * |
| 6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
| 8 * published by the Free Software Foundation. | 8 * published by the Free Software Foundation. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <linux/module.h> | 11 #include <linux/module.h> |
| 12 #include <linux/moduleparam.h> | 12 #include <linux/moduleparam.h> |
| 13 #include <linux/kernel.h> | 13 #include <linux/kernel.h> |
| 14 #include <linux/init.h> | 14 #include <linux/init.h> |
| 15 #include <linux/delay.h> | 15 #include <linux/delay.h> |
| 16 #include <linux/pm.h> | 16 #include <linux/pm.h> |
| 17 #include <linux/i2c.h> | 17 #include <linux/i2c.h> |
| 18 #include <linux/platform_device.h> | 18 #include <linux/platform_device.h> |
| 19 #include <sound/core.h> | 19 #include <sound/core.h> |
| 20 #include <sound/pcm.h> | 20 #include <sound/pcm.h> |
| 21 #include <sound/pcm_params.h> | 21 #include <sound/pcm_params.h> |
| 22 #include <sound/soc.h> | 22 #include <sound/soc.h> |
| 23 #include <sound/soc-dapm.h> | |
| 24 #include <sound/initval.h> | 23 #include <sound/initval.h> |
| 25 #include <sound/tlv.h> | 24 #include <sound/tlv.h> |
| 26 #include <linux/slab.h> | 25 #include <linux/slab.h> |
| 27 #include <asm/div64.h> | 26 #include <asm/div64.h> |
| 28 #include <sound/max98088.h> | 27 #include <sound/max98088.h> |
| 29 #include "max98088.h" | 28 #include "max98088.h" |
| 30 | 29 |
| 31 enum max98088_type { | 30 enum max98088_type { |
| 32 MAX98088, | 31 MAX98088, |
| 33 MAX98089, | 32 MAX98089, |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 { 0x00, 0x00, 0 }, /* F8 */ | 601 { 0x00, 0x00, 0 }, /* F8 */ |
| 603 { 0x00, 0x00, 0 }, /* F9 */ | 602 { 0x00, 0x00, 0 }, /* F9 */ |
| 604 { 0x00, 0x00, 0 }, /* FA */ | 603 { 0x00, 0x00, 0 }, /* FA */ |
| 605 { 0x00, 0x00, 0 }, /* FB */ | 604 { 0x00, 0x00, 0 }, /* FB */ |
| 606 { 0x00, 0x00, 0 }, /* FC */ | 605 { 0x00, 0x00, 0 }, /* FC */ |
| 607 { 0x00, 0x00, 0 }, /* FD */ | 606 { 0x00, 0x00, 0 }, /* FD */ |
| 608 { 0x00, 0x00, 0 }, /* FE */ | 607 { 0x00, 0x00, 0 }, /* FE */ |
| 609 { 0xFF, 0x00, 1 }, /* FF */ | 608 { 0xFF, 0x00, 1 }, /* FF */ |
| 610 }; | 609 }; |
| 611 | 610 |
| 612 static int max98088_volatile_register(unsigned int reg) | 611 static int max98088_volatile_register(struct snd_soc_codec *codec, unsigned int
reg) |
| 613 { | 612 { |
| 614 return max98088_access[reg].vol; | 613 return max98088_access[reg].vol; |
| 615 } | 614 } |
| 616 | 615 |
| 617 | 616 |
| 618 /* | 617 /* |
| 619 * Load equalizer DSP coefficient configurations registers | 618 * Load equalizer DSP coefficient configurations registers |
| 620 */ | 619 */ |
| 621 static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai, | 620 static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai, |
| 622 unsigned int band, u16 *coefs) | 621 unsigned int band, u16 *coefs) |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 {"INA1 Input", NULL, "INA1"}, | 1221 {"INA1 Input", NULL, "INA1"}, |
| 1223 {"INA2 Input", NULL, "INA2"}, | 1222 {"INA2 Input", NULL, "INA2"}, |
| 1224 {"INB1 Input", NULL, "INB1"}, | 1223 {"INB1 Input", NULL, "INB1"}, |
| 1225 {"INB2 Input", NULL, "INB2"}, | 1224 {"INB2 Input", NULL, "INB2"}, |
| 1226 {"MIC1 Input", NULL, "MIC1"}, | 1225 {"MIC1 Input", NULL, "MIC1"}, |
| 1227 {"MIC2 Input", NULL, "MIC2"}, | 1226 {"MIC2 Input", NULL, "MIC2"}, |
| 1228 }; | 1227 }; |
| 1229 | 1228 |
| 1230 static int max98088_add_widgets(struct snd_soc_codec *codec) | 1229 static int max98088_add_widgets(struct snd_soc_codec *codec) |
| 1231 { | 1230 { |
| 1232 snd_soc_dapm_new_controls(codec, max98088_dapm_widgets, | 1231 struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 1232 |
| 1233 snd_soc_dapm_new_controls(dapm, max98088_dapm_widgets, |
| 1233 ARRAY_SIZE(max98088_dapm_widgets)); | 1234 ARRAY_SIZE(max98088_dapm_widgets)); |
| 1234 | 1235 |
| 1235 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | 1236 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
| 1236 | 1237 |
| 1237 snd_soc_add_controls(codec, max98088_snd_controls, | 1238 snd_soc_add_controls(codec, max98088_snd_controls, |
| 1238 ARRAY_SIZE(max98088_snd_controls)); | 1239 ARRAY_SIZE(max98088_snd_controls)); |
| 1239 | 1240 |
| 1240 snd_soc_dapm_new_widgets(codec); | 1241 snd_soc_dapm_new_widgets(dapm); |
| 1241 return 0; | 1242 return 0; |
| 1242 } | 1243 } |
| 1243 | 1244 |
| 1244 /* codec mclk clock divider coefficients */ | 1245 /* codec mclk clock divider coefficients */ |
| 1245 static const struct { | 1246 static const struct { |
| 1246 u32 rate; | 1247 u32 rate; |
| 1247 u8 sr; | 1248 u8 sr; |
| 1248 } rate_table[] = { | 1249 } rate_table[] = { |
| 1249 {8000, 0x10}, | 1250 {8000, 0x10}, |
| 1250 {11025, 0x20}, | 1251 {11025, 0x20}, |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 enum snd_soc_bias_level level) | 1616 enum snd_soc_bias_level level) |
| 1616 { | 1617 { |
| 1617 switch (level) { | 1618 switch (level) { |
| 1618 case SND_SOC_BIAS_ON: | 1619 case SND_SOC_BIAS_ON: |
| 1619 break; | 1620 break; |
| 1620 | 1621 |
| 1621 case SND_SOC_BIAS_PREPARE: | 1622 case SND_SOC_BIAS_PREPARE: |
| 1622 break; | 1623 break; |
| 1623 | 1624 |
| 1624 case SND_SOC_BIAS_STANDBY: | 1625 case SND_SOC_BIAS_STANDBY: |
| 1625 if (codec->bias_level == SND_SOC_BIAS_OFF) | 1626 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) |
| 1626 max98088_sync_cache(codec); | 1627 max98088_sync_cache(codec); |
| 1627 | 1628 |
| 1628 snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, | 1629 snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, |
| 1629 M98088_MBEN, M98088_MBEN); | 1630 M98088_MBEN, M98088_MBEN); |
| 1630 break; | 1631 break; |
| 1631 | 1632 |
| 1632 case SND_SOC_BIAS_OFF: | 1633 case SND_SOC_BIAS_OFF: |
| 1633 snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, | 1634 snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, |
| 1634 M98088_MBEN, 0); | 1635 M98088_MBEN, 0); |
| 1635 codec->cache_sync = 1; | 1636 codec->cache_sync = 1; |
| 1636 break; | 1637 break; |
| 1637 } | 1638 } |
| 1638 codec->bias_level = level; | 1639 codec->dapm.bias_level = level; |
| 1639 return 0; | 1640 return 0; |
| 1640 } | 1641 } |
| 1641 | 1642 |
| 1642 #define MAX98088_RATES SNDRV_PCM_RATE_8000_96000 | 1643 #define MAX98088_RATES SNDRV_PCM_RATE_8000_96000 |
| 1643 #define MAX98088_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) | 1644 #define MAX98088_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) |
| 1644 | 1645 |
| 1645 static struct snd_soc_dai_ops max98088_dai1_ops = { | 1646 static struct snd_soc_dai_ops max98088_dai1_ops = { |
| 1646 .set_sysclk = max98088_dai_set_sysclk, | 1647 .set_sysclk = max98088_dai_set_sysclk, |
| 1647 .set_fmt = max98088_dai1_set_fmt, | 1648 .set_fmt = max98088_dai1_set_fmt, |
| 1648 .hw_params = max98088_dai1_hw_params, | 1649 .hw_params = max98088_dai1_hw_params, |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 int ret = 0; | 1951 int ret = 0; |
| 1951 | 1952 |
| 1952 codec->cache_sync = 1; | 1953 codec->cache_sync = 1; |
| 1953 | 1954 |
| 1954 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); | 1955 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); |
| 1955 if (ret != 0) { | 1956 if (ret != 0) { |
| 1956 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 1957 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 1957 return ret; | 1958 return ret; |
| 1958 } | 1959 } |
| 1959 | 1960 |
| 1960 /* initalize private data */ | 1961 /* initialize private data */ |
| 1961 | 1962 |
| 1962 max98088->sysclk = (unsigned)-1; | 1963 max98088->sysclk = (unsigned)-1; |
| 1963 max98088->eq_textcnt = 0; | 1964 max98088->eq_textcnt = 0; |
| 1964 | 1965 |
| 1965 cdata = &max98088->dai[0]; | 1966 cdata = &max98088->dai[0]; |
| 1966 cdata->rate = (unsigned)-1; | 1967 cdata->rate = (unsigned)-1; |
| 1967 cdata->fmt = (unsigned)-1; | 1968 cdata->fmt = (unsigned)-1; |
| 1968 cdata->eq_sel = 0; | 1969 cdata->eq_sel = 0; |
| 1969 | 1970 |
| 1970 cdata = &max98088->dai[1]; | 1971 cdata = &max98088->dai[1]; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 | 2099 |
| 2099 static void __exit max98088_exit(void) | 2100 static void __exit max98088_exit(void) |
| 2100 { | 2101 { |
| 2101 i2c_del_driver(&max98088_i2c_driver); | 2102 i2c_del_driver(&max98088_i2c_driver); |
| 2102 } | 2103 } |
| 2103 module_exit(max98088_exit); | 2104 module_exit(max98088_exit); |
| 2104 | 2105 |
| 2105 MODULE_DESCRIPTION("ALSA SoC MAX98088 driver"); | 2106 MODULE_DESCRIPTION("ALSA SoC MAX98088 driver"); |
| 2106 MODULE_AUTHOR("Peter Hsiang, Jesse Marroquin"); | 2107 MODULE_AUTHOR("Peter Hsiang, Jesse Marroquin"); |
| 2107 MODULE_LICENSE("GPL"); | 2108 MODULE_LICENSE("GPL"); |
| OLD | NEW |