Skip to contentSkip to conversation

AES32 Driver

PATCH Remy Bruno 2 participants 2 messages Sep 20, 2006

lore
Share & tools
lore

Remy Bruno

author
#0 lore raw

Hi,

I modified the hdspm driver in order to support the RME AES32 card. As I'm not sure if it is possible to get the rights for modifying the hg repository, I send the diff file attached (obtained with "diff -u -r", as neither "hg bundle" nor "hg outgoing -p" worked). This diff is against the last hg tree.

The modifications have been done on the basis of the RME Windows driver source code that RME sent to me (but that I am not allowed to send back). The AES32 and MADI cards are differentiated by the firmware revision. I tested the modified driver on an AES32 and (at least partly) validated it. Of course, the MADI part should not be concerned by my modifications, except for one point:
the offset of HDSPM_statusRegister2. In the original hdspm file, it is set to 96, but when I look at the source code by RME, it is set to 48 (but increment is 32 bits, so it corresponds to 192), for AES32 as well as for MADI. So I set it to 192 for both cards. The new driver should thus be tested on the MADI to check if I didn't break this.

I also changed the hdsp driver: by default, precise_ptr was set to 1, which does not work on the cards I have (our company uses many hdsp cards, so I was able to check that this feature does not work at least on some cards). So I reset it to 0, which works on all the cards we have. Of course, it is still possible to change it back to 1 by using the appropriate control, but I think it is better to have default values that work for all cards (and furthermore, I don't see the purpose of this feature, as it works well without it...).

Please let me know if my changes are integrated in the main tree.

Regards,

Remy Bruno

pci/rme9652/hdsp.c +1 -1
diff -u -r alsa-kernel/pci/rme9652/hdsp.c alsa-kernel-aes32/pci/rme9652/hdsp.c
@@ -4940,7 +4940,7 @@
 	}
 
 	hdsp->irq = pci->irq;
-	hdsp->precise_ptr = 1;
+	hdsp->precise_ptr = 0;
 	hdsp->use_midi_tasklet = 1;
 
 	if ((err = snd_hdsp_initialize_memory(hdsp)) < 0)
pci/rme9652/hdspm.c +1148 -245

1,688 lines not on this page · raw message

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#1 lore raw

At Wed, 20 Sep 2006 13:35:20 +0200,

Quoted 4 lines · Remy Bruno

Hi,

I modified the hdspm driver in order to support the RME AES32 card.

Great, thanks for the patch!

Quoted 2 lines

As I'm not sure if it is possible to get the rights for modifying the hg repository,

In HG or GIT development, you don't need the right for modification of upstream. The commitment on your local tree is basically independent from the upstream. It's a complete different development style. Of course, you can keep the old way (i.e. keeping changes uncommitted), so that the sync with upstream works more easily like before, too.

Quoted 3 lines

I send the diff file attached (obtained with "diff -u -r", as neither "hg bundle" nor "hg outgoing -p" worked). This diff is against the last hg tree.

HG bundle or outgoing works only after you commit the changes on your local tree. So, hg diff is the correct way to generate a patch.

Quoted 2 lines

The modifications have been done on the basis of the RME Windows driver source code that RME sent to me (but that I am not allowed to send back).

Well, be careful about this statement.
You are not always allowed to "copy" the stuff from Windows source code unless explicitly permitted by the provider. I think RME is one of such linux-friendly guys, so I don't think it's too problematic, though...

Quoted 9 lines

The AES32
and MADI cards are differentiated by the firmware revision. I tested the modified driver on an AES32 and (at least partly) validated it. Of course, the MADI part should not be concerned by my modifications, except for one point:
the offset of HDSPM_statusRegister2. In the original hdspm file, it is set to 96, but when I look at the source code by RME, it is set to 48 (but increment is 32 bits, so it corresponds to 192), for AES32 as well as for MADI. So I set it to 192 for both cards. The new driver should thus be tested on the MADI to check if I didn't break this.

Yep.

Quoted 9 lines

