Skip to contentSkip to conversation

SGI O2 sound driver

PATCH Thomas Bogendoerfer 2 participants 8 messages Jun 28, 2008 – Jul 5, 2008

Subsystems (3)
lore
Share & tools
lore

Thomas Bogendoerfer

author maintainer
#0 lore raw

Hi

after seeing another request for an O2 sound driver on #mipslinux, I decided to have a look on my own, what's so difficult about it.

Below is my first working driver, which is able to play .mp3 with mpg321. The trick to get it working was to dma_alloc_coherent the dma ring buffer instead of using get_free_pages(). The driver is still missing cleanups and features.

Thomas.

 include/sound/ad1843.h  |   47 +++
 sound/mips/Kconfig      |    6 +
 sound/mips/Makefile     |    2 +
 sound/mips/ad1843.c     |  622 +++++++++++++++++++++++++++++++++++++
 sound/mips/sgio2audio.c |  789 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1466 insertions(+), 0 deletions(-)
include/sound/ad1843.h new file +47 -0
new file mode 100644
index 0000000..0a85e19
@@ -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
index 531f8ba..a3e202e 100644
@@ -11,5 +11,11 @@ config SND_AU1X00
 	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
index 47afed9..55624d8 100644
@@ -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 new file +622 -0

622 lines not on this page · raw message

sound/mips/sgio2audio.c new file +789 -0

789 lines not on this page · raw message

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#1 lore raw
Quoted 2 lines · Thomas Bogendoerfer

the dma ring buffer instead of using get_free_pages(). The driver is still missing cleanups and features.

v2 is now checkpatch clean and I switched over to use a platform device. The next step is now to get capture and 2nd playback going.

Thomas.

 arch/mips/sgi-ip32/ip32-platform.c |   18 +
 include/sound/ad1843.h             |   47 +++
 sound/mips/Kconfig                 |    6 +
 sound/mips/Makefile                |    2 +
 sound/mips/ad1843.c                |  644 ++++++++++++++++++++++++++++++++
 sound/mips/sgio2audio.c            |  714 ++++++++++++++++++++++++++++++++++++
 6 files changed, 1431 insertions(+), 0 deletions(-)
arch/mips/sgi-ip32/ip32-platform.c +18 -0
index 89a71f4..8b624b9 100644
@@ -65,6 +65,24 @@ static __init int meth_devinit(void)
 
 device_initcall(meth_devinit);
 
+static __init int sgio2audio_devinit(void)
+{
+	struct platform_device *pd;
+	int ret;
+
+	pd = platform_device_alloc("sgio2audio", -1);
+	if (!pd)
+		return -ENOMEM;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		platform_device_put(pd);
+
+	return ret;
+}
+
+device_initcall(sgio2audio_devinit);
+
 MODULE_AUTHOR("Ralf Baechle <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2");
include/sound/ad1843.h new file +47 -0

47 lines not on this page · raw message

sound/mips/Kconfig +6 -0
index 531f8ba..a3e202e 100644
@@ -11,5 +11,11 @@ config SND_AU1X00
 	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
index 47afed9..55624d8 100644
@@ -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 new file +644 -0

644 lines not on this page · raw message

sound/mips/sgio2audio.c new file +714 -0

714 lines not on this page · raw message

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#2 lore raw
Quoted 2 lines · Thomas Bogendoerfer

v2 is now checkpatch clean and I switched over to use a platform device. The next step is now to get capture and 2nd playback going.

(important) changes in v3:

- support 2nd DAC
- added delay after releasing module reset

Thomas.

 arch/mips/sgi-ip32/ip32-platform.c |   18 +
 include/sound/ad1843.h             |   47 +++
 sound/mips/Kconfig                 |    6 +
 sound/mips/Makefile                |    2 +
 sound/mips/ad1843.c                |  653 ++++++++++++++++++++++++++++++++
 sound/mips/sgio2audio.c            |  730 ++++++++++++++++++++++++++++++++++++
 6 files changed, 1456 insertions(+), 0 deletions(-)
arch/mips/sgi-ip32/ip32-platform.c +18 -0
index 89a71f4..8b624b9 100644
@@ -65,6 +65,24 @@ static __init int meth_devinit(void)
 
 device_initcall(meth_devinit);
 
+static __init int sgio2audio_devinit(void)
+{
+	struct platform_device *pd;
+	int ret;
+
+	pd = platform_device_alloc("sgio2audio", -1);
+	if (!pd)
+		return -ENOMEM;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		platform_device_put(pd);
+
+	return ret;
+}
+
+device_initcall(sgio2audio_devinit);
+
 MODULE_AUTHOR("Ralf Baechle <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2");
include/sound/ad1843.h new file +47 -0

47 lines not on this page · raw message

sound/mips/Kconfig +6 -0
index 531f8ba..a3e202e 100644
@@ -11,5 +11,11 @@ config SND_AU1X00
 	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
index 47afed9..55624d8 100644
@@ -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 new file +653 -0

653 lines not on this page · raw message

