diff options
author | Hans de Goede <hdegoede@redhat.com> | 2009-06-10 03:52:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 18:07:44 -0400 |
commit | a0001a289f667e254eba51f2f729ec677daba503 (patch) | |
tree | fbd62c78fbbd0c29bbb48e0b3c6e9f2839aad271 /drivers/media/video/gspca/gspca.c | |
parent | 3d48f7d09aadccf570a871ce0d5eec34092b38c1 (diff) |
V4L/DVB (11972): gspca - main: Skip disabled controls.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/gspca.c')
-rw-r--r-- | drivers/media/video/gspca/gspca.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index ae0e14033d66..f1108f1be837 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -983,43 +983,54 @@ out: | |||
983 | return ret; | 983 | return ret; |
984 | } | 984 | } |
985 | 985 | ||
986 | static const struct ctrl *get_ctrl(struct gspca_dev *gspca_dev, | ||
987 | int id) | ||
988 | { | ||
989 | const struct ctrl *ctrls; | ||
990 | int i; | ||
991 | |||
992 | for (i = 0, ctrls = gspca_dev->sd_desc->ctrls; | ||
993 | i < gspca_dev->sd_desc->nctrls; | ||
994 | i++, ctrls++) { | ||
995 | if (gspca_dev->ctrl_dis & (1 << i)) | ||
996 | continue; | ||
997 | if (id == ctrls->qctrl.id) | ||
998 | return ctrls; | ||
999 | } | ||
1000 | return NULL; | ||
1001 | } | ||
1002 | |||
986 | static int vidioc_queryctrl(struct file *file, void *priv, | 1003 | static int vidioc_queryctrl(struct file *file, void *priv, |
987 | struct v4l2_queryctrl *q_ctrl) | 1004 | struct v4l2_queryctrl *q_ctrl) |
988 | { | 1005 | { |
989 | struct gspca_dev *gspca_dev = priv; | 1006 | struct gspca_dev *gspca_dev = priv; |
990 | int i, ix; | 1007 | const struct ctrl *ctrls; |
1008 | int i; | ||
991 | u32 id; | 1009 | u32 id; |
992 | 1010 | ||
993 | ix = -1; | 1011 | ctrls = NULL; |
994 | id = q_ctrl->id; | 1012 | id = q_ctrl->id; |
995 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { | 1013 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { |
996 | id &= V4L2_CTRL_ID_MASK; | 1014 | id &= V4L2_CTRL_ID_MASK; |
997 | id++; | 1015 | id++; |
998 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | 1016 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { |
999 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id) | 1017 | if (gspca_dev->ctrl_dis & (1 << i)) |
1000 | continue; | 1018 | continue; |
1001 | if (ix < 0) { | 1019 | if (ctrls->qctrl.id < id) |
1002 | ix = i; | ||
1003 | continue; | 1020 | continue; |
1021 | if (ctrls != NULL) { | ||
1022 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id | ||
1023 | > ctrls->qctrl.id) | ||
1024 | continue; | ||
1004 | } | 1025 | } |
1005 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id | 1026 | ctrls = &gspca_dev->sd_desc->ctrls[i]; |
1006 | > gspca_dev->sd_desc->ctrls[ix].qctrl.id) | ||
1007 | continue; | ||
1008 | ix = i; | ||
1009 | } | ||
1010 | } | ||
1011 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | ||
1012 | if (id == gspca_dev->sd_desc->ctrls[i].qctrl.id) { | ||
1013 | ix = i; | ||
1014 | break; | ||
1015 | } | 1027 | } |
1028 | } else { | ||
1029 | ctrls = get_ctrl(gspca_dev, id); | ||
1016 | } | 1030 | } |
1017 | if (ix < 0) | 1031 | if (ctrls == NULL) |
1018 | return -EINVAL; | 1032 | return -EINVAL; |
1019 | memcpy(q_ctrl, &gspca_dev->sd_desc->ctrls[ix].qctrl, | 1033 | memcpy(q_ctrl, ctrls, sizeof *q_ctrl); |
1020 | sizeof *q_ctrl); | ||
1021 | if (gspca_dev->ctrl_dis & (1 << ix)) | ||
1022 | q_ctrl->flags |= V4L2_CTRL_FLAG_DISABLED; | ||
1023 | return 0; | 1034 | return 0; |
1024 | } | 1035 | } |
1025 | 1036 | ||
@@ -1028,56 +1039,45 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1028 | { | 1039 | { |
1029 | struct gspca_dev *gspca_dev = priv; | 1040 | struct gspca_dev *gspca_dev = priv; |
1030 | const struct ctrl *ctrls; | 1041 | const struct ctrl *ctrls; |
1031 | int i, ret; | 1042 | int ret; |
1032 | 1043 | ||
1033 | for (i = 0, ctrls = gspca_dev->sd_desc->ctrls; | 1044 | ctrls = get_ctrl(gspca_dev, ctrl->id); |
1034 | i < gspca_dev->sd_desc->nctrls; | 1045 | if (ctrls == NULL) |
1035 | i++, ctrls++) { | 1046 | return -EINVAL; |
1036 | if (ctrl->id != ctrls->qctrl.id) | 1047 | |
1037 | continue; | 1048 | if (ctrl->value < ctrls->qctrl.minimum |
1038 | if (gspca_dev->ctrl_dis & (1 << i)) | 1049 | || ctrl->value > ctrls->qctrl.maximum) |
1039 | return -EINVAL; | 1050 | return -ERANGE; |
1040 | if (ctrl->value < ctrls->qctrl.minimum | 1051 | PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value); |
1041 | || ctrl->value > ctrls->qctrl.maximum) | 1052 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) |
1042 | return -ERANGE; | 1053 | return -ERESTARTSYS; |
1043 | PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value); | 1054 | if (gspca_dev->present) |
1044 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) | 1055 | ret = ctrls->set(gspca_dev, ctrl->value); |
1045 | return -ERESTARTSYS; | 1056 | else |
1046 | if (gspca_dev->present) | 1057 | ret = -ENODEV; |
1047 | ret = ctrls->set(gspca_dev, ctrl->value); | 1058 | mutex_unlock(&gspca_dev->usb_lock); |
1048 | else | 1059 | return ret; |
1049 | ret = -ENODEV; | ||
1050 | mutex_unlock(&gspca_dev->usb_lock); | ||
1051 | return ret; | ||
1052 | } | ||
1053 | return -EINVAL; | ||
1054 | } | 1060 | } |
1055 | 1061 | ||
1056 | static int vidioc_g_ctrl(struct file *file, void *priv, | 1062 | static int vidioc_g_ctrl(struct file *file, void *priv, |
1057 | struct v4l2_control *ctrl) | 1063 | struct v4l2_control *ctrl) |
1058 | { | 1064 | { |
1059 | struct gspca_dev *gspca_dev = priv; | 1065 | struct gspca_dev *gspca_dev = priv; |
1060 | |||
1061 | const struct ctrl *ctrls; | 1066 | const struct ctrl *ctrls; |
1062 | int i, ret; | 1067 | int ret; |
1063 | 1068 | ||
1064 | for (i = 0, ctrls = gspca_dev->sd_desc->ctrls; | 1069 | ctrls = get_ctrl(gspca_dev, ctrl->id); |
1065 | i < gspca_dev->sd_desc->nctrls; | 1070 | if (ctrls == NULL) |
1066 | i++, ctrls++) { | 1071 | return -EINVAL; |
1067 | if (ctrl->id != ctrls->qctrl.id) | 1072 | |
1068 | continue; | 1073 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) |
1069 | if (gspca_dev->ctrl_dis & (1 << i)) | 1074 | return -ERESTARTSYS; |
1070 | return -EINVAL; | 1075 | if (gspca_dev->present) |
1071 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) | 1076 | ret = ctrls->get(gspca_dev, &ctrl->value); |
1072 | return -ERESTARTSYS; | 1077 | else |
1073 | if (gspca_dev->present) | 1078 | ret = -ENODEV; |
1074 | ret = ctrls->get(gspca_dev, &ctrl->value); | 1079 | mutex_unlock(&gspca_dev->usb_lock); |
1075 | else | 1080 | return ret; |
1076 | ret = -ENODEV; | ||
1077 | mutex_unlock(&gspca_dev->usb_lock); | ||
1078 | return ret; | ||
1079 | } | ||
1080 | return -EINVAL; | ||
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | /*fixme: have an audio flag in gspca_dev?*/ | 1083 | /*fixme: have an audio flag in gspca_dev?*/ |