AnsweredAssumed Answered

Machine driver for adau1701

Question asked by Anil Ghadiya on Jan 14, 2015
Latest reply on Jan 16, 2015 by Anil Ghadiya

Hi,

 

We are trying to build the existing adau1701 driver, insert it as independent module and test the codec functionality using ALSA utils.

So, we took the following files from the kernel source(for SD card image(trusty) for iMX6Q) and build the .ko file.

     adaua701.c/h

     sigmadsp.c/h

We are able to insert this module. Then, we built the machine driver as .ko file and able to insert that as module using insmod.

But, Probe functions of these modules are not getting called and there is no card in /proc/asound/cards.

 

When does the probe functions of these module gets invoked?

 

Below is the my machine driver code.

 

Thanks in Advance,

Anil Patel

 

=================================================================================

#include <linux/module.h>

#include <linux/device.h>

#include <sound/core.h>

#include <sound/pcm.h>

#include <sound/soc.h>

#include <sound/pcm_params.h>

#include "adau1701.h"

 

static const struct snd_soc_dapm_widget imx_adau1701_dapm_widgets[] = {

  SND_SOC_DAPM_SPK("Speaker", NULL),

  SND_SOC_DAPM_LINE("Line Out", NULL),

  SND_SOC_DAPM_LINE("Line In", NULL),

};

 

 

static const struct snd_soc_dapm_route imx_adau1701_dapm_routes[] = {

  { "Speaker", NULL, "OUT0" },

  { "Speaker", NULL, "OUT1" },

  { "Line Out", NULL, "OUT2" },

  { "Line Out", NULL, "OUT3" },

 

 

  { "IN0", NULL, "Line In" },

  { "IN1", NULL, "Line In" },

};

 

 

static int imx_adau1701_hw_params(struct snd_pcm_substream *substream,  struct snd_pcm_hw_params *params)

{

  struct snd_soc_pcm_runtime *rtd = substream->private_data;

  struct snd_soc_dai *codec_dai = rtd->codec_dai;

  int ret;

 

  ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1701_CLK_SRC_OSC, 12288000,  SND_SOC_CLOCK_IN);

  return ret;

}

 

 

static struct snd_soc_ops imx_adau1701_ops = {

  .hw_params = imx_adau1701_hw_params,

};

 

 

#define IMX_ADAU1701_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM)

 

 

static struct snd_soc_dai_link imx_adau1701_dai[] = {

 

  .name = "adau1701",

  .stream_name = "adau1701",

  .cpu_dai_name = "imx-i2s.0",

  .codec_dai_name = "adau1701",

  .platform_name = "imx-i2s-pcm-audio",

  .codec_name = "adau1701.0-0034",

  .ops = &imx_adau1701_ops,

  .dai_fmt = IMX_ADAU1701_DAI_FMT,

};

 

 

static struct snd_soc_card imx_adau1701 = {

  .name = "imx-adau1701",

  .owner = THIS_MODULE,

  .dai_link = &imx_adau1701_dai,

  .num_links = 1,

  .dapm_widgets = imx_adau1701_dapm_widgets,

  .num_dapm_widgets = ARRAY_SIZE(imx_adau1701_dapm_widgets),

  .dapm_routes = imx_adau1701_dapm_routes,

  .num_dapm_routes = ARRAY_SIZE(imx_adau1701_dapm_routes),

};

 

 

static int imx_adau1701_probe(struct platform_device *pdev)

{

  struct snd_soc_card *card = &imx_adau1701;

  card->dev = &pdev->dev;

  return snd_soc_register_card(&imx_adau1701);

}

 

 

static int imx_adau1701_remove(struct platform_device *pdev)

{

  struct snd_soc_card *card = platform_get_drvdata(pdev);

  snd_soc_unregister_card(card);

  return 0;

}

 

 

static struct platform_driver imx_adau1701_driver = {

  .driver = {

       .name = "imx-adau1701",

       .owner = THIS_MODULE,

       .pm = &snd_soc_pm_ops,

  },

  .probe = imx_adau1701_probe,

  .remove = imx_adau1701_remove,

};

 

module_platform_driver(imx_adau1701_driver);

 

 

MODULE_AUTHOR("xyz");

MODULE_DESCRIPTION("ALSA SoC imx6q ADAU1701 driver");

MODULE_LICENSE("GPL");

MODULE_ALIAS("platform:imx-adau1701");

Outcomes