I also changed the hdsp driver: by default, precise_ptr was set to 1, which does not work on the cards I have (our company uses many hdsp cards, so I was able to check that this feature does not work at least on some cards). So I reset it to 0, which works on all the cards we have. Of course, it is still possible to change it back to 1 by using the appropriate control, but I think it is better to have default values that work for all cards (and furthermore, I don't see the purpose of this feature, as it works well without it...).

Please let me know if my changes are integrated in the main tree.

The code changes look fine to me. But for merging to upstream, please follow the standard coding style:

* 8 columns tab indent (hard tabs are preferred)
* Avoid C++ comments but use C-style
* Fold lines to fit within 80 chars as much as possible
* Don't put braces around a single if() line, i.e.

	if (xxx)
		bbb;

More details can be found in Documentation/CodingStyle in linux kernel tree.

Also, some other nitpicking below:

pci/rme9652/hdspm.c line 340

Quoted 11 lines
pci/rme9652/hdspm.c +11 -0
+// (status >> HDSPM_AES32_wcFreq_bit) & 0xF gives WC frequency
+#define HDSPM_bit2freq(n) (\
+    (n)==1?32000:\
+    (n)==2?44100:\
+    (n)==3?48000:\
+    (n)==4?64000:\
+    (n)==5?88200:\
+    (n)==6?96000:\
+    (n)==7?128000:\
+    (n)==8?176400:\
+    (n)==9?192000:0)

Better to use an array and make it a static inline function.

pci/rme9652/hdspm.c line 2080

Quoted 4 lines
pci/rme9652/hdspm.c +4 -0
+static int hdspm_emphasis(struct hdspm * hdspm)
+{
+	return (hdspm->control_register & HDSPM_Emphasis) ? 1 : 0;
+}

The emphasis, dolby and professional bits are for IEC958 status bits, right? If so, most drivers provide a generic control element "IEC958 Playback Default" (in the source code, it's packed like

	.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT)

). It's a control for encoding/decoding the iec958 status bits. But, it's OK to use the controls as you implemented right now as the first version. We can change this later.

Quoted 5 lines

static void __devinit snd_hdspm_proc_init(struct hdspm * hdspm) {

pci/rme9652/hdspm.c +0 -0
 	struct snd_info_entry *entry;
 
 	if (!snd_card_proc_new(hdspm->card, "hdspm", &entry))

pci/rme9652/hdspm.c line 3367

Quoted 10 lines
pci/rme9652/hdspm.c +7 -1
 		snd_info_set_text_ops(entry, hdspm,
-				      snd_hdspm_proc_read);
+                    hdspm->is_aes32?
+                       snd_hdspm_proc_read_aes32 :
+                       snd_hdspm_proc_read_madi);
+	/* // debug file to read all hdspm registers
+           if (!snd_card_proc_new(hdspm->card, "debug", &entry))
+		snd_info_set_text_ops(entry, hdspm,
+		    snd_hdspm_proc_read_debug); */
 }

If it's only for debugging, put #ifdef CONFIG_SND_DEBUG there.

pci/rme9652/hdspm.c line 4366

Quoted 7 lines
pci/rme9652/hdspm.c +2 -0
@@ -3468,9 +4361,14 @@
 	pci_read_config_word(hdspm->pci,
 			     PCI_CLASS_REVISION, &hdspm->firmware_rev);
 
+        hdspm->is_aes32 = (hdspm->firmware_rev >= HDSPM_AESREVISION);
+
 	strcpy(card->driver, "HDSPM");

I guess it's better to give a different driver name here for AES32. This is an identifier used in alsa-lib, and the card-specific configuration is parsed by this string
(i.e. /usr/share/alsa/cards/*.conf is chosen by this).

pci/rme9652/hdspm.c line 4401

Quoted 9 lines
pci/rme9652/hdspm.c +5 -0
@@ -3496,6 +4394,11 @@
 		   (unsigned long)hdspm->iobase, hdspm->port,
 		   hdspm->port + io_extent - 1);
 
+        // Windows driver modifies the two following PCI registers
+        pci_write_config_byte(pci, PCI_COMMAND,
+            PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
+        pci_write_config_byte(pci, PCI_LATENCY_TIMER, 0xFF);
+        

PCI_COMMAND_MASTER is what pci_set_master() does. The setting of LATENCY_TIMER and COMMAND_MEMORY are skeptical. Avoid this unless you certainly need this setup.

thanks,

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV