18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#ifndef __PVRUSB2_HDW_INTERNAL_H
78c2ecf20Sopenharmony_ci#define __PVRUSB2_HDW_INTERNAL_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/*
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci  This header sets up all the internal structures and definitions needed to
128c2ecf20Sopenharmony_ci  track and coordinate the driver's interaction with the hardware.  ONLY
138c2ecf20Sopenharmony_ci  source files which actually implement part of that whole circus should be
148c2ecf20Sopenharmony_ci  including this header.  Higher levels, like the external layers to the
158c2ecf20Sopenharmony_ci  various public APIs (V4L, sysfs, etc) should NOT ever include this
168c2ecf20Sopenharmony_ci  private, internal header.  This means that pvrusb2-hdw, pvrusb2-encoder,
178c2ecf20Sopenharmony_ci  etc will include this, but pvrusb2-v4l should not.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci*/
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include <linux/videodev2.h>
228c2ecf20Sopenharmony_ci#include <linux/i2c.h>
238c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
248c2ecf20Sopenharmony_ci#include <linux/mutex.h>
258c2ecf20Sopenharmony_ci#include "pvrusb2-hdw.h"
268c2ecf20Sopenharmony_ci#include "pvrusb2-io.h"
278c2ecf20Sopenharmony_ci#include <media/v4l2-device.h>
288c2ecf20Sopenharmony_ci#include <media/drv-intf/cx2341x.h>
298c2ecf20Sopenharmony_ci#include <media/i2c/ir-kbd-i2c.h>
308c2ecf20Sopenharmony_ci#include "pvrusb2-devattr.h"
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* Legal values for PVR2_CID_HSM */
338c2ecf20Sopenharmony_ci#define PVR2_CVAL_HSM_FAIL 0
348c2ecf20Sopenharmony_ci#define PVR2_CVAL_HSM_FULL 1
358c2ecf20Sopenharmony_ci#define PVR2_CVAL_HSM_HIGH 2
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define PVR2_VID_ENDPOINT        0x84
388c2ecf20Sopenharmony_ci#define PVR2_UNK_ENDPOINT        0x86    /* maybe raw yuv ? */
398c2ecf20Sopenharmony_ci#define PVR2_VBI_ENDPOINT        0x88
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define PVR2_CTL_BUFFSIZE        64
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define FREQTABLE_SIZE 500
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define LOCK_TAKE(x) do { mutex_lock(&x##_mutex); x##_held = !0; } while (0)
468c2ecf20Sopenharmony_ci#define LOCK_GIVE(x) do { x##_held = 0; mutex_unlock(&x##_mutex); } while (0)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_citypedef int (*pvr2_ctlf_is_dirty)(struct pvr2_ctrl *);
498c2ecf20Sopenharmony_citypedef void (*pvr2_ctlf_clear_dirty)(struct pvr2_ctrl *);
508c2ecf20Sopenharmony_citypedef int (*pvr2_ctlf_check_value)(struct pvr2_ctrl *,int);
518c2ecf20Sopenharmony_citypedef int (*pvr2_ctlf_get_value)(struct pvr2_ctrl *,int *);
528c2ecf20Sopenharmony_citypedef int (*pvr2_ctlf_set_value)(struct pvr2_ctrl *,int msk,int val);
538c2ecf20Sopenharmony_citypedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val,
548c2ecf20Sopenharmony_ci				    char *,unsigned int,unsigned int *);
558c2ecf20Sopenharmony_citypedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *,
568c2ecf20Sopenharmony_ci				    const char *,unsigned int,
578c2ecf20Sopenharmony_ci				    int *mskp,int *valp);
588c2ecf20Sopenharmony_citypedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *);
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* This structure describes a specific control.  A table of these is set up
618c2ecf20Sopenharmony_ci   in pvrusb2-hdw.c. */
628c2ecf20Sopenharmony_cistruct pvr2_ctl_info {
638c2ecf20Sopenharmony_ci	/* Control's name suitable for use as an identifier */
648c2ecf20Sopenharmony_ci	const char *name;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	/* Short description of control */
678c2ecf20Sopenharmony_ci	const char *desc;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	/* Control's implementation */
708c2ecf20Sopenharmony_ci	pvr2_ctlf_get_value get_value;      /* Get its value */
718c2ecf20Sopenharmony_ci	pvr2_ctlf_get_value get_def_value;  /* Get its default value */
728c2ecf20Sopenharmony_ci	pvr2_ctlf_get_value get_min_value;  /* Get minimum allowed value */
738c2ecf20Sopenharmony_ci	pvr2_ctlf_get_value get_max_value;  /* Get maximum allowed value */
748c2ecf20Sopenharmony_ci	pvr2_ctlf_set_value set_value;      /* Set its value */
758c2ecf20Sopenharmony_ci	pvr2_ctlf_check_value check_value;  /* Check that value is valid */
768c2ecf20Sopenharmony_ci	pvr2_ctlf_val_to_sym val_to_sym;    /* Custom convert value->symbol */
778c2ecf20Sopenharmony_ci	pvr2_ctlf_sym_to_val sym_to_val;    /* Custom convert symbol->value */
788c2ecf20Sopenharmony_ci	pvr2_ctlf_is_dirty is_dirty;        /* Return true if dirty */
798c2ecf20Sopenharmony_ci	pvr2_ctlf_clear_dirty clear_dirty;  /* Clear dirty state */
808c2ecf20Sopenharmony_ci	pvr2_ctlf_get_v4lflags get_v4lflags;/* Retrieve v4l flags */
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	/* Control's type (int, enum, bitmask) */
838c2ecf20Sopenharmony_ci	enum pvr2_ctl_type type;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	/* Associated V4L control ID, if any */
868c2ecf20Sopenharmony_ci	int v4l_id;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	/* Associated driver internal ID, if any */
898c2ecf20Sopenharmony_ci	int internal_id;
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	/* Don't implicitly initialize this control's value */
928c2ecf20Sopenharmony_ci	int skip_init;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	/* Starting value for this control */
958c2ecf20Sopenharmony_ci	int default_value;
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	/* Type-specific control information */
988c2ecf20Sopenharmony_ci	union {
998c2ecf20Sopenharmony_ci		struct { /* Integer control */
1008c2ecf20Sopenharmony_ci			long min_value; /* lower limit */
1018c2ecf20Sopenharmony_ci			long max_value; /* upper limit */
1028c2ecf20Sopenharmony_ci		} type_int;
1038c2ecf20Sopenharmony_ci		struct { /* enumerated control */
1048c2ecf20Sopenharmony_ci			unsigned int count;       /* enum value count */
1058c2ecf20Sopenharmony_ci			const char * const *value_names; /* symbol names */
1068c2ecf20Sopenharmony_ci		} type_enum;
1078c2ecf20Sopenharmony_ci		struct { /* bitmask control */
1088c2ecf20Sopenharmony_ci			unsigned int valid_bits; /* bits in use */
1098c2ecf20Sopenharmony_ci			const char **bit_names;  /* symbol name/bit */
1108c2ecf20Sopenharmony_ci		} type_bitmask;
1118c2ecf20Sopenharmony_ci	} def;
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* Same as pvr2_ctl_info, but includes storage for the control description */
1168c2ecf20Sopenharmony_ci#define PVR2_CTLD_INFO_DESC_SIZE 32
1178c2ecf20Sopenharmony_cistruct pvr2_ctld_info {
1188c2ecf20Sopenharmony_ci	struct pvr2_ctl_info info;
1198c2ecf20Sopenharmony_ci	char desc[PVR2_CTLD_INFO_DESC_SIZE];
1208c2ecf20Sopenharmony_ci};
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_cistruct pvr2_ctrl {
1238c2ecf20Sopenharmony_ci	const struct pvr2_ctl_info *info;
1248c2ecf20Sopenharmony_ci	struct pvr2_hdw *hdw;
1258c2ecf20Sopenharmony_ci};
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci/* Disposition of firmware1 loading situation */
1308c2ecf20Sopenharmony_ci#define FW1_STATE_UNKNOWN 0
1318c2ecf20Sopenharmony_ci#define FW1_STATE_MISSING 1
1328c2ecf20Sopenharmony_ci#define FW1_STATE_FAILED 2
1338c2ecf20Sopenharmony_ci#define FW1_STATE_RELOAD 3
1348c2ecf20Sopenharmony_ci#define FW1_STATE_OK 4
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci/* What state the device is in if it is a hybrid */
1378c2ecf20Sopenharmony_ci#define PVR2_PATHWAY_UNKNOWN 0
1388c2ecf20Sopenharmony_ci#define PVR2_PATHWAY_ANALOG 1
1398c2ecf20Sopenharmony_ci#define PVR2_PATHWAY_DIGITAL 2
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_citypedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16);
1428c2ecf20Sopenharmony_ci#define PVR2_I2C_FUNC_CNT 128
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* This structure contains all state data directly needed to
1458c2ecf20Sopenharmony_ci   manipulate the hardware (as opposed to complying with a kernel
1468c2ecf20Sopenharmony_ci   interface) */
1478c2ecf20Sopenharmony_cistruct pvr2_hdw {
1488c2ecf20Sopenharmony_ci	/* Underlying USB device handle */
1498c2ecf20Sopenharmony_ci	struct usb_device *usb_dev;
1508c2ecf20Sopenharmony_ci	struct usb_interface *usb_intf;
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	/* Our handle into the v4l2 sub-device architecture */
1538c2ecf20Sopenharmony_ci	struct v4l2_device v4l2_dev;
1548c2ecf20Sopenharmony_ci	/* Device description, anything that must adjust behavior based on
1558c2ecf20Sopenharmony_ci	   device specific info will use information held here. */
1568c2ecf20Sopenharmony_ci	const struct pvr2_device_desc *hdw_desc;
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	/* Kernel worker thread handling */
1598c2ecf20Sopenharmony_ci	struct work_struct workpoll;     /* Update driver state */
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	/* Video spigot */
1628c2ecf20Sopenharmony_ci	struct pvr2_stream *vid_stream;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	/* Mutex for all hardware state control */
1658c2ecf20Sopenharmony_ci	struct mutex big_lock_mutex;
1668c2ecf20Sopenharmony_ci	int big_lock_held;  /* For debugging */
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci	/* This is a simple string which identifies the instance of this
1698c2ecf20Sopenharmony_ci	   driver.  It is unique within the set of existing devices, but
1708c2ecf20Sopenharmony_ci	   there is no attempt to keep the name consistent with the same
1718c2ecf20Sopenharmony_ci	   physical device each time. */
1728c2ecf20Sopenharmony_ci	char name[32];
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	/* This is a simple string which identifies the physical device
1758c2ecf20Sopenharmony_ci	   instance itself - if possible.  (If not possible, then it is
1768c2ecf20Sopenharmony_ci	   based on the specific driver instance, similar to name above.)
1778c2ecf20Sopenharmony_ci	   The idea here is that userspace might hopefully be able to use
1788c2ecf20Sopenharmony_ci	   this recognize specific tuners.  It will encode a serial number,
1798c2ecf20Sopenharmony_ci	   if available. */
1808c2ecf20Sopenharmony_ci	char identifier[32];
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	/* I2C stuff */
1838c2ecf20Sopenharmony_ci	struct i2c_adapter i2c_adap;
1848c2ecf20Sopenharmony_ci	struct i2c_algorithm i2c_algo;
1858c2ecf20Sopenharmony_ci	pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT];
1868c2ecf20Sopenharmony_ci	int i2c_cx25840_hack_state;
1878c2ecf20Sopenharmony_ci	int i2c_linked;
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci	/* IR related */
1908c2ecf20Sopenharmony_ci	unsigned int ir_scheme_active; /* IR scheme as seen from the outside */
1918c2ecf20Sopenharmony_ci	struct IR_i2c_init_data ir_init_data; /* params passed to IR modules */
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	/* Frequency table */
1948c2ecf20Sopenharmony_ci	unsigned int freqTable[FREQTABLE_SIZE];
1958c2ecf20Sopenharmony_ci	unsigned int freqProgSlot;
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci	/* Stuff for handling low level control interaction with device */
1988c2ecf20Sopenharmony_ci	struct mutex ctl_lock_mutex;
1998c2ecf20Sopenharmony_ci	int ctl_lock_held;  /* For debugging */
2008c2ecf20Sopenharmony_ci	struct urb *ctl_write_urb;
2018c2ecf20Sopenharmony_ci	struct urb *ctl_read_urb;
2028c2ecf20Sopenharmony_ci	unsigned char *ctl_write_buffer;
2038c2ecf20Sopenharmony_ci	unsigned char *ctl_read_buffer;
2048c2ecf20Sopenharmony_ci	int ctl_write_pend_flag;
2058c2ecf20Sopenharmony_ci	int ctl_read_pend_flag;
2068c2ecf20Sopenharmony_ci	int ctl_timeout_flag;
2078c2ecf20Sopenharmony_ci	struct completion ctl_done;
2088c2ecf20Sopenharmony_ci	unsigned char cmd_buffer[PVR2_CTL_BUFFSIZE];
2098c2ecf20Sopenharmony_ci	int cmd_debug_state;               // Low level command debugging info
2108c2ecf20Sopenharmony_ci	unsigned char cmd_debug_code;      //
2118c2ecf20Sopenharmony_ci	unsigned int cmd_debug_write_len;  //
2128c2ecf20Sopenharmony_ci	unsigned int cmd_debug_read_len;   //
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	/* Bits of state that describe what is going on with various parts
2158c2ecf20Sopenharmony_ci	   of the driver. */
2168c2ecf20Sopenharmony_ci	int state_pathway_ok;         /* Pathway config is ok */
2178c2ecf20Sopenharmony_ci	int state_encoder_ok;         /* Encoder is operational */
2188c2ecf20Sopenharmony_ci	int state_encoder_run;        /* Encoder is running */
2198c2ecf20Sopenharmony_ci	int state_encoder_config;     /* Encoder is configured */
2208c2ecf20Sopenharmony_ci	int state_encoder_waitok;     /* Encoder pre-wait done */
2218c2ecf20Sopenharmony_ci	int state_encoder_runok;      /* Encoder has run for >= .25 sec */
2228c2ecf20Sopenharmony_ci	int state_decoder_run;        /* Decoder is running */
2238c2ecf20Sopenharmony_ci	int state_decoder_ready;      /* Decoder is stabilized & streamable */
2248c2ecf20Sopenharmony_ci	int state_usbstream_run;      /* FX2 is streaming */
2258c2ecf20Sopenharmony_ci	int state_decoder_quiescent;  /* Decoder idle for minimal interval */
2268c2ecf20Sopenharmony_ci	int state_pipeline_config;    /* Pipeline is configured */
2278c2ecf20Sopenharmony_ci	int state_pipeline_req;       /* Somebody wants to stream */
2288c2ecf20Sopenharmony_ci	int state_pipeline_pause;     /* Pipeline must be paused */
2298c2ecf20Sopenharmony_ci	int state_pipeline_idle;      /* Pipeline not running */
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	/* This is the master state of the driver.  It is the combined
2328c2ecf20Sopenharmony_ci	   result of other bits of state.  Examining this will indicate the
2338c2ecf20Sopenharmony_ci	   overall state of the driver.  Values here are one of
2348c2ecf20Sopenharmony_ci	   PVR2_STATE_xxxx */
2358c2ecf20Sopenharmony_ci	unsigned int master_state;
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	/* True if device led is currently on */
2388c2ecf20Sopenharmony_ci	int led_on;
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci	/* True if states must be re-evaluated */
2418c2ecf20Sopenharmony_ci	int state_stale;
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	void (*state_func)(void *);
2448c2ecf20Sopenharmony_ci	void *state_data;
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	/* Timer for measuring required decoder settling time before we're
2478c2ecf20Sopenharmony_ci	   allowed to fire it up again. */
2488c2ecf20Sopenharmony_ci	struct timer_list quiescent_timer;
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	/* Timer for measuring decoder stabilization time, which is the
2518c2ecf20Sopenharmony_ci	   amount of time we need to let the decoder run before we can
2528c2ecf20Sopenharmony_ci	   trust its output (otherwise the encoder might see garbage and
2538c2ecf20Sopenharmony_ci	   then fail to start correctly). */
2548c2ecf20Sopenharmony_ci	struct timer_list decoder_stabilization_timer;
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci	/* Timer for measuring encoder pre-wait time */
2578c2ecf20Sopenharmony_ci	struct timer_list encoder_wait_timer;
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	/* Timer for measuring encoder minimum run time */
2608c2ecf20Sopenharmony_ci	struct timer_list encoder_run_timer;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	/* Place to block while waiting for state changes */
2638c2ecf20Sopenharmony_ci	wait_queue_head_t state_wait_data;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	int force_dirty;        /* consider all controls dirty if true */
2678c2ecf20Sopenharmony_ci	int flag_ok;            /* device in known good state */
2688c2ecf20Sopenharmony_ci	int flag_modulefail;    /* true if at least one module failed to load */
2698c2ecf20Sopenharmony_ci	int flag_disconnected;  /* flag_ok == 0 due to disconnect */
2708c2ecf20Sopenharmony_ci	int flag_init_ok;       /* true if structure is fully initialized */
2718c2ecf20Sopenharmony_ci	int fw1_state;          /* current situation with fw1 */
2728c2ecf20Sopenharmony_ci	int pathway_state;      /* one of PVR2_PATHWAY_xxx */
2738c2ecf20Sopenharmony_ci	int flag_decoder_missed;/* We've noticed missing decoder */
2748c2ecf20Sopenharmony_ci	int flag_tripped;       /* Indicates overall failure to start */
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	unsigned int decoder_client_id;
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci	// CPU firmware info (used to help find / save firmware data)
2798c2ecf20Sopenharmony_ci	char *fw_buffer;
2808c2ecf20Sopenharmony_ci	unsigned int fw_size;
2818c2ecf20Sopenharmony_ci	int fw_cpu_flag; /* True if we are dealing with the CPU */
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	/* Tuner / frequency control stuff */
2848c2ecf20Sopenharmony_ci	unsigned int tuner_type;
2858c2ecf20Sopenharmony_ci	int tuner_updated;
2868c2ecf20Sopenharmony_ci	unsigned int freqValTelevision;  /* Current freq for tv mode */
2878c2ecf20Sopenharmony_ci	unsigned int freqValRadio;       /* Current freq for radio mode */
2888c2ecf20Sopenharmony_ci	unsigned int freqSlotTelevision; /* Current slot for tv mode */
2898c2ecf20Sopenharmony_ci	unsigned int freqSlotRadio;      /* Current slot for radio mode */
2908c2ecf20Sopenharmony_ci	unsigned int freqSelector;       /* 0=radio 1=television */
2918c2ecf20Sopenharmony_ci	int freqDirty;
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	/* Current tuner info - this information is polled from the I2C bus */
2948c2ecf20Sopenharmony_ci	struct v4l2_tuner tuner_signal_info;
2958c2ecf20Sopenharmony_ci	int tuner_signal_stale;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	/* Cropping capability info */
2988c2ecf20Sopenharmony_ci	struct v4l2_cropcap cropcap_info;
2998c2ecf20Sopenharmony_ci	int cropcap_stale;
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	/* Video standard handling */
3028c2ecf20Sopenharmony_ci	v4l2_std_id std_mask_eeprom; // Hardware supported selections
3038c2ecf20Sopenharmony_ci	v4l2_std_id std_mask_avail;  // Which standards we may select from
3048c2ecf20Sopenharmony_ci	v4l2_std_id std_mask_cur;    // Currently selected standard(s)
3058c2ecf20Sopenharmony_ci	int std_enum_cur;            // selected standard enumeration value
3068c2ecf20Sopenharmony_ci	int std_dirty;               // True if std_mask_cur has changed
3078c2ecf20Sopenharmony_ci	struct pvr2_ctl_info std_info_enum;
3088c2ecf20Sopenharmony_ci	struct pvr2_ctl_info std_info_avail;
3098c2ecf20Sopenharmony_ci	struct pvr2_ctl_info std_info_cur;
3108c2ecf20Sopenharmony_ci	struct pvr2_ctl_info std_info_detect;
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	// Generated string names, one per actual V4L2 standard
3138c2ecf20Sopenharmony_ci	const char *std_mask_ptrs[32];
3148c2ecf20Sopenharmony_ci	char std_mask_names[32][16];
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	int unit_number;             /* ID for driver instance */
3178c2ecf20Sopenharmony_ci	unsigned long serial_number; /* ID for hardware itself */
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	char bus_info[32]; /* Bus location info */
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	/* Minor numbers used by v4l logic (yes, this is a hack, as there
3228c2ecf20Sopenharmony_ci	   should be no v4l junk here).  Probably a better way to do this. */
3238c2ecf20Sopenharmony_ci	int v4l_minor_number_video;
3248c2ecf20Sopenharmony_ci	int v4l_minor_number_vbi;
3258c2ecf20Sopenharmony_ci	int v4l_minor_number_radio;
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci	/* Bit mask of PVR2_CVAL_INPUT choices which are valid for the hardware */
3288c2ecf20Sopenharmony_ci	unsigned int input_avail_mask;
3298c2ecf20Sopenharmony_ci	/* Bit mask of PVR2_CVAL_INPUT choices which are currently allowed */
3308c2ecf20Sopenharmony_ci	unsigned int input_allowed_mask;
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci	/* Location of eeprom or a negative number if none */
3338c2ecf20Sopenharmony_ci	int eeprom_addr;
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci	enum pvr2_config active_stream_type;
3368c2ecf20Sopenharmony_ci	enum pvr2_config desired_stream_type;
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci	/* Control state needed for cx2341x module */
3398c2ecf20Sopenharmony_ci	struct cx2341x_mpeg_params enc_cur_state;
3408c2ecf20Sopenharmony_ci	struct cx2341x_mpeg_params enc_ctl_state;
3418c2ecf20Sopenharmony_ci	/* True if an encoder attribute has changed */
3428c2ecf20Sopenharmony_ci	int enc_stale;
3438c2ecf20Sopenharmony_ci	/* True if an unsafe encoder attribute has changed */
3448c2ecf20Sopenharmony_ci	int enc_unsafe_stale;
3458c2ecf20Sopenharmony_ci	/* True if enc_cur_state is valid */
3468c2ecf20Sopenharmony_ci	int enc_cur_valid;
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci	/* Control state */
3498c2ecf20Sopenharmony_ci#define VCREATE_DATA(lab) int lab##_val; int lab##_dirty
3508c2ecf20Sopenharmony_ci	VCREATE_DATA(brightness);
3518c2ecf20Sopenharmony_ci	VCREATE_DATA(contrast);
3528c2ecf20Sopenharmony_ci	VCREATE_DATA(saturation);
3538c2ecf20Sopenharmony_ci	VCREATE_DATA(hue);
3548c2ecf20Sopenharmony_ci	VCREATE_DATA(volume);
3558c2ecf20Sopenharmony_ci	VCREATE_DATA(balance);
3568c2ecf20Sopenharmony_ci	VCREATE_DATA(bass);
3578c2ecf20Sopenharmony_ci	VCREATE_DATA(treble);
3588c2ecf20Sopenharmony_ci	VCREATE_DATA(mute);
3598c2ecf20Sopenharmony_ci	VCREATE_DATA(cropl);
3608c2ecf20Sopenharmony_ci	VCREATE_DATA(cropt);
3618c2ecf20Sopenharmony_ci	VCREATE_DATA(cropw);
3628c2ecf20Sopenharmony_ci	VCREATE_DATA(croph);
3638c2ecf20Sopenharmony_ci	VCREATE_DATA(input);
3648c2ecf20Sopenharmony_ci	VCREATE_DATA(audiomode);
3658c2ecf20Sopenharmony_ci	VCREATE_DATA(res_hor);
3668c2ecf20Sopenharmony_ci	VCREATE_DATA(res_ver);
3678c2ecf20Sopenharmony_ci	VCREATE_DATA(srate);
3688c2ecf20Sopenharmony_ci#undef VCREATE_DATA
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	struct pvr2_ctld_info *mpeg_ctrl_info;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	struct pvr2_ctrl *controls;
3738c2ecf20Sopenharmony_ci	unsigned int control_cnt;
3748c2ecf20Sopenharmony_ci};
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci/* This function gets the current frequency */
3778c2ecf20Sopenharmony_ciunsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *);
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_civoid pvr2_hdw_status_poll(struct pvr2_hdw *);
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci#endif /* __PVRUSB2_HDW_INTERNAL_H */
382