vsvar.h revision 1.18
1/*	$NetBSD: vsvar.h,v 1.18 2021/02/06 09:27:35 isaki Exp $	*/
2
3/*
4 * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28/*
29 * OKI MSM6258V ADPCM voice synthesizer device driver.
30 */
31
32#define VS_ADDR		(0xe92000)
33#define VS_DMA		(3)
34#define VS_DMAINTR	(0x6a)
35
36/* XXX: PPI should be defined elsewhere */
37#define PPI_ADDR		(0x00e9a000)
38#define PPI_MAPSIZE		(0x00002000)
39#define PPI_PORTA		0
40#define PPI_PORTB		1
41#define PPI_PORTC		2
42#define PPI_CTRL		3
43
44#define VS_RATE_15K	(15625)
45#define VS_RATE_10K	(10417)
46#define VS_RATE_7K	 (7813)
47#define VS_RATE_5K	 (5208)
48#define VS_RATE_3K	 (3906)
49
50#define VS_SRATE_1024	(0x00)
51#define VS_SRATE_768	(0x04)
52#define VS_SRATE_512	(0x08)
53
54#define VS_PANOUT_LR	(0x00)
55#define VS_PANOUT_R	(0x01)
56#define VS_PANOUT_L	(0x02)
57#define VS_PANOUT_OFF	(0x03)
58
59#define VS_MAX_BUFSIZE	(65536*4) /* XXX: enough? */
60
61/* XXX: msm6258vreg.h */
62#define MSM6258_CMD 	0		/* W */
63#define MSM6258_CMD_STOP	(0x01)
64#define MSM6258_CMD_PLAY_START	(0x02)
65#define MSM6258_CMD_REC_START	(0x04)
66#define MSM6258_STAT	0		/* R */
67#define MSM6258_DATA	1		/* R/W */
68
69struct vs_dma {
70	bus_dma_tag_t		vd_dmat;
71	bus_dmamap_t		vd_map;
72	void *			vd_addr;
73	bus_dma_segment_t	vd_segs[1];
74	int			vd_nsegs;
75	size_t			vd_size;
76	struct vs_dma		*vd_next;
77};
78#define KVADDR(dma)	((void *)(dma)->vd_addr)
79#define KVADDR_END(dma) ((void *)((size_t)KVADDR(dma) + (dma)->vd_size)))
80#define DMAADDR(dma)	((dma)->vd_map->dm_segs[0].ds_addr)
81
82struct vs_softc {
83	device_t sc_dev;
84	kmutex_t sc_lock;
85	kmutex_t sc_intr_lock;
86
87	bus_space_tag_t sc_iot;
88	bus_space_handle_t sc_ioh;
89	bus_space_handle_t sc_ppi; /* XXX */
90	uint8_t *sc_addr;
91
92	bus_dma_tag_t sc_dmat;
93	struct dmac_channel_stat *sc_dma_ch;
94	struct vs_dma *sc_dmas;
95	struct vs_dma *sc_prev_vd;
96
97	struct {
98		struct dmac_dma_xfer *xfer;
99		int rate;
100	} sc_current;
101
102	const struct audio_hw_if *sc_hw_if;
103
104	void (*sc_pintr)(void *);
105	void (*sc_rintr)(void *);
106	void *sc_parg;
107	void *sc_rarg;
108
109	struct msm6258_codecvar sc_codecvar;
110};
111