linux/drivers/media/i2c/mt9t112.c

// SPDX-License-Identifier: GPL-2.0
/*
 * mt9t112 Camera Driver
 *
 * Copyright (C) 2018 Jacopo Mondi <[email protected]>
 *
 * Copyright (C) 2009 Renesas Solutions Corp.
 * Kuninori Morimoto <[email protected]>
 *
 * Based on ov772x driver, mt9m111 driver,
 *
 * Copyright (C) 2008 Kuninori Morimoto <[email protected]>
 * Copyright (C) 2008, Robert Jarzmik <[email protected]>
 * Copyright 2006-7 Jonathan Corbet <[email protected]>
 * Copyright (C) 2008 Magnus Damm
 * Copyright (C) 2008, Guennadi Liakhovetski <[email protected]>
 *
 * TODO: This driver lacks support for frame rate control due to missing
 *	 register level documentation and suitable hardware for testing.
 *	 v4l-utils compliance tools will report errors.
 */

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/v4l2-mediabus.h>
#include <linux/videodev2.h>

#include <media/i2c/mt9t112.h>
#include <media/v4l2-common.h>
#include <media/v4l2-image-sizes.h>
#include <media/v4l2-subdev.h>

/* you can check PLL/clock info */
/* #define EXT_CLOCK 24000000 */

/************************************************************************
 *			macro
 ***********************************************************************/
/*
 * frame size
 */
#define MAX_WIDTH
#define MAX_HEIGHT

/*
 * macro of read/write
 */
#define ECHECKER(ret, x)

#define mt9t112_reg_write(ret, client, a, b)
#define mt9t112_mcu_write(ret, client, a, b)

#define mt9t112_reg_mask_set(ret, client, a, b, c)
#define mt9t112_mcu_mask_set(ret, client, a, b, c)

#define mt9t112_reg_read(ret, client, a)

/*
 * Logical address
 */
#define _VAR(id, offset, base)
#define VAR(id, offset)
#define VAR8(id, offset)

/************************************************************************
 *			struct
 ***********************************************************************/
struct mt9t112_format {};

struct mt9t112_priv {};

/************************************************************************
 *			supported format
 ***********************************************************************/

static const struct mt9t112_format mt9t112_cfmts[] =;

/************************************************************************
 *			general function
 ***********************************************************************/
static struct mt9t112_priv *to_mt9t112(const struct i2c_client *client)
{}

static int __mt9t112_reg_read(const struct i2c_client *client, u16 command)
{}

static int __mt9t112_reg_write(const struct i2c_client *client,
			       u16 command, u16 data)
{}

static int __mt9t112_reg_mask_set(const struct i2c_client *client,
				  u16  command, u16  mask, u16  set)
{}

/* mcu access */
static int __mt9t112_mcu_read(const struct i2c_client *client, u16 command)
{}

static int __mt9t112_mcu_write(const struct i2c_client *client,
			       u16 command, u16 data)
{}

static int __mt9t112_mcu_mask_set(const struct i2c_client *client,
				  u16  command, u16  mask, u16  set)
{}

static int mt9t112_reset(const struct i2c_client *client)
{}

#ifndef EXT_CLOCK
#define CLOCK_INFO(a, b)
#else
#define CLOCK_INFO
static int mt9t112_clock_info(const struct i2c_client *client, u32 ext)
{
	int m, n, p1, p2, p3, p4, p5, p6, p7;
	u32 vco, clk;
	char *enable;

	ext /= 1000; /* kbyte order */

	mt9t112_reg_read(n, client, 0x0012);
	p1 = n & 0x000f;
	n = n >> 4;
	p2 = n & 0x000f;
	n = n >> 4;
	p3 = n & 0x000f;

	mt9t112_reg_read(n, client, 0x002a);
	p4 = n & 0x000f;
	n = n >> 4;
	p5 = n & 0x000f;
	n = n >> 4;
	p6 = n & 0x000f;

	mt9t112_reg_read(n, client, 0x002c);
	p7 = n & 0x000f;

	mt9t112_reg_read(n, client, 0x0010);
	m = n & 0x00ff;
	n = (n >> 8) & 0x003f;

	enable = ((ext < 6000) || (ext > 54000)) ? "X" : "";
	dev_dbg(&client->dev, "EXTCLK          : %10u K %s\n", ext, enable);

	vco = 2 * m * ext / (n + 1);
	enable = ((vco < 384000) || (vco > 768000)) ? "X" : "";
	dev_dbg(&client->dev, "VCO             : %10u K %s\n", vco, enable);

	clk = vco / (p1 + 1) / (p2 + 1);
	enable = (clk > 96000) ? "X" : "";
	dev_dbg(&client->dev, "PIXCLK          : %10u K %s\n", clk, enable);

	clk = vco / (p3 + 1);
	enable = (clk > 768000) ? "X" : "";
	dev_dbg(&client->dev, "MIPICLK         : %10u K %s\n", clk, enable);

	clk = vco / (p6 + 1);
	enable = (clk > 96000) ? "X" : "";
	dev_dbg(&client->dev, "MCU CLK         : %10u K %s\n", clk, enable);

	clk = vco / (p5 + 1);
	enable = (clk > 54000) ? "X" : "";
	dev_dbg(&client->dev, "SOC CLK         : %10u K %s\n", clk, enable);

	clk = vco / (p4 + 1);
	enable = (clk > 70000) ? "X" : "";
	dev_dbg(&client->dev, "Sensor CLK      : %10u K %s\n", clk, enable);

	clk = vco / (p7 + 1);
	dev_dbg(&client->dev, "External sensor : %10u K\n", clk);

	clk = ext / (n + 1);
	enable = ((clk < 2000) || (clk > 24000)) ? "X" : "";
	dev_dbg(&client->dev, "PFD             : %10u K %s\n", clk, enable);

	return 0;
}
#endif

