Skip to contentSkip to conversation

CS5535 AUDIO ALSA driver

RFC In review [email protected] 3 participants 4 messages Sep 15, 2005

Subsystems (5)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

RFC 1/1 CS5535 AUDIO ALSA driver

Hi Jaroslav, Martin, alsa and kernel folk,

Appended is my patch adding support for the CS5535 Audio device. I've done this patch against 2.6.13.1. I didn't find the CS5535 pci id in pci_ids so I've added those and the remaining pci functions for the CS5535 device as defines there. I don't have the ability to test the chip's SPDIF capability yet. I'll add support for it next. Please let me know if it looks okay so far and if you have any feedback or suggestions.

Regards,
Jaya Kumar

---

 CREDITS                                 |    1 
 MAINTAINERS                             |    5 
 include/linux/pci_ids.h                 |    4 
 include/sound/cs5535audio.h             |  128 +++++++++
 sound/pci/Kconfig                       |   13 
 sound/pci/Makefile                      |    1 
 sound/pci/cs5535audio/Makefile          |    8 
 sound/pci/cs5535audio/cs5535audio.c     |  416 ++++++++++++++++++++++++++++++
 sound/pci/cs5535audio/cs5535audio_pcm.c |  433 ++++++++++++++++++++++++++++++++
 9 files changed, 1009 insertions(+)
CREDITS +1 -0
diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/CREDITS linux-2.6.13.1/CREDITS
@@ -1884,6 +1884,7 @@ N: Jaya Kumar
 E: [email protected]
 W: http://www.intworks.biz
 D: Arc monochrome LCD framebuffer driver, x86 reboot fixups
+D: pirq addr, CS5535 alsa audio driver
 S: Gurgaon, India
 S: Kuala Lumpur, Malaysia
 
include/linux/pci_ids.h +4 -0
diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/include/linux/pci_ids.h linux-2.6.13.1/include/linux/pci_ids.h
@@ -392,6 +392,10 @@
 #define PCI_DEVICE_ID_NS_87560_USB	0x0012
 #define PCI_DEVICE_ID_NS_83815		0x0020
 #define PCI_DEVICE_ID_NS_83820		0x0022
+#define PCI_DEVICE_ID_NS_CS5535_IDE	0x002d
+#define PCI_DEVICE_ID_NS_CS5535_AUDIO	0x002e
+#define PCI_DEVICE_ID_NS_CS5535_USB	0x002f
+#define PCI_DEVICE_ID_NS_CS5535_VIDEO	0x0030
 #define PCI_DEVICE_ID_NS_SCx200_BRIDGE	0x0500
 #define PCI_DEVICE_ID_NS_SCx200_SMI	0x0501
 #define PCI_DEVICE_ID_NS_SCx200_IDE	0x0502
include/sound/cs5535audio.h +128 -0

128 lines not on this page · raw message

MAINTAINERS +5 -0
diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/MAINTAINERS linux-2.6.13.1/MAINTAINERS
@@ -621,6 +621,11 @@ M:	[email protected]
 L:	[email protected]
 S:	Maintained
 
+CS5535 Audio ALSA driver
+P:	Jaya Kumar
+M:	[email protected]
+S:	Maintained
+
 CYBERPRO FB DRIVER
 P:	Russell King
 M:	[email protected]
sound/pci/cs5535audio/cs5535audio.c +416 -0

416 lines not on this page · raw message

sound/pci/cs5535audio/cs5535audio_pcm.c +433 -0

433 lines not on this page · raw message

sound/pci/cs5535audio/Makefile +8 -0
diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/sound/pci/cs5535audio/Makefile linux-2.6.13.1/sound/pci/cs5535audio/Makefile
@@ -0,0 +1,8 @@
+#
+# Makefile for cs5535audio
+#
+
+snd-cs5535audio-objs := cs5535audio.o cs5535audio_pcm.o
+
+# Toplevel Module Dependency
+obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o
sound/pci/Kconfig +13 -0
diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/sound/pci/Kconfig linux-2.6.13.1/sound/pci/Kconfig
@@ -350,6 +350,19 @@ config SND_ENS1370
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-ens1370.
 
+config SND_CS5535AUDIO
+	tristate "CS5535 Audio"
+	depends on SND
+	select SND_PCM
+	select SND_AC97_CODEC
+	help
+	  Say Y here to include support for audio on CS5535 chips. It is
+	  referred to as NS CS5535 IO or AMD CS5535 IO companion in 
+	  various literature.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cs5535audio.
+
 config SND_ENS1371
 	tristate "(Creative) Ensoniq AudioPCI 1371/1373"
 	depends on SND
sound/pci/Makefile +1 -0
diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/sound/pci/Makefile linux-2.6.13.1/sound/pci/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_SND) += \
 	au88x0/ \
 	ca0106/ \
 	cs46xx/ \
+	cs5535audio/ \
 	emu10k1/ \
 	hda/ \
 	ice1712/ \

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#1 lore raw
Quoted 3 lines · [email protected] wrote:

Hi Jaroslav, Martin, alsa and kernel folk,

Appended is my patch adding support for the CS5535 Audio device.

Is this anything like the XpressAUDIO subsystem of the CS5530A device?

David Vrabel

Signature · 11 lines
David Vrabel, Design Engineer

Arcom, Clifton Road           Tel: +44 (0)1223 411200 ext. 3233
Cambridge CB1 7EA, UK         Web: http://www.arcom.com/


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
#2 lore raw
In reply to [email protected]

