1 /* $OpenBSD: envyvar.h,v 1.19 2015/08/30 08:52:26 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 unsigned int swpos; 35 unsigned int bufsz; 36 unsigned int blksz; 37 }; 38 39 struct envy_codec { 40 char *name; 41 int (*ndev)(struct envy_softc *); 42 void (*devinfo)(struct envy_softc *, struct mixer_devinfo *, int); 43 void (*get)(struct envy_softc *, struct mixer_ctrl *, int); 44 int (*set)(struct envy_softc *, struct mixer_ctrl *, int); 45 }; 46 47 struct envy_card { 48 int subid; 49 char *name; 50 int nich; 51 struct envy_codec *adc; 52 int noch; 53 struct envy_codec *dac; 54 int nmidi; 55 void (*init)(struct envy_softc *); 56 void (*codec_write)(struct envy_softc *, int, int, int); 57 unsigned char *eeprom; 58 }; 59 60 struct envy_softc { 61 struct device dev; 62 struct device *audio; 63 int isht; /* is a Envy24HT ? */ 64 int isac97; /* is a Envy24HT AC97 ? */ 65 struct envy_buf ibuf, obuf; 66 pcitag_t pci_tag; 67 pci_chipset_tag_t pci_pc; 68 pci_intr_handle_t *pci_ih; 69 bus_dma_tag_t pci_dmat; 70 bus_space_tag_t ccs_iot; 71 bus_space_handle_t ccs_ioh; 72 bus_size_t ccs_iosz; 73 bus_space_tag_t mt_iot; 74 bus_space_handle_t mt_ioh; 75 bus_size_t mt_iosz; 76 int iactive; /* trigger_input called */ 77 int oactive; /* trigger_output called */ 78 int ibusy; /* input DMA started */ 79 int obusy; /* output DMA started */ 80 #ifdef ENVY_DEBUG 81 unsigned spurious; 82 struct timespec start_ts; 83 #define ENVY_NINTR 16 84 unsigned nintr; 85 struct envy_intr { 86 int ipos, opos, st, mask, ctl, iactive, oactive; 87 struct timespec ts; 88 } intrs[ENVY_NINTR]; 89 #endif 90 struct envy_card *card; 91 unsigned char shadow[4][16]; 92 #define ENVY_EEPROM_MAXSZ 32 93 unsigned char eeprom[ENVY_EEPROM_MAXSZ]; 94 struct ac97_codec_if *codec_if; 95 struct ac97_host_if host_if; 96 enum ac97_host_flags codec_flags; 97 void (*iintr)(void *); 98 void *iarg; 99 void (*ointr)(void *); 100 void *oarg; 101 #if NMIDI > 0 102 void (*midi_in)(void *, int); 103 void (*midi_out)(void *); 104 void *midi_arg; 105 struct device *midi; 106 int midi_isopen; 107 #endif 108 }; 109 110 #define ENVY_MIX_CLASSIN 0 111 #define ENVY_MIX_CLASSOUT 1 112 #define ENVY_MIX_CLASSMON 2 113 114 #define ENVY_MIX_NCLASS 3 115 #define ENVY_MIX_NOUTSRC 10 116 #define ENVY_MIX_NMONITOR 20 117 118 #define ENVY_MIX_OUTSRC_LINEIN 0 119 #define ENVY_MIX_OUTSRC_SPDIN 8 120 #define ENVY_MIX_OUTSRC_DMA 10 121 #define ENVY_MIX_OUTSRC_MON 11 122 123 #endif /* !defined(SYS_DEV_PCI_ENVYVAR_H) */ 124