static int mt9t112_set_a_frame_size(const struct i2c_client *client,
				    u16 width, u16 height)
{}

static int mt9t112_set_pll_dividers(const struct i2c_client *client,
				    u8 m, u8 n, u8 p1, u8 p2, u8 p3, u8 p4,
				    u8 p5, u8 p6, u8 p7)
{}

static int mt9t112_init_pll(const struct i2c_client *client)
{}

static int mt9t112_init_setting(const struct i2c_client *client)
{}

static int mt9t112_auto_focus_setting(const struct i2c_client *client)
{}

static int mt9t112_auto_focus_trigger(const struct i2c_client *client)
{}

static int mt9t112_init_camera(const struct i2c_client *client)
{}

/************************************************************************
 *			v4l2_subdev_core_ops
 ***********************************************************************/

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int mt9t112_g_register(struct v4l2_subdev *sd,
			      struct v4l2_dbg_register *reg)
{}

static int mt9t112_s_register(struct v4l2_subdev *sd,
			      const struct v4l2_dbg_register *reg)
{}
#endif

static int mt9t112_power_on(struct mt9t112_priv *priv)
{}

static int mt9t112_power_off(struct mt9t112_priv *priv)
{}

static int mt9t112_s_power(struct v4l2_subdev *sd, int on)
{}

static const struct v4l2_subdev_core_ops mt9t112_subdev_core_ops =;

/************************************************************************
 *			v4l2_subdev_video_ops
 **********************************************************************/
static int mt9t112_s_stream(struct v4l2_subdev *sd, int enable)
{}

static int mt9t112_set_params(struct mt9t112_priv *priv,
			      const struct v4l2_rect *rect,
			      u32 code)
{}

static int mt9t112_get_selection(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *sd_state,
				 struct v4l2_subdev_selection *sel)
{}

static int mt9t112_set_selection(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *sd_state,
				 struct v4l2_subdev_selection *sel)
{}

static int mt9t112_get_fmt(struct v4l2_subdev *sd,
			   struct v4l2_subdev_state *sd_state,
			   struct v4l2_subdev_format *format)
{}

static int mt9t112_s_fmt(struct v4l2_subdev *sd,
			 struct v4l2_mbus_framefmt *mf)
{}

static int mt9t112_set_fmt(struct v4l2_subdev *sd,
			   struct v4l2_subdev_state *sd_state,
			   struct v4l2_subdev_format *format)
{}

static int mt9t112_enum_mbus_code(struct v4l2_subdev *sd,
				  struct v4l2_subdev_state *sd_state,
				  struct v4l2_subdev_mbus_code_enum *code)
{}

static const struct v4l2_subdev_video_ops mt9t112_subdev_video_ops =;

static const struct v4l2_subdev_pad_ops mt9t112_subdev_pad_ops =;

/************************************************************************
 *			i2c driver
 ***********************************************************************/
static const struct v4l2_subdev_ops mt9t112_subdev_ops =;

static int mt9t112_camera_probe(struct i2c_client *client)
{}

static int mt9t112_probe(struct i2c_client *client)
{}

static void mt9t112_remove(struct i2c_client *client)
{}

static const struct i2c_device_id mt9t112_id[] =;
MODULE_DEVICE_TABLE(i2c, mt9t112_id);

static struct i2c_driver mt9t112_i2c_driver =;

module_i2c_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();