V4L/DVB (10626): ivtv: fix regression in get sliced vbi format
[sfrench/cifs-2.6.git] / drivers / media / video / ivtv / ivtv-ioctl.c
index 4bae38d21ef6099cd24cc21edfc3d7d3a4a56f44..c13bd2aa0bea6180a98fe078be7449e6ea2e25ca 100644 (file)
@@ -393,7 +393,7 @@ static int ivtv_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
                return 0;
        }
 
-       itv->video_dec_func(itv, VIDIOC_G_FMT, fmt);
+       v4l2_subdev_call(itv->sd_video, video, g_fmt, fmt);
        vbifmt->service_set = ivtv_get_service_set(vbifmt);
        return 0;
 }
@@ -581,7 +581,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
        p->height = h;
        if (p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1)
                fmt->fmt.pix.width /= 2;
-       itv->video_dec_func(itv, VIDIOC_S_FMT, fmt);
+       v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt);
        return ivtv_g_fmt_vid_cap(file, fh, fmt);
 }
 
@@ -593,7 +593,7 @@ static int ivtv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f
                return -EBUSY;
        itv->vbi.sliced_in->service_set = 0;
        itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
-       itv->video_dec_func(itv, VIDIOC_S_FMT, fmt);
+       v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt);
        return ivtv_g_fmt_vbi_cap(file, fh, fmt);
 }
 
@@ -611,7 +611,7 @@ static int ivtv_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
        if (ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0)
                return -EBUSY;
        itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
-       itv->video_dec_func(itv, VIDIOC_S_FMT, fmt);
+       v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt);
        memcpy(itv->vbi.sliced_in, vbifmt, sizeof(*itv->vbi.sliced_in));
        return 0;
 }
@@ -674,29 +674,28 @@ static int ivtv_s_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_f
        return ret;
 }
 
-static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_chip_ident *chip)
+static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_dbg_chip_ident *chip)
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
 
        chip->ident = V4L2_IDENT_NONE;
        chip->revision = 0;
-       if (chip->match_type == V4L2_CHIP_MATCH_HOST) {
-               if (v4l2_chip_match_host(chip->match_type, chip->match_chip))
+       if (chip->match.type == V4L2_CHIP_MATCH_HOST) {
+               if (v4l2_chip_match_host(&chip->match))
                        chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416;
                return 0;
        }
-       if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
-               return ivtv_i2c_id(itv, chip->match_chip, VIDIOC_G_CHIP_IDENT, chip);
-       if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR)
-               return ivtv_call_i2c_client(itv, chip->match_chip, VIDIOC_G_CHIP_IDENT, chip);
-       return -EINVAL;
+       if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER &&
+           chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
+               return -EINVAL;
+       /* TODO: is this correct? */
+       return ivtv_call_all_err(itv, core, g_chip_ident, chip);
 }
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
 {
-       struct v4l2_register *regs = arg;
-       unsigned long flags;
+       struct v4l2_dbg_register *regs = arg;
        volatile u8 __iomem *reg_start;
 
        if (!capable(CAP_SYS_ADMIN))
@@ -711,35 +710,36 @@ static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
        else
                return -EINVAL;
 
-       spin_lock_irqsave(&ivtv_cards_lock, flags);
+       regs->size = 4;
        if (cmd == VIDIOC_DBG_G_REGISTER)
                regs->val = readl(regs->reg + reg_start);
        else
                writel(regs->val, regs->reg + reg_start);
-       spin_unlock_irqrestore(&ivtv_cards_lock, flags);
        return 0;
 }
 
-static int ivtv_g_register(struct file *file, void *fh, struct v4l2_register *reg)
+static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
 
-       if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
+       if (v4l2_chip_match_host(&reg->match))
                return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
-       if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
-               return ivtv_i2c_id(itv, reg->match_chip, VIDIOC_DBG_G_REGISTER, reg);
-       return ivtv_call_i2c_client(itv, reg->match_chip, VIDIOC_DBG_G_REGISTER, reg);
+       /* TODO: subdev errors should not be ignored, this should become a
+          subdev helper function. */
+       ivtv_call_all(itv, core, g_register, reg);
+       return 0;
 }
 
