A few questions about an audio CODEC

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
Will do! Work is almost over for today but currently I am just figuring out this ASoC stuff and how these drivers communicate with one another. Thanks again for all your help!
 

nsaspook

Joined Aug 27, 2009
13,315
@nsaspook Ah I see, thanks! Yep I agree lol and I already started that video XD glad I am heading in the right direction! Thanks again!
There is a lot of complexity in the older static configuration kernels that was solved with the 'device tree' dynamic configuration used in newer kernels. Once you understand how static configuration works you might want to experiment with a kernel update so you can convert the machine driver code to device tree. It takes a while to GROK how it all works so take your time if possible.

https://github.com/torvalds/linux/blob/master/Documentation/devicetree/usage-model.txt
https://www.kernel.org/doc/Documentation/devicetree/bindings/sound/simple-card.txt
 

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
There is a lot of complexity in the older static configuration kernels that was solved with the 'device tree' dynamic configuration used in newer kernels.
Is mine statically configured? I can't seem to find the machine driver. I tried a simple grep search: 'grep -lr wm8753.c', the 8753 is the old codec and the results are:

sound/soc/imx/imx-ccwmx51-wm8753.c
sound/soc/s3c24xx/neo1973_wm8753.c
sound/soc/s3c24xx/neo1973_gta02_wm8753.c
sound/soc/s3c24xx/cc9m2443js_wm8753.c
sound/soc/codecs/wm8753.c
sound/soc/codecs/ak4642.c
sound/soc/codecs/wm8731.c
sound/soc/codecs/tlv320aic3x.c
sound/soc/codecs/ak4535.c
sound/soc/codecs/wm8971.c

It seems odd to me that so many different files are importing wm8753.c. I would have figured maybe 1 or 2 files would be using it.
 

nsaspook

