linux/drivers/media/i2c/ov4689.c

// SPDX-License-Identifier: GPL-2.0
/*
 * ov4689 driver
 *
 * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
 * Copyright (C) 2022, 2024 Mikhail Rudenko
 */

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

#define OV4689_REG_CTRL_MODE
#define OV4689_MODE_SW_STANDBY
#define OV4689_MODE_STREAMING

#define OV4689_REG_CHIP_ID
#define CHIP_ID

#define OV4689_REG_EXPOSURE
#define OV4689_EXPOSURE_MIN
#define OV4689_EXPOSURE_STEP

#define OV4689_REG_GAIN
#define OV4689_GAIN_STEP
#define OV4689_GAIN_DEFAULT

#define OV4689_REG_DIG_GAIN
#define OV4689_DIG_GAIN_MIN
#define OV4689_DIG_GAIN_MAX
#define OV4689_DIG_GAIN_STEP
#define OV4689_DIG_GAIN_DEFAULT

#define OV4689_REG_H_CROP_START
#define OV4689_REG_V_CROP_START
#define OV4689_REG_H_CROP_END
#define OV4689_REG_V_CROP_END
#define OV4689_REG_H_OUTPUT_SIZE
#define OV4689_REG_V_OUTPUT_SIZE

#define OV4689_REG_HTS
#define OV4689_HTS_DIVIDER
#define OV4689_HTS_MAX

#define OV4689_REG_VTS
#define OV4689_VTS_MAX

#define OV4689_REG_H_WIN_OFF
#define OV4689_REG_V_WIN_OFF

#define OV4689_REG_TIMING_FORMAT1
#define OV4689_REG_TIMING_FORMAT2
#define OV4689_TIMING_FLIP_MASK
#define OV4689_TIMING_FLIP_ARRAY
#define OV4689_TIMING_FLIP_DIGITAL
#define OV4689_TIMING_FLIP_BOTH

#define OV4689_REG_ANCHOR_LEFT_START
#define OV4689_ANCHOR_LEFT_START_DEF
#define OV4689_REG_ANCHOR_LEFT_END
#define OV4689_ANCHOR_LEFT_END_DEF
#define OV4689_REG_ANCHOR_RIGHT_START
#define OV4689_ANCHOR_RIGHT_START_DEF
#define OV4689_REG_ANCHOR_RIGHT_END
#define OV4689_ANCHOR_RIGHT_END_DEF

#define OV4689_REG_VFIFO_CTRL_01

#define OV4689_REG_WB_GAIN_RED
#define OV4689_REG_WB_GAIN_BLUE
#define OV4689_WB_GAIN_MIN
#define OV4689_WB_GAIN_MAX
#define OV4689_WB_GAIN_STEP
#define OV4689_WB_GAIN_DEFAULT

#define OV4689_REG_TEST_PATTERN
#define OV4689_TEST_PATTERN_ENABLE
#define OV4689_TEST_PATTERN_DISABLE

#define OV4689_LANES
#define OV4689_XVCLK_FREQ

#define OV4689_PIXEL_ARRAY_WIDTH
#define OV4689_PIXEL_ARRAY_HEIGHT
#define OV4689_DUMMY_ROWS
#define OV4689_DUMMY_COLUMNS

static const char *const ov4689_supply_names[] =;

enum ov4689_mode_id {};

struct ov4689_mode {};

struct ov4689 {};

#define to_ov4689(sd)

struct ov4689_gain_range {};

/*
 * Xclk 24Mhz
 * max_framerate 90fps
 * mipi_datarate per lane 1008Mbps
 */
static const struct cci_reg_sequence ov4689_2688x1520_regs[] =;

static const struct ov4689_mode supported_modes[] =;

static const u64 link_freq_menu_items[] =;

static const char *const ov4689_test_pattern_menu[] =;

/*
 * These coefficients are based on those used in Rockchip's camera
 * engine, with minor tweaks for continuity.
 */
static const struct ov4689_gain_range ov4689_gain_ranges[] =;

static void ov4689_fill_fmt(const struct ov4689_mode *mode,
			    struct v4l2_mbus_framefmt *fmt)
{}

static int ov4689_set_fmt(struct v4l2_subdev *sd,
			  struct v4l2_subdev_state *sd_state,
			  struct v4l2_subdev_format *fmt)
{}

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

static int ov4689_enum_frame_sizes(struct v4l2_subdev *sd,
				   struct v4l2_subdev_state *sd_state,
				   struct v4l2_subdev_frame_size_enum *fse)
{}

static int ov4689_enable_test_pattern(struct ov4689 *ov4689, u32 pattern)
{}

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

static int ov4689_setup_timings(struct ov4689 *ov4689)
{}

static int ov4689_setup_blc_anchors(struct ov4689 *ov4689)
{}

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

/* Calculate the delay in us by clock rate and clock cycles */
static inline u32 ov4689_cal_delay(struct ov4689 *ov4689, u32 cycles)
{}

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

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

static int ov4689_init_state(struct v4l2_subdev *sd,
			     struct v4l2_subdev_state *sd_state)
{}

static const struct dev_pm_ops ov4689_pm_ops =;

static const struct v4l2_subdev_video_ops ov4689_video_ops =;

static const struct v4l2_subdev_pad_ops ov4689_pad_ops =;

static const struct v4l2_subdev_internal_ops ov4689_internal_ops =;

static const struct v4l2_subdev_ops ov4689_subdev_ops =;

/*
 * Map userspace (logical) gain to sensor (physical) gain using
 * ov4689_gain_ranges table.
 */
static int ov4689_map_gain(struct ov4689 *ov4689, int logical_gain, int *result)
{}

static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops ov4689_ctrl_ops =;

static int ov4689_initialize_controls(struct ov4689 *ov4689)
{}

static int ov4689_check_sensor_id(struct ov4689 *ov4689,
				  struct i2c_client *client)
{}

static int ov4689_configure_regulators(struct ov4689 *ov4689)
{}

static u64 ov4689_check_link_frequency(struct v4l2_fwnode_endpoint *ep)
{}

static int ov4689_check_hwcfg(struct device *dev)
{}

static int ov4689_probe(struct i2c_client *client)
{}

static void ov4689_remove(struct i2c_client *client)
{}

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

static struct i2c_driver ov4689_i2c_driver =;

module_i2c_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();