summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-11-16 03:59:49 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-11-18 05:44:51 -0500
commit7b61ba8ff838dbee422d428fbd882ab83db4b2d9 (patch)
treecaa863cac4a8e249bdaa8f4016e76d52ea467306
parent65bc2fe86e667077b38a63ce6cb40677be09bc4f (diff)
[media] cx88: make checkpatch happier
This driver is old, and have lots of checkpatch violations. As we're touching a lot on this driver due to the printk conversions, let's run checkpatch --fix on it, in order to solve some of those issues. Also, do a few manual adjustments: - remove the FSF address and use the usual coding style for the initial comments; - use WARN_ON() instead of BUG_ON(); - remove an unused typedef; - break a few long lines. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/pci/cx88/cx88-alsa.c79
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c94
-rw-r--r--drivers/media/pci/cx88/cx88-cards.c85
-rw-r--r--drivers/media/pci/cx88/cx88-core.c121
-rw-r--r--drivers/media/pci/cx88/cx88-dsp.c11
-rw-r--r--drivers/media/pci/cx88/cx88-dvb.c112
-rw-r--r--drivers/media/pci/cx88/cx88-i2c.c95
-rw-r--r--drivers/media/pci/cx88/cx88-input.c18
-rw-r--r--drivers/media/pci/cx88/cx88-mpeg.c63
-rw-r--r--drivers/media/pci/cx88/cx88-reg.h13
-rw-r--r--drivers/media/pci/cx88/cx88-tvaudio.c87
-rw-r--r--drivers/media/pci/cx88/cx88-vbi.c20
-rw-r--r--drivers/media/pci/cx88/cx88-video.c195
-rw-r--r--drivers/media/pci/cx88/cx88-vp3054-i2c.c44
-rw-r--r--drivers/media/pci/cx88/cx88.h37
15 files changed, 515 insertions, 559 deletions
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index d2f1880a157e..56770e84b3d5 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Support for audio capture 2 * Support for audio capture
4 * PCI function #1 of the cx2388x. 3 * PCI function #1 of the cx2388x.
5 * 4 *
@@ -18,10 +17,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 19 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 20 */
26 21
27#include "cx88.h" 22#include "cx88.h"
@@ -118,8 +113,8 @@ MODULE_VERSION(CX88_VERSION);
118 113
119MODULE_SUPPORTED_DEVICE("{{Conexant,23881},{{Conexant,23882},{{Conexant,23883}"); 114MODULE_SUPPORTED_DEVICE("{{Conexant,23881},{{Conexant,23882},{{Conexant,23883}");
120static unsigned int debug; 115static unsigned int debug;
121module_param(debug,int,0644); 116module_param(debug, int, 0644);
122MODULE_PARM_DESC(debug,"enable debug messages"); 117MODULE_PARM_DESC(debug, "enable debug messages");
123 118
124/**************************************************************************** 119/****************************************************************************
125 Module specific funtions 120 Module specific funtions
@@ -132,7 +127,7 @@ MODULE_PARM_DESC(debug,"enable debug messages");
132static int _cx88_start_audio_dma(snd_cx88_card_t *chip) 127static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
133{ 128{
134 struct cx88_audio_buffer *buf = chip->buf; 129 struct cx88_audio_buffer *buf = chip->buf;
135 struct cx88_core *core=chip->core; 130 struct cx88_core *core = chip->core;
136 const struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25]; 131 const struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25];
137 132
138 /* Make sure RISC/FIFO are off before changing FIFO/RISC settings */ 133 /* Make sure RISC/FIFO are off before changing FIFO/RISC settings */
@@ -177,7 +172,8 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
177 */ 172 */
178static int _cx88_stop_audio_dma(snd_cx88_card_t *chip) 173static int _cx88_stop_audio_dma(snd_cx88_card_t *chip)
179{ 174{
180 struct cx88_core *core=chip->core; 175 struct cx88_core *core = chip->core;
176
181 dprintk(1, "Stopping audio DMA\n"); 177 dprintk(1, "Stopping audio DMA\n");
182 178
183 /* stop dma */ 179 /* stop dma */
@@ -261,7 +257,7 @@ static irqreturn_t cx8801_irq(int irq, void *dev_id)
261 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) { 257 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) {
262 status = cx_read(MO_PCI_INTSTAT) & 258 status = cx_read(MO_PCI_INTSTAT) &
263 (core->pci_irqmask | PCI_INT_AUDINT); 259 (core->pci_irqmask | PCI_INT_AUDINT);
264 if (0 == status) 260 if (status == 0)
265 goto out; 261 goto out;
266 dprintk(3, "cx8801_irq loop %d/%d, status %x\n", 262 dprintk(3, "cx8801_irq loop %d/%d, status %x\n",
267 loop, MAX_IRQ_LOOP, status); 263 loop, MAX_IRQ_LOOP, status);
@@ -274,7 +270,7 @@ static irqreturn_t cx8801_irq(int irq, void *dev_id)
274 cx8801_aud_irq(chip); 270 cx8801_aud_irq(chip);
275 } 271 }
276 272
277 if (MAX_IRQ_LOOP == loop) { 273 if (loop == MAX_IRQ_LOOP) {
278 pr_err("IRQ loop detected, disabling interrupts\n"); 274 pr_err("IRQ loop detected, disabling interrupts\n");
279 cx_clear(MO_PCI_INTMSK, PCI_INT_AUDINT); 275 cx_clear(MO_PCI_INTMSK, PCI_INT_AUDINT);
280 } 276 }
@@ -290,7 +286,7 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages)
290 int i; 286 int i;
291 287
292 buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); 288 buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
293 if (NULL == buf->vaddr) { 289 if (buf->vaddr == NULL) {
294 dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); 290 dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
295 return -ENOMEM; 291 return -ENOMEM;
296 } 292 }
@@ -303,13 +299,13 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages)
303 buf->nr_pages = nr_pages; 299 buf->nr_pages = nr_pages;
304 300
305 buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); 301 buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
306 if (NULL == buf->sglist) 302 if (buf->sglist == NULL)
307 goto vzalloc_err; 303 goto vzalloc_err;
308 304
309 sg_init_table(buf->sglist, buf->nr_pages); 305 sg_init_table(buf->sglist, buf->nr_pages);
310 for (i = 0; i < buf->nr_pages; i++) { 306 for (i = 0; i < buf->nr_pages; i++) {
311 pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE); 307 pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE);
312 if (NULL == pg) 308 if (pg == NULL)
313 goto vmalloc_to_page_err; 309 goto vmalloc_to_page_err;
314 sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0); 310 sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0);
315 } 311 }
@@ -331,7 +327,7 @@ static int cx88_alsa_dma_map(struct cx88_audio_dev *dev)
331 buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist, 327 buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
332 buf->nr_pages, PCI_DMA_FROMDEVICE); 328 buf->nr_pages, PCI_DMA_FROMDEVICE);
333 329
334 if (0 == buf->sglen) { 330 if (buf->sglen == 0) {
335 pr_warn("%s: cx88_alsa_map_sg failed\n", __func__); 331 pr_warn("%s: cx88_alsa_map_sg failed\n", __func__);
336 return -ENOMEM; 332 return -ENOMEM;
337 } 333 }
@@ -366,7 +362,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
366 362
367 BUG_ON(!chip->dma_size); 363 BUG_ON(!chip->dma_size);
368 364
369 dprintk(2,"Freeing buffer\n"); 365 dprintk(2, "Freeing buffer\n");
370 cx88_alsa_dma_unmap(chip); 366 cx88_alsa_dma_unmap(chip);
371 cx88_alsa_dma_free(chip->buf); 367 cx88_alsa_dma_free(chip->buf);
372 if (risc->cpu) 368 if (risc->cpu)
@@ -431,6 +427,7 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
431 427
432 if (cx88_sram_channels[SRAM_CH25].fifo_size != DEFAULT_FIFO_SIZE) { 428 if (cx88_sram_channels[SRAM_CH25].fifo_size != DEFAULT_FIFO_SIZE) {
433 unsigned int bpl = cx88_sram_channels[SRAM_CH25].fifo_size / 4; 429 unsigned int bpl = cx88_sram_channels[SRAM_CH25].fifo_size / 4;
430
434 bpl &= ~7; /* must be multiple of 8 */ 431 bpl &= ~7; /* must be multiple of 8 */
435 runtime->hw.period_bytes_min = bpl; 432 runtime->hw.period_bytes_min = bpl;
436 runtime->hw.period_bytes_max = bpl; 433 runtime->hw.period_bytes_max = bpl;
@@ -438,7 +435,7 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
438 435
439 return 0; 436 return 0;
440_error: 437_error:
441 dprintk(1,"Error opening PCM!\n"); 438 dprintk(1, "Error opening PCM!\n");
442 return err; 439 return err;
443} 440}
444 441
@@ -453,8 +450,8 @@ static int snd_cx88_close(struct snd_pcm_substream *substream)
453/* 450/*
454 * hw_params callback 451 * hw_params callback
455 */ 452 */
456static int snd_cx88_hw_params(struct snd_pcm_substream * substream, 453static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
457 struct snd_pcm_hw_params * hw_params) 454 struct snd_pcm_hw_params *hw_params)
458{ 455{
459 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 456 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
460 457
@@ -474,7 +471,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
474 BUG_ON(chip->num_periods & (chip->num_periods-1)); 471 BUG_ON(chip->num_periods & (chip->num_periods-1));
475 472
476 buf = kzalloc(sizeof(*buf), GFP_KERNEL); 473 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
477 if (NULL == buf) 474 if (buf == NULL)
478 return -ENOMEM; 475 return -ENOMEM;
479 476
480 chip->buf = buf; 477 chip->buf = buf;
@@ -511,7 +508,7 @@ error:
511/* 508/*
512 * hw free callback 509 * hw free callback
513 */ 510 */
514static int snd_cx88_hw_free(struct snd_pcm_substream * substream) 511static int snd_cx88_hw_free(struct snd_pcm_substream *substream)
515{ 512{
516 513
517 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 514 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
@@ -545,13 +542,13 @@ static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd)
545 542
546 switch (cmd) { 543 switch (cmd) {
547 case SNDRV_PCM_TRIGGER_START: 544 case SNDRV_PCM_TRIGGER_START:
548 err=_cx88_start_audio_dma(chip); 545 err = _cx88_start_audio_dma(chip);
549 break; 546 break;
550 case SNDRV_PCM_TRIGGER_STOP: 547 case SNDRV_PCM_TRIGGER_STOP:
551 err=_cx88_stop_audio_dma(chip); 548 err = _cx88_stop_audio_dma(chip);
552 break; 549 break;
553 default: 550 default:
554 err=-EINVAL; 551 err = -EINVAL;
555 break; 552 break;
556 } 553 }
557 554
@@ -584,6 +581,7 @@ static struct page *snd_cx88_page(struct snd_pcm_substream *substream,
584 unsigned long offset) 581 unsigned long offset)
585{ 582{
586 void *pageptr = substream->runtime->dma_area + offset; 583 void *pageptr = substream->runtime->dma_area + offset;
584
587 return vmalloc_to_page(pageptr); 585 return vmalloc_to_page(pageptr);
588} 586}
589 587
@@ -638,7 +636,7 @@ static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *value) 636 struct snd_ctl_elem_value *value)
639{ 637{
640 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 638 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
641 struct cx88_core *core=chip->core; 639 struct cx88_core *core = chip->core;
642 int vol = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f), 640 int vol = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f),
643 bal = cx_read(AUD_BAL_CTL); 641 bal = cx_read(AUD_BAL_CTL);
644 642
@@ -675,7 +673,7 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
675 struct snd_ctl_elem_value *value) 673 struct snd_ctl_elem_value *value)
676{ 674{
677 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 675 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
678 struct cx88_core *core=chip->core; 676 struct cx88_core *core = chip->core;
679 int left, right, v, b; 677 int left, right, v, b;
680 int changed = 0; 678 int changed = 0;
681 u32 old; 679 u32 old;
@@ -814,8 +812,8 @@ static struct snd_kcontrol_new snd_cx88_alc_switch = {
814 */ 812 */
815 813
816static const struct pci_device_id cx88_audio_pci_tbl[] = { 814static const struct pci_device_id cx88_audio_pci_tbl[] = {
817 {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 815 {0x14f1, 0x8801, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
818 {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 816 {0x14f1, 0x8811, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
819 {0, } 817 {0, }
820}; 818};
821MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl); 819MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl);
@@ -830,7 +828,7 @@ static int snd_cx88_free(snd_cx88_card_t *chip)
830 if (chip->irq >= 0) 828 if (chip->irq >= 0)
831 free_irq(chip->irq, chip); 829 free_irq(chip->irq, chip);
832 830
833 cx88_core_put(chip->core,chip->pci); 831 cx88_core_put(chip->core, chip->pci);
834 832
835 pci_disable_device(chip->pci); 833 pci_disable_device(chip->pci);
836 return 0; 834 return 0;
@@ -839,7 +837,7 @@ static int snd_cx88_free(snd_cx88_card_t *chip)
839/* 837/*
840 * Component Destructor 838 * Component Destructor
841 */ 839 */
842static void snd_cx88_dev_free(struct snd_card * card) 840static void snd_cx88_dev_free(struct snd_card *card)
843{ 841{
844 snd_cx88_card_t *chip = card->private_data; 842 snd_cx88_card_t *chip = card->private_data;
845 843
@@ -872,14 +870,14 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
872 chip = card->private_data; 870 chip = card->private_data;
873 871
874 core = cx88_core_get(pci); 872 core = cx88_core_get(pci);
875 if (NULL == core) { 873 if (core == NULL) {
876 err = -EINVAL; 874 err = -EINVAL;
877 return err; 875 return err;
878 } 876 }
879 877
880 err = pci_set_dma_mask(pci,DMA_BIT_MASK(32)); 878 err = pci_set_dma_mask(pci, DMA_BIT_MASK(32));
881 if (err) { 879 if (err) {
882 dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n",core->name); 880 dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n", core->name);
883 cx88_core_put(core, pci); 881 cx88_core_put(core, pci);
884 return err; 882 return err;
885 } 883 }
@@ -908,7 +906,7 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
908 dprintk(1, "ALSA %s/%i: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n", 906 dprintk(1, "ALSA %s/%i: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
909 core->name, devno, 907 core->name, devno,
910 pci_name(pci), pci->revision, pci->irq, 908 pci_name(pci), pci->revision, pci->irq,
911 pci_lat, (unsigned long long)pci_resource_start(pci,0)); 909 pci_lat, (unsigned long long)pci_resource_start(pci, 0));
912 910
913 chip->irq = pci->irq; 911 chip->irq = pci->irq;
914 synchronize_irq(chip->irq); 912 synchronize_irq(chip->irq);
@@ -964,19 +962,20 @@ static int cx88_audio_initdev(struct pci_dev *pci,
964 if (core->sd_wm8775) 962 if (core->sd_wm8775)
965 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip)); 963 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip));
966 964
967 strcpy (card->driver, "CX88x"); 965 strcpy(card->driver, "CX88x");
968 sprintf(card->shortname, "Conexant CX%x", pci->device); 966 sprintf(card->shortname, "Conexant CX%x", pci->device);
969 sprintf(card->longname, "%s at %#llx", 967 sprintf(card->longname, "%s at %#llx",
970 card->shortname,(unsigned long long)pci_resource_start(pci, 0)); 968 card->shortname,
971 strcpy (card->mixername, "CX88"); 969 (unsigned long long)pci_resource_start(pci, 0));
970 strcpy(card->mixername, "CX88");
972 971
973 dprintk (0, "%s/%i: ALSA support for cx2388x boards\n", 972 dprintk(0, "%s/%i: ALSA support for cx2388x boards\n",
974 card->driver,devno); 973 card->driver, devno);
975 974
976 err = snd_card_register(card); 975 err = snd_card_register(card);
977 if (err < 0) 976 if (err < 0)
978 goto error; 977 goto error;
979 pci_set_drvdata(pci,card); 978 pci_set_drvdata(pci, card);
980 979
981 devno++; 980 devno++;
982 return 0; 981 return 0;
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index 4163e777825d..bffd064daff5 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Support for a cx23416 mpeg encoder via cx2388x host port. 2 * Support for a cx23416 mpeg encoder via cx2388x host port.
4 * "blackbird" reference design. 3 * "blackbird" reference design.
5 * 4 *
@@ -20,10 +19,6 @@
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 21 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */ 22 */
28 23
29#include "cx88.h" 24#include "cx88.h"
@@ -46,8 +41,8 @@ MODULE_LICENSE("GPL");
46MODULE_VERSION(CX88_VERSION); 41MODULE_VERSION(CX88_VERSION);
47 42
48static unsigned int debug; 43static unsigned int debug;
49module_param(debug,int,0644); 44module_param(debug, int, 0644);
50MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); 45MODULE_PARM_DESC(debug, "enable debug messages [blackbird]");
51 46
52#define dprintk(level, fmt, arg...) do { \ 47#define dprintk(level, fmt, arg...) do { \
53 if (debug + 1 > level) \ 48 if (debug + 1 > level) \
@@ -216,14 +211,14 @@ static void host_setup(struct cx88_core *core)
216static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state) 211static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state)
217{ 212{
218 unsigned long timeout = jiffies + msecs_to_jiffies(1); 213 unsigned long timeout = jiffies + msecs_to_jiffies(1);
219 u32 gpio0,need; 214 u32 gpio0, need;
220 215
221 need = state ? 2 : 0; 216 need = state ? 2 : 0;
222 for (;;) { 217 for (;;) {
223 gpio0 = cx_read(MO_GP0_IO) & 2; 218 gpio0 = cx_read(MO_GP0_IO) & 2;
224 if (need == gpio0) 219 if (need == gpio0)
225 return 0; 220 return 0;
226 if (time_after(jiffies,timeout)) 221 if (time_after(jiffies, timeout))
227 return -1; 222 return -1;
228 udelay(1); 223 udelay(1);
229 } 224 }
@@ -242,7 +237,7 @@ static int memory_write(struct cx88_core *core, u32 address, u32 value)
242 cx_read(P1_MDATA0); 237 cx_read(P1_MDATA0);
243 cx_read(P1_MADDR0); 238 cx_read(P1_MADDR0);
244 239
245 return wait_ready_gpio0_bit1(core,1); 240 return wait_ready_gpio0_bit1(core, 1);
246} 241}
247 242
248static int memory_read(struct cx88_core *core, u32 address, u32 *value) 243static int memory_read(struct cx88_core *core, u32 address, u32 *value)
@@ -256,7 +251,7 @@ static int memory_read(struct cx88_core *core, u32 address, u32 *value)
256 cx_writeb(P1_MADDR0, (unsigned int)address); 251 cx_writeb(P1_MADDR0, (unsigned int)address);
257 cx_read(P1_MADDR0); 252 cx_read(P1_MADDR0);
258 253
259 retval = wait_ready_gpio0_bit1(core,1); 254 retval = wait_ready_gpio0_bit1(core, 1);
260 255
261 cx_writeb(P1_MDATA3, 0); 256 cx_writeb(P1_MDATA3, 0);
262 val = (unsigned char)cx_read(P1_MDATA3) << 24; 257 val = (unsigned char)cx_read(P1_MDATA3) << 24;
@@ -283,7 +278,7 @@ static int register_write(struct cx88_core *core, u32 address, u32 value)
283 cx_read(P1_RDATA0); 278 cx_read(P1_RDATA0);
284 cx_read(P1_RADDR0); 279 cx_read(P1_RADDR0);
285 280
286 return wait_ready_gpio0_bit1(core,1); 281 return wait_ready_gpio0_bit1(core, 1);
287} 282}
288 283
289 284
@@ -297,7 +292,7 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value)
297 cx_writeb(P1_RRDWR, 0); 292 cx_writeb(P1_RRDWR, 0);
298 cx_read(P1_RADDR0); 293 cx_read(P1_RADDR0);
299 294
300 retval = wait_ready_gpio0_bit1(core,1); 295 retval = wait_ready_gpio0_bit1(core, 1);
301 val = (unsigned char)cx_read(P1_RDATA0); 296 val = (unsigned char)cx_read(P1_RDATA0);
302 val |= (unsigned char)cx_read(P1_RDATA1) << 8; 297 val |= (unsigned char)cx_read(P1_RDATA1) << 8;
303 val |= (unsigned char)cx_read(P1_RDATA2) << 16; 298 val |= (unsigned char)cx_read(P1_RDATA2) << 16;
@@ -316,7 +311,7 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
316 u32 value, flag, retval; 311 u32 value, flag, retval;
317 int i; 312 int i;
318 313
319 dprintk(1,"%s: 0x%X\n", __func__, command); 314 dprintk(1, "%s: 0x%X\n", __func__, command);
320 315
321 /* this may not be 100% safe if we can't read any memory location 316 /* this may not be 100% safe if we can't read any memory location
322 without side effects */ 317 without side effects */
@@ -354,7 +349,7 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
354 memory_read(dev->core, dev->mailbox, &flag); 349 memory_read(dev->core, dev->mailbox, &flag);
355 if (0 != (flag & 4)) 350 if (0 != (flag & 4))
356 break; 351 break;
357 if (time_after(jiffies,timeout)) { 352 if (time_after(jiffies, timeout)) {
358 dprintk(0, "ERROR: API Mailbox timeout %x\n", command); 353 dprintk(0, "ERROR: API Mailbox timeout %x\n", command);
359 return -EIO; 354 return -EIO;
360 } 355 }
@@ -368,7 +363,7 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
368 } 363 }
369 364
370 memory_read(dev->core, dev->mailbox + 2, &retval); 365 memory_read(dev->core, dev->mailbox + 2, &retval);
371 dprintk(1, "API result = %d\n",retval); 366 dprintk(1, "API result = %d\n", retval);
372 367
373 flag = 0; 368 flag = 0;
374 memory_write(dev->core, dev->mailbox, flag); 369 memory_write(dev->core, dev->mailbox, flag);
@@ -400,8 +395,8 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
400 395
401static int blackbird_find_mailbox(struct cx8802_dev *dev) 396static int blackbird_find_mailbox(struct cx8802_dev *dev)
402{ 397{
403 u32 signature[4]={0x12345678, 0x34567812, 0x56781234, 0x78123456}; 398 u32 signature[4] = {0x12345678, 0x34567812, 0x56781234, 0x78123456};
404 int signaturecnt=0; 399 int signaturecnt = 0;
405 u32 value; 400 u32 value;
406 int i; 401 int i;
407 402
@@ -411,7 +406,7 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev)
411 signaturecnt++; 406 signaturecnt++;
412 else 407 else
413 signaturecnt = 0; 408 signaturecnt = 0;
414 if (4 == signaturecnt) { 409 if (signaturecnt == 4) {
415 dprintk(1, "Mailbox signature found\n"); 410 dprintk(1, "Mailbox signature found\n");
416 return i+1; 411 return i+1;
417 } 412 }
@@ -459,14 +454,14 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
459 return -EINVAL; 454 return -EINVAL;
460 } 455 }
461 456
462 if (0 != memcmp(firmware->data, magic, 8)) { 457 if (memcmp(firmware->data, magic, 8) != 0) {
463 pr_err("Firmware magic mismatch, wrong file?\n"); 458 pr_err("Firmware magic mismatch, wrong file?\n");
464 release_firmware(firmware); 459 release_firmware(firmware);
465 return -EINVAL; 460 return -EINVAL;
466 } 461 }
467 462
468 /* transfer to the chip */ 463 /* transfer to the chip */
469 dprintk(1,"Loading firmware ...\n"); 464 dprintk(1, "Loading firmware ...\n");
470 dataptr = (__le32 *)firmware->data; 465 dataptr = (__le32 *)firmware->data;
471 for (i = 0; i < (firmware->size >> 2); i++) { 466 for (i = 0; i < (firmware->size >> 2); i++) {
472 value = le32_to_cpu(*dataptr); 467 value = le32_to_cpu(*dataptr);
@@ -534,7 +529,7 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
534 int version; 529 int version;
535 int retval; 530 int retval;
536 531
537 dprintk(1,"Initialize codec\n"); 532 dprintk(1, "Initialize codec\n");
538 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ 533 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
539 if (retval < 0) { 534 if (retval < 0) {
540 /* ping was not successful, reset and upload firmware */ 535 /* ping was not successful, reset and upload firmware */
@@ -782,7 +777,7 @@ static int vidioc_querycap(struct file *file, void *priv,
782 return 0; 777 return 0;
783} 778}
784 779
785static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, 780static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
786 struct v4l2_fmtdesc *f) 781 struct v4l2_fmtdesc *f)
787{ 782{
788 if (f->index != 0) 783 if (f->index != 0)
@@ -815,7 +810,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
815{ 810{
816 struct cx8802_dev *dev = video_drvdata(file); 811 struct cx8802_dev *dev = video_drvdata(file);
817 struct cx88_core *core = dev->core; 812 struct cx88_core *core = dev->core;
818 unsigned maxw, maxh; 813 unsigned int maxw, maxh;
819 enum v4l2_field field; 814 enum v4l2_field field;
820 815
821 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 816 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
@@ -871,14 +866,14 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
871 return 0; 866 return 0;
872} 867}
873 868
874static int vidioc_s_frequency (struct file *file, void *priv, 869static int vidioc_s_frequency(struct file *file, void *priv,
875 const struct v4l2_frequency *f) 870 const struct v4l2_frequency *f)
876{ 871{
877 struct cx8802_dev *dev = video_drvdata(file); 872 struct cx8802_dev *dev = video_drvdata(file);
878 struct cx88_core *core = dev->core; 873 struct cx88_core *core = dev->core;
879 bool streaming; 874 bool streaming;
880 875
881 if (unlikely(UNSET == core->board.tuner_type)) 876 if (unlikely(core->board.tuner_type == UNSET))
882 return -EINVAL; 877 return -EINVAL;
883 if (unlikely(f->tuner != 0)) 878 if (unlikely(f->tuner != 0))
884 return -EINVAL; 879 return -EINVAL;
@@ -886,7 +881,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
886 if (streaming) 881 if (streaming)
887 blackbird_stop_codec(dev); 882 blackbird_stop_codec(dev);
888 883
889 cx88_set_freq (core,f); 884 cx88_set_freq(core, f);
890 blackbird_initialize_codec(dev); 885 blackbird_initialize_codec(dev);
891 cx88_set_scale(core, core->width, core->height, 886 cx88_set_scale(core, core->width, core->height,
892 core->field); 887 core->field);
@@ -895,7 +890,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
895 return 0; 890 return 0;
896} 891}
897 892
898static int vidioc_log_status (struct file *file, void *priv) 893static int vidioc_log_status(struct file *file, void *priv)
899{ 894{
900 struct cx8802_dev *dev = video_drvdata(file); 895 struct cx8802_dev *dev = video_drvdata(file);
901 struct cx88_core *core = dev->core; 896 struct cx88_core *core = dev->core;
@@ -907,21 +902,22 @@ static int vidioc_log_status (struct file *file, void *priv)
907 return 0; 902 return 0;
908} 903}
909 904
910static int vidioc_enum_input (struct file *file, void *priv, 905static int vidioc_enum_input(struct file *file, void *priv,
911 struct v4l2_input *i) 906 struct v4l2_input *i)
912{ 907{
913 struct cx8802_dev *dev = video_drvdata(file); 908 struct cx8802_dev *dev = video_drvdata(file);
914 struct cx88_core *core = dev->core; 909 struct cx88_core *core = dev->core;
915 return cx88_enum_input (core,i); 910
911 return cx88_enum_input(core, i);
916} 912}
917 913
918static int vidioc_g_frequency (struct file *file, void *priv, 914static int vidioc_g_frequency(struct file *file, void *priv,
919 struct v4l2_frequency *f) 915 struct v4l2_frequency *f)
920{ 916{
921 struct cx8802_dev *dev = video_drvdata(file); 917 struct cx8802_dev *dev = video_drvdata(file);
922 struct cx88_core *core = dev->core; 918 struct cx88_core *core = dev->core;
923 919
924 if (unlikely(UNSET == core->board.tuner_type)) 920 if (unlikely(core->board.tuner_type == UNSET))
925 return -EINVAL; 921 return -EINVAL;
926 if (unlikely(f->tuner != 0)) 922 if (unlikely(f->tuner != 0))
927 return -EINVAL; 923 return -EINVAL;
@@ -932,7 +928,7 @@ static int vidioc_g_frequency (struct file *file, void *priv,
932 return 0; 928 return 0;
933} 929}
934 930
935static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) 931static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
936{ 932{
937 struct cx8802_dev *dev = video_drvdata(file); 933 struct cx8802_dev *dev = video_drvdata(file);
938 struct cx88_core *core = dev->core; 934 struct cx88_core *core = dev->core;
@@ -941,7 +937,7 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)
941 return 0; 937 return 0;
942} 938}
943 939
944static int vidioc_s_input (struct file *file, void *priv, unsigned int i) 940static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
945{ 941{
946 struct cx8802_dev *dev = video_drvdata(file); 942 struct cx8802_dev *dev = video_drvdata(file);
947 struct cx88_core *core = dev->core; 943 struct cx88_core *core = dev->core;
@@ -952,20 +948,20 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i)
952 return -EINVAL; 948 return -EINVAL;
953 949
954 cx88_newstation(core); 950 cx88_newstation(core);
955 cx88_video_mux(core,i); 951 cx88_video_mux(core, i);
956 return 0; 952 return 0;
957} 953}
958 954
959static int vidioc_g_tuner (struct file *file, void *priv, 955static int vidioc_g_tuner(struct file *file, void *priv,
960 struct v4l2_tuner *t) 956 struct v4l2_tuner *t)
961{ 957{
962 struct cx8802_dev *dev = video_drvdata(file); 958 struct cx8802_dev *dev = video_drvdata(file);
963 struct cx88_core *core = dev->core; 959 struct cx88_core *core = dev->core;
964 u32 reg; 960 u32 reg;
965 961
966 if (unlikely(UNSET == core->board.tuner_type)) 962 if (unlikely(core->board.tuner_type == UNSET))
967 return -EINVAL; 963 return -EINVAL;
968 if (0 != t->index) 964 if (t->index != 0)
969 return -EINVAL; 965 return -EINVAL;
970 966
971 strcpy(t->name, "Television"); 967 strcpy(t->name, "Television");
@@ -973,21 +969,21 @@ static int vidioc_g_tuner (struct file *file, void *priv,
973 t->rangehigh = 0xffffffffUL; 969 t->rangehigh = 0xffffffffUL;
974 call_all(core, tuner, g_tuner, t); 970 call_all(core, tuner, g_tuner, t);
975 971
976 cx88_get_stereo(core ,t); 972 cx88_get_stereo(core, t);
977 reg = cx_read(MO_DEVICE_STATUS); 973 reg = cx_read(MO_DEVICE_STATUS);
978 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; 974 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
979 return 0; 975 return 0;
980} 976}
981 977
982static int vidioc_s_tuner (struct file *file, void *priv, 978static int vidioc_s_tuner(struct file *file, void *priv,
983 const struct v4l2_tuner *t) 979 const struct v4l2_tuner *t)
984{ 980{
985 struct cx8802_dev *dev = video_drvdata(file); 981 struct cx8802_dev *dev = video_drvdata(file);
986 struct cx88_core *core = dev->core; 982 struct cx88_core *core = dev->core;
987 983
988 if (UNSET == core->board.tuner_type) 984 if (core->board.tuner_type == UNSET)
989 return -EINVAL; 985 return -EINVAL;
990 if (0 != t->index) 986 if (t->index != 0)
991 return -EINVAL; 987 return -EINVAL;
992 988
993 cx88_set_stereo(core, t->audmode, 1); 989 cx88_set_stereo(core, t->audmode, 1);
@@ -1011,8 +1007,8 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
1011 return cx88_set_tvnorm(core, id); 1007 return cx88_set_tvnorm(core, id);
1012} 1008}
1013 1009
1014static const struct v4l2_file_operations mpeg_fops = 1010static const struct v4l2_file_operations mpeg_fops = {
1015{ 1011
1016 .owner = THIS_MODULE, 1012 .owner = THIS_MODULE,
1017 .open = v4l2_fh_open, 1013 .open = v4l2_fh_open,
1018 .release = vb2_fop_release, 1014 .release = vb2_fop_release,
@@ -1051,7 +1047,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
1051static struct video_device cx8802_mpeg_template = { 1047static struct video_device cx8802_mpeg_template = {
1052 .name = "cx8802", 1048 .name = "cx8802",
1053 .fops = &mpeg_fops, 1049 .fops = &mpeg_fops,
1054 .ioctl_ops = &mpeg_ioctl_ops, 1050 .ioctl_ops = &mpeg_ioctl_ops,
1055 .tvnorms = CX88_NORMS, 1051 .tvnorms = CX88_NORMS,
1056}; 1052};
1057 1053
@@ -1136,8 +1132,8 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1136 struct vb2_queue *q; 1132 struct vb2_queue *q;
1137 int err; 1133 int err;
1138 1134
1139 dprintk( 1, "%s\n", __func__); 1135 dprintk(1, "%s\n", __func__);
1140 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 1136 dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1141 core->boardnr, 1137 core->boardnr,
1142 core->name, 1138 core->name,
1143 core->pci_bus, 1139 core->pci_bus,
@@ -1165,8 +1161,8 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1165 1161
1166 /* initial device configuration: needed ? */ 1162 /* initial device configuration: needed ? */
1167// init_controls(core); 1163// init_controls(core);
1168 cx88_set_tvnorm(core,core->tvnorm); 1164 cx88_set_tvnorm(core, core->tvnorm);
1169 cx88_video_mux(core,0); 1165 cx88_video_mux(core, 0);
1170 cx2341x_handler_set_50hz(&dev->cxhdl, core->height == 576); 1166 cx2341x_handler_set_50hz(&dev->cxhdl, core->height == 576);
1171 cx2341x_handler_setup(&dev->cxhdl); 1167 cx2341x_handler_setup(&dev->cxhdl);
1172 1168
diff --git a/drivers/media/pci/cx88/cx88-cards.c b/drivers/media/pci/cx88/cx88-cards.c
index 1a65db957dcb..269179142cd8 100644
--- a/drivers/media/pci/cx88/cx88-cards.c
+++ b/drivers/media/pci/cx88/cx88-cards.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * device driver for Conexant 2388x based TV cards 2 * device driver for Conexant 2388x based TV cards
4 * card-specific stuff. 3 * card-specific stuff.
5 * 4 *
@@ -14,10 +13,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 15 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 16 */
22 17
23#include "cx88.h" 18#include "cx88.h"
@@ -38,19 +33,19 @@ module_param_array(tuner, int, NULL, 0444);
38module_param_array(radio, int, NULL, 0444); 33module_param_array(radio, int, NULL, 0444);
39module_param_array(card, int, NULL, 0444); 34module_param_array(card, int, NULL, 0444);
40 35
41MODULE_PARM_DESC(tuner,"tuner type"); 36MODULE_PARM_DESC(tuner, "tuner type");
42MODULE_PARM_DESC(radio,"radio tuner type"); 37MODULE_PARM_DESC(radio, "radio tuner type");
43MODULE_PARM_DESC(card,"card type"); 38MODULE_PARM_DESC(card, "card type");
44 39
45static unsigned int latency = UNSET; 40static unsigned int latency = UNSET;
46module_param(latency,int,0444); 41module_param(latency, int, 0444);
47MODULE_PARM_DESC(latency,"pci latency timer"); 42MODULE_PARM_DESC(latency, "pci latency timer");
48 43
49static int disable_ir; 44static int disable_ir;
50module_param(disable_ir, int, 0444); 45module_param(disable_ir, int, 0444);
51MODULE_PARM_DESC(disable_ir, "Disable IR support"); 46MODULE_PARM_DESC(disable_ir, "Disable IR support");
52 47
53#define dprintk(level,fmt, arg...) do { \ 48#define dprintk(level, fmt, arg...) do { \
54 if (cx88_core_debug >= level) \ 49 if (cx88_core_debug >= level) \
55 printk(KERN_DEBUG pr_fmt("%s: core:" fmt), \ 50 printk(KERN_DEBUG pr_fmt("%s: core:" fmt), \
56 __func__, ##arg); \ 51 __func__, ##arg); \
@@ -2911,33 +2906,33 @@ static const struct {
2911 int fm; 2906 int fm;
2912 const char *name; 2907 const char *name;
2913} gdi_tuner[] = { 2908} gdi_tuner[] = {
2914 [ 0x01 ] = { .id = UNSET, 2909 [0x01] = { .id = UNSET,
2915 .name = "NTSC_M" }, 2910 .name = "NTSC_M" },
2916 [ 0x02 ] = { .id = UNSET, 2911 [0x02] = { .id = UNSET,
2917 .name = "PAL_B" }, 2912 .name = "PAL_B" },
2918 [ 0x03 ] = { .id = UNSET, 2913 [0x03] = { .id = UNSET,
2919 .name = "PAL_I" }, 2914 .name = "PAL_I" },
2920 [ 0x04 ] = { .id = UNSET, 2915 [0x04] = { .id = UNSET,
2921 .name = "PAL_D" }, 2916 .name = "PAL_D" },
2922 [ 0x05 ] = { .id = UNSET, 2917 [0x05] = { .id = UNSET,
2923 .name = "SECAM" }, 2918 .name = "SECAM" },
2924 2919
2925 [ 0x10 ] = { .id = UNSET, 2920 [0x10] = { .id = UNSET,
2926 .fm = 1, 2921 .fm = 1,
2927 .name = "TEMIC_4049" }, 2922 .name = "TEMIC_4049" },
2928 [ 0x11 ] = { .id = TUNER_TEMIC_4136FY5, 2923 [0x11] = { .id = TUNER_TEMIC_4136FY5,
2929 .name = "TEMIC_4136" }, 2924 .name = "TEMIC_4136" },
2930 [ 0x12 ] = { .id = UNSET, 2925 [0x12] = { .id = UNSET,
2931 .name = "TEMIC_4146" }, 2926 .name = "TEMIC_4146" },
2932 2927
2933 [ 0x20 ] = { .id = TUNER_PHILIPS_FQ1216ME, 2928 [0x20] = { .id = TUNER_PHILIPS_FQ1216ME,
2934 .fm = 1, 2929 .fm = 1,
2935 .name = "PHILIPS_FQ1216_MK3" }, 2930 .name = "PHILIPS_FQ1216_MK3" },
2936 [ 0x21 ] = { .id = UNSET, .fm = 1, 2931 [0x21] = { .id = UNSET, .fm = 1,
2937 .name = "PHILIPS_FQ1236_MK3" }, 2932 .name = "PHILIPS_FQ1236_MK3" },
2938 [ 0x22 ] = { .id = UNSET, 2933 [0x22] = { .id = UNSET,
2939 .name = "PHILIPS_FI1236_MK3" }, 2934 .name = "PHILIPS_FI1236_MK3" },
2940 [ 0x23 ] = { .id = UNSET, 2935 [0x23] = { .id = UNSET,
2941 .name = "PHILIPS_FI1216_MK3" }, 2936 .name = "PHILIPS_FI1216_MK3" },
2942}; 2937};
2943 2938
@@ -2947,7 +2942,7 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
2947 ? gdi_tuner[eeprom_data[0x0d]].name : NULL; 2942 ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
2948 2943
2949 pr_info("GDI: tuner=%s\n", name ? name : "unknown"); 2944 pr_info("GDI: tuner=%s\n", name ? name : "unknown");
2950 if (NULL == name) 2945 if (name == NULL)
2951 return; 2946 return;
2952 core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id; 2947 core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
2953 core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ? 2948 core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ?
@@ -3167,7 +3162,7 @@ static int cx88_xc4000_tuner_callback(struct cx88_core *core,
3167} 3162}
3168 3163
3169/* ----------------------------------------------------------------------- */ 3164/* ----------------------------------------------------------------------- */
3170/* Tuner callback function. Currently only needed for the Pinnacle * 3165/* Tuner callback function. Currently only needed for the Pinnacle *
3171 * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both * 3166 * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both *
3172 * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */ 3167 * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */
3173 3168
@@ -3401,7 +3396,7 @@ static void cx88_card_setup(struct cx88_core *core)
3401 3396
3402 memset(&tun_setup, 0, sizeof(tun_setup)); 3397 memset(&tun_setup, 0, sizeof(tun_setup));
3403 3398
3404 if (0 == core->i2c_rc) { 3399 if (core->i2c_rc == 0) {
3405 core->i2c_client.addr = 0xa0 >> 1; 3400 core->i2c_client.addr = 0xa0 >> 1;
3406 tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom)); 3401 tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom));
3407 } 3402 }
@@ -3409,17 +3404,17 @@ static void cx88_card_setup(struct cx88_core *core)
3409 switch (core->boardnr) { 3404 switch (core->boardnr) {
3410 case CX88_BOARD_HAUPPAUGE: 3405 case CX88_BOARD_HAUPPAUGE:
3411 case CX88_BOARD_HAUPPAUGE_ROSLYN: 3406 case CX88_BOARD_HAUPPAUGE_ROSLYN:
3412 if (0 == core->i2c_rc) 3407 if (core->i2c_rc == 0)
3413 hauppauge_eeprom(core, eeprom+8); 3408 hauppauge_eeprom(core, eeprom+8);
3414 break; 3409 break;
3415 case CX88_BOARD_GDI: 3410 case CX88_BOARD_GDI:
3416 if (0 == core->i2c_rc) 3411 if (core->i2c_rc == 0)
3417 gdi_eeprom(core, eeprom); 3412 gdi_eeprom(core, eeprom);
3418 break; 3413 break;
3419 case CX88_BOARD_LEADTEK_PVR2000: 3414 case CX88_BOARD_LEADTEK_PVR2000:
3420 case CX88_BOARD_WINFAST_DV2000: 3415 case CX88_BOARD_WINFAST_DV2000:
3421 case CX88_BOARD_WINFAST2000XP_EXPERT: 3416 case CX88_BOARD_WINFAST2000XP_EXPERT:
3422 if (0 == core->i2c_rc) 3417 if (core->i2c_rc == 0)
3423 leadtek_eeprom(core, eeprom); 3418 leadtek_eeprom(core, eeprom);
3424 break; 3419 break;
3425 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 3420 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
@@ -3432,7 +3427,7 @@ static void cx88_card_setup(struct cx88_core *core)
3432 case CX88_BOARD_HAUPPAUGE_HVR4000: 3427 case CX88_BOARD_HAUPPAUGE_HVR4000:
3433 case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 3428 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
3434 case CX88_BOARD_HAUPPAUGE_IRONLY: 3429 case CX88_BOARD_HAUPPAUGE_IRONLY:
3435 if (0 == core->i2c_rc) 3430 if (core->i2c_rc == 0)
3436 hauppauge_eeprom(core, eeprom); 3431 hauppauge_eeprom(core, eeprom);
3437 break; 3432 break;
3438 case CX88_BOARD_KWORLD_DVBS_100: 3433 case CX88_BOARD_KWORLD_DVBS_100:
@@ -3478,21 +3473,21 @@ static void cx88_card_setup(struct cx88_core *core)
3478 cx_write(MO_GP0_IO, 0x00080808); 3473 cx_write(MO_GP0_IO, 0x00080808);
3479 break; 3474 break;
3480 case CX88_BOARD_ATI_HDTVWONDER: 3475 case CX88_BOARD_ATI_HDTVWONDER:
3481 if (0 == core->i2c_rc) { 3476 if (core->i2c_rc == 0) {
3482 /* enable tuner */ 3477 /* enable tuner */
3483 int i; 3478 int i;
3484 static const u8 buffer [][2] = { 3479 static const u8 buffer[][2] = {
3485 {0x10,0x12}, 3480 {0x10, 0x12},
3486 {0x13,0x04}, 3481 {0x13, 0x04},
3487 {0x16,0x00}, 3482 {0x16, 0x00},
3488 {0x14,0x04}, 3483 {0x14, 0x04},
3489 {0x17,0x00} 3484 {0x17, 0x00}
3490 }; 3485 };
3491 core->i2c_client.addr = 0x0a; 3486 core->i2c_client.addr = 0x0a;
3492 3487
3493 for (i = 0; i < ARRAY_SIZE(buffer); i++) 3488 for (i = 0; i < ARRAY_SIZE(buffer); i++)
3494 if (2 != i2c_master_send(&core->i2c_client, 3489 if (2 != i2c_master_send(&core->i2c_client,
3495 buffer[i],2)) 3490 buffer[i], 2))
3496 pr_warn("Unable to enable tuner(%i).\n", 3491 pr_warn("Unable to enable tuner(%i).\n",
3497 i); 3492 i);
3498 } 3493 }
@@ -3616,7 +3611,7 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
3616#endif 3611#endif
3617 3612
3618 /* check insmod options */ 3613 /* check insmod options */
3619 if (UNSET != latency) 3614 if (latency != UNSET)
3620 lat = latency; 3615 lat = latency;
3621 3616
3622 /* apply stuff */ 3617 /* apply stuff */
@@ -3625,7 +3620,7 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
3625 value |= ctrl; 3620 value |= ctrl;
3626 pci_write_config_byte(pci, CX88X_DEVCTRL, value); 3621 pci_write_config_byte(pci, CX88X_DEVCTRL, value);
3627 } 3622 }
3628 if (UNSET != lat) { 3623 if (lat != UNSET) {
3629 pr_info("setting pci latency timer to %d\n", 3624 pr_info("setting pci latency timer to %d\n",
3630 latency); 3625 latency);
3631 pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency); 3626 pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency);
@@ -3635,8 +3630,8 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
3635 3630
3636int cx88_get_resources(const struct cx88_core *core, struct pci_dev *pci) 3631int cx88_get_resources(const struct cx88_core *core, struct pci_dev *pci)
3637{ 3632{
3638 if (request_mem_region(pci_resource_start(pci,0), 3633 if (request_mem_region(pci_resource_start(pci, 0),
3639 pci_resource_len(pci,0), 3634 pci_resource_len(pci, 0),
3640 core->name)) 3635 core->name))
3641 return 0; 3636 return 0;
3642 pr_err("func %d: Can't get MMIO memory @ 0x%llx, subsystem: %04x:%04x\n", 3637 pr_err("func %d: Can't get MMIO memory @ 0x%llx, subsystem: %04x:%04x\n",
@@ -3692,7 +3687,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3692 return NULL; 3687 return NULL;
3693 } 3688 }
3694 3689
3695 if (0 != cx88_get_resources(core, pci)) { 3690 if (cx88_get_resources(core, pci) != 0) {
3696 v4l2_ctrl_handler_free(&core->video_hdl); 3691 v4l2_ctrl_handler_free(&core->video_hdl);
3697 v4l2_ctrl_handler_free(&core->audio_hdl); 3692 v4l2_ctrl_handler_free(&core->audio_hdl);
3698 v4l2_device_unregister(&core->v4l2_dev); 3693 v4l2_device_unregister(&core->v4l2_dev);
@@ -3724,7 +3719,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3724 if (pci->subsystem_vendor == cx88_subids[i].subvendor && 3719 if (pci->subsystem_vendor == cx88_subids[i].subvendor &&
3725 pci->subsystem_device == cx88_subids[i].subdevice) 3720 pci->subsystem_device == cx88_subids[i].subdevice)
3726 core->boardnr = cx88_subids[i].card; 3721 core->boardnr = cx88_subids[i].card;
3727 if (UNSET == core->boardnr) { 3722 if (core->boardnr == UNSET) {
3728 core->boardnr = CX88_BOARD_UNKNOWN; 3723 core->boardnr = CX88_BOARD_UNKNOWN;
3729 cx88_card_list(core, pci); 3724 cx88_card_list(core, pci);
3730 } 3725 }
@@ -3754,7 +3749,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3754 cx88_i2c_init(core, pci); 3749 cx88_i2c_init(core, pci);
3755 3750
3756 /* load tuner module, if needed */ 3751 /* load tuner module, if needed */
3757 if (UNSET != core->board.tuner_type) { 3752 if (core->board.tuner_type != UNSET) {
3758 /* Ignore 0x6b and 0x6f on cx88 boards. 3753 /* Ignore 0x6b and 0x6f on cx88 boards.
3759 * FusionHDTV5 RT Gold has an ir receiver at 0x6b 3754 * FusionHDTV5 RT Gold has an ir receiver at 0x6b
3760 * and an RTC at 0x6f which can get corrupted if probed. */ 3755 * and an RTC at 0x6f which can get corrupted if probed. */
diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index 27203e094655..33719f0b06a5 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * device driver for Conexant 2388x based TV cards 2 * device driver for Conexant 2388x based TV cards
4 * driver core 3 * driver core
5 * 4 *
@@ -19,10 +18,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 20 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 21 */
27 22
28#include "cx88.h" 23#include "cx88.h"
@@ -54,12 +49,12 @@ module_param_named(core_debug, cx88_core_debug, int, 0644);
54MODULE_PARM_DESC(core_debug, "enable debug messages [core]"); 49MODULE_PARM_DESC(core_debug, "enable debug messages [core]");
55 50
56static unsigned int nicam; 51static unsigned int nicam;
57module_param(nicam,int,0644); 52module_param(nicam, int, 0644);
58MODULE_PARM_DESC(nicam,"tv audio is nicam"); 53MODULE_PARM_DESC(nicam, "tv audio is nicam");
59 54
60static unsigned int nocomb; 55static unsigned int nocomb;
61module_param(nocomb,int,0644); 56module_param(nocomb, int, 0644);
62MODULE_PARM_DESC(nocomb,"disable comb filter"); 57MODULE_PARM_DESC(nocomb, "disable comb filter");
63 58
64#define dprintk0(fmt, arg...) \ 59#define dprintk0(fmt, arg...) \
65 printk(KERN_DEBUG pr_fmt("%s: core:" fmt), \ 60 printk(KERN_DEBUG pr_fmt("%s: core:" fmt), \
@@ -79,13 +74,13 @@ static DEFINE_MUTEX(devlist);
79 74
80/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be 75/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be
81 generated _after_ lpi lines are transferred. */ 76 generated _after_ lpi lines are transferred. */
82static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist, 77static __le32 *cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
83 unsigned int offset, u32 sync_line, 78 unsigned int offset, u32 sync_line,
84 unsigned int bpl, unsigned int padding, 79 unsigned int bpl, unsigned int padding,
85 unsigned int lines, unsigned int lpi, bool jump) 80 unsigned int lines, unsigned int lpi, bool jump)
86{ 81{
87 struct scatterlist *sg; 82 struct scatterlist *sg;
88 unsigned int line,todo,sol; 83 unsigned int line, todo, sol;
89 84
90 if (jump) { 85 if (jump) {
91 (*rp++) = cpu_to_le32(RISC_JUMP); 86 (*rp++) = cpu_to_le32(RISC_JUMP);
@@ -103,33 +98,33 @@ static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
103 offset -= sg_dma_len(sg); 98 offset -= sg_dma_len(sg);
104 sg = sg_next(sg); 99 sg = sg_next(sg);
105 } 100 }
106 if (lpi && line>0 && !(line % lpi)) 101 if (lpi && line > 0 && !(line % lpi))
107 sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC; 102 sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC;
108 else 103 else
109 sol = RISC_SOL; 104 sol = RISC_SOL;
110 if (bpl <= sg_dma_len(sg)-offset) { 105 if (bpl <= sg_dma_len(sg)-offset) {
111 /* fits into current chunk */ 106 /* fits into current chunk */
112 *(rp++)=cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl); 107 *(rp++) = cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl);
113 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 108 *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset);
114 offset+=bpl; 109 offset += bpl;
115 } else { 110 } else {
116 /* scanline needs to be split */ 111 /* scanline needs to be split */
117 todo = bpl; 112 todo = bpl;
118 *(rp++)=cpu_to_le32(RISC_WRITE|sol| 113 *(rp++) = cpu_to_le32(RISC_WRITE|sol|
119 (sg_dma_len(sg)-offset)); 114 (sg_dma_len(sg)-offset));
120 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 115 *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset);
121 todo -= (sg_dma_len(sg)-offset); 116 todo -= (sg_dma_len(sg)-offset);
122 offset = 0; 117 offset = 0;
123 sg = sg_next(sg); 118 sg = sg_next(sg);
124 while (todo > sg_dma_len(sg)) { 119 while (todo > sg_dma_len(sg)) {
125 *(rp++)=cpu_to_le32(RISC_WRITE| 120 *(rp++) = cpu_to_le32(RISC_WRITE|
126 sg_dma_len(sg)); 121 sg_dma_len(sg));
127 *(rp++)=cpu_to_le32(sg_dma_address(sg)); 122 *(rp++) = cpu_to_le32(sg_dma_address(sg));
128 todo -= sg_dma_len(sg); 123 todo -= sg_dma_len(sg);
129 sg = sg_next(sg); 124 sg = sg_next(sg);
130 } 125 }
131 *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); 126 *(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo);
132 *(rp++)=cpu_to_le32(sg_dma_address(sg)); 127 *(rp++) = cpu_to_le32(sg_dma_address(sg));
133 offset += todo; 128 offset += todo;
134 } 129 }
135 offset += padding; 130 offset += padding;
@@ -143,13 +138,13 @@ int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
143 unsigned int top_offset, unsigned int bottom_offset, 138 unsigned int top_offset, unsigned int bottom_offset,
144 unsigned int bpl, unsigned int padding, unsigned int lines) 139 unsigned int bpl, unsigned int padding, unsigned int lines)
145{ 140{
146 u32 instructions,fields; 141 u32 instructions, fields;
147 __le32 *rp; 142 __le32 *rp;
148 143
149 fields = 0; 144 fields = 0;
150 if (UNSET != top_offset) 145 if (top_offset != UNSET)
151 fields++; 146 fields++;
152 if (UNSET != bottom_offset) 147 if (bottom_offset != UNSET)
153 fields++; 148 fields++;
154 149
155 /* estimate risc mem: worst case is one write per page border + 150 /* estimate risc mem: worst case is one write per page border +
@@ -161,21 +156,21 @@ int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
161 risc->size = instructions * 8; 156 risc->size = instructions * 8;
162 risc->dma = 0; 157 risc->dma = 0;
163 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); 158 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma);
164 if (NULL == risc->cpu) 159 if (risc->cpu == NULL)
165 return -ENOMEM; 160 return -ENOMEM;
166 161
167 /* write risc instructions */ 162 /* write risc instructions */
168 rp = risc->cpu; 163 rp = risc->cpu;
169 if (UNSET != top_offset) 164 if (top_offset != UNSET)
170 rp = cx88_risc_field(rp, sglist, top_offset, 0, 165 rp = cx88_risc_field(rp, sglist, top_offset, 0,
171 bpl, padding, lines, 0, true); 166 bpl, padding, lines, 0, true);
172 if (UNSET != bottom_offset) 167 if (bottom_offset != UNSET)
173 rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200, 168 rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200,
174 bpl, padding, lines, 0, top_offset == UNSET); 169 bpl, padding, lines, 0, top_offset == UNSET);
175 170
176 /* save pointer to jmp instruction address */ 171 /* save pointer to jmp instruction address */
177 risc->jmp = rp; 172 risc->jmp = rp;
178 BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 173 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
179 return 0; 174 return 0;
180} 175}
181 176
@@ -195,7 +190,7 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
195 risc->size = instructions * 8; 190 risc->size = instructions * 8;
196 risc->dma = 0; 191 risc->dma = 0;
197 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); 192 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma);
198 if (NULL == risc->cpu) 193 if (risc->cpu == NULL)
199 return -ENOMEM; 194 return -ENOMEM;
200 195
201 /* write risc instructions */ 196 /* write risc instructions */
@@ -204,7 +199,7 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
204 199
205 /* save pointer to jmp instruction address */ 200 /* save pointer to jmp instruction address */
206 risc->jmp = rp; 201 risc->jmp = rp;
207 BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 202 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
208 return 0; 203 return 0;
209} 204}
210 205
@@ -340,7 +335,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,
340 const struct sram_channel *ch, 335 const struct sram_channel *ch,
341 unsigned int bpl, u32 risc) 336 unsigned int bpl, u32 risc)
342{ 337{
343 unsigned int i,lines; 338 unsigned int i, lines;
344 u32 cdt; 339 u32 cdt;
345 340
346 bpl = (bpl + 7) & ~7; /* alignment */ 341 bpl = (bpl + 7) & ~7; /* alignment */
@@ -348,7 +343,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,
348 lines = ch->fifo_size / bpl; 343 lines = ch->fifo_size / bpl;
349 if (lines > 6) 344 if (lines > 6)
350 lines = 6; 345 lines = 6;
351 BUG_ON(lines < 2); 346 WARN_ON(lines < 2);
352 347
353 /* write CDT */ 348 /* write CDT */
354 for (i = 0; i < lines; i++) 349 for (i = 0; i < lines; i++)
@@ -366,7 +361,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,
366 /* fill registers */ 361 /* fill registers */
367 cx_write(ch->ptr1_reg, ch->fifo_start); 362 cx_write(ch->ptr1_reg, ch->fifo_start);
368 cx_write(ch->ptr2_reg, cdt); 363 cx_write(ch->ptr2_reg, cdt);
369 cx_write(ch->cnt1_reg, (bpl >> 3) -1); 364 cx_write(ch->cnt1_reg, (bpl >> 3) - 1);
370 cx_write(ch->cnt2_reg, (lines*16) >> 3); 365 cx_write(ch->cnt2_reg, (lines*16) >> 3);
371 366
372 dprintk(2, "sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines); 367 dprintk(2, "sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines);
@@ -379,23 +374,23 @@ int cx88_sram_channel_setup(struct cx88_core *core,
379static int cx88_risc_decode(u32 risc) 374static int cx88_risc_decode(u32 risc)
380{ 375{
381 static const char * const instr[16] = { 376 static const char * const instr[16] = {
382 [ RISC_SYNC >> 28 ] = "sync", 377 [RISC_SYNC >> 28] = "sync",
383 [ RISC_WRITE >> 28 ] = "write", 378 [RISC_WRITE >> 28] = "write",
384 [ RISC_WRITEC >> 28 ] = "writec", 379 [RISC_WRITEC >> 28] = "writec",
385 [ RISC_READ >> 28 ] = "read", 380 [RISC_READ >> 28] = "read",
386 [ RISC_READC >> 28 ] = "readc", 381 [RISC_READC >> 28] = "readc",
387 [ RISC_JUMP >> 28 ] = "jump", 382 [RISC_JUMP >> 28] = "jump",
388 [ RISC_SKIP >> 28 ] = "skip", 383 [RISC_SKIP >> 28] = "skip",
389 [ RISC_WRITERM >> 28 ] = "writerm", 384 [RISC_WRITERM >> 28] = "writerm",
390 [ RISC_WRITECM >> 28 ] = "writecm", 385 [RISC_WRITECM >> 28] = "writecm",
391 [ RISC_WRITECR >> 28 ] = "writecr", 386 [RISC_WRITECR >> 28] = "writecr",
392 }; 387 };
393 static int const incr[16] = { 388 static int const incr[16] = {
394 [ RISC_WRITE >> 28 ] = 2, 389 [RISC_WRITE >> 28] = 2,
395 [ RISC_JUMP >> 28 ] = 2, 390 [RISC_JUMP >> 28] = 2,
396 [ RISC_WRITERM >> 28 ] = 3, 391 [RISC_WRITERM >> 28] = 3,
397 [ RISC_WRITECM >> 28 ] = 3, 392 [RISC_WRITECM >> 28] = 3,
398 [ RISC_WRITECR >> 28 ] = 4, 393 [RISC_WRITECR >> 28] = 4,
399 }; 394 };
400 static const char * const bits[] = { 395 static const char * const bits[] = {
401 "12", "13", "14", "resync", 396 "12", "13", "14", "resync",
@@ -432,7 +427,7 @@ void cx88_sram_channel_dump(struct cx88_core *core,
432 "line / byte", 427 "line / byte",
433 }; 428 };
434 u32 risc; 429 u32 risc;
435 unsigned int i,j,n; 430 unsigned int i, j, n;
436 431
437 dprintk0("%s - dma channel status dump\n", 432 dprintk0("%s - dma channel status dump\n",
438 ch->name); 433 ch->name);
@@ -645,7 +640,7 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm)
645static inline unsigned int norm_htotal(v4l2_std_id norm) 640static inline unsigned int norm_htotal(v4l2_std_id norm)
646{ 641{
647 642
648 unsigned int fsc4=norm_fsc8(norm)/2; 643 unsigned int fsc4 = norm_fsc8(norm)/2;
649 644
650 /* returns 4*FSC / vtotal / frames per seconds */ 645 /* returns 4*FSC / vtotal / frames per seconds */
651 return (norm & V4L2_STD_625_50) ? 646 return (norm & V4L2_STD_625_50) ?
@@ -711,7 +706,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
711 } 706 }
712 if (INPUT(core->input).type == CX88_VMUX_SVIDEO) 707 if (INPUT(core->input).type == CX88_VMUX_SVIDEO)
713 value |= (1 << 13) | (1 << 5); 708 value |= (1 << 13) | (1 << 5);
714 if (V4L2_FIELD_INTERLACED == field) 709 if (field == V4L2_FIELD_INTERLACED)
715 value |= (1 << 3); // VINT (interlaced vertical scaling) 710 value |= (1 << 3); // VINT (interlaced vertical scaling)
716 if (width < 385) 711 if (width < 385)
717 value |= (1 << 0); // 3-tap interpolation 712 value |= (1 << 0); // 3-tap interpolation
@@ -742,7 +737,7 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
742 prescale = 5; 737 prescale = 5;
743 738
744 pll = ofreq * 8 * prescale * (u64)(1 << 20); 739 pll = ofreq * 8 * prescale * (u64)(1 << 20);
745 do_div(pll,xtal); 740 do_div(pll, xtal);
746 reg = (pll & 0x3ffffff) | (pre[prescale] << 26); 741 reg = (pll & 0x3ffffff) | (pre[prescale] << 26);
747 if (((reg >> 20) & 0x3f) < 14) { 742 if (((reg >> 20) & 0x3f) < 14) {
748 pr_err("pll out of range\n"); 743 pr_err("pll out of range\n");
@@ -755,8 +750,8 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
755 for (i = 0; i < 100; i++) { 750 for (i = 0; i < 100; i++) {
756 reg = cx_read(MO_DEVICE_STATUS); 751 reg = cx_read(MO_DEVICE_STATUS);
757 if (reg & (1<<2)) { 752 if (reg & (1<<2)) {
758 dprintk(1,"pll locked [pre=%d,ofreq=%d]\n", 753 dprintk(1, "pll locked [pre=%d,ofreq=%d]\n",
759 prescale,ofreq); 754 prescale, ofreq);
760 return 0; 755 return 0;
761 } 756 }
762 dprintk(1, "pll not locked yet, waiting ...\n"); 757 dprintk(1, "pll not locked yet, waiting ...\n");
@@ -863,9 +858,9 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
863 u32 fsc8; 858 u32 fsc8;
864 u32 adc_clock; 859 u32 adc_clock;
865 u32 vdec_clock; 860 u32 vdec_clock;
866 u32 step_db,step_dr; 861 u32 step_db, step_dr;
867 u64 tmp64; 862 u64 tmp64;
868 u32 bdelay,agcdelay,htotal; 863 u32 bdelay, agcdelay, htotal;
869 u32 cxiformat, cxoformat; 864 u32 cxiformat, cxoformat;
870 865
871 if (norm == core->tvnorm) 866 if (norm == core->tvnorm)
@@ -917,7 +912,7 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
917 dprintk(1, "set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n", 912 dprintk(1, "set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n",
918 v4l2_norm_to_name(core->tvnorm), fsc8, adc_clock, vdec_clock, 913 v4l2_norm_to_name(core->tvnorm), fsc8, adc_clock, vdec_clock,
919 step_db, step_dr); 914 step_db, step_dr);
920 set_pll(core,2,vdec_clock); 915 set_pll(core, 2, vdec_clock);
921 916
922 dprintk(1, "set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", 917 dprintk(1, "set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n",
923 cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); 918 cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
@@ -1013,7 +1008,7 @@ void cx88_vdev_init(struct cx88_core *core,
1013 core->name, type, core->board.name); 1008 core->name, type, core->board.name);
1014} 1009}
1015 1010
1016struct cx88_core* cx88_core_get(struct pci_dev *pci) 1011struct cx88_core *cx88_core_get(struct pci_dev *pci)
1017{ 1012{
1018 struct cx88_core *core; 1013 struct cx88_core *core;
1019 1014
@@ -1024,7 +1019,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1024 if (PCI_SLOT(pci->devfn) != core->pci_slot) 1019 if (PCI_SLOT(pci->devfn) != core->pci_slot)
1025 continue; 1020 continue;
1026 1021
1027 if (0 != cx88_get_resources(core, pci)) { 1022 if (cx88_get_resources(core, pci) != 0) {
1028 mutex_unlock(&devlist); 1023 mutex_unlock(&devlist);
1029 return NULL; 1024 return NULL;
1030 } 1025 }
@@ -1034,7 +1029,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1034 } 1029 }
1035 1030
1036 core = cx88_core_create(pci, cx88_devcount); 1031 core = cx88_core_create(pci, cx88_devcount);
1037 if (NULL != core) { 1032 if (core != NULL) {
1038 cx88_devcount++; 1033 cx88_devcount++;
1039 list_add_tail(&core->devlist, &cx88_devlist); 1034 list_add_tail(&core->devlist, &cx88_devlist);
1040 } 1035 }
@@ -1045,15 +1040,15 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1045 1040
1046void cx88_core_put(struct cx88_core *core, struct pci_dev *pci) 1041void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1047{ 1042{
1048 release_mem_region(pci_resource_start(pci,0), 1043 release_mem_region(pci_resource_start(pci, 0),
1049 pci_resource_len(pci,0)); 1044 pci_resource_len(pci, 0));
1050 1045
1051 if (!atomic_dec_and_test(&core->refcount)) 1046 if (!atomic_dec_and_test(&core->refcount))
1052 return; 1047 return;
1053 1048
1054 mutex_lock(&devlist); 1049 mutex_lock(&devlist);
1055 cx88_ir_fini(core); 1050 cx88_ir_fini(core);
1056 if (0 == core->i2c_rc) { 1051 if (core->i2c_rc == 0) {
1057 if (core->i2c_rtc) 1052 if (core->i2c_rtc)
1058 i2c_unregister_device(core->i2c_rtc); 1053 i2c_unregister_device(core->i2c_rtc);
1059 i2c_del_adapter(&core->i2c_adap); 1054 i2c_del_adapter(&core->i2c_adap);
diff --git a/drivers/media/pci/cx88/cx88-dsp.c b/drivers/media/pci/cx88/cx88-dsp.c
index 4f1ec8d13389..235124e2a763 100644
--- a/drivers/media/pci/cx88/cx88-dsp.c
+++ b/drivers/media/pci/cx88/cx88-dsp.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Stereo and SAP detection for cx88 2 * Stereo and SAP detection for cx88
4 * 3 *
5 * Copyright (c) 2009 Marton Balint <cus@fazekas.hu> 4 * Copyright (c) 2009 Marton Balint <cus@fazekas.hu>
@@ -13,10 +12,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 14 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 15 */
21 16
22#include "cx88.h" 17#include "cx88.h"
@@ -82,6 +77,7 @@ static s32 int_cos(u32 x)
82 u32 t2, t4, t6, t8; 77 u32 t2, t4, t6, t8;
83 s32 ret; 78 s32 ret;
84 u16 period = x / INT_PI; 79 u16 period = x / INT_PI;
80
85 if (period % 2) 81 if (period % 2)
86 return -int_cos(x - INT_PI); 82 return -int_cos(x - INT_PI);
87 x = x % INT_PI; 83 x = x % INT_PI;
@@ -111,6 +107,7 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq)
111 107
112 for (i = 0; i < N; i++) { 108 for (i = 0; i < N; i++) {
113 s32 s = x[i] + ((s64)coeff * s_prev / 32768) - s_prev2; 109 s32 s = x[i] + ((s64)coeff * s_prev / 32768) - s_prev2;
110
114 s_prev2 = s_prev; 111 s_prev2 = s_prev;
115 s_prev = s; 112 s_prev = s;
116 } 113 }
@@ -129,6 +126,7 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq)
129static u32 freq_magnitude(s16 x[], u32 N, u32 freq) 126static u32 freq_magnitude(s16 x[], u32 N, u32 freq)
130{ 127{
131 u32 sum = int_goertzel(x, N, freq); 128 u32 sum = int_goertzel(x, N, freq);
129
132 return (u32)int_sqrt(sum); 130 return (u32)int_sqrt(sum);
133} 131}
134 132
@@ -225,6 +223,7 @@ static s32 detect_btsc(struct cx88_core *core, s16 x[], u32 N)
225 s32 sap = freq_magnitude(x, N, FREQ_BTSC_SAP); 223 s32 sap = freq_magnitude(x, N, FREQ_BTSC_SAP);
226 s32 dual_ref = freq_magnitude(x, N, FREQ_BTSC_DUAL_REF); 224 s32 dual_ref = freq_magnitude(x, N, FREQ_BTSC_DUAL_REF);
227 s32 dual = freq_magnitude(x, N, FREQ_BTSC_DUAL); 225 s32 dual = freq_magnitude(x, N, FREQ_BTSC_DUAL);
226
228 dprintk(1, "detect btsc: dual_ref=%d, dual=%d, sap_ref=%d, sap=%d\n", 227 dprintk(1, "detect btsc: dual_ref=%d, dual=%d, sap_ref=%d, sap=%d\n",
229 dual_ref, dual, sap_ref, sap); 228 dual_ref, dual, sap_ref, sap);
230 /* FIXME: Currently not supported */ 229 /* FIXME: Currently not supported */
@@ -307,7 +306,7 @@ s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core)
307 306
308 kfree(samples); 307 kfree(samples);
309 308
310 if (UNSET != ret) 309 if (ret != UNSET)
311 dprintk(1, "stereo/sap detection result:%s%s%s\n", 310 dprintk(1, "stereo/sap detection result:%s%s%s\n",
312 (ret & V4L2_TUNER_SUB_MONO) ? " mono" : "", 311 (ret & V4L2_TUNER_SUB_MONO) ? " mono" : "",
313 (ret & V4L2_TUNER_SUB_STEREO) ? " stereo" : "", 312 (ret & V4L2_TUNER_SUB_STEREO) ? " stereo" : "",
diff --git a/drivers/media/pci/cx88/cx88-dvb.c b/drivers/media/pci/cx88/cx88-dvb.c
index 378135ddb6fb..5188f8f2d6dd 100644
--- a/drivers/media/pci/cx88/cx88-dvb.c
+++ b/drivers/media/pci/cx88/cx88-dvb.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * device driver for Conexant 2388x based TV cards 2 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines 3 * MPEG Transport Stream (DVB) routines
5 * 4 *
@@ -15,10 +14,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 16 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 17 */
23 18
24#include "cx88.h" 19#include "cx88.h"
@@ -70,7 +65,7 @@ MODULE_VERSION(CX88_VERSION);
70 65
71static unsigned int debug; 66static unsigned int debug;
72module_param(debug, int, 0644); 67module_param(debug, int, 0644);
73MODULE_PARM_DESC(debug,"enable debug messages [dvb]"); 68MODULE_PARM_DESC(debug, "enable debug messages [dvb]");
74 69
75static unsigned int dvb_buf_tscnt = 32; 70static unsigned int dvb_buf_tscnt = 32;
76module_param(dvb_buf_tscnt, int, 0644); 71module_param(dvb_buf_tscnt, int, 0644);
@@ -173,9 +168,9 @@ static const struct vb2_ops dvb_qops = {
173 168
174/* ------------------------------------------------------------------ */ 169/* ------------------------------------------------------------------ */
175 170
176static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire) 171static int cx88_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire)
177{ 172{
178 struct cx8802_dev *dev= fe->dvb->priv; 173 struct cx8802_dev *dev = fe->dvb->priv;
179 struct cx8802_driver *drv = NULL; 174 struct cx8802_driver *drv = NULL;
180 int ret = 0; 175 int ret = 0;
181 int fe_id; 176 int fe_id;
@@ -189,7 +184,7 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
189 mutex_lock(&dev->core->lock); 184 mutex_lock(&dev->core->lock);
190 drv = cx8802_get_driver(dev, CX88_MPEG_DVB); 185 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
191 if (drv) { 186 if (drv) {
192 if (acquire){ 187 if (acquire) {
193 dev->frontends.active_fe_id = fe_id; 188 dev->frontends.active_fe_id = fe_id;
194 ret = drv->request_acquire(drv); 189 ret = drv->request_acquire(drv);
195 } else { 190 } else {
@@ -226,13 +221,13 @@ static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
226 221
227/* ------------------------------------------------------------------ */ 222/* ------------------------------------------------------------------ */
228 223
229static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) 224static int dvico_fusionhdtv_demod_init(struct dvb_frontend *fe)
230{ 225{
231 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; 226 static const u8 clock_config[] = { CLOCK_CTL, 0x38, 0x39 };
232 static const u8 reset [] = { RESET, 0x80 }; 227 static const u8 reset[] = { RESET, 0x80 };
233 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 228 static const u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 };
234 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 }; 229 static const u8 agc_cfg[] = { AGC_TARGET, 0x24, 0x20 };
235 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 230 static const u8 gpp_ctl_cfg[] = { GPP_CTL, 0x33 };
236 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 231 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
237 232
238 mt352_write(fe, clock_config, sizeof(clock_config)); 233 mt352_write(fe, clock_config, sizeof(clock_config));
@@ -248,11 +243,11 @@ static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
248 243
249static int dvico_dual_demod_init(struct dvb_frontend *fe) 244static int dvico_dual_demod_init(struct dvb_frontend *fe)
250{ 245{
251 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 }; 246 static const u8 clock_config[] = { CLOCK_CTL, 0x38, 0x38 };
252 static const u8 reset [] = { RESET, 0x80 }; 247 static const u8 reset[] = { RESET, 0x80 };
253 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 248 static const u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 };
254 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; 249 static const u8 agc_cfg[] = { AGC_TARGET, 0x28, 0x20 };
255 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 250 static const u8 gpp_ctl_cfg[] = { GPP_CTL, 0x33 };
256 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 251 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
257 252
258 mt352_write(fe, clock_config, sizeof(clock_config)); 253 mt352_write(fe, clock_config, sizeof(clock_config));
@@ -267,12 +262,12 @@ static int dvico_dual_demod_init(struct dvb_frontend *fe)
267 return 0; 262 return 0;
268} 263}
269 264
270static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe) 265static int dntv_live_dvbt_demod_init(struct dvb_frontend *fe)
271{ 266{
272 static const u8 clock_config [] = { 0x89, 0x38, 0x39 }; 267 static const u8 clock_config[] = { 0x89, 0x38, 0x39 };
273 static const u8 reset [] = { 0x50, 0x80 }; 268 static const u8 reset[] = { 0x50, 0x80 };
274 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; 269 static const u8 adc_ctl_1_cfg[] = { 0x8E, 0x40 };
275 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF, 270 static const u8 agc_cfg[] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
276 0x00, 0xFF, 0x00, 0x40, 0x40 }; 271 0x00, 0xFF, 0x00, 0x40, 0x40 };
277 static const u8 dntv_extra[] = { 0xB5, 0x7A }; 272 static const u8 dntv_extra[] = { 0xB5, 0x7A };
278 static const u8 capt_range_cfg[] = { 0x75, 0x32 }; 273 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
@@ -316,12 +311,12 @@ static struct mb86a16_config twinhan_vp1027 = {
316}; 311};
317 312
318#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) 313#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054)
319static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe) 314static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend *fe)
320{ 315{
321 static const u8 clock_config [] = { 0x89, 0x38, 0x38 }; 316 static const u8 clock_config[] = { 0x89, 0x38, 0x38 };
322 static const u8 reset [] = { 0x50, 0x80 }; 317 static const u8 reset[] = { 0x50, 0x80 };
323 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; 318 static const u8 adc_ctl_1_cfg[] = { 0x8E, 0x40 };
324 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF, 319 static const u8 agc_cfg[] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
325 0x00, 0xFF, 0x00, 0x40, 0x40 }; 320 0x00, 0xFF, 0x00, 0x40, 0x40 };
326 static const u8 dntv_extra[] = { 0xB5, 0x7A }; 321 static const u8 dntv_extra[] = { 0xB5, 0x7A };
327 static const u8 capt_range_cfg[] = { 0x75, 0x32 }; 322 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
@@ -378,9 +373,10 @@ static const struct cx22702_config hauppauge_hvr_config = {
378 .output_mode = CX22702_SERIAL_OUTPUT, 373 .output_mode = CX22702_SERIAL_OUTPUT,
379}; 374};
380 375
381static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured) 376static int or51132_set_ts_param(struct dvb_frontend *fe, int is_punctured)
382{ 377{
383 struct cx8802_dev *dev= fe->dvb->priv; 378 struct cx8802_dev *dev = fe->dvb->priv;
379
384 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; 380 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
385 return 0; 381 return 0;
386} 382}
@@ -390,9 +386,9 @@ static const struct or51132_config pchdtv_hd3000 = {
390 .set_ts_params = or51132_set_ts_param, 386 .set_ts_params = or51132_set_ts_param,
391}; 387};
392 388
393static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index) 389static int lgdt330x_pll_rf_set(struct dvb_frontend *fe, int index)
394{ 390{
395 struct cx8802_dev *dev= fe->dvb->priv; 391 struct cx8802_dev *dev = fe->dvb->priv;
396 struct cx88_core *core = dev->core; 392 struct cx88_core *core = dev->core;
397 393
398 dprintk(1, "%s: index = %d\n", __func__, index); 394 dprintk(1, "%s: index = %d\n", __func__, index);
@@ -403,9 +399,10 @@ static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
403 return 0; 399 return 0;
404} 400}
405 401
406static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured) 402static int lgdt330x_set_ts_param(struct dvb_frontend *fe, int is_punctured)
407{ 403{
408 struct cx8802_dev *dev= fe->dvb->priv; 404 struct cx8802_dev *dev = fe->dvb->priv;
405
409 if (is_punctured) 406 if (is_punctured)
410 dev->ts_gen_cntrl |= 0x04; 407 dev->ts_gen_cntrl |= 0x04;
411 else 408 else
@@ -434,9 +431,10 @@ static const struct lgdt330x_config pchdtv_hd5500 = {
434 .set_ts_params = lgdt330x_set_ts_param, 431 .set_ts_params = lgdt330x_set_ts_param,
435}; 432};
436 433
437static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured) 434static int nxt200x_set_ts_param(struct dvb_frontend *fe, int is_punctured)
438{ 435{
439 struct cx8802_dev *dev= fe->dvb->priv; 436 struct cx8802_dev *dev = fe->dvb->priv;
437
440 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; 438 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
441 return 0; 439 return 0;
442} 440}
@@ -446,18 +444,19 @@ static const struct nxt200x_config ati_hdtvwonder = {
446 .set_ts_params = nxt200x_set_ts_param, 444 .set_ts_params = nxt200x_set_ts_param,
447}; 445};
448 446
449static int cx24123_set_ts_param(struct dvb_frontend* fe, 447static int cx24123_set_ts_param(struct dvb_frontend *fe,
450 int is_punctured) 448 int is_punctured)
451{ 449{
452 struct cx8802_dev *dev= fe->dvb->priv; 450 struct cx8802_dev *dev = fe->dvb->priv;
451
453 dev->ts_gen_cntrl = 0x02; 452 dev->ts_gen_cntrl = 0x02;
454 return 0; 453 return 0;
455} 454}
456 455
457static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, 456static int kworld_dvbs_100_set_voltage(struct dvb_frontend *fe,
458 enum fe_sec_voltage voltage) 457 enum fe_sec_voltage voltage)
459{ 458{
460 struct cx8802_dev *dev= fe->dvb->priv; 459 struct cx8802_dev *dev = fe->dvb->priv;
461 struct cx88_core *core = dev->core; 460 struct cx88_core *core = dev->core;
462 461
463 if (voltage == SEC_VOLTAGE_OFF) 462 if (voltage == SEC_VOLTAGE_OFF)
@@ -473,11 +472,11 @@ static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
473static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, 472static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
474 enum fe_sec_voltage voltage) 473 enum fe_sec_voltage voltage)
475{ 474{
476 struct cx8802_dev *dev= fe->dvb->priv; 475 struct cx8802_dev *dev = fe->dvb->priv;
477 struct cx88_core *core = dev->core; 476 struct cx88_core *core = dev->core;
478 477
479 if (voltage == SEC_VOLTAGE_OFF) { 478 if (voltage == SEC_VOLTAGE_OFF) {
480 dprintk(1,"LNB Voltage OFF\n"); 479 dprintk(1, "LNB Voltage OFF\n");
481 cx_write(MO_GP0_IO, 0x0000efff); 480 cx_write(MO_GP0_IO, 0x0000efff);
482 } 481 }
483 482
@@ -489,7 +488,7 @@ static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
489static int tevii_dvbs_set_voltage(struct dvb_frontend *fe, 488static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
490 enum fe_sec_voltage voltage) 489 enum fe_sec_voltage voltage)
491{ 490{
492 struct cx8802_dev *dev= fe->dvb->priv; 491 struct cx8802_dev *dev = fe->dvb->priv;
493 struct cx88_core *core = dev->core; 492 struct cx88_core *core = dev->core;
494 493
495 cx_set(MO_GP0_IO, 0x6040); 494 cx_set(MO_GP0_IO, 0x6040);
@@ -688,6 +687,7 @@ static int cx24116_set_ts_param(struct dvb_frontend *fe,
688 int is_punctured) 687 int is_punctured)
689{ 688{
690 struct cx8802_dev *dev = fe->dvb->priv; 689 struct cx8802_dev *dev = fe->dvb->priv;
690
691 dev->ts_gen_cntrl = 0x2; 691 dev->ts_gen_cntrl = 0x2;
692 692
693 return 0; 693 return 0;
@@ -697,6 +697,7 @@ static int stv0900_set_ts_param(struct dvb_frontend *fe,
697 int is_punctured) 697 int is_punctured)
698{ 698{
699 struct cx8802_dev *dev = fe->dvb->priv; 699 struct cx8802_dev *dev = fe->dvb->priv;
700
700 dev->ts_gen_cntrl = 0; 701 dev->ts_gen_cntrl = 0;
701 702
702 return 0; 703 return 0;
@@ -734,6 +735,7 @@ static int ds3000_set_ts_param(struct dvb_frontend *fe,
734 int is_punctured) 735 int is_punctured)
735{ 736{
736 struct cx8802_dev *dev = fe->dvb->priv; 737 struct cx8802_dev *dev = fe->dvb->priv;
738
737 dev->ts_gen_cntrl = 4; 739 dev->ts_gen_cntrl = 4;
738 740
739 return 0; 741 return 0;
@@ -1005,7 +1007,7 @@ static int dvb_register(struct cx8802_dev *dev)
1005 int mfe_shared = 0; /* bus not shared by default */ 1007 int mfe_shared = 0; /* bus not shared by default */
1006 int res = -EINVAL; 1008 int res = -EINVAL;
1007 1009
1008 if (0 != core->i2c_rc) { 1010 if (core->i2c_rc != 0) {
1009 pr_err("no i2c-bus available, cannot attach dvb drivers\n"); 1011 pr_err("no i2c-bus available, cannot attach dvb drivers\n");
1010 goto frontend_detach; 1012 goto frontend_detach;
1011 } 1013 }
@@ -1423,7 +1425,7 @@ static int dvb_register(struct cx8802_dev *dev)
1423 if (attach_xc3028(0x61, dev) < 0) 1425 if (attach_xc3028(0x61, dev) < 0)
1424 goto frontend_detach; 1426 goto frontend_detach;
1425 break; 1427 break;
1426 case CX88_BOARD_KWORLD_ATSC_120: 1428 case CX88_BOARD_KWORLD_ATSC_120:
1427 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1429 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1428 &kworld_atsc_120_config, 1430 &kworld_atsc_120_config,
1429 &core->i2c_adap); 1431 &core->i2c_adap);
@@ -1617,7 +1619,7 @@ static int dvb_register(struct cx8802_dev *dev)
1617 break; 1619 break;
1618 } 1620 }
1619 1621
1620 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) { 1622 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
1621 pr_err("frontend initialization failed\n"); 1623 pr_err("frontend initialization failed\n");
1622 goto frontend_detach; 1624 goto frontend_detach;
1623 } 1625 }
@@ -1653,7 +1655,8 @@ static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
1653{ 1655{
1654 struct cx88_core *core = drv->core; 1656 struct cx88_core *core = drv->core;
1655 int err = 0; 1657 int err = 0;
1656 dprintk( 1, "%s\n", __func__); 1658
1659 dprintk(1, "%s\n", __func__);
1657 1660
1658 switch (core->boardnr) { 1661 switch (core->boardnr) {
1659 case CX88_BOARD_HAUPPAUGE_HVR1300: 1662 case CX88_BOARD_HAUPPAUGE_HVR1300:
@@ -1717,7 +1720,8 @@ static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1717{ 1720{
1718 struct cx88_core *core = drv->core; 1721 struct cx88_core *core = drv->core;
1719 int err = 0; 1722 int err = 0;
1720 dprintk( 1, "%s\n", __func__); 1723
1724 dprintk(1, "%s\n", __func__);
1721 1725
1722 switch (core->boardnr) { 1726 switch (core->boardnr) {
1723 case CX88_BOARD_HAUPPAUGE_HVR1300: 1727 case CX88_BOARD_HAUPPAUGE_HVR1300:
@@ -1740,8 +1744,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1740 struct vb2_dvb_frontend *fe; 1744 struct vb2_dvb_frontend *fe;
1741 int i; 1745 int i;
1742 1746
1743 dprintk( 1, "%s\n", __func__); 1747 dprintk(1, "%s\n", __func__);
1744 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 1748 dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1745 core->boardnr, 1749 core->boardnr,
1746 core->name, 1750 core->name,
1747 core->pci_bus, 1751 core->pci_bus,
@@ -1753,7 +1757,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1753 1757
1754 /* If vp3054 isn't enabled, a stub will just return 0 */ 1758 /* If vp3054 isn't enabled, a stub will just return 0 */
1755 err = vp3054_i2c_probe(dev); 1759 err = vp3054_i2c_probe(dev);
1756 if (0 != err) 1760 if (err != 0)
1757 goto fail_core; 1761 goto fail_core;
1758 1762
1759 /* dvb stuff */ 1763 /* dvb stuff */
@@ -1811,7 +1815,7 @@ static int cx8802_dvb_remove(struct cx8802_driver *drv)
1811 struct cx88_core *core = drv->core; 1815 struct cx88_core *core = drv->core;
1812 struct cx8802_dev *dev = drv->core->dvbdev; 1816 struct cx8802_dev *dev = drv->core->dvbdev;
1813 1817
1814 dprintk( 1, "%s\n", __func__); 1818 dprintk(1, "%s\n", __func__);
1815 1819
1816 vb2_dvb_unregister_bus(&dev->frontends); 1820 vb2_dvb_unregister_bus(&dev->frontends);
1817 1821
diff --git a/drivers/media/pci/cx88/cx88-i2c.c b/drivers/media/pci/cx88/cx88-i2c.c
index 831f8db5150e..99596fe56cd2 100644
--- a/drivers/media/pci/cx88/cx88-i2c.c
+++ b/drivers/media/pci/cx88/cx88-i2c.c
@@ -1,31 +1,26 @@
1 1
2/* 2/*
3 3 *
4 cx88-i2c.c -- all the i2c code is here 4 * cx88-i2c.c -- all the i2c code is here
5 5 *
6 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) 6 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
7 & Marcus Metzler (mocm@thp.uni-koeln.de) 7 * & Marcus Metzler (mocm@thp.uni-koeln.de)
8 (c) 2002 Yurij Sysoev <yurij@naturesoft.net> 8 * (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
9 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org> 9 * (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
10 10 *
11 (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org> 11 * (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
12 - Multituner support and i2c address binding 12 * - Multituner support and i2c address binding
13 13 *
14 This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or 16 * the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version. 17 * (at your option) any later version.
18 18 *
19 This program is distributed in the hope that it will be useful, 19 * This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details. 22 * GNU General Public License for more details.
23 23 */
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28*/
29 24
30#include "cx88.h" 25#include "cx88.h"
31 26
@@ -38,11 +33,11 @@
38 33
39static unsigned int i2c_debug; 34static unsigned int i2c_debug;
40module_param(i2c_debug, int, 0644); 35module_param(i2c_debug, int, 0644);
41MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]"); 36MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
42 37
43static unsigned int i2c_scan; 38static unsigned int i2c_scan;
44module_param(i2c_scan, int, 0444); 39module_param(i2c_scan, int, 0444);
45MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 40MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
46 41
47static unsigned int i2c_udelay = 5; 42static unsigned int i2c_udelay = 5;
48module_param(i2c_udelay, int, 0644); 43module_param(i2c_udelay, int, 0644);
@@ -112,22 +107,22 @@ static const struct i2c_algo_bit_data cx8800_i2c_algo_template = {
112/* ----------------------------------------------------------------------- */ 107/* ----------------------------------------------------------------------- */
113 108
114static const char * const i2c_devs[128] = { 109static const char * const i2c_devs[128] = {
115 [ 0x1c >> 1 ] = "lgdt330x", 110 [0x1c >> 1] = "lgdt330x",
116 [ 0x86 >> 1 ] = "tda9887/cx22702", 111 [0x86 >> 1] = "tda9887/cx22702",
117 [ 0xa0 >> 1 ] = "eeprom", 112 [0xa0 >> 1] = "eeprom",
118 [ 0xc0 >> 1 ] = "tuner (analog)", 113 [0xc0 >> 1] = "tuner (analog)",
119 [ 0xc2 >> 1 ] = "tuner (analog/dvb)", 114 [0xc2 >> 1] = "tuner (analog/dvb)",
120 [ 0xc8 >> 1 ] = "xc5000", 115 [0xc8 >> 1] = "xc5000",
121}; 116};
122 117
123static void do_i2c_scan(const char *name, struct i2c_client *c) 118static void do_i2c_scan(const char *name, struct i2c_client *c)
124{ 119{
125 unsigned char buf; 120 unsigned char buf;
126 int i,rc; 121 int i, rc;
127 122
128 for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) { 123 for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
129 c->addr = i; 124 c->addr = i;
130 rc = i2c_master_recv(c,&buf,0); 125 rc = i2c_master_recv(c, &buf, 0);
131 if (rc < 0) 126 if (rc < 0)
132 continue; 127 continue;
133 pr_info("i2c scan: found device @ 0x%x [%s]\n", 128 pr_info("i2c scan: found device @ 0x%x [%s]\n",
@@ -139,14 +134,14 @@ static void do_i2c_scan(const char *name, struct i2c_client *c)
139int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) 134int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
140{ 135{
141 /* Prevents usage of invalid delay values */ 136 /* Prevents usage of invalid delay values */
142 if (i2c_udelay<5) 137 if (i2c_udelay < 5)
143 i2c_udelay=5; 138 i2c_udelay = 5;
144 139
145 core->i2c_algo = cx8800_i2c_algo_template; 140 core->i2c_algo = cx8800_i2c_algo_template;
146 141
147 142
148 core->i2c_adap.dev.parent = &pci->dev; 143 core->i2c_adap.dev.parent = &pci->dev;
149 strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name)); 144 strlcpy(core->i2c_adap.name, core->name, sizeof(core->i2c_adap.name));
150 core->i2c_adap.owner = THIS_MODULE; 145 core->i2c_adap.owner = THIS_MODULE;
151 core->i2c_algo.udelay = i2c_udelay; 146 core->i2c_algo.udelay = i2c_udelay;
152 core->i2c_algo.data = core; 147 core->i2c_algo.data = core;
@@ -155,18 +150,22 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
155 core->i2c_client.adapter = &core->i2c_adap; 150 core->i2c_client.adapter = &core->i2c_adap;
156 strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE); 151 strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE);
157 152
158 cx8800_bit_setscl(core,1); 153 cx8800_bit_setscl(core, 1);
159 cx8800_bit_setsda(core,1); 154 cx8800_bit_setsda(core, 1);
160 155
161 core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap); 156 core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap);
162 if (0 == core->i2c_rc) { 157 if (core->i2c_rc == 0) {
163 static u8 tuner_data[] = 158 static u8 tuner_data[] = {
164 { 0x0b, 0xdc, 0x86, 0x52 }; 159 0x0b, 0xdc, 0x86, 0x52 };
165 static struct i2c_msg tuner_msg = 160 static struct i2c_msg tuner_msg = {
166 { .flags = 0, .addr = 0xc2 >> 1, .buf = tuner_data, .len = 4 }; 161 .flags = 0,
162 .addr = 0xc2 >> 1,
163 .buf = tuner_data,
164 .len = 4
165 };
167 166
168 dprintk(1, "i2c register ok\n"); 167 dprintk(1, "i2c register ok\n");
169 switch( core->boardnr ) { 168 switch (core->boardnr) {
170 case CX88_BOARD_HAUPPAUGE_HVR1300: 169 case CX88_BOARD_HAUPPAUGE_HVR1300:
171 case CX88_BOARD_HAUPPAUGE_HVR3000: 170 case CX88_BOARD_HAUPPAUGE_HVR3000:
172 case CX88_BOARD_HAUPPAUGE_HVR4000: 171 case CX88_BOARD_HAUPPAUGE_HVR4000:
@@ -177,7 +176,7 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
177 break; 176 break;
178 } 177 }
179 if (i2c_scan) 178 if (i2c_scan)
180 do_i2c_scan(core->name,&core->i2c_client); 179 do_i2c_scan(core->name, &core->i2c_client);
181 } else 180 } else
182 pr_err("i2c register FAILED\n"); 181 pr_err("i2c register FAILED\n");
183 182
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index 3a05629ba6e4..c072b7ecc8d6 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -16,10 +16,6 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 19 */
24 20
25#include "cx88.h" 21#include "cx88.h"
@@ -58,7 +54,7 @@ struct cx88_IR {
58 u32 mask_keyup; 54 u32 mask_keyup;
59}; 55};
60 56
61static unsigned ir_samplerate = 4; 57static unsigned int ir_samplerate = 4;
62module_param(ir_samplerate, uint, 0444); 58module_param(ir_samplerate, uint, 0444);
63MODULE_PARM_DESC(ir_samplerate, "IR samplerate in kHz, 1 - 20, default 4"); 59MODULE_PARM_DESC(ir_samplerate, "IR samplerate in kHz, 1 - 20, default 4");
64 60
@@ -67,10 +63,10 @@ module_param(ir_debug, int, 0644); /* debug level [IR] */
67MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); 63MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
68 64
69#define ir_dprintk(fmt, arg...) if (ir_debug) \ 65#define ir_dprintk(fmt, arg...) if (ir_debug) \
70 printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) 66 printk(KERN_DEBUG "%s IR: " fmt, ir->core->name, ##arg)
71 67
72#define dprintk(fmt, arg...) if (ir_debug) \ 68#define dprintk(fmt, arg...) if (ir_debug) \
73 printk(KERN_DEBUG "cx88 IR: " fmt , ##arg) 69 printk(KERN_DEBUG "cx88 IR: " fmt, ##arg)
74 70
75/* ---------------------------------------------------------------------- */ 71/* ---------------------------------------------------------------------- */
76 72
@@ -97,7 +93,7 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
97 93
98 auxgpio = cx_read(MO_GP1_IO); 94 auxgpio = cx_read(MO_GP1_IO);
99 /* Take out the parity part */ 95 /* Take out the parity part */
100 gpio=(gpio & 0x7fd) + (auxgpio & 0xef); 96 gpio = (gpio & 0x7fd) + (auxgpio & 0xef);
101 break; 97 break;
102 case CX88_BOARD_WINFAST_DTV1000: 98 case CX88_BOARD_WINFAST_DTV1000:
103 case CX88_BOARD_WINFAST_DTV1800H: 99 case CX88_BOARD_WINFAST_DTV1800H:
@@ -512,7 +508,7 @@ int cx88_ir_fini(struct cx88_core *core)
512 struct cx88_IR *ir = core->ir; 508 struct cx88_IR *ir = core->ir;
513 509
514 /* skip detach on non attached boards */ 510 /* skip detach on non attached boards */
515 if (NULL == ir) 511 if (ir == NULL)
516 return 0; 512 return 0;
517 513
518 cx88_ir_stop(core); 514 cx88_ir_stop(core);
@@ -530,7 +526,7 @@ void cx88_ir_irq(struct cx88_core *core)
530{ 526{
531 struct cx88_IR *ir = core->ir; 527 struct cx88_IR *ir = core->ir;
532 u32 samples; 528 u32 samples;
533 unsigned todo, bits; 529 unsigned int todo, bits;
534 struct ir_raw_event ev; 530 struct ir_raw_event ev;
535 531
536 if (!ir || !ir->sampling) 532 if (!ir || !ir->sampling)
@@ -602,7 +598,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
602 const unsigned short *addr_list = default_addr_list; 598 const unsigned short *addr_list = default_addr_list;
603 const unsigned short *addrp; 599 const unsigned short *addrp;
604 /* Instantiate the IR receiver device, if present */ 600 /* Instantiate the IR receiver device, if present */
605 if (0 != core->i2c_rc) 601 if (core->i2c_rc != 0)
606 return; 602 return;
607 603
608 memset(&info, 0, sizeof(struct i2c_board_info)); 604 memset(&info, 0, sizeof(struct i2c_board_info));
diff --git a/drivers/media/pci/cx88/cx88-mpeg.c b/drivers/media/pci/cx88/cx88-mpeg.c
index ed3fcc8149bd..4533e2c6cb9f 100644
--- a/drivers/media/pci/cx88/cx88-mpeg.c
+++ b/drivers/media/pci/cx88/cx88-mpeg.c
@@ -42,8 +42,8 @@ MODULE_LICENSE("GPL");
42MODULE_VERSION(CX88_VERSION); 42MODULE_VERSION(CX88_VERSION);
43 43
44static unsigned int debug; 44static unsigned int debug;
45module_param(debug,int,0644); 45module_param(debug, int, 0644);
46MODULE_PARM_DESC(debug,"enable debug messages [mpeg]"); 46MODULE_PARM_DESC(debug, "enable debug messages [mpeg]");
47 47
48#define dprintk(level, fmt, arg...) do { \ 48#define dprintk(level, fmt, arg...) do { \
49 if (debug + 1 > level) \ 49 if (debug + 1 > level) \
@@ -54,7 +54,7 @@ MODULE_PARM_DESC(debug,"enable debug messages [mpeg]");
54#if defined(CONFIG_MODULES) && defined(MODULE) 54#if defined(CONFIG_MODULES) && defined(MODULE)
55static void request_module_async(struct work_struct *work) 55static void request_module_async(struct work_struct *work)
56{ 56{
57 struct cx8802_dev *dev=container_of(work, struct cx8802_dev, request_module_wk); 57 struct cx8802_dev *dev = container_of(work, struct cx8802_dev, request_module_wk);
58 58
59 if (dev->core->board.mpeg & CX88_MPEG_DVB) 59 if (dev->core->board.mpeg & CX88_MPEG_DVB)
60 request_module("cx88-dvb"); 60 request_module("cx88-dvb");
@@ -103,8 +103,8 @@ int cx8802_start_dma(struct cx8802_dev *dev,
103 103
104 dprintk(1, "core->active_type_id = 0x%08x\n", core->active_type_id); 104 dprintk(1, "core->active_type_id = 0x%08x\n", core->active_type_id);
105 105
106 if ( (core->active_type_id == CX88_MPEG_DVB) && 106 if ((core->active_type_id == CX88_MPEG_DVB) &&
107 (core->board.mpeg & CX88_MPEG_DVB) ) { 107 (core->board.mpeg & CX88_MPEG_DVB)) {
108 108
109 dprintk(1, "cx8802_start_dma doing .dvb\n"); 109 dprintk(1, "cx8802_start_dma doing .dvb\n");
110 /* negedge driven & software reset */ 110 /* negedge driven & software reset */
@@ -148,8 +148,8 @@ int cx8802_start_dma(struct cx8802_dev *dev,
148 } 148 }
149 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); 149 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl);
150 udelay(100); 150 udelay(100);
151 } else if ( (core->active_type_id == CX88_MPEG_BLACKBIRD) && 151 } else if ((core->active_type_id == CX88_MPEG_BLACKBIRD) &&
152 (core->board.mpeg & CX88_MPEG_BLACKBIRD) ) { 152 (core->board.mpeg & CX88_MPEG_BLACKBIRD)) {
153 dprintk(1, "cx8802_start_dma doing .blackbird\n"); 153 dprintk(1, "cx8802_start_dma doing .blackbird\n");
154 cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */ 154 cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */
155 155
@@ -185,6 +185,7 @@ int cx8802_start_dma(struct cx8802_dev *dev,
185static int cx8802_stop_dma(struct cx8802_dev *dev) 185static int cx8802_stop_dma(struct cx8802_dev *dev)
186{ 186{
187 struct cx88_core *core = dev->core; 187 struct cx88_core *core = dev->core;
188
188 dprintk(1, "\n"); 189 dprintk(1, "\n");
189 190
190 /* stop dma */ 191 /* stop dma */
@@ -209,7 +210,7 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
209 return 0; 210 return 0;
210 211
211 buf = list_entry(q->active.next, struct cx88_buffer, list); 212 buf = list_entry(q->active.next, struct cx88_buffer, list);
212 dprintk(2,"restart_queue [%p/%d]: restart dma\n", 213 dprintk(2, "restart_queue [%p/%d]: restart dma\n",
213 buf, buf->vb.vb2_buf.index); 214 buf, buf->vb.vb2_buf.index);
214 cx8802_start_dma(dev, q, buf); 215 cx8802_start_dma(dev, q, buf);
215 return 0; 216 return 0;
@@ -254,7 +255,7 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
254 if (list_empty(&cx88q->active)) { 255 if (list_empty(&cx88q->active)) {
255 dprintk(1, "queue is empty - first active\n"); 256 dprintk(1, "queue is empty - first active\n");
256 list_add_tail(&buf->list, &cx88q->active); 257 list_add_tail(&buf->list, &cx88q->active);
257 dprintk(1,"[%p/%d] %s - first active\n", 258 dprintk(1, "[%p/%d] %s - first active\n",
258 buf, buf->vb.vb2_buf.index, __func__); 259 buf, buf->vb.vb2_buf.index, __func__);
259 260
260 } else { 261 } else {
@@ -276,13 +277,13 @@ static void do_cancel_buffers(struct cx8802_dev *dev)
276 struct cx88_buffer *buf; 277 struct cx88_buffer *buf;
277 unsigned long flags; 278 unsigned long flags;
278 279
279 spin_lock_irqsave(&dev->slock,flags); 280 spin_lock_irqsave(&dev->slock, flags);
280 while (!list_empty(&q->active)) { 281 while (!list_empty(&q->active)) {
281 buf = list_entry(q->active.next, struct cx88_buffer, list); 282 buf = list_entry(q->active.next, struct cx88_buffer, list);
282 list_del(&buf->list); 283 list_del(&buf->list);
283 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); 284 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
284 } 285 }
285 spin_unlock_irqrestore(&dev->slock,flags); 286 spin_unlock_irqrestore(&dev->slock, flags);
286} 287}
287 288
288void cx8802_cancel_buffers(struct cx8802_dev *dev) 289void cx8802_cancel_buffers(struct cx8802_dev *dev)
@@ -292,7 +293,7 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev)
292 do_cancel_buffers(dev); 293 do_cancel_buffers(dev);
293} 294}
294 295
295static const char * cx88_mpeg_irqs[32] = { 296static const char *cx88_mpeg_irqs[32] = {
296 "ts_risci1", NULL, NULL, NULL, 297 "ts_risci1", NULL, NULL, NULL,
297 "ts_risci2", NULL, NULL, NULL, 298 "ts_risci2", NULL, NULL, NULL,
298 "ts_oflow", NULL, NULL, NULL, 299 "ts_oflow", NULL, NULL, NULL,
@@ -356,7 +357,7 @@ static irqreturn_t cx8802_irq(int irq, void *dev_id)
356 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) { 357 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) {
357 status = cx_read(MO_PCI_INTSTAT) & 358 status = cx_read(MO_PCI_INTSTAT) &
358 (core->pci_irqmask | PCI_INT_TSINT); 359 (core->pci_irqmask | PCI_INT_TSINT);
359 if (0 == status) 360 if (status == 0)
360 goto out; 361 goto out;
361 dprintk(1, "cx8802_irq\n"); 362 dprintk(1, "cx8802_irq\n");
362 dprintk(1, " loop: %d/%d\n", loop, MAX_IRQ_LOOP); 363 dprintk(1, " loop: %d/%d\n", loop, MAX_IRQ_LOOP);
@@ -365,14 +366,14 @@ static irqreturn_t cx8802_irq(int irq, void *dev_id)
365 cx_write(MO_PCI_INTSTAT, status); 366 cx_write(MO_PCI_INTSTAT, status);
366 367
367 if (status & core->pci_irqmask) 368 if (status & core->pci_irqmask)
368 cx88_core_irq(core,status); 369 cx88_core_irq(core, status);
369 if (status & PCI_INT_TSINT) 370 if (status & PCI_INT_TSINT)
370 cx8802_mpeg_irq(dev); 371 cx8802_mpeg_irq(dev);
371 } 372 }
372 if (MAX_IRQ_LOOP == loop) { 373 if (loop == MAX_IRQ_LOOP) {
373 dprintk(0, "clearing mask\n"); 374 dprintk(0, "clearing mask\n");
374 pr_warn("irq loop -- clearing mask\n"); 375 pr_warn("irq loop -- clearing mask\n");
375 cx_write(MO_PCI_INTMSK,0); 376 cx_write(MO_PCI_INTMSK, 0);
376 } 377 }
377 378
378 out: 379 out:
@@ -388,7 +389,7 @@ static int cx8802_init_common(struct cx8802_dev *dev)
388 if (pci_enable_device(dev->pci)) 389 if (pci_enable_device(dev->pci))
389 return -EIO; 390 return -EIO;
390 pci_set_master(dev->pci); 391 pci_set_master(dev->pci);
391 err = pci_set_dma_mask(dev->pci,DMA_BIT_MASK(32)); 392 err = pci_set_dma_mask(dev->pci, DMA_BIT_MASK(32));
392 if (err) { 393 if (err) {
393 pr_err("Oops: no 32bit PCI DMA ???\n"); 394 pr_err("Oops: no 32bit PCI DMA ???\n");
394 return -EIO; 395 return -EIO;
@@ -417,7 +418,7 @@ static int cx8802_init_common(struct cx8802_dev *dev)
417 cx_set(MO_PCI_INTMSK, core->pci_irqmask); 418 cx_set(MO_PCI_INTMSK, core->pci_irqmask);
418 419
419 /* everything worked */ 420 /* everything worked */
420 pci_set_drvdata(dev->pci,dev); 421 pci_set_drvdata(dev->pci, dev);
421 return 0; 422 return 0;
422} 423}
423 424
@@ -451,7 +452,7 @@ static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
451 cx88_shutdown(dev->core); 452 cx88_shutdown(dev->core);
452 453
453 pci_save_state(pci_dev); 454 pci_save_state(pci_dev);
454 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 455 if (pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)) != 0) {
455 pci_disable_device(pci_dev); 456 pci_disable_device(pci_dev);
456 dev->state.disabled = 1; 457 dev->state.disabled = 1;
457 } 458 }
@@ -465,14 +466,14 @@ static int cx8802_resume_common(struct pci_dev *pci_dev)
465 int err; 466 int err;
466 467
467 if (dev->state.disabled) { 468 if (dev->state.disabled) {
468 err=pci_enable_device(pci_dev); 469 err = pci_enable_device(pci_dev);
469 if (err) { 470 if (err) {
470 pr_err("can't enable device\n"); 471 pr_err("can't enable device\n");
471 return err; 472 return err;
472 } 473 }
473 dev->state.disabled = 0; 474 dev->state.disabled = 0;
474 } 475 }
475 err=pci_set_power_state(pci_dev, PCI_D0); 476 err = pci_set_power_state(pci_dev, PCI_D0);
476 if (err) { 477 if (err) {
477 pr_err("can't enable device\n"); 478 pr_err("can't enable device\n");
478 pci_disable_device(pci_dev); 479 pci_disable_device(pci_dev);
@@ -489,14 +490,14 @@ static int cx8802_resume_common(struct pci_dev *pci_dev)
489 spin_lock_irqsave(&dev->slock, flags); 490 spin_lock_irqsave(&dev->slock, flags);
490 if (!list_empty(&dev->mpegq.active)) { 491 if (!list_empty(&dev->mpegq.active)) {
491 pr_info("resume mpeg\n"); 492 pr_info("resume mpeg\n");
492 cx8802_restart_queue(dev,&dev->mpegq); 493 cx8802_restart_queue(dev, &dev->mpegq);
493 } 494 }
494 spin_unlock_irqrestore(&dev->slock, flags); 495 spin_unlock_irqrestore(&dev->slock, flags);
495 496
496 return 0; 497 return 0;
497} 498}
498 499
499struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) 500struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype)
500{ 501{
501 struct cx8802_driver *d; 502 struct cx8802_driver *d;
502 503
@@ -613,7 +614,7 @@ int cx8802_register_driver(struct cx8802_driver *drv)
613 dev->core->boardnr); 614 dev->core->boardnr);
614 615
615 /* Bring up a new struct for each driver instance */ 616 /* Bring up a new struct for each driver instance */
616 driver = kzalloc(sizeof(*drv),GFP_KERNEL); 617 driver = kzalloc(sizeof(*drv), GFP_KERNEL);
617 if (driver == NULL) { 618 if (driver == NULL) {
618 err = -ENOMEM; 619 err = -ENOMEM;
619 goto out; 620 goto out;
@@ -696,7 +697,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
696 697
697 /* general setup */ 698 /* general setup */
698 core = cx88_core_get(pci_dev); 699 core = cx88_core_get(pci_dev);
699 if (NULL == core) 700 if (core == NULL)
700 return -EINVAL; 701 return -EINVAL;
701 702
702 pr_info("cx2388x 8802 Driver Manager\n"); 703 pr_info("cx2388x 8802 Driver Manager\n");
@@ -706,8 +707,8 @@ static int cx8802_probe(struct pci_dev *pci_dev,
706 goto fail_core; 707 goto fail_core;
707 708
708 err = -ENOMEM; 709 err = -ENOMEM;
709 dev = kzalloc(sizeof(*dev),GFP_KERNEL); 710 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
710 if (NULL == dev) 711 if (dev == NULL)
711 goto fail_core; 712 goto fail_core;
712 dev->pci = pci_dev; 713 dev->pci = pci_dev;
713 dev->core = core; 714 dev->core = core;
@@ -721,7 +722,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
721 722
722 INIT_LIST_HEAD(&dev->drvlist); 723 INIT_LIST_HEAD(&dev->drvlist);
723 mutex_lock(&cx8802_mutex); 724 mutex_lock(&cx8802_mutex);
724 list_add_tail(&dev->devlist,&cx8802_devlist); 725 list_add_tail(&dev->devlist, &cx8802_devlist);
725 mutex_unlock(&cx8802_mutex); 726 mutex_unlock(&cx8802_mutex);
726 727
727 /* now autoload cx88-dvb or cx88-blackbird */ 728 /* now autoload cx88-dvb or cx88-blackbird */
@@ -732,7 +733,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
732 kfree(dev); 733 kfree(dev);
733 fail_core: 734 fail_core:
734 core->dvbdev = NULL; 735 core->dvbdev = NULL;
735 cx88_core_put(core,pci_dev); 736 cx88_core_put(core, pci_dev);
736 return err; 737 return err;
737} 738}
738 739
@@ -772,7 +773,7 @@ static void cx8802_remove(struct pci_dev *pci_dev)
772 773
773 /* common */ 774 /* common */
774 cx8802_fini_common(dev); 775 cx8802_fini_common(dev);
775 cx88_core_put(dev->core,dev->pci); 776 cx88_core_put(dev->core, dev->pci);
776 kfree(dev); 777 kfree(dev);
777} 778}
778 779
@@ -782,7 +783,7 @@ static const struct pci_device_id cx8802_pci_tbl[] = {
782 .device = 0x8802, 783 .device = 0x8802,
783 .subvendor = PCI_ANY_ID, 784 .subvendor = PCI_ANY_ID,
784 .subdevice = PCI_ANY_ID, 785 .subdevice = PCI_ANY_ID,
785 },{ 786 }, {
786 /* --- end of list --- */ 787 /* --- end of list --- */
787 } 788 }
788}; 789};
diff --git a/drivers/media/pci/cx88/cx88-reg.h b/drivers/media/pci/cx88/cx88-reg.h
index 2ec52d1cdea0..88ed8a2e4ee1 100644
--- a/drivers/media/pci/cx88/cx88-reg.h
+++ b/drivers/media/pci/cx88/cx88-reg.h
@@ -576,7 +576,7 @@
576#define RISC_CNT_INC 0x00010000 576#define RISC_CNT_INC 0x00010000
577#define RISC_CNT_RSVR 0x00020000 577#define RISC_CNT_RSVR 0x00020000
578#define RISC_CNT_RESET 0x00030000 578#define RISC_CNT_RESET 0x00030000
579#define RISC_JMP_SRP 0x01 579#define RISC_JMP_SRP 0x01
580 580
581 581
582/* ---------------------------------------------------------------------- */ 582/* ---------------------------------------------------------------------- */
@@ -822,15 +822,4 @@
822#define DEFAULT_SAT_U_NTSC 0x7F 822#define DEFAULT_SAT_U_NTSC 0x7F
823#define DEFAULT_SAT_V_NTSC 0x5A 823#define DEFAULT_SAT_V_NTSC 0x5A
824 824
825typedef enum
826{
827 SOURCE_TUNER = 0,
828 SOURCE_COMPOSITE,
829 SOURCE_SVIDEO,
830 SOURCE_OTHER1,
831 SOURCE_OTHER2,
832 SOURCE_COMPVIASVIDEO,
833 SOURCE_CCIR656
834} VIDEOSOURCETYPE;
835
836#endif /* _CX88_REG_H_ */ 825#endif /* _CX88_REG_H_ */
diff --git a/drivers/media/pci/cx88/cx88-tvaudio.c b/drivers/media/pci/cx88/cx88-tvaudio.c
index b1d8680235e6..20f6924abe35 100644
--- a/drivers/media/pci/cx88/cx88-tvaudio.c
+++ b/drivers/media/pci/cx88/cx88-tvaudio.c
@@ -1,39 +1,34 @@
1/* 1/*
2 2 * cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
3 cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver 3 *
4 4 * (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version]
5 (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version] 5 * (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
6 (c) 2002 Yurij Sysoev <yurij@naturesoft.net> 6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org>
7 (c) 2003 Gerd Knorr <kraxel@bytesex.org> 7 *
8 8 * -----------------------------------------------------------------------
9 ----------------------------------------------------------------------- 9 *
10 10 * Lot of voodoo here. Even the data sheet doesn't help to
11 Lot of voodoo here. Even the data sheet doesn't help to 11 * understand what is going on here, the documentation for the audio
12 understand what is going on here, the documentation for the audio 12 * part of the cx2388x chip is *very* bad.
13 part of the cx2388x chip is *very* bad. 13 *
14 14 * Some of this comes from party done linux driver sources I got from
15 Some of this comes from party done linux driver sources I got from 15 * [undocumented].
16 [undocumented]. 16 *
17 17 * Some comes from the dscaler sources, one of the dscaler driver guy works
18 Some comes from the dscaler sources, one of the dscaler driver guy works 18 * for Conexant ...
19 for Conexant ... 19 *
20 20 * -----------------------------------------------------------------------
21 ----------------------------------------------------------------------- 21 *
22 22 * This program is free software; you can redistribute it and/or modify
23 This program is free software; you can redistribute it and/or modify 23 * it under the terms of the GNU General Public License as published by
24 it under the terms of the GNU General Public License as published by 24 * the Free Software Foundation; either version 2 of the License, or
25 the Free Software Foundation; either version 2 of the License, or 25 * (at your option) any later version.
26 (at your option) any later version. 26 *
27 27 * This program is distributed in the hope that it will be useful,
28 This program is distributed in the hope that it will be useful, 28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 but WITHOUT ANY WARRANTY; without even the implied warranty of 29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 * GNU General Public License for more details.
31 GNU General Public License for more details. 31 */
32
33 You should have received a copy of the GNU General Public License
34 along with this program; if not, write to the Free Software
35 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36*/
37 32
38#include "cx88.h" 33#include "cx88.h"
39 34
@@ -57,11 +52,11 @@ module_param(audio_debug, int, 0644);
57MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]"); 52MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]");
58 53
59static unsigned int always_analog; 54static unsigned int always_analog;
60module_param(always_analog,int,0644); 55module_param(always_analog, int, 0644);
61MODULE_PARM_DESC(always_analog,"force analog audio out"); 56MODULE_PARM_DESC(always_analog, "force analog audio out");
62 57
63static unsigned int radio_deemphasis; 58static unsigned int radio_deemphasis;
64module_param(radio_deemphasis,int,0644); 59module_param(radio_deemphasis, int, 0644);
65MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, 0=None, 1=50us (elsewhere), 2=75us (USA)"); 60MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, 0=None, 1=50us (elsewhere), 2=75us (USA)");
66 61
67#define dprintk(fmt, arg...) do { \ 62#define dprintk(fmt, arg...) do { \
@@ -350,7 +345,7 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
350 { /* end of list */ }, 345 { /* end of list */ },
351 }; 346 };
352 347
353 set_audio_start(core,SEL_NICAM); 348 set_audio_start(core, SEL_NICAM);
354 switch (core->tvaudio) { 349 switch (core->tvaudio) {
355 case WW_L: 350 case WW_L:
356 dprintk("%s SECAM-L NICAM (status: devel)\n", __func__); 351 dprintk("%s SECAM-L NICAM (status: devel)\n", __func__);
@@ -770,7 +765,7 @@ void cx88_set_tvaudio(struct cx88_core *core)
770 /* set nicam mode - otherwise 765 /* set nicam mode - otherwise
771 AUD_NICAM_STATUS2 contains wrong values */ 766 AUD_NICAM_STATUS2 contains wrong values */
772 set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO); 767 set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO);
773 if (0 == cx88_detect_nicam(core)) { 768 if (cx88_detect_nicam(core) == 0) {
774 /* fall back to fm / am mono */ 769 /* fall back to fm / am mono */
775 set_audio_standard_A2(core, EN_A2_FORCE_MONO1); 770 set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
776 core->audiomode_current = V4L2_TUNER_MODE_MONO; 771 core->audiomode_current = V4L2_TUNER_MODE_MONO;
@@ -869,11 +864,11 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
869 } 864 }
870 865
871 /* If software stereo detection is not supported... */ 866 /* If software stereo detection is not supported... */
872 if (UNSET == t->rxsubchans) { 867 if (t->rxsubchans == UNSET) {
873 t->rxsubchans = V4L2_TUNER_SUB_MONO; 868 t->rxsubchans = V4L2_TUNER_SUB_MONO;
874 /* If the hardware itself detected stereo, also return 869 /* If the hardware itself detected stereo, also return
875 stereo as an available subchannel */ 870 stereo as an available subchannel */
876 if (V4L2_TUNER_MODE_STEREO == t->audmode) 871 if (t->audmode == V4L2_TUNER_MODE_STEREO)
877 t->rxsubchans |= V4L2_TUNER_SUB_STEREO; 872 t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
878 } 873 }
879 return; 874 return;
@@ -887,7 +882,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
887 if (manual) { 882 if (manual) {
888 core->audiomode_manual = mode; 883 core->audiomode_manual = mode;
889 } else { 884 } else {
890 if (UNSET != core->audiomode_manual) 885 if (core->audiomode_manual != UNSET)
891 return; 886 return;
892 } 887 }
893 core->audiomode_current = mode; 888 core->audiomode_current = mode;
@@ -915,7 +910,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
915 case WW_M: 910 case WW_M:
916 case WW_I: 911 case WW_I:
917 case WW_L: 912 case WW_L:
918 if (1 == core->use_nicam) { 913 if (core->use_nicam == 1) {
919 switch (mode) { 914 switch (mode) {
920 case V4L2_TUNER_MODE_MONO: 915 case V4L2_TUNER_MODE_MONO:
921 case V4L2_TUNER_MODE_LANG1: 916 case V4L2_TUNER_MODE_LANG1:
@@ -975,7 +970,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
975 break; 970 break;
976 } 971 }
977 972
978 if (UNSET != ctl) { 973 if (ctl != UNSET) {
979 dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x [status=0x%x,ctl=0x%x,vol=0x%x]\n", 974 dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x [status=0x%x,ctl=0x%x,vol=0x%x]\n",
980 mask, ctl, cx_read(AUD_STATUS), 975 mask, ctl, cx_read(AUD_STATUS),
981 cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL)); 976 cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL));
@@ -1011,7 +1006,7 @@ int cx88_audio_thread(void *data)
1011 memset(&t, 0, sizeof(t)); 1006 memset(&t, 0, sizeof(t));
1012 cx88_get_stereo(core, &t); 1007 cx88_get_stereo(core, &t);
1013 1008
1014 if (UNSET != core->audiomode_manual) 1009 if (core->audiomode_manual != UNSET)
1015 /* manually set, don't do anything. */ 1010 /* manually set, don't do anything. */
1016 continue; 1011 continue;
1017 1012
diff --git a/drivers/media/pci/cx88/cx88-vbi.c b/drivers/media/pci/cx88/cx88-vbi.c
index 227f0f66e015..9028822f507e 100644
--- a/drivers/media/pci/cx88/cx88-vbi.c
+++ b/drivers/media/pci/cx88/cx88-vbi.c
@@ -8,8 +8,8 @@
8#include <linux/init.h> 8#include <linux/init.h>
9 9
10static unsigned int vbi_debug; 10static unsigned int vbi_debug;
11module_param(vbi_debug,int,0644); 11module_param(vbi_debug, int, 0644);
12MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); 12MODULE_PARM_DESC(vbi_debug, "enable debug messages [vbi]");
13 13
14#define dprintk(level, fmt, arg...) do { \ 14#define dprintk(level, fmt, arg...) do { \
15 if (vbi_debug >= level) \ 15 if (vbi_debug >= level) \
@@ -19,7 +19,7 @@ MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]");
19 19
20/* ------------------------------------------------------------------ */ 20/* ------------------------------------------------------------------ */
21 21
22int cx8800_vbi_fmt (struct file *file, void *priv, 22int cx8800_vbi_fmt(struct file *file, void *priv,
23 struct v4l2_format *f) 23 struct v4l2_format *f)
24{ 24{
25 struct cx8800_dev *dev = video_drvdata(file); 25 struct cx8800_dev *dev = video_drvdata(file);
@@ -57,9 +57,9 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
57 cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24], 57 cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24],
58 VBI_LINE_LENGTH, buf->risc.dma); 58 VBI_LINE_LENGTH, buf->risc.dma);
59 59
60 cx_write(MO_VBOS_CONTROL, ( (1 << 18) | // comb filter delay fixup 60 cx_write(MO_VBOS_CONTROL, ((1 << 18) | // comb filter delay fixup
61 (1 << 15) | // enable vbi capture 61 (1 << 15) | // enable vbi capture
62 (1 << 11) )); 62 (1 << 11)));
63 63
64 /* reset counter */ 64 /* reset counter */
65 cx_write(MO_VBI_GPCNTRL, GP_COUNT_CONTROL_RESET); 65 cx_write(MO_VBI_GPCNTRL, GP_COUNT_CONTROL_RESET);
@@ -70,7 +70,7 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
70 cx_set(MO_VID_INTMSK, 0x0f0088); 70 cx_set(MO_VID_INTMSK, 0x0f0088);
71 71
72 /* enable capture */ 72 /* enable capture */
73 cx_set(VID_CAPTURE_CONTROL,0x18); 73 cx_set(VID_CAPTURE_CONTROL, 0x18);
74 74
75 /* start dma */ 75 /* start dma */
76 cx_set(MO_DEV_CNTRL2, (1<<5)); 76 cx_set(MO_DEV_CNTRL2, (1<<5));
@@ -87,7 +87,7 @@ void cx8800_stop_vbi_dma(struct cx8800_dev *dev)
87 cx_clear(MO_VID_DMACNTRL, 0x88); 87 cx_clear(MO_VID_DMACNTRL, 0x88);
88 88
89 /* disable capture */ 89 /* disable capture */
90 cx_clear(VID_CAPTURE_CONTROL,0x18); 90 cx_clear(VID_CAPTURE_CONTROL, 0x18);
91 91
92 /* disable irqs */ 92 /* disable irqs */
93 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT); 93 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT);
@@ -103,7 +103,7 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
103 return 0; 103 return 0;
104 104
105 buf = list_entry(q->active.next, struct cx88_buffer, list); 105 buf = list_entry(q->active.next, struct cx88_buffer, list);
106 dprintk(2,"restart_queue [%p/%d]: restart dma\n", 106 dprintk(2, "restart_queue [%p/%d]: restart dma\n",
107 buf, buf->vb.vb2_buf.index); 107 buf, buf->vb.vb2_buf.index);
108 cx8800_start_vbi_dma(dev, q, buf); 108 cx8800_start_vbi_dma(dev, q, buf);
109 return 0; 109 return 0;
@@ -179,7 +179,7 @@ static void buffer_queue(struct vb2_buffer *vb)
179 if (list_empty(&q->active)) { 179 if (list_empty(&q->active)) {
180 list_add_tail(&buf->list, &q->active); 180 list_add_tail(&buf->list, &q->active);
181 cx8800_start_vbi_dma(dev, q, buf); 181 cx8800_start_vbi_dma(dev, q, buf);
182 dprintk(2,"[%p/%d] vbi_queue - first active\n", 182 dprintk(2, "[%p/%d] vbi_queue - first active\n",
183 buf, buf->vb.vb2_buf.index); 183 buf, buf->vb.vb2_buf.index);
184 184
185 } else { 185 } else {
@@ -187,7 +187,7 @@ static void buffer_queue(struct vb2_buffer *vb)
187 prev = list_entry(q->active.prev, struct cx88_buffer, list); 187 prev = list_entry(q->active.prev, struct cx88_buffer, list);
188 list_add_tail(&buf->list, &q->active); 188 list_add_tail(&buf->list, &q->active);
189 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 189 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
190 dprintk(2,"[%p/%d] buffer_queue - append to active\n", 190 dprintk(2, "[%p/%d] buffer_queue - append to active\n",
191 buf, buf->vb.vb2_buf.index); 191 buf, buf->vb.vb2_buf.index);
192 } 192 }
193} 193}
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index 3d349dfb23ff..797d5d0a4060 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 22 */
27 23
28#include "cx88.h" 24#include "cx88.h"
@@ -59,17 +55,17 @@ module_param_array(video_nr, int, NULL, 0444);
59module_param_array(vbi_nr, int, NULL, 0444); 55module_param_array(vbi_nr, int, NULL, 0444);
60module_param_array(radio_nr, int, NULL, 0444); 56module_param_array(radio_nr, int, NULL, 0444);
61 57
62MODULE_PARM_DESC(video_nr,"video device numbers"); 58MODULE_PARM_DESC(video_nr, "video device numbers");
63MODULE_PARM_DESC(vbi_nr,"vbi device numbers"); 59MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
64MODULE_PARM_DESC(radio_nr,"radio device numbers"); 60MODULE_PARM_DESC(radio_nr, "radio device numbers");
65 61
66static unsigned int video_debug; 62static unsigned int video_debug;
67module_param(video_debug,int,0644); 63module_param(video_debug, int, 0644);
68MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); 64MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
69 65
70static unsigned int irq_debug; 66static unsigned int irq_debug;
71module_param(irq_debug,int,0644); 67module_param(irq_debug, int, 0644);
72MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); 68MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]");
73 69
74#define dprintk(level, fmt, arg...) do { \ 70#define dprintk(level, fmt, arg...) do { \
75 if (video_debug >= level) \ 71 if (video_debug >= level) \
@@ -88,55 +84,55 @@ static const struct cx8800_fmt formats[] = {
88 .cxformat = ColorFormatY8, 84 .cxformat = ColorFormatY8,
89 .depth = 8, 85 .depth = 8,
90 .flags = FORMAT_FLAGS_PACKED, 86 .flags = FORMAT_FLAGS_PACKED,
91 },{ 87 }, {
92 .name = "15 bpp RGB, le", 88 .name = "15 bpp RGB, le",
93 .fourcc = V4L2_PIX_FMT_RGB555, 89 .fourcc = V4L2_PIX_FMT_RGB555,
94 .cxformat = ColorFormatRGB15, 90 .cxformat = ColorFormatRGB15,
95 .depth = 16, 91 .depth = 16,
96 .flags = FORMAT_FLAGS_PACKED, 92 .flags = FORMAT_FLAGS_PACKED,
97 },{ 93 }, {
98 .name = "15 bpp RGB, be", 94 .name = "15 bpp RGB, be",
99 .fourcc = V4L2_PIX_FMT_RGB555X, 95 .fourcc = V4L2_PIX_FMT_RGB555X,
100 .cxformat = ColorFormatRGB15 | ColorFormatBSWAP, 96 .cxformat = ColorFormatRGB15 | ColorFormatBSWAP,
101 .depth = 16, 97 .depth = 16,
102 .flags = FORMAT_FLAGS_PACKED, 98 .flags = FORMAT_FLAGS_PACKED,
103 },{ 99 }, {
104 .name = "16 bpp RGB, le", 100 .name = "16 bpp RGB, le",
105 .fourcc = V4L2_PIX_FMT_RGB565, 101 .fourcc = V4L2_PIX_FMT_RGB565,
106 .cxformat = ColorFormatRGB16, 102 .cxformat = ColorFormatRGB16,
107 .depth = 16, 103 .depth = 16,
108 .flags = FORMAT_FLAGS_PACKED, 104 .flags = FORMAT_FLAGS_PACKED,
109 },{ 105 }, {
110 .name = "16 bpp RGB, be", 106 .name = "16 bpp RGB, be",
111 .fourcc = V4L2_PIX_FMT_RGB565X, 107 .fourcc = V4L2_PIX_FMT_RGB565X,
112 .cxformat = ColorFormatRGB16 | ColorFormatBSWAP, 108 .cxformat = ColorFormatRGB16 | ColorFormatBSWAP,
113 .depth = 16, 109 .depth = 16,
114 .flags = FORMAT_FLAGS_PACKED, 110 .flags = FORMAT_FLAGS_PACKED,
115 },{ 111 }, {
116 .name = "24 bpp RGB, le", 112 .name = "24 bpp RGB, le",
117 .fourcc = V4L2_PIX_FMT_BGR24, 113 .fourcc = V4L2_PIX_FMT_BGR24,
118 .cxformat = ColorFormatRGB24, 114 .cxformat = ColorFormatRGB24,
119 .depth = 24, 115 .depth = 24,
120 .flags = FORMAT_FLAGS_PACKED, 116 .flags = FORMAT_FLAGS_PACKED,
121 },{ 117 }, {
122 .name = "32 bpp RGB, le", 118 .name = "32 bpp RGB, le",
123 .fourcc = V4L2_PIX_FMT_BGR32, 119 .fourcc = V4L2_PIX_FMT_BGR32,
124 .cxformat = ColorFormatRGB32, 120 .cxformat = ColorFormatRGB32,
125 .depth = 32, 121 .depth = 32,
126 .flags = FORMAT_FLAGS_PACKED, 122 .flags = FORMAT_FLAGS_PACKED,
127 },{ 123 }, {
128 .name = "32 bpp RGB, be", 124 .name = "32 bpp RGB, be",
129 .fourcc = V4L2_PIX_FMT_RGB32, 125 .fourcc = V4L2_PIX_FMT_RGB32,
130 .cxformat = ColorFormatRGB32 | ColorFormatBSWAP | ColorFormatWSWAP, 126 .cxformat = ColorFormatRGB32 | ColorFormatBSWAP | ColorFormatWSWAP,
131 .depth = 32, 127 .depth = 32,
132 .flags = FORMAT_FLAGS_PACKED, 128 .flags = FORMAT_FLAGS_PACKED,
133 },{ 129 }, {
134 .name = "4:2:2, packed, YUYV", 130 .name = "4:2:2, packed, YUYV",
135 .fourcc = V4L2_PIX_FMT_YUYV, 131 .fourcc = V4L2_PIX_FMT_YUYV,
136 .cxformat = ColorFormatYUY2, 132 .cxformat = ColorFormatYUY2,
137 .depth = 16, 133 .depth = 16,
138 .flags = FORMAT_FLAGS_PACKED, 134 .flags = FORMAT_FLAGS_PACKED,
139 },{ 135 }, {
140 .name = "4:2:2, packed, UYVY", 136 .name = "4:2:2, packed, UYVY",
141 .fourcc = V4L2_PIX_FMT_UYVY, 137 .fourcc = V4L2_PIX_FMT_UYVY,
142 .cxformat = ColorFormatYUY2 | ColorFormatBSWAP, 138 .cxformat = ColorFormatYUY2 | ColorFormatBSWAP,
@@ -145,7 +141,7 @@ static const struct cx8800_fmt formats[] = {
145 }, 141 },
146}; 142};
147 143
148static const struct cx8800_fmt* format_by_fourcc(unsigned int fourcc) 144static const struct cx8800_fmt *format_by_fourcc(unsigned int fourcc)
149{ 145{
150 unsigned int i; 146 unsigned int i;
151 147
@@ -185,7 +181,7 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
185 .reg = MO_CONTR_BRIGHT, 181 .reg = MO_CONTR_BRIGHT,
186 .mask = 0x00ff, 182 .mask = 0x00ff,
187 .shift = 0, 183 .shift = 0,
188 },{ 184 }, {
189 .id = V4L2_CID_CONTRAST, 185 .id = V4L2_CID_CONTRAST,
190 .minimum = 0, 186 .minimum = 0,
191 .maximum = 0xff, 187 .maximum = 0xff,
@@ -195,7 +191,7 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
195 .reg = MO_CONTR_BRIGHT, 191 .reg = MO_CONTR_BRIGHT,
196 .mask = 0xff00, 192 .mask = 0xff00,
197 .shift = 8, 193 .shift = 8,
198 },{ 194 }, {
199 .id = V4L2_CID_HUE, 195 .id = V4L2_CID_HUE,
200 .minimum = 0, 196 .minimum = 0,
201 .maximum = 0xff, 197 .maximum = 0xff,
@@ -205,7 +201,7 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
205 .reg = MO_HUE, 201 .reg = MO_HUE,
206 .mask = 0x00ff, 202 .mask = 0x00ff,
207 .shift = 0, 203 .shift = 0,
208 },{ 204 }, {
209 /* strictly, this only describes only U saturation. 205 /* strictly, this only describes only U saturation.
210 * V saturation is handled specially through code. 206 * V saturation is handled specially through code.
211 */ 207 */
@@ -270,7 +266,7 @@ static const struct cx88_ctrl cx8800_aud_ctls[] = {
270 .sreg = SHADOW_AUD_VOL_CTL, 266 .sreg = SHADOW_AUD_VOL_CTL,
271 .mask = (1 << 6), 267 .mask = (1 << 6),
272 .shift = 6, 268 .shift = 6,
273 },{ 269 }, {
274 .id = V4L2_CID_AUDIO_VOLUME, 270 .id = V4L2_CID_AUDIO_VOLUME,
275 .minimum = 0, 271 .minimum = 0,
276 .maximum = 0x3f, 272 .maximum = 0x3f,
@@ -280,7 +276,7 @@ static const struct cx88_ctrl cx8800_aud_ctls[] = {
280 .sreg = SHADOW_AUD_VOL_CTL, 276 .sreg = SHADOW_AUD_VOL_CTL,
281 .mask = 0x3f, 277 .mask = 0x3f,
282 .shift = 0, 278 .shift = 0,
283 },{ 279 }, {
284 .id = V4L2_CID_AUDIO_BALANCE, 280 .id = V4L2_CID_AUDIO_BALANCE,
285 .minimum = 0, 281 .minimum = 0,
286 .maximum = 0x7f, 282 .maximum = 0x7f,
@@ -304,10 +300,10 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
304{ 300{
305 /* struct cx88_core *core = dev->core; */ 301 /* struct cx88_core *core = dev->core; */
306 302
307 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n", 303 dprintk(1, "video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
308 input, INPUT(input).vmux, 304 input, INPUT(input).vmux,
309 INPUT(input).gpio0,INPUT(input).gpio1, 305 INPUT(input).gpio0, INPUT(input).gpio1,
310 INPUT(input).gpio2,INPUT(input).gpio3); 306 INPUT(input).gpio2, INPUT(input).gpio3);
311 core->input = input; 307 core->input = input;
312 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input).vmux << 14); 308 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input).vmux << 14);
313 cx_write(MO_GP3_IO, INPUT(input).gpio3); 309 cx_write(MO_GP3_IO, INPUT(input).gpio3);
@@ -374,7 +370,7 @@ static int start_video_dma(struct cx8800_dev *dev,
374 cx_write(MO_COLOR_CTRL, dev->fmt->cxformat | ColorFormatGamma); 370 cx_write(MO_COLOR_CTRL, dev->fmt->cxformat | ColorFormatGamma);
375 371
376 /* reset counter */ 372 /* reset counter */
377 cx_write(MO_VIDY_GPCNTRL,GP_COUNT_CONTROL_RESET); 373 cx_write(MO_VIDY_GPCNTRL, GP_COUNT_CONTROL_RESET);
378 q->count = 0; 374 q->count = 0;
379 375
380 /* enable irqs */ 376 /* enable irqs */
@@ -390,7 +386,7 @@ static int start_video_dma(struct cx8800_dev *dev,
390 cx_set(MO_VID_INTMSK, 0x0f0011); 386 cx_set(MO_VID_INTMSK, 0x0f0011);
391 387
392 /* enable capture */ 388 /* enable capture */
393 cx_set(VID_CAPTURE_CONTROL,0x06); 389 cx_set(VID_CAPTURE_CONTROL, 0x06);
394 390
395 /* start dma */ 391 /* start dma */
396 cx_set(MO_DEV_CNTRL2, (1<<5)); 392 cx_set(MO_DEV_CNTRL2, (1<<5));
@@ -408,7 +404,7 @@ static int stop_video_dma(struct cx8800_dev *dev)
408 cx_clear(MO_VID_DMACNTRL, 0x11); 404 cx_clear(MO_VID_DMACNTRL, 0x11);
409 405
410 /* disable capture */ 406 /* disable capture */
411 cx_clear(VID_CAPTURE_CONTROL,0x06); 407 cx_clear(VID_CAPTURE_CONTROL, 0x06);
412 408
413 /* disable irqs */ 409 /* disable irqs */
414 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT); 410 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT);
@@ -423,7 +419,7 @@ static int restart_video_queue(struct cx8800_dev *dev,
423 419
424 if (!list_empty(&q->active)) { 420 if (!list_empty(&q->active)) {
425 buf = list_entry(q->active.next, struct cx88_buffer, list); 421 buf = list_entry(q->active.next, struct cx88_buffer, list);
426 dprintk(2,"restart_queue [%p/%d]: restart dma\n", 422 dprintk(2, "restart_queue [%p/%d]: restart dma\n",
427 buf, buf->vb.vb2_buf.index); 423 buf, buf->vb.vb2_buf.index);
428 start_video_dma(dev, q, buf); 424 start_video_dma(dev, q, buf);
429 } 425 }
@@ -492,7 +488,7 @@ static int buffer_prepare(struct vb2_buffer *vb)
492 core->height >> 1); 488 core->height >> 1);
493 break; 489 break;
494 } 490 }
495 dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", 491 dprintk(2, "[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
496 buf, buf->vb.vb2_buf.index, 492 buf, buf->vb.vb2_buf.index,
497 core->width, core->height, dev->fmt->depth, dev->fmt->name, 493 core->width, core->height, dev->fmt->depth, dev->fmt->name,
498 (unsigned long)buf->risc.dma); 494 (unsigned long)buf->risc.dma);
@@ -526,7 +522,7 @@ static void buffer_queue(struct vb2_buffer *vb)
526 522
527 if (list_empty(&q->active)) { 523 if (list_empty(&q->active)) {
528 list_add_tail(&buf->list, &q->active); 524 list_add_tail(&buf->list, &q->active);
529 dprintk(2,"[%p/%d] buffer_queue - first active\n", 525 dprintk(2, "[%p/%d] buffer_queue - first active\n",
530 buf, buf->vb.vb2_buf.index); 526 buf, buf->vb.vb2_buf.index);
531 527
532 } else { 528 } else {
@@ -668,7 +664,7 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
668 struct cx88_core *core = 664 struct cx88_core *core =
669 container_of(ctrl->handler, struct cx88_core, audio_hdl); 665 container_of(ctrl->handler, struct cx88_core, audio_hdl);
670 const struct cx88_ctrl *cc = ctrl->priv; 666 const struct cx88_ctrl *cc = ctrl->priv;
671 u32 value,mask; 667 u32 value, mask;
672 668
673 /* Pass changes onto any WM8775 */ 669 /* Pass changes onto any WM8775 */
674 if (core->sd_wm8775) { 670 if (core->sd_wm8775) {
@@ -700,7 +696,7 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
700 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; 696 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask;
701 break; 697 break;
702 } 698 }
703 dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", 699 dprintk(1, "set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
704 ctrl->id, ctrl->name, ctrl->val, cc->reg, value, 700 ctrl->id, ctrl->name, ctrl->val, cc->reg, value,
705 mask, cc->sreg ? " [shadowed]" : ""); 701 mask, cc->sreg ? " [shadowed]" : "");
706 if (cc->sreg) 702 if (cc->sreg)
@@ -741,7 +737,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
741 unsigned int maxw, maxh; 737 unsigned int maxw, maxh;
742 738
743 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 739 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
744 if (NULL == fmt) 740 if (fmt == NULL)
745 return -EINVAL; 741 return -EINVAL;
746 742
747 maxw = norm_maxw(core->tvnorm); 743 maxw = norm_maxw(core->tvnorm);
@@ -782,9 +778,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
782{ 778{
783 struct cx8800_dev *dev = video_drvdata(file); 779 struct cx8800_dev *dev = video_drvdata(file);
784 struct cx88_core *core = dev->core; 780 struct cx88_core *core = dev->core;
785 int err = vidioc_try_fmt_vid_cap (file,priv,f); 781 int err = vidioc_try_fmt_vid_cap(file, priv, f);
786 782
787 if (0 != err) 783 if (err != 0)
788 return err; 784 return err;
789 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq)) 785 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq))
790 return -EBUSY; 786 return -EBUSY;
@@ -804,7 +800,7 @@ void cx88_querycap(struct file *file, struct cx88_core *core,
804 800
805 strlcpy(cap->card, core->board.name, sizeof(cap->card)); 801 strlcpy(cap->card, core->board.name, sizeof(cap->card));
806 cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; 802 cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
807 if (UNSET != core->board.tuner_type) 803 if (core->board.tuner_type != UNSET)
808 cap->device_caps |= V4L2_CAP_TUNER; 804 cap->device_caps |= V4L2_CAP_TUNER;
809 switch (vdev->vfl_type) { 805 switch (vdev->vfl_type) {
810 case VFL_TYPE_RADIO: 806 case VFL_TYPE_RADIO:
@@ -836,13 +832,13 @@ static int vidioc_querycap(struct file *file, void *priv,
836 return 0; 832 return 0;
837} 833}
838 834
839static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, 835static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
840 struct v4l2_fmtdesc *f) 836 struct v4l2_fmtdesc *f)
841{ 837{
842 if (unlikely(f->index >= ARRAY_SIZE(formats))) 838 if (unlikely(f->index >= ARRAY_SIZE(formats)))
843 return -EINVAL; 839 return -EINVAL;
844 840
845 strlcpy(f->description,formats[f->index].name,sizeof(f->description)); 841 strlcpy(f->description, formats[f->index].name, sizeof(f->description));
846 f->pixelformat = formats[f->index].fourcc; 842 f->pixelformat = formats[f->index].fourcc;
847 843
848 return 0; 844 return 0;
@@ -866,18 +862,18 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms)
866} 862}
867 863
868/* only one input in this sample driver */ 864/* only one input in this sample driver */
869int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i) 865int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i)
870{ 866{
871 static const char * const iname[] = { 867 static const char * const iname[] = {
872 [ CX88_VMUX_COMPOSITE1 ] = "Composite1", 868 [CX88_VMUX_COMPOSITE1] = "Composite1",
873 [ CX88_VMUX_COMPOSITE2 ] = "Composite2", 869 [CX88_VMUX_COMPOSITE2] = "Composite2",
874 [ CX88_VMUX_COMPOSITE3 ] = "Composite3", 870 [CX88_VMUX_COMPOSITE3] = "Composite3",
875 [ CX88_VMUX_COMPOSITE4 ] = "Composite4", 871 [CX88_VMUX_COMPOSITE4] = "Composite4",
876 [ CX88_VMUX_SVIDEO ] = "S-Video", 872 [CX88_VMUX_SVIDEO] = "S-Video",
877 [ CX88_VMUX_TELEVISION ] = "Television", 873 [CX88_VMUX_TELEVISION] = "Television",
878 [ CX88_VMUX_CABLE ] = "Cable TV", 874 [CX88_VMUX_CABLE] = "Cable TV",
879 [ CX88_VMUX_DVB ] = "DVB", 875 [CX88_VMUX_DVB] = "DVB",
880 [ CX88_VMUX_DEBUG ] = "for debug only", 876 [CX88_VMUX_DEBUG] = "for debug only",
881 }; 877 };
882 unsigned int n = i->index; 878 unsigned int n = i->index;
883 879
@@ -886,7 +882,7 @@ int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i)
886 if (0 == INPUT(n).type) 882 if (0 == INPUT(n).type)
887 return -EINVAL; 883 return -EINVAL;
888 i->type = V4L2_INPUT_TYPE_CAMERA; 884 i->type = V4L2_INPUT_TYPE_CAMERA;
889 strcpy(i->name,iname[INPUT(n).type]); 885 strcpy(i->name, iname[INPUT(n).type]);
890 if ((CX88_VMUX_TELEVISION == INPUT(n).type) || 886 if ((CX88_VMUX_TELEVISION == INPUT(n).type) ||
891 (CX88_VMUX_CABLE == INPUT(n).type)) { 887 (CX88_VMUX_CABLE == INPUT(n).type)) {
892 i->type = V4L2_INPUT_TYPE_TUNER; 888 i->type = V4L2_INPUT_TYPE_TUNER;
@@ -896,15 +892,16 @@ int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i)
896} 892}
897EXPORT_SYMBOL(cx88_enum_input); 893EXPORT_SYMBOL(cx88_enum_input);
898 894
899static int vidioc_enum_input (struct file *file, void *priv, 895static int vidioc_enum_input(struct file *file, void *priv,
900 struct v4l2_input *i) 896 struct v4l2_input *i)
901{ 897{
902 struct cx8800_dev *dev = video_drvdata(file); 898 struct cx8800_dev *dev = video_drvdata(file);
903 struct cx88_core *core = dev->core; 899 struct cx88_core *core = dev->core;
904 return cx88_enum_input (core,i); 900
901 return cx88_enum_input(core, i);
905} 902}
906 903
907static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) 904static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
908{ 905{
909 struct cx8800_dev *dev = video_drvdata(file); 906 struct cx8800_dev *dev = video_drvdata(file);
910 struct cx88_core *core = dev->core; 907 struct cx88_core *core = dev->core;
@@ -913,7 +910,7 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)
913 return 0; 910 return 0;
914} 911}
915 912
916static int vidioc_s_input (struct file *file, void *priv, unsigned int i) 913static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
917{ 914{
918 struct cx8800_dev *dev = video_drvdata(file); 915 struct cx8800_dev *dev = video_drvdata(file);
919 struct cx88_core *core = dev->core; 916 struct cx88_core *core = dev->core;
@@ -924,20 +921,20 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i)
924 return -EINVAL; 921 return -EINVAL;
925 922
926 cx88_newstation(core); 923 cx88_newstation(core);
927 cx88_video_mux(core,i); 924 cx88_video_mux(core, i);
928 return 0; 925 return 0;
929} 926}
930 927
931static int vidioc_g_tuner (struct file *file, void *priv, 928static int vidioc_g_tuner(struct file *file, void *priv,
932 struct v4l2_tuner *t) 929 struct v4l2_tuner *t)
933{ 930{
934 struct cx8800_dev *dev = video_drvdata(file); 931 struct cx8800_dev *dev = video_drvdata(file);
935 struct cx88_core *core = dev->core; 932 struct cx88_core *core = dev->core;
936 u32 reg; 933 u32 reg;
937 934
938 if (unlikely(UNSET == core->board.tuner_type)) 935 if (unlikely(core->board.tuner_type == UNSET))
939 return -EINVAL; 936 return -EINVAL;
940 if (0 != t->index) 937 if (t->index != 0)
941 return -EINVAL; 938 return -EINVAL;
942 939
943 strcpy(t->name, "Television"); 940 strcpy(t->name, "Television");
@@ -945,34 +942,34 @@ static int vidioc_g_tuner (struct file *file, void *priv,
945 t->rangehigh = 0xffffffffUL; 942 t->rangehigh = 0xffffffffUL;
946 call_all(core, tuner, g_tuner, t); 943 call_all(core, tuner, g_tuner, t);
947 944
948 cx88_get_stereo(core ,t); 945 cx88_get_stereo(core, t);
949 reg = cx_read(MO_DEVICE_STATUS); 946 reg = cx_read(MO_DEVICE_STATUS);
950 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; 947 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
951 return 0; 948 return 0;
952} 949}
953 950
954static int vidioc_s_tuner (struct file *file, void *priv, 951static int vidioc_s_tuner(struct file *file, void *priv,
955 const struct v4l2_tuner *t) 952 const struct v4l2_tuner *t)
956{ 953{
957 struct cx8800_dev *dev = video_drvdata(file); 954 struct cx8800_dev *dev = video_drvdata(file);
958 struct cx88_core *core = dev->core; 955 struct cx88_core *core = dev->core;
959 956
960 if (UNSET == core->board.tuner_type) 957 if (core->board.tuner_type == UNSET)
961 return -EINVAL; 958 return -EINVAL;
962 if (0 != t->index) 959 if (t->index != 0)
963 return -EINVAL; 960 return -EINVAL;
964 961
965 cx88_set_stereo(core, t->audmode, 1); 962 cx88_set_stereo(core, t->audmode, 1);
966 return 0; 963 return 0;
967} 964}
968 965
969static int vidioc_g_frequency (struct file *file, void *priv, 966static int vidioc_g_frequency(struct file *file, void *priv,
970 struct v4l2_frequency *f) 967 struct v4l2_frequency *f)
971{ 968{
972 struct cx8800_dev *dev = video_drvdata(file); 969 struct cx8800_dev *dev = video_drvdata(file);
973 struct cx88_core *core = dev->core; 970 struct cx88_core *core = dev->core;
974 971
975 if (unlikely(UNSET == core->board.tuner_type)) 972 if (unlikely(core->board.tuner_type == UNSET))
976 return -EINVAL; 973 return -EINVAL;
977 if (f->tuner) 974 if (f->tuner)
978 return -EINVAL; 975 return -EINVAL;
@@ -984,12 +981,12 @@ static int vidioc_g_frequency (struct file *file, void *priv,
984 return 0; 981 return 0;
985} 982}
986 983
987int cx88_set_freq (struct cx88_core *core, 984int cx88_set_freq(struct cx88_core *core,
988 const struct v4l2_frequency *f) 985 const struct v4l2_frequency *f)
989{ 986{
990 struct v4l2_frequency new_freq = *f; 987 struct v4l2_frequency new_freq = *f;
991 988
992 if (unlikely(UNSET == core->board.tuner_type)) 989 if (unlikely(core->board.tuner_type == UNSET))
993 return -EINVAL; 990 return -EINVAL;
994 if (unlikely(f->tuner != 0)) 991 if (unlikely(f->tuner != 0))
995 return -EINVAL; 992 return -EINVAL;
@@ -1000,14 +997,14 @@ int cx88_set_freq (struct cx88_core *core,
1000 core->freq = new_freq.frequency; 997 core->freq = new_freq.frequency;
1001 998
1002 /* When changing channels it is required to reset TVAUDIO */ 999 /* When changing channels it is required to reset TVAUDIO */
1003 msleep (10); 1000 usleep_range(10000, 20000);
1004 cx88_set_tvaudio(core); 1001 cx88_set_tvaudio(core);
1005 1002
1006 return 0; 1003 return 0;
1007} 1004}
1008EXPORT_SYMBOL(cx88_set_freq); 1005EXPORT_SYMBOL(cx88_set_freq);
1009 1006
1010static int vidioc_s_frequency (struct file *file, void *priv, 1007static int vidioc_s_frequency(struct file *file, void *priv,
1011 const struct v4l2_frequency *f) 1008 const struct v4l2_frequency *f)
1012{ 1009{
1013 struct cx8800_dev *dev = video_drvdata(file); 1010 struct cx8800_dev *dev = video_drvdata(file);
@@ -1017,7 +1014,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
1017} 1014}
1018 1015
1019#ifdef CONFIG_VIDEO_ADV_DEBUG 1016#ifdef CONFIG_VIDEO_ADV_DEBUG
1020static int vidioc_g_register (struct file *file, void *fh, 1017static int vidioc_g_register(struct file *file, void *fh,
1021 struct v4l2_dbg_register *reg) 1018 struct v4l2_dbg_register *reg)
1022{ 1019{
1023 struct cx8800_dev *dev = video_drvdata(file); 1020 struct cx8800_dev *dev = video_drvdata(file);
@@ -1029,7 +1026,7 @@ static int vidioc_g_register (struct file *file, void *fh,
1029 return 0; 1026 return 0;
1030} 1027}
1031 1028
1032static int vidioc_s_register (struct file *file, void *fh, 1029static int vidioc_s_register(struct file *file, void *fh,
1033 const struct v4l2_dbg_register *reg) 1030 const struct v4l2_dbg_register *reg)
1034{ 1031{
1035 struct cx8800_dev *dev = video_drvdata(file); 1032 struct cx8800_dev *dev = video_drvdata(file);
@@ -1044,7 +1041,7 @@ static int vidioc_s_register (struct file *file, void *fh,
1044/* RADIO ESPECIFIC IOCTLS */ 1041/* RADIO ESPECIFIC IOCTLS */
1045/* ----------------------------------------------------------- */ 1042/* ----------------------------------------------------------- */
1046 1043
1047static int radio_g_tuner (struct file *file, void *priv, 1044static int radio_g_tuner(struct file *file, void *priv,
1048 struct v4l2_tuner *t) 1045 struct v4l2_tuner *t)
1049{ 1046{
1050 struct cx8800_dev *dev = video_drvdata(file); 1047 struct cx8800_dev *dev = video_drvdata(file);
@@ -1059,13 +1056,13 @@ static int radio_g_tuner (struct file *file, void *priv,
1059 return 0; 1056 return 0;
1060} 1057}
1061 1058
1062static int radio_s_tuner (struct file *file, void *priv, 1059static int radio_s_tuner(struct file *file, void *priv,
1063 const struct v4l2_tuner *t) 1060 const struct v4l2_tuner *t)
1064{ 1061{
1065 struct cx8800_dev *dev = video_drvdata(file); 1062 struct cx8800_dev *dev = video_drvdata(file);
1066 struct cx88_core *core = dev->core; 1063 struct cx88_core *core = dev->core;
1067 1064
1068 if (0 != t->index) 1065 if (t->index != 0)
1069 return -EINVAL; 1066 return -EINVAL;
1070 1067
1071 call_all(core, tuner, s_tuner, t); 1068 call_all(core, tuner, s_tuner, t);
@@ -1132,19 +1129,19 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id)
1132 for (loop = 0; loop < 10; loop++) { 1129 for (loop = 0; loop < 10; loop++) {
1133 status = cx_read(MO_PCI_INTSTAT) & 1130 status = cx_read(MO_PCI_INTSTAT) &
1134 (core->pci_irqmask | PCI_INT_VIDINT); 1131 (core->pci_irqmask | PCI_INT_VIDINT);
1135 if (0 == status) 1132 if (status == 0)
1136 goto out; 1133 goto out;
1137 cx_write(MO_PCI_INTSTAT, status); 1134 cx_write(MO_PCI_INTSTAT, status);
1138 handled = 1; 1135 handled = 1;
1139 1136
1140 if (status & core->pci_irqmask) 1137 if (status & core->pci_irqmask)
1141 cx88_core_irq(core,status); 1138 cx88_core_irq(core, status);
1142 if (status & PCI_INT_VIDINT) 1139 if (status & PCI_INT_VIDINT)
1143 cx8800_vid_irq(dev); 1140 cx8800_vid_irq(dev);
1144 } 1141 }
1145 if (10 == loop) { 1142 if (loop == 10) {
1146 pr_warn("irq loop -- clearing mask\n"); 1143 pr_warn("irq loop -- clearing mask\n");
1147 cx_write(MO_PCI_INTMSK,0); 1144 cx_write(MO_PCI_INTMSK, 0);
1148 } 1145 }
1149 1146
1150 out: 1147 out:
@@ -1154,8 +1151,8 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id)
1154/* ----------------------------------------------------------- */ 1151/* ----------------------------------------------------------- */
1155/* exported stuff */ 1152/* exported stuff */
1156 1153
1157static const struct v4l2_file_operations video_fops = 1154static const struct v4l2_file_operations video_fops = {
1158{ 1155
1159 .owner = THIS_MODULE, 1156 .owner = THIS_MODULE,
1160 .open = v4l2_fh_open, 1157 .open = v4l2_fh_open,
1161 .release = vb2_fop_release, 1158 .release = vb2_fop_release,
@@ -1197,7 +1194,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
1197static const struct video_device cx8800_video_template = { 1194static const struct video_device cx8800_video_template = {
1198 .name = "cx8800-video", 1195 .name = "cx8800-video",
1199 .fops = &video_fops, 1196 .fops = &video_fops,
1200 .ioctl_ops = &video_ioctl_ops, 1197 .ioctl_ops = &video_ioctl_ops,
1201 .tvnorms = CX88_NORMS, 1198 .tvnorms = CX88_NORMS,
1202}; 1199};
1203 1200
@@ -1234,8 +1231,8 @@ static const struct video_device cx8800_vbi_template = {
1234 .tvnorms = CX88_NORMS, 1231 .tvnorms = CX88_NORMS,
1235}; 1232};
1236 1233
1237static const struct v4l2_file_operations radio_fops = 1234static const struct v4l2_file_operations radio_fops = {
1238{ 1235
1239 .owner = THIS_MODULE, 1236 .owner = THIS_MODULE,
1240 .open = radio_open, 1237 .open = radio_open,
1241 .poll = v4l2_ctrl_poll, 1238 .poll = v4l2_ctrl_poll,
@@ -1260,7 +1257,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
1260static const struct video_device cx8800_radio_template = { 1257static const struct video_device cx8800_radio_template = {
1261 .name = "cx8800-radio", 1258 .name = "cx8800-radio",
1262 .fops = &radio_fops, 1259 .fops = &radio_fops,
1263 .ioctl_ops = &radio_ioctl_ops, 1260 .ioctl_ops = &radio_ioctl_ops,
1264}; 1261};
1265 1262
1266static const struct v4l2_ctrl_ops cx8800_ctrl_vid_ops = { 1263static const struct v4l2_ctrl_ops cx8800_ctrl_vid_ops = {
@@ -1289,8 +1286,8 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1289 int err; 1286 int err;
1290 int i; 1287 int i;
1291 1288
1292 dev = kzalloc(sizeof(*dev),GFP_KERNEL); 1289 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1293 if (NULL == dev) 1290 if (dev == NULL)
1294 return -ENOMEM; 1291 return -ENOMEM;
1295 1292
1296 /* pci init */ 1293 /* pci init */
@@ -1300,7 +1297,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1300 goto fail_free; 1297 goto fail_free;
1301 } 1298 }
1302 core = cx88_core_get(dev->pci); 1299 core = cx88_core_get(dev->pci);
1303 if (NULL == core) { 1300 if (core == NULL) {
1304 err = -EINVAL; 1301 err = -EINVAL;
1305 goto fail_free; 1302 goto fail_free;
1306 } 1303 }
@@ -1315,7 +1312,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1315 (unsigned long long)pci_resource_start(pci_dev, 0)); 1312 (unsigned long long)pci_resource_start(pci_dev, 0));
1316 1313
1317 pci_set_master(pci_dev); 1314 pci_set_master(pci_dev);
1318 err = pci_set_dma_mask(pci_dev,DMA_BIT_MASK(32)); 1315 err = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
1319 if (err) { 1316 if (err) {
1320 pr_err("Oops: no 32bit PCI DMA ???\n"); 1317 pr_err("Oops: no 32bit PCI DMA ???\n");
1321 goto fail_core; 1318 goto fail_core;
@@ -1524,7 +1521,7 @@ fail_unreg:
1524 mutex_unlock(&core->lock); 1521 mutex_unlock(&core->lock);
1525fail_core: 1522fail_core:
1526 core->v4ldev = NULL; 1523 core->v4ldev = NULL;
1527 cx88_core_put(core,dev->pci); 1524 cx88_core_put(core, dev->pci);
1528fail_free: 1525fail_free:
1529 kfree(dev); 1526 kfree(dev);
1530 return err; 1527 return err;
@@ -1555,7 +1552,7 @@ static void cx8800_finidev(struct pci_dev *pci_dev)
1555 core->v4ldev = NULL; 1552 core->v4ldev = NULL;
1556 1553
1557 /* free memory */ 1554 /* free memory */
1558 cx88_core_put(core,dev->pci); 1555 cx88_core_put(core, dev->pci);
1559 kfree(dev); 1556 kfree(dev);
1560} 1557}
1561 1558
@@ -1584,7 +1581,7 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
1584 cx88_shutdown(core); 1581 cx88_shutdown(core);
1585 1582
1586 pci_save_state(pci_dev); 1583 pci_save_state(pci_dev);
1587 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 1584 if (pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)) != 0) {
1588 pci_disable_device(pci_dev); 1585 pci_disable_device(pci_dev);
1589 dev->state.disabled = 1; 1586 dev->state.disabled = 1;
1590 } 1587 }
@@ -1599,7 +1596,7 @@ static int cx8800_resume(struct pci_dev *pci_dev)
1599 int err; 1596 int err;
1600 1597
1601 if (dev->state.disabled) { 1598 if (dev->state.disabled) {
1602 err=pci_enable_device(pci_dev); 1599 err = pci_enable_device(pci_dev);
1603 if (err) { 1600 if (err) {
1604 pr_err("can't enable device\n"); 1601 pr_err("can't enable device\n");
1605 return err; 1602 return err;
@@ -1607,7 +1604,7 @@ static int cx8800_resume(struct pci_dev *pci_dev)
1607 1604
1608 dev->state.disabled = 0; 1605 dev->state.disabled = 0;
1609 } 1606 }
1610 err= pci_set_power_state(pci_dev, PCI_D0); 1607 err = pci_set_power_state(pci_dev, PCI_D0);
1611 if (err) { 1608 if (err) {
1612 pr_err("can't set power state\n"); 1609 pr_err("can't set power state\n");
1613 pci_disable_device(pci_dev); 1610 pci_disable_device(pci_dev);
@@ -1628,11 +1625,11 @@ static int cx8800_resume(struct pci_dev *pci_dev)
1628 spin_lock_irqsave(&dev->slock, flags); 1625 spin_lock_irqsave(&dev->slock, flags);
1629 if (!list_empty(&dev->vidq.active)) { 1626 if (!list_empty(&dev->vidq.active)) {
1630 pr_info("resume video\n"); 1627 pr_info("resume video\n");
1631 restart_video_queue(dev,&dev->vidq); 1628 restart_video_queue(dev, &dev->vidq);
1632 } 1629 }
1633 if (!list_empty(&dev->vbiq.active)) { 1630 if (!list_empty(&dev->vbiq.active)) {
1634 pr_info("resume vbi\n"); 1631 pr_info("resume vbi\n");
1635 cx8800_restart_vbi_queue(dev,&dev->vbiq); 1632 cx8800_restart_vbi_queue(dev, &dev->vbiq);
1636 } 1633 }
1637 spin_unlock_irqrestore(&dev->slock, flags); 1634 spin_unlock_irqrestore(&dev->slock, flags);
1638 1635
@@ -1648,7 +1645,7 @@ static const struct pci_device_id cx8800_pci_tbl[] = {
1648 .device = 0x8800, 1645 .device = 0x8800,
1649 .subvendor = PCI_ANY_ID, 1646 .subvendor = PCI_ANY_ID,
1650 .subdevice = PCI_ANY_ID, 1647 .subdevice = PCI_ANY_ID,
1651 },{ 1648 }, {
1652 /* --- end of list --- */ 1649 /* --- end of list --- */
1653 } 1650 }
1654}; 1651};
diff --git a/drivers/media/pci/cx88/cx88-vp3054-i2c.c b/drivers/media/pci/cx88/cx88-vp3054-i2c.c
index 4f47ea2ae344..eea56ae9071e 100644
--- a/drivers/media/pci/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/pci/cx88/cx88-vp3054-i2c.c
@@ -1,26 +1,20 @@
1/* 1/*
2 2 * cx88-vp3054-i2c.c -- support for the secondary I2C bus of the
3 cx88-vp3054-i2c.c -- support for the secondary I2C bus of the 3 * DNTV Live! DVB-T Pro (VP-3054), wired as:
4 DNTV Live! DVB-T Pro (VP-3054), wired as: 4 * GPIO[0] -> SCL, GPIO[1] -> SDA
5 GPIO[0] -> SCL, GPIO[1] -> SDA 5 *
6 6 * (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
7 (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> 7 *
8 8 * This program is free software; you can redistribute it and/or modify
9 This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by
10 it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or
11 the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version.
12 (at your option) any later version. 12 *
13 13 * This program is distributed in the hope that it will be useful,
14 This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details.
17 GNU General Public License for more details. 17 */
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23*/
24 18
25#include "cx88.h" 19#include "cx88.h"
26#include "cx88-vp3054-i2c.h" 20#include "cx88-vp3054-i2c.h"
@@ -128,11 +122,11 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
128 i2c_set_adapdata(&vp3054_i2c->adap, dev); 122 i2c_set_adapdata(&vp3054_i2c->adap, dev);
129 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; 123 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo;
130 124
131 vp3054_bit_setscl(dev,1); 125 vp3054_bit_setscl(dev, 1);
132 vp3054_bit_setsda(dev,1); 126 vp3054_bit_setsda(dev, 1);
133 127
134 rc = i2c_bit_add_bus(&vp3054_i2c->adap); 128 rc = i2c_bit_add_bus(&vp3054_i2c->adap);
135 if (0 != rc) { 129 if (rc != 0) {
136 pr_err("vp3054_i2c register FAILED\n"); 130 pr_err("vp3054_i2c register FAILED\n");
137 131
138 kfree(dev->vp3054); 132 kfree(dev->vp3054);
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 01c1287baf93..ac1fb9fb340e 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef CX88_H 18#ifndef CX88_H
@@ -58,7 +54,7 @@
58/* defines and enums */ 54/* defines and enums */
59 55
60/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM/LC */ 56/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM/LC */
61#define CX88_NORMS (V4L2_STD_ALL \ 57#define CX88_NORMS (V4L2_STD_ALL \
62 & ~V4L2_STD_PAL_H \ 58 & ~V4L2_STD_PAL_H \
63 & ~V4L2_STD_NTSC_M_KR \ 59 & ~V4L2_STD_NTSC_M_KR \
64 & ~V4L2_STD_SECAM_LC) 60 & ~V4L2_STD_SECAM_LC)
@@ -366,12 +362,12 @@ struct cx88_core {
366 u32 i2c_state, i2c_rc; 362 u32 i2c_state, i2c_rc;
367 363
368 /* config info -- analog */ 364 /* config info -- analog */
369 struct v4l2_device v4l2_dev; 365 struct v4l2_device v4l2_dev;
370 struct v4l2_ctrl_handler video_hdl; 366 struct v4l2_ctrl_handler video_hdl;
371 struct v4l2_ctrl *chroma_agc; 367 struct v4l2_ctrl *chroma_agc;
372 struct v4l2_ctrl_handler audio_hdl; 368 struct v4l2_ctrl_handler audio_hdl;
373 struct v4l2_subdev *sd_wm8775; 369 struct v4l2_subdev *sd_wm8775;
374 struct i2c_client *i2c_rtc; 370 struct i2c_client *i2c_rtc;
375 unsigned int boardnr; 371 unsigned int boardnr;
376 struct cx88_board board; 372 struct cx88_board board;
377 373
@@ -388,8 +384,8 @@ struct cx88_core {
388 /* state info */ 384 /* state info */
389 struct task_struct *kthread; 385 struct task_struct *kthread;
390 v4l2_std_id tvnorm; 386 v4l2_std_id tvnorm;
391 unsigned width, height; 387 unsigned int width, height;
392 unsigned field; 388 unsigned int field;
393 enum cx88_tvaudio tvaudio; 389 enum cx88_tvaudio tvaudio;
394 u32 audiomode_manual; 390 u32 audiomode_manual;
395 u32 audiomode_current; 391 u32 audiomode_current;
@@ -489,7 +485,7 @@ struct cx8800_dev {
489 485
490 /* pci i/o */ 486 /* pci i/o */
491 struct pci_dev *pci; 487 struct pci_dev *pci;
492 unsigned char pci_rev,pci_lat; 488 unsigned char pci_rev, pci_lat;
493 489
494 const struct cx8800_fmt *fmt; 490 const struct cx8800_fmt *fmt;
495 491
@@ -552,7 +548,7 @@ struct cx8802_dev {
552 548
553 /* pci i/o */ 549 /* pci i/o */
554 struct pci_dev *pci; 550 struct pci_dev *pci;
555 unsigned char pci_rev,pci_lat; 551 unsigned char pci_rev, pci_lat;
556 552
557 /* dma queues */ 553 /* dma queues */
558 struct cx88_dmaqueue mpegq; 554 struct cx88_dmaqueue mpegq;
@@ -594,23 +590,23 @@ struct cx8802_dev {
594/* ----------------------------------------------------------- */ 590/* ----------------------------------------------------------- */
595 591
596#define cx_read(reg) readl(core->lmmio + ((reg)>>2)) 592#define cx_read(reg) readl(core->lmmio + ((reg)>>2))
597#define cx_write(reg,value) writel((value), core->lmmio + ((reg)>>2)) 593#define cx_write(reg, value) writel((value), core->lmmio + ((reg)>>2))
598#define cx_writeb(reg,value) writeb((value), core->bmmio + (reg)) 594#define cx_writeb(reg, value) writeb((value), core->bmmio + (reg))
599 595
600#define cx_andor(reg,mask,value) \ 596#define cx_andor(reg, mask, value) \
601 writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\ 597 writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\
602 ((value) & (mask)), core->lmmio+((reg)>>2)) 598 ((value) & (mask)), core->lmmio+((reg)>>2))
603#define cx_set(reg,bit) cx_andor((reg),(bit),(bit)) 599#define cx_set(reg, bit) cx_andor((reg), (bit), (bit))
604#define cx_clear(reg,bit) cx_andor((reg),(bit),0) 600#define cx_clear(reg, bit) cx_andor((reg), (bit), 0)
605 601
606#define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); } 602#define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); }
607 603
608/* shadow registers */ 604/* shadow registers */
609#define cx_sread(sreg) (core->shadow[sreg]) 605#define cx_sread(sreg) (core->shadow[sreg])
610#define cx_swrite(sreg,reg,value) \ 606#define cx_swrite(sreg, reg, value) \
611 (core->shadow[sreg] = value, \ 607 (core->shadow[sreg] = value, \
612 writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) 608 writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
613#define cx_sandor(sreg,reg,mask,value) \ 609#define cx_sandor(sreg, reg, mask, value) \
614 (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \ 610 (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \
615 writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) 611 writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
616 612
@@ -667,7 +663,7 @@ extern int cx88_stop_audio_dma(struct cx88_core *core);
667/* cx88-vbi.c */ 663/* cx88-vbi.c */
668 664
669/* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */ 665/* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */
670int cx8800_vbi_fmt (struct file *file, void *priv, 666int cx8800_vbi_fmt(struct file *file, void *priv,
671 struct v4l2_format *f); 667 struct v4l2_format *f);
672 668
673/* 669/*
@@ -708,7 +704,8 @@ int cx8802_register_driver(struct cx8802_driver *drv);
708int cx8802_unregister_driver(struct cx8802_driver *drv); 704int cx8802_unregister_driver(struct cx8802_driver *drv);
709 705
710/* Caller must hold core->lock */ 706/* Caller must hold core->lock */
711struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); 707struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev,
708 enum cx88_board_type btype);
712 709
713/* ----------------------------------------------------------- */ 710/* ----------------------------------------------------------- */
714/* cx88-dsp.c */ 711/* cx88-dsp.c */