diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-03 06:14:34 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 21:44:01 -0300 |
commit | 84b5dbf39ed2f51224841bbbf08439158d69d427 (patch) | |
tree | b24963462dc1ad93860645d8729d1ddfc6ce526e /drivers/media/video/cx231xx/cx231xx-vbi.c | |
parent | e0d3bafd02586cfde286c320f56906fd9fa8d256 (diff) |
V4L/DVB (10955): cx231xx: CodingStyle automatic fixes with Lindent
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-vbi.c')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-vbi.c | 555 |
1 files changed, 287 insertions, 268 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.c b/drivers/media/video/cx231xx/cx231xx-vbi.c index e370160973f..87a77d53faa 100644 --- a/drivers/media/video/cx231xx/cx231xx-vbi.c +++ b/drivers/media/video/cx231xx/cx231xx-vbi.c @@ -2,7 +2,7 @@ cx231xx_vbi.c - driver for Conexant Cx23100/101/102 USB video capture devices Copyright (C) 2008 <srinivasa.deevi at conexant dot com> - Based on cx88 driver + Based on cx88 driver This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,8 +39,7 @@ #include "cx231xx.h" #include "cx231xx-vbi.h" -static inline void print_err_status(struct cx231xx *dev, - int packet, int status) +static inline void print_err_status(struct cx231xx *dev, int packet, int status) { char *errmsg = "Unknown"; @@ -71,10 +70,11 @@ static inline void print_err_status(struct cx231xx *dev, break; } if (packet < 0) { - cx231xx_err(DRIVER_NAME "URB status %d [%s].\n", status, errmsg); + cx231xx_err(DRIVER_NAME "URB status %d [%s].\n", status, + errmsg); } else { cx231xx_err(DRIVER_NAME "URB packet %d, status %d [%s].\n", - packet, status, errmsg); + packet, status, errmsg); } } @@ -83,12 +83,12 @@ static inline void print_err_status(struct cx231xx *dev, */ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) { - struct cx231xx_buffer *buf; - struct cx231xx_dmaqueue *dma_q = urb->context; - int rc = 1; + struct cx231xx_buffer *buf; + struct cx231xx_dmaqueue *dma_q = urb->context; + int rc = 1; unsigned char *p_buffer; - u32 bytes_parsed = 0, buffer_size = 0; - u8 sav_eav = 0; + u32 bytes_parsed = 0, buffer_size = 0; + u8 sav_eav = 0; if (!dev) return 0; @@ -104,60 +104,58 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) buf = dev->vbi_mode.isoc_ctl.buf; - /* get buffer pointer and length */ - p_buffer = urb->transfer_buffer; - buffer_size = urb->actual_length; - - if (buffer_size > 0) { - - bytes_parsed = 0; - - if(dma_q->is_partial_line) { - /* Handle the case where we were working on a partial line */ - sav_eav = dma_q->last_sav; - } else { - /* Check for a SAV/EAV overlapping the buffer boundary */ - sav_eav = cx231xx_find_boundary_SAV_EAV(p_buffer, dma_q->partial_buf, &bytes_parsed); - } - - sav_eav &= 0xF0; - /* Get the first line if we have some portion of an SAV/EAV from the last buffer - or a partial line */ - if(sav_eav) { - bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, - sav_eav, /* SAV/EAV */ - p_buffer + bytes_parsed, /* p_buffer */ - buffer_size - bytes_parsed); /* buffer size */ - } - - /* Now parse data that is completely in this buffer */ - dma_q->is_partial_line = 0; - - while(bytes_parsed < buffer_size) - { - u32 bytes_used = 0; - - sav_eav = cx231xx_find_next_SAV_EAV( - p_buffer + bytes_parsed, /* p_buffer */ - buffer_size - bytes_parsed, /* buffer size */ - &bytes_used); /* Receives bytes used to get SAV/EAV */ - - bytes_parsed += bytes_used; - - sav_eav &= 0xF0; - if(sav_eav && (bytes_parsed < buffer_size)) - { - bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, - sav_eav, /* SAV/EAV */ - p_buffer + bytes_parsed, /* p_buffer */ - buffer_size - bytes_parsed); /* buffer size */ - } - } - - /* Save the last four bytes of the buffer so we can check the buffer boundary - condition next time */ - memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4); - bytes_parsed = 0; + /* get buffer pointer and length */ + p_buffer = urb->transfer_buffer; + buffer_size = urb->actual_length; + + if (buffer_size > 0) { + + bytes_parsed = 0; + + if (dma_q->is_partial_line) { + /* Handle the case where we were working on a partial line */ + sav_eav = dma_q->last_sav; + } else { + /* Check for a SAV/EAV overlapping the buffer boundary */ + sav_eav = + cx231xx_find_boundary_SAV_EAV(p_buffer, + dma_q->partial_buf, + &bytes_parsed); + } + + sav_eav &= 0xF0; + /* Get the first line if we have some portion of an SAV/EAV from the last buffer + or a partial line */ + if (sav_eav) { + bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, sav_eav, /* SAV/EAV */ + p_buffer + bytes_parsed, /* p_buffer */ + buffer_size - bytes_parsed); /* buffer size */ + } + + /* Now parse data that is completely in this buffer */ + dma_q->is_partial_line = 0; + + while (bytes_parsed < buffer_size) { + u32 bytes_used = 0; + + sav_eav = cx231xx_find_next_SAV_EAV(p_buffer + bytes_parsed, /* p_buffer */ + buffer_size - bytes_parsed, /* buffer size */ + &bytes_used); /* Receives bytes used to get SAV/EAV */ + + bytes_parsed += bytes_used; + + sav_eav &= 0xF0; + if (sav_eav && (bytes_parsed < buffer_size)) { + bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, sav_eav, /* SAV/EAV */ + p_buffer + bytes_parsed, /* p_buffer */ + buffer_size - bytes_parsed); /* buffer size */ + } + } + + /* Save the last four bytes of the buffer so we can check the buffer boundary + condition next time */ + memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4); + bytes_parsed = 0; } return rc; @@ -168,25 +166,26 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) ------------------------------------------------------------------*/ static int -vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) +vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count, + unsigned int *size) { struct cx231xx_fh *fh = vq->priv_data; - struct cx231xx *dev = fh->dev; - u32 height = 0; + struct cx231xx *dev = fh->dev; + u32 height = 0; height = ((dev->norm & V4L2_STD_625_50) ? - PAL_VBI_LINES : NTSC_VBI_LINES) ; + PAL_VBI_LINES : NTSC_VBI_LINES); - *size = ( dev->width * height * 2); + *size = (dev->width * height * 2); if (0 == *count) *count = CX231XX_DEF_VBI_BUF; if (*count < CX231XX_MIN_BUF) *count = CX231XX_MIN_BUF; - /* call VBI setup if required */ + /* call VBI setup if required */ /* cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f); - */ + */ return 0; } @@ -194,8 +193,8 @@ vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *s /* This is called *without* dev->slock held; please keep it that way */ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) { - struct cx231xx_fh *fh = vq->priv_data; - struct cx231xx *dev = fh->dev; + struct cx231xx_fh *fh = vq->priv_data; + struct cx231xx *dev = fh->dev; unsigned long flags = 0; if (in_interrupt()) BUG(); @@ -208,7 +207,7 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) This should be safe; by the time we get here, the buffer isn't queued anymore. If we ever start marking the buffers as VIDEOBUF_ACTIVE, it won't be, though. - */ + */ spin_lock_irqsave(&dev->vbi_mode.slock, flags); if (dev->vbi_mode.isoc_ctl.buf == buf) dev->vbi_mode.isoc_ctl.buf = NULL; @@ -220,25 +219,26 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) static int vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, - enum v4l2_field field) + enum v4l2_field field) { - struct cx231xx_fh *fh = vq->priv_data; - struct cx231xx_buffer *buf = container_of(vb, struct cx231xx_buffer, vb); - struct cx231xx *dev = fh->dev; - int rc = 0, urb_init = 0; - u32 height = 0; + struct cx231xx_fh *fh = vq->priv_data; + struct cx231xx_buffer *buf = + container_of(vb, struct cx231xx_buffer, vb); + struct cx231xx *dev = fh->dev; + int rc = 0, urb_init = 0; + u32 height = 0; height = ((dev->norm & V4L2_STD_625_50) ? - PAL_VBI_LINES : NTSC_VBI_LINES) ; - buf->vb.size = ( (dev->width << 1) * height ); + PAL_VBI_LINES : NTSC_VBI_LINES); + buf->vb.size = ((dev->width << 1) * height); - if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) + if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) return -EINVAL; - buf->vb.width = dev->width; + buf->vb.width = dev->width; buf->vb.height = height; - buf->vb.field = field; - buf->vb.field = V4L2_FIELD_SEQ_TB; + buf->vb.field = field; + buf->vb.field = V4L2_FIELD_SEQ_TB; if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { rc = videobuf_iolock(vq, &buf->vb, NULL); @@ -251,8 +251,9 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, if (urb_init) { rc = cx231xx_init_vbi_isoc(dev, CX231XX_NUM_VBI_PACKETS, - CX231XX_NUM_VBI_BUFS, dev->vbi_mode.alt_max_pkt_size[0], - cx231xx_isoc_vbi_copy); + CX231XX_NUM_VBI_BUFS, + dev->vbi_mode.alt_max_pkt_size[0], + cx231xx_isoc_vbi_copy); if (rc < 0) goto fail; } @@ -260,7 +261,7 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, buf->vb.state = VIDEOBUF_PREPARED; return 0; -fail: + fail: free_buffer(vq, buf); return rc; } @@ -268,10 +269,11 @@ fail: static void vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) { - struct cx231xx_buffer *buf = container_of(vb, struct cx231xx_buffer, vb); - struct cx231xx_fh *fh = vq->priv_data; - struct cx231xx *dev = fh->dev; - struct cx231xx_dmaqueue *vidq = &dev->vbi_mode.vidq; + struct cx231xx_buffer *buf = + container_of(vb, struct cx231xx_buffer, vb); + struct cx231xx_fh *fh = vq->priv_data; + struct cx231xx *dev = fh->dev; + struct cx231xx_dmaqueue *vidq = &dev->vbi_mode.vidq; buf->vb.state = VIDEOBUF_QUEUED; list_add_tail(&buf->vb.queue, &vidq->active); @@ -279,29 +281,27 @@ vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) } static void vbi_buffer_release(struct videobuf_queue *vq, - struct videobuf_buffer *vb) + struct videobuf_buffer *vb) { - struct cx231xx_buffer *buf = container_of(vb, struct cx231xx_buffer, vb); - /* - struct cx231xx_fh *fh = vq->priv_data; - struct cx231xx *dev = (struct cx231xx *)fh->dev; + struct cx231xx_buffer *buf = + container_of(vb, struct cx231xx_buffer, vb); + /* + struct cx231xx_fh *fh = vq->priv_data; + struct cx231xx *dev = (struct cx231xx *)fh->dev; - cx231xx_info(DRIVER_NAME "cx231xx: called vbi_buffer_release\n"); - */ + cx231xx_info(DRIVER_NAME "cx231xx: called vbi_buffer_release\n"); + */ free_buffer(vq, buf); } - struct videobuf_queue_ops cx231xx_vbi_qops = { - .buf_setup = vbi_buffer_setup, - .buf_prepare = vbi_buffer_prepare, - .buf_queue = vbi_buffer_queue, - .buf_release = vbi_buffer_release, + .buf_setup = vbi_buffer_setup, + .buf_prepare = vbi_buffer_prepare, + .buf_queue = vbi_buffer_queue, + .buf_release = vbi_buffer_release, }; - - /* ------------------------------------------------------------------ URB control ------------------------------------------------------------------*/ @@ -311,23 +311,24 @@ struct videobuf_queue_ops cx231xx_vbi_qops = { */ static void cx231xx_irq_vbi_callback(struct urb *urb) { - struct cx231xx_dmaqueue *dma_q = urb->context; - struct cx231xx_video_mode *vmode = container_of(dma_q, struct cx231xx_video_mode, vidq); - struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); + struct cx231xx_dmaqueue *dma_q = urb->context; + struct cx231xx_video_mode *vmode = + container_of(dma_q, struct cx231xx_video_mode, vidq); + struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); int rc; - - switch (urb->status) { - case 0: /* success */ - case -ETIMEDOUT: /* NAK */ - break; - case -ECONNRESET: /* kill */ - case -ENOENT: - case -ESHUTDOWN: - return; - default: /* error */ - cx231xx_err(DRIVER_NAME "urb completition error %d.\n", urb->status); - break; + switch (urb->status) { + case 0: /* success */ + case -ETIMEDOUT: /* NAK */ + break; + case -ECONNRESET: /* kill */ + case -ENOENT: + case -ESHUTDOWN: + return; + default: /* error */ + cx231xx_err(DRIVER_NAME "urb completition error %d.\n", + urb->status); + break; } /* Copy data from URB */ @@ -341,7 +342,7 @@ static void cx231xx_irq_vbi_callback(struct urb *urb) urb->status = usb_submit_urb(urb, GFP_ATOMIC); if (urb->status) { cx231xx_err(DRIVER_NAME "urb resubmit failed (error=%i)\n", - urb->status); + urb->status); } } @@ -353,21 +354,23 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev) struct urb *urb; int i; - cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_uninit_vbi_isoc\n"); + cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_uninit_vbi_isoc\n"); dev->vbi_mode.isoc_ctl.nfields = -1; for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { urb = dev->vbi_mode.isoc_ctl.urb[i]; if (urb) { - if (!irqs_disabled()) - usb_kill_urb(urb); - else - usb_unlink_urb(urb); + if (!irqs_disabled()) + usb_kill_urb(urb); + else + usb_unlink_urb(urb); if (dev->vbi_mode.isoc_ctl.transfer_buffer[i]) { - kfree(dev->vbi_mode.isoc_ctl.transfer_buffer[i]); - dev->vbi_mode.isoc_ctl.transfer_buffer[i] = NULL; + kfree(dev->vbi_mode.isoc_ctl. + transfer_buffer[i]); + dev->vbi_mode.isoc_ctl.transfer_buffer[i] = + NULL; } usb_free_urb(urb); dev->vbi_mode.isoc_ctl.urb[i] = NULL; @@ -384,14 +387,16 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev) cx231xx_capture_start(dev, 0, Vbi); } + EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc); /* * Allocate URBs and start IRQ */ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, - int num_bufs, int max_pkt_size, - int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)) + int num_bufs, int max_pkt_size, + int (*isoc_copy) (struct cx231xx * dev, + struct urb * urb)) { struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq; int i; @@ -404,31 +409,33 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, /* De-allocates all pending stuff */ cx231xx_uninit_vbi_isoc(dev); - /* clear if any halt */ - usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr)); - + /* clear if any halt */ + usb_clear_halt(dev->udev, + usb_rcvbulkpipe(dev->udev, + dev->vbi_mode.end_point_addr)); dev->vbi_mode.isoc_ctl.isoc_copy = isoc_copy; dev->vbi_mode.isoc_ctl.num_bufs = num_bufs; - dma_q->pos = 0; - dma_q->is_partial_line = 0; - dma_q->last_sav = 0; - dma_q->current_field = -1; - dma_q->bytes_left_in_line = dev->width << 1; - dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ? - PAL_VBI_LINES : NTSC_VBI_LINES) ; - dma_q->lines_completed = 0; - for(i = 0; i < 8 ; i++) - dma_q->partial_buf[i] = 0; - - dev->vbi_mode.isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); + dma_q->pos = 0; + dma_q->is_partial_line = 0; + dma_q->last_sav = 0; + dma_q->current_field = -1; + dma_q->bytes_left_in_line = dev->width << 1; + dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ? + PAL_VBI_LINES : NTSC_VBI_LINES); + dma_q->lines_completed = 0; + for (i = 0; i < 8; i++) + dma_q->partial_buf[i] = 0; + + dev->vbi_mode.isoc_ctl.urb = + kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->vbi_mode.isoc_ctl.urb) { cx231xx_errdev("cannot alloc memory for usb buffers\n"); return -ENOMEM; } - dev->vbi_mode.isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, - GFP_KERNEL); + dev->vbi_mode.isoc_ctl.transfer_buffer = + kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->vbi_mode.isoc_ctl.transfer_buffer) { cx231xx_errdev("cannot allocate memory for usbtransfer\n"); kfree(dev->vbi_mode.isoc_ctl.urb); @@ -445,27 +452,29 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) { - cx231xx_err(DRIVER_NAME ": cannot alloc isoc_ctl.urb %i\n", i); + cx231xx_err(DRIVER_NAME + ": cannot alloc isoc_ctl.urb %i\n", i); cx231xx_uninit_vbi_isoc(dev); return -ENOMEM; } dev->vbi_mode.isoc_ctl.urb[i] = urb; - urb->transfer_flags = 0; + urb->transfer_flags = 0; - dev->vbi_mode.isoc_ctl.transfer_buffer[i] = kzalloc(sb_size, GFP_KERNEL); + dev->vbi_mode.isoc_ctl.transfer_buffer[i] = + kzalloc(sb_size, GFP_KERNEL); if (!dev->vbi_mode.isoc_ctl.transfer_buffer[i]) { - cx231xx_err(DRIVER_NAME ": unable to allocate %i bytes for transfer" - " buffer %i%s\n", - sb_size, i, - in_interrupt()?" while in int":""); + cx231xx_err(DRIVER_NAME + ": unable to allocate %i bytes for transfer" + " buffer %i%s\n", sb_size, i, + in_interrupt()? " while in int" : ""); cx231xx_uninit_vbi_isoc(dev); return -ENOMEM; } pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr); - usb_fill_bulk_urb(urb, dev->udev, pipe, - dev->vbi_mode.isoc_ctl.transfer_buffer[i], sb_size, - cx231xx_irq_vbi_callback, dma_q); + usb_fill_bulk_urb(urb, dev->udev, pipe, + dev->vbi_mode.isoc_ctl.transfer_buffer[i], + sb_size, cx231xx_irq_vbi_callback, dma_q); } init_waitqueue_head(&dma_q->wq); @@ -474,55 +483,58 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { rc = usb_submit_urb(dev->vbi_mode.isoc_ctl.urb[i], GFP_ATOMIC); if (rc) { - cx231xx_err(DRIVER_NAME ": submit of urb %i failed (error=%i)\n", i, - rc); + cx231xx_err(DRIVER_NAME + ": submit of urb %i failed (error=%i)\n", i, + rc); cx231xx_uninit_vbi_isoc(dev); return rc; } } - cx231xx_capture_start(dev, 1, Vbi); + cx231xx_capture_start(dev, 1, Vbi); return 0; } -EXPORT_SYMBOL_GPL(cx231xx_init_vbi_isoc); +EXPORT_SYMBOL_GPL(cx231xx_init_vbi_isoc); -u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, - u8 sav_eav, u8 *p_buffer, u32 buffer_size) +u32 cx231xx_get_vbi_line(struct cx231xx * dev, struct cx231xx_dmaqueue * dma_q, + u8 sav_eav, u8 * p_buffer, u32 buffer_size) { - u32 bytes_copied = 0; - int current_field = -1; + u32 bytes_copied = 0; + int current_field = -1; - switch(sav_eav) { + switch (sav_eav) { - case SAV_VBI_FIELD1: - current_field = 1; - break; + case SAV_VBI_FIELD1: + current_field = 1; + break; - case SAV_VBI_FIELD2: - current_field = 2; - break; - default: - break; - } + case SAV_VBI_FIELD2: + current_field = 2; + break; + default: + break; + } - if(current_field < 0 ) - return bytes_copied; + if (current_field < 0) + return bytes_copied; - dma_q->last_sav = sav_eav; + dma_q->last_sav = sav_eav; - bytes_copied = cx231xx_copy_vbi_line(dev, dma_q, p_buffer, buffer_size, current_field); + bytes_copied = + cx231xx_copy_vbi_line(dev, dma_q, p_buffer, buffer_size, + current_field); - return bytes_copied; + return bytes_copied; } /* * Announces that a buffer were filled and request the next */ static inline void vbi_buffer_filled(struct cx231xx *dev, - struct cx231xx_dmaqueue *dma_q, - struct cx231xx_buffer *buf) + struct cx231xx_dmaqueue *dma_q, + struct cx231xx_buffer *buf) { /* Advice that buffer was filled */ /* cx231xx_info(DRIVER_NAME "[%p/%d] wakeup\n", buf, buf->vb.i); */ @@ -537,80 +549,83 @@ static inline void vbi_buffer_filled(struct cx231xx *dev, wake_up(&buf->vb.done); } -u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, - u8 *p_line, u32 length, int field_number) +u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, + u8 * p_line, u32 length, int field_number) { - u32 bytes_to_copy; - struct cx231xx_buffer *buf; - u32 _line_size = dev->width * 2; + u32 bytes_to_copy; + struct cx231xx_buffer *buf; + u32 _line_size = dev->width * 2; - if( dma_q->current_field != field_number ) { - cx231xx_reset_vbi_buffer(dev, dma_q); - } + if (dma_q->current_field != field_number) { + cx231xx_reset_vbi_buffer(dev, dma_q); + } - /* get the buffer pointer */ - buf = dev->vbi_mode.isoc_ctl.buf; + /* get the buffer pointer */ + buf = dev->vbi_mode.isoc_ctl.buf; - /* Remember the field number for next time */ - dma_q->current_field = field_number; + /* Remember the field number for next time */ + dma_q->current_field = field_number; - bytes_to_copy = dma_q->bytes_left_in_line; - if(bytes_to_copy > length) - bytes_to_copy = length; + bytes_to_copy = dma_q->bytes_left_in_line; + if (bytes_to_copy > length) + bytes_to_copy = length; - if(dma_q->lines_completed >= dma_q->lines_per_field) { - dma_q->bytes_left_in_line -= bytes_to_copy; - dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? 0 : 1; - return 0; - } + if (dma_q->lines_completed >= dma_q->lines_per_field) { + dma_q->bytes_left_in_line -= bytes_to_copy; + dma_q->is_partial_line = + (dma_q->bytes_left_in_line == 0) ? 0 : 1; + return 0; + } - dma_q->is_partial_line = 1; + dma_q->is_partial_line = 1; - /* If we don't have a buffer, just return the number of bytes we would - have copied if we had a buffer. */ - if(!buf) { - dma_q->bytes_left_in_line -= bytes_to_copy; - dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? 0 : 1; - return bytes_to_copy; - } + /* If we don't have a buffer, just return the number of bytes we would + have copied if we had a buffer. */ + if (!buf) { + dma_q->bytes_left_in_line -= bytes_to_copy; + dma_q->is_partial_line = + (dma_q->bytes_left_in_line == 0) ? 0 : 1; + return bytes_to_copy; + } - /* copy the data to video buffer */ - cx231xx_do_vbi_copy(dev, dma_q, p_line, bytes_to_copy); + /* copy the data to video buffer */ + cx231xx_do_vbi_copy(dev, dma_q, p_line, bytes_to_copy); - dma_q->pos += bytes_to_copy; - dma_q->bytes_left_in_line -= bytes_to_copy; + dma_q->pos += bytes_to_copy; + dma_q->bytes_left_in_line -= bytes_to_copy; - if(dma_q->bytes_left_in_line == 0) { + if (dma_q->bytes_left_in_line == 0) { - dma_q->bytes_left_in_line = _line_size; - dma_q->lines_completed++; - dma_q->is_partial_line = 0; + dma_q->bytes_left_in_line = _line_size; + dma_q->lines_completed++; + dma_q->is_partial_line = 0; - if(cx231xx_is_vbi_buffer_done(dev, dma_q) && buf ) { + if (cx231xx_is_vbi_buffer_done(dev, dma_q) && buf) { - vbi_buffer_filled(dev, dma_q, buf); + vbi_buffer_filled(dev, dma_q, buf); - dma_q->pos = 0; - buf = NULL; - dma_q->lines_completed = 0; - } - } + dma_q->pos = 0; + buf = NULL; + dma_q->lines_completed = 0; + } + } - return bytes_to_copy; + return bytes_to_copy; } /* * video-buf generic routine to get the next available buffer */ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q, - struct cx231xx_buffer **buf) + struct cx231xx_buffer **buf) { - struct cx231xx_video_mode *vmode = container_of(dma_q, struct cx231xx_video_mode, vidq); - struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); + struct cx231xx_video_mode *vmode = + container_of(dma_q, struct cx231xx_video_mode, vidq); + struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); char *outp; if (list_empty(&dma_q->active)) { - cx231xx_err(DRIVER_NAME ": No active queue to serve\n"); + cx231xx_err(DRIVER_NAME ": No active queue to serve\n"); dev->vbi_mode.isoc_ctl.buf = NULL; *buf = NULL; return; @@ -628,66 +643,70 @@ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q, return; } - -void cx231xx_reset_vbi_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q) +void cx231xx_reset_vbi_buffer(struct cx231xx *dev, + struct cx231xx_dmaqueue *dma_q) { - struct cx231xx_buffer *buf; + struct cx231xx_buffer *buf; - buf = dev->vbi_mode.isoc_ctl.buf; + buf = dev->vbi_mode.isoc_ctl.buf; - if(buf == NULL) { + if (buf == NULL) { - /* first try to get the buffer */ - get_next_vbi_buf(dma_q, &buf); + /* first try to get the buffer */ + get_next_vbi_buf(dma_q, &buf); - dma_q->pos = 0; - dma_q->current_field = -1; - } + dma_q->pos = 0; + dma_q->current_field = -1; + } - dma_q->bytes_left_in_line = dev->width << 1; - dma_q->lines_completed = 0; + dma_q->bytes_left_in_line = dev->width << 1; + dma_q->lines_completed = 0; } int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, - u8 *p_buffer, u32 bytes_to_copy) + u8 * p_buffer, u32 bytes_to_copy) { - u8 *p_out_buffer = NULL; - u32 current_line_bytes_copied = 0; - struct cx231xx_buffer *buf; - u32 _line_size = dev->width << 1; - void *startwrite; - int offset, lencopy; + u8 *p_out_buffer = NULL; + u32 current_line_bytes_copied = 0; + struct cx231xx_buffer *buf; + u32 _line_size = dev->width << 1; + void *startwrite; + int offset, lencopy; - buf = dev->vbi_mode.isoc_ctl.buf; + buf = dev->vbi_mode.isoc_ctl.buf; - if (buf == NULL) { - return -1; - } + if (buf == NULL) { + return -1; + } p_out_buffer = videobuf_to_vmalloc(&buf->vb); - if(dma_q->bytes_left_in_line != _line_size ) { - current_line_bytes_copied = _line_size - dma_q->bytes_left_in_line; - } + if (dma_q->bytes_left_in_line != _line_size) { + current_line_bytes_copied = + _line_size - dma_q->bytes_left_in_line; + } - offset = ( dma_q->lines_completed * _line_size ) + current_line_bytes_copied; + offset = + (dma_q->lines_completed * _line_size) + current_line_bytes_copied; - /* prepare destination address */ + /* prepare destination address */ startwrite = p_out_buffer + offset; - lencopy = dma_q->bytes_left_in_line > bytes_to_copy ? bytes_to_copy : dma_q->bytes_left_in_line; + lencopy = + dma_q->bytes_left_in_line > + bytes_to_copy ? bytes_to_copy : dma_q->bytes_left_in_line; - memcpy(startwrite, p_buffer, lencopy); + memcpy(startwrite, p_buffer, lencopy); - return 0; + return 0; } - -u8 cx231xx_is_vbi_buffer_done(struct cx231xx *dev,struct cx231xx_dmaqueue *dma_q) +u8 cx231xx_is_vbi_buffer_done(struct cx231xx * dev, + struct cx231xx_dmaqueue * dma_q) { - u32 height = 0; + u32 height = 0; height = ((dev->norm & V4L2_STD_625_50) ? - PAL_VBI_LINES : NTSC_VBI_LINES) ; - return (dma_q->lines_completed == height)?1:0; + PAL_VBI_LINES : NTSC_VBI_LINES); + return (dma_q->lines_completed == height) ? 1 : 0; } |