Hi,

At Thu, 15 Sep 2005 17:04:23 +0800,

Quoted 10 lines · [email protected] wrote:

Hi Jaroslav, Martin, alsa and kernel folk,

Appended is my patch adding support for the CS5535 Audio device. I've done this patch against 2.6.13.1. I didn't find the CS5535 pci id in pci_ids so I've added those and the remaining pci functions for the CS5535 device as defines there. I don't have the ability to test the chip's SPDIF capability yet. I'll add support for it next. Please let me know if it looks okay so far and if you have any feedback or suggestions.

Just small glitches I found below:

include/sound/cs5535audio.h

Quoted 3 lines

diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/include/sound/cs5535audio.h linux-2.6.13.1/include/sound/cs5535audio.h

include/sound/cs5535audio.h +0 -0

You can put this header filer into sound/pci/cs5535, so that it won't be exported. Then you don't need __KERNEL__ check, too.

include/sound/cs5535audio.h line 101

Quoted 8 lines
include/sound/cs5535audio.h +8 -0
+typedef struct cs5535audio_dma_desc {
+	u32 addr;	
+	u16 size;
+	u16 reserved:13;
+	u16 jmp:1;
+	u16 eop:1;
+	u16 eot:1;
+} cs5535audio_dma_desc_t;

The bitfield isn't portable to use to comminucate with the hardware. Better to use u16 and normal bit operations.

sound/pci/cs5535audio/cs5535audio.c line 44

Quoted 7 lines

diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/sound/pci/cs5535audio/cs5535audio.c linux-2.6.13.1/sound/pci/cs5535audio/cs5535audio.c

sound/pci/cs5535audio/cs5535audio.c +4 -0
+#define do_delay() do { \
+        set_current_state(TASK_UNINTERRUPTIBLE); \
+        schedule_timeout(1); \
+} while (0)

The loop with do_delay() should be replaced with more portable ones like msleep().

sound/pci/cs5535audio/cs5535audio.c line 64

Quoted 4 lines
sound/pci/cs5535audio/cs5535audio.c +4 -0
+static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au, 
+							unsigned short reg)
+{
+	unsigned long regdata=0;

Unnecessary initialization :)

Quoted 3 lines
sound/pci/cs5535audio/cs5535audio.c +3 -0
+static int __devinit snd_cs5535audio_create(snd_card_t *card,
+				     struct pci_dev *pci,
+				     cs5535audio_t **rcs5535au)

(snip)

sound/pci/cs5535audio/cs5535audio.c line 299

Quoted 1 line
sound/pci/cs5535audio/cs5535audio.c +1 -0
+	cs5535au = kcalloc(1, sizeof(*cs5535au), GFP_KERNEL);

Let's use the new kzalloc().

Quoted 9 lines

diff -uprN -X dontdiff.13.1 linux-2.6.13.1-vanilla/sound/pci/cs5535audio/cs5535audio_pcm.c linux-2.6.13.1/sound/pci/cs5535audio/cs5535audio_pcm.c

sound/pci/cs5535audio/cs5535audio_pcm.c +6 -0
+static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, 
+					cs5535audio_dma_t *dma,
+					snd_pcm_substream_t *substream,
+					unsigned int periods,
+					unsigned int period_bytes)
+{

(snip)

sound/pci/cs5535audio/cs5535audio_pcm.c line 170

Quoted 4 lines
sound/pci/cs5535audio/cs5535audio_pcm.c +4 -0
+	spin_lock(&cs5535au->reg_lock);
+	dma->ops->disable_dma(cs5535au);
+	dma->ops->setup_prd(cs5535au, jmpprd_addr);
+	spin_unlock(&cs5535au->reg_lock);

You need spin_lock_irq() here, instead.

thanks,

Takashi

author maintainer
#3 lore raw
Quoted 1 line · Takashi Iwai

Just small glitches I found below:

Much appreciated. Thanks for reviewing. :-)

Quoted 2 lines

You can put this header filer into sound/pci/cs5535, so that it won't be exported. Then you don't need __KERNEL__ check, too.

Will do.

Quoted 5 lines

include/sound/cs5535audio.h line 101

Quoted 2 lines
include/sound/cs5535audio.h +2 -0
+     u16 eot:1;
+} cs5535audio_dma_desc_t;

The bitfield isn't portable to use to comminucate with the hardware. Better to use u16 and normal bit operations.

I think 5535 is x86-32 specific, but you are right, I shouldn't use bit fields. I'll convert over to masks.

Quoted 2 lines

The loop with do_delay() should be replaced with more portable ones like msleep().

Will do.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+{
+     unsigned long regdata=0;

Unnecessary initialization :)

Good catch.

Quoted 3 lines
Quoted 1 line

+ cs5535au = kcalloc(1, sizeof(*cs5535au), GFP_KERNEL);

Let's use the new kzalloc().

Will do.

Quoted 7 lines

sound/pci/cs5535audio/cs5535audio_pcm.c line 170

Quoted 4 lines
sound/pci/cs5535audio/cs5535audio_pcm.c +4 -0
+     spin_lock(&cs5535au->reg_lock);
+     dma->ops->disable_dma(cs5535au);
+     dma->ops->setup_prd(cs5535au, jmpprd_addr);
+     spin_unlock(&cs5535au->reg_lock);

You need spin_lock_irq() here, instead.

Got it. Will do.

Thanks,
jk