xref: /haiku/src/add-ons/kernel/drivers/audio/sb16/driver.h (revision 2897df967633aab846ff4917b53e2af7d1e54eeb)
1 #ifndef DRIVER_H
2 #define DRIVER_H
3 
4 #include <drivers/driver_settings.h>
5 #include <drivers/KernelExport.h>
6 #include <drivers/Drivers.h>
7 
8 #include <string.h>
9 #include <stdlib.h>
10 
11 #define DEVFS_PATH	"audio/hmulti"
12 #include <hmulti_audio.h>
13 
14 
15 #define STRMINBUF		2
16 #define STRMAXBUF		2
17 #define DEFAULT_FRAMESPERBUF	512
18 
19 #define SB16_MULTI_CONTROL_FIRSTID       1024
20 #define SB16_MULTI_CONTROL_MASTERID      0
21 
22 typedef struct {
23 	int		running;
24 	spinlock	lock;
25 	int bits;
26 
27 	void*		buffers[STRMAXBUF];
28 	uint32		num_buffers;
29 	uint32		num_channels;
30 	uint32		sample_size;
31 	uint32		sampleformat;
32 	uint32		samplerate;
33 	uint32		buffer_length;
34 	sem_id		buffer_ready_sem;
35 	uint32		frames_count;
36 	uint32		buffer_cycle;
37 	bigtime_t	real_time;
38 } sb16_stream_t;
39 
40 typedef struct {
41 	int port, irq, dma8, dma16, midiport;
42 	int opened;
43 
44 	sb16_stream_t playback_stream;
45 	sb16_stream_t record_stream;
46 } sb16_dev_t;
47 
48 extern device_hooks driver_hooks;
49 
50 status_t sb16_hw_init(sb16_dev_t* dev);
51 void sb16_hw_stop(sb16_dev_t* dev);
52 void sb16_hw_uninit(sb16_dev_t* dev);
53 
54 status_t sb16_stream_setup_buffers(sb16_dev_t* dev, sb16_stream_t* s, const char* desc);
55 status_t sb16_stream_start(sb16_dev_t* dev, sb16_stream_t* s);
56 status_t sb16_stream_stop(sb16_dev_t* dev, sb16_stream_t* s);
57 void sb16_stream_buffer_done(sb16_stream_t* stream);
58 
59 status_t multi_audio_control(void* cookie, uint32 op, void* arg, size_t len);
60 
61 #endif /* DRIVER_H */
62 
63