Commit 4a7581f0 authored by Lukas Karas's avatar Lukas Karas Committed by Mauro Carvalho Chehab

V4L/DVB (11408): gspca - m5602-s5k83a: Add led support to the s5k83a sensor.

This patch toggles the led seen on many laptops having a m5602 connected
to a Samsung s5k83a sensor.
Signed-off-by: default avatarLukas Karas <lukas.karas@centrum.cz>
Signed-off-by: default avatarErik Andr?n <erik.andren@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent dc913258
......@@ -309,7 +309,11 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
static void m5602_stop_transfer(struct gspca_dev *gspca_dev)
{
/* Is there are a command to stop a data transfer? */
struct sd *sd = (struct sd *) gspca_dev;
/* Run the sensor specific end transfer sequence */
if (sd->sensor->stop)
sd->sensor->stop(sd);
}
/* sub-driver description, the ctrl and nctrl is filled at probe time */
......
......@@ -108,6 +108,16 @@ int s5k83a_init(struct sd *sd)
return (err < 0) ? err : 0;
}
int s5k83a_start(struct sd *sd)
{
return s5k83a_set_led_indication(sd, 1);
}
int s5k83a_stop(struct sd *sd)
{
return s5k83a_set_led_indication(sd, 0);
}
int s5k83a_power_down(struct sd *sd)
{
return 0;
......@@ -345,3 +355,22 @@ int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
int s5k83a_set_led_indication(struct sd *sd, u8 val)
{
int err = 0;
u8 data[1];
err = m5602_read_bridge(sd, M5602_XB_GPIO_DAT, data);
if (err < 0)
return err;
if (val)
data[0] = data[0] | S5K83A_GPIO_LED_MASK;
else
data[0] = data[0] & ~S5K83A_GPIO_LED_MASK;
err = m5602_write_bridge(sd, M5602_XB_GPIO_DAT, data[0]);
return (err < 0) ? err : 0;
}
......@@ -34,7 +34,7 @@
#define S5K83A_DEFAULT_GAIN 0x00
#define S5K83A_MAXIMUM_GAIN 0x3c
#define S5K83A_FLIP_MASK 0x10
#define S5K83A_GPIO_LED_MASK 0x10
/*****************************************************************************/
......@@ -44,8 +44,12 @@ extern int dump_sensor;
int s5k83a_probe(struct sd *sd);
int s5k83a_init(struct sd *sd);
int s5k83a_start(struct sd *sd);
int s5k83a_stop(struct sd *sd);
int s5k83a_power_down(struct sd *sd);
int s5k83a_set_led_indication(struct sd *sd, u8 val);
int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val);
int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val);
int s5k83a_set_whiteness(struct gspca_dev *gspca_dev, __s32 val);
......@@ -61,6 +65,8 @@ static struct m5602_sensor s5k83a = {
.name = "S5K83A",
.probe = s5k83a_probe,
.init = s5k83a_init,
.start = s5k83a_start,
.stop = s5k83a_stop,
.power_down = s5k83a_power_down,
.i2c_slave_id = 0x5a,
.i2c_regW = 2,
......@@ -381,7 +387,7 @@ static const unsigned char init_s5k83a[][4] =
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT, 0x1c, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
{BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
......
......@@ -61,6 +61,9 @@ struct m5602_sensor {
/* Executed when the camera starts to send data */
int (*start)(struct sd *sd);
/* Executed when the camera ends to send data */
int (*stop)(struct sd *sd);
/* Performs a power down sequence */
int (*power_down)(struct sd *sd);
......
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