diff options
author | Antonio Ospite <ospite@studenti.unina.it> | 2009-12-02 04:18:46 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-15 21:18:00 -0500 |
commit | 28ffe77fe2faea6658870818fd0593f1a03cc018 (patch) | |
tree | b46ee20c5f1635c4ed31cba569d48772137f4591 /drivers/media/video | |
parent | 7bd330b44eb92b8e5ae265ab447cd317290c7aee (diff) |
V4L/DVB (13564): gspca - main: Implement vidioc_enum_frameintervals.
Some drivers support multiple frameintervals (framerates), make gspca able to
enumerate them.
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/gspca/gspca.c | 29 | ||||
-rw-r--r-- | drivers/media/video/gspca/gspca.h | 9 |
2 files changed, 38 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index 0a99a21f265b..e6e8df484851 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -982,6 +982,34 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, | |||
982 | return -EINVAL; | 982 | return -EINVAL; |
983 | } | 983 | } |
984 | 984 | ||
985 | static int vidioc_enum_frameintervals(struct file *filp, void *priv, | ||
986 | struct v4l2_frmivalenum *fival) | ||
987 | { | ||
988 | struct gspca_dev *gspca_dev = priv; | ||
989 | int mode = wxh_to_mode(gspca_dev, fival->width, fival->height); | ||
990 | __u32 i; | ||
991 | |||
992 | if (gspca_dev->cam.mode_framerates == NULL || | ||
993 | gspca_dev->cam.mode_framerates[mode].nrates == 0) | ||
994 | return -EINVAL; | ||
995 | |||
996 | if (fival->pixel_format != | ||
997 | gspca_dev->cam.cam_mode[mode].pixelformat) | ||
998 | return -EINVAL; | ||
999 | |||
1000 | for (i = 0; i < gspca_dev->cam.mode_framerates[mode].nrates; i++) { | ||
1001 | if (fival->index == i) { | ||
1002 | fival->type = V4L2_FRMSIZE_TYPE_DISCRETE; | ||
1003 | fival->discrete.numerator = 1; | ||
1004 | fival->discrete.denominator = | ||
1005 | gspca_dev->cam.mode_framerates[mode].rates[i]; | ||
1006 | return 0; | ||
1007 | } | ||
1008 | } | ||
1009 | |||
1010 | return -EINVAL; | ||
1011 | } | ||
1012 | |||
985 | static void gspca_release(struct video_device *vfd) | 1013 | static void gspca_release(struct video_device *vfd) |
986 | { | 1014 | { |
987 | struct gspca_dev *gspca_dev = container_of(vfd, struct gspca_dev, vdev); | 1015 | struct gspca_dev *gspca_dev = container_of(vfd, struct gspca_dev, vdev); |
@@ -1973,6 +2001,7 @@ static const struct v4l2_ioctl_ops dev_ioctl_ops = { | |||
1973 | .vidioc_g_parm = vidioc_g_parm, | 2001 | .vidioc_g_parm = vidioc_g_parm, |
1974 | .vidioc_s_parm = vidioc_s_parm, | 2002 | .vidioc_s_parm = vidioc_s_parm, |
1975 | .vidioc_enum_framesizes = vidioc_enum_framesizes, | 2003 | .vidioc_enum_framesizes = vidioc_enum_framesizes, |
2004 | .vidioc_enum_frameintervals = vidioc_enum_frameintervals, | ||
1976 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 2005 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1977 | .vidioc_g_register = vidioc_g_register, | 2006 | .vidioc_g_register = vidioc_g_register, |
1978 | .vidioc_s_register = vidioc_s_register, | 2007 | .vidioc_s_register = vidioc_s_register, |
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index 181617355ec3..a55c0a04ecf7 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h | |||
@@ -45,11 +45,20 @@ extern int gspca_debug; | |||
45 | /* image transfers */ | 45 | /* image transfers */ |
46 | #define MAX_NURBS 4 /* max number of URBs */ | 46 | #define MAX_NURBS 4 /* max number of URBs */ |
47 | 47 | ||
48 | |||
49 | /* used to list framerates supported by a camera mode (resolution) */ | ||
50 | struct framerates { | ||
51 | int *rates; | ||
52 | int nrates; | ||
53 | }; | ||
54 | |||
48 | /* device information - set at probe time */ | 55 | /* device information - set at probe time */ |
49 | struct cam { | 56 | struct cam { |
50 | int bulk_size; /* buffer size when image transfer by bulk */ | 57 | int bulk_size; /* buffer size when image transfer by bulk */ |
51 | const struct v4l2_pix_format *cam_mode; /* size nmodes */ | 58 | const struct v4l2_pix_format *cam_mode; /* size nmodes */ |
52 | char nmodes; | 59 | char nmodes; |
60 | const struct framerates *mode_framerates; /* must have size nmode, | ||
61 | * just like cam_mode */ | ||
53 | __u8 bulk_nurbs; /* number of URBs in bulk mode | 62 | __u8 bulk_nurbs; /* number of URBs in bulk mode |
54 | * - cannot be > MAX_NURBS | 63 | * - cannot be > MAX_NURBS |
55 | * - when 0 and bulk_size != 0 means | 64 | * - when 0 and bulk_size != 0 means |