linux/drivers/media/i2c/imx296.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Driver for IMX296 CMOS Image Sensor from Sony
 *
 * Copyright 2019 Laurent Pinchart <[email protected]>
 */

#include <linux/clk.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/videodev2.h>

#include <media/v4l2-ctrls.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>

#define IMX296_PIXEL_ARRAY_WIDTH
#define IMX296_PIXEL_ARRAY_HEIGHT

#define IMX296_REG_8BIT(n)
#define IMX296_REG_16BIT(n)
#define IMX296_REG_24BIT(n)
#define IMX296_REG_SIZE_SHIFT
#define IMX296_REG_ADDR_MASK

#define IMX296_CTRL00
#define IMX296_CTRL00_STANDBY
#define IMX296_CTRL08
#define IMX296_CTRL08_REGHOLD
#define IMX296_CTRL0A
#define IMX296_CTRL0A_XMSTA
#define IMX296_CTRL0B
#define IMX296_CTRL0B_TRIGEN
#define IMX296_CTRL0D
#define IMX296_CTRL0D_WINMODE_ALL
#define IMX296_CTRL0D_WINMODE_FD_BINNING
#define IMX296_CTRL0D_HADD_ON_BINNING
#define IMX296_CTRL0D_SAT_CNT
#define IMX296_CTRL0E
#define IMX296_CTRL0E_VREVERSE
#define IMX296_CTRL0E_HREVERSE
#define IMX296_VMAX
#define IMX296_HMAX
#define IMX296_TMDCTRL
#define IMX296_TMDCTRL_LATCH
#define IMX296_TMDOUT
#define IMX296_TMDOUT_MASK
#define IMX296_WDSEL
#define IMX296_WDSEL_NORMAL
#define IMX296_WDSEL_MULTI_2
#define IMX296_WDSEL_MULTI_4
#define IMX296_BLKLEVELAUTO
#define IMX296_BLKLEVELAUTO_ON
#define IMX296_BLKLEVELAUTO_OFF
#define IMX296_SST
#define IMX296_SST_EN
#define IMX296_CTRLTOUT
#define IMX296_CTRLTOUT_TOUT1SEL_LOW
#define IMX296_CTRLTOUT_TOUT1SEL_PULSE
#define IMX296_CTRLTOUT_TOUT2SEL_LOW
#define IMX296_CTRLTOUT_TOUT2SEL_PULSE
#define IMX296_CTRLTRIG
#define IMX296_CTRLTRIG_TOUT1_SEL_LOW
#define IMX296_CTRLTRIG_TOUT1_SEL_PULSE1
#define IMX296_CTRLTRIG_TOUT2_SEL_LOW
#define IMX296_CTRLTRIG_TOUT2_SEL_PULSE2
#define IMX296_SYNCSEL
#define IMX296_SYNCSEL_NORMAL
#define IMX296_SYNCSEL_HIZ
#define IMX296_PULSE1
#define IMX296_PULSE1_EN_NOR
#define IMX296_PULSE1_EN_TRIG
#define IMX296_PULSE1_POL_HIGH
#define IMX296_PULSE1_POL_LOW
#define IMX296_PULSE1_UP
#define IMX296_PULSE1_DN
#define IMX296_PULSE2
#define IMX296_PULSE2_EN_NOR
#define IMX296_PULSE2_EN_TRIG
#define IMX296_PULSE2_POL_HIGH
#define IMX296_PULSE2_POL_LOW
#define IMX296_PULSE2_UP
#define IMX296_PULSE2_DN
#define IMX296_INCKSEL(n)
#define IMX296_SHS1
#define IMX296_SHS2
#define IMX296_SHS3
#define IMX296_SHS4
#define IMX296_VBLANKLP
#define IMX296_VBLANKLP_NORMAL
#define IMX296_VBLANKLP_LOW_POWER
#define IMX296_EXP_CNT
#define IMX296_EXP_CNT_RESET
#define IMX296_EXP_MAX
#define IMX296_VINT
#define IMX296_VINT_EN
#define IMX296_LOWLAGTRG
#define IMX296_LOWLAGTRG_FAST
#define IMX296_I2CCTRL
#define IMX296_I2CCTRL_I2CACKEN

#define IMX296_SENSOR_INFO
#define IMX296_SENSOR_INFO_MONO
#define IMX296_SENSOR_INFO_IMX296LQ
#define IMX296_SENSOR_INFO_IMX296LL
#define IMX296_S_SHSA
#define IMX296_S_SHSB
/*
 * Registers 0x31c8 to 0x31cd, 0x31d0 to 0x31d5, 0x31e2, 0x31e3, 0x31ea and
 * 0x31eb are related to exposure mode but otherwise not documented.
 */

#define IMX296_GAINCTRL
#define IMX296_GAINCTRL_WD_GAIN_MODE_NORMAL
#define IMX296_GAINCTRL_WD_GAIN_MODE_MULTI
#define IMX296_GAIN
#define IMX296_GAIN_MIN
#define IMX296_GAIN_MAX
#define IMX296_GAIN1
#define IMX296_GAIN2
#define IMX296_GAIN3
#define IMX296_GAINDLY
#define IMX296_GAINDLY_NONE
#define IMX296_GAINDLY_1FRAME
#define IMX296_PGCTRL
#define IMX296_PGCTRL_REGEN
#define IMX296_PGCTRL_THRU
#define IMX296_PGCTRL_CLKEN
#define IMX296_PGCTRL_MODE(n)
#define IMX296_PGHPOS
#define IMX296_PGVPOS
#define IMX296_PGHPSTEP
#define IMX296_PGVPSTEP
#define IMX296_PGHPNUM
#define IMX296_PGVPNUM
#define IMX296_PGDATA1
#define IMX296_PGDATA2
#define IMX296_PGHGSTEP
#define IMX296_BLKLEVEL

