Commit 3290d402 authored by Erik Andr?n's avatar Erik Andr?n Committed by Mauro Carvalho Chehab

V4L/DVB (11529): gspca - m5602-s5k4aa: Add noise suppression ctrl

Signed-off-by: default avatarErik Andr?n <erik.andren@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 71c6e59d
...@@ -26,6 +26,8 @@ static int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); ...@@ -26,6 +26,8 @@ static int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
static int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val); static int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
static int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val); static int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val); static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val);
static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val);
static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val);
static static
const const
...@@ -131,7 +133,21 @@ const static struct ctrl s5k4aa_ctrls[] = { ...@@ -131,7 +133,21 @@ const static struct ctrl s5k4aa_ctrls[] = {
}, },
.set = s5k4aa_set_exposure, .set = s5k4aa_set_exposure,
.get = s5k4aa_get_exposure .get = s5k4aa_get_exposure
} },
#define NOISE_SUPP_IDX 4
{
{
.id = V4L2_CID_PRIVATE_BASE,
.type = V4L2_CTRL_TYPE_BOOLEAN,
.name = "Noise suppression (smoothing)",
.minimum = 0,
.maximum = 1,
.step = 1,
.default_value = 1,
},
.set = s5k4aa_set_noise,
.get = s5k4aa_get_noise
},
}; };
static void s5k4aa_dump_registers(struct sd *sd); static void s5k4aa_dump_registers(struct sd *sd);
...@@ -304,13 +320,15 @@ int s5k4aa_init(struct sd *sd) ...@@ -304,13 +320,15 @@ int s5k4aa_init(struct sd *sd)
if (err < 0) if (err < 0)
return err; return err;
err = s5k4aa_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]); err = s5k4aa_set_noise(&sd->gspca_dev, sensor_settings[NOISE_SUPP_IDX]);
if (err < 0) if (err < 0)
return err; return err;
err = s5k4aa_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]); err = s5k4aa_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]);
if (err < 0)
return err; return err;
return s5k4aa_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]);
} }
static int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) static int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
...@@ -495,6 +513,34 @@ static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val) ...@@ -495,6 +513,34 @@ static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val)
return err; return err;
} }
static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
*val = sensor_settings[NOISE_SUPP_IDX];
PDEBUG(D_V4L2, "Read noise %d", *val);
return 0;
}
static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
sensor_settings[NOISE_SUPP_IDX] = val;
PDEBUG(D_V4L2, "Set noise to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
data = val & 0x01;
return m5602_write_sensor(sd, S5K4AA_NOISE_SUPP, &data, 1);
}
void s5k4aa_disconnect(struct sd *sd) void s5k4aa_disconnect(struct sd *sd)
{ {
sd->sensor = NULL; sd->sensor = NULL;
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#define S5K4AA_EXPOSURE_LO 0x18 #define S5K4AA_EXPOSURE_LO 0x18
#define S5K4AA_GAIN_1 0x1f /* (digital?) gain : 5 bits */ #define S5K4AA_GAIN_1 0x1f /* (digital?) gain : 5 bits */
#define S5K4AA_GAIN_2 0x20 /* (analogue?) gain : 7 bits */ #define S5K4AA_GAIN_2 0x20 /* (analogue?) gain : 7 bits */
#define S5K4AA_NOISE_SUPP 0x37
#define S5K4AA_RM_ROW_SKIP_4X 0x08 #define S5K4AA_RM_ROW_SKIP_4X 0x08
#define S5K4AA_RM_ROW_SKIP_2X 0x04 #define S5K4AA_RM_ROW_SKIP_2X 0x04
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "m5602_bridge.h" #include "m5602_bridge.h"
#define M5602_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 0) #define M5602_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 0)
#define M5602_V4L2_CID_NOISE_SUPPRESION (V4L2_CID_PRIVATE_BASE + 1)
/* Enumerates all supported sensors */ /* Enumerates all supported sensors */
enum sensors { enum sensors {
......
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