Skip to contentSkip to conversation

caiaq/NativeInstruments: control support

PATCH In review Daniel Mack 2 participants 4 messages Nov 20, 2007 – Nov 21, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 caiaq/NativeInstruments: control support

Hi,

This patch adds support for input controllers on "Kore controller" and uses ALSA's control API to enable LED switching on several hardware products as well as some internal audio related functions of "Audio 8 DJ".

Subject: SOUND: caiaq - add control API and more input features
From: Daniel Mack <[email protected]>

SOUND: caiaq - add control API and more input features

- added support for all input controllers on Native Instrument's "Kore controller".
- added ALSA controls to switch LEDs on "RigKontrol 2", "RigKontrol3", "Audio Kontrol 1" and "Kore controller".
- added ALSA controls to switch input mode, software lock and ground lift features on "Audio 8 DJ".

#1 lore raw
Quoted 5 lines · Daniel Mack

Subject: SOUND: caiaq - add control API and more input features
From: Daniel Mack <[email protected]>

SOUND: caiaq - add control API and more input features

Quoted 8 lines

- added support for all input controllers on Native Instrument's "Kore controller".
- added ALSA controls to switch LEDs on "RigKontrol 2", "RigKontrol3", "Audio Kontrol 1" and "Kore controller".
- added ALSA controls to switch input mode, software lock and ground lift features on "Audio 8 DJ".

Attached now.

sound/usb/Kconfig +1 -0
index 7061438..05a311d 100644
@@ -57,6 +57,7 @@ config SND_USB_CAIAQ_INPUT
 
 	   * Native Instruments RigKontrol2
 	   * Native Instruments RigKontrol3
+	   * Native Instruments Kore Controller
 	   * Native Instruments Audio Kontrol 1
 
 endmenu
sound/usb/caiaq/Makefile +1 -1
index 455c8c5..345a965 100644
@@ -1,3 +1,3 @@
-snd-usb-caiaq-objs := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-input.o
+snd-usb-caiaq-objs := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-input.o caiaq-control.o
 
 obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o
sound/usb/caiaq/caiaq-control.c new file +329 -0

329 lines not on this page · raw message

sound/usb/caiaq/caiaq-control.h new file +6 -0
new file mode 100644
index 0000000..2e7ab1a
@@ -0,0 +1,6 @@
+#ifndef CAIAQ_CONTROL_H
+#define CAIAQ_CONTROL_H
+
+int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev);
+
+#endif /* CAIAQ_CONTROL_H */
sound/usb/caiaq/caiaq-device.c +49 -14

136 lines not on this page · raw message

sound/usb/caiaq/caiaq-device.h +9 -2
index 6857612..a616b6a 100644
@@ -35,6 +35,7 @@
 #define EP1_CMD_MIDI_WRITE	0x7
 #define EP1_CMD_AUDIO_PARAMS	0x9
 #define EP1_CMD_AUTO_MSG	0xb
