// SPDX-License-Identifier: GPL-2.0-or-later
/* Subdriver for the GL860 chip with the OV2640 sensor
* Author Olivier LORIN, from Malmostoso's logs
*/
/* Sensor : OV2640 */
#include "gl860.h"
static u8 dat_init1[] = "\x00\x41\x07\x6a\x06\x61\x0d\x6a" "\x10\x10\xc1\x01" ;
static u8 c61[] = {0 x61}; /* expected */
static u8 c51[] = {0 x51}; /* expected */
static u8 c50[] = {0 x50}; /* expected */
static u8 c28[] = {0 x28}; /* expected */
static u8 ca8[] = {0 xa8}; /* expected */
static u8 dat_post[] =
"\x00\x41\x07\x6a\x06\xef\x0d\x6a" "\x10\x10\xc1\x01" ;
static u8 dat_640[] = "\xd0\x01\xd1\x08\xd2\xe0\xd3\x02\xd4\x10\xd5\x81" ;
static u8 dat_800[] = "\xd0\x01\xd1\x10\xd2\x58\xd3\x02\xd4\x18\xd5\x21" ;
static u8 dat_1280[] = "\xd0\x01\xd1\x18\xd2\xc0\xd3\x02\xd4\x28\xd5\x01" ;
static u8 dat_1600[] = "\xd0\x01\xd1\x20\xd2\xb0\xd3\x02\xd4\x30\xd5\x41" ;
static struct validx tbl_init_at_startup[] = {
{0 x0000, 0 x0000}, {0 x0010, 0 x0010}, {0 x0008, 0 x00c0}, {0 x0001, 0 x00c1},
{0 x0001, 0 x00c2}, {0 x0020, 0 x0006}, {0 x006a, 0 x000d},
{0 x0050, 0 x0000}, {0 x0041, 0 x0000}, {0 x006a, 0 x0007}, {0 x0061, 0 x0006},
{0 x006a, 0 x000d}, {0 x0000, 0 x00c0}, {0 x0010, 0 x0010}, {0 x0001, 0 x00c1},
{0 x0041, 0 x00c2}, {0 x0004, 0 x00d8}, {0 x0012, 0 x0004}, {0 x0000, 0 x0058},
{0 x0041, 0 x0000}, {0 x0061, 0 x0000},
};
static struct validx tbl_common[] = {
{0 x6000, 0 x00ff}, {0 x60ff, 0 x002c}, {0 x60df, 0 x002e}, {0 x6001, 0 x00ff},
{0 x6080, 0 x0012}, {0 x6000, 0 x0000}, {0 x6000, 0 x0045}, {0 x6000, 0 x0010},
{0 x6035, 0 x003c}, {0 x6000, 0 x0011}, {0 x6028, 0 x0004}, {0 x60e5, 0 x0013},
{0 x6088, 0 x0014}, {0 x600c, 0 x002c}, {0 x6078, 0 x0033}, {0 x60f7, 0 x003b},
{0 x6000, 0 x003e}, {0 x6011, 0 x0043}, {0 x6010, 0 x0016}, {0 x6082, 0 x0039},
{0 x6088, 0 x0035}, {0 x600a, 0 x0022}, {0 x6040, 0 x0037}, {0 x6000, 0 x0023},
{0 x60a0, 0 x0034}, {0 x601a, 0 x0036}, {0 x6002, 0 x0006}, {0 x60c0, 0 x0007},
{0 x60b7, 0 x000d}, {0 x6001, 0 x000e}, {0 x6000, 0 x004c}, {0 x6081, 0 x004a},
{0 x6099, 0 x0021}, {0 x6002, 0 x0009}, {0 x603e, 0 x0024}, {0 x6034, 0 x0025},
{0 x6081, 0 x0026}, {0 x6000, 0 x0000}, {0 x6000, 0 x0045}, {0 x6000, 0 x0010},
{0 x6000, 0 x005c}, {0 x6000, 0 x0063}, {0 x6000, 0 x007c}, {0 x6070, 0 x0061},
{0 x6080, 0 x0062}, {0 x6080, 0 x0020}, {0 x6030, 0 x0028}, {0 x6000, 0 x006c},
{0 x6000, 0 x006e}, {0 x6002, 0 x0070}, {0 x6094, 0 x0071}, {0 x60c1, 0 x0073},
{0 x6034, 0 x003d}, {0 x6057, 0 x005a}, {0 x60bb, 0 x004f}, {0 x609c, 0 x0050},
{0 x6080, 0 x006d}, {0 x6002, 0 x0039}, {0 x6033, 0 x003a}, {0 x60f1, 0 x003b},
{0 x6031, 0 x003c}, {0 x6000, 0 x00ff}, {0 x6014, 0 x00e0}, {0 x60ff, 0 x0076},
{0 x60a0, 0 x0033}, {0 x6020, 0 x0042}, {0 x6018, 0 x0043}, {0 x6000, 0 x004c},
{0 x60d0, 0 x0087}, {0 x600f, 0 x0088}, {0 x6003, 0 x00d7}, {0 x6010, 0 x00d9},
{0 x6005, 0 x00da}, {0 x6082, 0 x00d3}, {0 x60c0, 0 x00f9}, {0 x6006, 0 x0044},
{0 x6007, 0 x00d1}, {0 x6002, 0 x00d2}, {0 x6000, 0 x00d2}, {0 x6011, 0 x00d8},
{0 x6008, 0 x00c8}, {0 x6080, 0 x00c9}, {0 x6008, 0 x007c}, {0 x6020, 0 x007d},
{0 x6020, 0 x007d}, {0 x6000, 0 x0090}, {0 x600e, 0 x0091}, {0 x601a, 0 x0091},
{0 x6031, 0 x0091}, {0 x605a, 0 x0091}, {0 x6069, 0 x0091}, {0 x6075, 0 x0091},
{0 x607e, 0 x0091}, {0 x6088, 0 x0091}, {0 x608f, 0 x0091}, {0 x6096, 0 x0091},
{0 x60a3, 0 x0091}, {0 x60af, 0 x0091}, {0 x60c4, 0 x0091}, {0 x60d7, 0 x0091},
{0 x60e8, 0 x0091}, {0 x6020, 0 x0091}, {0 x6000, 0 x0092}, {0 x6006, 0 x0093},
{0 x60e3, 0 x0093}, {0 x6005, 0 x0093}, {0 x6005, 0 x0093}, {0 x6000, 0 x0093},
{0 x6004, 0 x0093}, {0 x6000, 0 x0093}, {0 x6000, 0 x0093}, {0 x6000, 0 x0093},
{0 x6000, 0 x0093}, {0 x6000, 0 x0093}, {0 x6000, 0 x0093}, {0 x6000, 0 x0093},
{0 x6000, 0 x0096}, {0 x6008, 0 x0097}, {0 x6019, 0 x0097}, {0 x6002, 0 x0097},
{0 x600c, 0 x0097}, {0 x6024, 0 x0097}, {0 x6030, 0 x0097}, {0 x6028, 0 x0097},
{0 x6026, 0 x0097}, {0 x6002, 0 x0097}, {0 x6098, 0 x0097}, {0 x6080, 0 x0097},
{0 x6000, 0 x0097}, {0 x6000, 0 x0097}, {0 x60ed, 0 x00c3}, {0 x609a, 0 x00c4},
{0 x6000, 0 x00a4}, {0 x6011, 0 x00c5}, {0 x6051, 0 x00c6}, {0 x6010, 0 x00c7},
{0 x6066, 0 x00b6}, {0 x60a5, 0 x00b8}, {0 x6064, 0 x00b7}, {0 x607c, 0 x00b9},
{0 x60af, 0 x00b3}, {0 x6097, 0 x00b4}, {0 x60ff, 0 x00b5}, {0 x60c5, 0 x00b0},
{0 x6094, 0 x00b1}, {0 x600f, 0 x00b2}, {0 x605c, 0 x00c4}, {0 x6000, 0 x00a8},
{0 x60c8, 0 x00c0}, {0 x6096, 0 x00c1}, {0 x601d, 0 x0086}, {0 x6000, 0 x0050},
{0 x6090, 0 x0051}, {0 x6018, 0 x0052}, {0 x6000, 0 x0053}, {0 x6000, 0 x0054},
{0 x6088, 0 x0055}, {0 x6000, 0 x0057}, {0 x6090, 0 x005a}, {0 x6018, 0 x005b},
{0 x6005, 0 x005c}, {0 x60ed, 0 x00c3}, {0 x6000, 0 x007f}, {0 x6005, 0 x00da},
{0 x601f, 0 x00e5}, {0 x6067, 0 x00e1}, {0 x6000, 0 x00e0}, {0 x60ff, 0 x00dd},
{0 x6000, 0 x0005}, {0 x6001, 0 x00ff}, {0 x6000, 0 x0000}, {0 x6000, 0 x0045},
{0 x6000, 0 x0010},
};
static struct validx tbl_sensor_settings_common1[] = {
{0 x0041, 0 x0000}, {0 x006a, 0 x0007}, {0 x00ef, 0 x0006}, {0 x006a, 0 x000d},
{0 x0000, 0 x00c0}, {0 x0010, 0 x0010}, {0 x0001, 0 x00c1}, {0 x0041, 0 x00c2},
{0 x0004, 0 x00d8}, {0 x0012, 0 x0004}, {0 x0000, 0 x0058}, {0 x0041, 0 x0000},
{50 , 0 xffff},
{0 x0061, 0 x0000},
{0 xffff, 0 xffff},
{0 x6000, 0 x00ff}, {0 x6000, 0 x007c}, {0 x6007, 0 x007d},
{30 , 0 xffff},
{0 x0040, 0 x0000},
};
static struct validx tbl_sensor_settings_common2[] = {
{0 x6001, 0 x00ff}, {0 x6038, 0 x000c},
{10 , 0 xffff},
{0 x6000, 0 x0011},
};
static struct validx tbl_640[] = {
{0 x6000, 0 x00ff}, {0 x60f1, 0 x00dd}, {0 x6004, 0 x00e0}, {0 x6067, 0 x00e1},
{0 x6004, 0 x00da}, {0 x6000, 0 x00ff}, {0 x60f1, 0 x00dd}, {0 x6004, 0 x00e0},
{0 x6001, 0 x00ff}, {0 x6000, 0 x0012}, {0 x6000, 0 x0011}, {0 x6011, 0 x0017},
{0 x6075, 0 x0018}, {0 x6001, 0 x0019}, {0 x6097, 0 x001a}, {0 x6036, 0 x0032},
{0 x60bb, 0 x004f}, {0 x6057, 0 x005a}, {0 x609c, 0 x0050}, {0 x6080, 0 x006d},
{0 x6092, 0 x0026}, {0 x60ff, 0 x0020}, {0 x6000, 0 x0027}, {0 x6000, 0 x00ff},
{0 x60c8, 0 x00c0}, {0 x6096, 0 x00c1}, {0 x6000, 0 x008c}, {0 x603d, 0 x0086},
{0 x6089, 0 x0050}, {0 x6090, 0 x0051}, {0 x602c, 0 x0052}, {0 x6000, 0 x0053},
{0 x6000, 0 x0054}, {0 x6088, 0 x0055}, {0 x6000, 0 x0057}, {0 x60a0, 0 x005a},
{0 x6078, 0 x005b}, {0 x6000, 0 x005c}, {0 x6004, 0 x00d3}, {0 x6000, 0 x00e0},
{0 x60ff, 0 x00dd}, {0 x60a1, 0 x005a},
};
static struct validx tbl_800[] = {
{0 x6000, 0 x00ff}, {0 x60f1, 0 x00dd}, {0 x6004, 0 x00e0}, {0 x6067, 0 x00e1},
{0 x6004, 0 x00da}, {0 x6000, 0 x00ff}, {0 x60f1, 0 x00dd}, {0 x6004, 0 x00e0},
{0 x6001, 0 x00ff}, {0 x6040, 0 x0012}, {0 x6000, 0 x0011}, {0 x6011, 0 x0017},
{0 x6043, 0 x0018}, {0 x6000, 0 x0019}, {0 x604b, 0 x001a}, {0 x6009, 0 x0032},
{0 x60ca, 0 x004f}, {0 x60a8, 0 x0050}, {0 x6000, 0 x006d}, {0 x6038, 0 x003d},
{0 x60c8, 0 x0035}, {0 x6000, 0 x0022}, {0 x6092, 0 x0026}, {0 x60ff, 0 x0020},
{0 x6000, 0 x0027}, {0 x6000, 0 x00ff}, {0 x6064, 0 x00c0}, {0 x604b, 0 x00c1},
{0 x6000, 0 x008c}, {0 x601d, 0 x0086}, {0 x6082, 0 x00d3}, {0 x6000, 0 x00e0},
{0 x60ff, 0 x00dd}, {0 x6020, 0 x008c}, {0 x6001, 0 x00ff}, {0 x6044, 0 x0018},
};
static struct validx tbl_big1[] = {
{0 x0002, 0 x00c1}, {0 x6000, 0 x00ff}, {0 x60f1, 0 x00dd}, {0 x6004, 0 x00e0},
{0 x6001, 0 x00ff}, {0 x6000, 0 x0012}, {0 x6000, 0 x0000}, {0 x6000, 0 x0045},
{0 x6000, 0 x0010}, {0 x6000, 0 x0011}, {0 x6011, 0 x0017}, {0 x6075, 0 x0018},
{0 x6001, 0 x0019}, {0 x6097, 0 x001a}, {0 x6036, 0 x0032}, {0 x60bb, 0 x004f},
{0 x609c, 0 x0050}, {0 x6057, 0 x005a}, {0 x6080, 0 x006d}, {0 x6043, 0 x000f},
{0 x608f, 0 x0003}, {0 x6005, 0 x007c}, {0 x6081, 0 x0026}, {0 x6000, 0 x00ff},
{0 x60c8, 0 x00c0}, {0 x6096, 0 x00c1}, {0 x6000, 0 x008c},
};
static struct validx tbl_big2[] = {
{0 x603d, 0 x0086}, {0 x6000, 0 x0050}, {0 x6090, 0 x0051}, {0 x602c, 0 x0052},
{0 x6000, 0 x0053}, {0 x6000, 0 x0054}, {0 x6088, 0 x0055}, {0 x6000, 0 x0057},
{0 x6040, 0 x005a}, {0 x60f0, 0 x005b}, {0 x6001, 0 x005c}, {0 x6082, 0 x00d3},
{0 x6000, 0 x008e},
};
static struct validx tbl_big3[] = {
{0 x6004, 0 x00da}, {0 x6000, 0 x00e0}, {0 x6067, 0 x00e1}, {0 x60ff, 0 x00dd},
{0 x6001, 0 x00ff}, {0 x6000, 0 x00ff}, {0 x60f1, 0 x00dd}, {0 x6004, 0 x00e0},
{0 x6001, 0 x00ff}, {0 x6000, 0 x0011}, {0 x6000, 0 x00ff}, {0 x6010, 0 x00c7},
{0 x6000, 0 x0092}, {0 x6006, 0 x0093}, {0 x60e3, 0 x0093}, {0 x6005, 0 x0093},
{0 x6005, 0 x0093}, {0 x60ed, 0 x00c3}, {0 x6000, 0 x00a4}, {0 x60d0, 0 x0087},
{0 x6003, 0 x0096}, {0 x600c, 0 x0097}, {0 x6024, 0 x0097}, {0 x6030, 0 x0097},
{0 x6028, 0 x0097}, {0 x6026, 0 x0097}, {0 x6002, 0 x0097}, {0 x6001, 0 x00ff},
{0 x6043, 0 x000f}, {0 x608f, 0 x0003}, {0 x6000, 0 x002d}, {0 x6000, 0 x002e},
{0 x600a, 0 x0022}, {0 x6002, 0 x0070}, {0 x6008, 0 x0014}, {0 x6048, 0 x0014},
{0 x6000, 0 x00ff}, {0 x6000, 0 x00e0}, {0 x60ff, 0 x00dd},
};
static struct validx tbl_post_unset_alt[] = {
{0 x006a, 0 x000d}, {0 x6001, 0 x00ff}, {0 x6081, 0 x0026}, {0 x6000, 0 x0000},
{0 x6000, 0 x0045}, {0 x6000, 0 x0010}, {0 x6068, 0 x000d},
{50 , 0 xffff},
{0 x0021, 0 x0000},
};
static int ov2640_init_at_startup(struct gspca_dev *gspca_dev);
static int ov2640_configure_alt(struct gspca_dev *gspca_dev);
static int ov2640_init_pre_alt(struct gspca_dev *gspca_dev);
static int ov2640_init_post_alt(struct gspca_dev *gspca_dev);
static void ov2640_post_unset_alt(struct gspca_dev *gspca_dev);
static int ov2640_camera_settings(struct gspca_dev *gspca_dev);
/*==========================================================================*/
void ov2640_init_settings(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
sd->vcur.backlight = 32 ;
sd->vcur.brightness = 0 ;
sd->vcur.sharpness = 6 ;
sd->vcur.contrast = 0 ;
sd->vcur.gamma = 32 ;
sd->vcur.hue = 0 ;
sd->vcur.saturation = 128 ;
sd->vcur.whitebal = 64 ;
sd->vcur.mirror = 0 ;
sd->vcur.flip = 0 ;
sd->vmax.backlight = 64 ;
sd->vmax.brightness = 255 ;
sd->vmax.sharpness = 31 ;
sd->vmax.contrast = 255 ;
sd->vmax.gamma = 64 ;
sd->vmax.hue = 254 + 2 ;
sd->vmax.saturation = 255 ;
sd->vmax.whitebal = 128 ;
sd->vmax.mirror = 1 ;
sd->vmax.flip = 1 ;
sd->vmax.AC50Hz = 0 ;
sd->dev_camera_settings = ov2640_camera_settings;
sd->dev_init_at_startup = ov2640_init_at_startup;
sd->dev_configure_alt = ov2640_configure_alt;
sd->dev_init_pre_alt = ov2640_init_pre_alt;
sd->dev_post_unset_alt = ov2640_post_unset_alt;
}
/*==========================================================================*/
static void common(struct gspca_dev *gspca_dev)
{
fetch_validx(gspca_dev, tbl_common, ARRAY_SIZE(tbl_common));
}
static int ov2640_init_at_startup(struct gspca_dev *gspca_dev)
{
fetch_validx(gspca_dev, tbl_init_at_startup,
ARRAY_SIZE(tbl_init_at_startup));
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200, 12 , dat_init1);
common(gspca_dev);
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x0000, 0 x0006, 1 , c61);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x00ef, 0 x0006, 0 , NULL);
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x0000, 0 x0000, 1 , c51);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0051, 0 x0000, 0 , NULL);
/* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */
return 0 ;
}
static int ov2640_init_pre_alt(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
sd->mirrorMask = 0 ;
sd->vold.backlight = -1 ;
sd->vold.brightness = -1 ;
sd->vold.sharpness = -1 ;
sd->vold.contrast = -1 ;
sd->vold.saturation = -1 ;
sd->vold.gamma = -1 ;
sd->vold.hue = -1 ;
sd->vold.whitebal = -1 ;
sd->vold.mirror = -1 ;
sd->vold.flip = -1 ;
ov2640_init_post_alt(gspca_dev);
return 0 ;
}
static int ov2640_init_post_alt(struct gspca_dev *gspca_dev)
{
s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
s32 n; /* reserved for FETCH functions */
ctrl_out(gspca_dev, 0 x40, 5 , 0 x0001, 0 x0000, 0 , NULL);
n = fetch_validx(gspca_dev, tbl_sensor_settings_common1,
ARRAY_SIZE(tbl_sensor_settings_common1));
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200, 12 , dat_post);
common(gspca_dev);
keep_on_fetching_validx(gspca_dev, tbl_sensor_settings_common1,
ARRAY_SIZE(tbl_sensor_settings_common1), n);
switch (reso) {
case IMAGE_640:
n = fetch_validx(gspca_dev, tbl_640, ARRAY_SIZE(tbl_640));
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200, 12 , dat_640);
break ;
case IMAGE_800:
n = fetch_validx(gspca_dev, tbl_800, ARRAY_SIZE(tbl_800));
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200, 12 , dat_800);
break ;
case IMAGE_1600:
case IMAGE_1280:
n = fetch_validx(gspca_dev, tbl_big1, ARRAY_SIZE(tbl_big1));
if (reso == IMAGE_1280) {
n = fetch_validx(gspca_dev, tbl_big2,
ARRAY_SIZE(tbl_big2));
} else {
ctrl_out(gspca_dev, 0 x40, 1 , 0 x601d, 0 x0086, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001, 0 x00d7, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6082, 0 x00d3, 0 , NULL);
}
n = fetch_validx(gspca_dev, tbl_big3, ARRAY_SIZE(tbl_big3));
if (reso == IMAGE_1280) {
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001, 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200,
12 , dat_1280);
} else {
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6020, 0 x008c, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001, 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6076, 0 x0018, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200,
12 , dat_1600);
}
break ;
}
n = fetch_validx(gspca_dev, tbl_sensor_settings_common2,
ARRAY_SIZE(tbl_sensor_settings_common2));
ov2640_camera_settings(gspca_dev);
return 0 ;
}
static int ov2640_configure_alt(struct gspca_dev *gspca_dev)
{
s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
switch (reso) {
case IMAGE_640:
gspca_dev->alt = 3 + 1 ;
break ;
case IMAGE_800:
case IMAGE_1280:
case IMAGE_1600:
gspca_dev->alt = 1 + 1 ;
break ;
}
return 0 ;
}
static int ov2640_camera_settings(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 backlight = sd->vcur.backlight;
s32 bright = sd->vcur.brightness;
s32 sharp = sd->vcur.sharpness;
s32 gam = sd->vcur.gamma;
s32 cntr = sd->vcur.contrast;
s32 sat = sd->vcur.saturation;
s32 hue = sd->vcur.hue;
s32 wbal = sd->vcur.whitebal;
s32 mirror = (((sd->vcur.mirror > 0 ) ^ sd->mirrorMask) == 0 );
s32 flip = (((sd->vcur.flip > 0 ) ^ sd->mirrorMask) == 0 );
if (backlight != sd->vold.backlight) {
/* No sd->vold.backlight=backlight; (to be done again later) */
if (backlight < 0 || backlight > sd->vmax.backlight)
backlight = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001 , 0 x00ff,
0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x601e + backlight , 0 x0024,
0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x601e + backlight - 10 , 0 x0025,
0 , NULL);
}
if (bright != sd->vold.brightness) {
sd->vold.brightness = bright;
if (bright < 0 || bright > sd->vmax.brightness)
bright = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 , 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6009 , 0 x007c, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 + bright, 0 x007d, 0 , NULL);
}
if (wbal != sd->vold.whitebal) {
sd->vold.whitebal = wbal;
if (wbal < 0 || wbal > sd->vmax.whitebal)
wbal = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 , 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6003 , 0 x007c, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 + wbal, 0 x007d, 0 , NULL);
}
if (cntr != sd->vold.contrast) {
sd->vold.contrast = cntr;
if (cntr < 0 || cntr > sd->vmax.contrast)
cntr = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 , 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6007 , 0 x007c, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 + cntr, 0 x007d, 0 , NULL);
}
if (sat != sd->vold.saturation) {
sd->vold.saturation = sat;
if (sat < 0 || sat > sd->vmax.saturation)
sat = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 , 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001 , 0 x007c, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 + sat, 0 x007d, 0 , NULL);
}
if (sharp != sd->vold.sharpness) {
sd->vold.sharpness = sharp;
if (sharp < 0 || sharp > sd->vmax.sharpness)
sharp = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 , 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001 , 0 x0092, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x60c0 + sharp, 0 x0093, 0 , NULL);
}
if (hue != sd->vold.hue) {
sd->vold.hue = hue;
if (hue < 0 || hue > sd->vmax.hue)
hue = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 , 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6002 , 0 x007c, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 + hue * (hue < 255 ), 0 x007d,
0 , NULL);
if (hue >= 255 )
sd->swapRB = 1 ;
else
sd->swapRB = 0 ;
}
if (gam != sd->vold.gamma) {
sd->vold.gamma = gam;
if (gam < 0 || gam > sd->vmax.gamma)
gam = 0 ;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 , 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6008 , 0 x007c, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000 + gam, 0 x007d, 0 , NULL);
}
if (mirror != sd->vold.mirror || flip != sd->vold.flip) {
sd->vold.mirror = mirror;
sd->vold.flip = flip;
mirror = 0 x80 * mirror;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001, 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000, 0 x8004, 0 , NULL);
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x6000, 0 x8004, 1 , c28);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6028 + mirror, 0 x0004, 0 , NULL);
flip = 0 x50 * flip + mirror;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001, 0 x00ff, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6000, 0 x8004, 0 , NULL);
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x6000, 0 x8004, 1 , ca8);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6028 + flip, 0 x0004, 0 , NULL);
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x0000, 0 x0000, 1 , c50);
}
if (backlight != sd->vold.backlight) {
sd->vold.backlight = backlight;
ctrl_out(gspca_dev, 0 x40, 1 , 0 x6001 , 0 x00ff,
0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x601e + backlight , 0 x0024,
0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x601e + backlight - 10 , 0 x0025,
0 , NULL);
}
return 0 ;
}
static void ov2640_post_unset_alt(struct gspca_dev *gspca_dev)
{
ctrl_out(gspca_dev, 0 x40, 5 , 0 x0000, 0 x0000, 0 , NULL);
msleep(20 );
fetch_validx(gspca_dev, tbl_post_unset_alt,
ARRAY_SIZE(tbl_post_unset_alt));
}
Messung V0.5 in Prozent C=94 H=94 G=93