#define IMX296_FID0_ROI
#define IMX296_FID0_ROIH1ON
#define IMX296_FID0_ROIV1ON
#define IMX296_FID0_ROIPH1
#define IMX296_FID0_ROIPV1
#define IMX296_FID0_ROIWH1
#define IMX296_FID0_ROIWH1_MIN
#define IMX296_FID0_ROIWV1
#define IMX296_FID0_ROIWV1_MIN

#define IMX296_CM_HSST_STARTTMG
#define IMX296_CM_HSST_ENDTMG
#define IMX296_DA_HSST_STARTTMG
#define IMX296_DA_HSST_ENDTMG
#define IMX296_LM_HSST_STARTTMG
#define IMX296_LM_HSST_ENDTMG
#define IMX296_SST_SIEASTA1_SET
#define IMX296_SST_SIEASTA1PRE_1U
#define IMX296_SST_SIEASTA1PRE_1D
#define IMX296_SST_SIEASTA1PRE_2U
#define IMX296_SST_SIEASTA1PRE_2D
#define IMX296_HSST
#define IMX296_HSST_EN

#define IMX296_CKREQSEL
#define IMX296_CKREQSEL_HS
#define IMX296_GTTABLENUM
#define IMX296_CTRL418C

struct imx296_clk_params {};

static const struct imx296_clk_params imx296_clk_params[] =;

static const char * const imx296_supply_names[] =;

struct imx296 {};

static inline struct imx296 *to_imx296(struct v4l2_subdev *sd)
{}

static int imx296_read(struct imx296 *sensor, u32 addr)
{}

static int imx296_write(struct imx296 *sensor, u32 addr, u32 value, int *err)
{}

static int imx296_power_on(struct imx296 *sensor)
{}

static void imx296_power_off(struct imx296 *sensor)
{}

/* -----------------------------------------------------------------------------
 * Controls
 */

static const char * const imx296_test_pattern_menu[] =;

static int imx296_s_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops imx296_ctrl_ops =;

static int imx296_ctrls_init(struct imx296 *sensor)
{}

/* -----------------------------------------------------------------------------
 * V4L2 Subdev Operations
 */

/*
 * This table is extracted from vendor data that is entirely undocumented. The
 * first register write is required to activate the CSI-2 output. The other
 * entries may or may not be optional?
 */
static const struct {} imx296_init_table[] =;

static int imx296_setup(struct imx296 *sensor, struct v4l2_subdev_state *state)
{}

static int imx296_stream_on(struct imx296 *sensor)
{}

static int imx296_stream_off(struct imx296 *sensor)
{}

static int imx296_s_stream(struct v4l2_subdev *sd, int enable)
{}

static int imx296_enum_mbus_code(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *state,
				 struct v4l2_subdev_mbus_code_enum *code)
{}

static int imx296_enum_frame_size(struct v4l2_subdev *sd,
				  struct v4l2_subdev_state *state,
				  struct v4l2_subdev_frame_size_enum *fse)
{}

static int imx296_set_format(struct v4l2_subdev *sd,
			     struct v4l2_subdev_state *state,
			     struct v4l2_subdev_format *fmt)
{}

static int imx296_get_selection(struct v4l2_subdev *sd,
				struct v4l2_subdev_state *state,
				struct v4l2_subdev_selection *sel)
{}

static int imx296_set_selection(struct v4l2_subdev *sd,
				struct v4l2_subdev_state *state,
				struct v4l2_subdev_selection *sel)
{}

static int imx296_init_state(struct v4l2_subdev *sd,
			     struct v4l2_subdev_state *state)
{}

static const struct v4l2_subdev_video_ops imx296_subdev_video_ops =;

static const struct v4l2_subdev_pad_ops imx296_subdev_pad_ops =;

static const struct v4l2_subdev_ops imx296_subdev_ops =;

static const struct v4l2_subdev_internal_ops imx296_internal_ops =;

static int imx296_subdev_init(struct imx296 *sensor)
{}

static void imx296_subdev_cleanup(struct imx296 *sensor)
{}

/* -----------------------------------------------------------------------------
 * Power management
 */

static int __maybe_unused imx296_runtime_resume(struct device *dev)
{}

static int __maybe_unused imx296_runtime_suspend(struct device *dev)
{}

static const struct dev_pm_ops imx296_pm_ops =;

/* -----------------------------------------------------------------------------
 * Probe & Remove
 */

static int imx296_read_temperature(struct imx296 *sensor, int *temp)
{}

static int imx296_identify_model(struct imx296 *sensor)
{}

static const struct regmap_config imx296_regmap_config =;

static int imx296_probe(struct i2c_client *client)
{}

static void imx296_remove(struct i2c_client *client)
{}

static const struct of_device_id imx296_of_match[] =;
MODULE_DEVICE_TABLE(of, imx296_of_match);

static struct i2c_driver imx296_i2c_driver =;

module_i2c_driver();

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