/*
* vs6624.c ST VS6624 CMOS image sensor driver
*
* Copyright (c) 2011 Analog Devices Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/videodev2.h>
#include <media/v4l2-chip-ident.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-mediabus.h>
#include "vs6624_regs.h"
#define VGA_WIDTH 640
#define VGA_HEIGHT 480
#define QVGA_WIDTH 320
#define QVGA_HEIGHT 240
#define QQVGA_WIDTH 160
#define QQVGA_HEIGHT 120
#define CIF_WIDTH 352
#define CIF_HEIGHT 288
#define QCIF_WIDTH 176
#define QCIF_HEIGHT 144
#define QQCIF_WIDTH 88
#define QQCIF_HEIGHT 72
#define MAX_FRAME_RATE 30
struct vs6624 {
struct v4l2_subdev sd;
struct v4l2_ctrl_handler hdl;
struct v4l2_fract frame_rate;
struct v4l2_mbus_framefmt fmt;
unsigned ce_pin;
};
static const struct vs6624_format {
enum v4l2_mbus_pixelcode mbus_code;
enum v4l2_colorspace colorspace;
} vs6624_formats[] = {
{
.mbus_code = V4L2_MBUS_FMT_UYVY8_2X8,
.colorspace = V4L2_COLORSPACE_JPEG,
},
{
.mbus_code = V4L2_MBUS_FMT_YUYV8_2X8,
.colorspace = V4L2_COLORSPACE_JPEG,
},
{
.mbus_code = V4L2_MBUS_FMT_RGB565_2X8_LE,
.colorspace = V4L2_COLORSPACE_SRGB,
},
};
static struct v4l2_mbus_framefmt vs6624_default_fmt = {
.width = VGA_WIDTH,
.height = VGA_HEIGHT,
.code = V4L2_MBUS_FMT_UYVY8_2X8,
.field = V4L2_FIELD_NONE,
.colorspace = V4L2_COLORSPACE_JPEG,
};
static const u16 vs6624_p1[] = {
0x8104, 0x03,
0x8105, 0x01,
0xc900, 0x03,
0xc904, 0x47,
0xc905, 0x10,
0xc906, 0x80,
0xc907, 0x3a,
0x903a, 0x02,
0x903b, 0x47,
0x903c, 0x15,
0xc908, 0x31,
0xc909, 0xdc,
0xc90a, 0x80,
0xc90b, 0x44,
0x9044, 0x02,
0x9045, 0x31,
0x9046, 0xe2,
0xc90c, 0x07,
0xc90d, 0xe0,
0xc90e, 0x80,
0xc90f, 0x47,
0x9047, 0x90,
0x9048, 0x83,
0x9049, 0x81,
0x904a, 0xe0,
0x904b, 0x60,
0x904c, 0x08,
0x904d, 0x90,
0x904e, 0xc0,
0x904f, 0x43,
0x9050, 0x74,
0x9051, 0x01,
0x9052, 0xf0,
0x9053, 0x80,
0x9054, 0x05,
0x9055, 0xE4,
0x9056, 0x90,
0x9057, 0xc0,
0x9058, 0x43,
0x9059, 0xf0,
0x905a, 0x02,
0x905b, 0x07,
0x905c, 0xec,
0xc910, 0x5d,
0xc911, 0xca,
0xc912, 0x80,
0xc913, 0x5d,
0x905d, 0xa3,
0x905e, 0x04,
0x905f, 0xf0,
0x9060, 0xa3,
0x9061, 0x04,
0x9062, 0xf0,
0x9063, 0x22,
0xc914, 0x72,
0xc915, 0x92,
0xc916, 0x80,
0xc917, 0x64,
0x9064, 0x74,
0x9065, 0x01,
0x9066, 0x02,
0x9067, 0x72,
0x9068, 0x95,
0xc918, 0x47,
0xc919, 0xf2,
0xc91a, 0x81,
0xc91b, 0x69,
0x9169, 0x74,
0x916a, 0x02,
0x916b, 0xf0,
0x916c, 0xec,
0x916d, 0xb4,
0x916e, 0x10,
0x916f, 0x0a,
0x9170, 0x90,
0x9171, 0x80,
0x9172, 0x16,
0x9173, 0xe0,
0x9174, 0x70,
0x9175, 0x04,
0x9176, 0x90,
0x9177, 0xd3,
0x9178, 0xc4,
0x9179, 0xf0,
0x917a, 0x22,
0xc91c, 0x0a,
0xc91d, 0xbe,
0xc91e, 0x80,
0xc91f, 0x73,
0x9073, 0xfc,
0x9074, 0xa3,
0x9075, 0xe0,
0x9076, 0xf5,
0x9077, 0x82,
0x9078, 0x8c,
0x9079, 0x83,
0x907a, 0xa3,
0x907b, 0xa3,
0x907c, 0xe0,
0x907d, 0xfc,
0x907e, 0xa3,
0x907f, 0xe0,
0x9080, 0xc3,
0x9081, 0x9f,
0x9082, 0xff,
0x9083, 0xec,
0x9084, 0x9e,
0x9085, 0xfe,
0x9086, 0x02,
0x9087, 0x0a,
0x9088, 0xea,
0xc920, 0x47,
0xc921, 0x38,
0xc922,