-static int ivtv_s_register(struct file *file, void *fh, struct v4l2_register *reg)
+static int ivtv_s_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
 
-       if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
+       if (v4l2_chip_match_host(&reg->match))
                return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
-       if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
-               return ivtv_i2c_id(itv, reg->match_chip, VIDIOC_DBG_S_REGISTER, reg);
-       return ivtv_call_i2c_client(itv, reg->match_chip, VIDIOC_DBG_S_REGISTER, reg);
+       /* TODO: subdev errors should not be ignored, this should become a
+          subdev helper function. */
+       ivtv_call_all(itv, core, s_register, reg);
+       return 0;
 }
 #endif
 
@@ -884,12 +884,6 @@ static int ivtv_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
 
        streamtype = id->type;
 
-       if (ivtv_debug & IVTV_DBGFLG_IOCTL) {
-               printk(KERN_INFO "ivtv%d ioctl: ", itv->num);
-               /* Should be replaced */
-               /* v4l_printk_ioctl(VIDIOC_S_CROP); */
-       }
-
        if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
            (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
                if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) {
@@ -1050,7 +1044,7 @@ static int ivtv_s_output(struct file *file, void *fh, unsigned int outp)
        itv->active_output = outp;
        route.input = SAA7127_INPUT_TYPE_NORMAL;
        route.output = itv->card->video_outputs[outp].video_output;
-       ivtv_saa7127(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+       ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing, &route);
 
        return 0;
 }
@@ -1062,7 +1056,7 @@ static int ivtv_g_frequency(struct file *file, void *fh, struct v4l2_frequency *
        if (vf->tuner != 0)
                return -EINVAL;
 
-       ivtv_call_i2c_clients(itv, VIDIOC_G_FREQUENCY, vf);
+       ivtv_call_all(itv, tuner, g_frequency, vf);
        return 0;
 }
 
@@ -1075,7 +1069,7 @@ int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
 
        ivtv_mute(itv);
        IVTV_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency);
-       ivtv_call_i2c_clients(itv, VIDIOC_S_FREQUENCY, vf);
+       ivtv_call_all(itv, tuner, s_frequency, vf);
        ivtv_unmute(itv);
        return 0;
 }
@@ -1123,14 +1117,14 @@ int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
        IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std);
 
        /* Tuner */
-       ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std);
+       ivtv_call_all(itv, tuner, s_std, itv->std);
 
        if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
                /* set display standard */
                itv->std_out = *std;
                itv->is_out_60hz = itv->is_60hz;
                itv->is_out_50hz = itv->is_50hz;
-               ivtv_call_i2c_clients(itv, VIDIOC_INT_S_STD_OUTPUT, &itv->std_out);
+               ivtv_call_all(itv, video, s_std_output, itv->std_out);
                ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz);
                itv->main_rect.left = itv->main_rect.top = 0;
                itv->main_rect.width = 720;
@@ -1154,7 +1148,7 @@ static int ivtv_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
        if (vt->index != 0)
                return -EINVAL;
 
-       ivtv_call_i2c_clients(itv, VIDIOC_S_TUNER, vt);
+       ivtv_call_all(itv, tuner, s_tuner, vt);
 
        return 0;
 }
@@ -1166,7 +1160,7 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
        if (vt->index != 0)
                return -EINVAL;
 
-       ivtv_call_i2c_clients(itv, VIDIOC_G_TUNER, vt);
+       ivtv_call_all(itv, tuner, g_tuner, vt);
 
        if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
                strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name));
@@ -1444,14 +1438,15 @@ static int ivtv_log_status(struct file *file, void *fh)
        struct v4l2_audio audin;
        int i;
 
-       IVTV_INFO("=================  START STATUS CARD #%d  =================\n", itv->num);
+       IVTV_INFO("=================  START STATUS CARD #%d  =================\n",
+                      itv->instance);
        IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name);
        if (itv->hw_flags & IVTV_HW_TVEEPROM) {
                struct tveeprom tv;
 
                ivtv_read_eeprom(itv, &tv);
        }
-       ivtv_call_i2c_clients(itv, VIDIOC_LOG_STATUS, NULL);
+       ivtv_call_all(itv, core, log_status);
        ivtv_get_input(itv, itv->active_input, &vidin);
        ivtv_get_audio_input(itv, itv->audio_input, &audin);
        IVTV_INFO("Video Input:  %s\n", vidin.name);
@@ -1518,7 +1513,7 @@ static int ivtv_log_status(struct file *file, void *fh)
        }
        IVTV_INFO("Tuner:  %s\n",
                test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV");
-       cx2341x_log_status(&itv->params, itv->name);
+       cx2341x_log_status(&itv->params, itv->device.name);
        IVTV_INFO("Status flags:    0x%08lx\n", itv->i_flags);
        for (i = 0; i < IVTV_MAX_STREAMS; i++) {
                struct ivtv_stream *s = &itv->streams[i];
@@ -1530,8 +1525,11 @@ static int ivtv_log_status(struct file *file, void *fh)
                                (s->buffers * s->buf_size) / 1024, s->buffers);
        }
 
-       IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n", (long long)itv->mpg_data_received, (long long)itv->vbi_data_inserted);
-       IVTV_INFO("==================  END STATUS CARD #%d  ==================\n", itv->num);
+       IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n",
+                       (long long)itv->mpg_data_received,
+                       (long long)itv->vbi_data_inserted);
+       IVTV_INFO("==================  END STATUS CARD #%d  ==================\n",
+                       itv->instance);
 
        return 0;
 }
@@ -1728,7 +1726,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
        return 0;
 }
 
-static int ivtv_default(struct file *file, void *fh, int cmd, void *arg)
+static long ivtv_default(struct file *file, void *fh, int cmd, void *arg)
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
 
@@ -1736,7 +1734,7 @@ static int ivtv_default(struct file *file, void *fh, int cmd, void *arg)
        case VIDIOC_INT_S_AUDIO_ROUTING: {
                struct v4l2_routing *route = arg;
 
-               ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, route);
+               ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, route);
                break;
        }
 
@@ -1746,10 +1744,22 @@ static int ivtv_default(struct file *file, void *fh, int cmd, void *arg)
                if ((val == 0 && itv->options.newi2c) || (val & 0x01))
                        ivtv_reset_ir_gpio(itv);
                if (val & 0x02)
-                       itv->video_dec_func(itv, cmd, NULL);
+                       v4l2_subdev_call(itv->sd_video, core, reset, 0);
                break;
        }
 
+       case IVTV_IOC_DMA_FRAME:
+       case VIDEO_GET_PTS:
+       case VIDEO_GET_FRAME_COUNT:
+       case VIDEO_GET_EVENT:
+       case VIDEO_PLAY:
+       case VIDEO_STOP:
+       case VIDEO_FREEZE:
+       case VIDEO_CONTINUE:
+       case VIDEO_COMMAND:
+       case VIDEO_TRY_COMMAND:
+               return ivtv_decoder_ioctls(file, cmd, (void *)arg);
+
        default:
                return -EINVAL;
        }
@@ -1792,18 +1802,6 @@ static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp,
                ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode);
                return 0;
 
-       case IVTV_IOC_DMA_FRAME:
-       case VIDEO_GET_PTS:
-       case VIDEO_GET_FRAME_COUNT:
-       case VIDEO_GET_EVENT:
-       case VIDEO_PLAY:
-       case VIDEO_STOP:
-       case VIDEO_FREEZE:
-       case VIDEO_CONTINUE:
-       case VIDEO_COMMAND:
-       case VIDEO_TRY_COMMAND:
-               return ivtv_decoder_ioctls(filp, cmd, (void *)arg);
-
        default:
                break;
        }
@@ -1830,7 +1828,7 @@ static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp,
 
        if (ivtv_debug & IVTV_DBGFLG_IOCTL)
                vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
-       ret = __video_ioctl2(filp, cmd, arg);
+       ret = video_ioctl2(filp, cmd, arg);
        vfd->debug = 0;
        return ret;
 }