blob: 099569c31fbb3b84ab8f483f22eb393d40d9b5b6 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __SOUND_ES1688_H
3#define __SOUND_ES1688_H
4
5/*
6 * Header file for ES488/ES1688
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02007 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
David Howellsa1ce3922012-10-02 18:01:25 +010010#include <sound/control.h>
11#include <sound/pcm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/interrupt.h>
13
14#define ES1688_HW_AUTO 0x0000
15#define ES1688_HW_688 0x0001
16#define ES1688_HW_1688 0x0002
Fengguang Wue5b35422012-07-29 19:39:09 +080017#define ES1688_HW_UNDEF 0x0003
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Takashi Iwaid3a7e472005-11-17 14:31:42 +010019struct snd_es1688 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 unsigned long port; /* port of ESS chip */
21 struct resource *res_port;
22 unsigned long mpu_port; /* MPU-401 port of ESS chip */
23 int irq; /* IRQ number of ESS chip */
24 int mpu_irq; /* MPU IRQ */
25 int dma8; /* 8-bit DMA */
26 unsigned short version; /* version of ESS chip */
27 unsigned short hardware; /* see to ES1688_HW_XXXX */
28
29 unsigned short trigger_value;
30 unsigned char pad;
31 unsigned int dma_size;
32
Takashi Iwaid3a7e472005-11-17 14:31:42 +010033 struct snd_pcm *pcm;
34 struct snd_pcm_substream *playback_substream;
35 struct snd_pcm_substream *capture_substream;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37 spinlock_t reg_lock;
38 spinlock_t mixer_lock;
39};
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/* I/O ports */
42
43#define ES1688P(codec, x) ((codec)->port + e_s_s_ESS1688##x)
44
45#define e_s_s_ESS1688RESET 0x6
46#define e_s_s_ESS1688READ 0xa
47#define e_s_s_ESS1688WRITE 0xc
48#define e_s_s_ESS1688COMMAND 0xc
49#define e_s_s_ESS1688STATUS 0xc
50#define e_s_s_ESS1688DATA_AVAIL 0xe
51#define e_s_s_ESS1688DATA_AVAIL_16 0xf
52#define e_s_s_ESS1688MIXER_ADDR 0x4
53#define e_s_s_ESS1688MIXER_DATA 0x5
54#define e_s_s_ESS1688OPL3_LEFT 0x0
55#define e_s_s_ESS1688OPL3_RIGHT 0x2
56#define e_s_s_ESS1688OPL3_BOTH 0x8
57#define e_s_s_ESS1688ENABLE0 0x0
58#define e_s_s_ESS1688ENABLE1 0x9
59#define e_s_s_ESS1688ENABLE2 0xb
60#define e_s_s_ESS1688INIT1 0x7
61
62#define ES1688_DSP_CMD_DMAOFF 0xd0
63#define ES1688_DSP_CMD_SPKON 0xd1
64#define ES1688_DSP_CMD_SPKOFF 0xd3
65#define ES1688_DSP_CMD_DMAON 0xd4
66
67#define ES1688_PCM_DEV 0x14
68#define ES1688_MIC_DEV 0x1a
69#define ES1688_REC_DEV 0x1c
70#define ES1688_MASTER_DEV 0x32
71#define ES1688_FM_DEV 0x36
72#define ES1688_CD_DEV 0x38
73#define ES1688_AUX_DEV 0x3a
74#define ES1688_SPEAKER_DEV 0x3c
75#define ES1688_LINE_DEV 0x3e
76#define ES1688_RECLEV_DEV 0xb4
77
78#define ES1688_MIXS_MASK 0x17
79#define ES1688_MIXS_MIC 0x00
80#define ES1688_MIXS_MIC_MASTER 0x01
81#define ES1688_MIXS_CD 0x02
82#define ES1688_MIXS_AOUT 0x03
83#define ES1688_MIXS_MIC1 0x04
84#define ES1688_MIXS_REC_MIX 0x05
85#define ES1688_MIXS_LINE 0x06
86#define ES1688_MIXS_MASTER 0x07
87#define ES1688_MIXS_MUTE 0x10
88
89/*
90
91 */
92
Takashi Iwaid3a7e472005-11-17 14:31:42 +010093void snd_es1688_mixer_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Takashi Iwaid3a7e472005-11-17 14:31:42 +010095int snd_es1688_create(struct snd_card *card,
Krzysztof Helt396fa822010-05-09 20:35:44 +020096 struct snd_es1688 *chip,
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 unsigned long port,
98 unsigned long mpu_port,
99 int irq,
100 int mpu_irq,
101 int dma8,
Krzysztof Helt396fa822010-05-09 20:35:44 +0200102 unsigned short hardware);
Lars-Peter Clausen4b8ab882015-01-02 12:24:37 +0100103int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device);
Krzysztof Helt396fa822010-05-09 20:35:44 +0200104int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip);
Krzysztof Helta20971b2010-05-10 09:47:32 +0200105int snd_es1688_reset(struct snd_es1688 *chip);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107#endif /* __SOUND_ES1688_H */