Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 1 | /* |
| 2 | * |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 15 | */ |
| 16 | #ifndef __PVRUSB2_HDW_INTERNAL_H |
| 17 | #define __PVRUSB2_HDW_INTERNAL_H |
| 18 | |
| 19 | /* |
| 20 | |
| 21 | This header sets up all the internal structures and definitions needed to |
| 22 | track and coordinate the driver's interaction with the hardware. ONLY |
| 23 | source files which actually implement part of that whole circus should be |
| 24 | including this header. Higher levels, like the external layers to the |
| 25 | various public APIs (V4L, sysfs, etc) should NOT ever include this |
| 26 | private, internal header. This means that pvrusb2-hdw, pvrusb2-encoder, |
| 27 | etc will include this, but pvrusb2-v4l should not. |
| 28 | |
| 29 | */ |
| 30 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 31 | #include <linux/videodev2.h> |
| 32 | #include <linux/i2c.h> |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 33 | #include <linux/workqueue.h> |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 34 | #include <linux/mutex.h> |
| 35 | #include "pvrusb2-hdw.h" |
| 36 | #include "pvrusb2-io.h" |
Mike Isely | b72b7bf | 2009-03-06 23:20:31 -0300 | [diff] [blame] | 37 | #include <media/v4l2-device.h> |
Mauro Carvalho Chehab | d647f0b | 2015-11-13 19:40:07 -0200 | [diff] [blame] | 38 | #include <media/drv-intf/cx2341x.h> |
Mauro Carvalho Chehab | b5dcee22 | 2015-11-10 12:01:44 -0200 | [diff] [blame] | 39 | #include <media/i2c/ir-kbd-i2c.h> |
Mike Isely | 989eb15 | 2007-11-26 01:53:12 -0300 | [diff] [blame] | 40 | #include "pvrusb2-devattr.h" |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 41 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 42 | /* Legal values for PVR2_CID_HSM */ |
| 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 /* maybe raw yuv ? */ |
| 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 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 58 | typedef int (*pvr2_ctlf_is_dirty)(struct pvr2_ctrl *); |
| 59 | typedef void (*pvr2_ctlf_clear_dirty)(struct pvr2_ctrl *); |
Mike Isely | 5549f54 | 2006-12-27 23:28:54 -0300 | [diff] [blame] | 60 | typedef int (*pvr2_ctlf_check_value)(struct pvr2_ctrl *,int); |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 61 | typedef int (*pvr2_ctlf_get_value)(struct pvr2_ctrl *,int *); |
| 62 | typedef int (*pvr2_ctlf_set_value)(struct pvr2_ctrl *,int msk,int val); |
| 63 | typedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val, |
| 64 | char *,unsigned int,unsigned int *); |
| 65 | typedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *, |
| 66 | const char *,unsigned int, |
| 67 | int *mskp,int *valp); |
Mike Isely | a761f43 | 2006-06-25 20:04:44 -0300 | [diff] [blame] | 68 | typedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *); |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 69 | |
| 70 | /* This structure describes a specific control. A table of these is set up |
| 71 | in pvrusb2-hdw.c. */ |
| 72 | struct pvr2_ctl_info { |
| 73 | /* Control's name suitable for use as an identifier */ |
| 74 | const char *name; |
| 75 | |
| 76 | /* Short description of control */ |
| 77 | const char *desc; |
| 78 | |
| 79 | /* Control's implementation */ |
| 80 | pvr2_ctlf_get_value get_value; /* Get its value */ |
Mike Isely | 26dd1c57 | 2008-08-31 20:55:03 -0300 | [diff] [blame] | 81 | pvr2_ctlf_get_value get_def_value; /* Get its default value */ |
Mike Isely | 89ebd63 | 2006-08-08 09:10:07 -0300 | [diff] [blame] | 82 | pvr2_ctlf_get_value get_min_value; /* Get minimum allowed value */ |
| 83 | pvr2_ctlf_get_value get_max_value; /* Get maximum allowed value */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 84 | pvr2_ctlf_set_value set_value; /* Set its value */ |
Mike Isely | 5549f54 | 2006-12-27 23:28:54 -0300 | [diff] [blame] | 85 | pvr2_ctlf_check_value check_value; /* Check that value is valid */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 86 | pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */ |
| 87 | pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */ |
| 88 | pvr2_ctlf_is_dirty is_dirty; /* Return true if dirty */ |
| 89 | pvr2_ctlf_clear_dirty clear_dirty; /* Clear dirty state */ |
Mike Isely | a761f43 | 2006-06-25 20:04:44 -0300 | [diff] [blame] | 90 | pvr2_ctlf_get_v4lflags get_v4lflags;/* Retrieve v4l flags */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 91 | |
| 92 | /* Control's type (int, enum, bitmask) */ |
| 93 | enum pvr2_ctl_type type; |
| 94 | |
| 95 | /* Associated V4L control ID, if any */ |
| 96 | int v4l_id; |
| 97 | |
| 98 | /* Associated driver internal ID, if any */ |
| 99 | int internal_id; |
| 100 | |
| 101 | /* Don't implicitly initialize this control's value */ |
| 102 | int skip_init; |
| 103 | |
| 104 | /* Starting value for this control */ |
| 105 | int default_value; |
| 106 | |
| 107 | /* Type-specific control information */ |
| 108 | union { |
| 109 | struct { /* Integer control */ |
| 110 | long min_value; /* lower limit */ |
| 111 | long max_value; /* upper limit */ |
| 112 | } type_int; |
| 113 | struct { /* enumerated control */ |
| 114 | unsigned int count; /* enum value count */ |
Hans Verkuil | 513521e | 2010-12-29 14:25:52 -0300 | [diff] [blame] | 115 | const char * const *value_names; /* symbol names */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 116 | } type_enum; |
| 117 | struct { /* bitmask control */ |
| 118 | unsigned int valid_bits; /* bits in use */ |
| 119 | const char **bit_names; /* symbol name/bit */ |
| 120 | } type_bitmask; |
| 121 | } def; |
| 122 | }; |
| 123 | |
| 124 | |
Mike Isely | c05c046 | 2006-06-25 20:04:25 -0300 | [diff] [blame] | 125 | /* Same as pvr2_ctl_info, but includes storage for the control description */ |
| 126 | #define PVR2_CTLD_INFO_DESC_SIZE 32 |
| 127 | struct pvr2_ctld_info { |
| 128 | struct pvr2_ctl_info info; |
| 129 | char desc[PVR2_CTLD_INFO_DESC_SIZE]; |
| 130 | }; |
| 131 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 132 | struct pvr2_ctrl { |
| 133 | const struct pvr2_ctl_info *info; |
| 134 | struct pvr2_hdw *hdw; |
| 135 | }; |
| 136 | |
| 137 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 138 | |
| 139 | /* Disposition of firmware1 loading situation */ |
| 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 | |
Mike Isely | 62433e3 | 2008-04-22 14:45:40 -0300 | [diff] [blame] | 146 | /* What state the device is in if it is a hybrid */ |
| 147 | #define PVR2_PATHWAY_UNKNOWN 0 |
| 148 | #define PVR2_PATHWAY_ANALOG 1 |
| 149 | #define PVR2_PATHWAY_DIGITAL 2 |
| 150 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 151 | typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16); |
| 152 | #define PVR2_I2C_FUNC_CNT 128 |
| 153 | |
| 154 | /* This structure contains all state data directly needed to |
| 155 | manipulate the hardware (as opposed to complying with a kernel |
| 156 | interface) */ |
| 157 | struct pvr2_hdw { |
| 158 | /* Underlying USB device handle */ |
| 159 | struct usb_device *usb_dev; |
| 160 | struct usb_interface *usb_intf; |
| 161 | |
Mike Isely | b72b7bf | 2009-03-06 23:20:31 -0300 | [diff] [blame] | 162 | /* Our handle into the v4l2 sub-device architecture */ |
| 163 | struct v4l2_device v4l2_dev; |
Mike Isely | f66fbd7 | 2007-11-26 01:55:07 -0300 | [diff] [blame] | 164 | /* Device description, anything that must adjust behavior based on |
| 165 | device specific info will use information held here. */ |
Mike Isely | 989eb15 | 2007-11-26 01:53:12 -0300 | [diff] [blame] | 166 | const struct pvr2_device_desc *hdw_desc; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 167 | |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 168 | /* Kernel worker thread handling */ |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 169 | struct work_struct workpoll; /* Update driver state */ |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 170 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 171 | /* Video spigot */ |
| 172 | struct pvr2_stream *vid_stream; |
| 173 | |
| 174 | /* Mutex for all hardware state control */ |
| 175 | struct mutex big_lock_mutex; |
| 176 | int big_lock_held; /* For debugging */ |
| 177 | |
Mike Isely | 13a8879 | 2009-01-14 04:22:56 -0300 | [diff] [blame] | 178 | /* This is a simple string which identifies the instance of this |
| 179 | driver. It is unique within the set of existing devices, but |
| 180 | there is no attempt to keep the name consistent with the same |
| 181 | physical device each time. */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 182 | char name[32]; |
| 183 | |
Mike Isely | 13a8879 | 2009-01-14 04:22:56 -0300 | [diff] [blame] | 184 | /* This is a simple string which identifies the physical device |
| 185 | instance itself - if possible. (If not possible, then it is |
| 186 | based on the specific driver instance, similar to name above.) |
| 187 | The idea here is that userspace might hopefully be able to use |
| 188 | this recognize specific tuners. It will encode a serial number, |
| 189 | if available. */ |
| 190 | char identifier[32]; |
| 191 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 192 | /* I2C stuff */ |
| 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; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 198 | |
Mike Isely | 27eab38 | 2009-04-06 01:51:38 -0300 | [diff] [blame] | 199 | /* IR related */ |
| 200 | unsigned int ir_scheme_active; /* IR scheme as seen from the outside */ |
Andy Walls | 4999e27 | 2011-01-16 21:21:03 -0300 | [diff] [blame] | 201 | struct IR_i2c_init_data ir_init_data; /* params passed to IR modules */ |
Mike Isely | 27eab38 | 2009-04-06 01:51:38 -0300 | [diff] [blame] | 202 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 203 | /* Frequency table */ |
| 204 | unsigned int freqTable[FREQTABLE_SIZE]; |
| 205 | unsigned int freqProgSlot; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 206 | |
| 207 | /* Stuff for handling low level control interaction with device */ |
| 208 | struct mutex ctl_lock_mutex; |
| 209 | int ctl_lock_held; /* For debugging */ |
| 210 | struct urb *ctl_write_urb; |
| 211 | struct urb *ctl_read_urb; |
| 212 | unsigned char *ctl_write_buffer; |
| 213 | unsigned char *ctl_read_buffer; |
Mike Isely | 26e3304 | 2007-12-03 01:43:23 -0300 | [diff] [blame] | 214 | int ctl_write_pend_flag; |
| 215 | int ctl_read_pend_flag; |
| 216 | int ctl_timeout_flag; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 217 | struct completion ctl_done; |
| 218 | unsigned char cmd_buffer[PVR2_CTL_BUFFSIZE]; |
| 219 | int cmd_debug_state; // Low level command debugging info |
| 220 | unsigned char cmd_debug_code; // |
| 221 | unsigned int cmd_debug_write_len; // |
| 222 | unsigned int cmd_debug_read_len; // |
| 223 | |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 224 | /* Bits of state that describe what is going on with various parts |
| 225 | of the driver. */ |
Mike Isely | 62433e3 | 2008-04-22 14:45:40 -0300 | [diff] [blame] | 226 | int state_pathway_ok; /* Pathway config is ok */ |
Mike Isely | e802c14 | 2007-12-03 01:44:43 -0300 | [diff] [blame] | 227 | int state_encoder_ok; /* Encoder is operational */ |
| 228 | int state_encoder_run; /* Encoder is running */ |
| 229 | int state_encoder_config; /* Encoder is configured */ |
| 230 | int state_encoder_waitok; /* Encoder pre-wait done */ |
Mike Isely | d913d63 | 2008-04-06 04:04:35 -0300 | [diff] [blame] | 231 | int state_encoder_runok; /* Encoder has run for >= .25 sec */ |
Mike Isely | e802c14 | 2007-12-03 01:44:43 -0300 | [diff] [blame] | 232 | int state_decoder_run; /* Decoder is running */ |
Mike Isely | 6e93137 | 2010-02-06 02:10:38 -0300 | [diff] [blame] | 233 | int state_decoder_ready; /* Decoder is stabilized & streamable */ |
Mike Isely | e802c14 | 2007-12-03 01:44:43 -0300 | [diff] [blame] | 234 | int state_usbstream_run; /* FX2 is streaming */ |
Mike Isely | 6e93137 | 2010-02-06 02:10:38 -0300 | [diff] [blame] | 235 | int state_decoder_quiescent; /* Decoder idle for minimal interval */ |
Mike Isely | e802c14 | 2007-12-03 01:44:43 -0300 | [diff] [blame] | 236 | int state_pipeline_config; /* Pipeline is configured */ |
Mike Isely | 7f421fe4 | 2008-04-22 14:45:39 -0300 | [diff] [blame] | 237 | int state_pipeline_req; /* Somebody wants to stream */ |
| 238 | int state_pipeline_pause; /* Pipeline must be paused */ |
| 239 | int state_pipeline_idle; /* Pipeline not running */ |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 240 | |
| 241 | /* This is the master state of the driver. It is the combined |
| 242 | result of other bits of state. Examining this will indicate the |
| 243 | overall state of the driver. Values here are one of |
| 244 | PVR2_STATE_xxxx */ |
| 245 | unsigned int master_state; |
| 246 | |
Mike Isely | 40381cb | 2008-04-22 14:45:42 -0300 | [diff] [blame] | 247 | /* True if device led is currently on */ |
| 248 | int led_on; |
| 249 | |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 250 | /* True if states must be re-evaluated */ |
| 251 | int state_stale; |
| 252 | |
| 253 | void (*state_func)(void *); |
| 254 | void *state_data; |
| 255 | |
Mike Isely | 6e93137 | 2010-02-06 02:10:38 -0300 | [diff] [blame] | 256 | /* Timer for measuring required decoder settling time before we're |
| 257 | allowed to fire it up again. */ |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 258 | struct timer_list quiescent_timer; |
| 259 | |
Mike Isely | 6e93137 | 2010-02-06 02:10:38 -0300 | [diff] [blame] | 260 | /* Timer for measuring decoder stabilization time, which is the |
| 261 | amount of time we need to let the decoder run before we can |
| 262 | trust its output (otherwise the encoder might see garbage and |
| 263 | then fail to start correctly). */ |
| 264 | struct timer_list decoder_stabilization_timer; |
| 265 | |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 266 | /* Timer for measuring encoder pre-wait time */ |
| 267 | struct timer_list encoder_wait_timer; |
| 268 | |
Mike Isely | d913d63 | 2008-04-06 04:04:35 -0300 | [diff] [blame] | 269 | /* Timer for measuring encoder minimum run time */ |
| 270 | struct timer_list encoder_run_timer; |
| 271 | |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 272 | /* Place to block while waiting for state changes */ |
| 273 | wait_queue_head_t state_wait_data; |
| 274 | |
| 275 | |
Mike Isely | 2776472 | 2009-03-07 01:57:25 -0300 | [diff] [blame] | 276 | int force_dirty; /* consider all controls dirty if true */ |
Mike Isely | 9a607f0 | 2007-10-14 18:18:12 -0300 | [diff] [blame] | 277 | int flag_ok; /* device in known good state */ |
Mike Isely | 2710814 | 2009-10-12 00:21:20 -0300 | [diff] [blame] | 278 | int flag_modulefail; /* true if at least one module failed to load */ |
Mike Isely | 9a607f0 | 2007-10-14 18:18:12 -0300 | [diff] [blame] | 279 | int flag_disconnected; /* flag_ok == 0 due to disconnect */ |
| 280 | int flag_init_ok; /* true if structure is fully initialized */ |
Mike Isely | 9a607f0 | 2007-10-14 18:18:12 -0300 | [diff] [blame] | 281 | int fw1_state; /* current situation with fw1 */ |
Mike Isely | 62433e3 | 2008-04-22 14:45:40 -0300 | [diff] [blame] | 282 | int pathway_state; /* one of PVR2_PATHWAY_xxx */ |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 283 | int flag_decoder_missed;/* We've noticed missing decoder */ |
| 284 | int flag_tripped; /* Indicates overall failure to start */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 285 | |
Mike Isely | 00e5f73 | 2009-03-07 00:17:11 -0300 | [diff] [blame] | 286 | unsigned int decoder_client_id; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 287 | |
| 288 | // CPU firmware info (used to help find / save firmware data) |
| 289 | char *fw_buffer; |
| 290 | unsigned int fw_size; |
Mike Isely | 4db666c | 2007-09-08 22:16:27 -0300 | [diff] [blame] | 291 | int fw_cpu_flag; /* True if we are dealing with the CPU */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 292 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 293 | /* Tuner / frequency control stuff */ |
| 294 | unsigned int tuner_type; |
| 295 | int tuner_updated; |
Mike Isely | 1bde028 | 2006-12-27 23:30:13 -0300 | [diff] [blame] | 296 | unsigned int freqValTelevision; /* Current freq for tv mode */ |
| 297 | unsigned int freqValRadio; /* Current freq for radio mode */ |
| 298 | unsigned int freqSlotTelevision; /* Current slot for tv mode */ |
| 299 | unsigned int freqSlotRadio; /* Current slot for radio mode */ |
| 300 | unsigned int freqSelector; /* 0=radio 1=television */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 301 | int freqDirty; |
| 302 | |
Mike Isely | 18103c57 | 2007-01-20 00:09:47 -0300 | [diff] [blame] | 303 | /* Current tuner info - this information is polled from the I2C bus */ |
| 304 | struct v4l2_tuner tuner_signal_info; |
| 305 | int tuner_signal_stale; |
| 306 | |
Mike Isely | 432907f | 2008-08-31 21:02:20 -0300 | [diff] [blame] | 307 | /* Cropping capability info */ |
| 308 | struct v4l2_cropcap cropcap_info; |
| 309 | int cropcap_stale; |
| 310 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 311 | /* Video standard handling */ |
| 312 | v4l2_std_id std_mask_eeprom; // Hardware supported selections |
| 313 | v4l2_std_id std_mask_avail; // Which standards we may select from |
| 314 | v4l2_std_id std_mask_cur; // Currently selected standard(s) |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 315 | int std_enum_cur; // selected standard enumeration value |
| 316 | int std_dirty; // True if std_mask_cur has changed |
| 317 | struct pvr2_ctl_info std_info_enum; |
| 318 | struct pvr2_ctl_info std_info_avail; |
| 319 | struct pvr2_ctl_info std_info_cur; |
Mike Isely | ac04d00 | 2012-02-20 02:28:56 -0300 | [diff] [blame] | 320 | struct pvr2_ctl_info std_info_detect; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 321 | |
| 322 | // Generated string names, one per actual V4L2 standard |
| 323 | const char *std_mask_ptrs[32]; |
Mike Isely | 99ba151 | 2012-02-20 02:31:25 -0300 | [diff] [blame] | 324 | char std_mask_names[32][16]; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 325 | |
| 326 | int unit_number; /* ID for driver instance */ |
| 327 | unsigned long serial_number; /* ID for hardware itself */ |
| 328 | |
Mike Isely | 31a1854 | 2007-04-08 01:11:47 -0300 | [diff] [blame] | 329 | char bus_info[32]; /* Bus location info */ |
| 330 | |
Pantelis Koukousoulas | 2fdf3d9 | 2006-12-27 23:07:58 -0300 | [diff] [blame] | 331 | /* Minor numbers used by v4l logic (yes, this is a hack, as there |
| 332 | should be no v4l junk here). Probably a better way to do this. */ |
Mike Isely | 8079384 | 2006-12-27 23:12:28 -0300 | [diff] [blame] | 333 | int v4l_minor_number_video; |
| 334 | int v4l_minor_number_vbi; |
Mike Isely | fd5a75f | 2006-12-27 23:11:22 -0300 | [diff] [blame] | 335 | int v4l_minor_number_radio; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 336 | |
Mike Isely | 1cb03b7 | 2008-04-21 03:47:43 -0300 | [diff] [blame] | 337 | /* Bit mask of PVR2_CVAL_INPUT choices which are valid for the hardware */ |
Mike Isely | 7fb20fa | 2008-04-22 14:45:37 -0300 | [diff] [blame] | 338 | unsigned int input_avail_mask; |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 339 | /* Bit mask of PVR2_CVAL_INPUT choices which are currently allowed */ |
Mike Isely | 1cb03b7 | 2008-04-21 03:47:43 -0300 | [diff] [blame] | 340 | unsigned int input_allowed_mask; |
Mike Isely | 7fb20fa | 2008-04-22 14:45:37 -0300 | [diff] [blame] | 341 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 342 | /* Location of eeprom or a negative number if none */ |
| 343 | int eeprom_addr; |
| 344 | |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 345 | enum pvr2_config active_stream_type; |
| 346 | enum pvr2_config desired_stream_type; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 347 | |
Mike Isely | b30d244 | 2006-06-25 20:05:01 -0300 | [diff] [blame] | 348 | /* Control state needed for cx2341x module */ |
| 349 | struct cx2341x_mpeg_params enc_cur_state; |
| 350 | struct cx2341x_mpeg_params enc_ctl_state; |
| 351 | /* True if an encoder attribute has changed */ |
| 352 | int enc_stale; |
Mike Isely | 681c739 | 2007-11-26 01:48:52 -0300 | [diff] [blame] | 353 | /* True if an unsafe encoder attribute has changed */ |
| 354 | int enc_unsafe_stale; |
Mike Isely | b30d244 | 2006-06-25 20:05:01 -0300 | [diff] [blame] | 355 | /* True if enc_cur_state is valid */ |
| 356 | int enc_cur_valid; |
Mike Isely | c05c046 | 2006-06-25 20:04:25 -0300 | [diff] [blame] | 357 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 358 | /* Control state */ |
| 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); |
vdb128@picaros.org | e784bfb | 2008-08-30 18:26:39 -0300 | [diff] [blame] | 369 | VCREATE_DATA(cropl); |
| 370 | VCREATE_DATA(cropt); |
| 371 | VCREATE_DATA(cropw); |
| 372 | VCREATE_DATA(croph); |
Mike Isely | c05c046 | 2006-06-25 20:04:25 -0300 | [diff] [blame] | 373 | VCREATE_DATA(input); |
| 374 | VCREATE_DATA(audiomode); |
| 375 | VCREATE_DATA(res_hor); |
| 376 | VCREATE_DATA(res_ver); |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 377 | VCREATE_DATA(srate); |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 378 | #undef VCREATE_DATA |
| 379 | |
Mike Isely | b30d244 | 2006-06-25 20:05:01 -0300 | [diff] [blame] | 380 | struct pvr2_ctld_info *mpeg_ctrl_info; |
Mike Isely | c05c046 | 2006-06-25 20:04:25 -0300 | [diff] [blame] | 381 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 382 | struct pvr2_ctrl *controls; |
Mike Isely | c05c046 | 2006-06-25 20:04:25 -0300 | [diff] [blame] | 383 | unsigned int control_cnt; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 384 | }; |
| 385 | |
Mike Isely | 1bde028 | 2006-12-27 23:30:13 -0300 | [diff] [blame] | 386 | /* This function gets the current frequency */ |
| 387 | unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *); |
| 388 | |
Mike Isely | a51f500 | 2009-03-06 23:30:37 -0300 | [diff] [blame] | 389 | void pvr2_hdw_status_poll(struct pvr2_hdw *); |
| 390 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 391 | #endif /* __PVRUSB2_HDW_INTERNAL_H */ |