diff options
Diffstat (limited to 'sound/soc/pxa/poodle.c')
-rw-r--r-- | sound/soc/pxa/poodle.c | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index cad2c4c0ac95..a51058f66747 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/moduleparam.h> | 18 | #include <linux/moduleparam.h> |
19 | #include <linux/timer.h> | 19 | #include <linux/timer.h> |
20 | #include <linux/i2c.h> | ||
20 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
22 | #include <sound/core.h> | 23 | #include <sound/core.h> |
@@ -75,7 +76,7 @@ static void poodle_ext_control(struct snd_soc_codec *codec) | |||
75 | static int poodle_startup(struct snd_pcm_substream *substream) | 76 | static int poodle_startup(struct snd_pcm_substream *substream) |
76 | { | 77 | { |
77 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 78 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
78 | struct snd_soc_codec *codec = rtd->socdev->codec; | 79 | struct snd_soc_codec *codec = rtd->socdev->card->codec; |
79 | 80 | ||
80 | /* check the jack status at stream startup */ | 81 | /* check the jack status at stream startup */ |
81 | poodle_ext_control(codec); | 82 | poodle_ext_control(codec); |
@@ -238,19 +239,17 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = { | |||
238 | */ | 239 | */ |
239 | static int poodle_wm8731_init(struct snd_soc_codec *codec) | 240 | static int poodle_wm8731_init(struct snd_soc_codec *codec) |
240 | { | 241 | { |
241 | int i, err; | 242 | int err; |
242 | 243 | ||
243 | snd_soc_dapm_nc_pin(codec, "LLINEIN"); | 244 | snd_soc_dapm_nc_pin(codec, "LLINEIN"); |
244 | snd_soc_dapm_nc_pin(codec, "RLINEIN"); | 245 | snd_soc_dapm_nc_pin(codec, "RLINEIN"); |
245 | snd_soc_dapm_enable_pin(codec, "MICIN"); | 246 | snd_soc_dapm_enable_pin(codec, "MICIN"); |
246 | 247 | ||
247 | /* Add poodle specific controls */ | 248 | /* Add poodle specific controls */ |
248 | for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) { | 249 | err = snd_soc_add_controls(codec, wm8731_poodle_controls, |
249 | err = snd_ctl_add(codec->card, | 250 | ARRAY_SIZE(wm8731_poodle_controls)); |
250 | snd_soc_cnew(&wm8731_poodle_controls[i], codec, NULL)); | 251 | if (err < 0) |
251 | if (err < 0) | 252 | return err; |
252 | return err; | ||
253 | } | ||
254 | 253 | ||
255 | /* Add poodle specific widgets */ | 254 | /* Add poodle specific widgets */ |
256 | snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, | 255 | snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, |
@@ -281,17 +280,42 @@ static struct snd_soc_card snd_soc_poodle = { | |||
281 | .num_links = 1, | 280 | .num_links = 1, |
282 | }; | 281 | }; |
283 | 282 | ||
284 | /* poodle audio private data */ | 283 | /* |
285 | static struct wm8731_setup_data poodle_wm8731_setup = { | 284 | * FIXME: This is a temporary bodge to avoid cross-tree merge issues. |
286 | .i2c_bus = 0, | 285 | * New drivers should register the wm8731 I2C device in the machine |
287 | .i2c_address = 0x1b, | 286 | * setup code (under arch/arm for ARM systems). |
288 | }; | 287 | */ |
288 | static int wm8731_i2c_register(void) | ||
289 | { | ||
290 | struct i2c_board_info info; | ||
291 | struct i2c_adapter *adapter; | ||
292 | struct i2c_client *client; | ||
293 | |||
294 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
295 | info.addr = 0x1b; | ||
296 | strlcpy(info.type, "wm8731", I2C_NAME_SIZE); | ||
297 | |||
298 | adapter = i2c_get_adapter(0); | ||
299 | if (!adapter) { | ||
300 | printk(KERN_ERR "can't get i2c adapter 0\n"); | ||
301 | return -ENODEV; | ||
302 | } | ||
303 | |||
304 | client = i2c_new_device(adapter, &info); | ||
305 | i2c_put_adapter(adapter); | ||
306 | if (!client) { | ||
307 | printk(KERN_ERR "can't add i2c device at 0x%x\n", | ||
308 | (unsigned int)info.addr); | ||
309 | return -ENODEV; | ||
310 | } | ||
311 | |||
312 | return 0; | ||
313 | } | ||
289 | 314 | ||
290 | /* poodle audio subsystem */ | 315 | /* poodle audio subsystem */ |
291 | static struct snd_soc_device poodle_snd_devdata = { | 316 | static struct snd_soc_device poodle_snd_devdata = { |
292 | .card = &snd_soc_poodle, | 317 | .card = &snd_soc_poodle, |
293 | .codec_dev = &soc_codec_dev_wm8731, | 318 | .codec_dev = &soc_codec_dev_wm8731, |
294 | .codec_data = &poodle_wm8731_setup, | ||
295 | }; | 319 | }; |
296 | 320 | ||
297 | static struct platform_device *poodle_snd_device; | 321 | static struct platform_device *poodle_snd_device; |
@@ -303,6 +327,10 @@ static int __init poodle_init(void) | |||
303 | if (!machine_is_poodle()) | 327 | if (!machine_is_poodle()) |
304 | return -ENODEV; | 328 | return -ENODEV; |
305 | 329 | ||
330 | ret = wm8731_i2c_register(); | ||
331 | if (ret != 0) | ||
332 | return ret; | ||
333 | |||
306 | locomo_gpio_set_dir(&poodle_locomo_device.dev, | 334 | locomo_gpio_set_dir(&poodle_locomo_device.dev, |
307 | POODLE_LOCOMO_GPIO_AMP_ON, 0); | 335 | POODLE_LOCOMO_GPIO_AMP_ON, 0); |
308 | /* should we mute HP at startup - burning power ?*/ | 336 | /* should we mute HP at startup - burning power ?*/ |