V4L/DVB (6021): cx88: Copy board information into card state
[deliverable/linux.git] / drivers / media / video / cx88 / cx88-core.c
index d86813be56de33fa8df22e3402ba94fa669af524..ece788bd3d551477f5c5b3996034439ae7a5dddd 100644 (file)
@@ -489,12 +489,12 @@ static char *cx88_pci_irqs[32] = {
 };
 
 void cx88_print_irqbits(char *name, char *tag, char **strings,
-                       u32 bits, u32 mask)
+                       int len, u32 bits, u32 mask)
 {
        unsigned int i;
 
        printk(KERN_DEBUG "%s: %s [0x%x]", name, tag, bits);
-       for (i = 0; i < 32; i++) {
+       for (i = 0; i < len; i++) {
                if (!(bits & (1 << i)))
                        continue;
                if (strings[i])
@@ -520,8 +520,8 @@ int cx88_core_irq(struct cx88_core *core, u32 status)
        }
        if (!handled)
                cx88_print_irqbits(core->name, "irq pci",
-                                  cx88_pci_irqs, status,
-                                  core->pci_irqmask);
+                                  cx88_pci_irqs, ARRAY_SIZE(cx88_pci_irqs),
+                                  status, core->pci_irqmask);
        return handled;
 }
 
@@ -738,7 +738,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
                value |= (1 << 15);
                value |= (1 << 16);
        }
-       if (INPUT(core->input)->type == CX88_VMUX_SVIDEO)
+       if (INPUT(core->input).type == CX88_VMUX_SVIDEO)
                value |= (1 << 13) | (1 << 5);
        if (V4L2_FIELD_INTERLACED == field)
                value |= (1 << 3); // VINT (interlaced vertical scaling)
@@ -833,7 +833,7 @@ static int set_tvaudio(struct cx88_core *core)
 {
        v4l2_std_id norm = core->tvnorm;
 
-       if (CX88_VMUX_TELEVISION != INPUT(core->input)->type)
+       if (CX88_VMUX_TELEVISION != INPUT(core->input).type)
                return 0;
 
        if (V4L2_STD_PAL_BG & norm) {
@@ -1067,7 +1067,7 @@ struct video_device *cx88_vdev_init(struct cx88_core *core,
        vfd->dev     = &pci->dev;
        vfd->release = video_device_release;
        snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
-                core->name, type, cx88_boards[core->board].name);
+                core->name, type, core->board.name);
        return vfd;
 }
 
@@ -1077,8 +1077,11 @@ static int get_ressources(struct cx88_core *core, struct pci_dev *pci)
                               pci_resource_len(pci,0),
                               core->name))
                return 0;
-       printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n",
-              core->name,(unsigned long long)pci_resource_start(pci,0));
+       printk(KERN_ERR
+              "%s/%d: Can't get MMIO memory @ 0x%llx, subsystem: %04x:%04x\n",
+              core->name, PCI_FUNC(pci->devfn),
+              (unsigned long long)pci_resource_start(pci, 0),
+              pci->subsystem_vendor, pci->subsystem_device);
        return -EBUSY;
 }
 
@@ -1115,12 +1118,6 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
        core->nr = cx88_devcount++;
        sprintf(core->name,"cx88[%d]",core->nr);
        if (0 != get_ressources(core,pci)) {
-               printk(KERN_ERR "CORE %s No more PCI ressources for "
-                       "subsystem: %04x:%04x, board: %s\n",
-                       core->name,pci->subsystem_vendor,
-                       pci->subsystem_device,
-                       cx88_boards[core->board].name);
-
                cx88_devcount--;
                goto fail_free;
        }
@@ -1133,39 +1130,34 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
        core->bmmio = (u8 __iomem *)core->lmmio;
 
        /* board config */
-       core->board = UNSET;
+       core->boardnr = UNSET;
        if (card[core->nr] < cx88_bcount)
-               core->board = card[core->nr];
-       for (i = 0; UNSET == core->board  &&  i < cx88_idcount; i++)
+               core->boardnr = card[core->nr];
+       for (i = 0; UNSET == core->boardnr  &&  i < cx88_idcount; i++)
                if (pci->subsystem_vendor == cx88_subids[i].subvendor &&
                    pci->subsystem_device == cx88_subids[i].subdevice)
-                       core->board = cx88_subids[i].card;
-       if (UNSET == core->board) {
-               core->board = CX88_BOARD_UNKNOWN;
+                       core->boardnr = cx88_subids[i].card;
+       if (UNSET == core->boardnr) {
+               core->boardnr = CX88_BOARD_UNKNOWN;
                cx88_card_list(core,pci);
        }
+
+       memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board));
+
        printk(KERN_INFO "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
                core->name,pci->subsystem_vendor,
-               pci->subsystem_device,cx88_boards[core->board].name,
-               core->board, card[core->nr] == core->board ?
+               pci->subsystem_device, core->board.name,
+               core->boardnr, card[core->nr] == core->boardnr ?
                "insmod option" : "autodetected");
 
-       core->tuner_type = tuner[core->nr];
-       core->radio_type = radio[core->nr];
-       if (UNSET == core->tuner_type)
-               core->tuner_type = cx88_boards[core->board].tuner_type;
-       if (UNSET == core->radio_type)
-               core->radio_type = cx88_boards[core->board].radio_type;
-       if (!core->tuner_addr)
-               core->tuner_addr = cx88_boards[core->board].tuner_addr;
-       if (!core->radio_addr)
-               core->radio_addr = cx88_boards[core->board].radio_addr;
+       if (tuner[core->nr] != UNSET)
+               core->board.tuner_type = tuner[core->nr];
+       if (radio[core->nr] != UNSET)
+               core->board.radio_type = radio[core->nr];
 
        printk(KERN_INFO "TV tuner %d at 0x%02x, Radio tuner %d at 0x%02x\n",
-               core->tuner_type, core->tuner_addr<<1,
-               core->radio_type, core->radio_addr<<1);
-
-       core->tda9887_conf = cx88_boards[core->board].tda9887_conf;
+               core->board.tuner_type, core->board.tuner_addr<<1,
+               core->board.radio_type, core->board.radio_addr<<1);
 
        /* init hardware */
        cx88_reset(core);
This page took 0.032808 seconds and 5 git commands to generate.