+#define EP1_CMD_DIMM_LEDS       0xc
 
 struct caiaq_device_spec {
 	unsigned short fw_version;
@@ -90,11 +91,14 @@ struct snd_usb_caiaqdev {
 	struct snd_pcm_substream *sub_playback[MAX_STREAMS];
 	struct snd_pcm_substream *sub_capture[MAX_STREAMS];
 
+	/* Controls */
+	unsigned char control_state[64];
+
 	/* Linux input */
 #ifdef CONFIG_SND_USB_CAIAQ_INPUT
 	struct input_dev *input_dev;
 	char phys[64];			/* physical device path */
-	unsigned short keycode[10];
+	unsigned short keycode[64];
 #endif
 
 	/* ALSA */
@@ -114,6 +118,9 @@ struct snd_usb_caiaq_cb_info {
 
 int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
 int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
-
+int snd_usb_caiaq_send_command (struct snd_usb_caiaqdev *dev,
+                                unsigned char command,
+				const unsigned char *buffer,
+				int len);
 
 #endif /* CAIAQ_DEVICE_H */
sound/usb/caiaq/caiaq-input.c +100 -10

164 lines not on this page · raw message

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw

At Tue, 20 Nov 2007 14:37:46 +0100,

Quoted 3 lines · Daniel Mack
sound/usb/caiaq/caiaq-control.c new file +0 -0

(snip)

sound/usb/caiaq/caiaq-control.c line 31

Quoted 3 lines
sound/usb/caiaq/caiaq-control.c new file +3 -0
+#ifdef CONFIG_SND_USB_CAIAQ_INPUT
+#include <linux/input.h>
+#endif

Do you really need ifdef here?

Quoted 15 lines
sound/usb/caiaq/caiaq-control.c new file +15 -0
+static int control_put(struct snd_kcontrol *kcontrol,
+		       struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
+	struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
+	int pos = kcontrol->private_value;
+
+	if (pos & CNT_INTVAL) {
+		dev->control_state[pos & ~CNT_INTVAL] 
+			= ucontrol->value.integer.value[0];
+		snd_usb_caiaq_send_command(dev, EP1_CMD_DIMM_LEDS,
+				dev->control_state, sizeof(dev->control_state));
+	} else {
+		if (ucontrol->value.integer.value[0])
+			dev->control_state[pos / 8] |= 1 << (pos % 8);

sound/usb/caiaq/caiaq-control.c line 113

Quoted 10 lines
sound/usb/caiaq/caiaq-control.c new file +10 -0
+		else
+			dev->control_state[pos / 8] &= ~(1 << (pos % 8));
+	
+		snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
+				dev->control_state, sizeof(dev->control_state));
+	}
+	
+
+	return 0;
+}

The put callback is supposed to return 1 if a value is changed. It's no strict requirement, so far, but if this still doesn't follow put a comment like FIXME.

Quoted 10 lines

+/*
+ *
+ * 0
+ * 1 << 1
+ * 1 << 0 | 1 << 1
+ * 1 << 0 | 1 << 1 | 1 << 2
+ * 1 << 0
+ * 0
+ *
+ */

What's this? :)

thanks,

Takashi

#3 lore raw
Quoted 5 lines · Takashi Iwai

Review

Quoted 3 lines
(quoted diff) +3 -0
+#ifdef CONFIG_SND_USB_CAIAQ_INPUT
+#include <linux/input.h>
+#endif

Do you really need ifdef here?

No, I agree. Also removed that from other places.

Quoted 3 lines

The put callback is supposed to return 1 if a value is changed. It's no strict requirement, so far, but if this still doesn't follow put a comment like FIXME.

Changed.

Quoted 11 lines
Quoted 10 lines

+/*
+ *
+ * 0
+ * 1 << 1
+ * 1 << 0 | 1 << 1
+ * 1 << 0 | 1 << 1 | 1 << 2
+ * 1 << 0
+ * 0
+ *
+ */

Quoted 1 line

What's this? :)

I developement left-over - I'm still not yet used to git-update-index ;)

New version attached.

Greets,
Daniel

sound/usb/Kconfig +1 -0
index 7061438..05a311d 100644
@@ -57,6 +57,7 @@ config SND_USB_CAIAQ_INPUT
 
 	   * Native Instruments RigKontrol2
 	   * Native Instruments RigKontrol3
+	   * Native Instruments Kore Controller
 	   * Native Instruments Audio Kontrol 1
 
 endmenu
sound/usb/caiaq/Makefile +1 -1
index 455c8c5..345a965 100644
@@ -1,3 +1,3 @@
-snd-usb-caiaq-objs := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-input.o
+snd-usb-caiaq-objs := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-input.o caiaq-control.o
 
 obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o
sound/usb/caiaq/caiaq-audio.c +0 -2
index 0666908..bf551c0 100644
@@ -27,9 +27,7 @@
 #include <sound/initval.h>
 #include <sound/pcm.h>
 #include <sound/rawmidi.h>
-#ifdef CONFIG_SND_USB_CAIAQ_INPUT
 #include <linux/input.h>
-#endif
 
 #include "caiaq-device.h"
 #include "caiaq-audio.h"
sound/usb/caiaq/caiaq-control.c new file +316 -0

316 lines not on this page · raw message

sound/usb/caiaq/caiaq-control.h new file +6 -0
new file mode 100644
index 0000000..2e7ab1a
@@ -0,0 +1,6 @@
+#ifndef CAIAQ_CONTROL_H
+#define CAIAQ_CONTROL_H
+
+int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev);
+
+#endif /* CAIAQ_CONTROL_H */
sound/usb/caiaq/caiaq-device.c +49 -14

136 lines not on this page · raw message

sound/usb/caiaq/caiaq-device.h +9 -2
index 6857612..a616b6a 100644
@@ -35,6 +35,7 @@
 #define EP1_CMD_MIDI_WRITE	0x7
 #define EP1_CMD_AUDIO_PARAMS	0x9
 #define EP1_CMD_AUTO_MSG	0xb
+#define EP1_CMD_DIMM_LEDS       0xc
 
 struct caiaq_device_spec {
 	unsigned short fw_version;
@@ -90,11 +91,14 @@ struct snd_usb_caiaqdev {
 	struct snd_pcm_substream *sub_playback[MAX_STREAMS];
 	struct snd_pcm_substream *sub_capture[MAX_STREAMS];
 
+	/* Controls */
+	unsigned char control_state[64];
+
 	/* Linux input */
 #ifdef CONFIG_SND_USB_CAIAQ_INPUT
 	struct input_dev *input_dev;
 	char phys[64];			/* physical device path */
-	unsigned short keycode[10];
+	unsigned short keycode[64];
 #endif
 
 	/* ALSA */
@@ -114,6 +118,9 @@ struct snd_usb_caiaq_cb_info {
 
 int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
 int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
-
+int snd_usb_caiaq_send_command (struct snd_usb_caiaqdev *dev,
+                                unsigned char command,
+				const unsigned char *buffer,
+				int len);
 
 #endif /* CAIAQ_DEVICE_H */
sound/usb/caiaq/caiaq-input.c +100 -10

164 lines not on this page · raw message

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel