// SPDX-License-Identifier: GPL-2.0-or-later
/* Subdriver for the GL860 chip with the MI2020 sensor
* Author Olivier LORIN, from logs by Iceman/Soro2005 + Fret_saw/Hulkie/Tricid
* with the help of Kytrix/BUGabundo/Blazercist.
* Driver achieved thanks to a webcam gift by Kytrix.
*/
/* Sensor : MI2020 */
#include "gl860.h"
static u8 dat_wbal1[] = {0 x8c, 0 xa2, 0 x0c};
static u8 dat_bright1[] = {0 x8c, 0 xa2, 0 x06};
static u8 dat_bright3[] = {0 x8c, 0 xa1, 0 x02};
static u8 dat_bright4[] = {0 x90, 0 x00, 0 x0f};
static u8 dat_bright5[] = {0 x8c, 0 xa1, 0 x03};
static u8 dat_bright6[] = {0 x90, 0 x00, 0 x05};
static u8 dat_hvflip1[] = {0 x8c, 0 x27, 0 x19};
static u8 dat_hvflip3[] = {0 x8c, 0 x27, 0 x3b};
static u8 dat_hvflip5[] = {0 x8c, 0 xa1, 0 x03};
static u8 dat_hvflip6[] = {0 x90, 0 x00, 0 x06};
static struct idxdata tbl_middle_hvflip_low[] = {
{0 x33, {0 x90, 0 x00, 0 x06}},
{6 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x90, 0 x00, 0 x06}},
{6 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x90, 0 x00, 0 x06}},
{6 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x90, 0 x00, 0 x06}},
{6 , {0 xff, 0 xff, 0 xff}},
};
static struct idxdata tbl_middle_hvflip_big[] = {
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{102 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x02}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x72}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x01}},
};
static struct idxdata tbl_end_hvflip[] = {
{0 x33, {0 x8c, 0 xa1, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x1f}},
{6 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x1f}},
{6 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x1f}},
{6 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x1f}},
};
static u8 dat_freq1[] = { 0 x8c, 0 xa4, 0 x04 };
static u8 dat_multi5[] = { 0 x8c, 0 xa1, 0 x03 };
static u8 dat_multi6[] = { 0 x90, 0 x00, 0 x05 };
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},
{53 , 0 xffff},
{0 x0040, 0 x0000}, {0 x0063, 0 x0006},
};
static struct validx tbl_common_0B[] = {
{0 x0002, 0 x0004}, {0 x006a, 0 x0007}, {0 x00ef, 0 x0006}, {0 x006a, 0 x000d},
{0 x0000, 0 x00c0}, {0 x0010, 0 x0010}, {0 x0003, 0 x00c1}, {0 x0042, 0 x00c2},
{0 x0004, 0 x00d8}, {0 x0000, 0 x0058}, {0 x0041, 0 x0000},
};
static struct idxdata tbl_common_3B[] = {
{0 x33, {0 x86, 0 x25, 0 x01}}, {0 x33, {0 x86, 0 x25, 0 x00}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x30, {0 x1a, 0 x0a, 0 xcc}}, {0 x32, {0 x02, 0 x00, 0 x08}},
{0 x33, {0 xf4, 0 x03, 0 x1d}},
{6 , {0 xff, 0 xff, 0 xff}}, /* 12 */
{0 x34, {0 x1e, 0 x8f, 0 x09}}, {0 x34, {0 x1c, 0 x01, 0 x28}},
{0 x34, {0 x1e, 0 x8f, 0 x09}},
{2 , {0 xff, 0 xff, 0 xff}}, /* - */
{0 x34, {0 x1e, 0 x8f, 0 x09}}, {0 x32, {0 x14, 0 x06, 0 xe6}},
{0 x33, {0 x8c, 0 x22, 0 x23}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 xa2, 0 x0f}}, {0 x33, {0 x90, 0 x00, 0 x0d}},
{0 x33, {0 x8c, 0 xa2, 0 x10}}, {0 x33, {0 x90, 0 x00, 0 x0b}},
{0 x33, {0 x8c, 0 xa2, 0 x11}}, {0 x33, {0 x90, 0 x00, 0 x07}},
{0 x33, {0 xf4, 0 x03, 0 x1d}}, {0 x35, {0 xa2, 0 x00, 0 xe2}},
{0 x33, {0 x8c, 0 xab, 0 x05}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{0 x32, {0 x6e, 0 x00, 0 x86}}, {0 x32, {0 x70, 0 x0f, 0 xaa}},
{0 x32, {0 x72, 0 x0f, 0 xe4}}, {0 x33, {0 x8c, 0 xa3, 0 x4a}},
{0 x33, {0 x90, 0 x00, 0 x5a}}, {0 x33, {0 x8c, 0 xa3, 0 x4b}},
{0 x33, {0 x90, 0 x00, 0 xa6}}, {0 x33, {0 x8c, 0 xa3, 0 x61}},
{0 x33, {0 x90, 0 x00, 0 xc8}}, {0 x33, {0 x8c, 0 xa3, 0 x62}},
{0 x33, {0 x90, 0 x00, 0 xe1}}, {0 x34, {0 xce, 0 x01, 0 xa8}},
{0 x34, {0 xd0, 0 x66, 0 x33}}, {0 x34, {0 xd2, 0 x31, 0 x9a}},
{0 x34, {0 xd4, 0 x94, 0 x63}}, {0 x34, {0 xd6, 0 x4b, 0 x25}},
{0 x34, {0 xd8, 0 x26, 0 x70}}, {0 x34, {0 xda, 0 x72, 0 x4c}},
{0 x34, {0 xdc, 0 xff, 0 x04}}, {0 x34, {0 xde, 0 x01, 0 x5b}},
{0 x34, {0 xe6, 0 x01, 0 x13}}, {0 x34, {0 xee, 0 x0b, 0 xf0}},
{0 x34, {0 xf6, 0 x0b, 0 xa4}}, {0 x35, {0 x00, 0 xf6, 0 xe7}},
{0 x35, {0 x08, 0 x0d, 0 xfd}}, {0 x35, {0 x10, 0 x25, 0 x63}},
{0 x35, {0 x18, 0 x35, 0 x6c}}, {0 x35, {0 x20, 0 x42, 0 x7e}},
{0 x35, {0 x28, 0 x19, 0 x44}}, {0 x35, {0 x30, 0 x39, 0 xd4}},
{0 x35, {0 x38, 0 xf5, 0 xa8}}, {0 x35, {0 x4c, 0 x07, 0 x90}},
{0 x35, {0 x44, 0 x07, 0 xb8}}, {0 x35, {0 x5c, 0 x06, 0 x88}},
{0 x35, {0 x54, 0 x07, 0 xff}}, {0 x34, {0 xe0, 0 x01, 0 x52}},
{0 x34, {0 xe8, 0 x00, 0 xcc}}, {0 x34, {0 xf0, 0 x0d, 0 x83}},
{0 x34, {0 xf8, 0 x0c, 0 xb3}}, {0 x35, {0 x02, 0 xfe, 0 xba}},
{0 x35, {0 x0a, 0 x04, 0 xe0}}, {0 x35, {0 x12, 0 x1c, 0 x63}},
{0 x35, {0 x1a, 0 x2b, 0 x5a}}, {0 x35, {0 x22, 0 x32, 0 x5e}},
{0 x35, {0 x2a, 0 x0d, 0 x28}}, {0 x35, {0 x32, 0 x2c, 0 x02}},
{0 x35, {0 x3a, 0 xf4, 0 xfa}}, {0 x35, {0 x4e, 0 x07, 0 xef}},
{0 x35, {0 x46, 0 x07, 0 x88}}, {0 x35, {0 x5e, 0 x07, 0 xc1}},
{0 x35, {0 x56, 0 x04, 0 x64}}, {0 x34, {0 xe4, 0 x01, 0 x15}},
{0 x34, {0 xec, 0 x00, 0 x82}}, {0 x34, {0 xf4, 0 x0c, 0 xce}},
{0 x34, {0 xfc, 0 x0c, 0 xba}}, {0 x35, {0 x06, 0 x1f, 0 x02}},
{0 x35, {0 x0e, 0 x02, 0 xe3}}, {0 x35, {0 x16, 0 x1a, 0 x50}},
{0 x35, {0 x1e, 0 x24, 0 x39}}, {0 x35, {0 x26, 0 x23, 0 x4c}},
{0 x35, {0 x2e, 0 xf9, 0 x1b}}, {0 x35, {0 x36, 0 x23, 0 x19}},
{0 x35, {0 x3e, 0 x12, 0 x08}}, {0 x35, {0 x52, 0 x07, 0 x22}},
{0 x35, {0 x4a, 0 x03, 0 xd3}}, {0 x35, {0 x62, 0 x06, 0 x54}},
{0 x35, {0 x5a, 0 x04, 0 x5d}}, {0 x34, {0 xe2, 0 x01, 0 x04}},
{0 x34, {0 xea, 0 x00, 0 xa0}}, {0 x34, {0 xf2, 0 x0c, 0 xbc}},
{0 x34, {0 xfa, 0 x0c, 0 x5b}}, {0 x35, {0 x04, 0 x17, 0 xf2}},
{0 x35, {0 x0c, 0 x02, 0 x08}}, {0 x35, {0 x14, 0 x28, 0 x43}},
{0 x35, {0 x1c, 0 x28, 0 x62}}, {0 x35, {0 x24, 0 x2b, 0 x60}},
{0 x35, {0 x2c, 0 x07, 0 x33}}, {0 x35, {0 x34, 0 x1f, 0 xb0}},
{0 x35, {0 x3c, 0 xed, 0 xcd}}, {0 x35, {0 x50, 0 x00, 0 x06}},
{0 x35, {0 x48, 0 x07, 0 xff}}, {0 x35, {0 x60, 0 x05, 0 x89}},
{0 x35, {0 x58, 0 x07, 0 xff}}, {0 x35, {0 x40, 0 x00, 0 xa0}},
{0 x35, {0 x42, 0 x00, 0 x00}}, {0 x32, {0 x10, 0 x01, 0 xfc}},
{0 x33, {0 x8c, 0 xa1, 0 x18}}, {0 x33, {0 x90, 0 x00, 0 x3c}},
{0 x33, {0 x78, 0 x00, 0 x00}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x35, {0 xb8, 0 x1f, 0 x20}}, {0 x33, {0 x8c, 0 xa2, 0 x06}},
{0 x33, {0 x90, 0 x00, 0 x10}}, {0 x33, {0 x8c, 0 xa2, 0 x07}},
{0 x33, {0 x90, 0 x00, 0 x08}}, {0 x33, {0 x8c, 0 xa2, 0 x42}},
{0 x33, {0 x90, 0 x00, 0 x0b}}, {0 x33, {0 x8c, 0 xa2, 0 x4a}},
{0 x33, {0 x90, 0 x00, 0 x8c}}, {0 x35, {0 xba, 0 xfa, 0 x08}},
{0 x33, {0 x8c, 0 xa2, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x22}},
{0 x33, {0 x8c, 0 xa2, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 xbb}},
{0 x33, {0 x8c, 0 xa4, 0 x04}}, {0 x33, {0 x90, 0 x00, 0 x80}},
{0 x33, {0 x8c, 0 xa7, 0 x9d}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 xa7, 0 x9e}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 xa2, 0 x0c}}, {0 x33, {0 x90, 0 x00, 0 x17}},
{0 x33, {0 x8c, 0 xa2, 0 x15}}, {0 x33, {0 x90, 0 x00, 0 x04}},
{0 x33, {0 x8c, 0 xa2, 0 x14}}, {0 x33, {0 x90, 0 x00, 0 x20}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x17}}, {0 x33, {0 x90, 0 x21, 0 x11}},
{0 x33, {0 x8c, 0 x27, 0 x1b}}, {0 x33, {0 x90, 0 x02, 0 x4f}},
{0 x33, {0 x8c, 0 x27, 0 x25}}, {0 x33, {0 x90, 0 x06, 0 x0f}},
{0 x33, {0 x8c, 0 x27, 0 x39}}, {0 x33, {0 x90, 0 x21, 0 x11}},
{0 x33, {0 x8c, 0 x27, 0 x3d}}, {0 x33, {0 x90, 0 x01, 0 x20}},
{0 x33, {0 x8c, 0 x27, 0 x47}}, {0 x33, {0 x90, 0 x09, 0 x4c}},
{0 x33, {0 x8c, 0 x27, 0 x03}}, {0 x33, {0 x90, 0 x02, 0 x84}},
{0 x33, {0 x8c, 0 x27, 0 x05}}, {0 x33, {0 x90, 0 x01, 0 xe2}},
{0 x33, {0 x8c, 0 x27, 0 x07}}, {0 x33, {0 x90, 0 x06, 0 x40}},
{0 x33, {0 x8c, 0 x27, 0 x09}}, {0 x33, {0 x90, 0 x04, 0 xb0}},
{0 x33, {0 x8c, 0 x27, 0 x0d}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x0f}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x11}}, {0 x33, {0 x90, 0 x04, 0 xbd}},
{0 x33, {0 x8c, 0 x27, 0 x13}}, {0 x33, {0 x90, 0 x06, 0 x4d}},
{0 x33, {0 x8c, 0 x27, 0 x15}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x17}}, {0 x33, {0 x90, 0 x21, 0 x11}},
{0 x33, {0 x8c, 0 x27, 0 x19}}, {0 x33, {0 x90, 0 x04, 0 x6c}},
{0 x33, {0 x8c, 0 x27, 0 x1b}}, {0 x33, {0 x90, 0 x02, 0 x4f}},
{0 x33, {0 x8c, 0 x27, 0 x1d}}, {0 x33, {0 x90, 0 x01, 0 x02}},
{0 x33, {0 x8c, 0 x27, 0 x1f}}, {0 x33, {0 x90, 0 x02, 0 x79}},
{0 x33, {0 x8c, 0 x27, 0 x21}}, {0 x33, {0 x90, 0 x01, 0 x55}},
{0 x33, {0 x8c, 0 x27, 0 x23}}, {0 x33, {0 x90, 0 x02, 0 x85}},
{0 x33, {0 x8c, 0 x27, 0 x25}}, {0 x33, {0 x90, 0 x06, 0 x0f}},
{0 x33, {0 x8c, 0 x27, 0 x27}}, {0 x33, {0 x90, 0 x20, 0 x20}},
{0 x33, {0 x8c, 0 x27, 0 x29}}, {0 x33, {0 x90, 0 x20, 0 x20}},
{0 x33, {0 x8c, 0 x27, 0 x2b}}, {0 x33, {0 x90, 0 x10, 0 x20}},
{0 x33, {0 x8c, 0 x27, 0 x2d}}, {0 x33, {0 x90, 0 x20, 0 x07}},
{0 x33, {0 x8c, 0 x27, 0 x2f}}, {0 x33, {0 x90, 0 x00, 0 x04}},
{0 x33, {0 x8c, 0 x27, 0 x31}}, {0 x33, {0 x90, 0 x00, 0 x04}},
{0 x33, {0 x8c, 0 x27, 0 x33}}, {0 x33, {0 x90, 0 x04, 0 xbb}},
{0 x33, {0 x8c, 0 x27, 0 x35}}, {0 x33, {0 x90, 0 x06, 0 x4b}},
{0 x33, {0 x8c, 0 x27, 0 x37}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x39}}, {0 x33, {0 x90, 0 x21, 0 x11}},
{0 x33, {0 x8c, 0 x27, 0 x3b}}, {0 x33, {0 x90, 0 x00, 0 x24}},
{0 x33, {0 x8c, 0 x27, 0 x3d}}, {0 x33, {0 x90, 0 x01, 0 x20}},
{0 x33, {0 x8c, 0 x27, 0 x41}}, {0 x33, {0 x90, 0 x01, 0 x69}},
{0 x33, {0 x8c, 0 x27, 0 x45}}, {0 x33, {0 x90, 0 x04, 0 xed}},
{0 x33, {0 x8c, 0 x27, 0 x47}}, {0 x33, {0 x90, 0 x09, 0 x4c}},
{0 x33, {0 x8c, 0 x27, 0 x51}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x53}}, {0 x33, {0 x90, 0 x03, 0 x20}},
{0 x33, {0 x8c, 0 x27, 0 x55}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x57}}, {0 x33, {0 x90, 0 x02, 0 x58}},
{0 x33, {0 x8c, 0 x27, 0 x5f}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x61}}, {0 x33, {0 x90, 0 x06, 0 x40}},
{0 x33, {0 x8c, 0 x27, 0 x63}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x65}}, {0 x33, {0 x90, 0 x04, 0 xb0}},
{0 x33, {0 x8c, 0 x22, 0 x2e}}, {0 x33, {0 x90, 0 x00, 0 xa1}},
{0 x33, {0 x8c, 0 xa4, 0 x08}}, {0 x33, {0 x90, 0 x00, 0 x1f}},
{0 x33, {0 x8c, 0 xa4, 0 x09}}, {0 x33, {0 x90, 0 x00, 0 x21}},
{0 x33, {0 x8c, 0 xa4, 0 x0a}}, {0 x33, {0 x90, 0 x00, 0 x25}},
{0 x33, {0 x8c, 0 xa4, 0 x0b}}, {0 x33, {0 x90, 0 x00, 0 x27}},
{0 x33, {0 x8c, 0 x24, 0 x11}}, {0 x33, {0 x90, 0 x00, 0 xa1}},
{0 x33, {0 x8c, 0 x24, 0 x13}}, {0 x33, {0 x90, 0 x00, 0 xc1}},
{0 x33, {0 x8c, 0 x24, 0 x15}}, {0 x33, {0 x90, 0 x00, 0 x6a}},
{0 x33, {0 x8c, 0 x24, 0 x17}}, {0 x33, {0 x90, 0 x00, 0 x80}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x05}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x06}},
{3 , {0 xff, 0 xff, 0 xff}},
};
static struct idxdata tbl_init_post_alt_low1[] = {
{0 x33, {0 x8c, 0 x27, 0 x15}}, {0 x33, {0 x90, 0 x00, 0 x25}},
{0 x33, {0 x8c, 0 x22, 0 x2e}}, {0 x33, {0 x90, 0 x00, 0 x81}},
{0 x33, {0 x8c, 0 xa4, 0 x08}}, {0 x33, {0 x90, 0 x00, 0 x17}},
{0 x33, {0 x8c, 0 xa4, 0 x09}}, {0 x33, {0 x90, 0 x00, 0 x1a}},
{0 x33, {0 x8c, 0 xa4, 0 x0a}}, {0 x33, {0 x90, 0 x00, 0 x1d}},
{0 x33, {0 x8c, 0 xa4, 0 x0b}}, {0 x33, {0 x90, 0 x00, 0 x20}},
{0 x33, {0 x8c, 0 x24, 0 x11}}, {0 x33, {0 x90, 0 x00, 0 x81}},
{0 x33, {0 x8c, 0 x24, 0 x13}}, {0 x33, {0 x90, 0 x00, 0 x9b}},
};
static struct idxdata tbl_init_post_alt_low2[] = {
{0 x33, {0 x8c, 0 x27, 0 x03}}, {0 x33, {0 x90, 0 x03, 0 x24}},
{0 x33, {0 x8c, 0 x27, 0 x05}}, {0 x33, {0 x90, 0 x02, 0 x58}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x05}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x06}},
{2 , {0 xff, 0 xff, 0 xff}},
};
static struct idxdata tbl_init_post_alt_low3[] = {
{0 x34, {0 x1e, 0 x8f, 0 x09}}, {0 x34, {0 x1c, 0 x01, 0 x28}},
{0 x34, {0 x1e, 0 x8f, 0 x09}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x34, {0 x1e, 0 x8f, 0 x09}}, {0 x32, {0 x14, 0 x06, 0 xe6}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{0 x33, {0 x2e, 0 x01, 0 x00}}, {0 x34, {0 x04, 0 x00, 0 x2a}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 x27, 0 x95}}, {0 x33, {0 x90, 0 x01, 0 x00}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x72}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x02}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x05}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x06}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x05}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x06}},
};
static struct idxdata tbl_init_post_alt_big[] = {
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x05}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x06}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x34, {0 x1e, 0 x8f, 0 x09}}, {0 x34, {0 x1c, 0 x01, 0 x28}},
{0 x34, {0 x1e, 0 x8f, 0 x09}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x34, {0 x1e, 0 x8f, 0 x09}}, {0 x32, {0 x14, 0 x06, 0 xe6}},
{0 x33, {0 x8c, 0 xa1, 0 x03}},
{0 x33, {0 x90, 0 x00, 0 x05}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x06}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x05}},
{2 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x06}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x72}},
{0 x33, {0 x8c, 0 xa1, 0 x30}}, {0 x33, {0 x90, 0 x00, 0 x03}},
{0 x33, {0 x8c, 0 xa1, 0 x31}}, {0 x33, {0 x90, 0 x00, 0 x02}},
{0 x33, {0 x8c, 0 xa1, 0 x32}}, {0 x33, {0 x90, 0 x00, 0 x03}},
{0 x33, {0 x8c, 0 xa1, 0 x34}}, {0 x33, {0 x90, 0 x00, 0 x03}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x02}},
{0 x33, {0 x2e, 0 x01, 0 x00}}, {0 x34, {0 x04, 0 x00, 0 x2a}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{0 x33, {0 x8c, 0 x27, 0 x97}}, {0 x33, {0 x90, 0 x01, 0 x00}},
{51 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x00}},
{51 , {0 xff, 0 xff, 0 xff}},
{0 x33, {0 x8c, 0 xa1, 0 x20}}, {0 x33, {0 x90, 0 x00, 0 x72}},
{0 x33, {0 x8c, 0 xa1, 0 x03}}, {0 x33, {0 x90, 0 x00, 0 x02}},
{0 x33, {0 x8c, 0 xa7, 0 x02}}, {0 x33, {0 x90, 0 x00, 0 x01}},
{51 , {0 xff, 0 xff, 0 xff}},
};
static struct idxdata tbl_init_post_alt_3B[] = {
{0 x32, {0 x10, 0 x01, 0 xf8}}, {0 x34, {0 xce, 0 x01, 0 xa8}},
{0 x34, {0 xd0, 0 x66, 0 x33}}, {0 x34, {0 xd2, 0 x31, 0 x9a}},
{0 x34, {0 xd4, 0 x94, 0 x63}}, {0 x34, {0 xd6, 0 x4b, 0 x25}},
{0 x34, {0 xd8, 0 x26, 0 x70}}, {0 x34, {0 xda, 0 x72, 0 x4c}},
{0 x34, {0 xdc, 0 xff, 0 x04}}, {0 x34, {0 xde, 0 x01, 0 x5b}},
{0 x34, {0 xe6, 0 x01, 0 x13}}, {0 x34, {0 xee, 0 x0b, 0 xf0}},
{0 x34, {0 xf6, 0 x0b, 0 xa4}}, {0 x35, {0 x00, 0 xf6, 0 xe7}},
{0 x35, {0 x08, 0 x0d, 0 xfd}}, {0 x35, {0 x10, 0 x25, 0 x63}},
{0 x35, {0 x18, 0 x35, 0 x6c}}, {0 x35, {0 x20, 0 x42, 0 x7e}},
{0 x35, {0 x28, 0 x19, 0 x44}}, {0 x35, {0 x30, 0 x39, 0 xd4}},
{0 x35, {0 x38, 0 xf5, 0 xa8}}, {0 x35, {0 x4c, 0 x07, 0 x90}},
{0 x35, {0 x44, 0 x07, 0 xb8}}, {0 x35, {0 x5c, 0 x06, 0 x88}},
{0 x35, {0 x54, 0 x07, 0 xff}}, {0 x34, {0 xe0, 0 x01, 0 x52}},
{0 x34, {0 xe8, 0 x00, 0 xcc}}, {0 x34, {0 xf0, 0 x0d, 0 x83}},
{0 x34, {0 xf8, 0 x0c, 0 xb3}}, {0 x35, {0 x02, 0 xfe, 0 xba}},
{0 x35, {0 x0a, 0 x04, 0 xe0}}, {0 x35, {0 x12, 0 x1c, 0 x63}},
{0 x35, {0 x1a, 0 x2b, 0 x5a}}, {0 x35, {0 x22, 0 x32, 0 x5e}},
{0 x35, {0 x2a, 0 x0d, 0 x28}}, {0 x35, {0 x32, 0 x2c, 0 x02}},
{0 x35, {0 x3a, 0 xf4, 0 xfa}}, {0 x35, {0 x4e, 0 x07, 0 xef}},
{0 x35, {0 x46, 0 x07, 0 x88}}, {0 x35, {0 x5e, 0 x07, 0 xc1}},
{0 x35, {0 x56, 0 x04, 0 x64}}, {0 x34, {0 xe4, 0 x01, 0 x15}},
{0 x34, {0 xec, 0 x00, 0 x82}}, {0 x34, {0 xf4, 0 x0c, 0 xce}},
{0 x34, {0 xfc, 0 x0c, 0 xba}}, {0 x35, {0 x06, 0 x1f, 0 x02}},
{0 x35, {0 x0e, 0 x02, 0 xe3}}, {0 x35, {0 x16, 0 x1a, 0 x50}},
{0 x35, {0 x1e, 0 x24, 0 x39}}, {0 x35, {0 x26, 0 x23, 0 x4c}},
{0 x35, {0 x2e, 0 xf9, 0 x1b}}, {0 x35, {0 x36, 0 x23, 0 x19}},
{0 x35, {0 x3e, 0 x12, 0 x08}}, {0 x35, {0 x52, 0 x07, 0 x22}},
{0 x35, {0 x4a, 0 x03, 0 xd3}}, {0 x35, {0 x62, 0 x06, 0 x54}},
{0 x35, {0 x5a, 0 x04, 0 x5d}}, {0 x34, {0 xe2, 0 x01, 0 x04}},
{0 x34, {0 xea, 0 x00, 0 xa0}}, {0 x34, {0 xf2, 0 x0c, 0 xbc}},
{0 x34, {0 xfa, 0 x0c, 0 x5b}}, {0 x35, {0 x04, 0 x17, 0 xf2}},
{0 x35, {0 x0c, 0 x02, 0 x08}}, {0 x35, {0 x14, 0 x28, 0 x43}},
{0 x35, {0 x1c, 0 x28, 0 x62}}, {0 x35, {0 x24, 0 x2b, 0 x60}},
{0 x35, {0 x2c, 0 x07, 0 x33}}, {0 x35, {0 x34, 0 x1f, 0 xb0}},
{0 x35, {0 x3c, 0 xed, 0 xcd}}, {0 x35, {0 x50, 0 x00, 0 x06}},
{0 x35, {0 x48, 0 x07, 0 xff}}, {0 x35, {0 x60, 0 x05, 0 x89}},
{0 x35, {0 x58, 0 x07, 0 xff}}, {0 x35, {0 x40, 0 x00, 0 xa0}},
{0 x35, {0 x42, 0 x00, 0 x00}}, {0 x32, {0 x10, 0 x01, 0 xfc}},
{0 x33, {0 x8c, 0 xa1, 0 x18}}, {0 x33, {0 x90, 0 x00, 0 x3c}},
};
static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81" ;
static u8 *dat_800 = "\xd0\x02\xd1\x10\xd2\x57\xd3\x02\xd4\x18\xd5\x21" ;
static u8 *dat_1280 = "\xd0\x02\xd1\x20\xd2\x01\xd3\x02\xd4\x28\xd5\x01" ;
static u8 *dat_1600 = "\xd0\x02\xd1\x20\xd2\xaf\xd3\x02\xd4\x30\xd5\x41" ;
static int mi2020_init_at_startup(struct gspca_dev *gspca_dev);
static int mi2020_configure_alt(struct gspca_dev *gspca_dev);
static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev);
static int mi2020_init_post_alt(struct gspca_dev *gspca_dev);
static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev);
static int mi2020_camera_settings(struct gspca_dev *gspca_dev);
/*==========================================================================*/
void mi2020_init_settings(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
sd->vcur.backlight = 0 ;
sd->vcur.brightness = 70 ;
sd->vcur.sharpness = 20 ;
sd->vcur.contrast = 0 ;
sd->vcur.gamma = 0 ;
sd->vcur.hue = 0 ;
sd->vcur.saturation = 60 ;
sd->vcur.whitebal = 0 ; /* 50, not done by hardware */
sd->vcur.mirror = 0 ;
sd->vcur.flip = 0 ;
sd->vcur.AC50Hz = 1 ;
sd->vmax.backlight = 64 ;
sd->vmax.brightness = 128 ;
sd->vmax.sharpness = 40 ;
sd->vmax.contrast = 3 ;
sd->vmax.gamma = 2 ;
sd->vmax.hue = 0 + 1 ; /* 200, not done by hardware */
sd->vmax.saturation = 0 ; /* 100, not done by hardware */
sd->vmax.whitebal = 2 ; /* 100, not done by hardware */
sd->vmax.mirror = 1 ;
sd->vmax.flip = 1 ;
sd->vmax.AC50Hz = 1 ;
sd->dev_camera_settings = mi2020_camera_settings;
sd->dev_init_at_startup = mi2020_init_at_startup;
sd->dev_configure_alt = mi2020_configure_alt;
sd->dev_init_pre_alt = mi2020_init_pre_alt;
sd->dev_post_unset_alt = mi2020_post_unset_alt;
}
/*==========================================================================*/
static void common(struct gspca_dev *gspca_dev)
{
fetch_validx(gspca_dev, tbl_common_0B, ARRAY_SIZE(tbl_common_0B));
fetch_idxdata(gspca_dev, tbl_common_3B, ARRAY_SIZE(tbl_common_3B));
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0041, 0 x0000, 0 , NULL);
}
static int mi2020_init_at_startup(struct gspca_dev *gspca_dev)
{
u8 c;
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x0000, 0 x0004, 1 , &c);
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x0000, 0 x0004, 1 , &c);
fetch_validx(gspca_dev, tbl_init_at_startup,
ARRAY_SIZE(tbl_init_at_startup));
ctrl_out(gspca_dev, 0 x40, 1 , 0 x7a00, 0 x8030, 0 , NULL);
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x7a00, 0 x8030, 1 , &c);
common(gspca_dev);
msleep(61 );
/* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */
/* msleep(36); */
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0001, 0 x0000, 0 , NULL);
return 0 ;
}
static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
sd->mirrorMask = 0 ;
sd->vold.hue = -1 ;
/* These controls need to be reset */
sd->vold.brightness = -1 ;
sd->vold.sharpness = -1 ;
/* If not different from default, they do not need to be set */
sd->vold.contrast = 0 ;
sd->vold.gamma = 0 ;
sd->vold.backlight = 0 ;
mi2020_init_post_alt(gspca_dev);
return 0 ;
}
static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
s32 mirror = (((sd->vcur.mirror > 0 ) ^ sd->mirrorMask) > 0 );
s32 flip = (((sd->vcur.flip > 0 ) ^ sd->mirrorMask) > 0 );
s32 freq = (sd->vcur.AC50Hz > 0 );
s32 wbal = sd->vcur.whitebal;
u8 dat_freq2[] = {0 x90, 0 x00, 0 x80};
u8 dat_multi1[] = {0 x8c, 0 xa7, 0 x00};
u8 dat_multi2[] = {0 x90, 0 x00, 0 x00};
u8 dat_multi3[] = {0 x8c, 0 xa7, 0 x00};
u8 dat_multi4[] = {0 x90, 0 x00, 0 x00};
u8 dat_hvflip2[] = {0 x90, 0 x04, 0 x6c};
u8 dat_hvflip4[] = {0 x90, 0 x00, 0 x24};
u8 dat_wbal2[] = {0 x90, 0 x00, 0 x00};
u8 c;
sd->nbIm = -1 ;
dat_freq2[2 ] = freq ? 0 xc0 : 0 x80;
dat_multi1[2 ] = 0 x9d;
dat_multi3[2 ] = dat_multi1[2 ] + 1 ;
if (wbal == 0 ) {
dat_multi4[2 ] = dat_multi2[2 ] = 0 ;
dat_wbal2[2 ] = 0 x17;
} else if (wbal == 1 ) {
dat_multi4[2 ] = dat_multi2[2 ] = 0 ;
dat_wbal2[2 ] = 0 x35;
} else if (wbal == 2 ) {
dat_multi4[2 ] = dat_multi2[2 ] = 0 x20;
dat_wbal2[2 ] = 0 x17;
}
dat_hvflip2[2 ] = 0 x6c + 2 * (1 - flip) + (1 - mirror);
dat_hvflip4[2 ] = 0 x24 + 2 * (1 - flip) + (1 - mirror);
msleep(200 );
ctrl_out(gspca_dev, 0 x40, 5 , 0 x0001, 0 x0000, 0 , NULL);
msleep(2 );
common(gspca_dev);
msleep(142 );
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0010, 0 x0010, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0003, 0 x00c1, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0042, 0 x00c2, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x006a, 0 x000d, 0 , NULL);
switch (reso) {
case IMAGE_640:
case IMAGE_800:
if (reso != IMAGE_800)
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200,
12 , dat_640);
else
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200,
12 , dat_800);
fetch_idxdata(gspca_dev, tbl_init_post_alt_low1,
ARRAY_SIZE(tbl_init_post_alt_low1));
if (reso == IMAGE_800)
fetch_idxdata(gspca_dev, tbl_init_post_alt_low2,
ARRAY_SIZE(tbl_init_post_alt_low2));
fetch_idxdata(gspca_dev, tbl_init_post_alt_low3,
ARRAY_SIZE(tbl_init_post_alt_low3));
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0010, 0 x0010, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0000, 0 x00c1, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0041, 0 x00c2, 0 , NULL);
msleep(120 );
break ;
case IMAGE_1280:
case IMAGE_1600:
if (reso == IMAGE_1280) {
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200,
12 , dat_1280);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x8c\x27\x07" );
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x90\x05\x04" );
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x8c\x27\x09" );
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x90\x04\x02" );
} else {
ctrl_out(gspca_dev, 0 x40, 3 , 0 x0000, 0 x0200,
12 , dat_1600);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x8c\x27\x07" );
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x90\x06\x40" );
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x8c\x27\x09" );
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033,
3 , "\x90\x04\xb0" );
}
fetch_idxdata(gspca_dev, tbl_init_post_alt_big,
ARRAY_SIZE(tbl_init_post_alt_big));
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0001, 0 x0010, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0000, 0 x00c1, 0 , NULL);
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0041, 0 x00c2, 0 , NULL);
msleep(1850 );
}
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0040, 0 x0000, 0 , NULL);
msleep(40 );
/* AC power frequency */
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_freq1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_freq2);
msleep(33 );
/* light source */
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi3);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi4);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_wbal1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_wbal2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi5);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi6);
msleep(7 );
ctrl_in(gspca_dev, 0 xc0, 2 , 0 x0000, 0 x0000, 1 , &c);
fetch_idxdata(gspca_dev, tbl_init_post_alt_3B,
ARRAY_SIZE(tbl_init_post_alt_3B));
/* hvflip */
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip3);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip4);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip5);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip6);
msleep(250 );
if (reso == IMAGE_640 || reso == IMAGE_800)
fetch_idxdata(gspca_dev, tbl_middle_hvflip_low,
ARRAY_SIZE(tbl_middle_hvflip_low));
else
fetch_idxdata(gspca_dev, tbl_middle_hvflip_big,
ARRAY_SIZE(tbl_middle_hvflip_big));
fetch_idxdata(gspca_dev, tbl_end_hvflip,
ARRAY_SIZE(tbl_end_hvflip));
sd->nbIm = 0 ;
sd->vold.mirror = mirror;
sd->vold.flip = flip;
sd->vold.AC50Hz = freq;
sd->vold.whitebal = wbal;
mi2020_camera_settings(gspca_dev);
return 0 ;
}
static int mi2020_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 mi2020_camera_settings(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
s32 backlight = sd->vcur.backlight;
s32 bright = sd->vcur.brightness;
s32 sharp = sd->vcur.sharpness;
s32 cntr = sd->vcur.contrast;
s32 gam = sd->vcur.gamma;
s32 hue = (sd->vcur.hue > 0 );
s32 mirror = (((sd->vcur.mirror > 0 ) ^ sd->mirrorMask) > 0 );
s32 flip = (((sd->vcur.flip > 0 ) ^ sd->mirrorMask) > 0 );
s32 freq = (sd->vcur.AC50Hz > 0 );
s32 wbal = sd->vcur.whitebal;
u8 dat_sharp[] = {0 x6c, 0 x00, 0 x08};
u8 dat_bright2[] = {0 x90, 0 x00, 0 x00};
u8 dat_freq2[] = {0 x90, 0 x00, 0 x80};
u8 dat_multi1[] = {0 x8c, 0 xa7, 0 x00};
u8 dat_multi2[] = {0 x90, 0 x00, 0 x00};
u8 dat_multi3[] = {0 x8c, 0 xa7, 0 x00};
u8 dat_multi4[] = {0 x90, 0 x00, 0 x00};
u8 dat_hvflip2[] = {0 x90, 0 x04, 0 x6c};
u8 dat_hvflip4[] = {0 x90, 0 x00, 0 x24};
u8 dat_wbal2[] = {0 x90, 0 x00, 0 x00};
/* Less than 4 images received -> too early to set the settings */
if (sd->nbIm < 4 ) {
sd->waitSet = 1 ;
return 0 ;
}
sd->waitSet = 0 ;
if (freq != sd->vold.AC50Hz) {
sd->vold.AC50Hz = freq;
dat_freq2[2 ] = freq ? 0 xc0 : 0 x80;
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_freq1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_freq2);
msleep(20 );
}
if (wbal != sd->vold.whitebal) {
sd->vold.whitebal = wbal;
if (wbal < 0 || wbal > sd->vmax.whitebal)
wbal = 0 ;
dat_multi1[2 ] = 0 x9d;
dat_multi3[2 ] = dat_multi1[2 ] + 1 ;
if (wbal == 0 ) {
dat_multi4[2 ] = dat_multi2[2 ] = 0 ;
dat_wbal2[2 ] = 0 x17;
} else if (wbal == 1 ) {
dat_multi4[2 ] = dat_multi2[2 ] = 0 ;
dat_wbal2[2 ] = 0 x35;
} else if (wbal == 2 ) {
dat_multi4[2 ] = dat_multi2[2 ] = 0 x20;
dat_wbal2[2 ] = 0 x17;
}
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi3);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi4);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_wbal1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_wbal2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi5);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi6);
}
if (mirror != sd->vold.mirror || flip != sd->vold.flip) {
sd->vold.mirror = mirror;
sd->vold.flip = flip;
dat_hvflip2[2 ] = 0 x6c + 2 * (1 - flip) + (1 - mirror);
dat_hvflip4[2 ] = 0 x24 + 2 * (1 - flip) + (1 - mirror);
fetch_idxdata(gspca_dev, tbl_init_post_alt_3B,
ARRAY_SIZE(tbl_init_post_alt_3B));
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip3);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip4);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip5);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_hvflip6);
msleep(40 );
if (reso == IMAGE_640 || reso == IMAGE_800)
fetch_idxdata(gspca_dev, tbl_middle_hvflip_low,
ARRAY_SIZE(tbl_middle_hvflip_low));
else
fetch_idxdata(gspca_dev, tbl_middle_hvflip_big,
ARRAY_SIZE(tbl_middle_hvflip_big));
fetch_idxdata(gspca_dev, tbl_end_hvflip,
ARRAY_SIZE(tbl_end_hvflip));
}
if (bright != sd->vold.brightness) {
sd->vold.brightness = bright;
if (bright < 0 || bright > sd->vmax.brightness)
bright = 0 ;
dat_bright2[2 ] = bright;
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_bright1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_bright2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_bright3);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_bright4);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_bright5);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_bright6);
}
if (cntr != sd->vold.contrast || gam != sd->vold.gamma) {
sd->vold.contrast = cntr;
if (cntr < 0 || cntr > sd->vmax.contrast)
cntr = 0 ;
sd->vold.gamma = gam;
if (gam < 0 || gam > sd->vmax.gamma)
gam = 0 ;
dat_multi1[2 ] = 0 x6d;
dat_multi3[2 ] = dat_multi1[2 ] + 1 ;
if (cntr == 0 )
cntr = 4 ;
dat_multi4[2 ] = dat_multi2[2 ] = cntr * 0 x10 + 2 - gam;
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi3);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi4);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi5);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi6);
}
if (backlight != sd->vold.backlight) {
sd->vold.backlight = backlight;
if (backlight < 0 || backlight > sd->vmax.backlight)
backlight = 0 ;
dat_multi1[2 ] = 0 x9d;
dat_multi3[2 ] = dat_multi1[2 ] + 1 ;
dat_multi4[2 ] = dat_multi2[2 ] = backlight;
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi1);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi2);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi3);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi4);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi5);
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0033, 3 , dat_multi6);
}
if (sharp != sd->vold.sharpness) {
sd->vold.sharpness = sharp;
if (sharp < 0 || sharp > sd->vmax.sharpness)
sharp = 0 ;
dat_sharp[1 ] = sharp;
ctrl_out(gspca_dev, 0 x40, 3 , 0 x7a00, 0 x0032, 3 , dat_sharp);
}
if (hue != sd->vold.hue) {
sd->swapRB = hue;
sd->vold.hue = hue;
}
return 0 ;
}
static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev)
{
ctrl_out(gspca_dev, 0 x40, 5 , 0 x0000, 0 x0000, 0 , NULL);
msleep(40 );
ctrl_out(gspca_dev, 0 x40, 1 , 0 x0001, 0 x0000, 0 , NULL);
}
Messung V0.5 in Prozent C=94 H=94 G=93