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 #include <PCI.h> 28 #include "OsSupportBeOS.h" 29 #include "CEchoGals.h" 30 #include "multi_audio.h" 31 #include "multi.h" 32 #include "queue.h" 33 34 #define AUTHOR "Jérôme Duval" 35 #define DEVNAME 32 36 #define NUM_CARDS 3 37 38 #define ECHO_USE_PLAY (1 << 0) 39 #define ECHO_USE_RECORD (1 << 1) 40 #define ECHO_STATE_STARTED (1 << 0) 41 42 43 typedef struct _echo_mem { 44 LIST_ENTRY(_echo_mem) next; 45 void *log_base; 46 void *phy_base; 47 area_id area; 48 size_t size; 49 } echo_mem; 50 51 /* 52 * Streams 53 */ 54 55 typedef struct _echo_stream { 56 struct _echo_dev *card; 57 uint8 use; 58 uint8 state; 59 uint8 bitsPerSample; 60 uint32 sample_rate; 61 uint8 channels; 62 uint32 bufframes; 63 uint8 bufcount; 64 65 WORD pipe; 66 PDWORD position; 67 68 LIST_ENTRY(_echo_stream) next; 69 70 void (*inth) (void *); 71 void *inthparam; 72 73 echo_mem *buffer; 74 uint16 blksize; /* in samples */ 75 uint16 trigblk; /* blk on which to trigger inth */ 76 uint16 blkmod; /* Modulo value to wrap trigblk */ 77 78 /* multi_audio */ 79 volatile int64 frames_count; // for play or record 80 volatile bigtime_t real_time; // for play or record 81 volatile int32 buffer_cycle; // for play or record 82 int32 first_channel; 83 bool update_needed; 84 } echo_stream; 85 86 87 typedef struct _echo_dev { 88 char name[DEVNAME]; /* used for resources */ 89 pci_info info; 90 91 uint32 bmbar; 92 void * log_bmbar; 93 area_id area_bmbar; 94 uint32 irq; 95 uint16 type; 96 97 PCEchoGals pEG; 98 PCOsSupport pOSS; 99 100 void *ptb_log_base; 101 void *ptb_phy_base; 102 area_id ptb_area; 103 104 sem_id buffer_ready_sem; 105 106 LIST_HEAD(, _echo_stream) streams; 107 LIST_HEAD(, _echo_mem) mems; 108 109 echo_stream *pstream; 110 echo_stream *rstream; 111 112 /* multi_audio */ 113 multi_dev multi; 114 } echo_dev; 115 116 extern int32 num_cards; 117 extern echo_dev cards[NUM_CARDS]; 118 119 #ifdef __cplusplus 120 extern "C" { 121 #endif 122 123 status_t echo_stream_set_audioparms(echo_stream *stream, uint8 channels, 124 uint8 bitsPerSample, uint32 sample_rate); 125 status_t echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf, 126 char** buffer, size_t *stride); 127 void echo_stream_start(echo_stream *stream, void (*inth) (void *), void *inthparam); 128 void echo_stream_halt(echo_stream *stream); 129 echo_stream *echo_stream_new(echo_dev *card, uint8 use, uint32 bufframes, uint8 bufcount); 130 void echo_stream_delete(echo_stream *stream); 131 132 #ifdef __cplusplus 133 } 134 #endif 135 136 137 #endif /* _ECHO_H_ */ 138