linux/drivers/media/i2c/imx214.c

// SPDX-License-Identifier: GPL-2.0
/*
 * imx214.c - imx214 sensor driver
 *
 * Copyright 2018 Qtechnology A/S
 *
 * Ricardo Ribalda <[email protected]>
 */
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <media/media-entity.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>

#define IMX214_REG_MODE_SELECT
#define IMX214_MODE_STANDBY
#define IMX214_MODE_STREAMING

#define IMX214_DEFAULT_CLK_FREQ
#define IMX214_DEFAULT_LINK_FREQ
#define IMX214_DEFAULT_PIXEL_RATE
#define IMX214_FPS
#define IMX214_MBUS_CODE

/* Exposure control */
#define IMX214_REG_EXPOSURE
#define IMX214_EXPOSURE_MIN
#define IMX214_EXPOSURE_MAX
#define IMX214_EXPOSURE_STEP
#define IMX214_EXPOSURE_DEFAULT

/* IMX214 native and active pixel array size */
#define IMX214_NATIVE_WIDTH
#define IMX214_NATIVE_HEIGHT
#define IMX214_PIXEL_ARRAY_LEFT
#define IMX214_PIXEL_ARRAY_TOP
#define IMX214_PIXEL_ARRAY_WIDTH
#define IMX214_PIXEL_ARRAY_HEIGHT

static const char * const imx214_supply_name[] =;

#define IMX214_NUM_SUPPLIES

struct imx214 {};

struct reg_8 {};

enum {};

/*From imx214_mode_tbls.h*/
static const struct reg_8 mode_4096x2304[] =;

static const struct reg_8 mode_1920x1080[] =;

static const struct reg_8 mode_table_common[] =;

/*
 * Declare modes in order, from biggest
 * to smallest height.
 */
static const struct imx214_mode {} imx214_modes[] =;

static inline struct imx214 *to_imx214(struct v4l2_subdev *sd)
{}

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

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

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

static int imx214_enum_frame_size(struct v4l2_subdev *subdev,
				  struct v4l2_subdev_state *sd_state,
				  struct v4l2_subdev_frame_size_enum *fse)
{}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int imx214_s_register(struct v4l2_subdev *subdev,
			     const struct v4l2_dbg_register *reg)
{}

static int imx214_g_register(struct v4l2_subdev *subdev,
			     struct v4l2_dbg_register *reg)
{}
#endif

static const struct v4l2_subdev_core_ops imx214_core_ops =;

static struct v4l2_mbus_framefmt *
__imx214_get_pad_format(struct imx214 *imx214,
			struct v4l2_subdev_state *sd_state,
			unsigned int pad,
			enum v4l2_subdev_format_whence which)
{}

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

static struct v4l2_rect *
__imx214_get_pad_crop(struct imx214 *imx214,
		      struct v4l2_subdev_state *sd_state,
		      unsigned int pad, enum v4l2_subdev_format_whence which)
{}

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

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

static int imx214_entity_init_state(struct v4l2_subdev *subdev,
				    struct v4l2_subdev_state *sd_state)
{}

static int imx214_set_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops imx214_ctrl_ops =;

static int imx214_ctrls_init(struct imx214 *imx214)
{
	static const s64 link_freq[] = {
		IMX214_DEFAULT_LINK_FREQ
	};
	static const struct v4l2_area unit_size = {
		.width = 1120,
		.height = 1120,
	};
	struct v4l2_fwnode_device_properties props;
	struct v4l2_ctrl_handler *ctrl_hdlr;
	int ret;

	ret = v4l2_fwnode_device_parse(imx214->dev, &props);
	if (ret < 0)
		return ret;

	ctrl_hdlr = &imx214->ctrls;
	ret = v4l2_ctrl_handler_init(&imx214->ctrls, 6);
	if (ret)
		return ret;

	imx214->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, NULL,
					       V4L2_CID_PIXEL_RATE, 0,
					       IMX214_DEFAULT_PIXEL_RATE, 1,
					       IMX214_DEFAULT_PIXEL_RATE);

	imx214->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, NULL,
						   V4L2_CID_LINK_FREQ,
						   ARRAY_SIZE(link_freq) - 1,
						   0, link_freq);
	if (imx214->link_freq)
		imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;

	/*
	 * WARNING!
	 * Values obtained reverse engineering blobs and/or devices.
	 * Ranges and functionality might be wrong.
	 *
	 * Sony, please release some register set documentation for the
	 * device.
	 *
	 * Yours sincerely, Ricardo.
	 */
	imx214->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops,
					     V4L2_CID_EXPOSURE,
					     IMX214_EXPOSURE_MIN,
					     IMX214_EXPOSURE_MAX,
					     IMX214_EXPOSURE_STEP,
					     IMX214_EXPOSURE_DEFAULT);

	imx214->unit_size = v4l2_ctrl_new_std_compound(ctrl_hdlr,
				NULL,
				V4L2_CID_UNIT_CELL_SIZE,
				v4l2_ctrl_ptr_create((void *)&unit_size));

	v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx214_ctrl_ops, &props);

	ret = ctrl_hdlr->error;
	if (ret) {
		v4l2_ctrl_handler_free(ctrl_hdlr);
		dev_err(imx214->dev, "failed to add controls: %d\n", ret);
		return ret;
	}

	imx214->sd.ctrl_handler = ctrl_hdlr;

	return 0;
};

#define MAX_CMD
static int imx214_write_table(struct imx214 *imx214,
			      const struct reg_8 table[])
{}

static int imx214_start_streaming(struct imx214 *imx214)
{}

static int imx214_stop_streaming(struct imx214 *imx214)
{}

static int imx214_s_stream(struct v4l2_subdev *subdev, int enable)
{}

static int imx214_get_frame_interval(struct v4l2_subdev *subdev,
				     struct v4l2_subdev_state *sd_state,
				     struct v4l2_subdev_frame_interval *fival)
{}

static int imx214_enum_frame_interval(struct v4l2_subdev *subdev,
				struct v4l2_subdev_state *sd_state,
				struct v4l2_subdev_frame_interval_enum *fie)
{}

static const struct v4l2_subdev_video_ops imx214_video_ops =;

static const struct v4l2_subdev_pad_ops imx214_subdev_pad_ops =;

static const struct v4l2_subdev_ops imx214_subdev_ops =;

static const struct v4l2_subdev_internal_ops imx214_internal_ops =;

static const struct regmap_config sensor_regmap_config =;

static int imx214_get_regulators(struct device *dev, struct imx214 *imx214)
{}

static int imx214_parse_fwnode(struct device *dev)
{}

static int imx214_probe(struct i2c_client *client)
{}

static void imx214_remove(struct i2c_client *client)
{}

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

static const struct dev_pm_ops imx214_pm_ops =;

static struct i2c_driver imx214_i2c_driver =;

module_i2c_driver();

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