Joined Aug 27, 2009
13,315
It might be called a platform Driver or not even have a proper label as such. I've never really looked deep into the Linux sound system arch so its a learning experience for me too.
Example: sound/soc/s3c24xx/neo1973_wm8753.c and neo1973_gta02_wm8753.c both look like asoc 'machine' drivers.
Look for:
struct snd_soc_card {

https://www.kernel.org/doc/html/v4.16/sound/soc/machine.html
ASoC Machine Driver
The ASoC machine (or board) driver is the code that glues together all the component drivers (e.g. codecs, platforms and DAIs). It also describes the relationships between each component which include audio paths, GPIOs, interrupts, clocking, jacks and voltage regulators.

The machine driver can contain codec and platform specific code. It registers the audio subsystem with the kernel as a platform device and is represented by the following struct:-

I don't have a sound/soc/imx/imx-ccwmx51-wm8753.c or sound/soc/s3c24xx/cc9m2443js_wm8753.c in my generic kernel 2.6.x source tree.
 

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
@nsaspook Yes, I managed to find some documentation for my kernel. I did a grep for the string: 'struct snd_soc_card {' and my only result was: include/sound/soc.h

Correct me if I am wrong but I believe I am looking for a .c file and not a header file? If I don't include the '{' in the string then I get a rather large list of .c files located in sound/soc.
 

nsaspook

Joined Aug 27, 2009
13,315
@nsaspook Yes, I managed to find some documentation for my kernel. I did a grep for the string: 'struct snd_soc_card {' and my only result was: include/sound/soc.h

Correct me if I am wrong but I believe I am looking for a .c file and not a header file? If I don't include the '{' in the string then I get a rather large list of .c files located in sound/soc.
Yes, the '{' is from the .h file defining the struct.
The created variable should be in a .c file.

Exampe:
neo1973_wm8753.c should have a line like this that's sometimes labeled the 'machine driver':

static struct snd_soc_card neo1973 = {
.name = "neo1973",
.platform = &s3c24xx_soc_platform,
.dai_link = neo1973_dai,
.num_links = ARRAY_SIZE(neo1973_dai),
};
 

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
I believe I can narrow down the results of that search to:

sound/soc/imx/imx-ccwmx51-wm8753.c
sound/soc/s3c24xx/neo1973_wm8753.c
sound/soc/s3c24xx/cc9m2443js_wm8753.c

are these all machine drivers?
 

nsaspook

Joined Aug 27, 2009
13,315
I believe I can narrow down the results of that search to:

sound/soc/imx/imx-ccwmx51-wm8753.c
sound/soc/s3c24xx/neo1973_wm8753.c
sound/soc/s3c24xx/cc9m2443js_wm8753.c

are these all machine drivers?
Of those three I only have neo1973_wm8753.c in my source tree but that one is a 'machine driver'.
Code:
static struct snd_soc_card neo1973 = {
.name = "neo1973",
.platform = &s3c24xx_soc_platform,
.dai_link = neo1973_dai,
.num_links = ARRAY_SIZE(neo1973_dai),
};
static struct snd_soc_device neo1973_snd_devdata = {
.card = &neo1973,
.codec_dev = &soc_codec_dev_wm8753,
};
 
Last edited:

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
Seems so. Good luck.
Awhile back you had posted some information on the configuration process when configuring the kernel. I know you found the option for enabling all the audio codecs but what about enabling/disabling specific audio codecs? It must be possible because our .config page has certain ones available while others are not, for instance:

Code:
# CONFIG_SND_SOC_IMX_CCXMX53_SGTL5000 is not set
# CONFIG_SND_SOC_IMX_3STACK_AK4647 is not set
# CONFIG_SND_SOC_IMX_3STACK_WM8580 is not set
CONFIG_SND_SOC_IMX_CCWMX51_WM8753=y
# CONFIG_SND_SOC_IMX_3STACK_AK5702 is not set
# CONFIG_SND_SOC_IMX_3STACK_BLUETOOTH is not set
# CONFIG_SND_SOC_IMX_3STACK_CS42888 is not set
# CONFIG_SND_SOC_IMX_SPDIF is not set
# CONFIG_MXC_SSI_DUAL_FIFO is not set
CONFIG_SND_SOC_I2C_AND_SPI=y
# CONFIG_SND_SOC_ALL_CODECS is not set
CONFIG_SND_SOC_WM8753=y
Essentially, I would like to figure out how to get:

CONFIG_SND_SOC_IMX_CCWMX50_WM8750=y
CONFIG_SND_SOC_WM8750=y

to be options that are available in the .config file. I am assuming this can be done without enabling all codecs? Granted I haven't created IMX_CCWMX50_WM8750 yet but I am hoping to get that done soon.
 

nsaspook

Joined Aug 27, 2009
13,315

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
The Kconfig file for those options can be edited to ask, enable/disable any set of options you want.
https://docs.zephyrproject.org/1.3.0/reference/kbuild/kbuild_kconfig.html

For example this patch allow for a independently selected driver option. There might be a similar type modifications in your Kconfig file for your internal driver files.
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-February/085958.html
Okay I believe I found the right kconfig file. Here is the initialization for the wm8753:

Code:
config SND_SOC_IMX_CCWMX51_WM8753
tristate "SoC Audio support for IMX - WM8753"
select SND_MXC_SOC_SSI
select SND_SOC_WM8753
help
Say Y if you want to add support for Soc audio on IMX CCWMX51
with the WM8753
I am assuming in order to initialize the wm8750 I would just add:

Code:
config SND_SOC_IMX_CCWMX50_WM8750
tristate "SoC Audio support for IMX - WM8750"
select SND_MXC_SOC_SSI
select SND_SOC_WM8750
help
Say Y if you want to add support for Soc audio on IMX CCWMX50
with the WM8750
and then from what I understand I can just run a make and it should pop up on the list?
 

nsaspook

Joined Aug 27, 2009
13,315
Okay I believe I found the right kconfig file. Here is the initialization for the wm8753:

Code:
config SND_SOC_IMX_CCWMX51_WM8753
tristate "SoC Audio support for IMX - WM8753"
select SND_MXC_SOC_SSI
select SND_SOC_WM8753
help
Say Y if you want to add support for Soc audio on IMX CCWMX51
with the WM8753
I am assuming in order to initialize the wm8750 I would just add:

Code:
config SND_SOC_IMX_CCWMX50_WM8750
tristate "SoC Audio support for IMX - WM8750"
select SND_MXC_SOC_SSI
select SND_SOC_WM8750
help
Say Y if you want to add support for Soc audio on IMX CCWMX50
with the WM8750
and then from what I understand I can just run a make and it should pop up on the list?
You need to change the Makefile also to compile and generate the correct object(s).
 

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
Stumbling a bit I did a grep search for: SND_SOC_IMX_CCWMX51_WM8753 and I was presented with 8 different c files all referencing that string. Has me worried because I was under the assumption that I would only be editing the machine driver. Any chance these are auto-generated c files?
 

nsaspook

Joined Aug 27, 2009
13,315
Stumbling a bit I did a grep search for: SND_SOC_IMX_CCWMX51_WM8753 and I was presented with 8 different c files all referencing that string. Has me worried because I was under the assumption that I would only be editing the machine driver. Any chance these are auto-generated c files?
There might be data configuration files related to the define in other files. The only way to make sure is to run a diff (if you don't have a diff patch file already) from the vanilla kernel sources on your source tree.
 
Last edited:

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
@nsaspook Managed to narrow down a few things:

arch/arm/mach-mx5/mx51_ccwmx51js.c -- contains a very short reference to the wm8753.c codec driver:

Code:
#if defined(CONFIG_SND_SOC_IMX_CCWMX51_WM8753) || defined(CONFIG_SND_SOC_IMX_CCWMX51_WM8753_MODULE)
   mxc_register_device(&mxc_wm8753_device, &wm8753_data);
#endif
arch/arm/mach-mx5/devices_ccwmx51.c -- contains 7 references to the wm8753.c codec driver:

Code:
#if defined (CONFIG_MXC_CAMERA_MICRON111_1) || defined(CONFIG_MXC_CAMERA_MICRON111_1_MODULE)
   {
     I2C_BOARD_INFO("mt9v111_1", 0xB8>>1),
   },
#endif

...

#if defined(CONFIG_SND_SOC_IMX_CCWMX51_WM8753) || defined(CONFIG_SND_SOC_IMX_CCWMX51_WM8753_MODULE)
struct platform_device mxc_wm8753_device = {
   .name = "ccwmx51js",
};
#endif

...

struct mxc_audio_platform_data wm8753_data = {
   .ssi_num = 1,
   .src_port = 2,
   .ext_port = 3,
   .sysclk = 0 /* Set on the fly */,
};
arch/arm/mach-s3c2443/mach-cc9m2443js.c -- contains 3 references to the wm8753.c codec driver:

Code:
#if defined(CONFIG_SND_S3C24XX_SOC_CC9M2443JS_WM8753) || defined(CONFIG_SND_S3C24XX_SOC_CC9M2443JS_WM8753_MODULE)
   {
     I2C_BOARD_INFO("wm8753", 0x1a),
   },
#endif
arch/arm/mach-s3c2443/mach-ccw9m2443js.c -- contains 3 references to the wm8753.c codec driver:

Code:
#if defined(CONFIG_SND_S3C24XX_SOC_CC9M2443JS_WM8753) || defined(CONFIG_SND_S3C24XX_SOC_CC9M2443JS_WM8753_MODULE)
   {
     I2C_BOARD_INFO("wm8753", 0x1a),
   },
#endif
sound/soc/imx/imx-ccwmx51-wm8753.c -- Contains 28 references and I wont post that code here. I believe this is the machine driver.

sound/soc/s3c24xx/cc9m2443js_wm8753.c -- Contains 25 references and I wont post that code here. I believe this is the platform driver.

Also of course I found the CODEC driver itself. The files I eliminated:

neo1973_wm8753.c, neo1973_gta02_wm8753.c (apparently there was a phone called the neo1973??), a host a files in a directory labeled: from-2.6.31.14 (assuming these are leftover from a kernel update?)
 
Last edited:

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
Alright well I managed to get the CODEC loaded into the .config file properly, so that's good. However, I am struggling to figure out which c files I need to touch. Anyone with more experience than I know if there is a specific directory where the machine driver and platform driver will be?
 

Thread Starter

Robert Murch

Joined Nov 2, 2015
43
Just an update. I believe my machine driver is written correctly but I am not sure. I am getting an error while booting the machine but I am not sure if it is a result of a faulty machine driver or some initialization that happens prior to communication with the driver. Here is the output of the error:

Unknown hardware: "WM8750" "" "" "" ""
Hardware is initialized using a guess method
alsactl: set_control:1255: failed to obtain info for control #2 (No such file or directory)
alsactl: set_control:1255: failed to obtain info for control #6 (No such file or directory)
alsactl: set_control:1255: failed to obtain info for control #7 (No such file or directory)

I have looked online and have gotten mixed information on how to deal with this error. It was sugjested that I turn off debugging in alsa config:

│ │ [ ] Verbose procfs contents │ │
│ │ [ ] Verbose printk │ │
│ │ [ ] Debug │ │
│ │ [ ] Generic sound devices --->

I did that. It was also suggested that I look for and delete a .state file but my system does not seem to have any .state files in it.
 
Top