aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-ioctl.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c73
1 files changed, 35 insertions, 38 deletions
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 4bae38d21ef6..cd990a4b81a9 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -393,7 +393,7 @@ static int ivtv_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
393 return 0; 393 return 0;
394 } 394 }
395 395
396 itv->video_dec_func(itv, VIDIOC_G_FMT, fmt); 396 v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt);
397 vbifmt->service_set = ivtv_get_service_set(vbifmt); 397 vbifmt->service_set = ivtv_get_service_set(vbifmt);
398 return 0; 398 return 0;
399} 399}
@@ -581,7 +581,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
581 p->height = h; 581 p->height = h;
582 if (p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) 582 if (p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1)
583 fmt->fmt.pix.width /= 2; 583 fmt->fmt.pix.width /= 2;
584 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt); 584 v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt);
585 return ivtv_g_fmt_vid_cap(file, fh, fmt); 585 return ivtv_g_fmt_vid_cap(file, fh, fmt);
586} 586}
587 587
@@ -593,7 +593,7 @@ static int ivtv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f
593 return -EBUSY; 593 return -EBUSY;
594 itv->vbi.sliced_in->service_set = 0; 594 itv->vbi.sliced_in->service_set = 0;
595 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; 595 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
596 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt); 596 v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt);
597 return ivtv_g_fmt_vbi_cap(file, fh, fmt); 597 return ivtv_g_fmt_vbi_cap(file, fh, fmt);
598} 598}
599 599
@@ -611,7 +611,7 @@ static int ivtv_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
611 if (ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0) 611 if (ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0)
612 return -EBUSY; 612 return -EBUSY;
613 itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; 613 itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
614 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt); 614 v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt);
615 memcpy(itv->vbi.sliced_in, vbifmt, sizeof(*itv->vbi.sliced_in)); 615 memcpy(itv->vbi.sliced_in, vbifmt, sizeof(*itv->vbi.sliced_in));
616 return 0; 616 return 0;
617} 617}
@@ -685,18 +685,17 @@ static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_chip_ident
685 chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416; 685 chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416;
686 return 0; 686 return 0;
687 } 687 }
688 if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 688 if (chip->match_type != V4L2_CHIP_MATCH_I2C_DRIVER &&
689 return ivtv_i2c_id(itv, chip->match_chip, VIDIOC_G_CHIP_IDENT, chip); 689 chip->match_type != V4L2_CHIP_MATCH_I2C_ADDR)
690 if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR) 690 return -EINVAL;
691 return ivtv_call_i2c_client(itv, chip->match_chip, VIDIOC_G_CHIP_IDENT, chip); 691 /* TODO: is this correct? */
692 return -EINVAL; 692 return ivtv_call_all_err(itv, core, g_chip_ident, chip);
693} 693}
694 694
695#ifdef CONFIG_VIDEO_ADV_DEBUG 695#ifdef CONFIG_VIDEO_ADV_DEBUG
696static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg) 696static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
697{ 697{
698 struct v4l2_register *regs = arg; 698 struct v4l2_register *regs = arg;
699 unsigned long flags;
700 volatile u8 __iomem *reg_start; 699 volatile u8 __iomem *reg_start;
701 700
702 if (!capable(CAP_SYS_ADMIN)) 701 if (!capable(CAP_SYS_ADMIN))
@@ -711,12 +710,10 @@ static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
711 else 710 else
712 return -EINVAL; 711 return -EINVAL;
713 712
714 spin_lock_irqsave(&ivtv_cards_lock, flags);
715 if (cmd == VIDIOC_DBG_G_REGISTER) 713 if (cmd == VIDIOC_DBG_G_REGISTER)
716 regs->val = readl(regs->reg + reg_start); 714 regs->val = readl(regs->reg + reg_start);
717 else 715 else
718 writel(regs->val, regs->reg + reg_start); 716 writel(regs->val, regs->reg + reg_start);
719 spin_unlock_irqrestore(&ivtv_cards_lock, flags);
720 return 0; 717 return 0;
721} 718}
722 719
@@ -726,9 +723,10 @@ static int ivtv_g_register(struct file *file, void *fh, struct v4l2_register *re
726 723
727 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 724 if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
728 return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg); 725 return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
729 if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 726 /* TODO: subdev errors should not be ignored, this should become a
730 return ivtv_i2c_id(itv, reg->match_chip, VIDIOC_DBG_G_REGISTER, reg); 727 subdev helper function. */
731 return ivtv_call_i2c_client(itv, reg->match_chip, VIDIOC_DBG_G_REGISTER, reg); 728 ivtv_call_all(itv, core, g_register, reg);
729 return 0;
732} 730}
733 731
734static int ivtv_s_register(struct file *file, void *fh, struct v4l2_register *reg) 732static int ivtv_s_register(struct file *file, void *fh, struct v4l2_register *reg)
@@ -737,9 +735,10 @@ static int ivtv_s_register(struct file *file, void *fh, struct v4l2_register *re
737 735
738 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 736 if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
739 return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg); 737 return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
740 if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 738 /* TODO: subdev errors should not be ignored, this should become a
741 return ivtv_i2c_id(itv, reg->match_chip, VIDIOC_DBG_S_REGISTER, reg); 739 subdev helper function. */
742 return ivtv_call_i2c_client(itv, reg->match_chip, VIDIOC_DBG_S_REGISTER, reg); 740 ivtv_call_all(itv, core, s_register, reg);
741 return 0;
743} 742}
744#endif 743#endif
745 744
@@ -884,12 +883,6 @@ static int ivtv_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
884 883
885 streamtype = id->type; 884 streamtype = id->type;
886 885
887 if (ivtv_debug & IVTV_DBGFLG_IOCTL) {
888 printk(KERN_INFO "ivtv%d ioctl: ", itv->num);
889 /* Should be replaced */
890 /* v4l_printk_ioctl(VIDIOC_S_CROP); */
891 }
892
893 if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && 886 if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
894 (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { 887 (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
895 if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { 888 if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) {
@@ -1050,7 +1043,7 @@ static int ivtv_s_output(struct file *file, void *fh, unsigned int outp)
1050 itv->active_output = outp; 1043 itv->active_output = outp;
1051 route.input = SAA7127_INPUT_TYPE_NORMAL; 1044 route.input = SAA7127_INPUT_TYPE_NORMAL;
1052 route.output = itv->card->video_outputs[outp].video_output; 1045 route.output = itv->card->video_outputs[outp].video_output;
1053 ivtv_saa7127(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route); 1046 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing, &route);
1054 1047
1055 return 0; 1048 return 0;
1056} 1049}
@@ -1062,7 +1055,7 @@ static int ivtv_g_frequency(struct file *file, void *fh, struct v4l2_frequency *
1062 if (vf->tuner != 0) 1055 if (vf->tuner != 0)
1063 return -EINVAL; 1056 return -EINVAL;
1064 1057
1065 ivtv_call_i2c_clients(itv, VIDIOC_G_FREQUENCY, vf); 1058 ivtv_call_all(itv, tuner, g_frequency, vf);
1066 return 0; 1059 return 0;
1067} 1060}
1068 1061
@@ -1075,7 +1068,7 @@ int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
1075 1068
1076 ivtv_mute(itv); 1069 ivtv_mute(itv);
1077 IVTV_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency); 1070 IVTV_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency);
1078 ivtv_call_i2c_clients(itv, VIDIOC_S_FREQUENCY, vf); 1071 ivtv_call_all(itv, tuner, s_frequency, vf);
1079 ivtv_unmute(itv); 1072 ivtv_unmute(itv);
1080 return 0; 1073 return 0;
1081} 1074}
@@ -1123,14 +1116,14 @@ int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
1123 IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std); 1116 IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std);
1124 1117
1125 /* Tuner */ 1118 /* Tuner */
1126 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std); 1119 ivtv_call_all(itv, tuner, s_std, itv->std);
1127 1120
1128 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { 1121 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
1129 /* set display standard */ 1122 /* set display standard */
1130 itv->std_out = *std; 1123 itv->std_out = *std;
1131 itv->is_out_60hz = itv->is_60hz; 1124 itv->is_out_60hz = itv->is_60hz;
1132 itv->is_out_50hz = itv->is_50hz; 1125 itv->is_out_50hz = itv->is_50hz;
1133 ivtv_call_i2c_clients(itv, VIDIOC_INT_S_STD_OUTPUT, &itv->std_out); 1126 ivtv_call_all(itv, video, s_std_output, itv->std_out);
1134 ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz); 1127 ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz);
1135 itv->main_rect.left = itv->main_rect.top = 0; 1128 itv->main_rect.left = itv->main_rect.top = 0;
1136 itv->main_rect.width = 720; 1129 itv->main_rect.width = 720;
@@ -1154,7 +1147,7 @@ static int ivtv_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
1154 if (vt->index != 0) 1147 if (vt->index != 0)
1155 return -EINVAL; 1148 return -EINVAL;
1156 1149
1157 ivtv_call_i2c_clients(itv, VIDIOC_S_TUNER, vt); 1150 ivtv_call_all(itv, tuner, s_tuner, vt);
1158 1151
1159 return 0; 1152 return 0;
1160} 1153}
@@ -1166,7 +1159,7 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
1166 if (vt->index != 0) 1159 if (vt->index != 0)
1167 return -EINVAL; 1160 return -EINVAL;
1168 1161
1169 ivtv_call_i2c_clients(itv, VIDIOC_G_TUNER, vt); 1162 ivtv_call_all(itv, tuner, g_tuner, vt);
1170 1163
1171 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) { 1164 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
1172 strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); 1165 strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name));
@@ -1444,14 +1437,15 @@ static int ivtv_log_status(struct file *file, void *fh)
1444 struct v4l2_audio audin; 1437 struct v4l2_audio audin;
1445 int i; 1438 int i;
1446 1439
1447 IVTV_INFO("================= START STATUS CARD #%d =================\n", itv->num); 1440 IVTV_INFO("================= START STATUS CARD #%d =================\n",
1441 itv->instance);
1448 IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name); 1442 IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name);
1449 if (itv->hw_flags & IVTV_HW_TVEEPROM) { 1443 if (itv->hw_flags & IVTV_HW_TVEEPROM) {
1450 struct tveeprom tv; 1444 struct tveeprom tv;
1451 1445
1452 ivtv_read_eeprom(itv, &tv); 1446 ivtv_read_eeprom(itv, &tv);
1453 } 1447 }
1454 ivtv_call_i2c_clients(itv, VIDIOC_LOG_STATUS, NULL); 1448 ivtv_call_all(itv, core, log_status);
1455 ivtv_get_input(itv, itv->active_input, &vidin); 1449 ivtv_get_input(itv, itv->active_input, &vidin);
1456 ivtv_get_audio_input(itv, itv->audio_input, &audin); 1450 ivtv_get_audio_input(itv, itv->audio_input, &audin);
1457 IVTV_INFO("Video Input: %s\n", vidin.name); 1451 IVTV_INFO("Video Input: %s\n", vidin.name);
@@ -1518,7 +1512,7 @@ static int ivtv_log_status(struct file *file, void *fh)
1518 } 1512 }
1519 IVTV_INFO("Tuner: %s\n", 1513 IVTV_INFO("Tuner: %s\n",
1520 test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV"); 1514 test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV");
1521 cx2341x_log_status(&itv->params, itv->name); 1515 cx2341x_log_status(&itv->params, itv->device.name);
1522 IVTV_INFO("Status flags: 0x%08lx\n", itv->i_flags); 1516 IVTV_INFO("Status flags: 0x%08lx\n", itv->i_flags);
1523 for (i = 0; i < IVTV_MAX_STREAMS; i++) { 1517 for (i = 0; i < IVTV_MAX_STREAMS; i++) {
1524 struct ivtv_stream *s = &itv->streams[i]; 1518 struct ivtv_stream *s = &itv->streams[i];
@@ -1530,8 +1524,11 @@ static int ivtv_log_status(struct file *file, void *fh)
1530 (s->buffers * s->buf_size) / 1024, s->buffers); 1524 (s->buffers * s->buf_size) / 1024, s->buffers);
1531 } 1525 }
1532 1526
1533 IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n", (long long)itv->mpg_data_received, (long long)itv->vbi_data_inserted); 1527 IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n",
1534 IVTV_INFO("================== END STATUS CARD #%d ==================\n", itv->num); 1528 (long long)itv->mpg_data_received,
1529 (long long)itv->vbi_data_inserted);
1530 IVTV_INFO("================== END STATUS CARD #%d ==================\n",
1531 itv->instance);
1535 1532
1536 return 0; 1533 return 0;
1537} 1534}
@@ -1736,7 +1733,7 @@ static int ivtv_default(struct file *file, void *fh, int cmd, void *arg)
1736 case VIDIOC_INT_S_AUDIO_ROUTING: { 1733 case VIDIOC_INT_S_AUDIO_ROUTING: {
1737 struct v4l2_routing *route = arg; 1734 struct v4l2_routing *route = arg;
1738 1735
1739 ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, route); 1736 ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, route);
1740 break; 1737 break;
1741 } 1738 }
1742 1739
@@ -1746,7 +1743,7 @@ static int ivtv_default(struct file *file, void *fh, int cmd, void *arg)
1746 if ((val == 0 && itv->options.newi2c) || (val & 0x01)) 1743 if ((val == 0 && itv->options.newi2c) || (val & 0x01))
1747 ivtv_reset_ir_gpio(itv); 1744 ivtv_reset_ir_gpio(itv);
1748 if (val & 0x02) 1745 if (val & 0x02)
1749 itv->video_dec_func(itv, cmd, NULL); 1746 v4l2_subdev_call(itv->sd_video, core, reset, 0);
1750 break; 1747 break;
1751 } 1748 }
1752 1749