Hi All,
I am using IMx6q seco platform and I need some support to enable CS4299 audio codec on my platform. I am currently kernel version 3.0.35.Also I donnot see any cs4299.c in sound/soc/codec or in sound/soc/imx directories and only I see in some patch files applied on sound/pci/ac97/ac97_codec.c file
{ 0x43525930, 0xfffffff8, "CS4299", patch_cirrus_cs4299, NULL },
defined in structure
static const struct ac97_codec_id snd_ac97_codec_ids[] = {.
I was going through one of ac97 codec for reference vt1613 which is defined in sound/soc/codec/vt1613.c and sound/soc/imx/imx-ac97-vt1613.c and some configurations I see in board file also
static struct platform_device mx6_seco_q7_imx_audio_device = {
.name = "imx-vt1613",
};
static struct platform_device mx6_seco_q7_audio_device = {
.name = "vt1613-ac97",
};
#endif
static int imx6q_init_audio(void) {
#ifdef CONFIG_Q7_SND_SOC_IMX_AC97_VT1613
mxc_register_device(&mx6_seco_q7_imx_audio_device, &mx6_seco_q7_audio_data);
mxc_register_device(&mx6_seco_q7_audio_device, NULL);
imx6q_add_imx_ssi(SSI_CH_NUMBER - 1, &mx6_seco_q7_ssi_pdata);
#endif
. Is that 2 driver initialisation are needed?
Please some one help me integrating the same.
Thanks and Regards,
Prasanna
Hi Prasanna
one can add audio codec in kernel board file with SSI in AC97 mode using
static struct imx_ssi_platform_data ssi_pdata = {
.flags = (IMX_SSI_USE_AC97 | IMX_SSI_DMA),
};
and use attached Porting Guide Chapter 8 Porting Audio Codecs to a
Custom Board
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Igor I am using 3.14.28 kernel version with dts configuration. I have taken reference of vt1613 as vt1613 and cs4299(my current requirement) looks similar. Attached is dts file and machine driver which I have ported to cs4299.Please review the same and let me know if it looks ok to proceed.
Also as there is no driver for cs4299 available in net I have planned to use ac97.c (a generic driver available with kernel) .IS this ok to go forward or should we write a new codec driver for cs4299?? Please guide me on this as I am very new to audio driver and it will be very much helpful.
dts file entry:
codec_cs4299: codec_cs4299 {
compatible = "via,ac97-codec";
status = "disabled";
};
sound_cs4299: sound_cs4299 {
compatible = "fsl,imx-cs4299-audio";
model = "fsl,imx-cs4299-audio";
ssi-controller = <&ssi1>;
audio-codec = <&codec_cs4299>;
mux-int-port = <1>;
mux-ext-port = <6>;
status = "disabled";
};
ssi_cs4299: ssi_cs4299 {
fsl,mode = "ac97-slave";
pinctrl-names = "default", "ac97-running", "ac97-reset", "ac97-warm-reset";
pinctrl-0 = <&ac97link_running>;
pinctrl-1 = <&ac97link_running>;
pinctrl-2 = <&ac97link_reset>;
pinctrl-3 = <&ac97link_warm_reset>;
/* sync, sdata (output), reset */
ac97-gpios = <&gpio4 19 0 &gpio4 18 0 &gpio4 23 0>;
};
dio_codec2: cs4299 {
code_name = "cs4299";
phandle-num-enable = <4>;
phandle-list-enable = <&sound_cs4299>,
<&codec_cs4299>,
<&ssi1>,
<&audmux>;
phandle-num-set = <1>;
phandle-list-set = <&ssi1>;
phandle-list-source = <&ssi_cs4299>;
};
Also Machine driver:
/*
* imx-ac97-cs4299.c -- SoC audio for i.MX Seco UDOO board with
* CS4299 AC'97 codec
* Copyright: Seco s.r.l.
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#include <linux/module.h>
#include <linux/of_platform.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
//#include "../codecs/vt1613.h"
#include "imx-audmux.h"
#include "fsl_ssi.h"
#define DRV_NAME "imx-ac97-cs4299"
static int imx_cs4299_audio_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 *cpu_dai = rtd->cpu_dai;
int ret;
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_AC97
| SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFS);
if (ret < 0) {
dev_err(cpu_dai->dev,
"Failed to set cpu dai format: %d\n", ret);
return ret;
}
return 0;
}
static struct snd_soc_ops imx_cs4299_audio_ops = {
.hw_params = imx_cs4299_audio_params,
};
static struct snd_soc_dai_link imx_cs4299_dai = {
.name = "cs4299-AC97",
.stream_name = "AC97-analog",
.codec_dai_name = "ac97-hifi", i
};
static struct snd_soc_card imx_cs4299_card = {
.name = "imx-cs4299-audio",
.owner = THIS_MODULE,
.dai_link = &imx_cs4299_dai,
.num_links = 1,
};
static int imx_audmux_ac97_config(struct platform_device *pdev, int intPort, int extPort)
{
int ret;
unsigned int ptcr, pdcr;
intPort = intPort - 1;
extPort = extPort - 1;
ptcr = IMX_AUDMUX_V2_PTCR_SYN |
IMX_AUDMUX_V2_PTCR_TCLKDIR | IMX_AUDMUX_V2_PTCR_TCSEL(extPort);
pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(extPort);
ret = imx_audmux_v2_configure_port(intPort, ptcr, pdcr);
if (ret) {
dev_err(&pdev->dev, "Audmux internal port setup failed\n");
return ret;
}
ptcr = IMX_AUDMUX_V2_PTCR_SYN |
IMX_AUDMUX_V2_PTCR_TFSDIR | IMX_AUDMUX_V2_PTCR_TFSEL(intPort);
pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(intPort);
ret = imx_audmux_v2_configure_port(extPort, ptcr, pdcr);
if (ret) {
dev_err(&pdev->dev, "Audmux external port setup failed\n");
return ret;
}
return 0;
}
static int imx_cs4299_probe(struct platform_device *pdev)
{
struct device_node *ssi_np, *codec_np, *np = pdev->dev.of_node;
struct platform_device *codec_pdev;
struct platform_device *ssi_pdev;
int int_port, ext_port;
int ret;
ret = of_property_read_u32(np, "mux-int-port", &int_port);
if (ret) {
dev_err(&pdev->dev, "mux-int-port property missing or invalid\n");
return ret;
}
ret = of_property_read_u32(np, "mux-ext-port", &ext_port);
if (ret) {
dev_err(&pdev->dev, "mux-ext-port property missing or invalid\n");
return ret;
}
ret = imx_audmux_ac97_config(pdev, int_port, ext_port);
if (ret) {
dev_err(&pdev->dev, "Audmux port setup failed\n");
return ret;
}
ssi_np = of_parse_phandle(np, "ssi-controller", 0);
if (!ssi_np) {
dev_err(&pdev->dev, "ssi-controller phandle missing or invalid\n");
return -EINVAL;
}
ssi_pdev = of_find_device_by_node(ssi_np);
if (!ssi_pdev) {
dev_err(&pdev->dev, "Failed to find SSI platform device\n");
ret = -EINVAL;
goto fail;
}
codec_np = of_parse_phandle(np, "audio-codec", 0);
if (!codec_np) {
dev_err(&pdev->dev, "audio-codec phandle missing or invalid\n");
ret = -EINVAL;
goto fail;
}
codec_pdev = of_find_device_by_node(codec_np);
if (!codec_pdev) {
dev_err(&pdev->dev, "Failed to find codec device\n");
ret = -EINVAL;
goto fail;
}
imx_cs4299_dai.codec_name = dev_name(&codec_pdev->dev);
imx_cs4299_dai.cpu_of_node = ssi_np;
imx_cs4299_dai.cpu_dai_name = dev_name(&ssi_pdev->dev);
imx_cs4299_dai.platform_of_node = ssi_np;
imx_cs4299_dai.ops = &imx_cs4299_audio_ops;
imx_cs4299_dai.dai_fmt = SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFS;
imx_cs4299_card.dev = &pdev->dev;
platform_set_drvdata(pdev, &imx_cs4299_card);
ret = snd_soc_register_card(&imx_cs4299_card);
if (ret)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
fail:
if (ssi_np)
of_node_put(ssi_np);
if (codec_np)
of_node_put(codec_np);
return ret;
}
static int imx_cs4299_remove(struct platform_device *pdev)
{
int ret;
struct snd_soc_card *card = platform_get_drvdata(pdev);
ret = snd_soc_unregister_card(card);
return ret;
}
static const struct of_device_id imx_cs4299_audio_match[] = {
{ .compatible = "fsl,imx-cs4299-audio", },
{}
};
MODULE_DEVICE_TABLE(of, imx_cs4299_audio_match);
static struct platform_driver imx_cs4299_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = imx_cs4299_audio_match,
},
.probe = imx_cs4299_probe,
.remove = imx_cs4299_remove,
};
module_platform_driver(imx_cs4299_driver);
MODULE_AUTHOR("Seco <info@seco.it>");
MODULE_DESCRIPTION(DRV_NAME ": Freescale i.MX CS4299 AC97 ASoC machine driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:imx-cs4299");
Please review the same and let me know on the same
Thanks and regards,
Prasanna
Thank you for the quick response Igor. I shall try the same and if any issues I shall get back.
Regards,
Prasanna