wm8750.c (4bb09523de50dcf1afc5d3099b9da0381f01b04c) wm8750.c (1321b160fa1cf63fa841d954fe31220366b6647a)
1/*
2 * wm8750.c -- WM8750 ALSA SoC audio driver
3 *
4 * Copyright 2005 Openedhand Ltd.
5 *
6 * Author: Richard Purdie <richard@openedhand.com>
7 *
8 * Based on WM8753.c

--- 37 unchanged lines hidden (view full) ---

46#endif
47#define err(format, arg...) \
48 printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
49#define info(format, arg...) \
50 printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
51#define warn(format, arg...) \
52 printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
53
1/*
2 * wm8750.c -- WM8750 ALSA SoC audio driver
3 *
4 * Copyright 2005 Openedhand Ltd.
5 *
6 * Author: Richard Purdie <richard@openedhand.com>
7 *
8 * Based on WM8753.c

--- 37 unchanged lines hidden (view full) ---

46#endif
47#define err(format, arg...) \
48 printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
49#define info(format, arg...) \
50 printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
51#define warn(format, arg...) \
52 printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
53
54static struct work_struct wm8750_dapm_work;
55
56/*
57 * wm8750 register cache
58 * We can't read the WM8750 register space when we
59 * are using 2 wire for device control, so we cache them instead.
60 */
61static const u16 wm8750_reg[] = {
62 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */
63 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */

--- 931 unchanged lines hidden (view full) ---

995 },
996 .caps = {
997 .num_modes = ARRAY_SIZE(wm8750_modes),
998 .mode = wm8750_modes,
999 },
1000};
1001EXPORT_SYMBOL_GPL(wm8750_dai);
1002
54/*
55 * wm8750 register cache
56 * We can't read the WM8750 register space when we
57 * are using 2 wire for device control, so we cache them instead.
58 */
59static const u16 wm8750_reg[] = {
60 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */
61 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */

--- 931 unchanged lines hidden (view full) ---

993 },
994 .caps = {
995 .num_modes = ARRAY_SIZE(wm8750_modes),
996 .mode = wm8750_modes,
997 },
998};
999EXPORT_SYMBOL_GPL(wm8750_dai);
1000
1003static void wm8750_work(void *data)
1001static void wm8750_work(struct work_struct *work)
1004{
1002{
1005 struct snd_soc_codec *codec = (struct snd_soc_codec *)data;
1003 struct snd_soc_codec *codec =
1004 container_of(work, struct snd_soc_codec, delayed_work.work);
1006 wm8750_dapm_event(codec, codec->dapm_state);
1007}
1008
1009static int wm8750_suspend(struct platform_device *pdev, pm_message_t state)
1010{
1011 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1012 struct snd_soc_codec *codec = socdev->codec;
1013

--- 19 unchanged lines hidden (view full) ---

1033 }
1034
1035 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1036
1037 /* charge wm8750 caps */
1038 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
1039 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
1040 codec->dapm_state = SNDRV_CTL_POWER_D0;
1005 wm8750_dapm_event(codec, codec->dapm_state);
1006}
1007
1008static int wm8750_suspend(struct platform_device *pdev, pm_message_t state)
1009{
1010 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1011 struct snd_soc_codec *codec = socdev->codec;
1012

--- 19 unchanged lines hidden (view full) ---

1032 }
1033
1034 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1035
1036 /* charge wm8750 caps */
1037 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
1038 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
1039 codec->dapm_state = SNDRV_CTL_POWER_D0;
1041 schedule_delayed_work(&wm8750_dapm_work,
1040 schedule_delayed_work(&codec->delayed_work,
1042 msecs_to_jiffies(1000));
1043 }
1044
1045 return 0;
1046}
1047
1048/*
1049 * initialise the WM8750 driver

--- 28 unchanged lines hidden (view full) ---

1078 if (ret < 0) {
1079 kfree(codec->reg_cache);
1080 return ret;
1081 }
1082
1083 /* charge output caps */
1084 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
1085 codec->dapm_state = SNDRV_CTL_POWER_D3hot;
1041 msecs_to_jiffies(1000));
1042 }
1043
1044 return 0;
1045}
1046
1047/*
1048 * initialise the WM8750 driver

--- 28 unchanged lines hidden (view full) ---

1077 if (ret < 0) {
1078 kfree(codec->reg_cache);
1079 return ret;
1080 }
1081
1082 /* charge output caps */
1083 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
1084 codec->dapm_state = SNDRV_CTL_POWER_D3hot;
1086 schedule_delayed_work(&wm8750_dapm_work, msecs_to_jiffies(1000));
1085 schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000));
1087
1088 /* set the update bits */
1089 reg = wm8750_read_reg_cache(codec, WM8750_LDAC);
1090 wm8750_write(codec, WM8750_LDAC, reg | 0x0100);
1091 reg = wm8750_read_reg_cache(codec, WM8750_RDAC);
1092 wm8750_write(codec, WM8750_RDAC, reg | 0x0100);
1093 reg = wm8750_read_reg_cache(codec, WM8750_LOUT1V);
1094 wm8750_write(codec, WM8750_LOUT1V, reg | 0x0100);

--- 125 unchanged lines hidden (view full) ---

1220 if (codec == NULL)
1221 return -ENOMEM;
1222
1223 socdev->codec = codec;
1224 mutex_init(&codec->mutex);
1225 INIT_LIST_HEAD(&codec->dapm_widgets);
1226 INIT_LIST_HEAD(&codec->dapm_paths);
1227 wm8750_socdev = socdev;
1086
1087 /* set the update bits */
1088 reg = wm8750_read_reg_cache(codec, WM8750_LDAC);
1089 wm8750_write(codec, WM8750_LDAC, reg | 0x0100);
1090 reg = wm8750_read_reg_cache(codec, WM8750_RDAC);
1091 wm8750_write(codec, WM8750_RDAC, reg | 0x0100);
1092 reg = wm8750_read_reg_cache(codec, WM8750_LOUT1V);
1093 wm8750_write(codec, WM8750_LOUT1V, reg | 0x0100);

--- 125 unchanged lines hidden (view full) ---

1219 if (codec == NULL)
1220 return -ENOMEM;
1221
1222 socdev->codec = codec;
1223 mutex_init(&codec->mutex);
1224 INIT_LIST_HEAD(&codec->dapm_widgets);
1225 INIT_LIST_HEAD(&codec->dapm_paths);
1226 wm8750_socdev = socdev;
1228 INIT_WORK(&wm8750_dapm_work, wm8750_work, codec);
1227 INIT_DELAYED_WORK(&codec->delayed_work, wm8750_work);
1229#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1230 if (setup->i2c_address) {
1231 normal_i2c[0] = setup->i2c_address;
1232 codec->hw_write = (hw_write_t)i2c_master_send;
1233 ret = i2c_add_driver(&wm8750_i2c_driver);
1234 if (ret != 0)
1235 printk(KERN_ERR "can't add i2c driver");
1236 }

--- 38 unchanged lines hidden ---
1228#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1229 if (setup->i2c_address) {
1230 normal_i2c[0] = setup->i2c_address;
1231 codec->hw_write = (hw_write_t)i2c_master_send;
1232 ret = i2c_add_driver(&wm8750_i2c_driver);
1233 if (ret != 0)
1234 printk(KERN_ERR "can't add i2c driver");
1235 }

--- 38 unchanged lines hidden ---