wm8900.c (cf0dbba515415bb19b11f9323d5f7bebd7f24fd6) | wm8900.c (b2c812e22de88bb79c290c0e718280f10b64a48d) |
---|---|
1/* 2 * wm8900.c -- WM8900 ALSA Soc Audio driver 3 * 4 * Copyright 2007, 2008 Wolfson Microelectronics PLC. 5 * 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 10 unchanged lines hidden (view full) --- 19#include <linux/module.h> 20#include <linux/moduleparam.h> 21#include <linux/kernel.h> 22#include <linux/init.h> 23#include <linux/delay.h> 24#include <linux/pm.h> 25#include <linux/i2c.h> 26#include <linux/platform_device.h> | 1/* 2 * wm8900.c -- WM8900 ALSA Soc Audio driver 3 * 4 * Copyright 2007, 2008 Wolfson Microelectronics PLC. 5 * 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 10 unchanged lines hidden (view full) --- 19#include <linux/module.h> 20#include <linux/moduleparam.h> 21#include <linux/kernel.h> 22#include <linux/init.h> 23#include <linux/delay.h> 24#include <linux/pm.h> 25#include <linux/i2c.h> 26#include <linux/platform_device.h> |
27#include <linux/slab.h> | |
28#include <sound/core.h> 29#include <sound/pcm.h> 30#include <sound/pcm_params.h> 31#include <sound/soc.h> 32#include <sound/soc-dapm.h> 33#include <sound/initval.h> 34#include <sound/tlv.h> 35 --- 704 unchanged lines hidden (view full) --- 740 BUG_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n); 741 742 return 0; 743} 744 745static int wm8900_set_fll(struct snd_soc_codec *codec, 746 int fll_id, unsigned int freq_in, unsigned int freq_out) 747{ | 27#include <sound/core.h> 28#include <sound/pcm.h> 29#include <sound/pcm_params.h> 30#include <sound/soc.h> 31#include <sound/soc-dapm.h> 32#include <sound/initval.h> 33#include <sound/tlv.h> 34 --- 704 unchanged lines hidden (view full) --- 739 BUG_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n); 740 741 return 0; 742} 743 744static int wm8900_set_fll(struct snd_soc_codec *codec, 745 int fll_id, unsigned int freq_in, unsigned int freq_out) 746{ |
748 struct wm8900_priv *wm8900 = codec->private_data; | 747 struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); |
749 struct _fll_div fll_div; 750 unsigned int reg; 751 752 if (wm8900->fll_in == freq_in && wm8900->fll_out == freq_out) 753 return 0; 754 755 /* The digital side should be disabled during any change. */ 756 reg = snd_soc_read(codec, WM8900_REG_POWER1); --- 370 unchanged lines hidden (view full) --- 1127 codec->bias_level = level; 1128 return 0; 1129} 1130 1131static int wm8900_suspend(struct platform_device *pdev, pm_message_t state) 1132{ 1133 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 1134 struct snd_soc_codec *codec = socdev->card->codec; | 748 struct _fll_div fll_div; 749 unsigned int reg; 750 751 if (wm8900->fll_in == freq_in && wm8900->fll_out == freq_out) 752 return 0; 753 754 /* The digital side should be disabled during any change. */ 755 reg = snd_soc_read(codec, WM8900_REG_POWER1); --- 370 unchanged lines hidden (view full) --- 1126 codec->bias_level = level; 1127 return 0; 1128} 1129 1130static int wm8900_suspend(struct platform_device *pdev, pm_message_t state) 1131{ 1132 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 1133 struct snd_soc_codec *codec = socdev->card->codec; |
1135 struct wm8900_priv *wm8900 = codec->private_data; | 1134 struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); |
1136 int fll_out = wm8900->fll_out; 1137 int fll_in = wm8900->fll_in; 1138 int ret; 1139 1140 /* Stop the FLL in an orderly fashion */ 1141 ret = wm8900_set_fll(codec, 0, 0, 0); 1142 if (ret != 0) { 1143 dev_err(&pdev->dev, "Failed to stop FLL\n"); --- 7 unchanged lines hidden (view full) --- 1151 1152 return 0; 1153} 1154 1155static int wm8900_resume(struct platform_device *pdev) 1156{ 1157 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 1158 struct snd_soc_codec *codec = socdev->card->codec; | 1135 int fll_out = wm8900->fll_out; 1136 int fll_in = wm8900->fll_in; 1137 int ret; 1138 1139 /* Stop the FLL in an orderly fashion */ 1140 ret = wm8900_set_fll(codec, 0, 0, 0); 1141 if (ret != 0) { 1142 dev_err(&pdev->dev, "Failed to stop FLL\n"); --- 7 unchanged lines hidden (view full) --- 1150 1151 return 0; 1152} 1153 1154static int wm8900_resume(struct platform_device *pdev) 1155{ 1156 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 1157 struct snd_soc_codec *codec = socdev->card->codec; |
1159 struct wm8900_priv *wm8900 = codec->private_data; | 1158 struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); |
1160 u16 *cache; 1161 int i, ret; 1162 1163 cache = kmemdup(codec->reg_cache, sizeof(wm8900_reg_defaults), 1164 GFP_KERNEL); 1165 1166 wm8900_reset(codec); 1167 wm8900_set_bias_level(codec, SND_SOC_BIAS_STANDBY); --- 33 unchanged lines hidden (view full) --- 1201 unsigned int reg; 1202 int ret; 1203 1204 wm8900 = kzalloc(sizeof(struct wm8900_priv), GFP_KERNEL); 1205 if (wm8900 == NULL) 1206 return -ENOMEM; 1207 1208 codec = &wm8900->codec; | 1159 u16 *cache; 1160 int i, ret; 1161 1162 cache = kmemdup(codec->reg_cache, sizeof(wm8900_reg_defaults), 1163 GFP_KERNEL); 1164 1165 wm8900_reset(codec); 1166 wm8900_set_bias_level(codec, SND_SOC_BIAS_STANDBY); --- 33 unchanged lines hidden (view full) --- 1200 unsigned int reg; 1201 int ret; 1202 1203 wm8900 = kzalloc(sizeof(struct wm8900_priv), GFP_KERNEL); 1204 if (wm8900 == NULL) 1205 return -ENOMEM; 1206 1207 codec = &wm8900->codec; |
1209 codec->private_data = wm8900; | 1208 snd_soc_codec_set_drvdata(codec, wm8900); |
1210 codec->reg_cache = &wm8900->reg_cache[0]; 1211 codec->reg_cache_size = WM8900_MAXREG; 1212 1213 mutex_init(&codec->mutex); 1214 INIT_LIST_HEAD(&codec->dapm_widgets); 1215 INIT_LIST_HEAD(&codec->dapm_paths); 1216 1217 codec->name = "WM8900"; --- 82 unchanged lines hidden (view full) --- 1300static __devexit int wm8900_i2c_remove(struct i2c_client *client) 1301{ 1302 snd_soc_unregister_dai(&wm8900_dai); 1303 snd_soc_unregister_codec(wm8900_codec); 1304 1305 wm8900_set_bias_level(wm8900_codec, SND_SOC_BIAS_OFF); 1306 1307 wm8900_dai.dev = NULL; | 1209 codec->reg_cache = &wm8900->reg_cache[0]; 1210 codec->reg_cache_size = WM8900_MAXREG; 1211 1212 mutex_init(&codec->mutex); 1213 INIT_LIST_HEAD(&codec->dapm_widgets); 1214 INIT_LIST_HEAD(&codec->dapm_paths); 1215 1216 codec->name = "WM8900"; --- 82 unchanged lines hidden (view full) --- 1299static __devexit int wm8900_i2c_remove(struct i2c_client *client) 1300{ 1301 snd_soc_unregister_dai(&wm8900_dai); 1302 snd_soc_unregister_codec(wm8900_codec); 1303 1304 wm8900_set_bias_level(wm8900_codec, SND_SOC_BIAS_OFF); 1305 1306 wm8900_dai.dev = NULL; |
1308 kfree(wm8900_codec->private_data); | 1307 kfree(snd_soc_codec_get_drvdata(wm8900_codec)); |
1309 wm8900_codec = NULL; 1310 1311 return 0; 1312} 1313 1314static const struct i2c_device_id wm8900_i2c_id[] = { 1315 { "wm8900", 0 }, 1316 { } --- 76 unchanged lines hidden --- | 1308 wm8900_codec = NULL; 1309 1310 return 0; 1311} 1312 1313static const struct i2c_device_id wm8900_i2c_id[] = { 1314 { "wm8900", 0 }, 1315 { } --- 76 unchanged lines hidden --- |