V4L/DVB (4474): On some cases, depth were not returned.
authorMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 6 Aug 2006 12:10:06 +0000 (09:10 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Tue, 26 Sep 2006 14:53:49 +0000 (11:53 -0300)
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/bt8xx/bttv-driver.c
drivers/media/video/v4l1-compat.c

index 20dff7c316eb595e2c8e9385f90ba0ad22723de9..3d7b97c661b91410b35f7fc88b7c2a08c1c4cbd1 100644 (file)
@@ -2431,6 +2431,14 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
                fbuf->bytesperline  = btv->fbuf.fmt.bytesperline;
                if (fh->ovfmt)
                        fbuf->depth = fh->ovfmt->depth;
+               else {
+                       if (fbuf->width)
+                               fbuf->depth   = ((fbuf->bytesperline<<3)
+                                                  + (fbuf->width-1) )
+                                                  /fbuf->width;
+                       else
+                               fbuf->depth = 0;
+               }
                return 0;
        }
        case VIDIOCSFBUF:
index d7c3fcbc80f7b5585d2a9463ece0f31695b566ee..1d899e2db394e62eff8f3398b005e1d37e78be3c 100644 (file)
@@ -349,6 +349,8 @@ v4l_compat_translate_ioctl(struct inode         *inode,
        {
                struct video_buffer     *buffer = arg;
 
+               memset(buffer, 0, sizeof(*buffer));
+
                err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2);
                if (err < 0) {
                        dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n",err);
@@ -361,7 +363,7 @@ v4l_compat_translate_ioctl(struct inode         *inode,
                switch (fbuf2.fmt.pixelformat) {
                case V4L2_PIX_FMT_RGB332:
                        buffer->depth = 8;
-                               break;
+                       break;
                case V4L2_PIX_FMT_RGB555:
                        buffer->depth = 15;
                        break;
@@ -377,9 +379,13 @@ v4l_compat_translate_ioctl(struct inode         *inode,
                default:
                        buffer->depth = 0;
                }
-               if (0 != fbuf2.fmt.bytesperline)
+               if (fbuf2.fmt.bytesperline) {
                        buffer->bytesperline = fbuf2.fmt.bytesperline;
-               else {
+                       if (!buffer->depth && buffer->width)
+                               buffer->depth   = ((fbuf2.fmt.bytesperline<<3)
+                                                 + (buffer->width-1) )
+                                                 /buffer->width;
+               } else {
                        buffer->bytesperline =
                                (buffer->width * buffer->depth + 7) & 7;
                        buffer->bytesperline >>= 3;