linux/drivers/staging/media/atomisp/i2c/gc2235.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Support for GalaxyCore GC2235 2M camera sensor.
 *
 * Copyright (c) 2014 Intel Corporation. All Rights Reserved.
 *
 * 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.
 *
 */

#ifndef __GC2235_H__
#define __GC2235_H__
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/videodev2.h>
#include <linux/spinlock.h>
#include <media/v4l2-subdev.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
#include <linux/v4l2-mediabus.h>
#include <media/media-entity.h>

#include "../include/linux/atomisp_platform.h"

/*
 * FIXME: non-preview resolutions are currently broken
 */
#define ENABLE_NON_PREVIEW

/* Defines for register writes and register array processing */
#define I2C_MSG_LENGTH
#define I2C_RETRY_COUNT

#define GC2235_FOCAL_LENGTH_NUM

#define MAX_FMTS

/*
 * focal length bits definition:
 * bits 31-16: numerator, bits 15-0: denominator
 */
#define GC2235_FOCAL_LENGTH_DEFAULT

/*
 * current f-number bits definition:
 * bits 31-16: numerator, bits 15-0: denominator
 */
#define GC2235_F_NUMBER_DEFAULT

/*
 * f-number range bits definition:
 * bits 31-24: max f-number numerator
 * bits 23-16: max f-number denominator
 * bits 15-8: min f-number numerator
 * bits 7-0: min f-number denominator
 */
#define GC2235_F_NUMBER_RANGE
#define GC2235_ID

#define GC2235_FINE_INTG_TIME_MIN
#define GC2235_FINE_INTG_TIME_MAX_MARGIN
#define GC2235_COARSE_INTG_TIME_MIN
#define GC2235_COARSE_INTG_TIME_MAX_MARGIN

/*
 * GC2235 System control registers
 */
#define GC2235_SENSOR_ID_H
#define GC2235_SENSOR_ID_L
#define GC2235_RESET_RELATED
#define GC2235_SW_RESET
#define GC2235_MIPI_RESET
#define GC2235_RESET_BIT
#define GC2235_REGISTER_PAGE_0
#define GC2235_REGISTER_PAGE_3

#define GC2235_V_CROP_START_H
#define GC2235_V_CROP_START_L
#define GC2235_H_CROP_START_H
#define GC2235_H_CROP_START_L
#define GC2235_V_OUTSIZE_H
#define GC2235_V_OUTSIZE_L
#define GC2235_H_OUTSIZE_H
#define GC2235_H_OUTSIZE_L

#define GC2235_HB_H
#define GC2235_HB_L
#define GC2235_VB_H
#define GC2235_VB_L
#define GC2235_SH_DELAY_H
#define GC2235_SH_DELAY_L

#define GC2235_CSI2_MODE

#define GC2235_EXPOSURE_H
#define GC2235_EXPOSURE_L
#define GC2235_GLOBAL_GAIN
#define GC2235_PRE_GAIN
#define GC2235_AWB_R_GAIN
#define GC2235_AWB_G_GAIN
#define GC2235_AWB_B_GAIN

#define GC2235_START_STREAMING
#define GC2235_STOP_STREAMING

struct regval_list {};

struct gc2235_resolution {};

struct gc2235_format {};

/*
 * gc2235 device structure.
 */
struct gc2235_device {};

enum gc2235_tok_type {};

/*
 * struct gc2235_reg - MI sensor  register format
 * @type: type of the register
 * @reg: 8-bit offset to register
 * @val: 8/16/32-bit register value
 *
 * Define a structure for sensor register initialization values
 */
struct gc2235_reg {};

#define to_gc2235_sensor(x)

#define GC2235_MAX_WRITE_BUF_SIZE

struct gc2235_write_buffer {};

struct gc2235_write_ctrl {};

static struct gc2235_reg const gc2235_stream_on[] =;

static struct gc2235_reg const gc2235_stream_off[] =;

static struct gc2235_reg const gc2235_init_settings[] =;

/*
 * Register settings for various resolution
 */
#if ENABLE_NON_PREVIEW
static struct gc2235_reg const gc2235_1296_736_30fps[] = {
	{ GC2235_8BIT, 0x8b, 0xa0 },
	{ GC2235_8BIT, 0x8c, 0x02 },

