/*
* Driver for M-5MOLS 8M Pixel camera sensor with ISP
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* Author: HeungJun Kim <riverful.kim@samsung.com>
*
* Copyright (C) 2009 Samsung Electronics Co., Ltd.
* Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/videodev2.h>
#include <linux/module.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>
#include <media/i2c/m5mols.h>
#include "m5mols.h"
#include "m5mols_reg.h"
int m5mols_debug;
module_param(m5mols_debug, int, 0644);
#define MODULE_NAME "M5MOLS"
#define M5MOLS_I2C_CHECK_RETRY 500
/* The regulator consumer names for external voltage regulators */
static struct regulator_bulk_data supplies[] = {
{
.supply = "core", /* ARM core power, 1.2V */
}, {
.supply = "dig_18", /* digital power 1, 1.8V */
}, {
.supply = "d_sensor", /* sensor power 1, 1.8V */
}, {
.supply = "dig_28", /* digital power 2, 2.8V */
}, {
.supply = "a_sensor", /* analog power */
}, {
.supply = "dig_12", /* digital power 3, 1.2V */
},
};
static struct v4l2_mbus_framefmt m5mols_default_ffmt[M5MOLS_RESTYPE_MAX] = {
[M5MOLS_RESTYPE_MONITOR] = {
.width = 1920,
.height = 1080,
.code = MEDIA_BUS_FMT_VYUY8_2X8,
.field = V4L2_FIELD_NONE,
.colorspace = V4L2_COLORSPACE_JPEG,
},
[M5MOLS_RESTYPE_CAPTURE] = {
.width = 1920,
.height = 1080,
.code = MEDIA_BUS_FMT_JPEG_1X8,
.field = V4L2_FIELD_NONE,
.colorspace = V4L2_COLORSPACE_JPEG,
},
};
#define SIZE_DEFAULT_FFMT ARRAY_SIZE(m5mols_default_ffmt)
static const struct m5mols_resolution m5mols_reg_res[] = {
{ 0x01, M5MOLS_RESTYPE_MONITOR, 128, 96 }, /* SUB-QCIF */
{ 0x03, M5MOLS_RESTYPE_MONITOR, 160, 120 }, /* QQVGA */
{ 0x05, M5MOLS_RESTYPE_MONITOR, 176, 144 }, /* QCIF */
{ 0x06, M5MOLS_RESTYPE_MONITOR, 176, 176 },
{ 0x08, M5MOLS_RESTYPE_MONITOR, 240, 320 }, /* QVGA */
{ 0x09, M5MOLS_RESTYPE_MONITOR, 320, 240 }, /* QVGA */
{ 0x0c, M5MOLS_RESTYPE_MONITOR, 240, 400 }, /* WQVGA */
{ 0x0d, M5MOLS_RESTYPE_MONITOR, 400, 240 }, /* WQVGA */
{ 0x0e, M5MOLS_RESTYPE_MONITOR, 352, 288 }, /* CIF */
{ 0x13, M5MOLS_RESTYPE_MONITOR, 480, 360 },
{ 0x15, M5MOLS_RESTYPE_MONITOR, 640, 360 }, /* qHD */
{ 0x17, M5MOLS_RESTYPE_MONITOR, 640, 480 }, /* VGA */
{ 0x18, M5MOLS_RESTYPE_MONITOR, 720, 480 },
{ 0x1a, M5MOLS_RESTYPE_MONITOR, 800, 480 }, /* WVGA */
{ 0x1f, M5MOLS_RESTYPE_MONITOR, 800, 600 }, /* SVGA */
{ 0x21, M5MOLS_RESTYPE_MONITOR, 1280, 720 }, /* HD */
{ 0x25, M5MOLS_RESTYPE_MONITOR, 1920, 1080 }, /* 1080p */
{ 0x29, M5MOLS_RESTYPE_MONITOR, 3264, 2448 }, /* 2.63fps 8M */
{ 0x39, M5MOLS_RESTYPE_MONITOR, 800, 602 }, /* AHS_MON debug */
{ 0x02, M5MOLS_RESTYPE_CAPTURE, 320, 240 }, /* QVGA */
{ 0x04, M5MOLS_RESTYPE_CAPTURE, 400, 240 }, /* WQVGA */
{ 0x07, M5MOLS_RESTYPE_CAPTURE, 480, 360 },
{ 0x08, M5MOLS_RESTYPE_CAPTURE, 640, 360 }, /* qHD */
{ 0x09, M5MOLS_RESTYPE_CAPTURE, 640, 480 }, /* VGA */
{ 0x0a, M5MOLS_RESTYPE_CAPTURE, 800, 480 }, /* WVGA */
{ 0x10, M5MOLS_RESTYPE_CAPTURE, 1280, 720 }, /* HD */
{ 0x14, M5MOLS_RESTYPE_CAPTURE, 1280,