1 /* 2 * ES1370 Haiku Driver for ES1370 audio 3 * 4 * Copyright 2003-2007, Haiku, Inc. 5 * Distributed under the terms of the MIT License. 6 * 7 * Authors: 8 * Jerome Duval, jerome.duval@free.fr 9 */ 10 11 #ifndef _DEV_PCI_ES1370_H_ 12 #define _DEV_PCI_ES1370_H_ 13 14 #include <Drivers.h> 15 #include <SupportDefs.h> 16 #include <OS.h> 17 #include <PCI.h> 18 #include "es1370reg.h" 19 #include "config.h" 20 #include "queue.h" 21 #include "hmulti_audio.h" 22 #include "multi.h" 23 24 25 #define VERSION "Version alpha 1, Copyright (c) 2007 Jérôme Duval, compiled on " __DATE__ " " __TIME__ 26 #define DRIVER_NAME "es1370" 27 #define FRIENDLY_NAME "ES1370" 28 #define AUTHOR "Jérôme Duval" 29 30 #define FRIENDLY_NAME_ES1370 "ES1370" 31 32 #define ES1370_USE_PLAY (1 << 0) 33 #define ES1370_USE_RECORD (1 << 1) 34 #define ES1370_STATE_STARTED (1 << 0) 35 36 /* 37 * es1370 memory managment 38 */ 39 40 typedef struct _es1370_mem { 41 LIST_ENTRY(_es1370_mem) next; 42 void *log_base; 43 void *phy_base; 44 area_id area; 45 size_t size; 46 } es1370_mem; 47 48 /* 49 * Streams 50 */ 51 52 typedef struct _es1370_stream { 53 struct _es1370_dev *card; 54 uint8 use; 55 uint8 state; 56 uint8 b16; 57 uint32 sample_rate; 58 uint8 channels; 59 uint32 bufframes; 60 uint8 bufcount; 61 62 uint32 base; 63 64 LIST_ENTRY(_es1370_stream) next; 65 66 void (*inth) (void *); 67 void *inthparam; 68 69 void *dmaops_log_base; 70 void *dmaops_phy_base; 71 area_id dmaops_area; 72 73 es1370_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 } es1370_stream; 85 86 /* 87 * Devices 88 */ 89 90 typedef struct _es1370_dev { 91 char name[DEVNAME]; /* used for resources */ 92 pci_info info; 93 device_config config; 94 95 void *ptb_log_base; 96 void *ptb_phy_base; 97 area_id ptb_area; 98 99 sem_id buffer_ready_sem; 100 101 uint32 interrupt_mask; 102 103 LIST_HEAD(, _es1370_stream) streams; 104 105 LIST_HEAD(, _es1370_mem) mems; 106 107 es1370_stream *pstream; 108 es1370_stream *rstream; 109 110 /* multi_audio */ 111 multi_dev multi; 112 } es1370_dev; 113 114 #define ES1370_SETTINGS "es1370.settings" 115 116 typedef struct { 117 uint32 sample_rate; 118 uint32 buffer_frames; 119 int32 buffer_count; 120 } es1370_settings; 121 122 extern es1370_settings current_settings; 123 124 extern int32 num_cards; 125 extern es1370_dev cards[NUM_CARDS]; 126 127 status_t es1370_stream_set_audioparms(es1370_stream *stream, uint8 channels, 128 uint8 b16, uint32 sample_rate); 129 status_t es1370_stream_commit_parms(es1370_stream *stream); 130 status_t es1370_stream_get_nth_buffer(es1370_stream *stream, uint8 chan, uint8 buf, 131 char** buffer, size_t *stride); 132 void es1370_stream_start(es1370_stream *stream, void (*inth) (void *), void *inthparam); 133 void es1370_stream_halt(es1370_stream *stream); 134 es1370_stream *es1370_stream_new(es1370_dev *card, uint8 use, uint32 bufframes, uint8 bufcount); 135 void es1370_stream_delete(es1370_stream *stream); 136 137 #endif /* _DEV_PCI_ES1370_H_ */ 138