aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-video.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-video.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-video.c')
-rw-r--r--drivers/media/video/cx88/cx88-video.c63
1 files changed, 30 insertions, 33 deletions
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 58ec76be436..b0dd4313a84 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -368,17 +368,17 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
368 /* struct cx88_core *core = dev->core; */ 368 /* struct cx88_core *core = dev->core; */
369 369
370 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n", 370 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
371 input, INPUT(input)->vmux, 371 input, INPUT(input).vmux,
372 INPUT(input)->gpio0,INPUT(input)->gpio1, 372 INPUT(input).gpio0,INPUT(input).gpio1,
373 INPUT(input)->gpio2,INPUT(input)->gpio3); 373 INPUT(input).gpio2,INPUT(input).gpio3);
374 core->input = input; 374 core->input = input;
375 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input)->vmux << 14); 375 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input).vmux << 14);
376 cx_write(MO_GP3_IO, INPUT(input)->gpio3); 376 cx_write(MO_GP3_IO, INPUT(input).gpio3);
377 cx_write(MO_GP0_IO, INPUT(input)->gpio0); 377 cx_write(MO_GP0_IO, INPUT(input).gpio0);
378 cx_write(MO_GP1_IO, INPUT(input)->gpio1); 378 cx_write(MO_GP1_IO, INPUT(input).gpio1);
379 cx_write(MO_GP2_IO, INPUT(input)->gpio2); 379 cx_write(MO_GP2_IO, INPUT(input).gpio2);
380 380
381 switch (INPUT(input)->type) { 381 switch (INPUT(input).type) {
382 case CX88_VMUX_SVIDEO: 382 case CX88_VMUX_SVIDEO:
383 cx_set(MO_AFECFG_IO, 0x00000001); 383 cx_set(MO_AFECFG_IO, 0x00000001);
384 cx_set(MO_INPUT_FORMAT, 0x00010010); 384 cx_set(MO_INPUT_FORMAT, 0x00010010);
@@ -393,9 +393,9 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
393 break; 393 break;
394 } 394 }
395 395
396 if (cx88_boards[core->board].mpeg & CX88_MPEG_BLACKBIRD) { 396 if (core->board.mpeg & CX88_MPEG_BLACKBIRD) {
397 /* sets sound input from external adc */ 397 /* sets sound input from external adc */
398 if (INPUT(input)->extadc) 398 if (INPUT(input).extadc)
399 cx_set(AUD_CTL, EN_I2SIN_ENABLE); 399 cx_set(AUD_CTL, EN_I2SIN_ENABLE);
400 else 400 else
401 cx_clear(AUD_CTL, EN_I2SIN_ENABLE); 401 cx_clear(AUD_CTL, EN_I2SIN_ENABLE);
@@ -767,12 +767,11 @@ static int video_open(struct inode *inode, struct file *file)
767 fh); 767 fh);
768 768
769 if (fh->radio) { 769 if (fh->radio) {
770 int board = core->board;
771 dprintk(1,"video_open: setting radio device\n"); 770 dprintk(1,"video_open: setting radio device\n");
772 cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3); 771 cx_write(MO_GP3_IO, core->board.radio.gpio3);
773 cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0); 772 cx_write(MO_GP0_IO, core->board.radio.gpio0);
774 cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1); 773 cx_write(MO_GP1_IO, core->board.radio.gpio1);
775 cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2); 774 cx_write(MO_GP2_IO, core->board.radio.gpio2);
776 core->tvaudio = WW_FM; 775 core->tvaudio = WW_FM;
777 cx88_set_tvaudio(core); 776 cx88_set_tvaudio(core);
778 cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); 777 cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1);
@@ -1078,8 +1077,7 @@ static int vidioc_querycap (struct file *file, void *priv,
1078 struct cx88_core *core = dev->core; 1077 struct cx88_core *core = dev->core;
1079 1078
1080 strcpy(cap->driver, "cx8800"); 1079 strcpy(cap->driver, "cx8800");
1081 strlcpy(cap->card, cx88_boards[core->board].name, 1080 strlcpy(cap->card, core->board.name, sizeof(cap->card));
1082 sizeof(cap->card));
1083 sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); 1081 sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
1084 cap->version = CX88_VERSION_CODE; 1082 cap->version = CX88_VERSION_CODE;
1085 cap->capabilities = 1083 cap->capabilities =
@@ -1087,7 +1085,7 @@ static int vidioc_querycap (struct file *file, void *priv,
1087 V4L2_CAP_READWRITE | 1085 V4L2_CAP_READWRITE |
1088 V4L2_CAP_STREAMING | 1086 V4L2_CAP_STREAMING |
1089 V4L2_CAP_VBI_CAPTURE; 1087 V4L2_CAP_VBI_CAPTURE;
1090 if (UNSET != core->tuner_type) 1088 if (UNSET != core->board.tuner_type)
1091 cap->capabilities |= V4L2_CAP_TUNER; 1089 cap->capabilities |= V4L2_CAP_TUNER;
1092 return 0; 1090 return 0;
1093} 1091}
@@ -1221,14 +1219,14 @@ int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i)
1221 n = i->index; 1219 n = i->index;
1222 if (n >= 4) 1220 if (n >= 4)
1223 return -EINVAL; 1221 return -EINVAL;
1224 if (0 == INPUT(n)->type) 1222 if (0 == INPUT(n).type)
1225 return -EINVAL; 1223 return -EINVAL;
1226 memset(i,0,sizeof(*i)); 1224 memset(i,0,sizeof(*i));
1227 i->index = n; 1225 i->index = n;
1228 i->type = V4L2_INPUT_TYPE_CAMERA; 1226 i->type = V4L2_INPUT_TYPE_CAMERA;
1229 strcpy(i->name,iname[INPUT(n)->type]); 1227 strcpy(i->name,iname[INPUT(n).type]);
1230 if ((CX88_VMUX_TELEVISION == INPUT(n)->type) || 1228 if ((CX88_VMUX_TELEVISION == INPUT(n).type) ||
1231 (CX88_VMUX_CABLE == INPUT(n)->type)) 1229 (CX88_VMUX_CABLE == INPUT(n).type))
1232 i->type = V4L2_INPUT_TYPE_TUNER; 1230 i->type = V4L2_INPUT_TYPE_TUNER;
1233 i->std = CX88_NORMS; 1231 i->std = CX88_NORMS;
1234 return 0; 1232 return 0;
@@ -1297,7 +1295,7 @@ static int vidioc_g_tuner (struct file *file, void *priv,
1297 struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; 1295 struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
1298 u32 reg; 1296 u32 reg;
1299 1297
1300 if (unlikely(UNSET == core->tuner_type)) 1298 if (unlikely(UNSET == core->board.tuner_type))
1301 return -EINVAL; 1299 return -EINVAL;
1302 if (0 != t->index) 1300 if (0 != t->index)
1303 return -EINVAL; 1301 return -EINVAL;
@@ -1318,7 +1316,7 @@ static int vidioc_s_tuner (struct file *file, void *priv,
1318{ 1316{
1319 struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; 1317 struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
1320 1318
1321 if (UNSET == core->tuner_type) 1319 if (UNSET == core->board.tuner_type)
1322 return -EINVAL; 1320 return -EINVAL;
1323 if (0 != t->index) 1321 if (0 != t->index)
1324 return -EINVAL; 1322 return -EINVAL;
@@ -1333,7 +1331,7 @@ static int vidioc_g_frequency (struct file *file, void *priv,
1333 struct cx8800_fh *fh = priv; 1331 struct cx8800_fh *fh = priv;
1334 struct cx88_core *core = fh->dev->core; 1332 struct cx88_core *core = fh->dev->core;
1335 1333
1336 if (unlikely(UNSET == core->tuner_type)) 1334 if (unlikely(UNSET == core->board.tuner_type))
1337 return -EINVAL; 1335 return -EINVAL;
1338 1336
1339 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ 1337 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
@@ -1348,7 +1346,7 @@ static int vidioc_g_frequency (struct file *file, void *priv,
1348int cx88_set_freq (struct cx88_core *core, 1346int cx88_set_freq (struct cx88_core *core,
1349 struct v4l2_frequency *f) 1347 struct v4l2_frequency *f)
1350{ 1348{
1351 if (unlikely(UNSET == core->tuner_type)) 1349 if (unlikely(UNSET == core->board.tuner_type))
1352 return -EINVAL; 1350 return -EINVAL;
1353 if (unlikely(f->tuner != 0)) 1351 if (unlikely(f->tuner != 0))
1354 return -EINVAL; 1352 return -EINVAL;
@@ -1419,8 +1417,7 @@ static int radio_querycap (struct file *file, void *priv,
1419 struct cx88_core *core = dev->core; 1417 struct cx88_core *core = dev->core;
1420 1418
1421 strcpy(cap->driver, "cx8800"); 1419 strcpy(cap->driver, "cx8800");
1422 strlcpy(cap->card, cx88_boards[core->board].name, 1420 strlcpy(cap->card, core->board.name, sizeof(cap->card));
1423 sizeof(cap->card));
1424 sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci)); 1421 sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci));
1425 cap->version = CX88_VERSION_CODE; 1422 cap->version = CX88_VERSION_CODE;
1426 cap->capabilities = V4L2_CAP_TUNER; 1423 cap->capabilities = V4L2_CAP_TUNER;
@@ -1828,10 +1825,10 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1828 cx_set(MO_PCI_INTMSK, core->pci_irqmask); 1825 cx_set(MO_PCI_INTMSK, core->pci_irqmask);
1829 1826
1830 /* load and configure helper modules */ 1827 /* load and configure helper modules */
1831 if (TUNER_ABSENT != core->tuner_type) 1828 if (TUNER_ABSENT != core->board.tuner_type)
1832 request_module("tuner"); 1829 request_module("tuner");
1833 1830
1834 if (cx88_boards[ core->board ].audio_chip == AUDIO_CHIP_WM8775) 1831 if (core->board.audio_chip == AUDIO_CHIP_WM8775)
1835 request_module("wm8775"); 1832 request_module("wm8775");
1836 1833
1837 /* register v4l devices */ 1834 /* register v4l devices */
@@ -1858,7 +1855,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1858 printk(KERN_INFO "%s/0: registered device vbi%d\n", 1855 printk(KERN_INFO "%s/0: registered device vbi%d\n",
1859 core->name,dev->vbi_dev->minor & 0x1f); 1856 core->name,dev->vbi_dev->minor & 0x1f);
1860 1857
1861 if (core->has_radio) { 1858 if (core->board.radio.type == CX88_RADIO) {
1862 dev->radio_dev = cx88_vdev_init(core,dev->pci, 1859 dev->radio_dev = cx88_vdev_init(core,dev->pci,
1863 &cx8800_radio_template,"radio"); 1860 &cx8800_radio_template,"radio");
1864 err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, 1861 err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
@@ -1884,7 +1881,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1884 mutex_unlock(&core->lock); 1881 mutex_unlock(&core->lock);
1885 1882
1886 /* start tvaudio thread */ 1883 /* start tvaudio thread */
1887 if (core->tuner_type != TUNER_ABSENT) { 1884 if (core->board.tuner_type != TUNER_ABSENT) {
1888 core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); 1885 core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio");
1889 if (IS_ERR(core->kthread)) { 1886 if (IS_ERR(core->kthread)) {
1890 err = PTR_ERR(core->kthread); 1887 err = PTR_ERR(core->kthread);