10c0d06caSMauro Carvalho Chehab /* 20c0d06caSMauro Carvalho Chehab * Sonix sn9c201 sn9c202 library 30c0d06caSMauro Carvalho Chehab * 40c0d06caSMauro Carvalho Chehab * Copyright (C) 2012 Jean-Francois Moine <http://moinejf.free.fr> 50c0d06caSMauro Carvalho Chehab * Copyright (C) 2008-2009 microdia project <microdia@googlegroups.com> 60c0d06caSMauro Carvalho Chehab * Copyright (C) 2009 Brian Johnson <brijohn@gmail.com> 70c0d06caSMauro Carvalho Chehab * 80c0d06caSMauro Carvalho Chehab * This program is free software; you can redistribute it and/or modify 90c0d06caSMauro Carvalho Chehab * it under the terms of the GNU General Public License as published by 100c0d06caSMauro Carvalho Chehab * the Free Software Foundation; either version 2 of the License, or 110c0d06caSMauro Carvalho Chehab * any later version. 120c0d06caSMauro Carvalho Chehab * 130c0d06caSMauro Carvalho Chehab * This program is distributed in the hope that it will be useful, 140c0d06caSMauro Carvalho Chehab * but WITHOUT ANY WARRANTY; without even the implied warranty of 150c0d06caSMauro Carvalho Chehab * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 160c0d06caSMauro Carvalho Chehab * GNU General Public License for more details. 170c0d06caSMauro Carvalho Chehab * 180c0d06caSMauro Carvalho Chehab * You should have received a copy of the GNU General Public License 190c0d06caSMauro Carvalho Chehab * along with this program; if not, write to the Free Software 200c0d06caSMauro Carvalho Chehab * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 210c0d06caSMauro Carvalho Chehab */ 220c0d06caSMauro Carvalho Chehab 230c0d06caSMauro Carvalho Chehab #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 240c0d06caSMauro Carvalho Chehab 250c0d06caSMauro Carvalho Chehab #include <linux/input.h> 260c0d06caSMauro Carvalho Chehab 270c0d06caSMauro Carvalho Chehab #include "gspca.h" 280c0d06caSMauro Carvalho Chehab #include "jpeg.h" 290c0d06caSMauro Carvalho Chehab 300c0d06caSMauro Carvalho Chehab #include <media/v4l2-chip-ident.h> 310c0d06caSMauro Carvalho Chehab #include <linux/dmi.h> 320c0d06caSMauro Carvalho Chehab 330c0d06caSMauro Carvalho Chehab MODULE_AUTHOR("Brian Johnson <brijohn@gmail.com>, " 340c0d06caSMauro Carvalho Chehab "microdia project <microdia@googlegroups.com>"); 350c0d06caSMauro Carvalho Chehab MODULE_DESCRIPTION("GSPCA/SN9C20X USB Camera Driver"); 360c0d06caSMauro Carvalho Chehab MODULE_LICENSE("GPL"); 370c0d06caSMauro Carvalho Chehab 380c0d06caSMauro Carvalho Chehab /* 390c0d06caSMauro Carvalho Chehab * Pixel format private data 400c0d06caSMauro Carvalho Chehab */ 410c0d06caSMauro Carvalho Chehab #define SCALE_MASK 0x0f 420c0d06caSMauro Carvalho Chehab #define SCALE_160x120 0 430c0d06caSMauro Carvalho Chehab #define SCALE_320x240 1 440c0d06caSMauro Carvalho Chehab #define SCALE_640x480 2 450c0d06caSMauro Carvalho Chehab #define SCALE_1280x1024 3 460c0d06caSMauro Carvalho Chehab #define MODE_RAW 0x10 470c0d06caSMauro Carvalho Chehab #define MODE_JPEG 0x20 480c0d06caSMauro Carvalho Chehab #define MODE_SXGA 0x80 490c0d06caSMauro Carvalho Chehab 500c0d06caSMauro Carvalho Chehab #define SENSOR_OV9650 0 510c0d06caSMauro Carvalho Chehab #define SENSOR_OV9655 1 520c0d06caSMauro Carvalho Chehab #define SENSOR_SOI968 2 530c0d06caSMauro Carvalho Chehab #define SENSOR_OV7660 3 540c0d06caSMauro Carvalho Chehab #define SENSOR_OV7670 4 550c0d06caSMauro Carvalho Chehab #define SENSOR_MT9V011 5 560c0d06caSMauro Carvalho Chehab #define SENSOR_MT9V111 6 570c0d06caSMauro Carvalho Chehab #define SENSOR_MT9V112 7 580c0d06caSMauro Carvalho Chehab #define SENSOR_MT9M001 8 590c0d06caSMauro Carvalho Chehab #define SENSOR_MT9M111 9 600c0d06caSMauro Carvalho Chehab #define SENSOR_MT9M112 10 610c0d06caSMauro Carvalho Chehab #define SENSOR_HV7131R 11 620c0d06caSMauro Carvalho Chehab #define SENSOR_MT9VPRB 12 630c0d06caSMauro Carvalho Chehab 640c0d06caSMauro Carvalho Chehab /* camera flags */ 650c0d06caSMauro Carvalho Chehab #define HAS_NO_BUTTON 0x1 660c0d06caSMauro Carvalho Chehab #define LED_REVERSE 0x2 /* some cameras unset gpio to turn on leds */ 670c0d06caSMauro Carvalho Chehab #define FLIP_DETECT 0x4 680c0d06caSMauro Carvalho Chehab 690c0d06caSMauro Carvalho Chehab /* specific webcam descriptor */ 700c0d06caSMauro Carvalho Chehab struct sd { 710c0d06caSMauro Carvalho Chehab struct gspca_dev gspca_dev; 720c0d06caSMauro Carvalho Chehab 730c0d06caSMauro Carvalho Chehab struct { /* color control cluster */ 740c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *brightness; 750c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *contrast; 760c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *saturation; 770c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *hue; 780c0d06caSMauro Carvalho Chehab }; 790c0d06caSMauro Carvalho Chehab struct { /* blue/red balance control cluster */ 800c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *blue; 810c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *red; 820c0d06caSMauro Carvalho Chehab }; 830c0d06caSMauro Carvalho Chehab struct { /* h/vflip control cluster */ 840c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *hflip; 850c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *vflip; 860c0d06caSMauro Carvalho Chehab }; 870c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *gamma; 880c0d06caSMauro Carvalho Chehab struct { /* autogain and exposure or gain control cluster */ 890c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *autogain; 900c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *exposure; 910c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *gain; 920c0d06caSMauro Carvalho Chehab }; 930c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *jpegqual; 940c0d06caSMauro Carvalho Chehab 950c0d06caSMauro Carvalho Chehab struct work_struct work; 960c0d06caSMauro Carvalho Chehab struct workqueue_struct *work_thread; 970c0d06caSMauro Carvalho Chehab 980c0d06caSMauro Carvalho Chehab u32 pktsz; /* (used by pkt_scan) */ 990c0d06caSMauro Carvalho Chehab u16 npkt; 1000c0d06caSMauro Carvalho Chehab s8 nchg; 1010c0d06caSMauro Carvalho Chehab u8 fmt; /* (used for JPEG QTAB update */ 1020c0d06caSMauro Carvalho Chehab 1030c0d06caSMauro Carvalho Chehab #define MIN_AVG_LUM 80 1040c0d06caSMauro Carvalho Chehab #define MAX_AVG_LUM 130 1050c0d06caSMauro Carvalho Chehab atomic_t avg_lum; 1060c0d06caSMauro Carvalho Chehab u8 old_step; 1070c0d06caSMauro Carvalho Chehab u8 older_step; 1080c0d06caSMauro Carvalho Chehab u8 exposure_step; 1090c0d06caSMauro Carvalho Chehab 1100c0d06caSMauro Carvalho Chehab u8 i2c_addr; 1110c0d06caSMauro Carvalho Chehab u8 i2c_intf; 1120c0d06caSMauro Carvalho Chehab u8 sensor; 1130c0d06caSMauro Carvalho Chehab u8 hstart; 1140c0d06caSMauro Carvalho Chehab u8 vstart; 1150c0d06caSMauro Carvalho Chehab 1160c0d06caSMauro Carvalho Chehab u8 jpeg_hdr[JPEG_HDR_SZ]; 1170c0d06caSMauro Carvalho Chehab 1180c0d06caSMauro Carvalho Chehab u8 flags; 1190c0d06caSMauro Carvalho Chehab }; 1200c0d06caSMauro Carvalho Chehab 1210c0d06caSMauro Carvalho Chehab static void qual_upd(struct work_struct *work); 1220c0d06caSMauro Carvalho Chehab 1230c0d06caSMauro Carvalho Chehab struct i2c_reg_u8 { 1240c0d06caSMauro Carvalho Chehab u8 reg; 1250c0d06caSMauro Carvalho Chehab u8 val; 1260c0d06caSMauro Carvalho Chehab }; 1270c0d06caSMauro Carvalho Chehab 1280c0d06caSMauro Carvalho Chehab struct i2c_reg_u16 { 1290c0d06caSMauro Carvalho Chehab u8 reg; 1300c0d06caSMauro Carvalho Chehab u16 val; 1310c0d06caSMauro Carvalho Chehab }; 1320c0d06caSMauro Carvalho Chehab 1330c0d06caSMauro Carvalho Chehab static const struct dmi_system_id flip_dmi_table[] = { 1340c0d06caSMauro Carvalho Chehab { 1350c0d06caSMauro Carvalho Chehab .ident = "MSI MS-1034", 1360c0d06caSMauro Carvalho Chehab .matches = { 1370c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT'L CO.,LTD."), 1380c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_PRODUCT_NAME, "MS-1034"), 1390c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_PRODUCT_VERSION, "0341") 1400c0d06caSMauro Carvalho Chehab } 1410c0d06caSMauro Carvalho Chehab }, 1420c0d06caSMauro Carvalho Chehab { 1430c0d06caSMauro Carvalho Chehab .ident = "MSI MS-1632", 1440c0d06caSMauro Carvalho Chehab .matches = { 1450c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_VENDOR, "MSI"), 1460c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_NAME, "MS-1632") 1470c0d06caSMauro Carvalho Chehab } 1480c0d06caSMauro Carvalho Chehab }, 1490c0d06caSMauro Carvalho Chehab { 1500c0d06caSMauro Carvalho Chehab .ident = "MSI MS-1633X", 1510c0d06caSMauro Carvalho Chehab .matches = { 1520c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_VENDOR, "MSI"), 1530c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_NAME, "MS-1633X") 1540c0d06caSMauro Carvalho Chehab } 1550c0d06caSMauro Carvalho Chehab }, 1560c0d06caSMauro Carvalho Chehab { 1570c0d06caSMauro Carvalho Chehab .ident = "MSI MS-1635X", 1580c0d06caSMauro Carvalho Chehab .matches = { 1590c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_VENDOR, "MSI"), 1600c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_NAME, "MS-1635X") 1610c0d06caSMauro Carvalho Chehab } 1620c0d06caSMauro Carvalho Chehab }, 1630c0d06caSMauro Carvalho Chehab { 1640c0d06caSMauro Carvalho Chehab .ident = "ASUSTeK W7J", 1650c0d06caSMauro Carvalho Chehab .matches = { 1660c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."), 1670c0d06caSMauro Carvalho Chehab DMI_MATCH(DMI_BOARD_NAME, "W7J ") 1680c0d06caSMauro Carvalho Chehab } 1690c0d06caSMauro Carvalho Chehab }, 1700c0d06caSMauro Carvalho Chehab {} 1710c0d06caSMauro Carvalho Chehab }; 1720c0d06caSMauro Carvalho Chehab 1730c0d06caSMauro Carvalho Chehab static const struct v4l2_pix_format vga_mode[] = { 1740c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 1750c0d06caSMauro Carvalho Chehab .bytesperline = 160, 1760c0d06caSMauro Carvalho Chehab .sizeimage = 160 * 120 * 4 / 8 + 590, 1770c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_JPEG, 1780c0d06caSMauro Carvalho Chehab .priv = SCALE_160x120 | MODE_JPEG}, 1790c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 1800c0d06caSMauro Carvalho Chehab .bytesperline = 160, 1810c0d06caSMauro Carvalho Chehab .sizeimage = 160 * 120, 1820c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 1830c0d06caSMauro Carvalho Chehab .priv = SCALE_160x120 | MODE_RAW}, 1840c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 1850c0d06caSMauro Carvalho Chehab .bytesperline = 160, 1860c0d06caSMauro Carvalho Chehab .sizeimage = 240 * 120, 1870c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 1880c0d06caSMauro Carvalho Chehab .priv = SCALE_160x120}, 1890c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 1900c0d06caSMauro Carvalho Chehab .bytesperline = 320, 1910c0d06caSMauro Carvalho Chehab .sizeimage = 320 * 240 * 4 / 8 + 590, 1920c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_JPEG, 1930c0d06caSMauro Carvalho Chehab .priv = SCALE_320x240 | MODE_JPEG}, 1940c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 1950c0d06caSMauro Carvalho Chehab .bytesperline = 320, 1960c0d06caSMauro Carvalho Chehab .sizeimage = 320 * 240 , 1970c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 1980c0d06caSMauro Carvalho Chehab .priv = SCALE_320x240 | MODE_RAW}, 1990c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 2000c0d06caSMauro Carvalho Chehab .bytesperline = 320, 2010c0d06caSMauro Carvalho Chehab .sizeimage = 480 * 240 , 2020c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2030c0d06caSMauro Carvalho Chehab .priv = SCALE_320x240}, 2040c0d06caSMauro Carvalho Chehab {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 2050c0d06caSMauro Carvalho Chehab .bytesperline = 640, 2060c0d06caSMauro Carvalho Chehab .sizeimage = 640 * 480 * 4 / 8 + 590, 2070c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_JPEG, 2080c0d06caSMauro Carvalho Chehab .priv = SCALE_640x480 | MODE_JPEG}, 2090c0d06caSMauro Carvalho Chehab {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 2100c0d06caSMauro Carvalho Chehab .bytesperline = 640, 2110c0d06caSMauro Carvalho Chehab .sizeimage = 640 * 480, 2120c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2130c0d06caSMauro Carvalho Chehab .priv = SCALE_640x480 | MODE_RAW}, 2140c0d06caSMauro Carvalho Chehab {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 2150c0d06caSMauro Carvalho Chehab .bytesperline = 640, 2160c0d06caSMauro Carvalho Chehab .sizeimage = 960 * 480, 2170c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2180c0d06caSMauro Carvalho Chehab .priv = SCALE_640x480}, 2190c0d06caSMauro Carvalho Chehab }; 2200c0d06caSMauro Carvalho Chehab 2210c0d06caSMauro Carvalho Chehab static const struct v4l2_pix_format sxga_mode[] = { 2220c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 2230c0d06caSMauro Carvalho Chehab .bytesperline = 160, 2240c0d06caSMauro Carvalho Chehab .sizeimage = 160 * 120 * 4 / 8 + 590, 2250c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_JPEG, 2260c0d06caSMauro Carvalho Chehab .priv = SCALE_160x120 | MODE_JPEG}, 2270c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 2280c0d06caSMauro Carvalho Chehab .bytesperline = 160, 2290c0d06caSMauro Carvalho Chehab .sizeimage = 160 * 120, 2300c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2310c0d06caSMauro Carvalho Chehab .priv = SCALE_160x120 | MODE_RAW}, 2320c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 2330c0d06caSMauro Carvalho Chehab .bytesperline = 160, 2340c0d06caSMauro Carvalho Chehab .sizeimage = 240 * 120, 2350c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2360c0d06caSMauro Carvalho Chehab .priv = SCALE_160x120}, 2370c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 2380c0d06caSMauro Carvalho Chehab .bytesperline = 320, 2390c0d06caSMauro Carvalho Chehab .sizeimage = 320 * 240 * 4 / 8 + 590, 2400c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_JPEG, 2410c0d06caSMauro Carvalho Chehab .priv = SCALE_320x240 | MODE_JPEG}, 2420c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 2430c0d06caSMauro Carvalho Chehab .bytesperline = 320, 2440c0d06caSMauro Carvalho Chehab .sizeimage = 320 * 240 , 2450c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2460c0d06caSMauro Carvalho Chehab .priv = SCALE_320x240 | MODE_RAW}, 2470c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 2480c0d06caSMauro Carvalho Chehab .bytesperline = 320, 2490c0d06caSMauro Carvalho Chehab .sizeimage = 480 * 240 , 2500c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2510c0d06caSMauro Carvalho Chehab .priv = SCALE_320x240}, 2520c0d06caSMauro Carvalho Chehab {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 2530c0d06caSMauro Carvalho Chehab .bytesperline = 640, 2540c0d06caSMauro Carvalho Chehab .sizeimage = 640 * 480 * 4 / 8 + 590, 2550c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_JPEG, 2560c0d06caSMauro Carvalho Chehab .priv = SCALE_640x480 | MODE_JPEG}, 2570c0d06caSMauro Carvalho Chehab {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 2580c0d06caSMauro Carvalho Chehab .bytesperline = 640, 2590c0d06caSMauro Carvalho Chehab .sizeimage = 640 * 480, 2600c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2610c0d06caSMauro Carvalho Chehab .priv = SCALE_640x480 | MODE_RAW}, 2620c0d06caSMauro Carvalho Chehab {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 2630c0d06caSMauro Carvalho Chehab .bytesperline = 640, 2640c0d06caSMauro Carvalho Chehab .sizeimage = 960 * 480, 2650c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2660c0d06caSMauro Carvalho Chehab .priv = SCALE_640x480}, 2670c0d06caSMauro Carvalho Chehab {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 2680c0d06caSMauro Carvalho Chehab .bytesperline = 1280, 2690c0d06caSMauro Carvalho Chehab .sizeimage = 1280 * 1024, 2700c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2710c0d06caSMauro Carvalho Chehab .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA}, 2720c0d06caSMauro Carvalho Chehab }; 2730c0d06caSMauro Carvalho Chehab 2740c0d06caSMauro Carvalho Chehab static const struct v4l2_pix_format mono_mode[] = { 2750c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, 2760c0d06caSMauro Carvalho Chehab .bytesperline = 160, 2770c0d06caSMauro Carvalho Chehab .sizeimage = 160 * 120, 2780c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2790c0d06caSMauro Carvalho Chehab .priv = SCALE_160x120 | MODE_RAW}, 2800c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, 2810c0d06caSMauro Carvalho Chehab .bytesperline = 320, 2820c0d06caSMauro Carvalho Chehab .sizeimage = 320 * 240 , 2830c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2840c0d06caSMauro Carvalho Chehab .priv = SCALE_320x240 | MODE_RAW}, 2850c0d06caSMauro Carvalho Chehab {640, 480, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, 2860c0d06caSMauro Carvalho Chehab .bytesperline = 640, 2870c0d06caSMauro Carvalho Chehab .sizeimage = 640 * 480, 2880c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2890c0d06caSMauro Carvalho Chehab .priv = SCALE_640x480 | MODE_RAW}, 2900c0d06caSMauro Carvalho Chehab {1280, 1024, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, 2910c0d06caSMauro Carvalho Chehab .bytesperline = 1280, 2920c0d06caSMauro Carvalho Chehab .sizeimage = 1280 * 1024, 2930c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 2940c0d06caSMauro Carvalho Chehab .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA}, 2950c0d06caSMauro Carvalho Chehab }; 2960c0d06caSMauro Carvalho Chehab 2970c0d06caSMauro Carvalho Chehab static const s16 hsv_red_x[] = { 2980c0d06caSMauro Carvalho Chehab 41, 44, 46, 48, 50, 52, 54, 56, 2990c0d06caSMauro Carvalho Chehab 58, 60, 62, 64, 66, 68, 70, 72, 3000c0d06caSMauro Carvalho Chehab 74, 76, 78, 80, 81, 83, 85, 87, 3010c0d06caSMauro Carvalho Chehab 88, 90, 92, 93, 95, 97, 98, 100, 3020c0d06caSMauro Carvalho Chehab 101, 102, 104, 105, 107, 108, 109, 110, 3030c0d06caSMauro Carvalho Chehab 112, 113, 114, 115, 116, 117, 118, 119, 3040c0d06caSMauro Carvalho Chehab 120, 121, 122, 123, 123, 124, 125, 125, 3050c0d06caSMauro Carvalho Chehab 126, 127, 127, 128, 128, 129, 129, 129, 3060c0d06caSMauro Carvalho Chehab 130, 130, 130, 130, 131, 131, 131, 131, 3070c0d06caSMauro Carvalho Chehab 131, 131, 131, 131, 130, 130, 130, 130, 3080c0d06caSMauro Carvalho Chehab 129, 129, 129, 128, 128, 127, 127, 126, 3090c0d06caSMauro Carvalho Chehab 125, 125, 124, 123, 122, 122, 121, 120, 3100c0d06caSMauro Carvalho Chehab 119, 118, 117, 116, 115, 114, 112, 111, 3110c0d06caSMauro Carvalho Chehab 110, 109, 107, 106, 105, 103, 102, 101, 3120c0d06caSMauro Carvalho Chehab 99, 98, 96, 94, 93, 91, 90, 88, 3130c0d06caSMauro Carvalho Chehab 86, 84, 83, 81, 79, 77, 75, 74, 3140c0d06caSMauro Carvalho Chehab 72, 70, 68, 66, 64, 62, 60, 58, 3150c0d06caSMauro Carvalho Chehab 56, 54, 52, 49, 47, 45, 43, 41, 3160c0d06caSMauro Carvalho Chehab 39, 36, 34, 32, 30, 28, 25, 23, 3170c0d06caSMauro Carvalho Chehab 21, 19, 16, 14, 12, 9, 7, 5, 3180c0d06caSMauro Carvalho Chehab 3, 0, -1, -3, -6, -8, -10, -12, 3190c0d06caSMauro Carvalho Chehab -15, -17, -19, -22, -24, -26, -28, -30, 3200c0d06caSMauro Carvalho Chehab -33, -35, -37, -39, -41, -44, -46, -48, 3210c0d06caSMauro Carvalho Chehab -50, -52, -54, -56, -58, -60, -62, -64, 3220c0d06caSMauro Carvalho Chehab -66, -68, -70, -72, -74, -76, -78, -80, 3230c0d06caSMauro Carvalho Chehab -81, -83, -85, -87, -88, -90, -92, -93, 3240c0d06caSMauro Carvalho Chehab -95, -97, -98, -100, -101, -102, -104, -105, 3250c0d06caSMauro Carvalho Chehab -107, -108, -109, -110, -112, -113, -114, -115, 3260c0d06caSMauro Carvalho Chehab -116, -117, -118, -119, -120, -121, -122, -123, 3270c0d06caSMauro Carvalho Chehab -123, -124, -125, -125, -126, -127, -127, -128, 3280c0d06caSMauro Carvalho Chehab -128, -128, -128, -128, -128, -128, -128, -128, 3290c0d06caSMauro Carvalho Chehab -128, -128, -128, -128, -128, -128, -128, -128, 3300c0d06caSMauro Carvalho Chehab -128, -128, -128, -128, -128, -128, -128, -128, 3310c0d06caSMauro Carvalho Chehab -128, -127, -127, -126, -125, -125, -124, -123, 3320c0d06caSMauro Carvalho Chehab -122, -122, -121, -120, -119, -118, -117, -116, 3330c0d06caSMauro Carvalho Chehab -115, -114, -112, -111, -110, -109, -107, -106, 3340c0d06caSMauro Carvalho Chehab -105, -103, -102, -101, -99, -98, -96, -94, 3350c0d06caSMauro Carvalho Chehab -93, -91, -90, -88, -86, -84, -83, -81, 3360c0d06caSMauro Carvalho Chehab -79, -77, -75, -74, -72, -70, -68, -66, 3370c0d06caSMauro Carvalho Chehab -64, -62, -60, -58, -56, -54, -52, -49, 3380c0d06caSMauro Carvalho Chehab -47, -45, -43, -41, -39, -36, -34, -32, 3390c0d06caSMauro Carvalho Chehab -30, -28, -25, -23, -21, -19, -16, -14, 3400c0d06caSMauro Carvalho Chehab -12, -9, -7, -5, -3, 0, 1, 3, 3410c0d06caSMauro Carvalho Chehab 6, 8, 10, 12, 15, 17, 19, 22, 3420c0d06caSMauro Carvalho Chehab 24, 26, 28, 30, 33, 35, 37, 39, 41 3430c0d06caSMauro Carvalho Chehab }; 3440c0d06caSMauro Carvalho Chehab 3450c0d06caSMauro Carvalho Chehab static const s16 hsv_red_y[] = { 3460c0d06caSMauro Carvalho Chehab 82, 80, 78, 76, 74, 73, 71, 69, 3470c0d06caSMauro Carvalho Chehab 67, 65, 63, 61, 58, 56, 54, 52, 3480c0d06caSMauro Carvalho Chehab 50, 48, 46, 44, 41, 39, 37, 35, 3490c0d06caSMauro Carvalho Chehab 32, 30, 28, 26, 23, 21, 19, 16, 3500c0d06caSMauro Carvalho Chehab 14, 12, 10, 7, 5, 3, 0, -1, 3510c0d06caSMauro Carvalho Chehab -3, -6, -8, -10, -13, -15, -17, -19, 3520c0d06caSMauro Carvalho Chehab -22, -24, -26, -29, -31, -33, -35, -38, 3530c0d06caSMauro Carvalho Chehab -40, -42, -44, -46, -48, -51, -53, -55, 3540c0d06caSMauro Carvalho Chehab -57, -59, -61, -63, -65, -67, -69, -71, 3550c0d06caSMauro Carvalho Chehab -73, -75, -77, -79, -81, -82, -84, -86, 3560c0d06caSMauro Carvalho Chehab -88, -89, -91, -93, -94, -96, -98, -99, 3570c0d06caSMauro Carvalho Chehab -101, -102, -104, -105, -106, -108, -109, -110, 3580c0d06caSMauro Carvalho Chehab -112, -113, -114, -115, -116, -117, -119, -120, 3590c0d06caSMauro Carvalho Chehab -120, -121, -122, -123, -124, -125, -126, -126, 3600c0d06caSMauro Carvalho Chehab -127, -128, -128, -128, -128, -128, -128, -128, 3610c0d06caSMauro Carvalho Chehab -128, -128, -128, -128, -128, -128, -128, -128, 3620c0d06caSMauro Carvalho Chehab -128, -128, -128, -128, -128, -128, -128, -128, 3630c0d06caSMauro Carvalho Chehab -128, -128, -128, -128, -128, -128, -128, -128, 3640c0d06caSMauro Carvalho Chehab -127, -127, -126, -125, -125, -124, -123, -122, 3650c0d06caSMauro Carvalho Chehab -121, -120, -119, -118, -117, -116, -115, -114, 3660c0d06caSMauro Carvalho Chehab -113, -111, -110, -109, -107, -106, -105, -103, 3670c0d06caSMauro Carvalho Chehab -102, -100, -99, -97, -96, -94, -92, -91, 3680c0d06caSMauro Carvalho Chehab -89, -87, -85, -84, -82, -80, -78, -76, 3690c0d06caSMauro Carvalho Chehab -74, -73, -71, -69, -67, -65, -63, -61, 3700c0d06caSMauro Carvalho Chehab -58, -56, -54, -52, -50, -48, -46, -44, 3710c0d06caSMauro Carvalho Chehab -41, -39, -37, -35, -32, -30, -28, -26, 3720c0d06caSMauro Carvalho Chehab -23, -21, -19, -16, -14, -12, -10, -7, 3730c0d06caSMauro Carvalho Chehab -5, -3, 0, 1, 3, 6, 8, 10, 3740c0d06caSMauro Carvalho Chehab 13, 15, 17, 19, 22, 24, 26, 29, 3750c0d06caSMauro Carvalho Chehab 31, 33, 35, 38, 40, 42, 44, 46, 3760c0d06caSMauro Carvalho Chehab 48, 51, 53, 55, 57, 59, 61, 63, 3770c0d06caSMauro Carvalho Chehab 65, 67, 69, 71, 73, 75, 77, 79, 3780c0d06caSMauro Carvalho Chehab 81, 82, 84, 86, 88, 89, 91, 93, 3790c0d06caSMauro Carvalho Chehab 94, 96, 98, 99, 101, 102, 104, 105, 3800c0d06caSMauro Carvalho Chehab 106, 108, 109, 110, 112, 113, 114, 115, 3810c0d06caSMauro Carvalho Chehab 116, 117, 119, 120, 120, 121, 122, 123, 3820c0d06caSMauro Carvalho Chehab 124, 125, 126, 126, 127, 128, 128, 129, 3830c0d06caSMauro Carvalho Chehab 129, 130, 130, 131, 131, 131, 131, 132, 3840c0d06caSMauro Carvalho Chehab 132, 132, 132, 132, 132, 132, 132, 132, 3850c0d06caSMauro Carvalho Chehab 132, 132, 132, 131, 131, 131, 130, 130, 3860c0d06caSMauro Carvalho Chehab 130, 129, 129, 128, 127, 127, 126, 125, 3870c0d06caSMauro Carvalho Chehab 125, 124, 123, 122, 121, 120, 119, 118, 3880c0d06caSMauro Carvalho Chehab 117, 116, 115, 114, 113, 111, 110, 109, 3890c0d06caSMauro Carvalho Chehab 107, 106, 105, 103, 102, 100, 99, 97, 3900c0d06caSMauro Carvalho Chehab 96, 94, 92, 91, 89, 87, 85, 84, 82 3910c0d06caSMauro Carvalho Chehab }; 3920c0d06caSMauro Carvalho Chehab 3930c0d06caSMauro Carvalho Chehab static const s16 hsv_green_x[] = { 3940c0d06caSMauro Carvalho Chehab -124, -124, -125, -125, -125, -125, -125, -125, 3950c0d06caSMauro Carvalho Chehab -125, -126, -126, -125, -125, -125, -125, -125, 3960c0d06caSMauro Carvalho Chehab -125, -124, -124, -124, -123, -123, -122, -122, 3970c0d06caSMauro Carvalho Chehab -121, -121, -120, -120, -119, -118, -117, -117, 3980c0d06caSMauro Carvalho Chehab -116, -115, -114, -113, -112, -111, -110, -109, 3990c0d06caSMauro Carvalho Chehab -108, -107, -105, -104, -103, -102, -100, -99, 4000c0d06caSMauro Carvalho Chehab -98, -96, -95, -93, -92, -91, -89, -87, 4010c0d06caSMauro Carvalho Chehab -86, -84, -83, -81, -79, -77, -76, -74, 4020c0d06caSMauro Carvalho Chehab -72, -70, -69, -67, -65, -63, -61, -59, 4030c0d06caSMauro Carvalho Chehab -57, -55, -53, -51, -49, -47, -45, -43, 4040c0d06caSMauro Carvalho Chehab -41, -39, -37, -35, -33, -30, -28, -26, 4050c0d06caSMauro Carvalho Chehab -24, -22, -20, -18, -15, -13, -11, -9, 4060c0d06caSMauro Carvalho Chehab -7, -4, -2, 0, 1, 3, 6, 8, 4070c0d06caSMauro Carvalho Chehab 10, 12, 14, 17, 19, 21, 23, 25, 4080c0d06caSMauro Carvalho Chehab 27, 29, 32, 34, 36, 38, 40, 42, 4090c0d06caSMauro Carvalho Chehab 44, 46, 48, 50, 52, 54, 56, 58, 4100c0d06caSMauro Carvalho Chehab 60, 62, 64, 66, 68, 70, 71, 73, 4110c0d06caSMauro Carvalho Chehab 75, 77, 78, 80, 82, 83, 85, 87, 4120c0d06caSMauro Carvalho Chehab 88, 90, 91, 93, 94, 96, 97, 98, 4130c0d06caSMauro Carvalho Chehab 100, 101, 102, 104, 105, 106, 107, 108, 4140c0d06caSMauro Carvalho Chehab 109, 111, 112, 113, 113, 114, 115, 116, 4150c0d06caSMauro Carvalho Chehab 117, 118, 118, 119, 120, 120, 121, 122, 4160c0d06caSMauro Carvalho Chehab 122, 123, 123, 124, 124, 124, 125, 125, 4170c0d06caSMauro Carvalho Chehab 125, 125, 125, 125, 125, 126, 126, 125, 4180c0d06caSMauro Carvalho Chehab 125, 125, 125, 125, 125, 124, 124, 124, 4190c0d06caSMauro Carvalho Chehab 123, 123, 122, 122, 121, 121, 120, 120, 4200c0d06caSMauro Carvalho Chehab 119, 118, 117, 117, 116, 115, 114, 113, 4210c0d06caSMauro Carvalho Chehab 112, 111, 110, 109, 108, 107, 105, 104, 4220c0d06caSMauro Carvalho Chehab 103, 102, 100, 99, 98, 96, 95, 93, 4230c0d06caSMauro Carvalho Chehab 92, 91, 89, 87, 86, 84, 83, 81, 4240c0d06caSMauro Carvalho Chehab 79, 77, 76, 74, 72, 70, 69, 67, 4250c0d06caSMauro Carvalho Chehab 65, 63, 61, 59, 57, 55, 53, 51, 4260c0d06caSMauro Carvalho Chehab 49, 47, 45, 43, 41, 39, 37, 35, 4270c0d06caSMauro Carvalho Chehab 33, 30, 28, 26, 24, 22, 20, 18, 4280c0d06caSMauro Carvalho Chehab 15, 13, 11, 9, 7, 4, 2, 0, 4290c0d06caSMauro Carvalho Chehab -1, -3, -6, -8, -10, -12, -14, -17, 4300c0d06caSMauro Carvalho Chehab -19, -21, -23, -25, -27, -29, -32, -34, 4310c0d06caSMauro Carvalho Chehab -36, -38, -40, -42, -44, -46, -48, -50, 4320c0d06caSMauro Carvalho Chehab -52, -54, -56, -58, -60, -62, -64, -66, 4330c0d06caSMauro Carvalho Chehab -68, -70, -71, -73, -75, -77, -78, -80, 4340c0d06caSMauro Carvalho Chehab -82, -83, -85, -87, -88, -90, -91, -93, 4350c0d06caSMauro Carvalho Chehab -94, -96, -97, -98, -100, -101, -102, -104, 4360c0d06caSMauro Carvalho Chehab -105, -106, -107, -108, -109, -111, -112, -113, 4370c0d06caSMauro Carvalho Chehab -113, -114, -115, -116, -117, -118, -118, -119, 4380c0d06caSMauro Carvalho Chehab -120, -120, -121, -122, -122, -123, -123, -124, -124 4390c0d06caSMauro Carvalho Chehab }; 4400c0d06caSMauro Carvalho Chehab 4410c0d06caSMauro Carvalho Chehab static const s16 hsv_green_y[] = { 4420c0d06caSMauro Carvalho Chehab -100, -99, -98, -97, -95, -94, -93, -91, 4430c0d06caSMauro Carvalho Chehab -90, -89, -87, -86, -84, -83, -81, -80, 4440c0d06caSMauro Carvalho Chehab -78, -76, -75, -73, -71, -70, -68, -66, 4450c0d06caSMauro Carvalho Chehab -64, -63, -61, -59, -57, -55, -53, -51, 4460c0d06caSMauro Carvalho Chehab -49, -48, -46, -44, -42, -40, -38, -36, 4470c0d06caSMauro Carvalho Chehab -34, -32, -30, -27, -25, -23, -21, -19, 4480c0d06caSMauro Carvalho Chehab -17, -15, -13, -11, -9, -7, -4, -2, 4490c0d06caSMauro Carvalho Chehab 0, 1, 3, 5, 7, 9, 11, 14, 4500c0d06caSMauro Carvalho Chehab 16, 18, 20, 22, 24, 26, 28, 30, 4510c0d06caSMauro Carvalho Chehab 32, 34, 36, 38, 40, 42, 44, 46, 4520c0d06caSMauro Carvalho Chehab 48, 50, 52, 54, 56, 58, 59, 61, 4530c0d06caSMauro Carvalho Chehab 63, 65, 67, 68, 70, 72, 74, 75, 4540c0d06caSMauro Carvalho Chehab 77, 78, 80, 82, 83, 85, 86, 88, 4550c0d06caSMauro Carvalho Chehab 89, 90, 92, 93, 95, 96, 97, 98, 4560c0d06caSMauro Carvalho Chehab 100, 101, 102, 103, 104, 105, 106, 107, 4570c0d06caSMauro Carvalho Chehab 108, 109, 110, 111, 112, 112, 113, 114, 4580c0d06caSMauro Carvalho Chehab 115, 115, 116, 116, 117, 117, 118, 118, 4590c0d06caSMauro Carvalho Chehab 119, 119, 119, 120, 120, 120, 120, 120, 4600c0d06caSMauro Carvalho Chehab 121, 121, 121, 121, 121, 121, 120, 120, 4610c0d06caSMauro Carvalho Chehab 120, 120, 120, 119, 119, 119, 118, 118, 4620c0d06caSMauro Carvalho Chehab 117, 117, 116, 116, 115, 114, 114, 113, 4630c0d06caSMauro Carvalho Chehab 112, 111, 111, 110, 109, 108, 107, 106, 4640c0d06caSMauro Carvalho Chehab 105, 104, 103, 102, 100, 99, 98, 97, 4650c0d06caSMauro Carvalho Chehab 95, 94, 93, 91, 90, 89, 87, 86, 4660c0d06caSMauro Carvalho Chehab 84, 83, 81, 80, 78, 76, 75, 73, 4670c0d06caSMauro Carvalho Chehab 71, 70, 68, 66, 64, 63, 61, 59, 4680c0d06caSMauro Carvalho Chehab 57, 55, 53, 51, 49, 48, 46, 44, 4690c0d06caSMauro Carvalho Chehab 42, 40, 38, 36, 34, 32, 30, 27, 4700c0d06caSMauro Carvalho Chehab 25, 23, 21, 19, 17, 15, 13, 11, 4710c0d06caSMauro Carvalho Chehab 9, 7, 4, 2, 0, -1, -3, -5, 4720c0d06caSMauro Carvalho Chehab -7, -9, -11, -14, -16, -18, -20, -22, 4730c0d06caSMauro Carvalho Chehab -24, -26, -28, -30, -32, -34, -36, -38, 4740c0d06caSMauro Carvalho Chehab -40, -42, -44, -46, -48, -50, -52, -54, 4750c0d06caSMauro Carvalho Chehab -56, -58, -59, -61, -63, -65, -67, -68, 4760c0d06caSMauro Carvalho Chehab -70, -72, -74, -75, -77, -78, -80, -82, 4770c0d06caSMauro Carvalho Chehab -83, -85, -86, -88, -89, -90, -92, -93, 4780c0d06caSMauro Carvalho Chehab -95, -96, -97, -98, -100, -101, -102, -103, 4790c0d06caSMauro Carvalho Chehab -104, -105, -106, -107, -108, -109, -110, -111, 4800c0d06caSMauro Carvalho Chehab -112, -112, -113, -114, -115, -115, -116, -116, 4810c0d06caSMauro Carvalho Chehab -117, -117, -118, -118, -119, -119, -119, -120, 4820c0d06caSMauro Carvalho Chehab -120, -120, -120, -120, -121, -121, -121, -121, 4830c0d06caSMauro Carvalho Chehab -121, -121, -120, -120, -120, -120, -120, -119, 4840c0d06caSMauro Carvalho Chehab -119, -119, -118, -118, -117, -117, -116, -116, 4850c0d06caSMauro Carvalho Chehab -115, -114, -114, -113, -112, -111, -111, -110, 4860c0d06caSMauro Carvalho Chehab -109, -108, -107, -106, -105, -104, -103, -102, -100 4870c0d06caSMauro Carvalho Chehab }; 4880c0d06caSMauro Carvalho Chehab 4890c0d06caSMauro Carvalho Chehab static const s16 hsv_blue_x[] = { 4900c0d06caSMauro Carvalho Chehab 112, 113, 114, 114, 115, 116, 117, 117, 4910c0d06caSMauro Carvalho Chehab 118, 118, 119, 119, 120, 120, 120, 121, 4920c0d06caSMauro Carvalho Chehab 121, 121, 122, 122, 122, 122, 122, 122, 4930c0d06caSMauro Carvalho Chehab 122, 122, 122, 122, 122, 122, 121, 121, 4940c0d06caSMauro Carvalho Chehab 121, 120, 120, 120, 119, 119, 118, 118, 4950c0d06caSMauro Carvalho Chehab 117, 116, 116, 115, 114, 113, 113, 112, 4960c0d06caSMauro Carvalho Chehab 111, 110, 109, 108, 107, 106, 105, 104, 4970c0d06caSMauro Carvalho Chehab 103, 102, 100, 99, 98, 97, 95, 94, 4980c0d06caSMauro Carvalho Chehab 93, 91, 90, 88, 87, 85, 84, 82, 4990c0d06caSMauro Carvalho Chehab 80, 79, 77, 76, 74, 72, 70, 69, 5000c0d06caSMauro Carvalho Chehab 67, 65, 63, 61, 60, 58, 56, 54, 5010c0d06caSMauro Carvalho Chehab 52, 50, 48, 46, 44, 42, 40, 38, 5020c0d06caSMauro Carvalho Chehab 36, 34, 32, 30, 28, 26, 24, 22, 5030c0d06caSMauro Carvalho Chehab 19, 17, 15, 13, 11, 9, 7, 5, 5040c0d06caSMauro Carvalho Chehab 2, 0, -1, -3, -5, -7, -9, -12, 5050c0d06caSMauro Carvalho Chehab -14, -16, -18, -20, -22, -24, -26, -28, 5060c0d06caSMauro Carvalho Chehab -31, -33, -35, -37, -39, -41, -43, -45, 5070c0d06caSMauro Carvalho Chehab -47, -49, -51, -53, -54, -56, -58, -60, 5080c0d06caSMauro Carvalho Chehab -62, -64, -66, -67, -69, -71, -73, -74, 5090c0d06caSMauro Carvalho Chehab -76, -78, -79, -81, -83, -84, -86, -87, 5100c0d06caSMauro Carvalho Chehab -89, -90, -92, -93, -94, -96, -97, -98, 5110c0d06caSMauro Carvalho Chehab -99, -101, -102, -103, -104, -105, -106, -107, 5120c0d06caSMauro Carvalho Chehab -108, -109, -110, -111, -112, -113, -114, -114, 5130c0d06caSMauro Carvalho Chehab -115, -116, -117, -117, -118, -118, -119, -119, 5140c0d06caSMauro Carvalho Chehab -120, -120, -120, -121, -121, -121, -122, -122, 5150c0d06caSMauro Carvalho Chehab -122, -122, -122, -122, -122, -122, -122, -122, 5160c0d06caSMauro Carvalho Chehab -122, -122, -121, -121, -121, -120, -120, -120, 5170c0d06caSMauro Carvalho Chehab -119, -119, -118, -118, -117, -116, -116, -115, 5180c0d06caSMauro Carvalho Chehab -114, -113, -113, -112, -111, -110, -109, -108, 5190c0d06caSMauro Carvalho Chehab -107, -106, -105, -104, -103, -102, -100, -99, 5200c0d06caSMauro Carvalho Chehab -98, -97, -95, -94, -93, -91, -90, -88, 5210c0d06caSMauro Carvalho Chehab -87, -85, -84, -82, -80, -79, -77, -76, 5220c0d06caSMauro Carvalho Chehab -74, -72, -70, -69, -67, -65, -63, -61, 5230c0d06caSMauro Carvalho Chehab -60, -58, -56, -54, -52, -50, -48, -46, 5240c0d06caSMauro Carvalho Chehab -44, -42, -40, -38, -36, -34, -32, -30, 5250c0d06caSMauro Carvalho Chehab -28, -26, -24, -22, -19, -17, -15, -13, 5260c0d06caSMauro Carvalho Chehab -11, -9, -7, -5, -2, 0, 1, 3, 5270c0d06caSMauro Carvalho Chehab 5, 7, 9, 12, 14, 16, 18, 20, 5280c0d06caSMauro Carvalho Chehab 22, 24, 26, 28, 31, 33, 35, 37, 5290c0d06caSMauro Carvalho Chehab 39, 41, 43, 45, 47, 49, 51, 53, 5300c0d06caSMauro Carvalho Chehab 54, 56, 58, 60, 62, 64, 66, 67, 5310c0d06caSMauro Carvalho Chehab 69, 71, 73, 74, 76, 78, 79, 81, 5320c0d06caSMauro Carvalho Chehab 83, 84, 86, 87, 89, 90, 92, 93, 5330c0d06caSMauro Carvalho Chehab 94, 96, 97, 98, 99, 101, 102, 103, 5340c0d06caSMauro Carvalho Chehab 104, 105, 106, 107, 108, 109, 110, 111, 112 5350c0d06caSMauro Carvalho Chehab }; 5360c0d06caSMauro Carvalho Chehab 5370c0d06caSMauro Carvalho Chehab static const s16 hsv_blue_y[] = { 5380c0d06caSMauro Carvalho Chehab -11, -13, -15, -17, -19, -21, -23, -25, 5390c0d06caSMauro Carvalho Chehab -27, -29, -31, -33, -35, -37, -39, -41, 5400c0d06caSMauro Carvalho Chehab -43, -45, -46, -48, -50, -52, -54, -55, 5410c0d06caSMauro Carvalho Chehab -57, -59, -61, -62, -64, -66, -67, -69, 5420c0d06caSMauro Carvalho Chehab -71, -72, -74, -75, -77, -78, -80, -81, 5430c0d06caSMauro Carvalho Chehab -83, -84, -86, -87, -88, -90, -91, -92, 5440c0d06caSMauro Carvalho Chehab -93, -95, -96, -97, -98, -99, -100, -101, 5450c0d06caSMauro Carvalho Chehab -102, -103, -104, -105, -106, -106, -107, -108, 5460c0d06caSMauro Carvalho Chehab -109, -109, -110, -111, -111, -112, -112, -113, 5470c0d06caSMauro Carvalho Chehab -113, -114, -114, -114, -115, -115, -115, -115, 5480c0d06caSMauro Carvalho Chehab -116, -116, -116, -116, -116, -116, -116, -116, 5490c0d06caSMauro Carvalho Chehab -116, -115, -115, -115, -115, -114, -114, -114, 5500c0d06caSMauro Carvalho Chehab -113, -113, -112, -112, -111, -111, -110, -110, 5510c0d06caSMauro Carvalho Chehab -109, -108, -108, -107, -106, -105, -104, -103, 5520c0d06caSMauro Carvalho Chehab -102, -101, -100, -99, -98, -97, -96, -95, 5530c0d06caSMauro Carvalho Chehab -94, -93, -91, -90, -89, -88, -86, -85, 5540c0d06caSMauro Carvalho Chehab -84, -82, -81, -79, -78, -76, -75, -73, 5550c0d06caSMauro Carvalho Chehab -71, -70, -68, -67, -65, -63, -62, -60, 5560c0d06caSMauro Carvalho Chehab -58, -56, -55, -53, -51, -49, -47, -45, 5570c0d06caSMauro Carvalho Chehab -44, -42, -40, -38, -36, -34, -32, -30, 5580c0d06caSMauro Carvalho Chehab -28, -26, -24, -22, -20, -18, -16, -14, 5590c0d06caSMauro Carvalho Chehab -12, -10, -8, -6, -4, -2, 0, 1, 5600c0d06caSMauro Carvalho Chehab 3, 5, 7, 9, 11, 13, 15, 17, 5610c0d06caSMauro Carvalho Chehab 19, 21, 23, 25, 27, 29, 31, 33, 5620c0d06caSMauro Carvalho Chehab 35, 37, 39, 41, 43, 45, 46, 48, 5630c0d06caSMauro Carvalho Chehab 50, 52, 54, 55, 57, 59, 61, 62, 5640c0d06caSMauro Carvalho Chehab 64, 66, 67, 69, 71, 72, 74, 75, 5650c0d06caSMauro Carvalho Chehab 77, 78, 80, 81, 83, 84, 86, 87, 5660c0d06caSMauro Carvalho Chehab 88, 90, 91, 92, 93, 95, 96, 97, 5670c0d06caSMauro Carvalho Chehab 98, 99, 100, 101, 102, 103, 104, 105, 5680c0d06caSMauro Carvalho Chehab 106, 106, 107, 108, 109, 109, 110, 111, 5690c0d06caSMauro Carvalho Chehab 111, 112, 112, 113, 113, 114, 114, 114, 5700c0d06caSMauro Carvalho Chehab 115, 115, 115, 115, 116, 116, 116, 116, 5710c0d06caSMauro Carvalho Chehab 116, 116, 116, 116, 116, 115, 115, 115, 5720c0d06caSMauro Carvalho Chehab 115, 114, 114, 114, 113, 113, 112, 112, 5730c0d06caSMauro Carvalho Chehab 111, 111, 110, 110, 109, 108, 108, 107, 5740c0d06caSMauro Carvalho Chehab 106, 105, 104, 103, 102, 101, 100, 99, 5750c0d06caSMauro Carvalho Chehab 98, 97, 96, 95, 94, 93, 91, 90, 5760c0d06caSMauro Carvalho Chehab 89, 88, 86, 85, 84, 82, 81, 79, 5770c0d06caSMauro Carvalho Chehab 78, 76, 75, 73, 71, 70, 68, 67, 5780c0d06caSMauro Carvalho Chehab 65, 63, 62, 60, 58, 56, 55, 53, 5790c0d06caSMauro Carvalho Chehab 51, 49, 47, 45, 44, 42, 40, 38, 5800c0d06caSMauro Carvalho Chehab 36, 34, 32, 30, 28, 26, 24, 22, 5810c0d06caSMauro Carvalho Chehab 20, 18, 16, 14, 12, 10, 8, 6, 5820c0d06caSMauro Carvalho Chehab 4, 2, 0, -1, -3, -5, -7, -9, -11 5830c0d06caSMauro Carvalho Chehab }; 5840c0d06caSMauro Carvalho Chehab 5850c0d06caSMauro Carvalho Chehab static const u16 i2c_ident[] = { 5860c0d06caSMauro Carvalho Chehab V4L2_IDENT_OV9650, 5870c0d06caSMauro Carvalho Chehab V4L2_IDENT_OV9655, 5880c0d06caSMauro Carvalho Chehab V4L2_IDENT_SOI968, 5890c0d06caSMauro Carvalho Chehab V4L2_IDENT_OV7660, 5900c0d06caSMauro Carvalho Chehab V4L2_IDENT_OV7670, 5910c0d06caSMauro Carvalho Chehab V4L2_IDENT_MT9V011, 5920c0d06caSMauro Carvalho Chehab V4L2_IDENT_MT9V111, 5930c0d06caSMauro Carvalho Chehab V4L2_IDENT_MT9V112, 5940c0d06caSMauro Carvalho Chehab V4L2_IDENT_MT9M001C12ST, 5950c0d06caSMauro Carvalho Chehab V4L2_IDENT_MT9M111, 5960c0d06caSMauro Carvalho Chehab V4L2_IDENT_MT9M112, 5970c0d06caSMauro Carvalho Chehab V4L2_IDENT_HV7131R, 5980c0d06caSMauro Carvalho Chehab [SENSOR_MT9VPRB] = V4L2_IDENT_UNKNOWN, 5990c0d06caSMauro Carvalho Chehab }; 6000c0d06caSMauro Carvalho Chehab 6010c0d06caSMauro Carvalho Chehab static const u16 bridge_init[][2] = { 6020c0d06caSMauro Carvalho Chehab {0x1000, 0x78}, {0x1001, 0x40}, {0x1002, 0x1c}, 6030c0d06caSMauro Carvalho Chehab {0x1020, 0x80}, {0x1061, 0x01}, {0x1067, 0x40}, 6040c0d06caSMauro Carvalho Chehab {0x1068, 0x30}, {0x1069, 0x20}, {0x106a, 0x10}, 6050c0d06caSMauro Carvalho Chehab {0x106b, 0x08}, {0x1188, 0x87}, {0x11a1, 0x00}, 6060c0d06caSMauro Carvalho Chehab {0x11a2, 0x00}, {0x11a3, 0x6a}, {0x11a4, 0x50}, 6070c0d06caSMauro Carvalho Chehab {0x11ab, 0x00}, {0x11ac, 0x00}, {0x11ad, 0x50}, 6080c0d06caSMauro Carvalho Chehab {0x11ae, 0x3c}, {0x118a, 0x04}, {0x0395, 0x04}, 6090c0d06caSMauro Carvalho Chehab {0x11b8, 0x3a}, {0x118b, 0x0e}, {0x10f7, 0x05}, 6100c0d06caSMauro Carvalho Chehab {0x10f8, 0x14}, {0x10fa, 0xff}, {0x10f9, 0x00}, 6110c0d06caSMauro Carvalho Chehab {0x11ba, 0x0a}, {0x11a5, 0x2d}, {0x11a6, 0x2d}, 6120c0d06caSMauro Carvalho Chehab {0x11a7, 0x3a}, {0x11a8, 0x05}, {0x11a9, 0x04}, 6130c0d06caSMauro Carvalho Chehab {0x11aa, 0x3f}, {0x11af, 0x28}, {0x11b0, 0xd8}, 6140c0d06caSMauro Carvalho Chehab {0x11b1, 0x14}, {0x11b2, 0xec}, {0x11b3, 0x32}, 6150c0d06caSMauro Carvalho Chehab {0x11b4, 0xdd}, {0x11b5, 0x32}, {0x11b6, 0xdd}, 6160c0d06caSMauro Carvalho Chehab {0x10e0, 0x2c}, {0x11bc, 0x40}, {0x11bd, 0x01}, 6170c0d06caSMauro Carvalho Chehab {0x11be, 0xf0}, {0x11bf, 0x00}, {0x118c, 0x1f}, 6180c0d06caSMauro Carvalho Chehab {0x118d, 0x1f}, {0x118e, 0x1f}, {0x118f, 0x1f}, 6190c0d06caSMauro Carvalho Chehab {0x1180, 0x01}, {0x1181, 0x00}, {0x1182, 0x01}, 6200c0d06caSMauro Carvalho Chehab {0x1183, 0x00}, {0x1184, 0x50}, {0x1185, 0x80}, 6210c0d06caSMauro Carvalho Chehab {0x1007, 0x00} 6220c0d06caSMauro Carvalho Chehab }; 6230c0d06caSMauro Carvalho Chehab 6240c0d06caSMauro Carvalho Chehab /* Gain = (bit[3:0] / 16 + 1) * (bit[4] + 1) * (bit[5] + 1) * (bit[6] + 1) */ 6250c0d06caSMauro Carvalho Chehab static const u8 ov_gain[] = { 6260c0d06caSMauro Carvalho Chehab 0x00 /* 1x */, 0x04 /* 1.25x */, 0x08 /* 1.5x */, 0x0c /* 1.75x */, 6270c0d06caSMauro Carvalho Chehab 0x10 /* 2x */, 0x12 /* 2.25x */, 0x14 /* 2.5x */, 0x16 /* 2.75x */, 6280c0d06caSMauro Carvalho Chehab 0x18 /* 3x */, 0x1a /* 3.25x */, 0x1c /* 3.5x */, 0x1e /* 3.75x */, 6290c0d06caSMauro Carvalho Chehab 0x30 /* 4x */, 0x31 /* 4.25x */, 0x32 /* 4.5x */, 0x33 /* 4.75x */, 6300c0d06caSMauro Carvalho Chehab 0x34 /* 5x */, 0x35 /* 5.25x */, 0x36 /* 5.5x */, 0x37 /* 5.75x */, 6310c0d06caSMauro Carvalho Chehab 0x38 /* 6x */, 0x39 /* 6.25x */, 0x3a /* 6.5x */, 0x3b /* 6.75x */, 6320c0d06caSMauro Carvalho Chehab 0x3c /* 7x */, 0x3d /* 7.25x */, 0x3e /* 7.5x */, 0x3f /* 7.75x */, 6330c0d06caSMauro Carvalho Chehab 0x70 /* 8x */ 6340c0d06caSMauro Carvalho Chehab }; 6350c0d06caSMauro Carvalho Chehab 6360c0d06caSMauro Carvalho Chehab /* Gain = (bit[8] + 1) * (bit[7] + 1) * (bit[6:0] * 0.03125) */ 6370c0d06caSMauro Carvalho Chehab static const u16 micron1_gain[] = { 6380c0d06caSMauro Carvalho Chehab /* 1x 1.25x 1.5x 1.75x */ 6390c0d06caSMauro Carvalho Chehab 0x0020, 0x0028, 0x0030, 0x0038, 6400c0d06caSMauro Carvalho Chehab /* 2x 2.25x 2.5x 2.75x */ 6410c0d06caSMauro Carvalho Chehab 0x00a0, 0x00a4, 0x00a8, 0x00ac, 6420c0d06caSMauro Carvalho Chehab /* 3x 3.25x 3.5x 3.75x */ 6430c0d06caSMauro Carvalho Chehab 0x00b0, 0x00b4, 0x00b8, 0x00bc, 6440c0d06caSMauro Carvalho Chehab /* 4x 4.25x 4.5x 4.75x */ 6450c0d06caSMauro Carvalho Chehab 0x00c0, 0x00c4, 0x00c8, 0x00cc, 6460c0d06caSMauro Carvalho Chehab /* 5x 5.25x 5.5x 5.75x */ 6470c0d06caSMauro Carvalho Chehab 0x00d0, 0x00d4, 0x00d8, 0x00dc, 6480c0d06caSMauro Carvalho Chehab /* 6x 6.25x 6.5x 6.75x */ 6490c0d06caSMauro Carvalho Chehab 0x00e0, 0x00e4, 0x00e8, 0x00ec, 6500c0d06caSMauro Carvalho Chehab /* 7x 7.25x 7.5x 7.75x */ 6510c0d06caSMauro Carvalho Chehab 0x00f0, 0x00f4, 0x00f8, 0x00fc, 6520c0d06caSMauro Carvalho Chehab /* 8x */ 6530c0d06caSMauro Carvalho Chehab 0x01c0 6540c0d06caSMauro Carvalho Chehab }; 6550c0d06caSMauro Carvalho Chehab 6560c0d06caSMauro Carvalho Chehab /* mt9m001 sensor uses a different gain formula then other micron sensors */ 6570c0d06caSMauro Carvalho Chehab /* Gain = (bit[6] + 1) * (bit[5-0] * 0.125) */ 6580c0d06caSMauro Carvalho Chehab static const u16 micron2_gain[] = { 6590c0d06caSMauro Carvalho Chehab /* 1x 1.25x 1.5x 1.75x */ 6600c0d06caSMauro Carvalho Chehab 0x0008, 0x000a, 0x000c, 0x000e, 6610c0d06caSMauro Carvalho Chehab /* 2x 2.25x 2.5x 2.75x */ 6620c0d06caSMauro Carvalho Chehab 0x0010, 0x0012, 0x0014, 0x0016, 6630c0d06caSMauro Carvalho Chehab /* 3x 3.25x 3.5x 3.75x */ 6640c0d06caSMauro Carvalho Chehab 0x0018, 0x001a, 0x001c, 0x001e, 6650c0d06caSMauro Carvalho Chehab /* 4x 4.25x 4.5x 4.75x */ 6660c0d06caSMauro Carvalho Chehab 0x0020, 0x0051, 0x0052, 0x0053, 6670c0d06caSMauro Carvalho Chehab /* 5x 5.25x 5.5x 5.75x */ 6680c0d06caSMauro Carvalho Chehab 0x0054, 0x0055, 0x0056, 0x0057, 6690c0d06caSMauro Carvalho Chehab /* 6x 6.25x 6.5x 6.75x */ 6700c0d06caSMauro Carvalho Chehab 0x0058, 0x0059, 0x005a, 0x005b, 6710c0d06caSMauro Carvalho Chehab /* 7x 7.25x 7.5x 7.75x */ 6720c0d06caSMauro Carvalho Chehab 0x005c, 0x005d, 0x005e, 0x005f, 6730c0d06caSMauro Carvalho Chehab /* 8x */ 6740c0d06caSMauro Carvalho Chehab 0x0060 6750c0d06caSMauro Carvalho Chehab }; 6760c0d06caSMauro Carvalho Chehab 6770c0d06caSMauro Carvalho Chehab /* Gain = .5 + bit[7:0] / 16 */ 6780c0d06caSMauro Carvalho Chehab static const u8 hv7131r_gain[] = { 6790c0d06caSMauro Carvalho Chehab 0x08 /* 1x */, 0x0c /* 1.25x */, 0x10 /* 1.5x */, 0x14 /* 1.75x */, 6800c0d06caSMauro Carvalho Chehab 0x18 /* 2x */, 0x1c /* 2.25x */, 0x20 /* 2.5x */, 0x24 /* 2.75x */, 6810c0d06caSMauro Carvalho Chehab 0x28 /* 3x */, 0x2c /* 3.25x */, 0x30 /* 3.5x */, 0x34 /* 3.75x */, 6820c0d06caSMauro Carvalho Chehab 0x38 /* 4x */, 0x3c /* 4.25x */, 0x40 /* 4.5x */, 0x44 /* 4.75x */, 6830c0d06caSMauro Carvalho Chehab 0x48 /* 5x */, 0x4c /* 5.25x */, 0x50 /* 5.5x */, 0x54 /* 5.75x */, 6840c0d06caSMauro Carvalho Chehab 0x58 /* 6x */, 0x5c /* 6.25x */, 0x60 /* 6.5x */, 0x64 /* 6.75x */, 6850c0d06caSMauro Carvalho Chehab 0x68 /* 7x */, 0x6c /* 7.25x */, 0x70 /* 7.5x */, 0x74 /* 7.75x */, 6860c0d06caSMauro Carvalho Chehab 0x78 /* 8x */ 6870c0d06caSMauro Carvalho Chehab }; 6880c0d06caSMauro Carvalho Chehab 6890c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u8 soi968_init[] = { 6900c0d06caSMauro Carvalho Chehab {0x0c, 0x00}, {0x0f, 0x1f}, 6910c0d06caSMauro Carvalho Chehab {0x11, 0x80}, {0x38, 0x52}, {0x1e, 0x00}, 6920c0d06caSMauro Carvalho Chehab {0x33, 0x08}, {0x35, 0x8c}, {0x36, 0x0c}, 6930c0d06caSMauro Carvalho Chehab {0x37, 0x04}, {0x45, 0x04}, {0x47, 0xff}, 6940c0d06caSMauro Carvalho Chehab {0x3e, 0x00}, {0x3f, 0x00}, {0x3b, 0x20}, 6950c0d06caSMauro Carvalho Chehab {0x3a, 0x96}, {0x3d, 0x0a}, {0x14, 0x8e}, 6960c0d06caSMauro Carvalho Chehab {0x13, 0x8b}, {0x12, 0x40}, {0x17, 0x13}, 6970c0d06caSMauro Carvalho Chehab {0x18, 0x63}, {0x19, 0x01}, {0x1a, 0x79}, 6980c0d06caSMauro Carvalho Chehab {0x32, 0x24}, {0x03, 0x00}, {0x11, 0x40}, 6990c0d06caSMauro Carvalho Chehab {0x2a, 0x10}, {0x2b, 0xe0}, {0x10, 0x32}, 7000c0d06caSMauro Carvalho Chehab {0x00, 0x00}, {0x01, 0x80}, {0x02, 0x80}, 7010c0d06caSMauro Carvalho Chehab }; 7020c0d06caSMauro Carvalho Chehab 7030c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u8 ov7660_init[] = { 7040c0d06caSMauro Carvalho Chehab {0x0e, 0x80}, {0x0d, 0x08}, {0x0f, 0xc3}, 7050c0d06caSMauro Carvalho Chehab {0x04, 0xc3}, {0x10, 0x40}, {0x11, 0x40}, 7060c0d06caSMauro Carvalho Chehab {0x12, 0x05}, {0x13, 0xba}, {0x14, 0x2a}, 7070c0d06caSMauro Carvalho Chehab /* HDG Set hstart and hstop, datasheet default 0x11, 0x61, using 7080c0d06caSMauro Carvalho Chehab 0x10, 0x61 and sd->hstart, vstart = 3, fixes ugly colored borders */ 7090c0d06caSMauro Carvalho Chehab {0x17, 0x10}, {0x18, 0x61}, 7100c0d06caSMauro Carvalho Chehab {0x37, 0x0f}, {0x38, 0x02}, {0x39, 0x43}, 7110c0d06caSMauro Carvalho Chehab {0x3a, 0x00}, {0x69, 0x90}, {0x2d, 0x00}, 7120c0d06caSMauro Carvalho Chehab {0x2e, 0x00}, {0x01, 0x78}, {0x02, 0x50}, 7130c0d06caSMauro Carvalho Chehab }; 7140c0d06caSMauro Carvalho Chehab 7150c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u8 ov7670_init[] = { 7160c0d06caSMauro Carvalho Chehab {0x11, 0x80}, {0x3a, 0x04}, {0x12, 0x01}, 7170c0d06caSMauro Carvalho Chehab {0x32, 0xb6}, {0x03, 0x0a}, {0x0c, 0x00}, {0x3e, 0x00}, 7180c0d06caSMauro Carvalho Chehab {0x70, 0x3a}, {0x71, 0x35}, {0x72, 0x11}, {0x73, 0xf0}, 7190c0d06caSMauro Carvalho Chehab {0xa2, 0x02}, {0x13, 0xe0}, {0x00, 0x00}, {0x10, 0x00}, 7200c0d06caSMauro Carvalho Chehab {0x0d, 0x40}, {0x14, 0x28}, {0xa5, 0x05}, {0xab, 0x07}, 7210c0d06caSMauro Carvalho Chehab {0x24, 0x95}, {0x25, 0x33}, {0x26, 0xe3}, {0x9f, 0x75}, 7220c0d06caSMauro Carvalho Chehab {0xa0, 0x65}, {0xa1, 0x0b}, {0xa6, 0xd8}, {0xa7, 0xd8}, 7230c0d06caSMauro Carvalho Chehab {0xa8, 0xf0}, {0xa9, 0x90}, {0xaa, 0x94}, {0x13, 0xe5}, 7240c0d06caSMauro Carvalho Chehab {0x0e, 0x61}, {0x0f, 0x4b}, {0x16, 0x02}, {0x1e, 0x27}, 7250c0d06caSMauro Carvalho Chehab {0x21, 0x02}, {0x22, 0x91}, {0x29, 0x07}, {0x33, 0x0b}, 7260c0d06caSMauro Carvalho Chehab {0x35, 0x0b}, {0x37, 0x1d}, {0x38, 0x71}, {0x39, 0x2a}, 7270c0d06caSMauro Carvalho Chehab {0x3c, 0x78}, {0x4d, 0x40}, {0x4e, 0x20}, {0x69, 0x00}, 7280c0d06caSMauro Carvalho Chehab {0x74, 0x19}, {0x8d, 0x4f}, {0x8e, 0x00}, {0x8f, 0x00}, 7290c0d06caSMauro Carvalho Chehab {0x90, 0x00}, {0x91, 0x00}, {0x96, 0x00}, {0x9a, 0x80}, 7300c0d06caSMauro Carvalho Chehab {0xb0, 0x84}, {0xb1, 0x0c}, {0xb2, 0x0e}, {0xb3, 0x82}, 7310c0d06caSMauro Carvalho Chehab {0xb8, 0x0a}, {0x43, 0x0a}, {0x44, 0xf0}, {0x45, 0x20}, 7320c0d06caSMauro Carvalho Chehab {0x46, 0x7d}, {0x47, 0x29}, {0x48, 0x4a}, {0x59, 0x8c}, 7330c0d06caSMauro Carvalho Chehab {0x5a, 0xa5}, {0x5b, 0xde}, {0x5c, 0x96}, {0x5d, 0x66}, 7340c0d06caSMauro Carvalho Chehab {0x5e, 0x10}, {0x6c, 0x0a}, {0x6d, 0x55}, {0x6e, 0x11}, 7350c0d06caSMauro Carvalho Chehab {0x6f, 0x9e}, {0x6a, 0x40}, {0x01, 0x40}, {0x02, 0x40}, 7360c0d06caSMauro Carvalho Chehab {0x13, 0xe7}, {0x4f, 0x6e}, {0x50, 0x70}, {0x51, 0x02}, 7370c0d06caSMauro Carvalho Chehab {0x52, 0x1d}, {0x53, 0x56}, {0x54, 0x73}, {0x55, 0x0a}, 7380c0d06caSMauro Carvalho Chehab {0x56, 0x55}, {0x57, 0x80}, {0x58, 0x9e}, {0x41, 0x08}, 7390c0d06caSMauro Carvalho Chehab {0x3f, 0x02}, {0x75, 0x03}, {0x76, 0x63}, {0x4c, 0x04}, 7400c0d06caSMauro Carvalho Chehab {0x77, 0x06}, {0x3d, 0x02}, {0x4b, 0x09}, {0xc9, 0x30}, 7410c0d06caSMauro Carvalho Chehab {0x41, 0x08}, {0x56, 0x48}, {0x34, 0x11}, {0xa4, 0x88}, 7420c0d06caSMauro Carvalho Chehab {0x96, 0x00}, {0x97, 0x30}, {0x98, 0x20}, {0x99, 0x30}, 7430c0d06caSMauro Carvalho Chehab {0x9a, 0x84}, {0x9b, 0x29}, {0x9c, 0x03}, {0x9d, 0x99}, 7440c0d06caSMauro Carvalho Chehab {0x9e, 0x7f}, {0x78, 0x04}, {0x79, 0x01}, {0xc8, 0xf0}, 7450c0d06caSMauro Carvalho Chehab {0x79, 0x0f}, {0xc8, 0x00}, {0x79, 0x10}, {0xc8, 0x7e}, 7460c0d06caSMauro Carvalho Chehab {0x79, 0x0a}, {0xc8, 0x80}, {0x79, 0x0b}, {0xc8, 0x01}, 7470c0d06caSMauro Carvalho Chehab {0x79, 0x0c}, {0xc8, 0x0f}, {0x79, 0x0d}, {0xc8, 0x20}, 7480c0d06caSMauro Carvalho Chehab {0x79, 0x09}, {0xc8, 0x80}, {0x79, 0x02}, {0xc8, 0xc0}, 7490c0d06caSMauro Carvalho Chehab {0x79, 0x03}, {0xc8, 0x40}, {0x79, 0x05}, {0xc8, 0x30}, 7500c0d06caSMauro Carvalho Chehab {0x79, 0x26}, {0x62, 0x20}, {0x63, 0x00}, {0x64, 0x06}, 7510c0d06caSMauro Carvalho Chehab {0x65, 0x00}, {0x66, 0x05}, {0x94, 0x05}, {0x95, 0x0a}, 7520c0d06caSMauro Carvalho Chehab {0x17, 0x13}, {0x18, 0x01}, {0x19, 0x02}, {0x1a, 0x7a}, 7530c0d06caSMauro Carvalho Chehab {0x46, 0x59}, {0x47, 0x30}, {0x58, 0x9a}, {0x59, 0x84}, 7540c0d06caSMauro Carvalho Chehab {0x5a, 0x91}, {0x5b, 0x57}, {0x5c, 0x75}, {0x5d, 0x6d}, 7550c0d06caSMauro Carvalho Chehab {0x5e, 0x13}, {0x64, 0x07}, {0x94, 0x07}, {0x95, 0x0d}, 7560c0d06caSMauro Carvalho Chehab {0xa6, 0xdf}, {0xa7, 0xdf}, {0x48, 0x4d}, {0x51, 0x00}, 7570c0d06caSMauro Carvalho Chehab {0x6b, 0x0a}, {0x11, 0x80}, {0x2a, 0x00}, {0x2b, 0x00}, 7580c0d06caSMauro Carvalho Chehab {0x92, 0x00}, {0x93, 0x00}, {0x55, 0x0a}, {0x56, 0x60}, 7590c0d06caSMauro Carvalho Chehab {0x4f, 0x6e}, {0x50, 0x70}, {0x51, 0x00}, {0x52, 0x1d}, 7600c0d06caSMauro Carvalho Chehab {0x53, 0x56}, {0x54, 0x73}, {0x58, 0x9a}, {0x4f, 0x6e}, 7610c0d06caSMauro Carvalho Chehab {0x50, 0x70}, {0x51, 0x00}, {0x52, 0x1d}, {0x53, 0x56}, 7620c0d06caSMauro Carvalho Chehab {0x54, 0x73}, {0x58, 0x9a}, {0x3f, 0x01}, {0x7b, 0x03}, 7630c0d06caSMauro Carvalho Chehab {0x7c, 0x09}, {0x7d, 0x16}, {0x7e, 0x38}, {0x7f, 0x47}, 7640c0d06caSMauro Carvalho Chehab {0x80, 0x53}, {0x81, 0x5e}, {0x82, 0x6a}, {0x83, 0x74}, 7650c0d06caSMauro Carvalho Chehab {0x84, 0x80}, {0x85, 0x8c}, {0x86, 0x9b}, {0x87, 0xb2}, 7660c0d06caSMauro Carvalho Chehab {0x88, 0xcc}, {0x89, 0xe5}, {0x7a, 0x24}, {0x3b, 0x00}, 7670c0d06caSMauro Carvalho Chehab {0x9f, 0x76}, {0xa0, 0x65}, {0x13, 0xe2}, {0x6b, 0x0a}, 7680c0d06caSMauro Carvalho Chehab {0x11, 0x80}, {0x2a, 0x00}, {0x2b, 0x00}, {0x92, 0x00}, 7690c0d06caSMauro Carvalho Chehab {0x93, 0x00}, 7700c0d06caSMauro Carvalho Chehab }; 7710c0d06caSMauro Carvalho Chehab 7720c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u8 ov9650_init[] = { 7730c0d06caSMauro Carvalho Chehab {0x00, 0x00}, {0x01, 0x78}, 7740c0d06caSMauro Carvalho Chehab {0x02, 0x78}, {0x03, 0x36}, {0x04, 0x03}, 7750c0d06caSMauro Carvalho Chehab {0x05, 0x00}, {0x06, 0x00}, {0x08, 0x00}, 7760c0d06caSMauro Carvalho Chehab {0x09, 0x01}, {0x0c, 0x00}, {0x0d, 0x00}, 7770c0d06caSMauro Carvalho Chehab {0x0e, 0xa0}, {0x0f, 0x52}, {0x10, 0x7c}, 7780c0d06caSMauro Carvalho Chehab {0x11, 0x80}, {0x12, 0x45}, {0x13, 0xc2}, 7790c0d06caSMauro Carvalho Chehab {0x14, 0x2e}, {0x15, 0x00}, {0x16, 0x07}, 7800c0d06caSMauro Carvalho Chehab {0x17, 0x24}, {0x18, 0xc5}, {0x19, 0x00}, 7810c0d06caSMauro Carvalho Chehab {0x1a, 0x3c}, {0x1b, 0x00}, {0x1e, 0x04}, 7820c0d06caSMauro Carvalho Chehab {0x1f, 0x00}, {0x24, 0x78}, {0x25, 0x68}, 7830c0d06caSMauro Carvalho Chehab {0x26, 0xd4}, {0x27, 0x80}, {0x28, 0x80}, 7840c0d06caSMauro Carvalho Chehab {0x29, 0x30}, {0x2a, 0x00}, {0x2b, 0x00}, 7850c0d06caSMauro Carvalho Chehab {0x2c, 0x80}, {0x2d, 0x00}, {0x2e, 0x00}, 7860c0d06caSMauro Carvalho Chehab {0x2f, 0x00}, {0x30, 0x08}, {0x31, 0x30}, 7870c0d06caSMauro Carvalho Chehab {0x32, 0x84}, {0x33, 0xe2}, {0x34, 0xbf}, 7880c0d06caSMauro Carvalho Chehab {0x35, 0x81}, {0x36, 0xf9}, {0x37, 0x00}, 7890c0d06caSMauro Carvalho Chehab {0x38, 0x93}, {0x39, 0x50}, {0x3a, 0x01}, 7900c0d06caSMauro Carvalho Chehab {0x3b, 0x01}, {0x3c, 0x73}, {0x3d, 0x19}, 7910c0d06caSMauro Carvalho Chehab {0x3e, 0x0b}, {0x3f, 0x80}, {0x40, 0xc1}, 7920c0d06caSMauro Carvalho Chehab {0x41, 0x00}, {0x42, 0x08}, {0x67, 0x80}, 7930c0d06caSMauro Carvalho Chehab {0x68, 0x80}, {0x69, 0x40}, {0x6a, 0x00}, 7940c0d06caSMauro Carvalho Chehab {0x6b, 0x0a}, {0x8b, 0x06}, {0x8c, 0x20}, 7950c0d06caSMauro Carvalho Chehab {0x8d, 0x00}, {0x8e, 0x00}, {0x8f, 0xdf}, 7960c0d06caSMauro Carvalho Chehab {0x92, 0x00}, {0x93, 0x00}, {0x94, 0x88}, 7970c0d06caSMauro Carvalho Chehab {0x95, 0x88}, {0x96, 0x04}, {0xa1, 0x00}, 7980c0d06caSMauro Carvalho Chehab {0xa5, 0x80}, {0xa8, 0x80}, {0xa9, 0xb8}, 7990c0d06caSMauro Carvalho Chehab {0xaa, 0x92}, {0xab, 0x0a}, 8000c0d06caSMauro Carvalho Chehab }; 8010c0d06caSMauro Carvalho Chehab 8020c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u8 ov9655_init[] = { 8030c0d06caSMauro Carvalho Chehab {0x0e, 0x61}, {0x11, 0x80}, {0x13, 0xba}, 8040c0d06caSMauro Carvalho Chehab {0x14, 0x2e}, {0x16, 0x24}, {0x1e, 0x04}, {0x27, 0x08}, 8050c0d06caSMauro Carvalho Chehab {0x28, 0x08}, {0x29, 0x15}, {0x2c, 0x08}, {0x34, 0x3d}, 8060c0d06caSMauro Carvalho Chehab {0x35, 0x00}, {0x38, 0x12}, {0x0f, 0x42}, {0x39, 0x57}, 8070c0d06caSMauro Carvalho Chehab {0x3a, 0x00}, {0x3b, 0xcc}, {0x3c, 0x0c}, {0x3d, 0x19}, 8080c0d06caSMauro Carvalho Chehab {0x3e, 0x0c}, {0x3f, 0x01}, {0x41, 0x40}, {0x42, 0x80}, 8090c0d06caSMauro Carvalho Chehab {0x45, 0x46}, {0x46, 0x62}, {0x47, 0x2a}, {0x48, 0x3c}, 8100c0d06caSMauro Carvalho Chehab {0x4a, 0xf0}, {0x4b, 0xdc}, {0x4c, 0xdc}, {0x4d, 0xdc}, 8110c0d06caSMauro Carvalho Chehab {0x4e, 0xdc}, {0x6c, 0x04}, {0x6f, 0x9e}, {0x70, 0x05}, 8120c0d06caSMauro Carvalho Chehab {0x71, 0x78}, {0x77, 0x02}, {0x8a, 0x23}, {0x90, 0x7e}, 8130c0d06caSMauro Carvalho Chehab {0x91, 0x7c}, {0x9f, 0x6e}, {0xa0, 0x6e}, {0xa5, 0x68}, 8140c0d06caSMauro Carvalho Chehab {0xa6, 0x60}, {0xa8, 0xc1}, {0xa9, 0xfa}, {0xaa, 0x92}, 8150c0d06caSMauro Carvalho Chehab {0xab, 0x04}, {0xac, 0x80}, {0xad, 0x80}, {0xae, 0x80}, 8160c0d06caSMauro Carvalho Chehab {0xaf, 0x80}, {0xb2, 0xf2}, {0xb3, 0x20}, {0xb5, 0x00}, 8170c0d06caSMauro Carvalho Chehab {0xb6, 0xaf}, {0xbb, 0xae}, {0xbc, 0x44}, {0xbd, 0x44}, 8180c0d06caSMauro Carvalho Chehab {0xbe, 0x3b}, {0xbf, 0x3a}, {0xc1, 0xc8}, {0xc2, 0x01}, 8190c0d06caSMauro Carvalho Chehab {0xc4, 0x00}, {0xc6, 0x85}, {0xc7, 0x81}, {0xc9, 0xe0}, 8200c0d06caSMauro Carvalho Chehab {0xca, 0xe8}, {0xcc, 0xd8}, {0xcd, 0x93}, {0x2d, 0x00}, 8210c0d06caSMauro Carvalho Chehab {0x2e, 0x00}, {0x01, 0x80}, {0x02, 0x80}, {0x12, 0x61}, 8220c0d06caSMauro Carvalho Chehab {0x36, 0xfa}, {0x8c, 0x8d}, {0xc0, 0xaa}, {0x69, 0x0a}, 8230c0d06caSMauro Carvalho Chehab {0x03, 0x09}, {0x17, 0x16}, {0x18, 0x6e}, {0x19, 0x01}, 8240c0d06caSMauro Carvalho Chehab {0x1a, 0x3e}, {0x32, 0x09}, {0x2a, 0x10}, {0x2b, 0x0a}, 8250c0d06caSMauro Carvalho Chehab {0x92, 0x00}, {0x93, 0x00}, {0xa1, 0x00}, {0x10, 0x7c}, 8260c0d06caSMauro Carvalho Chehab {0x04, 0x03}, {0x00, 0x13}, 8270c0d06caSMauro Carvalho Chehab }; 8280c0d06caSMauro Carvalho Chehab 8290c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u16 mt9v112_init[] = { 8300c0d06caSMauro Carvalho Chehab {0xf0, 0x0000}, {0x0d, 0x0021}, {0x0d, 0x0020}, 8310c0d06caSMauro Carvalho Chehab {0x34, 0xc019}, {0x0a, 0x0011}, {0x0b, 0x000b}, 8320c0d06caSMauro Carvalho Chehab {0x20, 0x0703}, {0x35, 0x2022}, {0xf0, 0x0001}, 8330c0d06caSMauro Carvalho Chehab {0x05, 0x0000}, {0x06, 0x340c}, {0x3b, 0x042a}, 8340c0d06caSMauro Carvalho Chehab {0x3c, 0x0400}, {0xf0, 0x0002}, {0x2e, 0x0c58}, 8350c0d06caSMauro Carvalho Chehab {0x5b, 0x0001}, {0xc8, 0x9f0b}, {0xf0, 0x0001}, 8360c0d06caSMauro Carvalho Chehab {0x9b, 0x5300}, {0xf0, 0x0000}, {0x2b, 0x0020}, 8370c0d06caSMauro Carvalho Chehab {0x2c, 0x002a}, {0x2d, 0x0032}, {0x2e, 0x0020}, 8380c0d06caSMauro Carvalho Chehab {0x09, 0x01dc}, {0x01, 0x000c}, {0x02, 0x0020}, 8390c0d06caSMauro Carvalho Chehab {0x03, 0x01e0}, {0x04, 0x0280}, {0x06, 0x000c}, 8400c0d06caSMauro Carvalho Chehab {0x05, 0x0098}, {0x20, 0x0703}, {0x09, 0x01f2}, 8410c0d06caSMauro Carvalho Chehab {0x2b, 0x00a0}, {0x2c, 0x00a0}, {0x2d, 0x00a0}, 8420c0d06caSMauro Carvalho Chehab {0x2e, 0x00a0}, {0x01, 0x000c}, {0x02, 0x0020}, 8430c0d06caSMauro Carvalho Chehab {0x03, 0x01e0}, {0x04, 0x0280}, {0x06, 0x000c}, 8440c0d06caSMauro Carvalho Chehab {0x05, 0x0098}, {0x09, 0x01c1}, {0x2b, 0x00ae}, 8450c0d06caSMauro Carvalho Chehab {0x2c, 0x00ae}, {0x2d, 0x00ae}, {0x2e, 0x00ae}, 8460c0d06caSMauro Carvalho Chehab }; 8470c0d06caSMauro Carvalho Chehab 8480c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u16 mt9v111_init[] = { 8490c0d06caSMauro Carvalho Chehab {0x01, 0x0004}, {0x0d, 0x0001}, {0x0d, 0x0000}, 8500c0d06caSMauro Carvalho Chehab {0x01, 0x0001}, {0x05, 0x0004}, {0x2d, 0xe0a0}, 8510c0d06caSMauro Carvalho Chehab {0x2e, 0x0c64}, {0x2f, 0x0064}, {0x06, 0x600e}, 8520c0d06caSMauro Carvalho Chehab {0x08, 0x0480}, {0x01, 0x0004}, {0x02, 0x0016}, 8530c0d06caSMauro Carvalho Chehab {0x03, 0x01e7}, {0x04, 0x0287}, {0x05, 0x0004}, 8540c0d06caSMauro Carvalho Chehab {0x06, 0x002d}, {0x07, 0x3002}, {0x08, 0x0008}, 8550c0d06caSMauro Carvalho Chehab {0x0e, 0x0008}, {0x20, 0x0000} 8560c0d06caSMauro Carvalho Chehab }; 8570c0d06caSMauro Carvalho Chehab 8580c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u16 mt9v011_init[] = { 8590c0d06caSMauro Carvalho Chehab {0x07, 0x0002}, {0x0d, 0x0001}, {0x0d, 0x0000}, 8600c0d06caSMauro Carvalho Chehab {0x01, 0x0008}, {0x02, 0x0016}, {0x03, 0x01e1}, 8610c0d06caSMauro Carvalho Chehab {0x04, 0x0281}, {0x05, 0x0083}, {0x06, 0x0006}, 8620c0d06caSMauro Carvalho Chehab {0x0d, 0x0002}, {0x0a, 0x0000}, {0x0b, 0x0000}, 8630c0d06caSMauro Carvalho Chehab {0x0c, 0x0000}, {0x0d, 0x0000}, {0x0e, 0x0000}, 8640c0d06caSMauro Carvalho Chehab {0x0f, 0x0000}, {0x10, 0x0000}, {0x11, 0x0000}, 8650c0d06caSMauro Carvalho Chehab {0x12, 0x0000}, {0x13, 0x0000}, {0x14, 0x0000}, 8660c0d06caSMauro Carvalho Chehab {0x15, 0x0000}, {0x16, 0x0000}, {0x17, 0x0000}, 8670c0d06caSMauro Carvalho Chehab {0x18, 0x0000}, {0x19, 0x0000}, {0x1a, 0x0000}, 8680c0d06caSMauro Carvalho Chehab {0x1b, 0x0000}, {0x1c, 0x0000}, {0x1d, 0x0000}, 8690c0d06caSMauro Carvalho Chehab {0x32, 0x0000}, {0x20, 0x1101}, {0x21, 0x0000}, 8700c0d06caSMauro Carvalho Chehab {0x22, 0x0000}, {0x23, 0x0000}, {0x24, 0x0000}, 8710c0d06caSMauro Carvalho Chehab {0x25, 0x0000}, {0x26, 0x0000}, {0x27, 0x0024}, 8720c0d06caSMauro Carvalho Chehab {0x2f, 0xf7b0}, {0x30, 0x0005}, {0x31, 0x0000}, 8730c0d06caSMauro Carvalho Chehab {0x32, 0x0000}, {0x33, 0x0000}, {0x34, 0x0100}, 8740c0d06caSMauro Carvalho Chehab {0x3d, 0x068f}, {0x40, 0x01e0}, {0x41, 0x00d1}, 8750c0d06caSMauro Carvalho Chehab {0x44, 0x0082}, {0x5a, 0x0000}, {0x5b, 0x0000}, 8760c0d06caSMauro Carvalho Chehab {0x5c, 0x0000}, {0x5d, 0x0000}, {0x5e, 0x0000}, 8770c0d06caSMauro Carvalho Chehab {0x5f, 0xa31d}, {0x62, 0x0611}, {0x0a, 0x0000}, 8780c0d06caSMauro Carvalho Chehab {0x06, 0x0029}, {0x05, 0x0009}, {0x20, 0x1101}, 8790c0d06caSMauro Carvalho Chehab {0x20, 0x1101}, {0x09, 0x0064}, {0x07, 0x0003}, 8800c0d06caSMauro Carvalho Chehab {0x2b, 0x0033}, {0x2c, 0x00a0}, {0x2d, 0x00a0}, 8810c0d06caSMauro Carvalho Chehab {0x2e, 0x0033}, {0x07, 0x0002}, {0x06, 0x0000}, 8820c0d06caSMauro Carvalho Chehab {0x06, 0x0029}, {0x05, 0x0009}, 8830c0d06caSMauro Carvalho Chehab }; 8840c0d06caSMauro Carvalho Chehab 8850c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u16 mt9m001_init[] = { 8860c0d06caSMauro Carvalho Chehab {0x0d, 0x0001}, 8870c0d06caSMauro Carvalho Chehab {0x0d, 0x0000}, 8880c0d06caSMauro Carvalho Chehab {0x04, 0x0500}, /* hres = 1280 */ 8890c0d06caSMauro Carvalho Chehab {0x03, 0x0400}, /* vres = 1024 */ 8900c0d06caSMauro Carvalho Chehab {0x20, 0x1100}, 8910c0d06caSMauro Carvalho Chehab {0x06, 0x0010}, 8920c0d06caSMauro Carvalho Chehab {0x2b, 0x0024}, 8930c0d06caSMauro Carvalho Chehab {0x2e, 0x0024}, 8940c0d06caSMauro Carvalho Chehab {0x35, 0x0024}, 8950c0d06caSMauro Carvalho Chehab {0x2d, 0x0020}, 8960c0d06caSMauro Carvalho Chehab {0x2c, 0x0020}, 8970c0d06caSMauro Carvalho Chehab {0x09, 0x0ad4}, 8980c0d06caSMauro Carvalho Chehab {0x35, 0x0057}, 8990c0d06caSMauro Carvalho Chehab }; 9000c0d06caSMauro Carvalho Chehab 9010c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u16 mt9m111_init[] = { 9020c0d06caSMauro Carvalho Chehab {0xf0, 0x0000}, {0x0d, 0x0021}, {0x0d, 0x0008}, 9030c0d06caSMauro Carvalho Chehab {0xf0, 0x0001}, {0x3a, 0x4300}, {0x9b, 0x4300}, 9040c0d06caSMauro Carvalho Chehab {0x06, 0x708e}, {0xf0, 0x0002}, {0x2e, 0x0a1e}, 9050c0d06caSMauro Carvalho Chehab {0xf0, 0x0000}, 9060c0d06caSMauro Carvalho Chehab }; 9070c0d06caSMauro Carvalho Chehab 9080c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u16 mt9m112_init[] = { 9090c0d06caSMauro Carvalho Chehab {0xf0, 0x0000}, {0x0d, 0x0021}, {0x0d, 0x0008}, 9100c0d06caSMauro Carvalho Chehab {0xf0, 0x0001}, {0x3a, 0x4300}, {0x9b, 0x4300}, 9110c0d06caSMauro Carvalho Chehab {0x06, 0x708e}, {0xf0, 0x0002}, {0x2e, 0x0a1e}, 9120c0d06caSMauro Carvalho Chehab {0xf0, 0x0000}, 9130c0d06caSMauro Carvalho Chehab }; 9140c0d06caSMauro Carvalho Chehab 9150c0d06caSMauro Carvalho Chehab static const struct i2c_reg_u8 hv7131r_init[] = { 9160c0d06caSMauro Carvalho Chehab {0x02, 0x08}, {0x02, 0x00}, {0x01, 0x08}, 9170c0d06caSMauro Carvalho Chehab {0x02, 0x00}, {0x20, 0x00}, {0x21, 0xd0}, 9180c0d06caSMauro Carvalho Chehab {0x22, 0x00}, {0x23, 0x09}, {0x01, 0x08}, 9190c0d06caSMauro Carvalho Chehab {0x01, 0x08}, {0x01, 0x08}, {0x25, 0x07}, 9200c0d06caSMauro Carvalho Chehab {0x26, 0xc3}, {0x27, 0x50}, {0x30, 0x62}, 9210c0d06caSMauro Carvalho Chehab {0x31, 0x10}, {0x32, 0x06}, {0x33, 0x10}, 9220c0d06caSMauro Carvalho Chehab {0x20, 0x00}, {0x21, 0xd0}, {0x22, 0x00}, 9230c0d06caSMauro Carvalho Chehab {0x23, 0x09}, {0x01, 0x08}, 9240c0d06caSMauro Carvalho Chehab }; 9250c0d06caSMauro Carvalho Chehab 9260c0d06caSMauro Carvalho Chehab static void reg_r(struct gspca_dev *gspca_dev, u16 reg, u16 length) 9270c0d06caSMauro Carvalho Chehab { 9280c0d06caSMauro Carvalho Chehab struct usb_device *dev = gspca_dev->dev; 9290c0d06caSMauro Carvalho Chehab int result; 9300c0d06caSMauro Carvalho Chehab 9310c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 9320c0d06caSMauro Carvalho Chehab return; 9330c0d06caSMauro Carvalho Chehab result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 9340c0d06caSMauro Carvalho Chehab 0x00, 9350c0d06caSMauro Carvalho Chehab USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 9360c0d06caSMauro Carvalho Chehab reg, 9370c0d06caSMauro Carvalho Chehab 0x00, 9380c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf, 9390c0d06caSMauro Carvalho Chehab length, 9400c0d06caSMauro Carvalho Chehab 500); 9410c0d06caSMauro Carvalho Chehab if (unlikely(result < 0 || result != length)) { 9420c0d06caSMauro Carvalho Chehab pr_err("Read register %02x failed %d\n", reg, result); 9430c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = result; 9440c0d06caSMauro Carvalho Chehab } 9450c0d06caSMauro Carvalho Chehab } 9460c0d06caSMauro Carvalho Chehab 9470c0d06caSMauro Carvalho Chehab static void reg_w(struct gspca_dev *gspca_dev, u16 reg, 9480c0d06caSMauro Carvalho Chehab const u8 *buffer, int length) 9490c0d06caSMauro Carvalho Chehab { 9500c0d06caSMauro Carvalho Chehab struct usb_device *dev = gspca_dev->dev; 9510c0d06caSMauro Carvalho Chehab int result; 9520c0d06caSMauro Carvalho Chehab 9530c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 9540c0d06caSMauro Carvalho Chehab return; 9550c0d06caSMauro Carvalho Chehab memcpy(gspca_dev->usb_buf, buffer, length); 9560c0d06caSMauro Carvalho Chehab result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 9570c0d06caSMauro Carvalho Chehab 0x08, 9580c0d06caSMauro Carvalho Chehab USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 9590c0d06caSMauro Carvalho Chehab reg, 9600c0d06caSMauro Carvalho Chehab 0x00, 9610c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf, 9620c0d06caSMauro Carvalho Chehab length, 9630c0d06caSMauro Carvalho Chehab 500); 9640c0d06caSMauro Carvalho Chehab if (unlikely(result < 0 || result != length)) { 9650c0d06caSMauro Carvalho Chehab pr_err("Write register %02x failed %d\n", reg, result); 9660c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = result; 9670c0d06caSMauro Carvalho Chehab } 9680c0d06caSMauro Carvalho Chehab } 9690c0d06caSMauro Carvalho Chehab 9700c0d06caSMauro Carvalho Chehab static void reg_w1(struct gspca_dev *gspca_dev, u16 reg, const u8 value) 9710c0d06caSMauro Carvalho Chehab { 9720c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, reg, &value, 1); 9730c0d06caSMauro Carvalho Chehab } 9740c0d06caSMauro Carvalho Chehab 9750c0d06caSMauro Carvalho Chehab static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer) 9760c0d06caSMauro Carvalho Chehab { 9770c0d06caSMauro Carvalho Chehab int i; 9780c0d06caSMauro Carvalho Chehab 9790c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x10c0, buffer, 8); 9800c0d06caSMauro Carvalho Chehab for (i = 0; i < 5; i++) { 9810c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x10c0, 1); 9820c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 9830c0d06caSMauro Carvalho Chehab return; 9840c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_buf[0] & 0x04) { 9850c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_buf[0] & 0x08) { 9860c0d06caSMauro Carvalho Chehab pr_err("i2c_w error\n"); 9870c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = -EIO; 9880c0d06caSMauro Carvalho Chehab } 9890c0d06caSMauro Carvalho Chehab return; 9900c0d06caSMauro Carvalho Chehab } 9910c0d06caSMauro Carvalho Chehab msleep(10); 9920c0d06caSMauro Carvalho Chehab } 9930c0d06caSMauro Carvalho Chehab pr_err("i2c_w reg %02x no response\n", buffer[2]); 9940c0d06caSMauro Carvalho Chehab /* gspca_dev->usb_err = -EIO; fixme: may occur */ 9950c0d06caSMauro Carvalho Chehab } 9960c0d06caSMauro Carvalho Chehab 9970c0d06caSMauro Carvalho Chehab static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) 9980c0d06caSMauro Carvalho Chehab { 9990c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 10000c0d06caSMauro Carvalho Chehab u8 row[8]; 10010c0d06caSMauro Carvalho Chehab 10020c0d06caSMauro Carvalho Chehab /* 10030c0d06caSMauro Carvalho Chehab * from the point of view of the bridge, the length 10040c0d06caSMauro Carvalho Chehab * includes the address 10050c0d06caSMauro Carvalho Chehab */ 10060c0d06caSMauro Carvalho Chehab row[0] = sd->i2c_intf | (2 << 4); 10070c0d06caSMauro Carvalho Chehab row[1] = sd->i2c_addr; 10080c0d06caSMauro Carvalho Chehab row[2] = reg; 10090c0d06caSMauro Carvalho Chehab row[3] = val; 10100c0d06caSMauro Carvalho Chehab row[4] = 0x00; 10110c0d06caSMauro Carvalho Chehab row[5] = 0x00; 10120c0d06caSMauro Carvalho Chehab row[6] = 0x00; 10130c0d06caSMauro Carvalho Chehab row[7] = 0x10; 10140c0d06caSMauro Carvalho Chehab 10150c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, row); 10160c0d06caSMauro Carvalho Chehab } 10170c0d06caSMauro Carvalho Chehab 10180c0d06caSMauro Carvalho Chehab static void i2c_w1_buf(struct gspca_dev *gspca_dev, 10190c0d06caSMauro Carvalho Chehab const struct i2c_reg_u8 *buf, int sz) 10200c0d06caSMauro Carvalho Chehab { 10210c0d06caSMauro Carvalho Chehab while (--sz >= 0) { 10220c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, buf->reg, buf->val); 10230c0d06caSMauro Carvalho Chehab buf++; 10240c0d06caSMauro Carvalho Chehab } 10250c0d06caSMauro Carvalho Chehab } 10260c0d06caSMauro Carvalho Chehab 10270c0d06caSMauro Carvalho Chehab static void i2c_w2(struct gspca_dev *gspca_dev, u8 reg, u16 val) 10280c0d06caSMauro Carvalho Chehab { 10290c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 10300c0d06caSMauro Carvalho Chehab u8 row[8]; 10310c0d06caSMauro Carvalho Chehab 10320c0d06caSMauro Carvalho Chehab /* 10330c0d06caSMauro Carvalho Chehab * from the point of view of the bridge, the length 10340c0d06caSMauro Carvalho Chehab * includes the address 10350c0d06caSMauro Carvalho Chehab */ 10360c0d06caSMauro Carvalho Chehab row[0] = sd->i2c_intf | (3 << 4); 10370c0d06caSMauro Carvalho Chehab row[1] = sd->i2c_addr; 10380c0d06caSMauro Carvalho Chehab row[2] = reg; 10390c0d06caSMauro Carvalho Chehab row[3] = val >> 8; 10400c0d06caSMauro Carvalho Chehab row[4] = val; 10410c0d06caSMauro Carvalho Chehab row[5] = 0x00; 10420c0d06caSMauro Carvalho Chehab row[6] = 0x00; 10430c0d06caSMauro Carvalho Chehab row[7] = 0x10; 10440c0d06caSMauro Carvalho Chehab 10450c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, row); 10460c0d06caSMauro Carvalho Chehab } 10470c0d06caSMauro Carvalho Chehab 10480c0d06caSMauro Carvalho Chehab static void i2c_w2_buf(struct gspca_dev *gspca_dev, 10490c0d06caSMauro Carvalho Chehab const struct i2c_reg_u16 *buf, int sz) 10500c0d06caSMauro Carvalho Chehab { 10510c0d06caSMauro Carvalho Chehab while (--sz >= 0) { 10520c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, buf->reg, buf->val); 10530c0d06caSMauro Carvalho Chehab buf++; 10540c0d06caSMauro Carvalho Chehab } 10550c0d06caSMauro Carvalho Chehab } 10560c0d06caSMauro Carvalho Chehab 10570c0d06caSMauro Carvalho Chehab static void i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val) 10580c0d06caSMauro Carvalho Chehab { 10590c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 10600c0d06caSMauro Carvalho Chehab u8 row[8]; 10610c0d06caSMauro Carvalho Chehab 10620c0d06caSMauro Carvalho Chehab row[0] = sd->i2c_intf | (1 << 4); 10630c0d06caSMauro Carvalho Chehab row[1] = sd->i2c_addr; 10640c0d06caSMauro Carvalho Chehab row[2] = reg; 10650c0d06caSMauro Carvalho Chehab row[3] = 0; 10660c0d06caSMauro Carvalho Chehab row[4] = 0; 10670c0d06caSMauro Carvalho Chehab row[5] = 0; 10680c0d06caSMauro Carvalho Chehab row[6] = 0; 10690c0d06caSMauro Carvalho Chehab row[7] = 0x10; 10700c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, row); 10710c0d06caSMauro Carvalho Chehab row[0] = sd->i2c_intf | (1 << 4) | 0x02; 10720c0d06caSMauro Carvalho Chehab row[2] = 0; 10730c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, row); 10740c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x10c2, 5); 10750c0d06caSMauro Carvalho Chehab *val = gspca_dev->usb_buf[4]; 10760c0d06caSMauro Carvalho Chehab } 10770c0d06caSMauro Carvalho Chehab 10780c0d06caSMauro Carvalho Chehab static void i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val) 10790c0d06caSMauro Carvalho Chehab { 10800c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 10810c0d06caSMauro Carvalho Chehab u8 row[8]; 10820c0d06caSMauro Carvalho Chehab 10830c0d06caSMauro Carvalho Chehab row[0] = sd->i2c_intf | (1 << 4); 10840c0d06caSMauro Carvalho Chehab row[1] = sd->i2c_addr; 10850c0d06caSMauro Carvalho Chehab row[2] = reg; 10860c0d06caSMauro Carvalho Chehab row[3] = 0; 10870c0d06caSMauro Carvalho Chehab row[4] = 0; 10880c0d06caSMauro Carvalho Chehab row[5] = 0; 10890c0d06caSMauro Carvalho Chehab row[6] = 0; 10900c0d06caSMauro Carvalho Chehab row[7] = 0x10; 10910c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, row); 10920c0d06caSMauro Carvalho Chehab row[0] = sd->i2c_intf | (2 << 4) | 0x02; 10930c0d06caSMauro Carvalho Chehab row[2] = 0; 10940c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, row); 10950c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x10c2, 5); 10960c0d06caSMauro Carvalho Chehab *val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; 10970c0d06caSMauro Carvalho Chehab } 10980c0d06caSMauro Carvalho Chehab 10990c0d06caSMauro Carvalho Chehab static void ov9650_init_sensor(struct gspca_dev *gspca_dev) 11000c0d06caSMauro Carvalho Chehab { 11010c0d06caSMauro Carvalho Chehab u16 id; 11020c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 11030c0d06caSMauro Carvalho Chehab 11040c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, 0x1c, &id); 11050c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 11060c0d06caSMauro Carvalho Chehab return; 11070c0d06caSMauro Carvalho Chehab 11080c0d06caSMauro Carvalho Chehab if (id != 0x7fa2) { 11090c0d06caSMauro Carvalho Chehab pr_err("sensor id for ov9650 doesn't match (0x%04x)\n", id); 11100c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = -ENODEV; 11110c0d06caSMauro Carvalho Chehab return; 11120c0d06caSMauro Carvalho Chehab } 11130c0d06caSMauro Carvalho Chehab 11140c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, 0x80); /* sensor reset */ 11150c0d06caSMauro Carvalho Chehab msleep(200); 11160c0d06caSMauro Carvalho Chehab i2c_w1_buf(gspca_dev, ov9650_init, ARRAY_SIZE(ov9650_init)); 11170c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 11180c0d06caSMauro Carvalho Chehab pr_err("OV9650 sensor initialization failed\n"); 11190c0d06caSMauro Carvalho Chehab sd->hstart = 1; 11200c0d06caSMauro Carvalho Chehab sd->vstart = 7; 11210c0d06caSMauro Carvalho Chehab } 11220c0d06caSMauro Carvalho Chehab 11230c0d06caSMauro Carvalho Chehab static void ov9655_init_sensor(struct gspca_dev *gspca_dev) 11240c0d06caSMauro Carvalho Chehab { 11250c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 11260c0d06caSMauro Carvalho Chehab 11270c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, 0x80); /* sensor reset */ 11280c0d06caSMauro Carvalho Chehab msleep(200); 11290c0d06caSMauro Carvalho Chehab i2c_w1_buf(gspca_dev, ov9655_init, ARRAY_SIZE(ov9655_init)); 11300c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 11310c0d06caSMauro Carvalho Chehab pr_err("OV9655 sensor initialization failed\n"); 11320c0d06caSMauro Carvalho Chehab 11330c0d06caSMauro Carvalho Chehab sd->hstart = 1; 11340c0d06caSMauro Carvalho Chehab sd->vstart = 2; 11350c0d06caSMauro Carvalho Chehab } 11360c0d06caSMauro Carvalho Chehab 11370c0d06caSMauro Carvalho Chehab static void soi968_init_sensor(struct gspca_dev *gspca_dev) 11380c0d06caSMauro Carvalho Chehab { 11390c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 11400c0d06caSMauro Carvalho Chehab 11410c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, 0x80); /* sensor reset */ 11420c0d06caSMauro Carvalho Chehab msleep(200); 11430c0d06caSMauro Carvalho Chehab i2c_w1_buf(gspca_dev, soi968_init, ARRAY_SIZE(soi968_init)); 11440c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 11450c0d06caSMauro Carvalho Chehab pr_err("SOI968 sensor initialization failed\n"); 11460c0d06caSMauro Carvalho Chehab 11470c0d06caSMauro Carvalho Chehab sd->hstart = 60; 11480c0d06caSMauro Carvalho Chehab sd->vstart = 11; 11490c0d06caSMauro Carvalho Chehab } 11500c0d06caSMauro Carvalho Chehab 11510c0d06caSMauro Carvalho Chehab static void ov7660_init_sensor(struct gspca_dev *gspca_dev) 11520c0d06caSMauro Carvalho Chehab { 11530c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 11540c0d06caSMauro Carvalho Chehab 11550c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, 0x80); /* sensor reset */ 11560c0d06caSMauro Carvalho Chehab msleep(200); 11570c0d06caSMauro Carvalho Chehab i2c_w1_buf(gspca_dev, ov7660_init, ARRAY_SIZE(ov7660_init)); 11580c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 11590c0d06caSMauro Carvalho Chehab pr_err("OV7660 sensor initialization failed\n"); 11600c0d06caSMauro Carvalho Chehab sd->hstart = 3; 11610c0d06caSMauro Carvalho Chehab sd->vstart = 3; 11620c0d06caSMauro Carvalho Chehab } 11630c0d06caSMauro Carvalho Chehab 11640c0d06caSMauro Carvalho Chehab static void ov7670_init_sensor(struct gspca_dev *gspca_dev) 11650c0d06caSMauro Carvalho Chehab { 11660c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 11670c0d06caSMauro Carvalho Chehab 11680c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, 0x80); /* sensor reset */ 11690c0d06caSMauro Carvalho Chehab msleep(200); 11700c0d06caSMauro Carvalho Chehab i2c_w1_buf(gspca_dev, ov7670_init, ARRAY_SIZE(ov7670_init)); 11710c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 11720c0d06caSMauro Carvalho Chehab pr_err("OV7670 sensor initialization failed\n"); 11730c0d06caSMauro Carvalho Chehab 11740c0d06caSMauro Carvalho Chehab sd->hstart = 0; 11750c0d06caSMauro Carvalho Chehab sd->vstart = 1; 11760c0d06caSMauro Carvalho Chehab } 11770c0d06caSMauro Carvalho Chehab 11780c0d06caSMauro Carvalho Chehab static void mt9v_init_sensor(struct gspca_dev *gspca_dev) 11790c0d06caSMauro Carvalho Chehab { 11800c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 11810c0d06caSMauro Carvalho Chehab u16 value; 11820c0d06caSMauro Carvalho Chehab 11830c0d06caSMauro Carvalho Chehab sd->i2c_addr = 0x5d; 11840c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, 0xff, &value); 11850c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err >= 0 11860c0d06caSMauro Carvalho Chehab && value == 0x8243) { 11870c0d06caSMauro Carvalho Chehab i2c_w2_buf(gspca_dev, mt9v011_init, ARRAY_SIZE(mt9v011_init)); 11880c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) { 11890c0d06caSMauro Carvalho Chehab pr_err("MT9V011 sensor initialization failed\n"); 11900c0d06caSMauro Carvalho Chehab return; 11910c0d06caSMauro Carvalho Chehab } 11920c0d06caSMauro Carvalho Chehab sd->hstart = 2; 11930c0d06caSMauro Carvalho Chehab sd->vstart = 2; 11940c0d06caSMauro Carvalho Chehab sd->sensor = SENSOR_MT9V011; 11950c0d06caSMauro Carvalho Chehab pr_info("MT9V011 sensor detected\n"); 11960c0d06caSMauro Carvalho Chehab return; 11970c0d06caSMauro Carvalho Chehab } 11980c0d06caSMauro Carvalho Chehab 11990c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = 0; 12000c0d06caSMauro Carvalho Chehab sd->i2c_addr = 0x5c; 12010c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0x01, 0x0004); 12020c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, 0xff, &value); 12030c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err >= 0 12040c0d06caSMauro Carvalho Chehab && value == 0x823a) { 12050c0d06caSMauro Carvalho Chehab i2c_w2_buf(gspca_dev, mt9v111_init, ARRAY_SIZE(mt9v111_init)); 12060c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) { 12070c0d06caSMauro Carvalho Chehab pr_err("MT9V111 sensor initialization failed\n"); 12080c0d06caSMauro Carvalho Chehab return; 12090c0d06caSMauro Carvalho Chehab } 12100c0d06caSMauro Carvalho Chehab sd->hstart = 2; 12110c0d06caSMauro Carvalho Chehab sd->vstart = 2; 12120c0d06caSMauro Carvalho Chehab sd->sensor = SENSOR_MT9V111; 12130c0d06caSMauro Carvalho Chehab pr_info("MT9V111 sensor detected\n"); 12140c0d06caSMauro Carvalho Chehab return; 12150c0d06caSMauro Carvalho Chehab } 12160c0d06caSMauro Carvalho Chehab 12170c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = 0; 12180c0d06caSMauro Carvalho Chehab sd->i2c_addr = 0x5d; 12190c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xf0, 0x0000); 12200c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) { 12210c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = 0; 12220c0d06caSMauro Carvalho Chehab sd->i2c_addr = 0x48; 12230c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xf0, 0x0000); 12240c0d06caSMauro Carvalho Chehab } 12250c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, 0x00, &value); 12260c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err >= 0 12270c0d06caSMauro Carvalho Chehab && value == 0x1229) { 12280c0d06caSMauro Carvalho Chehab i2c_w2_buf(gspca_dev, mt9v112_init, ARRAY_SIZE(mt9v112_init)); 12290c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) { 12300c0d06caSMauro Carvalho Chehab pr_err("MT9V112 sensor initialization failed\n"); 12310c0d06caSMauro Carvalho Chehab return; 12320c0d06caSMauro Carvalho Chehab } 12330c0d06caSMauro Carvalho Chehab sd->hstart = 6; 12340c0d06caSMauro Carvalho Chehab sd->vstart = 2; 12350c0d06caSMauro Carvalho Chehab sd->sensor = SENSOR_MT9V112; 12360c0d06caSMauro Carvalho Chehab pr_info("MT9V112 sensor detected\n"); 12370c0d06caSMauro Carvalho Chehab return; 12380c0d06caSMauro Carvalho Chehab } 12390c0d06caSMauro Carvalho Chehab 12400c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = -ENODEV; 12410c0d06caSMauro Carvalho Chehab } 12420c0d06caSMauro Carvalho Chehab 12430c0d06caSMauro Carvalho Chehab static void mt9m112_init_sensor(struct gspca_dev *gspca_dev) 12440c0d06caSMauro Carvalho Chehab { 12450c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 12460c0d06caSMauro Carvalho Chehab 12470c0d06caSMauro Carvalho Chehab i2c_w2_buf(gspca_dev, mt9m112_init, ARRAY_SIZE(mt9m112_init)); 12480c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 12490c0d06caSMauro Carvalho Chehab pr_err("MT9M112 sensor initialization failed\n"); 12500c0d06caSMauro Carvalho Chehab 12510c0d06caSMauro Carvalho Chehab sd->hstart = 0; 12520c0d06caSMauro Carvalho Chehab sd->vstart = 2; 12530c0d06caSMauro Carvalho Chehab } 12540c0d06caSMauro Carvalho Chehab 12550c0d06caSMauro Carvalho Chehab static void mt9m111_init_sensor(struct gspca_dev *gspca_dev) 12560c0d06caSMauro Carvalho Chehab { 12570c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 12580c0d06caSMauro Carvalho Chehab 12590c0d06caSMauro Carvalho Chehab i2c_w2_buf(gspca_dev, mt9m111_init, ARRAY_SIZE(mt9m111_init)); 12600c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 12610c0d06caSMauro Carvalho Chehab pr_err("MT9M111 sensor initialization failed\n"); 12620c0d06caSMauro Carvalho Chehab 12630c0d06caSMauro Carvalho Chehab sd->hstart = 0; 12640c0d06caSMauro Carvalho Chehab sd->vstart = 2; 12650c0d06caSMauro Carvalho Chehab } 12660c0d06caSMauro Carvalho Chehab 12670c0d06caSMauro Carvalho Chehab static void mt9m001_init_sensor(struct gspca_dev *gspca_dev) 12680c0d06caSMauro Carvalho Chehab { 12690c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 12700c0d06caSMauro Carvalho Chehab u16 id; 12710c0d06caSMauro Carvalho Chehab 12720c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, 0x00, &id); 12730c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 12740c0d06caSMauro Carvalho Chehab return; 12750c0d06caSMauro Carvalho Chehab 12760c0d06caSMauro Carvalho Chehab /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */ 12770c0d06caSMauro Carvalho Chehab switch (id) { 12780c0d06caSMauro Carvalho Chehab case 0x8411: 12790c0d06caSMauro Carvalho Chehab case 0x8421: 12800c0d06caSMauro Carvalho Chehab pr_info("MT9M001 color sensor detected\n"); 12810c0d06caSMauro Carvalho Chehab break; 12820c0d06caSMauro Carvalho Chehab case 0x8431: 12830c0d06caSMauro Carvalho Chehab pr_info("MT9M001 mono sensor detected\n"); 12840c0d06caSMauro Carvalho Chehab break; 12850c0d06caSMauro Carvalho Chehab default: 12860c0d06caSMauro Carvalho Chehab pr_err("No MT9M001 chip detected, ID = %x\n\n", id); 12870c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = -ENODEV; 12880c0d06caSMauro Carvalho Chehab return; 12890c0d06caSMauro Carvalho Chehab } 12900c0d06caSMauro Carvalho Chehab 12910c0d06caSMauro Carvalho Chehab i2c_w2_buf(gspca_dev, mt9m001_init, ARRAY_SIZE(mt9m001_init)); 12920c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 12930c0d06caSMauro Carvalho Chehab pr_err("MT9M001 sensor initialization failed\n"); 12940c0d06caSMauro Carvalho Chehab 12950c0d06caSMauro Carvalho Chehab sd->hstart = 1; 12960c0d06caSMauro Carvalho Chehab sd->vstart = 1; 12970c0d06caSMauro Carvalho Chehab } 12980c0d06caSMauro Carvalho Chehab 12990c0d06caSMauro Carvalho Chehab static void hv7131r_init_sensor(struct gspca_dev *gspca_dev) 13000c0d06caSMauro Carvalho Chehab { 13010c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 13020c0d06caSMauro Carvalho Chehab 13030c0d06caSMauro Carvalho Chehab i2c_w1_buf(gspca_dev, hv7131r_init, ARRAY_SIZE(hv7131r_init)); 13040c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 13050c0d06caSMauro Carvalho Chehab pr_err("HV7131R Sensor initialization failed\n"); 13060c0d06caSMauro Carvalho Chehab 13070c0d06caSMauro Carvalho Chehab sd->hstart = 0; 13080c0d06caSMauro Carvalho Chehab sd->vstart = 1; 13090c0d06caSMauro Carvalho Chehab } 13100c0d06caSMauro Carvalho Chehab 13110c0d06caSMauro Carvalho Chehab static void set_cmatrix(struct gspca_dev *gspca_dev, 13120c0d06caSMauro Carvalho Chehab s32 brightness, s32 contrast, s32 satur, s32 hue) 13130c0d06caSMauro Carvalho Chehab { 13140c0d06caSMauro Carvalho Chehab s32 hue_coord, hue_index = 180 + hue; 13150c0d06caSMauro Carvalho Chehab u8 cmatrix[21]; 13160c0d06caSMauro Carvalho Chehab 13170c0d06caSMauro Carvalho Chehab memset(cmatrix, 0, sizeof cmatrix); 13180c0d06caSMauro Carvalho Chehab cmatrix[2] = (contrast * 0x25 / 0x100) + 0x26; 13190c0d06caSMauro Carvalho Chehab cmatrix[0] = 0x13 + (cmatrix[2] - 0x26) * 0x13 / 0x25; 13200c0d06caSMauro Carvalho Chehab cmatrix[4] = 0x07 + (cmatrix[2] - 0x26) * 0x07 / 0x25; 13210c0d06caSMauro Carvalho Chehab cmatrix[18] = brightness - 0x80; 13220c0d06caSMauro Carvalho Chehab 13230c0d06caSMauro Carvalho Chehab hue_coord = (hsv_red_x[hue_index] * satur) >> 8; 13240c0d06caSMauro Carvalho Chehab cmatrix[6] = hue_coord; 13250c0d06caSMauro Carvalho Chehab cmatrix[7] = (hue_coord >> 8) & 0x0f; 13260c0d06caSMauro Carvalho Chehab 13270c0d06caSMauro Carvalho Chehab hue_coord = (hsv_red_y[hue_index] * satur) >> 8; 13280c0d06caSMauro Carvalho Chehab cmatrix[8] = hue_coord; 13290c0d06caSMauro Carvalho Chehab cmatrix[9] = (hue_coord >> 8) & 0x0f; 13300c0d06caSMauro Carvalho Chehab 13310c0d06caSMauro Carvalho Chehab hue_coord = (hsv_green_x[hue_index] * satur) >> 8; 13320c0d06caSMauro Carvalho Chehab cmatrix[10] = hue_coord; 13330c0d06caSMauro Carvalho Chehab cmatrix[11] = (hue_coord >> 8) & 0x0f; 13340c0d06caSMauro Carvalho Chehab 13350c0d06caSMauro Carvalho Chehab hue_coord = (hsv_green_y[hue_index] * satur) >> 8; 13360c0d06caSMauro Carvalho Chehab cmatrix[12] = hue_coord; 13370c0d06caSMauro Carvalho Chehab cmatrix[13] = (hue_coord >> 8) & 0x0f; 13380c0d06caSMauro Carvalho Chehab 13390c0d06caSMauro Carvalho Chehab hue_coord = (hsv_blue_x[hue_index] * satur) >> 8; 13400c0d06caSMauro Carvalho Chehab cmatrix[14] = hue_coord; 13410c0d06caSMauro Carvalho Chehab cmatrix[15] = (hue_coord >> 8) & 0x0f; 13420c0d06caSMauro Carvalho Chehab 13430c0d06caSMauro Carvalho Chehab hue_coord = (hsv_blue_y[hue_index] * satur) >> 8; 13440c0d06caSMauro Carvalho Chehab cmatrix[16] = hue_coord; 13450c0d06caSMauro Carvalho Chehab cmatrix[17] = (hue_coord >> 8) & 0x0f; 13460c0d06caSMauro Carvalho Chehab 13470c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x10e1, cmatrix, 21); 13480c0d06caSMauro Carvalho Chehab } 13490c0d06caSMauro Carvalho Chehab 13500c0d06caSMauro Carvalho Chehab static void set_gamma(struct gspca_dev *gspca_dev, s32 val) 13510c0d06caSMauro Carvalho Chehab { 13520c0d06caSMauro Carvalho Chehab u8 gamma[17]; 13530c0d06caSMauro Carvalho Chehab u8 gval = val * 0xb8 / 0x100; 13540c0d06caSMauro Carvalho Chehab 13550c0d06caSMauro Carvalho Chehab gamma[0] = 0x0a; 13560c0d06caSMauro Carvalho Chehab gamma[1] = 0x13 + (gval * (0xcb - 0x13) / 0xb8); 13570c0d06caSMauro Carvalho Chehab gamma[2] = 0x25 + (gval * (0xee - 0x25) / 0xb8); 13580c0d06caSMauro Carvalho Chehab gamma[3] = 0x37 + (gval * (0xfa - 0x37) / 0xb8); 13590c0d06caSMauro Carvalho Chehab gamma[4] = 0x45 + (gval * (0xfc - 0x45) / 0xb8); 13600c0d06caSMauro Carvalho Chehab gamma[5] = 0x55 + (gval * (0xfb - 0x55) / 0xb8); 13610c0d06caSMauro Carvalho Chehab gamma[6] = 0x65 + (gval * (0xfc - 0x65) / 0xb8); 13620c0d06caSMauro Carvalho Chehab gamma[7] = 0x74 + (gval * (0xfd - 0x74) / 0xb8); 13630c0d06caSMauro Carvalho Chehab gamma[8] = 0x83 + (gval * (0xfe - 0x83) / 0xb8); 13640c0d06caSMauro Carvalho Chehab gamma[9] = 0x92 + (gval * (0xfc - 0x92) / 0xb8); 13650c0d06caSMauro Carvalho Chehab gamma[10] = 0xa1 + (gval * (0xfc - 0xa1) / 0xb8); 13660c0d06caSMauro Carvalho Chehab gamma[11] = 0xb0 + (gval * (0xfc - 0xb0) / 0xb8); 13670c0d06caSMauro Carvalho Chehab gamma[12] = 0xbf + (gval * (0xfb - 0xbf) / 0xb8); 13680c0d06caSMauro Carvalho Chehab gamma[13] = 0xce + (gval * (0xfb - 0xce) / 0xb8); 13690c0d06caSMauro Carvalho Chehab gamma[14] = 0xdf + (gval * (0xfd - 0xdf) / 0xb8); 13700c0d06caSMauro Carvalho Chehab gamma[15] = 0xea + (gval * (0xf9 - 0xea) / 0xb8); 13710c0d06caSMauro Carvalho Chehab gamma[16] = 0xf5; 13720c0d06caSMauro Carvalho Chehab 13730c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x1190, gamma, 17); 13740c0d06caSMauro Carvalho Chehab } 13750c0d06caSMauro Carvalho Chehab 13760c0d06caSMauro Carvalho Chehab static void set_redblue(struct gspca_dev *gspca_dev, s32 blue, s32 red) 13770c0d06caSMauro Carvalho Chehab { 13780c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x118c, red); 13790c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x118f, blue); 13800c0d06caSMauro Carvalho Chehab } 13810c0d06caSMauro Carvalho Chehab 13820c0d06caSMauro Carvalho Chehab static void set_hvflip(struct gspca_dev *gspca_dev, s32 hflip, s32 vflip) 13830c0d06caSMauro Carvalho Chehab { 13840c0d06caSMauro Carvalho Chehab u8 value, tslb; 13850c0d06caSMauro Carvalho Chehab u16 value2; 13860c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 13870c0d06caSMauro Carvalho Chehab 13880c0d06caSMauro Carvalho Chehab if ((sd->flags & FLIP_DETECT) && dmi_check_system(flip_dmi_table)) { 13890c0d06caSMauro Carvalho Chehab hflip = !hflip; 13900c0d06caSMauro Carvalho Chehab vflip = !vflip; 13910c0d06caSMauro Carvalho Chehab } 13920c0d06caSMauro Carvalho Chehab 13930c0d06caSMauro Carvalho Chehab switch (sd->sensor) { 13940c0d06caSMauro Carvalho Chehab case SENSOR_OV7660: 13950c0d06caSMauro Carvalho Chehab value = 0x01; 13960c0d06caSMauro Carvalho Chehab if (hflip) 13970c0d06caSMauro Carvalho Chehab value |= 0x20; 13980c0d06caSMauro Carvalho Chehab if (vflip) { 13990c0d06caSMauro Carvalho Chehab value |= 0x10; 14000c0d06caSMauro Carvalho Chehab sd->vstart = 2; 14010c0d06caSMauro Carvalho Chehab } else { 14020c0d06caSMauro Carvalho Chehab sd->vstart = 3; 14030c0d06caSMauro Carvalho Chehab } 14040c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1182, sd->vstart); 14050c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x1e, value); 14060c0d06caSMauro Carvalho Chehab break; 14070c0d06caSMauro Carvalho Chehab case SENSOR_OV9650: 14080c0d06caSMauro Carvalho Chehab i2c_r1(gspca_dev, 0x1e, &value); 14090c0d06caSMauro Carvalho Chehab value &= ~0x30; 14100c0d06caSMauro Carvalho Chehab tslb = 0x01; 14110c0d06caSMauro Carvalho Chehab if (hflip) 14120c0d06caSMauro Carvalho Chehab value |= 0x20; 14130c0d06caSMauro Carvalho Chehab if (vflip) { 14140c0d06caSMauro Carvalho Chehab value |= 0x10; 14150c0d06caSMauro Carvalho Chehab tslb = 0x49; 14160c0d06caSMauro Carvalho Chehab } 14170c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x1e, value); 14180c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x3a, tslb); 14190c0d06caSMauro Carvalho Chehab break; 14200c0d06caSMauro Carvalho Chehab case SENSOR_MT9V111: 14210c0d06caSMauro Carvalho Chehab case SENSOR_MT9V011: 14220c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, 0x20, &value2); 14230c0d06caSMauro Carvalho Chehab value2 &= ~0xc0a0; 14240c0d06caSMauro Carvalho Chehab if (hflip) 14250c0d06caSMauro Carvalho Chehab value2 |= 0x8080; 14260c0d06caSMauro Carvalho Chehab if (vflip) 14270c0d06caSMauro Carvalho Chehab value2 |= 0x4020; 14280c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0x20, value2); 14290c0d06caSMauro Carvalho Chehab break; 14300c0d06caSMauro Carvalho Chehab case SENSOR_MT9M112: 14310c0d06caSMauro Carvalho Chehab case SENSOR_MT9M111: 14320c0d06caSMauro Carvalho Chehab case SENSOR_MT9V112: 14330c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, 0x20, &value2); 14340c0d06caSMauro Carvalho Chehab value2 &= ~0x0003; 14350c0d06caSMauro Carvalho Chehab if (hflip) 14360c0d06caSMauro Carvalho Chehab value2 |= 0x0002; 14370c0d06caSMauro Carvalho Chehab if (vflip) 14380c0d06caSMauro Carvalho Chehab value2 |= 0x0001; 14390c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0x20, value2); 14400c0d06caSMauro Carvalho Chehab break; 14410c0d06caSMauro Carvalho Chehab case SENSOR_HV7131R: 14420c0d06caSMauro Carvalho Chehab i2c_r1(gspca_dev, 0x01, &value); 14430c0d06caSMauro Carvalho Chehab value &= ~0x03; 14440c0d06caSMauro Carvalho Chehab if (vflip) 14450c0d06caSMauro Carvalho Chehab value |= 0x01; 14460c0d06caSMauro Carvalho Chehab if (hflip) 14470c0d06caSMauro Carvalho Chehab value |= 0x02; 14480c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x01, value); 14490c0d06caSMauro Carvalho Chehab break; 14500c0d06caSMauro Carvalho Chehab } 14510c0d06caSMauro Carvalho Chehab } 14520c0d06caSMauro Carvalho Chehab 14530c0d06caSMauro Carvalho Chehab static void set_exposure(struct gspca_dev *gspca_dev, s32 expo) 14540c0d06caSMauro Carvalho Chehab { 14550c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 14560c0d06caSMauro Carvalho Chehab u8 exp[8] = {sd->i2c_intf, sd->i2c_addr, 14570c0d06caSMauro Carvalho Chehab 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; 14580c0d06caSMauro Carvalho Chehab int expo2; 14590c0d06caSMauro Carvalho Chehab 14600c0d06caSMauro Carvalho Chehab if (gspca_dev->streaming) 14610c0d06caSMauro Carvalho Chehab exp[7] = 0x1e; 14620c0d06caSMauro Carvalho Chehab 14630c0d06caSMauro Carvalho Chehab switch (sd->sensor) { 14640c0d06caSMauro Carvalho Chehab case SENSOR_OV7660: 14650c0d06caSMauro Carvalho Chehab case SENSOR_OV7670: 14660c0d06caSMauro Carvalho Chehab case SENSOR_OV9655: 14670c0d06caSMauro Carvalho Chehab case SENSOR_OV9650: 14680c0d06caSMauro Carvalho Chehab if (expo > 547) 14690c0d06caSMauro Carvalho Chehab expo2 = 547; 14700c0d06caSMauro Carvalho Chehab else 14710c0d06caSMauro Carvalho Chehab expo2 = expo; 14720c0d06caSMauro Carvalho Chehab exp[0] |= (2 << 4); 14730c0d06caSMauro Carvalho Chehab exp[2] = 0x10; /* AECH */ 14740c0d06caSMauro Carvalho Chehab exp[3] = expo2 >> 2; 14750c0d06caSMauro Carvalho Chehab exp[7] = 0x10; 14760c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, exp); 14770c0d06caSMauro Carvalho Chehab exp[2] = 0x04; /* COM1 */ 14780c0d06caSMauro Carvalho Chehab exp[3] = expo2 & 0x0003; 14790c0d06caSMauro Carvalho Chehab exp[7] = 0x10; 14800c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, exp); 14810c0d06caSMauro Carvalho Chehab expo -= expo2; 14820c0d06caSMauro Carvalho Chehab exp[7] = 0x1e; 14830c0d06caSMauro Carvalho Chehab exp[0] |= (3 << 4); 14840c0d06caSMauro Carvalho Chehab exp[2] = 0x2d; /* ADVFL & ADVFH */ 14850c0d06caSMauro Carvalho Chehab exp[3] = expo; 14860c0d06caSMauro Carvalho Chehab exp[4] = expo >> 8; 14870c0d06caSMauro Carvalho Chehab break; 14880c0d06caSMauro Carvalho Chehab case SENSOR_MT9M001: 14890c0d06caSMauro Carvalho Chehab case SENSOR_MT9V112: 14900c0d06caSMauro Carvalho Chehab case SENSOR_MT9V011: 14910c0d06caSMauro Carvalho Chehab exp[0] |= (3 << 4); 14920c0d06caSMauro Carvalho Chehab exp[2] = 0x09; 14930c0d06caSMauro Carvalho Chehab exp[3] = expo >> 8; 14940c0d06caSMauro Carvalho Chehab exp[4] = expo; 14950c0d06caSMauro Carvalho Chehab break; 14960c0d06caSMauro Carvalho Chehab case SENSOR_HV7131R: 14970c0d06caSMauro Carvalho Chehab exp[0] |= (4 << 4); 14980c0d06caSMauro Carvalho Chehab exp[2] = 0x25; 14990c0d06caSMauro Carvalho Chehab exp[3] = expo >> 5; 15000c0d06caSMauro Carvalho Chehab exp[4] = expo << 3; 15010c0d06caSMauro Carvalho Chehab exp[5] = 0; 15020c0d06caSMauro Carvalho Chehab break; 15030c0d06caSMauro Carvalho Chehab default: 15040c0d06caSMauro Carvalho Chehab return; 15050c0d06caSMauro Carvalho Chehab } 15060c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, exp); 15070c0d06caSMauro Carvalho Chehab } 15080c0d06caSMauro Carvalho Chehab 15090c0d06caSMauro Carvalho Chehab static void set_gain(struct gspca_dev *gspca_dev, s32 g) 15100c0d06caSMauro Carvalho Chehab { 15110c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 15120c0d06caSMauro Carvalho Chehab u8 gain[8] = {sd->i2c_intf, sd->i2c_addr, 15130c0d06caSMauro Carvalho Chehab 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; 15140c0d06caSMauro Carvalho Chehab 15150c0d06caSMauro Carvalho Chehab if (gspca_dev->streaming) 15160c0d06caSMauro Carvalho Chehab gain[7] = 0x15; /* or 1d ? */ 15170c0d06caSMauro Carvalho Chehab 15180c0d06caSMauro Carvalho Chehab switch (sd->sensor) { 15190c0d06caSMauro Carvalho Chehab case SENSOR_OV7660: 15200c0d06caSMauro Carvalho Chehab case SENSOR_OV7670: 15210c0d06caSMauro Carvalho Chehab case SENSOR_SOI968: 15220c0d06caSMauro Carvalho Chehab case SENSOR_OV9655: 15230c0d06caSMauro Carvalho Chehab case SENSOR_OV9650: 15240c0d06caSMauro Carvalho Chehab gain[0] |= (2 << 4); 15250c0d06caSMauro Carvalho Chehab gain[3] = ov_gain[g]; 15260c0d06caSMauro Carvalho Chehab break; 15270c0d06caSMauro Carvalho Chehab case SENSOR_MT9V011: 15280c0d06caSMauro Carvalho Chehab gain[0] |= (3 << 4); 15290c0d06caSMauro Carvalho Chehab gain[2] = 0x35; 15300c0d06caSMauro Carvalho Chehab gain[3] = micron1_gain[g] >> 8; 15310c0d06caSMauro Carvalho Chehab gain[4] = micron1_gain[g]; 15320c0d06caSMauro Carvalho Chehab break; 15330c0d06caSMauro Carvalho Chehab case SENSOR_MT9V112: 15340c0d06caSMauro Carvalho Chehab gain[0] |= (3 << 4); 15350c0d06caSMauro Carvalho Chehab gain[2] = 0x2f; 15360c0d06caSMauro Carvalho Chehab gain[3] = micron1_gain[g] >> 8; 15370c0d06caSMauro Carvalho Chehab gain[4] = micron1_gain[g]; 15380c0d06caSMauro Carvalho Chehab break; 15390c0d06caSMauro Carvalho Chehab case SENSOR_MT9M001: 15400c0d06caSMauro Carvalho Chehab gain[0] |= (3 << 4); 15410c0d06caSMauro Carvalho Chehab gain[2] = 0x2f; 15420c0d06caSMauro Carvalho Chehab gain[3] = micron2_gain[g] >> 8; 15430c0d06caSMauro Carvalho Chehab gain[4] = micron2_gain[g]; 15440c0d06caSMauro Carvalho Chehab break; 15450c0d06caSMauro Carvalho Chehab case SENSOR_HV7131R: 15460c0d06caSMauro Carvalho Chehab gain[0] |= (2 << 4); 15470c0d06caSMauro Carvalho Chehab gain[2] = 0x30; 15480c0d06caSMauro Carvalho Chehab gain[3] = hv7131r_gain[g]; 15490c0d06caSMauro Carvalho Chehab break; 15500c0d06caSMauro Carvalho Chehab default: 15510c0d06caSMauro Carvalho Chehab return; 15520c0d06caSMauro Carvalho Chehab } 15530c0d06caSMauro Carvalho Chehab i2c_w(gspca_dev, gain); 15540c0d06caSMauro Carvalho Chehab } 15550c0d06caSMauro Carvalho Chehab 15560c0d06caSMauro Carvalho Chehab static void set_quality(struct gspca_dev *gspca_dev, s32 val) 15570c0d06caSMauro Carvalho Chehab { 15580c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 15590c0d06caSMauro Carvalho Chehab 15600c0d06caSMauro Carvalho Chehab jpeg_set_qual(sd->jpeg_hdr, val); 15610c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1061, 0x01); /* stop transfer */ 15620c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x10e0, sd->fmt | 0x20); /* write QTAB */ 15630c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x1100, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64); 15640c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x1140, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64); 15650c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1061, 0x03); /* restart transfer */ 15660c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x10e0, sd->fmt); 15670c0d06caSMauro Carvalho Chehab sd->fmt ^= 0x0c; /* invert QTAB use + write */ 15680c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x10e0, sd->fmt); 15690c0d06caSMauro Carvalho Chehab } 15700c0d06caSMauro Carvalho Chehab 15710c0d06caSMauro Carvalho Chehab #ifdef CONFIG_VIDEO_ADV_DEBUG 15720c0d06caSMauro Carvalho Chehab static int sd_dbg_g_register(struct gspca_dev *gspca_dev, 15730c0d06caSMauro Carvalho Chehab struct v4l2_dbg_register *reg) 15740c0d06caSMauro Carvalho Chehab { 15750c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 15760c0d06caSMauro Carvalho Chehab 15770c0d06caSMauro Carvalho Chehab switch (reg->match.type) { 15780c0d06caSMauro Carvalho Chehab case V4L2_CHIP_MATCH_HOST: 15790c0d06caSMauro Carvalho Chehab if (reg->match.addr != 0) 15800c0d06caSMauro Carvalho Chehab return -EINVAL; 15810c0d06caSMauro Carvalho Chehab if (reg->reg < 0x1000 || reg->reg > 0x11ff) 15820c0d06caSMauro Carvalho Chehab return -EINVAL; 15830c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, reg->reg, 1); 15840c0d06caSMauro Carvalho Chehab reg->val = gspca_dev->usb_buf[0]; 15850c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 15860c0d06caSMauro Carvalho Chehab case V4L2_CHIP_MATCH_I2C_ADDR: 15870c0d06caSMauro Carvalho Chehab if (reg->match.addr != sd->i2c_addr) 15880c0d06caSMauro Carvalho Chehab return -EINVAL; 15890c0d06caSMauro Carvalho Chehab if (sd->sensor >= SENSOR_MT9V011 && 15900c0d06caSMauro Carvalho Chehab sd->sensor <= SENSOR_MT9M112) { 15910c0d06caSMauro Carvalho Chehab i2c_r2(gspca_dev, reg->reg, (u16 *) ®->val); 15920c0d06caSMauro Carvalho Chehab } else { 15930c0d06caSMauro Carvalho Chehab i2c_r1(gspca_dev, reg->reg, (u8 *) ®->val); 15940c0d06caSMauro Carvalho Chehab } 15950c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 15960c0d06caSMauro Carvalho Chehab } 15970c0d06caSMauro Carvalho Chehab return -EINVAL; 15980c0d06caSMauro Carvalho Chehab } 15990c0d06caSMauro Carvalho Chehab 16000c0d06caSMauro Carvalho Chehab static int sd_dbg_s_register(struct gspca_dev *gspca_dev, 1601*977ba3b1SHans Verkuil const struct v4l2_dbg_register *reg) 16020c0d06caSMauro Carvalho Chehab { 16030c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 16040c0d06caSMauro Carvalho Chehab 16050c0d06caSMauro Carvalho Chehab switch (reg->match.type) { 16060c0d06caSMauro Carvalho Chehab case V4L2_CHIP_MATCH_HOST: 16070c0d06caSMauro Carvalho Chehab if (reg->match.addr != 0) 16080c0d06caSMauro Carvalho Chehab return -EINVAL; 16090c0d06caSMauro Carvalho Chehab if (reg->reg < 0x1000 || reg->reg > 0x11ff) 16100c0d06caSMauro Carvalho Chehab return -EINVAL; 16110c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, reg->reg, reg->val); 16120c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 16130c0d06caSMauro Carvalho Chehab case V4L2_CHIP_MATCH_I2C_ADDR: 16140c0d06caSMauro Carvalho Chehab if (reg->match.addr != sd->i2c_addr) 16150c0d06caSMauro Carvalho Chehab return -EINVAL; 16160c0d06caSMauro Carvalho Chehab if (sd->sensor >= SENSOR_MT9V011 && 16170c0d06caSMauro Carvalho Chehab sd->sensor <= SENSOR_MT9M112) { 16180c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, reg->reg, reg->val); 16190c0d06caSMauro Carvalho Chehab } else { 16200c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, reg->reg, reg->val); 16210c0d06caSMauro Carvalho Chehab } 16220c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 16230c0d06caSMauro Carvalho Chehab } 16240c0d06caSMauro Carvalho Chehab return -EINVAL; 16250c0d06caSMauro Carvalho Chehab } 16260c0d06caSMauro Carvalho Chehab #endif 16270c0d06caSMauro Carvalho Chehab 16280c0d06caSMauro Carvalho Chehab static int sd_chip_ident(struct gspca_dev *gspca_dev, 16290c0d06caSMauro Carvalho Chehab struct v4l2_dbg_chip_ident *chip) 16300c0d06caSMauro Carvalho Chehab { 16310c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 16320c0d06caSMauro Carvalho Chehab 16330c0d06caSMauro Carvalho Chehab switch (chip->match.type) { 16340c0d06caSMauro Carvalho Chehab case V4L2_CHIP_MATCH_HOST: 16350c0d06caSMauro Carvalho Chehab if (chip->match.addr != 0) 16360c0d06caSMauro Carvalho Chehab return -EINVAL; 16370c0d06caSMauro Carvalho Chehab chip->revision = 0; 16380c0d06caSMauro Carvalho Chehab chip->ident = V4L2_IDENT_SN9C20X; 16390c0d06caSMauro Carvalho Chehab return 0; 16400c0d06caSMauro Carvalho Chehab case V4L2_CHIP_MATCH_I2C_ADDR: 16410c0d06caSMauro Carvalho Chehab if (chip->match.addr != sd->i2c_addr) 16420c0d06caSMauro Carvalho Chehab return -EINVAL; 16430c0d06caSMauro Carvalho Chehab chip->revision = 0; 16440c0d06caSMauro Carvalho Chehab chip->ident = i2c_ident[sd->sensor]; 16450c0d06caSMauro Carvalho Chehab return 0; 16460c0d06caSMauro Carvalho Chehab } 16470c0d06caSMauro Carvalho Chehab return -EINVAL; 16480c0d06caSMauro Carvalho Chehab } 16490c0d06caSMauro Carvalho Chehab 16500c0d06caSMauro Carvalho Chehab static int sd_config(struct gspca_dev *gspca_dev, 16510c0d06caSMauro Carvalho Chehab const struct usb_device_id *id) 16520c0d06caSMauro Carvalho Chehab { 16530c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 16540c0d06caSMauro Carvalho Chehab struct cam *cam; 16550c0d06caSMauro Carvalho Chehab 16560c0d06caSMauro Carvalho Chehab cam = &gspca_dev->cam; 16570c0d06caSMauro Carvalho Chehab cam->needs_full_bandwidth = 1; 16580c0d06caSMauro Carvalho Chehab 16590c0d06caSMauro Carvalho Chehab sd->sensor = id->driver_info >> 8; 16600c0d06caSMauro Carvalho Chehab sd->i2c_addr = id->driver_info; 16610c0d06caSMauro Carvalho Chehab sd->flags = id->driver_info >> 16; 16620c0d06caSMauro Carvalho Chehab sd->i2c_intf = 0x80; /* i2c 100 Kb/s */ 16630c0d06caSMauro Carvalho Chehab 16640c0d06caSMauro Carvalho Chehab switch (sd->sensor) { 16650c0d06caSMauro Carvalho Chehab case SENSOR_MT9M112: 16660c0d06caSMauro Carvalho Chehab case SENSOR_MT9M111: 16670c0d06caSMauro Carvalho Chehab case SENSOR_OV9650: 16680c0d06caSMauro Carvalho Chehab case SENSOR_SOI968: 16690c0d06caSMauro Carvalho Chehab cam->cam_mode = sxga_mode; 16700c0d06caSMauro Carvalho Chehab cam->nmodes = ARRAY_SIZE(sxga_mode); 16710c0d06caSMauro Carvalho Chehab break; 16720c0d06caSMauro Carvalho Chehab case SENSOR_MT9M001: 16730c0d06caSMauro Carvalho Chehab cam->cam_mode = mono_mode; 16740c0d06caSMauro Carvalho Chehab cam->nmodes = ARRAY_SIZE(mono_mode); 16750c0d06caSMauro Carvalho Chehab break; 16760c0d06caSMauro Carvalho Chehab case SENSOR_HV7131R: 16770c0d06caSMauro Carvalho Chehab sd->i2c_intf = 0x81; /* i2c 400 Kb/s */ 16780c0d06caSMauro Carvalho Chehab /* fall thru */ 16790c0d06caSMauro Carvalho Chehab default: 16800c0d06caSMauro Carvalho Chehab cam->cam_mode = vga_mode; 16810c0d06caSMauro Carvalho Chehab cam->nmodes = ARRAY_SIZE(vga_mode); 16820c0d06caSMauro Carvalho Chehab break; 16830c0d06caSMauro Carvalho Chehab } 16840c0d06caSMauro Carvalho Chehab 16850c0d06caSMauro Carvalho Chehab sd->old_step = 0; 16860c0d06caSMauro Carvalho Chehab sd->older_step = 0; 16870c0d06caSMauro Carvalho Chehab sd->exposure_step = 16; 16880c0d06caSMauro Carvalho Chehab 16890c0d06caSMauro Carvalho Chehab INIT_WORK(&sd->work, qual_upd); 16900c0d06caSMauro Carvalho Chehab 16910c0d06caSMauro Carvalho Chehab return 0; 16920c0d06caSMauro Carvalho Chehab } 16930c0d06caSMauro Carvalho Chehab 16940c0d06caSMauro Carvalho Chehab static int sd_s_ctrl(struct v4l2_ctrl *ctrl) 16950c0d06caSMauro Carvalho Chehab { 16960c0d06caSMauro Carvalho Chehab struct gspca_dev *gspca_dev = 16970c0d06caSMauro Carvalho Chehab container_of(ctrl->handler, struct gspca_dev, ctrl_handler); 16980c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *)gspca_dev; 16990c0d06caSMauro Carvalho Chehab 17000c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = 0; 17010c0d06caSMauro Carvalho Chehab 17020c0d06caSMauro Carvalho Chehab if (!gspca_dev->streaming) 17030c0d06caSMauro Carvalho Chehab return 0; 17040c0d06caSMauro Carvalho Chehab 17050c0d06caSMauro Carvalho Chehab switch (ctrl->id) { 17060c0d06caSMauro Carvalho Chehab /* color control cluster */ 17070c0d06caSMauro Carvalho Chehab case V4L2_CID_BRIGHTNESS: 17080c0d06caSMauro Carvalho Chehab set_cmatrix(gspca_dev, sd->brightness->val, 17090c0d06caSMauro Carvalho Chehab sd->contrast->val, sd->saturation->val, sd->hue->val); 17100c0d06caSMauro Carvalho Chehab break; 17110c0d06caSMauro Carvalho Chehab case V4L2_CID_GAMMA: 17120c0d06caSMauro Carvalho Chehab set_gamma(gspca_dev, ctrl->val); 17130c0d06caSMauro Carvalho Chehab break; 17140c0d06caSMauro Carvalho Chehab /* blue/red balance cluster */ 17150c0d06caSMauro Carvalho Chehab case V4L2_CID_BLUE_BALANCE: 17160c0d06caSMauro Carvalho Chehab set_redblue(gspca_dev, sd->blue->val, sd->red->val); 17170c0d06caSMauro Carvalho Chehab break; 17180c0d06caSMauro Carvalho Chehab /* h/vflip cluster */ 17190c0d06caSMauro Carvalho Chehab case V4L2_CID_HFLIP: 17200c0d06caSMauro Carvalho Chehab set_hvflip(gspca_dev, sd->hflip->val, sd->vflip->val); 17210c0d06caSMauro Carvalho Chehab break; 17220c0d06caSMauro Carvalho Chehab /* standalone exposure control */ 17230c0d06caSMauro Carvalho Chehab case V4L2_CID_EXPOSURE: 17240c0d06caSMauro Carvalho Chehab set_exposure(gspca_dev, ctrl->val); 17250c0d06caSMauro Carvalho Chehab break; 17260c0d06caSMauro Carvalho Chehab /* standalone gain control */ 17270c0d06caSMauro Carvalho Chehab case V4L2_CID_GAIN: 17280c0d06caSMauro Carvalho Chehab set_gain(gspca_dev, ctrl->val); 17290c0d06caSMauro Carvalho Chehab break; 17300c0d06caSMauro Carvalho Chehab /* autogain + exposure or gain control cluster */ 17310c0d06caSMauro Carvalho Chehab case V4L2_CID_AUTOGAIN: 17320c0d06caSMauro Carvalho Chehab if (sd->sensor == SENSOR_SOI968) 17330c0d06caSMauro Carvalho Chehab set_gain(gspca_dev, sd->gain->val); 17340c0d06caSMauro Carvalho Chehab else 17350c0d06caSMauro Carvalho Chehab set_exposure(gspca_dev, sd->exposure->val); 17360c0d06caSMauro Carvalho Chehab break; 17370c0d06caSMauro Carvalho Chehab case V4L2_CID_JPEG_COMPRESSION_QUALITY: 17380c0d06caSMauro Carvalho Chehab set_quality(gspca_dev, ctrl->val); 17390c0d06caSMauro Carvalho Chehab break; 17400c0d06caSMauro Carvalho Chehab } 17410c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 17420c0d06caSMauro Carvalho Chehab } 17430c0d06caSMauro Carvalho Chehab 17440c0d06caSMauro Carvalho Chehab static const struct v4l2_ctrl_ops sd_ctrl_ops = { 17450c0d06caSMauro Carvalho Chehab .s_ctrl = sd_s_ctrl, 17460c0d06caSMauro Carvalho Chehab }; 17470c0d06caSMauro Carvalho Chehab 17480c0d06caSMauro Carvalho Chehab static int sd_init_controls(struct gspca_dev *gspca_dev) 17490c0d06caSMauro Carvalho Chehab { 17500c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 17510c0d06caSMauro Carvalho Chehab struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; 17520c0d06caSMauro Carvalho Chehab 17530c0d06caSMauro Carvalho Chehab gspca_dev->vdev.ctrl_handler = hdl; 17540c0d06caSMauro Carvalho Chehab v4l2_ctrl_handler_init(hdl, 13); 17550c0d06caSMauro Carvalho Chehab 17560c0d06caSMauro Carvalho Chehab sd->brightness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17570c0d06caSMauro Carvalho Chehab V4L2_CID_BRIGHTNESS, 0, 255, 1, 127); 17580c0d06caSMauro Carvalho Chehab sd->contrast = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17590c0d06caSMauro Carvalho Chehab V4L2_CID_CONTRAST, 0, 255, 1, 127); 17600c0d06caSMauro Carvalho Chehab sd->saturation = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17610c0d06caSMauro Carvalho Chehab V4L2_CID_SATURATION, 0, 255, 1, 127); 17620c0d06caSMauro Carvalho Chehab sd->hue = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17630c0d06caSMauro Carvalho Chehab V4L2_CID_HUE, -180, 180, 1, 0); 17640c0d06caSMauro Carvalho Chehab 17650c0d06caSMauro Carvalho Chehab sd->gamma = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17660c0d06caSMauro Carvalho Chehab V4L2_CID_GAMMA, 0, 255, 1, 0x10); 17670c0d06caSMauro Carvalho Chehab 17680c0d06caSMauro Carvalho Chehab sd->blue = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17690c0d06caSMauro Carvalho Chehab V4L2_CID_BLUE_BALANCE, 0, 127, 1, 0x28); 17700c0d06caSMauro Carvalho Chehab sd->red = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17710c0d06caSMauro Carvalho Chehab V4L2_CID_RED_BALANCE, 0, 127, 1, 0x28); 17720c0d06caSMauro Carvalho Chehab 17730c0d06caSMauro Carvalho Chehab if (sd->sensor != SENSOR_OV9655 && sd->sensor != SENSOR_SOI968 && 17740c0d06caSMauro Carvalho Chehab sd->sensor != SENSOR_OV7670 && sd->sensor != SENSOR_MT9M001 && 17750c0d06caSMauro Carvalho Chehab sd->sensor != SENSOR_MT9VPRB) { 17760c0d06caSMauro Carvalho Chehab sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17770c0d06caSMauro Carvalho Chehab V4L2_CID_HFLIP, 0, 1, 1, 0); 17780c0d06caSMauro Carvalho Chehab sd->vflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17790c0d06caSMauro Carvalho Chehab V4L2_CID_VFLIP, 0, 1, 1, 0); 17800c0d06caSMauro Carvalho Chehab } 17810c0d06caSMauro Carvalho Chehab 17820c0d06caSMauro Carvalho Chehab if (sd->sensor != SENSOR_SOI968 && sd->sensor != SENSOR_MT9VPRB && 17830c0d06caSMauro Carvalho Chehab sd->sensor != SENSOR_MT9M112 && sd->sensor != SENSOR_MT9M111 && 17840c0d06caSMauro Carvalho Chehab sd->sensor != SENSOR_MT9V111) 17850c0d06caSMauro Carvalho Chehab sd->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17860c0d06caSMauro Carvalho Chehab V4L2_CID_EXPOSURE, 0, 0x1780, 1, 0x33); 17870c0d06caSMauro Carvalho Chehab 17880c0d06caSMauro Carvalho Chehab if (sd->sensor != SENSOR_MT9VPRB && sd->sensor != SENSOR_MT9M112 && 17890c0d06caSMauro Carvalho Chehab sd->sensor != SENSOR_MT9M111 && sd->sensor != SENSOR_MT9V111) { 17900c0d06caSMauro Carvalho Chehab sd->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17910c0d06caSMauro Carvalho Chehab V4L2_CID_GAIN, 0, 28, 1, 0); 17920c0d06caSMauro Carvalho Chehab sd->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17930c0d06caSMauro Carvalho Chehab V4L2_CID_AUTOGAIN, 0, 1, 1, 1); 17940c0d06caSMauro Carvalho Chehab } 17950c0d06caSMauro Carvalho Chehab 17960c0d06caSMauro Carvalho Chehab sd->jpegqual = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 17970c0d06caSMauro Carvalho Chehab V4L2_CID_JPEG_COMPRESSION_QUALITY, 50, 90, 1, 80); 17980c0d06caSMauro Carvalho Chehab if (hdl->error) { 17990c0d06caSMauro Carvalho Chehab pr_err("Could not initialize controls\n"); 18000c0d06caSMauro Carvalho Chehab return hdl->error; 18010c0d06caSMauro Carvalho Chehab } 18020c0d06caSMauro Carvalho Chehab 18030c0d06caSMauro Carvalho Chehab v4l2_ctrl_cluster(4, &sd->brightness); 18040c0d06caSMauro Carvalho Chehab v4l2_ctrl_cluster(2, &sd->blue); 18050c0d06caSMauro Carvalho Chehab if (sd->hflip) 18060c0d06caSMauro Carvalho Chehab v4l2_ctrl_cluster(2, &sd->hflip); 18070c0d06caSMauro Carvalho Chehab if (sd->autogain) { 18080c0d06caSMauro Carvalho Chehab if (sd->sensor == SENSOR_SOI968) 18090c0d06caSMauro Carvalho Chehab /* this sensor doesn't have the exposure control and 18100c0d06caSMauro Carvalho Chehab autogain is clustered with gain instead. This works 18110c0d06caSMauro Carvalho Chehab because sd->exposure == NULL. */ 18120c0d06caSMauro Carvalho Chehab v4l2_ctrl_auto_cluster(3, &sd->autogain, 0, false); 18130c0d06caSMauro Carvalho Chehab else 18140c0d06caSMauro Carvalho Chehab /* Otherwise autogain is clustered with exposure. */ 18150c0d06caSMauro Carvalho Chehab v4l2_ctrl_auto_cluster(2, &sd->autogain, 0, false); 18160c0d06caSMauro Carvalho Chehab } 18170c0d06caSMauro Carvalho Chehab return 0; 18180c0d06caSMauro Carvalho Chehab } 18190c0d06caSMauro Carvalho Chehab 18200c0d06caSMauro Carvalho Chehab static int sd_init(struct gspca_dev *gspca_dev) 18210c0d06caSMauro Carvalho Chehab { 18220c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 18230c0d06caSMauro Carvalho Chehab int i; 18240c0d06caSMauro Carvalho Chehab u8 value; 18250c0d06caSMauro Carvalho Chehab u8 i2c_init[9] = 18260c0d06caSMauro Carvalho Chehab {0x80, sd->i2c_addr, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}; 18270c0d06caSMauro Carvalho Chehab 18280c0d06caSMauro Carvalho Chehab for (i = 0; i < ARRAY_SIZE(bridge_init); i++) { 18290c0d06caSMauro Carvalho Chehab value = bridge_init[i][1]; 18300c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, bridge_init[i][0], &value, 1); 18310c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) { 18320c0d06caSMauro Carvalho Chehab pr_err("Device initialization failed\n"); 18330c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 18340c0d06caSMauro Carvalho Chehab } 18350c0d06caSMauro Carvalho Chehab } 18360c0d06caSMauro Carvalho Chehab 18370c0d06caSMauro Carvalho Chehab if (sd->flags & LED_REVERSE) 18380c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1006, 0x00); 18390c0d06caSMauro Carvalho Chehab else 18400c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1006, 0x20); 18410c0d06caSMauro Carvalho Chehab 18420c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x10c0, i2c_init, 9); 18430c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) { 18440c0d06caSMauro Carvalho Chehab pr_err("Device initialization failed\n"); 18450c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 18460c0d06caSMauro Carvalho Chehab } 18470c0d06caSMauro Carvalho Chehab 18480c0d06caSMauro Carvalho Chehab switch (sd->sensor) { 18490c0d06caSMauro Carvalho Chehab case SENSOR_OV9650: 18500c0d06caSMauro Carvalho Chehab ov9650_init_sensor(gspca_dev); 18510c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18520c0d06caSMauro Carvalho Chehab break; 18530c0d06caSMauro Carvalho Chehab pr_info("OV9650 sensor detected\n"); 18540c0d06caSMauro Carvalho Chehab break; 18550c0d06caSMauro Carvalho Chehab case SENSOR_OV9655: 18560c0d06caSMauro Carvalho Chehab ov9655_init_sensor(gspca_dev); 18570c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18580c0d06caSMauro Carvalho Chehab break; 18590c0d06caSMauro Carvalho Chehab pr_info("OV9655 sensor detected\n"); 18600c0d06caSMauro Carvalho Chehab break; 18610c0d06caSMauro Carvalho Chehab case SENSOR_SOI968: 18620c0d06caSMauro Carvalho Chehab soi968_init_sensor(gspca_dev); 18630c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18640c0d06caSMauro Carvalho Chehab break; 18650c0d06caSMauro Carvalho Chehab pr_info("SOI968 sensor detected\n"); 18660c0d06caSMauro Carvalho Chehab break; 18670c0d06caSMauro Carvalho Chehab case SENSOR_OV7660: 18680c0d06caSMauro Carvalho Chehab ov7660_init_sensor(gspca_dev); 18690c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18700c0d06caSMauro Carvalho Chehab break; 18710c0d06caSMauro Carvalho Chehab pr_info("OV7660 sensor detected\n"); 18720c0d06caSMauro Carvalho Chehab break; 18730c0d06caSMauro Carvalho Chehab case SENSOR_OV7670: 18740c0d06caSMauro Carvalho Chehab ov7670_init_sensor(gspca_dev); 18750c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18760c0d06caSMauro Carvalho Chehab break; 18770c0d06caSMauro Carvalho Chehab pr_info("OV7670 sensor detected\n"); 18780c0d06caSMauro Carvalho Chehab break; 18790c0d06caSMauro Carvalho Chehab case SENSOR_MT9VPRB: 18800c0d06caSMauro Carvalho Chehab mt9v_init_sensor(gspca_dev); 18810c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18820c0d06caSMauro Carvalho Chehab break; 18830c0d06caSMauro Carvalho Chehab pr_info("MT9VPRB sensor detected\n"); 18840c0d06caSMauro Carvalho Chehab break; 18850c0d06caSMauro Carvalho Chehab case SENSOR_MT9M111: 18860c0d06caSMauro Carvalho Chehab mt9m111_init_sensor(gspca_dev); 18870c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18880c0d06caSMauro Carvalho Chehab break; 18890c0d06caSMauro Carvalho Chehab pr_info("MT9M111 sensor detected\n"); 18900c0d06caSMauro Carvalho Chehab break; 18910c0d06caSMauro Carvalho Chehab case SENSOR_MT9M112: 18920c0d06caSMauro Carvalho Chehab mt9m112_init_sensor(gspca_dev); 18930c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 18940c0d06caSMauro Carvalho Chehab break; 18950c0d06caSMauro Carvalho Chehab pr_info("MT9M112 sensor detected\n"); 18960c0d06caSMauro Carvalho Chehab break; 18970c0d06caSMauro Carvalho Chehab case SENSOR_MT9M001: 18980c0d06caSMauro Carvalho Chehab mt9m001_init_sensor(gspca_dev); 18990c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 19000c0d06caSMauro Carvalho Chehab break; 19010c0d06caSMauro Carvalho Chehab break; 19020c0d06caSMauro Carvalho Chehab case SENSOR_HV7131R: 19030c0d06caSMauro Carvalho Chehab hv7131r_init_sensor(gspca_dev); 19040c0d06caSMauro Carvalho Chehab if (gspca_dev->usb_err < 0) 19050c0d06caSMauro Carvalho Chehab break; 19060c0d06caSMauro Carvalho Chehab pr_info("HV7131R sensor detected\n"); 19070c0d06caSMauro Carvalho Chehab break; 19080c0d06caSMauro Carvalho Chehab default: 19090c0d06caSMauro Carvalho Chehab pr_err("Unsupported sensor\n"); 19100c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = -ENODEV; 19110c0d06caSMauro Carvalho Chehab } 19120c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 19130c0d06caSMauro Carvalho Chehab } 19140c0d06caSMauro Carvalho Chehab 19150c0d06caSMauro Carvalho Chehab static void configure_sensor_output(struct gspca_dev *gspca_dev, int mode) 19160c0d06caSMauro Carvalho Chehab { 19170c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 19180c0d06caSMauro Carvalho Chehab u8 value; 19190c0d06caSMauro Carvalho Chehab 19200c0d06caSMauro Carvalho Chehab switch (sd->sensor) { 19210c0d06caSMauro Carvalho Chehab case SENSOR_SOI968: 19220c0d06caSMauro Carvalho Chehab if (mode & MODE_SXGA) { 19230c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x17, 0x1d); 19240c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x18, 0xbd); 19250c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x19, 0x01); 19260c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x1a, 0x81); 19270c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, 0x00); 19280c0d06caSMauro Carvalho Chehab sd->hstart = 140; 19290c0d06caSMauro Carvalho Chehab sd->vstart = 19; 19300c0d06caSMauro Carvalho Chehab } else { 19310c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x17, 0x13); 19320c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x18, 0x63); 19330c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x19, 0x01); 19340c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x1a, 0x79); 19350c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, 0x40); 19360c0d06caSMauro Carvalho Chehab sd->hstart = 60; 19370c0d06caSMauro Carvalho Chehab sd->vstart = 11; 19380c0d06caSMauro Carvalho Chehab } 19390c0d06caSMauro Carvalho Chehab break; 19400c0d06caSMauro Carvalho Chehab case SENSOR_OV9650: 19410c0d06caSMauro Carvalho Chehab if (mode & MODE_SXGA) { 19420c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x17, 0x1b); 19430c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x18, 0xbc); 19440c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x19, 0x01); 19450c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x1a, 0x82); 19460c0d06caSMauro Carvalho Chehab i2c_r1(gspca_dev, 0x12, &value); 19470c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, value & 0x07); 19480c0d06caSMauro Carvalho Chehab } else { 19490c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x17, 0x24); 19500c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x18, 0xc5); 19510c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x19, 0x00); 19520c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x1a, 0x3c); 19530c0d06caSMauro Carvalho Chehab i2c_r1(gspca_dev, 0x12, &value); 19540c0d06caSMauro Carvalho Chehab i2c_w1(gspca_dev, 0x12, (value & 0x7) | 0x40); 19550c0d06caSMauro Carvalho Chehab } 19560c0d06caSMauro Carvalho Chehab break; 19570c0d06caSMauro Carvalho Chehab case SENSOR_MT9M112: 19580c0d06caSMauro Carvalho Chehab case SENSOR_MT9M111: 19590c0d06caSMauro Carvalho Chehab if (mode & MODE_SXGA) { 19600c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xf0, 0x0002); 19610c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xc8, 0x970b); 19620c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xf0, 0x0000); 19630c0d06caSMauro Carvalho Chehab } else { 19640c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xf0, 0x0002); 19650c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xc8, 0x8000); 19660c0d06caSMauro Carvalho Chehab i2c_w2(gspca_dev, 0xf0, 0x0000); 19670c0d06caSMauro Carvalho Chehab } 19680c0d06caSMauro Carvalho Chehab break; 19690c0d06caSMauro Carvalho Chehab } 19700c0d06caSMauro Carvalho Chehab } 19710c0d06caSMauro Carvalho Chehab 19720c0d06caSMauro Carvalho Chehab static int sd_isoc_init(struct gspca_dev *gspca_dev) 19730c0d06caSMauro Carvalho Chehab { 19740c0d06caSMauro Carvalho Chehab struct usb_interface *intf; 19750c0d06caSMauro Carvalho Chehab u32 flags = gspca_dev->cam.cam_mode[(int)gspca_dev->curr_mode].priv; 19760c0d06caSMauro Carvalho Chehab 19770c0d06caSMauro Carvalho Chehab /* 19780c0d06caSMauro Carvalho Chehab * When using the SN9C20X_I420 fmt the sn9c20x needs more bandwidth 19790c0d06caSMauro Carvalho Chehab * than our regular bandwidth calculations reserve, so we force the 19800c0d06caSMauro Carvalho Chehab * use of a specific altsetting when using the SN9C20X_I420 fmt. 19810c0d06caSMauro Carvalho Chehab */ 19820c0d06caSMauro Carvalho Chehab if (!(flags & (MODE_RAW | MODE_JPEG))) { 19830c0d06caSMauro Carvalho Chehab intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface); 19840c0d06caSMauro Carvalho Chehab 19850c0d06caSMauro Carvalho Chehab if (intf->num_altsetting != 9) { 19860c0d06caSMauro Carvalho Chehab pr_warn("sn9c20x camera with unknown number of alt " 19870c0d06caSMauro Carvalho Chehab "settings (%d), please report!\n", 19880c0d06caSMauro Carvalho Chehab intf->num_altsetting); 19890c0d06caSMauro Carvalho Chehab gspca_dev->alt = intf->num_altsetting; 19900c0d06caSMauro Carvalho Chehab return 0; 19910c0d06caSMauro Carvalho Chehab } 19920c0d06caSMauro Carvalho Chehab 19930c0d06caSMauro Carvalho Chehab switch (gspca_dev->width) { 19940c0d06caSMauro Carvalho Chehab case 160: /* 160x120 */ 19950c0d06caSMauro Carvalho Chehab gspca_dev->alt = 2; 19960c0d06caSMauro Carvalho Chehab break; 19970c0d06caSMauro Carvalho Chehab case 320: /* 320x240 */ 19980c0d06caSMauro Carvalho Chehab gspca_dev->alt = 6; 19990c0d06caSMauro Carvalho Chehab break; 20000c0d06caSMauro Carvalho Chehab default: /* >= 640x480 */ 20010c0d06caSMauro Carvalho Chehab gspca_dev->alt = 9; 20020c0d06caSMauro Carvalho Chehab break; 20030c0d06caSMauro Carvalho Chehab } 20040c0d06caSMauro Carvalho Chehab } 20050c0d06caSMauro Carvalho Chehab 20060c0d06caSMauro Carvalho Chehab return 0; 20070c0d06caSMauro Carvalho Chehab } 20080c0d06caSMauro Carvalho Chehab 20090c0d06caSMauro Carvalho Chehab #define HW_WIN(mode, hstart, vstart) \ 20100c0d06caSMauro Carvalho Chehab ((const u8 []){hstart, 0, vstart, 0, \ 20110c0d06caSMauro Carvalho Chehab (mode & MODE_SXGA ? 1280 >> 4 : 640 >> 4), \ 20120c0d06caSMauro Carvalho Chehab (mode & MODE_SXGA ? 1024 >> 3 : 480 >> 3)}) 20130c0d06caSMauro Carvalho Chehab 20140c0d06caSMauro Carvalho Chehab #define CLR_WIN(width, height) \ 20150c0d06caSMauro Carvalho Chehab ((const u8 [])\ 20160c0d06caSMauro Carvalho Chehab {0, width >> 2, 0, height >> 1,\ 20170c0d06caSMauro Carvalho Chehab ((width >> 10) & 0x01) | ((height >> 8) & 0x6)}) 20180c0d06caSMauro Carvalho Chehab 20190c0d06caSMauro Carvalho Chehab static int sd_start(struct gspca_dev *gspca_dev) 20200c0d06caSMauro Carvalho Chehab { 20210c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 20220c0d06caSMauro Carvalho Chehab int mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 20230c0d06caSMauro Carvalho Chehab int width = gspca_dev->width; 20240c0d06caSMauro Carvalho Chehab int height = gspca_dev->height; 20250c0d06caSMauro Carvalho Chehab u8 fmt, scale = 0; 20260c0d06caSMauro Carvalho Chehab 20270c0d06caSMauro Carvalho Chehab jpeg_define(sd->jpeg_hdr, height, width, 20280c0d06caSMauro Carvalho Chehab 0x21); 20290c0d06caSMauro Carvalho Chehab jpeg_set_qual(sd->jpeg_hdr, v4l2_ctrl_g_ctrl(sd->jpegqual)); 20300c0d06caSMauro Carvalho Chehab 20310c0d06caSMauro Carvalho Chehab if (mode & MODE_RAW) 20320c0d06caSMauro Carvalho Chehab fmt = 0x2d; 20330c0d06caSMauro Carvalho Chehab else if (mode & MODE_JPEG) 20340c0d06caSMauro Carvalho Chehab fmt = 0x24; 20350c0d06caSMauro Carvalho Chehab else 20360c0d06caSMauro Carvalho Chehab fmt = 0x2f; /* YUV 420 */ 20370c0d06caSMauro Carvalho Chehab sd->fmt = fmt; 20380c0d06caSMauro Carvalho Chehab 20390c0d06caSMauro Carvalho Chehab switch (mode & SCALE_MASK) { 20400c0d06caSMauro Carvalho Chehab case SCALE_1280x1024: 20410c0d06caSMauro Carvalho Chehab scale = 0xc0; 20420c0d06caSMauro Carvalho Chehab pr_info("Set 1280x1024\n"); 20430c0d06caSMauro Carvalho Chehab break; 20440c0d06caSMauro Carvalho Chehab case SCALE_640x480: 20450c0d06caSMauro Carvalho Chehab scale = 0x80; 20460c0d06caSMauro Carvalho Chehab pr_info("Set 640x480\n"); 20470c0d06caSMauro Carvalho Chehab break; 20480c0d06caSMauro Carvalho Chehab case SCALE_320x240: 20490c0d06caSMauro Carvalho Chehab scale = 0x90; 20500c0d06caSMauro Carvalho Chehab pr_info("Set 320x240\n"); 20510c0d06caSMauro Carvalho Chehab break; 20520c0d06caSMauro Carvalho Chehab case SCALE_160x120: 20530c0d06caSMauro Carvalho Chehab scale = 0xa0; 20540c0d06caSMauro Carvalho Chehab pr_info("Set 160x120\n"); 20550c0d06caSMauro Carvalho Chehab break; 20560c0d06caSMauro Carvalho Chehab } 20570c0d06caSMauro Carvalho Chehab 20580c0d06caSMauro Carvalho Chehab configure_sensor_output(gspca_dev, mode); 20590c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x1100, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64); 20600c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x1140, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64); 20610c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x10fb, CLR_WIN(width, height), 5); 20620c0d06caSMauro Carvalho Chehab reg_w(gspca_dev, 0x1180, HW_WIN(mode, sd->hstart, sd->vstart), 6); 20630c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1189, scale); 20640c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x10e0, fmt); 20650c0d06caSMauro Carvalho Chehab 20660c0d06caSMauro Carvalho Chehab set_cmatrix(gspca_dev, v4l2_ctrl_g_ctrl(sd->brightness), 20670c0d06caSMauro Carvalho Chehab v4l2_ctrl_g_ctrl(sd->contrast), 20680c0d06caSMauro Carvalho Chehab v4l2_ctrl_g_ctrl(sd->saturation), 20690c0d06caSMauro Carvalho Chehab v4l2_ctrl_g_ctrl(sd->hue)); 20700c0d06caSMauro Carvalho Chehab set_gamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); 20710c0d06caSMauro Carvalho Chehab set_redblue(gspca_dev, v4l2_ctrl_g_ctrl(sd->blue), 20720c0d06caSMauro Carvalho Chehab v4l2_ctrl_g_ctrl(sd->red)); 20730c0d06caSMauro Carvalho Chehab if (sd->gain) 20740c0d06caSMauro Carvalho Chehab set_gain(gspca_dev, v4l2_ctrl_g_ctrl(sd->gain)); 20750c0d06caSMauro Carvalho Chehab if (sd->exposure) 20760c0d06caSMauro Carvalho Chehab set_exposure(gspca_dev, v4l2_ctrl_g_ctrl(sd->exposure)); 20770c0d06caSMauro Carvalho Chehab if (sd->hflip) 20780c0d06caSMauro Carvalho Chehab set_hvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip), 20790c0d06caSMauro Carvalho Chehab v4l2_ctrl_g_ctrl(sd->vflip)); 20800c0d06caSMauro Carvalho Chehab 20810c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1007, 0x20); 20820c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1061, 0x03); 20830c0d06caSMauro Carvalho Chehab 20840c0d06caSMauro Carvalho Chehab /* if JPEG, prepare the compression quality update */ 20850c0d06caSMauro Carvalho Chehab if (mode & MODE_JPEG) { 20860c0d06caSMauro Carvalho Chehab sd->pktsz = sd->npkt = 0; 20870c0d06caSMauro Carvalho Chehab sd->nchg = 0; 20880c0d06caSMauro Carvalho Chehab sd->work_thread = 20890c0d06caSMauro Carvalho Chehab create_singlethread_workqueue(KBUILD_MODNAME); 20900c0d06caSMauro Carvalho Chehab } 20910c0d06caSMauro Carvalho Chehab 20920c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 20930c0d06caSMauro Carvalho Chehab } 20940c0d06caSMauro Carvalho Chehab 20950c0d06caSMauro Carvalho Chehab static void sd_stopN(struct gspca_dev *gspca_dev) 20960c0d06caSMauro Carvalho Chehab { 20970c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1007, 0x00); 20980c0d06caSMauro Carvalho Chehab reg_w1(gspca_dev, 0x1061, 0x01); 20990c0d06caSMauro Carvalho Chehab } 21000c0d06caSMauro Carvalho Chehab 21010c0d06caSMauro Carvalho Chehab /* called on streamoff with alt==0 and on disconnect */ 21020c0d06caSMauro Carvalho Chehab /* the usb_lock is held at entry - restore on exit */ 21030c0d06caSMauro Carvalho Chehab static void sd_stop0(struct gspca_dev *gspca_dev) 21040c0d06caSMauro Carvalho Chehab { 21050c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 21060c0d06caSMauro Carvalho Chehab 21070c0d06caSMauro Carvalho Chehab if (sd->work_thread != NULL) { 21080c0d06caSMauro Carvalho Chehab mutex_unlock(&gspca_dev->usb_lock); 21090c0d06caSMauro Carvalho Chehab destroy_workqueue(sd->work_thread); 21100c0d06caSMauro Carvalho Chehab mutex_lock(&gspca_dev->usb_lock); 21110c0d06caSMauro Carvalho Chehab sd->work_thread = NULL; 21120c0d06caSMauro Carvalho Chehab } 21130c0d06caSMauro Carvalho Chehab } 21140c0d06caSMauro Carvalho Chehab 21150c0d06caSMauro Carvalho Chehab static void do_autoexposure(struct gspca_dev *gspca_dev, u16 avg_lum) 21160c0d06caSMauro Carvalho Chehab { 21170c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 21180c0d06caSMauro Carvalho Chehab s32 cur_exp = v4l2_ctrl_g_ctrl(sd->exposure); 21190c0d06caSMauro Carvalho Chehab s32 max = sd->exposure->maximum - sd->exposure_step; 21200c0d06caSMauro Carvalho Chehab s32 min = sd->exposure->minimum + sd->exposure_step; 21210c0d06caSMauro Carvalho Chehab s16 new_exp; 21220c0d06caSMauro Carvalho Chehab 21230c0d06caSMauro Carvalho Chehab /* 21240c0d06caSMauro Carvalho Chehab * some hardcoded values are present 21250c0d06caSMauro Carvalho Chehab * like those for maximal/minimal exposure 21260c0d06caSMauro Carvalho Chehab * and exposure steps 21270c0d06caSMauro Carvalho Chehab */ 21280c0d06caSMauro Carvalho Chehab if (avg_lum < MIN_AVG_LUM) { 21290c0d06caSMauro Carvalho Chehab if (cur_exp > max) 21300c0d06caSMauro Carvalho Chehab return; 21310c0d06caSMauro Carvalho Chehab 21320c0d06caSMauro Carvalho Chehab new_exp = cur_exp + sd->exposure_step; 21330c0d06caSMauro Carvalho Chehab if (new_exp > max) 21340c0d06caSMauro Carvalho Chehab new_exp = max; 21350c0d06caSMauro Carvalho Chehab if (new_exp < min) 21360c0d06caSMauro Carvalho Chehab new_exp = min; 21370c0d06caSMauro Carvalho Chehab v4l2_ctrl_s_ctrl(sd->exposure, new_exp); 21380c0d06caSMauro Carvalho Chehab 21390c0d06caSMauro Carvalho Chehab sd->older_step = sd->old_step; 21400c0d06caSMauro Carvalho Chehab sd->old_step = 1; 21410c0d06caSMauro Carvalho Chehab 21420c0d06caSMauro Carvalho Chehab if (sd->old_step ^ sd->older_step) 21430c0d06caSMauro Carvalho Chehab sd->exposure_step /= 2; 21440c0d06caSMauro Carvalho Chehab else 21450c0d06caSMauro Carvalho Chehab sd->exposure_step += 2; 21460c0d06caSMauro Carvalho Chehab } 21470c0d06caSMauro Carvalho Chehab if (avg_lum > MAX_AVG_LUM) { 21480c0d06caSMauro Carvalho Chehab if (cur_exp < min) 21490c0d06caSMauro Carvalho Chehab return; 21500c0d06caSMauro Carvalho Chehab new_exp = cur_exp - sd->exposure_step; 21510c0d06caSMauro Carvalho Chehab if (new_exp > max) 21520c0d06caSMauro Carvalho Chehab new_exp = max; 21530c0d06caSMauro Carvalho Chehab if (new_exp < min) 21540c0d06caSMauro Carvalho Chehab new_exp = min; 21550c0d06caSMauro Carvalho Chehab v4l2_ctrl_s_ctrl(sd->exposure, new_exp); 21560c0d06caSMauro Carvalho Chehab sd->older_step = sd->old_step; 21570c0d06caSMauro Carvalho Chehab sd->old_step = 0; 21580c0d06caSMauro Carvalho Chehab 21590c0d06caSMauro Carvalho Chehab if (sd->old_step ^ sd->older_step) 21600c0d06caSMauro Carvalho Chehab sd->exposure_step /= 2; 21610c0d06caSMauro Carvalho Chehab else 21620c0d06caSMauro Carvalho Chehab sd->exposure_step += 2; 21630c0d06caSMauro Carvalho Chehab } 21640c0d06caSMauro Carvalho Chehab } 21650c0d06caSMauro Carvalho Chehab 21660c0d06caSMauro Carvalho Chehab static void do_autogain(struct gspca_dev *gspca_dev, u16 avg_lum) 21670c0d06caSMauro Carvalho Chehab { 21680c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 21690c0d06caSMauro Carvalho Chehab s32 cur_gain = v4l2_ctrl_g_ctrl(sd->gain); 21700c0d06caSMauro Carvalho Chehab 21710c0d06caSMauro Carvalho Chehab if (avg_lum < MIN_AVG_LUM && cur_gain < sd->gain->maximum) 21720c0d06caSMauro Carvalho Chehab v4l2_ctrl_s_ctrl(sd->gain, cur_gain + 1); 21730c0d06caSMauro Carvalho Chehab if (avg_lum > MAX_AVG_LUM && cur_gain > sd->gain->minimum) 21740c0d06caSMauro Carvalho Chehab v4l2_ctrl_s_ctrl(sd->gain, cur_gain - 1); 21750c0d06caSMauro Carvalho Chehab } 21760c0d06caSMauro Carvalho Chehab 21770c0d06caSMauro Carvalho Chehab static void sd_dqcallback(struct gspca_dev *gspca_dev) 21780c0d06caSMauro Carvalho Chehab { 21790c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 21800c0d06caSMauro Carvalho Chehab int avg_lum; 21810c0d06caSMauro Carvalho Chehab 21820c0d06caSMauro Carvalho Chehab if (sd->autogain == NULL || !v4l2_ctrl_g_ctrl(sd->autogain)) 21830c0d06caSMauro Carvalho Chehab return; 21840c0d06caSMauro Carvalho Chehab 21850c0d06caSMauro Carvalho Chehab avg_lum = atomic_read(&sd->avg_lum); 21860c0d06caSMauro Carvalho Chehab if (sd->sensor == SENSOR_SOI968) 21870c0d06caSMauro Carvalho Chehab do_autogain(gspca_dev, avg_lum); 21880c0d06caSMauro Carvalho Chehab else 21890c0d06caSMauro Carvalho Chehab do_autoexposure(gspca_dev, avg_lum); 21900c0d06caSMauro Carvalho Chehab } 21910c0d06caSMauro Carvalho Chehab 21920c0d06caSMauro Carvalho Chehab /* JPEG quality update */ 21930c0d06caSMauro Carvalho Chehab /* This function is executed from a work queue. */ 21940c0d06caSMauro Carvalho Chehab static void qual_upd(struct work_struct *work) 21950c0d06caSMauro Carvalho Chehab { 21960c0d06caSMauro Carvalho Chehab struct sd *sd = container_of(work, struct sd, work); 21970c0d06caSMauro Carvalho Chehab struct gspca_dev *gspca_dev = &sd->gspca_dev; 21980c0d06caSMauro Carvalho Chehab s32 qual = v4l2_ctrl_g_ctrl(sd->jpegqual); 21990c0d06caSMauro Carvalho Chehab 2200844db450SHans de Goede /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */ 22010c0d06caSMauro Carvalho Chehab mutex_lock(&gspca_dev->usb_lock); 22020c0d06caSMauro Carvalho Chehab PDEBUG(D_STREAM, "qual_upd %d%%", qual); 2203844db450SHans de Goede gspca_dev->usb_err = 0; 22040c0d06caSMauro Carvalho Chehab set_quality(gspca_dev, qual); 22050c0d06caSMauro Carvalho Chehab mutex_unlock(&gspca_dev->usb_lock); 22060c0d06caSMauro Carvalho Chehab } 22070c0d06caSMauro Carvalho Chehab 22088099affaSPeter Senna Tschudin #if IS_ENABLED(CONFIG_INPUT) 22090c0d06caSMauro Carvalho Chehab static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 22100c0d06caSMauro Carvalho Chehab u8 *data, /* interrupt packet */ 22110c0d06caSMauro Carvalho Chehab int len) /* interrupt packet length */ 22120c0d06caSMauro Carvalho Chehab { 22130c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 22140c0d06caSMauro Carvalho Chehab 22150c0d06caSMauro Carvalho Chehab if (!(sd->flags & HAS_NO_BUTTON) && len == 1) { 22160c0d06caSMauro Carvalho Chehab input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); 22170c0d06caSMauro Carvalho Chehab input_sync(gspca_dev->input_dev); 22180c0d06caSMauro Carvalho Chehab input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); 22190c0d06caSMauro Carvalho Chehab input_sync(gspca_dev->input_dev); 22200c0d06caSMauro Carvalho Chehab return 0; 22210c0d06caSMauro Carvalho Chehab } 22220c0d06caSMauro Carvalho Chehab return -EINVAL; 22230c0d06caSMauro Carvalho Chehab } 22240c0d06caSMauro Carvalho Chehab #endif 22250c0d06caSMauro Carvalho Chehab 22260c0d06caSMauro Carvalho Chehab /* check the JPEG compression */ 22270c0d06caSMauro Carvalho Chehab static void transfer_check(struct gspca_dev *gspca_dev, 22280c0d06caSMauro Carvalho Chehab u8 *data) 22290c0d06caSMauro Carvalho Chehab { 22300c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 22310c0d06caSMauro Carvalho Chehab int new_qual, r; 22320c0d06caSMauro Carvalho Chehab 22330c0d06caSMauro Carvalho Chehab new_qual = 0; 22340c0d06caSMauro Carvalho Chehab 22350c0d06caSMauro Carvalho Chehab /* if USB error, discard the frame and decrease the quality */ 22360c0d06caSMauro Carvalho Chehab if (data[6] & 0x08) { /* USB FIFO full */ 22370c0d06caSMauro Carvalho Chehab gspca_dev->last_packet_type = DISCARD_PACKET; 22380c0d06caSMauro Carvalho Chehab new_qual = -5; 22390c0d06caSMauro Carvalho Chehab } else { 22400c0d06caSMauro Carvalho Chehab 22410c0d06caSMauro Carvalho Chehab /* else, compute the filling rate and a new JPEG quality */ 22420c0d06caSMauro Carvalho Chehab r = (sd->pktsz * 100) / 22430c0d06caSMauro Carvalho Chehab (sd->npkt * 22440c0d06caSMauro Carvalho Chehab gspca_dev->urb[0]->iso_frame_desc[0].length); 22450c0d06caSMauro Carvalho Chehab if (r >= 85) 22460c0d06caSMauro Carvalho Chehab new_qual = -3; 22470c0d06caSMauro Carvalho Chehab else if (r < 75) 22480c0d06caSMauro Carvalho Chehab new_qual = 2; 22490c0d06caSMauro Carvalho Chehab } 22500c0d06caSMauro Carvalho Chehab if (new_qual != 0) { 22510c0d06caSMauro Carvalho Chehab sd->nchg += new_qual; 22520c0d06caSMauro Carvalho Chehab if (sd->nchg < -6 || sd->nchg >= 12) { 22530c0d06caSMauro Carvalho Chehab /* Note: we are in interrupt context, so we can't 22540c0d06caSMauro Carvalho Chehab use v4l2_ctrl_g/s_ctrl here. Access the value 22550c0d06caSMauro Carvalho Chehab directly instead. */ 22560c0d06caSMauro Carvalho Chehab s32 curqual = sd->jpegqual->cur.val; 22570c0d06caSMauro Carvalho Chehab sd->nchg = 0; 22580c0d06caSMauro Carvalho Chehab new_qual += curqual; 22590c0d06caSMauro Carvalho Chehab if (new_qual < sd->jpegqual->minimum) 22600c0d06caSMauro Carvalho Chehab new_qual = sd->jpegqual->minimum; 22610c0d06caSMauro Carvalho Chehab else if (new_qual > sd->jpegqual->maximum) 22620c0d06caSMauro Carvalho Chehab new_qual = sd->jpegqual->maximum; 22630c0d06caSMauro Carvalho Chehab if (new_qual != curqual) { 22640c0d06caSMauro Carvalho Chehab sd->jpegqual->cur.val = new_qual; 22650c0d06caSMauro Carvalho Chehab queue_work(sd->work_thread, &sd->work); 22660c0d06caSMauro Carvalho Chehab } 22670c0d06caSMauro Carvalho Chehab } 22680c0d06caSMauro Carvalho Chehab } else { 22690c0d06caSMauro Carvalho Chehab sd->nchg = 0; 22700c0d06caSMauro Carvalho Chehab } 22710c0d06caSMauro Carvalho Chehab sd->pktsz = sd->npkt = 0; 22720c0d06caSMauro Carvalho Chehab } 22730c0d06caSMauro Carvalho Chehab 22740c0d06caSMauro Carvalho Chehab static void sd_pkt_scan(struct gspca_dev *gspca_dev, 22750c0d06caSMauro Carvalho Chehab u8 *data, /* isoc packet */ 22760c0d06caSMauro Carvalho Chehab int len) /* iso packet length */ 22770c0d06caSMauro Carvalho Chehab { 22780c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 22790c0d06caSMauro Carvalho Chehab int avg_lum, is_jpeg; 22800c0d06caSMauro Carvalho Chehab static const u8 frame_header[] = 22810c0d06caSMauro Carvalho Chehab {0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96}; 22820c0d06caSMauro Carvalho Chehab 22830c0d06caSMauro Carvalho Chehab is_jpeg = (sd->fmt & 0x03) == 0; 22840c0d06caSMauro Carvalho Chehab if (len >= 64 && memcmp(data, frame_header, 6) == 0) { 22850c0d06caSMauro Carvalho Chehab avg_lum = ((data[35] >> 2) & 3) | 22860c0d06caSMauro Carvalho Chehab (data[20] << 2) | 22870c0d06caSMauro Carvalho Chehab (data[19] << 10); 22880c0d06caSMauro Carvalho Chehab avg_lum += ((data[35] >> 4) & 3) | 22890c0d06caSMauro Carvalho Chehab (data[22] << 2) | 22900c0d06caSMauro Carvalho Chehab (data[21] << 10); 22910c0d06caSMauro Carvalho Chehab avg_lum += ((data[35] >> 6) & 3) | 22920c0d06caSMauro Carvalho Chehab (data[24] << 2) | 22930c0d06caSMauro Carvalho Chehab (data[23] << 10); 22940c0d06caSMauro Carvalho Chehab avg_lum += (data[36] & 3) | 22950c0d06caSMauro Carvalho Chehab (data[26] << 2) | 22960c0d06caSMauro Carvalho Chehab (data[25] << 10); 22970c0d06caSMauro Carvalho Chehab avg_lum += ((data[36] >> 2) & 3) | 22980c0d06caSMauro Carvalho Chehab (data[28] << 2) | 22990c0d06caSMauro Carvalho Chehab (data[27] << 10); 23000c0d06caSMauro Carvalho Chehab avg_lum += ((data[36] >> 4) & 3) | 23010c0d06caSMauro Carvalho Chehab (data[30] << 2) | 23020c0d06caSMauro Carvalho Chehab (data[29] << 10); 23030c0d06caSMauro Carvalho Chehab avg_lum += ((data[36] >> 6) & 3) | 23040c0d06caSMauro Carvalho Chehab (data[32] << 2) | 23050c0d06caSMauro Carvalho Chehab (data[31] << 10); 23060c0d06caSMauro Carvalho Chehab avg_lum += ((data[44] >> 4) & 3) | 23070c0d06caSMauro Carvalho Chehab (data[34] << 2) | 23080c0d06caSMauro Carvalho Chehab (data[33] << 10); 23090c0d06caSMauro Carvalho Chehab avg_lum >>= 9; 23100c0d06caSMauro Carvalho Chehab atomic_set(&sd->avg_lum, avg_lum); 23110c0d06caSMauro Carvalho Chehab 23120c0d06caSMauro Carvalho Chehab if (is_jpeg) 23130c0d06caSMauro Carvalho Chehab transfer_check(gspca_dev, data); 23140c0d06caSMauro Carvalho Chehab 23150c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); 23160c0d06caSMauro Carvalho Chehab len -= 64; 23170c0d06caSMauro Carvalho Chehab if (len == 0) 23180c0d06caSMauro Carvalho Chehab return; 23190c0d06caSMauro Carvalho Chehab data += 64; 23200c0d06caSMauro Carvalho Chehab } 23210c0d06caSMauro Carvalho Chehab if (gspca_dev->last_packet_type == LAST_PACKET) { 23220c0d06caSMauro Carvalho Chehab if (is_jpeg) { 23230c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, FIRST_PACKET, 23240c0d06caSMauro Carvalho Chehab sd->jpeg_hdr, JPEG_HDR_SZ); 23250c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, INTER_PACKET, 23260c0d06caSMauro Carvalho Chehab data, len); 23270c0d06caSMauro Carvalho Chehab } else { 23280c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, FIRST_PACKET, 23290c0d06caSMauro Carvalho Chehab data, len); 23300c0d06caSMauro Carvalho Chehab } 23310c0d06caSMauro Carvalho Chehab } else { 23320c0d06caSMauro Carvalho Chehab /* if JPEG, count the packets and their size */ 23330c0d06caSMauro Carvalho Chehab if (is_jpeg) { 23340c0d06caSMauro Carvalho Chehab sd->npkt++; 23350c0d06caSMauro Carvalho Chehab sd->pktsz += len; 23360c0d06caSMauro Carvalho Chehab } 23370c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 23380c0d06caSMauro Carvalho Chehab } 23390c0d06caSMauro Carvalho Chehab } 23400c0d06caSMauro Carvalho Chehab 23410c0d06caSMauro Carvalho Chehab /* sub-driver description */ 23420c0d06caSMauro Carvalho Chehab static const struct sd_desc sd_desc = { 23430c0d06caSMauro Carvalho Chehab .name = KBUILD_MODNAME, 23440c0d06caSMauro Carvalho Chehab .config = sd_config, 23450c0d06caSMauro Carvalho Chehab .init = sd_init, 23460c0d06caSMauro Carvalho Chehab .init_controls = sd_init_controls, 23470c0d06caSMauro Carvalho Chehab .isoc_init = sd_isoc_init, 23480c0d06caSMauro Carvalho Chehab .start = sd_start, 23490c0d06caSMauro Carvalho Chehab .stopN = sd_stopN, 23500c0d06caSMauro Carvalho Chehab .stop0 = sd_stop0, 23510c0d06caSMauro Carvalho Chehab .pkt_scan = sd_pkt_scan, 23528099affaSPeter Senna Tschudin #if IS_ENABLED(CONFIG_INPUT) 23530c0d06caSMauro Carvalho Chehab .int_pkt_scan = sd_int_pkt_scan, 23540c0d06caSMauro Carvalho Chehab #endif 23550c0d06caSMauro Carvalho Chehab .dq_callback = sd_dqcallback, 23560c0d06caSMauro Carvalho Chehab #ifdef CONFIG_VIDEO_ADV_DEBUG 23570c0d06caSMauro Carvalho Chehab .set_register = sd_dbg_s_register, 23580c0d06caSMauro Carvalho Chehab .get_register = sd_dbg_g_register, 23590c0d06caSMauro Carvalho Chehab #endif 23600c0d06caSMauro Carvalho Chehab .get_chip_ident = sd_chip_ident, 23610c0d06caSMauro Carvalho Chehab }; 23620c0d06caSMauro Carvalho Chehab 23630c0d06caSMauro Carvalho Chehab #define SN9C20X(sensor, i2c_addr, flags) \ 23640c0d06caSMauro Carvalho Chehab .driver_info = ((flags & 0xff) << 16) \ 23650c0d06caSMauro Carvalho Chehab | (SENSOR_ ## sensor << 8) \ 23660c0d06caSMauro Carvalho Chehab | (i2c_addr) 23670c0d06caSMauro Carvalho Chehab 23680c0d06caSMauro Carvalho Chehab static const struct usb_device_id device_table[] = { 23690c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6240), SN9C20X(MT9M001, 0x5d, 0)}, 23700c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6242), SN9C20X(MT9M111, 0x5d, 0)}, 23710c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6248), SN9C20X(OV9655, 0x30, 0)}, 23720c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x624c), SN9C20X(MT9M112, 0x5d, 0)}, 23730c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x624e), SN9C20X(SOI968, 0x30, LED_REVERSE)}, 23740c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x624f), SN9C20X(OV9650, 0x30, 23750c0d06caSMauro Carvalho Chehab (FLIP_DETECT | HAS_NO_BUTTON))}, 23760c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6251), SN9C20X(OV9650, 0x30, 0)}, 23770c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6253), SN9C20X(OV9650, 0x30, 0)}, 23780c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6260), SN9C20X(OV7670, 0x21, 0)}, 23790c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6270), SN9C20X(MT9VPRB, 0x00, 0)}, 23800c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x627b), SN9C20X(OV7660, 0x21, FLIP_DETECT)}, 23810c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x627c), SN9C20X(HV7131R, 0x11, 0)}, 23820c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x627f), SN9C20X(OV9650, 0x30, 0)}, 23830c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6280), SN9C20X(MT9M001, 0x5d, 0)}, 23840c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6282), SN9C20X(MT9M111, 0x5d, 0)}, 23850c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x6288), SN9C20X(OV9655, 0x30, 0)}, 23860c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x628c), SN9C20X(MT9M112, 0x5d, 0)}, 23870c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x628e), SN9C20X(SOI968, 0x30, 0)}, 23880c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x628f), SN9C20X(OV9650, 0x30, 0)}, 23890c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x62a0), SN9C20X(OV7670, 0x21, 0)}, 23900c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x62b0), SN9C20X(MT9VPRB, 0x00, 0)}, 23910c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x62b3), SN9C20X(OV9655, 0x30, LED_REVERSE)}, 23920c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x62bb), SN9C20X(OV7660, 0x21, LED_REVERSE)}, 23930c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0c45, 0x62bc), SN9C20X(HV7131R, 0x11, 0)}, 23940c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x045e, 0x00f4), SN9C20X(OV9650, 0x30, 0)}, 23950c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x145f, 0x013d), SN9C20X(OV7660, 0x21, 0)}, 23960c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0458, 0x7029), SN9C20X(HV7131R, 0x11, 0)}, 23970c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0458, 0x704a), SN9C20X(MT9M112, 0x5d, 0)}, 23980c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0458, 0x704c), SN9C20X(MT9M112, 0x5d, 0)}, 23990c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xa168, 0x0610), SN9C20X(HV7131R, 0x11, 0)}, 24000c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xa168, 0x0611), SN9C20X(HV7131R, 0x11, 0)}, 24010c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xa168, 0x0613), SN9C20X(HV7131R, 0x11, 0)}, 24020c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xa168, 0x0618), SN9C20X(HV7131R, 0x11, 0)}, 24030c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xa168, 0x0614), SN9C20X(MT9M111, 0x5d, 0)}, 24040c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xa168, 0x0615), SN9C20X(MT9M111, 0x5d, 0)}, 24050c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xa168, 0x0617), SN9C20X(MT9M111, 0x5d, 0)}, 24060c0d06caSMauro Carvalho Chehab {} 24070c0d06caSMauro Carvalho Chehab }; 24080c0d06caSMauro Carvalho Chehab MODULE_DEVICE_TABLE(usb, device_table); 24090c0d06caSMauro Carvalho Chehab 24100c0d06caSMauro Carvalho Chehab /* -- device connect -- */ 24110c0d06caSMauro Carvalho Chehab static int sd_probe(struct usb_interface *intf, 24120c0d06caSMauro Carvalho Chehab const struct usb_device_id *id) 24130c0d06caSMauro Carvalho Chehab { 24140c0d06caSMauro Carvalho Chehab return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 24150c0d06caSMauro Carvalho Chehab THIS_MODULE); 24160c0d06caSMauro Carvalho Chehab } 24170c0d06caSMauro Carvalho Chehab 24180c0d06caSMauro Carvalho Chehab static struct usb_driver sd_driver = { 24190c0d06caSMauro Carvalho Chehab .name = KBUILD_MODNAME, 24200c0d06caSMauro Carvalho Chehab .id_table = device_table, 24210c0d06caSMauro Carvalho Chehab .probe = sd_probe, 24220c0d06caSMauro Carvalho Chehab .disconnect = gspca_disconnect, 24230c0d06caSMauro Carvalho Chehab #ifdef CONFIG_PM 24240c0d06caSMauro Carvalho Chehab .suspend = gspca_suspend, 24250c0d06caSMauro Carvalho Chehab .resume = gspca_resume, 24260c0d06caSMauro Carvalho Chehab .reset_resume = gspca_resume, 24270c0d06caSMauro Carvalho Chehab #endif 24280c0d06caSMauro Carvalho Chehab }; 24290c0d06caSMauro Carvalho Chehab 24300c0d06caSMauro Carvalho Chehab module_usb_driver(sd_driver); 2431