diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-03 06:14:34 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 21:44:01 -0300 |
commit | 84b5dbf39ed2f51224841bbbf08439158d69d427 (patch) | |
tree | b24963462dc1ad93860645d8729d1ddfc6ce526e | |
parent | e0d3bafd02586cfde286c320f56906fd9fa8d256 (diff) |
V4L/DVB (10955): cx231xx: CodingStyle automatic fixes with Lindent
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-audio.c | 255 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-avcore.c | 4383 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-cards.c | 976 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-conf-reg.h | 132 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-core.c | 1126 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-dvb.c | 264 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-i2c.c | 567 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-input.c | 24 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-reg.h | 59 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-vbi.c | 555 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-vbi.h | 26 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-video.c | 1820 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx.h | 522 |
13 files changed, 5809 insertions, 4900 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-audio.c b/drivers/media/video/cx231xx/cx231xx-audio.c index e4335e2a410..cee64879c4f 100644 --- a/drivers/media/video/cx231xx/cx231xx-audio.c +++ b/drivers/media/video/cx231xx/cx231xx-audio.c @@ -58,21 +58,20 @@ static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) dprintk("Stopping isoc\n"); - for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { - if(dev->adev.urb[i]) { - if (!irqs_disabled()) - usb_kill_urb(dev->adev.urb[i]); - else - usb_unlink_urb(dev->adev.urb[i]); + if (dev->adev.urb[i]) { + if (!irqs_disabled()) + usb_kill_urb(dev->adev.urb[i]); + else + usb_unlink_urb(dev->adev.urb[i]); - usb_free_urb(dev->adev.urb[i]); - dev->adev.urb[i] = NULL; + usb_free_urb(dev->adev.urb[i]); + dev->adev.urb[i] = NULL; - kfree(dev->adev.transfer_buffer[i]); - dev->adev.transfer_buffer[i] = NULL; + kfree(dev->adev.transfer_buffer[i]); + dev->adev.transfer_buffer[i] = NULL; - } + } } return 0; @@ -80,27 +79,27 @@ static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) static void cx231xx_audio_isocirq(struct urb *urb) { - struct cx231xx *dev = urb->context; - int i; - unsigned int oldptr; - int period_elapsed = 0; - int status; - unsigned char *cp; - unsigned int stride; + struct cx231xx *dev = urb->context; + int i; + unsigned int oldptr; + int period_elapsed = 0; + int status; + unsigned char *cp; + unsigned int stride; struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - - switch (urb->status) { - case 0: /* success */ - case -ETIMEDOUT: /* NAK */ - break; - case -ECONNRESET: /* kill */ - case -ENOENT: - case -ESHUTDOWN: - return; - default: /* error */ - dprintk("urb completition error %d.\n", urb->status); - break; + struct snd_pcm_runtime *runtime; + + switch (urb->status) { + case 0: /* success */ + case -ETIMEDOUT: /* NAK */ + break; + case -ECONNRESET: /* kill */ + case -ENOENT: + case -ESHUTDOWN: + return; + default: /* error */ + dprintk("urb completition error %d.\n", urb->status); + break; } if (dev->adev.capture_pcm_substream) { @@ -145,7 +144,6 @@ static void cx231xx_audio_isocirq(struct urb *urb) runtime->period_size; period_elapsed = 1; } - snd_pcm_stream_unlock(substream); } if (period_elapsed) @@ -156,19 +154,19 @@ static void cx231xx_audio_isocirq(struct urb *urb) status = usb_submit_urb(urb, GFP_ATOMIC); if (status < 0) { cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", - status); + status); } return; } static int cx231xx_init_audio_isoc(struct cx231xx *dev) { - int i, errCode; - int sb_size; + int i, errCode; + 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; for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { struct urb *urb; @@ -191,7 +189,8 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) urb->dev = dev->udev; 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_buffer = dev->adev.transfer_buffer[i]; urb->interval = 1; @@ -200,10 +199,9 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) urb->transfer_buffer_length = sb_size; 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].length = - dev->adev.max_pkt_size; + urb->iso_frame_desc[j].length = dev->adev.max_pkt_size; } dev->adev.urb[i] = urb; } @@ -221,11 +219,11 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) static int cx231xx_cmd(struct cx231xx *dev, int cmd, int arg) { - dprintk("%s transfer\n", (dev->adev.capture_stream == STREAM_ON)? - "stop" : "start"); + dprintk("%s transfer\n", (dev->adev.capture_stream == STREAM_ON) ? + "stop" : "start"); switch (cmd) { - case CX231XX_CAPTURE_STREAM_EN: + case CX231XX_CAPTURE_STREAM_EN: if (dev->adev.capture_stream == STREAM_OFF && arg == 1) { dev->adev.capture_stream = STREAM_ON; cx231xx_init_audio_isoc(dev); @@ -233,8 +231,8 @@ static int cx231xx_cmd(struct cx231xx *dev, int cmd, int arg) dev->adev.capture_stream = STREAM_OFF; cx231xx_isoc_audio_deinit(dev); } else { - cx231xx_errdev( "An underrun very likely occurred. " - "Ignoring it.\n"); + cx231xx_errdev("An underrun very likely occurred. " + "Ignoring it.\n"); } return 0; default: @@ -265,9 +263,8 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, static struct snd_pcm_hardware snd_cx231xx_hw_capture = { .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_MMAP_VALID, + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID, .formats = SNDRV_PCM_FMTBIT_S16_LE, @@ -278,10 +275,10 @@ static struct snd_pcm_hardware snd_cx231xx_hw_capture = { .channels_min = 2, .channels_max = 2, .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */ - .period_bytes_min = 64, /* 12544/2, */ + .period_bytes_min = 64, /* 12544/2, */ .period_bytes_max = 12544, .periods_min = 2, - .periods_max = 98, /* 12544, */ + .periods_max = 98, /* 12544, */ }; static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream) @@ -294,29 +291,29 @@ static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream) if (!dev) { cx231xx_errdev("BUG: cx231xx can't find device struct." - " Can't proceed with open\n"); + " Can't proceed with open\n"); return -ENODEV; } /* Sets volume, mute, etc */ dev->mute = 0; - /* set alternate setting for audio interface */ - ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 1); /* 1 - 48000 samples per sec */ - if (ret < 0) { - cx231xx_errdev("failed to set alternate setting !\n"); + /* set alternate setting for audio interface */ + ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 1); /* 1 - 48000 samples per sec */ + if (ret < 0) { + cx231xx_errdev("failed to set alternate setting !\n"); - return ret; - } + return ret; + } - /* inform hardware to start streaming */ - ret = cx231xx_capture_start(dev, 1, Audio); + /* inform hardware to start streaming */ + ret = cx231xx_capture_start(dev, 1, Audio); runtime->hw = snd_cx231xx_hw_capture; - mutex_lock(&dev->lock); + mutex_lock(&dev->lock); dev->adev.users++; - mutex_unlock(&dev->lock); + mutex_unlock(&dev->lock); snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); dev->adev.capture_pcm_substream = substream; @@ -327,26 +324,25 @@ static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream) static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) { - int ret; + int ret; struct cx231xx *dev = snd_pcm_substream_chip(substream); - dprintk("closing device\n"); - /* set alternate setting for audio interface */ - ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); /* 1 - 48000 samples per sec */ - if (ret < 0) { - cx231xx_errdev("failed to set alternate setting !\n"); + /* set alternate setting for audio interface */ + ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); /* 1 - 48000 samples per sec */ + if (ret < 0) { + cx231xx_errdev("failed to set alternate setting !\n"); - return ret; - } + return ret; + } - /* inform hardware to start streaming */ - ret = cx231xx_capture_start(dev, 0, Audio); + /* inform hardware to start streaming */ + ret = cx231xx_capture_start(dev, 0, Audio); dev->mute = 1; mutex_lock(&dev->lock); - dev->adev.users--; + dev->adev.users--; mutex_unlock(&dev->lock); if (dev->adev.users == 0 && dev->adev.shutdown == 1) { @@ -360,7 +356,7 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) } static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) + struct snd_pcm_hw_params *hw_params) { unsigned int channels, rate, format; int ret; @@ -368,7 +364,7 @@ static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream, dprintk("Setting capture parameters\n"); ret = snd_pcm_alloc_vmalloc_buffer(substream, - params_buffer_bytes(hw_params)); + params_buffer_bytes(hw_params)); format = params_format(hw_params); rate = params_rate(hw_params); channels = params_channels(hw_params); @@ -397,45 +393,45 @@ static int snd_cx231xx_prepare(struct snd_pcm_substream *substream) } static int snd_cx231xx_capture_trigger(struct snd_pcm_substream *substream, - int cmd) + int cmd) { struct cx231xx *dev = snd_pcm_substream_chip(substream); - int retval; + int retval; + dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START) ? + "start" : "stop"); - dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START)? - "start": "stop"); - - spin_lock(&dev->adev.slock); + spin_lock(&dev->adev.slock); switch (cmd) { 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; break; case SNDRV_PCM_TRIGGER_STOP: - cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN, CX231XX_STOP_AUDIO); + cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN, CX231XX_STOP_AUDIO); retval = 0; - break; + break; default: retval = -EINVAL; } - spin_unlock(&dev->adev.slock); + spin_unlock(&dev->adev.slock); return retval; } static snd_pcm_uframes_t snd_cx231xx_capture_pointer(struct snd_pcm_substream - *substream) + *substream) { struct cx231xx *dev; - unsigned long flags; + unsigned long flags; snd_pcm_uframes_t hwptr_done; dev = snd_pcm_substream_chip(substream); - spin_lock_irqsave(&dev->adev.slock, flags); + spin_lock_irqsave(&dev->adev.slock, flags); hwptr_done = dev->adev.hwptr_done_capture; - spin_unlock_irqrestore(&dev->adev.slock, flags); + spin_unlock_irqrestore(&dev->adev.slock, flags); return hwptr_done; } @@ -449,26 +445,26 @@ static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, } static struct snd_pcm_ops snd_cx231xx_pcm_capture = { - .open = snd_cx231xx_capture_open, - .close = snd_cx231xx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, + .open = snd_cx231xx_capture_open, + .close = snd_cx231xx_pcm_close, + .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cx231xx_hw_capture_params, - .hw_free = snd_cx231xx_hw_capture_free, - .prepare = snd_cx231xx_prepare, - .trigger = snd_cx231xx_capture_trigger, - .pointer = snd_cx231xx_capture_pointer, - .page = snd_pcm_get_vmalloc_page, + .hw_free = snd_cx231xx_hw_capture_free, + .prepare = snd_cx231xx_prepare, + .trigger = snd_cx231xx_capture_trigger, + .pointer = snd_cx231xx_capture_pointer, + .page = snd_pcm_get_vmalloc_page, }; static int cx231xx_audio_init(struct cx231xx *dev) { struct cx231xx_audio *adev = &dev->adev; - struct snd_pcm *pcm; - struct snd_card *card; - static int devnr; - int err; - struct usb_interface *uif; - int i, isoc_pipe = 0; + struct snd_pcm *pcm; + struct snd_card *card; + static int devnr; + int err; + struct usb_interface *uif; + int i, isoc_pipe = 0; if (dev->has_alsa_audio != 1) { /* This device does not support the extension (in this case @@ -478,7 +474,7 @@ static int cx231xx_audio_init(struct cx231xx *dev) } cx231xx_info("cx231xx-audio.c: probing for cx231xx " - "non standard usbaudio\n"); + "non standard usbaudio\n"); card = snd_card_new(index[devnr], "Cx231xx Audio", THIS_MODULE, 0); if (card == NULL) { @@ -492,7 +488,8 @@ static int cx231xx_audio_init(struct cx231xx *dev) 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->private_data = dev; strcpy(pcm->name, "Conexant cx231xx Capture"); @@ -508,29 +505,35 @@ static int cx231xx_audio_init(struct cx231xx *dev) adev->sndcard = card; adev->udev = dev->udev; - /* 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]; + /* 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]; - 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; - cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", adev->end_point_addr, - adev->num_alt); - adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); + adev->num_alt = uif->num_altsetting; + cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", + adev->end_point_addr, adev->num_alt); + adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); - if (adev->alt_max_pkt_size == NULL) { - cx231xx_errdev("out of memory!\n"); - return -ENOMEM; - } + if (adev->alt_max_pkt_size == NULL) { + cx231xx_errdev("out of memory!\n"); + return -ENOMEM; + } - for (i = 0; i < adev->num_alt ; i++) { - u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. - wMaxPacketSize); - adev->alt_max_pkt_size[i] = - (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); - cx231xx_info("Alternate setting %i, max size= %i\n", i, - adev->alt_max_pkt_size[i]); - } + for (i = 0; i < adev->num_alt; i++) { + u16 tmp = + le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. + wMaxPacketSize); + adev->alt_max_pkt_size[i] = + (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); + cx231xx_info("Alternate setting %i, max size= %i\n", i, + adev->alt_max_pkt_size[i]); + } return 0; } @@ -549,7 +552,7 @@ static int cx231xx_audio_fini(struct cx231xx *dev) if (dev->adev.sndcard) { snd_card_free(dev->adev.sndcard); - kfree(dev->adev.alt_max_pkt_size); + kfree(dev->adev.alt_max_pkt_size); dev->adev.sndcard = NULL; } @@ -557,7 +560,7 @@ static int cx231xx_audio_fini(struct cx231xx *dev) } static struct cx231xx_ops audio_ops = { - .id = CX231XX_AUDIO, + .id = CX231XX_AUDIO, .name = "Cx231xx Audio Extension", .init = cx231xx_audio_init, .fini = cx231xx_audio_fini, diff --git a/drivers/media/video/cx231xx/cx231xx-avcore.c b/drivers/media/video/cx231xx/cx231xx-avcore.c index b5597337966..3c09b947384 100644 --- a/drivers/media/video/cx231xx/cx231xx-avcore.c +++ b/drivers/media/video/cx231xx/cx231xx-avcore.c @@ -38,115 +38,180 @@ #include "cx231xx.h" - /************************************************************************************* * C O L I B R I - B L O C K C O N T R O L functions * *************************************************************************************/ int cx231xx_colibri_init_super_block(struct cx231xx *dev, u32 ref_count) { - int status = 0; - u8 temp = 0; - u32 colibri_power_status = 0; - int i = 0; - - /* super block initialize */ - temp = (u8)(ref_count & 0xff); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE2, 2, temp, 1); - - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE2, 2, &colibri_power_status, 1); - - temp = (u8)((ref_count & 0x300) >> 8); - temp |= 0x40; - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE1, 2, temp, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_PLL2, 2, 0x0f, 1); - - /* enable pll */ - while(colibri_power_status != 0x18) - { - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_PWRDN, 2, 0x18, 1); - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_PWRDN, 2, &colibri_power_status, 1); - colibri_power_status &= 0xff; - if(status < 0) { - cx231xx_info(": Init Super Block failed in sending/receiving cmds\n"); - break; - } - i++; - if( i == 10) { - cx231xx_info(": Init Super Block force break in loop !!!!\n"); - status = -1; - break; - } - } - - if(status < 0 ) - return status; - - /* start tuning filter */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE3, 2, 0x40, 1); - msleep(5); - - /* exit tuning */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE3, 2, 0x00, 1); - - return status; + int status = 0; + u8 temp = 0; + u32 colibri_power_status = 0; + int i = 0; + + /* super block initialize */ + temp = (u8) (ref_count & 0xff); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE2, + 2, temp, 1); + + status = + cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE2, 2, + &colibri_power_status, 1); + + temp = (u8) ((ref_count & 0x300) >> 8); + temp |= 0x40; + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE1, + 2, temp, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_PLL2, 2, + 0x0f, 1); + + /* enable pll */ + while (colibri_power_status != 0x18) { + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + SUP_BLK_PWRDN, 2, 0x18, 1); + status = + cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, + SUP_BLK_PWRDN, 2, + &colibri_power_status, 1); + colibri_power_status &= 0xff; + if (status < 0) { + cx231xx_info + (": Init Super Block failed in sending/receiving cmds\n"); + break; + } + i++; + if (i == 10) { + cx231xx_info + (": Init Super Block force break in loop !!!!\n"); + status = -1; + break; + } + } + + if (status < 0) + return status; + + /* start tuning filter */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE3, + 2, 0x40, 1); + msleep(5); + + /* exit tuning */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, SUP_BLK_TUNE3, + 2, 0x00, 1); + + return status; } int cx231xx_colibri_init_channels(struct cx231xx *dev) { - int status = 0; - - /* power up all 3 channels, clear pd_buffer */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_PWRDN_CLAMP_CH1, 2, 0x00, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_PWRDN_CLAMP_CH2, 2, 0x00, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_PWRDN_CLAMP_CH3, 2, 0x00, 1); - - /* Enable quantizer calibration */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_COM_QUANT, 2, 0x02, 1); - - /* channel initialize, force modulator (fb) reset */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_FB_FRCRST_CH1, 2, 0x17, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_FB_FRCRST_CH2, 2, 0x17, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_FB_FRCRST_CH3, 2, 0x17, 1); - - /* start quantilizer calibration */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_CAL_ATEST_CH1, 2, 0x10, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_CAL_ATEST_CH2, 2, 0x10, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_CAL_ATEST_CH3, 2, 0x10, 1); - msleep(5); - - /* exit modulator (fb) reset */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_FB_FRCRST_CH1, 2, 0x07, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_FB_FRCRST_CH2, 2, 0x07, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_FB_FRCRST_CH3, 2, 0x07, 1); - - /* enable the pre_clamp in each channel for single-ended input */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_NTF_PRECLMP_EN_CH1, 2, 0xf0, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_NTF_PRECLMP_EN_CH2, 2, 0xf0, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_NTF_PRECLMP_EN_CH3, 2, 0xf0, 1); - - /* use diode instead of resistor, so set term_en to 0, res_en to 0 */ - status = cx231xx_reg_mask_write(dev, Colibri_DEVICE_ADDRESS, 8, ADC_QGAIN_RES_TRM_CH1, 3, 7, 0x00); - status = cx231xx_reg_mask_write(dev, Colibri_DEVICE_ADDRESS, 8, ADC_QGAIN_RES_TRM_CH2, 3, 7, 0x00); - status = cx231xx_reg_mask_write(dev, Colibri_DEVICE_ADDRESS, 8, ADC_QGAIN_RES_TRM_CH3, 3, 7, 0x00); - - /* dynamic element matching off */ - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_DCSERVO_DEM_CH1, 2, 0x03, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_DCSERVO_DEM_CH2, 2, 0x03, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_DCSERVO_DEM_CH3, 2, 0x03, 1); - - return status; + int status = 0; + + /* power up all 3 channels, clear pd_buffer */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_PWRDN_CLAMP_CH1, 2, 0x00, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_PWRDN_CLAMP_CH2, 2, 0x00, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_PWRDN_CLAMP_CH3, 2, 0x00, 1); + + /* Enable quantizer calibration */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_COM_QUANT, + 2, 0x02, 1); + + /* channel initialize, force modulator (fb) reset */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_FB_FRCRST_CH1, 2, 0x17, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_FB_FRCRST_CH2, 2, 0x17, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_FB_FRCRST_CH3, 2, 0x17, 1); + + /* start quantilizer calibration */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_CAL_ATEST_CH1, 2, 0x10, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_CAL_ATEST_CH2, 2, 0x10, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_CAL_ATEST_CH3, 2, 0x10, 1); + msleep(5); + + /* exit modulator (fb) reset */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_FB_FRCRST_CH1, 2, 0x07, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_FB_FRCRST_CH2, 2, 0x07, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_FB_FRCRST_CH3, 2, 0x07, 1); + + /* enable the pre_clamp in each channel for single-ended input */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_NTF_PRECLMP_EN_CH1, 2, 0xf0, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_NTF_PRECLMP_EN_CH2, 2, 0xf0, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_NTF_PRECLMP_EN_CH3, 2, 0xf0, 1); + + /* use diode instead of resistor, so set term_en to 0, res_en to 0 */ + status = + cx231xx_reg_mask_write(dev, Colibri_DEVICE_ADDRESS, 8, + ADC_QGAIN_RES_TRM_CH1, 3, 7, 0x00); + status = + cx231xx_reg_mask_write(dev, Colibri_DEVICE_ADDRESS, 8, + ADC_QGAIN_RES_TRM_CH2, 3, 7, 0x00); + status = + cx231xx_reg_mask_write(dev, Colibri_DEVICE_ADDRESS, 8, + ADC_QGAIN_RES_TRM_CH3, 3, 7, 0x00); + + /* dynamic element matching off */ + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_DCSERVO_DEM_CH1, 2, 0x03, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_DCSERVO_DEM_CH2, 2, 0x03, 1); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_DCSERVO_DEM_CH3, 2, 0x03, 1); + + return status; } int cx231xx_colibri_setup_AFE_for_baseband(struct cx231xx *dev) { - u32 c_value = 0; - int status = 0; + u32 c_value = 0; + int status = 0; - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_PWRDN_CLAMP_CH2, 2, &c_value, 1); - c_value &= (~(0x50)); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_PWRDN_CLAMP_CH2, 2, c_value, 1); + status = + cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_PWRDN_CLAMP_CH2, 2, &c_value, 1); + c_value &= (~(0x50)); + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_PWRDN_CLAMP_CH2, 2, c_value, 1); - return status; + return status; } /* @@ -157,559 +222,802 @@ int cx231xx_colibri_setup_AFE_for_baseband(struct cx231xx *dev) */ int cx231xx_colibri_set_input_mux(struct cx231xx *dev, u32 input_mux) { - u8 ch1_setting = (u8)input_mux; - u8 ch2_setting = (u8)(input_mux >> 8); - u8 ch3_setting = (u8)(input_mux >> 16); - int status = 0; - u32 value = 0; - - if(ch1_setting != 0) - { - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_INPUT_CH1, 2, &value, 1); - value &= (!INPUT_SEL_MASK); - value |= (ch1_setting-1)<<4; - value &= 0xff; - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_INPUT_CH1, 2, value, 1); - } - - if(ch2_setting != 0) - { - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_INPUT_CH2, 2, &value, 1); - value &= (!INPUT_SEL_MASK); - value |= (ch2_setting-1)<<4; - value &= 0xff; - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_INPUT_CH2, 2, value, 1); - } - - /* For ch3_setting, the value to put in the register is 7 less than the input number */ - if(ch3_setting != 0) - { - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_INPUT_CH3, 2, &value, 1); - value &= (!INPUT_SEL_MASK); - value |= (ch3_setting-1)<<4; - value &= 0xff; - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, ADC_INPUT_CH3, 2, value, 1); - } - - return status; + u8 ch1_setting = (u8) input_mux; + u8 ch2_setting = (u8) (input_mux >> 8); + u8 ch3_setting = (u8) (input_mux >> 16); + int status = 0; + u32 value = 0; + + if (ch1_setting != 0) { + status = + cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_INPUT_CH1, 2, &value, 1); + value &= (!INPUT_SEL_MASK); + value |= (ch1_setting - 1) << 4; + value &= 0xff; + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_INPUT_CH1, 2, value, 1); + } + + if (ch2_setting != 0) { + status = + cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_INPUT_CH2, 2, &value, 1); + value &= (!INPUT_SEL_MASK); + value |= (ch2_setting - 1) << 4; + value &= 0xff; + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_INPUT_CH2, 2, value, 1); + } + + /* For ch3_setting, the value to put in the register is 7 less than the input number */ + if (ch3_setting != 0) { + status = + cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_INPUT_CH3, 2, &value, 1); + value &= (!INPUT_SEL_MASK); + value |= (ch3_setting - 1) << 4; + value &= 0xff; + status = + cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, + ADC_INPUT_CH3, 2, value, 1); + } + + return status; } int cx231xx_colibri_set_mode(struct cx231xx *dev, enum AFE_MODE mode) { - int status = 0; - - switch(mode) { - case AFE_MODE_LOW_IF: - /* SetupAFEforLowIF(); */ - break; - case AFE_MODE_BASEBAND: - status = cx231xx_colibri_setup_AFE_for_baseband(dev); - break; - case AFE_MODE_EU_HI_IF: - /* SetupAFEforEuHiIF(); */ - break; - case AFE_MODE_US_HI_IF: - /* SetupAFEforUsHiIF(); */ - break; - case AFE_MODE_JAPAN_HI_IF: - /* SetupAFEforJapanHiIF(); */ - break; - } - - if((mode != dev->colibri_mode) && (dev->video_input == CX231XX_VMUX_TELEVISION)) { - status = cx231xx_colibri_adjust_ref_count(dev, CX231XX_VMUX_TELEVISION); - } - - dev->colibri_mode = mode; - - return status; + int status = 0; + + switch (mode) { + case AFE_MODE_LOW_IF: + /* SetupAFEforLowIF(); */ + break; + case AFE_MODE_BASEBAND: + status = cx231xx_colibri_setup_AFE_for_baseband(dev); + break; + case AFE_MODE_EU_HI_IF: + /* SetupAFEforEuHiIF(); */ + break; + case AFE_MODE_US_HI_IF: + /* SetupAFEforUsHiIF(); */ + break; + case AFE_MODE_JAPAN_HI_IF: + /* SetupAFEforJapanHiIF(); */ + break; + } + + if ((mode != dev->colibri_mode) + && (dev->video_input == CX231XX_VMUX_TELEVISION)) { + status = + cx231xx_colibri_adjust_ref_count(dev, + CX231XX_VMUX_TELEVISION); + } + + dev->colibri_mode = mode; + + return status; } /* For power saving in the EVK */ int cx231xx_colibri_update_power_control(struct cx231xx *dev, AV_MODE avmode) { - u32 colibri_power_status = 0; - int status = 0; - - switch (dev->model) { - case CX231XX_BOARD_CNXT_RDE_250: - case CX231XX_BOARD_CNXT_RDU_250: - - if(avmode==POLARIS_AVMODE_ANALOGT_TV) - { - while(colibri_power_status != 0x18) { - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - SUP_BLK_PWRDN, 2, 0x18, 1); - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, - SUP_BLK_PWRDN, 2, &colibri_power_status, 1); - if(status < 0 ) - break; - } - - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - ADC_PWRDN_CLAMP_CH1, 2, 0x00, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - ADC_PWRDN_CLAMP_CH2, 2, 0x00, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - ADC_PWRDN_CLAMP_CH3, 2, 0x00, 1); - } - else if(avmode==POLARIS_AVMODE_DIGITAL) { - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - ADC_PWRDN_CLAMP_CH1, 2, 0x70, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - ADC_PWRDN_CLAMP_CH2, 2, 0x70, 1); - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - ADC_PWRDN_CLAMP_CH3, 2, 0x70, 1); - - status = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS, - SUP_BLK_PWRDN, 2, &colibri_power_status, 1); - colibri_power_status |=0x07; - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - SUP_BLK_PWRDN, 2, colibri_power_status, 1); - } - else if(avmode==POLARIS_AVMODE_ENXTERNAL_AV) { - - while(colibri_power_status != 0x18) { - status = cx231xx_write_i2c_data(dev, Colibri_DEVICE_ADDRESS, - |