Merge branch 'asoc-5.3' into asoc-5.4
[linux-2.6-microblaze.git] / sound / soc / sunxi / sun4i-i2s.c
index 85c3b2c..2c909c6 100644 (file)
@@ -222,10 +222,11 @@ static const struct sun4i_i2s_clk_div sun4i_i2s_mclk_div[] = {
 };
 
 static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s,
-                                 unsigned int oversample_rate,
+                                 unsigned long parent_rate,
+                                 unsigned int sampling_rate,
                                  unsigned int word_size)
 {
-       int div = oversample_rate / word_size / 2;
+       int div = parent_rate / sampling_rate / word_size / 2;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(sun4i_i2s_bclk_div); i++) {
@@ -239,11 +240,10 @@ static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s,
 }
 
 static int sun4i_i2s_get_mclk_div(struct sun4i_i2s *i2s,
-                                 unsigned int oversample_rate,
-                                 unsigned int module_rate,
-                                 unsigned int sampling_rate)
+                                 unsigned long parent_rate,
+                                 unsigned long mclk_rate)
 {
-       int div = module_rate / sampling_rate / oversample_rate;
+       int div = parent_rate / mclk_rate;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(sun4i_i2s_mclk_div); i++) {
@@ -315,15 +315,14 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai,
                return -EINVAL;
        }
 
-       bclk_div = sun4i_i2s_get_bclk_div(i2s, oversample_rate,
-                                         word_size);
+       bclk_div = sun4i_i2s_get_bclk_div(i2s, i2s->mclk_freq,
+                                         rate, word_size);
        if (bclk_div < 0) {
                dev_err(dai->dev, "Unsupported BCLK divider: %d\n", bclk_div);
                return -EINVAL;
        }
 
-       mclk_div = sun4i_i2s_get_mclk_div(i2s, oversample_rate,
-                                         clk_rate, rate);
+       mclk_div = sun4i_i2s_get_mclk_div(i2s, clk_rate, i2s->mclk_freq);
        if (mclk_div < 0) {
                dev_err(dai->dev, "Unsupported MCLK divider: %d\n", mclk_div);
                return -EINVAL;
@@ -411,10 +410,9 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
 
        /* Configure the channels */
        regmap_field_write(i2s->field_txchansel,
-                          SUN4I_I2S_CHAN_SEL(params_channels(params)));
-
+                          SUN4I_I2S_CHAN_SEL(channels));
        regmap_field_write(i2s->field_rxchansel,
-                          SUN4I_I2S_CHAN_SEL(params_channels(params)));
+                          SUN4I_I2S_CHAN_SEL(channels));
 
        if (i2s->variant->has_chsel_tx_chen)
                regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG,
@@ -1087,10 +1085,8 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
                return PTR_ERR(regs);
 
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               dev_err(&pdev->dev, "Can't retrieve our interrupt\n");
+       if (irq < 0)
                return irq;
-       }
 
        i2s->variant = of_device_get_match_data(&pdev->dev);
        if (!i2s->variant) {
@@ -1154,7 +1150,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
                goto err_suspend;
        }
 
-       ret = snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
+       ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
        if (ret) {
                dev_err(&pdev->dev, "Could not register PCM\n");
                goto err_suspend;
@@ -1185,8 +1181,6 @@ static int sun4i_i2s_remove(struct platform_device *pdev)
 {
        struct sun4i_i2s *i2s = dev_get_drvdata(&pdev->dev);
 
-       snd_dmaengine_pcm_unregister(&pdev->dev);
-
        pm_runtime_disable(&pdev->dev);
        if (!pm_runtime_status_suspended(&pdev->dev))
                sun4i_i2s_runtime_suspend(&pdev->dev);