162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef __PVRUSB2_HDW_INTERNAL_H
762306a36Sopenharmony_ci#define __PVRUSB2_HDW_INTERNAL_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/*
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci  This header sets up all the internal structures and definitions needed to
1262306a36Sopenharmony_ci  track and coordinate the driver's interaction with the hardware.  ONLY
1362306a36Sopenharmony_ci  source files which actually implement part of that whole circus should be
1462306a36Sopenharmony_ci  including this header.  Higher levels, like the external layers to the
1562306a36Sopenharmony_ci  various public APIs (V4L, sysfs, etc) should NOT ever include this
1662306a36Sopenharmony_ci  private, internal header.  This means that pvrusb2-hdw, pvrusb2-encoder,
1762306a36Sopenharmony_ci  etc will include this, but pvrusb2-v4l should not.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci*/
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#include <linux/videodev2.h>
2262306a36Sopenharmony_ci#include <linux/i2c.h>
2362306a36Sopenharmony_ci#include <linux/workqueue.h>
2462306a36Sopenharmony_ci#include <linux/mutex.h>
2562306a36Sopenharmony_ci#include "pvrusb2-hdw.h"
2662306a36Sopenharmony_ci#include "pvrusb2-io.h"
2762306a36Sopenharmony_ci#include <media/v4l2-device.h>
2862306a36Sopenharmony_ci#include <media/drv-intf/cx2341x.h>
2962306a36Sopenharmony_ci#include <media/i2c/ir-kbd-i2c.h>
3062306a36Sopenharmony_ci#include "pvrusb2-devattr.h"
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* Legal values for PVR2_CID_HSM */
3362306a36Sopenharmony_ci#define PVR2_CVAL_HSM_FAIL 0
3462306a36Sopenharmony_ci#define PVR2_CVAL_HSM_FULL 1
3562306a36Sopenharmony_ci#define PVR2_CVAL_HSM_HIGH 2
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define PVR2_VID_ENDPOINT        0x84
3862306a36Sopenharmony_ci#define PVR2_UNK_ENDPOINT        0x86    /* maybe raw yuv ? */
3962306a36Sopenharmony_ci#define PVR2_VBI_ENDPOINT        0x88
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define PVR2_CTL_BUFFSIZE        64
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define FREQTABLE_SIZE 500
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define LOCK_TAKE(x) do { mutex_lock(&x##_mutex); x##_held = !0; } while (0)
4662306a36Sopenharmony_ci#define LOCK_GIVE(x) do { x##_held = 0; mutex_unlock(&x##_mutex); } while (0)
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_citypedef int (*pvr2_ctlf_is_dirty)(struct pvr2_ctrl *);
4962306a36Sopenharmony_citypedef void (*pvr2_ctlf_clear_dirty)(struct pvr2_ctrl *);
5062306a36Sopenharmony_citypedef int (*pvr2_ctlf_check_value)(struct pvr2_ctrl *,int);
5162306a36Sopenharmony_citypedef int (*pvr2_ctlf_get_value)(struct pvr2_ctrl *,int *);
5262306a36Sopenharmony_citypedef int (*pvr2_ctlf_set_value)(struct pvr2_ctrl *,int msk,int val);
5362306a36Sopenharmony_citypedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val,
5462306a36Sopenharmony_ci				    char *,unsigned int,unsigned int *);
5562306a36Sopenharmony_citypedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *,
5662306a36Sopenharmony_ci				    const char *,unsigned int,
5762306a36Sopenharmony_ci				    int *mskp,int *valp);
5862306a36Sopenharmony_citypedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *);
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/* This structure describes a specific control.  A table of these is set up
6162306a36Sopenharmony_ci   in pvrusb2-hdw.c. */
6262306a36Sopenharmony_cistruct pvr2_ctl_info {
6362306a36Sopenharmony_ci	/* Control's name suitable for use as an identifier */
6462306a36Sopenharmony_ci	const char *name;
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci	/* Short description of control */
6762306a36Sopenharmony_ci	const char *desc;
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci	/* Control's implementation */
7062306a36Sopenharmony_ci	pvr2_ctlf_get_value get_value;      /* Get its value */
7162306a36Sopenharmony_ci	pvr2_ctlf_get_value get_def_value;  /* Get its default value */
7262306a36Sopenharmony_ci	pvr2_ctlf_get_value get_min_value;  /* Get minimum allowed value */
7362306a36Sopenharmony_ci	pvr2_ctlf_get_value get_max_value;  /* Get maximum allowed value */
7462306a36Sopenharmony_ci	pvr2_ctlf_set_value set_value;      /* Set its value */
7562306a36Sopenharmony_ci	pvr2_ctlf_check_value check_value;  /* Check that value is valid */
7662306a36Sopenharmony_ci	pvr2_ctlf_val_to_sym val_to_sym;    /* Custom convert value->symbol */
7762306a36Sopenharmony_ci	pvr2_ctlf_sym_to_val sym_to_val;    /* Custom convert symbol->value */
7862306a36Sopenharmony_ci	pvr2_ctlf_is_dirty is_dirty;        /* Return true if dirty */
7962306a36Sopenharmony_ci	pvr2_ctlf_clear_dirty clear_dirty;  /* Clear dirty state */
8062306a36Sopenharmony_ci	pvr2_ctlf_get_v4lflags get_v4lflags;/* Retrieve v4l flags */
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci	/* Control's type (int, enum, bitmask) */
8362306a36Sopenharmony_ci	enum pvr2_ctl_type type;
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci	/* Associated V4L control ID, if any */
8662306a36Sopenharmony_ci	int v4l_id;
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci	/* Associated driver internal ID, if any */
8962306a36Sopenharmony_ci	int internal_id;
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci	/* Don't implicitly initialize this control's value */
9262306a36Sopenharmony_ci	int skip_init;
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	/* Starting value for this control */
9562306a36Sopenharmony_ci	int default_value;
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci	/* Type-specific control information */
9862306a36Sopenharmony_ci	union {
9962306a36Sopenharmony_ci		struct { /* Integer control */
10062306a36Sopenharmony_ci			long min_value; /* lower limit */
10162306a36Sopenharmony_ci			long max_value; /* upper limit */
10262306a36Sopenharmony_ci		} type_int;
10362306a36Sopenharmony_ci		struct { /* enumerated control */
10462306a36Sopenharmony_ci			unsigned int count;       /* enum value count */
10562306a36Sopenharmony_ci			const char * const *value_names; /* symbol names */
10662306a36Sopenharmony_ci		} type_enum;
10762306a36Sopenharmony_ci		struct { /* bitmask control */
10862306a36Sopenharmony_ci			unsigned int valid_bits; /* bits in use */
10962306a36Sopenharmony_ci			const char **bit_names;  /* symbol name/bit */
11062306a36Sopenharmony_ci		} type_bitmask;
11162306a36Sopenharmony_ci	} def;
11262306a36Sopenharmony_ci};
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/* Same as pvr2_ctl_info, but includes storage for the control description */
11662306a36Sopenharmony_ci#define PVR2_CTLD_INFO_DESC_SIZE 32
11762306a36Sopenharmony_cistruct pvr2_ctld_info {
11862306a36Sopenharmony_ci	struct pvr2_ctl_info info;
11962306a36Sopenharmony_ci	char desc[PVR2_CTLD_INFO_DESC_SIZE];
12062306a36Sopenharmony_ci};
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_cistruct pvr2_ctrl {
12362306a36Sopenharmony_ci	const struct pvr2_ctl_info *info;
12462306a36Sopenharmony_ci	struct pvr2_hdw *hdw;
12562306a36Sopenharmony_ci};
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci/* Disposition of firmware1 loading situation */
13062306a36Sopenharmony_ci#define FW1_STATE_UNKNOWN 0
13162306a36Sopenharmony_ci#define FW1_STATE_MISSING 1
13262306a36Sopenharmony_ci#define FW1_STATE_FAILED 2
13362306a36Sopenharmony_ci#define FW1_STATE_RELOAD 3
13462306a36Sopenharmony_ci#define FW1_STATE_OK 4
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci/* What state the device is in if it is a hybrid */
13762306a36Sopenharmony_ci#define PVR2_PATHWAY_UNKNOWN 0
13862306a36Sopenharmony_ci#define PVR2_PATHWAY_ANALOG 1
13962306a36Sopenharmony_ci#define PVR2_PATHWAY_DIGITAL 2
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_citypedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16);
14262306a36Sopenharmony_ci#define PVR2_I2C_FUNC_CNT 128
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci/* This structure contains all state data directly needed to
14562306a36Sopenharmony_ci   manipulate the hardware (as opposed to complying with a kernel
14662306a36Sopenharmony_ci   interface) */
14762306a36Sopenharmony_cistruct pvr2_hdw {
14862306a36Sopenharmony_ci	/* Underlying USB device handle */
14962306a36Sopenharmony_ci	struct usb_device *usb_dev;
15062306a36Sopenharmony_ci	struct usb_interface *usb_intf;
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci	/* Our handle into the v4l2 sub-device architecture */
15362306a36Sopenharmony_ci	struct v4l2_device v4l2_dev;
15462306a36Sopenharmony_ci	/* Device description, anything that must adjust behavior based on
15562306a36Sopenharmony_ci	   device specific info will use information held here. */
15662306a36Sopenharmony_ci	const struct pvr2_device_desc *hdw_desc;
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci	/* Kernel worker thread handling */
15962306a36Sopenharmony_ci	struct work_struct workpoll;     /* Update driver state */
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci	/* Video spigot */
16262306a36Sopenharmony_ci	struct pvr2_stream *vid_stream;
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ci	/* Mutex for all hardware state control */
16562306a36Sopenharmony_ci	struct mutex big_lock_mutex;
16662306a36Sopenharmony_ci	int big_lock_held;  /* For debugging */
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci	/* This is a simple string which identifies the instance of this
16962306a36Sopenharmony_ci	   driver.  It is unique within the set of existing devices, but
17062306a36Sopenharmony_ci	   there is no attempt to keep the name consistent with the same
17162306a36Sopenharmony_ci	   physical device each time. */
17262306a36Sopenharmony_ci	char name[32];
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci	/* This is a simple string which identifies the physical device
17562306a36Sopenharmony_ci	   instance itself - if possible.  (If not possible, then it is
17662306a36Sopenharmony_ci	   based on the specific driver instance, similar to name above.)
17762306a36Sopenharmony_ci	   The idea here is that userspace might hopefully be able to use
17862306a36Sopenharmony_ci	   this recognize specific tuners.  It will encode a serial number,
17962306a36Sopenharmony_ci	   if available. */
18062306a36Sopenharmony_ci	char identifier[32];
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci	/* I2C stuff */
18362306a36Sopenharmony_ci	struct i2c_adapter i2c_adap;
18462306a36Sopenharmony_ci	struct i2c_algorithm i2c_algo;
18562306a36Sopenharmony_ci	pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT];
18662306a36Sopenharmony_ci	int i2c_cx25840_hack_state;
18762306a36Sopenharmony_ci	int i2c_linked;
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci	/* IR related */
19062306a36Sopenharmony_ci	unsigned int ir_scheme_active; /* IR scheme as seen from the outside */
19162306a36Sopenharmony_ci	struct IR_i2c_init_data ir_init_data; /* params passed to IR modules */
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci	/* Frequency table */
19462306a36Sopenharmony_ci	unsigned int freqTable[FREQTABLE_SIZE];
19562306a36Sopenharmony_ci	unsigned int freqProgSlot;
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci	/* Stuff for handling low level control interaction with device */
19862306a36Sopenharmony_ci	struct mutex ctl_lock_mutex;
19962306a36Sopenharmony_ci	int ctl_lock_held;  /* For debugging */
20062306a36Sopenharmony_ci	struct urb *ctl_write_urb;
20162306a36Sopenharmony_ci	struct urb *ctl_read_urb;
20262306a36Sopenharmony_ci	unsigned char *ctl_write_buffer;
20362306a36Sopenharmony_ci	unsigned char *ctl_read_buffer;
20462306a36Sopenharmony_ci	int ctl_write_pend_flag;
20562306a36Sopenharmony_ci	int ctl_read_pend_flag;
20662306a36Sopenharmony_ci	int ctl_timeout_flag;
20762306a36Sopenharmony_ci	struct completion ctl_done;
20862306a36Sopenharmony_ci	unsigned char cmd_buffer[PVR2_CTL_BUFFSIZE];
20962306a36Sopenharmony_ci	int cmd_debug_state;               // Low level command debugging info
21062306a36Sopenharmony_ci	unsigned char cmd_debug_code;      //
21162306a36Sopenharmony_ci	unsigned int cmd_debug_write_len;  //
21262306a36Sopenharmony_ci	unsigned int cmd_debug_read_len;   //
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci	/* Bits of state that describe what is going on with various parts
21562306a36Sopenharmony_ci	   of the driver. */
21662306a36Sopenharmony_ci	int state_pathway_ok;         /* Pathway config is ok */
21762306a36Sopenharmony_ci	int state_encoder_ok;         /* Encoder is operational */
21862306a36Sopenharmony_ci	int state_encoder_run;        /* Encoder is running */
21962306a36Sopenharmony_ci	int state_encoder_config;     /* Encoder is configured */
22062306a36Sopenharmony_ci	int state_encoder_waitok;     /* Encoder pre-wait done */
22162306a36Sopenharmony_ci	int state_encoder_runok;      /* Encoder has run for >= .25 sec */
22262306a36Sopenharmony_ci	int state_decoder_run;        /* Decoder is running */
22362306a36Sopenharmony_ci	int state_decoder_ready;      /* Decoder is stabilized & streamable */
22462306a36Sopenharmony_ci	int state_usbstream_run;      /* FX2 is streaming */
22562306a36Sopenharmony_ci	int state_decoder_quiescent;  /* Decoder idle for minimal interval */
22662306a36Sopenharmony_ci	int state_pipeline_config;    /* Pipeline is configured */
22762306a36Sopenharmony_ci	int state_pipeline_req;       /* Somebody wants to stream */
22862306a36Sopenharmony_ci	int state_pipeline_pause;     /* Pipeline must be paused */
22962306a36Sopenharmony_ci	int state_pipeline_idle;      /* Pipeline not running */
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci	/* This is the master state of the driver.  It is the combined
23262306a36Sopenharmony_ci	   result of other bits of state.  Examining this will indicate the
23362306a36Sopenharmony_ci	   overall state of the driver.  Values here are one of
23462306a36Sopenharmony_ci	   PVR2_STATE_xxxx */
23562306a36Sopenharmony_ci	unsigned int master_state;
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci	/* True if device led is currently on */
23862306a36Sopenharmony_ci	int led_on;
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci	/* True if states must be re-evaluated */
24162306a36Sopenharmony_ci	int state_stale;
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci	void (*state_func)(void *);
24462306a36Sopenharmony_ci	void *state_data;
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ci	/* Timer for measuring required decoder settling time before we're
24762306a36Sopenharmony_ci	   allowed to fire it up again. */
24862306a36Sopenharmony_ci	struct timer_list quiescent_timer;
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci	/* Timer for measuring decoder stabilization time, which is the
25162306a36Sopenharmony_ci	   amount of time we need to let the decoder run before we can
25262306a36Sopenharmony_ci	   trust its output (otherwise the encoder might see garbage and
25362306a36Sopenharmony_ci	   then fail to start correctly). */
25462306a36Sopenharmony_ci	struct timer_list decoder_stabilization_timer;
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci	/* Timer for measuring encoder pre-wait time */
25762306a36Sopenharmony_ci	struct timer_list encoder_wait_timer;
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci	/* Timer for measuring encoder minimum run time */
26062306a36Sopenharmony_ci	struct timer_list encoder_run_timer;
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	/* Place to block while waiting for state changes */
26362306a36Sopenharmony_ci	wait_queue_head_t state_wait_data;
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_ci	int force_dirty;        /* consider all controls dirty if true */
26762306a36Sopenharmony_ci	int flag_ok;            /* device in known good state */
26862306a36Sopenharmony_ci	int flag_modulefail;    /* true if at least one module failed to load */
26962306a36Sopenharmony_ci	int flag_disconnected;  /* flag_ok == 0 due to disconnect */
27062306a36Sopenharmony_ci	int flag_init_ok;       /* true if structure is fully initialized */
27162306a36Sopenharmony_ci	int fw1_state;          /* current situation with fw1 */
27262306a36Sopenharmony_ci	int pathway_state;      /* one of PVR2_PATHWAY_xxx */
27362306a36Sopenharmony_ci	int flag_decoder_missed;/* We've noticed missing decoder */
27462306a36Sopenharmony_ci	int flag_tripped;       /* Indicates overall failure to start */
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci	unsigned int decoder_client_id;
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_ci	// CPU firmware info (used to help find / save firmware data)
27962306a36Sopenharmony_ci	char *fw_buffer;
28062306a36Sopenharmony_ci	unsigned int fw_size;
28162306a36Sopenharmony_ci	int fw_cpu_flag; /* True if we are dealing with the CPU */
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci	/* Tuner / frequency control stuff */
28462306a36Sopenharmony_ci	unsigned int tuner_type;
28562306a36Sopenharmony_ci	int tuner_updated;
28662306a36Sopenharmony_ci	unsigned int freqValTelevision;  /* Current freq for tv mode */
28762306a36Sopenharmony_ci	unsigned int freqValRadio;       /* Current freq for radio mode */
28862306a36Sopenharmony_ci	unsigned int freqSlotTelevision; /* Current slot for tv mode */
28962306a36Sopenharmony_ci	unsigned int freqSlotRadio;      /* Current slot for radio mode */
29062306a36Sopenharmony_ci	unsigned int freqSelector;       /* 0=radio 1=television */
29162306a36Sopenharmony_ci	int freqDirty;
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ci	/* Current tuner info - this information is polled from the I2C bus */
29462306a36Sopenharmony_ci	struct v4l2_tuner tuner_signal_info;
29562306a36Sopenharmony_ci	int tuner_signal_stale;
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci	/* Cropping capability info */
29862306a36Sopenharmony_ci	struct v4l2_cropcap cropcap_info;
29962306a36Sopenharmony_ci	int cropcap_stale;
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci	/* Video standard handling */
30262306a36Sopenharmony_ci	v4l2_std_id std_mask_eeprom; // Hardware supported selections
30362306a36Sopenharmony_ci	v4l2_std_id std_mask_avail;  // Which standards we may select from
30462306a36Sopenharmony_ci	v4l2_std_id std_mask_cur;    // Currently selected standard(s)
30562306a36Sopenharmony_ci	int std_enum_cur;            // selected standard enumeration value
30662306a36Sopenharmony_ci	int std_dirty;               // True if std_mask_cur has changed
30762306a36Sopenharmony_ci	struct pvr2_ctl_info std_info_enum;
30862306a36Sopenharmony_ci	struct pvr2_ctl_info std_info_avail;
30962306a36Sopenharmony_ci	struct pvr2_ctl_info std_info_cur;
31062306a36Sopenharmony_ci	struct pvr2_ctl_info std_info_detect;
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci	// Generated string names, one per actual V4L2 standard
31362306a36Sopenharmony_ci	const char *std_mask_ptrs[32];
31462306a36Sopenharmony_ci	char std_mask_names[32][16];
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ci	int unit_number;             /* ID for driver instance */
31762306a36Sopenharmony_ci	unsigned long serial_number; /* ID for hardware itself */
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci	char bus_info[32]; /* Bus location info */
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci	/* Minor numbers used by v4l logic (yes, this is a hack, as there
32262306a36Sopenharmony_ci	   should be no v4l junk here).  Probably a better way to do this. */
32362306a36Sopenharmony_ci	int v4l_minor_number_video;
32462306a36Sopenharmony_ci	int v4l_minor_number_vbi;
32562306a36Sopenharmony_ci	int v4l_minor_number_radio;
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ci	/* Bit mask of PVR2_CVAL_INPUT choices which are valid for the hardware */
32862306a36Sopenharmony_ci	unsigned int input_avail_mask;
32962306a36Sopenharmony_ci	/* Bit mask of PVR2_CVAL_INPUT choices which are currently allowed */
33062306a36Sopenharmony_ci	unsigned int input_allowed_mask;
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci	/* Location of eeprom or a negative number if none */
33362306a36Sopenharmony_ci	int eeprom_addr;
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci	enum pvr2_config active_stream_type;
33662306a36Sopenharmony_ci	enum pvr2_config desired_stream_type;
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci	/* Control state needed for cx2341x module */
33962306a36Sopenharmony_ci	struct cx2341x_mpeg_params enc_cur_state;
34062306a36Sopenharmony_ci	struct cx2341x_mpeg_params enc_ctl_state;
34162306a36Sopenharmony_ci	/* True if an encoder attribute has changed */
34262306a36Sopenharmony_ci	int enc_stale;
34362306a36Sopenharmony_ci	/* True if an unsafe encoder attribute has changed */
34462306a36Sopenharmony_ci	int enc_unsafe_stale;
34562306a36Sopenharmony_ci	/* True if enc_cur_state is valid */
34662306a36Sopenharmony_ci	int enc_cur_valid;
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ci	/* Control state */
34962306a36Sopenharmony_ci#define VCREATE_DATA(lab) int lab##_val; int lab##_dirty
35062306a36Sopenharmony_ci	VCREATE_DATA(brightness);
35162306a36Sopenharmony_ci	VCREATE_DATA(contrast);
35262306a36Sopenharmony_ci	VCREATE_DATA(saturation);
35362306a36Sopenharmony_ci	VCREATE_DATA(hue);
35462306a36Sopenharmony_ci	VCREATE_DATA(volume);
35562306a36Sopenharmony_ci	VCREATE_DATA(balance);
35662306a36Sopenharmony_ci	VCREATE_DATA(bass);
35762306a36Sopenharmony_ci	VCREATE_DATA(treble);
35862306a36Sopenharmony_ci	VCREATE_DATA(mute);
35962306a36Sopenharmony_ci	VCREATE_DATA(cropl);
36062306a36Sopenharmony_ci	VCREATE_DATA(cropt);
36162306a36Sopenharmony_ci	VCREATE_DATA(cropw);
36262306a36Sopenharmony_ci	VCREATE_DATA(croph);
36362306a36Sopenharmony_ci	VCREATE_DATA(input);
36462306a36Sopenharmony_ci	VCREATE_DATA(audiomode);
36562306a36Sopenharmony_ci	VCREATE_DATA(res_hor);
36662306a36Sopenharmony_ci	VCREATE_DATA(res_ver);
36762306a36Sopenharmony_ci	VCREATE_DATA(srate);
36862306a36Sopenharmony_ci#undef VCREATE_DATA
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_ci	struct pvr2_ctld_info *mpeg_ctrl_info;
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ci	struct pvr2_ctrl *controls;
37362306a36Sopenharmony_ci	unsigned int control_cnt;
37462306a36Sopenharmony_ci};
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci/* This function gets the current frequency */
37762306a36Sopenharmony_ciunsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *);
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_civoid pvr2_hdw_status_poll(struct pvr2_hdw *);
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci#endif /* __PVRUSB2_HDW_INTERNAL_H */
382