uda1380.c (eaa53216c5909ae1567d15888e55d9b1d7269ca7) | uda1380.c (c001bf633a910cfc8a5b84b80634db4636bf1724) |
---|---|
1/* 2 * uda1380.c - Philips UDA1380 ALSA SoC audio driver 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 * Copyright (c) 2007-2009 Philipp Zabel <philipp.zabel@gmail.com> --- 24 unchanged lines hidden (view full) --- 33#include "uda1380.h" 34 35/* codec private data */ 36struct uda1380_priv { 37 struct snd_soc_codec *codec; 38 unsigned int dac_clk; 39 struct work_struct work; 40 struct i2c_client *i2c; | 1/* 2 * uda1380.c - Philips UDA1380 ALSA SoC audio driver 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 * Copyright (c) 2007-2009 Philipp Zabel <philipp.zabel@gmail.com> --- 24 unchanged lines hidden (view full) --- 33#include "uda1380.h" 34 35/* codec private data */ 36struct uda1380_priv { 37 struct snd_soc_codec *codec; 38 unsigned int dac_clk; 39 struct work_struct work; 40 struct i2c_client *i2c; |
41 u16 *reg_cache; |
|
41}; 42 43/* 44 * uda1380 register cache 45 */ 46static const u16 uda1380_reg[UDA1380_CACHEREGNUM] = { 47 0x0502, 0x0000, 0x0000, 0x3f3f, 48 0x0202, 0x0000, 0x0000, 0x0000, --- 9 unchanged lines hidden (view full) --- 58static unsigned long uda1380_cache_dirty; 59 60/* 61 * read uda1380 register cache 62 */ 63static inline unsigned int uda1380_read_reg_cache(struct snd_soc_codec *codec, 64 unsigned int reg) 65{ | 42}; 43 44/* 45 * uda1380 register cache 46 */ 47static const u16 uda1380_reg[UDA1380_CACHEREGNUM] = { 48 0x0502, 0x0000, 0x0000, 0x3f3f, 49 0x0202, 0x0000, 0x0000, 0x0000, --- 9 unchanged lines hidden (view full) --- 59static unsigned long uda1380_cache_dirty; 60 61/* 62 * read uda1380 register cache 63 */ 64static inline unsigned int uda1380_read_reg_cache(struct snd_soc_codec *codec, 65 unsigned int reg) 66{ |
66 u16 *cache = codec->reg_cache; | 67 struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); 68 u16 *cache = uda1380->reg_cache; 69 |
67 if (reg == UDA1380_RESET) 68 return 0; 69 if (reg >= UDA1380_CACHEREGNUM) 70 return -1; 71 return cache[reg]; 72} 73 74/* 75 * write uda1380 register cache 76 */ 77static inline void uda1380_write_reg_cache(struct snd_soc_codec *codec, 78 u16 reg, unsigned int value) 79{ | 70 if (reg == UDA1380_RESET) 71 return 0; 72 if (reg >= UDA1380_CACHEREGNUM) 73 return -1; 74 return cache[reg]; 75} 76 77/* 78 * write uda1380 register cache 79 */ 80static inline void uda1380_write_reg_cache(struct snd_soc_codec *codec, 81 u16 reg, unsigned int value) 82{ |
80 u16 *cache = codec->reg_cache; | 83 struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); 84 u16 *cache = uda1380->reg_cache; |
81 82 if (reg >= UDA1380_CACHEREGNUM) 83 return; 84 if ((reg >= 0x10) && (cache[reg] != value)) 85 set_bit(reg - 0x10, &uda1380_cache_dirty); 86 cache[reg] = value; 87} 88 --- 40 unchanged lines hidden (view full) --- 129 return -EIO; 130} 131 132static void uda1380_sync_cache(struct snd_soc_codec *codec) 133{ 134 struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); 135 int reg; 136 u8 data[3]; | 85 86 if (reg >= UDA1380_CACHEREGNUM) 87 return; 88 if ((reg >= 0x10) && (cache[reg] != value)) 89 set_bit(reg - 0x10, &uda1380_cache_dirty); 90 cache[reg] = value; 91} 92 --- 40 unchanged lines hidden (view full) --- 133 return -EIO; 134} 135 136static void uda1380_sync_cache(struct snd_soc_codec *codec) 137{ 138 struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); 139 int reg; 140 u8 data[3]; |
137 u16 *cache = codec->reg_cache; | 141 u16 *cache = uda1380->reg_cache; |
138 139 /* Sync reg_cache with the hardware */ 140 for (reg = 0; reg < UDA1380_MVOL; reg++) { 141 data[0] = reg; 142 data[1] = (cache[reg] & 0xff00) >> 8; 143 data[2] = cache[reg] & 0x00ff; 144 if (i2c_master_send(uda1380->i2c, data, 3) != 3) 145 dev_err(codec->dev, "%s: write to reg 0x%x failed\n", --- 571 unchanged lines hidden (view full) --- 717 break; 718 } 719 720 return 0; 721} 722 723static const struct snd_soc_codec_driver soc_codec_dev_uda1380 = { 724 .probe = uda1380_probe, | 142 143 /* Sync reg_cache with the hardware */ 144 for (reg = 0; reg < UDA1380_MVOL; reg++) { 145 data[0] = reg; 146 data[1] = (cache[reg] & 0xff00) >> 8; 147 data[2] = cache[reg] & 0x00ff; 148 if (i2c_master_send(uda1380->i2c, data, 3) != 3) 149 dev_err(codec->dev, "%s: write to reg 0x%x failed\n", --- 571 unchanged lines hidden (view full) --- 721 break; 722 } 723 724 return 0; 725} 726 727static const struct snd_soc_codec_driver soc_codec_dev_uda1380 = { 728 .probe = uda1380_probe, |
725 .read = uda1380_read_reg_cache, 726 .write = uda1380_write, | |
727 .set_bias_level = uda1380_set_bias_level, 728 .suspend_bias_off = true, 729 | 729 .set_bias_level = uda1380_set_bias_level, 730 .suspend_bias_off = true, 731 |
730 .reg_cache_size = ARRAY_SIZE(uda1380_reg), 731 .reg_word_size = sizeof(u16), 732 .reg_cache_default = uda1380_reg, 733 .reg_cache_step = 1, 734 | |
735 .component_driver = { 736 .controls = uda1380_snd_controls, 737 .num_controls = ARRAY_SIZE(uda1380_snd_controls), 738 .dapm_widgets = uda1380_dapm_widgets, 739 .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), 740 .dapm_routes = uda1380_dapm_routes, 741 .num_dapm_routes = ARRAY_SIZE(uda1380_dapm_routes), 742 }, --- 23 unchanged lines hidden (view full) --- 766 767 if (gpio_is_valid(pdata->gpio_power)) { 768 ret = devm_gpio_request_one(&i2c->dev, pdata->gpio_power, 769 GPIOF_OUT_INIT_LOW, "uda1380 power"); 770 if (ret) 771 return ret; 772 } 773 | 732 .component_driver = { 733 .controls = uda1380_snd_controls, 734 .num_controls = ARRAY_SIZE(uda1380_snd_controls), 735 .dapm_widgets = uda1380_dapm_widgets, 736 .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), 737 .dapm_routes = uda1380_dapm_routes, 738 .num_dapm_routes = ARRAY_SIZE(uda1380_dapm_routes), 739 }, --- 23 unchanged lines hidden (view full) --- 763 764 if (gpio_is_valid(pdata->gpio_power)) { 765 ret = devm_gpio_request_one(&i2c->dev, pdata->gpio_power, 766 GPIOF_OUT_INIT_LOW, "uda1380 power"); 767 if (ret) 768 return ret; 769 } 770 |
771 uda1380->reg_cache = devm_kmemdup(&i2c->dev, 772 uda1380_reg, 773 ARRAY_SIZE(uda1380_reg) * sizeof(u16), 774 GFP_KERNEL); 775 if (!uda1380->reg_cache) 776 return -ENOMEM; 777 |
|
774 i2c_set_clientdata(i2c, uda1380); 775 uda1380->i2c = i2c; 776 777 ret = snd_soc_register_codec(&i2c->dev, 778 &soc_codec_dev_uda1380, uda1380_dai, ARRAY_SIZE(uda1380_dai)); 779 return ret; 780} 781 --- 33 unchanged lines hidden --- | 778 i2c_set_clientdata(i2c, uda1380); 779 uda1380->i2c = i2c; 780 781 ret = snd_soc_register_codec(&i2c->dev, 782 &soc_codec_dev_uda1380, uda1380_dai, ARRAY_SIZE(uda1380_dai)); 783 return ret; 784} 785 --- 33 unchanged lines hidden --- |