Skip to contentSkip to conversation

sx1 mixer support

PATCH Pavel Machek 3 participants 7 messages Nov 24, 2006 – Nov 30, 2006 Sound

lore
Share & tools
lore
#0 lore raw

(I think this should go in through omap tree, because sx1 support in mainline is nonexistent for now, but...)

From: Vladimir Ananiev <[email protected]>

Support mixer on Siemens SX1. Supporting mixer is quite important, because it allows doing voice calls, and SX1 is a telephone after all.

sound/arm/Kconfig +11 -0
index 8f34673..8c035b0 100644
@@ -63,6 +63,17 @@ config SND_OMAP_TSC2101
  	  To compile this driver as a module, choose M here: the module
  	  will be called snd-omap-tsc2101.
 
+config SND_SX1
+ 	tristate "Siemens SX1 Egold alsa driver"
+ 	depends on ARCH_OMAP && SND
+ 	select SND_PCM
+	select OMAP_MCBSP
+ 	help
+ 	  Say Y here if you have a OMAP310 based Siemens SX1.
+ 
+ 	  To compile this driver as a module, choose M here: the module
+ 	  will be called snd-omap-sx1.
+
 config SND_OMAP_TSC2102
  	tristate "OMAP TSC2102 alsa driver"
  	depends on ARCH_OMAP && SND
sound/arm/omap/Makefile +3 -0
index 64e341f..c6bebac 100644
@@ -10,3 +10,6 @@ snd-omap-alsa-tsc2101-objs := omap-alsa.
 
 obj-$(CONFIG_SND_OMAP_TSC2102) += snd-omap-alsa-tsc2102.o
 snd-omap-alsa-tsc2102-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-tsc2102.o omap-alsa-tsc2102-mixer.o
+
+obj-$(CONFIG_SND_SX1) += snd-omap-alsa-sx1.o
+snd-omap-alsa-sx1-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-sx1.o omap-alsa-sx1-mixer.o
sound/arm/omap/omap-alsa-sx1-mixer.c new file +444 -0

444 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1-mixer.h new file +45 -0

45 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.c new file +281 -0

281 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.h new file +81 -0

81 lines not on this page · raw message

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw

At Fri, 24 Nov 2006 12:14:45 +0100,

Quoted 3 lines · Pavel Machek

(I think this should go in through omap tree, because sx1 support in mainline is nonexistent for now, but...)

Yes, it's fine with me.

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +0 -0

(snip)

sound/arm/omap/omap-alsa-sx1-mixer.c line 33

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +2 -0
+static int current_volume 		= 0;	/* current volume, we cant read it */
+static int current_fm_volume 		= 0;	/* current FM radio volume, we cant read it */

Zero-initializations can be stripped. (And lines seem still too long :)

Quoted 1 line

+int set_mixer_volume(int mixer_vol)

Missing static? Also there are many global functions around here.

sound/arm/omap/omap-alsa-sx1-mixer.c

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +2 -0
+{
+	/* FIXME: Alsa has mixer_vol in 0-100 range, while SX1 needs 0-9 range */

An incorrect information. ALSA native mixers can use any value ranges while OSS mixers require 0-100 range.

sound/arm/omap/omap-alsa-sx1-mixer.c line 104

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +2 -0
+/* ---------------------------------------------------------------------------------------- */
+static int __pcm_playback_target_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)

What is the reason to use __ prefix?

Don't use snd_xxx_t typedefs any more. They are obsolete (and will be removed in 2.6.20 tree).

Also, the line is too long (ditto for other callbacks).

sound/arm/omap/omap-alsa-sx1-mixer.c line 139

