~ubuntu-branches/ubuntu/precise/alsa-driver/precise

« back to all changes in this revision

Viewing changes to alsa-kernel/soc/codecs/wm9713.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2011-02-21 18:06:40 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20110221180640-a8p2yxtvgf7xbxub
Tags: 1.0.24+dfsg-0ubuntu1
* New upstream release
* Refreshed patches:
  - distinguish_kernel_makefile_and_source_dirs.patch
  - debian_dfsg_configure.patch
* debian/control: Update Vcs-bzr field to point to new branch location

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <sound/pcm_params.h>
27
27
#include <sound/tlv.h>
28
28
#include <sound/soc.h>
29
 
#include <sound/soc-dapm.h>
30
29
 
31
30
#include "wm9713.h"
32
31
 
647
646
 
648
647
static int wm9713_add_widgets(struct snd_soc_codec *codec)
649
648
{
650
 
        snd_soc_dapm_new_controls(codec, wm9713_dapm_widgets,
 
649
        struct snd_soc_dapm_context *dapm = &codec->dapm;
 
650
 
 
651
        snd_soc_dapm_new_controls(dapm, wm9713_dapm_widgets,
651
652
                                  ARRAY_SIZE(wm9713_dapm_widgets));
652
653
 
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));
654
655
 
655
656
        return 0;
656
657
}
764
765
static int wm9713_set_pll(struct snd_soc_codec *codec,
765
766
        int pll_id, unsigned int freq_in, unsigned int freq_out)
766
767
{
767
 
        struct wm9713_priv *wm9713 = codec->private_data;
 
768
        struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
768
769
        u16 reg, reg2;
769
770
        struct _pll_div pll_div;
770
771
 
1057
1058
        .set_tristate   = wm9713_set_dai_tristate,
1058
1059
};
1059
1060
 
1060
 
struct snd_soc_dai wm9713_dai[] = {
 
1061
static struct snd_soc_dai_driver wm9713_dai[] = {
1061
1062
{
1062
 
        .name = "AC97 HiFi",
 
1063
        .name = "wm9713-hifi",
1063
1064
        .ac97_control = 1,
1064
1065
        .playback = {
1065
1066
                .stream_name = "HiFi Playback",
1076
1077
        .ops = &wm9713_dai_ops_hifi,
1077
1078
        },
1078
1079
        {
1079
 
        .name = "AC97 Aux",
 
1080
        .name = "wm9713-aux",
1080
1081
        .playback = {
1081
1082
                .stream_name = "Aux Playback",
1082
1083
                .channels_min = 1,
1086
1087
        .ops = &wm9713_dai_ops_aux,
1087
1088
        },
1088
1089
        {
1089
 
        .name = "WM9713 Voice",
 
1090
        .name = "wm9713-voice",
1090
1091
        .playback = {
1091
1092
                .stream_name = "Voice Playback",
1092
1093
                .channels_min = 1,
1103
1104
        .symmetric_rates = 1,
1104
1105
        },
1105
1106
};
1106
 
EXPORT_SYMBOL_GPL(wm9713_dai);
1107
1107
 
1108
1108
int wm9713_reset(struct snd_soc_codec *codec, int try_warm)
1109
1109
{
1148
1148
                ac97_write(codec, AC97_POWERDOWN, 0xffff);
1149
1149
                break;
1150
1150
        }
1151
 
        codec->bias_level = level;
 
1151
        codec->dapm.bias_level = level;
1152
1152
        return 0;
1153
1153
}
1154
1154
 
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)
1157
1157
{
1158
 
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1159
 
        struct snd_soc_codec *codec = socdev->card->codec;
1160
1158
        u16 reg;
1161
1159
 
1162
1160
        /* Disable everything except touchpanel - that will be handled
1171
1169
        return 0;
1172
1170
}
1173
1171
 
1174
 
static int wm9713_soc_resume(struct platform_device *pdev)
 
1172
static int wm9713_soc_resume(struct snd_soc_codec *codec)
1175
1173
{
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);
1179
1175
        int i, ret;
1180
1176
        u16 *cache = codec->reg_cache;
1181
1177
 
1201
1197
                }
1202
1198
        }
1203
1199
 
1204
 
        if (codec->suspend_bias_level == SND_SOC_BIAS_ON)
1205
 
                wm9713_set_bias_level(codec, SND_SOC_BIAS_ON);
1206
 
 
1207
1200
        return ret;
1208
1201
}
1209
1202
 
1210
 
static int wm9713_soc_probe(struct platform_device *pdev)
 
1203
static int wm9713_soc_probe(struct snd_soc_codec *codec)
1211
1204
{
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;
1215
1207
 
1216
 
        socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec),
1217
 
                                      GFP_KERNEL);
1218
 
        if (socdev->card->codec == NULL)
 
1208
        wm9713 = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL);
 
1209
        if (wm9713 == NULL)
1219
1210
                return -ENOMEM;
1220
 
        codec = socdev->card->codec;
1221
 
        mutex_init(&codec->mutex);
1222
 
 
1223
 
        codec->reg_cache = kmemdup(wm9713_reg, sizeof(wm9713_reg), GFP_KERNEL);
1224
 
        if (codec->reg_cache == NULL) {
1225
 
                ret = -ENOMEM;
1226
 
                goto cache_err;
1227
 
        }
1228
 
        codec->reg_cache_size = sizeof(wm9713_reg);
1229
 
        codec->reg_cache_step = 2;
1230
 
 
1231
 
        codec->private_data = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL);
1232
 
        if (codec->private_data == NULL) {
1233
 
                ret = -ENOMEM;
1234
 
                goto priv_err;
1235
 
        }
1236
 
 
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);
1246
1212
 
1247
1213
        ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
1248
1214
        if (ret < 0)
1249
1215
                goto codec_err;
1250
1216
 
1251
 
        /* register pcms */
1252
 
        ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1253
 
        if (ret < 0)
1254
 
                goto pcm_err;
1255
 
 
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);
1275
1236
        return 0;
1276
1237
 
1277
1238
reset_err:
1278
 
