/*
* Copyright 2017-2018 NXP
*/
/*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/ctype.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/of_device.h>
#include <linux/i2c.h>
#include <linux/v4l2-mediabus.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/regulator/consumer.h>
#include <media/v4l2-subdev.h>
#define MAX9271_MAX_SENSOR_NUM 4
#define CAMERA_USES_15HZ
#define ADDR_MAX9286 0x6A
#define ADDR_MAX9271 0x40
#define ADDR_MAX9271_ALL (ADDR_MAX9271 + 5) /* Broadcast address */
#define MIPI_CSI2_SENS_VC0_PAD_SOURCE 0
#define MIPI_CSI2_SENS_VC1_PAD_SOURCE 1
#define MIPI_CSI2_SENS_VC2_PAD_SOURCE 2
#define MIPI_CSI2_SENS_VC3_PAD_SOURCE 3
#define MIPI_CSI2_SENS_VCX_PADS_NUM 4
#define MAX_FPS 30
#define MIN_FPS 30
#define DEFAULT_FPS 30
#define ADDR_OV_SENSOR 0x30
#define ADDR_AP_SENSOR 0x5D
/*!
* Maintains the information on the current state of the sesor.
*/
struct imxdpu_videomode {
char name[64]; /* may not be needed */
uint32_t pixelclock; /* Hz */
/* htotal (pixels) = hlen + hfp + hsync + hbp */
uint32_t hlen;
uint32_t hfp;
uint32_t hbp;
uint32_t hsync;
/* field0 - vtotal (lines) = vlen + vfp + vsync + vbp */
uint32_t vlen;
uint32_t vfp;
uint32_t vbp;
uint32_t vsync;
/* field1 */
uint32_t vlen1;
uint32_t vfp1;
uint32_t vbp1;
uint32_t vsync1;
uint32_t flags;
uint32_t format;
uint32_t dest_format; /*buffer format for capture*/
int16_t clip_top;
int16_t clip_left;
uint16_t clip_width;
uint16_t clip_height;
};
struct sensor_data {
struct v4l2_subdev subdev;
struct media_pad pads[MIPI_CSI2_SENS_VCX_PADS_NUM];
struct i2c_client *i2c_client;
struct v4l2_mbus_framefmt format;
struct v4l2_captureparm streamcap;
char running;
/* control settings */
int brightness;
int hue;
int contrast;
int saturation;
int red;
int green;
int blue;
int ae_mode;
u32 mclk;
u8 mclk_source;
struct clk *sensor_clk;
int v_channel;
bool is_mipi;
struct imxdpu_videomode cap_mode;
unsigned int sensor_num; /* sensor num connect max9271 */
unsigned char sensor_is_there; /* Bit 0~3 for 4 cameras, 0b1= is there; 0b0 = is not there */
int pwn_gpio;
};
static unsigned int g_max9286_width = 1280;
static unsigned int g_max9286_height = 800;
#define OV10635_REG_PID 0x300A
#define OV10635_REG_VER 0x300B
struct reg_value {
unsigned short reg_addr;
unsigned char val;
unsigned int delay_ms;
};
enum ov10635_frame_rate {
OV10635_30_FPS,
};
static struct reg_value ov10635_init_data[] = {
{ 0x0103, 0x01, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x300c, 0x61, 0 },
{ 0x301b, 0xff, 0 },
{ 0x301c, 0xff, 0 },
{ 0x301a, 0xff, 0 },
{ 0x3011, 0x42, 0 },
{ 0x6900, 0x0c, 0 },
{ 0x6901, 0x11, 0 },
{ 0x3503, 0x10, 0 },
{ 0x3025, 0x03, 0 },
{ 0x3003, 0x20, 0 },
{ 0x3004, 0x21, 0 },
{ 0x3005, 0x20, 0 },
{ 0x3006, 0x91, 0 },
{ 0x3600, 0x74, 0 },
{ 0x3601, 0x2b, 0 },
{ 0x3612, 0x00, 0 },
{ 0x3611, 0x67, 0 },
{ 0x3633, 0xca, 0 },
{ 0x3602, 0x2f, 0 },
{ 0x3603, 0x00, 0 },
{ 0x3630, 0x28, 0 },
{ 0x3631, 0x16, 0 },
{ 0x3714, 0x10, 0 },
{ 0x371d, 0x01, 0 },
{ 0x4300, 0x38, 0 },
{ 0x3007, 0x01, 0 },
{ 0x3024, 0x01, 0 },
{ 0x3020, 0x0b, 0 },
{ 0x3702, 0x20, 0 },
{ 0x3703, 0x48, 0 },
{ 0x3704, 0x32, 0 },
{ 0x3709, 0xa8, 0 },
{ 0x3709, 0xa8, 0 },
{ 0x370c, 0xc7, 0 },
{ 0x370d, 0x80, 0 },
{ 0x3712, 0x00, 0 },
{ 0x3713, 0x20, 0 },
{ 0x3715, 0x04, 0 },
{ 0x381d, 0x40, 0 },
{ 0x381c, 0x00, 0 },
{ 0x3822, 0x50, 0 },
{ 0x3824, 0x50, 0 },
{ 0x3815, 0x8c, 0 },
{ 0x3804, 0x05, 0 },
{ 0x3805, 0x1f, 0 },
{ 0x3800, 0x00, 0 },
{ 0x3801, 0x00, 0 },
{ 0x3806, 0x03, 0 },
{ 0x3807, 0x29, 0 },
{ 0x3802, 0x00, 0 },
{ 0x3803, 0x04, 0 },
{ 0x3808, 0x05, 0 },
{ 0x3809, 0x00, 0 },
{ 0x380a, 0x03, 0 },
{ 0x380b, 0x20, 0 },
{ 0x380c, 0x07, 0 },
{ 0x380d, 0x71, 0 },
{ 0x6e42, 0x03, 0 },
{ 0x6e43, 0x48, 0 },
{ 0x380e, 0x03, 0 },
{ 0x380f, 0x48, 0 },
{ 0x3813, 0x02, 0 },
{ 0x3811, 0x10, 0 },
{ 0x381f, 0x0c, 0 },
{ 0x3828, 0x03, 0 },
{ 0x3829, 0x10, 0 },
{ 0x382a, 0x10, 0 },
{ 0x382b, 0x10, 0 },
{ 0x3621, 0x64, 0 },
{ 0x5005, 0x08, 0 },
{ 0x56d5, 0x00, 0 },
{ 0x56d6, 0x80, 0 },
{ 0x56d7, 0x00, 0 },
{ 0x56d8, 0x00, 0 },
{ 0x56d9, 0x00, 0 },
{ 0x56da, 0x80, 0 },
{ 0x56db, 0x00, 0 },
{ 0x56dc, 0x00, 0 },
{ 0x56e8, 0x00, 0 },
{ 0x56e9, 0x7f, 0 },
{ 0x56ea, 0x00, 0 },
{ 0x56eb, 0x7f, 0 },
{ 0x5100, 0x00, 0 },
{ 0x5101, 0x80, 0 },
{ 0x5102, 0x00, 0 },
{ 0x5103, 0x80, 0 },
{ 0x5104, 0x00, 0 },
{ 0x5105, 0x80, 0 },
{ 0x5106, 0x00, 0 },
{ 0x5107, 0x80, 0 },
{ 0x5108, 0x00, 0 },
{ 0x5109, 0x00, 0 },
{ 0x510a, 0x00, 0 },
{ 0x510b, 0x00, 0 },
{ 0x510c, 0x00, 0 },
{ 0x510d, 0x00, 0 },
{ 0x510e, 0x00, 0 },
{ 0x510f, 0x00, 0 },
{ 0x5110, 0x00, 0 },
{ 0x5111, 0x80, 0 },
{ 0x5112, 0x00, 0 },
{ 0x5113, 0x80, 0 },
{ 0x5114, 0x00, 0 },
{ 0x5115, 0x80, 0 },
{ 0x5116, 0x00, 0 },
{ 0x5117, 0x80, 0 },
{ 0x5118, 0x00, 0 },
{ 0x5119, 0x00, 0 },
{ 0x511a, 0x00, 0 },
{ 0x511b, 0x00, 0 },
{ 0x511c, 0x00, 0 },
{ 0x511d, 0x00, 0 },
{ 0x511e, 0x00, 0 },
{ 0x511f, 0x00, 0 },
{ 0x56d0, 0x00, 0 },
{ 0x5006, 0x24, 0 },
{ 0x5608, 0x0d, 0 },
{ 0x52d7, 0x06, 0 },
{ 0x528d, 0x08, 0 },
{ 0x5293, 0x12, 0 },
{ 0x52d3, 0x12, 0 },
{ 0x5288, 0x06, 0 },
{ 0x5289, 0x20, 0 },
{ 0x52c8, 0x06, 0 },
{ 0x52c9, 0x20, 0 },
{ 0x52cd, 0x04, 0 },
{ 0x5381, 0x00, 0 },
{ 0x5382, 0xff, 0 },
{ 0x5589, 0x76, 0 },
{ 0x558a, 0x47, 0 },
{ 0x558b, 0xef, 0 },
{ 0x558c, 0xc9, 0 },
{ 0x558d, 0x49, 0 },
{ 0x558e, 0x30, 0 },
{ 0x558f, 0x67, 0 },
{ 0x5590, 0x3f, 0 },
{ 0x5591, 0xf0, 0 },
{ 0x5592, 0x10, 0 },
{ 0x55a2, 0x6d, 0 },
{ 0x55a3, 0x55, 0 },
{ 0x55a4, 0xc3, 0 },
{ 0x55a5, 0xb5, 0 },
{ 0x55a6, 0x43, 0 },
{ 0x55a7, 0x38, 0 },
{ 0x55a8, 0x5f, 0 },
{ 0x55a9, 0x4b, 0 },
{ 0x55aa, 0xf0, 0 },
{ 0x55ab, 0x10, 0 },
{ 0x5581, 0x52, 0 },
{ 0x5300, 0x01, 0 },
{ 0x5301, 0x00, 0 },
{ 0x5302, 0x00, 0 },
{ 0x5303, 0x0e, 0 },
{ 0x5304, 0x00, 0 },
{ 0x5305, 0x0e, 0 },
{ 0x5306, 0x00, 0 },
{ 0x5307, 0x36, 0 },
{ 0x5308, 0x00, 0 },
{ 0x5309, 0xd9, 0 },
{ 0x530a, 0x00, 0 },
{ 0x530b, 0x0f, 0 },
{ 0x530c, 0x00, 0 },
{ 0x530d, 0x2c, 0 },
{ 0x530e, 0x00, 0 },
{ 0x530f, 0x59, 0 },
{ 0x5310, 0x00, 0 },
{ 0x5311, 0x7b, 0 },
{ 0x5312, 0x00, 0 },
{ 0x5313, 0x22, 0 },
{ 0x5314, 0x00, 0 },
{ 0x5315, 0xd5, 0 },
{ 0x5316, 0x00, 0 },
{ 0x5317, 0x13, 0 },
{ 0x5318, 0x00, 0 },
{ 0x5319, 0x18, 0 },
{ 0x531a, 0x00, 0 },
{ 0x531b, 0x26, 0 },
{ 0x531c, 0x00, 0 },
{ 0x531d, 0xdc, 0 },
{ 0x531e, 0x00, 0 },
{ 0x531f, 0x02, 0 },
{ 0x5320, 0x00, 0 },
{ 0x5321, 0x24, 0 },
{ 0x5322, 0x00, 0 },
{ 0x5323, 0x56, 0 },
{ 0x5324, 0x00, 0 },
{ 0x5325, 0x85, 0 },
{ 0x5326, 0x00, 0 },
{ 0x5327, 0x20, 0 },
{ 0x5609, 0x01, 0 },
{ 0x560a, 0x40, 0 },
{ 0x560b, 0x01, 0 },
{ 0x560c, 0x40, 0 },
{ 0x560d, 0x00, 0 },
{ 0x560e, 0xfa, 0 },
{ 0x560f, 0x00, 0 },
{ 0x5610, 0xfa, 0 },
{ 0x5611, 0x02, 0 },
{ 0x5612, 0x80, 0 },
{ 0x5613, 0x02, 0 },
{ 0x5614, 0x80, 0 },
{ 0x5615, 0x01, 0 },
{ 0x5616, 0x2c, 0 },
{ 0x5617, 0x01, 0 },
{ 0x5618, 0x2c, 0 },
{ 0x563b, 0x01, 0 },
{ 0x563c, 0x01, 0 },
{ 0x563d, 0x01, 0 },
{ 0x563e, 0x01, 0 },
{ 0x563f, 0
- 1
- 2
前往页