648
647
static int wm9713_add_widgets(struct snd_soc_codec *codec)
650
snd_soc_dapm_new_controls(codec, wm9713_dapm_widgets,
649
struct snd_soc_dapm_context *dapm = &codec->dapm;
651
snd_soc_dapm_new_controls(dapm, wm9713_dapm_widgets,
651
652
ARRAY_SIZE(wm9713_dapm_widgets));
653
snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
654
snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
1148
1148
ac97_write(codec, AC97_POWERDOWN, 0xffff);
1151
codec->bias_level = level;
1151
codec->dapm.bias_level = level;
1155
static int wm9713_soc_suspend(struct platform_device *pdev,
1155
static int wm9713_soc_suspend(struct snd_soc_codec *codec,
1156
1156
pm_message_t state)
1158
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1159
struct snd_soc_codec *codec = socdev->card->codec;
1162
1160
/* Disable everything except touchpanel - that will be handled
1174
static int wm9713_soc_resume(struct platform_device *pdev)
1172
static int wm9713_soc_resume(struct snd_soc_codec *codec)
1176
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1177
struct snd_soc_codec *codec = socdev->card->codec;
1178
struct wm9713_priv *wm9713 = codec->private_data;
1174
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
1180
1176
u16 *cache = codec->reg_cache;
1204
if (codec->suspend_bias_level == SND_SOC_BIAS_ON)
1205
wm9713_set_bias_level(codec, SND_SOC_BIAS_ON);
1210
static int wm9713_soc_probe(struct platform_device *pdev)
1203
static int wm9713_soc_probe(struct snd_soc_codec *codec)
1212
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1213
struct snd_soc_codec *codec;
1205
struct wm9713_priv *wm9713;
1214
1206
int ret = 0, reg;
1216
socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec),
1218
if (socdev->card->codec == NULL)
1208
wm9713 = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL);
1219
1210
return -ENOMEM;
1220
codec = socdev->card->codec;
1221
mutex_init(&codec->mutex);
1223
codec->reg_cache = kmemdup(wm9713_reg, sizeof(wm9713_reg), GFP_KERNEL);
1224
if (codec->reg_cache == NULL) {
1228
codec->reg_cache_size = sizeof(wm9713_reg);
1229
codec->reg_cache_step = 2;
1231
codec->private_data = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL);
1232
if (codec->private_data == NULL) {
1237
codec->name = "WM9713";
1238
codec->owner = THIS_MODULE;
1239
codec->dai = wm9713_dai;
1240
codec->num_dai = ARRAY_SIZE(wm9713_dai);
1241
codec->write = ac97_write;
1242
codec->read = ac97_read;
1243
codec->set_bias_level = wm9713_set_bias_level;
1244
INIT_LIST_HEAD(&codec->dapm_widgets);
1245
INIT_LIST_HEAD(&codec->dapm_paths);
1211
snd_soc_codec_set_drvdata(codec, wm9713);
1247
1213
ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
1249
1215
goto codec_err;
1252
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1256
1217
/* do a cold reset for the controller and then try
1257
1218
* a warm reset followed by an optional cold reset for codec */
1258
1219
wm9713_reset(codec, 0);
1278
snd_soc_free_pcms(socdev);
1280
1239
snd_soc_free_ac97_codec(codec);
1283
kfree(codec->private_data);
1286
kfree(codec->reg_cache);
1289
kfree(socdev->card->codec);
1290
socdev->card->codec = NULL;
1294
static int wm9713_soc_remove(struct platform_device *pdev)
1245
static int wm9713_soc_remove(struct snd_soc_codec *codec)
1296
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1297
struct snd_soc_codec *codec = socdev->card->codec;
1302
snd_soc_dapm_free(socdev);
1303
snd_soc_free_pcms(socdev);
1247
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
1304
1248
snd_soc_free_ac97_codec(codec);
1305
kfree(codec->private_data);
1306
kfree(codec->reg_cache);
1311
struct snd_soc_codec_device soc_codec_dev_wm9713 = {
1253
static struct snd_soc_codec_driver soc_codec_dev_wm9713 = {
1312
1254
.probe = wm9713_soc_probe,
1313
1255
.remove = wm9713_soc_remove,
1314
1256
.suspend = wm9713_soc_suspend,
1315
1257
.resume = wm9713_soc_resume,
1317
EXPORT_SYMBOL_GPL(soc_codec_dev_wm9713);
1259
.write = ac97_write,
1260
.set_bias_level = wm9713_set_bias_level,
1261
.reg_cache_size = ARRAY_SIZE(wm9713_reg),
1262
.reg_word_size = sizeof(u16),
1263
.reg_cache_step = 2,
1264
.reg_cache_default = wm9713_reg,
1267
static __devinit int wm9713_probe(struct platform_device *pdev)
1269
return snd_soc_register_codec(&pdev->dev,
1270
&soc_codec_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai));
1273
static int __devexit wm9713_remove(struct platform_device *pdev)
1275
snd_soc_unregister_codec(&pdev->dev);
1279
static struct platform_driver wm9713_codec_driver = {
1281
.name = "wm9713-codec",
1282
.owner = THIS_MODULE,
1285
.probe = wm9713_probe,
1286
.remove = __devexit_p(wm9713_remove),
1289
static int __init wm9713_init(void)
1291
return platform_driver_register(&wm9713_codec_driver);
1293
module_init(wm9713_init);
1295
static void __exit wm9713_exit(void)
1297
platform_driver_unregister(&wm9713_codec_driver);
1299
module_exit(wm9713_exit);
1319
1301
MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver");
1320
1302
MODULE_AUTHOR("Liam Girdwood");