Skip to content

Commit

Permalink
ALSA: sh: add SuperH DAC audio driver for ALSA V4
Browse files Browse the repository at this point in the history
This is a port of the sound/oss/sh_dac_audio.c driver.
The driver uses an on-chip 8-bit D/A converter, which has a speaker connected
to one of its channels, found in several ancient HP machines.
For interrupts it uses a high-resolution timer (hrtimer).
Tested on SH7709 based hp6xx (HP Jornada 680/690 and HP Palmtop 620lx/660lx).

Also, since OSS Emulation works, the old OSS sound/oss/sh_dac_audio.c driver
would be obsolete soon, and it could be removed.

Signed-off-by: Rafael Ignacio Zurita <[email protected]>
Acked-by: Paul Mundt <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Rafael Ignacio Zurita authored and tiwai committed Nov 4, 2009
1 parent bcc2c6b commit 9dcaa7b
Show file tree
Hide file tree
Showing 6 changed files with 543 additions and 0 deletions.
55 changes: 55 additions & 0 deletions arch/sh/boards/mach-hp6xx/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/irq.h>
#include <sound/sh_dac_audio.h>
#include <asm/hd64461.h>
#include <asm/io.h>
#include <mach/hp6xx.h>
Expand Down Expand Up @@ -51,9 +52,63 @@ static struct platform_device jornadakbd_device = {
.id = -1,
};

static void dac_audio_start(struct dac_audio_pdata *pdata)
{
u16 v;
u8 v8;

/* HP Jornada 680/690 speaker on */
v = inw(HD64461_GPADR);
v &= ~HD64461_GPADR_SPEAKER;
outw(v, HD64461_GPADR);

/* HP Palmtop 620lx/660lx speaker on */
v8 = inb(PKDR);
v8 &= ~PKDR_SPEAKER;
outb(v8, PKDR);

sh_dac_enable(pdata->channel);
}

static void dac_audio_stop(struct dac_audio_pdata *pdata)
{
u16 v;
u8 v8;

/* HP Jornada 680/690 speaker off */
v = inw(HD64461_GPADR);
v |= HD64461_GPADR_SPEAKER;
outw(v, HD64461_GPADR);

/* HP Palmtop 620lx/660lx speaker off */
v8 = inb(PKDR);
v8 |= PKDR_SPEAKER;
outb(v8, PKDR);

sh_dac_output(0, pdata->channel);
sh_dac_disable(pdata->channel);
}

static struct dac_audio_pdata dac_audio_platform_data = {
.buffer_size = 64000,
.channel = 1,
.start = dac_audio_start,
.stop = dac_audio_stop,
};

static struct platform_device dac_audio_device = {
.name = "dac_audio",
.id = -1,
.dev = {
.platform_data = &dac_audio_platform_data,
}

};

static struct platform_device *hp6xx_devices[] __initdata = {
&cf_ide_device,
&jornadakbd_device,
&dac_audio_device,
};

static void __init hp6xx_init_irq(void)
Expand Down
4 changes: 4 additions & 0 deletions arch/sh/include/mach-common/mach/hp6xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

#define PKDR_LED_GREEN 0x10

/* HP Palmtop 620lx/660lx speaker on/off */
#define PKDR_SPEAKER 0x20

#define SCPDR_TS_SCAN_ENABLE 0x20
#define SCPDR_TS_SCAN_Y 0x02
#define SCPDR_TS_SCAN_X 0x01
Expand All @@ -42,6 +45,7 @@
#define ADC_CHANNEL_BACKUP 4
#define ADC_CHANNEL_CHARGE 5

/* HP Jornada 680/690 speaker on/off */
#define HD64461_GPADR_SPEAKER 0x01
#define HD64461_GPADR_PCMCIA0 (0x02|0x08)

Expand Down
21 changes: 21 additions & 0 deletions include/sound/sh_dac_audio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* SH_DAC specific configuration, for the dac_audio platform_device
*
* Copyright (C) 2009 Rafael Ignacio Zurita <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/

#ifndef __INCLUDE_SH_DAC_AUDIO_H
#define __INCLUDE_SH_DAC_AUDIO_H

struct dac_audio_pdata {
int buffer_size;
int channel;
void (*start)(struct dac_audio_pdata *pd);
void (*stop)(struct dac_audio_pdata *pd);
};

#endif /* __INCLUDE_SH_DAC_AUDIO_H */
8 changes: 8 additions & 0 deletions sound/sh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ config SND_AICA
help
ALSA Sound driver for the SEGA Dreamcast console.

config SND_SH_DAC_AUDIO
tristate "SuperH DAC audio support"
depends on SND
depends on CPU_SH3 && HIGH_RES_TIMERS
select SND_PCM
help
Say Y here to include support for the on-chip DAC.

endif # SND_SUPERH

2 changes: 2 additions & 0 deletions sound/sh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#

snd-aica-objs := aica.o
snd-sh_dac_audio-objs := sh_dac_audio.o

# Toplevel Module Dependency
obj-$(CONFIG_SND_AICA) += snd-aica.o
obj-$(CONFIG_SND_SH_DAC_AUDIO) += snd-sh_dac_audio.o
Loading

0 comments on commit 9dcaa7b

Please sign in to comment.