aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/ov534.c
diff options
context:
space:
mode:
authorMosalam Ebrahimi <m.ebrahimi@ieee.org>2010-03-08 11:52:17 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:47:00 -0400
commit4b7875407b2fb56433586877ca0a564b8d999f4e (patch)
treec55db88f1e161b9312d9bbd1c4cc9c32922b0f0f /drivers/media/video/gspca/ov534.c
parent7f9e9e8dc2d5b226819e486e13c9532f40a0fbda (diff)
V4L/DVB: gspca - ov534: Add Powerline Frequency control
Note that setting this options to 50Hz can reduce the framerate, so it is still disabled (60Hz) by default. Signed-off-by: Mosalam Ebrahimi <m.ebrahimi@ieee.org> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it> Signed-off-by: Jean-François Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/ov534.c')
-rw-r--r--drivers/media/video/gspca/ov534.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c
index 878384442482..29af17e173d5 100644
--- a/drivers/media/video/gspca/ov534.c
+++ b/drivers/media/video/gspca/ov534.c
@@ -66,7 +66,7 @@ struct sd {
66 s8 sharpness; 66 s8 sharpness;
67 u8 hflip; 67 u8 hflip;
68 u8 vflip; 68 u8 vflip;
69 69 u8 freqfltr;
70}; 70};
71 71
72/* V4L2 controls supported by the driver */ 72/* V4L2 controls supported by the driver */
@@ -90,6 +90,10 @@ static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
90static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); 90static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
91static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); 91static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
92static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); 92static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
93static int sd_setfreqfltr(struct gspca_dev *gspca_dev, __s32 val);
94static int sd_getfreqfltr(struct gspca_dev *gspca_dev, __s32 *val);
95static int sd_querymenu(struct gspca_dev *gspca_dev,
96 struct v4l2_querymenu *menu);
93 97
94static const struct ctrl sd_ctrls[] = { 98static const struct ctrl sd_ctrls[] = {
95 { /* 0 */ 99 { /* 0 */
@@ -233,6 +237,20 @@ static const struct ctrl sd_ctrls[] = {
233 .set = sd_setvflip, 237 .set = sd_setvflip,
234 .get = sd_getvflip, 238 .get = sd_getvflip,
235 }, 239 },
240 { /* 10 */
241 {
242 .id = V4L2_CID_POWER_LINE_FREQUENCY,
243 .type = V4L2_CTRL_TYPE_MENU,
244 .name = "Light Frequency Filter",
245 .minimum = 0,
246 .maximum = 1,
247 .step = 1,
248#define FREQFLTR_DEF 0
249 .default_value = FREQFLTR_DEF,
250 },
251 .set = sd_setfreqfltr,
252 .get = sd_getfreqfltr,
253 },
236}; 254};
237 255
238static const struct v4l2_pix_format ov772x_mode[] = { 256static const struct v4l2_pix_format ov772x_mode[] = {
@@ -784,6 +802,17 @@ static void setvflip(struct gspca_dev *gspca_dev)
784 sccb_reg_read(gspca_dev, 0x0c) & ~0x80); 802 sccb_reg_read(gspca_dev, 0x0c) & ~0x80);
785} 803}
786 804
805static void setfreqfltr(struct gspca_dev *gspca_dev)
806{
807 struct sd *sd = (struct sd *) gspca_dev;
808
809 if (sd->freqfltr == 0)
810 sccb_reg_write(gspca_dev, 0x2b, 0x00);
811 else
812 sccb_reg_write(gspca_dev, 0x2b, 0x9e);
813}
814
815
787/* this function is called at probe time */ 816/* this function is called at probe time */
788static int sd_config(struct gspca_dev *gspca_dev, 817static int sd_config(struct gspca_dev *gspca_dev,
789 const struct usb_device_id *id) 818 const struct usb_device_id *id)
@@ -817,6 +846,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
817 sd->sharpness = SHARPNESS_DEF; 846 sd->sharpness = SHARPNESS_DEF;
818 sd->hflip = HFLIP_DEF; 847 sd->hflip = HFLIP_DEF;
819 sd->vflip = VFLIP_DEF; 848 sd->vflip = VFLIP_DEF;
849 sd->freqfltr = FREQFLTR_DEF;
820 850
821 return 0; 851 return 0;
822} 852}
@@ -886,6 +916,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
886 setsharpness(gspca_dev); 916 setsharpness(gspca_dev);
887 setvflip(gspca_dev); 917 setvflip(gspca_dev);
888 sethflip(gspca_dev); 918 sethflip(gspca_dev);
919 setfreqfltr(gspca_dev);
889 920
890 ov534_set_led(gspca_dev, 1); 921 ov534_set_led(gspca_dev, 1);
891 ov534_reg_write(gspca_dev, 0xe0, 0x00); 922 ov534_reg_write(gspca_dev, 0xe0, 0x00);
@@ -1179,6 +1210,43 @@ static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
1179 return 0; 1210 return 0;
1180} 1211}
1181 1212
1213static int sd_setfreqfltr(struct gspca_dev *gspca_dev, __s32 val)
1214{
1215 struct sd *sd = (struct sd *) gspca_dev;
1216
1217 sd->freqfltr = val;
1218 if (gspca_dev->streaming)
1219 setfreqfltr(gspca_dev);
1220 return 0;
1221}
1222
1223static int sd_getfreqfltr(struct gspca_dev *gspca_dev, __s32 *val)
1224{
1225 struct sd *sd = (struct sd *) gspca_dev;
1226
1227 *val = sd->freqfltr;
1228 return 0;
1229}
1230
1231static int sd_querymenu(struct gspca_dev *gspca_dev,
1232 struct v4l2_querymenu *menu)
1233{
1234 switch (menu->id) {
1235 case V4L2_CID_POWER_LINE_FREQUENCY:
1236 switch (menu->index) {
1237 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
1238 strcpy((char *) menu->name, "Disabled");
1239 return 0;
1240 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
1241 strcpy((char *) menu->name, "50 Hz");
1242 return 0;
1243 }
1244 break;
1245 }
1246
1247 return -EINVAL;
1248}
1249
1182/* get stream parameters (framerate) */ 1250/* get stream parameters (framerate) */
1183static int sd_get_streamparm(struct gspca_dev *gspca_dev, 1251static int sd_get_streamparm(struct gspca_dev *gspca_dev,
1184 struct v4l2_streamparm *parm) 1252 struct v4l2_streamparm *parm)
@@ -1230,6 +1298,7 @@ static const struct sd_desc sd_desc = {
1230 .start = sd_start, 1298 .start = sd_start,
1231 .stopN = sd_stopN, 1299 .stopN = sd_stopN,
1232 .pkt_scan = sd_pkt_scan, 1300 .pkt_scan = sd_pkt_scan,
1301 .querymenu = sd_querymenu,
1233 .get_streamparm = sd_get_streamparm, 1302 .get_streamparm = sd_get_streamparm,
1234 .set_streamparm = sd_set_streamparm, 1303 .set_streamparm = sd_set_streamparm,
1235}; 1304};