diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-09-03 16:12:14 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-09-03 17:37:27 -0400 |
commit | f50ba1bed3cfd65d6899afc4cb77299ee5c297ae (patch) | |
tree | c3a998c560dc55ab29a3011a20a7acdb6451680e /drivers | |
parent | 221e7dbe55fe515ff786142bac64b507fa9f26de (diff) |
V4L/DVB (8814): gspca: Set DISABLED the disabled controls at query control time.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/gspca/etoms.c | 2 | ||||
-rw-r--r-- | drivers/media/video/gspca/gspca.c | 33 | ||||
-rw-r--r-- | drivers/media/video/gspca/gspca.h | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/pac7311.c | 4 | ||||
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 25 | ||||
-rw-r--r-- | drivers/media/video/gspca/vc032x.c | 3 | ||||
-rw-r--r-- | drivers/media/video/gspca/zc3xx.c | 16 |
7 files changed, 61 insertions, 23 deletions
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c index a3cccab7b814..e5a9eee673a9 100644 --- a/drivers/media/video/gspca/etoms.c +++ b/drivers/media/video/gspca/etoms.c | |||
@@ -81,6 +81,7 @@ static struct ctrl sd_ctrls[] = { | |||
81 | .set = sd_setcontrast, | 81 | .set = sd_setcontrast, |
82 | .get = sd_getcontrast, | 82 | .get = sd_getcontrast, |
83 | }, | 83 | }, |
84 | #define COLOR_IDX 2 | ||
84 | { | 85 | { |
85 | { | 86 | { |
86 | .id = V4L2_CID_SATURATION, | 87 | .id = V4L2_CID_SATURATION, |
@@ -665,6 +666,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
665 | } else { | 666 | } else { |
666 | cam->cam_mode = vga_mode; | 667 | cam->cam_mode = vga_mode; |
667 | cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; | 668 | cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; |
669 | gspca_dev->ctrl_dis = (1 << COLOR_IDX); | ||
668 | } | 670 | } |
669 | sd->brightness = BRIGHTNESS_DEF; | 671 | sd->brightness = BRIGHTNESS_DEF; |
670 | sd->contrast = CONTRAST_DEF; | 672 | sd->contrast = CONTRAST_DEF; |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index 28842ed24c09..33161e1e0bcc 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -856,37 +856,44 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
856 | return 0; | 856 | return 0; |
857 | } | 857 | } |
858 | 858 | ||
859 | /* the use of V4L2_CTRL_FLAG_NEXT_CTRL asks for the controls to be sorted */ | ||
860 | static int vidioc_queryctrl(struct file *file, void *priv, | 859 | static int vidioc_queryctrl(struct file *file, void *priv, |
861 | struct v4l2_queryctrl *q_ctrl) | 860 | struct v4l2_queryctrl *q_ctrl) |
862 | { | 861 | { |
863 | struct gspca_dev *gspca_dev = priv; | 862 | struct gspca_dev *gspca_dev = priv; |
864 | int i; | 863 | int i, ix; |
865 | u32 id; | 864 | u32 id; |
866 | 865 | ||
866 | ix = -1; | ||
867 | id = q_ctrl->id; | 867 | id = q_ctrl->id; |
868 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { | 868 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { |
869 | id &= V4L2_CTRL_ID_MASK; | 869 | id &= V4L2_CTRL_ID_MASK; |
870 | id++; | 870 | id++; |
871 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | 871 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { |
872 | if (id >= gspca_dev->sd_desc->ctrls[i].qctrl.id) { | 872 | if (id < gspca_dev->sd_desc->ctrls[i].qctrl.id) |
873 | memcpy(q_ctrl, | 873 | continue; |
874 | &gspca_dev->sd_desc->ctrls[i].qctrl, | 874 | if (ix < 0) { |
875 | sizeof *q_ctrl); | 875 | ix = i; |
876 | return 0; | 876 | continue; |
877 | } | 877 | } |
878 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id | ||
879 | > gspca_dev->sd_desc->ctrls[ix].qctrl.id) | ||
880 | continue; | ||
881 | ix = i; | ||
878 | } | 882 | } |
879 | return -EINVAL; | ||
880 | } | 883 | } |
881 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | 884 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { |
882 | if (id == gspca_dev->sd_desc->ctrls[i].qctrl.id) { | 885 | if (id == gspca_dev->sd_desc->ctrls[i].qctrl.id) { |
883 | memcpy(q_ctrl, | 886 | ix = i; |
884 | &gspca_dev->sd_desc->ctrls[i].qctrl, | 887 | break; |
885 | sizeof *q_ctrl); | ||
886 | return 0; | ||
887 | } | 888 | } |
888 | } | 889 | } |
889 | return -EINVAL; | 890 | if (ix < 0) |
891 | return -EINVAL; | ||
892 | memcpy(q_ctrl, &gspca_dev->sd_desc->ctrls[ix].qctrl, | ||
893 | sizeof *q_ctrl); | ||
894 | if (gspca_dev->ctrl_dis & (1 << ix)) | ||
895 | q_ctrl->flags |= V4L2_CTRL_FLAG_DISABLED; | ||
896 | return 0; | ||
890 | } | 897 | } |
891 | 898 | ||
892 | static int vidioc_s_ctrl(struct file *file, void *priv, | 899 | static int vidioc_s_ctrl(struct file *file, void *priv, |
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index 2596568e82fd..a804ef18b8da 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h | |||
@@ -126,6 +126,7 @@ struct gspca_dev { | |||
126 | 126 | ||
127 | struct cam cam; /* device information */ | 127 | struct cam cam; /* device information */ |
128 | const struct sd_desc *sd_desc; /* subdriver description */ | 128 | const struct sd_desc *sd_desc; /* subdriver description */ |
129 | unsigned ctrl_dis; /* disabled controls (bit map) */ | ||
129 | 130 | ||
130 | __u8 usb_buf[8]; /* buffer for USB exchanges */ | 131 | __u8 usb_buf[8]; /* buffer for USB exchanges */ |
131 | struct urb *urb[MAX_NURBS]; | 132 | struct urb *urb[MAX_NURBS]; |
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c index 3c5142852f27..69d610062d00 100644 --- a/drivers/media/video/gspca/pac7311.c +++ b/drivers/media/video/gspca/pac7311.c | |||
@@ -150,6 +150,7 @@ static struct ctrl sd_ctrls[] = { | |||
150 | .get = sd_getautogain, | 150 | .get = sd_getautogain, |
151 | }, | 151 | }, |
152 | /* next controls work with pac7302 only */ | 152 | /* next controls work with pac7302 only */ |
153 | #define HFLIP_IDX 4 | ||
153 | { | 154 | { |
154 | { | 155 | { |
155 | .id = V4L2_CID_HFLIP, | 156 | .id = V4L2_CID_HFLIP, |
@@ -164,6 +165,7 @@ static struct ctrl sd_ctrls[] = { | |||
164 | .set = sd_sethflip, | 165 | .set = sd_sethflip, |
165 | .get = sd_gethflip, | 166 | .get = sd_gethflip, |
166 | }, | 167 | }, |
168 | #define VFLIP_IDX 5 | ||
167 | { | 169 | { |
168 | { | 170 | { |
169 | .id = V4L2_CID_VFLIP, | 171 | .id = V4L2_CID_VFLIP, |
@@ -467,6 +469,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
467 | 469 | ||
468 | cam->cam_mode = vga_mode; | 470 | cam->cam_mode = vga_mode; |
469 | cam->nmodes = ARRAY_SIZE(vga_mode); | 471 | cam->nmodes = ARRAY_SIZE(vga_mode); |
472 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | ||
473 | | (1 << VFLIP_IDX); | ||
470 | } | 474 | } |
471 | 475 | ||
472 | sd->brightness = BRIGHTNESS_DEF; | 476 | sd->brightness = BRIGHTNESS_DEF; |
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 0d4677688c91..e657b8ba6db7 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -116,6 +116,7 @@ static struct ctrl sd_ctrls[] = { | |||
116 | .set = sd_setcolors, | 116 | .set = sd_setcolors, |
117 | .get = sd_getcolors, | 117 | .get = sd_getcolors, |
118 | }, | 118 | }, |
119 | #define AUTOGAIN_IDX 3 | ||
119 | { | 120 | { |
120 | { | 121 | { |
121 | .id = V4L2_CID_AUTOGAIN, | 122 | .id = V4L2_CID_AUTOGAIN, |
@@ -936,6 +937,14 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
936 | sd->autogain = AUTOGAIN_DEF; | 937 | sd->autogain = AUTOGAIN_DEF; |
937 | sd->ag_cnt = -1; | 938 | sd->ag_cnt = -1; |
938 | 939 | ||
940 | switch (sd->sensor) { | ||
941 | case SENSOR_OV7630: | ||
942 | case SENSOR_OV7648: | ||
943 | case SENSOR_OV7660: | ||
944 | gspca_dev->ctrl_dis = (1 << AUTOGAIN_IDX); | ||
945 | break; | ||
946 | } | ||
947 | |||
939 | return 0; | 948 | return 0; |
940 | } | 949 | } |
941 | 950 | ||
@@ -1150,16 +1159,12 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
1150 | { | 1159 | { |
1151 | struct sd *sd = (struct sd *) gspca_dev; | 1160 | struct sd *sd = (struct sd *) gspca_dev; |
1152 | 1161 | ||
1153 | switch (sd->sensor) { | 1162 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) |
1154 | case SENSOR_HV7131R: | 1163 | return; |
1155 | case SENSOR_MO4000: | 1164 | if (sd->autogain) |
1156 | case SENSOR_MI0360: | 1165 | sd->ag_cnt = AG_CNT_START; |
1157 | if (sd->autogain) | 1166 | else |
1158 | sd->ag_cnt = AG_CNT_START; | 1167 | sd->ag_cnt = -1; |
1159 | else | ||
1160 | sd->ag_cnt = -1; | ||
1161 | break; | ||
1162 | } | ||
1163 | } | 1168 | } |
1164 | 1169 | ||
1165 | /* -- start the camera -- */ | 1170 | /* -- start the camera -- */ |
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c index 47c7ce641d99..5454f0eb0077 100644 --- a/drivers/media/video/gspca/vc032x.c +++ b/drivers/media/video/gspca/vc032x.c | |||
@@ -69,6 +69,7 @@ static struct ctrl sd_ctrls[] = { | |||
69 | .set = sd_setautogain, | 69 | .set = sd_setautogain, |
70 | .get = sd_getautogain, | 70 | .get = sd_getautogain, |
71 | }, | 71 | }, |
72 | #define LIGHTFREQ_IDX 1 | ||
72 | { | 73 | { |
73 | { | 74 | { |
74 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 75 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
@@ -1463,6 +1464,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1463 | sd->qindex = 7; | 1464 | sd->qindex = 7; |
1464 | sd->autogain = AUTOGAIN_DEF; | 1465 | sd->autogain = AUTOGAIN_DEF; |
1465 | sd->lightfreq = FREQ_DEF; | 1466 | sd->lightfreq = FREQ_DEF; |
1467 | if (sd->sensor != SENSOR_OV7670) | ||
1468 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX); | ||
1466 | 1469 | ||
1467 | if (sd->bridge == BRIDGE_VC0321) { | 1470 | if (sd->bridge == BRIDGE_VC0321) { |
1468 | reg_r(gspca_dev, 0x8a, 0, 3); | 1471 | reg_r(gspca_dev, 0x8a, 0, 3); |
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index 79436f27cd4e..e78b9b7591d5 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c | |||
@@ -85,6 +85,7 @@ static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | |||
85 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | 85 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); |
86 | 86 | ||
87 | static struct ctrl sd_ctrls[] = { | 87 | static struct ctrl sd_ctrls[] = { |
88 | #define BRIGHTNESS_IDX 0 | ||
88 | #define SD_BRIGHTNESS 0 | 89 | #define SD_BRIGHTNESS 0 |
89 | { | 90 | { |
90 | { | 91 | { |
@@ -141,6 +142,7 @@ static struct ctrl sd_ctrls[] = { | |||
141 | .set = sd_setautogain, | 142 | .set = sd_setautogain, |
142 | .get = sd_getautogain, | 143 | .get = sd_getautogain, |
143 | }, | 144 | }, |
145 | #define LIGHTFREQ_IDX 4 | ||
144 | #define SD_FREQ 4 | 146 | #define SD_FREQ 4 |
145 | { | 147 | { |
146 | { | 148 | { |
@@ -7150,6 +7152,20 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
7150 | sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value; | 7152 | sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value; |
7151 | sd->sharpness = sd_ctrls[SD_SHARPNESS].qctrl.default_value; | 7153 | sd->sharpness = sd_ctrls[SD_SHARPNESS].qctrl.default_value; |
7152 | 7154 | ||
7155 | switch (sd->sensor) { | ||
7156 | case SENSOR_GC0305: | ||
7157 | case SENSOR_OV7620: | ||
7158 | case SENSOR_PO2030: | ||
7159 | gspca_dev->ctrl_dis = (1 << BRIGHTNESS_IDX); | ||
7160 | break; | ||
7161 | case SENSOR_HDCS2020: | ||
7162 | case SENSOR_HV7131B: | ||
7163 | case SENSOR_HV7131C: | ||
7164 | case SENSOR_OV7630C: | ||
7165 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX); | ||
7166 | break; | ||
7167 | } | ||
7168 | |||
7153 | /* switch the led off */ | 7169 | /* switch the led off */ |
7154 | reg_w(gspca_dev->dev, 0x01, 0x0000); | 7170 | reg_w(gspca_dev->dev, 0x01, 0x0000); |
7155 | return 0; | 7171 | return 0; |