Commit c876a346 authored by Thierry MERLE's avatar Thierry MERLE Committed by Mauro Carvalho Chehab

V4L/DVB (4953): Usbvision minor fixes

- fix debug outputs
- fix returned parameters on VIDIOC_G_FMT, VIDIOC_S_FMT and 
  VIDIOC_TRY_FMT and mmap size setting
Signed-off-by: default avatarThierry MERLE <thierry.merle@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent f30ebd43
...@@ -87,6 +87,7 @@ MODULE_PARM_DESC(SwitchSVideoInput, " Set the S-Video input. Some cables and in ...@@ -87,6 +87,7 @@ MODULE_PARM_DESC(SwitchSVideoInput, " Set the S-Video input. Some cables and in
#define DBG_ISOC 1<<2 #define DBG_ISOC 1<<2
#define DBG_PARSE 1<<3 #define DBG_PARSE 1<<3
#define DBG_SCRATCH 1<<4 #define DBG_SCRATCH 1<<4
#define DBG_FUNC 1<<5
static const int max_imgwidth = MAX_FRAME_WIDTH; static const int max_imgwidth = MAX_FRAME_WIDTH;
static const int max_imgheight = MAX_FRAME_HEIGHT; static const int max_imgheight = MAX_FRAME_HEIGHT;
......
...@@ -92,8 +92,6 @@ ...@@ -92,8 +92,6 @@
#define ENABLE_HEXDUMP 0 /* Enable if you need it */ #define ENABLE_HEXDUMP 0 /* Enable if you need it */
#define USBVISION_DEBUG /* Turn on debug messages */
#ifdef USBVISION_DEBUG #ifdef USBVISION_DEBUG
#define PDEBUG(level, fmt, args...) \ #define PDEBUG(level, fmt, args...) \
if (video_debug & (level)) info("[%s:%d] " fmt, __PRETTY_FUNCTION__, __LINE__ , ## args) if (video_debug & (level)) info("[%s:%d] " fmt, __PRETTY_FUNCTION__, __LINE__ , ## args)
...@@ -104,7 +102,7 @@ ...@@ -104,7 +102,7 @@
#define DBG_IOCTL 1<<0 #define DBG_IOCTL 1<<0
#define DBG_IO 1<<1 #define DBG_IO 1<<1
#define DBG_PROBE 1<<2 #define DBG_PROBE 1<<2
#define DBG_FUNC 1<<3 #define DBG_MMAP 1<<3
//String operations //String operations
#define rmspace(str) while(*str==' ') str++; #define rmspace(str) while(*str==' ') str++;
...@@ -821,7 +819,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, ...@@ -821,7 +819,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
vb->memory = V4L2_MEMORY_MMAP; vb->memory = V4L2_MEMORY_MMAP;
vb->field = V4L2_FIELD_NONE; vb->field = V4L2_FIELD_NONE;
vb->length = usbvision->max_frame_size; vb->length = usbvision->curwidth*usbvision->curheight*usbvision->palette.bytes_per_pixel;
vb->timestamp = usbvision->frame[vb->index].timestamp; vb->timestamp = usbvision->frame[vb->index].timestamp;
vb->sequence = usbvision->frame[vb->index].sequence; vb->sequence = usbvision->frame[vb->index].sequence;
return 0; return 0;
...@@ -959,13 +957,14 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, ...@@ -959,13 +957,14 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline*usbvision->curheight; vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline*usbvision->curheight;
vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */ vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */
PDEBUG(DBG_IOCTL, "VIDIOC_G_FMT w=%d, h=%d, format=%s",
vf->fmt.pix.width, vf->fmt.pix.height,usbvision->palette.desc);
return 0;
} }
return 0;
default: default:
PDEBUG(DBG_IOCTL, "VIDIOC_G_FMT invalid type %d",vf->type); PDEBUG(DBG_IOCTL, "VIDIOC_G_FMT invalid type %d",vf->type);
return -EINVAL; return -EINVAL;
} }
PDEBUG(DBG_IOCTL, "VIDIOC_G_FMT w=%d, h=%d",vf->fmt.win.w.width, vf->fmt.win.w.height);
return 0; return 0;
} }
case VIDIOC_TRY_FMT: case VIDIOC_TRY_FMT:
...@@ -991,6 +990,15 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, ...@@ -991,6 +990,15 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH); RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH);
RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT); RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
vf->fmt.pix.bytesperline = vf->fmt.pix.width*usbvision->palette.bytes_per_pixel;
vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline*vf->fmt.pix.height;
if(cmd == VIDIOC_TRY_FMT) {
PDEBUG(DBG_IOCTL, "VIDIOC_TRY_FMT grabdisplay w=%d, h=%d, format=%s",
vf->fmt.pix.width, vf->fmt.pix.height,usbvision->palette.desc);
return 0;
}
/* stop io in case it is already in progress */ /* stop io in case it is already in progress */
if(usbvision->streaming == Stream_On) { if(usbvision->streaming == Stream_On) {
if ((ret = usbvision_stream_interrupt(usbvision))) if ((ret = usbvision_stream_interrupt(usbvision)))
...@@ -1133,7 +1141,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1133,7 +1141,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
} }
if (!(vma->vm_flags & VM_WRITE) || if (!(vma->vm_flags & VM_WRITE) ||
size != PAGE_ALIGN(usbvision->max_frame_size)) { size != PAGE_ALIGN(usbvision->curwidth*usbvision->curheight*usbvision->palette.bytes_per_pixel)) {
up(&usbvision->lock); up(&usbvision->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1143,7 +1151,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1143,7 +1151,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
break; break;
} }
if (i == USBVISION_NUMFRAMES) { if (i == USBVISION_NUMFRAMES) {
PDEBUG(DBG_FUNC, "mmap: user supplied mapping address is out of range"); PDEBUG(DBG_MMAP, "mmap: user supplied mapping address is out of range");
up(&usbvision->lock); up(&usbvision->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1156,7 +1164,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1156,7 +1164,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
while (size > 0) { while (size > 0) {
if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
PDEBUG(DBG_FUNC, "mmap: vm_insert_page failed"); PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed");
up(&usbvision->lock); up(&usbvision->lock);
return -EAGAIN; return -EAGAIN;
} }
...@@ -2003,7 +2011,7 @@ static int __init usbvision_init(void) ...@@ -2003,7 +2011,7 @@ static int __init usbvision_init(void)
PDEBUG(DBG_IOCTL, "IOCTL debugging is enabled [video]"); PDEBUG(DBG_IOCTL, "IOCTL debugging is enabled [video]");
PDEBUG(DBG_IO, "IO debugging is enabled [video]"); PDEBUG(DBG_IO, "IO debugging is enabled [video]");
PDEBUG(DBG_PROBE, "PROBE debugging is enabled [video]"); PDEBUG(DBG_PROBE, "PROBE debugging is enabled [video]");
PDEBUG(DBG_FUNC, "FUNC debugging is enabled [video]"); PDEBUG(DBG_MMAP, "MMAP debugging is enabled [video]");
/* disable planar mode support unless compression enabled */ /* disable planar mode support unless compression enabled */
if (isocMode != ISOC_MODE_COMPRESS ) { if (isocMode != ISOC_MODE_COMPRESS ) {
......
...@@ -3,9 +3,14 @@ ...@@ -3,9 +3,14 @@
* usbvision header file * usbvision header file
* *
* Copyright (c) 1999-2005 Joerg Heckenbach <joerg@heckenbach-aw.de> * Copyright (c) 1999-2005 Joerg Heckenbach <joerg@heckenbach-aw.de>
* Dwaine Garden <dwainegarden@rogers.com>
*
*
* Report problems to v4l MailingList : http://www.redhat.com/mailman/listinfo/video4linux-list
* *
* This module is part of usbvision driver project. * This module is part of usbvision driver project.
* Updates to driver completed by Dwaine P. Garden * Updates to driver completed by Dwaine P. Garden
* v4l2 conversion by Thierry Merle <thierry.merle@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -32,6 +37,8 @@ ...@@ -32,6 +37,8 @@
#include <media/tuner.h> #include <media/tuner.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#define USBVISION_DEBUG /* Turn on debug messages */
#ifndef VID_HARDWARE_USBVISION #ifndef VID_HARDWARE_USBVISION
#define VID_HARDWARE_USBVISION 34 /* USBVision Video Grabber */ #define VID_HARDWARE_USBVISION 34 /* USBVision Video Grabber */
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment