1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef __PVRUSB2_HDW_INTERNAL_H
21#define __PVRUSB2_HDW_INTERNAL_H
22
23
24
25
26
27
28
29
30
31
32
33
34
35#include <linux/videodev2.h>
36#include <linux/i2c.h>
37#include <linux/workqueue.h>
38#include <linux/mutex.h>
39#include "pvrusb2-hdw.h"
40#include "pvrusb2-io.h"
41#include <media/v4l2-device.h>
42#include <media/cx2341x.h>
43#include <media/ir-kbd-i2c.h>
44#include "pvrusb2-devattr.h"
45
46
47#define PVR2_CVAL_HSM_FAIL 0
48#define PVR2_CVAL_HSM_FULL 1
49#define PVR2_CVAL_HSM_HIGH 2
50
51#define PVR2_VID_ENDPOINT 0x84
52#define PVR2_UNK_ENDPOINT 0x86
53#define PVR2_VBI_ENDPOINT 0x88
54
55#define PVR2_CTL_BUFFSIZE 64
56
57#define FREQTABLE_SIZE 500
58
59#define LOCK_TAKE(x) do { mutex_lock(&x##_mutex); x##_held = !0; } while (0)
60#define LOCK_GIVE(x) do { x##_held = 0; mutex_unlock(&x##_mutex); } while (0)
61
62typedef int (*pvr2_ctlf_is_dirty)(struct pvr2_ctrl *);
63typedef void (*pvr2_ctlf_clear_dirty)(struct pvr2_ctrl *);
64typedef int (*pvr2_ctlf_check_value)(struct pvr2_ctrl *,int);
65typedef int (*pvr2_ctlf_get_value)(struct pvr2_ctrl *,int *);
66typedef int (*pvr2_ctlf_set_value)(struct pvr2_ctrl *,int msk,int val);
67typedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val,
68 char *,unsigned int,unsigned int *);
69typedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *,
70 const char *,unsigned int,
71 int *mskp,int *valp);
72typedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *);
73
74
75
76struct pvr2_ctl_info {
77
78 const char *name;
79
80
81 const char *desc;
82
83
84 pvr2_ctlf_get_value get_value;
85 pvr2_ctlf_get_value get_def_value;
86 pvr2_ctlf_get_value get_min_value;
87 pvr2_ctlf_get_value get_max_value;
88 pvr2_ctlf_set_value set_value;
89 pvr2_ctlf_check_value check_value;
90 pvr2_ctlf_val_to_sym val_to_sym;
91 pvr2_ctlf_sym_to_val sym_to_val;
92 pvr2_ctlf_is_dirty is_dirty;
93 pvr2_ctlf_clear_dirty clear_dirty;
94 pvr2_ctlf_get_v4lflags get_v4lflags;
95
96
97 enum pvr2_ctl_type type;
98
99
100 int v4l_id;
101
102
103 int internal_id;
104
105
106 int skip_init;
107
108
109 int default_value;
110
111
112 union {
113 struct {
114 long min_value;
115 long max_value;
116 } type_int;
117 struct {
118 unsigned int count;
119 const char * const *value_names;
120 } type_enum;
121 struct {
122 unsigned int valid_bits;
123 const char **bit_names;
124 } type_bitmask;
125 } def;
126};
127
128
129
130#define PVR2_CTLD_INFO_DESC_SIZE 32
131struct pvr2_ctld_info {
132 struct pvr2_ctl_info info;
133 char desc[PVR2_CTLD_INFO_DESC_SIZE];
134};
135
136struct pvr2_ctrl {
137 const struct pvr2_ctl_info *info;
138 struct pvr2_hdw *hdw;
139};
140
141
142
143
144#define FW1_STATE_UNKNOWN 0
145#define FW1_STATE_MISSING 1
146#define FW1_STATE_FAILED 2
147#define FW1_STATE_RELOAD 3
148#define FW1_STATE_OK 4
149
150
151#define PVR2_PATHWAY_UNKNOWN 0
152#define PVR2_PATHWAY_ANALOG 1
153#define PVR2_PATHWAY_DIGITAL 2
154
155typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16);
156#define PVR2_I2C_FUNC_CNT 128
157
158
159
160
161struct pvr2_hdw {
162
163 struct usb_device *usb_dev;
164 struct usb_interface *usb_intf;
165
166
167 struct v4l2_device v4l2_dev;
168
169
170 const struct pvr2_device_desc *hdw_desc;
171
172
173 struct workqueue_struct *workqueue;
174 struct work_struct workpoll;
175
176
177 struct pvr2_stream *vid_stream;
178
179
180 struct mutex big_lock_mutex;
181 int big_lock_held;
182
183
184
185
186
187 char name[32];
188
189
190
191
192
193
194
195 char identifier[32];
196
197
198 struct i2c_adapter i2c_adap;
199 struct i2c_algorithm i2c_algo;
200 pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT];
201 int i2c_cx25840_hack_state;
202 int i2c_linked;
203
204
205 unsigned int ir_scheme_active;
206 struct IR_i2c_init_data ir_init_data;
207
208
209 unsigned int freqTable[FREQTABLE_SIZE];
210 unsigned int freqProgSlot;
211
212
213 struct mutex ctl_lock_mutex;
214 int ctl_lock_held;
215 struct urb *ctl_write_urb;
216 struct urb *ctl_read_urb;
217 unsigned char *ctl_write_buffer;
218 unsigned char *ctl_read_buffer;
219 int ctl_write_pend_flag;
220 int ctl_read_pend_flag;
221 int ctl_timeout_flag;
222 struct completion ctl_done;
223 unsigned char cmd_buffer[PVR2_CTL_BUFFSIZE];
224 int cmd_debug_state;
225 unsigned char cmd_debug_code;
226 unsigned int cmd_debug_write_len;
227 unsigned int cmd_debug_read_len;
228
229
230
231 int state_pathway_ok;
232 int state_encoder_ok;
233 int state_encoder_run;
234 int state_encoder_config;
235 int state_encoder_waitok;
236 int state_encoder_runok;
237 int state_decoder_run;
238 int state_decoder_ready;
239 int state_usbstream_run;
240 int state_decoder_quiescent;
241 int state_pipeline_config;
242 int state_pipeline_req;
243 int state_pipeline_pause;
244 int state_pipeline_idle;
245
246
247
248
249
250 unsigned int master_state;
251
252
253 int led_on;
254
255
256 int state_stale;
257
258 void (*state_func)(void *);
259 void *state_data;
260
261
262
263 struct timer_list quiescent_timer;
264
265
266
267
268
269 struct timer_list decoder_stabilization_timer;
270
271
272 struct timer_list encoder_wait_timer;
273
274
275 struct timer_list encoder_run_timer;
276
277
278 wait_queue_head_t state_wait_data;
279
280
281 int force_dirty;
282 int flag_ok;
283 int flag_modulefail;
284 int flag_disconnected;
285 int flag_init_ok;
286 int fw1_state;
287 int pathway_state;
288 int flag_decoder_missed;
289 int flag_tripped;
290
291 unsigned int decoder_client_id;
292
293
294 char *fw_buffer;
295 unsigned int fw_size;
296 int fw_cpu_flag;
297
298
299 unsigned int tuner_type;
300 int tuner_updated;
301 unsigned int freqValTelevision;
302 unsigned int freqValRadio;
303 unsigned int freqSlotTelevision;
304 unsigned int freqSlotRadio;
305 unsigned int freqSelector;
306 int freqDirty;
307
308
309 struct v4l2_tuner tuner_signal_info;
310 int tuner_signal_stale;
311
312
313 struct v4l2_cropcap cropcap_info;
314 int cropcap_stale;
315
316
317 v4l2_std_id std_mask_eeprom;
318 v4l2_std_id std_mask_avail;
319 v4l2_std_id std_mask_cur;
320 int std_enum_cur;
321 int std_dirty;
322 struct pvr2_ctl_info std_info_enum;
323 struct pvr2_ctl_info std_info_avail;
324 struct pvr2_ctl_info std_info_cur;
325 struct pvr2_ctl_info std_info_detect;
326
327
328 const char *std_mask_ptrs[32];
329 char std_mask_names[32][16];
330
331 int unit_number;
332 unsigned long serial_number;
333
334 char bus_info[32];
335
336
337
338 int v4l_minor_number_video;
339 int v4l_minor_number_vbi;
340 int v4l_minor_number_radio;
341
342
343 unsigned int input_avail_mask;
344
345 unsigned int input_allowed_mask;
346
347
348 int eeprom_addr;
349
350 enum pvr2_config active_stream_type;
351 enum pvr2_config desired_stream_type;
352
353
354 struct cx2341x_mpeg_params enc_cur_state;
355 struct cx2341x_mpeg_params enc_ctl_state;
356
357 int enc_stale;
358
359 int enc_unsafe_stale;
360
361 int enc_cur_valid;
362
363
364#define VCREATE_DATA(lab) int lab##_val; int lab##_dirty
365 VCREATE_DATA(brightness);
366 VCREATE_DATA(contrast);
367 VCREATE_DATA(saturation);
368 VCREATE_DATA(hue);
369 VCREATE_DATA(volume);
370 VCREATE_DATA(balance);
371 VCREATE_DATA(bass);
372 VCREATE_DATA(treble);
373 VCREATE_DATA(mute);
374 VCREATE_DATA(cropl);
375 VCREATE_DATA(cropt);
376 VCREATE_DATA(cropw);
377 VCREATE_DATA(croph);
378 VCREATE_DATA(input);
379 VCREATE_DATA(audiomode);
380 VCREATE_DATA(res_hor);
381 VCREATE_DATA(res_ver);
382 VCREATE_DATA(srate);
383#undef VCREATE_DATA
384
385 struct pvr2_ctld_info *mpeg_ctrl_info;
386
387 struct pvr2_ctrl *controls;
388 unsigned int control_cnt;
389};
390
391
392unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *);
393
394void pvr2_hdw_status_poll(struct pvr2_hdw *);
395
396#endif
397
398
399
400
401
402
403
404
405
406
407