2014-01-08 06:13:21 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Lubomir Rintel
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL").
|
2016-06-01 21:03:44 +08:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Fushicai USBTV007 Audio-Video Grabber Driver
|
|
|
|
*
|
|
|
|
* No physical hardware was harmed running Windows during the
|
|
|
|
* reverse-engineering activity
|
2014-01-08 06:13:21 +08:00
|
|
|
*/
|
|
|
|
|
2014-02-04 17:00:52 +08:00
|
|
|
#include <linux/module.h>
|
2014-01-08 06:13:21 +08:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
|
|
|
|
#include <media/v4l2-device.h>
|
2016-10-16 17:38:22 +08:00
|
|
|
#include <media/v4l2-ctrls.h>
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
#include <media/videobuf2-v4l2.h>
|
2014-01-08 06:13:21 +08:00
|
|
|
#include <media/videobuf2-vmalloc.h>
|
|
|
|
|
|
|
|
/* Hardware. */
|
|
|
|
#define USBTV_VIDEO_ENDP 0x81
|
2014-08-12 05:42:22 +08:00
|
|
|
#define USBTV_AUDIO_ENDP 0x83
|
2014-01-08 06:13:21 +08:00
|
|
|
#define USBTV_BASE 0xc000
|
2016-10-16 17:38:22 +08:00
|
|
|
#define USBTV_CONTROL_REG 11
|
2014-01-08 06:13:21 +08:00
|
|
|
#define USBTV_REQUEST_REG 12
|
|
|
|
|
|
|
|
/* Number of concurrent isochronous urbs submitted.
|
|
|
|
* Higher numbers was seen to overly saturate the USB bus. */
|
|
|
|
#define USBTV_ISOC_TRANSFERS 16
|
|
|
|
#define USBTV_ISOC_PACKETS 8
|
|
|
|
|
|
|
|
#define USBTV_CHUNK_SIZE 256
|
|
|
|
#define USBTV_CHUNK 240
|
|
|
|
|
2014-08-12 05:42:22 +08:00
|
|
|
#define USBTV_AUDIO_URBSIZE 20480
|
|
|
|
#define USBTV_AUDIO_HDRSIZE 4
|
|
|
|
#define USBTV_AUDIO_BUFFER 65536
|
|
|
|
|
2014-01-08 06:13:21 +08:00
|
|
|
/* Chunk header. */
|
|
|
|
#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
|
|
|
|
== 0x88000000)
|
|
|
|
#define USBTV_FRAME_ID(chunk) ((be32_to_cpu(chunk[0]) & 0x00ff0000) >> 16)
|
|
|
|
#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
|
|
|
|
#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff)
|
|
|
|
|
|
|
|
#define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL)
|
|
|
|
|
|
|
|
/* parameters for supported TV norms */
|
|
|
|
struct usbtv_norm_params {
|
|
|
|
v4l2_std_id norm;
|
|
|
|
int cap_width, cap_height;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* A single videobuf2 frame buffer. */
|
|
|
|
struct usbtv_buf {
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer vb;
|
2014-01-08 06:13:21 +08:00
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Per-device structure. */
|
|
|
|
struct usbtv {
|
|
|
|
struct device *dev;
|
|
|
|
struct usb_device *udev;
|
|
|
|
|
|
|
|
/* video */
|
|
|
|
struct v4l2_device v4l2_dev;
|
2016-10-16 17:38:22 +08:00
|
|
|
struct v4l2_ctrl_handler ctrl;
|
2014-01-08 06:13:21 +08:00
|
|
|
struct video_device vdev;
|
|
|
|
struct vb2_queue vb2q;
|
|
|
|
struct mutex v4l2_lock;
|
|
|
|
struct mutex vb2q_lock;
|
|
|
|
|
|
|
|
/* List of videobuf2 buffers protected by a lock. */
|
|
|
|
spinlock_t buflock;
|
|
|
|
struct list_head bufs;
|
|
|
|
|
|
|
|
/* Number of currently processed frame, useful find
|
|
|
|
* out when a new one begins. */
|
|
|
|
u32 frame_id;
|
|
|
|
int chunks_done;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
USBTV_COMPOSITE_INPUT,
|
|
|
|
USBTV_SVIDEO_INPUT,
|
|
|
|
} input;
|
|
|
|
v4l2_std_id norm;
|
|
|
|
int width, height;
|
|
|
|
int n_chunks;
|
|
|
|
int iso_size;
|
2015-12-20 19:57:17 +08:00
|
|
|
int last_odd;
|
2014-01-08 06:13:21 +08:00
|
|
|
unsigned int sequence;
|
|
|
|
struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
|
2014-08-12 05:42:22 +08:00
|
|
|
|
|
|
|
/* audio */
|
|
|
|
struct snd_card *snd;
|
|
|
|
struct snd_pcm_substream *snd_substream;
|
|
|
|
atomic_t snd_stream;
|
|
|
|
struct work_struct snd_trigger;
|
|
|
|
struct urb *snd_bulk_urb;
|
|
|
|
size_t snd_buffer_pos;
|
|
|
|
size_t snd_period_pos;
|
2014-01-08 06:13:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size);
|
|
|
|
|
|
|
|
int usbtv_video_init(struct usbtv *usbtv);
|
|
|
|
void usbtv_video_free(struct usbtv *usbtv);
|
2014-08-12 05:42:22 +08:00
|
|
|
|
|
|
|
int usbtv_audio_init(struct usbtv *usbtv);
|
|
|
|
void usbtv_audio_free(struct usbtv *usbtv);
|
|
|
|
void usbtv_audio_suspend(struct usbtv *usbtv);
|
|
|
|
void usbtv_audio_resume(struct usbtv *usbtv);
|