Path: blob/master/drivers/media/video/hdpvr/hdpvr.h
17633 views
/*1* Hauppauge HD PVR USB driver2*3* Copyright (C) 2008 Janne Grunau ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License as7* published by the Free Software Foundation, version 2.8*9*/1011#include <linux/usb.h>12#include <linux/i2c.h>13#include <linux/mutex.h>14#include <linux/workqueue.h>15#include <linux/videodev2.h>1617#include <media/v4l2-device.h>18#include <media/ir-kbd-i2c.h>1920#define HDPVR_MAJOR_VERSION 021#define HDPVR_MINOR_VERSION 222#define HDPVR_RELEASE 023#define HDPVR_VERSION \24KERNEL_VERSION(HDPVR_MAJOR_VERSION, HDPVR_MINOR_VERSION, HDPVR_RELEASE)2526#define HDPVR_MAX 827#define HDPVR_I2C_MAX_SIZE 1282829/* Define these values to match your devices */30#define HD_PVR_VENDOR_ID 0x204031#define HD_PVR_PRODUCT_ID 0x490032#define HD_PVR_PRODUCT_ID1 0x490133#define HD_PVR_PRODUCT_ID2 0x490234#define HD_PVR_PRODUCT_ID4 0x490335#define HD_PVR_PRODUCT_ID3 0x49823637#define UNSET (-1U)3839#define NUM_BUFFERS 644041#define HDPVR_FIRMWARE_VERSION 0x0842#define HDPVR_FIRMWARE_VERSION_AC3 0x0d43#define HDPVR_FIRMWARE_VERSION_0X12 0x1244#define HDPVR_FIRMWARE_VERSION_0X15 0x154546/* #define HDPVR_DEBUG */4748extern int hdpvr_debug;4950#define MSG_INFO 151#define MSG_BUFFER 25253struct hdpvr_options {54u8 video_std;55u8 video_input;56u8 audio_input;57u8 bitrate; /* in 100kbps */58u8 peak_bitrate; /* in 100kbps */59u8 bitrate_mode;60u8 gop_mode;61enum v4l2_mpeg_audio_encoding audio_codec;62u8 brightness;63u8 contrast;64u8 hue;65u8 saturation;66u8 sharpness;67};6869/* Structure to hold all of our device specific stuff */70struct hdpvr_device {71/* the v4l device for this device */72struct video_device *video_dev;73/* the usb device for this device */74struct usb_device *udev;75/* v4l2-device unused */76struct v4l2_device v4l2_dev;7778/* the max packet size of the bulk endpoint */79size_t bulk_in_size;80/* the address of the bulk in endpoint */81__u8 bulk_in_endpointAddr;8283/* holds the current device status */84__u8 status;85/* count the number of openers */86uint open_count;8788/* holds the cureent set options */89struct hdpvr_options options;9091uint flags;9293/* synchronize I/O */94struct mutex io_mutex;95/* available buffers */96struct list_head free_buff_list;97/* in progress buffers */98struct list_head rec_buff_list;99/* waitqueue for buffers */100wait_queue_head_t wait_buffer;101/* waitqueue for data */102wait_queue_head_t wait_data;103/**/104struct workqueue_struct *workqueue;105/**/106struct work_struct worker;107108/* I2C adapter */109struct i2c_adapter i2c_adapter;110/* I2C lock */111struct mutex i2c_mutex;112/* I2C message buffer space */113char i2c_buf[HDPVR_I2C_MAX_SIZE];114115/* For passing data to ir-kbd-i2c */116struct IR_i2c_init_data ir_i2c_init_data;117118/* usb control transfer buffer and lock */119struct mutex usbc_mutex;120u8 *usbc_buf;121};122123static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev)124{125return container_of(v4l2_dev, struct hdpvr_device, v4l2_dev);126}127128129/* buffer one bulk urb of data */130struct hdpvr_buffer {131struct list_head buff_list;132133struct urb *urb;134135struct hdpvr_device *dev;136137uint pos;138139__u8 status;140};141142/* */143144struct hdpvr_video_info {145u16 width;146u16 height;147u8 fps;148};149150enum {151STATUS_UNINITIALIZED = 0,152STATUS_IDLE,153STATUS_STARTING,154STATUS_SHUTTING_DOWN,155STATUS_STREAMING,156STATUS_ERROR,157STATUS_DISCONNECTED,158};159160enum {161HDPVR_FLAG_AC3_CAP = 1,162};163164enum {165BUFSTAT_UNINITIALIZED = 0,166BUFSTAT_AVAILABLE,167BUFSTAT_INPROGRESS,168BUFSTAT_READY,169};170171#define CTRL_START_STREAMING_VALUE 0x0700172#define CTRL_STOP_STREAMING_VALUE 0x0800173#define CTRL_BITRATE_VALUE 0x1000174#define CTRL_BITRATE_MODE_VALUE 0x1200175#define CTRL_GOP_MODE_VALUE 0x1300176#define CTRL_VIDEO_INPUT_VALUE 0x1500177#define CTRL_VIDEO_STD_TYPE 0x1700178#define CTRL_AUDIO_INPUT_VALUE 0x2500179#define CTRL_BRIGHTNESS 0x2900180#define CTRL_CONTRAST 0x2a00181#define CTRL_HUE 0x2b00182#define CTRL_SATURATION 0x2c00183#define CTRL_SHARPNESS 0x2d00184#define CTRL_LOW_PASS_FILTER_VALUE 0x3100185186#define CTRL_DEFAULT_INDEX 0x0003187188189/* :0 s 38 01 1000 0003 0004 4 = 0a00ca00190* BITRATE SETTING191* 1st and 2nd byte (little endian): average bitrate in 100 000 bit/s192* min: 1 mbit/s, max: 13.5 mbit/s193* 3rd and 4th byte (little endian): peak bitrate in 100 000 bit/s194* min: average + 100kbit/s,195* max: 20.2 mbit/s196*/197198/* :0 s 38 01 1200 0003 0001 1 = 02199* BIT RATE MODE200* constant = 1, variable (peak) = 2, variable (average) = 3201*/202203/* :0 s 38 01 1300 0003 0001 1 = 03204* GOP MODE (2 bit)205* low bit 0/1: advanced/simple GOP206* high bit 0/1: IDR(4/32/128) / no IDR (4/32/0)207*/208209/* :0 s 38 01 1700 0003 0001 1 = 00210* VIDEO STANDARD or FREQUNCY 0 = 60hz, 1 = 50hz211*/212213/* :0 s 38 01 3100 0003 0004 4 = 03030000214* FILTER CONTROL215* 1st byte luma low pass filter strength,216* 2nd byte chroma low pass filter strength,217* 3rd byte MF enable chroma, min=0, max=1218* 4th byte n219*/220221222/* :0 s 38 b9 0001 0000 0000 0 */223224225226/* :0 s 38 d3 0000 0000 0001 1 = 00 */227/* ret = usb_control_msg(dev->udev, */228/* usb_sndctrlpipe(dev->udev, 0), */229/* 0xd3, 0x38, */230/* 0, 0, */231/* "\0", 1, */232/* 1000); */233234/* info("control request returned %d", ret); */235/* msleep(5000); */236237238/* :0 s b8 81 1400 0003 0005 5 <239* :0 0 5 = d0024002 19240* QUERY FRAME SIZE AND RATE241* 1st and 2nd byte (little endian): horizontal resolution242* 3rd and 4th byte (little endian): vertical resolution243* 5th byte: frame rate244*/245246/* :0 s b8 81 1800 0003 0003 3 <247* :0 0 3 = 030104248* QUERY SIGNAL AND DETECTED LINES, maybe INPUT249*/250251enum hdpvr_video_std {252HDPVR_60HZ = 0,253HDPVR_50HZ,254};255256enum hdpvr_video_input {257HDPVR_COMPONENT = 0,258HDPVR_SVIDEO,259HDPVR_COMPOSITE,260HDPVR_VIDEO_INPUTS261};262263enum hdpvr_audio_inputs {264HDPVR_RCA_BACK = 0,265HDPVR_RCA_FRONT,266HDPVR_SPDIF,267HDPVR_AUDIO_INPUTS268};269270enum hdpvr_bitrate_mode {271HDPVR_CONSTANT = 1,272HDPVR_VARIABLE_PEAK,273HDPVR_VARIABLE_AVERAGE,274};275276enum hdpvr_gop_mode {277HDPVR_ADVANCED_IDR_GOP = 0,278HDPVR_SIMPLE_IDR_GOP,279HDPVR_ADVANCED_NOIDR_GOP,280HDPVR_SIMPLE_NOIDR_GOP,281};282283void hdpvr_delete(struct hdpvr_device *dev);284285/*========================================================================*/286/* hardware control functions */287int hdpvr_set_options(struct hdpvr_device *dev);288289int hdpvr_set_bitrate(struct hdpvr_device *dev);290291int hdpvr_set_audio(struct hdpvr_device *dev, u8 input,292enum v4l2_mpeg_audio_encoding codec);293294int hdpvr_config_call(struct hdpvr_device *dev, uint value,295unsigned char valbuf);296297struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev);298299/* :0 s b8 81 1800 0003 0003 3 < */300/* :0 0 3 = 0301ff */301int get_input_lines_info(struct hdpvr_device *dev);302303304/*========================================================================*/305/* v4l2 registration */306int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,307int devnumber);308309int hdpvr_cancel_queue(struct hdpvr_device *dev);310311/*========================================================================*/312/* i2c adapter registration */313int hdpvr_register_i2c_adapter(struct hdpvr_device *dev);314315struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev);316struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev);317318/*========================================================================*/319/* buffer management */320int hdpvr_free_buffers(struct hdpvr_device *dev);321int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count);322323324