1#ifndef __LALA_H
2#define __LALA_H
3
4#include <KernelExport.h>
5#include <config_manager.h>
6#include <PCI.h>
7#include <OS.h>
8#include <malloc.h>
9
10typedef struct
11{
12	pci_module_info *	pci;
13
14	uint8				bus;
15	uint8				device;
16	uint8				function;
17
18	const char *		name;
19	void *				param;
20} audio_drv_t;
21
22typedef struct
23{
24	int32			vendor;
25	int32			device;
26	int32			revision;
27	int32			class;
28	int32			subclass;
29	int32			subsystem_vendor;
30	int32			subsystem_device;
31	const char *	name;
32	void *			param;
33} pci_id_table_t;
34
35
36typedef int32 	control_id;
37
38
39typedef status_t (*drv_attach)		(audio_drv_t *drv, void **cookie);
40typedef status_t (*drv_powerctl)	(audio_drv_t *drv, void *cookie, int op);
41typedef status_t (*drv_detach)		(audio_drv_t *drv, void *cookie);
42
43
44typedef struct
45{
46	const char *	basename;
47	pci_id_table_t *pci_id_table;
48
49	uint32			_reserved1[16];
50
51	drv_attach		attach;
52	drv_detach		detach;
53	drv_powerctl	powerctl;
54
55	uint32			_reserved2[16];
56} driver_info_t;
57
58
59typedef struct
60{
61	char *	base;		/* pointer to first sample for channel for buffer */
62	size_t	stride;		/* offset to next sample */
63	uint32	_reserved[4];
64} stream_buffer_desc_t;
65
66
67typedef status_t (*stream_attach)			(audio_drv_t *drv, void *cookie, int stream_id);
68typedef status_t (*stream_detach)			(audio_drv_t *drv, void *cookie, int stream_id);
69typedef status_t (*stream_control)			(audio_drv_t *drv, void *cookie, int stream_id, int op);
70typedef status_t (*stream_process)			(audio_drv_t *drv, void *cookie, int stream_id, int buffer);
71typedef status_t (*stream_set_buffers)		(audio_drv_t *drv, void *cookie, int stream_id, uint32 *buffer_size, stream_buffer_desc_t *desc);
72typedef status_t (*stream_set_frame_rate)	(audio_drv_t *drv, void *cookie, int stream_id, uint32 *frame_rate);
73
74
75enum {
76	B_RECORDING_STREAM			= 0x00000001,
77	B_PLAYBACK_STREAM			= 0x00000002,
78	B_BUFFER_SIZE_LINEAR		= 0x00001000,
79	B_BUFFER_SIZE_EXPONETIAL	= 0x00002000,
80	B_SAMPLE_TYPE_INT16			= 0x00010000,
81	B_SAMPLE_TYPE_INT32			= 0x00020000,
82	B_SAMPLE_TYPE_FLOAT32		= 0x00040000,
83};
84
85enum {
86	B_CHANNEL_LEFT	= 0x0001,
87	B_CHANNEL_RIGHT	= 0x0002,
88};
89
90enum {
91	B_FRAME_RATE_32000		= 0x0100,
92	B_FRAME_RATE_44100		= 0x0200,
93	B_FRAME_RATE_48000		= 0x0400,
94	B_FRAME_RATE_96000		= 0x0800,
95	B_FRAME_RATE_VARIABLE	= 0x20000000,
96};
97
98typedef struct
99{
100	uint32	flags;
101	uint32	cookie_size;
102	uint32	sample_bits;
103	uint32	channel_count;
104	uint32	channel_mask;
105	uint32	frame_rate_min;
106	uint32	frame_rate_max;
107	uint32	frame_rate_mask;
108	uint32	buffer_size_min;
109	uint32	buffer_size_max;
110	uint32	buffer_count;
111
112	uint32	_reserved1[32];
113
114	stream_attach			attach;
115	stream_detach			detach;
116	stream_control			control;
117	stream_process			process;
118
119	stream_set_buffers		set_buffers;
120	stream_set_frame_rate	set_frame_rate;
121
122	uint32					_reserved2[16];
123
124} stream_info_t;
125
126
127// protection is 0 for kernel only access, or B_READ_AREA, B_WRITE_AREA for user space access
128area_id		alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name);
129area_id		map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name);
130
131status_t	create_stream(audio_drv_t *drv, int stream_id, stream_info_t *info);
132status_t	delete_stream(audio_drv_t *drv, int stream_id);
133
134void		report_stream_buffer_ready(audio_drv_t *drv, int stream_id, int buffer, bigtime_t end_time, int64 total_frames);
135
136control_id	create_control_group(control_id parent, audio_drv_t *dev);
137control_id	create_control(control_id parent, uint32 flags, void *get, void *set, const char *name);
138
139
140#define LOG(a)		dprintf a
141#define PRINT(a)	dprintf a
142
143#endif
144