sound/mips/sgio2audio.c new file +730 -0

730 lines not on this page · raw message

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#3 lore raw

Re: SGI O2 sound driver v4

Quoted 1 line · Thomas Bogendoerfer

[...]

changes in v4:

- added control
- added capture support (no idea, if it is correct, yet)

I'm on a buissness trip the next two days, so I'm not able to work on the driver. Here is a short TODO:

- test capture and fix bugs
- switch over to use S24_BE (didn't work the first time I checked it)
- rewrite dma_push/dma_pull functions after switching for S24_BE
- maybe more controls
- rip out button support and write input driver for it
- add dma error interrupt handling
- check spinlock usage
- use atomic_test_set for pcm open stuff

Thomas.

 arch/mips/sgi-ip32/ip32-platform.c |   18 +
 include/sound/ad1843.h             |   45 ++
 sound/mips/Kconfig                 |    6 +
 sound/mips/Makefile                |    2 +
 sound/mips/ad1843.c                |  545 +++++++++++++++++++
 sound/mips/sgio2audio.c            | 1034 ++++++++++++++++++++++++++++++++++++
 6 files changed, 1650 insertions(+), 0 deletions(-)
arch/mips/sgi-ip32/ip32-platform.c +18 -0
index 89a71f4..8b624b9 100644
@@ -65,6 +65,24 @@ static __init int meth_devinit(void)
 
 device_initcall(meth_devinit);
 
+static __init int sgio2audio_devinit(void)
+{
+	struct platform_device *pd;
+	int ret;
+
+	pd = platform_device_alloc("sgio2audio", -1);
+	if (!pd)
+		return -ENOMEM;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		platform_device_put(pd);
+
+	return ret;
+}
+
+device_initcall(sgio2audio_devinit);
+
 MODULE_AUTHOR("Ralf Baechle <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2");
include/sound/ad1843.h new file +45 -0

45 lines not on this page · raw message

sound/mips/Kconfig +6 -0
index 531f8ba..a3e202e 100644
@@ -11,5 +11,11 @@ config SND_AU1X00
 	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
index 47afed9..55624d8 100644
@@ -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 new file +545 -0

545 lines not on this page · raw message

sound/mips/sgio2audio.c new file +1034 -0

1,034 lines not on this page · raw message

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#4 lore raw

Re: SGI O2 sound driver v4

Quoted 2 lines · Thomas Bogendoerfer
Quoted 1 line

[...]

changes in v5:

- fixed contols
- got rid of wrong spinlocks
- setup two pcm devices
- moved button support to a new input driver
- restructered interrupt setup

TODO:
- test capture
- check inputs (mic/line/cd)
- add dma error interrupt handling

I'm planning to submit the different parts to the maintainers after I've checked that capturing is working.

Thomas.

 arch/mips/sgi-ip32/ip32-platform.c |   36 ++
 drivers/input/misc/Kconfig         |   10 +
 drivers/input/misc/Makefile        |    1 +
 drivers/input/misc/sgio2_btns.c    |  154 ++++++
 include/sound/ad1843.h             |   46 ++
 sound/mips/Kconfig                 |    6 +
 sound/mips/Makefile                |    2 +
 sound/mips/ad1843.c                |  530 +++++++++++++++++++
 sound/mips/sgio2audio.c            |  986 ++++++++++++++++++++++++++++++++++++
 9 files changed, 1771 insertions(+), 0 deletions(-)
arch/mips/sgi-ip32/ip32-platform.c +36 -0
index 89a71f4..2ee401b 100644
@@ -65,6 +65,42 @@ static __init int meth_devinit(void)
 
 device_initcall(meth_devinit);
 
+static __init int sgio2audio_devinit(void)
+{
+	struct platform_device *pd;
+	int ret;
+
+	pd = platform_device_alloc("sgio2audio", -1);
+	if (!pd)
+		return -ENOMEM;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		platform_device_put(pd);
+
+	return ret;
+}
+
+device_initcall(sgio2audio_devinit);
+
+static __init int sgio2btns_devinit(void)
+{
+	struct platform_device *pd;
+	int ret;
+
+	pd = platform_device_alloc("sgio2btns", -1);
+	if (!pd)
+		return -ENOMEM;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		platform_device_put(pd);
+
+	return ret;
+}
+
+device_initcall(sgio2btns_devinit);
+
 MODULE_AUTHOR("Ralf Baechle <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2");
drivers/input/misc/Kconfig +10 -0
index 432699d..e33d7cb 100644
@@ -189,6 +189,16 @@ config INPUT_UINPUT
 	  To compile this driver as a module, choose M here: the
 	  module will be called uinput.
 
+config INPUT_SGIO2_BTNS
+	tristate "SGI O2 volume button interface"
+	depends on SGI_IP32
+	select INPUT_POLLDEV
+	help
+	  Say Y here if you want to support SGI O2 volume button interface.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called sgio_btns.
+
 config HP_SDC_RTC
 	tristate "HP SDC Real Time Clock"
 	depends on GSC || HP300
drivers/input/misc/Makefile +1 -0
index ebd39f2..0e274f1 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
+obj-$(CONFIG_INPUT_SGIO2_BTNS)		+= sgio2_btns.o
drivers/input/misc/sgio2_btns.c new file +154 -0

154 lines not on this page · raw message

include/sound/ad1843.h new file +46 -0

46 lines not on this page · raw message

sound/mips/Kconfig +6 -0
index 531f8ba..a3e202e 100644
@@ -11,5 +11,11 @@ config SND_AU1X00
 	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
index 47afed9..55624d8 100644
@@ -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 new file +530 -0

530 lines not on this page · raw message

sound/mips/sgio2audio.c new file +986 -0

986 lines not on this page · raw message

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#5 lore raw

Re: SGI O2 sound driver v6

Quoted 1 line · Thomas Bogendoerfer

[...]

changes in v6:

- fixed mmap setup
- capture is working now
- reworked all mixer controls
- added dma error interrupt
- fixed button detection in input driver

This is the final complete patch. I'm now going to split the patch into pieces for submission to the different maintainers.

Thomas.

 arch/mips/sgi-ip32/ip32-platform.c |   36 ++
 drivers/input/misc/Kconfig         |   10 +
 drivers/input/misc/Makefile        |    1 +
 drivers/input/misc/sgio2_btns.c    |  154 ++++++
 include/sound/ad1843.h             |   46 ++
 sound/mips/Kconfig                 |    6 +
 sound/mips/Makefile                |    2 +
 sound/mips/ad1843.c                |  539 +++++++++++++++++++
 sound/mips/sgio2audio.c            | 1013 ++++++++++++++++++++++++++++++++++++
 9 files changed, 1807 insertions(+), 0 deletions(-)
arch/mips/sgi-ip32/ip32-platform.c +36 -0
index 89a71f4..2ee401b 100644
@@ -65,6 +65,42 @@ static __init int meth_devinit(void)
 
 device_initcall(meth_devinit);
 
+static __init int sgio2audio_devinit(void)
+{
+	struct platform_device *pd;
+	int ret;
+
+	pd = platform_device_alloc("sgio2audio", -1);
+	if (!pd)
+		return -ENOMEM;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		platform_device_put(pd);
+
+	return ret;
+}
+
+device_initcall(sgio2audio_devinit);
+
+static __init int sgio2btns_devinit(void)
+{
+	struct platform_device *pd;
+	int ret;
+
+	pd = platform_device_alloc("sgio2btns", -1);
+	if (!pd)
+		return -ENOMEM;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		platform_device_put(pd);
+
+	return ret;
+}
+
+device_initcall(sgio2btns_devinit);
+
 MODULE_AUTHOR("Ralf Baechle <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2");
drivers/input/misc/Kconfig +10 -0
index 432699d..e33d7cb 100644
@@ -189,6 +189,16 @@ config INPUT_UINPUT
 	  To compile this driver as a module, choose M here: the
 	  module will be called uinput.
 
+config INPUT_SGIO2_BTNS
+	tristate "SGI O2 volume button interface"
+	depends on SGI_IP32
+	select INPUT_POLLDEV
+	help
+	  Say Y here if you want to support SGI O2 volume button interface.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called sgio_btns.
+
 config HP_SDC_RTC
 	tristate "HP SDC Real Time Clock"
 	depends on GSC || HP300
drivers/input/misc/Makefile +1 -0
index ebd39f2..0e274f1 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
+obj-$(CONFIG_INPUT_SGIO2_BTNS)		+= sgio2_btns.o
drivers/input/misc/sgio2_btns.c new file +154 -0

154 lines not on this page · raw message

include/sound/ad1843.h new file +46 -0

46 lines not on this page · raw message

sound/mips/Kconfig +6 -0
index 531f8ba..a3e202e 100644
@@ -11,5 +11,11 @@ config SND_AU1X00
 	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
index 47afed9..55624d8 100644
@@ -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 new file +539 -0

539 lines not on this page · raw message

sound/mips/sgio2audio.c new file +1013 -0

1,013 lines not on this page · raw message

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
#6 lore raw

Re: SGI O2 sound driver v6

drivers/input/misc/sgio2_btns.c line 2

Quoted 5 lines · Thomas Bogendoerfer
drivers/input/misc/sgio2_btns.c new file +2 -0
@@ -0,0 +1,154 @@
+/*
+ *  Cobalt button interface driver.

You should update that text.

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
author maintainer
#7 lore raw

Re: SGI O2 sound driver v6

Quoted 8 lines · Martin Michlmayr

drivers/input/misc/sgio2_btns.c line 2

Quoted 5 lines · Thomas Bogendoerfer
drivers/input/misc/sgio2_btns.c new file +2 -0
@@ -0,0 +1,154 @@
+/*
+ *  Cobalt button interface driver.

You should update that text.

of course. I noticed it, while preparing the patch for maintainer submission and fixed it. Thanks for noticing.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]