xref: /openbsd/sys/dev/pci/envyvar.h (revision cca36db2)
1 /*	$OpenBSD: envyvar.h,v 1.16 2010/10/04 09:32:43 ratchov Exp $	*/
2 /*
3  * Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef SYS_DEV_PCI_ENVYVAR_H
19 #define SYS_DEV_PCI_ENVYVAR_H
20 
21 #include <sys/types.h>
22 #include <sys/device.h>
23 #include <sys/time.h>
24 #include <dev/audio_if.h>
25 #include <dev/midi_if.h>
26 
27 struct envy_softc;
28 
29 struct envy_buf {
30 	bus_dma_segment_t	seg;
31 	bus_dmamap_t		map;
32 	caddr_t			addr;
33 	size_t			size;
34 };
35 
36 struct envy_codec {
37 	char *name;
38 	int (*ndev)(struct envy_softc *);
39 	void (*devinfo)(struct envy_softc *, struct mixer_devinfo *, int);
40 	void (*get)(struct envy_softc *, struct mixer_ctrl *, int);
41 	int (*set)(struct envy_softc *, struct mixer_ctrl *, int);
42 };
43 
44 struct envy_card {
45 	int subid;
46 	char *name;
47 	int nich;
48 	struct envy_codec *adc;
49 	int noch;
50 	struct envy_codec *dac;
51 	void (*init)(struct envy_softc *);
52 	void (*codec_write)(struct envy_softc *, int, int, int);
53 	unsigned char *eeprom;
54 };
55 
56 struct envy_softc {
57 	struct device		dev;
58 	struct device	       *audio;
59 	int			isht;		/* is a Envy24HT ? */
60 	int			isac97;		/* is a Envy24HT AC97 ? */
61 	struct envy_buf		ibuf, obuf;
62 	pcitag_t		pci_tag;
63 	pci_chipset_tag_t	pci_pc;
64 	pci_intr_handle_t      *pci_ih;
65 	bus_dma_tag_t		pci_dmat;
66 	bus_space_tag_t		ccs_iot;
67 	bus_space_handle_t	ccs_ioh;
68 	bus_size_t		ccs_iosz;
69 	bus_space_tag_t		mt_iot;
70 	bus_space_handle_t	mt_ioh;
71 	bus_size_t		mt_iosz;
72 	int			iactive;	/* trigger_input called */
73 	int			oactive;	/* trigger_output called */
74 	int			ibusy;		/* input DMA started */
75 	int			obusy;		/* output DMA started */
76 #ifdef ENVY_DEBUG
77 	unsigned 		spurious;
78 	struct timespec		start_ts;
79 #define ENVY_NINTR		16
80 	unsigned 		nintr;
81 	struct envy_intr {
82 		int ipos, opos, st, mask, ctl, iactive, oactive;
83 		struct timespec ts;
84 	} intrs[ENVY_NINTR];
85 #endif
86 	struct envy_card       *card;
87 	unsigned char 		shadow[4][16];
88 #define ENVY_EEPROM_MAXSZ 32
89 	unsigned char		eeprom[ENVY_EEPROM_MAXSZ];
90 	struct ac97_codec_if   *codec_if;
91 	struct ac97_host_if	host_if;
92 	enum ac97_host_flags	codec_flags;
93 	void (*iintr)(void *);
94 	void *iarg;
95 	void (*ointr)(void *);
96 	void *oarg;
97 #if NMIDI > 0
98 	void (*midi_in)(void *, int);
99 	void (*midi_out)(void *);
100 	void *midi_arg;
101 	struct device *midi;
102 #endif
103 };
104 
105 #define ENVY_MIX_CLASSIN	0
106 #define ENVY_MIX_CLASSOUT	1
107 #define ENVY_MIX_CLASSMON	2
108 
109 #define ENVY_MIX_NCLASS		3
110 #define ENVY_MIX_NOUTSRC	10
111 #define ENVY_MIX_NMONITOR	20
112 
113 #define ENVY_MIX_OUTSRC_LINEIN	0
114 #define ENVY_MIX_OUTSRC_SPDIN	8
115 #define ENVY_MIX_OUTSRC_DMA	10
116 #define ENVY_MIX_OUTSRC_MON	11
117 
118 #endif /* !defined(SYS_DEV_PCI_ENVYVAR_H) */
119