xref: /haiku/headers/private/drivers/dvb.h (revision 893988af824e65e49e55f517b157db8386e8002b)
1 /*
2  * Copyright (c) 2005 Marcus Overhagen <marcus@overhagen.de>
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without restriction,
7  * including without limitation the rights to use, copy, modify,
8  * merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 /* This is the driver ioctl interface used for DVB on BeOS
26  * it is not final, and will be changed before a public release
27  * is made of the DVB framework (media add-on and example player).
28  *
29  * The driver should publish in /dev/dvb/cardname/n (with n=1..).
30  * It must implement the ioctl codes from dvb_ioctl_t.
31  * The driver must have buffers readable by userspace, it
32  * should directly use DMA buffers for that.
33  * The DVB add-on expects DVB_CAPTURE to block until data is
34  * available, or a timeout has expired. If the timeout expired,
35  * it must return B_TIMED_OUT. This ensures that the driver
36  * doesn't block when reception conditions are going bad, and
37  * allows user space programs to recognize this.
38  * If the ioctl succeeds, the driver must record the capture end time
39  * and report the data pointer and size. The data must stay valid
40  * for a few ms, to give the user space thread, running at realtime
41  * priority, a chance to read it. The driver must do at least
42  * double buffering to achieve this.
43  * For DVB-T, two buffers of 61 kByte give about 16 ms validity period
44  * for each buffer, thats enough. A 100 ms timout is used, to ensure
45  * that DVB_CAPTURE doesn't block when no data is available.
46  *
47  * A normal ioctl sequence is:
48  *  - DVB_GET_INTERFACE_INFO
49  *  - DVB_SET_TUNING_PARAMETERS
50  *  - DVB_GET_STATUS
51  *  - DVB_START_CAPTURE
52  *  - DVB_CAPTURE (repeated)
53  *  - DVB_STOP_CAPTURE
54  *
55  * The following ioctls can be called at any time,
56  * including when capture is active:
57  *  - DVB_GET_INTERFACE_INFO
58  *  - DVB_GET_FREQUENCY_INFO
59  *  - DVB_GET_TUNING_PARAMETERS
60  *  - DVB_GET_STATUS
61  *  - DVB_GET_SS
62  *  - DVB_GET_BER
63  *  - DVB_GET_SNR
64  *  - DVB_GET_UPC
65  *
66  * In future releases, other ioctls that are not yet defined may
67  * be called. It's important that the driver does not crash, but
68  * instead returnes an error code.
69  *
70  * Parameter reference for ioctl() functions:
71  *
72  * opcode                    | parameter               | description
73  * --------------------------+-------------------------+-----------------------------------------
74  * DVB_GET_INTERFACE_INFO    | dvb_interface_info_t    | get interface capabilites (memset to 0 first)
75  * DVB_GET_FREQUENCY_INFO    | dvb_frequency_info_t    | get interface capabilites (memset to 0 first)
76  * DVB_SET_TUNING_PARAMETERS | dvb_tuning_parameters_t | perform tuning information
77  * DVB_GET_TUNING_PARAMETERS | dvb_tuning_parameters_t | get active parameters (after autotuning) (memset to 0 first)
78  * DVB_START_CAPTURE         | (none)                  | start the capture
79  * DVB_STOP_CAPTURE          | (none)                  | stop the capture
80  * DVB_GET_STATUS            | dvb_status_t            | get current status
81  * DVB_GET_SS                | uint32                  | signal strength, range 0 to 1000
82  * DVB_GET_BER               | uint32                  | block error rate, range 0 to 1000
83  * DVB_GET_SNR               | uint32                  | signal noise ratio, range 0 to 1000
84  * DVB_GET_UPC               | uint32                  | XXX ???, range 0 to 1000
85  * DVB_CAPTURE               | dvb_capture_t           | get information about captured data
86  *
87  */
88 
89 
90 #ifndef __DVB_H
91 #define __DVB_H
92 
93 #include <Drivers.h>
94 
95 typedef enum {
96 	DVB_TYPE_UNKNOWN			= -1,
97 	DVB_TYPE_DVB_C				= 0x10,
98 	DVB_TYPE_DVB_H				= 0x20,
99 	DVB_TYPE_DVB_S				= 0x30,
100 	DVB_TYPE_DVB_T				= 0x40,
101 } dvb_type_t;
102 
103 
104 // channel bandwith
105 typedef enum {
106 	DVB_BANDWIDTH_AUTO	 		= 0,
107 	DVB_BANDWIDTH_5_MHZ			= 5000,
108 	DVB_BANDWIDTH_6_MHZ			= 6000,
109 	DVB_BANDWIDTH_7_MHZ			= 7000,
110 	DVB_BANDWIDTH_8_MHZ			= 8000,
111 } dvb_bandwidth_t;
112 
113 
114 // channel polarity
115 typedef enum {
116 	DVB_POLARITY_UNKNOWN		= -1,
117 	DVB_POLARITY_VERTICAL		= 1,
118 	DVB_POLARITY_HORIZONTAL		= 2,
119 } dvb_polarity_t;
120 
121 
122 // "modulation" or "constellation"
123 typedef enum {
124 	DVB_MODULATION_AUTO,
125 	DVB_MODULATION_QPSK,
126 	DVB_MODULATION_16_QAM,
127 	DVB_MODULATION_32_QAM,
128 	DVB_MODULATION_64_QAM,
129 	DVB_MODULATION_128_QAM,
130 	DVB_MODULATION_256_QAM,
131 } dvb_modulation_t;
132 
133 
134 // dvb_cofdm_mode, dvb_transmission_mode
135 typedef enum {
136 	DVB_TRANSMISSION_MODE_AUTO,
137 	DVB_TRANSMISSION_MODE_2K,
138 	DVB_TRANSMISSION_MODE_4K,
139 	DVB_TRANSMISSION_MODE_8K,
140 } dvb_transmission_mode_t;
141 
142 
143 // code rate, specified by inner FEC (forward error correction) scheme
144 typedef enum {
145 	DVB_FEC_AUTO,
146 	DVB_FEC_NONE,
147 	DVB_FEC_1_2,
148 	DVB_FEC_2_3,
149 	DVB_FEC_3_4,
150 	DVB_FEC_4_5,
151 	DVB_FEC_5_6,
152 	DVB_FEC_6_7,
153 	DVB_FEC_7_8,
154 	DVB_FEC_8_9,
155 } dvb_code_rate_t;
156 
157 
158 // guard interval
159 typedef enum {
160 	DVB_GUARD_INTERVAL_AUTO,
161 	DVB_GUARD_INTERVAL_1_4,
162 	DVB_GUARD_INTERVAL_1_8,
163 	DVB_GUARD_INTERVAL_1_16,
164 	DVB_GUARD_INTERVAL_1_32,
165 } dvb_guard_interval_t;
166 
167 
168 // alpha value for hierarchical transmission
169 typedef enum {
170 	DVB_HIERARCHY_AUTO,
171 	DVB_HIERARCHY_NONE,
172 	DVB_HIERARCHY_1,
173 	DVB_HIERARCHY_2,
174 	DVB_HIERARCHY_4,
175 } dvb_hierarchy_t;
176 
177 
178 // spectral inversion
179 typedef enum {
180 	DVB_INVERSION_AUTO,
181 	DVB_INVERSION_ON,
182 	DVB_INVERSION_OFF,
183 } dvb_inversion_t;
184 
185 
186 typedef enum {
187 	DVB_STATUS_SIGNAL		= 0x0001,
188 	DVB_STATUS_CARRIER		= 0x0002,
189 	DVB_STATUS_LOCK			= 0x0004,
190 	DVB_STATUS_VITERBI		= 0x0008,
191 	DVB_STATUS_SYNC			= 0x0010,
192 } dvb_status_t;
193 
194 
195 typedef enum {
196 	DVB_GET_INTERFACE_INFO		= (B_DEVICE_OP_CODES_END + 0x100),
197 	DVB_GET_FREQUENCY_INFO 		= (B_DEVICE_OP_CODES_END + 0x120),
198 	DVB_SET_TUNING_PARAMETERS,
199 	DVB_GET_TUNING_PARAMETERS,
200 	DVB_START_CAPTURE,
201 	DVB_STOP_CAPTURE,
202 	DVB_GET_STATUS,
203 	DVB_GET_SS,
204 	DVB_GET_BER,
205 	DVB_GET_SNR,
206 	DVB_GET_UPC,
207 	DVB_CAPTURE,
208 } dvb_ioctl_t;
209 
210 
211 typedef struct {
212 	uint32					version;	// set this to 1
213 	uint32					flags;		// set this to 0
214 	dvb_type_t				type;
215 	uint32					_res1[16];
216 	char					name[100];
217 	char					info[500];
218 	uint32					_res2[16];
219 } dvb_interface_info_t;
220 
221 
222 typedef struct {
223 	uint32					_res1[16];
224 	uint64					frequency_min;
225 	uint64					frequency_max;
226 	uint64					frequency_step;
227 	uint32					_res2[64];
228 } dvb_frequency_info_t;
229 
230 
231 typedef struct {
232 	uint64					frequency;
233 	dvb_inversion_t			inversion;
234 	dvb_bandwidth_t			bandwidth;
235 	dvb_modulation_t		modulation;
236 	dvb_hierarchy_t			hierarchy;
237 	dvb_code_rate_t			code_rate_hp;
238 	dvb_code_rate_t			code_rate_lp;
239 	dvb_transmission_mode_t	transmission_mode;
240 	dvb_guard_interval_t	guard_interval;
241 } dvb_t_tuning_parameters_t;
242 
243 
244 typedef struct {
245 	uint64					frequency;
246 	dvb_inversion_t			inversion;
247 	dvb_modulation_t		modulation;
248 	uint32					symbolrate;
249 	dvb_polarity_t			polarity;
250 } dvb_s_tuning_parameters_t;
251 
252 
253 typedef struct {
254 	union {
255 		dvb_t_tuning_parameters_t	dvb_t;
256 		dvb_s_tuning_parameters_t	dvb_s;
257 		uint32						_pad[32];
258 	} u;
259 } dvb_tuning_parameters_t;
260 
261 
262 typedef struct {
263 	void *					data;
264 	size_t					size;
265 	bigtime_t				end_time;
266 	uint32					_res[2];
267 } dvb_capture_t;
268 
269 #endif
270