blob: 1d636a2d8896e30e9c1f801bbe6ee1c435cbc703 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __SOUND_ES1688_H
2#define __SOUND_ES1688_H
3
4/*
5 * Header file for ES488/ES1688
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02006 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
David Howellsa1ce3922012-10-02 18:01:25 +010025#include <sound/control.h>
26#include <sound/pcm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/interrupt.h>
28
29#define ES1688_HW_AUTO 0x0000
30#define ES1688_HW_688 0x0001
31#define ES1688_HW_1688 0x0002
Fengguang Wue5b35422012-07-29 19:39:09 +080032#define ES1688_HW_UNDEF 0x0003
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Takashi Iwaid3a7e472005-11-17 14:31:42 +010034struct snd_es1688 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 unsigned long port; /* port of ESS chip */
36 struct resource *res_port;
37 unsigned long mpu_port; /* MPU-401 port of ESS chip */
38 int irq; /* IRQ number of ESS chip */
39 int mpu_irq; /* MPU IRQ */
40 int dma8; /* 8-bit DMA */
41 unsigned short version; /* version of ESS chip */
42 unsigned short hardware; /* see to ES1688_HW_XXXX */
43
44 unsigned short trigger_value;
45 unsigned char pad;
46 unsigned int dma_size;
47
Takashi Iwaid3a7e472005-11-17 14:31:42 +010048 struct snd_pcm *pcm;
49 struct snd_pcm_substream *playback_substream;
50 struct snd_pcm_substream *capture_substream;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52 spinlock_t reg_lock;
53 spinlock_t mixer_lock;
54};
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056/* I/O ports */
57
58#define ES1688P(codec, x) ((codec)->port + e_s_s_ESS1688##x)
59
60#define e_s_s_ESS1688RESET 0x6
61#define e_s_s_ESS1688READ 0xa
62#define e_s_s_ESS1688WRITE 0xc
63#define e_s_s_ESS1688COMMAND 0xc
64#define e_s_s_ESS1688STATUS 0xc
65#define e_s_s_ESS1688DATA_AVAIL 0xe
66#define e_s_s_ESS1688DATA_AVAIL_16 0xf
67#define e_s_s_ESS1688MIXER_ADDR 0x4
68#define e_s_s_ESS1688MIXER_DATA 0x5
69#define e_s_s_ESS1688OPL3_LEFT 0x0
70#define e_s_s_ESS1688OPL3_RIGHT 0x2
71#define e_s_s_ESS1688OPL3_BOTH 0x8
72#define e_s_s_ESS1688ENABLE0 0x0
73#define e_s_s_ESS1688ENABLE1 0x9
74#define e_s_s_ESS1688ENABLE2 0xb
75#define e_s_s_ESS1688INIT1 0x7
76
77#define ES1688_DSP_CMD_DMAOFF 0xd0
78#define ES1688_DSP_CMD_SPKON 0xd1
79#define ES1688_DSP_CMD_SPKOFF 0xd3
80#define ES1688_DSP_CMD_DMAON 0xd4
81
82#define ES1688_PCM_DEV 0x14
83#define ES1688_MIC_DEV 0x1a
84#define ES1688_REC_DEV 0x1c
85#define ES1688_MASTER_DEV 0x32
86#define ES1688_FM_DEV 0x36
87#define ES1688_CD_DEV 0x38
88#define ES1688_AUX_DEV 0x3a
89#define ES1688_SPEAKER_DEV 0x3c
90#define ES1688_LINE_DEV 0x3e
91#define ES1688_RECLEV_DEV 0xb4
92
93#define ES1688_MIXS_MASK 0x17
94#define ES1688_MIXS_MIC 0x00
95#define ES1688_MIXS_MIC_MASTER 0x01
96#define ES1688_MIXS_CD 0x02
97#define ES1688_MIXS_AOUT 0x03
98#define ES1688_MIXS_MIC1 0x04
99#define ES1688_MIXS_REC_MIX 0x05
100#define ES1688_MIXS_LINE 0x06
101#define ES1688_MIXS_MASTER 0x07
102#define ES1688_MIXS_MUTE 0x10
103
104/*
105
106 */
107
Takashi Iwaid3a7e472005-11-17 14:31:42 +0100108void snd_es1688_mixer_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Takashi Iwaid3a7e472005-11-17 14:31:42 +0100110int snd_es1688_create(struct snd_card *card,
Krzysztof Helt396fa822010-05-09 20:35:44 +0200111 struct snd_es1688 *chip,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 unsigned long port,
113 unsigned long mpu_port,
114 int irq,
115 int mpu_irq,
116 int dma8,
Krzysztof Helt396fa822010-05-09 20:35:44 +0200117 unsigned short hardware);
118int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device,
119 struct snd_pcm **rpcm);
120int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip);
Krzysztof Helta20971b2010-05-10 09:47:32 +0200121int snd_es1688_reset(struct snd_es1688 *chip);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123#endif /* __SOUND_ES1688_H */