Quoted 13 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +13 -0
+static int __pcm_playback_target_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	int ret_val = 0;
+	int cur_val = ucontrol->value.integer.value[0];
+
+	if ((cur_val >= 0) &&
+	    (cur_val < PLAYBACK_TARGET_COUNT) &&
+	    (cur_val != current_playback_target)) {
+		if (cur_val == PLAYBACK_TARGET_LOUDSPEAKER) {
+			set_record_source(REC_SRC_SINGLE_ENDED_MICIN_HED);
+			set_loudspeaker_to_playback_target();
+ 		}
+		else if (cur_val == PLAYBACK_TARGET_HEADPHONE) {

'}' ane else should be in the same line.

Quoted 4 lines

+/*
+ * Alsa mixer interface function for getting the volume read from the SX1 in a
+ * 0-100 alsa mixer format.
+ */

I don't think this comment is correct...

sound/arm/omap/omap-alsa-sx1-mixer.c line 174

Quoted 9 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +9 -0
+static int __pcm_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ucontrol->value.integer.value[0] = current_volume;
+	return 0;
+}
+
+static int __pcm_playback_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	return set_mixer_volume(ucontrol->value.integer.value[0]);

The put callback is supposed to return the following values:

0 = the value isn't changed
1 = the value is changed
netagive value = error

The return of 1 is not strictly needed in practice, but it's better to behave in a correct manner.

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1.c new file +0 -0

(snip)

sound/arm/omap/omap-alsa-sx1.c line 54

Quoted 8 lines
sound/arm/omap/omap-alsa-sx1.c new file +8 -0
+/* Send IPC message to sound server */
+extern int cn_sx1snd_send(unsigned int cmd, unsigned int arg1, unsigned int arg2)
+{
+	struct cn_msg *m;
+	unsigned short data[3];
+	int err;
+
+	m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC);

Better to use gfp_any() here, too?
(Or is it really too big for stack?)

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1.h new file +0 -0

(snip)

sound/arm/omap/omap-alsa-sx1.h line 48

Quoted 10 lines
sound/arm/omap/omap-alsa-sx1.h new file +10 -0
+/*
+ * Defines codec specific functions pointers that can be used from the
+ * common omap-alsa base driver for all omap codecs.
+ */
+void egold_configure(void);
+void egold_set_samplerate(long rate);
+void egold_clock_setup(void);
+int egold_clock_on(void);
+int egold_clock_off(void);
+int egold_get_default_samplerate(void);

Do they need to be exported? I see them only in a single file as callbacks...

Thanks,

Takashi

#2 lore raw

Hi!

Quoted 7 lines
Quoted 3 lines · Pavel Machek

(I think this should go in through omap tree, because sx1 support in mainline is nonexistent for now, but...)

Yes, it's fine with me.

Quoted 8 lines
Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +0 -0

(snip)

sound/arm/omap/omap-alsa-sx1-mixer.c

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +2 -0
+static int current_volume 		= 0;	/* current volume, we cant read it */
+static int current_fm_volume 		= 0;	/* current FM radio volume, we cant read it */

Zero-initializations can be stripped. (And lines seem still too long :)

Fixed.

Quoted 9 lines
Quoted 1 line

+int set_mixer_volume(int mixer_vol)

Missing static? Also there are many global functions around here.

sound/arm/omap/omap-alsa-sx1-mixer.c

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +2 -0
+{
+	/* FIXME: Alsa has mixer_vol in 0-100 range, while SX1 needs 0-9 range */

An incorrect information. ALSA native mixers can use any value ranges while OSS mixers require 0-100 range.

Aha, I had this fixed but not commited. Sorry.

Quoted 4 lines

sound/arm/omap/omap-alsa-sx1-mixer.c

Quoted 2 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +2 -0
+/* ---------------------------------------------------------------------------------------- */
+static int __pcm_playback_target_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)

What is the reason to use __ prefix?

I guess Vladimir liked it, fixed.

Quoted 2 lines

Don't use snd_xxx_t typedefs any more. They are obsolete (and will be removed in 2.6.20 tree).

Fixed.

Quoted 1 line

Also, the line is too long (ditto for other callbacks).

Yep, fixed.

Quoted 7 lines
Quoted 7 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +7 -0
+static int __pcm_playback_target_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	int ret_val = 0;
+	int cur_val = ucontrol->value.integer.value[0];
+
+	if ((cur_val >= 0) &&
+	    (cur_val < PLAYBACK_TARGET_COUNT) &&
Quoted 8 lines

sound/arm/omap/omap-alsa-sx1-mixer.c

Quoted 6 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +6 -0
+	    (cur_val != current_playback_target)) {
+		if (cur_val == PLAYBACK_TARGET_LOUDSPEAKER) {
+			set_record_source(REC_SRC_SINGLE_ENDED_MICIN_HED);
+			set_loudspeaker_to_playback_target();
+ 		}
+		else if (cur_val == PLAYBACK_TARGET_HEADPHONE) {

'}' ane else should be in the same line.

Ok.

Quoted 6 lines
Quoted 4 lines

+/*
+ * Alsa mixer interface function for getting the volume read from the SX1 in a
+ * 0-100 alsa mixer format.
+ */

I don't think this comment is correct...

Hmm, plus it is completely useless. Removed.

Quoted 12 lines

sound/arm/omap/omap-alsa-sx1-mixer.c

Quoted 9 lines
sound/arm/omap/omap-alsa-sx1-mixer.c new file +9 -0
+static int __pcm_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ucontrol->value.integer.value[0] = current_volume;
+	return 0;
+}
+
+static int __pcm_playback_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	return set_mixer_volume(ucontrol->value.integer.value[0]);

The put callback is supposed to return the following values:

Quoted 6 lines

0 = the value isn't changed
1 = the value is changed
netagive value = error

The return of 1 is not strictly needed in practice, but it's better to behave in a correct manner.

Hmm, that leads to some quite ugly code, but ok.

Quoted 14 lines
Quoted 2 lines
sound/arm/omap/omap-alsa-sx1.c new file +0 -0

(snip)

sound/arm/omap/omap-alsa-sx1.c

Quoted 8 lines
sound/arm/omap/omap-alsa-sx1.c new file +8 -0
+/* Send IPC message to sound server */
+extern int cn_sx1snd_send(unsigned int cmd, unsigned int arg1, unsigned int arg2)
+{
+	struct cn_msg *m;
+	unsigned short data[3];
+	int err;
+
+	m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC);

Better to use gfp_any() here, too?
(Or is it really too big for stack?)

Let's go with gfp_any() for now.

Quoted 5 lines
Quoted 5 lines
sound/arm/omap/omap-alsa-sx1.c new file +5 -0
+/*
+ * Defines codec specific functions pointers that can be used from the
+ * common omap-alsa base driver for all omap codecs.
+ */
+void egold_configure(void);
Quoted 8 lines

sound/arm/omap/omap-alsa-sx1.c

Quoted 5 lines
sound/arm/omap/omap-alsa-sx1.c new file +5 -0
+void egold_set_samplerate(long rate);
+void egold_clock_setup(void);
+int egold_clock_on(void);
+int egold_clock_off(void);
+int egold_get_default_samplerate(void);

Do they need to be exported? I see them only in a single file as callbacks...

Apparently they do not. Fixed.

Thanks for all the comments!

---

From: Vladimir Ananiev <[email protected]>

Add mixer support for Siemens SX1. As SX1 is an cellphone, and this allows voice calls, it is quite important.

sound/arm/Kconfig +11 -0
index 8f34673..8c035b0 100644
@@ -63,6 +63,17 @@ config SND_OMAP_TSC2101
  	  To compile this driver as a module, choose M here: the module
  	  will be called snd-omap-tsc2101.
 
+config SND_SX1
+ 	tristate "Siemens SX1 Egold alsa driver"
+ 	depends on ARCH_OMAP && SND
+ 	select SND_PCM
+	select OMAP_MCBSP
+ 	help
+ 	  Say Y here if you have a OMAP310 based Siemens SX1.
+ 
+ 	  To compile this driver as a module, choose M here: the module
+ 	  will be called snd-omap-sx1.
+
 config SND_OMAP_TSC2102
  	tristate "OMAP TSC2102 alsa driver"
  	depends on ARCH_OMAP && SND
sound/arm/omap/Makefile +3 -0
index 64e341f..c6bebac 100644
@@ -10,3 +10,6 @@ snd-omap-alsa-tsc2101-objs := omap-alsa.
 
 obj-$(CONFIG_SND_OMAP_TSC2102) += snd-omap-alsa-tsc2102.o
 snd-omap-alsa-tsc2102-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-tsc2102.o omap-alsa-tsc2102-mixer.o
+
+obj-$(CONFIG_SND_SX1) += snd-omap-alsa-sx1.o
+snd-omap-alsa-sx1-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-sx1.o omap-alsa-sx1-mixer.o
sound/arm/omap/omap-alsa-sx1-mixer.c new file +470 -0

470 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1-mixer.h new file +45 -0

45 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.c new file +281 -0

281 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.h new file +70 -0

70 lines not on this page · raw message

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

At Fri, 24 Nov 2006 13:50:40 +0100,

Quoted 14 lines · Pavel Machek
Quoted 13 lines

Review

Quoted 10 lines

+ * Defines codec specific functions pointers that can be used from the
+ * common omap-alsa base driver for all omap codecs.
+ */

(quoted diff) +6 -0
+void egold_configure(void);
+void egold_set_samplerate(long rate);
+void egold_clock_setup(void);
+int egold_clock_on(void);
+int egold_clock_off(void);
+int egold_get_default_samplerate(void);

Do they need to be exported? I see them only in a single file as callbacks...

Quoted 1 line

Apparently they do not. Fixed.

They are still globals. Could be static, right?

Takashi

#4 lore raw

Hi!

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

Review

Quoted 9 lines

+ * Defines codec specific functions pointers that can be used from the
+ * common omap-alsa base driver for all omap codecs.
+ */

(quoted diff) +6 -0
+void egold_configure(void);
+void egold_set_samplerate(long rate);
+void egold_clock_setup(void);
+int egold_clock_on(void);
+int egold_clock_off(void);
+int egold_get_default_samplerate(void);

Do they need to be exported? I see them only in a single file as callbacks...

Quoted 3 lines
Quoted 1 line

Apparently they do not. Fixed.

They are still globals. Could be static, right?

Yes, and few more can be static, too. Fixed.

---

From: Vladimir Ananiev <[email protected]>

Add mixer support for Siemens SX1. As SX1 is an cellphone, and this allows voice calls, it is quite important.

sound/arm/Kconfig +11 -0
index 8f34673..8c035b0 100644
@@ -63,6 +63,17 @@ config SND_OMAP_TSC2101
  	  To compile this driver as a module, choose M here: the module
  	  will be called snd-omap-tsc2101.
 
+config SND_SX1
+ 	tristate "Siemens SX1 Egold alsa driver"
+ 	depends on ARCH_OMAP && SND
+ 	select SND_PCM
+	select OMAP_MCBSP
+ 	help
+ 	  Say Y here if you have a OMAP310 based Siemens SX1.
+ 
+ 	  To compile this driver as a module, choose M here: the module
+ 	  will be called snd-omap-sx1.
+
 config SND_OMAP_TSC2102
  	tristate "OMAP TSC2102 alsa driver"
  	depends on ARCH_OMAP && SND
sound/arm/omap/Makefile +3 -0
index 64e341f..c6bebac 100644
@@ -10,3 +10,6 @@ snd-omap-alsa-tsc2101-objs := omap-alsa.
 
 obj-$(CONFIG_SND_OMAP_TSC2102) += snd-omap-alsa-tsc2102.o
 snd-omap-alsa-tsc2102-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-tsc2102.o omap-alsa-tsc2102-mixer.o
+
+obj-$(CONFIG_SND_SX1) += snd-omap-alsa-sx1.o
+snd-omap-alsa-sx1-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-sx1.o omap-alsa-sx1-mixer.o
sound/arm/omap/omap-alsa-sx1-mixer.c new file +470 -0

470 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1-mixer.h new file +45 -0

45 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.c new file +281 -0

281 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.h new file +70 -0

70 lines not on this page · raw message

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw
In reply to Takashi Iwai

Hi!

Quoted 3 lines
Quoted 1 line

Apparently they do not. Fixed.

They are still globals. Could be static, right?

Yes, fixed.

---

From: Vladimir Ananiev <[email protected]>

Add mixer support for Siemens SX1. As SX1 is an cellphone, and this allows voice calls, it is quite important.

sound/arm/Kconfig +11 -0
index 8f34673..8c035b0 100644
@@ -63,6 +63,17 @@ config SND_OMAP_TSC2101
  	  To compile this driver as a module, choose M here: the module
  	  will be called snd-omap-tsc2101.
 
+config SND_SX1
+ 	tristate "Siemens SX1 Egold alsa driver"
+ 	depends on ARCH_OMAP && SND
+ 	select SND_PCM
+	select OMAP_MCBSP
+ 	help
+ 	  Say Y here if you have a OMAP310 based Siemens SX1.
+ 
+ 	  To compile this driver as a module, choose M here: the module
+ 	  will be called snd-omap-sx1.
+
 config SND_OMAP_TSC2102
  	tristate "OMAP TSC2102 alsa driver"
  	depends on ARCH_OMAP && SND
sound/arm/omap/Makefile +3 -0
index 64e341f..c6bebac 100644
@@ -10,3 +10,6 @@ snd-omap-alsa-tsc2101-objs := omap-alsa.
 
 obj-$(CONFIG_SND_OMAP_TSC2102) += snd-omap-alsa-tsc2102.o
 snd-omap-alsa-tsc2102-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-tsc2102.o omap-alsa-tsc2102-mixer.o
+
+obj-$(CONFIG_SND_SX1) += snd-omap-alsa-sx1.o
+snd-omap-alsa-sx1-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-sx1.o omap-alsa-sx1-mixer.o
sound/arm/omap/omap-alsa-sx1-mixer.c new file +470 -0

470 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1-mixer.h new file +45 -0

45 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.c new file +281 -0

281 lines not on this page · raw message

sound/arm/omap/omap-alsa-sx1.h new file +70 -0

70 lines not on this page · raw message

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
Quoted 7 lines · Pavel Machek

Hi!

Quoted 3 lines
Quoted 1 line

Apparently they do not. Fixed.

They are still globals. Could be static, right?

Yes, fixed.

Pushing this version to linux-omap after a bit more tabifying.

Tony