V4L/DVB (9078): gspca: New exported function to retrieve the current frame buffer.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Jean-Francois Moine 2008-09-20 05:44:21 -03:00 committed by Mauro Carvalho Chehab
parent 9de436cfc4
commit 1b60e1adc7
2 changed files with 22 additions and 12 deletions

View File

@ -102,6 +102,22 @@ static struct vm_operations_struct gspca_vm_ops = {
.close = gspca_vm_close, .close = gspca_vm_close,
}; };
/* get the current input frame buffer */
struct gspca_frame *gspca_get_i_frame(struct gspca_dev *gspca_dev)
{
struct gspca_frame *frame;
int i;
i = gspca_dev->fr_i;
i = gspca_dev->fr_queue[i];
frame = &gspca_dev->frame[i];
if ((frame->v4l2_buf.flags & BUF_ALL_FLAGS)
!= V4L2_BUF_FLAG_QUEUED)
return NULL;
return frame;
}
EXPORT_SYMBOL(gspca_get_i_frame);
/* /*
* fill a video frame from an URB and resubmit * fill a video frame from an URB and resubmit
*/ */
@ -110,7 +126,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
{ {
struct gspca_frame *frame; struct gspca_frame *frame;
__u8 *data; /* address of data in the iso message */ __u8 *data; /* address of data in the iso message */
int i, j, len, st; int i, len, st;
cam_pkt_op pkt_scan; cam_pkt_op pkt_scan;
if (urb->status != 0) { if (urb->status != 0) {
@ -124,11 +140,8 @@ static void fill_frame(struct gspca_dev *gspca_dev,
for (i = 0; i < urb->number_of_packets; i++) { for (i = 0; i < urb->number_of_packets; i++) {
/* check the availability of the frame buffer */ /* check the availability of the frame buffer */
j = gspca_dev->fr_i; frame = gspca_get_i_frame(gspca_dev);
j = gspca_dev->fr_queue[j]; if (!frame) {
frame = &gspca_dev->frame[j];
if ((frame->v4l2_buf.flags & BUF_ALL_FLAGS)
!= V4L2_BUF_FLAG_QUEUED) {
gspca_dev->last_packet_type = DISCARD_PACKET; gspca_dev->last_packet_type = DISCARD_PACKET;
break; break;
} }
@ -185,7 +198,6 @@ static void bulk_irq(struct urb *urb
{ {
struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;
struct gspca_frame *frame; struct gspca_frame *frame;
int j;
PDEBUG(D_PACK, "bulk irq"); PDEBUG(D_PACK, "bulk irq");
if (!gspca_dev->streaming) if (!gspca_dev->streaming)
@ -199,11 +211,8 @@ static void bulk_irq(struct urb *urb
} }
/* check the availability of the frame buffer */ /* check the availability of the frame buffer */
j = gspca_dev->fr_i; frame = gspca_get_i_frame(gspca_dev);
j = gspca_dev->fr_queue[j]; if (!frame) {
frame = &gspca_dev->frame[j];
if ((frame->v4l2_buf.flags & BUF_ALL_FLAGS)
!= V4L2_BUF_FLAG_QUEUED) {
gspca_dev->last_packet_type = DISCARD_PACKET; gspca_dev->last_packet_type = DISCARD_PACKET;
} else { } else {
PDEBUG(D_PACK, "packet l:%d", urb->actual_length); PDEBUG(D_PACK, "packet l:%d", urb->actual_length);

View File

@ -178,6 +178,7 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
struct gspca_frame *frame, struct gspca_frame *frame,
const __u8 *data, const __u8 *data,
int len); int len);
struct gspca_frame *gspca_get_i_frame(struct gspca_dev *gspca_dev);
#ifdef CONFIG_PM #ifdef CONFIG_PM
int gspca_suspend(struct usb_interface *intf, pm_message_t message); int gspca_suspend(struct usb_interface *intf, pm_message_t message);
int gspca_resume(struct usb_interface *intf); int gspca_resume(struct usb_interface *intf);