0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/usb.h>
0009 #include <linux/i2c.h>
0010 #include <linux/mutex.h>
0011 #include <linux/workqueue.h>
0012 #include <linux/videodev2.h>
0013
0014 #include <media/v4l2-device.h>
0015 #include <media/v4l2-ctrls.h>
0016 #include <media/i2c/ir-kbd-i2c.h>
0017
0018 #define HDPVR_MAX 8
0019 #define HDPVR_I2C_MAX_SIZE 128
0020
0021
0022 #define HD_PVR_VENDOR_ID 0x2040
0023 #define HD_PVR_PRODUCT_ID 0x4900
0024 #define HD_PVR_PRODUCT_ID1 0x4901
0025 #define HD_PVR_PRODUCT_ID2 0x4902
0026 #define HD_PVR_PRODUCT_ID4 0x4903
0027 #define HD_PVR_PRODUCT_ID3 0x4982
0028
0029 #define UNSET (-1U)
0030
0031 #define NUM_BUFFERS 64
0032
0033 #define HDPVR_FIRMWARE_VERSION 0x08
0034 #define HDPVR_FIRMWARE_VERSION_AC3 0x0d
0035 #define HDPVR_FIRMWARE_VERSION_0X12 0x12
0036 #define HDPVR_FIRMWARE_VERSION_0X15 0x15
0037 #define HDPVR_FIRMWARE_VERSION_0X1E 0x1e
0038
0039
0040
0041 extern int hdpvr_debug;
0042
0043 #define MSG_INFO 1
0044 #define MSG_BUFFER 2
0045
0046 struct hdpvr_options {
0047 u8 video_std;
0048 u8 video_input;
0049 u8 audio_input;
0050 u8 bitrate;
0051 u8 peak_bitrate;
0052 u8 bitrate_mode;
0053 u8 gop_mode;
0054 enum v4l2_mpeg_audio_encoding audio_codec;
0055 u8 brightness;
0056 u8 contrast;
0057 u8 hue;
0058 u8 saturation;
0059 u8 sharpness;
0060 };
0061
0062
0063 struct hdpvr_device {
0064
0065 struct video_device video_dev;
0066
0067 struct v4l2_ctrl_handler hdl;
0068
0069 struct usb_device *udev;
0070
0071 struct v4l2_device v4l2_dev;
0072 struct {
0073 struct v4l2_ctrl *video_mode;
0074 struct v4l2_ctrl *video_bitrate;
0075 struct v4l2_ctrl *video_bitrate_peak;
0076 };
0077
0078 uint width, height;
0079
0080
0081 size_t bulk_in_size;
0082
0083 __u8 bulk_in_endpointAddr;
0084
0085
0086 __u8 status;
0087
0088
0089 struct hdpvr_options options;
0090 v4l2_std_id cur_std;
0091 struct v4l2_dv_timings cur_dv_timings;
0092
0093 uint flags;
0094
0095
0096 struct mutex io_mutex;
0097
0098 struct list_head free_buff_list;
0099
0100 struct list_head rec_buff_list;
0101
0102 wait_queue_head_t wait_buffer;
0103
0104 wait_queue_head_t wait_data;
0105
0106 struct work_struct worker;
0107
0108 struct v4l2_fh *owner;
0109
0110
0111 struct i2c_adapter i2c_adapter;
0112
0113 struct mutex i2c_mutex;
0114
0115 char i2c_buf[HDPVR_I2C_MAX_SIZE];
0116
0117
0118 struct IR_i2c_init_data ir_i2c_init_data;
0119
0120
0121 struct mutex usbc_mutex;
0122 u8 *usbc_buf;
0123 u8 fw_ver;
0124 };
0125
0126 static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev)
0127 {
0128 return container_of(v4l2_dev, struct hdpvr_device, v4l2_dev);
0129 }
0130
0131
0132
0133 struct hdpvr_buffer {
0134 struct list_head buff_list;
0135
0136 struct urb *urb;
0137
0138 struct hdpvr_device *dev;
0139
0140 uint pos;
0141
0142 __u8 status;
0143 };
0144
0145
0146
0147 struct hdpvr_video_info {
0148 u16 width;
0149 u16 height;
0150 u8 fps;
0151 bool valid;
0152 };
0153
0154 enum {
0155 STATUS_UNINITIALIZED = 0,
0156 STATUS_IDLE,
0157 STATUS_STARTING,
0158 STATUS_SHUTTING_DOWN,
0159 STATUS_STREAMING,
0160 STATUS_ERROR,
0161 STATUS_DISCONNECTED,
0162 };
0163
0164 enum {
0165 HDPVR_FLAG_AC3_CAP = 1,
0166 };
0167
0168 enum {
0169 BUFSTAT_UNINITIALIZED = 0,
0170 BUFSTAT_AVAILABLE,
0171 BUFSTAT_INPROGRESS,
0172 BUFSTAT_READY,
0173 };
0174
0175 #define CTRL_START_STREAMING_VALUE 0x0700
0176 #define CTRL_STOP_STREAMING_VALUE 0x0800
0177 #define CTRL_BITRATE_VALUE 0x1000
0178 #define CTRL_BITRATE_MODE_VALUE 0x1200
0179 #define CTRL_GOP_MODE_VALUE 0x1300
0180 #define CTRL_VIDEO_INPUT_VALUE 0x1500
0181 #define CTRL_VIDEO_STD_TYPE 0x1700
0182 #define CTRL_AUDIO_INPUT_VALUE 0x2500
0183 #define CTRL_BRIGHTNESS 0x2900
0184 #define CTRL_CONTRAST 0x2a00
0185 #define CTRL_HUE 0x2b00
0186 #define CTRL_SATURATION 0x2c00
0187 #define CTRL_SHARPNESS 0x2d00
0188 #define CTRL_LOW_PASS_FILTER_VALUE 0x3100
0189
0190 #define CTRL_DEFAULT_INDEX 0x0003
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 enum hdpvr_video_std {
0256 HDPVR_60HZ = 0,
0257 HDPVR_50HZ,
0258 };
0259
0260 enum hdpvr_video_input {
0261 HDPVR_COMPONENT = 0,
0262 HDPVR_SVIDEO,
0263 HDPVR_COMPOSITE,
0264 HDPVR_VIDEO_INPUTS
0265 };
0266
0267 enum hdpvr_audio_inputs {
0268 HDPVR_RCA_BACK = 0,
0269 HDPVR_RCA_FRONT,
0270 HDPVR_SPDIF,
0271 HDPVR_AUDIO_INPUTS
0272 };
0273
0274 enum hdpvr_bitrate_mode {
0275 HDPVR_CONSTANT = 1,
0276 HDPVR_VARIABLE_PEAK,
0277 HDPVR_VARIABLE_AVERAGE,
0278 };
0279
0280 enum hdpvr_gop_mode {
0281 HDPVR_ADVANCED_IDR_GOP = 0,
0282 HDPVR_SIMPLE_IDR_GOP,
0283 HDPVR_ADVANCED_NOIDR_GOP,
0284 HDPVR_SIMPLE_NOIDR_GOP,
0285 };
0286
0287 void hdpvr_delete(struct hdpvr_device *dev);
0288
0289
0290
0291 int hdpvr_set_options(struct hdpvr_device *dev);
0292
0293 int hdpvr_set_bitrate(struct hdpvr_device *dev);
0294
0295 int hdpvr_set_audio(struct hdpvr_device *dev, u8 input,
0296 enum v4l2_mpeg_audio_encoding codec);
0297
0298 int hdpvr_config_call(struct hdpvr_device *dev, uint value,
0299 unsigned char valbuf);
0300
0301 int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vid_info);
0302
0303
0304
0305 int get_input_lines_info(struct hdpvr_device *dev);
0306
0307
0308
0309
0310 int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
0311 int devnumber);
0312
0313 int hdpvr_cancel_queue(struct hdpvr_device *dev);
0314
0315
0316
0317 int hdpvr_register_i2c_adapter(struct hdpvr_device *dev);
0318
0319 struct i2c_client *hdpvr_register_ir_i2c(struct hdpvr_device *dev);
0320
0321
0322
0323 int hdpvr_free_buffers(struct hdpvr_device *dev);
0324 int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count);