linux-armv7 3.16.1 vt1613 driver

This forum is for supported devices using an ARMv7 Freescale SoC.

linux-armv7 3.16.1 vt1613 driver

Postby abcde » Fri Sep 05, 2014 4:34 pm

linux-armv7 3.16.1 doesn't recognize vt1613 audio codec that is found on udoo. It is recognized by linux-udoo. I found https://github.com/UDOOboard/Kernel_Uni ... s/vt1613.c but I have not checked it yet. Is there any other way of getting sound working without compiling this driver or returning to old kernel?
abcde
 
Posts: 7
Joined: Fri Sep 05, 2014 4:23 pm

Re: linux-armv7 3.16.1 vt1613 driver

Postby abcde » Sat Sep 06, 2014 5:57 pm

I tried to adjust driver to 3.16.1 kernel, but I haven't been touching C for a few years and I've never programmed drivers. Therefore I need help.

Below you can find my patch that fixes some of compiller errors/warnings:

$this->bbcode_second_pass_code('', '--- vt1613.c 2014-09-06 17:51:20.037035346 +0000
+++ sound/soc/codecs/vt1613.c 2014-09-06 17:52:37.997116671 +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)
{
@@ -881,16 +843,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 +864,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));
@@ -939,7 +900,7 @@
.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,7 +924,7 @@
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);

@@ -981,7 +942,7 @@
.owner = THIS_MODULE,
},
.probe = vt1613_codec_probe,
- .remove = __devexit_p(vt1613_remove),
+ .remove = vt1613_remove,
};

static int __init vt1613_modinit(void)')

But still following errors/warnings are left:

$this->bbcode_second_pass_code('', '
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
CALL scripts/checksyscalls.sh
CC sound/soc/codecs/vt1613.o
sound/soc/codecs/vt1613.c:892:2: warning: initialization from incompatible pointer type [enabled by default]
.suspend = vt1613_suspend,
^
sound/soc/codecs/vt1613.c:892:2: warning: (near initialization for 'vt1613_driver.suspend') [enabled by default]
sound/soc/codecs/vt1613.c:900:2: error: unknown field 'volatile_register' specified in initializer
.volatile_register = vt1613_volatile_register,
^
sound/soc/codecs/vt1613.c:900:2: warning: initialization from incompatible pointer type [enabled by default]
sound/soc/codecs/vt1613.c:900:2: warning: (near initialization for 'vt1613_driver.set_bias_level') [enabled by default]
sound/soc/codecs/vt1613.c: In function 'vt1613_remove':
sound/soc/codecs/vt1613.c:931:9: error: implicit declaration of function 'snd_soc_unregister_dais' [-Werror=implicit-function-declaration]
snd_soc_unregister_dais(&vt1613_dai[0], ARRAY_SIZE(vt1613_dai));
^
sound/soc/codecs/vt1613.c:932:9: warning: passing argument 1 of 'snd_soc_unregister_codec' from incompatible pointer type [enabled by default]
snd_soc_unregister_codec(&vt1613->codec);
^
In file included from sound/soc/codecs/vt1613.c:33:0:
include/sound/soc.h:395:6: note: expected 'struct device *' but argument is of type 'struct snd_soc_codec *'
void snd_soc_unregister_codec(struct device *dev);
^
cc1: some warnings being treated as errors
scripts/Makefile.build:257: recipe for target 'sound/soc/codecs/vt1613.o' failed
make[1]: *** [sound/soc/codecs/vt1613.o] Error 1
Makefile:1479: recipe for target 'sound/soc/codecs/vt1613.o' failed
make: *** [sound/soc/codecs/vt1613.o] Error 2
')

I'm compilling using following command:
$this->bbcode_second_pass_code('', '
make sound/soc/codecs/vt1613.o
')

Please help me with this :)
abcde
 
Posts: 7
Joined: Fri Sep 05, 2014 4:23 pm

Re: linux-armv7 3.16.1 vt1613 driver

Postby abcde » Sun Sep 07, 2014 3:04 pm

Below you can find patch that compiles and loads. 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 it's because I do not use volatile_register which doesn't exist in newest kernel. As I said I'm not programmer therefore my changes were done without deep understanding of code.

$this->bbcode_second_pass_code('', '
--- ./src/linux-3.16/vt1613.c 2014-09-06 17:51:20.037035346 +0000
+++ /root/vt1613/vt1613.c 2014-09-07 14:42:32.508436369 +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>

@@ -82,7 +81,8 @@

/* codec private data */
struct vt1613_priv {
- struct snd_soc_codec codec;
+ /*struct snd_soc_codec codec;*/
+ struct device codec;
int master;
int fmt;
int rev;
@@ -126,7 +126,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 +142,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 +449,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 +554,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 +792,7 @@
},
};

+/*
static int vt1613_volatile_register(unsigned int reg)
{
if (reg == VT1613_CHIP_ID ||
@@ -837,8 +801,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 +846,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 +867,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 +900,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 +927,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 +945,7 @@
.owner = THIS_MODULE,
},
.probe = vt1613_codec_probe,
- .remove = __devexit_p(vt1613_remove),
+ .remove = vt1613_remove,
};

static int __init vt1613_modinit(void)
')
abcde
 
Posts: 7
Joined: Fri Sep 05, 2014 4:23 pm

Re: linux-armv7 3.16.1 vt1613 driver

Postby abcde » Mon Sep 08, 2014 9:50 am

I posted this on http://mailman.alsa-project.org/piperma ... 80888.html in case anyone is interested.
abcde
 
Posts: 7
Joined: Fri Sep 05, 2014 4:23 pm


Return to Freescale

Who is online

Users browsing this forum: No registered users and 11 guests