aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c83
1 files changed, 38 insertions, 45 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 575472f1e702..882796e84dbc 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -49,7 +49,7 @@
49 "Sascha Sommer <saschasommer@freenet.de>" 49 "Sascha Sommer <saschasommer@freenet.de>"
50 50
51#define DRIVER_DESC "Empia em28xx based USB video device driver" 51#define DRIVER_DESC "Empia em28xx based USB video device driver"
52#define EM28XX_VERSION_CODE KERNEL_VERSION(0, 1, 1) 52#define EM28XX_VERSION_CODE KERNEL_VERSION(0, 1, 2)
53 53
54#define em28xx_videodbg(fmt, arg...) do {\ 54#define em28xx_videodbg(fmt, arg...) do {\
55 if (video_debug) \ 55 if (video_debug) \
@@ -400,7 +400,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
400 f.frequency = dev->ctl_freq; 400 f.frequency = dev->ctl_freq;
401 f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 401 f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
402 402
403 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); 403 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
404 404
405 return 0; 405 return 0;
406} 406}
@@ -515,10 +515,6 @@ static struct videobuf_queue_ops em28xx_video_qops = {
515 515
516static void video_mux(struct em28xx *dev, int index) 516static void video_mux(struct em28xx *dev, int index)
517{ 517{
518 struct v4l2_routing route;
519
520 route.input = INPUT(index)->vmux;
521 route.output = 0;
522 dev->ctl_input = index; 518 dev->ctl_input = index;
523 dev->ctl_ainput = INPUT(index)->amux; 519 dev->ctl_ainput = INPUT(index)->amux;
524 dev->ctl_aoutput = INPUT(index)->aout; 520 dev->ctl_aoutput = INPUT(index)->aout;
@@ -526,25 +522,22 @@ static void video_mux(struct em28xx *dev, int index)
526 if (!dev->ctl_aoutput) 522 if (!dev->ctl_aoutput)
527 dev->ctl_aoutput = EM28XX_AOUT_MASTER; 523 dev->ctl_aoutput = EM28XX_AOUT_MASTER;
528 524
529 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); 525 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing,
526 INPUT(index)->vmux, 0, 0);
530 527
531 if (dev->board.has_msp34xx) { 528 if (dev->board.has_msp34xx) {
532 if (dev->i2s_speed) { 529 if (dev->i2s_speed) {
533 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, 530 v4l2_device_call_all(&dev->v4l2_dev, 0, audio,
534 &dev->i2s_speed); 531 s_i2s_clock_freq, dev->i2s_speed);
535 } 532 }
536 route.input = dev->ctl_ainput;
537 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
538 /* Note: this is msp3400 specific */ 533 /* Note: this is msp3400 specific */
539 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, 534 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing,
540 &route); 535 dev->ctl_ainput, MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0);
541 } 536 }
542 537
543 if (dev->board.adecoder != EM28XX_NOADECODER) { 538 if (dev->board.adecoder != EM28XX_NOADECODER) {
544 route.input = dev->ctl_ainput; 539 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing,
545 route.output = dev->ctl_aoutput; 540 dev->ctl_ainput, dev->ctl_aoutput, 0);
546 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING,
547 &route);
548 } 541 }
549 542
550 em28xx_audio_analog_set(dev); 543 em28xx_audio_analog_set(dev);
@@ -829,7 +822,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
829 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 822 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
830 823
831 em28xx_resolution_set(dev); 824 em28xx_resolution_set(dev);
832 em28xx_i2c_call_clients(dev, VIDIOC_S_STD, &dev->norm); 825 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm);
833 826
834 mutex_unlock(&dev->lock); 827 mutex_unlock(&dev->lock);
835 return 0; 828 return 0;
@@ -995,8 +988,9 @@ static int vidioc_queryctrl(struct file *file, void *priv,
995 } 988 }
996 } 989 }
997 } 990 }
991
998 mutex_lock(&dev->lock); 992 mutex_lock(&dev->lock);
999 em28xx_i2c_call_clients(dev, VIDIOC_QUERYCTRL, qc); 993 v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, qc);
1000 mutex_unlock(&dev->lock); 994 mutex_unlock(&dev->lock);
1001 995
1002 if (qc->type) 996 if (qc->type)
@@ -1020,11 +1014,11 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
1020 mutex_lock(&dev->lock); 1014 mutex_lock(&dev->lock);
1021 1015
1022 if (dev->board.has_msp34xx) 1016 if (dev->board.has_msp34xx)
1023 em28xx_i2c_call_clients(dev, VIDIOC_G_CTRL, ctrl); 1017 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl);
1024 else { 1018 else {
1025 rc = em28xx_get_ctrl(dev, ctrl); 1019 rc = em28xx_get_ctrl(dev, ctrl);
1026 if (rc < 0) { 1020 if (rc < 0) {
1027 em28xx_i2c_call_clients(dev, VIDIOC_G_CTRL, ctrl); 1021 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl);
1028 rc = 0; 1022 rc = 0;
1029 } 1023 }
1030 } 1024 }
@@ -1048,7 +1042,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1048 mutex_lock(&dev->lock); 1042 mutex_lock(&dev->lock);
1049 1043
1050 if (dev->board.has_msp34xx) 1044 if (dev->board.has_msp34xx)
1051 em28xx_i2c_call_clients(dev, VIDIOC_S_CTRL, ctrl); 1045 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl);
1052 else { 1046 else {
1053 rc = 1; 1047 rc = 1;
1054 for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { 1048 for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {
@@ -1067,7 +1061,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1067 1061
1068 /* Control not found - try to send it to the attached devices */ 1062 /* Control not found - try to send it to the attached devices */
1069 if (rc == 1) { 1063 if (rc == 1) {
1070 em28xx_i2c_call_clients(dev, VIDIOC_S_CTRL, ctrl); 1064 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl);
1071 rc = 0; 1065 rc = 0;
1072 } 1066 }
1073 1067
@@ -1092,10 +1086,9 @@ static int vidioc_g_tuner(struct file *file, void *priv,
1092 strcpy(t->name, "Tuner"); 1086 strcpy(t->name, "Tuner");
1093 1087
1094 mutex_lock(&dev->lock); 1088 mutex_lock(&dev->lock);
1095 1089 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
1096 em28xx_i2c_call_clients(dev, VIDIOC_G_TUNER, t);
1097
1098 mutex_unlock(&dev->lock); 1090 mutex_unlock(&dev->lock);
1091
1099 return 0; 1092 return 0;
1100} 1093}
1101 1094
@@ -1114,10 +1107,9 @@ static int vidioc_s_tuner(struct file *file, void *priv,
1114 return -EINVAL; 1107 return -EINVAL;
1115 1108
1116 mutex_lock(&dev->lock); 1109 mutex_lock(&dev->lock);
1117 1110 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t);
1118 em28xx_i2c_call_clients(dev, VIDIOC_S_TUNER, t);
1119
1120 mutex_unlock(&dev->lock); 1111 mutex_unlock(&dev->lock);
1112
1121 return 0; 1113 return 0;
1122} 1114}
1123 1115
@@ -1157,7 +1149,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
1157 mutex_lock(&dev->lock); 1149 mutex_lock(&dev->lock);
1158 1150
1159 dev->ctl_freq = f->frequency; 1151 dev->ctl_freq = f->frequency;
1160 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); 1152 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f);
1161 1153
1162 mutex_unlock(&dev->lock); 1154 mutex_unlock(&dev->lock);
1163 1155
@@ -1186,7 +1178,7 @@ static int vidioc_g_chip_ident(struct file *file, void *priv,
1186 chip->ident = V4L2_IDENT_NONE; 1178 chip->ident = V4L2_IDENT_NONE;
1187 chip->revision = 0; 1179 chip->revision = 0;
1188 1180
1189 em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); 1181 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_chip_ident, chip);
1190 1182
1191 return 0; 1183 return 0;
1192} 1184}
@@ -1211,7 +1203,7 @@ static int vidioc_g_register(struct file *file, void *priv,
1211 reg->size = 1; 1203 reg->size = 1;
1212 return 0; 1204 return 0;
1213 case V4L2_CHIP_MATCH_I2C_DRIVER: 1205 case V4L2_CHIP_MATCH_I2C_DRIVER:
1214 em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg); 1206 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg);
1215 return 0; 1207 return 0;
1216 case V4L2_CHIP_MATCH_I2C_ADDR: 1208 case V4L2_CHIP_MATCH_I2C_ADDR:
1217 /* Not supported yet */ 1209 /* Not supported yet */
@@ -1263,7 +1255,7 @@ static int vidioc_s_register(struct file *file, void *priv,
1263 1255
1264 return rc; 1256 return rc;
1265 case V4L2_CHIP_MATCH_I2C_DRIVER: 1257 case V4L2_CHIP_MATCH_I2C_DRIVER:
1266 em28xx_i2c_call_clients(dev, VIDIOC_DBG_S_REGISTER, reg); 1258 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg);
1267 return 0; 1259 return 0;
1268 case V4L2_CHIP_MATCH_I2C_ADDR: 1260 case V4L2_CHIP_MATCH_I2C_ADDR:
1269 /* Not supported yet */ 1261 /* Not supported yet */
@@ -1406,13 +1398,13 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv,
1406 mutex_lock(&dev->lock); 1398 mutex_lock(&dev->lock);
1407 1399
1408 f->fmt.sliced.service_set = 0; 1400 f->fmt.sliced.service_set = 0;
1409 1401 v4l2_device_call_all(&dev->v4l2_dev, 0, video, g_fmt, f);
1410 em28xx_i2c_call_clients(dev, VIDIOC_G_FMT, f);
1411 1402
1412 if (f->fmt.sliced.service_set == 0) 1403 if (f->fmt.sliced.service_set == 0)
1413 rc = -EINVAL; 1404 rc = -EINVAL;
1414 1405
1415 mutex_unlock(&dev->lock); 1406 mutex_unlock(&dev->lock);
1407
1416 return rc; 1408 return rc;
1417} 1409}
1418 1410
@@ -1428,7 +1420,7 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
1428 return rc; 1420 return rc;
1429 1421
1430 mutex_lock(&dev->lock); 1422 mutex_lock(&dev->lock);
1431 em28xx_i2c_call_clients(dev, VIDIOC_G_FMT, f); 1423 v4l2_device_call_all(&dev->v4l2_dev, 0, video, g_fmt, f);
1432 mutex_unlock(&dev->lock); 1424 mutex_unlock(&dev->lock);
1433 1425
1434 if (f->fmt.sliced.service_set == 0) 1426 if (f->fmt.sliced.service_set == 0)
@@ -1532,7 +1524,7 @@ static int radio_g_tuner(struct file *file, void *priv,
1532 t->type = V4L2_TUNER_RADIO; 1524 t->type = V4L2_TUNER_RADIO;
1533 1525
1534 mutex_lock(&dev->lock); 1526 mutex_lock(&dev->lock);
1535 em28xx_i2c_call_clients(dev, VIDIOC_G_TUNER, t); 1527 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
1536 mutex_unlock(&dev->lock); 1528 mutex_unlock(&dev->lock);
1537 1529
1538 return 0; 1530 return 0;
@@ -1567,7 +1559,7 @@ static int radio_s_tuner(struct file *file, void *priv,
1567 return -EINVAL; 1559 return -EINVAL;
1568 1560
1569 mutex_lock(&dev->lock); 1561 mutex_lock(&dev->lock);
1570 em28xx_i2c_call_clients(dev, VIDIOC_S_TUNER, t); 1562 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t);
1571 mutex_unlock(&dev->lock); 1563 mutex_unlock(&dev->lock);
1572 1564
1573 return 0; 1565 return 0;
@@ -1655,7 +1647,7 @@ static int em28xx_v4l2_open(struct file *filp)
1655 } 1647 }
1656 if (fh->radio) { 1648 if (fh->radio) {
1657 em28xx_videodbg("video_open: setting radio device\n"); 1649 em28xx_videodbg("video_open: setting radio device\n");
1658 em28xx_i2c_call_clients(dev, AUDC_SET_RADIO, NULL); 1650 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio);
1659 } 1651 }
1660 1652
1661 dev->users++; 1653 dev->users++;
@@ -1738,7 +1730,7 @@ static int em28xx_v4l2_close(struct file *filp)
1738 } 1730 }
1739 1731
1740 /* Save some power by putting tuner to sleep */ 1732 /* Save some power by putting tuner to sleep */
1741 em28xx_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); 1733 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_standby);
1742 1734
1743 /* do this before setting alternate! */ 1735 /* do this before setting alternate! */
1744 em28xx_uninit_isoc(dev); 1736 em28xx_uninit_isoc(dev);
@@ -1959,11 +1951,12 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1959 vfd = video_device_alloc(); 1951 vfd = video_device_alloc();
1960 if (NULL == vfd) 1952 if (NULL == vfd)
1961 return NULL; 1953 return NULL;
1962 *vfd = *template; 1954
1963 vfd->minor = -1; 1955 *vfd = *template;
1964 vfd->parent = &dev->udev->dev; 1956 vfd->minor = -1;
1965 vfd->release = video_device_release; 1957 vfd->v4l2_dev = &dev->v4l2_dev;
1966 vfd->debug = video_debug; 1958 vfd->release = video_device_release;
1959 vfd->debug = video_debug;
1967 1960
1968 snprintf(vfd->name, sizeof(vfd->name), "%s %s", 1961 snprintf(vfd->name, sizeof(vfd->name), "%s %s",
1969 dev->name, type_name); 1962 dev->name, type_name);