0001
0002
0003
0004
0005
0006 #ifndef __PVRUSB2_HDW_INTERNAL_H
0007 #define __PVRUSB2_HDW_INTERNAL_H
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <linux/videodev2.h>
0022 #include <linux/i2c.h>
0023 #include <linux/workqueue.h>
0024 #include <linux/mutex.h>
0025 #include "pvrusb2-hdw.h"
0026 #include "pvrusb2-io.h"
0027 #include <media/v4l2-device.h>
0028 #include <media/drv-intf/cx2341x.h>
0029 #include <media/i2c/ir-kbd-i2c.h>
0030 #include "pvrusb2-devattr.h"
0031
0032
0033 #define PVR2_CVAL_HSM_FAIL 0
0034 #define PVR2_CVAL_HSM_FULL 1
0035 #define PVR2_CVAL_HSM_HIGH 2
0036
0037 #define PVR2_VID_ENDPOINT 0x84
0038 #define PVR2_UNK_ENDPOINT 0x86
0039 #define PVR2_VBI_ENDPOINT 0x88
0040
0041 #define PVR2_CTL_BUFFSIZE 64
0042
0043 #define FREQTABLE_SIZE 500
0044
0045 #define LOCK_TAKE(x) do { mutex_lock(&x##_mutex); x##_held = !0; } while (0)
0046 #define LOCK_GIVE(x) do { x##_held = 0; mutex_unlock(&x##_mutex); } while (0)
0047
0048 typedef int (*pvr2_ctlf_is_dirty)(struct pvr2_ctrl *);
0049 typedef void (*pvr2_ctlf_clear_dirty)(struct pvr2_ctrl *);
0050 typedef int (*pvr2_ctlf_check_value)(struct pvr2_ctrl *,int);
0051 typedef int (*pvr2_ctlf_get_value)(struct pvr2_ctrl *,int *);
0052 typedef int (*pvr2_ctlf_set_value)(struct pvr2_ctrl *,int msk,int val);
0053 typedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val,
0054 char *,unsigned int,unsigned int *);
0055 typedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *,
0056 const char *,unsigned int,
0057 int *mskp,int *valp);
0058 typedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *);
0059
0060
0061
0062 struct pvr2_ctl_info {
0063
0064 const char *name;
0065
0066
0067 const char *desc;
0068
0069
0070 pvr2_ctlf_get_value get_value;
0071 pvr2_ctlf_get_value get_def_value;
0072 pvr2_ctlf_get_value get_min_value;
0073 pvr2_ctlf_get_value get_max_value;
0074 pvr2_ctlf_set_value set_value;
0075 pvr2_ctlf_check_value check_value;
0076 pvr2_ctlf_val_to_sym val_to_sym;
0077 pvr2_ctlf_sym_to_val sym_to_val;
0078 pvr2_ctlf_is_dirty is_dirty;
0079 pvr2_ctlf_clear_dirty clear_dirty;
0080 pvr2_ctlf_get_v4lflags get_v4lflags;
0081
0082
0083 enum pvr2_ctl_type type;
0084
0085
0086 int v4l_id;
0087
0088
0089 int internal_id;
0090
0091
0092 int skip_init;
0093
0094
0095 int default_value;
0096
0097
0098 union {
0099 struct {
0100 long min_value;
0101 long max_value;
0102 } type_int;
0103 struct {
0104 unsigned int count;
0105 const char * const *value_names;
0106 } type_enum;
0107 struct {
0108 unsigned int valid_bits;
0109 const char **bit_names;
0110 } type_bitmask;
0111 } def;
0112 };
0113
0114
0115
0116 #define PVR2_CTLD_INFO_DESC_SIZE 32
0117 struct pvr2_ctld_info {
0118 struct pvr2_ctl_info info;
0119 char desc[PVR2_CTLD_INFO_DESC_SIZE];
0120 };
0121
0122 struct pvr2_ctrl {
0123 const struct pvr2_ctl_info *info;
0124 struct pvr2_hdw *hdw;
0125 };
0126
0127
0128
0129
0130 #define FW1_STATE_UNKNOWN 0
0131 #define FW1_STATE_MISSING 1
0132 #define FW1_STATE_FAILED 2
0133 #define FW1_STATE_RELOAD 3
0134 #define FW1_STATE_OK 4
0135
0136
0137 #define PVR2_PATHWAY_UNKNOWN 0
0138 #define PVR2_PATHWAY_ANALOG 1
0139 #define PVR2_PATHWAY_DIGITAL 2
0140
0141 typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16);
0142 #define PVR2_I2C_FUNC_CNT 128
0143
0144
0145
0146
0147 struct pvr2_hdw {
0148
0149 struct usb_device *usb_dev;
0150 struct usb_interface *usb_intf;
0151
0152
0153 struct v4l2_device v4l2_dev;
0154
0155
0156 const struct pvr2_device_desc *hdw_desc;
0157
0158
0159 struct work_struct workpoll;
0160
0161
0162 struct pvr2_stream *vid_stream;
0163
0164
0165 struct mutex big_lock_mutex;
0166 int big_lock_held;
0167
0168
0169
0170
0171
0172 char name[32];
0173
0174
0175
0176
0177
0178
0179
0180 char identifier[32];
0181
0182
0183 struct i2c_adapter i2c_adap;
0184 struct i2c_algorithm i2c_algo;
0185 pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT];
0186 int i2c_cx25840_hack_state;
0187 int i2c_linked;
0188
0189
0190 unsigned int ir_scheme_active;
0191 struct IR_i2c_init_data ir_init_data;
0192
0193
0194 unsigned int freqTable[FREQTABLE_SIZE];
0195 unsigned int freqProgSlot;
0196
0197
0198 struct mutex ctl_lock_mutex;
0199 int ctl_lock_held;
0200 struct urb *ctl_write_urb;
0201 struct urb *ctl_read_urb;
0202 unsigned char *ctl_write_buffer;
0203 unsigned char *ctl_read_buffer;
0204 int ctl_write_pend_flag;
0205 int ctl_read_pend_flag;
0206 int ctl_timeout_flag;
0207 struct completion ctl_done;
0208 unsigned char cmd_buffer[PVR2_CTL_BUFFSIZE];
0209 int cmd_debug_state;
0210 unsigned char cmd_debug_code;
0211 unsigned int cmd_debug_write_len;
0212 unsigned int cmd_debug_read_len;
0213
0214
0215
0216 int state_pathway_ok;
0217 int state_encoder_ok;
0218 int state_encoder_run;
0219 int state_encoder_config;
0220 int state_encoder_waitok;
0221 int state_encoder_runok;
0222 int state_decoder_run;
0223 int state_decoder_ready;
0224 int state_usbstream_run;
0225 int state_decoder_quiescent;
0226 int state_pipeline_config;
0227 int state_pipeline_req;
0228 int state_pipeline_pause;
0229 int state_pipeline_idle;
0230
0231
0232
0233
0234
0235 unsigned int master_state;
0236
0237
0238 int led_on;
0239
0240
0241 int state_stale;
0242
0243 void (*state_func)(void *);
0244 void *state_data;
0245
0246
0247
0248 struct timer_list quiescent_timer;
0249
0250
0251
0252
0253
0254 struct timer_list decoder_stabilization_timer;
0255
0256
0257 struct timer_list encoder_wait_timer;
0258
0259
0260 struct timer_list encoder_run_timer;
0261
0262
0263 wait_queue_head_t state_wait_data;
0264
0265
0266 int force_dirty;
0267 int flag_ok;
0268 int flag_modulefail;
0269 int flag_disconnected;
0270 int flag_init_ok;
0271 int fw1_state;
0272 int pathway_state;
0273 int flag_decoder_missed;
0274 int flag_tripped;
0275
0276 unsigned int decoder_client_id;
0277
0278
0279 char *fw_buffer;
0280 unsigned int fw_size;
0281 int fw_cpu_flag;
0282
0283
0284 unsigned int tuner_type;
0285 int tuner_updated;
0286 unsigned int freqValTelevision;
0287 unsigned int freqValRadio;
0288 unsigned int freqSlotTelevision;
0289 unsigned int freqSlotRadio;
0290 unsigned int freqSelector;
0291 int freqDirty;
0292
0293
0294 struct v4l2_tuner tuner_signal_info;
0295 int tuner_signal_stale;
0296
0297
0298 struct v4l2_cropcap cropcap_info;
0299 int cropcap_stale;
0300
0301
0302 v4l2_std_id std_mask_eeprom;
0303 v4l2_std_id std_mask_avail;
0304 v4l2_std_id std_mask_cur;
0305 int std_enum_cur;
0306 int std_dirty;
0307 struct pvr2_ctl_info std_info_enum;
0308 struct pvr2_ctl_info std_info_avail;
0309 struct pvr2_ctl_info std_info_cur;
0310 struct pvr2_ctl_info std_info_detect;
0311
0312
0313 const char *std_mask_ptrs[32];
0314 char std_mask_names[32][16];
0315
0316 int unit_number;
0317 unsigned long serial_number;
0318
0319 char bus_info[32];
0320
0321
0322
0323 int v4l_minor_number_video;
0324 int v4l_minor_number_vbi;
0325 int v4l_minor_number_radio;
0326
0327
0328 unsigned int input_avail_mask;
0329
0330 unsigned int input_allowed_mask;
0331
0332
0333 int eeprom_addr;
0334
0335 enum pvr2_config active_stream_type;
0336 enum pvr2_config desired_stream_type;
0337
0338
0339 struct cx2341x_mpeg_params enc_cur_state;
0340 struct cx2341x_mpeg_params enc_ctl_state;
0341
0342 int enc_stale;
0343
0344 int enc_unsafe_stale;
0345
0346 int enc_cur_valid;
0347
0348
0349 #define VCREATE_DATA(lab) int lab##_val; int lab##_dirty
0350 VCREATE_DATA(brightness);
0351 VCREATE_DATA(contrast);
0352 VCREATE_DATA(saturation);
0353 VCREATE_DATA(hue);
0354 VCREATE_DATA(volume);
0355 VCREATE_DATA(balance);
0356 VCREATE_DATA(bass);
0357 VCREATE_DATA(treble);
0358 VCREATE_DATA(mute);
0359 VCREATE_DATA(cropl);
0360 VCREATE_DATA(cropt);
0361 VCREATE_DATA(cropw);
0362 VCREATE_DATA(croph);
0363 VCREATE_DATA(input);
0364 VCREATE_DATA(audiomode);
0365 VCREATE_DATA(res_hor);
0366 VCREATE_DATA(res_ver);
0367 VCREATE_DATA(srate);
0368 #undef VCREATE_DATA
0369
0370 struct pvr2_ctld_info *mpeg_ctrl_info;
0371
0372 struct pvr2_ctrl *controls;
0373 unsigned int control_cnt;
0374 };
0375
0376
0377 unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *);
0378
0379 void pvr2_hdw_status_poll(struct pvr2_hdw *);
0380
0381 #endif