diff options
Diffstat (limited to 'sound/soc/codecs/wm8350.c')
-rw-r--r-- | sound/soc/codecs/wm8350.c | 66 |
1 files changed, 21 insertions, 45 deletions
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 593d5b9c9f03..2e0772f9c456 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/slab.h> | ||
16 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
17 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
18 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
@@ -800,7 +801,7 @@ static int wm8350_add_widgets(struct snd_soc_codec *codec) | |||
800 | return ret; | 801 | return ret; |
801 | } | 802 | } |
802 | 803 | ||
803 | return snd_soc_dapm_new_widgets(codec); | 804 | return 0; |
804 | } | 805 | } |
805 | 806 | ||
806 | static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 807 | static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
@@ -925,7 +926,7 @@ static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
925 | iface |= 0x3 << 8; | 926 | iface |= 0x3 << 8; |
926 | break; | 927 | break; |
927 | case SND_SOC_DAIFMT_DSP_B: | 928 | case SND_SOC_DAIFMT_DSP_B: |
928 | iface |= 0x3 << 8; /* lg not sure which mode */ | 929 | iface |= 0x3 << 8 | WM8350_AIF_LRCLK_INV; |
929 | break; | 930 | break; |
930 | default: | 931 | default: |
931 | return -EINVAL; | 932 | return -EINVAL; |
@@ -1101,7 +1102,7 @@ static inline int fll_factors(struct _fll_div *fll_div, unsigned int input, | |||
1101 | } | 1102 | } |
1102 | 1103 | ||
1103 | static int wm8350_set_fll(struct snd_soc_dai *codec_dai, | 1104 | static int wm8350_set_fll(struct snd_soc_dai *codec_dai, |
1104 | int pll_id, unsigned int freq_in, | 1105 | int pll_id, int source, unsigned int freq_in, |
1105 | unsigned int freq_out) | 1106 | unsigned int freq_out) |
1106 | { | 1107 | { |
1107 | struct snd_soc_codec *codec = codec_dai->codec; | 1108 | struct snd_soc_codec *codec = codec_dai->codec; |
@@ -1340,15 +1341,16 @@ static int wm8350_resume(struct platform_device *pdev) | |||
1340 | return 0; | 1341 | return 0; |
1341 | } | 1342 | } |
1342 | 1343 | ||
1343 | static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) | 1344 | static irqreturn_t wm8350_hp_jack_handler(int irq, void *data) |
1344 | { | 1345 | { |
1345 | struct wm8350_data *priv = data; | 1346 | struct wm8350_data *priv = data; |
1347 | struct wm8350 *wm8350 = priv->codec.control_data; | ||
1346 | u16 reg; | 1348 | u16 reg; |
1347 | int report; | 1349 | int report; |
1348 | int mask; | 1350 | int mask; |
1349 | struct wm8350_jack_data *jack = NULL; | 1351 | struct wm8350_jack_data *jack = NULL; |
1350 | 1352 | ||
1351 | switch (irq) { | 1353 | switch (irq - wm8350->irq_base) { |
1352 | case WM8350_IRQ_CODEC_JCK_DET_L: | 1354 | case WM8350_IRQ_CODEC_JCK_DET_L: |
1353 | jack = &priv->hpl; | 1355 | jack = &priv->hpl; |
1354 | mask = WM8350_JACK_L_LVL; | 1356 | mask = WM8350_JACK_L_LVL; |
@@ -1365,7 +1367,7 @@ static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) | |||
1365 | 1367 | ||
1366 | if (!jack->jack) { | 1368 | if (!jack->jack) { |
1367 | dev_warn(wm8350->dev, "Jack interrupt called with no jack\n"); | 1369 | dev_warn(wm8350->dev, "Jack interrupt called with no jack\n"); |
1368 | return; | 1370 | return IRQ_NONE; |
1369 | } | 1371 | } |
1370 | 1372 | ||
1371 | /* Debounce */ | 1373 | /* Debounce */ |
@@ -1378,6 +1380,8 @@ static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) | |||
1378 | report = 0; | 1380 | report = 0; |
1379 | 1381 | ||
1380 | snd_soc_jack_report(jack->jack, report, jack->report); | 1382 | snd_soc_jack_report(jack->jack, report, jack->report); |
1383 | |||
1384 | return IRQ_HANDLED; | ||
1381 | } | 1385 | } |
1382 | 1386 | ||
1383 | /** | 1387 | /** |
@@ -1421,9 +1425,7 @@ int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, | |||
1421 | wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); | 1425 | wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); |
1422 | 1426 | ||
1423 | /* Sync status */ | 1427 | /* Sync status */ |
1424 | wm8350_hp_jack_handler(wm8350, irq, priv); | 1428 | wm8350_hp_jack_handler(irq + wm8350->irq_base, priv); |
1425 | |||
1426 | wm8350_unmask_irq(wm8350, irq); | ||
1427 | 1429 | ||
1428 | return 0; | 1430 | return 0; |
1429 | } | 1431 | } |
@@ -1482,12 +1484,16 @@ static int wm8350_probe(struct platform_device *pdev) | |||
1482 | wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, | 1484 | wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, |
1483 | WM8350_OUT2_VU | WM8350_OUT2R_MUTE); | 1485 | WM8350_OUT2_VU | WM8350_OUT2R_MUTE); |
1484 | 1486 | ||
1485 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); | 1487 | /* Make sure jack detect is disabled to start off with */ |
1486 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); | 1488 | wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, |
1489 | WM8350_JDL_ENA | WM8350_JDR_ENA); | ||
1490 | |||
1487 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, | 1491 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, |
1488 | wm8350_hp_jack_handler, priv); | 1492 | wm8350_hp_jack_handler, 0, "Left jack detect", |
1493 | priv); | ||
1489 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, | 1494 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, |
1490 | wm8350_hp_jack_handler, priv); | 1495 | wm8350_hp_jack_handler, 0, "Right jack detect", |
1496 | priv); | ||
1491 | 1497 | ||
1492 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | 1498 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); |
1493 | if (ret < 0) { | 1499 | if (ret < 0) { |
@@ -1501,18 +1507,7 @@ static int wm8350_probe(struct platform_device *pdev) | |||
1501 | 1507 | ||
1502 | wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1508 | wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
1503 | 1509 | ||
1504 | ret = snd_soc_init_card(socdev); | ||
1505 | if (ret < 0) { | ||
1506 | dev_err(&pdev->dev, "failed to register card\n"); | ||
1507 | goto card_err; | ||
1508 | } | ||
1509 | |||
1510 | return 0; | 1510 | return 0; |
1511 | |||
1512 | card_err: | ||
1513 | snd_soc_free_pcms(socdev); | ||
1514 | snd_soc_dapm_free(socdev); | ||
1515 | return ret; | ||
1516 | } | 1511 | } |
1517 | 1512 | ||
1518 | static int wm8350_remove(struct platform_device *pdev) | 1513 | static int wm8350_remove(struct platform_device *pdev) |
@@ -1527,10 +1522,8 @@ static int wm8350_remove(struct platform_device *pdev) | |||
1527 | WM8350_JDL_ENA | WM8350_JDR_ENA); | 1522 | WM8350_JDL_ENA | WM8350_JDR_ENA); |
1528 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); | 1523 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); |
1529 | 1524 | ||
1530 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); | 1525 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv); |
1531 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); | 1526 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv); |
1532 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); | ||
1533 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); | ||
1534 | 1527 | ||
1535 | priv->hpl.jack = NULL; | 1528 | priv->hpl.jack = NULL; |
1536 | priv->hpr.jack = NULL; | 1529 | priv->hpr.jack = NULL; |
@@ -1680,21 +1673,6 @@ static int __devexit wm8350_codec_remove(struct platform_device *pdev) | |||
1680 | return 0; | 1673 | return 0; |
1681 | } | 1674 | } |
1682 | 1675 | ||
1683 | #ifdef CONFIG_PM | ||
1684 | static int wm8350_codec_suspend(struct platform_device *pdev, pm_message_t m) | ||
1685 | { | ||
1686 | return snd_soc_suspend_device(&pdev->dev); | ||
1687 | } | ||
1688 | |||
1689 | static int wm8350_codec_resume(struct platform_device *pdev) | ||
1690 | { | ||
1691 | return snd_soc_resume_device(&pdev->dev); | ||
1692 | } | ||
1693 | #else | ||
1694 | #define wm8350_codec_suspend NULL | ||
1695 | #define wm8350_codec_resume NULL | ||
1696 | #endif | ||
1697 | |||
1698 | static struct platform_driver wm8350_codec_driver = { | 1676 | static struct platform_driver wm8350_codec_driver = { |
1699 | .driver = { | 1677 | .driver = { |
1700 | .name = "wm8350-codec", | 1678 | .name = "wm8350-codec", |
@@ -1702,8 +1680,6 @@ static struct platform_driver wm8350_codec_driver = { | |||
1702 | }, | 1680 | }, |
1703 | .probe = wm8350_codec_probe, | 1681 | .probe = wm8350_codec_probe, |
1704 | .remove = __devexit_p(wm8350_codec_remove), | 1682 | .remove = __devexit_p(wm8350_codec_remove), |
1705 | .suspend = wm8350_codec_suspend, | ||
1706 | .resume = wm8350_codec_resume, | ||
1707 | }; | 1683 | }; |
1708 | 1684 | ||
1709 | static __init int wm8350_init(void) | 1685 | static __init int wm8350_init(void) |