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