	{ GC2235_8BIT, 0x07, 0x01 }, /* VBI */
	{ GC2235_8BIT, 0x08, 0x44 },
	{ GC2235_8BIT, 0x09, 0x00 }, /* row start */
	{ GC2235_8BIT, 0x0a, 0xf0 },
	{ GC2235_8BIT, 0x0b, 0x00 }, /* col start */
	{ GC2235_8BIT, 0x0c, 0xa0 },
	{ GC2235_8BIT, 0x0d, 0x02 }, /* win height 736 */
	{ GC2235_8BIT, 0x0e, 0xf0 },
	{ GC2235_8BIT, 0x0f, 0x05 }, /* win width: 1296 */
	{ GC2235_8BIT, 0x10, 0x20 },

	{ GC2235_8BIT, 0x90, 0x01 },
	{ GC2235_8BIT, 0x92, 0x08 },
	{ GC2235_8BIT, 0x94, 0x08 },
	{ GC2235_8BIT, 0x95, 0x02 }, /* crop win height 736 */
	{ GC2235_8BIT, 0x96, 0xe0 },
	{ GC2235_8BIT, 0x97, 0x05 }, /* crop win width 1296 */
	{ GC2235_8BIT, 0x98, 0x10 },
	/* mimi init */
	{ GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
	{ GC2235_8BIT, 0x01, 0x07 },
	{ GC2235_8BIT, 0x02, 0x11 },
	{ GC2235_8BIT, 0x03, 0x11 },
	{ GC2235_8BIT, 0x06, 0x80 },
	{ GC2235_8BIT, 0x11, 0x2b },
	/* set mipi buffer */
	{ GC2235_8BIT, 0x12, 0x54 }, /* val_low = (width * 10 / 8) & 0xFF */
	{ GC2235_8BIT, 0x13, 0x06 }, /* val_high = (width * 10 / 8) >> 8 */

	{ GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
	{ GC2235_8BIT, 0x04, 0x10 },
	{ GC2235_8BIT, 0x05, 0x00 },
	{ GC2235_8BIT, 0x17, 0x01 },

	{ GC2235_8BIT, 0x22, 0x01 },
	{ GC2235_8BIT, 0x23, 0x05 },
	{ GC2235_8BIT, 0x24, 0x10 },
	{ GC2235_8BIT, 0x25, 0x10 },
	{ GC2235_8BIT, 0x26, 0x02 },
	{ GC2235_8BIT, 0x21, 0x10 },
	{ GC2235_8BIT, 0x29, 0x01 },
	{ GC2235_8BIT, 0x2a, 0x02 },
	{ GC2235_8BIT, 0x2b, 0x02 },

	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
	{ GC2235_TOK_TERM, 0, 0 }
};

static struct gc2235_reg const gc2235_960_640_30fps[] = {
	{ GC2235_8BIT, 0x8b, 0xa0 },
	{ GC2235_8BIT, 0x8c, 0x02 },

	{ GC2235_8BIT, 0x07, 0x02 }, /* VBI */
	{ GC2235_8BIT, 0x08, 0xA4 },
	{ GC2235_8BIT, 0x09, 0x01 }, /* row start */
	{ GC2235_8BIT, 0x0a, 0x18 },
	{ GC2235_8BIT, 0x0b, 0x01 }, /* col start */
	{ GC2235_8BIT, 0x0c, 0x40 },
	{ GC2235_8BIT, 0x0d, 0x02 }, /* win height 656 */
	{ GC2235_8BIT, 0x0e, 0x90 },
	{ GC2235_8BIT, 0x0f, 0x03 }, /* win width: 976 */
	{ GC2235_8BIT, 0x10, 0xd0 },

	{ GC2235_8BIT, 0x90, 0x01 },
	{ GC2235_8BIT, 0x92, 0x02 },
	{ GC2235_8BIT, 0x94, 0x06 },
	{ GC2235_8BIT, 0x95, 0x02 }, /* crop win height 640 */
	{ GC2235_8BIT, 0x96, 0x80 },
	{ GC2235_8BIT, 0x97, 0x03 }, /* crop win width 960 */
	{ GC2235_8BIT, 0x98, 0xc0 },
	/* mimp init */
	{ GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
	{ GC2235_8BIT, 0x01, 0x07 },
	{ GC2235_8BIT, 0x02, 0x11 },
	{ GC2235_8BIT, 0x03, 0x11 },
	{ GC2235_8BIT, 0x06, 0x80 },
	{ GC2235_8BIT, 0x11, 0x2b },
	/* set mipi buffer */
	{ GC2235_8BIT, 0x12, 0xb0 }, /* val_low = (width * 10 / 8) & 0xFF */
	{ GC2235_8BIT, 0x13, 0x04 }, /* val_high = (width * 10 / 8) >> 8 */

	{ GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
	{ GC2235_8BIT, 0x04, 0x10 },
	{ GC2235_8BIT, 0x05, 0x00 },
	{ GC2235_8BIT, 0x17, 0x01 },
	{ GC2235_8BIT, 0x22, 0x01 },
	{ GC2235_8BIT, 0x23, 0x05 },
	{ GC2235_8BIT, 0x24, 0x10 },
	{ GC2235_8BIT, 0x25, 0x10 },
	{ GC2235_8BIT, 0x26, 0x02 },
	{ GC2235_8BIT, 0x21, 0x10 },
	{ GC2235_8BIT, 0x29, 0x01 },
	{ GC2235_8BIT, 0x2a, 0x02 },
	{ GC2235_8BIT, 0x2b, 0x02 },
	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
	{ GC2235_TOK_TERM, 0, 0 }
};
#endif

static struct gc2235_reg const gc2235_1600_900_30fps[] =;

static struct gc2235_reg const gc2235_1616_1082_30fps[] =;

static struct gc2235_reg const gc2235_1616_1216_30fps[] =;

static struct gc2235_resolution gc2235_res_preview[] =;

#define N_RES_PREVIEW

/*
 * Disable non-preview configurations until the configuration selection is
 * improved.
 */
#if ENABLE_NON_PREVIEW
static struct gc2235_resolution gc2235_res_still[] = {
	{
		.desc = "gc2235_1600_900_30fps",
		.width = 1600,
		.height = 900,
		.pix_clk_freq = 30,
		.fps = 30,
		.used = 0,
		.pixels_per_line = 2132,
		.lines_per_frame = 1068,
		.skip_frames = 3,
		.regs = gc2235_1600_900_30fps,
	},
	{
		.desc = "gc2235_1600_1066_30fps",
		.width = 1616,
		.height = 1082,
		.pix_clk_freq = 30,
		.fps = 30,
		.used = 0,
		.pixels_per_line = 2132,
		.lines_per_frame = 1368,
		.skip_frames = 3,
		.regs = gc2235_1616_1082_30fps,
	},
	{
		.desc = "gc2235_1600_1200_30fps",
		.width = 1616,
		.height = 1216,
		.pix_clk_freq = 30,
		.fps = 30,
		.used = 0,
		.pixels_per_line = 2132,
		.lines_per_frame = 1368,
		.skip_frames = 3,
		.regs = gc2235_1616_1216_30fps,
	},

};

#define N_RES_STILL

static struct gc2235_resolution gc2235_res_video[] = {
	{
		.desc = "gc2235_1296_736_30fps",
		.width = 1296,
		.height = 736,
		.pix_clk_freq = 30,
		.fps = 30,
		.used = 0,
		.pixels_per_line = 1828,
		.lines_per_frame = 888,
		.skip_frames = 3,
		.regs = gc2235_1296_736_30fps,
	},
	{
		.desc = "gc2235_960_640_30fps",
		.width = 960,
		.height = 640,
		.pix_clk_freq = 30,
		.fps = 30,
		.used = 0,
		.pixels_per_line = 1492,
		.lines_per_frame = 792,
		.skip_frames = 3,
		.regs = gc2235_960_640_30fps,
	},

};

#define N_RES_VIDEO
#endif

static struct gc2235_resolution *gc2235_res =;
static unsigned long N_RES =;
#endif