aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/cx231xx/cx231xx-video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-video.c')
-rw-r--r--drivers/media/video/cx231xx/cx231xx-video.c1820
1 files changed, 921 insertions, 899 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c
index 3eb5626ead1..18919e0f019 100644
--- a/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/drivers/media/video/cx231xx/cx231xx-video.c
@@ -2,9 +2,9 @@
cx231xx-video.c - driver for Conexant Cx23100/101/102 USB video capture devices
Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
- Based on em28xx driver
- Based on cx23885 driver
- Based on cx88 driver
+ Based on em28xx driver
+ Based on cx23885 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
@@ -21,7 +21,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
#include <linux/init.h>
#include <linux/list.h>
#include <linux/module.h>
@@ -44,11 +43,9 @@
#include "cx231xx.h"
#include "cx231xx-vbi.h"
-
#define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>"
#define DRIVER_DESC "Conexant cx231xx based USB video device driver"
-
#define cx231xx_videodbg(fmt, arg...) do {\
if (video_debug) \
printk(KERN_INFO "%s %s :"fmt, \
@@ -70,138 +67,133 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
-
-
static unsigned int card[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET };
static unsigned int video_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET };
static unsigned int vbi_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET };
static unsigned int radio_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET };
-module_param_array(card, int, NULL, 0444);
+module_param_array(card, int, NULL, 0444);
module_param_array(video_nr, int, NULL, 0444);
module_param_array(vbi_nr, int, NULL, 0444);
module_param_array(radio_nr, int, NULL, 0444);
-MODULE_PARM_DESC(card, "card type");
+MODULE_PARM_DESC(card, "card type");
MODULE_PARM_DESC(video_nr, "video device numbers");
-MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
+MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
MODULE_PARM_DESC(radio_nr, "radio device numbers");
static unsigned int video_debug;
module_param(video_debug, int, 0644);
MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
-
-
/* supported video standards */
static struct cx231xx_fmt format[] = {
{
- .name = "16bpp YUY2, 4:2:2, packed",
- .fourcc = V4L2_PIX_FMT_YUYV,
- .depth = 16,
- .reg = 0,
- },
+ .name = "16bpp YUY2, 4:2:2, packed",
+ .fourcc = V4L2_PIX_FMT_YUYV,
+ .depth = 16,
+ .reg = 0,
+ },
};
-
/* supported controls */
/* Common to all boards */
/* ------------------------------------------------------------------- */
static const struct v4l2_queryctrl no_ctl = {
- .name = "42",
+ .name = "42",
.flags = V4L2_CTRL_FLAG_DISABLED,
};
static struct cx231xx_ctrl cx231xx_ctls[] = {
/* --- video --- */
{
- .v = {
- .id = V4L2_CID_BRIGHTNESS,
- .name = "Brightness",
- .minimum = 0x00,
- .maximum = 0xff,
- .step = 1,
- .default_value = 0x7f,
- .type = V4L2_CTRL_TYPE_INTEGER,
- },
- .off = 128,
- .reg = LUMA_CTRL,
- .mask = 0x00ff,
- .shift = 0,
- }, {
- .v = {
- .id = V4L2_CID_CONTRAST,
- .name = "Contrast",
- .minimum = 0,
- .maximum = 0xff,
- .step = 1,
- .default_value = 0x3f,
- .type = V4L2_CTRL_TYPE_INTEGER,
- },
- .off = 0,
- .reg = LUMA_CTRL,
- .mask = 0xff00,
- .shift = 8,
- }, {
- .v = {
- .id = V4L2_CID_HUE,
- .name = "Hue",
- .minimum = 0,
- .maximum = 0xff,
- .step = 1,
- .default_value = 0x7f,
- .type = V4L2_CTRL_TYPE_INTEGER,
- },
- .off = 128,
- .reg = CHROMA_CTRL,
- .mask = 0xff0000,
- .shift = 16,
- }, {
- /* strictly, this only describes only U saturation.
- * V saturation is handled specially through code.
- */
- .v = {
- .id = V4L2_CID_SATURATION,
- .name = "Saturation",
- .minimum = 0,
- .maximum = 0xff,
- .step = 1,
- .default_value = 0x7f,
- .type = V4L2_CTRL_TYPE_INTEGER,
- },
- .off = 0,
- .reg = CHROMA_CTRL,
- .mask = 0x00ff,
- .shift = 0,
- }, {
- /* --- audio --- */
- .v = {
- .id = V4L2_CID_AUDIO_MUTE,
- .name = "Mute",
- .minimum = 0,
- .maximum = 1,
- .default_value = 1,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- },
- .reg = PATH1_CTL1,
- .mask = (0x1f << 24),
- .shift = 24,
- }, {
- .v = {
- .id = V4L2_CID_AUDIO_VOLUME,
- .name = "Volume",
- .minimum = 0,
- .maximum = 0x3f,
- .step = 1,
- .default_value = 0x3f,
- .type = V4L2_CTRL_TYPE_INTEGER,
- },
- .reg = PATH1_VOL_CTL,
- .mask = 0xff,
- .shift = 0,
- }
+ .v = {
+ .id = V4L2_CID_BRIGHTNESS,
+ .name = "Brightness",
+ .minimum = 0x00,
+ .maximum = 0xff,
+ .step = 1,
+ .default_value = 0x7f,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ },
+ .off = 128,
+ .reg = LUMA_CTRL,
+ .mask = 0x00ff,
+ .shift = 0,
+ }, {
+ .v = {
+ .id = V4L2_CID_CONTRAST,
+ .name = "Contrast",
+ .minimum = 0,
+ .maximum = 0xff,
+ .step = 1,
+ .default_value = 0x3f,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ },
+ .off = 0,
+ .reg = LUMA_CTRL,
+ .mask = 0xff00,
+ .shift = 8,
+ }, {
+ .v = {
+ .id = V4L2_CID_HUE,
+ .name = "Hue",
+ .minimum = 0,
+ .maximum = 0xff,
+ .step = 1,
+ .default_value = 0x7f,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ },
+ .off = 128,
+ .reg = CHROMA_CTRL,
+ .mask = 0xff0000,
+ .shift = 16,
+ }, {
+ /* strictly, this only describes only U saturation.
+ * V saturation is handled specially through code.
+ */
+ .v = {
+ .id = V4L2_CID_SATURATION,
+ .name = "Saturation",
+ .minimum = 0,
+ .maximum = 0xff,
+ .step = 1,
+ .default_value = 0x7f,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ },
+ .off = 0,
+ .reg = CHROMA_CTRL,
+ .mask = 0x00ff,
+ .shift = 0,
+ }, {
+ /* --- audio --- */
+ .v = {
+ .id = V4L2_CID_AUDIO_MUTE,
+ .name = "Mute",
+ .minimum = 0,
+ .maximum = 1,
+ .default_value = 1,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ },
+ .reg = PATH1_CTL1,
+ .mask = (0x1f << 24),
+ .shift = 24,
+ }, {
+ .v = {
+ .id = V4L2_CID_AUDIO_VOLUME,
+ .name = "Volume",
+ .minimum = 0,
+ .maximum = 0x3f,
+ .step = 1,
+ .default_value = 0x3f,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ },
+ .reg = PATH1_VOL_CTL,
+ .mask = 0xff,
+ .shift = 0,
+ }
};
static const int CX231XX_CTLS = ARRAY_SIZE(cx231xx_ctls);
@@ -224,7 +216,6 @@ static const u32 *ctrl_classes[] = {
NULL
};
-
/* ------------------------------------------------------------------
Video buffer and parser functions
------------------------------------------------------------------*/
@@ -233,8 +224,8 @@ static const u32 *ctrl_classes[] = {
* Announces that a buffer were filled and request the next
*/
static inline void 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_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i);
@@ -248,9 +239,7 @@ static inline void buffer_filled(struct cx231xx *dev,
wake_up(&buf->vb.done);
}
-
-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";
@@ -281,10 +270,10 @@ static inline void print_err_status(struct cx231xx *dev,
break;
}
if (packet < 0) {
- cx231xx_isocdbg("URB status %d [%s].\n", status, errmsg);
+ cx231xx_isocdbg("URB status %d [%s].\n", status, errmsg);
} else {
cx231xx_isocdbg("URB packet %d, status %d [%s].\n",
- packet, status, errmsg);
+ packet, status, errmsg);
}
}
@@ -292,14 +281,14 @@ static inline void print_err_status(struct cx231xx *dev,
* video-buf generic routine to get the next available buffer
*/
static inline void get_next_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, video_mode);
+ struct cx231xx_video_mode *vmode =
+ container_of(dma_q, struct cx231xx_video_mode, vidq);
+ struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode);
char *outp;
-
if (list_empty(&dma_q->active)) {
cx231xx_isocdbg("No active queue to serve\n");
dev->video_mode.isoc_ctl.buf = NULL;
@@ -324,13 +313,13 @@ static inline void get_next_buf(struct cx231xx_dmaqueue *dma_q,
*/
static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)
{
- struct cx231xx_buffer *buf;
- struct cx231xx_dmaqueue *dma_q = urb->context;
+ struct cx231xx_buffer *buf;
+ struct cx231xx_dmaqueue *dma_q = urb->context;
unsigned char *outp = NULL;
- int i, rc = 1;
+ int i, 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;
@@ -357,342 +346,347 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)
continue;
}
- if (urb->iso_frame_desc[i].actual_length <= 0) {
+ if (urb->iso_frame_desc[i].actual_length <= 0) {
/* cx231xx_isocdbg("packet %d is empty",i); - spammy */
continue;
}
if (urb->iso_frame_desc[i].actual_length >
- dev->video_mode.max_pkt_size) {
+ dev->video_mode.max_pkt_size) {
cx231xx_isocdbg("packet bigger than packet size");
continue;
}
- /* get buffer pointer and length */
+ /* get buffer pointer and length */
p_buffer = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
- buffer_size = urb->iso_frame_desc[i].actual_length;
- 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_video_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_video_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;
+ buffer_size = urb->iso_frame_desc[i].actual_length;
+ 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);
+ }
- }
- return rc;
-}
+ 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_video_line(dev, dma_q, sav_eav, /* SAV/EAV */
+ p_buffer + bytes_parsed, /* p_buffer */
+ buffer_size - bytes_parsed); /* buffer size */
+ }
-u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_used)
-{
- u32 bytes_used;
- u8 boundary_bytes[8];
- u8 sav_eav = 0;
+ /* Now parse data that is completely in this buffer */
+ /* dma_q->is_partial_line = 0; */
- *p_bytes_used = 0;
+ while (bytes_parsed < buffer_size) {
+ u32 bytes_used = 0;
- /* Create an array of the last 4 bytes of the last buffer and the first
- 4 bytes of the current buffer. */
+ 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 */
- memcpy(boundary_bytes, partial_buf, 4);
- memcpy(boundary_bytes + 4, p_buffer, 4);
+ bytes_parsed += bytes_used;
- /* Check for the SAV/EAV in the boundary buffer */
- sav_eav = cx231xx_find_next_SAV_EAV((u8*)&boundary_bytes, 8, &bytes_used);
+ sav_eav &= 0xF0;
+ if (sav_eav && (bytes_parsed < buffer_size)) {
+ bytes_parsed += cx231xx_get_video_line(dev, dma_q, sav_eav, /* SAV/EAV */
+ p_buffer + bytes_parsed, /* p_buffer */
+ buffer_size - bytes_parsed); /* buffer size */
+ }
+ }
- if(sav_eav) {
- /* found a boundary SAV/EAV. Updates the bytes used to reflect
- only those used in the new buffer */
- *p_bytes_used = bytes_used - 4;
- }
+ /* 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 sav_eav;
+ }
+ return rc;
}
-u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used)
+u8 cx231xx_find_boundary_SAV_EAV(u8 * p_buffer, u8 * partial_buf,
+ u32 * p_bytes_used)
{
- u32 i;
- u8 sav_eav = 0;
+ u32 bytes_used;
+ u8 boundary_bytes[8];
+ u8 sav_eav = 0;
+
+ *p_bytes_used = 0;
- /* Don't search if the buffer size is less than 4. It causes a page fault since
- buffer_size - 4 evaluates to a large number in that case. */
- if(buffer_size < 4) {
- *p_bytes_used = buffer_size;
- return 0;
- }
+ /* Create an array of the last 4 bytes of the last buffer and the first
+ 4 bytes of the current buffer. */
- for(i = 0;i < (buffer_size - 3); i++) {
+ memcpy(boundary_bytes, partial_buf, 4);
+ memcpy(boundary_bytes + 4, p_buffer, 4);
- if((p_buffer[i] == 0xFF) &&
- (p_buffer[i+1] == 0x00) &&
- (p_buffer[i+2] == 0x00)) {
+ /* Check for the SAV/EAV in the boundary buffer */
+ sav_eav =
+ cx231xx_find_next_SAV_EAV((u8 *) & boundary_bytes, 8, &bytes_used);
- *p_bytes_used = i+4;
- sav_eav = p_buffer[i+3];
- return sav_eav;
- }
- }
+ if (sav_eav) {
+ /* found a boundary SAV/EAV. Updates the bytes used to reflect
+ only those used in the new buffer */
+ *p_bytes_used = bytes_used - 4;
+ }
- *p_bytes_used = buffer_size;
- return 0;
+ return sav_eav;
}
+u8 cx231xx_find_next_SAV_EAV(u8 * p_buffer, u32 buffer_size, u32 * p_bytes_used)
+{
+ u32 i;
+ u8 sav_eav = 0;
+ /* Don't search if the buffer size is less than 4. It causes a page fault since
+ buffer_size - 4 evaluates to a large number in that case. */
+ if (buffer_size < 4) {
+ *p_bytes_used = buffer_size;
+ return 0;
+ }
+ for (i = 0; i < (buffer_size - 3); i++) {
-u32 cx231xx_get_video_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;
+ if ((p_buffer[i] == 0xFF) &&
+ (p_buffer[i + 1] == 0x00) && (p_buffer[i + 2] == 0x00)) {
+ *p_bytes_used = i + 4;
+ sav_eav = p_buffer[i + 3];
+ return sav_eav;
+ }
+ }
- switch(sav_eav) {
- case SAV_ACTIVE_VIDEO_FIELD1:
- /* looking for skipped line which occurred in PAL 720x480 mode. In this case,
- there will be no active data contained between the SAV and EAV */
- if ( (buffer_size > 3) &&
- (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) &&
- ( (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) ||
- (p_buffer[3] == EAV_VBLANK_FIELD1) || (p_buffer[3] == EAV_VBLANK_FIELD2)
- )
- )
- {
- return bytes_copied;
- }
- current_field = 1;
- break;
+ *p_bytes_used = buffer_size;
+ return 0;
+}
- case SAV_ACTIVE_VIDEO_FIELD2:
- /* looking for skipped line which occurred in PAL 720x480 mode. In this case,
- there will be no active data contained between the SAV and EAV */
- if ( (buffer_size > 3) &&
- (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) &&
- ( (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) ||
- (p_buffer[3] == EAV_VBLANK_FIELD1) || (p_buffer[3] == EAV_VBLANK_FIELD2)
- )
- )
- {
- return bytes_copied;
- }
- current_field = 2;
- break;
- }
+u32 cx231xx_get_video_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;
+
+ switch (sav_eav) {
+ case SAV_ACTIVE_VIDEO_FIELD1:
+ /* looking for skipped line which occurred in PAL 720x480 mode. In this case,
+ there will be no active data contained between the SAV and EAV */
+ if ((buffer_size > 3) &&
+ (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00)
+ && (p_buffer[2] == 0x00)
+ && ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1)
+ || (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2)
+ || (p_buffer[3] == EAV_VBLANK_FIELD1)
+ || (p_buffer[3] == EAV_VBLANK_FIELD2)
+ )
+ ) {
+ return bytes_copied;
+ }
+ current_field = 1;
+ break;
- dma_q->last_sav = sav_eav;
+ case SAV_ACTIVE_VIDEO_FIELD2:
+ /* looking for skipped line which occurred in PAL 720x480 mode. In this case,
+ there will be no active data contained between the SAV and EAV */
+ if ((buffer_size > 3) &&
+ (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00)
+ && (p_buffer[2] == 0x00)
+ && ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1)
+ || (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2)
+ || (p_buffer[3] == EAV_VBLANK_FIELD1)
+ || (p_buffer[3] == EAV_VBLANK_FIELD2)
+ )
+ ) {
+ return bytes_copied;
+ }
+ current_field = 2;
+ break;
+ }
- bytes_copied = cx231xx_copy_video_line(dev, dma_q, p_buffer, buffer_size, current_field);
+ dma_q->last_sav = sav_eav;
- return bytes_copied;
+ bytes_copied =
+ cx231xx_copy_video_line(dev, dma_q, p_buffer, buffer_size,
+ current_field);
+
+ return bytes_copied;
}
-u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
- u8 *p_line, u32 length, int field_number)
+u32 cx231xx_copy_video_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;
-
- if( dma_q->current_field != field_number ) {
- cx231xx_reset_video_buffer(dev, dma_q);
- }
+ u32 bytes_to_copy;
+ struct cx231xx_buffer *buf;
+ u32 _line_size = dev->width * 2;
- /* get the buffer pointer */
- buf = dev->video_mode.isoc_ctl.buf;
+ if (dma_q->current_field != field_number) {
+ cx231xx_reset_video_buffer(dev, dma_q);
+ }
- /* Remember the field number for next time */
- dma_q->current_field = field_number;
+ /* get the buffer pointer */
+ buf = dev->video_mode.isoc_ctl.buf;
- bytes_to_copy = dma_q->bytes_left_in_line;
- if(bytes_to_copy > length)
- bytes_to_copy = length;
+ /* 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;
- 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_copy(dev, dma_q, p_line, bytes_to_copy);
+ /* copy the data to video buffer */
+ cx231xx_do_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_buffer_done(dev, dma_q) && buf) {
+ if (cx231xx_is_buffer_done(dev, dma_q) && buf) {
- buffer_filled(dev, dma_q, buf);
+ 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;
}
-void cx231xx_reset_video_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q)
+void cx231xx_reset_video_buffer(struct cx231xx *dev,
+ struct cx231xx_dmaqueue *dma_q)
{
- struct cx231xx_buffer *buf;
+ struct cx231xx_buffer *buf;
- /* handle the switch from field 1 to field 2 */
- if(dma_q->current_field == 1) {
- if(dma_q->lines_completed >= dma_q->lines_per_field ) {
- dma_q->field1_done = 1;
- } else {
- dma_q->field1_done = 0;
- }
- }
+ /* handle the switch from field 1 to field 2 */
+ if (dma_q->current_field == 1) {
+ if (dma_q->lines_completed >= dma_q->lines_per_field) {
+ dma_q->field1_done = 1;
+ } else {
+ dma_q->field1_done = 0;
+ }
+ }
- buf = dev->video_mode.isoc_ctl.buf;
+ buf = dev->video_mode.isoc_ctl.buf;
- if(buf == NULL) {
- u8* outp = NULL;
- /* first try to get the buffer */
- get_next_buf(dma_q, &buf);
+ if (buf == NULL) {
+ u8 *outp = NULL;
+ /* first try to get the buffer */
+ get_next_buf(dma_q, &buf);
- if(buf)
- outp = videobuf_to_vmalloc(&buf->vb);
+ if (buf)
+ outp = videobuf_to_vmalloc(&buf->vb);
- dma_q->pos = 0;
- dma_q->field1_done = 0;
- dma_q->current_field = -1;
- }
+ dma_q->pos = 0;
+ dma_q->field1_done = 0;
+ dma_q->current_field = -1;
+ }
- /* reset the counters */
- dma_q->bytes_left_in_line = dev->width << 1;
- dma_q->lines_completed = 0;
+ /* reset the counters */
+ dma_q->bytes_left_in_line = dev->width << 1;
+ dma_q->lines_completed = 0;
}
int cx231xx_do_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->video_mode.isoc_ctl.buf;
+ buf = dev->video_mode.isoc_ctl.buf;
- if (buf == NULL)
- return -1;
+ if (buf == NULL)
+ return -1;
p_out_buffer = videobuf_to_vmalloc(&buf->vb);
- current_line_bytes_copied = _line_size - dma_q->bytes_left_in_line;
+ current_line_bytes_copied = _line_size - dma_q->bytes_left_in_line;
- /* Offset field 2 one line from the top of the buffer */
- offset = (dma_q->current_field == 1)? 0: _line_size;
+ /* Offset field 2 one line from the top of the buffer */
+ offset = (dma_q->current_field == 1) ? 0 : _line_size;
- /* Offset for field 2 */
- startwrite = p_out_buffer + offset;
+ /* Offset for field 2 */
+ startwrite = p_out_buffer + offset;
- /* lines already completed in the current field */
- startwrite += (dma_q->lines_completed * _line_size * 2);
+ /* lines already completed in the current field */
+ startwrite += (dma_q->lines_completed * _line_size * 2);
- /* bytes already completed in the current line */
- startwrite += current_line_bytes_copied;
+ /* bytes already completed in the current line */
+ startwrite += current_line_bytes_copied;
- 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;
- if( (u8*)(startwrite +lencopy) > (u8*)(p_out_buffer+ buf->vb.size) ) {
- return 0;
- }
+ if ((u8 *) (startwrite + lencopy) >
+ (u8 *) (p_out_buffer + buf->vb.size)) {
+ return 0;
+ }
- /* The below copies the UYVY data straight into video buffer */
- cx231xx_swab( (u16*)p_buffer, (u16*)startwrite, (u16)lencopy);
+ /* The below copies the UYVY data straight into video buffer */
+ cx231xx_swab((u16 *) p_buffer, (u16 *) startwrite, (u16) lencopy);
- return 0;
+ return 0;
}
-void cx231xx_swab(u16 *from, u16 *to, u16 len)
+void cx231xx_swab(u16 * from, u16 * to, u16 len)
{
- u16 i;
+ u16 i;
- if( len <= 0)
- return;
+ if (len <= 0)
+ return;
- for(i = 0; i < len/2; i++) {
- to[i] = (from[i] << 8) | (from[i] >> 8);
- }
+ for (i = 0; i < len / 2; i++) {
+ to[i] = (from[i] << 8) | (from[i] >> 8);
+ }
}
-u8 cx231xx_is_buffer_done(struct cx231xx *dev,struct cx231xx_dmaqueue *dma_q)
+u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q)
{
- u8 buffer_complete = 0;
+ u8 buffer_complete = 0;
- /* Dual field stream */
- buffer_complete =
- ((dma_q->current_field == 2) &&
- (dma_q->lines_completed >= dma_q->lines_per_field) &&
- dma_q->field1_done);
+ /* Dual field stream */
+ buffer_complete =
+ ((dma_q->current_field == 2) &&
+ (dma_q->lines_completed >= dma_q->lines_per_field) &&
+ dma_q->field1_done);
- return buffer_complete;
+ return buffer_complete;
}
-
/* ------------------------------------------------------------------
Videobuf operations
------------------------------------------------------------------*/
@@ -701,10 +695,11 @@ static int
buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
{
struct cx231xx_fh *fh = vq->priv_data;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx *dev = fh->dev;
struct v4l2_frequency f;
- *size = ( fh->dev->width * fh->dev->height * dev->format->depth + 7) >> 3;
+ *size =
+ (fh->dev->width * fh->dev->height * dev->format->depth + 7) >> 3;
if (0 == *count)
*count = CX231XX_DEF_BUF;
@@ -714,7 +709,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
/* Ask tuner to go to analog mode */
memset(&f, 0, sizeof(f));
f.frequency = dev->ctl_freq;
- f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
+ f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f);
@@ -724,8 +719,8 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
/* 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();
@@ -738,7 +733,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->video_mode.slock, flags);
if (dev->video_mode.isoc_ctl.buf == buf)
dev->video_mode.isoc_ctl.buf = NULL;
@@ -750,22 +745,24 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
static int
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;
+ 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;
/* The only currently supported format is 16 bits/pixel */
- buf->vb.size = (fh->dev->width * fh->dev->height * dev->format->depth + 7) >> 3;
+ buf->vb.size =
+ (fh->dev->width * fh->dev->height * dev->format->depth + 7) >> 3;
- 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 = dev->height;
- buf->vb.field = field;
+ buf->vb.field = field;
if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
rc = videobuf_iolock(vq, &buf->vb, NULL);
@@ -778,8 +775,9 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
if (urb_init) {
rc = cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS,
- CX231XX_NUM_BUFS, dev->video_mode.max_pkt_size,
- cx231xx_isoc_copy);
+ CX231XX_NUM_BUFS,
+ dev->video_mode.max_pkt_size,
+ cx231xx_isoc_copy);
if (rc < 0)
goto fail;
}
@@ -787,18 +785,18 @@ 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;
}
-static void
-buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
+static void 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->video_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->video_mode.vidq;
buf->vb.state = VIDEOBUF_QUEUED;
list_add_tail(&buf->vb.queue, &vidq->active);
@@ -806,11 +804,12 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
}
static void 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_isocdbg("cx231xx: called buffer_release\n");
@@ -818,15 +817,14 @@ static void buffer_release(struct videobuf_queue *vq,
}
static struct videobuf_queue_ops cx231xx_video_qops = {
- .buf_setup = buffer_setup,
- .buf_prepare = buffer_prepare,
- .buf_queue = buffer_queue,
- .buf_release = buffer_release,
+ .buf_setup = buffer_setup,
+ .buf_prepare = buffer_prepare,
+ .buf_queue = buffer_queue,
+ .buf_release = buffer_release,
};
/********************* v4l2 interface **************************************/
-
void video_mux(struct cx231xx *dev, int index)
{
@@ -837,40 +835,41 @@ void video_mux(struct cx231xx *dev, int index)
dev->video_input = index;
dev->ctl_ainput = INPUT(index)->amux;
- cx231xx_set_video_input_mux(dev,index);
+ cx231xx_set_video_input_mux(dev, index);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_INT_S_VIDEO_ROUTING,
+ &route);
- cx231xx_set_audio_input(dev, dev->ctl_ainput );
+ cx231xx_set_audio_input(dev, dev->ctl_ainput);
- cx231xx_info("video_mux : %d\n", index);
+ cx231xx_info("video_mux : %d\n", index);
- /* do mode control overrides if required */
- cx231xx_do_mode_ctrl_overrides(dev);
+ /* do mode control overrides if required */
+ cx231xx_do_mode_ctrl_overrides(dev);
}
/* Usage lock check functions */
static int res_get(struct cx231xx_fh *fh)
{
- struct cx231xx *dev = fh->dev;
- int rc = 0;
+ struct cx231xx *dev = fh->dev;
+ int rc = 0;
/* This instance already has stream_on */
if (fh->stream_on)
return rc;
- if(fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
- if (dev->stream_on)
- return -EBUSY;
- dev->stream_on = 1;
- } else if(fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
- if (dev->vbi_stream_on)
- return -EBUSY;
- dev->vbi_stream_on = 1;
- } else
- return -EINVAL;
+ if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ if (dev->stream_on)
+ return -EBUSY;
+ dev->stream_on = 1;
+ } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
+ if (dev->vbi_stream_on)
+ return -EBUSY;
+ dev->vbi_stream_on = 1;
+ } else
+ return -EINVAL;
- fh->stream_on = 1;
+ fh->stream_on = 1;
return rc;
}
@@ -882,14 +881,14 @@ static int res_check(struct cx231xx_fh *fh)
static void res_free(struct cx231xx_fh *fh)
{
- struct cx231xx *dev = fh->dev;
+ struct cx231xx *dev = fh->dev;
fh->stream_on = 0;
- if(fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
- dev->stream_on = 0;
- if(fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)
- dev->vbi_stream_on = 0;
+ if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+ dev->stream_on = 0;
+ if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)
+ dev->vbi_stream_on = 0;
}
static int check_dev(struct cx231xx *dev)
@@ -901,18 +900,18 @@ static int check_dev(struct cx231xx *dev)
if (dev->state & DEV_MISCONFIGURED) {
cx231xx_errdev("v4l2 ioctl: device is misconfigured; "
- "close and open it again\n");
+ "close and open it again\n");
return -EIO;
}
return 0;
}
void get_scale(struct cx231xx *dev,
- unsigned int width, unsigned int height,
- unsigned int *hscale, unsigned int *vscale)
+ unsigned int width, unsigned int height,
+ unsigned int *hscale, unsigned int *vscale)
{
- unsigned int maxw = norm_maxw(dev);
- unsigned int maxh = norm_maxh(dev);
+ unsigned int maxw = norm_maxw(dev);
+ unsigned int maxh = norm_maxh(dev);
*hscale = (((unsigned long)maxw) << 12) / width - 4096L;
if (*hscale >= 0x4000)
@@ -922,8 +921,8 @@ void get_scale(struct cx231xx *dev,
if (*vscale >= 0x4000)
*vscale = 0x3fff;
- dev->hscale = *hscale;
- dev->vscale = *vscale;
+ dev->hscale = *hscale;
+ dev->vscale = *vscale;
}
@@ -932,10 +931,10 @@ void get_scale(struct cx231xx *dev,
------------------------------------------------------------------*/
static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_format *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
mutex_lock(&dev->lock);
@@ -943,7 +942,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
f->fmt.pix.height = dev->height;
f->fmt.pix.pixelformat = dev->format->fourcc;;
f->fmt.pix.bytesperline = (dev->width * dev->format->depth + 7) >> 3;;
- f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height;
+ f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height;
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
f->fmt.pix.field = V4L2_FIELD_INTERLACED;
@@ -964,21 +963,21 @@ static struct cx231xx_fmt *format_by_fourcc(unsigned int fourcc)
}
static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_format *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int width = f->fmt.pix.width;
- int height = f->fmt.pix.height;
- unsigned int maxw = norm_maxw(dev);
- unsigned int maxh = norm_maxh(dev);
- unsigned int hscale, vscale;
- struct cx231xx_fmt *fmt;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int width = f->fmt.pix.width;
+ int height = f->fmt.pix.height;
+ unsigned int maxw = norm_maxw(dev);
+ unsigned int maxh = norm_maxh(dev);
+ unsigned int hscale, vscale;
+ struct cx231xx_fmt *fmt;
fmt = format_by_fourcc(f->fmt.pix.pixelformat);
if (!fmt) {
cx231xx_videodbg("Fourcc format (%08x) invalid.\n",
- f->fmt.pix.pixelformat);
+ f->fmt.pix.pixelformat);
return -EINVAL;
}
@@ -1013,23 +1012,22 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
}
static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_format *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
- struct cx231xx_fmt *fmt;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
+ struct cx231xx_fmt *fmt;
rc = check_dev(dev);
if (rc < 0)
return rc;
-
mutex_lock(&dev->lock);
- vidioc_try_fmt_vid_cap(file, priv, f);
+ vidioc_try_fmt_vid_cap(file, priv, f);
- fmt = format_by_fourcc(f->fmt.pix.pixelformat);
+ fmt = format_by_fourcc(f->fmt.pix.pixelformat);
if (!fmt) {
rc = -EINVAL;
goto out;
@@ -1050,23 +1048,23 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
/* set new image size */
dev->width = f->fmt.pix.width;
dev->height = f->fmt.pix.height;
- dev->format = fmt;
+ dev->format = fmt;
get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_FMT, f);
+ cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_FMT, f);
- /* Set the correct alternate setting for this resolution */
+ /* Set the correct alternate setting for this resolution */
cx231xx_resolution_set(dev);
-out:
+ out:
mutex_unlock(&dev->lock);
return rc;
}
-static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id)
+static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id * id)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
*id = dev->norm;
return 0;
@@ -1074,21 +1072,20 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id)
static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
struct v4l2_format f;
- int rc;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
return rc;
- cx231xx_info("vidioc_s_std : 0x%x\n", (unsigned int)*norm);
+ cx231xx_info("vidioc_s_std : 0x%x\n", (unsigned int)*norm);
mutex_lock(&dev->lock);
dev->norm = *norm;
-
/* Adjusts width/height, if needed */
f.fmt.pix.width = dev->width;
f.fmt.pix.height = dev->height;
@@ -1103,29 +1100,29 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
mutex_unlock(&dev->lock);
- cx231xx_resolution_set(dev);
+ cx231xx_resolution_set(dev);
- /* do mode control overrides */
- cx231xx_do_mode_ctrl_overrides(dev);
+ /* do mode control overrides */
+ cx231xx_do_mode_ctrl_overrides(dev);
return 0;
}
static const char *iname[] = {
[CX231XX_VMUX_COMPOSITE1] = "Composite1",
- [CX231XX_VMUX_SVIDEO] = "S-Video",
+ [CX231XX_VMUX_SVIDEO] = "S-Video",
[CX231XX_VMUX_TELEVISION] = "Television",
- [CX231XX_VMUX_CABLE] = "Cable TV",
- [CX231XX_VMUX_DVB] = "DVB",
- [CX231XX_VMUX_DEBUG] = "for debug only",
+ [CX231XX_VMUX_CABLE] = "Cable TV",
+ [CX231XX_VMUX_DVB] = "DVB",
+ [CX231XX_VMUX_DEBUG] = "for debug only",
};
static int vidioc_enum_input(struct file *file, void *priv,
- struct v4l2_input *i)
+ struct v4l2_input *i)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- unsigned int n;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ unsigned int n;
n = i->index;
if (n >= MAX_CX231XX_INPUT)
@@ -1139,7 +1136,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
strcpy(i->name, iname[INPUT(n)->type]);
if ((CX231XX_VMUX_TELEVISION == INPUT(n)->type) ||
- (CX231XX_VMUX_CABLE == INPUT(n)->type))
+ (CX231XX_VMUX_CABLE == INPUT(n)->type))
i->type = V4L2_INPUT_TYPE_TUNER;
i->std = dev->vdev->tvnorms;
@@ -1149,8 +1146,8 @@ static int vidioc_enum_input(struct file *file, void *priv,
static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
*i = dev->video_input;
@@ -1159,9 +1156,9 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1182,8 +1179,8 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
switch (a->index) {
case CX231XX_AMUX_VIDEO:
@@ -1204,35 +1201,34 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int status = 0;
-
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int status = 0;
/* Doesn't allow manual routing */
if (a->index != dev->ctl_ainput)
return -EINVAL;
dev->ctl_ainput = INPUT(a->index)->amux;
- status = cx231xx_set_audio_input(dev, dev->ctl_ainput);
+ status = cx231xx_set_audio_input(dev, dev->ctl_ainput);
return status;
}
static int vidioc_queryctrl(struct file *file, void *priv,
- struct v4l2_queryctrl *qc)
+ struct v4l2_queryctrl *qc)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int id = qc->id;
- int i;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int id = qc->id;
+ int i;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
return rc;
- qc->id = v4l2_ctrl_next(ctrl_classes, qc->id);
+ qc->id = v4l2_ctrl_next(ctrl_classes, qc->id);
if (unlikely(qc->id == 0))
return -EINVAL;
@@ -1240,8 +1236,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
qc->id = id;
- if (qc->id < V4L2_CID_BASE ||
- qc->id >= V4L2_CID_LASTP1)
+ if (qc->id < V4L2_CID_BASE || qc->id >= V4L2_CID_LASTP1)
return -EINVAL;
for (i = 0; i < CX231XX_CTLS; i++)
@@ -1255,7 +1250,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
*qc = cx231xx_ctls[i].v;
mutex_lock(&dev->lock);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_QUERYCTRL, qc);
+ cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_QUERYCTRL, qc);
mutex_unlock(&dev->lock);
if (qc->type)
@@ -1265,11 +1260,11 @@ static int vidioc_queryctrl(struct file *file, void *priv,
}
static int vidioc_g_ctrl(struct file *file, void *priv,
- struct v4l2_control *ctrl)
+ struct v4l2_control *ctrl)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1284,11 +1279,11 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
}
static int vidioc_s_ctrl(struct file *file, void *priv,
- struct v4l2_control *ctrl)
+ struct v4l2_control *ctrl)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1302,12 +1297,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
return rc;
}
-static int vidioc_g_tuner(struct file *file, void *priv,
- struct v4l2_tuner *t)
+static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1318,20 +1312,19 @@ static int vidioc_g_tuner(struct file *file, void *priv,
strcpy(t->name, "Tuner");
- t->type = V4L2_TUNER_ANALOG_TV;
+ t->type = V4L2_TUNER_ANALOG_TV;
t->capability = V4L2_TUNER_CAP_NORM;
- t->rangehigh = 0xffffffffUL;
- t->signal = 0xffff ; /* LOCKED */
+ t->rangehigh = 0xffffffffUL;
+ t->signal = 0xffff; /* LOCKED */
return 0;
}
-static int vidioc_s_tuner(struct file *file, void *priv,
- struct v4l2_tuner *t)
+static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1350,28 +1343,28 @@ static int vidioc_s_tuner(struct file *file, void *priv,
}
static int vidioc_g_frequency(struct file *file, void *priv,
- struct v4l2_frequency *f)
+ struct v4l2_frequency *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = dev->ctl_freq;
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f);
+ cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f);
- mutex_unlock(&dev->lock);
+ mutex_unlock(&dev->lock);
return 0;
}
static int vidioc_s_frequency(struct file *file, void *priv,
- struct v4l2_frequency *f)
+ struct v4l2_frequency *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1385,106 +1378,121 @@ static int vidioc_s_frequency(struct file *file, void *priv,
if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
return -EINVAL;
- /* set pre channel change settings in DIF first */
- rc = cx231xx_tuner_pre_channel_change(dev);
+ /* set pre channel change settings in DIF first */
+ rc = cx231xx_tuner_pre_channel_change(dev);
mutex_lock(&dev->lock);
dev->ctl_freq = f->frequency;
- if(dev->tuner_type == TUNER_XC5000) {
- if( dev->cx231xx_set_analog_freq != NULL ) {
- dev->cx231xx_set_analog_freq(dev, f->frequency );
+ if (dev->tuner_type == TUNER_XC5000) {
+ if (dev->cx231xx_set_analog_freq != NULL) {
+ dev->cx231xx_set_analog_freq(dev, f->frequency);
}
} else {
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, f);
+ cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY,
+ f);
}
mutex_unlock(&dev->lock);
- /* set post channel change settings in DIF first */
- rc = cx231xx_tuner_post_channel_change(dev);
+ /* set post channel change settings in DIF first */
+ rc = cx231xx_tuner_post_channel_change(dev);
- cx231xx_info("Set New FREQUENCY to %d\n",f->frequency);
+ cx231xx_info("Set New FREQUENCY to %d\n", f->frequency);
return rc;
}
#ifdef CONFIG_VIDEO_ADV_DEBUG
-
/*
-R, --list-registers=type=<host/i2cdrv/i2caddr>,chip=<chip>[,min=<addr>,max=<addr>]
- dump registers from <min> to <max> [VIDIOC_DBG_G_REGISTER]
+ dump registers from <min> to <max> [VIDIOC_DBG_G_REGISTER]
-r, --set-register=type=<host/i2cdrv/i2caddr>,chip=<chip>,reg=<addr>,val=<val>
- set the register [VIDIOC_DBG_S_REGISTER]
+ set the register [VIDIOC_DBG_S_REGISTER]
if type == host, then <chip> is the hosts chip ID (default 0)
if type == i2cdrv (default), then <chip> is the I2C driver name or ID
if type == i2caddr, then <chip> is the 7-bit I2C address
*/
-
static int vidioc_g_register(struct file *file, void *priv,
struct v4l2_dbg_register *reg)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
int ret = 0;
- u8 value[4] ={0,0,0,0};
- u32 data = 0;
-
- switch (reg->match.type) {
- case V4L2_CHIP_MATCH_HOST:
- switch(reg->match.addr) {
- case 0: /* Cx231xx - internal registers */
- ret = cx231xx_read_ctrl_reg(dev,VRT_GET_REGISTER, (u16) reg->reg, value, 4);
- reg->val = value[0] | value[1] << 8 | value[2] << 16 | value[3] << 24;
- break;
- case 1: /* Colibri - read byte */
- ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, &data, 1);
- reg->val = le32_to_cpu(data & 0xff);
- break;
- case 14: /* Colibri - read dword */
- ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, &data, 4);
- reg->val = le32_to_cpu(data);
- break;
- case 2: /* Hammerhead - read byte */
- ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, &data, 1);
- reg->val = le32_to_cpu(data & 0xff);
- break;
- case 24: /* Hammerhead - read dword */
- ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, &data, 4);
- reg->val = le32_to_cpu(data);
- break;
- case 3: /* flatiron - read byte */
- ret = cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, &data, 1);
- reg->val = le32_to_cpu(data & 0xff);
- break;
- case 34: /* flatiron - read dword */
- ret = cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, &data, 4);
- reg->val = le32_to_cpu(data);
- break;
- }
- return ret < 0?ret:0;
-
- case V4L2_CHIP_MATCH_I2C_DRIVER:
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg);
- return 0;
- case V4L2_CHIP_MATCH_I2C_ADDR:
- /* Not supported yet */
- return -EINVAL;
- default:
- if (!v4l2_chip_match_host(&reg->match))
- return -EINVAL;
- }
+ u8 value[4] = { 0, 0, 0, 0 };
+ u32 data = 0;
+
+ switch (reg->match.type) {
+ case V4L2_CHIP_MATCH_HOST:
+ switch (reg->match.addr) {
+ case 0: /* Cx231xx - internal registers */
+ ret =
+ cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER,
+ (u16) reg->reg, value, 4);
+ reg->val =
+ value[0] | value[1] << 8 | value[2] << 16 | value[3]
+ << 24;
+ break;
+ case 1: /* Colibri - read byte */
+ ret =
+ cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
+ (u16) reg->reg, 2, &data, 1);
+ reg->val = le32_to_cpu(data & 0xff);
+ break;
+ case 14: /* Colibri - read dword */
+ ret =
+ cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
+ (u16) reg->reg, 2, &data, 4);
+ reg->val = le32_to_cpu(data);
+ break;
+ case 2: /* Hammerhead - read byte */
+ ret =
+ cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
+ (u16) reg->reg, 2, &data, 1);
+ reg->val = le32_to_cpu(data & 0xff);
+ break;
+ case 24: /* Hammerhead - read dword */
+ ret =
+ cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
+ (u16) reg->reg, 2, &data, 4);
+ reg->val = le32_to_cpu(data);
+ break;
+ case 3: /* flatiron - read byte */
+ ret =
+ cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS,
+ (u16) reg->reg, 1, &data, 1);
+ reg->val = le32_to_cpu(data & 0xff);
+ break;
+ case 34: /* flatiron - read dword */
+ ret =
+ cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS,
+ (u16) reg->reg, 1, &data, 4);
+ reg->val = le32_to_cpu(data);
+ break;
+ }
+ return ret < 0 ? ret : 0;
+ case V4L2_CHIP_MATCH_I2C_DRIVER:
+ cx231xx_i2c_call_clients(&dev->i2c_bus[0],
+ VIDIOC_DBG_G_REGISTER, reg);
+ return 0;
+ case V4L2_CHIP_MATCH_I2C_ADDR:
+ /* Not supported yet */
+ return -EINVAL;
+ default:
+ if (!v4l2_chip_match_host(&reg->match))
+ return -EINVAL;
+ }
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg);
- mutex_unlock(&dev->lock);
+ mutex_unlock(&dev->lock);
return ret;
}
@@ -1492,70 +1500,97 @@ static int vidioc_g_register(struct file *file, void *priv,
static int vidioc_s_register(struct file *file, void *priv,
struct v4l2_dbg_register *reg)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int ret = 0;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int ret = 0;
__le64 buf;
- u32 value;
- u8 data[4] ={0,0,0,0};
+ u32 value;
+ u8 data[4] = { 0, 0, 0, 0 };
buf = cpu_to_le64(reg->val);
- switch (reg->match.type) {
- case V4L2_CHIP_MATCH_HOST:
- {
- value = (u32) buf & 0xffffffff;
-
- switch(reg->match.addr) {
- case 0: /* cx231xx internal registers */
- data[0]=(u8)value;
- data[1]=(u8)(value>>8);
- data[2]=(u8)(value>>16);
- data[3]=(u8)(value>>24);
- ret = cx231xx_write_ctrl_reg(dev,VRT_SET_REGISTER, (u16) reg->reg, data, 4);
- break;
- case 1: /* Colibri - read byte */
- ret = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, value, 1);
- break;
- case 14: /* Colibri - read dword */
- ret = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, value, 4);
- break;
- case 2: /* Hammerhead - read byte */
- ret = cx231xx_write_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, value, 1);
- break;
- case 24: /* Hammerhead - read dword */
- ret = cx231xx_write_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, value, 4);
- break;
- case 3: /* flatiron - read byte */
- ret = cx231xx_write_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, value, 1);
- break;
- case 34: /* flatiron - read dword */
- ret = cx231xx_write_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, value, 4);
- break;
- }
- }
- return ret < 0?ret:0;
-
- default:
- break;
- }
+ switch (reg->match.type) {
+ case V4L2_CHIP_MATCH_HOST:
+ {
+ value = (u32) buf & 0xffffffff;
+
+ switch (reg->match.addr) {
+ case 0: /* cx231xx internal registers */
+ data[0] = (u8) value;
+ data[1] = (u8) (value >> 8);
+ data[2] = (u8) (value >> 16);
+ data[3] = (u8) (value >> 24);
+ ret =
+ cx231xx_write_ctrl_reg(dev,
+ VRT_SET_REGISTER,
+ (u16) reg->reg, data,
+ 4);
+ break;
+ case 1: /* Colibri - read byte */
+ ret =
+ cx231xx_write_i2c_data(dev,
+ Colibri_DEVICE_ADDRESS,
+ (u16) reg->reg, 2,
+ value, 1);
+ break;
+ case 14: /* Colibri - read dword */
+ ret =
+ cx231xx_write_i2c_data(dev,
+ Colibri_DEVICE_ADDRESS,
+ (u16) reg->reg, 2,
+ value, 4);
+ break;
+ case 2: /* Hammerhead - read byte */
+ ret =
+ cx231xx_write_i2c_data(dev,
+ HAMMERHEAD_I2C_ADDRESS,
+ (u16) reg->reg, 2,
+ value, 1);
+ break;
+ case 24: /* Hammerhead - read dword */
+ ret =
+ cx231xx_write_i2c_data(dev,
+ HAMMERHEAD_I2C_ADDRESS,
+ (u16) reg->reg, 2,
+ value, 4);
+ break;
+ case 3: /* flatiron - read byte */
+ ret =
+ cx231xx_write_i2c_data(dev,
+ Flatrion_DEVICE_ADDRESS,
+ (u16) reg->reg, 1,
+ value, 1);
+ break;
+ case 34: /* flatiron - read dword */
+ ret =
+ cx231xx_write_i2c_data(dev,
+ Flatrion_DEVICE_ADDRESS,
+ (u16) reg->reg, 1,
+ value, 4);
+ break;
+ }
+ }
+ return ret < 0 ? ret : 0;
+
+ default:
+ break;
+ }
mutex_lock(&dev->lock);
cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_S_REGISTER, reg);
- mutex_unlock(&dev->lock);
+ mutex_unlock(&dev->lock);
- return ret;
+ return ret;
}
#endif
-
static int vidioc_cropcap(struct file *file, void *priv,
- struct v4l2_cropcap *cc)
+ struct v4l2_cropcap *cc)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -1572,17 +1607,17 @@ static int vidioc_cropcap(struct file *file, void *priv,
}
static int vidioc_streamon(struct file *file, void *priv,
- enum v4l2_buf_type type)
+ enum v4l2_buf_type type)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
return rc;
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
rc = res_get(fh);
if (likely(rc >= 0))
@@ -1594,52 +1629,51 @@ static int vidioc_streamon(struct file *file, void *priv,
}
static int vidioc_streamoff(struct file *file, void *priv,
- enum v4l2_buf_type type)
+ enum v4l2_buf_type type)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
return rc;
- if ( (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
- (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE) )
+ if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
+ (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE))
return -EINVAL;
if (type != fh->type)
return -EINVAL;
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
videobuf_streamoff(&fh->vb_vidq);
res_free(fh);
- mutex_unlock(&dev->lock);
+ mutex_unlock(&dev->lock);
return 0;
}
-static int vidioc_querycap(struct file *file, void *priv,
- struct v4l2_capability *cap)
+static int vidioc_querycap(struct file *file, void *priv,
+ struct v4l2_capability *cap)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
strlcpy(cap->driver, "cx231xx", sizeof(cap->driver));
strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card));
- strlcpy(cap->bus_info, dev_name(&dev->udev->dev), sizeof(cap->bus_info));
+ strlcpy(cap->bus_info, dev_name(&dev->udev->dev),
+ sizeof(cap->bus_info));
cap->version = CX231XX_VERSION_CODE;
- cap->capabilities =
- V4L2_CAP_VBI_CAPTURE |
+ cap->capabilities = V4L2_CAP_VBI_CAPTURE |
#if 0
- V4L2_CAP_SLICED_VBI_CAPTURE |
+ V4L2_CAP_SLICED_VBI_CAPTURE |
#endif
- V4L2_CAP_VIDEO_CAPTURE |
- V4L2_CAP_AUDIO |
- V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
+ V4L2_CAP_VIDEO_CAPTURE |
+ V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
if (dev->tuner_type != TUNER_ABSENT)
cap->capabilities |= V4L2_CAP_TUNER;
@@ -1647,10 +1681,10 @@ static int vidioc_querycap(struct file *file, void *priv,
return 0;
}
-static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_fmtdesc *f)
+static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
+ struct v4l2_fmtdesc *f)
{
- if (unlikely(f->index >= ARRAY_SIZE(format)))
+ if (unlikely(f->index >= ARRAY_SIZE(format)))
return -EINVAL;
strlcpy(f->description, format[f->index].name, sizeof(f->description));
@@ -1661,11 +1695,11 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
/* Sliced VBI ioctls */
static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_format *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1685,11 +1719,11 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv,
}
static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_format *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1705,26 +1739,25 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
return 0;
}
-
/* RAW VBI ioctls */
static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_format *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
f->fmt.vbi.sampling_rate = (dev->norm & V4L2_STD_625_50) ?
- 35468950:28636363;
+ 35468950 : 28636363;
f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH;
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
f->fmt.vbi.offset = 64 * 4;
f->fmt.vbi.start[0] = (dev->norm & V4L2_STD_625_50) ?
- PAL_VBI_START_LINE : NTSC_VBI_START_LINE;
+ PAL_VBI_START_LINE : NTSC_VBI_START_LINE;
f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ?
- PAL_VBI_LINES : NTSC_VBI_LINES;
+ PAL_VBI_LINES : NTSC_VBI_LINES;
f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ?
- PAL_VBI_START_LINE+312 : NTSC_VBI_START_LINE + 263;
+ PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263;
f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
return 0;
@@ -1732,29 +1765,29 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
}
static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_format *f)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
- if (dev->vbi_stream_on && !fh->stream_on) {
+ if (dev->vbi_stream_on && !fh->stream_on) {
cx231xx_errdev("%s device in use by another fh\n", __func__);
return -EBUSY;
}
f->type = V4L2_BUF_TYPE_VBI_CAPTURE;
f->fmt.vbi.sampling_rate = (dev->norm & V4L2_STD_625_50) ?
- 35468950:28636363;
+ 35468950 : 28636363;
f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH;
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
f->fmt.vbi.offset = 244;
f->fmt.vbi.flags = 0;
f->fmt.vbi.start[0] = (dev->norm & V4L2_STD_625_50) ?
- PAL_VBI_START_LINE : NTSC_VBI_START_LINE;
+ PAL_VBI_START_LINE : NTSC_VBI_START_LINE;
f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ?
- PAL_VBI_LINES : NTSC_VBI_LINES;
+ PAL_VBI_LINES : NTSC_VBI_LINES;
f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ?
- PAL_VBI_START_LINE+312 : NTSC_VBI_START_LINE + 263;
+ PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263;
f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
return 0;
@@ -1764,9 +1797,9 @@ static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv,
static int vidioc_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *rb)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1775,12 +1808,11 @@ static int vidioc_reqbufs(struct file *file, void *priv,
return (videobuf_reqbufs(&fh->vb_vidq, rb));
}
-static int vidioc_querybuf(struct file *file, void *priv,
- struct v4l2_buffer *b)
+static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *b)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1791,9 +1823,9 @@ static int vidioc_querybuf(struct file *file, void *priv,
static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
@@ -1804,33 +1836,31 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
{
- struct cx231xx_fh *fh = priv;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = priv;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
return rc;
- return (videobuf_dqbuf(&fh->vb_vidq, b,
- file->f_flags & O_NONBLOCK));
+ return (videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK));
}
#ifdef CONFIG_VIDEO_V4L1_COMPAT
static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
{
- struct cx231xx_fh *fh = priv;
+ struct cx231xx_fh *fh = priv;
return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8);
}
#endif
-
/* ----------------------------------------------------------- */
/* RADIO ESPECIFIC IOCTLS */
/* ----------------------------------------------------------- */
-static int radio_querycap(struct file *file, void *priv,
+static int radio_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
@@ -1844,8 +1874,7 @@ static int radio_querycap(struct file *file, void *priv,
return 0;
}
-static int radio_g_tuner(struct file *file, void *priv,
- struct v4l2_tuner *t)
+static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
{
struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
@@ -1855,15 +1884,14 @@ static int radio_g_tuner(struct file *file, void *priv,
strcpy(t->name, "Radio");
t->type = V4L2_TUNER_RADIO;
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
- mutex_unlock(&dev->lock);
+ mutex_unlock(&dev->lock);
return 0;
}
-static int radio_enum_input(struct file *file, void *priv,
- struct v4l2_input *i)
+static int radio_enum_input(struct file *file, void *priv, struct v4l2_input *i)
{
if (i->index != 0)
return -EINVAL;
@@ -1882,23 +1910,21 @@ static int radio_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
return 0;
}
-static int radio_s_tuner(struct file *file, void *priv,
- struct v4l2_tuner *t)
+static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
{
struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
if (0 != t->index)
return -EINVAL;
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_TUNER, t);
- mutex_unlock(&dev->lock);
+ mutex_unlock(&dev->lock);
return 0;
}
-static int radio_s_audio(struct file *file, void *fh,
- struct v4l2_audio *a)
+static int radio_s_audio(struct file *file, void *fh, struct v4l2_audio *a)
{
return 0;
}
@@ -1913,8 +1939,7 @@ static int radio_queryctrl(struct file *file, void *priv,
{
int i;
- if (c->id < V4L2_CID_BASE ||
- c->id >= V4L2_CID_LASTP1)
+ if (c->id < V4L2_CID_BASE || c->id >= V4L2_CID_LASTP1)
return -EINVAL;
if (c->id == V4L2_CID_AUDIO_MUTE) {
for (i = 0; i < CX231XX_CTLS; i++)
@@ -1932,25 +1957,26 @@ static int radio_queryctrl(struct file *file, void *priv,
*/
static int cx231xx_v4l2_open(struct file *filp)
{
- int minor = video_devdata(filp)->minor;
+ int minor = video_devdata(filp)->minor;
int errCode = 0, radio = 0;
struct cx231xx *dev = NULL;
struct cx231xx_fh *fh;
enum v4l2_buf_type fh_type = 0;
- dev = cx231xx_get_device(minor, &fh_type, &radio);
+ dev = cx231xx_get_device(minor, &fh_type, &radio);
if (NULL == dev)
return -ENODEV;
mutex_lock(&dev->lock);
cx231xx_videodbg("open minor=%d type=%s users=%d\n",
- minor, v4l2_type_names[fh_type], dev->users);
+ minor, v4l2_type_names[fh_type], dev->users);
#if 0
errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE);
if (errCode < 0) {
- cx231xx_errdev("Device locked on digital mode. Can't open analog\n");
+ cx231xx_errdev
+ ("Device locked on digital mode. Can't open analog\n");
mutex_unlock(&dev->lock);
return -EBUSY;
}
@@ -1973,25 +1999,24 @@ static int cx231xx_v4l2_open(struct file *filp)
dev->hscale = 0;
dev->vscale = 0;
-
- /* Power up in Analog TV mode */
- cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV);
+ /* Power up in Analog TV mode */
+ cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV);
#if 0
cx231xx_set_mode(dev, CX231XX_ANALOG_MODE);
#endif
cx231xx_resolution_set(dev);
- /* set video alternate setting */
- cx231xx_set_video_alternate(dev);
+ /* set video alternate setting */
+ cx231xx_set_video_alternate(dev);
/* Needed, since GPIO might have disabled power of
some i2c device */
cx231xx_config_i2c(dev);
/* device needs to be initialized before isoc transfer */
- dev->video_input = dev->video_input > 2 ? 2: dev->video_input;
- video_mux(dev, dev->video_input );
+ dev->video_input = dev->video_input > 2 ? 2 : dev->video_input;
+ video_mux(dev, dev->video_input);
}
if (fh->radio) {
@@ -1999,26 +2024,25 @@ static int cx231xx_v4l2_open(struct file *filp)
/* cx231xx_start_radio(dev); */
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], AUDC_SET_RADIO, NULL);
+ cx231xx_i2c_call_clients(&dev->i2c_bus[1], AUDC_SET_RADIO,
+ NULL);
}
dev->users++;
- if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
- videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops,
- NULL, &dev->video_mode.slock, fh->type, V4L2_FIELD_INTERLACED, /* V4L2_FIELD_SEQ_TB, */
- sizeof(struct cx231xx_buffer), fh);
- }
+ if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops, NULL, &dev->video_mode.slock, fh->type, V4L2_FIELD_INTERLACED, /* V4L2_FIELD_SEQ_TB, */
+ sizeof(struct cx231xx_buffer), fh);
+ }
- if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
+ if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
- /* Set the required alternate setting VBI interface works in Bulk mode only */
- cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
+ /* Set the required alternate setting VBI interface works in Bulk mode only */
+ cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
- videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops,
- NULL, &dev->vbi_mode.slock, fh->type, V4L2_FIELD_SEQ_TB, /* V4L2_FIELD_INTERLACED, */
- sizeof(struct cx231xx_buffer), fh);
- }
+ videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops, NULL, &dev->vbi_mode.slock, fh->type, V4L2_FIELD_SEQ_TB, /* V4L2_FIELD_INTERLACED, */
+ sizeof(struct cx231xx_buffer), fh);
+ }
mutex_unlock(&dev->lock);
@@ -2044,7 +2068,7 @@ void cx231xx_release_analog_resources(struct cx231xx *dev)
}
if (dev->vbi_dev) {
cx231xx_info("V4L2 device /dev/vbi%d deregistered\n",
- dev->vbi_dev->num);
+ dev->vbi_dev->num);
if (-1 != dev->vbi_dev->minor)
video_unregister_device(dev->vbi_dev);
else
@@ -2053,7 +2077,7 @@ void cx231xx_release_analog_resources(struct cx231xx *dev)
}
if (dev->vdev) {
cx231xx_info("V4L2 device /dev/video%d deregistered\n",
- dev->vdev->num);
+ dev->vdev->num);
if (-1 != dev->vdev->minor)
video_unregister_device(dev->vdev);
else
@@ -2069,44 +2093,44 @@ void cx231xx_release_analog_resources(struct cx231xx *dev)
*/
static int cx231xx_v4l2_close(struct file *filp)
{
- struct cx231xx_fh *fh = filp->private_data;
- struct cx231xx *dev = fh->dev;
+ struct cx231xx_fh *fh = filp->private_data;
+ struct cx231xx *dev = fh->dev;
cx231xx_videodbg("users=%d\n", dev->users);
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
if (res_check(fh))
res_free(fh);
- if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
- videobuf_stop(&fh->vb_vidq);
- videobuf_mmap_free(&fh->vb_vidq);
-
- /* the device is already disconnect,
- free the remaining resources */
- if (dev->state & DEV_DISCONNECTED) {
- cx231xx_release_resources(dev);
- mutex_unlock(&dev->lock);
- kfree(dev);
- return 0;
- }
-
- /* do this before setting alternate! */
- cx231xx_uninit_vbi_isoc(dev);
-
- /* set alternate 0 */
- if( !dev->vbi_or_sliced_cc_mode) {
- cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
- } else {
- cx231xx_set_alt_setting(dev, INDEX_HANC, 0);
- }
-
- kfree(fh);
- dev->users--;
- wake_up_interruptible_nr(&dev->open, 1);
- mutex_unlock(&dev->lock);
- return 0;
+ if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
+ videobuf_stop(&fh->vb_vidq);
+ videobuf_mmap_free(&fh->vb_vidq);
+
+ /* the device is already disconnect,
+ free the remaining resources */
+ if (dev->state & DEV_DISCONNECTED) {
+ cx231xx_release_resources(dev);
+ mutex_unlock(&dev->lock);
+ kfree(dev);
+ return 0;
+ }
+
+ /* do this before setting alternate! */
+ cx231xx_uninit_vbi_isoc(dev);
+
+ /* set alternate 0 */
+ if (!dev->vbi_or_sliced_cc_mode) {
+ cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
+ } else {
+ cx231xx_set_alt_setting(dev, INDEX_HANC, 0);
+ }
+
+ kfree(fh);
+ dev->users--;
+ wake_up_interruptible_nr(&dev->open, 1);
+ mutex_unlock(&dev->lock);
+ return 0;
}
if (dev->users == 1) {
@@ -2122,8 +2146,9 @@ static int cx231xx_v4l2_close(struct file *filp)
return 0;
}
- /* Save some power by putting tuner to sleep */
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_STANDBY, NULL);
+ /* Save some power by putting tuner to sleep */
+ cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_STANDBY,
+ NULL);
/* do this before setting alternate! */
cx231xx_uninit_isoc(dev);
@@ -2144,8 +2169,8 @@ static int cx231xx_v4l2_close(struct file *filp)
* will allocate buffers when called for the first time
*/
static ssize_t
-cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
- loff_t *pos)
+cx231xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
+ loff_t * pos)
{
struct cx231xx_fh *fh = filp->private_data;
struct cx231xx *dev = fh->dev;
@@ -2155,8 +2180,8 @@ cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
if (rc < 0)
return rc;
- if ( (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
- (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) ) {
+ if ((fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
+ (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)) {
mutex_lock(&dev->lock);
rc = res_get(fh);
mutex_unlock(&dev->lock);
@@ -2165,7 +2190,7 @@ cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
return rc;
return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0,
- filp->f_flags & O_NONBLOCK);
+ filp->f_flags & O_NONBLOCK);
}
return 0;
}
@@ -2191,10 +2216,10 @@ static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table * wait)
if (unlikely(rc < 0))
return POLLERR;
- if ( (V4L2_BUF_TYPE_VIDEO_CAPTURE == fh->type) ||
- (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) )
- return videobuf_poll_stream(filp, &fh->vb_vidq, wait);
- else
+ if ((V4L2_BUF_TYPE_VIDEO_CAPTURE == fh->type) ||
+ (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type))
+ return videobuf_poll_stream(filp, &fh->vb_vidq, wait);
+ else
return POLLERR;
}
@@ -2203,15 +2228,15 @@ static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table * wait)
*/
static int cx231xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
{
- struct cx231xx_fh *fh = filp->private_data;
- struct cx231xx *dev = fh->dev;
- int rc;
+ struct cx231xx_fh *fh = filp->private_data;
+ struct cx231xx *dev = fh->dev;
+ int rc;
rc = check_dev(dev);
if (rc < 0)
return rc;
- mutex_lock(&dev->lock);
+ mutex_lock(&dev->lock);
rc = res_get(fh);
mutex_unlock(&dev->lock);
@@ -2221,114 +2246,112 @@ static int cx231xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
rc = videobuf_mmap_mapper(&fh->vb_vidq, vma);
cx231xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n",
- (unsigned long)vma->vm_start,
- (unsigned long)vma->vm_end-(unsigned long)vma->vm_start,
- rc);
+ (unsigned long)vma->vm_start,
+ (unsigned long)vma->vm_end -
+ (unsigned long)vma->vm_start, rc);
return rc;
}
static const struct v4l2_file_operations cx231xx_v4l_fops = {
- .owner = THIS_MODULE,
- .open = cx231xx_v4l2_open,
- .release = cx231xx_v4l2_close,
- .read = cx231xx_v4l2_read,
- .poll = cx231xx_v4l2_poll,
- .mmap = cx231xx_v4l2_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = cx231xx_v4l2_open,
+ .release = cx231xx_v4l2_close,
+ .read = cx231xx_v4l2_read,
+ .poll = cx231xx_v4l2_poll,
+ .mmap = cx231xx_v4l2_mmap,
+ .ioctl = video_ioctl2,
};
static const struct v4l2_ioctl_ops video_ioctl_ops = {
- .vidioc_querycap = vidioc_querycap,
- .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
- .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
- .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
- .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
- .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap,
- .vidioc_try_fmt_vbi_cap = vidioc_try_fmt_vbi_cap,
- .vidioc_s_fmt_vbi_cap = vidioc_try_fmt_vbi_cap,
- .vidioc_g_audio = vidioc_g_audio,
- .vidioc_s_audio = vidioc_s_audio,
- .vidioc_cropcap = vidioc_cropcap,
- .vidioc_g_fmt_sliced_vbi_cap = vidioc_g_fmt_sliced_vbi_cap,
+ .vidioc_querycap = vidioc_querycap,
+ .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
+ .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
+ .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
+ .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
+ .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap,
+ .vidioc_try_fmt_vbi_cap = vidioc_try_fmt_vbi_cap,
+ .vidioc_s_fmt_vbi_cap = vidioc_try_fmt_vbi_cap,
+ .vidioc_g_audio = vidioc_g_audio,
+ .vidioc_s_audio = vidioc_s_audio,
+ .vidioc_cropcap = vidioc_cropcap,
+ .vidioc_g_fmt_sliced_vbi_cap = vidioc_g_fmt_sliced_vbi_cap,
.vidioc_try_fmt_sliced_vbi_cap = vidioc_try_set_sliced_vbi_cap,
- .vidioc_reqbufs = vidioc_reqbufs,
- .vidioc_querybuf = vidioc_querybuf,
- .vidioc_qbuf = vidioc_qbuf,
- .vidioc_dqbuf = vidioc_dqbuf,
- .vidioc_s_std = vidioc_s_std,
- .vidioc_g_std = vidioc_g_std,
- .vidioc_enum_input = vidioc_enum_input,
- .vidioc_g_input = vidioc_g_input,
- .vidioc_s_input = vidioc_s_input,
- .vidioc_queryctrl = vidioc_queryctrl,
- .vidioc_g_ctrl = vidioc_g_ctrl,
- .vidioc_s_ctrl = vidioc_s_ctrl,
- .vidioc_streamon = vidioc_streamon,
- .vidioc_streamoff = vidioc_streamoff,
- .vidioc_g_tuner = vidioc_g_tuner,
- .vidioc_s_tuner = vidioc_s_tuner,
- .vidioc_g_frequency = vidioc_g_frequency,
- .vidioc_s_frequency = vidioc_s_frequency,
+ .vidioc_reqbufs = vidioc_reqbufs,
+ .vidioc_querybuf = vidioc_querybuf,
+ .vidioc_qbuf = vidioc_qbuf,
+ .vidioc_dqbuf = vidioc_dqbuf,
+ .vidioc_s_std = vidioc_s_std,
+ .vidioc_g_std = vidioc_g_std,
+ .vidioc_enum_input = vidioc_enum_input,
+ .vidioc_g_input = vidioc_g_input,
+ .vidioc_s_input = vidioc_s_input,
+ .vidioc_queryctrl = vidioc_queryctrl,
+ .vidioc_g_ctrl = vidioc_g_ctrl,
+ .vidioc_s_ctrl = vidioc_s_ctrl,
+ .vidioc_streamon = vidioc_streamon,
+ .vidioc_streamoff = vidioc_streamoff,
+ .vidioc_g_tuner = vidioc_g_tuner,
+ .vidioc_s_tuner = vidioc_s_tuner,
+ .vidioc_g_frequency = vidioc_g_frequency,
+ .vidioc_s_frequency = vidioc_s_frequency,
#ifdef CONFIG_VIDEO_ADV_DEBUG
- .vidioc_g_register = vidioc_g_register,
- .vidioc_s_register = vidioc_s_register,
+ .vidioc_g_register = vidioc_g_register,
+ .vidioc_s_register = vidioc_s_register,
#endif
#ifdef CONFIG_VIDEO_V4L1_COMPAT
- .vidiocgmbuf = vidiocgmbuf,
+ .vidiocgmbuf = vidiocgmbuf,
#endif
};
static struct video_device cx231xx_vbi_template;
static const struct video_device cx231xx_video_template = {
- .fops = &cx231xx_v4l_fops,
- .release = video_device_release,
- .ioctl_ops = &video_ioctl_ops,
- .minor = -1,
- .tvnorms = V4L2_STD_ALL,
- .current_norm = V4L2_STD_PAL,
+ .fops = &cx231xx_v4l_fops,
+ .release = video_device_release,
+ .ioctl_ops = &video_ioctl_ops,
+ .minor = -1,
+ .tvnorms = V4L2_STD_ALL,
+ .current_norm = V4L2_STD_PAL,
};
static const struct v4l2_file_operations radio_fops = {
- .owner = THIS_MODULE,
- .open = cx231xx_v4l2_open,
- .release = cx231xx_v4l2_close,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = cx231xx_v4l2_open,
+ .release = cx231xx_v4l2_close,
+ .ioctl = video_ioctl2,
};
static const struct v4l2_ioctl_ops radio_ioctl_ops = {
- .vidioc_querycap = radio_querycap,
- .vidioc_g_tuner = radio_g_tuner,
- .vidioc_enum_input = radio_enum_input,
- .vidioc_g_audio = radio_g_audio,
- .vidioc_s_tuner = radio_s_tuner,
- .vidioc_s_audio = radio_s_audio,
- .vidioc_s_input = radio_s_input,
- .vidioc_queryctrl = radio_queryctrl,
- .vidioc_g_ctrl = vidioc_g_ctrl,
- .vidioc_s_ctrl = vidioc_s_ctrl,
- .vidioc_g_frequency = vidioc_g_frequency,
- .vidioc_s_frequency = vidioc_s_frequency,
+ .vidioc_querycap = radio_querycap,
+ .vidioc_g_tuner = radio_g_tuner,
+ .vidioc_enum_input = radio_enum_input,
+ .vidioc_g_audio = radio_g_audio,
+ .vidioc_s_tuner = radio_s_tuner,
+ .vidioc_s_audio = radio_s_audio,
+ .vidioc_s_input = radio_s_input,
+ .vidioc_queryctrl = radio_queryctrl,
+ .vidioc_g_ctrl = vidioc_g_ctrl,
+ .vidioc_s_ctrl = vidioc_s_ctrl,
+ .vidioc_g_frequency = vidioc_g_frequency,
+ .vidioc_s_frequency = vidioc_s_frequency,
#ifdef CONFIG_VIDEO_ADV_DEBUG
- .vidioc_g_register = vidioc_g_register,
- .vidioc_s_register = vidioc_s_register,
+ .vidioc_g_register = vidioc_g_register,
+ .vidioc_s_register = vidioc_s_register,
#endif
};
static struct video_device cx231xx_radio_template = {
- .name = "cx231xx-radio",
- .fops = &radio_fops,
- .ioctl_ops = &radio_ioctl_ops,
- .minor = -1,
+ .name = "cx231xx-radio",
+ .fops = &radio_fops,
+ .ioctl_ops = &radio_ioctl_ops,
+ .minor = -1,
};
/******************************** usb interface ******************************/
-
-static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
- const struct video_device *template,
- const char *type_name)
+static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, const struct video_device
+ *template, const char *type_name)
{
struct video_device *vfd;
@@ -2336,13 +2359,12 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
if (NULL == vfd)
return NULL;
*vfd = *template;
- vfd->minor = -1;
+ vfd->minor = -1;
vfd->parent = &dev->udev->dev;
vfd->release = video_device_release;
vfd->debug = video_debug;
- snprintf(vfd->name, sizeof(vfd->name), "%s %s",
- dev->name, type_name);
+ snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
return vfd;
}
@@ -2351,15 +2373,16 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
{
int ret;
- cx231xx_info("%s()\n", __func__);
+ cx231xx_info("%s()\n", __func__);
cx231xx_info("%s: v4l2 driver version %d.%d.%d\n",
- dev->name,
- (CX231XX_VERSION_CODE >> 16) & 0xff,
- (CX231XX_VERSION_CODE >> 8) & 0xff, CX231XX_VERSION_CODE & 0xff);
+ dev->name,
+ (CX231XX_VERSION_CODE >> 16) & 0xff,
+ (CX231XX_VERSION_CODE >> 8) & 0xff,
+ CX231XX_VERSION_CODE & 0xff);
/* set default norm */
- /*dev->norm = cx231xx_video_template.current_norm;*/
+ /*dev->norm = cx231xx_video_template.current_norm; */
dev->width = norm_maxw(dev);
dev->height = norm_maxh(dev);
dev->interlaced = 0;
@@ -2375,7 +2398,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
dev->volume = 0x1f;
/* enable vbi capturing */
- /* write code here... */
+ /* write code here... */
/* allocate and fill video video_device struct */
dev->vdev = cx231xx_vdev_init(dev, &cx231xx_video_template, "video");
@@ -2386,37 +2409,38 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
/* register v4l2 video video_device */
ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
- video_nr[dev->devno]);
+ video_nr[dev->devno]);
if (ret) {
- cx231xx_errdev("unable to register video device (error=%i).\n", ret);
+ cx231xx_errdev("unable to register video device (error=%i).\n",
+ ret);
return ret;
}
- cx231xx_info("%s/0: registered device video%d [v4l2]\n",
- dev->name, dev->vdev->num);
-
- /* Initialize VBI template */
- memcpy( &cx231xx_vbi_template, &cx231xx_video_template,
- sizeof(cx231xx_vbi_template) );
- strcpy(cx231xx_vbi_template.name,"cx231xx-vbi");
+ cx231xx_info("%s/0: registered device video%d [v4l2]\n",
+ dev->name, dev->vdev->num);
+ /* Initialize VBI template */
+ memcpy(&cx231xx_vbi_template, &cx231xx_video_template,
+ sizeof(cx231xx_vbi_template));
+ strcpy(cx231xx_vbi_template.name, "cx231xx-vbi");
/* Allocate and fill vbi video_device struct */
dev->vbi_dev = cx231xx_vdev_init(dev, &cx231xx_vbi_template, "vbi");
/* register v4l2 vbi video_device */
ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
- vbi_nr[dev->devno]);
+ vbi_nr[dev->devno]);
if (ret < 0) {
cx231xx_errdev("unable to register vbi device\n");
return ret;
}
- cx231xx_info("%s/0: registered device vbi%d\n",
- dev->name, dev->vbi_dev->num);
+ cx231xx_info("%s/0: registered device vbi%d\n",
+ dev->name, dev->vbi_dev->num);
if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) {
- dev->radio_dev = cx231xx_vdev_init(dev, &cx231xx_radio_template, "radio");
+ dev->radio_dev =
+ cx231xx_vdev_init(dev, &cx231xx_radio_template, "radio");
if (!dev->radio_dev) {
cx231xx_errdev("cannot allocate video_device.\n");
return -ENODEV;
@@ -2428,13 +2452,11 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
return ret;
}
cx231xx_info("Registered radio device as /dev/radio%d\n",
- dev->radio_dev->num);
+ dev->radio_dev->num);
}
cx231xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n",
- dev->vdev->num, dev->vbi_dev->num);
+ dev->vdev->num, dev->vbi_dev->num);
return 0;
}
-
-