Skip to contentSkip to conversation

ES938 support for ES18xx driver

PATCH Superseded Ondrej Zary 2 participants 2 messages Sep 29, 2014 Sound

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ES938 support for ES18xx driver

Add support for ES938 3-D Audio Effects Processor found on some ES18xx (and possibly other) sound cards, doing bass/treble and 3D control.

ES938 is controlled by MIDI SysEx commands sent through card's MPU401 port.

The code opens/closes the MIDI device everytime a mixer control value is changed so userspace apps can still use the MIDI port. Changing the mixer controls will fail when the MIDI port is open by an application.

---
Changes in v2:
- debug message when ES938 detected
- reworked sysex messages to use structs
- ktime instead of jiffies for timeout

---
 sound/isa/Kconfig  |    4 +
 sound/isa/Makefile |    2 +
 sound/isa/es18xx.c |   13 +++-
 sound/isa/es938.c  |  215 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 sound/isa/es938.h  |   48 ++++++++++++
 5 files changed, 281 insertions(+), 1 deletion(-)
 create mode 100644 sound/isa/es938.c
 create mode 100644 sound/isa/es938.h
sound/isa/Kconfig +4 -0
index 0216475..db0b678 100644
@@ -17,6 +17,9 @@ config SND_SB16_DSP
         select SND_PCM
         select SND_SB_COMMON
 
+config SND_ES938
+	tristate
+
 menuconfig SND_ISA
 	bool "ISA sound devices"
 	depends on ISA && ISA_DMA_API
@@ -183,6 +186,7 @@ config SND_ES18XX
 	select SND_OPL3_LIB
 	select SND_MPU401_UART
 	select SND_PCM
+	select SND_ES938
 	help
 	  Say Y here to include support for ESS AudioDrive ES18xx chips.
 
sound/isa/Makefile +2 -0
index 9a15f14..d59e0bf 100644
@@ -8,6 +8,7 @@ snd-als100-objs := als100.o
 snd-azt2320-objs := azt2320.o
 snd-cmi8328-objs := cmi8328.o
 snd-cmi8330-objs := cmi8330.o
+snd-es938-objs := es938.o
 snd-es18xx-objs := es18xx.o
 snd-opl3sa2-objs := opl3sa2.o
 snd-sc6000-objs := sc6000.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_SND_ALS100) += snd-als100.o
 obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o
 obj-$(CONFIG_SND_CMI8328) += snd-cmi8328.o
 obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o
+obj-$(CONFIG_SND_ES938) += snd-es938.o
 obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o
 obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o
 obj-$(CONFIG_SND_SC6000) += snd-sc6000.o
sound/isa/es18xx.c +12 -1
index 6faaac6..e174e8c 100644
@@ -96,6 +96,7 @@
 #define SNDRV_LEGACY_FIND_FREE_IRQ
 #define SNDRV_LEGACY_FIND_FREE_DMA
 #include <sound/initval.h>
+#include "es938.h"
 
 #define PFX "es18xx: "
 
@@ -122,6 +123,7 @@ struct snd_es18xx {
 	struct snd_pcm_substream *playback_b_substream;
 
 	struct snd_rawmidi *rmidi;
+	struct snd_es938 es938;
 
 	struct snd_kcontrol *hw_volume;
 	struct snd_kcontrol *hw_switch;
@@ -2167,7 +2169,16 @@ static int snd_audiodrive_probe(struct snd_card *card, int dev)
 			return err;
 	}
 
-	return snd_card_register(card);
+	err = snd_card_register(card);
+	if (err < 0)
+		return err;
+
+	if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT)
+		/* no error if this fails because ES938 is optional */
+		if (snd_es938_init(&chip->es938, card, 0, 0) == 0)
+			snd_printk(KERN_DEBUG "found ES938 audio processor\n");
+
+	return 0;
 }
 
 static int snd_es18xx_isa_match(struct device *pdev, unsigned int dev)
sound/isa/es938.c new file +215 -0

215 lines not on this page · raw message

sound/isa/es938.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
Ondrej Zary
#1 lore raw

Hi,

sound/isa/es18xx.c static int snd_audiodrive_probe(struct snd_card *card, int dev) · line 2181

Quoted 6 lines · Ondrej Zary
sound/isa/es18xx.c +6 -0
+	if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT)
+		/* no error if this fails because ES938 is optional */
+		if (snd_es938_init(&chip->es938, card, 0, 0) == 0)
+			snd_printk(KERN_DEBUG "found ES938 audio processor\n");
+
+	return 0;

Hmm, how's the braces policy here?
Given a double "if" I'd suspect that the outer "if" would want braces then. (perhaps checkpatch.pl has something to say here)

Not to mention that I'm having strong doubts about the kernel's "if" coding style guidelines in general:
IMHO *all* uses of "if" ought to be braced:
witness the Apple-specific OpenSSL bug catastrophy ("goto fail;"), where people said that adding braces to conditionals would have made things obvious.
Plus the annoyance that for an addition commit to an existing conditional the diff will *not* contain the addition only (one line),
but rather *three* lines, and the first line rather needlessly getting modified even!

+ if (is_foo)
+ bar;

So, given a ridiculously simple one-line addition:

- if (is_foo)

+ if (is_foo) {
    bar;

+ boo;
+ }

Rather than:

+ if (is_foo) {
+ bar;
+ }

if (is_foo) {
bar;
+ boo;
}

(SIX changed lines vs. 4!)

Not to mention my pet peeve about large sections of coding style documents - they establish Golden Rules to never be broken, but then
Fail To Elaborate Why - STUPID!
(that does not fully apply to our "if" CodingStyle paragraph though) What a great way to hamper properly thought out evolution of guidelines...

Perhaps we should have a seasoned discussion about that coding style issue, and others? (any update of Documentation/CodingStyle
would need to directly include an update to checkpatch.pl, too, though)

(sorry about that part being rather OT to your particular nice patch)

sound/isa/es938.c line 42

Quoted 7 lines
sound/isa/es938.c new file +7 -0
+	struct snd_es938_sysex_reg req = {
+		.midi_cmd = MIDI_CMD_COMMON_SYSEX,
+		.id = ES938_ID,
+		.cmd = ES938_CMD_REG_R,
+		.reg = reg,
+		.midi_end = MIDI_CMD_COMMON_SYSEX_END,
+	};

Hmm, perhaps const? :)
(and dito probably a const void * cast further below, to forego receiving the optionally activated gcc non-const cast warnings)

sound/isa/es938.c line 49

Quoted 1 line
sound/isa/es938.c new file +1 -0
+	end_time = ktime_add_ms(ktime_get(), 100);

Yay! One driver less which is advertising
less precise deprecated implementation style :)

sound/isa/es938.c line 59

Quoted 1 line
sound/isa/es938.c new file +1 -0
+	/* check if the reply is our and has SYSEX_END at the end */

"ours"

Thanks,

Andreas Mohr