Commit 0cae8964 authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (9541): gspca: Add infrared control for sonixj - mi0360.

Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4cc0edff
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "gspca.h" #include "gspca.h"
#include "jpeg.h" #include "jpeg.h"
#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -40,6 +42,7 @@ struct sd { ...@@ -40,6 +42,7 @@ struct sd {
unsigned char colors; unsigned char colors;
unsigned char autogain; unsigned char autogain;
__u8 vflip; /* ov7630 only */ __u8 vflip; /* ov7630 only */
__u8 infrared; /* mi0360 only */
signed char ag_cnt; signed char ag_cnt;
#define AG_CNT_START 13 #define AG_CNT_START 13
...@@ -73,6 +76,8 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); ...@@ -73,6 +76,8 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
static struct ctrl sd_ctrls[] = { static struct ctrl sd_ctrls[] = {
{ {
...@@ -150,6 +155,22 @@ static struct ctrl sd_ctrls[] = { ...@@ -150,6 +155,22 @@ static struct ctrl sd_ctrls[] = {
.set = sd_setvflip, .set = sd_setvflip,
.get = sd_getvflip, .get = sd_getvflip,
}, },
/* mi0360 only */
#define INFRARED_IDX 5
{
{
.id = V4L2_CID_INFRARED,
.type = V4L2_CTRL_TYPE_BOOLEAN,
.name = "Infrared",
.minimum = 0,
.maximum = 1,
.step = 1,
#define INFRARED_DEF 0
.default_value = INFRARED_DEF,
},
.set = sd_setinfrared,
.get = sd_getinfrared,
},
}; };
static struct v4l2_pix_format vga_mode[] = { static struct v4l2_pix_format vga_mode[] = {
...@@ -963,6 +984,8 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -963,6 +984,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->colors = COLOR_DEF; sd->colors = COLOR_DEF;
sd->autogain = AUTOGAIN_DEF; sd->autogain = AUTOGAIN_DEF;
sd->ag_cnt = -1; sd->ag_cnt = -1;
sd->vflip = VFLIP_DEF;
sd->infrared = INFRARED_DEF;
switch (sd->sensor) { switch (sd->sensor) {
case SENSOR_OV7630: case SENSOR_OV7630:
...@@ -973,7 +996,8 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -973,7 +996,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
} }
if (sd->sensor != SENSOR_OV7630) if (sd->sensor != SENSOR_OV7630)
gspca_dev->ctrl_dis |= (1 << VFLIP_IDX); gspca_dev->ctrl_dis |= (1 << VFLIP_IDX);
if (sd->sensor != SENSOR_MI0360)
gspca_dev->ctrl_dis |= (1 << INFRARED_IDX);
return 0; return 0;
} }
...@@ -1195,12 +1219,18 @@ static void setautogain(struct gspca_dev *gspca_dev) ...@@ -1195,12 +1219,18 @@ static void setautogain(struct gspca_dev *gspca_dev)
static void setvflip(struct sd *sd) static void setvflip(struct sd *sd)
{ {
if (sd->sensor != SENSOR_OV7630)
return;
i2c_w1(&sd->gspca_dev, 0x75, /* COMN */ i2c_w1(&sd->gspca_dev, 0x75, /* COMN */
sd->vflip ? 0x82 : 0x02); sd->vflip ? 0x82 : 0x02);
} }
static void setinfrared(struct sd *sd)
{
/*fixme: different sequence for StarCam Clip and StarCam 370i */
/* Clip */
i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
sd->infrared ? 0x66 : 0x64);
}
/* -- start the camera -- */ /* -- start the camera -- */
static int sd_start(struct gspca_dev *gspca_dev) static int sd_start(struct gspca_dev *gspca_dev)
{ {
...@@ -1343,8 +1373,10 @@ static int sd_start(struct gspca_dev *gspca_dev) ...@@ -1343,8 +1373,10 @@ static int sd_start(struct gspca_dev *gspca_dev)
reg_w1(gspca_dev, 0x17, reg17); reg_w1(gspca_dev, 0x17, reg17);
switch (sd->sensor) { switch (sd->sensor) {
case SENSOR_HV7131R:
case SENSOR_MI0360: case SENSOR_MI0360:
setinfrared(sd);
/* fall thru */
case SENSOR_HV7131R:
case SENSOR_MO4000: case SENSOR_MO4000:
case SENSOR_OM6802: case SENSOR_OM6802:
setbrightness(gspca_dev); setbrightness(gspca_dev);
...@@ -1598,6 +1630,24 @@ static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) ...@@ -1598,6 +1630,24 @@ static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
return 0; return 0;
} }
static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
sd->infrared = val;
if (gspca_dev->streaming)
setinfrared(sd);
return 0;
}
static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
*val = sd->infrared;
return 0;
}
/* sub-driver description */ /* sub-driver description */
static const struct sd_desc sd_desc = { static const struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment