0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <linux/module.h>
0037 #include <linux/slab.h>
0038 #include <linux/usb.h>
0039
0040 #include <media/v4l2-device.h>
0041 #include <media/v4l2-ctrls.h>
0042 #include <media/videobuf2-v4l2.h>
0043 #include <media/videobuf2-vmalloc.h>
0044
0045
0046 #define USBTV_VIDEO_ENDP 0x81
0047 #define USBTV_AUDIO_ENDP 0x83
0048 #define USBTV_BASE 0xc000
0049 #define USBTV_CONTROL_REG 11
0050 #define USBTV_REQUEST_REG 12
0051
0052
0053
0054 #define USBTV_ISOC_TRANSFERS 16
0055 #define USBTV_ISOC_PACKETS 8
0056
0057 #define USBTV_CHUNK_SIZE 256
0058 #define USBTV_CHUNK 240
0059
0060 #define USBTV_AUDIO_URBSIZE 20480
0061 #define USBTV_AUDIO_HDRSIZE 4
0062 #define USBTV_AUDIO_BUFFER 65536
0063
0064
0065 #define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
0066 == 0x88000000)
0067 #define USBTV_FRAME_ID(chunk) ((be32_to_cpu(chunk[0]) & 0x00ff0000) >> 16)
0068 #define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
0069 #define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff)
0070
0071 #define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL | \
0072 V4L2_STD_PAL_Nc | V4L2_STD_SECAM)
0073
0074
0075 struct usbtv_norm_params {
0076 v4l2_std_id norm;
0077 int cap_width, cap_height;
0078 };
0079
0080
0081 struct usbtv_buf {
0082 struct vb2_v4l2_buffer vb;
0083 struct list_head list;
0084 };
0085
0086
0087 struct usbtv {
0088 struct device *dev;
0089 struct usb_device *udev;
0090
0091
0092 struct v4l2_device v4l2_dev;
0093 struct v4l2_ctrl_handler ctrl;
0094 struct video_device vdev;
0095 struct vb2_queue vb2q;
0096 struct mutex v4l2_lock;
0097 struct mutex vb2q_lock;
0098
0099
0100 spinlock_t buflock;
0101 struct list_head bufs;
0102
0103
0104
0105 u32 frame_id;
0106 int chunks_done;
0107
0108 enum {
0109 USBTV_COMPOSITE_INPUT,
0110 USBTV_SVIDEO_INPUT,
0111 } input;
0112 v4l2_std_id norm;
0113 int width, height;
0114 int n_chunks;
0115 int iso_size;
0116 int last_odd;
0117 unsigned int sequence;
0118 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
0119
0120
0121 struct snd_card *snd;
0122 struct snd_pcm_substream *snd_substream;
0123 atomic_t snd_stream;
0124 struct work_struct snd_trigger;
0125 struct urb *snd_bulk_urb;
0126 size_t snd_buffer_pos;
0127 size_t snd_period_pos;
0128 };
0129
0130 int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size);
0131
0132 int usbtv_video_init(struct usbtv *usbtv);
0133 void usbtv_video_free(struct usbtv *usbtv);
0134
0135 int usbtv_audio_init(struct usbtv *usbtv);
0136 void usbtv_audio_free(struct usbtv *usbtv);
0137 void usbtv_audio_suspend(struct usbtv *usbtv);
0138 void usbtv_audio_resume(struct usbtv *usbtv);