aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Walls <awalls@md.metrocast.net>2010-09-12 13:45:14 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:05:55 -0400
commit51513353ec13a1318df31aaa4af4a6d196868904 (patch)
tree531c144155266d3f804ef9f302ed3292f1ab37a1
parent008d35f2f5256751a18f1f4aea79e3caf140098d (diff)
V4L/DVB: gspca_cpia1: Add basic v4l2 illuminator controls for the Intel Play QX3
This patch adds basic V4L2 controls for the illuminators on the Intel Play QX3 microscope. Signed-off-by: Andy Walls <awalls@md.metrocast.net> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jean-François Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/gspca/cpia1.c100
1 files changed, 98 insertions, 2 deletions
diff --git a/drivers/media/video/gspca/cpia1.c b/drivers/media/video/gspca/cpia1.c
index c56bf0f761e2..a9a4074ee682 100644
--- a/drivers/media/video/gspca/cpia1.c
+++ b/drivers/media/video/gspca/cpia1.c
@@ -373,6 +373,10 @@ static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
373static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); 373static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
374static int sd_setcomptarget(struct gspca_dev *gspca_dev, __s32 val); 374static int sd_setcomptarget(struct gspca_dev *gspca_dev, __s32 val);
375static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val); 375static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val);
376static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val);
377static int sd_getilluminator1(struct gspca_dev *gspca_dev, __s32 *val);
378static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val);
379static int sd_getilluminator2(struct gspca_dev *gspca_dev, __s32 *val);
376 380
377static const struct ctrl sd_ctrls[] = { 381static const struct ctrl sd_ctrls[] = {
378 { 382 {
@@ -434,6 +438,34 @@ static const struct ctrl sd_ctrls[] = {
434 }, 438 },
435 { 439 {
436 { 440 {
441 .id = V4L2_CID_ILLUMINATORS_1,
442 .type = V4L2_CTRL_TYPE_BOOLEAN,
443 .name = "Illuminator 1",
444 .minimum = 0,
445 .maximum = 1,
446 .step = 1,
447#define ILLUMINATORS_1_DEF 0
448 .default_value = ILLUMINATORS_1_DEF,
449 },
450 .set = sd_setilluminator1,
451 .get = sd_getilluminator1,
452 },
453 {
454 {
455 .id = V4L2_CID_ILLUMINATORS_2,
456 .type = V4L2_CTRL_TYPE_BOOLEAN,
457 .name = "Illuminator 2",
458 .minimum = 0,
459 .maximum = 1,
460 .step = 1,
461#define ILLUMINATORS_2_DEF 0
462 .default_value = ILLUMINATORS_2_DEF,
463 },
464 .set = sd_setilluminator2,
465 .get = sd_getilluminator2,
466 },
467 {
468 {
437#define V4L2_CID_COMP_TARGET V4L2_CID_PRIVATE_BASE 469#define V4L2_CID_COMP_TARGET V4L2_CID_PRIVATE_BASE
438 .id = V4L2_CID_COMP_TARGET, 470 .id = V4L2_CID_COMP_TARGET,
439 .type = V4L2_CTRL_TYPE_MENU, 471 .type = V4L2_CTRL_TYPE_MENU,
@@ -1059,7 +1091,6 @@ static int command_resume(struct gspca_dev *gspca_dev)
1059 0, sd->params.streamStartLine, 0, 0); 1091 0, sd->params.streamStartLine, 0, 0);
1060} 1092}
1061 1093
1062#if 0 /* Currently unused */
1063static int command_setlights(struct gspca_dev *gspca_dev) 1094static int command_setlights(struct gspca_dev *gspca_dev)
1064{ 1095{
1065 struct sd *sd = (struct sd *) gspca_dev; 1096 struct sd *sd = (struct sd *) gspca_dev;
@@ -1079,7 +1110,6 @@ static int command_setlights(struct gspca_dev *gspca_dev)
1079 return do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 2, 0, 1110 return do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 2, 0,
1080 p1 | p2 | 0xE0, 0); 1111 p1 | p2 | 0xE0, 0);
1081} 1112}
1082#endif
1083 1113
1084static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply) 1114static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply)
1085{ 1115{
@@ -1929,6 +1959,72 @@ static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val)
1929 return 0; 1959 return 0;
1930} 1960}
1931 1961
1962static int sd_setilluminator(struct gspca_dev *gspca_dev, __s32 val, int n)
1963{
1964 struct sd *sd = (struct sd *) gspca_dev;
1965 int ret;
1966
1967 if (!sd->params.qx3.qx3_detected)
1968 return -EINVAL;
1969
1970 switch (n) {
1971 case 1:
1972 sd->params.qx3.bottomlight = val ? 1 : 0;
1973 break;
1974 case 2:
1975 sd->params.qx3.toplight = val ? 1 : 0;
1976 break;
1977 default:
1978 return -EINVAL;
1979 }
1980
1981 ret = command_setlights(gspca_dev);
1982 if (ret && ret != -EINVAL)
1983 ret = -EBUSY;
1984
1985 return ret;
1986}
1987
1988static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val)
1989{
1990 return sd_setilluminator(gspca_dev, val, 1);
1991}
1992
1993static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val)
1994{
1995 return sd_setilluminator(gspca_dev, val, 2);
1996}
1997
1998static int sd_getilluminator(struct gspca_dev *gspca_dev, __s32 *val, int n)
1999{
2000 struct sd *sd = (struct sd *) gspca_dev;
2001
2002 if (!sd->params.qx3.qx3_detected)
2003 return -EINVAL;
2004
2005 switch (n) {
2006 case 1:
2007 *val = sd->params.qx3.bottomlight;
2008 break;
2009 case 2:
2010 *val = sd->params.qx3.toplight;
2011 break;
2012 default:
2013 return -EINVAL;
2014 }
2015 return 0;
2016}
2017
2018static int sd_getilluminator1(struct gspca_dev *gspca_dev, __s32 *val)
2019{
2020 return sd_getilluminator(gspca_dev, val, 1);
2021}
2022
2023static int sd_getilluminator2(struct gspca_dev *gspca_dev, __s32 *val)
2024{
2025 return sd_getilluminator(gspca_dev, val, 2);
2026}
2027
1932static int sd_querymenu(struct gspca_dev *gspca_dev, 2028static int sd_querymenu(struct gspca_dev *gspca_dev,
1933 struct v4l2_querymenu *menu) 2029 struct v4l2_querymenu *menu)
1934{ 2030{