1 //------------------------------------------------------------------------------ 2 // EchoGals/Echo24 BeOS Driver for Echo audio cards 3 // 4 // Copyright (c) 2003, Jérôme Duval 5 // 6 // Permission is hereby granted, free of charge, to any person obtaining a 7 // copy of this software and associated documentation files (the "Software"), 8 // to deal in the Software without restriction, including without limitation 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 // and/or sell copies of the Software, and to permit persons to whom the 11 // Software is furnished to do so, subject to the following conditions: 12 // 13 // The above copyright notice and this permission notice shall be included in 14 // all copies or substantial portions of the Software. 15 // 16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 // DEALINGS IN THE SOFTWARE. 23 24 #ifndef _ECHO_H_ 25 #define _ECHO_H_ 26 27 #ifdef CARDBUS 28 #include <pcmcia/cb_enabler.h> 29 #else 30 #include <PCI.h> 31 #endif 32 #include "OsSupportBeOS.h" 33 #include "CEchoGals.h" 34 #include "hmulti_audio.h" 35 #include "multi.h" 36 #include "queue.h" 37 38 #define AUTHOR "Jérôme Duval" 39 #define DEVNAME 32 40 #define NUM_CARDS 3 41 42 typedef struct { 43 uint8 channels; 44 uint8 bitsPerSample; 45 uint32 sample_rate; 46 uint32 buffer_frames; 47 int32 buffer_count; 48 } echo_settings; 49 50 extern echo_settings current_settings; 51 52 /* 53 * Echo midi 54 */ 55 56 typedef struct _midi_dev { 57 int32 count; 58 char name[64]; 59 sem_id midi_ready_sem; 60 ECHOGALS_MIDI_IN_CONTEXT context; 61 } midi_dev; 62 63 #define ECHO_USE_PLAY (1 << 0) 64 #define ECHO_USE_RECORD (1 << 1) 65 #define ECHO_STATE_STARTED (1 << 0) 66 67 /* 68 * Streams 69 */ 70 71 typedef struct _echo_stream { 72 struct _echo_dev *card; 73 uint8 use; 74 uint8 state; 75 uint8 bitsPerSample; 76 uint32 sample_rate; 77 uint8 channels; 78 uint32 bufframes; 79 uint8 bufcount; 80 81 WORD pipe; 82 PDWORD position; 83 84 LIST_ENTRY(_echo_stream) next; 85 86 void (*inth) (void *); 87 void *inthparam; 88 89 echo_mem *buffer; 90 uint16 blksize; /* in samples */ 91 uint16 trigblk; /* blk on which to trigger inth */ 92 uint16 blkmod; /* Modulo value to wrap trigblk */ 93 94 /* multi_audio */ 95 volatile int64 frames_count; // for play or record 96 volatile bigtime_t real_time; // for play or record 97 volatile int32 buffer_cycle; // for play or record 98 int32 first_channel; 99 bool update_needed; 100 } echo_stream; 101 102 103 typedef struct _echo_dev { 104 char name[DEVNAME]; /* used for resources */ 105 pci_info info; 106 107 uint32 bmbar; 108 void * log_bmbar; 109 area_id area_bmbar; 110 uint32 irq; 111 uint16 type; 112 113 PCEchoGals pEG; 114 ECHOGALS_CAPS caps; 115 NUINT mixer; 116 PCOsSupport pOSS; 117 118 void *ptb_log_base; 119 void *ptb_phy_base; 120 area_id ptb_area; 121 122 sem_id buffer_ready_sem; 123 124 LIST_HEAD(, _echo_stream) streams; 125 LIST_HEAD(, _echo_mem) mems; 126 127 echo_stream *pstream; 128 echo_stream *rstream; 129 130 /* multi_audio */ 131 multi_dev multi; 132 #ifdef MIDI_SUPPORT 133 midi_dev midi; 134 #endif 135 #ifdef CARDBUS 136 bool plugged; // Device plugged 137 bool opened; // Device opened 138 int32 index; 139 LIST_ENTRY(_echo_dev) next; 140 #endif 141 } echo_dev; 142 143 extern int32 num_cards; 144 #ifdef CARDBUS 145 LIST_HEAD(_echodevs, _echo_dev); 146 extern struct _echodevs devices; 147 #else 148 extern echo_dev cards[NUM_CARDS]; 149 #endif 150 151 #ifdef __cplusplus 152 extern "C" { 153 #endif 154 155 status_t echo_stream_set_audioparms(echo_stream *stream, uint8 channels, 156 uint8 bitsPerSample, uint32 sample_ratei, uint8 index); 157 status_t echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf, 158 char** buffer, size_t *stride); 159 void echo_stream_start(echo_stream *stream, void (*inth) (void *), void *inthparam); 160 void echo_stream_halt(echo_stream *stream); 161 echo_stream *echo_stream_new(echo_dev *card, uint8 use, uint32 bufframes, uint8 bufcount); 162 void echo_stream_delete(echo_stream *stream); 163 164 #ifdef __cplusplus 165 } 166 #endif 167 168 169 #endif /* _ECHO_H_ */ 170