Skip to contentSkip to conversation

O2 IP32: patch for ALSA sound for 2.6.12rc2

PATCH Frederic TEMPORELLI 2 participants 2 messages Apr 24, 2005

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

Hi,

Here's a patch for some ALSA sound stuff on O2 with 2.6.12rc2.

I wasn't able to get sound since 2.6.8.1, so I get back Glaurung's "sgio2audio" patch for 2.6.1 and update it to 2.6.12rc2. Most of the work was to understand how the driver is working and to update it according to ALSA API changes (I'm not used to work on drivers, moreover on ALSA drivers...)

I've just test the chenages and I've been able to play some music with xmms. Still glitches... but I'm thinking that some people will be interested.

important comments:
- driver can be used as module (modprobe snd-sgi-o2) . Not tested when statically linked to the kernel modprobe may have to be played twice to get the module loaded (seems that AD1843 isn't so easy to init)
- need to be compiled with CONFIG_SND_DEBUG, CONFIG_SND_DEBUG_MEMORY and CONFIG_SND_DEBUG_DETECT => you should be able to get SGI O2 Audio in ALSA mips section
- I didn't (yet) change anything else:
* still glitches. Vivien was talking about DMA issues...
* mixer not available
- I try to reduce created/modified files:
* create include/sound/ad1843.h (also created with 2.6.1 patch)
* change snd/sound/mips/Kconfig (was created by 2.6.1 patch, but now this file is also used for Au1x000 )
* change snd/sound/mips/Makefile (was created by 2.6.1 patch, but now this file is also used for Au1x000 )
* create sound/mips/ad1843.c and sound/mips/sgio2audio.c (also created with 2.6.1 patch)

==
Fred

include/sound/ad1843.h +47 -0
diff -urN -X dontdiff linux-2.6.12rc2-orig/include/sound/ad1843.h linux-2.6.12rc2-o2snd/include/sound/ad1843.h
@@ -0,0 +1,47 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright 2003 Vivien Chappelier <[email protected]>
+ */
+
+#ifndef __SOUND_AD1843_H
+#define __SOUND_AD1843_H
+
+typedef struct {
+  void *chip;
+  int (* read)(void *chip, int reg);
+  int (* write)(void *chip, int reg, int val);
+} ad1843_t;
+
+#define AD1843_GAIN_RECLEV 0
+#define AD1843_GAIN_LINE   1
+#define AD1843_GAIN_CD     2
+#define AD1843_GAIN_MIC    3
+#define AD1843_GAIN_PCM_0  4
+#define AD1843_GAIN_PCM_1  5
+#define AD1843_GAIN_SIZE   AD1843_GAIN_PCM_1+1
+
+int ad1843_get_gain(ad1843_t *ad1843, int id);
+int ad1843_set_gain(ad1843_t *ad1843, int id, int newval);
+int ad1843_get_recsrc(ad1843_t *ad1843);
+void ad1843_set_resample_mode(ad1843_t *ad1843, int onoff);
+int ad1843_set_recsrc(ad1843_t *ad1843, int newsrc);
+int ad1843_get_outsrc(ad1843_t *ad1843);
+int ad1843_set_outsrc(ad1843_t *ad1843, int mask);
+void ad1843_setup_dac(ad1843_t *ad1843,
+                      unsigned int id,
+                      unsigned int framerate,
+                      snd_pcm_format_t fmt,
+                      unsigned int channels);
+void ad1843_shutdown_dac(ad1843_t *ad1843,
+                         unsigned int id);
+void ad1843_setup_adc(ad1843_t *ad1843,
+                      unsigned int framerate,
+                      snd_pcm_format_t fmt,
+                      unsigned int channels);
+void ad1843_shutdown_adc(ad1843_t *ad1843);
+int ad1843_init(ad1843_t *ad1843);
+
+#endif /* __SOUND_AD1843_H */
sound/mips/Kconfig +6 -0
diff -urN -X dontdiff linux-2.6.12rc2-orig/sound/mips/Kconfig linux-2.6.12rc2-o2snd/sound/mips/Kconfig
@@ -11,5 +11,11 @@
 	help
 	  ALSA Sound driver for the Au1x00's AC97 port.
 
+config SND_SGI_O2
+	tristate "SGI O2 Audio"
+	depends on  SND && SGI_IP32
+        help
+                Sound support for the SGI O2 Workstation. 
+
 endmenu
 
sound/mips/Makefile +2 -0
diff -urN -X dontdiff linux-2.6.12rc2-orig/sound/mips/Makefile linux-2.6.12rc2-o2snd/sound/mips/Makefile
@@ -2,7 +2,9 @@
 # Makefile for ALSA
 #
 
+snd-sgi-o2-objs := sgio2audio.o ad1843.o
 snd-au1x00-objs := au1x00.o
 
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_AU1X00) += snd-au1x00.o
+obj-$(CONFIG_SND_SGI_O2) += snd-sgi-o2.o
sound/mips/ad1843.c +624 -0

624 lines not on this page · raw message

sound/mips/sgio2audio.c +794 -0

794 lines not on this page · raw message

#1 lore raw

O2 IP32: patch for ALSA sound for 2.6.12rc2 (2)

more comments about previous patch:
following problems have been reported when compiling static driver:
- "mace" musn't be defined in the driver => just comment line 112 in sgio2audio.c
- AD1843 init may be done twice (or more) to get it working... but driver can't be launch again when static...

Kumba, can you replace alsa_card_sgio2audio_init in sgio2audio.c with following code ? (not really nice, but should do the trick when AD1843 won't go ahead)
====================================================
/* initialization of the module */
#include <linux/delay.h>
static int __init alsa_card_sgio2audio_init(void)

{
       int err,tries;
       tries=0;
       while(tries<5){
               if ((err = snd_sgio2audio_probe()) < 0) {
                       printk("sgio2audio: probe SGI O2 Audio 
#%d\n",tries);
                       tries++;
                       msleep(1000);
               }
               else{
                       printk("sgio2audio: SGI O2 Audio probed - OK\n");
                       return 0;
               }
       }
       printk("sgio2audio: sorry, SGI O2 Audio can't be initialized\n");
       return err;
}

====================================================

Fred