Commit 399426ca authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] cx88: make checkpatch.pl happy

Usually, I don't like fixing coding style issues on non-staging
drivers, as it could be a mess pretty easy, and could become like
a snow ball. That's the case of recent changes on two changesets:
they disalign some statements. Yet, a care a lot with cx88 driver,
as it was the first driver I touched at the Kernel, and I've been
maintaining it since 2005. So, several of the coding style issues
were due to my code.

Per Andrey's suggestion, I ran checkpatch.pl in strict mode, with
fixed several other issues, did some function alinments, but broke
other alinments.

So, I had to manually apply another round of manual fixes to make
sure that everything is ok, and to make checkpatch happy with
this patch.

With this patch, checkpatch.pl is now happy when called with:
	./scripts/checkpatch.pl -f --max-line-length=998 --ignore PREFER_PR_LEVEL

Also, the 80-cols violations that made sense were fixed.

Checkpatch would be happier if we convert it to use dev_foo(),
but this is a more complex change.

NOTE: there are some places with msleep(1). As this driver was
written at the time that the default was to sleep at least 10ms
on such calls (e. g. CONFIG_HZ=100), I replaced those calls by
usleep_range(10000, 20000), with should be safe to avoid breakages.

Fixes: 65bc2fe8 ("[media] cx88: convert it to use pr_foo() macros")
Fixes: 7b61ba8f ("[media] cx88: make checkpatch happier")
Suggested-by: default avatarAndrey Utkin <andrey_utkin@fastmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
Reviewed-by: default avatarAndrey Utkin <andrey_utkin@fastmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 1d389714
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -31,7 +32,6 @@ ...@@ -31,7 +32,6 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/delay.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
chip->core->name, ##arg); \ chip->core->name, ##arg); \
} while (0) } while (0)
/**************************************************************************** /*
Data type declarations - Can be moded to a header file later * Data type declarations - Can be moded to a header file later
****************************************************************************/ */
struct cx88_audio_buffer { struct cx88_audio_buffer {
unsigned int bpl; unsigned int bpl;
...@@ -82,13 +82,10 @@ struct cx88_audio_dev { ...@@ -82,13 +82,10 @@ struct cx88_audio_dev {
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
}; };
typedef struct cx88_audio_dev snd_cx88_card_t;
/**************************************************************************** /*
Module global static vars * Module global static vars
****************************************************************************/ */
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
static const char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static const char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
...@@ -100,10 +97,9 @@ MODULE_PARM_DESC(enable, "Enable cx88x soundcard. default enabled."); ...@@ -100,10 +97,9 @@ MODULE_PARM_DESC(enable, "Enable cx88x soundcard. default enabled.");
module_param_array(index, int, NULL, 0444); module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for cx88x capture interface(s)."); MODULE_PARM_DESC(index, "Index value for cx88x capture interface(s).");
/*
/**************************************************************************** * Module macros
Module macros */
****************************************************************************/
MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards"); MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards");
MODULE_AUTHOR("Ricardo Cerqueira"); MODULE_AUTHOR("Ricardo Cerqueira");
...@@ -116,15 +112,15 @@ static unsigned int debug; ...@@ -116,15 +112,15 @@ static unsigned int debug;
module_param(debug, int, 0644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "enable debug messages"); MODULE_PARM_DESC(debug, "enable debug messages");
/**************************************************************************** /*
Module specific funtions * Module specific functions
****************************************************************************/ */
/* /*
* BOARD Specific: Sets audio DMA * BOARD Specific: Sets audio DMA
*/ */
static int _cx88_start_audio_dma(snd_cx88_card_t *chip) static int _cx88_start_audio_dma(struct cx88_audio_dev *chip)
{ {
struct cx88_audio_buffer *buf = chip->buf; struct cx88_audio_buffer *buf = chip->buf;
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
...@@ -143,8 +139,9 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip) ...@@ -143,8 +139,9 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
cx_write(MO_AUDD_GPCNTRL, GP_COUNT_CONTROL_RESET); cx_write(MO_AUDD_GPCNTRL, GP_COUNT_CONTROL_RESET);
atomic_set(&chip->count, 0); atomic_set(&chip->count, 0);
dprintk(1, "Start audio DMA, %d B/line, %d lines/FIFO, %d periods, %d byte buffer\n", dprintk(1,
buf->bpl, cx_read(audio_ch->cmds_start + 8)>>1, "Start audio DMA, %d B/line, %d lines/FIFO, %d periods, %d byte buffer\n",
buf->bpl, cx_read(audio_ch->cmds_start + 8) >> 1,
chip->num_periods, buf->bpl * chip->num_periods); chip->num_periods, buf->bpl * chip->num_periods);
/* Enables corresponding bits at AUD_INT_STAT */ /* Enables corresponding bits at AUD_INT_STAT */
...@@ -158,8 +155,11 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip) ...@@ -158,8 +155,11 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
cx_set(MO_PCI_INTMSK, chip->core->pci_irqmask | PCI_INT_AUDINT); cx_set(MO_PCI_INTMSK, chip->core->pci_irqmask | PCI_INT_AUDINT);
/* start dma */ /* start dma */
cx_set(MO_DEV_CNTRL2, (1<<5)); /* Enables Risc Processor */
cx_set(MO_AUD_DMACNTRL, 0x11); /* audio downstream FIFO and RISC enable */ /* Enables Risc Processor */
cx_set(MO_DEV_CNTRL2, (1 << 5));
/* audio downstream FIFO and RISC enable */
cx_set(MO_AUD_DMACNTRL, 0x11);
if (debug) if (debug)
cx88_sram_channel_dump(chip->core, audio_ch); cx88_sram_channel_dump(chip->core, audio_ch);
...@@ -170,7 +170,7 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip) ...@@ -170,7 +170,7 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
/* /*
* BOARD Specific: Resets audio DMA * BOARD Specific: Resets audio DMA
*/ */
static int _cx88_stop_audio_dma(snd_cx88_card_t *chip) static int _cx88_stop_audio_dma(struct cx88_audio_dev *chip)
{ {
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
...@@ -185,7 +185,8 @@ static int _cx88_stop_audio_dma(snd_cx88_card_t *chip) ...@@ -185,7 +185,8 @@ static int _cx88_stop_audio_dma(snd_cx88_card_t *chip)
AUD_INT_DN_RISCI2 | AUD_INT_DN_RISCI1); AUD_INT_DN_RISCI2 | AUD_INT_DN_RISCI1);
if (debug) if (debug)
cx88_sram_channel_dump(chip->core, &cx88_sram_channels[SRAM_CH25]); cx88_sram_channel_dump(chip->core,
&cx88_sram_channels[SRAM_CH25]);
return 0; return 0;
} }
...@@ -211,7 +212,7 @@ static const char *cx88_aud_irqs[32] = { ...@@ -211,7 +212,7 @@ static const char *cx88_aud_irqs[32] = {
/* /*
* BOARD Specific: Threats IRQ audio specific calls * BOARD Specific: Threats IRQ audio specific calls
*/ */
static void cx8801_aud_irq(snd_cx88_card_t *chip) static void cx8801_aud_irq(struct cx88_audio_dev *chip)
{ {
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
u32 status, mask; u32 status, mask;
...@@ -249,7 +250,7 @@ static void cx8801_aud_irq(snd_cx88_card_t *chip) ...@@ -249,7 +250,7 @@ static void cx8801_aud_irq(snd_cx88_card_t *chip)
*/ */
static irqreturn_t cx8801_irq(int irq, void *dev_id) static irqreturn_t cx8801_irq(int irq, void *dev_id)
{ {
snd_cx88_card_t *chip = dev_id; struct cx88_audio_dev *chip = dev_id;
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
u32 status; u32 status;
int loop, handled = 0; int loop, handled = 0;
...@@ -286,26 +287,25 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages) ...@@ -286,26 +287,25 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages)
int i; int i;
buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
if (buf->vaddr == NULL) { if (!buf->vaddr) {
dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
return -ENOMEM; return -ENOMEM;
} }
dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n", dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n",
(unsigned long)buf->vaddr, (unsigned long)buf->vaddr, nr_pages << PAGE_SHIFT);
nr_pages << PAGE_SHIFT);
memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
buf->nr_pages = nr_pages; buf->nr_pages = nr_pages;
buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
if (buf->sglist == NULL) if (!buf->sglist)
goto vzalloc_err; goto vzalloc_err;
sg_init_table(buf->sglist, buf->nr_pages); sg_init_table(buf->sglist, buf->nr_pages);
for (i = 0; i < buf->nr_pages; i++) { for (i = 0; i < buf->nr_pages; i++) {
pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE); pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE);
if (pg == NULL) if (!pg)
goto vmalloc_to_page_err; goto vmalloc_to_page_err;
sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0); sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0);
} }
...@@ -341,7 +341,8 @@ static int cx88_alsa_dma_unmap(struct cx88_audio_dev *dev) ...@@ -341,7 +341,8 @@ static int cx88_alsa_dma_unmap(struct cx88_audio_dev *dev)
if (!buf->sglen) if (!buf->sglen)
return 0; return 0;
dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE); dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen,
PCI_DMA_FROMDEVICE);
buf->sglen = 0; buf->sglen = 0;
return 0; return 0;
} }
...@@ -355,18 +356,18 @@ static int cx88_alsa_dma_free(struct cx88_audio_buffer *buf) ...@@ -355,18 +356,18 @@ static int cx88_alsa_dma_free(struct cx88_audio_buffer *buf)
return 0; return 0;
} }
static int dsp_buffer_free(struct cx88_audio_dev *chip)
static int dsp_buffer_free(snd_cx88_card_t *chip)
{ {
struct cx88_riscmem *risc = &chip->buf->risc; struct cx88_riscmem *risc = &chip->buf->risc;
BUG_ON(!chip->dma_size); WARN_ON(!chip->dma_size);
dprintk(2, "Freeing buffer\n"); dprintk(2, "Freeing buffer\n");
cx88_alsa_dma_unmap(chip); cx88_alsa_dma_unmap(chip);
cx88_alsa_dma_free(chip->buf); cx88_alsa_dma_free(chip->buf);
if (risc->cpu) if (risc->cpu)
pci_free_consistent(chip->pci, risc->size, risc->cpu, risc->dma); pci_free_consistent(chip->pci, risc->size,
risc->cpu, risc->dma);
kfree(chip->buf); kfree(chip->buf);
chip->buf = NULL; chip->buf = NULL;
...@@ -374,9 +375,9 @@ static int dsp_buffer_free(snd_cx88_card_t *chip) ...@@ -374,9 +375,9 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
return 0; return 0;
} }
/**************************************************************************** /*
ALSA PCM Interface * ALSA PCM Interface
****************************************************************************/ */
/* /*
* Digital hardware definition * Digital hardware definition
...@@ -394,13 +395,15 @@ static const struct snd_pcm_hardware snd_cx88_digital_hw = { ...@@ -394,13 +395,15 @@ static const struct snd_pcm_hardware snd_cx88_digital_hw = {
.rate_max = 48000, .rate_max = 48000,
.channels_min = 2, .channels_min = 2,
.channels_max = 2, .channels_max = 2,
/* Analog audio output will be full of clicks and pops if there /*
are not exactly four lines in the SRAM FIFO buffer. */ * Analog audio output will be full of clicks and pops if there
.period_bytes_min = DEFAULT_FIFO_SIZE/4, * are not exactly four lines in the SRAM FIFO buffer.
.period_bytes_max = DEFAULT_FIFO_SIZE/4, */
.period_bytes_min = DEFAULT_FIFO_SIZE / 4,
.period_bytes_max = DEFAULT_FIFO_SIZE / 4,
.periods_min = 1, .periods_min = 1,
.periods_max = 1024, .periods_max = 1024,
.buffer_bytes_max = (1024*1024), .buffer_bytes_max = (1024 * 1024),
}; };
/* /*
...@@ -408,7 +411,7 @@ static const struct snd_pcm_hardware snd_cx88_digital_hw = { ...@@ -408,7 +411,7 @@ static const struct snd_pcm_hardware snd_cx88_digital_hw = {
*/ */
static int snd_cx88_pcm_open(struct snd_pcm_substream *substream) static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
{ {
snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
int err; int err;
...@@ -417,7 +420,8 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream) ...@@ -417,7 +420,8 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
return -ENODEV; return -ENODEV;
} }
err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS); err = snd_pcm_hw_constraint_pow2(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIODS);
if (err < 0) if (err < 0)
goto _error; goto _error;
...@@ -453,7 +457,7 @@ static int snd_cx88_close(struct snd_pcm_substream *substream) ...@@ -453,7 +457,7 @@ static int snd_cx88_close(struct snd_pcm_substream *substream)
static int snd_cx88_hw_params(struct snd_pcm_substream *substream, static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
struct cx88_audio_buffer *buf; struct cx88_audio_buffer *buf;
int ret; int ret;
...@@ -467,11 +471,11 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream, ...@@ -467,11 +471,11 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
chip->num_periods = params_periods(hw_params); chip->num_periods = params_periods(hw_params);
chip->dma_size = chip->period_size * params_periods(hw_params); chip->dma_size = chip->period_size * params_periods(hw_params);
BUG_ON(!chip->dma_size); WARN_ON(!chip->dma_size);
BUG_ON(chip->num_periods & (chip->num_periods-1)); WARN_ON(chip->num_periods & (chip->num_periods - 1));
buf = kzalloc(sizeof(*buf), GFP_KERNEL); buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (buf == NULL) if (!buf)
return -ENOMEM; return -ENOMEM;
chip->buf = buf; chip->buf = buf;
...@@ -492,7 +496,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream, ...@@ -492,7 +496,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
goto error; goto error;
/* Loop back to start of program */ /* Loop back to start of program */
buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP|RISC_IRQ1|RISC_CNT_INC); buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma); buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
substream->runtime->dma_area = chip->buf->vaddr; substream->runtime->dma_area = chip->buf->vaddr;
...@@ -510,8 +514,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream, ...@@ -510,8 +514,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
*/ */
static int snd_cx88_hw_free(struct snd_pcm_substream *substream) static int snd_cx88_hw_free(struct snd_pcm_substream *substream)
{ {
struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
if (substream->runtime->dma_area) { if (substream->runtime->dma_area) {
dsp_buffer_free(chip); dsp_buffer_free(chip);
...@@ -534,7 +537,7 @@ static int snd_cx88_prepare(struct snd_pcm_substream *substream) ...@@ -534,7 +537,7 @@ static int snd_cx88_prepare(struct snd_pcm_substream *substream)
*/ */
static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd) static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd)
{ {
snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
int err; int err;
/* Local interrupts are already disabled by ALSA */ /* Local interrupts are already disabled by ALSA */
...@@ -562,7 +565,7 @@ static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -562,7 +565,7 @@ static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd)
*/ */
static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream)
{ {
snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
u16 count; u16 count;
...@@ -571,7 +574,7 @@ static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream) ...@@ -571,7 +574,7 @@ static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream)
// dprintk(2, "%s - count %d (+%u), period %d, frame %lu\n", __func__, // dprintk(2, "%s - count %d (+%u), period %d, frame %lu\n", __func__,
// count, new, count & (runtime->periods-1), // count, new, count & (runtime->periods-1),
// runtime->period_size * (count & (runtime->periods-1))); // runtime->period_size * (count & (runtime->periods-1)));
return runtime->period_size * (count & (runtime->periods-1)); return runtime->period_size * (count & (runtime->periods - 1));
} }
/* /*
...@@ -603,7 +606,8 @@ static const struct snd_pcm_ops snd_cx88_pcm_ops = { ...@@ -603,7 +606,8 @@ static const struct snd_pcm_ops snd_cx88_pcm_ops = {
/* /*
* create a PCM device * create a PCM device
*/ */
static int snd_cx88_pcm(snd_cx88_card_t *chip, int device, const char *name) static int snd_cx88_pcm(struct cx88_audio_dev *chip, int device,
const char *name)
{ {
int err; int err;
struct snd_pcm *pcm; struct snd_pcm *pcm;
...@@ -618,9 +622,9 @@ static int snd_cx88_pcm(snd_cx88_card_t *chip, int device, const char *name) ...@@ -618,9 +622,9 @@ static int snd_cx88_pcm(snd_cx88_card_t *chip, int device, const char *name)
return 0; return 0;
} }
/**************************************************************************** /*
CONTROL INTERFACE * CONTROL INTERFACE
****************************************************************************/ */
static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol, static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *info) struct snd_ctl_elem_info *info)
{ {
...@@ -635,7 +639,7 @@ static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol, ...@@ -635,7 +639,7 @@ static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol,
static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol, static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
int vol = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f), int vol = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f),
bal = cx_read(AUD_BAL_CTL); bal = cx_read(AUD_BAL_CTL);
...@@ -650,7 +654,7 @@ static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol, ...@@ -650,7 +654,7 @@ static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol,
static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol, static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
int left = value->value.integer.value[0]; int left = value->value.integer.value[0];
int right = value->value.integer.value[1]; int right = value->value.integer.value[1];
...@@ -672,7 +676,7 @@ static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol, ...@@ -672,7 +676,7 @@ static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol,
static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol, static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
int left, right, v, b; int left, right, v, b;
int changed = 0; int changed = 0;
...@@ -722,7 +726,7 @@ static const struct snd_kcontrol_new snd_cx88_volume = { ...@@ -722,7 +726,7 @@ static const struct snd_kcontrol_new snd_cx88_volume = {
static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol, static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
u32 bit = kcontrol->private_value; u32 bit = kcontrol->private_value;
...@@ -733,7 +737,7 @@ static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol, ...@@ -733,7 +737,7 @@ static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol,
static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
u32 bit = kcontrol->private_value; u32 bit = kcontrol->private_value;
int ret = 0; int ret = 0;
...@@ -745,8 +749,9 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, ...@@ -745,8 +749,9 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
vol ^= bit; vol ^= bit;
cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol);
/* Pass mute onto any WM8775 */ /* Pass mute onto any WM8775 */
if (core->sd_wm8775 && ((1<<6) == bit)) if (core->sd_wm8775 && ((1 << 6) == bit))
wm8775_s_ctrl(core, V4L2_CID_AUDIO_MUTE, 0 != (vol & bit)); wm8775_s_ctrl(core,
V4L2_CID_AUDIO_MUTE, 0 != (vol & bit));
ret = 1; ret = 1;
} }
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
...@@ -759,7 +764,7 @@ static const struct snd_kcontrol_new snd_cx88_dac_switch = { ...@@ -759,7 +764,7 @@ static const struct snd_kcontrol_new snd_cx88_dac_switch = {
.info = snd_ctl_boolean_mono_info, .info = snd_ctl_boolean_mono_info,
.get = snd_cx88_switch_get, .get = snd_cx88_switch_get,
.put = snd_cx88_switch_put, .put = snd_cx88_switch_put,
.private_value = (1<<8), .private_value = (1 << 8),
}; };
static const struct snd_kcontrol_new snd_cx88_source_switch = { static const struct snd_kcontrol_new snd_cx88_source_switch = {
...@@ -768,13 +773,13 @@ static const struct snd_kcontrol_new snd_cx88_source_switch = { ...@@ -768,13 +773,13 @@ static const struct snd_kcontrol_new snd_cx88_source_switch = {
.info = snd_ctl_boolean_mono_info, .info = snd_ctl_boolean_mono_info,
.get = snd_cx88_switch_get, .get = snd_cx88_switch_get,
.put = snd_cx88_switch_put, .put = snd_cx88_switch_put,
.private_value = (1<<6), .private_value = (1 << 6),
}; };
static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol, static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
s32 val; s32 val;
...@@ -786,7 +791,7 @@ static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol, ...@@ -786,7 +791,7 @@ static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol,
static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol, static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core = chip->core; struct cx88_core *core = chip->core;
wm8775_s_ctrl(core, V4L2_CID_AUDIO_LOUDNESS, wm8775_s_ctrl(core, V4L2_CID_AUDIO_LOUDNESS,
...@@ -802,9 +807,9 @@ static struct snd_kcontrol_new snd_cx88_alc_switch = { ...@@ -802,9 +807,9 @@ static struct snd_kcontrol_new snd_cx88_alc_switch = {
.put = snd_cx88_alc_put, .put = snd_cx88_alc_put,
}; };
/**************************************************************************** /*
Basic Flow for Sound Devices * Basic Flow for Sound Devices
****************************************************************************/ */
/* /*
* PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio * PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio
...@@ -822,9 +827,8 @@ MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl); ...@@ -822,9 +827,8 @@ MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl);
* Chip-specific destructor * Chip-specific destructor
*/ */
static int snd_cx88_free(snd_cx88_card_t *chip) static int snd_cx88_free(struct cx88_audio_dev *chip)
{ {
if (chip->irq >= 0) if (chip->irq >= 0)
free_irq(chip->irq, chip); free_irq(chip->irq, chip);
...@@ -839,22 +843,21 @@ static int snd_cx88_free(snd_cx88_card_t *chip) ...@@ -839,22 +843,21 @@ static int snd_cx88_free(snd_cx88_card_t *chip)
*/ */
static void snd_cx88_dev_free(struct snd_card *card) static void snd_cx88_dev_free(struct snd_card *card)
{ {
snd_cx88_card_t *chip = card->private_data; struct cx88_audio_dev *chip = card->private_data;
snd_cx88_free(chip); snd_cx88_free(chip);
} }
/* /*
* Alsa Constructor - Component probe * Alsa Constructor - Component probe
*/ */
static int devno; static int devno;
static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci, static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
snd_cx88_card_t **rchip, struct cx88_audio_dev **rchip,
struct cx88_core **core_ptr) struct cx88_core **core_ptr)
{ {
snd_cx88_card_t *chip; struct cx88_audio_dev *chip;
struct cx88_core *core; struct cx88_core *core;
int err; int err;
unsigned char pci_lat; unsigned char pci_lat;
...@@ -870,7 +873,7 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci, ...@@ -870,7 +873,7 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
chip = card->private_data; chip = card->private_data;
core = cx88_core_get(pci); core = cx88_core_get(pci);
if (core == NULL) { if (!core) {
err = -EINVAL; err = -EINVAL;
return err; return err;
} }
...@@ -882,7 +885,6 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci, ...@@ -882,7 +885,6 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
return err; return err;
} }
/* pci init */ /* pci init */
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
...@@ -903,7 +905,8 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci, ...@@ -903,7 +905,8 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
/* print pci info */ /* print pci info */
pci_read_config_byte(pci, PCI_LATENCY_TIMER, &pci_lat); pci_read_config_byte(pci, PCI_LATENCY_TIMER, &pci_lat);
dprintk(1, "ALSA %s/%i: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n", dprintk(1,
"ALSA %s/%i: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
core->name, devno, core->name, devno,
pci_name(pci), pci->revision, pci->irq, pci_name(pci), pci->revision, pci->irq,
pci_lat, (unsigned long long)pci_resource_start(pci, 0)); pci_lat, (unsigned long long)pci_resource_start(pci, 0));
...@@ -921,7 +924,7 @@ static int cx88_audio_initdev(struct pci_dev *pci, ...@@ -921,7 +924,7 @@ static int cx88_audio_initdev(struct pci_dev *pci,
const struct pci_device_id *pci_id) const struct pci_device_id *pci_id)
{ {
struct snd_card *card; struct snd_card *card;
snd_cx88_card_t *chip; struct cx88_audio_dev *chip;
struct cx88_core *core = NULL; struct cx88_core *core = NULL;
int err; int err;
...@@ -934,7 +937,7 @@ static int cx88_audio_initdev(struct pci_dev *pci, ...@@ -934,7 +937,7 @@ static int cx88_audio_initdev(struct pci_dev *pci,
} }
err = snd_card_new(&pci->dev, index[devno], id[devno], THIS_MODULE, err = snd_card_new(&pci->dev, index[devno], id[devno], THIS_MODULE,
sizeof(snd_cx88_card_t), &card); sizeof(struct cx88_audio_dev), &card);
if (err < 0) if (err < 0)
return err; return err;
...@@ -984,6 +987,7 @@ static int cx88_audio_initdev(struct pci_dev *pci, ...@@ -984,6 +987,7 @@ static int cx88_audio_initdev(struct pci_dev *pci,
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
/* /*
* ALSA destructor * ALSA destructor
*/ */
......
...@@ -66,6 +66,7 @@ enum blackbird_capture_type { ...@@ -66,6 +66,7 @@ enum blackbird_capture_type {
BLACKBIRD_RAW_CAPTURE, BLACKBIRD_RAW_CAPTURE,
BLACKBIRD_RAW_PASSTHRU_CAPTURE BLACKBIRD_RAW_PASSTHRU_CAPTURE
}; };
enum blackbird_capture_bits { enum blackbird_capture_bits {
BLACKBIRD_RAW_BITS_NONE = 0x00, BLACKBIRD_RAW_BITS_NONE = 0x00,
BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01, BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01,
...@@ -74,33 +75,40 @@ enum blackbird_capture_bits { ...@@ -74,33 +75,40 @@ enum blackbird_capture_bits {
BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08, BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08,
BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10 BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10
}; };
enum blackbird_capture_end { enum blackbird_capture_end {
BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */ BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */
BLACKBIRD_END_NOW, /* stop immediately, no irq */ BLACKBIRD_END_NOW, /* stop immediately, no irq */
}; };
enum blackbird_framerate { enum blackbird_framerate {
BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */ BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */
BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */ BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */
}; };
enum blackbird_stream_port { enum blackbird_stream_port {
BLACKBIRD_OUTPUT_PORT_MEMORY, BLACKBIRD_OUTPUT_PORT_MEMORY,
BLACKBIRD_OUTPUT_PORT_STREAMING, BLACKBIRD_OUTPUT_PORT_STREAMING,
BLACKBIRD_OUTPUT_PORT_SERIAL BLACKBIRD_OUTPUT_PORT_SERIAL
}; };
enum blackbird_data_xfer_status { enum blackbird_data_xfer_status {
BLACKBIRD_MORE_BUFFERS_FOLLOW, BLACKBIRD_MORE_BUFFERS_FOLLOW,
BLACKBIRD_LAST_BUFFER, BLACKBIRD_LAST_BUFFER,
}; };
enum blackbird_picture_mask { enum blackbird_picture_mask {
BLACKBIRD_PICTURE_MASK_NONE, BLACKBIRD_PICTURE_MASK_NONE,
BLACKBIRD_PICTURE_MASK_I_FRAMES, BLACKBIRD_PICTURE_MASK_I_FRAMES,
BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3, BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3,
BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7, BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7,
}; };
enum blackbird_vbi_mode_bits { enum blackbird_vbi_mode_bits {
BLACKBIRD_VBI_BITS_SLICED, BLACKBIRD_VBI_BITS_SLICED,
BLACKBIRD_VBI_BITS_RAW, BLACKBIRD_VBI_BITS_RAW,
}; };
enum blackbird_vbi_insertion_bits { enum blackbird_vbi_insertion_bits {
BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA, BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA,
BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1, BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1,
...@@ -108,56 +116,69 @@ enum blackbird_vbi_insertion_bits { ...@@ -108,56 +116,69 @@ enum blackbird_vbi_insertion_bits {
BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1, BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1,
BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1, BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1,
}; };
enum blackbird_dma_unit { enum blackbird_dma_unit {
BLACKBIRD_DMA_BYTES, BLACKBIRD_DMA_BYTES,
BLACKBIRD_DMA_FRAMES, BLACKBIRD_DMA_FRAMES,
}; };
enum blackbird_dma_transfer_status_bits { enum blackbird_dma_transfer_status_bits {
BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01, BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01,
BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04, BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04,
BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10, BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10,
}; };
enum blackbird_pause { enum blackbird_pause {
BLACKBIRD_PAUSE_ENCODING, BLACKBIRD_PAUSE_ENCODING,
BLACKBIRD_RESUME_ENCODING, BLACKBIRD_RESUME_ENCODING,
}; };
enum blackbird_copyright { enum blackbird_copyright {
BLACKBIRD_COPYRIGHT_OFF, BLACKBIRD_COPYRIGHT_OFF,
BLACKBIRD_COPYRIGHT_ON, BLACKBIRD_COPYRIGHT_ON,
}; };
enum blackbird_notification_type { enum blackbird_notification_type {
BLACKBIRD_NOTIFICATION_REFRESH, BLACKBIRD_NOTIFICATION_REFRESH,
}; };
enum blackbird_notification_status { enum blackbird_notification_status {
BLACKBIRD_NOTIFICATION_OFF, BLACKBIRD_NOTIFICATION_OFF,
BLACKBIRD_NOTIFICATION_ON, BLACKBIRD_NOTIFICATION_ON,
}; };
enum blackbird_notification_mailbox { enum blackbird_notification_mailbox {
BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1, BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1,
}; };
enum blackbird_field1_lines { enum blackbird_field1_lines {
BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */ BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */
BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */ BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */
BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */ BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */
}; };
enum blackbird_field2_lines { enum blackbird_field2_lines {
BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */ BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */
BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */ BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */
BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */ BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */
}; };
enum blackbird_custom_data_type { enum blackbird_custom_data_type {
BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
BLACKBIRD_CUSTOM_PRIVATE_PACKET, BLACKBIRD_CUSTOM_PRIVATE_PACKET,
}; };
enum blackbird_mute { enum blackbird_mute {
BLACKBIRD_UNMUTE, BLACKBIRD_UNMUTE,
BLACKBIRD_MUTE, BLACKBIRD_MUTE,
}; };
enum blackbird_mute_video_mask { enum blackbird_mute_video_mask {
BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00, BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00,
BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000, BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000,
BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000, BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000,
}; };
enum blackbird_mute_video_shift { enum blackbird_mute_video_shift {
BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8, BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8,
BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16, BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16,
...@@ -281,7 +302,6 @@ static int register_write(struct cx88_core *core, u32 address, u32 value) ...@@ -281,7 +302,6 @@ static int register_write(struct cx88_core *core, u32 address, u32 value)
return wait_ready_gpio0_bit1(core, 1); return wait_ready_gpio0_bit1(core, 1);
} }
static int register_read(struct cx88_core *core, u32 address, u32 *value) static int register_read(struct cx88_core *core, u32 address, u32 *value)
{ {
int retval; int retval;
...@@ -304,7 +324,8 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value) ...@@ -304,7 +324,8 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 data[CX2341X_MBOX_MAX_DATA]) static int blackbird_mbox_func(void *priv, u32 command, int in,
int out, u32 data[CX2341X_MBOX_MAX_DATA])
{ {
struct cx8802_dev *dev = priv; struct cx8802_dev *dev = priv;
unsigned long timeout; unsigned long timeout;
...@@ -313,11 +334,14 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat ...@@ -313,11 +334,14 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
dprintk(1, "%s: 0x%X\n", __func__, command); dprintk(1, "%s: 0x%X\n", __func__, command);
/* this may not be 100% safe if we can't read any memory location /*
without side effects */ * this may not be 100% safe if we can't read any memory location
* without side effects
*/
memory_read(dev->core, dev->mailbox - 4, &value); memory_read(dev->core, dev->mailbox - 4, &value);
if (value != 0x12345678) { if (value != 0x12345678) {
dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n"); dprintk(0,
"Firmware and/or mailbox pointer not initialized or corrupted\n");
return -EIO; return -EIO;
} }
...@@ -332,7 +356,8 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat ...@@ -332,7 +356,8 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
/* write command + args + fill remaining with zeros */ /* write command + args + fill remaining with zeros */
memory_write(dev->core, dev->mailbox + 1, command); /* command code */ memory_write(dev->core, dev->mailbox + 1, command); /* command code */
memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */ /* timeout */
memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT);
for (i = 0; i < in; i++) { for (i = 0; i < in; i++) {
memory_write(dev->core, dev->mailbox + 4 + i, data[i]); memory_write(dev->core, dev->mailbox + 4 + i, data[i]);
dprintk(1, "API Input %d = %d\n", i, data[i]); dprintk(1, "API Input %d = %d\n", i, data[i]);
...@@ -369,9 +394,13 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat ...@@ -369,9 +394,13 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
memory_write(dev->core, dev->mailbox, flag); memory_write(dev->core, dev->mailbox, flag);
return retval; return retval;
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* We don't need to call the API often, so using just one mailbox will probably suffice */ /*
* We don't need to call the API often, so using just one mailbox
* will probably suffice
*/
static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command, static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
u32 inputcnt, u32 outputcnt, ...) u32 inputcnt, u32 outputcnt, ...)
{ {
...@@ -381,9 +410,9 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command, ...@@ -381,9 +410,9 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
va_start(vargs, outputcnt); va_start(vargs, outputcnt);
for (i = 0; i < inputcnt; i++) { for (i = 0; i < inputcnt; i++)
data[i] = va_arg(vargs, int); data[i] = va_arg(vargs, int);
}
err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data); err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data);
for (i = 0; i < outputcnt; i++) { for (i = 0; i < outputcnt; i++) {
int *vptr = va_arg(vargs, int *); int *vptr = va_arg(vargs, int *);
...@@ -408,7 +437,7 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev) ...@@ -408,7 +437,7 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev)
signaturecnt = 0; signaturecnt = 0;
if (signaturecnt == 4) { if (signaturecnt == 4) {
dprintk(1, "Mailbox signature found\n"); dprintk(1, "Mailbox signature found\n");
return i+1; return i + 1;
} }
} }
dprintk(0, "Mailbox signature values not found!\n"); dprintk(0, "Mailbox signature values not found!\n");
...@@ -427,10 +456,13 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) ...@@ -427,10 +456,13 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
__le32 *dataptr; __le32 *dataptr;
retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED);
retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS,
retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640); IVTV_CMD_HW_BLOCKS_RST);
retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A); retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH,
msleep(1); 0x80000640);
retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE,
0x1A);
usleep_range(10000, 20000);
retval |= register_write(dev->core, IVTV_REG_APU, 0); retval |= register_write(dev->core, IVTV_REG_APU, 0);
if (retval < 0) if (retval < 0)
...@@ -439,7 +471,6 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) ...@@ -439,7 +471,6 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME, retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME,
&dev->pci->dev); &dev->pci->dev);
if (retval != 0) { if (retval != 0) {
pr_err("Hotplug firmware request failed (%s).\n", pr_err("Hotplug firmware request failed (%s).\n",
CX2341X_FIRM_ENC_FILENAME); CX2341X_FIRM_ENC_FILENAME);
...@@ -482,10 +513,11 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) ...@@ -482,10 +513,11 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
} }
dprintk(0, "Firmware upload successful.\n"); dprintk(0, "Firmware upload successful.\n");
retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS,
IVTV_CMD_HW_BLOCKS_RST);
retval |= register_read(dev->core, IVTV_REG_SPU, &value); retval |= register_read(dev->core, IVTV_REG_SPU, &value);
retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE); retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE);
msleep(1); usleep_range(10000, 20000);
retval |= register_read(dev->core, IVTV_REG_VPU, &value); retval |= register_read(dev->core, IVTV_REG_VPU, &value);
retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8); retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8);
...@@ -495,19 +527,19 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) ...@@ -495,19 +527,19 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
return 0; return 0;
} }
/** /*
Settings used by the windows tv app for PVR2000: * Settings used by the windows tv app for PVR2000:
================================================================================================================= * =================================================================================================================
Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode * Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode
----------------------------------------------------------------------------------------------------------------- * -----------------------------------------------------------------------------------------------------------------
MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo * MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo * MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo * VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo * DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo * DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
================================================================================================================= * =================================================================================================================
*DB: "DirectBurn" * [*] DB: "DirectBurn"
*/ */
static void blackbird_codec_settings(struct cx8802_dev *dev) static void blackbird_codec_settings(struct cx8802_dev *dev)
{ {
...@@ -519,7 +551,8 @@ static void blackbird_codec_settings(struct cx8802_dev *dev) ...@@ -519,7 +551,8 @@ static void blackbird_codec_settings(struct cx8802_dev *dev)
dev->cxhdl.width = core->width; dev->cxhdl.width = core->width;
dev->cxhdl.height = core->height; dev->cxhdl.height = core->height;
cx2341x_handler_set_50hz(&dev->cxhdl, dev->core->tvnorm & V4L2_STD_625_50); cx2341x_handler_set_50hz(&dev->cxhdl,
dev->core->tvnorm & V4L2_STD_625_50);
cx2341x_handler_setup(&dev->cxhdl); cx2341x_handler_setup(&dev->cxhdl);
} }
...@@ -545,15 +578,18 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) ...@@ -545,15 +578,18 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
dev->mailbox = retval; dev->mailbox = retval;
retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ /* ping */
retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0);
if (retval < 0) { if (retval < 0) {
dprintk(0, "ERROR: Firmware ping failed!\n"); dprintk(0, "ERROR: Firmware ping failed!\n");
return -1; return -1;
} }
retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version); retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION,
0, 1, &version);
if (retval < 0) { if (retval < 0) {
dprintk(0, "ERROR: Firmware get encoder version failed!\n"); dprintk(0,
"ERROR: Firmware get encoder version failed!\n");
return -1; return -1;
} }
dprintk(0, "Firmware version is 0x%08x\n", version); dprintk(0, "Firmware version is 0x%08x\n", version);
...@@ -567,9 +603,7 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) ...@@ -567,9 +603,7 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
blackbird_codec_settings(dev); blackbird_codec_settings(dev);
blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0, blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0,
BLACKBIRD_FIELD1_SAA7115, BLACKBIRD_FIELD1_SAA7115, BLACKBIRD_FIELD2_SAA7115);
BLACKBIRD_FIELD2_SAA7115
);
blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0, blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0,
BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
...@@ -611,9 +645,7 @@ static int blackbird_start_codec(struct cx8802_dev *dev) ...@@ -611,9 +645,7 @@ static int blackbird_start_codec(struct cx8802_dev *dev)
/* start capturing to the host interface */ /* start capturing to the host interface */
blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0,
BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_RAW_BITS_NONE);
BLACKBIRD_RAW_BITS_NONE
);
return 0; return 0;
} }
...@@ -623,8 +655,7 @@ static int blackbird_stop_codec(struct cx8802_dev *dev) ...@@ -623,8 +655,7 @@ static int blackbird_stop_codec(struct cx8802_dev *dev)
blackbird_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, blackbird_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
BLACKBIRD_END_NOW, BLACKBIRD_END_NOW,
BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_MPEG_CAPTURE,
BLACKBIRD_RAW_BITS_NONE BLACKBIRD_RAW_BITS_NONE);
);
cx2341x_handler_set_busy(&dev->cxhdl, 0); cx2341x_handler_set_busy(&dev->cxhdl, 0);
...@@ -695,7 +726,8 @@ static int start_streaming(struct vb2_queue *q, unsigned int count) ...@@ -695,7 +726,8 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
err = drv->request_acquire(drv); err = drv->request_acquire(drv);
if (err != 0) { if (err != 0) {
dprintk(1, "%s: Unable to acquire hardware, %d\n", __func__, err); dprintk(1, "%s: Unable to acquire hardware, %d\n", __func__,
err);
goto fail; goto fail;
} }
...@@ -860,7 +892,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -860,7 +892,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
core->width = f->fmt.pix.width; core->width = f->fmt.pix.width;
core->height = f->fmt.pix.height; core->height = f->fmt.pix.height;
core->field = f->fmt.pix.field; core->field = f->fmt.pix.field;
cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height,
f->fmt.pix.field);
blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
f->fmt.pix.height, f->fmt.pix.width); f->fmt.pix.height, f->fmt.pix.width);
return 0; return 0;
...@@ -883,8 +916,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -883,8 +916,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
cx88_set_freq(core, f); cx88_set_freq(core, f);
blackbird_initialize_codec(dev); blackbird_initialize_codec(dev);
cx88_set_scale(core, core->width, core->height, cx88_set_scale(core, core->width, core->height, core->field);
core->field);
if (streaming) if (streaming)
blackbird_start_codec(dev); blackbird_start_codec(dev);
return 0; return 0;
...@@ -944,7 +976,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) ...@@ -944,7 +976,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
if (i >= 4) if (i >= 4)
return -EINVAL; return -EINVAL;
if (0 == INPUT(i).type) if (!INPUT(i).type)
return -EINVAL; return -EINVAL;
cx88_newstation(core); cx88_newstation(core);
...@@ -971,7 +1003,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, ...@@ -971,7 +1003,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
cx88_get_stereo(core, t); cx88_get_stereo(core, t);
reg = cx_read(MO_DEVICE_STATUS); reg = cx_read(MO_DEVICE_STATUS);
t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; t->signal = (reg & (1 << 5)) ? 0xffff : 0x0000;
return 0; return 0;
} }
...@@ -1008,7 +1040,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) ...@@ -1008,7 +1040,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
} }
static const struct v4l2_file_operations mpeg_fops = { static const struct v4l2_file_operations mpeg_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = v4l2_fh_open, .open = v4l2_fh_open,
.release = vb2_fop_release, .release = vb2_fop_release,
...@@ -1061,7 +1092,9 @@ static int cx8802_blackbird_advise_acquire(struct cx8802_driver *drv) ...@@ -1061,7 +1092,9 @@ static int cx8802_blackbird_advise_acquire(struct cx8802_driver *drv)
switch (core->boardnr) { switch (core->boardnr) {
case CX88_BOARD_HAUPPAUGE_HVR1300: case CX88_BOARD_HAUPPAUGE_HVR1300:
/* By default, core setup will leave the cx22702 out of reset, on the bus. /*
* By default, core setup will leave the cx22702 out of reset,
* on the bus.
* We left the hardware on power up with the cx22702 active. * We left the hardware on power up with the cx22702 active.
* We're being given access to re-arrange the GPIOs. * We're being given access to re-arrange the GPIOs.
* Take the bus off the cx22702 and put the cx23416 on it. * Take the bus off the cx22702 and put the cx23416 on it.
......
...@@ -51,7 +51,6 @@ MODULE_PARM_DESC(disable_ir, "Disable IR support"); ...@@ -51,7 +51,6 @@ MODULE_PARM_DESC(disable_ir, "Disable IR support");
__func__, ##arg); \ __func__, ##arg); \
} while (0) } while (0)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* board config info */ /* board config info */
...@@ -278,7 +277,6 @@ static const struct cx88_board cx88_boards[] = { ...@@ -278,7 +277,6 @@ static const struct cx88_board cx88_boards[] = {
.gpio2 = 0x0035e700, .gpio2 = 0x0035e700,
.gpio3 = 0x02000000, .gpio3 = 0x02000000,
}, { }, {
.type = CX88_VMUX_COMPOSITE1, .type = CX88_VMUX_COMPOSITE1,
.vmux = 1, .vmux = 1,
.gpio0 = 0x0035c700, .gpio0 = 0x0035c700,
...@@ -492,21 +490,21 @@ static const struct cx88_board cx88_boards[] = { ...@@ -492,21 +490,21 @@ static const struct cx88_board cx88_boards[] = {
.tuner_addr = ADDR_UNSET, .tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET,
/* /*
GPIO[0] resets DT3302 DTV receiver * GPIO[0] resets DT3302 DTV receiver
0 - reset asserted * 0 - reset asserted
1 - normal operation * 1 - normal operation
GPIO[1] mutes analog audio output connector * GPIO[1] mutes analog audio output connector
0 - enable selected source * 0 - enable selected source
1 - mute * 1 - mute
GPIO[2] selects source for analog audio output connector * GPIO[2] selects source for analog audio output connector
0 - analog audio input connector on tab * 0 - analog audio input connector on tab
1 - analog DAC output from CX23881 chip * 1 - analog DAC output from CX23881 chip
GPIO[3] selects RF input connector on tuner module * GPIO[3] selects RF input connector on tuner module
0 - RF connector labeled CABLE * 0 - RF connector labeled CABLE
1 - RF connector labeled ANT * 1 - RF connector labeled ANT
GPIO[4] selects high RF for QAM256 mode * GPIO[4] selects high RF for QAM256 mode
0 - normal RF * 0 - normal RF
1 - high RF * 1 - high RF
*/ */
.input = { { .input = { {
.type = CX88_VMUX_TELEVISION, .type = CX88_VMUX_TELEVISION,
...@@ -730,7 +728,10 @@ static const struct cx88_board cx88_boards[] = { ...@@ -730,7 +728,10 @@ static const struct cx88_board cx88_boards[] = {
.radio_type = UNSET, .radio_type = UNSET,
.tuner_addr = ADDR_UNSET, .tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET,
/* Some variants use a tda9874 and so need the tvaudio module. */ /*
* Some variants use a tda9874 and so need the
* tvaudio module.
*/
.audio_chip = CX88_AUDIO_TVAUDIO, .audio_chip = CX88_AUDIO_TVAUDIO,
.input = { { .input = { {
.type = CX88_VMUX_TELEVISION, .type = CX88_VMUX_TELEVISION,
...@@ -1196,8 +1197,10 @@ static const struct cx88_board cx88_boards[] = { ...@@ -1196,8 +1197,10 @@ static const struct cx88_board cx88_boards[] = {
.mpeg = CX88_MPEG_DVB, .mpeg = CX88_MPEG_DVB,
}, },
[CX88_BOARD_KWORLD_MCE200_DELUXE] = { [CX88_BOARD_KWORLD_MCE200_DELUXE] = {
/* FIXME: tested TV input only, disabled composite, /*
svideo and radio until they can be tested also. */ * FIXME: tested TV input only, disabled composite,
* svideo and radio until they can be tested also.
*/
.name = "Kworld MCE 200 Deluxe", .name = "Kworld MCE 200 Deluxe",
.tuner_type = TUNER_TENA_9533_DI, .tuner_type = TUNER_TENA_9533_DI,
.radio_type = UNSET, .radio_type = UNSET,
...@@ -1708,16 +1711,24 @@ static const struct cx88_board cx88_boards[] = { ...@@ -1708,16 +1711,24 @@ static const struct cx88_board cx88_boards[] = {
}, },
}, },
[CX88_BOARD_POWERCOLOR_REAL_ANGEL] = { [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = {
.name = "PowerColor RA330", /* Long names may confuse LIRC. */ /* Long names may confuse LIRC. */
.name = "PowerColor RA330",
.tuner_type = TUNER_XC2028, .tuner_type = TUNER_XC2028,
.tuner_addr = 0x61, .tuner_addr = 0x61,
.input = { { .input = { {
/*
* Due to the way the cx88 driver is written,
* there is no way to deactivate audio pass-
* through without this entry. Furthermore, if
* the TV mux entry is first, you get audio
* from the tuner on boot for a little while.
*/
.type = CX88_VMUX_DEBUG, .type = CX88_VMUX_DEBUG,
.vmux = 3, /* Due to the way the cx88 driver is written, */ .vmux = 3,
.gpio0 = 0x00ff, /* there is no way to deactivate audio pass- */ .gpio0 = 0x00ff,
.gpio1 = 0xf39d, /* through without this entry. Furthermore, if */ .gpio1 = 0xf39d,
.gpio3 = 0x0000, /* the TV mux entry is first, you get audio */ .gpio3 = 0x0000,
}, { /* from the tuner on boot for a little while. */ }, {
.type = CX88_VMUX_TELEVISION, .type = CX88_VMUX_TELEVISION,
.vmux = 0, .vmux = 0,
.gpio0 = 0x00ff, .gpio0 = 0x00ff,
...@@ -1870,11 +1881,12 @@ static const struct cx88_board cx88_boards[] = { ...@@ -1870,11 +1881,12 @@ static const struct cx88_board cx88_boards[] = {
.gpio2 = 0x0cf7, .gpio2 = 0x0cf7,
}, },
}, },
/* Both radio, analog and ATSC work with this board. /*
However, for analog to work, s5h1409 gate should be open, * Both radio, analog and ATSC work with this board.
otherwise, tuner-xc3028 won't be detected. * However, for analog to work, s5h1409 gate should be open,
A proper fix require using the newer i2c methods to add * otherwise, tuner-xc3028 won't be detected.
tuner-xc3028 without doing an i2c probe. * A proper fix require using the newer i2c methods to add
* tuner-xc3028 without doing an i2c probe.
*/ */
[CX88_BOARD_KWORLD_ATSC_120] = { [CX88_BOARD_KWORLD_ATSC_120] = {
.name = "Kworld PlusTV HD PCI 120 (ATSC 120)", .name = "Kworld PlusTV HD PCI 120 (ATSC 120)",
...@@ -2808,9 +2820,9 @@ static const struct cx88_subid cx88_subids[] = { ...@@ -2808,9 +2820,9 @@ static const struct cx88_subid cx88_subids[] = {
}, },
}; };
/* ----------------------------------------------------------------------- */ /*
/* some leadtek specific stuff */ * some leadtek specific stuff
*/
static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data) static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
{ {
if (eeprom_data[4] != 0x7d || if (eeprom_data[4] != 0x7d ||
...@@ -2849,8 +2861,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) ...@@ -2849,8 +2861,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
core->model = tv.model; core->model = tv.model;
/* Make sure we support the board model */ /* Make sure we support the board model */
switch (tv.model) switch (tv.model) {
{
case 14009: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in) */ case 14009: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in) */
case 14019: /* WinTV-HVR3000 (Retail, IR Blaster, b/panel video, 3.5mm audio in) */ case 14019: /* WinTV-HVR3000 (Retail, IR Blaster, b/panel video, 3.5mm audio in) */
case 14029: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge) */ case 14029: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge) */
...@@ -2898,8 +2909,9 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) ...@@ -2898,8 +2909,9 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
pr_info("hauppauge eeprom: model=%d\n", tv.model); pr_info("hauppauge eeprom: model=%d\n", tv.model);
} }
/* ----------------------------------------------------------------------- */ /*
/* some GDI (was: Modular Technology) specific stuff */ * some GDI (was: Modular Technology) specific stuff
*/
static const struct { static const struct {
int id; int id;
...@@ -2942,15 +2954,16 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data) ...@@ -2942,15 +2954,16 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
? gdi_tuner[eeprom_data[0x0d]].name : NULL; ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
pr_info("GDI: tuner=%s\n", name ? name : "unknown"); pr_info("GDI: tuner=%s\n", name ? name : "unknown");
if (name == NULL) if (!name)
return; return;
core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id; core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ? core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ?
CX88_RADIO : 0; CX88_RADIO : 0;
} }
/* ------------------------------------------------------------------- */ /*
/* some Divco specific stuff */ * some Divco specific stuff
*/
static int cx88_dvico_xc2028_callback(struct cx88_core *core, static int cx88_dvico_xc2028_callback(struct cx88_core *core,
int command, int arg) int command, int arg)
{ {
...@@ -2979,9 +2992,9 @@ static int cx88_dvico_xc2028_callback(struct cx88_core *core, ...@@ -2979,9 +2992,9 @@ static int cx88_dvico_xc2028_callback(struct cx88_core *core,
return 0; return 0;
} }
/*
/* ----------------------------------------------------------------------- */ * some Geniatech specific stuff
/* some Geniatech specific stuff */ */
static int cx88_xc3028_geniatech_tuner_callback(struct cx88_core *core, static int cx88_xc3028_geniatech_tuner_callback(struct cx88_core *core,
int command, int mode) int command, int mode)
...@@ -3044,8 +3057,9 @@ static int cx88_xc4000_winfast2000h_plus_callback(struct cx88_core *core, ...@@ -3044,8 +3057,9 @@ static int cx88_xc4000_winfast2000h_plus_callback(struct cx88_core *core,
return -EINVAL; return -EINVAL;
} }
/* ------------------------------------------------------------------- */ /*
/* some Divco specific stuff */ * some Divco specific stuff
*/
static int cx88_pv_8000gt_callback(struct cx88_core *core, static int cx88_pv_8000gt_callback(struct cx88_core *core,
int command, int arg) int command, int arg)
{ {
...@@ -3064,8 +3078,9 @@ static int cx88_pv_8000gt_callback(struct cx88_core *core, ...@@ -3064,8 +3078,9 @@ static int cx88_pv_8000gt_callback(struct cx88_core *core,
return 0; return 0;
} }
/* ----------------------------------------------------------------------- */ /*
/* some DViCO specific stuff */ * some DViCO specific stuff
*/
static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core) static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core)
{ {
...@@ -3161,11 +3176,11 @@ static int cx88_xc4000_tuner_callback(struct cx88_core *core, ...@@ -3161,11 +3176,11 @@ static int cx88_xc4000_tuner_callback(struct cx88_core *core,
return -EINVAL; return -EINVAL;
} }
/* ----------------------------------------------------------------------- */ /*
/* Tuner callback function. Currently only needed for the Pinnacle * * Tuner callback function. Currently only needed for the Pinnacle
* PCTV HD 800i with an xc5000 sillicon tuner. This is used for both * * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both
* analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */ * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c)
*/
static int cx88_xc5000_tuner_callback(struct cx88_core *core, static int cx88_xc5000_tuner_callback(struct cx88_core *core,
int command, int arg) int command, int arg)
{ {
...@@ -3173,39 +3188,39 @@ static int cx88_xc5000_tuner_callback(struct cx88_core *core, ...@@ -3173,39 +3188,39 @@ static int cx88_xc5000_tuner_callback(struct cx88_core *core,
case CX88_BOARD_PINNACLE_PCTV_HD_800i: case CX88_BOARD_PINNACLE_PCTV_HD_800i:
if (command == 0) { /* This is the reset command from xc5000 */ if (command == 0) { /* This is the reset command from xc5000 */
/* djh - According to the engineer at PCTV Systems, /*
the xc5000 reset pin is supposed to be on GPIO12. * djh - According to the engineer at PCTV Systems,
However, despite three nights of effort, pulling * the xc5000 reset pin is supposed to be on GPIO12.
that GPIO low didn't reset the xc5000. While * However, despite three nights of effort, pulling
pulling MO_SRST_IO low does reset the xc5000, this * that GPIO low didn't reset the xc5000. While
also resets in the s5h1409 being reset as well. * pulling MO_SRST_IO low does reset the xc5000, this
This causes tuning to always fail since the internal * also resets in the s5h1409 being reset as well.
state of the s5h1409 does not match the driver's * This causes tuning to always fail since the internal
state. Given that the only two conditions in which * state of the s5h1409 does not match the driver's
the driver performs a reset is during firmware load * state. Given that the only two conditions in which
and powering down the chip, I am taking out the * the driver performs a reset is during firmware load
reset. We know that the chip is being reset * and powering down the chip, I am taking out the
when the cx88 comes online, and not being able to * reset. We know that the chip is being reset
do power management for this board is worse than * when the cx88 comes online, and not being able to
not having any tuning at all. */ * do power management for this board is worse than
* not having any tuning at all.
*/
return 0; return 0;
} else { }
dprintk(1, "xc5000: unknown tuner callback command.\n"); dprintk(1, "xc5000: unknown tuner callback command.\n");
return -EINVAL; return -EINVAL;
}
break;
case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
if (command == 0) { /* This is the reset command from xc5000 */ if (command == 0) { /* This is the reset command from xc5000 */
cx_clear(MO_GP0_IO, 0x00000010); cx_clear(MO_GP0_IO, 0x00000010);
msleep(10); usleep_range(10000, 20000);
cx_set(MO_GP0_IO, 0x00000010); cx_set(MO_GP0_IO, 0x00000010);
return 0; return 0;
} else { }
dprintk(1, "xc5000: unknown tuner callback command.\n"); dprintk(1, "xc5000: unknown tuner callback command.\n");
return -EINVAL; return -EINVAL;
} }
break;
}
return 0; /* Should never be here */ return 0; /* Should never be here */
} }
...@@ -3252,8 +3267,7 @@ static void cx88_card_list(struct cx88_core *core, struct pci_dev *pci) ...@@ -3252,8 +3267,7 @@ static void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
{ {
int i; int i;
if (0 == pci->subsystem_vendor && if (!pci->subsystem_vendor && !pci->subsystem_device) {
0 == pci->subsystem_device) {
pr_err("Your board has no valid PCI Subsystem ID and thus can't\n"); pr_err("Your board has no valid PCI Subsystem ID and thus can't\n");
pr_err("be autodetected. Please pass card=<n> insmod option to\n"); pr_err("be autodetected. Please pass card=<n> insmod option to\n");
pr_err("workaround that. Redirect complaints to the vendor of\n"); pr_err("workaround that. Redirect complaints to the vendor of\n");
...@@ -3274,7 +3288,9 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core) ...@@ -3274,7 +3288,9 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core)
switch (core->boardnr) { switch (core->boardnr) {
case CX88_BOARD_HAUPPAUGE_HVR1300: case CX88_BOARD_HAUPPAUGE_HVR1300:
/* /*
* Bring the 702 demod up before i2c scanning/attach or devices are hidden * Bring the 702 demod up before i2c scanning/attach or
* devices are hidden.
*
* We leave here with the 702 on the bus * We leave here with the 702 on the bus
* *
* "reset the IR receiver on GPIO[3]" * "reset the IR receiver on GPIO[3]"
...@@ -3295,7 +3311,7 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core) ...@@ -3295,7 +3311,7 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core)
cx_write(MO_GP2_IO, 0xef5); cx_write(MO_GP2_IO, 0xef5);
mdelay(50); mdelay(50);
cx_write(MO_GP2_IO, 0xcf7); cx_write(MO_GP2_IO, 0xcf7);
msleep(10); usleep_range(10000, 20000);
break; break;
case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
...@@ -3331,7 +3347,7 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core) ...@@ -3331,7 +3347,7 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core)
case CX88_BOARD_TWINHAN_VP1027_DVBS: case CX88_BOARD_TWINHAN_VP1027_DVBS:
cx_write(MO_GP0_IO, 0x00003230); cx_write(MO_GP0_IO, 0x00003230);
cx_write(MO_GP0_IO, 0x00003210); cx_write(MO_GP0_IO, 0x00003210);
msleep(1); usleep_range(10000, 20000);
cx_write(MO_GP0_IO, 0x00001230); cx_write(MO_GP0_IO, 0x00001230);
break; break;
} }
...@@ -3362,11 +3378,13 @@ void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl) ...@@ -3362,11 +3378,13 @@ void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl)
ctl->demod = XC3028_FE_OREN538; ctl->demod = XC3028_FE_OREN538;
break; break;
case CX88_BOARD_GENIATECH_X8000_MT: case CX88_BOARD_GENIATECH_X8000_MT:
/* FIXME: For this board, the xc3028 never recovers after being /*
powered down (the reset GPIO probably is not set properly). * FIXME: For this board, the xc3028 never recovers after being
We don't have access to the hardware so we cannot determine * powered down (the reset GPIO probably is not set properly).
which GPIO is used for xc3028, so just disable power xc3028 * We don't have access to the hardware so we cannot determine
power management for now */ * which GPIO is used for xc3028, so just disable power xc3028
* power management for now
*/
ctl->disable_power_mgmt = 1; ctl->disable_power_mgmt = 1;
break; break;
case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
...@@ -3396,7 +3414,7 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3396,7 +3414,7 @@ static void cx88_card_setup(struct cx88_core *core)
memset(&tun_setup, 0, sizeof(tun_setup)); memset(&tun_setup, 0, sizeof(tun_setup));
if (core->i2c_rc == 0) { if (!core->i2c_rc) {
core->i2c_client.addr = 0xa0 >> 1; core->i2c_client.addr = 0xa0 >> 1;
tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom)); tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom));
} }
...@@ -3404,17 +3422,17 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3404,17 +3422,17 @@ static void cx88_card_setup(struct cx88_core *core)
switch (core->boardnr) { switch (core->boardnr) {
case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE:
case CX88_BOARD_HAUPPAUGE_ROSLYN: case CX88_BOARD_HAUPPAUGE_ROSLYN:
if (core->i2c_rc == 0) if (!core->i2c_rc)
hauppauge_eeprom(core, eeprom+8); hauppauge_eeprom(core, eeprom + 8);
break; break;
case CX88_BOARD_GDI: case CX88_BOARD_GDI:
if (core->i2c_rc == 0) if (!core->i2c_rc)
gdi_eeprom(core, eeprom); gdi_eeprom(core, eeprom);
break; break;
case CX88_BOARD_LEADTEK_PVR2000: case CX88_BOARD_LEADTEK_PVR2000:
case CX88_BOARD_WINFAST_DV2000: case CX88_BOARD_WINFAST_DV2000:
case CX88_BOARD_WINFAST2000XP_EXPERT: case CX88_BOARD_WINFAST2000XP_EXPERT:
if (core->i2c_rc == 0) if (!core->i2c_rc)
leadtek_eeprom(core, eeprom); leadtek_eeprom(core, eeprom);
break; break;
case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
...@@ -3427,7 +3445,7 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3427,7 +3445,7 @@ static void cx88_card_setup(struct cx88_core *core)
case CX88_BOARD_HAUPPAUGE_HVR4000: case CX88_BOARD_HAUPPAUGE_HVR4000:
case CX88_BOARD_HAUPPAUGE_HVR4000LITE: case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
case CX88_BOARD_HAUPPAUGE_IRONLY: case CX88_BOARD_HAUPPAUGE_IRONLY:
if (core->i2c_rc == 0) if (!core->i2c_rc)
hauppauge_eeprom(core, eeprom); hauppauge_eeprom(core, eeprom);
break; break;
case CX88_BOARD_KWORLD_DVBS_100: case CX88_BOARD_KWORLD_DVBS_100:
...@@ -3438,7 +3456,7 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3438,7 +3456,7 @@ static void cx88_card_setup(struct cx88_core *core)
/* GPIO0:0 is hooked to demod reset */ /* GPIO0:0 is hooked to demod reset */
/* GPIO0:4 is hooked to xc3028 reset */ /* GPIO0:4 is hooked to xc3028 reset */
cx_write(MO_GP0_IO, 0x00111100); cx_write(MO_GP0_IO, 0x00111100);
msleep(1); usleep_range(10000, 20000);
cx_write(MO_GP0_IO, 0x00111111); cx_write(MO_GP0_IO, 0x00111111);
break; break;
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
...@@ -3454,9 +3472,9 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3454,9 +3472,9 @@ static void cx88_card_setup(struct cx88_core *core)
/* GPIO0:0 is hooked to mt352 reset pin */ /* GPIO0:0 is hooked to mt352 reset pin */
cx_set(MO_GP0_IO, 0x00000101); cx_set(MO_GP0_IO, 0x00000101);
cx_clear(MO_GP0_IO, 0x00000001); cx_clear(MO_GP0_IO, 0x00000001);
msleep(1); usleep_range(10000, 20000);
cx_set(MO_GP0_IO, 0x00000101); cx_set(MO_GP0_IO, 0x00000101);
if (0 == core->i2c_rc && if (!core->i2c_rc &&
core->boardnr == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID) core->boardnr == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID)
dvico_fusionhdtv_hybrid_init(core); dvico_fusionhdtv_hybrid_init(core);
break; break;
...@@ -3465,7 +3483,7 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3465,7 +3483,7 @@ static void cx88_card_setup(struct cx88_core *core)
cx_set(MO_GP0_IO, 0x00000707); cx_set(MO_GP0_IO, 0x00000707);
cx_set(MO_GP2_IO, 0x00000101); cx_set(MO_GP2_IO, 0x00000101);
cx_clear(MO_GP2_IO, 0x00000001); cx_clear(MO_GP2_IO, 0x00000001);
msleep(1); usleep_range(10000, 20000);
cx_clear(MO_GP0_IO, 0x00000007); cx_clear(MO_GP0_IO, 0x00000007);
cx_set(MO_GP2_IO, 0x00000101); cx_set(MO_GP2_IO, 0x00000101);
break; break;
...@@ -3473,7 +3491,7 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3473,7 +3491,7 @@ static void cx88_card_setup(struct cx88_core *core)
cx_write(MO_GP0_IO, 0x00080808); cx_write(MO_GP0_IO, 0x00080808);
break; break;
case CX88_BOARD_ATI_HDTVWONDER: case CX88_BOARD_ATI_HDTVWONDER:
if (core->i2c_rc == 0) { if (!core->i2c_rc) {
/* enable tuner */ /* enable tuner */
int i; int i;
static const u8 buffer[][2] = { static const u8 buffer[][2] = {
...@@ -3486,8 +3504,8 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3486,8 +3504,8 @@ static void cx88_card_setup(struct cx88_core *core)
core->i2c_client.addr = 0x0a; core->i2c_client.addr = 0x0a;
for (i = 0; i < ARRAY_SIZE(buffer); i++) for (i = 0; i < ARRAY_SIZE(buffer); i++)
if (2 != i2c_master_send(&core->i2c_client, if (i2c_master_send(&core->i2c_client,
buffer[i], 2)) buffer[i], 2) != 2)
pr_warn("Unable to enable tuner(%i).\n", pr_warn("Unable to enable tuner(%i).\n",
i); i);
} }
...@@ -3523,7 +3541,7 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3523,7 +3541,7 @@ static void cx88_card_setup(struct cx88_core *core)
cx_write(MO_GP0_IO, 0x8000); cx_write(MO_GP0_IO, 0x8000);
msleep(100); msleep(100);
cx_write(MO_SRST_IO, 0); cx_write(MO_SRST_IO, 0);
msleep(10); usleep_range(10000, 20000);
cx_write(MO_GP0_IO, 0x8080); cx_write(MO_GP0_IO, 0x8080);
msleep(100); msleep(100);
cx_write(MO_SRST_IO, 1); cx_write(MO_SRST_IO, 1);
...@@ -3531,9 +3549,8 @@ static void cx88_card_setup(struct cx88_core *core) ...@@ -3531,9 +3549,8 @@ static void cx88_card_setup(struct cx88_core *core)
break; break;
} /*end switch() */ } /*end switch() */
/* Setup tuners */ /* Setup tuners */
if ((core->board.radio_type != UNSET)) { if (core->board.radio_type != UNSET) {
tun_setup.mode_mask = T_RADIO; tun_setup.mode_mask = T_RADIO;
tun_setup.type = core->board.radio_type; tun_setup.type = core->board.radio_type;
tun_setup.addr = core->board.radio_addr; tun_setup.addr = core->board.radio_addr;
...@@ -3621,8 +3638,7 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci) ...@@ -3621,8 +3638,7 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
pci_write_config_byte(pci, CX88X_DEVCTRL, value); pci_write_config_byte(pci, CX88X_DEVCTRL, value);
} }
if (lat != UNSET) { if (lat != UNSET) {
pr_info("setting pci latency timer to %d\n", pr_info("setting pci latency timer to %d\n", latency);
latency);
pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency); pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency);
} }
return 0; return 0;
...@@ -3641,15 +3657,17 @@ int cx88_get_resources(const struct cx88_core *core, struct pci_dev *pci) ...@@ -3641,15 +3657,17 @@ int cx88_get_resources(const struct cx88_core *core, struct pci_dev *pci)
return -EBUSY; return -EBUSY;
} }
/* Allocate and initialize the cx88 core struct. One should hold the /*
* devlist mutex before calling this. */ * Allocate and initialize the cx88 core struct. One should hold the
* devlist mutex before calling this.
*/
struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
{ {
struct cx88_core *core; struct cx88_core *core;
int i; int i;
core = kzalloc(sizeof(*core), GFP_KERNEL); core = kzalloc(sizeof(*core), GFP_KERNEL);
if (core == NULL) if (!core)
return NULL; return NULL;
atomic_inc(&core->refcount); atomic_inc(&core->refcount);
...@@ -3701,7 +3719,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) ...@@ -3701,7 +3719,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
pci_resource_len(pci, 0)); pci_resource_len(pci, 0));
core->bmmio = (u8 __iomem *)core->lmmio; core->bmmio = (u8 __iomem *)core->lmmio;
if (core->lmmio == NULL) { if (!core->lmmio) {
release_mem_region(pci_resource_start(pci, 0), release_mem_region(pci_resource_start(pci, 0),
pci_resource_len(pci, 0)); pci_resource_len(pci, 0));
v4l2_ctrl_handler_free(&core->video_hdl); v4l2_ctrl_handler_free(&core->video_hdl);
...@@ -3715,7 +3733,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) ...@@ -3715,7 +3733,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
core->boardnr = UNSET; core->boardnr = UNSET;
if (card[core->nr] < ARRAY_SIZE(cx88_boards)) if (card[core->nr] < ARRAY_SIZE(cx88_boards))
core->boardnr = card[core->nr]; core->boardnr = card[core->nr];
for (i = 0; UNSET == core->boardnr && i < ARRAY_SIZE(cx88_subids); i++) for (i = 0; core->boardnr == UNSET && i < ARRAY_SIZE(cx88_subids); i++)
if (pci->subsystem_vendor == cx88_subids[i].subvendor && if (pci->subsystem_vendor == cx88_subids[i].subvendor &&
pci->subsystem_device == cx88_subids[i].subdevice) pci->subsystem_device == cx88_subids[i].subdevice)
core->boardnr = cx88_subids[i].card; core->boardnr = cx88_subids[i].card;
...@@ -3750,9 +3768,11 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) ...@@ -3750,9 +3768,11 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
/* load tuner module, if needed */ /* load tuner module, if needed */
if (core->board.tuner_type != UNSET) { if (core->board.tuner_type != UNSET) {
/* Ignore 0x6b and 0x6f on cx88 boards. /*
* Ignore 0x6b and 0x6f on cx88 boards.
* FusionHDTV5 RT Gold has an ir receiver at 0x6b * FusionHDTV5 RT Gold has an ir receiver at 0x6b
* and an RTC at 0x6f which can get corrupted if probed. */ * and an RTC at 0x6f which can get corrupted if probed.
*/
static const unsigned short tv_addrs[] = { static const unsigned short tv_addrs[] = {
0x42, 0x43, 0x4a, 0x4b, /* tda8290 */ 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
...@@ -3761,13 +3781,15 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) ...@@ -3761,13 +3781,15 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
}; };
int has_demod = (core->board.tda9887_conf & TDA9887_PRESENT); int has_demod = (core->board.tda9887_conf & TDA9887_PRESENT);
/* I don't trust the radio_type as is stored in the card /*
definitions, so we just probe for it. * I don't trust the radio_type as is stored in the card
The radio_type is sometimes missing, or set to UNSET but * definitions, so we just probe for it.
later code configures a tea5767. * The radio_type is sometimes missing, or set to UNSET but
* later code configures a tea5767.
*/ */
v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
"tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO)); "tuner", 0,
v4l2_i2c_tuner_addrs(ADDRS_RADIO));
if (has_demod) if (has_demod)
v4l2_i2c_new_subdev(&core->v4l2_dev, v4l2_i2c_new_subdev(&core->v4l2_dev,
&core->i2c_adap, "tuner", &core->i2c_adap, "tuner",
...@@ -3778,7 +3800,8 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) ...@@ -3778,7 +3800,8 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
0, has_demod ? tv_addrs + 4 : tv_addrs); 0, has_demod ? tv_addrs + 4 : tv_addrs);
} else { } else {
v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
"tuner", core->board.tuner_addr, NULL); "tuner", core->board.tuner_addr,
NULL);
} }
} }
......
...@@ -72,8 +72,10 @@ static DEFINE_MUTEX(devlist); ...@@ -72,8 +72,10 @@ static DEFINE_MUTEX(devlist);
#define NO_SYNC_LINE (-1U) #define NO_SYNC_LINE (-1U)
/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be /*
generated _after_ lpi lines are transferred. */ * @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be
* generated _after_ lpi lines are transferred.
*/
static __le32 *cx88_risc_field(__le32 *rp, struct scatterlist *sglist, static __le32 *cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
unsigned int offset, u32 sync_line, unsigned int offset, u32 sync_line,
unsigned int bpl, unsigned int padding, unsigned int bpl, unsigned int padding,
...@@ -102,28 +104,29 @@ static __le32 *cx88_risc_field(__le32 *rp, struct scatterlist *sglist, ...@@ -102,28 +104,29 @@ static __le32 *cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC; sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC;
else else
sol = RISC_SOL; sol = RISC_SOL;
if (bpl <= sg_dma_len(sg)-offset) { if (bpl <= sg_dma_len(sg) - offset) {
/* fits into current chunk */ /* fits into current chunk */
*(rp++) = cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl); *(rp++) = cpu_to_le32(RISC_WRITE | sol |
*(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); RISC_EOL | bpl);
*(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
offset += bpl; offset += bpl;
} else { } else {
/* scanline needs to be split */ /* scanline needs to be split */
todo = bpl; todo = bpl;
*(rp++) = cpu_to_le32(RISC_WRITE|sol| *(rp++) = cpu_to_le32(RISC_WRITE | sol |
(sg_dma_len(sg)-offset)); (sg_dma_len(sg) - offset));
*(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); *(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
todo -= (sg_dma_len(sg)-offset); todo -= (sg_dma_len(sg) - offset);
offset = 0; offset = 0;
sg = sg_next(sg); sg = sg_next(sg);
while (todo > sg_dma_len(sg)) { while (todo > sg_dma_len(sg)) {
*(rp++) = cpu_to_le32(RISC_WRITE| *(rp++) = cpu_to_le32(RISC_WRITE |
sg_dma_len(sg)); sg_dma_len(sg));
*(rp++) = cpu_to_le32(sg_dma_address(sg)); *(rp++) = cpu_to_le32(sg_dma_address(sg));
todo -= sg_dma_len(sg); todo -= sg_dma_len(sg);
sg = sg_next(sg); sg = sg_next(sg);
} }
*(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo); *(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo);
*(rp++) = cpu_to_le32(sg_dma_address(sg)); *(rp++) = cpu_to_le32(sg_dma_address(sg));
offset += todo; offset += todo;
} }
...@@ -147,16 +150,19 @@ int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, ...@@ -147,16 +150,19 @@ int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
if (bottom_offset != UNSET) if (bottom_offset != UNSET)
fields++; fields++;
/* estimate risc mem: worst case is one write per page border + /*
one write per scan line + syncs + jump (all 2 dwords). Padding * estimate risc mem: worst case is one write per page border +
can cause next bpl to start close to a page border. First DMA * one write per scan line + syncs + jump (all 2 dwords). Padding
region may be smaller than PAGE_SIZE */ * can cause next bpl to start close to a page border. First DMA
instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines); * region may be smaller than PAGE_SIZE
*/
instructions = fields * (1 + ((bpl + padding) * lines) /
PAGE_SIZE + lines);
instructions += 4; instructions += 4;
risc->size = instructions * 8; risc->size = instructions * 8;
risc->dma = 0; risc->dma = 0;
risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma);
if (risc->cpu == NULL) if (!risc->cpu)
return -ENOMEM; return -ENOMEM;
/* write risc instructions */ /* write risc instructions */
...@@ -166,13 +172,15 @@ int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, ...@@ -166,13 +172,15 @@ int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
bpl, padding, lines, 0, true); bpl, padding, lines, 0, true);
if (bottom_offset != UNSET) if (bottom_offset != UNSET)
rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200, rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200,
bpl, padding, lines, 0, top_offset == UNSET); bpl, padding, lines, 0,
top_offset == UNSET);
/* save pointer to jmp instruction address */ /* save pointer to jmp instruction address */
risc->jmp = rp; risc->jmp = rp;
WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
return 0; return 0;
} }
EXPORT_SYMBOL(cx88_risc_buffer);
int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
struct scatterlist *sglist, unsigned int bpl, struct scatterlist *sglist, unsigned int bpl,
...@@ -181,32 +189,38 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, ...@@ -181,32 +189,38 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
u32 instructions; u32 instructions;
__le32 *rp; __le32 *rp;
/* estimate risc mem: worst case is one write per page border + /*
one write per scan line + syncs + jump (all 2 dwords). Here * estimate risc mem: worst case is one write per page border +
there is no padding and no sync. First DMA region may be smaller * one write per scan line + syncs + jump (all 2 dwords). Here
than PAGE_SIZE */ * there is no padding and no sync. First DMA region may be smaller
* than PAGE_SIZE
*/
instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; instructions = 1 + (bpl * lines) / PAGE_SIZE + lines;
instructions += 3; instructions += 3;
risc->size = instructions * 8; risc->size = instructions * 8;
risc->dma = 0; risc->dma = 0;
risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma);
if (risc->cpu == NULL) if (!risc->cpu)
return -ENOMEM; return -ENOMEM;
/* write risc instructions */ /* write risc instructions */
rp = risc->cpu; rp = risc->cpu;
rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi, !lpi); rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0,
lines, lpi, !lpi);
/* save pointer to jmp instruction address */ /* save pointer to jmp instruction address */
risc->jmp = rp; risc->jmp = rp;
WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
return 0; return 0;
} }
EXPORT_SYMBOL(cx88_risc_databuffer);
/* ------------------------------------------------------------------ */ /*
/* our SRAM memory layout */ * our SRAM memory layout
*/
/* we are going to put all thr risc programs into host memory, so we /*
* we are going to put all thr risc programs into host memory, so we
* can use the whole SDRAM for the DMA fifos. To simplify things, we * can use the whole SDRAM for the DMA fifos. To simplify things, we
* use a static memory layout. That surely will waste memory in case * use a static memory layout. That surely will waste memory in case
* we don't use all DMA channels at the same time (which will be the * we don't use all DMA channels at the same time (which will be the
...@@ -330,6 +344,7 @@ const struct sram_channel cx88_sram_channels[] = { ...@@ -330,6 +344,7 @@ const struct sram_channel cx88_sram_channels[] = {
.cnt2_reg = MO_DMA27_CNT2, .cnt2_reg = MO_DMA27_CNT2,
}, },
}; };
EXPORT_SYMBOL(cx88_sram_channels);
int cx88_sram_channel_setup(struct cx88_core *core, int cx88_sram_channel_setup(struct cx88_core *core,
const struct sram_channel *ch, const struct sram_channel *ch,
...@@ -347,12 +362,12 @@ int cx88_sram_channel_setup(struct cx88_core *core, ...@@ -347,12 +362,12 @@ int cx88_sram_channel_setup(struct cx88_core *core,
/* write CDT */ /* write CDT */
for (i = 0; i < lines; i++) for (i = 0; i < lines; i++)
cx_write(cdt + 16*i, ch->fifo_start + bpl*i); cx_write(cdt + 16 * i, ch->fifo_start + bpl * i);
/* write CMDS */ /* write CMDS */
cx_write(ch->cmds_start + 0, risc); cx_write(ch->cmds_start + 0, risc);
cx_write(ch->cmds_start + 4, cdt); cx_write(ch->cmds_start + 4, cdt);
cx_write(ch->cmds_start + 8, (lines*16) >> 3); cx_write(ch->cmds_start + 8, (lines * 16) >> 3);
cx_write(ch->cmds_start + 12, ch->ctrl_start); cx_write(ch->cmds_start + 12, ch->ctrl_start);
cx_write(ch->cmds_start + 16, 64 >> 2); cx_write(ch->cmds_start + 16, 64 >> 2);
for (i = 20; i < 64; i += 4) for (i = 20; i < 64; i += 4)
...@@ -362,11 +377,12 @@ int cx88_sram_channel_setup(struct cx88_core *core, ...@@ -362,11 +377,12 @@ int cx88_sram_channel_setup(struct cx88_core *core,
cx_write(ch->ptr1_reg, ch->fifo_start); cx_write(ch->ptr1_reg, ch->fifo_start);
cx_write(ch->ptr2_reg, cdt); cx_write(ch->ptr2_reg, cdt);
cx_write(ch->cnt1_reg, (bpl >> 3) - 1); cx_write(ch->cnt1_reg, (bpl >> 3) - 1);
cx_write(ch->cnt2_reg, (lines*16) >> 3); cx_write(ch->cnt2_reg, (lines * 16) >> 3);
dprintk(2, "sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines); dprintk(2, "sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines);
return 0; return 0;
} }
EXPORT_SYMBOL(cx88_sram_channel_setup);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* debug helper code */ /* debug helper code */
...@@ -402,14 +418,13 @@ static int cx88_risc_decode(u32 risc) ...@@ -402,14 +418,13 @@ static int cx88_risc_decode(u32 risc)
dprintk0("0x%08x [ %s", risc, dprintk0("0x%08x [ %s", risc,
instr[risc >> 28] ? instr[risc >> 28] : "INVALID"); instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
for (i = ARRAY_SIZE(bits)-1; i >= 0; i--) for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--)
if (risc & (1 << (i + 12))) if (risc & (1 << (i + 12)))
pr_cont(" %s", bits[i]); pr_cont(" %s", bits[i]);
pr_cont(" count=%d ]\n", risc & 0xfff); pr_cont(" count=%d ]\n", risc & 0xfff);
return incr[risc >> 28] ? incr[risc >> 28] : 1; return incr[risc >> 28] ? incr[risc >> 28] : 1;
} }
void cx88_sram_channel_dump(struct cx88_core *core, void cx88_sram_channel_dump(struct cx88_core *core,
const struct sram_channel *ch) const struct sram_channel *ch)
{ {
...@@ -429,14 +444,12 @@ void cx88_sram_channel_dump(struct cx88_core *core, ...@@ -429,14 +444,12 @@ void cx88_sram_channel_dump(struct cx88_core *core,
u32 risc; u32 risc;
unsigned int i, j, n; unsigned int i, j, n;
dprintk0("%s - dma channel status dump\n", dprintk0("%s - dma channel status dump\n", ch->name);
ch->name);
for (i = 0; i < ARRAY_SIZE(name); i++) for (i = 0; i < ARRAY_SIZE(name); i++)
dprintk0(" cmds: %-12s: 0x%08x\n", dprintk0(" cmds: %-12s: 0x%08x\n",
name[i], name[i], cx_read(ch->cmds_start + 4 * i));
cx_read(ch->cmds_start + 4*i));
for (n = 1, i = 0; i < 4; i++) { for (n = 1, i = 0; i < 4; i++) {
risc = cx_read(ch->cmds_start + 4 * (i+11)); risc = cx_read(ch->cmds_start + 4 * (i + 11));
pr_cont(" risc%d: ", i); pr_cont(" risc%d: ", i);
if (--n) if (--n)
pr_cont("0x%08x [ arg #%d ]\n", risc, n); pr_cont("0x%08x [ arg #%d ]\n", risc, n);
...@@ -448,14 +461,14 @@ void cx88_sram_channel_dump(struct cx88_core *core, ...@@ -448,14 +461,14 @@ void cx88_sram_channel_dump(struct cx88_core *core,
dprintk0(" iq %x: ", i); dprintk0(" iq %x: ", i);
n = cx88_risc_decode(risc); n = cx88_risc_decode(risc);
for (j = 1; j < n; j++) { for (j = 1; j < n; j++) {
risc = cx_read(ch->ctrl_start + 4 * (i+j)); risc = cx_read(ch->ctrl_start + 4 * (i + j));
pr_cont(" iq %x: 0x%08x [ arg #%d ]\n", pr_cont(" iq %x: 0x%08x [ arg #%d ]\n",
i + j, risc, j); i + j, risc, j);
} }
} }
dprintk0("fifo: 0x%08x -> 0x%x\n", dprintk0("fifo: 0x%08x -> 0x%x\n",
ch->fifo_start, ch->fifo_start+ch->fifo_size); ch->fifo_start, ch->fifo_start + ch->fifo_size);
dprintk0("ctrl: 0x%08x -> 0x%x\n", dprintk0("ctrl: 0x%08x -> 0x%x\n",
ch->ctrl_start, ch->ctrl_start + 6 * 16); ch->ctrl_start, ch->ctrl_start + 6 * 16);
dprintk0(" ptr1_reg: 0x%08x\n", cx_read(ch->ptr1_reg)); dprintk0(" ptr1_reg: 0x%08x\n", cx_read(ch->ptr1_reg));
...@@ -463,6 +476,7 @@ void cx88_sram_channel_dump(struct cx88_core *core, ...@@ -463,6 +476,7 @@ void cx88_sram_channel_dump(struct cx88_core *core,
dprintk0(" cnt1_reg: 0x%08x\n", cx_read(ch->cnt1_reg)); dprintk0(" cnt1_reg: 0x%08x\n", cx_read(ch->cnt1_reg));
dprintk0(" cnt2_reg: 0x%08x\n", cx_read(ch->cnt2_reg)); dprintk0(" cnt2_reg: 0x%08x\n", cx_read(ch->cnt2_reg));
} }
EXPORT_SYMBOL(cx88_sram_channel_dump);
static const char *cx88_pci_irqs[32] = { static const char *cx88_pci_irqs[32] = {
"vid", "aud", "ts", "vip", "hst", "5", "6", "tm1", "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
...@@ -490,6 +504,7 @@ void cx88_print_irqbits(const char *tag, const char *strings[], ...@@ -490,6 +504,7 @@ void cx88_print_irqbits(const char *tag, const char *strings[],
} }
pr_cont("\n"); pr_cont("\n");
} }
EXPORT_SYMBOL(cx88_print_irqbits);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -507,6 +522,7 @@ int cx88_core_irq(struct cx88_core *core, u32 status) ...@@ -507,6 +522,7 @@ int cx88_core_irq(struct cx88_core *core, u32 status)
status, core->pci_irqmask); status, core->pci_irqmask);
return handled; return handled;
} }
EXPORT_SYMBOL(cx88_core_irq);
void cx88_wakeup(struct cx88_core *core, void cx88_wakeup(struct cx88_core *core,
struct cx88_dmaqueue *q, u32 count) struct cx88_dmaqueue *q, u32 count)
...@@ -521,6 +537,7 @@ void cx88_wakeup(struct cx88_core *core, ...@@ -521,6 +537,7 @@ void cx88_wakeup(struct cx88_core *core,
list_del(&buf->list); list_del(&buf->list);
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
} }
EXPORT_SYMBOL(cx88_wakeup);
void cx88_shutdown(struct cx88_core *core) void cx88_shutdown(struct cx88_core *core)
{ {
...@@ -545,6 +562,7 @@ void cx88_shutdown(struct cx88_core *core) ...@@ -545,6 +562,7 @@ void cx88_shutdown(struct cx88_core *core)
/* stop capturing */ /* stop capturing */
cx_write(VID_CAPTURE_CONTROL, 0); cx_write(VID_CAPTURE_CONTROL, 0);
} }
EXPORT_SYMBOL(cx88_shutdown);
int cx88_reset(struct cx88_core *core) int cx88_reset(struct cx88_core *core)
{ {
...@@ -560,13 +578,15 @@ int cx88_reset(struct cx88_core *core) ...@@ -560,13 +578,15 @@ int cx88_reset(struct cx88_core *core)
msleep(100); msleep(100);
/* init sram */ /* init sram */
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], 720*4, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21],
720 * 4, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 188*4, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28],
188 * 4, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27], 128, 0); cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27], 128, 0);
/* misc init ... */ /* misc init ... */
...@@ -594,11 +614,12 @@ int cx88_reset(struct cx88_core *core) ...@@ -594,11 +614,12 @@ int cx88_reset(struct cx88_core *core)
/* Reset on-board parts */ /* Reset on-board parts */
cx_write(MO_SRST_IO, 0); cx_write(MO_SRST_IO, 0);
msleep(10); usleep_range(10000, 20000);
cx_write(MO_SRST_IO, 1); cx_write(MO_SRST_IO, 1);
return 0; return 0;
} }
EXPORT_SYMBOL(cx88_reset);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -628,10 +649,11 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm) ...@@ -628,10 +649,11 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm)
if (norm & V4L2_STD_NTSC) // All NTSC/M and variants if (norm & V4L2_STD_NTSC) // All NTSC/M and variants
return 28636360; // 3.57954545 MHz +/- 10 Hz return 28636360; // 3.57954545 MHz +/- 10 Hz
/* SECAM have also different sub carrier for chroma, /*
but step_db and step_dr, at cx88_set_tvnorm already handles that. * SECAM have also different sub carrier for chroma,
* but step_db and step_dr, at cx88_set_tvnorm already handles that.
The same FSC applies to PAL/BGDKIH, PAL/60, NTSC/4.43 and PAL/N *
* The same FSC applies to PAL/BGDKIH, PAL/60, NTSC/4.43 and PAL/N
*/ */
return 35468950; // 4.43361875 MHz +/- 5 Hz return 35468950; // 4.43361875 MHz +/- 5 Hz
...@@ -639,13 +661,12 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm) ...@@ -639,13 +661,12 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm)
static inline unsigned int norm_htotal(v4l2_std_id norm) static inline unsigned int norm_htotal(v4l2_std_id norm)
{ {
unsigned int fsc4 = norm_fsc8(norm) / 2;
unsigned int fsc4 = norm_fsc8(norm)/2;
/* returns 4*FSC / vtotal / frames per seconds */ /* returns 4*FSC / vtotal / frames per seconds */
return (norm & V4L2_STD_625_50) ? return (norm & V4L2_STD_625_50) ?
((fsc4+312)/625+12)/25 : ((fsc4 + 312) / 625 + 12) / 25 :
((fsc4+262)/525*1001+15000)/30000; ((fsc4 + 262) / 525 * 1001 + 15000) / 30000;
} }
static inline unsigned int norm_vbipack(v4l2_std_id norm) static inline unsigned int norm_vbipack(v4l2_std_id norm)
...@@ -653,8 +674,8 @@ static inline unsigned int norm_vbipack(v4l2_std_id norm) ...@@ -653,8 +674,8 @@ static inline unsigned int norm_vbipack(v4l2_std_id norm)
return (norm & V4L2_STD_625_50) ? 511 : 400; return (norm & V4L2_STD_625_50) ? 511 : 400;
} }
int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int height, int cx88_set_scale(struct cx88_core *core, unsigned int width,
enum v4l2_field field) unsigned int height, enum v4l2_field field)
{ {
unsigned int swidth = norm_swidth(core->tvnorm); unsigned int swidth = norm_swidth(core->tvnorm);
unsigned int sheight = norm_maxh(core->tvnorm); unsigned int sheight = norm_maxh(core->tvnorm);
...@@ -721,6 +742,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig ...@@ -721,6 +742,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
return 0; return 0;
} }
EXPORT_SYMBOL(cx88_set_scale);
static const u32 xtal = 28636363; static const u32 xtal = 28636363;
...@@ -749,13 +771,13 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq) ...@@ -749,13 +771,13 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
cx_write(MO_PLL_REG, reg); cx_write(MO_PLL_REG, reg);
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
reg = cx_read(MO_DEVICE_STATUS); reg = cx_read(MO_DEVICE_STATUS);
if (reg & (1<<2)) { if (reg & (1 << 2)) {
dprintk(1, "pll locked [pre=%d,ofreq=%d]\n", dprintk(1, "pll locked [pre=%d,ofreq=%d]\n",
prescale, ofreq); prescale, ofreq);
return 0; return 0;
} }
dprintk(1, "pll not locked yet, waiting ...\n"); dprintk(1, "pll not locked yet, waiting ...\n");
msleep(10); usleep_range(10000, 20000);
} }
dprintk(1, "pll NOT locked [pre=%d,ofreq=%d]\n", prescale, ofreq); dprintk(1, "pll NOT locked [pre=%d,ofreq=%d]\n", prescale, ofreq);
return -1; return -1;
...@@ -764,9 +786,9 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq) ...@@ -764,9 +786,9 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
int cx88_start_audio_dma(struct cx88_core *core) int cx88_start_audio_dma(struct cx88_core *core)
{ {
/* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */ /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */
int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4; int bpl = cx88_sram_channels[SRAM_CH25].fifo_size / 4;
int rds_bpl = cx88_sram_channels[SRAM_CH27].fifo_size/AUD_RDS_LINES; int rds_bpl = cx88_sram_channels[SRAM_CH27].fifo_size / AUD_RDS_LINES;
/* If downstream RISC is enabled, bail out; ALSA is managing DMA */ /* If downstream RISC is enabled, bail out; ALSA is managing DMA */
if (cx_read(MO_AUD_DMACNTRL) & 0x10) if (cx_read(MO_AUD_DMACNTRL) & 0x10)
...@@ -803,8 +825,8 @@ static int set_tvaudio(struct cx88_core *core) ...@@ -803,8 +825,8 @@ static int set_tvaudio(struct cx88_core *core)
{ {
v4l2_std_id norm = core->tvnorm; v4l2_std_id norm = core->tvnorm;
if (CX88_VMUX_TELEVISION != INPUT(core->input).type && if (INPUT(core->input).type != CX88_VMUX_TELEVISION &&
CX88_VMUX_CABLE != INPUT(core->input).type) INPUT(core->input).type != CX88_VMUX_CABLE)
return 0; return 0;
if (V4L2_STD_PAL_BG & norm) { if (V4L2_STD_PAL_BG & norm) {
...@@ -819,7 +841,8 @@ static int set_tvaudio(struct cx88_core *core) ...@@ -819,7 +841,8 @@ static int set_tvaudio(struct cx88_core *core)
} else if (V4L2_STD_SECAM_L & norm) { } else if (V4L2_STD_SECAM_L & norm) {
core->tvaudio = WW_L; core->tvaudio = WW_L;
} else if ((V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H) & norm) { } else if ((V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H) &
norm) {
core->tvaudio = WW_BG; core->tvaudio = WW_BG;
} else if (V4L2_STD_SECAM_DK & norm) { } else if (V4L2_STD_SECAM_DK & norm) {
...@@ -844,15 +867,13 @@ static int set_tvaudio(struct cx88_core *core) ...@@ -844,15 +867,13 @@ static int set_tvaudio(struct cx88_core *core)
/* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */
/* /*
This should be needed only on cx88-alsa. It seems that some cx88 chips have * This should be needed only on cx88-alsa. It seems that some cx88 chips have
bugs and does require DMA enabled for it to work. * bugs and does require DMA enabled for it to work.
*/ */
cx88_start_audio_dma(core); cx88_start_audio_dma(core);
return 0; return 0;
} }
int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
{ {
u32 fsc8; u32 fsc8;
...@@ -916,8 +937,10 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) ...@@ -916,8 +937,10 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
dprintk(1, "set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", dprintk(1, "set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n",
cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
/* Chroma AGC must be disabled if SECAM is used, we enable it /*
by default on PAL and NTSC */ * Chroma AGC must be disabled if SECAM is used, we enable it
* by default on PAL and NTSC
*/
cx_andor(MO_INPUT_FORMAT, 0x40f, cx_andor(MO_INPUT_FORMAT, 0x40f,
norm & V4L2_STD_SECAM ? cxiformat : cxiformat | 0x400); norm & V4L2_STD_SECAM ? cxiformat : cxiformat | 0x400);
...@@ -952,7 +975,8 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) ...@@ -952,7 +975,8 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
agcdelay = vdec_clock * 68 / 20000000 + 15; agcdelay = vdec_clock * 68 / 20000000 + 15;
dprintk(1, dprintk(1,
"set_tvnorm: MO_AGC_BURST 0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n", "set_tvnorm: MO_AGC_BURST 0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n",
(bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST), bdelay, agcdelay); (bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST),
bdelay, agcdelay);
cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay); cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay);
// htotal // htotal
...@@ -966,7 +990,7 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) ...@@ -966,7 +990,7 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
// vbi stuff, set vbi offset to 10 (for 20 Clk*2 pixels), this makes // vbi stuff, set vbi offset to 10 (for 20 Clk*2 pixels), this makes
// the effective vbi offset ~244 samples, the same as the Bt8x8 // the effective vbi offset ~244 samples, the same as the Bt8x8
cx_write(MO_VBI_PACKET, (10<<11) | norm_vbipack(norm)); cx_write(MO_VBI_PACKET, (10 << 11) | norm_vbipack(norm));
// this is needed as well to set all tvnorm parameter // this is needed as well to set all tvnorm parameter
cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED); cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
...@@ -977,12 +1001,16 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) ...@@ -977,12 +1001,16 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
// tell i2c chips // tell i2c chips
call_all(core, video, s_std, norm); call_all(core, video, s_std, norm);
/* The chroma_agc control should be inaccessible if the video format is SECAM */ /*
* The chroma_agc control should be inaccessible
* if the video format is SECAM
*/
v4l2_ctrl_grab(core->chroma_agc, cxiformat == VideoFormatSECAM); v4l2_ctrl_grab(core->chroma_agc, cxiformat == VideoFormatSECAM);
// done // done
return 0; return 0;
} }
EXPORT_SYMBOL(cx88_set_tvnorm);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -1007,6 +1035,7 @@ void cx88_vdev_init(struct cx88_core *core, ...@@ -1007,6 +1035,7 @@ void cx88_vdev_init(struct cx88_core *core,
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
core->name, type, core->board.name); core->name, type, core->board.name);
} }
EXPORT_SYMBOL(cx88_vdev_init);
struct cx88_core *cx88_core_get(struct pci_dev *pci) struct cx88_core *cx88_core_get(struct pci_dev *pci)
{ {
...@@ -1029,7 +1058,7 @@ struct cx88_core *cx88_core_get(struct pci_dev *pci) ...@@ -1029,7 +1058,7 @@ struct cx88_core *cx88_core_get(struct pci_dev *pci)
} }
core = cx88_core_create(pci, cx88_devcount); core = cx88_core_create(pci, cx88_devcount);
if (core != NULL) { if (core) {
cx88_devcount++; cx88_devcount++;
list_add_tail(&core->devlist, &cx88_devlist); list_add_tail(&core->devlist, &cx88_devlist);
} }
...@@ -1037,6 +1066,7 @@ struct cx88_core *cx88_core_get(struct pci_dev *pci) ...@@ -1037,6 +1066,7 @@ struct cx88_core *cx88_core_get(struct pci_dev *pci)
mutex_unlock(&devlist); mutex_unlock(&devlist);
return core; return core;
} }
EXPORT_SYMBOL(cx88_core_get);
void cx88_core_put(struct cx88_core *core, struct pci_dev *pci) void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
{ {
...@@ -1062,29 +1092,4 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci) ...@@ -1062,29 +1092,4 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
v4l2_device_unregister(&core->v4l2_dev); v4l2_device_unregister(&core->v4l2_dev);
kfree(core); kfree(core);
} }
/* ------------------------------------------------------------------ */
EXPORT_SYMBOL(cx88_print_irqbits);
EXPORT_SYMBOL(cx88_core_irq);
EXPORT_SYMBOL(cx88_wakeup);
EXPORT_SYMBOL(cx88_reset);
EXPORT_SYMBOL(cx88_shutdown);
EXPORT_SYMBOL(cx88_risc_buffer);
EXPORT_SYMBOL(cx88_risc_databuffer);
EXPORT_SYMBOL(cx88_sram_channels);
EXPORT_SYMBOL(cx88_sram_channel_setup);
EXPORT_SYMBOL(cx88_sram_channel_dump);
EXPORT_SYMBOL(cx88_set_tvnorm);
EXPORT_SYMBOL(cx88_set_scale);
EXPORT_SYMBOL(cx88_vdev_init);
EXPORT_SYMBOL(cx88_core_get);
EXPORT_SYMBOL(cx88_core_put); EXPORT_SYMBOL(cx88_core_put);
EXPORT_SYMBOL(cx88_ir_start);
EXPORT_SYMBOL(cx88_ir_stop);
...@@ -31,18 +31,22 @@ ...@@ -31,18 +31,22 @@
#define baseband_freq(carrier, srate, tone) ((s32)( \ #define baseband_freq(carrier, srate, tone) ((s32)( \
(compat_remainder(carrier + tone, srate)) / srate * 2 * INT_PI)) (compat_remainder(carrier + tone, srate)) / srate * 2 * INT_PI))
/* We calculate the baseband frequencies of the carrier and the pilot tones /*
* based on the the sampling rate of the audio rds fifo. */ * We calculate the baseband frequencies of the carrier and the pilot tones
* based on the the sampling rate of the audio rds fifo.
*/
#define FREQ_A2_CARRIER baseband_freq(54687.5, 2689.36, 0.0) #define FREQ_A2_CARRIER baseband_freq(54687.5, 2689.36, 0.0)
#define FREQ_A2_DUAL baseband_freq(54687.5, 2689.36, 274.1) #define FREQ_A2_DUAL baseband_freq(54687.5, 2689.36, 274.1)
#define FREQ_A2_STEREO baseband_freq(54687.5, 2689.36, 117.5) #define FREQ_A2_STEREO baseband_freq(54687.5, 2689.36, 117.5)
/* The frequencies below are from the reference driver. They probably need /*
* The frequencies below are from the reference driver. They probably need
* further adjustments, because they are not tested at all. You may even need * further adjustments, because they are not tested at all. You may even need
* to play a bit with the registers of the chip to select the proper signal * to play a bit with the registers of the chip to select the proper signal
* for the input of the audio rds fifo, and measure it's sampling rate to * for the input of the audio rds fifo, and measure it's sampling rate to
* calculate the proper baseband frequencies... */ * calculate the proper baseband frequencies...
*/
#define FREQ_A2M_CARRIER ((s32)(2.114516 * 32768.0)) #define FREQ_A2M_CARRIER ((s32)(2.114516 * 32768.0))
#define FREQ_A2M_DUAL ((s32)(2.754916 * 32768.0)) #define FREQ_A2M_DUAL ((s32)(2.754916 * 32768.0))
...@@ -83,8 +87,10 @@ static s32 int_cos(u32 x) ...@@ -83,8 +87,10 @@ static s32 int_cos(u32 x)
x = x % INT_PI; x = x % INT_PI;
if (x > INT_PI / 2) if (x > INT_PI / 2)
return -int_cos(INT_PI / 2 - (x % (INT_PI / 2))); return -int_cos(INT_PI / 2 - (x % (INT_PI / 2)));
/* Now x is between 0 and INT_PI/2. /*
* To calculate cos(x) we use it's Taylor polinom. */ * Now x is between 0 and INT_PI/2.
* To calculate cos(x) we use it's Taylor polinom.
*/
t2 = x * x / 32768 / 2; t2 = x * x / 32768 / 2;
t4 = t2 * x / 32768 * x / 32768 / 3 / 4; t4 = t2 * x / 32768 * x / 32768 / 3 / 4;
t6 = t4 * x / 32768 * x / 32768 / 5 / 6; t6 = t4 * x / 32768 * x / 32768 / 5 / 6;
...@@ -95,8 +101,10 @@ static s32 int_cos(u32 x) ...@@ -95,8 +101,10 @@ static s32 int_cos(u32 x)
static u32 int_goertzel(s16 x[], u32 N, u32 freq) static u32 int_goertzel(s16 x[], u32 N, u32 freq)
{ {
/* We use the Goertzel algorithm to determine the power of the /*
* given frequency in the signal */ * We use the Goertzel algorithm to determine the power of the
* given frequency in the signal
*/
s32 s_prev = 0; s32 s_prev = 0;
s32 s_prev2 = 0; s32 s_prev2 = 0;
s32 coeff = 2 * int_cos(freq); s32 coeff = 2 * int_cos(freq);
...@@ -115,12 +123,14 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq) ...@@ -115,12 +123,14 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq)
tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev - tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev -
(s64)coeff * s_prev2 * s_prev / 32768; (s64)coeff * s_prev2 * s_prev / 32768;
/* XXX: N must be low enough so that N*N fits in s32. /*
* Else we need two divisions. */ * XXX: N must be low enough so that N*N fits in s32.
* Else we need two divisions.
*/
divisor = N * N; divisor = N * N;
do_div(tmp, divisor); do_div(tmp, divisor);
return (u32) tmp; return (u32)tmp;
} }
static u32 freq_magnitude(s16 x[], u32 N, u32 freq) static u32 freq_magnitude(s16 x[], u32 N, u32 freq)
...@@ -187,7 +197,8 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N) ...@@ -187,7 +197,8 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
dual = freq_magnitude(x, N, dual_freq); dual = freq_magnitude(x, N, dual_freq);
noise = noise_magnitude(x, N, FREQ_NOISE_START, FREQ_NOISE_END); noise = noise_magnitude(x, N, FREQ_NOISE_START, FREQ_NOISE_END);
dprintk(1, "detect a2/a2m/eiaj: carrier=%d, stereo=%d, dual=%d, noise=%d\n", dprintk(1,
"detect a2/a2m/eiaj: carrier=%d, stereo=%d, dual=%d, noise=%d\n",
carrier, stereo, dual, noise); carrier, stereo, dual, noise);
if (stereo > dual) if (stereo > dual)
...@@ -201,8 +212,10 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N) ...@@ -201,8 +212,10 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
(carrier < max(stereo, dual) * 6) && (carrier < max(stereo, dual) * 6) &&
(carrier > 20 && carrier < 200) && (carrier > 20 && carrier < 200) &&
(max(stereo, dual) > min(stereo, dual))) { (max(stereo, dual) > min(stereo, dual))) {
/* For EIAJ the carrier is always present, /*
so we probably don't need noise detection */ * For EIAJ the carrier is always present,
* so we probably don't need noise detection
*/
return ret; return ret;
} }
} else { } else {
...@@ -243,7 +256,8 @@ static s16 *read_rds_samples(struct cx88_core *core, u32 *N) ...@@ -243,7 +256,8 @@ static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
u32 current_address = cx_read(srch->ptr1_reg); u32 current_address = cx_read(srch->ptr1_reg);
u32 offset = (current_address - srch->fifo_start + bpl); u32 offset = (current_address - srch->fifo_start + bpl);
dprintk(1, "read RDS samples: current_address=%08x (offset=%08x), sample_count=%d, aud_intstat=%08x\n", dprintk(1,
"read RDS samples: current_address=%08x (offset=%08x), sample_count=%d, aud_intstat=%08x\n",
current_address, current_address,
current_address - srch->fifo_start, sample_count, current_address - srch->fifo_start, sample_count,
cx_read(MO_AUD_INTSTAT)); cx_read(MO_AUD_INTSTAT));
......
...@@ -711,10 +711,10 @@ static int cx24116_reset_device(struct dvb_frontend *fe) ...@@ -711,10 +711,10 @@ static int cx24116_reset_device(struct dvb_frontend *fe)
/* Reset the part */ /* Reset the part */
/* Put the cx24116 into reset */ /* Put the cx24116 into reset */
cx_write(MO_SRST_IO, 0); cx_write(MO_SRST_IO, 0);
msleep(10); usleep_range(10000, 20000);
/* Take the cx24116 out of reset */ /* Take the cx24116 out of reset */
cx_write(MO_SRST_IO, 1); cx_write(MO_SRST_IO, 1);
msleep(10); usleep_range(10000, 20000);
return 0; return 0;
} }
...@@ -812,8 +812,6 @@ static int cx8802_alloc_frontends(struct cx8802_dev *dev) ...@@ -812,8 +812,6 @@ static int cx8802_alloc_frontends(struct cx8802_dev *dev)
return 0; return 0;
} }
static const u8 samsung_smt_7020_inittab[] = { static const u8 samsung_smt_7020_inittab[] = {
0x01, 0x15, 0x01, 0x15,
0x02, 0x00, 0x02, 0x00,
...@@ -865,7 +863,6 @@ static const u8 samsung_smt_7020_inittab[] = { ...@@ -865,7 +863,6 @@ static const u8 samsung_smt_7020_inittab[] = {
0xff, 0xff, 0xff, 0xff,
}; };
static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe) static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
...@@ -987,7 +984,6 @@ static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe, ...@@ -987,7 +984,6 @@ static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
return 0; return 0;
} }
static const struct stv0299_config samsung_stv0299_config = { static const struct stv0299_config samsung_stv0299_config = {
.demod_address = 0x68, .demod_address = 0x68,
.inittab = samsung_smt_7020_inittab, .inittab = samsung_smt_7020_inittab,
...@@ -1029,7 +1025,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1029,7 +1025,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(cx22702_attach, fe0->dvb.frontend = dvb_attach(cx22702_attach,
&connexant_refboard_config, &connexant_refboard_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x61, &core->i2c_adap, 0x61, &core->i2c_adap,
DVB_PLL_THOMSON_DTT759X)) DVB_PLL_THOMSON_DTT759X))
...@@ -1043,7 +1039,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1043,7 +1039,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(cx22702_attach, fe0->dvb.frontend = dvb_attach(cx22702_attach,
&connexant_refboard_config, &connexant_refboard_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x60, &core->i2c_adap, 0x60, &core->i2c_adap,
DVB_PLL_THOMSON_DTT7579)) DVB_PLL_THOMSON_DTT7579))
...@@ -1057,7 +1053,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1057,7 +1053,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(cx22702_attach, fe0->dvb.frontend = dvb_attach(cx22702_attach,
&hauppauge_hvr_config, &hauppauge_hvr_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_PHILIPS_FMD1216ME_MK3)) TUNER_PHILIPS_FMD1216ME_MK3))
...@@ -1068,7 +1064,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1068,7 +1064,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(cx22702_attach, fe0->dvb.frontend = dvb_attach(cx22702_attach,
&hauppauge_hvr_config, &hauppauge_hvr_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_PHILIPS_FMD1216MEX_MK3)) TUNER_PHILIPS_FMD1216MEX_MK3))
...@@ -1111,7 +1107,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1111,7 +1107,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(mt352_attach, fe0->dvb.frontend = dvb_attach(mt352_attach,
&dvico_fusionhdtv, &dvico_fusionhdtv,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
goto frontend_detach; goto frontend_detach;
...@@ -1121,19 +1117,21 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1121,19 +1117,21 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(zl10353_attach, fe0->dvb.frontend = dvb_attach(zl10353_attach,
&dvico_fusionhdtv_plus_v1_1, &dvico_fusionhdtv_plus_v1_1,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
goto frontend_detach; goto frontend_detach;
} }
break; break;
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
/* The tin box says DEE1601, but it seems to be DTT7579 /*
* compatible, with a slightly different MT352 AGC gain. */ * The tin box says DEE1601, but it seems to be DTT7579
* compatible, with a slightly different MT352 AGC gain.
*/
fe0->dvb.frontend = dvb_attach(mt352_attach, fe0->dvb.frontend = dvb_attach(mt352_attach,
&dvico_fusionhdtv_dual, &dvico_fusionhdtv_dual,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
goto frontend_detach; goto frontend_detach;
...@@ -1143,7 +1141,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1143,7 +1141,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(zl10353_attach, fe0->dvb.frontend = dvb_attach(zl10353_attach,
&dvico_fusionhdtv_plus_v1_1, &dvico_fusionhdtv_plus_v1_1,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
goto frontend_detach; goto frontend_detach;
...@@ -1153,7 +1151,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1153,7 +1151,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(mt352_attach, fe0->dvb.frontend = dvb_attach(mt352_attach,
&dvico_fusionhdtv, &dvico_fusionhdtv,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x61, NULL, DVB_PLL_LG_Z201)) 0x61, NULL, DVB_PLL_LG_Z201))
goto frontend_detach; goto frontend_detach;
...@@ -1165,7 +1163,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1165,7 +1163,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(mt352_attach, fe0->dvb.frontend = dvb_attach(mt352_attach,
&dntv_live_dvbt_config, &dntv_live_dvbt_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
0x61, NULL, DVB_PLL_UNKNOWN_1)) 0x61, NULL, DVB_PLL_UNKNOWN_1))
goto frontend_detach; goto frontend_detach;
...@@ -1174,9 +1172,10 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1174,9 +1172,10 @@ static int dvb_register(struct cx8802_dev *dev)
case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) #if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054)
/* MT352 is on a secondary I2C bus made from some GPIO lines */ /* MT352 is on a secondary I2C bus made from some GPIO lines */
fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, fe0->dvb.frontend = dvb_attach(mt352_attach,
&dntv_live_dvbt_pro_config,
&dev->vp3054->adap); &dev->vp3054->adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_PHILIPS_FMD1216ME_MK3)) TUNER_PHILIPS_FMD1216ME_MK3))
...@@ -1190,7 +1189,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1190,7 +1189,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(zl10353_attach, fe0->dvb.frontend = dvb_attach(zl10353_attach,
&dvico_fusionhdtv_hybrid, &dvico_fusionhdtv_hybrid,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_THOMSON_FE6600)) TUNER_THOMSON_FE6600))
...@@ -1201,7 +1200,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1201,7 +1200,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(zl10353_attach, fe0->dvb.frontend = dvb_attach(zl10353_attach,
&dvico_fusionhdtv_xc3028, &dvico_fusionhdtv_xc3028,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend == NULL) if (!fe0->dvb.frontend)
fe0->dvb.frontend = dvb_attach(mt352_attach, fe0->dvb.frontend = dvb_attach(mt352_attach,
&dvico_fusionhdtv_mt352_xc3028, &dvico_fusionhdtv_mt352_xc3028,
&core->i2c_adap); &core->i2c_adap);
...@@ -1218,7 +1217,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1218,7 +1217,7 @@ static int dvb_register(struct cx8802_dev *dev)
case CX88_BOARD_PCHDTV_HD3000: case CX88_BOARD_PCHDTV_HD3000:
fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_THOMSON_DTT761X)) TUNER_THOMSON_DTT761X))
...@@ -1239,7 +1238,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1239,7 +1238,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(lgdt330x_attach, fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
&fusionhdtv_3_gold, &fusionhdtv_3_gold,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_MICROTUNE_4042FI5)) TUNER_MICROTUNE_4042FI5))
...@@ -1257,7 +1256,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1257,7 +1256,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(lgdt330x_attach, fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
&fusionhdtv_3_gold, &fusionhdtv_3_gold,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_THOMSON_DTT761X)) TUNER_THOMSON_DTT761X))
...@@ -1275,7 +1274,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1275,7 +1274,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(lgdt330x_attach, fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
&fusionhdtv_5_gold, &fusionhdtv_5_gold,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_LG_TDVS_H06XF)) TUNER_LG_TDVS_H06XF))
...@@ -1296,7 +1295,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1296,7 +1295,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(lgdt330x_attach, fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
&pchdtv_hd5500, &pchdtv_hd5500,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_LG_TDVS_H06XF)) TUNER_LG_TDVS_H06XF))
...@@ -1310,7 +1309,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1310,7 +1309,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(nxt200x_attach, fe0->dvb.frontend = dvb_attach(nxt200x_attach,
&ati_hdtvwonder, &ati_hdtvwonder,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x61, &core->i2c_adap, 0x61,
TUNER_PHILIPS_TUV1236D)) TUNER_PHILIPS_TUV1236D))
...@@ -1331,8 +1330,8 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1331,8 +1330,8 @@ static int dvb_register(struct cx8802_dev *dev)
override_tone = false; override_tone = false;
if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
&core->i2c_adap, 0x08, ISL6421_DCL, 0x00, &core->i2c_adap, 0x08, ISL6421_DCL,
override_tone)) 0x00, override_tone))
goto frontend_detach; goto frontend_detach;
} }
break; break;
...@@ -1358,7 +1357,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1358,7 +1357,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(s5h1409_attach, fe0->dvb.frontend = dvb_attach(s5h1409_attach,
&pinnacle_pctv_hd_800i_config, &pinnacle_pctv_hd_800i_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
&core->i2c_adap, &core->i2c_adap,
&pinnacle_pctv_hd_800i_tuner_config)) &pinnacle_pctv_hd_800i_tuner_config))
...@@ -1369,7 +1368,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1369,7 +1368,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(s5h1409_attach, fe0->dvb.frontend = dvb_attach(s5h1409_attach,
&dvico_hdtv5_pci_nano_config, &dvico_hdtv5_pci_nano_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
struct dvb_frontend *fe; struct dvb_frontend *fe;
struct xc2028_config cfg = { struct xc2028_config cfg = {
.i2c_adap = &core->i2c_adap, .i2c_adap = &core->i2c_adap,
...@@ -1383,7 +1382,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1383,7 +1382,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe = dvb_attach(xc2028_attach, fe = dvb_attach(xc2028_attach,
fe0->dvb.frontend, &cfg); fe0->dvb.frontend, &cfg);
if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) if (fe && fe->ops.tuner_ops.set_config)
fe->ops.tuner_ops.set_config(fe, &ctl); fe->ops.tuner_ops.set_config(fe, &ctl);
} }
break; break;
...@@ -1436,7 +1435,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1436,7 +1435,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(s5h1411_attach, fe0->dvb.frontend = dvb_attach(s5h1411_attach,
&dvico_fusionhdtv7_config, &dvico_fusionhdtv7_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
&core->i2c_adap, &core->i2c_adap,
&dvico_fusionhdtv7_tuner_config)) &dvico_fusionhdtv7_tuner_config))
...@@ -1493,7 +1492,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1493,7 +1492,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(stv0299_attach, fe0->dvb.frontend = dvb_attach(stv0299_attach,
&tevii_tuner_sharp_config, &tevii_tuner_sharp_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
&core->i2c_adap, DVB_PLL_OPERA1)) &core->i2c_adap, DVB_PLL_OPERA1))
goto frontend_detach; goto frontend_detach;
...@@ -1504,8 +1503,9 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1504,8 +1503,9 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(stv0288_attach, fe0->dvb.frontend = dvb_attach(stv0288_attach,
&tevii_tuner_earda_config, &tevii_tuner_earda_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61, if (!dvb_attach(stb6000_attach,
fe0->dvb.frontend, 0x61,
&core->i2c_adap)) &core->i2c_adap))
goto frontend_detach; goto frontend_detach;
core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
...@@ -1517,14 +1517,14 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1517,14 +1517,14 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(cx24116_attach, fe0->dvb.frontend = dvb_attach(cx24116_attach,
&tevii_s460_config, &tevii_s460_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) if (fe0->dvb.frontend)
fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
break; break;
case CX88_BOARD_TEVII_S464: case CX88_BOARD_TEVII_S464:
fe0->dvb.frontend = dvb_attach(ds3000_attach, fe0->dvb.frontend = dvb_attach(ds3000_attach,
&tevii_ds3000_config, &tevii_ds3000_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
dvb_attach(ts2020_attach, fe0->dvb.frontend, dvb_attach(ts2020_attach, fe0->dvb.frontend,
&tevii_ts2020_config, &core->i2c_adap); &tevii_ts2020_config, &core->i2c_adap);
fe0->dvb.frontend->ops.set_voltage = fe0->dvb.frontend->ops.set_voltage =
...@@ -1538,7 +1538,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1538,7 +1538,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(cx24116_attach, fe0->dvb.frontend = dvb_attach(cx24116_attach,
&hauppauge_hvr4000_config, &hauppauge_hvr4000_config,
&core->i2c_adap); &core->i2c_adap);
if (fe0->dvb.frontend != NULL) if (fe0->dvb.frontend)
fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
break; break;
case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII: case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
...@@ -1557,7 +1557,7 @@ static int dvb_register(struct cx8802_dev *dev) ...@@ -1557,7 +1557,7 @@ static int dvb_register(struct cx8802_dev *dev)
fe0->dvb.frontend = dvb_attach(stv0900_attach, fe0->dvb.frontend = dvb_attach(stv0900_attach,
&prof_7301_stv0900_config, &prof_7301_stv0900_config,
&core->i2c_adap, 0); &core->i2c_adap, 0);
if (fe0->dvb.frontend != NULL) { if (fe0->dvb.frontend) {
if (!dvb_attach(stb6100_attach, fe0->dvb.frontend, if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
&prof_7301_stb6100_config, &prof_7301_stb6100_config,
&core->i2c_adap)) &core->i2c_adap))
...@@ -1772,7 +1772,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) ...@@ -1772,7 +1772,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
struct vb2_queue *q; struct vb2_queue *q;
fe = vb2_dvb_get_frontend(&core->dvbdev->frontends, i); fe = vb2_dvb_get_frontend(&core->dvbdev->frontends, i);
if (fe == NULL) { if (!fe) {
pr_err("%s() failed to get frontend(%d)\n", pr_err("%s() failed to get frontend(%d)\n",
__func__, i); __func__, i);
err = -ENODEV; err = -ENODEV;
......
...@@ -24,10 +24,9 @@ ...@@ -24,10 +24,9 @@
#include "cx88.h" #include "cx88.h"
#include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h>
#include <asm/io.h> #include <linux/module.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
...@@ -41,7 +40,8 @@ MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); ...@@ -41,7 +40,8 @@ MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
static unsigned int i2c_udelay = 5; static unsigned int i2c_udelay = 5;
module_param(i2c_udelay, int, 0644); module_param(i2c_udelay, int, 0644);
MODULE_PARM_DESC(i2c_udelay, "i2c delay at insmod time, in usecs (should be 5 or higher). Lower value means higher bus speed."); MODULE_PARM_DESC(i2c_udelay,
"i2c delay at insmod time, in usecs (should be 5 or higher). Lower value means higher bus speed.");
#define dprintk(level, fmt, arg...) do { \ #define dprintk(level, fmt, arg...) do { \
if (i2c_debug >= level) \ if (i2c_debug >= level) \
...@@ -139,7 +139,6 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) ...@@ -139,7 +139,6 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
core->i2c_algo = cx8800_i2c_algo_template; core->i2c_algo = cx8800_i2c_algo_template;
core->i2c_adap.dev.parent = &pci->dev; core->i2c_adap.dev.parent = &pci->dev;
strlcpy(core->i2c_adap.name, core->name, sizeof(core->i2c_adap.name)); strlcpy(core->i2c_adap.name, core->name, sizeof(core->i2c_adap.name));
core->i2c_adap.owner = THIS_MODULE; core->i2c_adap.owner = THIS_MODULE;
......
...@@ -62,11 +62,15 @@ static int ir_debug; ...@@ -62,11 +62,15 @@ static int ir_debug;
module_param(ir_debug, int, 0644); /* debug level [IR] */ module_param(ir_debug, int, 0644); /* debug level [IR] */
MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
#define ir_dprintk(fmt, arg...) if (ir_debug) \ #define ir_dprintk(fmt, arg...) do { \
printk(KERN_DEBUG "%s IR: " fmt, ir->core->name, ##arg) if (ir_debug) \
printk(KERN_DEBUG "%s IR: " fmt, ir->core->name, ##arg);\
} while (0)
#define dprintk(fmt, arg...) if (ir_debug) \ #define dprintk(fmt, arg...) do { \
printk(KERN_DEBUG "cx88 IR: " fmt, ##arg) if (ir_debug) \
printk(KERN_DEBUG "cx88 IR: " fmt, ##arg); \
} while (0)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
...@@ -79,16 +83,17 @@ static void cx88_ir_handle_key(struct cx88_IR *ir) ...@@ -79,16 +83,17 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
gpio = cx_read(ir->gpio_addr); gpio = cx_read(ir->gpio_addr);
switch (core->boardnr) { switch (core->boardnr) {
case CX88_BOARD_NPGTECH_REALTV_TOP10FM: case CX88_BOARD_NPGTECH_REALTV_TOP10FM:
/* This board apparently uses a combination of 2 GPIO /*
to represent the keys. Additionally, the second GPIO * This board apparently uses a combination of 2 GPIO
can be used for parity. * to represent the keys. Additionally, the second GPIO
* can be used for parity.
Example: *
* Example:
for key "5" *
gpio = 0x758, auxgpio = 0xe5 or 0xf5 * for key "5"
for key "Power" * gpio = 0x758, auxgpio = 0xe5 or 0xf5
gpio = 0x758, auxgpio = 0xed or 0xfd * for key "Power"
* gpio = 0x758, auxgpio = 0xed or 0xfd
*/ */
auxgpio = cx_read(MO_GP1_IO); auxgpio = cx_read(MO_GP1_IO);
...@@ -231,12 +236,14 @@ int cx88_ir_start(struct cx88_core *core) ...@@ -231,12 +236,14 @@ int cx88_ir_start(struct cx88_core *core)
return 0; return 0;
} }
EXPORT_SYMBOL(cx88_ir_start);
void cx88_ir_stop(struct cx88_core *core) void cx88_ir_stop(struct cx88_core *core)
{ {
if (core->ir->users) if (core->ir->users)
__cx88_ir_stop(core); __cx88_ir_stop(core);
} }
EXPORT_SYMBOL(cx88_ir_stop);
static int cx88_ir_open(struct rc_dev *rc) static int cx88_ir_open(struct rc_dev *rc)
{ {
...@@ -508,7 +515,7 @@ int cx88_ir_fini(struct cx88_core *core) ...@@ -508,7 +515,7 @@ int cx88_ir_fini(struct cx88_core *core)
struct cx88_IR *ir = core->ir; struct cx88_IR *ir = core->ir;
/* skip detach on non attached boards */ /* skip detach on non attached boards */
if (ir == NULL) if (!ir)
return 0; return 0;
cx88_ir_stop(core); cx88_ir_stop(core);
......
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "cx88.h" #include "cx88.h"
...@@ -30,7 +26,7 @@ ...@@ -30,7 +26,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <asm/delay.h> #include <linux/delay.h>
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -54,7 +50,8 @@ MODULE_PARM_DESC(debug, "enable debug messages [mpeg]"); ...@@ -54,7 +50,8 @@ MODULE_PARM_DESC(debug, "enable debug messages [mpeg]");
#if defined(CONFIG_MODULES) && defined(MODULE) #if defined(CONFIG_MODULES) && defined(MODULE)
static void request_module_async(struct work_struct *work) static void request_module_async(struct work_struct *work)
{ {
struct cx8802_dev *dev = container_of(work, struct cx8802_dev, request_module_wk); struct cx8802_dev *dev = container_of(work, struct cx8802_dev,
request_module_wk);
if (dev->core->board.mpeg & CX88_MPEG_DVB) if (dev->core->board.mpeg & CX88_MPEG_DVB)
request_module("cx88-dvb"); request_module("cx88-dvb");
...@@ -77,7 +74,6 @@ static void flush_request_modules(struct cx8802_dev *dev) ...@@ -77,7 +74,6 @@ static void flush_request_modules(struct cx8802_dev *dev)
#define flush_request_modules(dev) #define flush_request_modules(dev)
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
static LIST_HEAD(cx8802_devlist); static LIST_HEAD(cx8802_devlist);
static DEFINE_MUTEX(cx8802_mutex); static DEFINE_MUTEX(cx8802_mutex);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -98,33 +94,35 @@ int cx8802_start_dma(struct cx8802_dev *dev, ...@@ -98,33 +94,35 @@ int cx8802_start_dma(struct cx8802_dev *dev,
/* write TS length to chip */ /* write TS length to chip */
cx_write(MO_TS_LNGTH, dev->ts_packet_size); cx_write(MO_TS_LNGTH, dev->ts_packet_size);
/* FIXME: this needs a review. /*
* also: move to cx88-blackbird + cx88-dvb source files? */ * FIXME: this needs a review.
* also: move to cx88-blackbird + cx88-dvb source files?
*/
dprintk(1, "core->active_type_id = 0x%08x\n", core->active_type_id); dprintk(1, "core->active_type_id = 0x%08x\n", core->active_type_id);
if ((core->active_type_id == CX88_MPEG_DVB) && if ((core->active_type_id == CX88_MPEG_DVB) &&
(core->board.mpeg & CX88_MPEG_DVB)) { (core->board.mpeg & CX88_MPEG_DVB)) {
dprintk(1, "cx8802_start_dma doing .dvb\n"); dprintk(1, "cx8802_start_dma doing .dvb\n");
/* negedge driven & software reset */ /* negedge driven & software reset */
cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl); cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl);
udelay(100); udelay(100);
cx_write(MO_PINMUX_IO, 0x00); cx_write(MO_PINMUX_IO, 0x00);
cx_write(TS_HW_SOP_CNTRL, 0x47<<16|188<<4|0x01); cx_write(TS_HW_SOP_CNTRL, 0x47 << 16 | 188 << 4 | 0x01);
switch (core->boardnr) { switch (core->boardnr) {
case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
case CX88_BOARD_PCHDTV_HD5500: case CX88_BOARD_PCHDTV_HD5500:
cx_write(TS_SOP_STAT, 1<<13); cx_write(TS_SOP_STAT, 1 << 13);
break; break;
case CX88_BOARD_SAMSUNG_SMT_7020: case CX88_BOARD_SAMSUNG_SMT_7020:
cx_write(TS_SOP_STAT, 0x00); cx_write(TS_SOP_STAT, 0x00);
break; break;
case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
cx_write(MO_PINMUX_IO, 0x88); /* Enable MPEG parallel IO and video signal pins */ /* Enable MPEG parallel IO and video signal pins */
cx_write(MO_PINMUX_IO, 0x88);
udelay(100); udelay(100);
break; break;
case CX88_BOARD_HAUPPAUGE_HVR1300: case CX88_BOARD_HAUPPAUGE_HVR1300:
...@@ -153,13 +151,15 @@ int cx8802_start_dma(struct cx8802_dev *dev, ...@@ -153,13 +151,15 @@ int cx8802_start_dma(struct cx8802_dev *dev,
dprintk(1, "cx8802_start_dma doing .blackbird\n"); dprintk(1, "cx8802_start_dma doing .blackbird\n");
cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */ cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */
cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */ /* punctured clock TS & posedge driven & software reset */
cx_write(TS_GEN_CNTRL, 0x46);
udelay(100); udelay(100);
cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */ cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */
cx_write(TS_VALERR_CNTRL, 0x2000); cx_write(TS_VALERR_CNTRL, 0x2000);
cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ /* punctured clock TS & posedge driven */
cx_write(TS_GEN_CNTRL, 0x06);
udelay(100); udelay(100);
} else { } else {
pr_err("%s() Failed. Unsupported value in .mpeg (0x%08x)\n", pr_err("%s() Failed. Unsupported value in .mpeg (0x%08x)\n",
...@@ -177,10 +177,11 @@ int cx8802_start_dma(struct cx8802_dev *dev, ...@@ -177,10 +177,11 @@ int cx8802_start_dma(struct cx8802_dev *dev,
cx_set(MO_TS_INTMSK, 0x1f0011); cx_set(MO_TS_INTMSK, 0x1f0011);
/* start dma */ /* start dma */
cx_set(MO_DEV_CNTRL2, (1<<5)); cx_set(MO_DEV_CNTRL2, (1 << 5));
cx_set(MO_TS_DMACNTRL, 0x11); cx_set(MO_TS_DMACNTRL, 0x11);
return 0; return 0;
} }
EXPORT_SYMBOL(cx8802_start_dma);
static int cx8802_stop_dma(struct cx8802_dev *dev) static int cx8802_stop_dma(struct cx8802_dev *dev)
{ {
...@@ -234,12 +235,14 @@ int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, ...@@ -234,12 +235,14 @@ int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev,
dev->ts_packet_size, dev->ts_packet_count, 0); dev->ts_packet_size, dev->ts_packet_count, 0);
if (rc) { if (rc) {
if (risc->cpu) if (risc->cpu)
pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); pci_free_consistent(dev->pci, risc->size,
risc->cpu, risc->dma);
memset(risc, 0, sizeof(*risc)); memset(risc, 0, sizeof(*risc));
return rc; return rc;
} }
return 0; return 0;
} }
EXPORT_SYMBOL(cx8802_buf_prepare);
void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
{ {
...@@ -268,6 +271,7 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) ...@@ -268,6 +271,7 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
buf, buf->vb.vb2_buf.index, __func__); buf, buf->vb.vb2_buf.index, __func__);
} }
} }
EXPORT_SYMBOL(cx8802_buf_queue);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
...@@ -292,6 +296,7 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev) ...@@ -292,6 +296,7 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev)
cx8802_stop_dma(dev); cx8802_stop_dma(dev);
do_cancel_buffers(dev); do_cancel_buffers(dev);
} }
EXPORT_SYMBOL(cx8802_cancel_buffers);
static const char *cx88_mpeg_irqs[32] = { static const char *cx88_mpeg_irqs[32] = {
"ts_risci1", NULL, NULL, NULL, "ts_risci1", NULL, NULL, NULL,
...@@ -324,7 +329,8 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev) ...@@ -324,7 +329,8 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
if (status & (1 << 16)) { if (status & (1 << 16)) {
pr_warn("mpeg risc op code error\n"); pr_warn("mpeg risc op code error\n");
cx_clear(MO_TS_DMACNTRL, 0x11); cx_clear(MO_TS_DMACNTRL, 0x11);
cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]); cx88_sram_channel_dump(dev->core,
&cx88_sram_channels[SRAM_CH28]);
} }
/* risc1 y */ /* risc1 y */
...@@ -452,7 +458,8 @@ static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state) ...@@ -452,7 +458,8 @@ static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
cx88_shutdown(dev->core); cx88_shutdown(dev->core);
pci_save_state(pci_dev); pci_save_state(pci_dev);
if (pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)) != 0) { if (pci_set_power_state(pci_dev,
pci_choose_state(pci_dev, state)) != 0) {
pci_disable_device(pci_dev); pci_disable_device(pci_dev);
dev->state.disabled = 1; dev->state.disabled = 1;
} }
...@@ -497,7 +504,8 @@ static int cx8802_resume_common(struct pci_dev *pci_dev) ...@@ -497,7 +504,8 @@ static int cx8802_resume_common(struct pci_dev *pci_dev)
return 0; return 0;
} }
struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev,
enum cx88_board_type btype)
{ {
struct cx8802_driver *d; struct cx8802_driver *d;
...@@ -507,6 +515,7 @@ struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_ ...@@ -507,6 +515,7 @@ struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_
return NULL; return NULL;
} }
EXPORT_SYMBOL(cx8802_get_driver);
/* Driver asked for hardware access. */ /* Driver asked for hardware access. */
static int cx8802_request_acquire(struct cx8802_driver *drv) static int cx8802_request_acquire(struct cx8802_driver *drv)
...@@ -524,7 +533,8 @@ static int cx8802_request_acquire(struct cx8802_driver *drv) ...@@ -524,7 +533,8 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
core->last_analog_input = core->input; core->last_analog_input = core->input;
core->input = 0; core->input = 0;
for (i = 0; for (i = 0;
i < (sizeof(core->board.input) / sizeof(struct cx88_input)); i < (sizeof(core->board.input) /
sizeof(struct cx88_input));
i++) { i++) {
if (core->board.input[i].type == CX88_VMUX_DVB) { if (core->board.input[i].type == CX88_VMUX_DVB) {
core->input = i; core->input = i;
...@@ -533,8 +543,7 @@ static int cx8802_request_acquire(struct cx8802_driver *drv) ...@@ -533,8 +543,7 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
} }
} }
if (drv->advise_acquire) if (drv->advise_acquire) {
{
core->active_ref++; core->active_ref++;
if (core->active_type_id == CX88_BOARD_NONE) { if (core->active_type_id == CX88_BOARD_NONE) {
core->active_type_id = drv->type_id; core->active_type_id = drv->type_id;
...@@ -552,11 +561,12 @@ static int cx8802_request_release(struct cx8802_driver *drv) ...@@ -552,11 +561,12 @@ static int cx8802_request_release(struct cx8802_driver *drv)
{ {
struct cx88_core *core = drv->core; struct cx88_core *core = drv->core;
if (drv->advise_release && --core->active_ref == 0) if (drv->advise_release && --core->active_ref == 0) {
{
if (drv->type_id == CX88_MPEG_DVB) { if (drv->type_id == CX88_MPEG_DVB) {
/* If the DVB driver is releasing, reset the input /*
state to the last configured analog input */ * If the DVB driver is releasing, reset the input
* state to the last configured analog input
*/
core->input = core->last_analog_input; core->input = core->last_analog_input;
} }
...@@ -570,7 +580,7 @@ static int cx8802_request_release(struct cx8802_driver *drv) ...@@ -570,7 +580,7 @@ static int cx8802_request_release(struct cx8802_driver *drv)
static int cx8802_check_driver(struct cx8802_driver *drv) static int cx8802_check_driver(struct cx8802_driver *drv)
{ {
if (drv == NULL) if (!drv)
return -ENODEV; return -ENODEV;
if ((drv->type_id != CX88_MPEG_DVB) && if ((drv->type_id != CX88_MPEG_DVB) &&
...@@ -581,10 +591,10 @@ static int cx8802_check_driver(struct cx8802_driver *drv) ...@@ -581,10 +591,10 @@ static int cx8802_check_driver(struct cx8802_driver *drv)
(drv->hw_access != CX8802_DRVCTL_EXCLUSIVE)) (drv->hw_access != CX8802_DRVCTL_EXCLUSIVE))
return -EINVAL; return -EINVAL;
if ((drv->probe == NULL) || if ((!drv->probe) ||
(drv->remove == NULL) || (!drv->remove) ||
(drv->advise_acquire == NULL) || (!drv->advise_acquire) ||
(drv->advise_release == NULL)) (!drv->advise_release))
return -EINVAL; return -EINVAL;
return 0; return 0;
...@@ -598,9 +608,11 @@ int cx8802_register_driver(struct cx8802_driver *drv) ...@@ -598,9 +608,11 @@ int cx8802_register_driver(struct cx8802_driver *drv)
pr_info("registering cx8802 driver, type: %s access: %s\n", pr_info("registering cx8802 driver, type: %s access: %s\n",
drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird",
drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); drv->hw_access == CX8802_DRVCTL_SHARED ?
"shared" : "exclusive");
if ((err = cx8802_check_driver(drv)) != 0) { err = cx8802_check_driver(drv);
if (err) {
pr_err("cx8802_driver is invalid\n"); pr_err("cx8802_driver is invalid\n");
return err; return err;
} }
...@@ -615,7 +627,7 @@ int cx8802_register_driver(struct cx8802_driver *drv) ...@@ -615,7 +627,7 @@ int cx8802_register_driver(struct cx8802_driver *drv)
/* Bring up a new struct for each driver instance */ /* Bring up a new struct for each driver instance */
driver = kzalloc(sizeof(*drv), GFP_KERNEL); driver = kzalloc(sizeof(*drv), GFP_KERNEL);
if (driver == NULL) { if (!driver) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
...@@ -644,6 +656,7 @@ int cx8802_register_driver(struct cx8802_driver *drv) ...@@ -644,6 +656,7 @@ int cx8802_register_driver(struct cx8802_driver *drv)
mutex_unlock(&cx8802_mutex); mutex_unlock(&cx8802_mutex);
return err; return err;
} }
EXPORT_SYMBOL(cx8802_register_driver);
int cx8802_unregister_driver(struct cx8802_driver *drv) int cx8802_unregister_driver(struct cx8802_driver *drv)
{ {
...@@ -653,7 +666,8 @@ int cx8802_unregister_driver(struct cx8802_driver *drv) ...@@ -653,7 +666,8 @@ int cx8802_unregister_driver(struct cx8802_driver *drv)
pr_info("unregistering cx8802 driver, type: %s access: %s\n", pr_info("unregistering cx8802 driver, type: %s access: %s\n",
drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird",
drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); drv->hw_access == CX8802_DRVCTL_SHARED ?
"shared" : "exclusive");
mutex_lock(&cx8802_mutex); mutex_lock(&cx8802_mutex);
...@@ -686,6 +700,7 @@ int cx8802_unregister_driver(struct cx8802_driver *drv) ...@@ -686,6 +700,7 @@ int cx8802_unregister_driver(struct cx8802_driver *drv)
return err; return err;
} }
EXPORT_SYMBOL(cx8802_unregister_driver);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
static int cx8802_probe(struct pci_dev *pci_dev, static int cx8802_probe(struct pci_dev *pci_dev,
...@@ -697,7 +712,7 @@ static int cx8802_probe(struct pci_dev *pci_dev, ...@@ -697,7 +712,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
/* general setup */ /* general setup */
core = cx88_core_get(pci_dev); core = cx88_core_get(pci_dev);
if (core == NULL) if (!core)
return -EINVAL; return -EINVAL;
pr_info("cx2388x 8802 Driver Manager\n"); pr_info("cx2388x 8802 Driver Manager\n");
...@@ -708,7 +723,7 @@ static int cx8802_probe(struct pci_dev *pci_dev, ...@@ -708,7 +723,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
err = -ENOMEM; err = -ENOMEM;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) if (!dev)
goto fail_core; goto fail_core;
dev->pci = pci_dev; dev->pci = pci_dev;
dev->core = core; dev->core = core;
...@@ -797,12 +812,3 @@ static struct pci_driver cx8802_pci_driver = { ...@@ -797,12 +812,3 @@ static struct pci_driver cx8802_pci_driver = {
}; };
module_pci_driver(cx8802_pci_driver); module_pci_driver(cx8802_pci_driver);
EXPORT_SYMBOL(cx8802_buf_prepare);
EXPORT_SYMBOL(cx8802_buf_queue);
EXPORT_SYMBOL(cx8802_cancel_buffers);
EXPORT_SYMBOL(cx8802_start_dma);
EXPORT_SYMBOL(cx8802_register_driver);
EXPORT_SYMBOL(cx8802_unregister_driver);
EXPORT_SYMBOL(cx8802_get_driver);
/* /*
* cx88x-hw.h - CX2388x register offsets
cx88x-hw.h - CX2388x register offsets *
* Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) * 2001 Michael Eskin
2001 Michael Eskin * 2002 Yurij Sysoev <yurij@naturesoft.net>
2002 Yurij Sysoev <yurij@naturesoft.net> * 2003 Gerd Knorr <kraxel@bytesex.org>
2003 Gerd Knorr <kraxel@bytesex.org> *
* This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation; either version 2 of the License, or * (at your option) any later version.
(at your option) any later version. *
* This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details.
GNU General Public License for more details. */
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _CX88_REG_H_ #ifndef _CX88_REG_H_
#define _CX88_REG_H_ #define _CX88_REG_H_
/* ---------------------------------------------------------------------- */ /*
/* PCI IDs and config space */ * PCI IDs and config space
*/
#ifndef PCI_VENDOR_ID_CONEXANT #ifndef PCI_VENDOR_ID_CONEXANT
# define PCI_VENDOR_ID_CONEXANT 0x14F1 # define PCI_VENDOR_ID_CONEXANT 0x14F1
...@@ -39,8 +35,9 @@ ...@@ -39,8 +35,9 @@
#define CX88X_EN_TBFX 0x02 #define CX88X_EN_TBFX 0x02
#define CX88X_EN_VSFX 0x04 #define CX88X_EN_VSFX 0x04
/* ---------------------------------------------------------------------- */ /*
/* PCI controller registers */ * PCI controller registers
*/
/* Command and Status Register */ /* Command and Status Register */
#define F0_CMD_STAT_MM 0x2f0004 #define F0_CMD_STAT_MM 0x2f0004
...@@ -63,8 +60,9 @@ ...@@ -63,8 +60,9 @@
#define F3_BAR0_MM 0x2f0310 #define F3_BAR0_MM 0x2f0310
#define F4_BAR0_MM 0x2f0410 #define F4_BAR0_MM 0x2f0410
/* ---------------------------------------------------------------------- */ /*
/* DMA Controller registers */ * DMA Controller registers
*/
#define MO_PDMA_STHRSH 0x200000 // Source threshold #define MO_PDMA_STHRSH 0x200000 // Source threshold
#define MO_PDMA_STADRS 0x200004 // Source target address #define MO_PDMA_STADRS 0x200004 // Source target address
...@@ -157,9 +155,9 @@ ...@@ -157,9 +155,9 @@
#define MO_DMA31_CNT2 0x300168 // {11}RW* DMA Table Size : Ch#31 #define MO_DMA31_CNT2 0x300168 // {11}RW* DMA Table Size : Ch#31
#define MO_DMA32_CNT2 0x30016C // {11}RW* DMA Table Size : Ch#32 #define MO_DMA32_CNT2 0x30016C // {11}RW* DMA Table Size : Ch#32
/*
/* ---------------------------------------------------------------------- */ * Video registers
/* Video registers */ */
#define MO_VIDY_DMA 0x310000 // {64}RWp Video Y #define MO_VIDY_DMA 0x310000 // {64}RWp Video Y
#define MO_VIDU_DMA 0x310008 // {64}RWp Video U #define MO_VIDU_DMA 0x310008 // {64}RWp Video U
...@@ -217,9 +215,9 @@ ...@@ -217,9 +215,9 @@
#define MO_VID_DMACNTRL 0x31C040 // {8}RW Video DMA control #define MO_VID_DMACNTRL 0x31C040 // {8}RW Video DMA control
#define MO_VID_XFR_STAT 0x31C044 // {1}RO Video transfer status #define MO_VID_XFR_STAT 0x31C044 // {1}RO Video transfer status
/*
/* ---------------------------------------------------------------------- */ * audio registers
/* audio registers */ */
#define MO_AUDD_DMA 0x320000 // {64}RWp Audio downstream #define MO_AUDD_DMA 0x320000 // {64}RWp Audio downstream
#define MO_AUDU_DMA 0x320008 // {64}RWp Audio upstream #define MO_AUDU_DMA 0x320008 // {64}RWp Audio upstream
...@@ -437,9 +435,9 @@ ...@@ -437,9 +435,9 @@
#define AUD_PHACC_FREQ_8LSB 0x320d2b #define AUD_PHACC_FREQ_8LSB 0x320d2b
#define AUD_QAM_MODE 0x320d04 #define AUD_QAM_MODE 0x320d04
/*
/* ---------------------------------------------------------------------- */ * transport stream registers
/* transport stream registers */ */
#define MO_TS_DMA 0x330000 // {64}RWp Transport stream downstream #define MO_TS_DMA 0x330000 // {64}RWp Transport stream downstream
#define MO_TS_GPCNT 0x33C020 // {16}RO TS general purpose counter #define MO_TS_GPCNT 0x33C020 // {16}RO TS general purpose counter
...@@ -455,9 +453,9 @@ ...@@ -455,9 +453,9 @@
#define TS_FIFO_OVFL_STAT 0x33C05C #define TS_FIFO_OVFL_STAT 0x33C05C
#define TS_VALERR_CNTRL 0x33C060 #define TS_VALERR_CNTRL 0x33C060
/*
/* ---------------------------------------------------------------------- */ * VIP registers
/* VIP registers */ */
#define MO_VIPD_DMA 0x340000 // {64}RWp VIP downstream #define MO_VIPD_DMA 0x340000 // {64}RWp VIP downstream
#define MO_VIPU_DMA 0x340008 // {64}RWp VIP upstream #define MO_VIPU_DMA 0x340008 // {64}RWp VIP upstream
...@@ -475,9 +473,9 @@ ...@@ -475,9 +473,9 @@
#define MO_VIP_INTCNTRL 0x34C05C // VIP Interrupt Control #define MO_VIP_INTCNTRL 0x34C05C // VIP Interrupt Control
#define MO_VIP_XFTERM 0x340060 // VIP transfer terminate #define MO_VIP_XFTERM 0x340060 // VIP transfer terminate
/*
/* ---------------------------------------------------------------------- */ * misc registers
/* misc registers */ */
#define MO_M2M_DMA 0x350000 // {64}RWp Mem2Mem DMA Bfr #define MO_M2M_DMA 0x350000 // {64}RWp Mem2Mem DMA Bfr
#define MO_GP0_IO 0x350010 // {32}RW* GPIOoutput enablesdata I/O #define MO_GP0_IO 0x350010 // {32}RW* GPIOoutput enablesdata I/O
...@@ -509,9 +507,9 @@ ...@@ -509,9 +507,9 @@
#define MO_INT1_STAT 0x35C064 // DMA RISC interrupt status #define MO_INT1_STAT 0x35C064 // DMA RISC interrupt status
#define MO_INT1_MSTAT 0x35C068 // DMA RISC interrupt masked status #define MO_INT1_MSTAT 0x35C068 // DMA RISC interrupt masked status
/*
/* ---------------------------------------------------------------------- */ * i2c bus registers
/* i2c bus registers */ */
#define MO_I2C 0x368000 // I2C data/control #define MO_I2C 0x368000 // I2C data/control
#define MO_I2C_DIV (0xf<<4) #define MO_I2C_DIV (0xf<<4)
...@@ -521,9 +519,11 @@ ...@@ -521,9 +519,11 @@
#define MO_I2C_SDA (1<<0) #define MO_I2C_SDA (1<<0)
/* ---------------------------------------------------------------------- */ /*
/* general purpose host registers */ * general purpose host registers
/* FIXME: tyops? s/0x35/0x38/ ?? */ *
* FIXME: tyops? s/0x35/0x38/ ??
*/
#define MO_GPHSTD_DMA 0x350000 // {64}RWp Host downstream #define MO_GPHSTD_DMA 0x350000 // {64}RWp Host downstream
#define MO_GPHSTU_DMA 0x350008 // {64}RWp Host upstream #define MO_GPHSTU_DMA 0x350008 // {64}RWp Host upstream
...@@ -545,9 +545,9 @@ ...@@ -545,9 +545,9 @@
#define MO_GPHST_XFR_STAT 0x38C044 // Host transfer status #define MO_GPHST_XFR_STAT 0x38C044 // Host transfer status
#define MO_GPHST_SOFT_RST 0x38C06C // Host software reset #define MO_GPHST_SOFT_RST 0x38C06C // Host software reset
/*
/* ---------------------------------------------------------------------- */ * RISC instructions
/* RISC instructions */ */
#define RISC_SYNC 0x80000000 #define RISC_SYNC 0x80000000
#define RISC_SYNC_ODD 0x80000000 #define RISC_SYNC_ODD 0x80000000
...@@ -578,9 +578,9 @@ ...@@ -578,9 +578,9 @@
#define RISC_CNT_RESET 0x00030000 #define RISC_CNT_RESET 0x00030000
#define RISC_JMP_SRP 0x01 #define RISC_JMP_SRP 0x01
/*
/* ---------------------------------------------------------------------- */ * various constants
/* various constants */ */
// DMA // DMA
/* Interrupt mask/status */ /* Interrupt mask/status */
......
...@@ -57,7 +57,8 @@ MODULE_PARM_DESC(always_analog, "force analog audio out"); ...@@ -57,7 +57,8 @@ MODULE_PARM_DESC(always_analog, "force analog audio out");
static unsigned int radio_deemphasis; static unsigned int radio_deemphasis;
module_param(radio_deemphasis, int, 0644); module_param(radio_deemphasis, int, 0644);
MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, 0=None, 1=50us (elsewhere), 2=75us (USA)"); MODULE_PARM_DESC(radio_deemphasis,
"Radio deemphasis time constant, 0=None, 1=50us (elsewhere), 2=75us (USA)");
#define dprintk(fmt, arg...) do { \ #define dprintk(fmt, arg...) do { \
if (audio_debug) \ if (audio_debug) \
...@@ -141,7 +142,10 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl) ...@@ -141,7 +142,10 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
if (core->board.mpeg & CX88_MPEG_BLACKBIRD) { if (core->board.mpeg & CX88_MPEG_BLACKBIRD) {
cx_write(AUD_I2SINPUTCNTL, 4); cx_write(AUD_I2SINPUTCNTL, 4);
cx_write(AUD_BAUDRATE, 1); cx_write(AUD_BAUDRATE, 1);
/* 'pass-thru mode': this enables the i2s output to the mpeg encoder */ /*
* 'pass-thru mode': this enables the i2s
* output to the mpeg encoder
*/
cx_set(AUD_CTL, EN_I2SOUT_ENABLE); cx_set(AUD_CTL, EN_I2SOUT_ENABLE);
cx_write(AUD_I2SOUTPUTCNTL, 1); cx_write(AUD_I2SOUTPUTCNTL, 1);
cx_write(AUD_I2SCNTL, 0); cx_write(AUD_I2SCNTL, 0);
...@@ -634,7 +638,6 @@ static void set_audio_standard_A2(struct cx88_core *core, u32 mode) ...@@ -634,7 +638,6 @@ static void set_audio_standard_A2(struct cx88_core *core, u32 mode)
case WW_M: case WW_M:
dprintk("%s Warning: wrong value\n", __func__); dprintk("%s Warning: wrong value\n", __func__);
return; return;
break;
} }
mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF; mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF;
...@@ -691,13 +694,15 @@ static void set_audio_standard_FM(struct cx88_core *core, ...@@ -691,13 +694,15 @@ static void set_audio_standard_FM(struct cx88_core *core,
{ /* end of list */ }, { /* end of list */ },
}; };
/* It is enough to leave default values? */ /*
/* No, it's not! The deemphasis registers are reset to the 75us * It is enough to leave default values?
*
* No, it's not! The deemphasis registers are reset to the 75us
* values by default. Analyzing the spectrum of the decoded audio * values by default. Analyzing the spectrum of the decoded audio
* reveals that "no deemphasis" is the same as 75 us, while the 50 us * reveals that "no deemphasis" is the same as 75 us, while the 50 us
* setting results in less deemphasis. */ * setting results in less deemphasis.
*/
static const struct rlist fm_no_deemph[] = { static const struct rlist fm_no_deemph[] = {
{AUD_POLYPH80SCALEFAC, 0x0003}, {AUD_POLYPH80SCALEFAC, 0x0003},
{ /* end of list */ }, { /* end of list */ },
}; };
...@@ -741,7 +746,7 @@ static int cx88_detect_nicam(struct cx88_core *core) ...@@ -741,7 +746,7 @@ static int cx88_detect_nicam(struct cx88_core *core)
} }
/* wait a little bit for next reading status */ /* wait a little bit for next reading status */
msleep(10); usleep_range(10000, 20000);
} }
dprintk("nicam is not detected.\n"); dprintk("nicam is not detected.\n");
...@@ -762,8 +767,10 @@ void cx88_set_tvaudio(struct cx88_core *core) ...@@ -762,8 +767,10 @@ void cx88_set_tvaudio(struct cx88_core *core)
/* prepare all dsp registers */ /* prepare all dsp registers */
set_audio_standard_A2(core, EN_A2_FORCE_MONO1); set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
/* set nicam mode - otherwise /*
AUD_NICAM_STATUS2 contains wrong values */ * set nicam mode - otherwise
* AUD_NICAM_STATUS2 contains wrong values
*/
set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO); set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO);
if (cx88_detect_nicam(core) == 0) { if (cx88_detect_nicam(core) == 0) {
/* fall back to fm / am mono */ /* fall back to fm / am mono */
...@@ -797,19 +804,22 @@ void cx88_set_tvaudio(struct cx88_core *core) ...@@ -797,19 +804,22 @@ void cx88_set_tvaudio(struct cx88_core *core)
pr_info("unknown tv audio mode [%d]\n", core->tvaudio); pr_info("unknown tv audio mode [%d]\n", core->tvaudio);
break; break;
} }
return;
} }
EXPORT_SYMBOL(cx88_set_tvaudio);
void cx88_newstation(struct cx88_core *core) void cx88_newstation(struct cx88_core *core)
{ {
core->audiomode_manual = UNSET; core->audiomode_manual = UNSET;
core->last_change = jiffies; core->last_change = jiffies;
} }
EXPORT_SYMBOL(cx88_newstation);
void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
{ {
static const char * const m[] = { "stereo", "dual mono", "mono", "sap" }; static const char * const m[] = { "stereo", "dual mono",
static const char * const p[] = { "no pilot", "pilot c1", "pilot c2", "?" }; "mono", "sap" };
static const char * const p[] = { "no pilot", "pilot c1",
"pilot c2", "?" };
u32 reg, mode, pilot; u32 reg, mode, pilot;
reg = cx_read(AUD_STATUS); reg = cx_read(AUD_STATUS);
...@@ -866,13 +876,16 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) ...@@ -866,13 +876,16 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
/* If software stereo detection is not supported... */ /* If software stereo detection is not supported... */
if (t->rxsubchans == UNSET) { if (t->rxsubchans == UNSET) {
t->rxsubchans = V4L2_TUNER_SUB_MONO; t->rxsubchans = V4L2_TUNER_SUB_MONO;
/* If the hardware itself detected stereo, also return /*
stereo as an available subchannel */ * If the hardware itself detected stereo, also return
* stereo as an available subchannel
*/
if (t->audmode == V4L2_TUNER_MODE_STEREO) if (t->audmode == V4L2_TUNER_MODE_STEREO)
t->rxsubchans |= V4L2_TUNER_SUB_STEREO; t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
} }
return;
} }
EXPORT_SYMBOL(cx88_get_stereo);
void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
{ {
...@@ -928,7 +941,8 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) ...@@ -928,7 +941,8 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
break; break;
} }
} else { } else {
if ((core->tvaudio == WW_I) || (core->tvaudio == WW_L)) { if ((core->tvaudio == WW_I) ||
(core->tvaudio == WW_L)) {
/* fall back to fm / am mono */ /* fall back to fm / am mono */
set_audio_standard_A2(core, EN_A2_FORCE_MONO1); set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
} else { } else {
...@@ -976,8 +990,8 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) ...@@ -976,8 +990,8 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL)); cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL));
cx_andor(AUD_CTL, mask, ctl); cx_andor(AUD_CTL, mask, ctl);
} }
return;
} }
EXPORT_SYMBOL(cx88_set_stereo);
int cx88_audio_thread(void *data) int cx88_audio_thread(void *data)
{ {
...@@ -1027,8 +1041,10 @@ int cx88_audio_thread(void *data) ...@@ -1027,8 +1041,10 @@ int cx88_audio_thread(void *data)
case WW_FM: case WW_FM:
case WW_I2SADC: case WW_I2SADC:
hw_autodetect: hw_autodetect:
/* stereo autodetection is supported by hardware so /*
we don't need to do it manually. Do nothing. */ * stereo autodetection is supported by hardware so
* we don't need to do it manually. Do nothing.
*/
break; break;
} }
} }
...@@ -1036,11 +1052,4 @@ int cx88_audio_thread(void *data) ...@@ -1036,11 +1052,4 @@ int cx88_audio_thread(void *data)
dprintk("cx88: tvaudio thread exiting\n"); dprintk("cx88: tvaudio thread exiting\n");
return 0; return 0;
} }
/* ----------------------------------------------------------- */
EXPORT_SYMBOL(cx88_set_tvaudio);
EXPORT_SYMBOL(cx88_newstation);
EXPORT_SYMBOL(cx88_set_stereo);
EXPORT_SYMBOL(cx88_get_stereo);
EXPORT_SYMBOL(cx88_audio_thread); EXPORT_SYMBOL(cx88_audio_thread);
...@@ -57,9 +57,9 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev, ...@@ -57,9 +57,9 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24], cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24],
VBI_LINE_LENGTH, buf->risc.dma); VBI_LINE_LENGTH, buf->risc.dma);
cx_write(MO_VBOS_CONTROL, ((1 << 18) | // comb filter delay fixup cx_write(MO_VBOS_CONTROL, (1 << 18) | /* comb filter delay fixup */
(1 << 15) | // enable vbi capture (1 << 15) | /* enable vbi capture */
(1 << 11))); (1 << 11));
/* reset counter */ /* reset counter */
cx_write(MO_VBI_GPCNTRL, GP_COUNT_CONTROL_RESET); cx_write(MO_VBI_GPCNTRL, GP_COUNT_CONTROL_RESET);
...@@ -73,7 +73,7 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev, ...@@ -73,7 +73,7 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
cx_set(VID_CAPTURE_CONTROL, 0x18); cx_set(VID_CAPTURE_CONTROL, 0x18);
/* start dma */ /* start dma */
cx_set(MO_DEV_CNTRL2, (1<<5)); cx_set(MO_DEV_CNTRL2, (1 << 5));
cx_set(MO_VID_DMACNTRL, 0x88); cx_set(MO_VID_DMACNTRL, 0x88);
return 0; return 0;
...@@ -125,7 +125,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -125,7 +125,6 @@ static int queue_setup(struct vb2_queue *q,
return 0; return 0;
} }
static int buffer_prepare(struct vb2_buffer *vb) static int buffer_prepare(struct vb2_buffer *vb)
{ {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
......
...@@ -73,7 +73,6 @@ MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]"); ...@@ -73,7 +73,6 @@ MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]");
__func__, ##arg); \ __func__, ##arg); \
} while (0) } while (0)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
/* static data */ /* static data */
...@@ -123,7 +122,8 @@ static const struct cx8800_fmt formats[] = { ...@@ -123,7 +122,8 @@ static const struct cx8800_fmt formats[] = {
}, { }, {
.name = "32 bpp RGB, be", .name = "32 bpp RGB, be",
.fourcc = V4L2_PIX_FMT_RGB32, .fourcc = V4L2_PIX_FMT_RGB32,
.cxformat = ColorFormatRGB32 | ColorFormatBSWAP | ColorFormatWSWAP, .cxformat = ColorFormatRGB32 | ColorFormatBSWAP |
ColorFormatWSWAP,
.depth = 32, .depth = 32,
.flags = FORMAT_FLAGS_PACKED, .flags = FORMAT_FLAGS_PACKED,
}, { }, {
...@@ -147,7 +147,7 @@ static const struct cx8800_fmt *format_by_fourcc(unsigned int fourcc) ...@@ -147,7 +147,7 @@ static const struct cx8800_fmt *format_by_fourcc(unsigned int fourcc)
for (i = 0; i < ARRAY_SIZE(formats); i++) for (i = 0; i < ARRAY_SIZE(formats); i++)
if (formats[i].fourcc == fourcc) if (formats[i].fourcc == fourcc)
return formats+i; return formats + i;
return NULL; return NULL;
} }
...@@ -221,8 +221,10 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = { ...@@ -221,8 +221,10 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
.step = 1, .step = 1,
.default_value = 0x0, .default_value = 0x0,
.off = 0, .off = 0,
/* NOTE: the value is converted and written to both even /*
and odd registers in the code */ * NOTE: the value is converted and written to both even
* and odd registers in the code
*/
.reg = MO_FILTER_ODD, .reg = MO_FILTER_ODD,
.mask = 7 << 7, .mask = 7 << 7,
.shift = 7, .shift = 7,
...@@ -326,19 +328,25 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input) ...@@ -326,19 +328,25 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
break; break;
} }
/* if there are audioroutes defined, we have an external /*
ADC to deal with audio */ * if there are audioroutes defined, we have an external
* ADC to deal with audio
*/
if (INPUT(input).audioroute) { if (INPUT(input).audioroute) {
/* The wm8775 module has the "2" route hardwired into /*
the initialization. Some boards may use different * The wm8775 module has the "2" route hardwired into
routes for different inputs. HVR-1300 surely does */ * the initialization. Some boards may use different
* routes for different inputs. HVR-1300 surely does
*/
if (core->sd_wm8775) { if (core->sd_wm8775) {
call_all(core, audio, s_routing, call_all(core, audio, s_routing,
INPUT(input).audioroute, 0, 0); INPUT(input).audioroute, 0, 0);
} }
/* cx2388's C-ADC is connected to the tuner only. /*
When used with S-Video, that ADC is busy dealing with * cx2388's C-ADC is connected to the tuner only.
chroma, so an external must be used for baseband audio */ * When used with S-Video, that ADC is busy dealing with
* chroma, so an external must be used for baseband audio
*/
if (INPUT(input).type != CX88_VMUX_TELEVISION && if (INPUT(input).type != CX88_VMUX_TELEVISION &&
INPUT(input).type != CX88_VMUX_CABLE) { INPUT(input).type != CX88_VMUX_CABLE) {
/* "I2S ADC mode" */ /* "I2S ADC mode" */
...@@ -376,12 +384,13 @@ static int start_video_dma(struct cx8800_dev *dev, ...@@ -376,12 +384,13 @@ static int start_video_dma(struct cx8800_dev *dev,
/* enable irqs */ /* enable irqs */
cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_VIDINT); cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_VIDINT);
/* Enables corresponding bits at PCI_INT_STAT: /*
bits 0 to 4: video, audio, transport stream, VIP, Host * Enables corresponding bits at PCI_INT_STAT:
bit 7: timer * bits 0 to 4: video, audio, transport stream, VIP, Host
bits 8 and 9: DMA complete for: SRC, DST * bit 7: timer
bits 10 and 11: BERR signal asserted for RISC: RD, WR * bits 8 and 9: DMA complete for: SRC, DST
bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB * bits 10 and 11: BERR signal asserted for RISC: RD, WR
* bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB
*/ */
cx_set(MO_VID_INTMSK, 0x0f0011); cx_set(MO_VID_INTMSK, 0x0f0011);
...@@ -389,7 +398,7 @@ static int start_video_dma(struct cx8800_dev *dev, ...@@ -389,7 +398,7 @@ static int start_video_dma(struct cx8800_dev *dev,
cx_set(VID_CAPTURE_CONTROL, 0x06); cx_set(VID_CAPTURE_CONTROL, 0x06);
/* start dma */ /* start dma */
cx_set(MO_DEV_CNTRL2, (1<<5)); cx_set(MO_DEV_CNTRL2, (1 << 5));
cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */ cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */
return 0; return 0;
...@@ -488,7 +497,8 @@ static int buffer_prepare(struct vb2_buffer *vb) ...@@ -488,7 +497,8 @@ static int buffer_prepare(struct vb2_buffer *vb)
core->height >> 1); core->height >> 1);
break; break;
} }
dprintk(2, "[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", dprintk(2,
"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
buf, buf->vb.vb2_buf.index, buf, buf->vb.vb2_buf.index,
core->width, core->height, dev->fmt->depth, dev->fmt->name, core->width, core->height, dev->fmt->depth, dev->fmt->name,
(unsigned long)buf->risc.dma); (unsigned long)buf->risc.dma);
...@@ -649,7 +659,8 @@ static int cx8800_s_vid_ctrl(struct v4l2_ctrl *ctrl) ...@@ -649,7 +659,8 @@ static int cx8800_s_vid_ctrl(struct v4l2_ctrl *ctrl)
value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; value = ((ctrl->val - cc->off) << cc->shift) & cc->mask;
break; break;
} }
dprintk(1, "set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", dprintk(1,
"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
ctrl->id, ctrl->name, ctrl->val, cc->reg, value, ctrl->id, ctrl->name, ctrl->val, cc->reg, value,
mask, cc->sreg ? " [shadowed]" : ""); mask, cc->sreg ? " [shadowed]" : "");
if (cc->sreg) if (cc->sreg)
...@@ -687,7 +698,8 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl) ...@@ -687,7 +698,8 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
mask = cc->mask; mask = cc->mask;
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_AUDIO_BALANCE: case V4L2_CID_AUDIO_BALANCE:
value = (ctrl->val < 0x40) ? (0x7f - ctrl->val) : (ctrl->val - 0x40); value = (ctrl->val < 0x40) ?
(0x7f - ctrl->val) : (ctrl->val - 0x40);
break; break;
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME:
value = 0x3f - (ctrl->val & 0x3f); value = 0x3f - (ctrl->val & 0x3f);
...@@ -696,7 +708,8 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl) ...@@ -696,7 +708,8 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; value = ((ctrl->val - cc->off) << cc->shift) & cc->mask;
break; break;
} }
dprintk(1, "set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", dprintk(1,
"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
ctrl->id, ctrl->name, ctrl->val, cc->reg, value, ctrl->id, ctrl->name, ctrl->val, cc->reg, value,
mask, cc->sreg ? " [shadowed]" : ""); mask, cc->sreg ? " [shadowed]" : "");
if (cc->sreg) if (cc->sreg)
...@@ -737,7 +750,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, ...@@ -737,7 +750,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
unsigned int maxw, maxh; unsigned int maxw, maxh;
fmt = format_by_fourcc(f->fmt.pix.pixelformat); fmt = format_by_fourcc(f->fmt.pix.pixelformat);
if (fmt == NULL) if (!fmt)
return -EINVAL; return -EINVAL;
maxw = norm_maxw(core->tvnorm); maxw = norm_maxw(core->tvnorm);
...@@ -879,14 +892,14 @@ int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i) ...@@ -879,14 +892,14 @@ int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i)
if (n >= 4) if (n >= 4)
return -EINVAL; return -EINVAL;
if (0 == INPUT(n).type) if (!INPUT(n).type)
return -EINVAL; return -EINVAL;
i->type = V4L2_INPUT_TYPE_CAMERA; i->type = V4L2_INPUT_TYPE_CAMERA;
strcpy(i->name, iname[INPUT(n).type]); strcpy(i->name, iname[INPUT(n).type]);
if ((CX88_VMUX_TELEVISION == INPUT(n).type) || if ((INPUT(n).type == CX88_VMUX_TELEVISION) ||
(CX88_VMUX_CABLE == INPUT(n).type)) { (INPUT(n).type == CX88_VMUX_CABLE))
i->type = V4L2_INPUT_TYPE_TUNER; i->type = V4L2_INPUT_TYPE_TUNER;
}
i->std = CX88_NORMS; i->std = CX88_NORMS;
return 0; return 0;
} }
...@@ -917,7 +930,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) ...@@ -917,7 +930,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
if (i >= 4) if (i >= 4)
return -EINVAL; return -EINVAL;
if (0 == INPUT(i).type) if (!INPUT(i).type)
return -EINVAL; return -EINVAL;
cx88_newstation(core); cx88_newstation(core);
...@@ -944,7 +957,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, ...@@ -944,7 +957,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
cx88_get_stereo(core, t); cx88_get_stereo(core, t);
reg = cx_read(MO_DEVICE_STATUS); reg = cx_read(MO_DEVICE_STATUS);
t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; t->signal = (reg & (1 << 5)) ? 0xffff : 0x0000;
return 0; return 0;
} }
...@@ -1152,7 +1165,6 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id) ...@@ -1152,7 +1165,6 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id)
/* exported stuff */ /* exported stuff */
static const struct v4l2_file_operations video_fops = { static const struct v4l2_file_operations video_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = v4l2_fh_open, .open = v4l2_fh_open,
.release = vb2_fop_release, .release = vb2_fop_release,
...@@ -1232,7 +1244,6 @@ static const struct video_device cx8800_vbi_template = { ...@@ -1232,7 +1244,6 @@ static const struct video_device cx8800_vbi_template = {
}; };
static const struct v4l2_file_operations radio_fops = { static const struct v4l2_file_operations radio_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = radio_open, .open = radio_open,
.poll = v4l2_ctrl_poll, .poll = v4l2_ctrl_poll,
...@@ -1287,7 +1298,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1287,7 +1298,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
int i; int i;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) if (!dev)
return -ENOMEM; return -ENOMEM;
/* pci init */ /* pci init */
...@@ -1297,7 +1308,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1297,7 +1308,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
goto fail_free; goto fail_free;
} }
core = cx88_core_get(dev->pci); core = cx88_core_get(dev->pci);
if (core == NULL) { if (!core) {
err = -EINVAL; err = -EINVAL;
goto fail_free; goto fail_free;
} }
...@@ -1341,8 +1352,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1341,8 +1352,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
struct v4l2_ctrl *vc; struct v4l2_ctrl *vc;
vc = v4l2_ctrl_new_std(&core->audio_hdl, &cx8800_ctrl_aud_ops, vc = v4l2_ctrl_new_std(&core->audio_hdl, &cx8800_ctrl_aud_ops,
cc->id, cc->minimum, cc->maximum, cc->step, cc->default_value); cc->id, cc->minimum, cc->maximum,
if (vc == NULL) { cc->step, cc->default_value);
if (!vc) {
err = core->audio_hdl.error; err = core->audio_hdl.error;
goto fail_core; goto fail_core;
} }
...@@ -1354,8 +1366,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1354,8 +1366,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
struct v4l2_ctrl *vc; struct v4l2_ctrl *vc;
vc = v4l2_ctrl_new_std(&core->video_hdl, &cx8800_ctrl_vid_ops, vc = v4l2_ctrl_new_std(&core->video_hdl, &cx8800_ctrl_vid_ops,
cc->id, cc->minimum, cc->maximum, cc->step, cc->default_value); cc->id, cc->minimum, cc->maximum,
if (vc == NULL) { cc->step, cc->default_value);
if (!vc) {
err = core->video_hdl.error; err = core->video_hdl.error;
goto fail_core; goto fail_core;
} }
...@@ -1382,15 +1395,17 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1382,15 +1395,17 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
sd = v4l2_i2c_new_subdev_board(&core->v4l2_dev, &core->i2c_adap, sd = v4l2_i2c_new_subdev_board(&core->v4l2_dev, &core->i2c_adap,
&wm8775_info, NULL); &wm8775_info, NULL);
if (sd != NULL) { if (sd) {
core->sd_wm8775 = sd; core->sd_wm8775 = sd;
sd->grp_id = WM8775_GID; sd->grp_id = WM8775_GID;
} }
} }
if (core->board.audio_chip == CX88_AUDIO_TVAUDIO) { if (core->board.audio_chip == CX88_AUDIO_TVAUDIO) {
/* This probes for a tda9874 as is used on some /*
Pixelview Ultra boards. */ * This probes for a tda9874 as is used on some
* Pixelview Ultra boards.
*/
v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
"tvaudio", 0, I2C_ADDRS(0xb0 >> 1)); "tvaudio", 0, I2C_ADDRS(0xb0 >> 1));
} }
...@@ -1504,7 +1519,8 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1504,7 +1519,8 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
/* start tvaudio thread */ /* start tvaudio thread */
if (core->board.tuner_type != UNSET) { if (core->board.tuner_type != UNSET) {
core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); core->kthread = kthread_run(cx88_audio_thread,
core, "cx88 tvaudio");
if (IS_ERR(core->kthread)) { if (IS_ERR(core->kthread)) {
err = PTR_ERR(core->kthread); err = PTR_ERR(core->kthread);
pr_err("failed to create cx88 audio thread, err=%d\n", pr_err("failed to create cx88 audio thread, err=%d\n",
...@@ -1581,7 +1597,8 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state) ...@@ -1581,7 +1597,8 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
cx88_shutdown(core); cx88_shutdown(core);
pci_save_state(pci_dev); pci_save_state(pci_dev);
if (pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)) != 0) { if (pci_set_power_state(pci_dev,
pci_choose_state(pci_dev, state)) != 0) {
pci_disable_device(pci_dev); pci_disable_device(pci_dev);
dev->state.disabled = 1; dev->state.disabled = 1;
} }
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h>
#include <asm/io.h>
MODULE_DESCRIPTION("driver for cx2388x VP3054 design"); MODULE_DESCRIPTION("driver for cx2388x VP3054 design");
MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
...@@ -108,7 +107,7 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) ...@@ -108,7 +107,7 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
return 0; return 0;
vp3054_i2c = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL); vp3054_i2c = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL);
if (vp3054_i2c == NULL) if (!vp3054_i2c)
return -ENOMEM; return -ENOMEM;
dev->vp3054 = vp3054_i2c; dev->vp3054 = vp3054_i2c;
...@@ -135,18 +134,17 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) ...@@ -135,18 +134,17 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
return rc; return rc;
} }
EXPORT_SYMBOL(vp3054_i2c_probe);
void vp3054_i2c_remove(struct cx8802_dev *dev) void vp3054_i2c_remove(struct cx8802_dev *dev)
{ {
struct vp3054_i2c_state *vp3054_i2c = dev->vp3054; struct vp3054_i2c_state *vp3054_i2c = dev->vp3054;
if (vp3054_i2c == NULL || if (!vp3054_i2c ||
dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO)
return; return;
i2c_del_adapter(&vp3054_i2c->adap); i2c_del_adapter(&vp3054_i2c->adap);
kfree(vp3054_i2c); kfree(vp3054_i2c);
} }
EXPORT_SYMBOL(vp3054_i2c_probe);
EXPORT_SYMBOL(vp3054_i2c_remove); EXPORT_SYMBOL(vp3054_i2c_remove);
/* /*
* cx88-vp3054-i2c.h -- support for the secondary I2C bus of the
cx88-vp3054-i2c.h -- support for the secondary I2C bus of the * DNTV Live! DVB-T Pro (VP-3054), wired as:
DNTV Live! DVB-T Pro (VP-3054), wired as: * GPIO[0] -> SCL, GPIO[1] -> SDA
GPIO[0] -> SCL, GPIO[1] -> SDA *
* (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
(c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> *
* This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation; either version 2 of the License, or * (at your option) any later version.
(at your option) any later version. *
* This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details.
GNU General Public License for more details. */
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
struct vp3054_i2c_state { struct vp3054_i2c_state {
......
/* /*
*
* v4l2 device driver for cx2388x based TV cards * v4l2 device driver for cx2388x based TV cards
* *
* (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs] * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
...@@ -99,7 +98,6 @@ static inline unsigned int norm_maxw(v4l2_std_id norm) ...@@ -99,7 +98,6 @@ static inline unsigned int norm_maxw(v4l2_std_id norm)
return 720; return 720;
} }
static inline unsigned int norm_maxh(v4l2_std_id norm) static inline unsigned int norm_maxh(v4l2_std_id norm)
{ {
return (norm & V4L2_STD_525_60) ? 480 : 576; return (norm & V4L2_STD_525_60) ? 480 : 576;
...@@ -141,6 +139,7 @@ struct sram_channel { ...@@ -141,6 +139,7 @@ struct sram_channel {
u32 cnt1_reg; u32 cnt1_reg;
u32 cnt2_reg; u32 cnt2_reg;
}; };
extern const struct sram_channel cx88_sram_channels[]; extern const struct sram_channel cx88_sram_channels[];
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
...@@ -428,7 +427,8 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) ...@@ -428,7 +427,8 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev)
if (!core->i2c_rc) { \ if (!core->i2c_rc) { \
if (core->gate_ctrl) \ if (core->gate_ctrl) \
core->gate_ctrl(core, 1); \ core->gate_ctrl(core, 1); \
v4l2_device_call_all(&core->v4l2_dev, grpid, o, f, ##args); \ v4l2_device_call_all(&core->v4l2_dev, \
grpid, o, f, ##args); \
if (core->gate_ctrl) \ if (core->gate_ctrl) \
core->gate_ctrl(core, 0); \ core->gate_ctrl(core, 0); \
} \ } \
...@@ -441,7 +441,7 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) ...@@ -441,7 +441,7 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev)
#define wm8775_s_ctrl(core, id, val) \ #define wm8775_s_ctrl(core, id, val) \
do { \ do { \
struct v4l2_ctrl *ctrl_ = \ struct v4l2_ctrl *ctrl_ = \
v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id);\
if (ctrl_ && !core->i2c_rc) { \ if (ctrl_ && !core->i2c_rc) { \
if (core->gate_ctrl) \ if (core->gate_ctrl) \
core->gate_ctrl(core, 1); \ core->gate_ctrl(core, 1); \
...@@ -454,7 +454,7 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) ...@@ -454,7 +454,7 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev)
#define wm8775_g_ctrl(core, id) \ #define wm8775_g_ctrl(core, id) \
({ \ ({ \
struct v4l2_ctrl *ctrl_ = \ struct v4l2_ctrl *ctrl_ = \
v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id);\
s32 val = 0; \ s32 val = 0; \
if (ctrl_ && !core->i2c_rc) { \ if (ctrl_ && !core->i2c_rc) { \
if (core->gate_ctrl) \ if (core->gate_ctrl) \
...@@ -505,7 +505,6 @@ struct cx8800_dev { ...@@ -505,7 +505,6 @@ struct cx8800_dev {
/* function 1: audio/alsa stuff */ /* function 1: audio/alsa stuff */
/* =============> moved to cx88-alsa.c <====================== */ /* =============> moved to cx88-alsa.c <====================== */
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* function 2: mpeg stuff */ /* function 2: mpeg stuff */
...@@ -567,6 +566,7 @@ struct cx8802_dev { ...@@ -567,6 +566,7 @@ struct cx8802_dev {
/* mpeg params */ /* mpeg params */
struct cx2341x_handler cxhdl; struct cx2341x_handler cxhdl;
#endif #endif
#if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) #if IS_ENABLED(CONFIG_VIDEO_CX88_DVB)
...@@ -589,13 +589,13 @@ struct cx8802_dev { ...@@ -589,13 +589,13 @@ struct cx8802_dev {
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
#define cx_read(reg) readl(core->lmmio + ((reg)>>2)) #define cx_read(reg) readl(core->lmmio + ((reg) >> 2))
#define cx_write(reg, value) writel((value), core->lmmio + ((reg)>>2)) #define cx_write(reg, value) writel((value), core->lmmio + ((reg) >> 2))
#define cx_writeb(reg, value) writeb((value), core->bmmio + (reg)) #define cx_writeb(reg, value) writeb((value), core->bmmio + (reg))
#define cx_andor(reg, mask, value) \ #define cx_andor(reg, mask, value) \
writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\ writel((readl(core->lmmio + ((reg) >> 2)) & ~(mask)) |\
((value) & (mask)), core->lmmio+((reg)>>2)) ((value) & (mask)), core->lmmio + ((reg) >> 2))
#define cx_set(reg, bit) cx_andor((reg), (bit), (bit)) #define cx_set(reg, bit) cx_andor((reg), (bit), (bit))
#define cx_clear(reg, bit) cx_andor((reg), (bit), 0) #define cx_clear(reg, bit) cx_andor((reg), (bit), 0)
...@@ -605,24 +605,26 @@ struct cx8802_dev { ...@@ -605,24 +605,26 @@ struct cx8802_dev {
#define cx_sread(sreg) (core->shadow[sreg]) #define cx_sread(sreg) (core->shadow[sreg])
#define cx_swrite(sreg, reg, value) \ #define cx_swrite(sreg, reg, value) \
(core->shadow[sreg] = value, \ (core->shadow[sreg] = value, \
writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) writel(core->shadow[sreg], core->lmmio + ((reg) >> 2)))
#define cx_sandor(sreg, reg, mask, value) \ #define cx_sandor(sreg, reg, mask, value) \
(core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \ (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | \
writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) ((value) & (mask)), \
writel(core->shadow[sreg], \
core->lmmio + ((reg) >> 2)))
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-core.c */ /* cx88-core.c */
extern unsigned int cx88_core_debug; extern unsigned int cx88_core_debug;
extern void cx88_print_irqbits(const char *tag, const char *strings[], void cx88_print_irqbits(const char *tag, const char *strings[],
int len, u32 bits, u32 mask); int len, u32 bits, u32 mask);
extern int cx88_core_irq(struct cx88_core *core, u32 status); int cx88_core_irq(struct cx88_core *core, u32 status);
extern void cx88_wakeup(struct cx88_core *core, void cx88_wakeup(struct cx88_core *core,
struct cx88_dmaqueue *q, u32 count); struct cx88_dmaqueue *q, u32 count);
extern void cx88_shutdown(struct cx88_core *core); void cx88_shutdown(struct cx88_core *core);
extern int cx88_reset(struct cx88_core *core); int cx88_reset(struct cx88_core *core);
extern int extern int
cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
...@@ -634,30 +636,29 @@ cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, ...@@ -634,30 +636,29 @@ cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
struct scatterlist *sglist, unsigned int bpl, struct scatterlist *sglist, unsigned int bpl,
unsigned int lines, unsigned int lpi); unsigned int lines, unsigned int lpi);
extern void cx88_risc_disasm(struct cx88_core *core, void cx88_risc_disasm(struct cx88_core *core,
struct cx88_riscmem *risc); struct cx88_riscmem *risc);
extern int cx88_sram_channel_setup(struct cx88_core *core, int cx88_sram_channel_setup(struct cx88_core *core,
const struct sram_channel *ch, const struct sram_channel *ch,
unsigned int bpl, u32 risc); unsigned int bpl, u32 risc);
extern void cx88_sram_channel_dump(struct cx88_core *core, void cx88_sram_channel_dump(struct cx88_core *core,
const struct sram_channel *ch); const struct sram_channel *ch);
extern int cx88_set_scale(struct cx88_core *core, unsigned int width, int cx88_set_scale(struct cx88_core *core, unsigned int width,
unsigned int height, enum v4l2_field field); unsigned int height, enum v4l2_field field);
extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm); int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm);
extern void cx88_vdev_init(struct cx88_core *core, void cx88_vdev_init(struct cx88_core *core,
struct pci_dev *pci, struct pci_dev *pci,
struct video_device *vfd, struct video_device *vfd,
const struct video_device *template_, const struct video_device *template_,
const char *type); const char *type);
extern struct cx88_core *cx88_core_get(struct pci_dev *pci); struct cx88_core *cx88_core_get(struct pci_dev *pci);
extern void cx88_core_put(struct cx88_core *core, void cx88_core_put(struct cx88_core *core,
struct pci_dev *pci); struct pci_dev *pci);
extern int cx88_start_audio_dma(struct cx88_core *core); int cx88_start_audio_dma(struct cx88_core *core);
extern int cx88_stop_audio_dma(struct cx88_core *core); int cx88_stop_audio_dma(struct cx88_core *core);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-vbi.c */ /* cx88-vbi.c */
...@@ -666,11 +667,6 @@ extern int cx88_stop_audio_dma(struct cx88_core *core); ...@@ -666,11 +667,6 @@ extern int cx88_stop_audio_dma(struct cx88_core *core);
int cx8800_vbi_fmt(struct file *file, void *priv, int cx8800_vbi_fmt(struct file *file, void *priv,
struct v4l2_format *f); struct v4l2_format *f);
/*
int cx8800_start_vbi_dma(struct cx8800_dev *dev,
struct cx88_dmaqueue *q,
struct cx88_buffer *buf);
*/
void cx8800_stop_vbi_dma(struct cx8800_dev *dev); void cx8800_stop_vbi_dma(struct cx8800_dev *dev);
int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q); int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q);
...@@ -679,17 +675,16 @@ extern const struct vb2_ops cx8800_vbi_qops; ...@@ -679,17 +675,16 @@ extern const struct vb2_ops cx8800_vbi_qops;
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-i2c.c */ /* cx88-i2c.c */
extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci); int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-cards.c */ /* cx88-cards.c */
extern int cx88_tuner_callback(void *dev, int component, int command, int arg); int cx88_tuner_callback(void *dev, int component, int command, int arg);
extern int cx88_get_resources(const struct cx88_core *core, int cx88_get_resources(const struct cx88_core *core,
struct pci_dev *pci); struct pci_dev *pci);
extern struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr); struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr);
extern void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl); void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-tvaudio.c */ /* cx88-tvaudio.c */
...@@ -720,7 +715,7 @@ int cx88_ir_fini(struct cx88_core *core); ...@@ -720,7 +715,7 @@ int cx88_ir_fini(struct cx88_core *core);
void cx88_ir_irq(struct cx88_core *core); void cx88_ir_irq(struct cx88_core *core);
int cx88_ir_start(struct cx88_core *core); int cx88_ir_start(struct cx88_core *core);
void cx88_ir_stop(struct cx88_core *core); void cx88_ir_stop(struct cx88_core *core);
extern void cx88_i2c_init_ir(struct cx88_core *core); void cx88_i2c_init_ir(struct cx88_core *core);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-mpeg.c */ /* cx88-mpeg.c */
......
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