net: qmi_wwan: add Olivetti Olicard 500
[linux/fpc-iii.git] / drivers / media / usb / usbtv / usbtv.h
blobcb1d388cc647703d12736c4d37c5b98b67a1457b
1 /*
2 * Fushicai USBTV007 Video Grabber Driver
4 * Copyright (c) 2013 Lubomir Rintel
5 * All rights reserved.
6 * No physical hardware was harmed running Windows during the
7 * reverse-engineering activity
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions, and the following disclaimer,
14 * without modification.
15 * 2. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * Alternatively, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL").
22 #include <linux/module.h>
23 #include <linux/slab.h>
24 #include <linux/usb.h>
26 #include <media/v4l2-device.h>
27 #include <media/videobuf2-vmalloc.h>
29 /* Hardware. */
30 #define USBTV_VIDEO_ENDP 0x81
31 #define USBTV_BASE 0xc000
32 #define USBTV_REQUEST_REG 12
34 /* Number of concurrent isochronous urbs submitted.
35 * Higher numbers was seen to overly saturate the USB bus. */
36 #define USBTV_ISOC_TRANSFERS 16
37 #define USBTV_ISOC_PACKETS 8
39 #define USBTV_CHUNK_SIZE 256
40 #define USBTV_CHUNK 240
42 /* Chunk header. */
43 #define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
44 == 0x88000000)
45 #define USBTV_FRAME_ID(chunk) ((be32_to_cpu(chunk[0]) & 0x00ff0000) >> 16)
46 #define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
47 #define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff)
49 #define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL)
51 /* parameters for supported TV norms */
52 struct usbtv_norm_params {
53 v4l2_std_id norm;
54 int cap_width, cap_height;
57 /* A single videobuf2 frame buffer. */
58 struct usbtv_buf {
59 struct vb2_buffer vb;
60 struct list_head list;
63 /* Per-device structure. */
64 struct usbtv {
65 struct device *dev;
66 struct usb_device *udev;
68 /* video */
69 struct v4l2_device v4l2_dev;
70 struct video_device vdev;
71 struct vb2_queue vb2q;
72 struct mutex v4l2_lock;
73 struct mutex vb2q_lock;
75 /* List of videobuf2 buffers protected by a lock. */
76 spinlock_t buflock;
77 struct list_head bufs;
79 /* Number of currently processed frame, useful find
80 * out when a new one begins. */
81 u32 frame_id;
82 int chunks_done;
84 enum {
85 USBTV_COMPOSITE_INPUT,
86 USBTV_SVIDEO_INPUT,
87 } input;
88 v4l2_std_id norm;
89 int width, height;
90 int n_chunks;
91 int iso_size;
92 unsigned int sequence;
93 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
96 int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size);
98 int usbtv_video_init(struct usbtv *usbtv);
99 void usbtv_video_free(struct usbtv *usbtv);