📄 zc030x_kerneldef.h
字号:
/* This declare the kernelspace structures *//* Zc030x - Driver file - Zc030x *//* This file is under GPL *//* Copyright: Martin Braun Arnaud Patard Cyril Russo Code based on: * USB Skeleton Driver 0.7 * SPCA50x based camera driver * phillips webcam drivers (pwc) -------------------------------------------*/#ifndef h_Zc030x_inc_h#define h_Zc030x_inc_h/* Kernel types and structures */#include <linux/kernel.h>/* DevFS needed for registering the driver */#include <linux/devfs_fs_kernel.h>/* Video for linux */#include <linux/videodev.h>/* And, USB, of course */#include <linux/usb.h>/* Include independant declarations */#include "zc030x.h"/* Include sensor signature definition */#include "zc030x_sensorsig.h"/* Include frame definition */#include "zc030x_frame.h"/* Define the module name and description */#define DRIVER_DESC "ZC030X USB Camera Driver"#define DRIVER_VERSION "0.10 still experimental"/* Below is for decoding tasklet *//* Adapt to linux kernel version */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #define HAVE_TQ_SCHED 1/* And reinclude the scheduler specific declarations with TQ */#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) #include <linux/sched.h> #ifdef TQ_ACTIVE #undef HAVE_TQ_SCHED #endif #else #error Need Linux 2.4.0 or higher#endif /* Then create macro to warp the differences */#ifdef HAVE_TQ_SCHED#define SCHEDULE_TASK(x) \ (x)->next = NULL; \ queue_task(x, &tq_scheduler)#else #define SCHEDULE_TASK(x) \ if (schedule_task(x) == 0) { \ }#endif #endif /* Else use the appropriate schedule declaration */#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) #include <linux/workqueue.h> #define tq_struct work_struct #define INIT_TQUEUE INIT_WORK #define schedule_task schedule_work #define SCHEDULE_TASK schedule_work#else #include <linux/tqueue.h>#endif/* Quick hack for urb_t declaration */#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) && LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #define urb_t struct urb#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) *//* kernel debugging messages *//* Configure debugging level... 0 = no debug messages 1 = init/detection/unload and other significant messages, 2 = some warning messages 3 = config/control function calls 4 = most function calls and data parsing messages 5 = highly repetitive mesgs NOTE: This should be changed to 0, 1, or 2 for production kernels *//* Module parameters */extern int debug;extern int currentwidth;extern int currentheight;extern int quality;extern int sensoraccept;extern char * sensor;#define ZC030X_ENABLE_DEBUG /*enable debugging messages *//* Declare the PDEBUG macro if needed */#ifdef ZC030X_ENABLE_DEBUG# define PDEBUG(level, fmt, args...) \if (debug >= level) info("[%s:%d] " fmt, __PRETTY_FUNCTION__, __LINE__ , ## args)#else # define PDEBUG(level, fmt, args...) do {} while(0)#endif /* I don't understand this */#define VIDEO_INTERFACE 0/* Nor this */#define DEFAULT_CONFIGURATION 1/* Alternate interface settings */#define ALT_IF_SETTING_0 0 #define ALT_IF_SETTING_128 1 #define ALT_IF_SETTING_192 2 #define ALT_IF_SETTING_256 3 #define ALT_IF_SETTING_384 4 #define ALT_IF_SETTING_512 5 #define ALT_IF_SETTING_768 6#define ALT_IF_SETTING_1023 7/* Reverse alternate interface setting (to know the packet size) */#define ALT_IF_SETTING_1 128 #define ALT_IF_SETTING_2 192 #define ALT_IF_SETTING_3 256 #define ALT_IF_SETTING_4 384#define ALT_IF_SETTING_5 512 #define ALT_IF_SETTING_6 768#define ALT_IF_SETTING_7 1023/* Size and number of buffers for the ISO pipe. */#define MAX_ISO_BUFS 2#define ISO_FRAMES_PER_DESC 10#define ISO_MAX_FRAME_SIZE 768#define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)#define ZC030X_NUMFRAMES 4/* Video Size 640 x 480 x 4 bytes for RGB *//* Define the maximum number of frame in the decoding queue */#define FRAME_HEADER_SIZE 20 /* Define the frame size in byte */static const int VideoByteSize = 640*480*4;#define MAX_VIDEODATA_SIZE (VideoByteSize + FRAME_HEADER_SIZE)/* Default gamma brightness and contrast */#define DefaultGamma 4<<8#define DefaultBrightness 32768#define DefaultContrast 32768/* State machine for each frame in the frame buffer during capture */enum { STATE_SCANNING, /* Scanning for start */ STATE_HEADER, /* Parsing header */ STATE_LINES, /* Parsing lines */};/* Buffer states */enum { BUF_NOT_ALLOCATED, BUF_ALLOCATED, BUF_PEND_DEALLOC, /* spca50x->buf_timer is set */};/* The following structures were based on cpia.h. Why reinvent the wheel? :-) */struct iso_buf{ void * data; int length; int read; struct urb * urb;};struct cam_params { __u8 BandWidth; __u8 Brightness; __u8 Contrast; __u8 Hue; __u8 Saturation; __u8 Sharpness; __u8 Gamma; __u8 WhiteBalance; __u8 BackLight; __u8 ColorEnable; __u8 FrameRate; __u8 Exposure; __u8 Gain; __u8 Mirror; __u8 Flicker; __u8 Default; __u8 ExposureAuto; __u8 WhiteBalanceAuto; __u8 GainAuto; __u8 BandWidthAuto; __u8 Vertical; __u8 Rgain; __u8 Ggain; __u8 Bgain;};/* Structure to hold all of our device specific stuff */struct usb_zc030x{ /********* USB device management *****************/ struct usb_device *udev; /* save off the usb device pointer */// char busy; struct usb_interface_descriptor *iface_desc; /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) devfs_handle_t devfs; /* TODO: merge own - devfs device node */ #endif int open; /* TODO: same ? - if the port is open or not */ int present; /* if the device is not disconnected */ unsigned char minor; /* the starting minor number for this device */ struct semaphore sem; /* locks this structure */ int prod_id; /* for use when need diferent functions */ int vend_id; int alt; /* current alternate interface */ int ctrlend; /* control endpoint */ int isocend; /* isoc endpoint */ int intrend; /* button interrupt endpoint */ int vendpoint; /* video isoc endpoint */ struct urb *inturb; /* urb for button interrupt */ int vmax_packet_size; /* USB maxpacket size */ /******** Camera/Sensor specific parameters *******/ int type_id; /* Video device type (-> supported_cams)*/ int sensor_id; /* Sensor type (-> supported_sensors) */ struct cam_params params; /* What we think the hardware is currently set to */ unsigned char sensor_addr; /* What is the address of the sensor ? */ __u16 Brightness; /* Brightness in [-32768;32767] */ __u16 Contrast; /* Contrast in [-32768;32767] */ __u16 Gamma; /* Gamma as 8.8 fixed point */ /********* jpeg decoder workspace *****************/ char * tmpBuffer; /* Temporary buffer to store compressed frames */ /********* Framebuffer/sbuf management ***********/ struct semaphore buf_lock; /* wait queue */ wait_queue_head_t wq; /* Processes waiting */ struct iso_buf sbuf[MAX_ISO_BUFS]; /* isoc receiving buffers */ int buf_state; int cursbuf; /* current isoc receiving buffer */ int streaming; /* isoc data is streaming */ zc030x_frame frame[ZC030X_NUMFRAMES]; /********* V4L device & buffers ******************/ struct video_device * pVideoDevice; /* video device (v4l) */ char *fbuf; /* Video buffer, contains captured frame data*/ char *mmbuf; /* video mmap buffer */ int curframe; /* frame buffer */ int VideoFormat; /* Video format */};unsigned long kvirt_to_pa(unsigned long adr);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -