linux/drivers/media/i2c/imx415.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Driver for the Sony IMX415 CMOS Image Sensor.
 *
 * Copyright (C) 2023 WolfVision GmbH.
 */

#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-cci.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>

#define IMX415_PIXEL_ARRAY_TOP
#define IMX415_PIXEL_ARRAY_LEFT
#define IMX415_PIXEL_ARRAY_WIDTH
#define IMX415_PIXEL_ARRAY_HEIGHT
#define IMX415_PIXEL_ARRAY_VBLANK

#define IMX415_NUM_CLK_PARAM_REGS

#define IMX415_MODE
#define IMX415_MODE_OPERATING
#define IMX415_MODE_STANDBY
#define IMX415_REGHOLD
#define IMX415_REGHOLD_INVALID
#define IMX415_REGHOLD_VALID
#define IMX415_XMSTA
#define IMX415_XMSTA_START
#define IMX415_XMSTA_STOP
#define IMX415_BCWAIT_TIME
#define IMX415_CPWAIT_TIME
#define IMX415_WINMODE
#define IMX415_ADDMODE
#define IMX415_REVERSE
#define IMX415_HREVERSE_SHIFT
#define IMX415_VREVERSE_SHIFT
#define IMX415_ADBIT
#define IMX415_MDBIT
#define IMX415_SYS_MODE
#define IMX415_OUTSEL
#define IMX415_DRV
#define IMX415_VMAX
#define IMX415_HMAX
#define IMX415_SHR0
#define IMX415_GAIN_PCG_0
#define IMX415_AGAIN_MIN
#define IMX415_AGAIN_MAX
#define IMX415_AGAIN_STEP
#define IMX415_BLKLEVEL
#define IMX415_BLKLEVEL_DEFAULT
#define IMX415_TPG_EN_DUOUT
#define IMX415_TPG_PATSEL_DUOUT
#define IMX415_TPG_COLORWIDTH
#define IMX415_TESTCLKEN_MIPI
#define IMX415_INCKSEL1
#define IMX415_INCKSEL2
#define IMX415_INCKSEL3
#define IMX415_INCKSEL4
#define IMX415_INCKSEL5
#define IMX415_DIG_CLP_MODE
#define IMX415_WRJ_OPEN
#define IMX415_SENSOR_INFO
#define IMX415_SENSOR_INFO_MASK
#define IMX415_CHIP_ID
#define IMX415_LANEMODE
#define IMX415_LANEMODE_2
#define IMX415_LANEMODE_4
#define IMX415_TXCLKESC_FREQ
#define IMX415_INCKSEL6
#define IMX415_TCLKPOST
#define IMX415_TCLKPREPARE
#define IMX415_TCLKTRAIL
#define IMX415_TCLKZERO
#define IMX415_THSPREPARE
#define IMX415_THSZERO
#define IMX415_THSTRAIL
#define IMX415_THSEXIT
#define IMX415_TLPX
#define IMX415_INCKSEL7

static const char *const imx415_supply_names[] =;

/*
 * The IMX415 data sheet uses lane rates but v4l2 uses link frequency to
 * describe MIPI CSI-2 speed. This driver uses lane rates wherever possible
 * and converts them to link frequencies by a factor of two when needed.
 */
static const s64 link_freq_menu_items[] =;

struct imx415_clk_params {};

/* INCK Settings - includes all lane rate and INCK dependent registers */
static const struct imx415_clk_params imx415_clk_params[] =;

/* all-pixel 2-lane 720 Mbps 15.74 Hz mode */
static const struct cci_reg_sequence imx415_mode_2_720[] =;

/* all-pixel 2-lane 1440 Mbps 30.01 Hz mode */
static const struct cci_reg_sequence imx415_mode_2_1440[] =;

/* all-pixel 4-lane 891 Mbps 30 Hz mode */
static const struct cci_reg_sequence imx415_mode_4_891[] =;

struct imx415_mode_reg_list {};

/*
 * Mode : number of lanes, lane rate and frame rate dependent settings
 *
 * pixel_rate and hmax_pix are needed to calculate hblank for the v4l2 ctrl
 * interface. These values can not be found in the data sheet and should be
 * treated as virtual values. Use following table when adding new modes.
 *
 * lane_rate  lanes    fps     hmax_pix   pixel_rate
 *
 *     594      2     10.000     4400       99000000
 *     891      2     15.000     4400      148500000
 *     720      2     15.748     4064      144000000
 *    1782      2     30.000     4400      297000000
 *    2079      2     30.000     4400      297000000
 *    1440      2     30.019     4510      304615385
 *
 *     594      4     20.000     5500      247500000
 *     594      4     25.000     4400      247500000
 *     720      4     25.000     4400      247500000
 *     720      4     30.019     4510      304615385
 *     891      4     30.000     4400      297000000
 *    1440      4     30.019     4510      304615385
 *    1440      4     60.038     4510      609230769
 *    1485      4     60.000     4400      594000000
 *    1782      4     60.000     4400      594000000
 *    2079      4     60.000     4400      594000000
 *    2376      4     90.164     4392      891000000
 */
struct imx415_mode {};

/* mode configs */
static const struct imx415_mode supported_modes[] =;

static const char *const imx415_test_pattern_menu[] =;

struct imx415 {};

/*
 * This table includes fixed register settings and a bunch of undocumented
 * registers that have to be set to another value than default.
 */
static const struct cci_reg_sequence imx415_init_table[] =;

static inline struct imx415 *to_imx415(struct v4l2_subdev *sd)
{}

static int imx415_set_testpattern(struct imx415 *sensor, int val)
{}

static int imx415_s_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops imx415_ctrl_ops =;

static int imx415_ctrls_init(struct imx415 *sensor)
{}

static int imx415_set_mode(struct imx415 *sensor, int mode)
{}

static int imx415_setup(struct imx415 *sensor, struct v4l2_subdev_state *state)
{}

static int imx415_wakeup(struct imx415 *sensor)
{}

static int imx415_stream_on(struct imx415 *sensor)
{}

static int imx415_stream_off(struct imx415 *sensor)
{}

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

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

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

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

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

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

static const struct v4l2_subdev_video_ops imx415_subdev_video_ops =;

static const struct v4l2_subdev_pad_ops imx415_subdev_pad_ops =;

static const struct v4l2_subdev_ops imx415_subdev_ops =;

static const struct v4l2_subdev_internal_ops imx415_internal_ops =;

static int imx415_subdev_init(struct imx415 *sensor)
{}

static void imx415_subdev_cleanup(struct imx415 *sensor)
{}

static int imx415_power_on(struct imx415 *sensor)
{}

static void imx415_power_off(struct imx415 *sensor)
{}

static int imx415_identify_model(struct imx415 *sensor)
{}

static int imx415_check_inck(unsigned long inck, u64 link_frequency)
{}

static int imx415_parse_hw_config(struct imx415 *sensor)
{}

static int imx415_probe(struct i2c_client *client)
{}

static void imx415_remove(struct i2c_client *client)
{}

static int imx415_runtime_resume(struct device *dev)
{}

static int imx415_runtime_suspend(struct device *dev)
{}

static DEFINE_RUNTIME_DEV_PM_OPS(imx415_pm_ops, imx415_runtime_suspend,
				 imx415_runtime_resume, NULL);

static const struct of_device_id imx415_of_match[] =;

MODULE_DEVICE_TABLE(of, imx415_of_match);

static struct i2c_driver imx415_driver =;

module_i2c_driver();

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