Path: blob/master/drivers/media/video/gspca/gl860/gl860-ov2640.c
17902 views
/* Subdriver for the GL860 chip with the OV2640 sensor1* Author Olivier LORIN, from Malmostoso's logs2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation; either version 2 of the License, or6* any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with this program. If not, see <http://www.gnu.org/licenses/>.15*/1617/* Sensor : OV2640 */1819#include "gl860.h"2021static u8 dat_init1[] = "\x00\x41\x07\x6a\x06\x61\x0d\x6a" "\x10\x10\xc1\x01";2223static u8 c61[] = {0x61}; /* expected */24static u8 c51[] = {0x51}; /* expected */25static u8 c50[] = {0x50}; /* expected */26static u8 c28[] = {0x28}; /* expected */27static u8 ca8[] = {0xa8}; /* expected */2829static u8 dat_post[] =30"\x00\x41\x07\x6a\x06\xef\x0d\x6a" "\x10\x10\xc1\x01";3132static u8 dat_640[] = "\xd0\x01\xd1\x08\xd2\xe0\xd3\x02\xd4\x10\xd5\x81";33static u8 dat_800[] = "\xd0\x01\xd1\x10\xd2\x58\xd3\x02\xd4\x18\xd5\x21";34static u8 dat_1280[] = "\xd0\x01\xd1\x18\xd2\xc0\xd3\x02\xd4\x28\xd5\x01";35static u8 dat_1600[] = "\xd0\x01\xd1\x20\xd2\xb0\xd3\x02\xd4\x30\xd5\x41";3637static struct validx tbl_init_at_startup[] = {38{0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001, 0x00c1},39{0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d},40{0x0050, 0x0000}, {0x0041, 0x0000}, {0x006a, 0x0007}, {0x0061, 0x0006},41{0x006a, 0x000d}, {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0001, 0x00c1},42{0x0041, 0x00c2}, {0x0004, 0x00d8}, {0x0012, 0x0004}, {0x0000, 0x0058},43{0x0041, 0x0000}, {0x0061, 0x0000},44};4546static struct validx tbl_common[] = {47{0x6000, 0x00ff}, {0x60ff, 0x002c}, {0x60df, 0x002e}, {0x6001, 0x00ff},48{0x6080, 0x0012}, {0x6000, 0x0000}, {0x6000, 0x0045}, {0x6000, 0x0010},49{0x6035, 0x003c}, {0x6000, 0x0011}, {0x6028, 0x0004}, {0x60e5, 0x0013},50{0x6088, 0x0014}, {0x600c, 0x002c}, {0x6078, 0x0033}, {0x60f7, 0x003b},51{0x6000, 0x003e}, {0x6011, 0x0043}, {0x6010, 0x0016}, {0x6082, 0x0039},52{0x6088, 0x0035}, {0x600a, 0x0022}, {0x6040, 0x0037}, {0x6000, 0x0023},53{0x60a0, 0x0034}, {0x601a, 0x0036}, {0x6002, 0x0006}, {0x60c0, 0x0007},54{0x60b7, 0x000d}, {0x6001, 0x000e}, {0x6000, 0x004c}, {0x6081, 0x004a},55{0x6099, 0x0021}, {0x6002, 0x0009}, {0x603e, 0x0024}, {0x6034, 0x0025},56{0x6081, 0x0026}, {0x6000, 0x0000}, {0x6000, 0x0045}, {0x6000, 0x0010},57{0x6000, 0x005c}, {0x6000, 0x0063}, {0x6000, 0x007c}, {0x6070, 0x0061},58{0x6080, 0x0062}, {0x6080, 0x0020}, {0x6030, 0x0028}, {0x6000, 0x006c},59{0x6000, 0x006e}, {0x6002, 0x0070}, {0x6094, 0x0071}, {0x60c1, 0x0073},60{0x6034, 0x003d}, {0x6057, 0x005a}, {0x60bb, 0x004f}, {0x609c, 0x0050},61{0x6080, 0x006d}, {0x6002, 0x0039}, {0x6033, 0x003a}, {0x60f1, 0x003b},62{0x6031, 0x003c}, {0x6000, 0x00ff}, {0x6014, 0x00e0}, {0x60ff, 0x0076},63{0x60a0, 0x0033}, {0x6020, 0x0042}, {0x6018, 0x0043}, {0x6000, 0x004c},64{0x60d0, 0x0087}, {0x600f, 0x0088}, {0x6003, 0x00d7}, {0x6010, 0x00d9},65{0x6005, 0x00da}, {0x6082, 0x00d3}, {0x60c0, 0x00f9}, {0x6006, 0x0044},66{0x6007, 0x00d1}, {0x6002, 0x00d2}, {0x6000, 0x00d2}, {0x6011, 0x00d8},67{0x6008, 0x00c8}, {0x6080, 0x00c9}, {0x6008, 0x007c}, {0x6020, 0x007d},68{0x6020, 0x007d}, {0x6000, 0x0090}, {0x600e, 0x0091}, {0x601a, 0x0091},69{0x6031, 0x0091}, {0x605a, 0x0091}, {0x6069, 0x0091}, {0x6075, 0x0091},70{0x607e, 0x0091}, {0x6088, 0x0091}, {0x608f, 0x0091}, {0x6096, 0x0091},71{0x60a3, 0x0091}, {0x60af, 0x0091}, {0x60c4, 0x0091}, {0x60d7, 0x0091},72{0x60e8, 0x0091}, {0x6020, 0x0091}, {0x6000, 0x0092}, {0x6006, 0x0093},73{0x60e3, 0x0093}, {0x6005, 0x0093}, {0x6005, 0x0093}, {0x6000, 0x0093},74{0x6004, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093},75{0x6000, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093},76{0x6000, 0x0096}, {0x6008, 0x0097}, {0x6019, 0x0097}, {0x6002, 0x0097},77{0x600c, 0x0097}, {0x6024, 0x0097}, {0x6030, 0x0097}, {0x6028, 0x0097},78{0x6026, 0x0097}, {0x6002, 0x0097}, {0x6098, 0x0097}, {0x6080, 0x0097},79{0x6000, 0x0097}, {0x6000, 0x0097}, {0x60ed, 0x00c3}, {0x609a, 0x00c4},80{0x6000, 0x00a4}, {0x6011, 0x00c5}, {0x6051, 0x00c6}, {0x6010, 0x00c7},81{0x6066, 0x00b6}, {0x60a5, 0x00b8}, {0x6064, 0x00b7}, {0x607c, 0x00b9},82{0x60af, 0x00b3}, {0x6097, 0x00b4}, {0x60ff, 0x00b5}, {0x60c5, 0x00b0},83{0x6094, 0x00b1}, {0x600f, 0x00b2}, {0x605c, 0x00c4}, {0x6000, 0x00a8},84{0x60c8, 0x00c0}, {0x6096, 0x00c1}, {0x601d, 0x0086}, {0x6000, 0x0050},85{0x6090, 0x0051}, {0x6018, 0x0052}, {0x6000, 0x0053}, {0x6000, 0x0054},86{0x6088, 0x0055}, {0x6000, 0x0057}, {0x6090, 0x005a}, {0x6018, 0x005b},87{0x6005, 0x005c}, {0x60ed, 0x00c3}, {0x6000, 0x007f}, {0x6005, 0x00da},88{0x601f, 0x00e5}, {0x6067, 0x00e1}, {0x6000, 0x00e0}, {0x60ff, 0x00dd},89{0x6000, 0x0005}, {0x6001, 0x00ff}, {0x6000, 0x0000}, {0x6000, 0x0045},90{0x6000, 0x0010},91};9293static struct validx tbl_sensor_settings_common1[] = {94{0x0041, 0x0000}, {0x006a, 0x0007}, {0x00ef, 0x0006}, {0x006a, 0x000d},95{0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0001, 0x00c1}, {0x0041, 0x00c2},96{0x0004, 0x00d8}, {0x0012, 0x0004}, {0x0000, 0x0058}, {0x0041, 0x0000},97{50, 0xffff},98{0x0061, 0x0000},99{0xffff, 0xffff},100{0x6000, 0x00ff}, {0x6000, 0x007c}, {0x6007, 0x007d},101{30, 0xffff},102{0x0040, 0x0000},103};104105static struct validx tbl_sensor_settings_common2[] = {106{0x6001, 0x00ff}, {0x6038, 0x000c},107{10, 0xffff},108{0x6000, 0x0011},109};110111static struct validx tbl_640[] = {112{0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, {0x6067, 0x00e1},113{0x6004, 0x00da}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0},114{0x6001, 0x00ff}, {0x6000, 0x0012}, {0x6000, 0x0011}, {0x6011, 0x0017},115{0x6075, 0x0018}, {0x6001, 0x0019}, {0x6097, 0x001a}, {0x6036, 0x0032},116{0x60bb, 0x004f}, {0x6057, 0x005a}, {0x609c, 0x0050}, {0x6080, 0x006d},117{0x6092, 0x0026}, {0x60ff, 0x0020}, {0x6000, 0x0027}, {0x6000, 0x00ff},118{0x60c8, 0x00c0}, {0x6096, 0x00c1}, {0x6000, 0x008c}, {0x603d, 0x0086},119{0x6089, 0x0050}, {0x6090, 0x0051}, {0x602c, 0x0052}, {0x6000, 0x0053},120{0x6000, 0x0054}, {0x6088, 0x0055}, {0x6000, 0x0057}, {0x60a0, 0x005a},121{0x6078, 0x005b}, {0x6000, 0x005c}, {0x6004, 0x00d3}, {0x6000, 0x00e0},122{0x60ff, 0x00dd}, {0x60a1, 0x005a},123};124125static struct validx tbl_800[] = {126{0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, {0x6067, 0x00e1},127{0x6004, 0x00da}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0},128{0x6001, 0x00ff}, {0x6040, 0x0012}, {0x6000, 0x0011}, {0x6011, 0x0017},129{0x6043, 0x0018}, {0x6000, 0x0019}, {0x604b, 0x001a}, {0x6009, 0x0032},130{0x60ca, 0x004f}, {0x60a8, 0x0050}, {0x6000, 0x006d}, {0x6038, 0x003d},131{0x60c8, 0x0035}, {0x6000, 0x0022}, {0x6092, 0x0026}, {0x60ff, 0x0020},132{0x6000, 0x0027}, {0x6000, 0x00ff}, {0x6064, 0x00c0}, {0x604b, 0x00c1},133{0x6000, 0x008c}, {0x601d, 0x0086}, {0x6082, 0x00d3}, {0x6000, 0x00e0},134{0x60ff, 0x00dd}, {0x6020, 0x008c}, {0x6001, 0x00ff}, {0x6044, 0x0018},135};136137static struct validx tbl_big1[] = {138{0x0002, 0x00c1}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0},139{0x6001, 0x00ff}, {0x6000, 0x0012}, {0x6000, 0x0000}, {0x6000, 0x0045},140{0x6000, 0x0010}, {0x6000, 0x0011}, {0x6011, 0x0017}, {0x6075, 0x0018},141{0x6001, 0x0019}, {0x6097, 0x001a}, {0x6036, 0x0032}, {0x60bb, 0x004f},142{0x609c, 0x0050}, {0x6057, 0x005a}, {0x6080, 0x006d}, {0x6043, 0x000f},143{0x608f, 0x0003}, {0x6005, 0x007c}, {0x6081, 0x0026}, {0x6000, 0x00ff},144{0x60c8, 0x00c0}, {0x6096, 0x00c1}, {0x6000, 0x008c},145};146147static struct validx tbl_big2[] = {148{0x603d, 0x0086}, {0x6000, 0x0050}, {0x6090, 0x0051}, {0x602c, 0x0052},149{0x6000, 0x0053}, {0x6000, 0x0054}, {0x6088, 0x0055}, {0x6000, 0x0057},150{0x6040, 0x005a}, {0x60f0, 0x005b}, {0x6001, 0x005c}, {0x6082, 0x00d3},151{0x6000, 0x008e},152};153154static struct validx tbl_big3[] = {155{0x6004, 0x00da}, {0x6000, 0x00e0}, {0x6067, 0x00e1}, {0x60ff, 0x00dd},156{0x6001, 0x00ff}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0},157{0x6001, 0x00ff}, {0x6000, 0x0011}, {0x6000, 0x00ff}, {0x6010, 0x00c7},158{0x6000, 0x0092}, {0x6006, 0x0093}, {0x60e3, 0x0093}, {0x6005, 0x0093},159{0x6005, 0x0093}, {0x60ed, 0x00c3}, {0x6000, 0x00a4}, {0x60d0, 0x0087},160{0x6003, 0x0096}, {0x600c, 0x0097}, {0x6024, 0x0097}, {0x6030, 0x0097},161{0x6028, 0x0097}, {0x6026, 0x0097}, {0x6002, 0x0097}, {0x6001, 0x00ff},162{0x6043, 0x000f}, {0x608f, 0x0003}, {0x6000, 0x002d}, {0x6000, 0x002e},163{0x600a, 0x0022}, {0x6002, 0x0070}, {0x6008, 0x0014}, {0x6048, 0x0014},164{0x6000, 0x00ff}, {0x6000, 0x00e0}, {0x60ff, 0x00dd},165};166167static struct validx tbl_post_unset_alt[] = {168{0x006a, 0x000d}, {0x6001, 0x00ff}, {0x6081, 0x0026}, {0x6000, 0x0000},169{0x6000, 0x0045}, {0x6000, 0x0010}, {0x6068, 0x000d},170{50, 0xffff},171{0x0021, 0x0000},172};173174static int ov2640_init_at_startup(struct gspca_dev *gspca_dev);175static int ov2640_configure_alt(struct gspca_dev *gspca_dev);176static int ov2640_init_pre_alt(struct gspca_dev *gspca_dev);177static int ov2640_init_post_alt(struct gspca_dev *gspca_dev);178static void ov2640_post_unset_alt(struct gspca_dev *gspca_dev);179static int ov2640_camera_settings(struct gspca_dev *gspca_dev);180/*==========================================================================*/181182void ov2640_init_settings(struct gspca_dev *gspca_dev)183{184struct sd *sd = (struct sd *) gspca_dev;185186sd->vcur.backlight = 32;187sd->vcur.brightness = 0;188sd->vcur.sharpness = 6;189sd->vcur.contrast = 0;190sd->vcur.gamma = 32;191sd->vcur.hue = 0;192sd->vcur.saturation = 128;193sd->vcur.whitebal = 64;194sd->vcur.mirror = 0;195sd->vcur.flip = 0;196197sd->vmax.backlight = 64;198sd->vmax.brightness = 255;199sd->vmax.sharpness = 31;200sd->vmax.contrast = 255;201sd->vmax.gamma = 64;202sd->vmax.hue = 254 + 2;203sd->vmax.saturation = 255;204sd->vmax.whitebal = 128;205sd->vmax.mirror = 1;206sd->vmax.flip = 1;207sd->vmax.AC50Hz = 0;208209sd->dev_camera_settings = ov2640_camera_settings;210sd->dev_init_at_startup = ov2640_init_at_startup;211sd->dev_configure_alt = ov2640_configure_alt;212sd->dev_init_pre_alt = ov2640_init_pre_alt;213sd->dev_post_unset_alt = ov2640_post_unset_alt;214}215216/*==========================================================================*/217218static void common(struct gspca_dev *gspca_dev)219{220fetch_validx(gspca_dev, tbl_common, ARRAY_SIZE(tbl_common));221}222223static int ov2640_init_at_startup(struct gspca_dev *gspca_dev)224{225fetch_validx(gspca_dev, tbl_init_at_startup,226ARRAY_SIZE(tbl_init_at_startup));227228ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_init1);229230common(gspca_dev);231232ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0006, 1, c61);233234ctrl_out(gspca_dev, 0x40, 1, 0x00ef, 0x0006, 0, NULL);235236ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, c51);237238ctrl_out(gspca_dev, 0x40, 1, 0x0051, 0x0000, 0, NULL);239/* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */240241return 0;242}243244static int ov2640_init_pre_alt(struct gspca_dev *gspca_dev)245{246struct sd *sd = (struct sd *) gspca_dev;247248sd->mirrorMask = 0;249250sd->vold.backlight = -1;251sd->vold.brightness = -1;252sd->vold.sharpness = -1;253sd->vold.contrast = -1;254sd->vold.saturation = -1;255sd->vold.gamma = -1;256sd->vold.hue = -1;257sd->vold.whitebal = -1;258sd->vold.mirror = -1;259sd->vold.flip = -1;260261ov2640_init_post_alt(gspca_dev);262263return 0;264}265266static int ov2640_init_post_alt(struct gspca_dev *gspca_dev)267{268s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;269s32 n; /* reserved for FETCH functions */270271ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL);272273n = fetch_validx(gspca_dev, tbl_sensor_settings_common1,274ARRAY_SIZE(tbl_sensor_settings_common1));275ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_post);276common(gspca_dev);277keep_on_fetching_validx(gspca_dev, tbl_sensor_settings_common1,278ARRAY_SIZE(tbl_sensor_settings_common1), n);279280switch (reso) {281case IMAGE_640:282n = fetch_validx(gspca_dev, tbl_640, ARRAY_SIZE(tbl_640));283ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_640);284break;285286case IMAGE_800:287n = fetch_validx(gspca_dev, tbl_800, ARRAY_SIZE(tbl_800));288ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_800);289break;290291case IMAGE_1600:292case IMAGE_1280:293n = fetch_validx(gspca_dev, tbl_big1, ARRAY_SIZE(tbl_big1));294295if (reso == IMAGE_1280) {296n = fetch_validx(gspca_dev, tbl_big2,297ARRAY_SIZE(tbl_big2));298} else {299ctrl_out(gspca_dev, 0x40, 1, 0x601d, 0x0086, 0, NULL);300ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00d7, 0, NULL);301ctrl_out(gspca_dev, 0x40, 1, 0x6082, 0x00d3, 0, NULL);302}303304n = fetch_validx(gspca_dev, tbl_big3, ARRAY_SIZE(tbl_big3));305306if (reso == IMAGE_1280) {307ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL);308ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,30912, dat_1280);310} else {311ctrl_out(gspca_dev, 0x40, 1, 0x6020, 0x008c, 0, NULL);312ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL);313ctrl_out(gspca_dev, 0x40, 1, 0x6076, 0x0018, 0, NULL);314ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,31512, dat_1600);316}317break;318}319320n = fetch_validx(gspca_dev, tbl_sensor_settings_common2,321ARRAY_SIZE(tbl_sensor_settings_common2));322323ov2640_camera_settings(gspca_dev);324325return 0;326}327328static int ov2640_configure_alt(struct gspca_dev *gspca_dev)329{330s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;331332switch (reso) {333case IMAGE_640:334gspca_dev->alt = 3 + 1;335break;336337case IMAGE_800:338case IMAGE_1280:339case IMAGE_1600:340gspca_dev->alt = 1 + 1;341break;342}343return 0;344}345346static int ov2640_camera_settings(struct gspca_dev *gspca_dev)347{348struct sd *sd = (struct sd *) gspca_dev;349350s32 backlight = sd->vcur.backlight;351s32 bright = sd->vcur.brightness;352s32 sharp = sd->vcur.sharpness;353s32 gam = sd->vcur.gamma;354s32 cntr = sd->vcur.contrast;355s32 sat = sd->vcur.saturation;356s32 hue = sd->vcur.hue;357s32 wbal = sd->vcur.whitebal;358s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) == 0);359s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) == 0);360361if (backlight != sd->vold.backlight) {362/* No sd->vold.backlight=backlight; (to be done again later) */363if (backlight < 0 || backlight > sd->vmax.backlight)364backlight = 0;365366ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x00ff,3670, NULL);368ctrl_out(gspca_dev, 0x40, 1, 0x601e + backlight , 0x0024,3690, NULL);370ctrl_out(gspca_dev, 0x40, 1, 0x601e + backlight - 10, 0x0025,3710, NULL);372}373374if (bright != sd->vold.brightness) {375sd->vold.brightness = bright;376if (bright < 0 || bright > sd->vmax.brightness)377bright = 0;378379ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL);380ctrl_out(gspca_dev, 0x40, 1, 0x6009 , 0x007c, 0, NULL);381ctrl_out(gspca_dev, 0x40, 1, 0x6000 + bright, 0x007d, 0, NULL);382}383384if (wbal != sd->vold.whitebal) {385sd->vold.whitebal = wbal;386if (wbal < 0 || wbal > sd->vmax.whitebal)387wbal = 0;388389ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL);390ctrl_out(gspca_dev, 0x40, 1, 0x6003 , 0x007c, 0, NULL);391ctrl_out(gspca_dev, 0x40, 1, 0x6000 + wbal, 0x007d, 0, NULL);392}393394if (cntr != sd->vold.contrast) {395sd->vold.contrast = cntr;396if (cntr < 0 || cntr > sd->vmax.contrast)397cntr = 0;398399ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL);400ctrl_out(gspca_dev, 0x40, 1, 0x6007 , 0x007c, 0, NULL);401ctrl_out(gspca_dev, 0x40, 1, 0x6000 + cntr, 0x007d, 0, NULL);402}403404if (sat != sd->vold.saturation) {405sd->vold.saturation = sat;406if (sat < 0 || sat > sd->vmax.saturation)407sat = 0;408409ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL);410ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x007c, 0, NULL);411ctrl_out(gspca_dev, 0x40, 1, 0x6000 + sat, 0x007d, 0, NULL);412}413414if (sharp != sd->vold.sharpness) {415sd->vold.sharpness = sharp;416if (sharp < 0 || sharp > sd->vmax.sharpness)417sharp = 0;418419ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL);420ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x0092, 0, NULL);421ctrl_out(gspca_dev, 0x40, 1, 0x60c0 + sharp, 0x0093, 0, NULL);422}423424if (hue != sd->vold.hue) {425sd->vold.hue = hue;426if (hue < 0 || hue > sd->vmax.hue)427hue = 0;428429ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL);430ctrl_out(gspca_dev, 0x40, 1, 0x6002 , 0x007c, 0, NULL);431ctrl_out(gspca_dev, 0x40, 1, 0x6000 + hue * (hue < 255), 0x007d,4320, NULL);433if (hue >= 255)434sd->swapRB = 1;435else436sd->swapRB = 0;437}438439if (gam != sd->vold.gamma) {440sd->vold.gamma = gam;441if (gam < 0 || gam > sd->vmax.gamma)442gam = 0;443444ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL);445ctrl_out(gspca_dev, 0x40, 1, 0x6008 , 0x007c, 0, NULL);446ctrl_out(gspca_dev, 0x40, 1, 0x6000 + gam, 0x007d, 0, NULL);447}448449if (mirror != sd->vold.mirror || flip != sd->vold.flip) {450sd->vold.mirror = mirror;451sd->vold.flip = flip;452453mirror = 0x80 * mirror;454ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL);455ctrl_out(gspca_dev, 0x40, 1, 0x6000, 0x8004, 0, NULL);456ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x8004, 1, c28);457ctrl_out(gspca_dev, 0x40, 1, 0x6028 + mirror, 0x0004, 0, NULL);458459flip = 0x50 * flip + mirror;460ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL);461ctrl_out(gspca_dev, 0x40, 1, 0x6000, 0x8004, 0, NULL);462ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x8004, 1, ca8);463ctrl_out(gspca_dev, 0x40, 1, 0x6028 + flip, 0x0004, 0, NULL);464465ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, c50);466}467468if (backlight != sd->vold.backlight) {469sd->vold.backlight = backlight;470471ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x00ff,4720, NULL);473ctrl_out(gspca_dev, 0x40, 1, 0x601e + backlight , 0x0024,4740, NULL);475ctrl_out(gspca_dev, 0x40, 1, 0x601e + backlight - 10, 0x0025,4760, NULL);477}478479return 0;480}481482static void ov2640_post_unset_alt(struct gspca_dev *gspca_dev)483{484ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL);485msleep(20);486fetch_validx(gspca_dev, tbl_post_unset_alt,487ARRAY_SIZE(tbl_post_unset_alt));488}489490491