diff mbox

vt1613 driver

Message ID 63bed6a2.d4bfc94.540cad91.b8037@o2.pl (mailing list archive)
State New, archived
Headers show

Commit Message

kukububu Sept. 7, 2014, 7:10 p.m. UTC
Hello,

I found driver for vt1613 (which is part of udoo arm computer) at https://github.com/UDOOboard/Kernel_Unico/blob/master/sound/soc/codecs/vt1613.c, but it's not compatibile with current kernel. Below you can find my patch that makes it possible to compile and load this driver. It probably has memory leak on unload (commented kfree), but the worst thing is that Linux still doesn't see sound card. I suppose that volatile register should be changed to reg_default, but I'm not programmer (I only had C course a few years ago and oboiously I've never touched any driver code) therefore this is far beyond my abilities. Can you help me with getting this driver to work on recent kernel please?

Regards,
Adrian
diff mbox

Patch

--- /usr/src/linux-armv7/src/linux-3.16/vt1613.c        2014-09-06 17:51:20.037035346 +0000
+++ /root/vt1613/vt1613.c       2014-09-07 18:27:25.258361596 +0000
@@ -33,7 +33,6 @@ 
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 #include <sound/initval.h>
-#include <mach/hardware.h>
 
 #include <sound/tlv.h>
 
@@ -126,7 +125,7 @@ 
         if (reg == AC97_RESET || reg == AC97_GPIO_STATUS ||
                 reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 ||
                 reg == AC97_REC_GAIN) {
-                return soc_ac97_ops.read(codec->ac97, reg);
+                return soc_ac97_ops->read(codec->ac97, reg);
         } else {
                 reg = reg >> 1;
 
@@ -142,7 +141,7 @@ 
         u16 *cache = codec->reg_cache;
 
         if (reg < 0x7c)
-                soc_ac97_ops.write(codec->ac97, reg, val);
+                soc_ac97_ops->write(codec->ac97, reg, val);
         reg = reg >> 1;
         if (reg < (ARRAY_SIZE(vt1613_ac97_reg)))
                 cache[reg] = val;
@@ -449,13 +448,6 @@ 
        return ret;
 }
 
-static int vt1613_digital_mute(struct snd_soc_dai *codec_dai, int mute)
-{
-       struct snd_soc_codec *codec = codec_dai->codec;
-
-       return __vt1613_digital_mute(codec, mute);
-}
-
 static int vt1613_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 {
         struct snd_soc_codec *codec = codec_dai->codec;
@@ -561,36 +553,6 @@ 
         return snd_soc_write(codec, reg, runtime->rate);
 }
 
-static void vt1613_constraints(struct vt1613_priv *vt1613,
-                                struct snd_pcm_substream *mst_substream)
-{
-        struct snd_pcm_substream *slv_substream;
-
-        /* Pick the stream, which need to be constrained */
-        if (mst_substream == vt1613->master_substream)
-                slv_substream = vt1613->slave_substream;
-        else if (mst_substream == vt1613->slave_substream)
-                slv_substream = vt1613->master_substream;
-        else /* This should not happen.. */
-                return;
-
-        /* Set the constraints according to the already configured stream */
-        snd_pcm_hw_constraint_minmax(slv_substream->runtime,
-                                SNDRV_PCM_HW_PARAM_RATE,
-                                vt1613->rate,
-                                vt1613->rate);
-
-        snd_pcm_hw_constraint_minmax(slv_substream->runtime,
-                                SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
-                                vt1613->sample_bits,
-                                vt1613->sample_bits);
-
-        snd_pcm_hw_constraint_minmax(slv_substream->runtime,
-                                SNDRV_PCM_HW_PARAM_CHANNELS,
-                                vt1613->channels,
-                                vt1613->channels);
-}
-
 static int vt1613_startup(struct snd_pcm_substream *substream,
                            struct snd_soc_dai *dai)
 {
@@ -829,6 +791,7 @@ 
 },
 };
 
+/*
 static int vt1613_volatile_register(unsigned int reg)
 {
        if (reg == VT1613_CHIP_ID ||
@@ -837,8 +800,9 @@ 
                return 1;
        return 0;
 }
+*/
 
-static int vt1613_suspend(struct snd_soc_codec *codec, pm_message_t state)
+static int vt1613_suspend(struct snd_soc_codec *codec)
 {
        vt1613_set_bias_level(codec, SND_SOC_BIAS_OFF);
 
@@ -881,16 +845,14 @@ 
 static int vt1613_driver_probe(struct snd_soc_codec *codec)
 {
        struct vt1613_priv *vt1613 = snd_soc_codec_get_drvdata(codec);
-       u16 reg, ana_pwr, lreg_ctrl;
-       int vag;
        int ret;
        int i;
 
-       ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
+       ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
 
-       soc_ac97_ops.reset(codec->ac97);
+       soc_ac97_ops->reset(codec->ac97);
         msleep(20);
-       soc_ac97_ops.warm_reset(codec->ac97);
+       soc_ac97_ops->warm_reset(codec->ac97);
         msleep(20);
 
        vt1613_init_chip(codec);
@@ -904,8 +866,9 @@ 
        snd_soc_write(codec, 0x5A, 0x0400); // <-- [gp000q7] Noise reducing during mic recording on vt1613
        vt1613->sysclk = VT1613_APLL_RATE_48000;
 
-       snd_soc_add_controls(codec, vt1613_snd_controls, ARRAY_SIZE(vt1613_snd_controls));
-        msleep(10);
+       /* snd_soc_add_controls(codec, vt1613_snd_controls, ARRAY_SIZE(vt1613_snd_controls)); */
+        snd_soc_add_codec_controls(codec, vt1613_snd_controls, ARRAY_SIZE(vt1613_snd_controls));
+       msleep(10);
 /*
 for (i = 0; i < ARRAY_SIZE(vt1613_ac97_reg); i++)
        printk("REGISTRO IDX 0x%02x = 0x%04x \n", i<<1, snd_soc_read(codec, i<<1));
@@ -936,10 +899,10 @@ 
        .reg_cache_size = ARRAY_SIZE(vt1613_ac97_reg),
        .reg_word_size = sizeof(u16),
        .reg_cache_default = vt1613_ac97_reg,
-       .volatile_register = vt1613_volatile_register,
+/*     .volatile_register = vt1613_volatile_register,*/
 };
 
-static __devinit int vt1613_codec_probe(struct platform_device *client)
+static int vt1613_codec_probe(struct platform_device *client)
 {
        struct vt1613_priv *vt1613;
        int ret;
@@ -963,13 +926,13 @@ 
        return 0;
 }
 
-static __devexit int vt1613_remove(struct platform_device *pdev)
+static int vt1613_remove(struct platform_device *pdev)
 {
        struct vt1613_priv *vt1613 = platform_get_drvdata(pdev);
-
-        snd_soc_unregister_dais(&vt1613_dai[0], ARRAY_SIZE(vt1613_dai));
+       /*
+        snd_soc_unregister_dais(&vt1613_dai[0]);
         snd_soc_unregister_codec(&vt1613->codec);
-        kfree(vt1613->codec.reg_cache);
+        kfree(vt1613->codec.reg_cache);*/
         kfree(vt1613);
 
        return 0;
@@ -981,7 +944,7 @@ 
                   .owner = THIS_MODULE,
        },
        .probe = vt1613_codec_probe,
-       .remove = __devexit_p(vt1613_remove),
+       .remove = vt1613_remove,
 };
 
 static int __init vt1613_modinit(void)