aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvision/usbvision.h
diff options
context:
space:
mode:
authorThierry MERLE <thierry.merle@free.fr>2006-12-04 06:31:45 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-12-10 06:22:49 -0500
commit483dfdb64fd4a9f240c84e0e225a90c044d65402 (patch)
tree385380b96155dea3a281cd88617f65ae8e610f66 /drivers/media/video/usbvision/usbvision.h
parentd8159a3684007e0ded915cb7465c9534a2650c53 (diff)
V4L/DVB (4937): Usbvision cleanup and code reorganization
- removal of overlay stuff - reorganization of functions in 3 files: * usbvision-i2c for I2C-related stuff * usbvision-video for v4l2 entry points * usbvision-core for all peripheral controls and utilities Signed-off-by: Thierry MERLE <thierry.merle@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/usbvision/usbvision.h')
-rw-r--r--drivers/media/video/usbvision/usbvision.h135
1 files changed, 98 insertions, 37 deletions
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h
index f304e66b03a6..f2eeda8326ff 100644
--- a/drivers/media/video/usbvision/usbvision.h
+++ b/drivers/media/video/usbvision/usbvision.h
@@ -28,7 +28,9 @@
28 28
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include "usbvision-i2c.h" 31#include <media/v4l2-common.h>
32#include <media/tuner.h>
33#include <linux/videodev2.h>
32 34
33#ifndef VID_HARDWARE_USBVISION 35#ifndef VID_HARDWARE_USBVISION
34 #define VID_HARDWARE_USBVISION 34 /* USBVision Video Grabber */ 36 #define VID_HARDWARE_USBVISION 34 /* USBVision Video Grabber */
@@ -139,11 +141,21 @@
139#define USBVISION_MAX_ISOC_PACKET_SIZE 959 // NT1003 Specs Document says 1023 141#define USBVISION_MAX_ISOC_PACKET_SIZE 959 // NT1003 Specs Document says 1023
140 142
141#define USBVISION_NUM_HEADERMARKER 20 143#define USBVISION_NUM_HEADERMARKER 20
142#define USBVISION_NUMFRAMES 3 144#define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */
143#define USBVISION_NUMSBUF 2 145#define USBVISION_NUMSBUF 2 /* Dimensioning the USB S buffering */
144 146
145#define USBVISION_POWEROFF_TIME 3 * (HZ) // 3 seconds 147#define USBVISION_POWEROFF_TIME 3 * (HZ) // 3 seconds
146 148
149
150#define FRAMERATE_MIN 0
151#define FRAMERATE_MAX 31
152
153enum {
154 ISOC_MODE_YUV422 = 0x03,
155 ISOC_MODE_YUV420 = 0x14,
156 ISOC_MODE_COMPRESS = 0x60,
157};
158
147/* This macro restricts an int variable to an inclusive range */ 159/* This macro restricts an int variable to an inclusive range */
148#define RESTRICT_TO_RANGE(v,mi,ma) { if ((v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); } 160#define RESTRICT_TO_RANGE(v,mi,ma) { if ((v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); }
149 161
@@ -181,8 +193,6 @@
181 mr = LIMIT_RGB(mm_r); \ 193 mr = LIMIT_RGB(mm_r); \
182} 194}
183 195
184
185
186/* Debugging aid */ 196/* Debugging aid */
187#define USBVISION_SAY_AND_WAIT(what) { \ 197#define USBVISION_SAY_AND_WAIT(what) { \
188 wait_queue_head_t wq; \ 198 wait_queue_head_t wq; \
@@ -202,7 +212,23 @@
202 ((udevice)->last_error == 0) && \ 212 ((udevice)->last_error == 0) && \
203 (!(udevice)->remove_pending)) 213 (!(udevice)->remove_pending))
204 214
215/* I2C structures */
216struct i2c_algo_usb_data {
217 void *data; /* private data for lowlevel routines */
218 int (*inb) (void *data, unsigned char addr, char *buf, short len);
219 int (*outb) (void *data, unsigned char addr, char *buf, short len);
220
221 /* local settings */
222 int udelay;
223 int mdelay;
224 int timeout;
225};
205 226
227#define I2C_USB_ADAP_MAX 16
228
229/* ----------------------------------------------------------------- */
230/* usbvision video structures */
231/* ----------------------------------------------------------------- */
206enum ScanState { 232enum ScanState {
207 ScanState_Scanning, /* Scanning for header */ 233 ScanState_Scanning, /* Scanning for header */
208 ScanState_Lines /* Parsing lines */ 234 ScanState_Lines /* Parsing lines */
@@ -347,7 +373,6 @@ struct usb_usbvision {
347 struct video_device *vdev; /* Video Device */ 373 struct video_device *vdev; /* Video Device */
348 struct video_device *rdev; /* Radio Device */ 374 struct video_device *rdev; /* Radio Device */
349 struct video_device *vbi; /* VBI Device */ 375 struct video_device *vbi; /* VBI Device */
350 struct video_audio audio_dev; /* Current audio params */
351 376
352 /* i2c Declaration Section*/ 377 /* i2c Declaration Section*/
353 struct i2c_adapter i2c_adap; 378 struct i2c_adapter i2c_adap;
@@ -361,6 +386,7 @@ struct usb_usbvision {
361 wait_queue_head_t ctrlUrb_wq; // Processes waiting 386 wait_queue_head_t ctrlUrb_wq; // Processes waiting
362 struct semaphore ctrlUrbLock; 387 struct semaphore ctrlUrbLock;
363 388
389 /* configuration part */
364 int have_tuner; 390 int have_tuner;
365 int tuner_type; 391 int tuner_type;
366 int tuner_addr; 392 int tuner_addr;
@@ -372,7 +398,7 @@ struct usb_usbvision {
372 int AudioMute; 398 int AudioMute;
373 int AudioChannel; 399 int AudioChannel;
374 int isocMode; // format of video data for the usb isoc-transfer 400 int isocMode; // format of video data for the usb isoc-transfer
375 unsigned int nr; // Number of the device < MAX_USBVISION 401 unsigned int nr; // Number of the device
376 402
377 /* Device structure */ 403 /* Device structure */
378 struct usb_device *dev; 404 struct usb_device *dev;
@@ -384,7 +410,6 @@ struct usb_usbvision {
384 struct work_struct powerOffWork; 410 struct work_struct powerOffWork;
385 int power; /* is the device powered on? */ 411 int power; /* is the device powered on? */
386 int user; /* user count for exclusive use */ 412 int user; /* user count for exclusive use */
387 int usbvision_used; /* Is this structure in use? */
388 int initialized; /* Had we already sent init sequence? */ 413 int initialized; /* Had we already sent init sequence? */
389 int DevModel; /* What type of USBVISION device we got? */ 414 int DevModel; /* What type of USBVISION device we got? */
390 enum StreamState streaming; /* Are we streaming Isochronous? */ 415 enum StreamState streaming; /* Are we streaming Isochronous? */
@@ -402,7 +427,6 @@ struct usb_usbvision {
402 wait_queue_head_t wait_stream; /* Processes waiting */ 427 wait_queue_head_t wait_stream; /* Processes waiting */
403 struct usbvision_frame *curFrame; // pointer to current frame, set by usbvision_find_header 428 struct usbvision_frame *curFrame; // pointer to current frame, set by usbvision_find_header
404 struct usbvision_frame frame[USBVISION_NUMFRAMES]; // frame buffer 429 struct usbvision_frame frame[USBVISION_NUMFRAMES]; // frame buffer
405 int curSbufNum; // number of current receiving sbuf
406 struct usbvision_sbuf sbuf[USBVISION_NUMSBUF]; // S buffering 430 struct usbvision_sbuf sbuf[USBVISION_NUMSBUF]; // S buffering
407 volatile int remove_pending; /* If set then about to exit */ 431 volatile int remove_pending; /* If set then about to exit */
408 432
@@ -413,13 +437,7 @@ struct usb_usbvision {
413 int scratch_headermarker[USBVISION_NUM_HEADERMARKER]; 437 int scratch_headermarker[USBVISION_NUM_HEADERMARKER];
414 int scratch_headermarker_read_ptr; 438 int scratch_headermarker_read_ptr;
415 int scratch_headermarker_write_ptr; 439 int scratch_headermarker_write_ptr;
416 int isocstate; 440 enum IsocState isocstate;
417 /* color controls */
418 int saturation;
419 int hue;
420 int brightness;
421 int contrast;
422 int depth;
423 struct usbvision_v4l2_format_st palette; 441 struct usbvision_v4l2_format_st palette;
424 442
425 struct v4l2_capability vcap; /* Video capabilities */ 443 struct v4l2_capability vcap; /* Video capabilities */
@@ -427,17 +445,6 @@ struct usb_usbvision {
427 struct usbvision_tvnorm *tvnorm; /* selected tv norm */ 445 struct usbvision_tvnorm *tvnorm; /* selected tv norm */
428 unsigned char video_endp; /* 0x82 for USBVISION devices based */ 446 unsigned char video_endp; /* 0x82 for USBVISION devices based */
429 447
430 // Overlay stuff:
431 struct v4l2_framebuffer vid_buf;
432 struct v4l2_format vid_win;
433 int vid_buf_valid; // Status: video buffer is valid (set)
434 int vid_win_valid; // Status: video window is valid (set)
435 int overlay; /*Status: Are we overlaying? */
436 unsigned int clipmask[USBVISION_CLIPMASK_SIZE / 4];
437 unsigned char *overlay_base; /* Virtual base address of video buffer */
438 unsigned char *overlay_win; /* virt start address of overlay window */
439 struct usbvision_frame overlay_frame;
440
441 // Decompression stuff: 448 // Decompression stuff:
442 unsigned char *IntraFrameBuffer; /* Buffer for reference frame */ 449 unsigned char *IntraFrameBuffer; /* Buffer for reference frame */
443 int BlockPos; //for test only 450 int BlockPos; //for test only
@@ -449,16 +456,6 @@ struct usb_usbvision {
449 int lastComprLevel; // How strong (100) or weak (0) was compression 456 int lastComprLevel; // How strong (100) or weak (0) was compression
450 int usb_bandwidth; /* Mbit/s */ 457 int usb_bandwidth; /* Mbit/s */
451 458
452 /* /proc entries, relative to /proc/video/usbvision/ */
453 struct proc_dir_entry *proc_devdir; /* Per-device proc directory */
454 struct proc_dir_entry *proc_info; /* <minor#>/info entry */
455 struct proc_dir_entry *proc_register; /* <minor#>/register entry */
456 struct proc_dir_entry *proc_freq; /* <minor#>/freq entry */
457 struct proc_dir_entry *proc_input; /* <minor#>/input entry */
458 struct proc_dir_entry *proc_frame; /* <minor#>/frame entry */
459 struct proc_dir_entry *proc_button; /* <minor#>/button entry */
460 struct proc_dir_entry *proc_control; /* <minor#>/control entry */
461
462 /* Statistics that can be overlayed on the screen */ 459 /* Statistics that can be overlayed on the screen */
463 unsigned long isocUrbCount; // How many URBs we received so far 460 unsigned long isocUrbCount; // How many URBs we received so far
464 unsigned long urb_length; /* Length of last URB */ 461 unsigned long urb_length; /* Length of last URB */
@@ -479,6 +476,70 @@ struct usb_usbvision {
479 int ComprBlockTypes[4]; 476 int ComprBlockTypes[4];
480}; 477};
481 478
479
480/* --------------------------------------------------------------- */
481/* defined in usbvision-i2c.c */
482/* i2c-algo-usb declaration */
483/* --------------------------------------------------------------- */
484
485int usbvision_i2c_usb_add_bus(struct i2c_adapter *);
486int usbvision_i2c_usb_del_bus(struct i2c_adapter *);
487
488static inline void *i2c_get_algo_usb_data (struct i2c_algo_usb_data *dev)
489{
490 return dev->data;
491}
492
493static inline void i2c_set_algo_usb_data (struct i2c_algo_usb_data *dev, void *data)
494{
495 dev->data = data;
496}
497
498
499/* ----------------------------------------------------------------------- */
500/* usbvision specific I2C functions */
501/* ----------------------------------------------------------------------- */
502int usbvision_init_i2c(struct usb_usbvision *usbvision);
503void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd,void *arg);
504
505/* defined in usbvision-core.c */
506void *usbvision_rvmalloc(unsigned long size);
507void usbvision_rvfree(void *mem, unsigned long size);
508int usbvision_read_reg(struct usb_usbvision *usbvision, unsigned char reg);
509int usbvision_write_reg(struct usb_usbvision *usbvision, unsigned char reg,
510 unsigned char value);
511
512int usbvision_frames_alloc(struct usb_usbvision *usbvision);
513void usbvision_frames_free(struct usb_usbvision *usbvision);
514int usbvision_scratch_alloc(struct usb_usbvision *usbvision);
515void usbvision_scratch_free(struct usb_usbvision *usbvision);
516int usbvision_sbuf_alloc(struct usb_usbvision *usbvision);
517void usbvision_sbuf_free(struct usb_usbvision *usbvision);
518int usbvision_decompress_alloc(struct usb_usbvision *usbvision);
519void usbvision_decompress_free(struct usb_usbvision *usbvision);
520
521int usbvision_setup(struct usb_usbvision *usbvision,int format);
522int usbvision_init_isoc(struct usb_usbvision *usbvision);
523int usbvision_restart_isoc(struct usb_usbvision *usbvision);
524void usbvision_stop_isoc(struct usb_usbvision *usbvision);
525
526int usbvision_set_audio(struct usb_usbvision *usbvision, int AudioChannel);
527int usbvision_audio_off(struct usb_usbvision *usbvision);
528
529int usbvision_begin_streaming(struct usb_usbvision *usbvision);
530void usbvision_empty_framequeues(struct usb_usbvision *dev);
531int usbvision_stream_interrupt(struct usb_usbvision *dev);
532
533int usbvision_muxsel(struct usb_usbvision *usbvision, int channel);
534int usbvision_set_input(struct usb_usbvision *usbvision);
535int usbvision_set_output(struct usb_usbvision *usbvision, int width, int height);
536
537void usbvision_init_powerOffTimer(struct usb_usbvision *usbvision);
538void usbvision_set_powerOffTimer(struct usb_usbvision *usbvision);
539void usbvision_reset_powerOffTimer(struct usb_usbvision *usbvision);
540int usbvision_power_off(struct usb_usbvision *usbvision);
541int usbvision_power_on(struct usb_usbvision *usbvision);
542
482#endif /* __LINUX_USBVISION_H */ 543#endif /* __LINUX_USBVISION_H */
483 544
484/* 545/*