media: gspca: convert to vb2
The gspca core has its own buffere implementation. Use the core VB 2 instead. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
90b2da89a0
commit
1f5965c4df
|
@ -2,6 +2,7 @@ menuconfig USB_GSPCA
|
|||
tristate "GSPCA based webcams"
|
||||
depends on VIDEO_V4L2
|
||||
depends on INPUT || INPUT=n
|
||||
select VIDEOBUF2_VMALLOC
|
||||
default m
|
||||
---help---
|
||||
Say Y here if you want to enable selecting webcams based
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,6 +9,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-ctrls.h>
|
||||
#include <media/v4l2-device.h>
|
||||
#include <media/videobuf2-v4l2.h>
|
||||
#include <media/videobuf2-vmalloc.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
|
||||
|
@ -138,19 +140,22 @@ enum gspca_packet_type {
|
|||
LAST_PACKET
|
||||
};
|
||||
|
||||
struct gspca_frame {
|
||||
__u8 *data; /* frame buffer */
|
||||
int vma_use_count;
|
||||
struct v4l2_buffer v4l2_buf;
|
||||
struct gspca_buffer {
|
||||
struct vb2_v4l2_buffer vb;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
static inline struct gspca_buffer *to_gspca_buffer(struct vb2_buffer *vb2)
|
||||
{
|
||||
return container_of(vb2, struct gspca_buffer, vb.vb2_buf);
|
||||
}
|
||||
|
||||
struct gspca_dev {
|
||||
struct video_device vdev; /* !! must be the first item */
|
||||
struct module *module; /* subdriver handling the device */
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct usb_device *dev;
|
||||
struct file *capt_file; /* file doing video capture */
|
||||
/* protected by queue_lock */
|
||||
|
||||
#if IS_ENABLED(CONFIG_INPUT)
|
||||
struct input_dev *input_dev;
|
||||
char phys[64]; /* physical device path */
|
||||
|
@ -176,34 +181,29 @@ struct gspca_dev {
|
|||
struct urb *int_urb;
|
||||
#endif
|
||||
|
||||
__u8 *frbuf; /* buffer for nframes */
|
||||
struct gspca_frame frame[GSPCA_MAX_FRAMES];
|
||||
u8 *image; /* image beeing filled */
|
||||
__u32 frsz; /* frame size */
|
||||
u8 *image; /* image being filled */
|
||||
u32 image_len; /* current length of image */
|
||||
atomic_t fr_q; /* next frame to queue */
|
||||
atomic_t fr_i; /* frame being filled */
|
||||
signed char fr_queue[GSPCA_MAX_FRAMES]; /* frame queue */
|
||||
char nframes; /* number of frames */
|
||||
u8 fr_o; /* next frame to dequeue */
|
||||
__u8 last_packet_type;
|
||||
__s8 empty_packet; /* if (-1) don't check empty packets */
|
||||
__u8 streaming; /* protected by both mutexes (*) */
|
||||
bool streaming;
|
||||
|
||||
__u8 curr_mode; /* current camera mode */
|
||||
struct v4l2_pix_format pixfmt; /* current mode parameters */
|
||||
__u32 sequence; /* frame sequence number */
|
||||
|
||||
struct vb2_queue queue;
|
||||
|
||||
spinlock_t qlock;
|
||||
struct list_head buf_list;
|
||||
|
||||
wait_queue_head_t wq; /* wait queue */
|
||||
struct mutex usb_lock; /* usb exchange protection */
|
||||
struct mutex queue_lock; /* ISOC queue protection */
|
||||
int usb_err; /* USB error - protected by usb_lock */
|
||||
u16 pkt_size; /* ISOC packet size */
|
||||
#ifdef CONFIG_PM
|
||||
char frozen; /* suspend - resume */
|
||||
#endif
|
||||
char present; /* device connected */
|
||||
char nbufread; /* number of buffers for read() */
|
||||
bool present;
|
||||
char memory; /* memory type (V4L2_MEMORY_xxx) */
|
||||
__u8 iface; /* USB interface number */
|
||||
__u8 alt; /* USB alternate setting */
|
||||
|
|
|
@ -342,7 +342,7 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
|
|||
data += 4;
|
||||
len -= 4;
|
||||
|
||||
if (cur_frame_len + len <= gspca_dev->frsz) {
|
||||
if (cur_frame_len + len <= gspca_dev->pixfmt.sizeimage) {
|
||||
gspca_dbg(gspca_dev, D_FRAM, "Continuing frame %d copying %d bytes\n",
|
||||
sd->frame_count, len);
|
||||
|
||||
|
@ -351,7 +351,7 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
|
|||
} else {
|
||||
/* Add the remaining data up to frame size */
|
||||
gspca_frame_add(gspca_dev, INTER_PACKET, data,
|
||||
gspca_dev->frsz - cur_frame_len);
|
||||
gspca_dev->pixfmt.sizeimage - cur_frame_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3642,7 +3642,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
|
|||
int size, l;
|
||||
|
||||
l = gspca_dev->image_len;
|
||||
size = gspca_dev->frsz;
|
||||
size = gspca_dev->pixfmt.sizeimage;
|
||||
if (len > size - l)
|
||||
len = size - l;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue