Skip to content

Commit

Permalink
V4L/DVB (9687): gspca: Split brightness and red and blue balance in s…
Browse files Browse the repository at this point in the history
…pca501.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Dec 29, 2008
1 parent bd131f3 commit 9a23f5f
Showing 1 changed file with 88 additions and 6 deletions.
94 changes: 88 additions & 6 deletions drivers/media/video/gspca/spca501.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct sd {
unsigned short contrast;
__u8 brightness;
__u8 colors;
__u8 blue_balance;
__u8 red_balance;

char subtype;
#define Arowana300KCMOSCamera 0
Expand All @@ -52,6 +54,10 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);

static struct ctrl sd_ctrls[] = {
#define MY_BRIGHTNESS 0
Expand All @@ -63,7 +69,7 @@ static struct ctrl sd_ctrls[] = {
.minimum = 0,
.maximum = 127,
.step = 1,
.default_value = 63,
.default_value = 0,
},
.set = sd_setbrightness,
.get = sd_getbrightness,
Expand All @@ -75,9 +81,9 @@ static struct ctrl sd_ctrls[] = {
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Contrast",
.minimum = 0,
.maximum = 0xffff,
.maximum = 64725,
.step = 1,
.default_value = 0xaa00,
.default_value = 64725,
},
.set = sd_setcontrast,
.get = sd_getcontrast,
Expand All @@ -91,11 +97,39 @@ static struct ctrl sd_ctrls[] = {
.minimum = 0,
.maximum = 63,
.step = 1,
.default_value = 31,
.default_value = 20,
},
.set = sd_setcolors,
.get = sd_getcolors,
},
#define MY_BLUE_BALANCE 3
{
{
.id = V4L2_CID_BLUE_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Blue Balance",
.minimum = 0,
.maximum = 127,
.step = 1,
.default_value = 0,
},
.set = sd_setblue_balance,
.get = sd_getblue_balance,
},
#define MY_RED_BALANCE 4
{
{
.id = V4L2_CID_RED_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Red Balance",
.minimum = 0,
.maximum = 127,
.step = 1,
.default_value = 0,
},
.set = sd_setred_balance,
.get = sd_getred_balance,
},
};

static struct v4l2_pix_format vga_mode[] = {
Expand Down Expand Up @@ -1846,9 +1880,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;

reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x11, sd->brightness);
reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x12, sd->brightness);
reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x13, sd->brightness);
}

static void getbrightness(struct gspca_dev *gspca_dev)
Expand Down Expand Up @@ -1880,6 +1912,20 @@ static void getcolors(struct gspca_dev *gspca_dev)
{
}

static void setblue_balance(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;

reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x11, sd->blue_balance);
}

static void setred_balance(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;

reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x13, sd->red_balance);
}

/* this function is called at probe time */
static int sd_config(struct gspca_dev *gspca_dev,
const struct usb_device_id *id)
Expand Down Expand Up @@ -2081,6 +2127,42 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}

static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;

sd->blue_balance = val;
if (gspca_dev->streaming)
setblue_balance(gspca_dev);
return 0;
}

static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;

*val = sd->blue_balance;
return 0;
}

static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;

sd->red_balance = val;
if (gspca_dev->streaming)
setred_balance(gspca_dev);
return 0;
}

static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;

*val = sd->red_balance;
return 0;
}

/* sub-driver description */
static const struct sd_desc sd_desc = {
.name = MODULE_NAME,
Expand Down

0 comments on commit 9a23f5f

Please sign in to comment.