Commit 3d3ec926 authored by Erik Andr?n's avatar Erik Andr?n Committed by Mauro Carvalho Chehab

V4L/DVB (11409): gspca - m5602-ov9650: Set the ov9650 sensor in soft sleep when inactive.

In order to save energy, put the sensor in soft sleep mode when not active
Signed-off-by: default avatarErik Andrén <erik.andren@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4a7581f0
...@@ -147,8 +147,14 @@ int ov9650_start(struct sd *sd) ...@@ -147,8 +147,14 @@ int ov9650_start(struct sd *sd)
int i, err = 0; int i, err = 0;
struct cam *cam = &sd->gspca_dev.cam; struct cam *cam = &sd->gspca_dev.cam;
for (i = 0; i < ARRAY_SIZE(res_init_ov9650) && !err; i++) for (i = 0; i < ARRAY_SIZE(res_init_ov9650) && !err; i++) {
err = m5602_write_bridge(sd, res_init_ov9650[i][0], res_init_ov9650[i][1]); if (res_init_ov9650[i][0] == BRIDGE)
err = m5602_write_bridge(sd, res_init_ov9650[i][1], res_init_ov9650[i][2]);
else if (res_init_ov9650[i][0] == SENSOR) {
u8 data = res_init_ov9650[i][2];
err = m5602_write_sensor(sd, res_init_ov9650[i][1], &data, 1);
}
}
if (err < 0) if (err < 0)
return err; return err;
...@@ -217,6 +223,12 @@ int ov9650_start(struct sd *sd) ...@@ -217,6 +223,12 @@ int ov9650_start(struct sd *sd)
return err; return err;
} }
int ov9650_stop(struct sd *sd)
{
u8 data = OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X;
return m5602_write_sensor(sd, OV9650_COM2, &data, 1);
}
int ov9650_power_down(struct sd *sd) int ov9650_power_down(struct sd *sd)
{ {
int i, err = 0; int i, err = 0;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define OV9650_BAVE 0x05 #define OV9650_BAVE 0x05
#define OV9650_GEAVE 0x06 #define OV9650_GEAVE 0x06
#define OV9650_RSVD7 0x07 #define OV9650_RSVD7 0x07
#define OV9650_COM2 0x09
#define OV9650_PID 0x0a #define OV9650_PID 0x0a
#define OV9650_VER 0x0b #define OV9650_VER 0x0b
#define OV9650_COM3 0x0c #define OV9650_COM3 0x0c
...@@ -116,6 +117,9 @@ ...@@ -116,6 +117,9 @@
#define OV9650_VFLIP (1 << 4) #define OV9650_VFLIP (1 << 4)
#define OV9650_HFLIP (1 << 5) #define OV9650_HFLIP (1 << 5)
#define OV9650_SOFT_SLEEP (1 << 4)
#define OV9650_OUTPUT_DRIVE_2X (1 << 0)
#define GAIN_DEFAULT 0x14 #define GAIN_DEFAULT 0x14
#define RED_GAIN_DEFAULT 0x70 #define RED_GAIN_DEFAULT 0x70
#define BLUE_GAIN_DEFAULT 0x20 #define BLUE_GAIN_DEFAULT 0x20
...@@ -130,6 +134,7 @@ extern int dump_sensor; ...@@ -130,6 +134,7 @@ extern int dump_sensor;
int ov9650_probe(struct sd *sd); int ov9650_probe(struct sd *sd);
int ov9650_init(struct sd *sd); int ov9650_init(struct sd *sd);
int ov9650_start(struct sd *sd); int ov9650_start(struct sd *sd);
int ov9650_stop(struct sd *sd);
int ov9650_power_down(struct sd *sd); int ov9650_power_down(struct sd *sd);
int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val); int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
...@@ -158,6 +163,7 @@ static struct m5602_sensor ov9650 = { ...@@ -158,6 +163,7 @@ static struct m5602_sensor ov9650 = {
.probe = ov9650_probe, .probe = ov9650_probe,
.init = ov9650_init, .init = ov9650_init,
.start = ov9650_start, .start = ov9650_start,
.stop = ov9650_stop,
.power_down = ov9650_power_down, .power_down = ov9650_power_down,
.nctrls = 8, .nctrls = 8,
...@@ -450,6 +456,9 @@ static const unsigned char init_ov9650[][3] = ...@@ -450,6 +456,9 @@ static const unsigned char init_ov9650[][3] =
{SENSOR, OV9650_GAIN, GAIN_DEFAULT}, {SENSOR, OV9650_GAIN, GAIN_DEFAULT},
{SENSOR, OV9650_BLUE, BLUE_GAIN_DEFAULT}, {SENSOR, OV9650_BLUE, BLUE_GAIN_DEFAULT},
{SENSOR, OV9650_RED, RED_GAIN_DEFAULT}, {SENSOR, OV9650_RED, RED_GAIN_DEFAULT},
/* Put the sensor in soft sleep mode */
{SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X},
}; };
static const unsigned char power_down_ov9650[][3] = static const unsigned char power_down_ov9650[][3] =
...@@ -472,13 +481,15 @@ static const unsigned char power_down_ov9650[][3] = ...@@ -472,13 +481,15 @@ static const unsigned char power_down_ov9650[][3] =
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
}; };
static const unsigned char res_init_ov9650[][2] = static const unsigned char res_init_ov9650[][3] =
{ {
{M5602_XB_LINE_OF_FRAME_H, 0x82}, {SENSOR, OV9650_COM2, (1 << 0)},
{M5602_XB_LINE_OF_FRAME_L, 0x00},
{M5602_XB_PIX_OF_LINE_H, 0x82}, {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x82},
{M5602_XB_PIX_OF_LINE_L, 0x00}, {BRIDGE, M5602_XB_LINE_OF_FRAME_L, 0x00},
{M5602_XB_SIG_INI, 0x01} {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82},
{BRIDGE, M5602_XB_PIX_OF_LINE_L, 0x00},
{BRIDGE, M5602_XB_SIG_INI, 0x01}
}; };
static const unsigned char VGA_ov9650[][3] = static const unsigned char VGA_ov9650[][3] =
......
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