diff options
Diffstat (limited to 'sound/soc/codecs/wm8903.c')
-rw-r--r-- | sound/soc/codecs/wm8903.c | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index bde74546db4a..8cf571f1a803 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -744,21 +744,6 @@ SOC_DOUBLE_R_TLV("Speaker Volume", | |||
744 | 0, 63, 0, out_tlv), | 744 | 0, 63, 0, out_tlv), |
745 | }; | 745 | }; |
746 | 746 | ||
747 | static int wm8903_add_controls(struct snd_soc_codec *codec) | ||
748 | { | ||
749 | int err, i; | ||
750 | |||
751 | for (i = 0; i < ARRAY_SIZE(wm8903_snd_controls); i++) { | ||
752 | err = snd_ctl_add(codec->card, | ||
753 | snd_soc_cnew(&wm8903_snd_controls[i], | ||
754 | codec, NULL)); | ||
755 | if (err < 0) | ||
756 | return err; | ||
757 | } | ||
758 | |||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | static const struct snd_kcontrol_new linput_mode_mux = | 747 | static const struct snd_kcontrol_new linput_mode_mux = |
763 | SOC_DAPM_ENUM("Left Input Mode Mux", linput_mode_enum); | 748 | SOC_DAPM_ENUM("Left Input Mode Mux", linput_mode_enum); |
764 | 749 | ||
@@ -1276,7 +1261,7 @@ static int wm8903_startup(struct snd_pcm_substream *substream, | |||
1276 | { | 1261 | { |
1277 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1262 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
1278 | struct snd_soc_device *socdev = rtd->socdev; | 1263 | struct snd_soc_device *socdev = rtd->socdev; |
1279 | struct snd_soc_codec *codec = socdev->codec; | 1264 | struct snd_soc_codec *codec = socdev->card->codec; |
1280 | struct wm8903_priv *wm8903 = codec->private_data; | 1265 | struct wm8903_priv *wm8903 = codec->private_data; |
1281 | struct i2c_client *i2c = codec->control_data; | 1266 | struct i2c_client *i2c = codec->control_data; |
1282 | struct snd_pcm_runtime *master_runtime; | 1267 | struct snd_pcm_runtime *master_runtime; |
@@ -1318,7 +1303,7 @@ static void wm8903_shutdown(struct snd_pcm_substream *substream, | |||
1318 | { | 1303 | { |
1319 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1304 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
1320 | struct snd_soc_device *socdev = rtd->socdev; | 1305 | struct snd_soc_device *socdev = rtd->socdev; |
1321 | struct snd_soc_codec *codec = socdev->codec; | 1306 | struct snd_soc_codec *codec = socdev->card->codec; |
1322 | struct wm8903_priv *wm8903 = codec->private_data; | 1307 | struct wm8903_priv *wm8903 = codec->private_data; |
1323 | 1308 | ||
1324 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 1309 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
@@ -1338,7 +1323,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, | |||
1338 | { | 1323 | { |
1339 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1324 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
1340 | struct snd_soc_device *socdev = rtd->socdev; | 1325 | struct snd_soc_device *socdev = rtd->socdev; |
1341 | struct snd_soc_codec *codec = socdev->codec; | 1326 | struct snd_soc_codec *codec = socdev->card->codec; |
1342 | struct wm8903_priv *wm8903 = codec->private_data; | 1327 | struct wm8903_priv *wm8903 = codec->private_data; |
1343 | struct i2c_client *i2c = codec->control_data; | 1328 | struct i2c_client *i2c = codec->control_data; |
1344 | int fs = params_rate(params); | 1329 | int fs = params_rate(params); |
@@ -1512,6 +1497,15 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, | |||
1512 | SNDRV_PCM_FMTBIT_S20_3LE |\ | 1497 | SNDRV_PCM_FMTBIT_S20_3LE |\ |
1513 | SNDRV_PCM_FMTBIT_S24_LE) | 1498 | SNDRV_PCM_FMTBIT_S24_LE) |
1514 | 1499 | ||
1500 | static struct snd_soc_dai_ops wm8903_dai_ops = { | ||
1501 | .startup = wm8903_startup, | ||
1502 | .shutdown = wm8903_shutdown, | ||
1503 | .hw_params = wm8903_hw_params, | ||
1504 | .digital_mute = wm8903_digital_mute, | ||
1505 | .set_fmt = wm8903_set_dai_fmt, | ||
1506 | .set_sysclk = wm8903_set_dai_sysclk, | ||
1507 | }; | ||
1508 | |||
1515 | struct snd_soc_dai wm8903_dai = { | 1509 | struct snd_soc_dai wm8903_dai = { |
1516 | .name = "WM8903", | 1510 | .name = "WM8903", |
1517 | .playback = { | 1511 | .playback = { |
@@ -1528,21 +1522,14 @@ struct snd_soc_dai wm8903_dai = { | |||
1528 | .rates = WM8903_CAPTURE_RATES, | 1522 | .rates = WM8903_CAPTURE_RATES, |
1529 | .formats = WM8903_FORMATS, | 1523 | .formats = WM8903_FORMATS, |
1530 | }, | 1524 | }, |
1531 | .ops = { | 1525 | .ops = &wm8903_dai_ops, |
1532 | .startup = wm8903_startup, | ||
1533 | .shutdown = wm8903_shutdown, | ||
1534 | .hw_params = wm8903_hw_params, | ||
1535 | .digital_mute = wm8903_digital_mute, | ||
1536 | .set_fmt = wm8903_set_dai_fmt, | ||
1537 | .set_sysclk = wm8903_set_dai_sysclk | ||
1538 | } | ||
1539 | }; | 1526 | }; |
1540 | EXPORT_SYMBOL_GPL(wm8903_dai); | 1527 | EXPORT_SYMBOL_GPL(wm8903_dai); |
1541 | 1528 | ||
1542 | static int wm8903_suspend(struct platform_device *pdev, pm_message_t state) | 1529 | static int wm8903_suspend(struct platform_device *pdev, pm_message_t state) |
1543 | { | 1530 | { |
1544 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 1531 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
1545 | struct snd_soc_codec *codec = socdev->codec; | 1532 | struct snd_soc_codec *codec = socdev->card->codec; |
1546 | 1533 | ||
1547 | wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1534 | wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); |
1548 | 1535 | ||
@@ -1552,7 +1539,7 @@ static int wm8903_suspend(struct platform_device *pdev, pm_message_t state) | |||
1552 | static int wm8903_resume(struct platform_device *pdev) | 1539 | static int wm8903_resume(struct platform_device *pdev) |
1553 | { | 1540 | { |
1554 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 1541 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
1555 | struct snd_soc_codec *codec = socdev->codec; | 1542 | struct snd_soc_codec *codec = socdev->card->codec; |
1556 | struct i2c_client *i2c = codec->control_data; | 1543 | struct i2c_client *i2c = codec->control_data; |
1557 | int i; | 1544 | int i; |
1558 | u16 *reg_cache = codec->reg_cache; | 1545 | u16 *reg_cache = codec->reg_cache; |
@@ -1577,8 +1564,8 @@ static int wm8903_resume(struct platform_device *pdev) | |||
1577 | 1564 | ||
1578 | static struct snd_soc_codec *wm8903_codec; | 1565 | static struct snd_soc_codec *wm8903_codec; |
1579 | 1566 | ||
1580 | static int wm8903_i2c_probe(struct i2c_client *i2c, | 1567 | static __devinit int wm8903_i2c_probe(struct i2c_client *i2c, |
1581 | const struct i2c_device_id *id) | 1568 | const struct i2c_device_id *id) |
1582 | { | 1569 | { |
1583 | struct wm8903_priv *wm8903; | 1570 | struct wm8903_priv *wm8903; |
1584 | struct snd_soc_codec *codec; | 1571 | struct snd_soc_codec *codec; |
@@ -1684,7 +1671,7 @@ err: | |||
1684 | return ret; | 1671 | return ret; |
1685 | } | 1672 | } |
1686 | 1673 | ||
1687 | static int wm8903_i2c_remove(struct i2c_client *client) | 1674 | static __devexit int wm8903_i2c_remove(struct i2c_client *client) |
1688 | { | 1675 | { |
1689 | struct snd_soc_codec *codec = i2c_get_clientdata(client); | 1676 | struct snd_soc_codec *codec = i2c_get_clientdata(client); |
1690 | 1677 | ||
@@ -1714,7 +1701,7 @@ static struct i2c_driver wm8903_i2c_driver = { | |||
1714 | .owner = THIS_MODULE, | 1701 | .owner = THIS_MODULE, |
1715 | }, | 1702 | }, |
1716 | .probe = wm8903_i2c_probe, | 1703 | .probe = wm8903_i2c_probe, |
1717 | .remove = wm8903_i2c_remove, | 1704 | .remove = __devexit_p(wm8903_i2c_remove), |
1718 | .id_table = wm8903_i2c_id, | 1705 | .id_table = wm8903_i2c_id, |
1719 | }; | 1706 | }; |
1720 | 1707 | ||
@@ -1728,7 +1715,7 @@ static int wm8903_probe(struct platform_device *pdev) | |||
1728 | goto err; | 1715 | goto err; |
1729 | } | 1716 | } |
1730 | 1717 | ||
1731 | socdev->codec = wm8903_codec; | 1718 | socdev->card->codec = wm8903_codec; |
1732 | 1719 | ||
1733 | /* register pcms */ | 1720 | /* register pcms */ |
1734 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | 1721 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); |
@@ -1737,8 +1724,9 @@ static int wm8903_probe(struct platform_device *pdev) | |||
1737 | goto err; | 1724 | goto err; |
1738 | } | 1725 | } |
1739 | 1726 | ||
1740 | wm8903_add_controls(socdev->codec); | 1727 | snd_soc_add_controls(socdev->card->codec, wm8903_snd_controls, |
1741 | wm8903_add_widgets(socdev->codec); | 1728 | ARRAY_SIZE(wm8903_snd_controls)); |
1729 | wm8903_add_widgets(socdev->card->codec); | ||
1742 | 1730 | ||
1743 | ret = snd_soc_init_card(socdev); | 1731 | ret = snd_soc_init_card(socdev); |
1744 | if (ret < 0) { | 1732 | if (ret < 0) { |
@@ -1759,7 +1747,7 @@ err: | |||
1759 | static int wm8903_remove(struct platform_device *pdev) | 1747 | static int wm8903_remove(struct platform_device *pdev) |
1760 | { | 1748 | { |
1761 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 1749 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
1762 | struct snd_soc_codec *codec = socdev->codec; | 1750 | struct snd_soc_codec *codec = socdev->card->codec; |
1763 | 1751 | ||
1764 | if (codec->control_data) | 1752 | if (codec->control_data) |
1765 | wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1753 | wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); |