From: Marcus Cooper <[email protected]>

Add the ability to carry raw data over spdif. Also added
tidy up of set format call.

Signed-off-by: Marcus Cooper <[email protected]>
---
 sound/soc/sunxi/spdif/sunxi_sndspdif.c | 15 ++++++++++++++-
 sound/soc/sunxi/spdif/sunxi_spdif.c    | 27 ++++++++-------------------
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/sound/soc/sunxi/spdif/sunxi_sndspdif.c 
b/sound/soc/sunxi/spdif/sunxi_sndspdif.c
index 7cea365..1b14be7 100644
--- a/sound/soc/sunxi/spdif/sunxi_sndspdif.c
+++ b/sound/soc/sunxi/spdif/sunxi_sndspdif.c
@@ -169,6 +169,7 @@ static int sunxi_sndspdif_hw_params(struct 
snd_pcm_substream *substream,
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        int ret = 0;
+       int fmt;
        unsigned long rate = params_rate(params);
        u32 mclk_div = 0, mpll = 0, bclk_div = 0, mult_fs = 0;
 
@@ -179,7 +180,19 @@ static int sunxi_sndspdif_hw_params(struct 
snd_pcm_substream *substream,
        if (ret < 0)
                return ret;
 
-       ret = snd_soc_dai_set_fmt(cpu_dai, 0);
+       /* Add the PCM and raw data select interface */
+       switch (params_channels(params)) {
+       case 1:/* PCM mode */
+       case 2:
+               fmt = 0;
+               break;
+       case 4:/* raw data mode */
+               fmt = 1;
+               break;
+       default:
+               return -EINVAL;
+       }
+       ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
        if (ret < 0)
                return ret;
 
diff --git a/sound/soc/sunxi/spdif/sunxi_spdif.c 
b/sound/soc/sunxi/spdif/sunxi_spdif.c
index fe99aa0..63f5221 100644
--- a/sound/soc/sunxi/spdif/sunxi_spdif.c
+++ b/sound/soc/sunxi/spdif/sunxi_spdif.c
@@ -147,30 +147,19 @@ static int sunxi_spdif_set_fmt(struct snd_soc_dai 
*cpu_dai, unsigned int fmt)
        reg_val |= SUNXI_SPDIF_FCTL_RXOM(3);
        writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_FCTL);
 
-       if (!fmt) {
-               /* PCM */
-               reg_val = 0;
-               reg_val |= (SUNXI_SPDIF_TXCHSTA0_CHNUM(2));
-               writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_TXCHSTA0);
-
-               reg_val = 0;
-               reg_val |= (SUNXI_SPDIF_TXCHSTA1_SAMWORDLEN(1));
-               writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_TXCHSTA1);
-       } else {
+       if (fmt) {
                /* non PCM */
                reg_val = readl(sunxi_spdif.regs + SUNXI_SPDIF_TXCFG);
                reg_val |= SUNXI_SPDIF_TXCFG_NONAUDIO;
                writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_TXCFG);
-
-               reg_val = 0;
-               reg_val |= (SUNXI_SPDIF_TXCHSTA0_CHNUM(2));
-               reg_val |= SUNXI_SPDIF_TXCHSTA0_AUDIO;
-               writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_TXCHSTA0);
-
-               reg_val = 0;
-               reg_val |= (SUNXI_SPDIF_TXCHSTA1_SAMWORDLEN(1));
-               writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_TXCHSTA1);
        }
+       reg_val = 0;
+       reg_val |= (SUNXI_SPDIF_TXCHSTA0_CHNUM(2));
+       writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_TXCHSTA0);
+
+       reg_val = 0;
+       reg_val |= (SUNXI_SPDIF_TXCHSTA1_SAMWORDLEN(1));
+       writel(reg_val, sunxi_spdif.regs + SUNXI_SPDIF_TXCHSTA1);
 
        return 0;
 }
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to