Sound problem

Post Reply
mgalemin
Posts: 13
Joined: Tue Oct 06, 2009 11:49 pm

Sound problem

Post by mgalemin » Mon Oct 12, 2009 11:28 pm

Hi All,

I'm trying to make sound working on my Mini2440 but without success. I use kernel 2.6.31 from Buserror (thank you, great work!) and the last buildroot 2009.08. In kernel I added OSS support. During kernel boot I can see sound driver loading output:

Code: Select all

usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.20.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
  #0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
After booting there is no /dev/dsp or /dev/mixer devices. Even after creating device nodes I still can't hear any output:

Code: Select all

# cat /sys/class/sound/mixer/dev
14:0
# cat /sys/class/sound/dsp/dev
14:3
# cat /sys/class/sound/audio/dev
14:4
# cat /sys/class/sound/timer/dev 
116:2
# cat /sys/class/sound/pcmC0D0p/dev
116:3
# cat /sys/class/sound/pcmC0D0c/dev
116:4
# cat /sys/class/sound/controlC0/dev
116:5
# mkdir /dev/snd/
# mknod /dev/snd/mixer c 14 0
# mknod /dev/snd/dsp c 14 3
# mknod /dev/snd/audio c 14 4
# mknod /dev/snd/timer c 116 2
# mknod /dev/snd/pcmC0D0p c 116 3
# mknod /dev/snd/pcmC0D0c c 116 4
# mknod /dev/snd/controlC0 c 116 5
# ln /dev/snd/mixer /dev/mixer
# ln /dev/snd/dsp /dev/dsp
# ln /dev/snd/audio /dev/audio
# ln /dev/snd/timer /dev/timer
# ln /dev/snd/pcmC0D0p /dev/pcmC0D0p
# ln /dev/snd/pcmC0D0c /dev/pcmC0D0c
# ln /dev/snd/controlC0 /dev/controlC0
# 
# 
# cat /dev/urandom > /dev/dsp
But I can't hear anything in my headphones. I also tried to created device nodes in /dev/sound/ folder with exactly the same result. Could anyone help me? Thanks.

buserror
Posts: 92
Joined: Thu Jan 22, 2009 12:28 am

Re: Sound problem

Post by buserror » Tue Oct 13, 2009 11:11 pm

Install alsa tools, and use alsamixer to unmute the master output.

mgalemin
Posts: 13
Joined: Tue Oct 06, 2009 11:49 pm

Re: Sound problem

Post by mgalemin » Thu Oct 15, 2009 2:30 am

buserror wrote:Install alsa tools, and use alsamixer to unmute the master output.
Thank you for your answer, buserror. But in fact I have installed Alsa-tools before and set maximal volume using alsamixer. And there is still no sound in headphones. I'm still digging kernel and rootfs.

mgalemin
Posts: 13
Joined: Tue Oct 06, 2009 11:49 pm

Re: Sound problem

Post by mgalemin » Thu Oct 15, 2009 11:50 am

Well, it was quit interesting quest. :)

I found that I couldn't hear anything because of some issue in driver /sound/soc/codecs/uda134x.c. I dug in to the kernel (2.6.31 from buserror repo), traced hardware calls and found that on UDA134X driver loading during the kernel boot value 0x80 is written to the STATUS register (address 0x16) of the UDA1341 IC and according to the datasheet it means that ADC and DAC are both switched off. It happens bias level setting in /sound/soc/soc-dapm.c file in function dapm_power_widgets:

Code: Select all

	/* If we just powered the last thing off drop to standby bias */
	if (codec->bias_level == SND_SOC_BIAS_PREPARE && !sys_power) {
		ret = snd_soc_dapm_set_bias_level(socdev,
						  SND_SOC_BIAS_STANDBY);
sys_power value is set in the same function:

Code: Select all

	/* Check which widgets we need to power and store them in
	 * lists indicating if they should be powered up or down.
	 */
	list_for_each_entry(w, &codec->dapm_widgets, list) {
		switch (w->id) {
		case snd_soc_dapm_pre:
			list_add_tail(&codec->down_list, &w->power_list);
			break;
		case snd_soc_dapm_post:
			list_add_tail(&codec->up_list, &w->power_list);
			break;

		default:
			if (!w->power_check)
				continue;

			power = w->power_check(w);
			if (power)
				sys_power = 1;

As you can see to set sys_power to 1 we need to add widget to codec->dapm_widgets and initialize its power_check pointer. As a temporary hack I added dummy widget to the codec in /sound/soc/codecs/uda134x.c (id = snd_soc_dapm_vmid because function that adds new widget doesn't initialize power_check pointer for this id):

Code: Select all

int uda134x_soc_dummy_power_check(struct snd_soc_dapm_widget *w)
{
    return 1;
}

static const struct snd_soc_dapm_widget uda134x_dummy_dapm_widget = {
    .id = snd_soc_dapm_vmid, 
    .power_check = uda134x_soc_dummy_power_check
};
And in uda134x_soc_probe function before snd_soc_init_card I added:

Code: Select all

	snd_soc_dapm_new_controls(codec, &uda134x_dummy_dapm_widget, 1);
	snd_soc_dapm_new_widgets(codec);
This resolved the sound issue. Is it bug in driver? And if so is it a proper workaround to solve this issue?

P.S. There is also bug in /sound/soc/codecs/uda134x.c file in function uda134x_mute:

Shoul be:

Code: Select all

uda134x_write(codec, UDA134X_DATA010, mute_reg);
instead of

Code: Select all

uda134x_write(codec, UDA134X_DATA010, mute_reg & ~(1<<2));

My diff for uda134x.c:

Code: Select all

===========================================================
--- a/sound/soc/codecs/uda134x.c	2009-10-07 19:48:17.000000000 +0300
+++ b/sound/soc/codecs/uda134x.c	2009-10-15 22:24:00.000000000 +0300
@@ -163,7 +163,7 @@
 	else
 		mute_reg &= ~(1<<2);
 
-	uda134x_write(codec, UDA134X_DATA010, mute_reg & ~(1<<2));
+	uda134x_write(codec, UDA134X_DATA010, mute_reg);
 
 	return 0;
 }
@@ -419,6 +419,16 @@
 SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0),
 };
 
+int uda134x_soc_dummy_power_check(struct snd_soc_dapm_widget *w)
+{
+    return 1;
+}
+
+static const struct snd_soc_dapm_widget uda134x_dummy_dapm_widget = {
+    .id = snd_soc_dapm_vmid, 
+    .power_check = uda134x_soc_dummy_power_check
+};
+
 static const struct snd_kcontrol_new uda1340_snd_controls[] = {
 SOC_SINGLE("Master Playback Volume", UDA134X_DATA000, 0, 0x3F, 1),
 
@@ -562,6 +572,9 @@
 		goto pcm_err;
 	}
 
+	snd_soc_dapm_new_controls(codec, &uda134x_dummy_dapm_widget, 1);
+	snd_soc_dapm_new_widgets(codec);
+	
 	ret = snd_soc_init_card(socdev);
 	if (ret < 0) {
 		printk(KERN_ERR "UDA134X: failed to register card\n");
===========================================================

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests