aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-core.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-08-15 13:41:57 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:05:16 -0400
commit6a59d64c5cc302e0139ddb1f5e57afceecb14368 (patch)
treee3a14e27b5aca04a4069797893d59df7bc0f8f65 /drivers/media/video/cx88/cx88-core.c
parentb09a79f5848f2143a8ffc724910743027d5a70e0 (diff)
V4L/DVB (6021): cx88: Copy board information into card state
The cx88 driver state stored the ID of the board type in core->board. Every time the driver need to get some information about the board configuration, it uses the board number as an index into board configuration array. This patch changes it so that the board number is in core->boardnr, and core->board is a copy of the board configuration information. This allows access to board information without the extra indirection. e.g. cx88_boards[core->board].mpeg becomes core->board.mpeg. This has a number of advantages: - The code is simpler to write. - It compiles to be smaller and faster, without needing the extra array lookup to get at the board information. - The cx88_boards array no longer needs to be exported to all cx88 modules. - The boards array can be made const - It should be possible to avoid keeping the (large) cx88_boards array around after the module is loaded. - If module parameters or eeprom info override some board configuration setting, it's not necessary to modify the boards array, which would affect all boards of the same type. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx88/cx88-core.c')
-rw-r--r--drivers/media/video/cx88/cx88-core.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 055264b9cd61..ece788bd3d55 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -738,7 +738,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
738 value |= (1 << 15); 738 value |= (1 << 15);
739 value |= (1 << 16); 739 value |= (1 << 16);
740 } 740 }
741 if (INPUT(core->input)->type == CX88_VMUX_SVIDEO) 741 if (INPUT(core->input).type == CX88_VMUX_SVIDEO)
742 value |= (1 << 13) | (1 << 5); 742 value |= (1 << 13) | (1 << 5);
743 if (V4L2_FIELD_INTERLACED == field) 743 if (V4L2_FIELD_INTERLACED == field)
744 value |= (1 << 3); // VINT (interlaced vertical scaling) 744 value |= (1 << 3); // VINT (interlaced vertical scaling)
@@ -833,7 +833,7 @@ static int set_tvaudio(struct cx88_core *core)
833{ 833{
834 v4l2_std_id norm = core->tvnorm; 834 v4l2_std_id norm = core->tvnorm;
835 835
836 if (CX88_VMUX_TELEVISION != INPUT(core->input)->type) 836 if (CX88_VMUX_TELEVISION != INPUT(core->input).type)
837 return 0; 837 return 0;
838 838
839 if (V4L2_STD_PAL_BG & norm) { 839 if (V4L2_STD_PAL_BG & norm) {
@@ -1067,7 +1067,7 @@ struct video_device *cx88_vdev_init(struct cx88_core *core,
1067 vfd->dev = &pci->dev; 1067 vfd->dev = &pci->dev;
1068 vfd->release = video_device_release; 1068 vfd->release = video_device_release;
1069 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 1069 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
1070 core->name, type, cx88_boards[core->board].name); 1070 core->name, type, core->board.name);
1071 return vfd; 1071 return vfd;
1072} 1072}
1073 1073
@@ -1130,39 +1130,34 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1130 core->bmmio = (u8 __iomem *)core->lmmio; 1130 core->bmmio = (u8 __iomem *)core->lmmio;
1131 1131
1132 /* board config */ 1132 /* board config */
1133 core->board = UNSET; 1133 core->boardnr = UNSET;
1134 if (card[core->nr] < cx88_bcount) 1134 if (card[core->nr] < cx88_bcount)
1135 core->board = card[core->nr]; 1135 core->boardnr = card[core->nr];
1136 for (i = 0; UNSET == core->board && i < cx88_idcount; i++) 1136 for (i = 0; UNSET == core->boardnr && i < cx88_idcount; i++)
1137 if (pci->subsystem_vendor == cx88_subids[i].subvendor && 1137 if (pci->subsystem_vendor == cx88_subids[i].subvendor &&
1138 pci->subsystem_device == cx88_subids[i].subdevice) 1138 pci->subsystem_device == cx88_subids[i].subdevice)
1139 core->board = cx88_subids[i].card; 1139 core->boardnr = cx88_subids[i].card;
1140 if (UNSET == core->board) { 1140 if (UNSET == core->boardnr) {
1141 core->board = CX88_BOARD_UNKNOWN; 1141 core->boardnr = CX88_BOARD_UNKNOWN;
1142 cx88_card_list(core,pci); 1142 cx88_card_list(core,pci);
1143 } 1143 }
1144
1145 memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board));
1146
1144 printk(KERN_INFO "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", 1147 printk(KERN_INFO "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
1145 core->name,pci->subsystem_vendor, 1148 core->name,pci->subsystem_vendor,
1146 pci->subsystem_device,cx88_boards[core->board].name, 1149 pci->subsystem_device, core->board.name,
1147 core->board, card[core->nr] == core->board ? 1150 core->boardnr, card[core->nr] == core->boardnr ?
1148 "insmod option" : "autodetected"); 1151 "insmod option" : "autodetected");
1149 1152
1150 core->tuner_type = tuner[core->nr]; 1153 if (tuner[core->nr] != UNSET)
1151 core->radio_type = radio[core->nr]; 1154 core->board.tuner_type = tuner[core->nr];
1152 if (UNSET == core->tuner_type) 1155 if (radio[core->nr] != UNSET)
1153 core->tuner_type = cx88_boards[core->board].tuner_type; 1156 core->board.radio_type = radio[core->nr];
1154 if (UNSET == core->radio_type)
1155 core->radio_type = cx88_boards[core->board].radio_type;
1156 if (!core->tuner_addr)
1157 core->tuner_addr = cx88_boards[core->board].tuner_addr;
1158 if (!core->radio_addr)
1159 core->radio_addr = cx88_boards[core->board].radio_addr;
1160 1157
1161 printk(KERN_INFO "TV tuner %d at 0x%02x, Radio tuner %d at 0x%02x\n", 1158 printk(KERN_INFO "TV tuner %d at 0x%02x, Radio tuner %d at 0x%02x\n",
1162 core->tuner_type, core->tuner_addr<<1, 1159 core->board.tuner_type, core->board.tuner_addr<<1,
1163 core->radio_type, core->radio_addr<<1); 1160 core->board.radio_type, core->board.radio_addr<<1);
1164
1165 core->tda9887_conf = cx88_boards[core->board].tda9887_conf;
1166 1161
1167 /* init hardware */ 1162 /* init hardware */
1168 cx88_reset(core); 1163 cx88_reset(core);