        snd_soc_free_pcms(socdev);
1279
 
pcm_err:
1280
1239
        snd_soc_free_ac97_codec(codec);
1281
 
 
1282
1240
codec_err:
1283
 
        kfree(codec->private_data);
1284
 
 
1285
 
priv_err:
1286
 
        kfree(codec->reg_cache);
1287
 
 
1288
 
cache_err:
1289
 
        kfree(socdev->card->codec);
1290
 
        socdev->card->codec = NULL;
 
1241
        kfree(wm9713);
1291
1242
        return ret;
1292
1243
}
1293
1244
 
1294
 
static int wm9713_soc_remove(struct platform_device *pdev)
 
1245
static int wm9713_soc_remove(struct snd_soc_codec *codec)
1295
1246
{
1296
 
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1297
 
        struct snd_soc_codec *codec = socdev->card->codec;
1298
 
 
1299
 
        if (codec == NULL)
1300
 
                return 0;
1301
 
 
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);
1307
 
        kfree(codec);
 
1249
        kfree(wm9713);
1308
1250
        return 0;
1309
1251
}
1310
1252
 
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,
1316
 
};
1317
 
EXPORT_SYMBOL_GPL(soc_codec_dev_wm9713);
 
1258
        .read = ac97_read,
 
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,
 
1265
};
 
1266
 
 
1267
static __devinit int wm9713_probe(struct platform_device *pdev)
 
1268
{
 
1269
        return snd_soc_register_codec(&pdev->dev,
 
1270
                        &soc_codec_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai));
 
1271
}
 
1272
 
 
1273
static int __devexit wm9713_remove(struct platform_device *pdev)
 
1274
{
 
1275
        snd_soc_unregister_codec(&pdev->dev);
 
1276
        return 0;
 
1277
}
 
1278
 
 
1279
static struct platform_driver wm9713_codec_driver = {
 
1280
        .driver = {
 
1281
                        .name = "wm9713-codec",
 
1282
                        .owner = THIS_MODULE,
 
1283
        },
 
1284
 
 
1285
        .probe = wm9713_probe,
 
1286
        .remove = __devexit_p(wm9713_remove),
 
1287
};
 
1288
 
 
1289
static int __init wm9713_init(void)
 
1290
{
 
1291
        return platform_driver_register(&wm9713_codec_driver);
 
1292
}
 
1293
module_init(wm9713_init);
 
1294
 
 
1295
static void __exit wm9713_exit(void)
 
1296
{
 
1297
        platform_driver_unregister(&wm9713_codec_driver);
 
1298
}
 
1299
module_exit(wm9713_exit);
1318
1300
 
1319
1301
MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver");
1320
1302
MODULE_AUTHOR("Liam Girdwood");