diff options
Diffstat (limited to 'linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h')
-rw-r--r-- | linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | 205 |
1 files changed, 121 insertions, 84 deletions
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h index 9c5f0f74c..63e2299cb 100644 --- a/linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h +++ b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h @@ -34,60 +34,21 @@ */ #include "compat.h" +#include <linux/config.h> #include <linux/videodev2.h> #include <linux/i2c.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -#include <asm/atomic.h> -#include <asm/mutex.h> +#include <linux/mutex.h> #else #include <asm/semaphore.h> #endif #include "pvrusb2-hdw.h" #include "pvrusb2-io.h" - - -/* Definition of state variables that we can inspect & change. Numbers are - assigned from zero counting up with no gaps. */ -#define PVR2_CID_BRIGHTNESS 0 -#define PVR2_CID_CONTRAST 1 -#define PVR2_CID_SATURATION 2 -#define PVR2_CID_HUE 3 -#define PVR2_CID_VOLUME 4 -#define PVR2_CID_BALANCE 5 -#define PVR2_CID_BASS 6 -#define PVR2_CID_TREBLE 7 -#define PVR2_CID_MUTE 8 -#define PVR2_CID_SRATE 9 -#define PVR2_CID_AUDIOBITRATE 10 -#define PVR2_CID_AUDIOCRC 11 -#define PVR2_CID_AUDIOEMPHASIS 12 -#define PVR2_CID_VBR 13 -#define PVR2_CID_AVERAGEVIDEOBITRATE 14 -#define PVR2_CID_PEAKVIDEOBITRATE 15 -#define PVR2_CID_STDAVAIL 16 // V4L2 video standard bit mask -#define PVR2_CID_INPUT 17 -#define PVR2_CID_AUDIOMODE 18 // V4L2 standard audio mode enum -#define PVR2_CID_FREQUENCY 19 // Units of Hz -#define PVR2_CID_HRES 20 -#define PVR2_CID_VRES 21 -#define PVR2_CID_INTERLACE 22 -#define PVR2_CID_AUDIOLAYER 23 -#define PVR2_CID_CHANNEL 24 -#define PVR2_CID_CHANPROG_ID 25 -#define PVR2_CID_CHANPROG_FREQ 26 -#define PVR2_CID_SIGNAL_PRESENT 27 -#define PVR2_CID_STREAMING_ENABLED 28 -#define PVR2_CID_HSM 29 -#define PVR2_CID_SUBSYS_MASK 30 -#define PVR2_CID_SUBSYS_STREAM_MASK 31 -#define PVR2_CID_STDCUR 32 // V4L2 video standard bit mask -#define PVR2_CID_STDNAME 33 // Enumeration of available standards +#include <media/cx2341x.h> /* Legal values for the SRATE state variable */ #define PVR2_CVAL_SRATE_48 0 #define PVR2_CVAL_SRATE_44_1 1 -#define PVR2_CVAL_SRATE_MIN PVR2_CVAL_SRATE_48 -#define PVR2_CVAL_SRATE_MAX PVR2_CVAL_SRATE_44_1 /* Legal values for the AUDIOBITRATE state variable */ #define PVR2_CVAL_AUDIOBITRATE_384 0 @@ -105,22 +66,16 @@ #define PVR2_CVAL_AUDIOBITRATE_48 12 #define PVR2_CVAL_AUDIOBITRATE_32 13 #define PVR2_CVAL_AUDIOBITRATE_VBR 14 -#define PVR2_CVAL_AUDIOBITRATE_MIN PVR2_CVAL_AUDIOBITRATE_384 -#define PVR2_CVAL_AUDIOBITRATE_MAX PVR2_CVAL_AUDIOBITRATE_VBR /* Legal values for the AUDIOEMPHASIS state variable */ #define PVR2_CVAL_AUDIOEMPHASIS_NONE 0 #define PVR2_CVAL_AUDIOEMPHASIS_50_15 1 #define PVR2_CVAL_AUDIOEMPHASIS_CCITT 2 -#define PVR2_CVAL_AUDIOEMPHASIS_MIN PVR2_CVAL_AUDIOEMPHASIS_NONE -#define PVR2_CVAL_AUDIOEMPHASIS_MAX PVR2_CVAL_AUDIOEMPHASIS_CCITT /* Legal values for PVR2_CID_HSM */ #define PVR2_CVAL_HSM_FAIL 0 #define PVR2_CVAL_HSM_FULL 1 #define PVR2_CVAL_HSM_HIGH 2 -#define PVR2_CVAL_HSM_MIN PVR2_CVAL_HSM_FAIL -#define PVR2_CVAL_HSM_MAX PVR2_CVAL_HSM_HIGH #define PVR2_VID_ENDPOINT 0x84 #define PVR2_UNK_ENDPOINT 0x86 /* maybe raw yuv ? */ @@ -135,37 +90,81 @@ struct pvr2_decoder; -struct pvr2_ctl_def; -struct pvr2_ctrl; - -typedef int (*pvr2_ctl_set_func)(struct pvr2_ctrl *,int val); -typedef int (*pvr2_ctl_get_func)(struct pvr2_ctrl *); - -struct pvr2_ctl_def { - int id; +typedef int (*pvr2_ctlf_is_dirty)(struct pvr2_ctrl *); +typedef void (*pvr2_ctlf_clear_dirty)(struct pvr2_ctrl *); +typedef int (*pvr2_ctlf_get_value)(struct pvr2_ctrl *,int *); +typedef int (*pvr2_ctlf_set_value)(struct pvr2_ctrl *,int msk,int val); +typedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val, + char *,unsigned int,unsigned int *); +typedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *, + const char *,unsigned int, + int *mskp,int *valp); +typedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *); + +/* This structure describes a specific control. A table of these is set up + in pvrusb2-hdw.c. */ +struct pvr2_ctl_info { + /* Control's name suitable for use as an identifier */ const char *name; + + /* Short description of control */ const char *desc; - pvr2_ctl_set_func set_func; - pvr2_ctl_get_func get_func; - int mask_value; - int max_value; - int min_value; + + /* Control's implementation */ + pvr2_ctlf_get_value get_value; /* Get its value */ + pvr2_ctlf_set_value set_value; /* Set its value */ + pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */ + pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */ + pvr2_ctlf_is_dirty is_dirty; /* Return true if dirty */ + pvr2_ctlf_clear_dirty clear_dirty; /* Clear dirty state */ + pvr2_ctlf_get_v4lflags get_v4lflags;/* Retrieve v4l flags */ + + /* Control's type (int, enum, bitmask) */ + enum pvr2_ctl_type type; + + /* Associated V4L control ID, if any */ + int v4l_id; + + /* Associated driver internal ID, if any */ + int internal_id; + + /* Don't implicitly initialize this control's value */ int skip_init; + + /* Starting value for this control */ int default_value; - int is_valid; - const char **value_defs_ptr; - unsigned int value_defs_count; + + /* Type-specific control information */ + union { + struct { /* Integer control */ + long min_value; /* lower limit */ + long max_value; /* upper limit */ + } type_int; + struct { /* enumerated control */ + unsigned int count; /* enum value count */ + const char **value_names; /* symbol names */ + } type_enum; + struct { /* bitmask control */ + unsigned int valid_bits; /* bits in use */ + const char **bit_names; /* symbol name/bit */ + } type_bitmask; + } def; }; +/* Same as pvr2_ctl_info, but includes storage for the control description */ +#define PVR2_CTLD_INFO_DESC_SIZE 32 +struct pvr2_ctld_info { + struct pvr2_ctl_info info; + char desc[PVR2_CTLD_INFO_DESC_SIZE]; +}; + struct pvr2_ctrl { + const struct pvr2_ctl_info *info; struct pvr2_hdw *hdw; - const struct pvr2_ctl_def *ctl_def; - int is_valid; - int value; - int dirty; }; + struct pvr2_audio_stat { void *ctxt; void (*detach)(void *); @@ -203,6 +202,9 @@ struct pvr2_decoder_ctrl { #define PVR2_HDW_TYPE_24XXX 1 #endif +typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16); +#define PVR2_I2C_FUNC_CNT 128 + /* This structure contains all state data directly needed to manipulate the hardware (as opposed to complying with a kernel interface) */ @@ -233,6 +235,8 @@ struct pvr2_hdw { /* I2C stuff */ struct i2c_adapter i2c_adap; struct i2c_algorithm i2c_algo; + pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT]; + int i2c_cx25840_hack_state; int i2c_linked; unsigned int i2c_pend_types; /* Which types of update are needed */ unsigned long i2c_pend_mask; /* Change bits we need to scan */ @@ -247,6 +251,8 @@ struct pvr2_hdw { /* Frequency table */ unsigned int freqTable[FREQTABLE_SIZE]; + unsigned int freqProgSlot; + unsigned int freqSlot; /* Stuff for handling low level control interaction with device */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) @@ -296,13 +302,25 @@ struct pvr2_hdw { /* Tuner / frequency control stuff */ unsigned int tuner_type; int tuner_updated; - v4l2_std_id video_std_avail; - v4l2_std_id video_std_cur; - struct pvr2_ctl_def video_std_enum; + unsigned int freqVal; + int freqDirty; + + /* Video standard handling */ + v4l2_std_id std_mask_eeprom; // Hardware supported selections + v4l2_std_id std_mask_avail; // Which standards we may select from + v4l2_std_id std_mask_cur; // Currently selected standard(s) + unsigned int std_enum_cnt; // # of enumerated standards + int std_enum_cur; // selected standard enumeration value + int std_dirty; // True if std_mask_cur has changed + struct pvr2_ctl_info std_info_enum; + struct pvr2_ctl_info std_info_avail; + struct pvr2_ctl_info std_info_cur; struct v4l2_standard *std_defs; - const char **video_std_names; - unsigned int std_cnt; - int std_id; + const char **std_enum_names; + + // Generated string names, one per actual V4L2 standard + const char *std_mask_ptrs[32]; + char std_mask_names[32][10]; int unit_number; /* ID for driver instance */ unsigned long serial_number; /* ID for hardware itself */ @@ -321,19 +339,38 @@ struct pvr2_hdw { int flag_bilingual; struct pvr2_audio_stat *audio_stat; - /* Every last bit of controllable state */ + /* Control state needed for cx2341x module */ + struct cx2341x_mpeg_params enc_cur_state; + struct cx2341x_mpeg_params enc_ctl_state; + /* True if an encoder attribute has changed */ + int enc_stale; + /* True if enc_cur_state is valid */ + int enc_cur_valid; + + /* Control state */ +#define VCREATE_DATA(lab) int lab##_val; int lab##_dirty + VCREATE_DATA(brightness); + VCREATE_DATA(contrast); + VCREATE_DATA(saturation); + VCREATE_DATA(hue); + VCREATE_DATA(volume); + VCREATE_DATA(balance); + VCREATE_DATA(bass); + VCREATE_DATA(treble); + VCREATE_DATA(mute); + VCREATE_DATA(input); + VCREATE_DATA(audiomode); + VCREATE_DATA(res_hor); + VCREATE_DATA(res_ver); + VCREATE_DATA(srate); +#undef VCREATE_DATA + + struct pvr2_ctld_info *mpeg_ctrl_info; + struct pvr2_ctrl *controls; + unsigned int control_cnt; }; -int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw); - -int pvr2_ctrl_internal_set_value(struct pvr2_ctrl *cptr,int val); -int pvr2_ctrl_internal_get_value(struct pvr2_ctrl *cptr); - -int pvr2_hdw_internal_set_stdenum_cur(struct pvr2_hdw *hdw,int val); -void pvr2_hdw_internal_set_std_cur(struct pvr2_hdw *hdw,int msk); -void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw,int msk); - #endif /* __PVRUSB2_HDW_INTERNAL_H */ /* |