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 /* 43 * Echo midi 44 */ 45 46 typedef struct _midi_dev { 47 int32 count; 48 char name[64]; 49 sem_id midi_ready_sem; 50 ECHOGALS_MIDI_IN_CONTEXT context; 51 } midi_dev; 52 53 #define ECHO_USE_PLAY (1 << 0) 54 #define ECHO_USE_RECORD (1 << 1) 55 #define ECHO_STATE_STARTED (1 << 0) 56 57 /* 58 * Streams 59 */ 60 61 typedef struct _echo_stream { 62 struct _echo_dev *card; 63 uint8 use; 64 uint8 state; 65 uint8 bitsPerSample; 66 uint32 sample_rate; 67 uint8 channels; 68 uint32 bufframes; 69 uint8 bufcount; 70 71 WORD pipe; 72 PDWORD position; 73 74 LIST_ENTRY(_echo_stream) next; 75 76 void (*inth) (void *); 77 void *inthparam; 78 79 echo_mem *buffer; 80 uint16 blksize; /* in samples */ 81 uint16 trigblk; /* blk on which to trigger inth */ 82 uint16 blkmod; /* Modulo value to wrap trigblk */ 83 84 /* multi_audio */ 85 volatile int64 frames_count; // for play or record 86 volatile bigtime_t real_time; // for play or record 87 volatile int32 buffer_cycle; // for play or record 88 int32 first_channel; 89 bool update_needed; 90 } echo_stream; 91 92 93 typedef struct _echo_dev { 94 char name[DEVNAME]; /* used for resources */ 95 pci_info info; 96 97 uint32 bmbar; 98 void * log_bmbar; 99 area_id area_bmbar; 100 uint32 irq; 101 uint16 type; 102 103 PCEchoGals pEG; 104 ECHOGALS_CAPS caps; 105 NUINT mixer; 106 PCOsSupport pOSS; 107 108 void *ptb_log_base; 109 phys_addr_t ptb_phy_base; 110 area_id ptb_area; 111 112 sem_id buffer_ready_sem; 113 114 LIST_HEAD(, _echo_stream) streams; 115 LIST_HEAD(, _echo_mem) mems; 116 117 echo_stream *pstream; 118 echo_stream *rstream; 119 120 /* multi_audio */ 121 multi_dev multi; 122 #ifdef MIDI_SUPPORT 123 midi_dev midi; 124 #endif 125 #ifdef CARDBUS 126 bool plugged; // Device plugged 127 bool opened; // Device opened 128 int32 index; 129 LIST_ENTRY(_echo_dev) next; 130 #endif 131 } echo_dev; 132 133 extern int32 num_cards; 134 #ifdef CARDBUS 135 LIST_HEAD(_echodevs, _echo_dev); 136 extern struct _echodevs devices; 137 #else 138 extern echo_dev cards[NUM_CARDS]; 139 #endif 140 141 #ifdef __cplusplus 142 extern "C" { 143 #endif 144 145 status_t echo_stream_set_audioparms(echo_stream *stream, uint8 channels, 146 uint8 bitsPerSample, uint32 sample_ratei, uint8 index); 147 status_t echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf, 148 char** buffer, size_t *stride); 149 void echo_stream_start(echo_stream *stream, void (*inth) (void *), void *inthparam); 150 void echo_stream_halt(echo_stream *stream); 151 echo_stream *echo_stream_new(echo_dev *card, uint8 use, uint32 bufframes, uint8 bufcount); 152 void echo_stream_delete(echo_stream *stream); 153 154 #ifdef __cplusplus 155 } 156 #endif 157 158 159 #endif /* _ECHO_H_ */ 160