diff options
Diffstat (limited to 'sound/soc/codecs/wm5102.c')
-rw-r--r-- | sound/soc/codecs/wm5102.c | 93 |
1 files changed, 88 insertions, 5 deletions
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 64637d1cf4e5..a8b3e3f701f9 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c | |||
@@ -619,7 +619,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, | |||
619 | { | 619 | { |
620 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 620 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
621 | struct arizona *arizona = dev_get_drvdata(codec->dev->parent); | 621 | struct arizona *arizona = dev_get_drvdata(codec->dev->parent); |
622 | unsigned int v; | 622 | unsigned int v = 0; |
623 | int ret; | 623 | int ret; |
624 | 624 | ||
625 | switch (event) { | 625 | switch (event) { |
@@ -654,7 +654,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, | |||
654 | break; | 654 | break; |
655 | } | 655 | } |
656 | 656 | ||
657 | return wm_adsp2_early_event(w, kcontrol, event); | 657 | return wm_adsp2_early_event(w, kcontrol, event, v); |
658 | } | 658 | } |
659 | 659 | ||
660 | static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, | 660 | static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, |
@@ -1408,7 +1408,7 @@ ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"), | |||
1408 | ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), | 1408 | ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), |
1409 | ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), | 1409 | ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), |
1410 | 1410 | ||
1411 | WM_ADSP2_E("DSP1", 0, wm5102_adsp_power_ev), | 1411 | WM_ADSP2("DSP1", 0, wm5102_adsp_power_ev), |
1412 | 1412 | ||
1413 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), | 1413 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), |
1414 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), | 1414 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), |
@@ -1599,6 +1599,9 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = { | |||
1599 | { "Slim2 Capture", NULL, "SYSCLK" }, | 1599 | { "Slim2 Capture", NULL, "SYSCLK" }, |
1600 | { "Slim3 Capture", NULL, "SYSCLK" }, | 1600 | { "Slim3 Capture", NULL, "SYSCLK" }, |
1601 | 1601 | ||
1602 | { "Audio Trace DSP", NULL, "DSP1" }, | ||
1603 | { "Audio Trace DSP", NULL, "SYSCLK" }, | ||
1604 | |||
1602 | { "IN1L PGA", NULL, "IN1L" }, | 1605 | { "IN1L PGA", NULL, "IN1L" }, |
1603 | { "IN1R PGA", NULL, "IN1R" }, | 1606 | { "IN1R PGA", NULL, "IN1R" }, |
1604 | 1607 | ||
@@ -1735,7 +1738,7 @@ static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source, | |||
1735 | } | 1738 | } |
1736 | } | 1739 | } |
1737 | 1740 | ||
1738 | #define WM5102_RATES SNDRV_PCM_RATE_8000_192000 | 1741 | #define WM5102_RATES SNDRV_PCM_RATE_KNOT |
1739 | 1742 | ||
1740 | #define WM5102_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | 1743 | #define WM5102_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
1741 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | 1744 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) |
@@ -1864,14 +1867,67 @@ static struct snd_soc_dai_driver wm5102_dai[] = { | |||
1864 | }, | 1867 | }, |
1865 | .ops = &arizona_simple_dai_ops, | 1868 | .ops = &arizona_simple_dai_ops, |
1866 | }, | 1869 | }, |
1870 | { | ||
1871 | .name = "wm5102-cpu-trace", | ||
1872 | .capture = { | ||
1873 | .stream_name = "Audio Trace CPU", | ||
1874 | .channels_min = 1, | ||
1875 | .channels_max = 6, | ||
1876 | .rates = WM5102_RATES, | ||
1877 | .formats = WM5102_FORMATS, | ||
1878 | }, | ||
1879 | .compress_new = snd_soc_new_compress, | ||
1880 | }, | ||
1881 | { | ||
1882 | .name = "wm5102-dsp-trace", | ||
1883 | .capture = { | ||
1884 | .stream_name = "Audio Trace DSP", | ||
1885 | .channels_min = 1, | ||
1886 | .channels_max = 4, | ||
1887 | .rates = WM5102_RATES, | ||
1888 | .formats = WM5102_FORMATS, | ||
1889 | }, | ||
1890 | }, | ||
1867 | }; | 1891 | }; |
1868 | 1892 | ||
1893 | static int wm5102_open(struct snd_compr_stream *stream) | ||
1894 | { | ||
1895 | struct snd_soc_pcm_runtime *rtd = stream->private_data; | ||
1896 | struct wm5102_priv *priv = snd_soc_codec_get_drvdata(rtd->codec); | ||
1897 | |||
1898 | return wm_adsp_compr_open(&priv->core.adsp[0], stream); | ||
1899 | } | ||
1900 | |||
1901 | static irqreturn_t wm5102_adsp2_irq(int irq, void *data) | ||
1902 | { | ||
1903 | struct wm5102_priv *priv = data; | ||
1904 | struct arizona *arizona = priv->core.arizona; | ||
1905 | int ret; | ||
1906 | |||
1907 | ret = wm_adsp_compr_handle_irq(&priv->core.adsp[0]); | ||
1908 | if (ret == -ENODEV) { | ||
1909 | dev_err(arizona->dev, "Spurious compressed data IRQ\n"); | ||
1910 | return IRQ_NONE; | ||
1911 | } | ||
1912 | |||
1913 | return IRQ_HANDLED; | ||
1914 | } | ||
1915 | |||
1869 | static int wm5102_codec_probe(struct snd_soc_codec *codec) | 1916 | static int wm5102_codec_probe(struct snd_soc_codec *codec) |
1870 | { | 1917 | { |
1871 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | 1918 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); |
1872 | struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); | 1919 | struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); |
1920 | struct arizona *arizona = priv->core.arizona; | ||
1873 | int ret; | 1921 | int ret; |
1874 | 1922 | ||
1923 | ret = arizona_request_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, | ||
1924 | "ADSP2 Compressed IRQ", wm5102_adsp2_irq, | ||
1925 | priv); | ||
1926 | if (ret != 0) { | ||
1927 | dev_err(codec->dev, "Failed to request DSP IRQ: %d\n", ret); | ||
1928 | return ret; | ||
1929 | } | ||
1930 | |||
1875 | ret = wm_adsp2_codec_probe(&priv->core.adsp[0], codec); | 1931 | ret = wm_adsp2_codec_probe(&priv->core.adsp[0], codec); |
1876 | if (ret) | 1932 | if (ret) |
1877 | return ret; | 1933 | return ret; |
@@ -1946,6 +2002,20 @@ static struct snd_soc_codec_driver soc_codec_dev_wm5102 = { | |||
1946 | .num_dapm_routes = ARRAY_SIZE(wm5102_dapm_routes), | 2002 | .num_dapm_routes = ARRAY_SIZE(wm5102_dapm_routes), |
1947 | }; | 2003 | }; |
1948 | 2004 | ||
2005 | static struct snd_compr_ops wm5102_compr_ops = { | ||
2006 | .open = wm5102_open, | ||
2007 | .free = wm_adsp_compr_free, | ||
2008 | .set_params = wm_adsp_compr_set_params, | ||
2009 | .get_caps = wm_adsp_compr_get_caps, | ||
2010 | .trigger = wm_adsp_compr_trigger, | ||
2011 | .pointer = wm_adsp_compr_pointer, | ||
2012 | .copy = wm_adsp_compr_copy, | ||
2013 | }; | ||
2014 | |||
2015 | static struct snd_soc_platform_driver wm5102_compr_platform = { | ||
2016 | .compr_ops = &wm5102_compr_ops, | ||
2017 | }; | ||
2018 | |||
1949 | static int wm5102_probe(struct platform_device *pdev) | 2019 | static int wm5102_probe(struct platform_device *pdev) |
1950 | { | 2020 | { |
1951 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | 2021 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
@@ -2005,12 +2075,25 @@ static int wm5102_probe(struct platform_device *pdev) | |||
2005 | pm_runtime_enable(&pdev->dev); | 2075 | pm_runtime_enable(&pdev->dev); |
2006 | pm_runtime_idle(&pdev->dev); | 2076 | pm_runtime_idle(&pdev->dev); |
2007 | 2077 | ||
2008 | return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, | 2078 | ret = snd_soc_register_platform(&pdev->dev, &wm5102_compr_platform); |
2079 | if (ret < 0) { | ||
2080 | dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); | ||
2081 | return ret; | ||
2082 | } | ||
2083 | |||
2084 | ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, | ||
2009 | wm5102_dai, ARRAY_SIZE(wm5102_dai)); | 2085 | wm5102_dai, ARRAY_SIZE(wm5102_dai)); |
2086 | if (ret < 0) { | ||
2087 | dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); | ||
2088 | snd_soc_unregister_platform(&pdev->dev); | ||
2089 | } | ||
2090 | |||
2091 | return ret; | ||
2010 | } | 2092 | } |
2011 | 2093 | ||
2012 | static int wm5102_remove(struct platform_device *pdev) | 2094 | static int wm5102_remove(struct platform_device *pdev) |
2013 | { | 2095 | { |
2096 | snd_soc_unregister_platform(&pdev->dev); | ||
2014 | snd_soc_unregister_codec(&pdev->dev); | 2097 | snd_soc_unregister_codec(&pdev->dev); |
2015 | pm_runtime_disable(&pdev->dev); | 2098 | pm_runtime_disable(&pdev->dev); |
2016 | 2099 | ||