Commit 84b5dbf3 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (10955): cx231xx: CodingStyle automatic fixes with Lindent

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e0d3bafd
...@@ -58,9 +58,8 @@ static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) ...@@ -58,9 +58,8 @@ static int cx231xx_isoc_audio_deinit(struct cx231xx *dev)
dprintk("Stopping isoc\n"); dprintk("Stopping isoc\n");
for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
if(dev->adev.urb[i]) { if (dev->adev.urb[i]) {
if (!irqs_disabled()) if (!irqs_disabled())
usb_kill_urb(dev->adev.urb[i]); usb_kill_urb(dev->adev.urb[i]);
else else
...@@ -145,7 +144,6 @@ static void cx231xx_audio_isocirq(struct urb *urb) ...@@ -145,7 +144,6 @@ static void cx231xx_audio_isocirq(struct urb *urb)
runtime->period_size; runtime->period_size;
period_elapsed = 1; period_elapsed = 1;
} }
snd_pcm_stream_unlock(substream); snd_pcm_stream_unlock(substream);
} }
if (period_elapsed) if (period_elapsed)
...@@ -166,7 +164,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) ...@@ -166,7 +164,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev)
int i, errCode; int i, errCode;
int sb_size; int sb_size;
cx231xx_info("%s: Starting AUDIO transfers\n",__func__); cx231xx_info("%s: Starting AUDIO transfers\n", __func__);
sb_size = CX231XX_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size; sb_size = CX231XX_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size;
...@@ -191,7 +189,8 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) ...@@ -191,7 +189,8 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev)
urb->dev = dev->udev; urb->dev = dev->udev;
urb->context = dev; urb->context = dev;
urb->pipe = usb_rcvisocpipe(dev->udev, dev->adev.end_point_addr); urb->pipe =
usb_rcvisocpipe(dev->udev, dev->adev.end_point_addr);
urb->transfer_flags = URB_ISO_ASAP; urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = dev->adev.transfer_buffer[i]; urb->transfer_buffer = dev->adev.transfer_buffer[i];
urb->interval = 1; urb->interval = 1;
...@@ -202,8 +201,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) ...@@ -202,8 +201,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev)
for (j = k = 0; j < CX231XX_NUM_AUDIO_PACKETS; for (j = k = 0; j < CX231XX_NUM_AUDIO_PACKETS;
j++, k += dev->adev.max_pkt_size) { j++, k += dev->adev.max_pkt_size) {
urb->iso_frame_desc[j].offset = k; urb->iso_frame_desc[j].offset = k;
urb->iso_frame_desc[j].length = urb->iso_frame_desc[j].length = dev->adev.max_pkt_size;
dev->adev.max_pkt_size;
} }
dev->adev.urb[i] = urb; dev->adev.urb[i] = urb;
} }
...@@ -221,7 +219,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) ...@@ -221,7 +219,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev)
static int cx231xx_cmd(struct cx231xx *dev, int cmd, int arg) static int cx231xx_cmd(struct cx231xx *dev, int cmd, int arg)
{ {
dprintk("%s transfer\n", (dev->adev.capture_stream == STREAM_ON)? dprintk("%s transfer\n", (dev->adev.capture_stream == STREAM_ON) ?
"stop" : "start"); "stop" : "start");
switch (cmd) { switch (cmd) {
...@@ -233,7 +231,7 @@ static int cx231xx_cmd(struct cx231xx *dev, int cmd, int arg) ...@@ -233,7 +231,7 @@ static int cx231xx_cmd(struct cx231xx *dev, int cmd, int arg)
dev->adev.capture_stream = STREAM_OFF; dev->adev.capture_stream = STREAM_OFF;
cx231xx_isoc_audio_deinit(dev); cx231xx_isoc_audio_deinit(dev);
} else { } else {
cx231xx_errdev( "An underrun very likely occurred. " cx231xx_errdev("An underrun very likely occurred. "
"Ignoring it.\n"); "Ignoring it.\n");
} }
return 0; return 0;
...@@ -266,8 +264,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, ...@@ -266,8 +264,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
static struct snd_pcm_hardware snd_cx231xx_hw_capture = { static struct snd_pcm_hardware snd_cx231xx_hw_capture = {
.info = SNDRV_PCM_INFO_BLOCK_TRANSFER | .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID,
SNDRV_PCM_INFO_MMAP_VALID,
.formats = SNDRV_PCM_FMTBIT_S16_LE, .formats = SNDRV_PCM_FMTBIT_S16_LE,
...@@ -330,7 +327,6 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) ...@@ -330,7 +327,6 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream)
int ret; int ret;
struct cx231xx *dev = snd_pcm_substream_chip(substream); struct cx231xx *dev = snd_pcm_substream_chip(substream);
dprintk("closing device\n"); dprintk("closing device\n");
/* set alternate setting for audio interface */ /* set alternate setting for audio interface */
...@@ -402,14 +398,14 @@ static int snd_cx231xx_capture_trigger(struct snd_pcm_substream *substream, ...@@ -402,14 +398,14 @@ static int snd_cx231xx_capture_trigger(struct snd_pcm_substream *substream,
struct cx231xx *dev = snd_pcm_substream_chip(substream); struct cx231xx *dev = snd_pcm_substream_chip(substream);
int retval; int retval;
dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START) ?
dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START)? "start" : "stop");
"start": "stop");
spin_lock(&dev->adev.slock); spin_lock(&dev->adev.slock);
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN, CX231XX_START_AUDIO); cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN,
CX231XX_START_AUDIO);
retval = 0; retval = 0;
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
...@@ -492,7 +488,8 @@ static int cx231xx_audio_init(struct cx231xx *dev) ...@@ -492,7 +488,8 @@ static int cx231xx_audio_init(struct cx231xx *dev)
return err; return err;
} }
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx231xx_pcm_capture); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
&snd_cx231xx_pcm_capture);
pcm->info_flags = 0; pcm->info_flags = 0;
pcm->private_data = dev; pcm->private_data = dev;
strcpy(pcm->name, "Conexant cx231xx Capture"); strcpy(pcm->name, "Conexant cx231xx Capture");
...@@ -509,13 +506,18 @@ static int cx231xx_audio_init(struct cx231xx *dev) ...@@ -509,13 +506,18 @@ static int cx231xx_audio_init(struct cx231xx *dev)
adev->udev = dev->udev; adev->udev = dev->udev;
/* compute alternate max packet sizes for Audio */ /* compute alternate max packet sizes for Audio */
uif = dev->udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.audio_index+1]; uif =
dev->udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.
audio_index + 1];
adev->end_point_addr = le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); adev->end_point_addr =
le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
bEndpointAddress);
adev->num_alt = uif->num_altsetting; adev->num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", adev->end_point_addr, cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n",
adev->num_alt); adev->end_point_addr, adev->num_alt);
adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL);
if (adev->alt_max_pkt_size == NULL) { if (adev->alt_max_pkt_size == NULL) {
...@@ -523,8 +525,9 @@ static int cx231xx_audio_init(struct cx231xx *dev) ...@@ -523,8 +525,9 @@ static int cx231xx_audio_init(struct cx231xx *dev)
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < adev->num_alt ; i++) { for (i = 0; i < adev->num_alt; i++) {
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. u16 tmp =
le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.
wMaxPacketSize); wMaxPacketSize);
adev->alt_max_pkt_size[i] = adev->alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -50,14 +50,12 @@ static unsigned long cx231xx_devused; ...@@ -50,14 +50,12 @@ static unsigned long cx231xx_devused;
*/ */
static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = { static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = {
{ 0x03, 0x01, 10 }, {0x03, 0x01, 10},
{ 0x03, 0x00, 30 }, {0x03, 0x00, 30},
{ 0x03, 0x01, 10 }, {0x03, 0x01, 10},
{ -1, -1, -1 }, {-1, -1, -1},
}; };
/* /*
* Board definitions * Board definitions
*/ */
...@@ -66,23 +64,28 @@ struct cx231xx_board cx231xx_boards[] = { ...@@ -66,23 +64,28 @@ struct cx231xx_board cx231xx_boards[] = {
[CX231XX_BOARD_UNKNOWN] = { [CX231XX_BOARD_UNKNOWN] = {
.name = "Unknown CX231xx video grabber", .name = "Unknown CX231xx video grabber",
.tuner_type = TUNER_ABSENT, .tuner_type = TUNER_ABSENT,
.input = { { .input = {{
.type = CX231XX_VMUX_TELEVISION, .type = CX231XX_VMUX_TELEVISION,
.vmux = CX231XX_VIN_3_1, .vmux = CX231XX_VIN_3_1,
.amux = CX231XX_AMUX_VIDEO, .amux = CX231XX_AMUX_VIDEO,
.gpio = 0, .gpio = 0,
}, { }, {
.type = CX231XX_VMUX_COMPOSITE1, .type =
CX231XX_VMUX_COMPOSITE1,
.vmux = CX231XX_VIN_2_1, .vmux = CX231XX_VIN_2_1,
.amux = CX231XX_AMUX_LINE_IN, .amux = CX231XX_AMUX_LINE_IN,
.gpio = 0, .gpio = 0,
}, { }, {
.type = CX231XX_VMUX_SVIDEO, .type =
.vmux = CX231XX_VIN_1_1 | (CX231XX_VIN_1_2 << 8 ) | CX231XX_VMUX_SVIDEO,
.vmux =
CX231XX_VIN_1_1 |
(CX231XX_VIN_1_2 << 8) |
CX25840_SVIDEO_ON, CX25840_SVIDEO_ON,
.amux = CX231XX_AMUX_LINE_IN, .amux =
CX231XX_AMUX_LINE_IN,
.gpio = 0, .gpio = 0,
} }, }},
}, },
[CX231XX_BOARD_CNXT_RDE_250] = { [CX231XX_BOARD_CNXT_RDE_250] = {
...@@ -105,23 +108,31 @@ struct cx231xx_board cx231xx_boards[] = { ...@@ -105,23 +108,31 @@ struct cx231xx_board cx231xx_boards[] = {
.demod_addr = 0x02, .demod_addr = 0x02,
.norm = V4L2_STD_PAL, .norm = V4L2_STD_PAL,
.input = { { .input = {{
.type = CX231XX_VMUX_TELEVISION, .type =
CX231XX_VMUX_TELEVISION,
.vmux = CX231XX_VIN_3_1, .vmux = CX231XX_VIN_3_1,
.amux = CX231XX_AMUX_VIDEO, .amux = CX231XX_AMUX_VIDEO,
.gpio = 0, .gpio = 0,
}, { }, {
.type = CX231XX_VMUX_COMPOSITE1, .type =
CX231XX_VMUX_COMPOSITE1,
.vmux = CX231XX_VIN_2_1, .vmux = CX231XX_VIN_2_1,
.amux = CX231XX_AMUX_LINE_IN, .amux =
CX231XX_AMUX_LINE_IN,
.gpio = 0, .gpio = 0,
}, { }, {
.type = CX231XX_VMUX_SVIDEO, .type =
.vmux = CX231XX_VIN_1_1 | (CX231XX_VIN_1_2 << 8 ) | CX231XX_VMUX_SVIDEO,
.vmux =
CX231XX_VIN_1_1 |
(CX231XX_VIN_1_2 <<
8) |
CX25840_SVIDEO_ON, CX25840_SVIDEO_ON,
.amux = CX231XX_AMUX_LINE_IN, .amux =
CX231XX_AMUX_LINE_IN,
.gpio = 0, .gpio = 0,
} }, }},
}, },
[CX231XX_BOARD_CNXT_RDU_250] = { [CX231XX_BOARD_CNXT_RDU_250] = {
...@@ -144,37 +155,46 @@ struct cx231xx_board cx231xx_boards[] = { ...@@ -144,37 +155,46 @@ struct cx231xx_board cx231xx_boards[] = {
.demod_addr = 0x32, .demod_addr = 0x32,
.norm = V4L2_STD_NTSC, .norm = V4L2_STD_NTSC,
.input = { { .input = {{
.type = CX231XX_VMUX_TELEVISION, .type =
CX231XX_VMUX_TELEVISION,
.vmux = CX231XX_VIN_3_1, .vmux = CX231XX_VIN_3_1,
.amux = CX231XX_AMUX_VIDEO, .amux = CX231XX_AMUX_VIDEO,
.gpio = 0, .gpio = 0,
}, { }, {
.type = CX231XX_VMUX_COMPOSITE1, .type =
CX231XX_VMUX_COMPOSITE1,
.vmux = CX231XX_VIN_2_1, .vmux = CX231XX_VIN_2_1,
.amux = CX231XX_AMUX_LINE_IN, .amux =
CX231XX_AMUX_LINE_IN,
.gpio = 0, .gpio = 0,
}, { }, {
.type = CX231XX_VMUX_SVIDEO, .type =
.vmux = CX231XX_VIN_1_1 | (CX231XX_VIN_1_2 << 8 ) | CX231XX_VMUX_SVIDEO,
.vmux =
CX231XX_VIN_1_1 |
(CX231XX_VIN_1_2 <<
8) |
CX25840_SVIDEO_ON, CX25840_SVIDEO_ON,
.amux = CX231XX_AMUX_LINE_IN, .amux =
CX231XX_AMUX_LINE_IN,
.gpio = 0, .gpio = 0,
} }, }},
}, },
}; };
const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards);
/* table of devices that work with this driver */ /* table of devices that work with this driver */
struct usb_device_id cx231xx_id_table [] = { struct usb_device_id cx231xx_id_table[] = {
{ USB_DEVICE(0x0572, 0x58A0), {USB_DEVICE(0x0572, 0x58A0),
.driver_info = CX231XX_BOARD_UNKNOWN }, .driver_info = CX231XX_BOARD_UNKNOWN},
{ USB_DEVICE(0x0572, 0x58A2), {USB_DEVICE(0x0572, 0x58A2),
.driver_info = CX231XX_BOARD_CNXT_RDE_250 }, .driver_info = CX231XX_BOARD_CNXT_RDE_250},
{ USB_DEVICE(0x0572, 0x5A3C), {USB_DEVICE(0x0572, 0x5A3C),
.driver_info = CX231XX_BOARD_CNXT_RDU_250 }, .driver_info = CX231XX_BOARD_CNXT_RDU_250},
{ }, {},
}; };
MODULE_DEVICE_TABLE(usb, cx231xx_id_table); MODULE_DEVICE_TABLE(usb, cx231xx_id_table);
/* cx231xx_tuner_callback /* cx231xx_tuner_callback
...@@ -188,19 +208,24 @@ int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) ...@@ -188,19 +208,24 @@ int cx231xx_tuner_callback(void *ptr, int component, int command, int arg)
if (dev->tuner_type == TUNER_XC5000) { if (dev->tuner_type == TUNER_XC5000) {
if (command == XC5000_TUNER_RESET) { if (command == XC5000_TUNER_RESET) {
cx231xx_info("Tuner Call back : RESET : command %d : tuner type %d \n", cx231xx_info
("Tuner Call back : RESET : command %d : tuner type %d \n",
command, dev->tuner_type); command, dev->tuner_type);
cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,
1);
msleep(10); msleep(10);
cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,0); cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,
0);
msleep(330); msleep(330);
cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,
1);
msleep(10); msleep(10);
} }
} }
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); EXPORT_SYMBOL_GPL(cx231xx_tuner_callback);
static void inline cx231xx_set_model(struct cx231xx *dev) static void inline cx231xx_set_model(struct cx231xx *dev)
...@@ -225,17 +250,17 @@ void cx231xx_pre_card_setup(struct cx231xx *dev) ...@@ -225,17 +250,17 @@ void cx231xx_pre_card_setup(struct cx231xx *dev)
/* do card specific GPIO settings if required */ /* do card specific GPIO settings if required */
cx231xx_info("Precard: Board is Conexnat RDE 250\n"); cx231xx_info("Precard: Board is Conexnat RDE 250\n");
/* set the direction for GPIO pins */ /* set the direction for GPIO pins */
cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit,1); cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1);
cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1);
cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio,1); cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1);
break; break;
case CX231XX_BOARD_CNXT_RDU_250: case CX231XX_BOARD_CNXT_RDU_250:
/* do card specific GPIO settings if required */ /* do card specific GPIO settings if required */
cx231xx_info("Precard: Board is Conexnat RDU 250\n"); cx231xx_info("Precard: Board is Conexnat RDU 250\n");
/* set the direction for GPIO pins */ /* set the direction for GPIO pins */
cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit,1); cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1);
cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1);
cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio,1); cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1);
break; break;
} }
...@@ -267,7 +292,8 @@ static void cx231xx_config_tuner(struct cx231xx *dev) ...@@ -267,7 +292,8 @@ static void cx231xx_config_tuner(struct cx231xx *dev)
tun_setup.addr = dev->tuner_addr; tun_setup.addr = dev->tuner_addr;
tun_setup.tuner_callback = cx231xx_tuner_callback; tun_setup.tuner_callback = cx231xx_tuner_callback;
cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_TYPE_ADDR, &tun_setup); cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_TYPE_ADDR,
&tun_setup);
#if 0 #if 0
if (tun_setup.type == TUNER_XC5000) { if (tun_setup.type == TUNER_XC5000) {
static struct xc2028_ctrl ctrl = { static struct xc2028_ctrl ctrl = {
...@@ -279,7 +305,8 @@ static void cx231xx_config_tuner(struct cx231xx *dev) ...@@ -279,7 +305,8 @@ static void cx231xx_config_tuner(struct cx231xx *dev)
.tuner = dev->tuner_type, .tuner = dev->tuner_type,
.priv = &ctrl, .priv = &ctrl,
}; };
cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_CONFIG, &cfg); cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_CONFIG,
&cfg);
} }
#endif #endif
...@@ -298,7 +325,7 @@ void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) ...@@ -298,7 +325,7 @@ void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir)
{ {
if (disable_ir) { if (disable_ir) {
ir->get_key = NULL; ir->get_key = NULL;
return ; return;
} }
/* detect & configure */ /* detect & configure */
...@@ -345,7 +372,6 @@ void cx231xx_card_setup(struct cx231xx *dev) ...@@ -345,7 +372,6 @@ void cx231xx_card_setup(struct cx231xx *dev)
"addresses)\n\n"); "addresses)\n\n");
} }
/* request some modules */ /* request some modules */
if (dev->board.decoder == CX231XX_AVDECODER) { if (dev->board.decoder == CX231XX_AVDECODER) {
cx231xx_info(": Requesting cx25840 module\n"); cx231xx_info(": Requesting cx25840 module\n");
...@@ -364,8 +390,6 @@ void cx231xx_card_setup(struct cx231xx *dev) ...@@ -364,8 +390,6 @@ void cx231xx_card_setup(struct cx231xx *dev)
#endif #endif
} }
/* /*
* cx231xx_config() * cx231xx_config()
* inits registers with sane defaults * inits registers with sane defaults
...@@ -415,10 +439,9 @@ void cx231xx_release_resources(struct cx231xx *dev) ...@@ -415,10 +439,9 @@ void cx231xx_release_resources(struct cx231xx *dev)
usb_put_dev(dev->udev); usb_put_dev(dev->udev);
/* Mark device as unused */ /* Mark device as unused */
cx231xx_devused &= ~(1<<dev->devno); cx231xx_devused &= ~(1 << dev->devno);
} }
/* /*
* cx231xx_init_dev() * cx231xx_init_dev()
* allocates and inits the device structs, registers i2c bus and v4l device * allocates and inits the device structs, registers i2c bus and v4l device
...@@ -519,7 +542,7 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, ...@@ -519,7 +542,7 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev,
return 0; return 0;
fail_reg_devices: fail_reg_devices:
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return retval; return retval;
} }
...@@ -530,7 +553,6 @@ static void request_module_async(struct work_struct *work) ...@@ -530,7 +553,6 @@ static void request_module_async(struct work_struct *work)
struct cx231xx *dev = container_of(work, struct cx231xx *dev = container_of(work,
struct cx231xx, request_module_wk); struct cx231xx, request_module_wk);
if (dev->has_alsa_audio) if (dev->has_alsa_audio)
request_module("cx231xx-alsa"); request_module("cx231xx-alsa");
...@@ -548,8 +570,6 @@ static void request_modules(struct cx231xx *dev) ...@@ -548,8 +570,6 @@ static void request_modules(struct cx231xx *dev)
#define request_modules(dev) #define request_modules(dev)
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
/* /*
* cx231xx_usb_probe() * cx231xx_usb_probe()
* checks for supported devices * checks for supported devices
...@@ -575,15 +595,15 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -575,15 +595,15 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
cx231xx_info(": Interface Number %d\n", ifnum); cx231xx_info(": Interface Number %d\n", ifnum);
/* Interface number 0 - IR interface */ /* Interface number 0 - IR interface */
if(ifnum == 0 ){ if (ifnum == 0) {
/* Check to see next free device and mark as used */ /* Check to see next free device and mark as used */
nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS);
cx231xx_devused |= 1<<nr; cx231xx_devused |= 1 << nr;
if (nr >= CX231XX_MAXBOARDS) { if (nr >= CX231XX_MAXBOARDS) {
cx231xx_info(": Supports only %i cx231xx boards.\n", cx231xx_info(": Supports only %i cx231xx boards.\n",
CX231XX_MAXBOARDS); CX231XX_MAXBOARDS);
cx231xx_devused &= ~(1<<nr); cx231xx_devused &= ~(1 << nr);
return -ENOMEM; return -ENOMEM;
} }
...@@ -591,7 +611,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -591,7 +611,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) { if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of memory!\n"); cx231xx_err(DRIVER_NAME ": out of memory!\n");
cx231xx_devused &= ~(1<<nr); cx231xx_devused &= ~(1 << nr);
return -ENOMEM; return -ENOMEM;
} }
...@@ -613,19 +633,19 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -613,19 +633,19 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
/* get maximum no.of IAD interfaces */ /* get maximum no.of IAD interfaces */
assoc_desc = udev->actconfig->intf_assoc[0]; assoc_desc = udev->actconfig->intf_assoc[0];
dev->max_iad_interface_count = assoc_desc->bInterfaceCount; dev->max_iad_interface_count = assoc_desc->bInterfaceCount;
cx231xx_info(": Found IAD interface count %d\n", dev->max_iad_interface_count); cx231xx_info(": Found IAD interface count %d\n",
dev->max_iad_interface_count);
/* init CIR module TBD */ /* init CIR module TBD */
/* store the current interface */ /* store the current interface */
lif = interface; lif = interface;
} } else if (ifnum == 1) {
else if(ifnum == 1 ){
/* Get dev structure first */ /* Get dev structure first */
dev = usb_get_intfdata(udev->actconfig->interface[0]); dev = usb_get_intfdata(udev->actconfig->interface[0]);
if(dev == NULL){ if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of first interface!\n"); cx231xx_err(DRIVER_NAME ": out of first interface!\n");
return -ENODEV; return -ENODEV;
} }
...@@ -640,18 +660,19 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -640,18 +660,19 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
nr = dev->devno; nr = dev->devno;
assoc_desc = udev->actconfig->intf_assoc[0]; assoc_desc = udev->actconfig->intf_assoc[0];
if(assoc_desc->bFirstInterface == ifnum){ if (assoc_desc->bFirstInterface == ifnum) {
cx231xx_info(": Found IAD interface match: AV Descriptor Start!! \n"); cx231xx_info
(": Found IAD interface match: AV Descriptor Start!! \n");
} else { } else {
cx231xx_err(DRIVER_NAME " Not found matching interface\n"); cx231xx_err(DRIVER_NAME
" Not found matching interface\n");
return -ENODEV; return -ENODEV;
} }
} } else if (ifnum >= 2) {
else if(ifnum >= 2) {
/* Get dev structure first */ /* Get dev structure first */
dev = usb_get_intfdata(udev->actconfig->interface[0]); dev = usb_get_intfdata(udev->actconfig->interface[0]);
if(dev == NULL){ if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of first interface!\n"); cx231xx_err(DRIVER_NAME ": out of first interface!\n");
return -ENODEV; return -ENODEV;
} }
...@@ -666,10 +687,11 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -666,10 +687,11 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
nr = dev->devno; nr = dev->devno;
/* set skip interface */ /* set skip interface */
if((dev->interface_count -1) != dev->max_iad_interface_count ) if ((dev->interface_count - 1) != dev->max_iad_interface_count)
skip_interface = 1; /* set skipping */ skip_interface = 1; /* set skipping */
else{ else {
cx231xx_info(": Found IAD interface number match with AV Device number!! \n"); cx231xx_info
(": Found IAD interface number match with AV Device number!! \n");
} }
} }
...@@ -705,69 +727,82 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -705,69 +727,82 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
speed, speed,
le16_to_cpu(udev->descriptor.idVendor), le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct), le16_to_cpu(udev->descriptor.idProduct),
ifnum, ifnum, interface->altsetting->desc.bInterfaceNumber);
interface->altsetting->desc.bInterfaceNumber);
/* AV device initialization */ /* AV device initialization */
if((dev->interface_count -1) == dev->max_iad_interface_count ) { if ((dev->interface_count - 1) == dev->max_iad_interface_count) {
cx231xx_info(" Calling init_dev\n"); cx231xx_info(" Calling init_dev\n");
/* allocate device struct */ /* allocate device struct */
retval = cx231xx_init_dev(&dev, udev, nr); retval = cx231xx_init_dev(&dev, udev, nr);
if (retval) { if (retval) {
cx231xx_devused &= ~(1<<dev->devno); cx231xx_devused &= ~(1 << dev->devno);
kfree(dev); kfree(dev);
return retval; return retval;
} }
/* compute alternate max packet sizes for video */ /* compute alternate max packet sizes for video */
uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.video_index+1]; uif =
udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.
video_index + 1];
dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); dev->video_mode.end_point_addr =
le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
bEndpointAddress);
dev->video_mode.num_alt = uif->num_altsetting; dev->video_mode.num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->video_mode.end_point_addr, cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->video_mode.end_point_addr,
dev->video_mode.num_alt); dev->video_mode.num_alt);
dev->video_mode.alt_max_pkt_size = kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); dev->video_mode.alt_max_pkt_size =
kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL);
if (dev->video_mode.alt_max_pkt_size == NULL) { if (dev->video_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n"); cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1<<nr); cx231xx_devused &= ~(1 << nr);
kfree(dev); kfree(dev);
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < dev->video_mode.num_alt ; i++) { for (i = 0; i < dev->video_mode.num_alt; i++) {
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. u16 tmp =
wMaxPacketSize); le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
desc.wMaxPacketSize);
dev->video_mode.alt_max_pkt_size[i] = dev->video_mode.alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
cx231xx_info("Alternate setting %i, max size= %i\n", i, cx231xx_info("Alternate setting %i, max size= %i\n", i,
dev->video_mode.alt_max_pkt_size[i]); dev->video_mode.alt_max_pkt_size[i]);
} }
/* compute alternate max packet sizes for vbi */ /* compute alternate max packet sizes for vbi */
uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index+1]; uif =
udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.
vanc_index + 1];
dev->vbi_mode.end_point_addr = dev->vbi_mode.end_point_addr =
le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
bEndpointAddress);
dev->vbi_mode.num_alt = uif->num_altsetting; dev->vbi_mode.num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->vbi_mode.end_point_addr, cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->vbi_mode.end_point_addr,
dev->vbi_mode.num_alt); dev->vbi_mode.num_alt);
dev->vbi_mode.alt_max_pkt_size = kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); dev->vbi_mode.alt_max_pkt_size =
kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL);
if (dev->vbi_mode.alt_max_pkt_size == NULL) { if (dev->vbi_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n"); cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1<<nr); cx231xx_devused &= ~(1 << nr);
kfree(dev); kfree(dev);
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < dev->vbi_mode.num_alt ; i++) { for (i = 0; i < dev->vbi_mode.num_alt; i++) {
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. u16 tmp =
wMaxPacketSize); le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
desc.wMaxPacketSize);
dev->vbi_mode.alt_max_pkt_size[i] = dev->vbi_mode.alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
cx231xx_info("Alternate setting %i, max size= %i\n", i, cx231xx_info("Alternate setting %i, max size= %i\n", i,
...@@ -775,58 +810,77 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -775,58 +810,77 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
} }
/* compute alternate max packet sizes for sliced CC */ /* compute alternate max packet sizes for sliced CC */
uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index+1]; uif =
udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.
hanc_index + 1];
dev->sliced_cc_mode.end_point_addr = dev->sliced_cc_mode.end_point_addr =
le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
bEndpointAddress);
dev->sliced_cc_mode.num_alt = uif->num_altsetting; dev->sliced_cc_mode.num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->sliced_cc_mode.end_point_addr, cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->sliced_cc_mode.end_point_addr,
dev->sliced_cc_mode.num_alt); dev->sliced_cc_mode.num_alt);
dev->sliced_cc_mode.alt_max_pkt_size = kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); dev->sliced_cc_mode.alt_max_pkt_size =
kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL);
if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n"); cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1<<nr); cx231xx_devused &= ~(1 << nr);
kfree(dev); kfree(dev);
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < dev->sliced_cc_mode.num_alt ; i++) { for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) {
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. u16 tmp =
wMaxPacketSize); le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
desc.wMaxPacketSize);
dev->sliced_cc_mode.alt_max_pkt_size[i] = dev->sliced_cc_mode.alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
cx231xx_info("Alternate setting %i, max size= %i\n", i, cx231xx_info("Alternate setting %i, max size= %i\n", i,
dev->sliced_cc_mode.alt_max_pkt_size[i]); dev->sliced_cc_mode.alt_max_pkt_size[i]);
} }
if(dev->current_pcb_config.ts1_source != 0xff ) { if (dev->current_pcb_config.ts1_source != 0xff) {
/* compute alternate max packet sizes for TS1 */ /* compute alternate max packet sizes for TS1 */
uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index+1]; uif =
udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].
interface_info.
ts1_index + 1];
dev->ts1_mode.end_point_addr = dev->ts1_mode.end_point_addr =
le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].
desc.bEndpointAddress);
dev->ts1_mode.num_alt = uif->num_altsetting; dev->ts1_mode.num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->ts1_mode.end_point_addr, cx231xx_info
(": EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->ts1_mode.end_point_addr,
dev->ts1_mode.num_alt); dev->ts1_mode.num_alt);
dev->ts1_mode.alt_max_pkt_size = kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); dev->ts1_mode.alt_max_pkt_size =
kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL);
if (dev->ts1_mode.alt_max_pkt_size == NULL) { if (dev->ts1_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n"); cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1<<nr); cx231xx_devused &= ~(1 << nr);
kfree(dev); kfree(dev);
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < dev->ts1_mode.num_alt ; i++) { for (i = 0; i < dev->ts1_mode.num_alt; i++) {
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. u16 tmp =
le16_to_cpu(uif->altsetting[i].
endpoint[isoc_pipe].desc.
wMaxPacketSize); wMaxPacketSize);
dev->ts1_mode.alt_max_pkt_size[i] = dev->ts1_mode.alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) +
cx231xx_info("Alternate setting %i, max size= %i\n", i, 1);
cx231xx_info
("Alternate setting %i, max size= %i\n", i,
dev->ts1_mode.alt_max_pkt_size[i]); dev->ts1_mode.alt_max_pkt_size[i]);
} }
} }
...@@ -837,13 +891,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -837,13 +891,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
usb_set_intfdata(lif, dev); usb_set_intfdata(lif, dev);
/* load other modules required */ /* load other modules required */
if((dev->interface_count -1) == dev->max_iad_interface_count ) if ((dev->interface_count - 1) == dev->max_iad_interface_count) {
{
cx231xx_info("Calling request modules\n"); cx231xx_info("Calling request modules\n");
request_modules(dev); request_modules(dev);
} }
if(skip_interface ) { if (skip_interface) {
cx231xx_info("Skipping the interface\n"); cx231xx_info("Skipping the interface\n");
return -ENODEV; return -ENODEV;
} }
...@@ -875,8 +928,7 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) ...@@ -875,8 +928,7 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface)
if (dev->users) { if (dev->users) {
cx231xx_warn cx231xx_warn
("device /dev/video%d is open! Deregistration and memory " ("device /dev/video%d is open! Deregistration and memory "
"deallocation are deferred on close.\n", "deallocation are deferred on close.\n", dev->vdev->num);
dev->vdev->num);
dev->state |= DEV_MISCONFIGURED; dev->state |= DEV_MISCONFIGURED;
cx231xx_uninit_isoc(dev); cx231xx_uninit_isoc(dev);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef _POLARIS_REG_H_ #ifndef _POLARIS_REG_H_
#define _POLARIS_REG_H_ #define _POLARIS_REG_H_
...@@ -60,13 +59,13 @@ ...@@ -60,13 +59,13 @@
#define I2C_DEMOD_EN 0x01 /* bit0 */ #define I2C_DEMOD_EN 0x01 /* bit0 */
#define PWR_RESETOUT_EN 0x100 /* bit8 */ #define PWR_RESETOUT_EN 0x100 /* bit8 */
typedef enum{ typedef enum {
POLARIS_AVMODE_DEFAULT = 0, POLARIS_AVMODE_DEFAULT = 0,
POLARIS_AVMODE_DIGITAL = 0x10, POLARIS_AVMODE_DIGITAL = 0x10,
POLARIS_AVMODE_ANALOGT_TV = 0x20, POLARIS_AVMODE_ANALOGT_TV = 0x20,
POLARIS_AVMODE_ENXTERNAL_AV = 0x30, POLARIS_AVMODE_ENXTERNAL_AV = 0x30,
}AV_MODE; } AV_MODE;
/* Colibri Registers */ /* Colibri Registers */
...@@ -75,8 +74,6 @@ typedef enum{ ...@@ -75,8 +74,6 @@ typedef enum{
#define EU_IF 0x9 #define EU_IF 0x9
#define US_IF 0xa #define US_IF 0xa
#define SUP_BLK_TUNE1 0x00 #define SUP_BLK_TUNE1 0x00
#define SUP_BLK_TUNE2 0x01 #define SUP_BLK_TUNE2 0x01
#define SUP_BLK_TUNE3 0x02 #define SUP_BLK_TUNE3 0x02
...@@ -487,5 +484,4 @@ typedef enum{ ...@@ -487,5 +484,4 @@ typedef enum{
/* Reserved [31:25] */ /* Reserved [31:25] */
#define FLD_DIF_CTL_IP 0x01FFFFFF #define FLD_DIF_CTL_IP 0x01FFFFFF
#endif #endif
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
/* #define ENABLE_DEBUG_ISOC_FRAMES */ /* #define ENABLE_DEBUG_ISOC_FRAMES */
static unsigned int core_debug; static unsigned int core_debug;
module_param(core_debug,int,0644); module_param(core_debug, int, 0644);
MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); MODULE_PARM_DESC(core_debug, "enable debug messages [core]");
#define cx231xx_coredbg(fmt, arg...) do {\ #define cx231xx_coredbg(fmt, arg...) do {\
if (core_debug) \ if (core_debug) \
...@@ -41,8 +41,8 @@ MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); ...@@ -41,8 +41,8 @@ MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
dev->name, __func__ , ##arg); } while (0) dev->name, __func__ , ##arg); } while (0)
static unsigned int reg_debug; static unsigned int reg_debug;
module_param(reg_debug,int,0644); module_param(reg_debug, int, 0644);
MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); MODULE_PARM_DESC(reg_debug, "enable debug messages [URB reg]");
#define cx231xx_regdbg(fmt, arg...) do {\ #define cx231xx_regdbg(fmt, arg...) do {\
if (reg_debug) \ if (reg_debug) \
...@@ -59,8 +59,6 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); ...@@ -59,8 +59,6 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
printk(KERN_INFO "%s %s :"fmt, \ printk(KERN_INFO "%s %s :"fmt, \
dev->name, __func__ , ##arg); } while (0) dev->name, __func__ , ##arg); } while (0)
/************************************************************************************ /************************************************************************************
* Device control list functions * * Device control list functions *
*************************************************************************************/ *************************************************************************************/
...@@ -69,8 +67,7 @@ static LIST_HEAD(cx231xx_devlist); ...@@ -69,8 +67,7 @@ static LIST_HEAD(cx231xx_devlist);
static DEFINE_MUTEX(cx231xx_devlist_mutex); static DEFINE_MUTEX(cx231xx_devlist_mutex);
struct cx231xx *cx231xx_get_device(int minor, struct cx231xx *cx231xx_get_device(int minor,
enum v4l2_buf_type *fh_type, enum v4l2_buf_type *fh_type, int *has_radio)
int *has_radio)
{ {
struct cx231xx *h, *dev = NULL; struct cx231xx *h, *dev = NULL;
...@@ -85,8 +82,7 @@ struct cx231xx *cx231xx_get_device(int minor, ...@@ -85,8 +82,7 @@ struct cx231xx *cx231xx_get_device(int minor,
dev = h; dev = h;
*fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; *fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
} }
if (h->radio_dev && if (h->radio_dev && h->radio_dev->minor == minor) {
h->radio_dev->minor == minor) {
dev = h; dev = h;
*has_radio = 1; *has_radio = 1;
} }
...@@ -115,9 +111,6 @@ void cx231xx_add_into_devlist(struct cx231xx *dev) ...@@ -115,9 +111,6 @@ void cx231xx_add_into_devlist(struct cx231xx *dev)
mutex_unlock(&cx231xx_devlist_mutex); mutex_unlock(&cx231xx_devlist_mutex);
}; };
static LIST_HEAD(cx231xx_extension_devlist); static LIST_HEAD(cx231xx_extension_devlist);
static DEFINE_MUTEX(cx231xx_extension_devlist_lock); static DEFINE_MUTEX(cx231xx_extension_devlist_lock);
...@@ -137,6 +130,7 @@ int cx231xx_register_extension(struct cx231xx_ops *ops) ...@@ -137,6 +130,7 @@ int cx231xx_register_extension(struct cx231xx_ops *ops)
mutex_unlock(&cx231xx_devlist_mutex); mutex_unlock(&cx231xx_devlist_mutex);
return 0; return 0;
} }
EXPORT_SYMBOL(cx231xx_register_extension); EXPORT_SYMBOL(cx231xx_register_extension);
void cx231xx_unregister_extension(struct cx231xx_ops *ops) void cx231xx_unregister_extension(struct cx231xx_ops *ops)
...@@ -155,8 +149,8 @@ void cx231xx_unregister_extension(struct cx231xx_ops *ops) ...@@ -155,8 +149,8 @@ void cx231xx_unregister_extension(struct cx231xx_ops *ops)
mutex_unlock(&cx231xx_extension_devlist_lock); mutex_unlock(&cx231xx_extension_devlist_lock);
mutex_unlock(&cx231xx_devlist_mutex); mutex_unlock(&cx231xx_devlist_mutex);
} }
EXPORT_SYMBOL(cx231xx_unregister_extension);
EXPORT_SYMBOL(cx231xx_unregister_extension);
void cx231xx_init_extension(struct cx231xx *dev) void cx231xx_init_extension(struct cx231xx *dev)
{ {
...@@ -209,22 +203,26 @@ int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, ...@@ -209,22 +203,26 @@ int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus,
saddr_len = req_data->saddr_len; saddr_len = req_data->saddr_len;
/* Set wValue */ /* Set wValue */
if(saddr_len == 1) /* need check saddr_len == 0 */ if (saddr_len == 1) /* need check saddr_len == 0 */
ven_req.wValue = req_data->dev_addr<<9|_i2c_period<<4|saddr_len<<2| ven_req.wValue =
_i2c_nostop<<1|I2C_SYNC|_i2c_reserve<<6; req_data->
dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 |
_i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6;
else else
ven_req.wValue = req_data->dev_addr<<9|_i2c_period<<4|saddr_len<<2| ven_req.wValue =
_i2c_nostop<<1|I2C_SYNC|_i2c_reserve<<6; req_data->
dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 |
_i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6;
/* set channel number */ /* set channel number */
if(req_data->direction & I2C_M_RD) if (req_data->direction & I2C_M_RD)
ven_req.bRequest = i2c_bus->nr + 4; /* channel number, for read, ven_req.bRequest = i2c_bus->nr + 4; /* channel number, for read,
spec required channel_num +4 */ spec required channel_num +4 */
else else
ven_req.bRequest = i2c_bus->nr; /* channel number, */ ven_req.bRequest = i2c_bus->nr; /* channel number, */
/* set index value */ /* set index value */
switch(saddr_len){ switch (saddr_len) {
case 0: case 0:
ven_req.wIndex = 0; /* need check */ ven_req.wIndex = 0; /* need check */
break; break;
...@@ -243,22 +241,22 @@ int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, ...@@ -243,22 +241,22 @@ int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus,
ven_req.bData = 0; ven_req.bData = 0;
/* set the direction */ /* set the direction */
if(req_data->direction){ if (req_data->direction) {
ven_req.direction = USB_DIR_IN; ven_req.direction = USB_DIR_IN;
memset(req_data->p_buffer, 0x00, ven_req.wLength); memset(req_data->p_buffer, 0x00, ven_req.wLength);
} } else
else
ven_req.direction = USB_DIR_OUT; ven_req.direction = USB_DIR_OUT;
/* set the buffer for read / write */ /* set the buffer for read / write */
ven_req.pBuff = req_data->p_buffer; ven_req.pBuff = req_data->p_buffer;
/* call common vendor command request */ /* call common vendor command request */
status = cx231xx_send_vendor_cmd(dev, &ven_req); status = cx231xx_send_vendor_cmd(dev, &ven_req);
if (status < 0) { if (status < 0) {
cx231xx_info("UsbInterface::sendCommand, output buffer failed with status -%d\n", status); cx231xx_info
("UsbInterface::sendCommand, output buffer failed with status -%d\n",
status);
} }
return status; return status;
...@@ -282,8 +280,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, ...@@ -282,8 +280,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
if (len > URB_MAX_CTRL_SIZE) if (len > URB_MAX_CTRL_SIZE)
return -EINVAL; return -EINVAL;
switch(len) switch (len) {
{
case 1: case 1:
val = ENABLE_ONE_BYTE; val = ENABLE_ONE_BYTE;
break; break;
...@@ -300,7 +297,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, ...@@ -300,7 +297,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
val = 0xFF; /* invalid option */ val = 0xFF; /* invalid option */
} }
if(val == 0xFF) if (val == 0xFF)
return -EINVAL; return -EINVAL;
if (reg_debug) { if (reg_debug) {
...@@ -309,8 +306,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, ...@@ -309,8 +306,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
pipe, pipe,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
req, 0, val, req, 0, val,
reg & 0xff, reg >> 8, reg & 0xff, reg >> 8, len & 0xff, len >> 8);
len & 0xff, len >> 8);
} }
/* mutex_lock(&dev->ctrl_urb_lock); */ /* mutex_lock(&dev->ctrl_urb_lock); */
...@@ -340,8 +336,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, ...@@ -340,8 +336,7 @@ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
return ret; return ret;
} }
int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN * ven_req)
int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN *ven_req)
{ {
int ret; int ret;
int pipe = 0; int pipe = 0;
...@@ -352,32 +347,34 @@ int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN *ven_req) ...@@ -352,32 +347,34 @@ int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN *ven_req)
if ((ven_req->wLength > URB_MAX_CTRL_SIZE)) if ((ven_req->wLength > URB_MAX_CTRL_SIZE))
return -EINVAL; return -EINVAL;
if(ven_req->direction) if (ven_req->direction)
pipe = usb_rcvctrlpipe(dev->udev, 0); pipe = usb_rcvctrlpipe(dev->udev, 0);
else else
pipe = usb_sndctrlpipe(dev->udev, 0); pipe = usb_sndctrlpipe(dev->udev, 0);
if (reg_debug) { if (reg_debug) {
int byte; int byte;
cx231xx_isocdbg("(pipe 0x%08x): " cx231xx_isocdbg("(pipe 0x%08x): "
"OUT: %02x %02x %02x %04x %04x %04x >>>", "OUT: %02x %02x %02x %04x %04x %04x >>>",
pipe, pipe,
ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ven_req->
direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
ven_req->bRequest, 0, ven_req->wValue, ven_req->bRequest, 0, ven_req->wValue,
ven_req->wIndex, ven_req->wIndex, ven_req->wLength);
ven_req->wLength);
for (byte = 0; byte < ven_req->wLength; byte++) for (byte = 0; byte < ven_req->wLength; byte++)
cx231xx_isocdbg(" %02x", (unsigned char)ven_req->pBuff[byte]); cx231xx_isocdbg(" %02x",
(unsigned char)ven_req->pBuff[byte]);
cx231xx_isocdbg("\n"); cx231xx_isocdbg("\n");
} }
/* mutex_lock(&dev->ctrl_urb_lock); */ /* mutex_lock(&dev->ctrl_urb_lock); */
ret = usb_control_msg(dev->udev, pipe, ven_req->bRequest, ret = usb_control_msg(dev->udev, pipe, ven_req->bRequest,
ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ven_req->
ven_req->wValue, ven_req->wIndex, ven_req->pBuff, ven_req->wLength, HZ); direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
ven_req->wValue, ven_req->wIndex, ven_req->pBuff,
ven_req->wLength, HZ);
/* mutex_unlock(&dev->ctrl_urb_lock); */ /* mutex_unlock(&dev->ctrl_urb_lock); */
return ret; return ret;
...@@ -400,8 +397,7 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, ...@@ -400,8 +397,7 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf,
if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) if ((len < 1) || (len > URB_MAX_CTRL_SIZE))
return -EINVAL; return -EINVAL;
switch(len) switch (len) {
{
case 1: case 1:
val = ENABLE_ONE_BYTE; val = ENABLE_ONE_BYTE;
break; break;
...@@ -418,7 +414,7 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, ...@@ -418,7 +414,7 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf,
val = 0xFF; /* invalid option */ val = 0xFF; /* invalid option */
} }
if(val == 0xFF) if (val == 0xFF)
return -EINVAL; return -EINVAL;
if (reg_debug) { if (reg_debug) {
...@@ -427,10 +423,9 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, ...@@ -427,10 +423,9 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf,
cx231xx_isocdbg("(pipe 0x%08x): " cx231xx_isocdbg("(pipe 0x%08x): "
"OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>", "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>",
pipe, pipe,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR |
req, 0, val, USB_RECIP_DEVICE, req, 0, val, reg & 0xff,
reg & 0xff, reg >> 8, reg >> 8, len & 0xff, len >> 8);
len & 0xff, len >> 8);
for (byte = 0; byte < len; byte++) for (byte = 0; byte < len; byte++)
cx231xx_isocdbg(" %02x", (unsigned char)buf[byte]); cx231xx_isocdbg(" %02x", (unsigned char)buf[byte]);
...@@ -447,7 +442,6 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, ...@@ -447,7 +442,6 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf,
return ret; return ret;
} }
/************************************************************************************ /************************************************************************************
* USB Alternate Setting functions * * USB Alternate Setting functions *
*************************************************************************************/ *************************************************************************************/
...@@ -465,13 +459,13 @@ int cx231xx_set_video_alternate(struct cx231xx *dev) ...@@ -465,13 +459,13 @@ int cx231xx_set_video_alternate(struct cx231xx *dev)
if (dev->width * 2 * dev->height > 720 * 240 * 2) if (dev->width * 2 * dev->height > 720 * 240 * 2)
min_pkt_size *= 2; min_pkt_size *= 2;
if(dev->width > 360) { if (dev->width > 360) {
/* resolutions: 720,704,640 */ /* resolutions: 720,704,640 */
dev->video_mode.alt = 3; dev->video_mode.alt = 3;
} else if(dev->width > 180) { } else if (dev->width > 180) {
/* resolutions: 360,352,320,240 */ /* resolutions: 360,352,320,240 */
dev->video_mode.alt = 2; dev->video_mode.alt = 2;
} else if(dev->width > 0) { } else if (dev->width > 0) {
/* resolutions: 180,176,160,128,88 */ /* resolutions: 180,176,160,128,88 */
dev->video_mode.alt = 1; dev->video_mode.alt = 1;
} else { } else {
...@@ -480,19 +474,28 @@ int cx231xx_set_video_alternate(struct cx231xx *dev) ...@@ -480,19 +474,28 @@ int cx231xx_set_video_alternate(struct cx231xx *dev)
} }
/* Get the correct video interface Index */ /* Get the correct video interface Index */
usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info.video_index+1; usb_interface_index =
dev->current_pcb_config.hs_config_info[0].interface_info.
video_index + 1;
if (dev->video_mode.alt != prev_alt) { if (dev->video_mode.alt != prev_alt) {
cx231xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", cx231xx_coredbg("minimum isoc packet size: %u (alt=%d)\n",
min_pkt_size, dev->video_mode.alt); min_pkt_size, dev->video_mode.alt);
dev->video_mode.max_pkt_size = dev->video_mode.alt_max_pkt_size[dev->video_mode.alt]; dev->video_mode.max_pkt_size =
dev->video_mode.alt_max_pkt_size[dev->video_mode.alt];
cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n",
dev->video_mode.alt, dev->video_mode.max_pkt_size); dev->video_mode.alt,
cx231xx_info(" setting alternate %d with wMaxPacketSize=%u , Interface = %d\n", dev->video_mode.max_pkt_size);
dev->video_mode.alt, dev->video_mode.max_pkt_size, usb_interface_index); cx231xx_info
errCode = usb_set_interface(dev->udev, usb_interface_index, dev->video_mode.alt); (" setting alternate %d with wMaxPacketSize=%u , Interface = %d\n",
dev->video_mode.alt, dev->video_mode.max_pkt_size,
usb_interface_index);
errCode =
usb_set_interface(dev->udev, usb_interface_index,
dev->video_mode.alt);
if (errCode < 0) { if (errCode < 0) {
cx231xx_errdev("cannot change alternate number to %d (error=%i)\n", cx231xx_errdev
("cannot change alternate number to %d (error=%i)\n",
dev->video_mode.alt, errCode); dev->video_mode.alt, errCode);
return errCode; return errCode;
} }
...@@ -506,57 +509,80 @@ int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt) ...@@ -506,57 +509,80 @@ int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt)
u32 usb_interface_index = 0; u32 usb_interface_index = 0;
u32 max_pkt_size = 0; u32 max_pkt_size = 0;
switch(index) { switch (index) {
case INDEX_TS1: case INDEX_TS1:
usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index+1; usb_interface_index =
dev->current_pcb_config.hs_config_info[0].interface_info.
ts1_index + 1;
dev->video_mode.alt = alt; dev->video_mode.alt = alt;
if(dev->ts1_mode.alt_max_pkt_size != NULL) if (dev->ts1_mode.alt_max_pkt_size != NULL)
max_pkt_size = dev->ts1_mode.max_pkt_size = dev->ts1_mode.alt_max_pkt_size[dev->ts1_mode.alt]; max_pkt_size = dev->ts1_mode.max_pkt_size =
dev->ts1_mode.alt_max_pkt_size[dev->ts1_mode.alt];
break; break;
case INDEX_TS2: case INDEX_TS2:
usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info.ts2_index+1; usb_interface_index =
dev->current_pcb_config.hs_config_info[0].interface_info.
ts2_index + 1;
break; break;
case INDEX_AUDIO: case INDEX_AUDIO:
usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info.audio_index+1; usb_interface_index =
dev->current_pcb_config.hs_config_info[0].interface_info.
audio_index + 1;
dev->adev.alt = alt; dev->adev.alt = alt;
if( dev->adev.alt_max_pkt_size != NULL) if (dev->adev.alt_max_pkt_size != NULL)
max_pkt_size = dev->adev.max_pkt_size = dev->adev.alt_max_pkt_size[dev->adev.alt]; max_pkt_size = dev->adev.max_pkt_size =
dev->adev.alt_max_pkt_size[dev->adev.alt];
break; break;
case INDEX_VIDEO: case INDEX_VIDEO:
usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info.video_index+1; usb_interface_index =
dev->current_pcb_config.hs_config_info[0].interface_info.
video_index + 1;
dev->video_mode.alt = alt; dev->video_mode.alt = alt;
if(dev->video_mode.alt_max_pkt_size != NULL) if (dev->video_mode.alt_max_pkt_size != NULL)
max_pkt_size = dev->video_mode.max_pkt_size = dev->video_mode.alt_max_pkt_size[dev->video_mode.alt]; max_pkt_size = dev->video_mode.max_pkt_size =
dev->video_mode.alt_max_pkt_size[dev->video_mode.
alt];
break; break;
case INDEX_VANC: case INDEX_VANC:
usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index+1; usb_interface_index =
dev->current_pcb_config.hs_config_info[0].interface_info.
vanc_index + 1;
dev->vbi_mode.alt = alt; dev->vbi_mode.alt = alt;
if(dev->vbi_mode.alt_max_pkt_size != NULL) if (dev->vbi_mode.alt_max_pkt_size != NULL)
max_pkt_size = dev->vbi_mode.max_pkt_size = dev->vbi_mode.alt_max_pkt_size[dev->vbi_mode.alt]; max_pkt_size = dev->vbi_mode.max_pkt_size =
dev->vbi_mode.alt_max_pkt_size[dev->vbi_mode.alt];
break; break;
case INDEX_HANC: case INDEX_HANC:
usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index+1; usb_interface_index =
dev->current_pcb_config.hs_config_info[0].interface_info.
hanc_index + 1;
dev->sliced_cc_mode.alt = alt; dev->sliced_cc_mode.alt = alt;
if(dev->sliced_cc_mode.alt_max_pkt_size != NULL) if (dev->sliced_cc_mode.alt_max_pkt_size != NULL)
max_pkt_size = dev->sliced_cc_mode.max_pkt_size = dev->sliced_cc_mode.alt_max_pkt_size[dev->sliced_cc_mode.alt]; max_pkt_size = dev->sliced_cc_mode.max_pkt_size =
dev->sliced_cc_mode.alt_max_pkt_size[dev->
sliced_cc_mode.
alt];
break; break;
default: default:
break; break;
} }
if(alt > 0 && max_pkt_size == 0 ) { if (alt > 0 && max_pkt_size == 0) {
cx231xx_errdev("cannot change interface %d alternate number to %d : Max. Pkt size is ZERO\n", cx231xx_errdev
("cannot change interface %d alternate number to %d : Max. Pkt size is ZERO\n",
usb_interface_index, alt); usb_interface_index, alt);
return -1; return -1;
} }
cx231xx_info(" setting alternate %d with wMaxPacketSize=%u , Interface = %d\n", cx231xx_info
(" setting alternate %d with wMaxPacketSize=%u , Interface = %d\n",
alt, max_pkt_size, usb_interface_index); alt, max_pkt_size, usb_interface_index);
if(usb_interface_index > 0 ) { if (usb_interface_index > 0) {
status = usb_set_interface(dev->udev, usb_interface_index, alt); status = usb_set_interface(dev->udev, usb_interface_index, alt);
if (status < 0) { if (status < 0) {
cx231xx_errdev("cannot change interface %d alternate number to %d (error=%i)\n", cx231xx_errdev
("cannot change interface %d alternate number to %d (error=%i)\n",
usb_interface_index, alt, status); usb_interface_index, alt, status);
return status; return status;
} }
...@@ -564,6 +590,7 @@ int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt) ...@@ -564,6 +590,7 @@ int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt)
return status; return status;
} }
EXPORT_SYMBOL_GPL(cx231xx_set_alt_setting); EXPORT_SYMBOL_GPL(cx231xx_set_alt_setting);
int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio) int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio)
...@@ -575,8 +602,7 @@ int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio) ...@@ -575,8 +602,7 @@ int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio)
/* Send GPIO reset sequences specified at board entry */ /* Send GPIO reset sequences specified at board entry */
while (gpio->sleep >= 0) { while (gpio->sleep >= 0) {
rc = cx231xx_set_gpio_value(dev, gpio->bit, rc = cx231xx_set_gpio_value(dev, gpio->bit, gpio->val);
gpio->val);
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -607,10 +633,11 @@ int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode) ...@@ -607,10 +633,11 @@ int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode)
if (dev->mode == CX231XX_DIGITAL_MODE) { if (dev->mode == CX231XX_DIGITAL_MODE) {
/* Set Digital power mode */ /* Set Digital power mode */
} else { } else {
/* Set Analog Power mode*/ /* Set Analog Power mode */
} }
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(cx231xx_set_mode); EXPORT_SYMBOL_GPL(cx231xx_set_mode);
/************************************************************************************ /************************************************************************************
...@@ -623,11 +650,11 @@ EXPORT_SYMBOL_GPL(cx231xx_set_mode); ...@@ -623,11 +650,11 @@ EXPORT_SYMBOL_GPL(cx231xx_set_mode);
static void cx231xx_irq_callback(struct urb *urb) static void cx231xx_irq_callback(struct urb *urb)
{ {
struct cx231xx_dmaqueue *dma_q = urb->context; struct cx231xx_dmaqueue *dma_q = urb->context;
struct cx231xx_video_mode *vmode = container_of(dma_q, struct cx231xx_video_mode, vidq); 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 *dev = container_of(vmode, struct cx231xx, video_mode);
int rc, i; int rc, i;
switch (urb->status) { switch (urb->status) {
case 0: /* success */ case 0: /* success */
case -ETIMEDOUT: /* NAK */ case -ETIMEDOUT: /* NAK */
...@@ -682,7 +709,8 @@ void cx231xx_uninit_isoc(struct cx231xx *dev) ...@@ -682,7 +709,8 @@ void cx231xx_uninit_isoc(struct cx231xx *dev)
if (dev->video_mode.isoc_ctl.transfer_buffer[i]) { if (dev->video_mode.isoc_ctl.transfer_buffer[i]) {
usb_buffer_free(dev->udev, usb_buffer_free(dev->udev,
urb->transfer_buffer_length, urb->transfer_buffer_length,
dev->video_mode.isoc_ctl.transfer_buffer[i], dev->video_mode.isoc_ctl.
transfer_buffer[i],
urb->transfer_dma); urb->transfer_dma);
} }
usb_free_urb(urb); usb_free_urb(urb);
...@@ -700,6 +728,7 @@ void cx231xx_uninit_isoc(struct cx231xx *dev) ...@@ -700,6 +728,7 @@ void cx231xx_uninit_isoc(struct cx231xx *dev)
cx231xx_capture_start(dev, 0, Raw_Video); cx231xx_capture_start(dev, 0, Raw_Video);
} }
EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc); EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc);
/* /*
...@@ -707,7 +736,7 @@ EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc); ...@@ -707,7 +736,7 @@ EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc);
*/ */
int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
int num_bufs, int max_pkt_size, int num_bufs, int max_pkt_size,
int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)) int (*isoc_copy) (struct cx231xx * dev, struct urb * urb))
{ {
struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq;
int i; int i;
...@@ -718,12 +747,11 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, ...@@ -718,12 +747,11 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
cx231xx_isocdbg("cx231xx: called cx231xx_prepare_isoc\n"); cx231xx_isocdbg("cx231xx: called cx231xx_prepare_isoc\n");
dev->video_input = dev->video_input > 2?2:dev->video_input; dev->video_input = dev->video_input > 2 ? 2 : dev->video_input;
cx231xx_info("Setting Video mux to %d\n",dev->video_input); cx231xx_info("Setting Video mux to %d\n", dev->video_input);
video_mux(dev, dev->video_input); video_mux(dev, dev->video_input);
/* De-allocates all pending stuff */ /* De-allocates all pending stuff */
cx231xx_uninit_isoc(dev); cx231xx_uninit_isoc(dev);
...@@ -734,20 +762,21 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, ...@@ -734,20 +762,21 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
dma_q->last_sav = 0; dma_q->last_sav = 0;
dma_q->current_field = -1; dma_q->current_field = -1;
dma_q->field1_done = 0; dma_q->field1_done = 0;
dma_q->lines_per_field = dev->height/2; dma_q->lines_per_field = dev->height / 2;
dma_q->bytes_left_in_line = dev->width << 1; dma_q->bytes_left_in_line = dev->width << 1;
dma_q->lines_completed = 0; dma_q->lines_completed = 0;
for(i = 0; i < 8 ; i++) for (i = 0; i < 8; i++)
dma_q->partial_buf[i] = 0; dma_q->partial_buf[i] = 0;
dev->video_mode.isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); dev->video_mode.isoc_ctl.urb =
kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
if (!dev->video_mode.isoc_ctl.urb) { if (!dev->video_mode.isoc_ctl.urb) {
cx231xx_errdev("cannot alloc memory for usb buffers\n"); cx231xx_errdev("cannot alloc memory for usb buffers\n");
return -ENOMEM; return -ENOMEM;
} }
dev->video_mode.isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, dev->video_mode.isoc_ctl.transfer_buffer =
GFP_KERNEL); kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
if (!dev->video_mode.isoc_ctl.transfer_buffer) { if (!dev->video_mode.isoc_ctl.transfer_buffer) {
cx231xx_errdev("cannot allocate memory for usbtransfer\n"); cx231xx_errdev("cannot allocate memory for usbtransfer\n");
kfree(dev->video_mode.isoc_ctl.urb); kfree(dev->video_mode.isoc_ctl.urb);
...@@ -769,23 +798,25 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, ...@@ -769,23 +798,25 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
} }
dev->video_mode.isoc_ctl.urb[i] = urb; dev->video_mode.isoc_ctl.urb[i] = urb;
dev->video_mode.isoc_ctl.transfer_buffer[i] = usb_buffer_alloc(dev->udev, dev->video_mode.isoc_ctl.transfer_buffer[i] =
sb_size, GFP_KERNEL, &urb->transfer_dma); usb_buffer_alloc(dev->udev, sb_size, GFP_KERNEL,
&urb->transfer_dma);
if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) { if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) {
cx231xx_err("unable to allocate %i bytes for transfer" cx231xx_err("unable to allocate %i bytes for transfer"
" buffer %i%s\n", " buffer %i%s\n",
sb_size, i, sb_size, i,
in_interrupt()?" while in int":""); in_interrupt()? " while in int" : "");
cx231xx_uninit_isoc(dev); cx231xx_uninit_isoc(dev);
return -ENOMEM; return -ENOMEM;
} }
memset(dev->video_mode.isoc_ctl.transfer_buffer[i], 0, sb_size); memset(dev->video_mode.isoc_ctl.transfer_buffer[i], 0, sb_size);
pipe = usb_rcvisocpipe(dev->udev, dev->video_mode.end_point_addr); pipe =
usb_rcvisocpipe(dev->udev, dev->video_mode.end_point_addr);
usb_fill_int_urb(urb, dev->udev, pipe, usb_fill_int_urb(urb, dev->udev, pipe,
dev->video_mode.isoc_ctl.transfer_buffer[i], sb_size, dev->video_mode.isoc_ctl.transfer_buffer[i],
cx231xx_irq_callback, dma_q, 1); sb_size, cx231xx_irq_callback, dma_q, 1);
urb->number_of_packets = max_packets; urb->number_of_packets = max_packets;
urb->transfer_flags = URB_ISO_ASAP; urb->transfer_flags = URB_ISO_ASAP;
...@@ -801,10 +832,10 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, ...@@ -801,10 +832,10 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
init_waitqueue_head(&dma_q->wq); init_waitqueue_head(&dma_q->wq);
/* submit urbs and enables IRQ */ /* submit urbs and enables IRQ */
for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) {
rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i], GFP_ATOMIC); rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i],
GFP_ATOMIC);
if (rc) { if (rc) {
cx231xx_err("submit of urb %i failed (error=%i)\n", i, cx231xx_err("submit of urb %i failed (error=%i)\n", i,
rc); rc);
...@@ -817,6 +848,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, ...@@ -817,6 +848,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(cx231xx_init_isoc); EXPORT_SYMBOL_GPL(cx231xx_init_isoc);
/************************************************************************************ /************************************************************************************
...@@ -858,7 +890,8 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -858,7 +890,8 @@ int cx231xx_dev_init(struct cx231xx *dev)
/* Note : with out calling set power mode function, colibri can not be set up correctly */ /* Note : with out calling set power mode function, colibri can not be set up correctly */
errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV); errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV);
if (errCode < 0) { if (errCode < 0) {
cx231xx_errdev("%s: cx231xx_set_power_mode : Failed to set Power - errCode [%d]!\n", cx231xx_errdev
("%s: cx231xx_set_power_mode : Failed to set Power - errCode [%d]!\n",
__func__, errCode); __func__, errCode);
return errCode; return errCode;
} }
...@@ -866,13 +899,15 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -866,13 +899,15 @@ int cx231xx_dev_init(struct cx231xx *dev)
/* initialize Colibri block */ /* initialize Colibri block */
errCode = cx231xx_colibri_init_super_block(dev, 0x23c); errCode = cx231xx_colibri_init_super_block(dev, 0x23c);
if (errCode < 0) { if (errCode < 0) {
cx231xx_errdev("%s: cx231xx_colibri init super block - errCode [%d]!\n", cx231xx_errdev
("%s: cx231xx_colibri init super block - errCode [%d]!\n",
__func__, errCode); __func__, errCode);
return errCode; return errCode;
} }
errCode = cx231xx_colibri_init_channels(dev); errCode = cx231xx_colibri_init_channels(dev);
if (errCode < 0) { if (errCode < 0) {
cx231xx_errdev("%s: cx231xx_colibri init channels - errCode [%d]!\n", cx231xx_errdev
("%s: cx231xx_colibri init channels - errCode [%d]!\n",
__func__, errCode); __func__, errCode);
return errCode; return errCode;
} }
...@@ -880,7 +915,8 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -880,7 +915,8 @@ int cx231xx_dev_init(struct cx231xx *dev)
/* Set DIF in By pass mode */ /* Set DIF in By pass mode */
errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND);
if (errCode < 0) { if (errCode < 0) {
cx231xx_errdev("%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", cx231xx_errdev
("%s: cx231xx_dif set to By pass mode - errCode [%d]!\n",
__func__, errCode); __func__, errCode);
return errCode; return errCode;
} }
...@@ -888,7 +924,8 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -888,7 +924,8 @@ int cx231xx_dev_init(struct cx231xx *dev)
/* flatiron related functions */ /* flatiron related functions */
errCode = cx231xx_flatiron_initialize(dev); errCode = cx231xx_flatiron_initialize(dev);
if (errCode < 0) { if (errCode < 0) {
cx231xx_errdev("%s: cx231xx_flatiron initialize - errCode [%d]!\n", cx231xx_errdev
("%s: cx231xx_flatiron initialize - errCode [%d]!\n",
__func__, errCode); __func__, errCode);
return errCode; return errCode;
} }
...@@ -904,7 +941,8 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -904,7 +941,8 @@ int cx231xx_dev_init(struct cx231xx *dev)
/* set AGC mode to Analog */ /* set AGC mode to Analog */
errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1);
if (errCode < 0) { if (errCode < 0) {
cx231xx_errdev("%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", cx231xx_errdev
("%s: cx231xx_AGC mode to Analog - errCode [%d]!\n",
__func__, errCode); __func__, errCode);
return errCode; return errCode;
} }
...@@ -913,7 +951,7 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -913,7 +951,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0); cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0);
cx231xx_set_alt_setting(dev, INDEX_VANC, 0); cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
cx231xx_set_alt_setting(dev, INDEX_HANC, 0); cx231xx_set_alt_setting(dev, INDEX_HANC, 0);
if(dev->board.has_dvb) if (dev->board.has_dvb)
cx231xx_set_alt_setting(dev, INDEX_TS1, 0); cx231xx_set_alt_setting(dev, INDEX_TS1, 0);
/* set the I2C master port to 3 on channel 1 */ /* set the I2C master port to 3 on channel 1 */
...@@ -921,6 +959,7 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -921,6 +959,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
return errCode; return errCode;
} }
EXPORT_SYMBOL_GPL(cx231xx_dev_init); EXPORT_SYMBOL_GPL(cx231xx_dev_init);
void cx231xx_dev_uninit(struct cx231xx *dev) void cx231xx_dev_uninit(struct cx231xx *dev)
...@@ -930,37 +969,36 @@ void cx231xx_dev_uninit(struct cx231xx *dev) ...@@ -930,37 +969,36 @@ void cx231xx_dev_uninit(struct cx231xx *dev)
cx231xx_i2c_unregister(&dev->i2c_bus[1]); cx231xx_i2c_unregister(&dev->i2c_bus[1]);
cx231xx_i2c_unregister(&dev->i2c_bus[0]); cx231xx_i2c_unregister(&dev->i2c_bus[0]);
} }
EXPORT_SYMBOL_GPL(cx231xx_dev_uninit);
EXPORT_SYMBOL_GPL(cx231xx_dev_uninit);
/************************************************************************************ /************************************************************************************
* G P I O related functions * * G P I O related functions *
*************************************************************************************/ *************************************************************************************/
int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val, int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val,
u8 len, u8 request, u8 direction) u8 len, u8 request, u8 direction)
{ {
int status = 0; int status = 0;
VENDOR_REQUEST_IN ven_req; VENDOR_REQUEST_IN ven_req;
/* Set wValue */ /* Set wValue */
ven_req.wValue = (u16)(gpio_bit>>16 & 0xffff); ven_req.wValue = (u16) (gpio_bit >> 16 & 0xffff);
/* set request */ /* set request */
if(!request){ if (!request) {
if(direction) if (direction)
ven_req.bRequest = VRT_GET_GPIO; /* 0x8 gpio */ ven_req.bRequest = VRT_GET_GPIO; /* 0x8 gpio */
else else
ven_req.bRequest = VRT_SET_GPIO; /* 0x9 gpio */ ven_req.bRequest = VRT_SET_GPIO; /* 0x9 gpio */
} } else {
else { if (direction)
if(direction)
ven_req.bRequest = VRT_GET_GPIE; /* 0xa gpie */ ven_req.bRequest = VRT_GET_GPIE; /* 0xa gpie */
else else
ven_req.bRequest = VRT_SET_GPIE; /* 0xb gpie */ ven_req.bRequest = VRT_SET_GPIE; /* 0xb gpie */
} }
/* set index value */ /* set index value */
ven_req.wIndex = (u16)(gpio_bit & 0xffff); ven_req.wIndex = (u16) (gpio_bit & 0xffff);
/* set wLength value */ /* set wLength value */
ven_req.wLength = len; ven_req.wLength = len;
...@@ -972,20 +1010,19 @@ int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val, ...@@ -972,20 +1010,19 @@ int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val,
ven_req.pBuff = gpio_val; ven_req.pBuff = gpio_val;
/* set the direction */ /* set the direction */
if(direction){ if (direction) {
ven_req.direction = USB_DIR_IN; ven_req.direction = USB_DIR_IN;
memset(ven_req.pBuff, 0x00, ven_req.wLength); memset(ven_req.pBuff, 0x00, ven_req.wLength);
} } else
else
ven_req.direction = USB_DIR_OUT; ven_req.direction = USB_DIR_OUT;
/* call common vendor command request */ /* call common vendor command request */
status = cx231xx_send_vendor_cmd(dev, &ven_req); status = cx231xx_send_vendor_cmd(dev, &ven_req);
if (status < 0) if (status < 0) {
{ cx231xx_info
cx231xx_info("UsbInterface::sendCommand, output buffer failed with status -%d\n", status); ("UsbInterface::sendCommand, output buffer failed with status -%d\n",
status);
} }
return status; return status;
...@@ -998,23 +1035,25 @@ EXPORT_SYMBOL_GPL(cx231xx_send_gpio_cmd); ...@@ -998,23 +1035,25 @@ EXPORT_SYMBOL_GPL(cx231xx_send_gpio_cmd);
*************************************************************************************/ *************************************************************************************/
int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode) int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode)
{ {
u8 value[4] = {0x0, 0x0, 0x0, 0x0}; u8 value[4] = { 0x0, 0x0, 0x0, 0x0 };
u32 tmp =0; u32 tmp = 0;
int status = 0; int status = 0;
status = cx231xx_read_ctrl_reg(dev,VRT_GET_REGISTER, address,value,4); status =
if(status < 0) cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, address, value, 4);
if (status < 0)
return status; return status;
tmp = *((u32 *)value); tmp = *((u32 *) value);
tmp |= mode; tmp |= mode;
value[0]=(u8) tmp; value[0] = (u8) tmp;
value[1]=(u8)(tmp>>8); value[1] = (u8) (tmp >> 8);
value[2]=(u8)(tmp>>16); value[2] = (u8) (tmp >> 16);
value[3]=(u8)(tmp>>24); value[3] = (u8) (tmp >> 24);
status = cx231xx_write_ctrl_reg(dev,VRT_SET_REGISTER, address,value,4); status =
cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, address, value, 4);
return status; return status;
} }
...@@ -1023,15 +1062,15 @@ int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode) ...@@ -1023,15 +1062,15 @@ int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode)
* I 2 C Internal C O N T R O L functions * * I 2 C Internal C O N T R O L functions *
*************************************************************************************/ *************************************************************************************/
int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr,
u8 saddr_len, u32 *data, u8 data_len) u8 saddr_len, u32 * data, u8 data_len)
{ {
int status = 0; int status = 0;
struct cx231xx_i2c_xfer_data req_data; struct cx231xx_i2c_xfer_data req_data;
u8 value[4] ={0,0,0,0}; u8 value[4] = { 0, 0, 0, 0 };
if(saddr_len == 0) if (saddr_len == 0)
saddr = 0; saddr = 0;
else if(saddr_len == 0) else if (saddr_len == 0)
saddr &= 0xff; saddr &= 0xff;
/* prepare xfer_data struct */ /* prepare xfer_data struct */
...@@ -1040,18 +1079,19 @@ int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, ...@@ -1040,18 +1079,19 @@ int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr,
req_data.saddr_len = saddr_len; req_data.saddr_len = saddr_len;
req_data.saddr_dat = saddr; req_data.saddr_dat = saddr;
req_data.buf_size = data_len; req_data.buf_size = data_len;
req_data.p_buffer = (u8*)value; req_data.p_buffer = (u8 *) value;
/* usb send command */ /* usb send command */
status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data);
if(status >= 0) if (status >= 0) {
{
/* Copy the data read back to main buffer */ /* Copy the data read back to main buffer */
if(data_len == 1) if (data_len == 1)
*data = value[0]; *data = value[0];
else else
*data = value[0] | value[1] << 8 | value[2] << 16 | value[3] << 24; *data =
value[0] | value[1] << 8 | value[2] << 16 | value[3]
<< 24;
} }
return status; return status;
...@@ -1061,17 +1101,17 @@ int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, ...@@ -1061,17 +1101,17 @@ int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr,
u8 saddr_len, u32 data, u8 data_len) u8 saddr_len, u32 data, u8 data_len)
{ {
int status = 0; int status = 0;
u8 value[4] ={0,0,0,0}; u8 value[4] = { 0, 0, 0, 0 };
struct cx231xx_i2c_xfer_data req_data; struct cx231xx_i2c_xfer_data req_data;
value[0]=(u8)data; value[0] = (u8) data;
value[1]=(u8)(data>>8); value[1] = (u8) (data >> 8);
value[2]=(u8)(data>>16); value[2] = (u8) (data >> 16);
value[3]=(u8)(data>>24); value[3] = (u8) (data >> 24);
if(saddr_len == 0) if (saddr_len == 0)
saddr = 0; saddr = 0;
else if(saddr_len == 0) else if (saddr_len == 0)
saddr &= 0xff; saddr &= 0xff;
/* prepare xfer_data struct */ /* prepare xfer_data struct */
...@@ -1088,54 +1128,58 @@ int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, ...@@ -1088,54 +1128,58 @@ int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr,
return status; return status;
} }
int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, u16 register_address, int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size,
u8 bit_start,u8 bit_end, u32 value) u16 register_address, u8 bit_start, u8 bit_end,
u32 value)
{ {
int status = 0; int status = 0;
u32 tmp; u32 tmp;
u32 mask = 0; u32 mask = 0;
int i; int i;
if (bit_start>(size-1) || bit_end>(size-1)) { if (bit_start > (size - 1) || bit_end > (size - 1)) {
return -1; return -1;
} }
if (size==8){ if (size == 8) {
status = cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, &tmp, 1); status =
cx231xx_read_i2c_data(dev, dev_addr, register_address, 2,
&tmp, 1);
} else { } else {
status = cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, &tmp, 4); status =
cx231xx_read_i2c_data(dev, dev_addr, register_address, 2,
&tmp, 4);
} }
if (status < 0) { if (status < 0) {
return status; return status;
} }
mask = 1<<bit_end; mask = 1 << bit_end;
for (i=bit_end; i>bit_start&&i>0; i--) { for (i = bit_end; i > bit_start && i > 0; i--) {
mask = mask + (1<<(i-1)); mask = mask + (1 << (i - 1));
} }
value <<= bit_start; value <<= bit_start;
if (size==8) if (size == 8) {
{
tmp &= ~mask; tmp &= ~mask;
tmp |= value; tmp |= value;
tmp &= 0xff; tmp &= 0xff;
status = cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, tmp, 1); status =
} cx231xx_write_i2c_data(dev, dev_addr, register_address, 2,
else tmp, 1);
{ } else {
tmp &= ~mask; tmp &= ~mask;
tmp |= value; tmp |= value;
status = cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, tmp, 4); status =
cx231xx_write_i2c_data(dev, dev_addr, register_address, 2,
tmp, 4);
} }
return status; return status;
} }
int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr,
u16 saddr, u32 mask, u32 value) u16 saddr, u32 mask, u32 value)
{ {
...@@ -1144,7 +1188,7 @@ int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, ...@@ -1144,7 +1188,7 @@ int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr,
status = cx231xx_read_i2c_data(dev, dev_addr, saddr, 2, &temp, 4); status = cx231xx_read_i2c_data(dev, dev_addr, saddr, 2, &temp, 4);
if(status < 0) if (status < 0)
return status; return status;
temp &= ~mask; temp &= ~mask;
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "xc5000.h" #include "xc5000.h"
#include "dvb_dummy_fe.h" #include "dvb_dummy_fe.h"
MODULE_DESCRIPTION("driver for cx231xx based DVB cards"); MODULE_DESCRIPTION("driver for cx231xx based DVB cards");
MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>"); MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -65,9 +64,7 @@ struct cx231xx_dvb { ...@@ -65,9 +64,7 @@ struct cx231xx_dvb {
struct dvb_net net; struct dvb_net net;
}; };
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"; char *errmsg = "Unknown";
...@@ -149,8 +146,8 @@ static int start_streaming(struct cx231xx_dvb *dvb) ...@@ -149,8 +146,8 @@ static int start_streaming(struct cx231xx_dvb *dvb)
return rc; return rc;
return cx231xx_init_isoc(dev, CX231XX_DVB_MAX_PACKETS, return cx231xx_init_isoc(dev, CX231XX_DVB_MAX_PACKETS,
CX231XX_DVB_NUM_BUFS, CX231XX_DVB_MAX_PACKETSIZE, CX231XX_DVB_NUM_BUFS,
dvb_isoc_copy); CX231XX_DVB_MAX_PACKETSIZE, dvb_isoc_copy);
} }
static int stop_streaming(struct cx231xx_dvb *dvb) static int stop_streaming(struct cx231xx_dvb *dvb)
...@@ -203,8 +200,6 @@ static int stop_feed(struct dvb_demux_feed *feed) ...@@ -203,8 +200,6 @@ static int stop_feed(struct dvb_demux_feed *feed)
return err; return err;
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int cx231xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) static int cx231xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire)
{ {
...@@ -218,13 +213,11 @@ static int cx231xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) ...@@ -218,13 +213,11 @@ static int cx231xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static struct xc5000_config cnxt_rde250_tunerconfig = { static struct xc5000_config cnxt_rde250_tunerconfig = {
.i2c_address = 0x61, .i2c_address = 0x61,
.if_khz = 5380, .if_khz = 5380,
}; };
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
#if 0 #if 0
static int attach_xc5000(u8 addr, struct cx231xx *dev) static int attach_xc5000(u8 addr, struct cx231xx *dev)
...@@ -239,8 +232,7 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev) ...@@ -239,8 +232,7 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
if (!dev->dvb->frontend) { if (!dev->dvb->frontend) {
printk(KERN_ERR "%s/2: dvb frontend not attached. " printk(KERN_ERR "%s/2: dvb frontend not attached. "
"Can't attach xc5000\n", "Can't attach xc5000\n", dev->name);
dev->name);
return -EINVAL; return -EINVAL;
} }
...@@ -258,20 +250,20 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev) ...@@ -258,20 +250,20 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
} }
#endif #endif
int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq ) int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq)
{ {
int status = 0; int status = 0;
if( (dev->dvb != NULL) && (dev->dvb->frontend != NULL) ){ if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) {
struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops;
if(dops->set_analog_params != NULL) { if (dops->set_analog_params != NULL) {
struct analog_parameters params; struct analog_parameters params;
params.frequency = freq; params.frequency = freq;
params.std = dev->norm; params.std = dev->norm;
params.mode = 0 ; /* 0- Air; 1 - cable */ params.mode = 0; /* 0- Air; 1 - cable */
/*params.audmode = ; */ /*params.audmode = ; */
/* Set the analog parameters to set the frequency */ /* Set the analog parameters to set the frequency */
...@@ -288,20 +280,22 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev) ...@@ -288,20 +280,22 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev)
{ {
int status = 0; int status = 0;
if( (dev->dvb != NULL) && (dev->dvb->frontend != NULL) ){ if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) {
struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops;
if(dops->init != NULL && !dev->xc_fw_load_done) { if (dops->init != NULL && !dev->xc_fw_load_done) {
cx231xx_info("Reloading firmware for XC5000\n"); cx231xx_info("Reloading firmware for XC5000\n");
status = dops->init(dev->dvb->frontend); status = dops->init(dev->dvb->frontend);
if(status == 0 ) { if (status == 0) {
dev->xc_fw_load_done = 1; dev->xc_fw_load_done = 1;
cx231xx_info("XC5000 firmware download completed\n"); cx231xx_info
("XC5000 firmware download completed\n");
} else { } else {
dev->xc_fw_load_done = 0; dev->xc_fw_load_done = 0;
cx231xx_info("XC5000 firmware download failed !!!\n"); cx231xx_info
("XC5000 firmware download failed !!!\n");
} }
} }
...@@ -310,13 +304,11 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev) ...@@ -310,13 +304,11 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev)
return status; return status;
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int register_dvb(struct cx231xx_dvb *dvb, static int register_dvb(struct cx231xx_dvb *dvb,
struct module *module, struct module *module,
struct cx231xx *dev, struct cx231xx *dev, struct device *device)
struct device *device)
{ {
int result; int result;
...@@ -326,7 +318,8 @@ static int register_dvb(struct cx231xx_dvb *dvb, ...@@ -326,7 +318,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, result = dvb_register_adapter(&dvb->adapter, dev->name, module, device,
adapter_nr); adapter_nr);
if (result < 0) { if (result < 0) {
printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", printk(KERN_WARNING
"%s: dvb_register_adapter failed (errno = %d)\n",
dev->name, result); dev->name, result);
goto fail_adapter; goto fail_adapter;
} }
...@@ -339,7 +332,8 @@ static int register_dvb(struct cx231xx_dvb *dvb, ...@@ -339,7 +332,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
/* register frontend */ /* register frontend */
result = dvb_register_frontend(&dvb->adapter, dvb->frontend); result = dvb_register_frontend(&dvb->adapter, dvb->frontend);
if (result < 0) { if (result < 0) {
printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", printk(KERN_WARNING
"%s: dvb_register_frontend failed (errno = %d)\n",
dev->name, result); dev->name, result);
goto fail_frontend; goto fail_frontend;
} }
...@@ -374,7 +368,8 @@ static int register_dvb(struct cx231xx_dvb *dvb, ...@@ -374,7 +368,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
dvb->fe_hw.source = DMX_FRONTEND_0; dvb->fe_hw.source = DMX_FRONTEND_0;
result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw);
if (result < 0) { if (result < 0) {
printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", printk(KERN_WARNING
"%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
dev->name, result); dev->name, result);
goto fail_fe_hw; goto fail_fe_hw;
} }
...@@ -382,15 +377,17 @@ static int register_dvb(struct cx231xx_dvb *dvb, ...@@ -382,15 +377,17 @@ static int register_dvb(struct cx231xx_dvb *dvb,
dvb->fe_mem.source = DMX_MEMORY_FE; dvb->fe_mem.source = DMX_MEMORY_FE;
result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem);
if (result < 0) { if (result < 0) {
printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", printk(KERN_WARNING
"%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
dev->name, result); dev->name, result);
goto fail_fe_mem; goto fail_fe_mem;
} }
result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw);
if (result < 0) { if (result < 0) {
printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", printk(KERN_WARNING
dev->name, result); "%s: connect_frontend failed (errno = %d)\n", dev->name,
result);
goto fail_fe_conn; goto fail_fe_conn;
} }
...@@ -398,20 +395,20 @@ static int register_dvb(struct cx231xx_dvb *dvb, ...@@ -398,20 +395,20 @@ static int register_dvb(struct cx231xx_dvb *dvb,
dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
return 0; return 0;
fail_fe_conn: fail_fe_conn:
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
fail_fe_mem: fail_fe_mem:
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
fail_fe_hw: fail_fe_hw:
dvb_dmxdev_release(&dvb->dmxdev); dvb_dmxdev_release(&dvb->dmxdev);
fail_dmxdev: fail_dmxdev:
dvb_dmx_release(&dvb->demux); dvb_dmx_release(&dvb->demux);
fail_dmx: fail_dmx:
dvb_unregister_frontend(dvb->frontend); dvb_unregister_frontend(dvb->frontend);
fail_frontend: fail_frontend:
dvb_frontend_detach(dvb->frontend); dvb_frontend_detach(dvb->frontend);
dvb_unregister_adapter(&dvb->adapter); dvb_unregister_adapter(&dvb->adapter);
fail_adapter: fail_adapter:
return result; return result;
} }
...@@ -427,7 +424,6 @@ static void unregister_dvb(struct cx231xx_dvb *dvb) ...@@ -427,7 +424,6 @@ static void unregister_dvb(struct cx231xx_dvb *dvb)
dvb_unregister_adapter(&dvb->adapter); dvb_unregister_adapter(&dvb->adapter);
} }
static int dvb_init(struct cx231xx *dev) static int dvb_init(struct cx231xx *dev)
{ {
int result = 0; int result = 0;
...@@ -455,11 +451,12 @@ static int dvb_init(struct cx231xx *dev) ...@@ -455,11 +451,12 @@ static int dvb_init(struct cx231xx *dev)
/* dev->dvb->frontend = dvb_attach(s5h1411_attach, /* dev->dvb->frontend = dvb_attach(s5h1411_attach,
&dvico_s5h1411_config, &dvico_s5h1411_config,
&dev->i2c_bus[1].i2c_adap);*/ &dev->i2c_bus[1].i2c_adap); */
dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach); dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach);
if(dev->dvb->frontend == NULL) { if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME ": Failed to attach dummy front end\n"); printk(DRIVER_NAME
": Failed to attach dummy front end\n");
result = -EINVAL; result = -EINVAL;
goto out_free; goto out_free;
} }
...@@ -467,7 +464,7 @@ static int dvb_init(struct cx231xx *dev) ...@@ -467,7 +464,7 @@ static int dvb_init(struct cx231xx *dev)
/* define general-purpose callback pointer */ /* define general-purpose callback pointer */
dvb->frontend->callback = cx231xx_tuner_callback; dvb->frontend->callback = cx231xx_tuner_callback;
if(dvb_attach(xc5000_attach, dev->dvb->frontend, if (dvb_attach(xc5000_attach, dev->dvb->frontend,
&dev->i2c_bus[1].i2c_adap, &dev->i2c_bus[1].i2c_adap,
&cnxt_rde250_tunerconfig) < 0) { &cnxt_rde250_tunerconfig) < 0) {
result = -EINVAL; result = -EINVAL;
...@@ -479,8 +476,9 @@ static int dvb_init(struct cx231xx *dev) ...@@ -479,8 +476,9 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach); dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach);
if(dev->dvb->frontend == NULL) { if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME ": Failed to attach dummy front end\n"); printk(DRIVER_NAME
": Failed to attach dummy front end\n");
result = -EINVAL; result = -EINVAL;
goto out_free; goto out_free;
} }
...@@ -488,7 +486,7 @@ static int dvb_init(struct cx231xx *dev) ...@@ -488,7 +486,7 @@ static int dvb_init(struct cx231xx *dev)
/* define general-purpose callback pointer */ /* define general-purpose callback pointer */
dvb->frontend->callback = cx231xx_tuner_callback; dvb->frontend->callback = cx231xx_tuner_callback;
if(dvb_attach(xc5000_attach, dev->dvb->frontend, if (dvb_attach(xc5000_attach, dev->dvb->frontend,
&dev->i2c_bus[1].i2c_adap, &dev->i2c_bus[1].i2c_adap,
&cnxt_rde250_tunerconfig) < 0) { &cnxt_rde250_tunerconfig) < 0) {
result = -EINVAL; result = -EINVAL;
...@@ -498,19 +496,16 @@ static int dvb_init(struct cx231xx *dev) ...@@ -498,19 +496,16 @@ static int dvb_init(struct cx231xx *dev)
default: default:
printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card"
" isn't supported yet\n", " isn't supported yet\n", dev->name);
dev->name);
break; break;
} }
if (NULL == dvb->frontend) { if (NULL == dvb->frontend) {
printk(KERN_ERR printk(KERN_ERR
"%s/2: frontend initialization failed\n", "%s/2: frontend initialization failed\n", dev->name);
dev->name);
result = -EINVAL; result = -EINVAL;
goto out_free; goto out_free;
} }
/* register everything */ /* register everything */
result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev);
...@@ -521,7 +516,7 @@ static int dvb_init(struct cx231xx *dev) ...@@ -521,7 +516,7 @@ static int dvb_init(struct cx231xx *dev)
printk(KERN_INFO "Successfully loaded cx231xx-dvb\n"); printk(KERN_INFO "Successfully loaded cx231xx-dvb\n");
return 0; return 0;
out_free: out_free:
cx231xx_set_mode(dev, CX231XX_SUSPEND); cx231xx_set_mode(dev, CX231XX_SUSPEND);
kfree(dvb); kfree(dvb);
dev->dvb = NULL; dev->dvb = NULL;
...@@ -562,4 +557,3 @@ static void __exit cx231xx_dvb_unregister(void) ...@@ -562,4 +557,3 @@ static void __exit cx231xx_dvb_unregister(void)
module_init(cx231xx_dvb_register); module_init(cx231xx_dvb_register);
module_exit(cx231xx_dvb_unregister); module_exit(cx231xx_dvb_unregister);
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "cx231xx.h" #include "cx231xx.h"
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
static unsigned int i2c_scan; static unsigned int i2c_scan;
...@@ -40,7 +39,6 @@ static unsigned int i2c_debug; ...@@ -40,7 +39,6 @@ static unsigned int i2c_debug;
module_param(i2c_debug, int, 0644); module_param(i2c_debug, int, 0644);
MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
#define dprintk1(lvl, fmt, args...) \ #define dprintk1(lvl, fmt, args...) \
do { \ do { \
if (i2c_debug >= lvl) { \ if (i2c_debug >= lvl) { \
...@@ -56,7 +54,6 @@ do { \ ...@@ -56,7 +54,6 @@ do { \
} \ } \
} while (0) } while (0)
/* /*
* cx231xx_i2c_send_bytes() * cx231xx_i2c_send_bytes()
*/ */
...@@ -74,25 +71,25 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, ...@@ -74,25 +71,25 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap,
u16 saddr = 0; u16 saddr = 0;
u8 need_gpio = 0; u8 need_gpio = 0;
if ((bus->nr == 1) && (msg->addr == 0x61)
if( (bus->nr ==1) && (msg->addr == 0x61) && (dev->tuner_type == TUNER_XC5000) ) { && (dev->tuner_type == TUNER_XC5000)) {
size = msg->len; size = msg->len;
if( size == 2 ) { /* register write sub addr*/ if (size == 2) { /* register write sub addr */
/* Just writing sub address will cause problem to XC5000 /* Just writing sub address will cause problem to XC5000
So ignore the request */ So ignore the request */
return 0; return 0;
} else if( size == 4 ) { /* register write with sub addr*/ } else if (size == 4) { /* register write with sub addr */
if(msg->len >= 2 ) if (msg->len >= 2)
saddr = msg->buf[0] << 8 | msg->buf[1]; saddr = msg->buf[0] << 8 | msg->buf[1];
else if ( msg->len == 1 ) else if (msg->len == 1)
saddr = msg->buf[0]; saddr = msg->buf[0];
switch(saddr) { switch (saddr) {
case 0x0000: /* start tuner calibration mode */ case 0x0000: /* start tuner calibration mode */
need_gpio = 1; need_gpio = 1;
dev->xc_fw_load_done = 1; /* FW Loading is done */ dev->xc_fw_load_done = 1; /* FW Loading is done */
...@@ -104,16 +101,20 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, ...@@ -104,16 +101,20 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap,
need_gpio = 1; need_gpio = 1;
break; break;
default: default:
if(dev->xc_fw_load_done) if (dev->xc_fw_load_done)
need_gpio = 1; need_gpio = 1;
break; break;
} }
if(need_gpio ) { if (need_gpio) {
dprintk1(1, " GPIO W R I T E : addr 0x%x, len %d, saddr 0x%x\n", dprintk1(1,
" GPIO W R I T E : addr 0x%x, len %d, saddr 0x%x\n",
msg->addr, msg->len, saddr); msg->addr, msg->len, saddr);
return dev->cx231xx_gpio_i2c_write(dev, msg->addr, msg->buf, msg->len); return dev->cx231xx_gpio_i2c_write(dev,
msg->addr,
msg->buf,
msg->len);
} }
} }
...@@ -123,7 +124,7 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, ...@@ -123,7 +124,7 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap,
/* adjust the length to correct length */ /* adjust the length to correct length */
size -= saddr_len; size -= saddr_len;
buf_ptr = (u8*) (msg->buf + 1 ); buf_ptr = (u8 *) (msg->buf + 1);
do { do {
/* prepare xfer_data struct */ /* prepare xfer_data struct */
...@@ -131,22 +132,22 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, ...@@ -131,22 +132,22 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap,
req_data.direction = msg->flags; req_data.direction = msg->flags;
req_data.saddr_len = saddr_len; req_data.saddr_len = saddr_len;
req_data.saddr_dat = msg->buf[0]; req_data.saddr_dat = msg->buf[0];
req_data.buf_size = size > 16 ? 16: size; req_data.buf_size = size > 16 ? 16 : size;
req_data.p_buffer = (u8*)(buf_ptr + loop * 16); req_data.p_buffer = (u8 *) (buf_ptr + loop * 16);
bus->i2c_nostop = (size > 16) ? 1: 0; bus->i2c_nostop = (size > 16) ? 1 : 0;
bus->i2c_reserve = (loop == 0) ? 0: 1; bus->i2c_reserve = (loop == 0) ? 0 : 1;
/* usb send command */ /* usb send command */
status = dev->cx231xx_send_usb_command(bus, &req_data); status = dev->cx231xx_send_usb_command(bus, &req_data);
loop++; loop++;
if( size >= 16 ) if (size >= 16)
size -= 16; size -= 16;
else else
size = 0; size = 0;
}while( size > 0 ); } while (size > 0);
bus->i2c_nostop = 0; bus->i2c_nostop = 0;
bus->i2c_reserve = 0; bus->i2c_reserve = 0;
...@@ -165,7 +166,7 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, ...@@ -165,7 +166,7 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap,
status = dev->cx231xx_send_usb_command(bus, &req_data); status = dev->cx231xx_send_usb_command(bus, &req_data);
} }
return status < 0 ? status: 0; return status < 0 ? status : 0;
} }
/* /*
...@@ -182,21 +183,23 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap, ...@@ -182,21 +183,23 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap,
u16 saddr = 0; u16 saddr = 0;
u8 need_gpio = 0; u8 need_gpio = 0;
if((bus->nr ==1) && (msg->addr == 0x61) && dev->tuner_type == TUNER_XC5000) { if ((bus->nr == 1) && (msg->addr == 0x61)
&& dev->tuner_type == TUNER_XC5000) {
if(msg->len == 2 ) if (msg->len == 2)
saddr = msg->buf[0] << 8 | msg->buf[1]; saddr = msg->buf[0] << 8 | msg->buf[1];
else if ( msg->len == 1 ) else if (msg->len == 1)
saddr = msg->buf[0]; saddr = msg->buf[0];
if( dev->xc_fw_load_done) { if (dev->xc_fw_load_done) {
switch(saddr) { switch (saddr) {
case 0x0009: /* BUSY check */ case 0x0009: /* BUSY check */
dprintk1(1, " GPIO R E A D : Special case BUSY check \n"); dprintk1(1,
" GPIO R E A D : Special case BUSY check \n");
/* Try to read BUSY register, just set it to zero */ /* Try to read BUSY register, just set it to zero */
msg->buf[0] = 0; msg->buf[0] = 0;
if(msg->len == 2 ) if (msg->len == 2)
msg->buf[1] = 0; msg->buf[1] = 0;
return 0; return 0;
case 0x0004: /* read Lock status */ case 0x0004: /* read Lock status */
...@@ -205,13 +208,21 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap, ...@@ -205,13 +208,21 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap,
} }
if(need_gpio) { if (need_gpio) {
/* this is a special case to handle Xceive tuner clock stretch issue /* this is a special case to handle Xceive tuner clock stretch issue
with gpio based I2C interface */ with gpio based I2C interface */
dprintk1(1, " GPIO R E A D : addr 0x%x, len %d, saddr 0x%x\n", dprintk1(1,
msg->addr, msg->len, msg->buf[0] << 8| msg->buf[1]); " GPIO R E A D : addr 0x%x, len %d, saddr 0x%x\n",
status = dev->cx231xx_gpio_i2c_write(dev, msg->addr, msg->buf, msg->len); msg->addr, msg->len,
status = dev->cx231xx_gpio_i2c_read(dev, msg->addr, msg->buf, msg->len); msg->buf[0] << 8 | msg->buf[1]);
status =
dev->cx231xx_gpio_i2c_write(dev, msg->addr,
msg->buf,
msg->len);
status =
dev->cx231xx_gpio_i2c_read(dev, msg->addr,
msg->buf,
msg->len);
return status; return status;
} }
} }
...@@ -241,7 +252,7 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap, ...@@ -241,7 +252,7 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap,
status = dev->cx231xx_send_usb_command(bus, &req_data); status = dev->cx231xx_send_usb_command(bus, &req_data);
} }
return status < 0 ? status: 0; return status < 0 ? status : 0;
} }
/* /*
...@@ -249,7 +260,8 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap, ...@@ -249,7 +260,8 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap,
* read a byte from the i2c device * read a byte from the i2c device
*/ */
static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap, static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap,
const struct i2c_msg *msg1, const struct i2c_msg *msg2) const struct i2c_msg *msg1,
const struct i2c_msg *msg2)
{ {
struct cx231xx_i2c *bus = i2c_adap->algo_data; struct cx231xx_i2c *bus = i2c_adap->algo_data;
struct cx231xx *dev = bus->dev; struct cx231xx *dev = bus->dev;
...@@ -258,19 +270,21 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap, ...@@ -258,19 +270,21 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap,
u16 saddr = 0; u16 saddr = 0;
u8 need_gpio = 0; u8 need_gpio = 0;
if(msg1->len == 2 ) if (msg1->len == 2)
saddr = msg1->buf[0] << 8 | msg1->buf[1]; saddr = msg1->buf[0] << 8 | msg1->buf[1];
else if ( msg1->len == 1 ) else if (msg1->len == 1)
saddr = msg1->buf[0]; saddr = msg1->buf[0];
if ( (bus->nr ==1) && (msg2->addr == 0x61) && dev->tuner_type == TUNER_XC5000) { if ((bus->nr == 1) && (msg2->addr == 0x61)
&& dev->tuner_type == TUNER_XC5000) {
if( (msg2->len < 16) ) { if ((msg2->len < 16)) {
dprintk1(1, " i2c_read : addr 0x%x, len %d, subaddr 0x%x, leng %d\n", dprintk1(1,
" i2c_read : addr 0x%x, len %d, subaddr 0x%x, leng %d\n",
msg2->addr, msg2->len, saddr, msg1->len); msg2->addr, msg2->len, saddr, msg1->len);
switch(saddr) { switch (saddr) {
case 0x0008: /* read FW load status */ case 0x0008: /* read FW load status */
need_gpio = 1; need_gpio = 1;
break; break;
...@@ -279,9 +293,15 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap, ...@@ -279,9 +293,15 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap,
break; break;
} }
if(need_gpio ) { if (need_gpio) {
status = dev->cx231xx_gpio_i2c_write(dev, msg1->addr, msg1->buf, msg1->len); status =
status = dev->cx231xx_gpio_i2c_read(dev, msg2->addr, msg2->buf, msg2->len); dev->cx231xx_gpio_i2c_write(dev, msg1->addr,
msg1->buf,
msg1->len);
status =
dev->cx231xx_gpio_i2c_read(dev, msg2->addr,
msg2->buf,
msg2->len);
return status; return status;
} }
} }
...@@ -298,7 +318,7 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap, ...@@ -298,7 +318,7 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap,
/* usb send command */ /* usb send command */
status = dev->cx231xx_send_usb_command(bus, &req_data); status = dev->cx231xx_send_usb_command(bus, &req_data);
return status < 0 ? status: 0; return status < 0 ? status : 0;
} }
/* /*
...@@ -324,7 +344,7 @@ static int cx231xx_i2c_check_for_device(struct i2c_adapter *i2c_adap, ...@@ -324,7 +344,7 @@ static int cx231xx_i2c_check_for_device(struct i2c_adapter *i2c_adap,
/* usb send command */ /* usb send command */
status = dev->cx231xx_send_usb_command(bus, &req_data); status = dev->cx231xx_send_usb_command(bus, &req_data);
return status < 0 ? status: 0; return status < 0 ? status : 0;
} }
/* /*
...@@ -363,9 +383,12 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -363,9 +383,12 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap,
printk(" %02x", msgs[i].buf[byte]); printk(" %02x", msgs[i].buf[byte]);
} }
} else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && } else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) &&
msgs[i].addr == msgs[i + 1].addr && (msgs[i].len <= 2) && (bus->nr < 2)) { msgs[i].addr == msgs[i + 1].addr
&& (msgs[i].len <= 2) && (bus->nr < 2)) {
/* read bytes */ /* read bytes */
rc = cx231xx_i2c_recv_bytes_with_saddr(i2c_adap, &msgs[i], &msgs[i+1]); rc = cx231xx_i2c_recv_bytes_with_saddr(i2c_adap,
&msgs[i],
&msgs[i + 1]);
if (i2c_debug >= 2) { if (i2c_debug >= 2) {
for (byte = 0; byte < msgs[i].len; byte++) for (byte = 0; byte < msgs[i].len; byte++)
printk(" %02x", msgs[i].buf[byte]); printk(" %02x", msgs[i].buf[byte]);
...@@ -377,7 +400,7 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -377,7 +400,7 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap,
for (byte = 0; byte < msgs[i].len; byte++) for (byte = 0; byte < msgs[i].len; byte++)
printk(" %02x", msgs[i].buf[byte]); printk(" %02x", msgs[i].buf[byte]);
} }
rc = cx231xx_i2c_send_bytes(i2c_adap,&msgs[i]); rc = cx231xx_i2c_send_bytes(i2c_adap, &msgs[i]);
} }
if (rc < 0) if (rc < 0)
goto err; goto err;
...@@ -386,7 +409,7 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -386,7 +409,7 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap,
} }
return num; return num;
err: err:
dprintk2(2, " ERROR: %i\n", rc); dprintk2(2, " ERROR: %i\n", rc);
return rc; return rc;
} }
...@@ -454,7 +477,6 @@ static int detach_inform(struct i2c_client *client) ...@@ -454,7 +477,6 @@ static int detach_inform(struct i2c_client *client)
return 0; return 0;
} }
static struct i2c_algorithm cx231xx_algo = { static struct i2c_algorithm cx231xx_algo = {
.master_xfer = cx231xx_i2c_xfer, .master_xfer = cx231xx_i2c_xfer,
.functionality = functionality, .functionality = functionality,
...@@ -507,7 +529,8 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c) ...@@ -507,7 +529,8 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c)
if (rc < 0) if (rc < 0)
continue; continue;
cx231xx_info("%s: i2c scan: found device @ 0x%x [%s]\n", cx231xx_info("%s: i2c scan: found device @ 0x%x [%s]\n",
dev->name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); dev->name, i << 1,
i2c_devs[i] ? i2c_devs[i] : "???");
} }
cx231xx_info(": Completed Checking for I2C devices.\n"); cx231xx_info(": Completed Checking for I2C devices.\n");
} }
...@@ -516,7 +539,8 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c) ...@@ -516,7 +539,8 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c)
* cx231xx_i2c_call_clients() * cx231xx_i2c_call_clients()
* send commands to all attached i2c devices * send commands to all attached i2c devices
*/ */
void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd, void *arg) void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd,
void *arg)
{ {
/* struct cx231xx *dev = bus->dev; */ /* struct cx231xx *dev = bus->dev; */
...@@ -536,17 +560,14 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus) ...@@ -536,17 +560,14 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
cx231xx_info("%s(bus = %d)\n", __func__, bus->nr); cx231xx_info("%s(bus = %d)\n", __func__, bus->nr);
memcpy(&bus->i2c_adap, &cx231xx_adap_template, memcpy(&bus->i2c_adap, &cx231xx_adap_template, sizeof(bus->i2c_adap));
sizeof(bus->i2c_adap)); memcpy(&bus->i2c_algo, &cx231xx_algo, sizeof(bus->i2c_algo));
memcpy(&bus->i2c_algo, &cx231xx_algo,
sizeof(bus->i2c_algo));
memcpy(&bus->i2c_client, &cx231xx_client_template, memcpy(&bus->i2c_client, &cx231xx_client_template,
sizeof(bus->i2c_client)); sizeof(bus->i2c_client));
bus->i2c_adap.dev.parent = &dev->udev->dev; bus->i2c_adap.dev.parent = &dev->udev->dev;
strlcpy(bus->i2c_adap.name, bus->dev->name, strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name));
sizeof(bus->i2c_adap.name));
bus->i2c_algo.data = bus; bus->i2c_algo.data = bus;
bus->i2c_adap.algo_data = bus; bus->i2c_adap.algo_data = bus;
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "cx231xx.h" #include "cx231xx.h"
static unsigned int ir_debug; static unsigned int ir_debug;
module_param(ir_debug, int, 0644); module_param(ir_debug, int, 0644);
MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
...@@ -71,11 +70,9 @@ struct cx231xx_IR { ...@@ -71,11 +70,9 @@ struct cx231xx_IR {
unsigned int last_readcount; unsigned int last_readcount;
unsigned int repeat_interval; unsigned int repeat_interval;
int (*get_key)(struct cx231xx_IR *, struct cx231xx_ir_poll_result *); int (*get_key) (struct cx231xx_IR *, struct cx231xx_ir_poll_result *);
}; };
/********************************************************** /**********************************************************
Polling code for cx231xx Polling code for cx231xx
**********************************************************/ **********************************************************/
...@@ -196,8 +193,7 @@ int cx231xx_ir_init(struct cx231xx *dev) ...@@ -196,8 +193,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
ir->polling = 100; /* ms */ ir->polling = 100; /* ms */
/* init input device */ /* init input device */
snprintf(ir->name, sizeof(ir->name), "cx231xx IR (%s)", snprintf(ir->name, sizeof(ir->name), "cx231xx IR (%s)", dev->name);
dev->name);
usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
strlcat(ir->phys, "/input0", sizeof(ir->phys)); strlcat(ir->phys, "/input0", sizeof(ir->phys));
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
/*****************************************************************************/ /*****************************************************************************/
#define HOST_REG2 0x001 #define HOST_REG2 0x001
/*****************************************************************************/ /*****************************************************************************/
#define HOST_REG3 0x002 #define HOST_REG3 0x002
...@@ -231,7 +230,6 @@ ...@@ -231,7 +230,6 @@
/* Reserved [3:1] */ /* Reserved [3:1] */
#define FLD_CIR_TEST_DIS 0x00000001 #define FLD_CIR_TEST_DIS 0x00000001
/*****************************************************************************/ /*****************************************************************************/
#define TEST_CTRL2 0x148 #define TEST_CTRL2 0x148
#define FLD_TSXCLK_POL_CTL 0x80000000 #define FLD_TSXCLK_POL_CTL 0x80000000
...@@ -257,7 +255,6 @@ ...@@ -257,7 +255,6 @@
#define FLD_FLTRN_BIST_TST_DONE 0x00000008 #define FLD_FLTRN_BIST_TST_DONE 0x00000008
#define FLD_VID_BIST_TST_DONE 0x00000007 #define FLD_VID_BIST_TST_DONE 0x00000007
/*****************************************************************************/ /*****************************************************************************/
/* DirectIF registers definition have been moved to DIF_reg.h */ /* DirectIF registers definition have been moved to DIF_reg.h */
/*****************************************************************************/ /*****************************************************************************/
...@@ -662,7 +659,6 @@ ...@@ -662,7 +659,6 @@
#define FLD_PLL_KI 0x00FF0000 #define FLD_PLL_KI 0x00FF0000
#define FLD_PLL_MAX_OFFSET 0x0000FFFF #define FLD_PLL_MAX_OFFSET 0x0000FFFF
/*****************************************************************************/ /*****************************************************************************/
#define HTL_CTRL 0x498 #define HTL_CTRL 0x498
/* Reserved [31:24] */ /* Reserved [31:24] */
...@@ -771,7 +767,6 @@ ...@@ -771,7 +767,6 @@
#define FLD_FIELD_PHASE_LIMIT 0x000000F0 #define FLD_FIELD_PHASE_LIMIT 0x000000F0
#define FLD_HEAD_SW_DET_LIMIT 0x0000000F #define FLD_HEAD_SW_DET_LIMIT 0x0000000F
/*****************************************************************************/ /*****************************************************************************/
#define DL_CTL 0x800 #define DL_CTL 0x800
#define DL_CTL_ADDRESS_LOW 0x800 /* Byte 1 in DL_CTL */ #define DL_CTL_ADDRESS_LOW 0x800 /* Byte 1 in DL_CTL */
...@@ -1424,7 +1419,6 @@ ...@@ -1424,7 +1419,6 @@
#define FLD_I2S_OUT_WS_SEL 0x00000020 #define FLD_I2S_OUT_WS_SEL 0x00000020
#define FLD_I2S_OUT_BCN_DEL 0x0000001F #define FLD_I2S_OUT_BCN_DEL 0x0000001F
/*****************************************************************************/ /*****************************************************************************/
#define AC97_CTL 0x91C #define AC97_CTL 0x91C
/* Reserved [31:26] */ /* Reserved [31:26] */
...@@ -1437,7 +1431,6 @@ ...@@ -1437,7 +1431,6 @@
/* Reserved [7:1] */ /* Reserved [7:1] */
#define FLD_AC97_SHUTDOWN 0x00000001 #define FLD_AC97_SHUTDOWN 0x00000001
/* Cx231xx redefine */ /* Cx231xx redefine */
#define QPSK_IAGC_CTL1 0x94c #define QPSK_IAGC_CTL1 0x94c
#define QPSK_IAGC_CTL2 0x950 #define QPSK_IAGC_CTL2 0x950
...@@ -1450,7 +1443,6 @@ ...@@ -1450,7 +1443,6 @@
#define QPSK_EQ_CTL 0x96c #define QPSK_EQ_CTL 0x96c
#define QPSK_LOCK_CTL 0x970 #define QPSK_LOCK_CTL 0x970
/*****************************************************************************/ /*****************************************************************************/
#define FM1_DFT_CTL 0x9A8 #define FM1_DFT_CTL 0x9A8
#define FLD_FM1_DFT_THRESHOLD 0xFFFF0000 #define FLD_FM1_DFT_THRESHOLD 0xFFFF0000
...@@ -1494,8 +1486,6 @@ ...@@ -1494,8 +1486,6 @@
/* Reserved [15:6] */ /* Reserved [15:6] */
#define FLD_AFE_VGA_OUT 0x0000003F #define FLD_AFE_VGA_OUT 0x0000003F
/*****************************************************************************/ /*****************************************************************************/
#define MTS_GAIN_STATUS 0x9BC #define MTS_GAIN_STATUS 0x9BC
/* Reserved [31:14] */ /* Reserved [31:14] */
...@@ -1543,7 +1533,6 @@ ...@@ -1543,7 +1533,6 @@
#define INPUT_MODE_YC2_2 2 /* INPUT_MODE_VALUE(2) */ #define INPUT_MODE_YC2_2 2 /* INPUT_MODE_VALUE(2) */
#define INPUT_MODE_YUV_3 3 /* INPUT_MODE_VALUE(3) */ #define INPUT_MODE_YUV_3 3 /* INPUT_MODE_VALUE(3) */
#define LUMA_LPF_LOW_BANDPASS 0 /* 0.6Mhz lowpass filter bandwidth */ #define LUMA_LPF_LOW_BANDPASS 0 /* 0.6Mhz lowpass filter bandwidth */
#define LUMA_LPF_MEDIUM_BANDPASS 1 /* 1.0Mhz lowpass filter bandwidth */ #define LUMA_LPF_MEDIUM_BANDPASS 1 /* 1.0Mhz lowpass filter bandwidth */
#define LUMA_LPF_HIGH_BANDPASS 2 /* 1.5Mhz lowpass filter bandwidth */ #define LUMA_LPF_HIGH_BANDPASS 2 /* 1.5Mhz lowpass filter bandwidth */
......
...@@ -39,8 +39,7 @@ ...@@ -39,8 +39,7 @@
#include "cx231xx.h" #include "cx231xx.h"
#include "cx231xx-vbi.h" #include "cx231xx-vbi.h"
static inline void print_err_status(struct cx231xx *dev, static inline void print_err_status(struct cx231xx *dev, int packet, int status)
int packet, int status)
{ {
char *errmsg = "Unknown"; char *errmsg = "Unknown";
...@@ -71,7 +70,8 @@ static inline void print_err_status(struct cx231xx *dev, ...@@ -71,7 +70,8 @@ static inline void print_err_status(struct cx231xx *dev,
break; break;
} }
if (packet < 0) { 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 { } else {
cx231xx_err(DRIVER_NAME "URB packet %d, status %d [%s].\n", cx231xx_err(DRIVER_NAME "URB packet %d, status %d [%s].\n",
packet, status, errmsg); packet, status, errmsg);
...@@ -112,20 +112,22 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) ...@@ -112,20 +112,22 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb)
bytes_parsed = 0; bytes_parsed = 0;
if(dma_q->is_partial_line) { if (dma_q->is_partial_line) {
/* Handle the case where we were working on a partial line */ /* Handle the case where we were working on a partial line */
sav_eav = dma_q->last_sav; sav_eav = dma_q->last_sav;
} else { } else {
/* Check for a SAV/EAV overlapping the buffer boundary */ /* 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 =
cx231xx_find_boundary_SAV_EAV(p_buffer,
dma_q->partial_buf,
&bytes_parsed);
} }
sav_eav &= 0xF0; sav_eav &= 0xF0;
/* Get the first line if we have some portion of an SAV/EAV from the last buffer /* Get the first line if we have some portion of an SAV/EAV from the last buffer
or a partial line */ or a partial line */
if(sav_eav) { if (sav_eav) {
bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, sav_eav, /* SAV/EAV */
sav_eav, /* SAV/EAV */
p_buffer + bytes_parsed, /* p_buffer */ p_buffer + bytes_parsed, /* p_buffer */
buffer_size - bytes_parsed); /* buffer size */ buffer_size - bytes_parsed); /* buffer size */
} }
...@@ -133,22 +135,18 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) ...@@ -133,22 +135,18 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb)
/* Now parse data that is completely in this buffer */ /* Now parse data that is completely in this buffer */
dma_q->is_partial_line = 0; dma_q->is_partial_line = 0;
while(bytes_parsed < buffer_size) while (bytes_parsed < buffer_size) {
{
u32 bytes_used = 0; u32 bytes_used = 0;
sav_eav = cx231xx_find_next_SAV_EAV( sav_eav = cx231xx_find_next_SAV_EAV(p_buffer + bytes_parsed, /* p_buffer */
p_buffer + bytes_parsed, /* p_buffer */
buffer_size - bytes_parsed, /* buffer size */ buffer_size - bytes_parsed, /* buffer size */
&bytes_used); /* Receives bytes used to get SAV/EAV */ &bytes_used); /* Receives bytes used to get SAV/EAV */
bytes_parsed += bytes_used; bytes_parsed += bytes_used;
sav_eav &= 0xF0; sav_eav &= 0xF0;
if(sav_eav && (bytes_parsed < buffer_size)) if (sav_eav && (bytes_parsed < buffer_size)) {
{ bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, sav_eav, /* SAV/EAV */
bytes_parsed += cx231xx_get_vbi_line(dev, dma_q,
sav_eav, /* SAV/EAV */
p_buffer + bytes_parsed, /* p_buffer */ p_buffer + bytes_parsed, /* p_buffer */
buffer_size - bytes_parsed); /* buffer size */ buffer_size - bytes_parsed); /* buffer size */
} }
...@@ -168,16 +166,17 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) ...@@ -168,16 +166,17 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb)
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
static int 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_fh *fh = vq->priv_data;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
u32 height = 0; u32 height = 0;
height = ((dev->norm & V4L2_STD_625_50) ? 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) if (0 == *count)
*count = CX231XX_DEF_VBI_BUF; *count = CX231XX_DEF_VBI_BUF;
...@@ -223,14 +222,15 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, ...@@ -223,14 +222,15 @@ 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_fh *fh = vq->priv_data;
struct cx231xx_buffer *buf = container_of(vb, struct cx231xx_buffer, vb); struct cx231xx_buffer *buf =
container_of(vb, struct cx231xx_buffer, vb);
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
int rc = 0, urb_init = 0; int rc = 0, urb_init = 0;
u32 height = 0; u32 height = 0;
height = ((dev->norm & V4L2_STD_625_50) ? height = ((dev->norm & V4L2_STD_625_50) ?
PAL_VBI_LINES : NTSC_VBI_LINES) ; PAL_VBI_LINES : NTSC_VBI_LINES);
buf->vb.size = ( (dev->width << 1) * height ); 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; return -EINVAL;
...@@ -251,7 +251,8 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, ...@@ -251,7 +251,8 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
if (urb_init) { if (urb_init) {
rc = cx231xx_init_vbi_isoc(dev, CX231XX_NUM_VBI_PACKETS, rc = cx231xx_init_vbi_isoc(dev, CX231XX_NUM_VBI_PACKETS,
CX231XX_NUM_VBI_BUFS, dev->vbi_mode.alt_max_pkt_size[0], CX231XX_NUM_VBI_BUFS,
dev->vbi_mode.alt_max_pkt_size[0],
cx231xx_isoc_vbi_copy); cx231xx_isoc_vbi_copy);
if (rc < 0) if (rc < 0)
goto fail; goto fail;
...@@ -260,7 +261,7 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, ...@@ -260,7 +261,7 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
buf->vb.state = VIDEOBUF_PREPARED; buf->vb.state = VIDEOBUF_PREPARED;
return 0; return 0;
fail: fail:
free_buffer(vq, buf); free_buffer(vq, buf);
return rc; return rc;
} }
...@@ -268,7 +269,8 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, ...@@ -268,7 +269,8 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
static void static void
vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
{ {
struct cx231xx_buffer *buf = container_of(vb, struct cx231xx_buffer, vb); struct cx231xx_buffer *buf =
container_of(vb, struct cx231xx_buffer, vb);
struct cx231xx_fh *fh = vq->priv_data; struct cx231xx_fh *fh = vq->priv_data;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
struct cx231xx_dmaqueue *vidq = &dev->vbi_mode.vidq; struct cx231xx_dmaqueue *vidq = &dev->vbi_mode.vidq;
...@@ -281,7 +283,8 @@ vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) ...@@ -281,7 +283,8 @@ vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
static void vbi_buffer_release(struct videobuf_queue *vq, 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_buffer *buf =
container_of(vb, struct cx231xx_buffer, vb);
/* /*
struct cx231xx_fh *fh = vq->priv_data; struct cx231xx_fh *fh = vq->priv_data;
struct cx231xx *dev = (struct cx231xx *)fh->dev; struct cx231xx *dev = (struct cx231xx *)fh->dev;
...@@ -292,7 +295,6 @@ static void vbi_buffer_release(struct videobuf_queue *vq, ...@@ -292,7 +295,6 @@ static void vbi_buffer_release(struct videobuf_queue *vq,
free_buffer(vq, buf); free_buffer(vq, buf);
} }
struct videobuf_queue_ops cx231xx_vbi_qops = { struct videobuf_queue_ops cx231xx_vbi_qops = {
.buf_setup = vbi_buffer_setup, .buf_setup = vbi_buffer_setup,
.buf_prepare = vbi_buffer_prepare, .buf_prepare = vbi_buffer_prepare,
...@@ -300,8 +302,6 @@ struct videobuf_queue_ops cx231xx_vbi_qops = { ...@@ -300,8 +302,6 @@ struct videobuf_queue_ops cx231xx_vbi_qops = {
.buf_release = vbi_buffer_release, .buf_release = vbi_buffer_release,
}; };
/* ------------------------------------------------------------------ /* ------------------------------------------------------------------
URB control URB control
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
...@@ -312,11 +312,11 @@ struct videobuf_queue_ops cx231xx_vbi_qops = { ...@@ -312,11 +312,11 @@ struct videobuf_queue_ops cx231xx_vbi_qops = {
static void cx231xx_irq_vbi_callback(struct urb *urb) static void cx231xx_irq_vbi_callback(struct urb *urb)
{ {
struct cx231xx_dmaqueue *dma_q = urb->context; struct cx231xx_dmaqueue *dma_q = urb->context;
struct cx231xx_video_mode *vmode = container_of(dma_q, struct cx231xx_video_mode, vidq); 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 *dev = container_of(vmode, struct cx231xx, vbi_mode);
int rc; int rc;
switch (urb->status) { switch (urb->status) {
case 0: /* success */ case 0: /* success */
case -ETIMEDOUT: /* NAK */ case -ETIMEDOUT: /* NAK */
...@@ -326,7 +326,8 @@ static void cx231xx_irq_vbi_callback(struct urb *urb) ...@@ -326,7 +326,8 @@ static void cx231xx_irq_vbi_callback(struct urb *urb)
case -ESHUTDOWN: case -ESHUTDOWN:
return; return;
default: /* error */ default: /* error */
cx231xx_err(DRIVER_NAME "urb completition error %d.\n", urb->status); cx231xx_err(DRIVER_NAME "urb completition error %d.\n",
urb->status);
break; break;
} }
...@@ -366,8 +367,10 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev) ...@@ -366,8 +367,10 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev)
if (dev->vbi_mode.isoc_ctl.transfer_buffer[i]) { if (dev->vbi_mode.isoc_ctl.transfer_buffer[i]) {
kfree(dev->vbi_mode.isoc_ctl.transfer_buffer[i]); kfree(dev->vbi_mode.isoc_ctl.
dev->vbi_mode.isoc_ctl.transfer_buffer[i] = NULL; transfer_buffer[i]);
dev->vbi_mode.isoc_ctl.transfer_buffer[i] =
NULL;
} }
usb_free_urb(urb); usb_free_urb(urb);
dev->vbi_mode.isoc_ctl.urb[i] = NULL; dev->vbi_mode.isoc_ctl.urb[i] = NULL;
...@@ -384,6 +387,7 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev) ...@@ -384,6 +387,7 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev)
cx231xx_capture_start(dev, 0, Vbi); cx231xx_capture_start(dev, 0, Vbi);
} }
EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc); EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc);
/* /*
...@@ -391,7 +395,8 @@ EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc); ...@@ -391,7 +395,8 @@ EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc);
*/ */
int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
int num_bufs, int max_pkt_size, int num_bufs, int max_pkt_size,
int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)) int (*isoc_copy) (struct cx231xx * dev,
struct urb * urb))
{ {
struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq; struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq;
int i; int i;
...@@ -405,8 +410,9 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, ...@@ -405,8 +410,9 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
cx231xx_uninit_vbi_isoc(dev); cx231xx_uninit_vbi_isoc(dev);
/* clear if any halt */ /* clear if any halt */
usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr)); 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.isoc_copy = isoc_copy;
dev->vbi_mode.isoc_ctl.num_bufs = num_bufs; dev->vbi_mode.isoc_ctl.num_bufs = num_bufs;
...@@ -416,19 +422,20 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, ...@@ -416,19 +422,20 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
dma_q->current_field = -1; dma_q->current_field = -1;
dma_q->bytes_left_in_line = dev->width << 1; dma_q->bytes_left_in_line = dev->width << 1;
dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ? dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ?
PAL_VBI_LINES : NTSC_VBI_LINES) ; PAL_VBI_LINES : NTSC_VBI_LINES);
dma_q->lines_completed = 0; dma_q->lines_completed = 0;
for(i = 0; i < 8 ; i++) for (i = 0; i < 8; i++)
dma_q->partial_buf[i] = 0; dma_q->partial_buf[i] = 0;
dev->vbi_mode.isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); dev->vbi_mode.isoc_ctl.urb =
kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
if (!dev->vbi_mode.isoc_ctl.urb) { if (!dev->vbi_mode.isoc_ctl.urb) {
cx231xx_errdev("cannot alloc memory for usb buffers\n"); cx231xx_errdev("cannot alloc memory for usb buffers\n");
return -ENOMEM; return -ENOMEM;
} }
dev->vbi_mode.isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, dev->vbi_mode.isoc_ctl.transfer_buffer =
GFP_KERNEL); kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
if (!dev->vbi_mode.isoc_ctl.transfer_buffer) { if (!dev->vbi_mode.isoc_ctl.transfer_buffer) {
cx231xx_errdev("cannot allocate memory for usbtransfer\n"); cx231xx_errdev("cannot allocate memory for usbtransfer\n");
kfree(dev->vbi_mode.isoc_ctl.urb); kfree(dev->vbi_mode.isoc_ctl.urb);
...@@ -445,27 +452,29 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, ...@@ -445,27 +452,29 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
urb = usb_alloc_urb(0, GFP_KERNEL); urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) { 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); cx231xx_uninit_vbi_isoc(dev);
return -ENOMEM; return -ENOMEM;
} }
dev->vbi_mode.isoc_ctl.urb[i] = urb; 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]) { if (!dev->vbi_mode.isoc_ctl.transfer_buffer[i]) {
cx231xx_err(DRIVER_NAME ": unable to allocate %i bytes for transfer" cx231xx_err(DRIVER_NAME
" buffer %i%s\n", ": unable to allocate %i bytes for transfer"
sb_size, i, " buffer %i%s\n", sb_size, i,
in_interrupt()?" while in int":""); in_interrupt()? " while in int" : "");
cx231xx_uninit_vbi_isoc(dev); cx231xx_uninit_vbi_isoc(dev);
return -ENOMEM; return -ENOMEM;
} }
pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr); pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr);
usb_fill_bulk_urb(urb, dev->udev, pipe, usb_fill_bulk_urb(urb, dev->udev, pipe,
dev->vbi_mode.isoc_ctl.transfer_buffer[i], sb_size, dev->vbi_mode.isoc_ctl.transfer_buffer[i],
cx231xx_irq_vbi_callback, dma_q); sb_size, cx231xx_irq_vbi_callback, dma_q);
} }
init_waitqueue_head(&dma_q->wq); init_waitqueue_head(&dma_q->wq);
...@@ -474,7 +483,8 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, ...@@ -474,7 +483,8 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { 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); rc = usb_submit_urb(dev->vbi_mode.isoc_ctl.urb[i], GFP_ATOMIC);
if (rc) { if (rc) {
cx231xx_err(DRIVER_NAME ": submit of urb %i failed (error=%i)\n", i, cx231xx_err(DRIVER_NAME
": submit of urb %i failed (error=%i)\n", i,
rc); rc);
cx231xx_uninit_vbi_isoc(dev); cx231xx_uninit_vbi_isoc(dev);
return rc; return rc;
...@@ -485,16 +495,16 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, ...@@ -485,16 +495,16 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
return 0; 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, u32 cx231xx_get_vbi_line(struct cx231xx * dev, struct cx231xx_dmaqueue * dma_q,
u8 sav_eav, u8 *p_buffer, u32 buffer_size) u8 sav_eav, u8 * p_buffer, u32 buffer_size)
{ {
u32 bytes_copied = 0; u32 bytes_copied = 0;
int current_field = -1; int current_field = -1;
switch(sav_eav) { switch (sav_eav) {
case SAV_VBI_FIELD1: case SAV_VBI_FIELD1:
current_field = 1; current_field = 1;
...@@ -507,12 +517,14 @@ u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -507,12 +517,14 @@ u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
break; break;
} }
if(current_field < 0 ) if (current_field < 0)
return bytes_copied; 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;
} }
...@@ -538,13 +550,13 @@ static inline void vbi_buffer_filled(struct cx231xx *dev, ...@@ -538,13 +550,13 @@ static inline void vbi_buffer_filled(struct cx231xx *dev,
} }
u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
u8 *p_line, u32 length, int field_number) u8 * p_line, u32 length, int field_number)
{ {
u32 bytes_to_copy; u32 bytes_to_copy;
struct cx231xx_buffer *buf; struct cx231xx_buffer *buf;
u32 _line_size = dev->width * 2; u32 _line_size = dev->width * 2;
if( dma_q->current_field != field_number ) { if (dma_q->current_field != field_number) {
cx231xx_reset_vbi_buffer(dev, dma_q); cx231xx_reset_vbi_buffer(dev, dma_q);
} }
...@@ -555,12 +567,13 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -555,12 +567,13 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
dma_q->current_field = field_number; dma_q->current_field = field_number;
bytes_to_copy = dma_q->bytes_left_in_line; bytes_to_copy = dma_q->bytes_left_in_line;
if(bytes_to_copy > length) if (bytes_to_copy > length)
bytes_to_copy = length; bytes_to_copy = length;
if(dma_q->lines_completed >= dma_q->lines_per_field) { if (dma_q->lines_completed >= dma_q->lines_per_field) {
dma_q->bytes_left_in_line -= bytes_to_copy; dma_q->bytes_left_in_line -= bytes_to_copy;
dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? 0 : 1; dma_q->is_partial_line =
(dma_q->bytes_left_in_line == 0) ? 0 : 1;
return 0; return 0;
} }
...@@ -568,9 +581,10 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -568,9 +581,10 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
/* If we don't have a buffer, just return the number of bytes we would /* If we don't have a buffer, just return the number of bytes we would
have copied if we had a buffer. */ have copied if we had a buffer. */
if(!buf) { if (!buf) {
dma_q->bytes_left_in_line -= bytes_to_copy; dma_q->bytes_left_in_line -= bytes_to_copy;
dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? 0 : 1; dma_q->is_partial_line =
(dma_q->bytes_left_in_line == 0) ? 0 : 1;
return bytes_to_copy; return bytes_to_copy;
} }
...@@ -580,13 +594,13 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -580,13 +594,13 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
dma_q->pos += bytes_to_copy; dma_q->pos += bytes_to_copy;
dma_q->bytes_left_in_line -= 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->bytes_left_in_line = _line_size;
dma_q->lines_completed++; dma_q->lines_completed++;
dma_q->is_partial_line = 0; 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);
...@@ -605,7 +619,8 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -605,7 +619,8 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q, 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_video_mode *vmode =
container_of(dma_q, struct cx231xx_video_mode, vidq);
struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode);
char *outp; char *outp;
...@@ -628,14 +643,14 @@ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q, ...@@ -628,14 +643,14 @@ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q,
return; return;
} }
void cx231xx_reset_vbi_buffer(struct cx231xx *dev,
void cx231xx_reset_vbi_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q) 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 */ /* first try to get the buffer */
get_next_vbi_buf(dma_q, &buf); get_next_vbi_buf(dma_q, &buf);
...@@ -649,7 +664,7 @@ void cx231xx_reset_vbi_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *dma ...@@ -649,7 +664,7 @@ void cx231xx_reset_vbi_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *dma
} }
int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 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; u8 *p_out_buffer = NULL;
u32 current_line_bytes_copied = 0; u32 current_line_bytes_copied = 0;
...@@ -666,28 +681,32 @@ int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -666,28 +681,32 @@ int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
p_out_buffer = videobuf_to_vmalloc(&buf->vb); p_out_buffer = videobuf_to_vmalloc(&buf->vb);
if(dma_q->bytes_left_in_line != _line_size ) { if (dma_q->bytes_left_in_line != _line_size) {
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 = ( 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; 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,
u8 cx231xx_is_vbi_buffer_done(struct cx231xx *dev,struct cx231xx_dmaqueue *dma_q) struct cx231xx_dmaqueue * dma_q)
{ {
u32 height = 0; u32 height = 0;
height = ((dev->norm & V4L2_STD_625_50) ? height = ((dev->norm & V4L2_STD_625_50) ?
PAL_VBI_LINES : NTSC_VBI_LINES) ; PAL_VBI_LINES : NTSC_VBI_LINES);
return (dma_q->lines_completed == height)?1:0; return (dma_q->lines_completed == height) ? 1 : 0;
} }
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
extern struct videobuf_queue_ops cx231xx_vbi_qops; extern struct videobuf_queue_ops cx231xx_vbi_qops;
#define NTSC_VBI_START_LINE 10 /* line 10 - 21 */ #define NTSC_VBI_START_LINE 10 /* line 10 - 21 */
#define NTSC_VBI_END_LINE 21 #define NTSC_VBI_END_LINE 21
#define NTSC_VBI_LINES (NTSC_VBI_END_LINE - NTSC_VBI_START_LINE + 1) #define NTSC_VBI_LINES (NTSC_VBI_END_LINE - NTSC_VBI_START_LINE + 1)
...@@ -42,20 +41,23 @@ extern struct videobuf_queue_ops cx231xx_vbi_qops; ...@@ -42,20 +41,23 @@ extern struct videobuf_queue_ops cx231xx_vbi_qops;
/* stream functions */ /* stream functions */
int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
int num_bufs, int max_pkt_size, int num_bufs, int max_pkt_size,
int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)); int (*isoc_copy) (struct cx231xx * dev,
struct urb * urb));
void cx231xx_uninit_vbi_isoc(struct cx231xx *dev); void cx231xx_uninit_vbi_isoc(struct cx231xx *dev);
/* vbi data copy functions */ /* vbi data copy functions */
u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
u8 sav_eav, u8 *p_buffer, u32 buffer_size); u8 sav_eav, u8 * p_buffer, u32 buffer_size);
u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
u8 *p_line, u32 length, int field_number); u8 * p_line, u32 length, int field_number);
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);
int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 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 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);
#endif #endif
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/init.h> #include <linux/init.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -44,11 +43,9 @@ ...@@ -44,11 +43,9 @@
#include "cx231xx.h" #include "cx231xx.h"
#include "cx231xx-vbi.h" #include "cx231xx-vbi.h"
#define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>" #define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>"
#define DRIVER_DESC "Conexant cx231xx based USB video device driver" #define DRIVER_DESC "Conexant cx231xx based USB video device driver"
#define cx231xx_videodbg(fmt, arg...) do {\ #define cx231xx_videodbg(fmt, arg...) do {\
if (video_debug) \ if (video_debug) \
printk(KERN_INFO "%s %s :"fmt, \ printk(KERN_INFO "%s %s :"fmt, \
...@@ -70,8 +67,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR); ...@@ -70,8 +67,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static unsigned int card[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; static unsigned int card[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET };
static unsigned int video_nr[] = {[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 vbi_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET };
...@@ -91,8 +86,6 @@ static unsigned int video_debug; ...@@ -91,8 +86,6 @@ static unsigned int video_debug;
module_param(video_debug, int, 0644); module_param(video_debug, int, 0644);
MODULE_PARM_DESC(video_debug, "enable debug messages [video]"); MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
/* supported video standards */ /* supported video standards */
static struct cx231xx_fmt format[] = { static struct cx231xx_fmt format[] = {
{ {
...@@ -103,7 +96,6 @@ static struct cx231xx_fmt format[] = { ...@@ -103,7 +96,6 @@ static struct cx231xx_fmt format[] = {
}, },
}; };
/* supported controls */ /* supported controls */
/* Common to all boards */ /* Common to all boards */
...@@ -224,7 +216,6 @@ static const u32 *ctrl_classes[] = { ...@@ -224,7 +216,6 @@ static const u32 *ctrl_classes[] = {
NULL NULL
}; };
/* ------------------------------------------------------------------ /* ------------------------------------------------------------------
Video buffer and parser functions Video buffer and parser functions
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
...@@ -248,9 +239,7 @@ static inline void buffer_filled(struct cx231xx *dev, ...@@ -248,9 +239,7 @@ static inline void buffer_filled(struct cx231xx *dev,
wake_up(&buf->vb.done); 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"; char *errmsg = "Unknown";
...@@ -294,12 +283,12 @@ static inline void print_err_status(struct cx231xx *dev, ...@@ -294,12 +283,12 @@ static inline void print_err_status(struct cx231xx *dev,
static inline void get_next_buf(struct cx231xx_dmaqueue *dma_q, 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_video_mode *vmode =
container_of(dma_q, struct cx231xx_video_mode, vidq);
struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode);
char *outp; char *outp;
if (list_empty(&dma_q->active)) { if (list_empty(&dma_q->active)) {
cx231xx_isocdbg("No active queue to serve\n"); cx231xx_isocdbg("No active queue to serve\n");
dev->video_mode.isoc_ctl.buf = NULL; dev->video_mode.isoc_ctl.buf = NULL;
...@@ -372,21 +361,22 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb) ...@@ -372,21 +361,22 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)
buffer_size = urb->iso_frame_desc[i].actual_length; buffer_size = urb->iso_frame_desc[i].actual_length;
bytes_parsed = 0; bytes_parsed = 0;
if(dma_q->is_partial_line) if (dma_q->is_partial_line) {
{
/* Handle the case where we were working on a partial line */ /* Handle the case where we were working on a partial line */
sav_eav = dma_q->last_sav; sav_eav = dma_q->last_sav;
} else { } else {
/* Check for a SAV/EAV overlapping the buffer boundary */ /* 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 =
cx231xx_find_boundary_SAV_EAV(p_buffer,
dma_q->partial_buf,
&bytes_parsed);
} }
sav_eav &= 0xF0; sav_eav &= 0xF0;
/* Get the first line if we have some portion of an SAV/EAV from the last buffer /* Get the first line if we have some portion of an SAV/EAV from the last buffer
or a partial line */ or a partial line */
if(sav_eav) { if (sav_eav) {
bytes_parsed += cx231xx_get_video_line(dev, dma_q, bytes_parsed += cx231xx_get_video_line(dev, dma_q, sav_eav, /* SAV/EAV */
sav_eav, /* SAV/EAV */
p_buffer + bytes_parsed, /* p_buffer */ p_buffer + bytes_parsed, /* p_buffer */
buffer_size - bytes_parsed); /* buffer size */ buffer_size - bytes_parsed); /* buffer size */
} }
...@@ -394,22 +384,18 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb) ...@@ -394,22 +384,18 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)
/* Now parse data that is completely in this buffer */ /* Now parse data that is completely in this buffer */
/* dma_q->is_partial_line = 0; */ /* dma_q->is_partial_line = 0; */
while(bytes_parsed < buffer_size) while (bytes_parsed < buffer_size) {
{
u32 bytes_used = 0; u32 bytes_used = 0;
sav_eav = cx231xx_find_next_SAV_EAV( sav_eav = cx231xx_find_next_SAV_EAV(p_buffer + bytes_parsed, /* p_buffer */
p_buffer + bytes_parsed, /* p_buffer */
buffer_size - bytes_parsed, /* buffer size */ buffer_size - bytes_parsed, /* buffer size */
&bytes_used); /* Receives bytes used to get SAV/EAV */ &bytes_used); /* Receives bytes used to get SAV/EAV */
bytes_parsed += bytes_used; bytes_parsed += bytes_used;
sav_eav &= 0xF0; sav_eav &= 0xF0;
if(sav_eav && (bytes_parsed < buffer_size)) if (sav_eav && (bytes_parsed < buffer_size)) {
{ bytes_parsed += cx231xx_get_video_line(dev, dma_q, sav_eav, /* SAV/EAV */
bytes_parsed += cx231xx_get_video_line(dev, dma_q,
sav_eav, /* SAV/EAV */
p_buffer + bytes_parsed, /* p_buffer */ p_buffer + bytes_parsed, /* p_buffer */
buffer_size - bytes_parsed); /* buffer size */ buffer_size - bytes_parsed); /* buffer size */
} }
...@@ -424,7 +410,8 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb) ...@@ -424,7 +410,8 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)
return rc; return rc;
} }
u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_used) u8 cx231xx_find_boundary_SAV_EAV(u8 * p_buffer, u8 * partial_buf,
u32 * p_bytes_used)
{ {
u32 bytes_used; u32 bytes_used;
u8 boundary_bytes[8]; u8 boundary_bytes[8];
...@@ -439,9 +426,10 @@ u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_use ...@@ -439,9 +426,10 @@ u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_use
memcpy(boundary_bytes + 4, p_buffer, 4); memcpy(boundary_bytes + 4, p_buffer, 4);
/* Check for the SAV/EAV in the boundary buffer */ /* Check for the SAV/EAV in the boundary buffer */
sav_eav = cx231xx_find_next_SAV_EAV((u8*)&boundary_bytes, 8, &bytes_used); sav_eav =
cx231xx_find_next_SAV_EAV((u8 *) & boundary_bytes, 8, &bytes_used);
if(sav_eav) { if (sav_eav) {
/* found a boundary SAV/EAV. Updates the bytes used to reflect /* found a boundary SAV/EAV. Updates the bytes used to reflect
only those used in the new buffer */ only those used in the new buffer */
*p_bytes_used = bytes_used - 4; *p_bytes_used = bytes_used - 4;
...@@ -450,26 +438,25 @@ u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_use ...@@ -450,26 +438,25 @@ u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_use
return sav_eav; return sav_eav;
} }
u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used) u8 cx231xx_find_next_SAV_EAV(u8 * p_buffer, u32 buffer_size, u32 * p_bytes_used)
{ {
u32 i; u32 i;
u8 sav_eav = 0; u8 sav_eav = 0;
/* Don't search if the buffer size is less than 4. It causes a page fault since /* 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. */ buffer_size - 4 evaluates to a large number in that case. */
if(buffer_size < 4) { if (buffer_size < 4) {
*p_bytes_used = buffer_size; *p_bytes_used = buffer_size;
return 0; return 0;
} }
for(i = 0;i < (buffer_size - 3); i++) { for (i = 0; i < (buffer_size - 3); i++) {
if((p_buffer[i] == 0xFF) && if ((p_buffer[i] == 0xFF) &&
(p_buffer[i+1] == 0x00) && (p_buffer[i + 1] == 0x00) && (p_buffer[i + 2] == 0x00)) {
(p_buffer[i+2] == 0x00)) {
*p_bytes_used = i+4; *p_bytes_used = i + 4;
sav_eav = p_buffer[i+3]; sav_eav = p_buffer[i + 3];
return sav_eav; return sav_eav;
} }
} }
...@@ -478,27 +465,26 @@ u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used) ...@@ -478,27 +465,26 @@ u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used)
return 0; return 0;
} }
u32 cx231xx_get_video_line(struct cx231xx * dev,
struct cx231xx_dmaqueue * dma_q, u8 sav_eav,
u8 * p_buffer, u32 buffer_size)
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; u32 bytes_copied = 0;
int current_field = -1; int current_field = -1;
switch (sav_eav) {
switch(sav_eav) {
case SAV_ACTIVE_VIDEO_FIELD1: case SAV_ACTIVE_VIDEO_FIELD1:
/* looking for skipped line which occurred in PAL 720x480 mode. In this case, /* 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 */ there will be no active data contained between the SAV and EAV */
if ( (buffer_size > 3) && if ((buffer_size > 3) &&
(p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) && (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00)
( (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) || && (p_buffer[2] == 0x00)
(p_buffer[3] == EAV_VBLANK_FIELD1) || (p_buffer[3] == EAV_VBLANK_FIELD2) && ((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; return bytes_copied;
} }
current_field = 1; current_field = 1;
...@@ -507,13 +493,15 @@ u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -507,13 +493,15 @@ u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
case SAV_ACTIVE_VIDEO_FIELD2: case SAV_ACTIVE_VIDEO_FIELD2:
/* looking for skipped line which occurred in PAL 720x480 mode. In this case, /* 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 */ there will be no active data contained between the SAV and EAV */
if ( (buffer_size > 3) && if ((buffer_size > 3) &&
(p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) && (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00)
( (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) || && (p_buffer[2] == 0x00)
(p_buffer[3] == EAV_VBLANK_FIELD1) || (p_buffer[3] == EAV_VBLANK_FIELD2) && ((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; return bytes_copied;
} }
current_field = 2; current_field = 2;
...@@ -522,19 +510,22 @@ u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -522,19 +510,22 @@ u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
dma_q->last_sav = sav_eav; dma_q->last_sav = sav_eav;
bytes_copied = cx231xx_copy_video_line(dev, dma_q, p_buffer, buffer_size, current_field); bytes_copied =
cx231xx_copy_video_line(dev, dma_q, p_buffer, buffer_size,
current_field);
return bytes_copied; return bytes_copied;
} }
u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, u32 cx231xx_copy_video_line(struct cx231xx * dev,
u8 *p_line, u32 length, int field_number) struct cx231xx_dmaqueue * dma_q, u8 * p_line,
u32 length, int field_number)
{ {
u32 bytes_to_copy; u32 bytes_to_copy;
struct cx231xx_buffer *buf; struct cx231xx_buffer *buf;
u32 _line_size = dev->width * 2; u32 _line_size = dev->width * 2;
if( dma_q->current_field != field_number ) { if (dma_q->current_field != field_number) {
cx231xx_reset_video_buffer(dev, dma_q); cx231xx_reset_video_buffer(dev, dma_q);
} }
...@@ -545,13 +536,13 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q ...@@ -545,13 +536,13 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q
dma_q->current_field = field_number; dma_q->current_field = field_number;
bytes_to_copy = dma_q->bytes_left_in_line; bytes_to_copy = dma_q->bytes_left_in_line;
if(bytes_to_copy > length) if (bytes_to_copy > length)
bytes_to_copy = length; bytes_to_copy = length;
if (dma_q->lines_completed >= dma_q->lines_per_field) {
if(dma_q->lines_completed >= dma_q->lines_per_field) {
dma_q->bytes_left_in_line -= bytes_to_copy; dma_q->bytes_left_in_line -= bytes_to_copy;
dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? 0 : 1; dma_q->is_partial_line =
(dma_q->bytes_left_in_line == 0) ? 0 : 1;
return 0; return 0;
} }
...@@ -559,10 +550,10 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q ...@@ -559,10 +550,10 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q
/* If we don't have a buffer, just return the number of bytes we would /* If we don't have a buffer, just return the number of bytes we would
have copied if we had a buffer. */ have copied if we had a buffer. */
if(!buf) if (!buf) {
{
dma_q->bytes_left_in_line -= bytes_to_copy; dma_q->bytes_left_in_line -= bytes_to_copy;
dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? 0 : 1; dma_q->is_partial_line =
(dma_q->bytes_left_in_line == 0) ? 0 : 1;
return bytes_to_copy; return bytes_to_copy;
} }
...@@ -572,13 +563,13 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q ...@@ -572,13 +563,13 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q
dma_q->pos += bytes_to_copy; dma_q->pos += bytes_to_copy;
dma_q->bytes_left_in_line -= 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->bytes_left_in_line = _line_size;
dma_q->lines_completed++; dma_q->lines_completed++;
dma_q->is_partial_line = 0; 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);
...@@ -591,13 +582,14 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q ...@@ -591,13 +582,14 @@ u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q
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 */ /* handle the switch from field 1 to field 2 */
if(dma_q->current_field == 1) { if (dma_q->current_field == 1) {
if(dma_q->lines_completed >= dma_q->lines_per_field ) { if (dma_q->lines_completed >= dma_q->lines_per_field) {
dma_q->field1_done = 1; dma_q->field1_done = 1;
} else { } else {
dma_q->field1_done = 0; dma_q->field1_done = 0;
...@@ -606,12 +598,12 @@ void cx231xx_reset_video_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *d ...@@ -606,12 +598,12 @@ void cx231xx_reset_video_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *d
buf = dev->video_mode.isoc_ctl.buf; buf = dev->video_mode.isoc_ctl.buf;
if(buf == NULL) { if (buf == NULL) {
u8* outp = NULL; u8 *outp = NULL;
/* first try to get the buffer */ /* first try to get the buffer */
get_next_buf(dma_q, &buf); get_next_buf(dma_q, &buf);
if(buf) if (buf)
outp = videobuf_to_vmalloc(&buf->vb); outp = videobuf_to_vmalloc(&buf->vb);
dma_q->pos = 0; dma_q->pos = 0;
...@@ -625,7 +617,7 @@ void cx231xx_reset_video_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *d ...@@ -625,7 +617,7 @@ void cx231xx_reset_video_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *d
} }
int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 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; u8 *p_out_buffer = NULL;
u32 current_line_bytes_copied = 0; u32 current_line_bytes_copied = 0;
...@@ -644,7 +636,7 @@ int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -644,7 +636,7 @@ int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
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 field 2 one line from the top of the buffer */
offset = (dma_q->current_field == 1)? 0: _line_size; offset = (dma_q->current_field == 1) ? 0 : _line_size;
/* Offset for field 2 */ /* Offset for field 2 */
startwrite = p_out_buffer + offset; startwrite = p_out_buffer + offset;
...@@ -655,31 +647,34 @@ int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, ...@@ -655,31 +647,34 @@ int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
/* bytes already completed in the current line */ /* bytes already completed in the current line */
startwrite += current_line_bytes_copied; 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) ) { if ((u8 *) (startwrite + lencopy) >
(u8 *) (p_out_buffer + buf->vb.size)) {
return 0; return 0;
} }
/* The below copies the UYVY data straight into video buffer */ /* The below copies the UYVY data straight into video buffer */
cx231xx_swab( (u16*)p_buffer, (u16*)startwrite, (u16)lencopy); 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) if (len <= 0)
return; return;
for(i = 0; i < len/2; i++) { for (i = 0; i < len / 2; i++) {
to[i] = (from[i] << 8) | (from[i] >> 8); 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;
...@@ -692,7 +687,6 @@ u8 cx231xx_is_buffer_done(struct cx231xx *dev,struct cx231xx_dmaqueue *dma_q) ...@@ -692,7 +687,6 @@ u8 cx231xx_is_buffer_done(struct cx231xx *dev,struct cx231xx_dmaqueue *dma_q)
return buffer_complete; return buffer_complete;
} }
/* ------------------------------------------------------------------ /* ------------------------------------------------------------------
Videobuf operations Videobuf operations
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
...@@ -704,7 +698,8 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) ...@@ -704,7 +698,8 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
struct v4l2_frequency f; 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) if (0 == *count)
*count = CX231XX_DEF_BUF; *count = CX231XX_DEF_BUF;
...@@ -753,12 +748,14 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, ...@@ -753,12 +748,14 @@ 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_fh *fh = vq->priv_data;
struct cx231xx_buffer *buf = container_of(vb, struct cx231xx_buffer, vb); struct cx231xx_buffer *buf =
container_of(vb, struct cx231xx_buffer, vb);
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
int rc = 0, urb_init = 0; int rc = 0, urb_init = 0;
/* The only currently supported format is 16 bits/pixel */ /* 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; return -EINVAL;
...@@ -778,7 +775,8 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, ...@@ -778,7 +775,8 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
if (urb_init) { if (urb_init) {
rc = cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS, rc = cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS,
CX231XX_NUM_BUFS, dev->video_mode.max_pkt_size, CX231XX_NUM_BUFS,
dev->video_mode.max_pkt_size,
cx231xx_isoc_copy); cx231xx_isoc_copy);
if (rc < 0) if (rc < 0)
goto fail; goto fail;
...@@ -787,15 +785,15 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, ...@@ -787,15 +785,15 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
buf->vb.state = VIDEOBUF_PREPARED; buf->vb.state = VIDEOBUF_PREPARED;
return 0; return 0;
fail: fail:
free_buffer(vq, buf); free_buffer(vq, buf);
return rc; return rc;
} }
static void static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
{ {
struct cx231xx_buffer *buf = container_of(vb, struct cx231xx_buffer, vb); struct cx231xx_buffer *buf =
container_of(vb, struct cx231xx_buffer, vb);
struct cx231xx_fh *fh = vq->priv_data; struct cx231xx_fh *fh = vq->priv_data;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq;
...@@ -808,7 +806,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) ...@@ -808,7 +806,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *vq, 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_buffer *buf =
container_of(vb, struct cx231xx_buffer, vb);
struct cx231xx_fh *fh = vq->priv_data; struct cx231xx_fh *fh = vq->priv_data;
struct cx231xx *dev = (struct cx231xx *)fh->dev; struct cx231xx *dev = (struct cx231xx *)fh->dev;
...@@ -826,7 +825,6 @@ static struct videobuf_queue_ops cx231xx_video_qops = { ...@@ -826,7 +825,6 @@ static struct videobuf_queue_ops cx231xx_video_qops = {
/********************* v4l2 interface **************************************/ /********************* v4l2 interface **************************************/
void video_mux(struct cx231xx *dev, int index) void video_mux(struct cx231xx *dev, int index)
{ {
...@@ -837,11 +835,12 @@ void video_mux(struct cx231xx *dev, int index) ...@@ -837,11 +835,12 @@ void video_mux(struct cx231xx *dev, int index)
dev->video_input = index; dev->video_input = index;
dev->ctl_ainput = INPUT(index)->amux; 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);
...@@ -859,11 +858,11 @@ static int res_get(struct cx231xx_fh *fh) ...@@ -859,11 +858,11 @@ static int res_get(struct cx231xx_fh *fh)
if (fh->stream_on) if (fh->stream_on)
return rc; return rc;
if(fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
if (dev->stream_on) if (dev->stream_on)
return -EBUSY; return -EBUSY;
dev->stream_on = 1; dev->stream_on = 1;
} else if(fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
if (dev->vbi_stream_on) if (dev->vbi_stream_on)
return -EBUSY; return -EBUSY;
dev->vbi_stream_on = 1; dev->vbi_stream_on = 1;
...@@ -886,9 +885,9 @@ static void res_free(struct cx231xx_fh *fh) ...@@ -886,9 +885,9 @@ static void res_free(struct cx231xx_fh *fh)
fh->stream_on = 0; fh->stream_on = 0;
if(fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
dev->stream_on = 0; dev->stream_on = 0;
if(fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)
dev->vbi_stream_on = 0; dev->vbi_stream_on = 0;
} }
...@@ -1024,7 +1023,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -1024,7 +1023,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
if (rc < 0) if (rc < 0)
return rc; return rc;
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
vidioc_try_fmt_vid_cap(file, priv, f); vidioc_try_fmt_vid_cap(file, priv, f);
...@@ -1058,12 +1056,12 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -1058,12 +1056,12 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
/* Set the correct alternate setting for this resolution */ /* Set the correct alternate setting for this resolution */
cx231xx_resolution_set(dev); cx231xx_resolution_set(dev);
out: out:
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return rc; 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_fh *fh = priv;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
...@@ -1088,7 +1086,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm) ...@@ -1088,7 +1086,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
dev->norm = *norm; dev->norm = *norm;
/* Adjusts width/height, if needed */ /* Adjusts width/height, if needed */
f.fmt.pix.width = dev->width; f.fmt.pix.width = dev->width;
f.fmt.pix.height = dev->height; f.fmt.pix.height = dev->height;
...@@ -1208,7 +1205,6 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) ...@@ -1208,7 +1205,6 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
int status = 0; int status = 0;
/* Doesn't allow manual routing */ /* Doesn't allow manual routing */
if (a->index != dev->ctl_ainput) if (a->index != dev->ctl_ainput)
return -EINVAL; return -EINVAL;
...@@ -1240,8 +1236,7 @@ static int vidioc_queryctrl(struct file *file, void *priv, ...@@ -1240,8 +1236,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
qc->id = id; qc->id = id;
if (qc->id < V4L2_CID_BASE || if (qc->id < V4L2_CID_BASE || qc->id >= V4L2_CID_LASTP1)
qc->id >= V4L2_CID_LASTP1)
return -EINVAL; return -EINVAL;
for (i = 0; i < CX231XX_CTLS; i++) for (i = 0; i < CX231XX_CTLS; i++)
...@@ -1302,8 +1297,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -1302,8 +1297,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
return rc; return rc;
} }
static int vidioc_g_tuner(struct file *file, void *priv, static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
struct v4l2_tuner *t)
{ {
struct cx231xx_fh *fh = priv; struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
...@@ -1321,13 +1315,12 @@ static int vidioc_g_tuner(struct file *file, void *priv, ...@@ -1321,13 +1315,12 @@ static int vidioc_g_tuner(struct file *file, void *priv,
t->type = V4L2_TUNER_ANALOG_TV; t->type = V4L2_TUNER_ANALOG_TV;
t->capability = V4L2_TUNER_CAP_NORM; t->capability = V4L2_TUNER_CAP_NORM;
t->rangehigh = 0xffffffffUL; t->rangehigh = 0xffffffffUL;
t->signal = 0xffff ; /* LOCKED */ t->signal = 0xffff; /* LOCKED */
return 0; return 0;
} }
static int vidioc_s_tuner(struct file *file, void *priv, static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
struct v4l2_tuner *t)
{ {
struct cx231xx_fh *fh = priv; struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
...@@ -1392,12 +1385,13 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -1392,12 +1385,13 @@ static int vidioc_s_frequency(struct file *file, void *priv,
dev->ctl_freq = f->frequency; dev->ctl_freq = f->frequency;
if(dev->tuner_type == TUNER_XC5000) { if (dev->tuner_type == TUNER_XC5000) {
if( dev->cx231xx_set_analog_freq != NULL ) { if (dev->cx231xx_set_analog_freq != NULL) {
dev->cx231xx_set_analog_freq(dev, f->frequency ); dev->cx231xx_set_analog_freq(dev, f->frequency);
} }
} else { } 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); mutex_unlock(&dev->lock);
...@@ -1405,14 +1399,13 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -1405,14 +1399,13 @@ static int vidioc_s_frequency(struct file *file, void *priv,
/* set post channel change settings in DIF first */ /* set post channel change settings in DIF first */
rc = cx231xx_tuner_post_channel_change(dev); 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; return rc;
} }
#ifdef CONFIG_VIDEO_ADV_DEBUG #ifdef CONFIG_VIDEO_ADV_DEBUG
/* /*
-R, --list-registers=type=<host/i2cdrv/i2caddr>,chip=<chip>[,min=<addr>,max=<addr>] -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]
...@@ -1424,52 +1417,68 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -1424,52 +1417,68 @@ static int vidioc_s_frequency(struct file *file, void *priv,
if type == i2caddr, then <chip> is the 7-bit I2C address if type == i2caddr, then <chip> is the 7-bit I2C address
*/ */
static int vidioc_g_register(struct file *file, void *priv, static int vidioc_g_register(struct file *file, void *priv,
struct v4l2_dbg_register *reg) struct v4l2_dbg_register *reg)
{ {
struct cx231xx_fh *fh = priv; struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
int ret = 0; int ret = 0;
u8 value[4] ={0,0,0,0}; u8 value[4] = { 0, 0, 0, 0 };
u32 data = 0; u32 data = 0;
switch (reg->match.type) { switch (reg->match.type) {
case V4L2_CHIP_MATCH_HOST: case V4L2_CHIP_MATCH_HOST:
switch(reg->match.addr) { switch (reg->match.addr) {
case 0: /* Cx231xx - internal registers */ case 0: /* Cx231xx - internal registers */
ret = cx231xx_read_ctrl_reg(dev,VRT_GET_REGISTER, (u16) reg->reg, value, 4); ret =
reg->val = value[0] | value[1] << 8 | value[2] << 16 | value[3] << 24; 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; break;
case 1: /* Colibri - read byte */ case 1: /* Colibri - read byte */
ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, &data, 1); ret =
cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
(u16) reg->reg, 2, &data, 1);
reg->val = le32_to_cpu(data & 0xff); reg->val = le32_to_cpu(data & 0xff);
break; break;
case 14: /* Colibri - read dword */ case 14: /* Colibri - read dword */
ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, &data, 4); ret =
cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
(u16) reg->reg, 2, &data, 4);
reg->val = le32_to_cpu(data); reg->val = le32_to_cpu(data);
break; break;
case 2: /* Hammerhead - read byte */ case 2: /* Hammerhead - read byte */
ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, &data, 1); ret =
cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
(u16) reg->reg, 2, &data, 1);
reg->val = le32_to_cpu(data & 0xff); reg->val = le32_to_cpu(data & 0xff);
break; break;
case 24: /* Hammerhead - read dword */ case 24: /* Hammerhead - read dword */
ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, &data, 4); ret =
cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
(u16) reg->reg, 2, &data, 4);
reg->val = le32_to_cpu(data); reg->val = le32_to_cpu(data);
break; break;
case 3: /* flatiron - read byte */ case 3: /* flatiron - read byte */
ret = cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, &data, 1); ret =
cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS,
(u16) reg->reg, 1, &data, 1);
reg->val = le32_to_cpu(data & 0xff); reg->val = le32_to_cpu(data & 0xff);
break; break;
case 34: /* flatiron - read dword */ case 34: /* flatiron - read dword */
ret = cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, &data, 4); ret =
cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS,
(u16) reg->reg, 1, &data, 4);
reg->val = le32_to_cpu(data); reg->val = le32_to_cpu(data);
break; break;
} }
return ret < 0?ret:0; return ret < 0 ? ret : 0;
case V4L2_CHIP_MATCH_I2C_DRIVER: case V4L2_CHIP_MATCH_I2C_DRIVER:
cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg); cx231xx_i2c_call_clients(&dev->i2c_bus[0],
VIDIOC_DBG_G_REGISTER, reg);
return 0; return 0;
case V4L2_CHIP_MATCH_I2C_ADDR: case V4L2_CHIP_MATCH_I2C_ADDR:
/* Not supported yet */ /* Not supported yet */
...@@ -1479,7 +1488,6 @@ static int vidioc_g_register(struct file *file, void *priv, ...@@ -1479,7 +1488,6 @@ static int vidioc_g_register(struct file *file, void *priv,
return -EINVAL; return -EINVAL;
} }
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg); cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg);
...@@ -1497,7 +1505,7 @@ static int vidioc_s_register(struct file *file, void *priv, ...@@ -1497,7 +1505,7 @@ static int vidioc_s_register(struct file *file, void *priv,
int ret = 0; int ret = 0;
__le64 buf; __le64 buf;
u32 value; u32 value;
u8 data[4] ={0,0,0,0}; u8 data[4] = { 0, 0, 0, 0 };
buf = cpu_to_le64(reg->val); buf = cpu_to_le64(reg->val);
...@@ -1506,35 +1514,63 @@ static int vidioc_s_register(struct file *file, void *priv, ...@@ -1506,35 +1514,63 @@ static int vidioc_s_register(struct file *file, void *priv,
{ {
value = (u32) buf & 0xffffffff; value = (u32) buf & 0xffffffff;
switch(reg->match.addr) { switch (reg->match.addr) {
case 0: /* cx231xx internal registers */ case 0: /* cx231xx internal registers */
data[0]=(u8)value; data[0] = (u8) value;
data[1]=(u8)(value>>8); data[1] = (u8) (value >> 8);
data[2]=(u8)(value>>16); data[2] = (u8) (value >> 16);
data[3]=(u8)(value>>24); data[3] = (u8) (value >> 24);
ret = cx231xx_write_ctrl_reg(dev,VRT_SET_REGISTER, (u16) reg->reg, data, 4); ret =
cx231xx_write_ctrl_reg(dev,
VRT_SET_REGISTER,
(u16) reg->reg, data,
4);
break; break;
case 1: /* Colibri - read byte */ case 1: /* Colibri - read byte */
ret = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, value, 1); ret =
cx231xx_write_i2c_data(dev,
Colibri_DEVICE_ADDRESS,
(u16) reg->reg, 2,
value, 1);
break; break;
case 14: /* Colibri - read dword */ case 14: /* Colibri - read dword */
ret = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, (u16) reg->reg, 2, value, 4); ret =
cx231xx_write_i2c_data(dev,
Colibri_DEVICE_ADDRESS,
(u16) reg->reg, 2,
value, 4);
break; break;
case 2: /* Hammerhead - read byte */ case 2: /* Hammerhead - read byte */
ret = cx231xx_write_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, value, 1); ret =
cx231xx_write_i2c_data(dev,
HAMMERHEAD_I2C_ADDRESS,
(u16) reg->reg, 2,
value, 1);
break; break;
case 24: /* Hammerhead - read dword */ case 24: /* Hammerhead - read dword */
ret = cx231xx_write_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS, (u16) reg->reg, 2, value, 4); ret =
cx231xx_write_i2c_data(dev,
HAMMERHEAD_I2C_ADDRESS,
(u16) reg->reg, 2,
value, 4);
break; break;
case 3: /* flatiron - read byte */ case 3: /* flatiron - read byte */
ret = cx231xx_write_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, value, 1); ret =
cx231xx_write_i2c_data(dev,
Flatrion_DEVICE_ADDRESS,
(u16) reg->reg, 1,
value, 1);
break; break;
case 34: /* flatiron - read dword */ case 34: /* flatiron - read dword */
ret = cx231xx_write_i2c_data(dev, Flatrion_DEVICE_ADDRESS, (u16) reg->reg, 1, value, 4); ret =
cx231xx_write_i2c_data(dev,
Flatrion_DEVICE_ADDRESS,
(u16) reg->reg, 1,
value, 4);
break; break;
} }
} }
return ret < 0?ret:0; return ret < 0 ? ret : 0;
default: default:
break; break;
...@@ -1550,7 +1586,6 @@ static int vidioc_s_register(struct file *file, void *priv, ...@@ -1550,7 +1586,6 @@ static int vidioc_s_register(struct file *file, void *priv,
} }
#endif #endif
static int vidioc_cropcap(struct file *file, void *priv, static int vidioc_cropcap(struct file *file, void *priv,
struct v4l2_cropcap *cc) struct v4l2_cropcap *cc)
{ {
...@@ -1604,8 +1639,8 @@ static int vidioc_streamoff(struct file *file, void *priv, ...@@ -1604,8 +1639,8 @@ static int vidioc_streamoff(struct file *file, void *priv,
if (rc < 0) if (rc < 0)
return rc; return rc;
if ( (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) || if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
(fh->type != V4L2_BUF_TYPE_VBI_CAPTURE) ) (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE))
return -EINVAL; return -EINVAL;
if (type != fh->type) if (type != fh->type)
return -EINVAL; return -EINVAL;
...@@ -1628,18 +1663,17 @@ static int vidioc_querycap(struct file *file, void *priv, ...@@ -1628,18 +1663,17 @@ static int vidioc_querycap(struct file *file, void *priv,
strlcpy(cap->driver, "cx231xx", sizeof(cap->driver)); strlcpy(cap->driver, "cx231xx", sizeof(cap->driver));
strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); 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->version = CX231XX_VERSION_CODE;
cap->capabilities = cap->capabilities = V4L2_CAP_VBI_CAPTURE |
V4L2_CAP_VBI_CAPTURE |
#if 0 #if 0
V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE |
#endif #endif
V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_AUDIO | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
if (dev->tuner_type != TUNER_ABSENT) if (dev->tuner_type != TUNER_ABSENT)
cap->capabilities |= V4L2_CAP_TUNER; cap->capabilities |= V4L2_CAP_TUNER;
...@@ -1705,7 +1739,6 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv, ...@@ -1705,7 +1739,6 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
return 0; return 0;
} }
/* RAW VBI ioctls */ /* RAW VBI ioctls */
static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
...@@ -1715,7 +1748,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, ...@@ -1715,7 +1748,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
f->fmt.vbi.sampling_rate = (dev->norm & V4L2_STD_625_50) ? 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.samples_per_line = VBI_LINE_LENGTH;
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
f->fmt.vbi.offset = 64 * 4; f->fmt.vbi.offset = 64 * 4;
...@@ -1724,7 +1757,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, ...@@ -1724,7 +1757,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ? 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) ? 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]; f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
return 0; return 0;
...@@ -1744,7 +1777,7 @@ static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv, ...@@ -1744,7 +1777,7 @@ static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv,
f->type = V4L2_BUF_TYPE_VBI_CAPTURE; f->type = V4L2_BUF_TYPE_VBI_CAPTURE;
f->fmt.vbi.sampling_rate = (dev->norm & V4L2_STD_625_50) ? 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.samples_per_line = VBI_LINE_LENGTH;
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
f->fmt.vbi.offset = 244; f->fmt.vbi.offset = 244;
...@@ -1754,7 +1787,7 @@ static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv, ...@@ -1754,7 +1787,7 @@ static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv,
f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ? 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) ? 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]; f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
return 0; return 0;
...@@ -1775,8 +1808,7 @@ static int vidioc_reqbufs(struct file *file, void *priv, ...@@ -1775,8 +1808,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
return (videobuf_reqbufs(&fh->vb_vidq, rb)); return (videobuf_reqbufs(&fh->vb_vidq, rb));
} }
static int vidioc_querybuf(struct file *file, void *priv, static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *b)
struct v4l2_buffer *b)
{ {
struct cx231xx_fh *fh = priv; struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
...@@ -1812,8 +1844,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) ...@@ -1812,8 +1844,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
if (rc < 0) if (rc < 0)
return rc; return rc;
return (videobuf_dqbuf(&fh->vb_vidq, b, return (videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK));
file->f_flags & O_NONBLOCK));
} }
#ifdef CONFIG_VIDEO_V4L1_COMPAT #ifdef CONFIG_VIDEO_V4L1_COMPAT
...@@ -1825,7 +1856,6 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) ...@@ -1825,7 +1856,6 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
} }
#endif #endif
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* RADIO ESPECIFIC IOCTLS */ /* RADIO ESPECIFIC IOCTLS */
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
...@@ -1844,8 +1874,7 @@ static int radio_querycap(struct file *file, void *priv, ...@@ -1844,8 +1874,7 @@ static int radio_querycap(struct file *file, void *priv,
return 0; return 0;
} }
static int radio_g_tuner(struct file *file, void *priv, static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
struct v4l2_tuner *t)
{ {
struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
...@@ -1862,8 +1891,7 @@ static int radio_g_tuner(struct file *file, void *priv, ...@@ -1862,8 +1891,7 @@ static int radio_g_tuner(struct file *file, void *priv,
return 0; return 0;
} }
static int radio_enum_input(struct file *file, void *priv, static int radio_enum_input(struct file *file, void *priv, struct v4l2_input *i)
struct v4l2_input *i)
{ {
if (i->index != 0) if (i->index != 0)
return -EINVAL; return -EINVAL;
...@@ -1882,8 +1910,7 @@ static int radio_g_audio(struct file *file, void *priv, struct v4l2_audio *a) ...@@ -1882,8 +1910,7 @@ static int radio_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
return 0; return 0;
} }
static int radio_s_tuner(struct file *file, void *priv, static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
struct v4l2_tuner *t)
{ {
struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
...@@ -1897,8 +1924,7 @@ static int radio_s_tuner(struct file *file, void *priv, ...@@ -1897,8 +1924,7 @@ static int radio_s_tuner(struct file *file, void *priv,
return 0; return 0;
} }
static int radio_s_audio(struct file *file, void *fh, static int radio_s_audio(struct file *file, void *fh, struct v4l2_audio *a)
struct v4l2_audio *a)
{ {
return 0; return 0;
} }
...@@ -1913,8 +1939,7 @@ static int radio_queryctrl(struct file *file, void *priv, ...@@ -1913,8 +1939,7 @@ static int radio_queryctrl(struct file *file, void *priv,
{ {
int i; int i;
if (c->id < V4L2_CID_BASE || if (c->id < V4L2_CID_BASE || c->id >= V4L2_CID_LASTP1)
c->id >= V4L2_CID_LASTP1)
return -EINVAL; return -EINVAL;
if (c->id == V4L2_CID_AUDIO_MUTE) { if (c->id == V4L2_CID_AUDIO_MUTE) {
for (i = 0; i < CX231XX_CTLS; i++) for (i = 0; i < CX231XX_CTLS; i++)
...@@ -1950,7 +1975,8 @@ static int cx231xx_v4l2_open(struct file *filp) ...@@ -1950,7 +1975,8 @@ static int cx231xx_v4l2_open(struct file *filp)
#if 0 #if 0
errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE);
if (errCode < 0) { 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); mutex_unlock(&dev->lock);
return -EBUSY; return -EBUSY;
} }
...@@ -1973,7 +1999,6 @@ static int cx231xx_v4l2_open(struct file *filp) ...@@ -1973,7 +1999,6 @@ static int cx231xx_v4l2_open(struct file *filp)
dev->hscale = 0; dev->hscale = 0;
dev->vscale = 0; dev->vscale = 0;
/* Power up in Analog TV mode */ /* Power up in Analog TV mode */
cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV); cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV);
...@@ -1990,8 +2015,8 @@ static int cx231xx_v4l2_open(struct file *filp) ...@@ -1990,8 +2015,8 @@ static int cx231xx_v4l2_open(struct file *filp)
cx231xx_config_i2c(dev); cx231xx_config_i2c(dev);
/* device needs to be initialized before isoc transfer */ /* device needs to be initialized before isoc transfer */
dev->video_input = dev->video_input > 2 ? 2: dev->video_input; dev->video_input = dev->video_input > 2 ? 2 : dev->video_input;
video_mux(dev, dev->video_input ); video_mux(dev, dev->video_input);
} }
if (fh->radio) { if (fh->radio) {
...@@ -1999,14 +2024,14 @@ static int cx231xx_v4l2_open(struct file *filp) ...@@ -1999,14 +2024,14 @@ static int cx231xx_v4l2_open(struct file *filp)
/* cx231xx_start_radio(dev); */ /* 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++; dev->users++;
if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops, videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops, NULL, &dev->video_mode.slock, fh->type, V4L2_FIELD_INTERLACED, /* V4L2_FIELD_SEQ_TB, */
NULL, &dev->video_mode.slock, fh->type, V4L2_FIELD_INTERLACED, /* V4L2_FIELD_SEQ_TB, */
sizeof(struct cx231xx_buffer), fh); sizeof(struct cx231xx_buffer), fh);
} }
...@@ -2015,8 +2040,7 @@ static int cx231xx_v4l2_open(struct file *filp) ...@@ -2015,8 +2040,7 @@ static int cx231xx_v4l2_open(struct file *filp)
/* Set the required alternate setting VBI interface works in Bulk mode only */ /* Set the required alternate setting VBI interface works in Bulk mode only */
cx231xx_set_alt_setting(dev, INDEX_VANC, 0); cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops, videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops, NULL, &dev->vbi_mode.slock, fh->type, V4L2_FIELD_SEQ_TB, /* V4L2_FIELD_INTERLACED, */
NULL, &dev->vbi_mode.slock, fh->type, V4L2_FIELD_SEQ_TB, /* V4L2_FIELD_INTERLACED, */
sizeof(struct cx231xx_buffer), fh); sizeof(struct cx231xx_buffer), fh);
} }
...@@ -2096,7 +2120,7 @@ static int cx231xx_v4l2_close(struct file *filp) ...@@ -2096,7 +2120,7 @@ static int cx231xx_v4l2_close(struct file *filp)
cx231xx_uninit_vbi_isoc(dev); cx231xx_uninit_vbi_isoc(dev);
/* set alternate 0 */ /* set alternate 0 */
if( !dev->vbi_or_sliced_cc_mode) { if (!dev->vbi_or_sliced_cc_mode) {
cx231xx_set_alt_setting(dev, INDEX_VANC, 0); cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
} else { } else {
cx231xx_set_alt_setting(dev, INDEX_HANC, 0); cx231xx_set_alt_setting(dev, INDEX_HANC, 0);
...@@ -2123,7 +2147,8 @@ static int cx231xx_v4l2_close(struct file *filp) ...@@ -2123,7 +2147,8 @@ static int cx231xx_v4l2_close(struct file *filp)
} }
/* Save some power by putting tuner to sleep */ /* Save some power by putting tuner to sleep */
cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_STANDBY, NULL); cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_STANDBY,
NULL);
/* do this before setting alternate! */ /* do this before setting alternate! */
cx231xx_uninit_isoc(dev); cx231xx_uninit_isoc(dev);
...@@ -2144,8 +2169,8 @@ static int cx231xx_v4l2_close(struct file *filp) ...@@ -2144,8 +2169,8 @@ static int cx231xx_v4l2_close(struct file *filp)
* will allocate buffers when called for the first time * will allocate buffers when called for the first time
*/ */
static ssize_t static ssize_t
cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, cx231xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
loff_t *pos) loff_t * pos)
{ {
struct cx231xx_fh *fh = filp->private_data; struct cx231xx_fh *fh = filp->private_data;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
...@@ -2155,8 +2180,8 @@ cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, ...@@ -2155,8 +2180,8 @@ cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
if (rc < 0) if (rc < 0)
return rc; return rc;
if ( (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) || if ((fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
(fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) ) { (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)) {
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
rc = res_get(fh); rc = res_get(fh);
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
...@@ -2191,8 +2216,8 @@ static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table * wait) ...@@ -2191,8 +2216,8 @@ static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table * wait)
if (unlikely(rc < 0)) if (unlikely(rc < 0))
return POLLERR; return POLLERR;
if ( (V4L2_BUF_TYPE_VIDEO_CAPTURE == fh->type) || if ((V4L2_BUF_TYPE_VIDEO_CAPTURE == fh->type) ||
(V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) ) (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type))
return videobuf_poll_stream(filp, &fh->vb_vidq, wait); return videobuf_poll_stream(filp, &fh->vb_vidq, wait);
else else
return POLLERR; return POLLERR;
...@@ -2222,8 +2247,8 @@ static int cx231xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -2222,8 +2247,8 @@ static int cx231xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
cx231xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n", cx231xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n",
(unsigned long)vma->vm_start, (unsigned long)vma->vm_start,
(unsigned long)vma->vm_end-(unsigned long)vma->vm_start, (unsigned long)vma->vm_end -
rc); (unsigned long)vma->vm_start, rc);
return rc; return rc;
} }
...@@ -2325,10 +2350,8 @@ static struct video_device cx231xx_radio_template = { ...@@ -2325,10 +2350,8 @@ static struct video_device cx231xx_radio_template = {
/******************************** usb interface ******************************/ /******************************** usb interface ******************************/
static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, const struct video_device
static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, *template, const char *type_name)
const struct video_device *template,
const char *type_name)
{ {
struct video_device *vfd; struct video_device *vfd;
...@@ -2341,8 +2364,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, ...@@ -2341,8 +2364,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
vfd->release = video_device_release; vfd->release = video_device_release;
vfd->debug = video_debug; vfd->debug = video_debug;
snprintf(vfd->name, sizeof(vfd->name), "%s %s", snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
dev->name, type_name);
return vfd; return vfd;
} }
...@@ -2356,10 +2378,11 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) ...@@ -2356,10 +2378,11 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
cx231xx_info("%s: v4l2 driver version %d.%d.%d\n", cx231xx_info("%s: v4l2 driver version %d.%d.%d\n",
dev->name, dev->name,
(CX231XX_VERSION_CODE >> 16) & 0xff, (CX231XX_VERSION_CODE >> 16) & 0xff,
(CX231XX_VERSION_CODE >> 8) & 0xff, CX231XX_VERSION_CODE & 0xff); (CX231XX_VERSION_CODE >> 8) & 0xff,
CX231XX_VERSION_CODE & 0xff);
/* set default norm */ /* set default norm */
/*dev->norm = cx231xx_video_template.current_norm;*/ /*dev->norm = cx231xx_video_template.current_norm; */
dev->width = norm_maxw(dev); dev->width = norm_maxw(dev);
dev->height = norm_maxh(dev); dev->height = norm_maxh(dev);
dev->interlaced = 0; dev->interlaced = 0;
...@@ -2388,7 +2411,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) ...@@ -2388,7 +2411,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
video_nr[dev->devno]); video_nr[dev->devno]);
if (ret) { 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; return ret;
} }
...@@ -2396,10 +2420,9 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) ...@@ -2396,10 +2420,9 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
dev->name, dev->vdev->num); dev->name, dev->vdev->num);
/* Initialize VBI template */ /* Initialize VBI template */
memcpy( &cx231xx_vbi_template, &cx231xx_video_template, memcpy(&cx231xx_vbi_template, &cx231xx_video_template,
sizeof(cx231xx_vbi_template) ); sizeof(cx231xx_vbi_template));
strcpy(cx231xx_vbi_template.name,"cx231xx-vbi"); strcpy(cx231xx_vbi_template.name, "cx231xx-vbi");
/* Allocate and fill vbi video_device struct */ /* Allocate and fill vbi video_device struct */
dev->vbi_dev = cx231xx_vdev_init(dev, &cx231xx_vbi_template, "vbi"); dev->vbi_dev = cx231xx_vdev_init(dev, &cx231xx_vbi_template, "vbi");
...@@ -2416,7 +2439,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) ...@@ -2416,7 +2439,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
dev->name, dev->vbi_dev->num); dev->name, dev->vbi_dev->num);
if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) { 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) { if (!dev->radio_dev) {
cx231xx_errdev("cannot allocate video_device.\n"); cx231xx_errdev("cannot allocate video_device.\n");
return -ENODEV; return -ENODEV;
...@@ -2436,5 +2460,3 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) ...@@ -2436,5 +2460,3 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
return 0; return 0;
} }
...@@ -82,17 +82,14 @@ ...@@ -82,17 +82,14 @@
*/ */
#define CX231XX_NUM_PACKETS 40 #define CX231XX_NUM_PACKETS 40
/* default alternate; 0 means choose the best */ /* default alternate; 0 means choose the best */
#define CX231XX_PINOUT 0 #define CX231XX_PINOUT 0
#define CX231XX_INTERLACED_DEFAULT 1 #define CX231XX_INTERLACED_DEFAULT 1
/* time to wait when stopping the isoc transfer */ /* time to wait when stopping the isoc transfer */
#define CX231XX_URB_TIMEOUT msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS) #define CX231XX_URB_TIMEOUT msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS)
enum cx231xx_mode { enum cx231xx_mode {
CX231XX_SUSPEND, CX231XX_SUSPEND,
CX231XX_ANALOG_MODE, CX231XX_ANALOG_MODE,
...@@ -143,12 +140,10 @@ struct cx231xx_usb_isoc_ctl { ...@@ -143,12 +140,10 @@ struct cx231xx_usb_isoc_ctl {
int nfields; int nfields;
/* isoc urb callback */ /* isoc urb callback */
int (*isoc_copy) (struct cx231xx *dev, struct urb *urb); int (*isoc_copy) (struct cx231xx * dev, struct urb * urb);
}; };
struct cx231xx_fmt { struct cx231xx_fmt {
char *name; char *name;
u32 fourcc; /* v4l2 format id */ u32 fourcc; /* v4l2 format id */
...@@ -184,7 +179,6 @@ struct cx231xx_dmaqueue { ...@@ -184,7 +179,6 @@ struct cx231xx_dmaqueue {
u32 lines_per_field; u32 lines_per_field;
}; };
/* inputs */ /* inputs */
#define MAX_CX231XX_INPUT 4 #define MAX_CX231XX_INPUT 4
...@@ -215,7 +209,7 @@ enum cx231xx_v_input { ...@@ -215,7 +209,7 @@ enum cx231xx_v_input {
/* cx231xx has two audio inputs: tuner and line in */ /* cx231xx has two audio inputs: tuner and line in */
enum cx231xx_amux { enum cx231xx_amux {
/* This is the only entry for cx231xx tuner input */ /* This is the only entry for cx231xx tuner input */
CX231XX_AMUX_VIDEO, /* cx231xx tuner*/ CX231XX_AMUX_VIDEO, /* cx231xx tuner */
CX231XX_AMUX_LINE_IN, /* Line In */ CX231XX_AMUX_LINE_IN, /* Line In */
}; };
...@@ -239,13 +233,12 @@ enum cx231xx_decoder { ...@@ -239,13 +233,12 @@ enum cx231xx_decoder {
CX231XX_AVDECODER CX231XX_AVDECODER
}; };
typedef enum _I2C_MASTER_PORT typedef enum _I2C_MASTER_PORT {
{ I2C_0 = 0,
I2C_0 =0, I2C_1 = 1,
I2C_1 =1, I2C_2 = 2,
I2C_2 =2, I2C_3 = 3
I2C_3 =3 } CX231XX_I2C_MASTER_PORT;
}CX231XX_I2C_MASTER_PORT;
struct cx231xx_board { struct cx231xx_board {
char *name; char *name;
...@@ -295,8 +288,7 @@ enum cx231xx_dev_state { ...@@ -295,8 +288,7 @@ enum cx231xx_dev_state {
DEV_MISCONFIGURED = 0x04, DEV_MISCONFIGURED = 0x04,
}; };
enum AFE_MODE enum AFE_MODE {
{
AFE_MODE_LOW_IF, AFE_MODE_LOW_IF,
AFE_MODE_BASEBAND, AFE_MODE_BASEBAND,
AFE_MODE_EU_HI_IF, AFE_MODE_EU_HI_IF,
...@@ -304,8 +296,7 @@ enum AFE_MODE ...@@ -304,8 +296,7 @@ enum AFE_MODE
AFE_MODE_JAPAN_HI_IF AFE_MODE_JAPAN_HI_IF
}; };
enum AUDIO_INPUT enum AUDIO_INPUT {
{
AUDIO_INPUT_MUTE, AUDIO_INPUT_MUTE,
AUDIO_INPUT_LINE, AUDIO_INPUT_LINE,
AUDIO_INPUT_TUNER_TV, AUDIO_INPUT_TUNER_TV,
...@@ -319,7 +310,6 @@ enum AUDIO_INPUT ...@@ -319,7 +310,6 @@ enum AUDIO_INPUT
#define CX231XX_STOP_AUDIO 0 #define CX231XX_STOP_AUDIO 0
#define CX231XX_START_AUDIO 1 #define CX231XX_START_AUDIO 1
/* cx231xx extensions */ /* cx231xx extensions */
#define CX231XX_AUDIO 0x10 #define CX231XX_AUDIO 0x10
#define CX231XX_DVB 0x20 #define CX231XX_DVB 0x20
...@@ -386,17 +376,16 @@ struct cx231xx_i2c { ...@@ -386,17 +376,16 @@ struct cx231xx_i2c {
u8 i2c_reserve; u8 i2c_reserve;
}; };
struct cx231xx_i2c_xfer_data{ struct cx231xx_i2c_xfer_data {
u8 dev_addr; u8 dev_addr;
u8 direction; /* 1 - IN, 0 - OUT */ u8 direction; /* 1 - IN, 0 - OUT */
u8 saddr_len; /* sub address len */ u8 saddr_len; /* sub address len */
u16 saddr_dat; /* sub addr data */ u16 saddr_dat; /* sub addr data */
u8 buf_size; /* buffer size */ u8 buf_size; /* buffer size */
u8* p_buffer; /* pointer to the buffer */ u8 *p_buffer; /* pointer to the buffer */
}; };
typedef struct _VENDOR_REQUEST_IN typedef struct _VENDOR_REQUEST_IN {
{
u8 bRequest; u8 bRequest;
u16 wValue; u16 wValue;
u16 wIndex; u16 wIndex;
...@@ -414,7 +403,7 @@ struct cx231xx_ctrl { ...@@ -414,7 +403,7 @@ struct cx231xx_ctrl {
u32 shift; u32 shift;
}; };
typedef enum{ typedef enum {
Raw_Video = 0, Raw_Video = 0,
Audio, Audio,
Vbi, /* VANC */ Vbi, /* VANC */
...@@ -422,7 +411,7 @@ typedef enum{ ...@@ -422,7 +411,7 @@ typedef enum{
TS1_serial_mode, TS1_serial_mode,
TS2, TS2,
TS1_parallel_mode TS1_parallel_mode
}TRANSFER_TYPE; } TRANSFER_TYPE;
struct cx231xx_video_mode { struct cx231xx_video_mode {
/* Isoc control struct */ /* Isoc control struct */
...@@ -438,7 +427,6 @@ struct cx231xx_video_mode { ...@@ -438,7 +427,6 @@ struct cx231xx_video_mode {
u16 end_point_addr; u16 end_point_addr;
}; };
/* main device struct */ /* main device struct */
struct cx231xx { struct cx231xx {
/* generic device properties */ /* generic device properties */
...@@ -506,21 +494,23 @@ struct cx231xx { ...@@ -506,21 +494,23 @@ struct cx231xx {
struct cx231xx_video_mode ts1_mode; struct cx231xx_video_mode ts1_mode;
struct usb_device *udev; /* the usb device */ struct usb_device *udev; /* the usb device */
char urb_buf[URB_MAX_CTRL_SIZE];/* urb control msg buffer */ char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
/* helper funcs that call usb_control_msg */ /* helper funcs that call usb_control_msg */
int (*cx231xx_read_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, int (*cx231xx_read_ctrl_reg) (struct cx231xx * dev, u8 req, u16 reg,
char *buf, int len); char *buf, int len);
int (*cx231xx_write_ctrl_reg)(struct cx231xx *dev, u8 req, u16 reg, int (*cx231xx_write_ctrl_reg) (struct cx231xx * dev, u8 req, u16 reg,
char *buf, int len); char *buf, int len);
int (*cx231xx_send_usb_command)(struct cx231xx_i2c *i2c_bus, int (*cx231xx_send_usb_command) (struct cx231xx_i2c * i2c_bus,
struct cx231xx_i2c_xfer_data *req_data); struct cx231xx_i2c_xfer_data *
int (*cx231xx_gpio_i2c_read)(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); req_data);
int (*cx231xx_gpio_i2c_write)(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); int (*cx231xx_gpio_i2c_read) (struct cx231xx * dev, u8 dev_addr,
u8 * buf, u8 len);
int (*cx231xx_gpio_i2c_write) (struct cx231xx * dev, u8 dev_addr,
u8 * buf, u8 len);
int (*cx231xx_set_analog_freq)(struct cx231xx *dev, u32 freq ) ; int (*cx231xx_set_analog_freq) (struct cx231xx * dev, u32 freq);
int (*cx231xx_reset_analog_tuner)(struct cx231xx *dev) ; int (*cx231xx_reset_analog_tuner) (struct cx231xx * dev);
enum cx231xx_mode mode; enum cx231xx_mode mode;
...@@ -555,27 +545,29 @@ struct cx231xx_ops { ...@@ -555,27 +545,29 @@ struct cx231xx_ops {
struct list_head next; struct list_head next;
char *name; char *name;
int id; int id;
int (*init)(struct cx231xx *); int (*init) (struct cx231xx *);
int (*fini)(struct cx231xx *); int (*fini) (struct cx231xx *);
}; };
/* call back functions in dvb module */ /* call back functions in dvb module */
int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq ) ; int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq);
int cx231xx_reset_analog_tuner(struct cx231xx *dev) ; int cx231xx_reset_analog_tuner(struct cx231xx *dev);
/* Provided by cx231xx-i2c.c */ /* Provided by cx231xx-i2c.c */
void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd, void *arg); void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd,
void *arg);
void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c); void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c);
int cx231xx_i2c_register(struct cx231xx_i2c *bus); int cx231xx_i2c_register(struct cx231xx_i2c *bus);
int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
/* Internal block control functions */ /* Internal block control functions */
int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr,
u16 saddr, u8 saddr_len, u32 *data, u8 data_len); u16 saddr, u8 saddr_len, u32 * data, u8 data_len);
int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr,
u16 saddr, u8 saddr_len, u32 data, u8 data_len); u16 saddr, u8 saddr_len, u32 data, u8 data_len);
int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, u16 register_address, int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size,
u8 bit_start,u8 bit_end, u32 value); u16 register_address, u8 bit_start, u8 bit_end,
u32 value);
int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr,
u16 saddr, u32 mask, u32 value); u16 saddr, u32 mask, u32 value);
u32 cx231xx_set_field(u32 field_mask, u32 data); u32 cx231xx_set_field(u32 field_mask, u32 data);
...@@ -602,17 +594,20 @@ int cx231xx_tuner_pre_channel_change(struct cx231xx *dev); ...@@ -602,17 +594,20 @@ int cx231xx_tuner_pre_channel_change(struct cx231xx *dev);
int cx231xx_tuner_post_channel_change(struct cx231xx *dev); int cx231xx_tuner_post_channel_change(struct cx231xx *dev);
/* video parser functions */ /* video parser functions */
u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used); u8 cx231xx_find_next_SAV_EAV(u8 * p_buffer, u32 buffer_size,
u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_used); u32 * p_bytes_used);
u8 cx231xx_find_boundary_SAV_EAV(u8 * p_buffer, u8 * partial_buf,
u32 * p_bytes_used);
int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 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);
void cx231xx_reset_video_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q); void cx231xx_reset_video_buffer(struct cx231xx *dev,
u8 cx231xx_is_buffer_done(struct cx231xx *dev,struct cx231xx_dmaqueue *dma_q); struct cx231xx_dmaqueue *dma_q);
u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q);
u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
u8 *p_line, u32 length, int field_number); u8 * p_line, u32 length, int field_number);
u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
u8 sav_eav, u8 *p_buffer, u32 buffer_size); u8 sav_eav, u8 * p_buffer, u32 buffer_size);
void cx231xx_swab(u16 *from, u16 *to, u16 len); void cx231xx_swab(u16 * from, u16 * to, u16 len);
/* Provided by cx231xx-core.c */ /* Provided by cx231xx-core.c */
...@@ -629,31 +624,33 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, ...@@ -629,31 +624,33 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
char *buf, int len); char *buf, int len);
int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode); int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode);
int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN *ven_req); int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN * ven_req);
int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus,
struct cx231xx_i2c_xfer_data *req_data); struct cx231xx_i2c_xfer_data *req_data);
/* Gpio related functions */ /* Gpio related functions */
int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val, int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val,
u8 len, u8 request, u8 direction); u8 len, u8 request, u8 direction);
int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val); int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val);
int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val); int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val);
int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value); int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value);
int cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number, int pin_value); int cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number,
int pin_value);
int cx231xx_gpio_i2c_start(struct cx231xx *dev); int cx231xx_gpio_i2c_start(struct cx231xx *dev);
int cx231xx_gpio_i2c_end(struct cx231xx *dev); int cx231xx_gpio_i2c_end(struct cx231xx *dev);
int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data); int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data);
int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf); int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 * buf);
int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev); int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev);
int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev); int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev);
int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev); int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev);
int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len);
int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len);
/* audio related functions */ /* audio related functions */
int cx231xx_set_audio_decoder_input(struct cx231xx *dev, enum AUDIO_INPUT audio_input); int cx231xx_set_audio_decoder_input(struct cx231xx *dev,
enum AUDIO_INPUT audio_input);
int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type); int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type);
int cx231xx_resolution_set(struct cx231xx *dev); int cx231xx_resolution_set(struct cx231xx *dev);
...@@ -661,7 +658,8 @@ int cx231xx_set_video_alternate(struct cx231xx *dev); ...@@ -661,7 +658,8 @@ int cx231xx_set_video_alternate(struct cx231xx *dev);
int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt); int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt);
int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
int num_bufs, int max_pkt_size, int num_bufs, int max_pkt_size,
int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)); int (*isoc_copy) (struct cx231xx * dev,
struct urb * urb));
void cx231xx_uninit_isoc(struct cx231xx *dev); void cx231xx_uninit_isoc(struct cx231xx *dev);
int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode); int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode);
int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio); int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio);
...@@ -695,7 +693,8 @@ int cx231xx_power_suspend(struct cx231xx *dev); ...@@ -695,7 +693,8 @@ int cx231xx_power_suspend(struct cx231xx *dev);
/* chip specific control functions */ /* chip specific control functions */
int cx231xx_init_ctrl_pin_status(struct cx231xx *dev); int cx231xx_init_ctrl_pin_status(struct cx231xx *dev);
int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, u8 analog_or_digital); int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev,
u8 analog_or_digital);
int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex); int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex);
/* video audio decoder related functions */ /* video audio decoder related functions */
...@@ -743,7 +742,6 @@ int cx231xx_ir_fini(struct cx231xx *dev); ...@@ -743,7 +742,6 @@ int cx231xx_ir_fini(struct cx231xx *dev);
printk(KERN_WARNING "%s: "fmt,\ printk(KERN_WARNING "%s: "fmt,\
dev->name , ##arg); } while (0) dev->name , ##arg); } while (0)
static inline unsigned int norm_maxw(struct cx231xx *dev) static inline unsigned int norm_maxw(struct cx231xx *dev)
{ {
if (dev->board.max_range_640_480) if (dev->board.max_range_640_480)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment