]> err.no Git - linux-2.6/blobdiff - drivers/media/video/ivtv/ivtv-ioctl.c
Merge branch 'r8169-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/romieu...
[linux-2.6] / drivers / media / video / ivtv / ivtv-ioctl.c
index e1a31830e9f6c96750b8b9fc8d3b8b95f2e8a29e..52e00a7f3110e7835ac2dfea5d674eacc14486b0 100644 (file)
@@ -314,34 +314,6 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
        return 0;
 }
 
-static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
-{
-       struct v4l2_register *regs = arg;
-       unsigned long flags;
-       volatile u8 __iomem *reg_start;
-
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
-       if (regs->reg >= IVTV_REG_OFFSET && regs->reg < IVTV_REG_OFFSET + IVTV_REG_SIZE)
-               reg_start = itv->reg_mem - IVTV_REG_OFFSET;
-       else if (itv->has_cx23415 && regs->reg >= IVTV_DECODER_OFFSET &&
-                       regs->reg < IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
-               reg_start = itv->dec_mem - IVTV_DECODER_OFFSET;
-       else if (regs->reg >= 0 && regs->reg < IVTV_ENCODER_SIZE)
-               reg_start = itv->enc_mem;
-       else
-               return -EINVAL;
-
-       spin_lock_irqsave(&ivtv_cards_lock, flags);
-       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_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_format *fmt)
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
@@ -603,10 +575,6 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
 
        p->width = w;
        p->height = h;
-       if (w != 720 || h != (itv->is_50hz ? 576 : 480))
-               p->video_temporal_filter = 0;
-       else
-               p->video_temporal_filter = 8;
        if (p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1)
                fmt->fmt.pix.width /= 2;
        itv->video_dec_func(itv, VIDIOC_S_FMT, fmt);
@@ -719,6 +687,34 @@ static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_chip_ident
        return -EINVAL;
 }
 
+#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;
+       volatile u8 __iomem *reg_start;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (regs->reg >= IVTV_REG_OFFSET && regs->reg < IVTV_REG_OFFSET + IVTV_REG_SIZE)
+               reg_start = itv->reg_mem - IVTV_REG_OFFSET;
+       else if (itv->has_cx23415 && regs->reg >= IVTV_DECODER_OFFSET &&
+                       regs->reg < IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
+               reg_start = itv->dec_mem - IVTV_DECODER_OFFSET;
+       else if (regs->reg >= 0 && regs->reg < IVTV_ENCODER_SIZE)
+               reg_start = itv->enc_mem;
+       else
+               return -EINVAL;
+
+       spin_lock_irqsave(&ivtv_cards_lock, flags);
+       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)
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
@@ -740,6 +736,7 @@ static int ivtv_s_register(struct file *file, void *fh, struct v4l2_register *re
                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);
 }
+#endif
 
 static int ivtv_g_priority(struct file *file, void *fh, enum v4l2_priority *p)
 {
@@ -762,15 +759,11 @@ static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vc
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
 
-       memset(vcap, 0, sizeof(*vcap));
        strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
        strlcpy(vcap->card, itv->card_name, sizeof(vcap->card));
        strlcpy(vcap->bus_info, pci_name(itv->dev), sizeof(vcap->bus_info));
        vcap->version = IVTV_DRIVER_VERSION;        /* version */
        vcap->capabilities = itv->v4l2_cap;         /* capabilities */
-       /* reserved.. must set to 0! */
-       vcap->reserved[0] = vcap->reserved[1] =
-               vcap->reserved[2] = vcap->reserved[3] = 0;
        return 0;
 }
 
@@ -1168,7 +1161,6 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
        if (vt->index != 0)
                return -EINVAL;
 
-       memset(vt, 0, sizeof(*vt));
        ivtv_call_i2c_clients(itv, VIDIOC_G_TUNER, vt);
 
        if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
@@ -1187,11 +1179,8 @@ static int ivtv_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
        int set = itv->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
        int f, l;
-       enum v4l2_buf_type type = cap->type;
 
-       memset(cap, 0, sizeof(*cap));
-       cap->type = type;
-       if (type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
+       if (cap->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
                for (f = 0; f < 2; f++) {
                        for (l = 0; l < 24; l++) {
                                if (valid_service_line(f, l, itv->is_50hz))
@@ -1200,7 +1189,7 @@ static int ivtv_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced
                }
                return 0;
        }
-       if (type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT) {
+       if (cap->type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT) {
                if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT))
                        return -EINVAL;
                if (itv->is_60hz) {
@@ -1243,7 +1232,6 @@ static int ivtv_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd
        struct ivtv_open_id *id = fh;
        struct ivtv *itv = id->itv;
 
-       memset(&enc->raw, 0, sizeof(enc->raw));
 
        switch (enc->cmd) {
        case V4L2_ENC_CMD_START:
@@ -1295,8 +1283,6 @@ static int ivtv_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder
 {
        struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
 
-       memset(&enc->raw, 0, sizeof(enc->raw));
-
        switch (enc->cmd) {
        case V4L2_ENC_CMD_START:
                IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
@@ -1349,10 +1335,10 @@ static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
                0,
        };
 
-       memset(fb, 0, sizeof(*fb));
-
        if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
                return -EINVAL;
+       if (!itv->osd_video_pbase)
+               return -EINVAL;
 
        fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY |
                V4L2_FBUF_CAP_GLOBAL_ALPHA;
@@ -1364,7 +1350,19 @@ static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
        fb->fmt.pixelformat = pixel_format[pixfmt];
        fb->fmt.width = itv->osd_rect.width;
        fb->fmt.height = itv->osd_rect.height;
+       fb->fmt.field = V4L2_FIELD_INTERLACED;
+       fb->fmt.bytesperline = fb->fmt.width;
+       fb->fmt.colorspace = V4L2_COLORSPACE_SMPTE170M;
+       fb->fmt.field = V4L2_FIELD_INTERLACED;
+       fb->fmt.priv = 0;
+       if (fb->fmt.pixelformat != V4L2_PIX_FMT_PAL8)
+               fb->fmt.bytesperline *= 2;
+       if (fb->fmt.pixelformat == V4L2_PIX_FMT_RGB32 ||
+           fb->fmt.pixelformat == V4L2_PIX_FMT_YUV32)
+               fb->fmt.bytesperline *= 2;
+       fb->fmt.sizeimage = fb->fmt.bytesperline * fb->fmt.height;
        fb->base = (void *)itv->osd_video_pbase;
+       fb->flags = 0;
 
        if (itv->osd_chroma_key_state)
                fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY;
@@ -1405,6 +1403,8 @@ static int ivtv_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
 
        if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
                return -EINVAL;
+       if (!itv->osd_video_pbase)
+               return -EINVAL;
 
        itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0;
        itv->osd_local_alpha_state =
@@ -1412,8 +1412,7 @@ static int ivtv_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
        itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0;
        ivtv_set_osd_alpha(itv);
        yi->track_osd = (fb->flags & V4L2_FBUF_FLAG_OVERLAY) != 0;
-
-       return 0;
+       return ivtv_g_fbuf(file, fh, fb);
 }
 
 static int ivtv_overlay(struct file *file, void *fh, unsigned int on)
@@ -1549,7 +1548,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
                        return -EINVAL;
                if (itv->output_mode == OUT_UDMA_YUV && args->y_source == NULL)
                        return 0;
-               if (ivtv_claim_stream(id, id->type)) {
+               if (ivtv_start_decoding(id, id->type)) {
                        return -EBUSY;
                }
                if (ivtv_set_output_mode(itv, OUT_UDMA_YUV) != OUT_UDMA_YUV) {
@@ -1754,6 +1753,7 @@ static int ivtv_default(struct file *file, void *fh, int cmd, void *arg)
 static int ivtv_serialized_ioctl(struct ivtv *itv, struct inode *inode, struct file *filp,
                unsigned int cmd, unsigned long arg)
 {
+       struct video_device *vfd = video_devdata(filp);
        struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data;
        int ret;
 
@@ -1822,13 +1822,11 @@ static int ivtv_serialized_ioctl(struct ivtv *itv, struct inode *inode, struct f
                        return ret;
        }
 
-       if (ivtv_debug & IVTV_DBGFLG_IOCTL) {
-               printk(KERN_INFO "ivtv%d ioctl: ", itv->num);
-               v4l_printk_ioctl(cmd);
-               printk("\n");
-       }
-
-       return video_ioctl2(inode, filp, cmd, arg);
+       if (ivtv_debug & IVTV_DBGFLG_IOCTL)
+               vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
+       ret = video_ioctl2(inode, filp, cmd, arg);
+       vfd->debug = 0;
+       return ret;
 }
 
 int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
@@ -1899,13 +1897,13 @@ void ivtv_set_funcs(struct video_device *vdev)
        vdev->vidioc_try_fmt_sliced_vbi_out = ivtv_try_fmt_sliced_vbi_out;
        vdev->vidioc_g_sliced_vbi_cap       = ivtv_g_sliced_vbi_cap;
        vdev->vidioc_g_chip_ident           = ivtv_g_chip_ident;
+#ifdef CONFIG_VIDEO_ADV_DEBUG
        vdev->vidioc_g_register             = ivtv_g_register;
        vdev->vidioc_s_register             = ivtv_s_register;
+#endif
        vdev->vidioc_default                = ivtv_default;
        vdev->vidioc_queryctrl              = ivtv_queryctrl;
        vdev->vidioc_querymenu              = ivtv_querymenu;
-       vdev->vidioc_g_ctrl                 = ivtv_g_ctrl;
-       vdev->vidioc_s_ctrl                 = ivtv_s_ctrl;
        vdev->vidioc_g_ext_ctrls            = ivtv_g_ext_ctrls;
        vdev->vidioc_s_ext_ctrls            = ivtv_s_ext_ctrls;
        vdev->vidioc_try_ext_ctrls          = ivtv_try_ext_ctrls;