All of lore.kernel.org
 help / color / mirror / Atom feed
From: Torsten Schenk <torsten.schenk@zoho.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, clemens@ladisch.de
Subject: [PATCH 4/5] TerraTec DMX 6Fire USB updates
Date: Mon, 04 Apr 2011 11:49:57 +0200	[thread overview]
Message-ID: <12f1feb30c7.-5993834303264871022.359084891425151717@zoho.com> (raw)
In-Reply-To: <s5hwrjamq64.wl%tiwai@suse.de>

Firmware loader: magical device bytes check updated (accepts all device versions now and accepts possibly loaded firmware, if it is knowing to be working)

Signed-off-by: Torsten Schenk <torsten.schenk@zoho.com>

diff -Nur a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c
--- a/sound/usb/6fire/firmware.c	2011-04-04 11:26:54.528833002 +0200
+++ b/sound/usb/6fire/firmware.c	2011-04-04 11:25:27.014833002 +0200
@@ -3,12 +3,6 @@
  *
  * Firmware loader
  *
- * Currently not working for all devices. To be able to use the device
- * in linux, it is also possible to let the windows driver upload the firmware.
- * For that, start the computer in windows and reboot.
- * As long as the device is connected to the power supply, no firmware reload
- * needs to be performed.
- *
  * Author:	Torsten Schenk <torsten.schenk@zoho.com>
  * Created:	Jan 01, 2011
  * Version:	0.3.0
@@ -72,6 +66,10 @@
 	0x94, 0x01, 0x5c, 0x02  /* alt 3: 404 EP2 and 604 EP6 (25 fpp) */
 };
 
+static const u8 known_fw_versions[][4] = {
+	{ 0x03, 0x01, 0x0b, 0x00 }
+};
+
 struct ihex_record {
 	u16 address;
 	u8 len;
@@ -364,6 +362,25 @@
 	return 0;
 }
 
+/* check, if the firmware version the devices has currently loaded
+ * is known by this driver. 'version' needs to have 4 bytes version
+ * info data. */
+static int usb6fire_fw_check(u8 *version)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(known_fw_versions); i++)
+		if (!memcmp(version, known_fw_versions + i, 4))
+			return 0;
+
+	snd_printk(KERN_ERR PREFIX "invalid fimware version in device: "
+			"%02x %02x %02x %02x. "
+			"please reconnect to power. if this failure "
+			"still happens, check your firmware installation.",
+			version[0], version[1], version[2], version[3]);
+	return -EINVAL;
+}
+
 int usb6fire_fw_init(struct usb_interface *intf)
 {
 	int i;
@@ -379,9 +396,7 @@
 				"firmware state.\n");
 		return ret;
 	}
-	if (buffer[0] != 0xeb || buffer[1] != 0xaa || buffer[2] != 0x55
-			|| buffer[4] != 0x03 || buffer[5] != 0x01 || buffer[7]
-			!= 0x00) {
+	if (buffer[0] != 0xeb || buffer[1] != 0xaa || buffer[2] != 0x55) {
 		snd_printk(KERN_ERR PREFIX "unknown device firmware state "
 				"received from device: ");
 		for (i = 0; i < 8; i++)
@@ -390,7 +405,7 @@
 		return -EIO;
 	}
 	/* do we need fpga loader ezusb firmware? */
-	if (buffer[3] == 0x01 && buffer[6] == 0x19) {
+	if (buffer[3] == 0x01) {
 		ret = usb6fire_fw_ezusb_upload(intf,
 				"6fire/dmx6firel2.ihx", 0, NULL, 0);
 		if (ret < 0)
@@ -398,7 +413,10 @@
 		return FW_NOT_READY;
 	}
 	/* do we need fpga firmware and application ezusb firmware? */
-	else if (buffer[3] == 0x02 && buffer[6] == 0x0b) {
+	else if (buffer[3] == 0x02) {
+		ret = usb6fire_fw_check(buffer + 4);
+		if (ret < 0)
+			return ret;
 		ret = usb6fire_fw_fpga_upload(intf, "6fire/dmx6firecf.bin");
 		if (ret < 0)
 			return ret;
@@ -411,8 +429,8 @@
 		return FW_NOT_READY;
 	}
 	/* all fw loaded? */
-	else if (buffer[3] == 0x03 && buffer[6] == 0x0b)
-		return 0;
+	else if (buffer[3] == 0x03)
+		return usb6fire_fw_check(buffer + 4);
 	/* unknown data? */
 	else {
 		snd_printk(KERN_ERR PREFIX "unknown device firmware state "

  parent reply	other threads:[~2011-04-04  9:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <12d995c1fa0.477955495632923443.5387390398635058860@zoho.com>
2011-01-20 16:54 ` Driver for TerraTec DMX 6Fire USB Takashi Iwai
2011-01-20 22:38   ` Torsten Schenk
2011-01-21  8:57     ` Takashi Iwai
2011-01-21 11:48       ` Torsten Schenk
2011-01-22 16:35         ` Takashi Iwai
2011-01-24 12:10           ` Torsten Schenk
2011-01-25 10:25             ` Takashi Iwai
2011-01-25 14:12               ` Torsten Schenk
2011-03-31 19:25         ` TerraTec DMX 6Fire USB updates Torsten Schenk
2011-04-01 12:52           ` Takashi Iwai
2011-04-03 12:30             ` Torsten Schenk
2011-04-04  7:28               ` Takashi Iwai
2011-04-04  9:41                 ` Torsten Schenk
2011-04-04  9:45                 ` [PATCH 1/5] " Torsten Schenk
2011-04-04 10:29                   ` Takashi Iwai
2011-04-04  9:47                 ` [PATCH 2/5] " Torsten Schenk
2011-04-04  9:49                 ` [PATCH 3/5] " Torsten Schenk
2011-04-04  9:49                 ` Torsten Schenk [this message]
2011-04-04  9:50                 ` [PATCH 5/5] " Torsten Schenk
2011-06-16 19:06             ` [PATCH] final issues in snd-usb-6fire concerning signedness bug Torsten Schenk
2011-06-16 19:33               ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12f1feb30c7.-5993834303264871022.359084891425151717@zoho.com \
    --to=torsten.schenk@zoho.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.