#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/units.h>
#include <linux/unaligned.h>
#include <media/mipi-csi2.h>
#include <media/v4l2-async.h>
#include <media/v4l2-cci.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>
#define VGXY61_REG_MODEL_ID …
#define VG5661_MODEL_ID …
#define VG5761_MODEL_ID …
#define VGXY61_REG_REVISION …
#define VGXY61_REG_FWPATCH_REVISION …
#define VGXY61_REG_FWPATCH_START_ADDR …
#define VGXY61_REG_SYSTEM_FSM …
#define VGXY61_SYSTEM_FSM_SW_STBY …
#define VGXY61_SYSTEM_FSM_STREAMING …
#define VGXY61_REG_NVM …
#define VGXY61_NVM_OK …
#define VGXY61_REG_STBY …
#define VGXY61_STBY_NO_REQ …
#define VGXY61_STBY_REQ_TMP_READ …
#define VGXY61_REG_STREAMING …
#define VGXY61_STREAMING_NO_REQ …
#define VGXY61_STREAMING_REQ_STOP …
#define VGXY61_STREAMING_REQ_START …
#define VGXY61_REG_EXT_CLOCK …
#define VGXY61_REG_CLK_PLL_PREDIV …
#define VGXY61_REG_CLK_SYS_PLL_MULT …
#define VGXY61_REG_GPIO_0_CTRL …
#define VGXY61_REG_GPIO_1_CTRL …
#define VGXY61_REG_GPIO_2_CTRL …
#define VGXY61_REG_GPIO_3_CTRL …
#define VGXY61_REG_SIGNALS_POLARITY_CTRL …
#define VGXY61_REG_LINE_LENGTH …
#define VGXY61_REG_ORIENTATION …
#define VGXY61_REG_VT_CTRL …
#define VGXY61_REG_FORMAT_CTRL …
#define VGXY61_REG_OIF_CTRL …
#define VGXY61_REG_OIF_ROI0_CTRL …
#define VGXY61_REG_ROI0_START_H …
#define VGXY61_REG_ROI0_START_V …
#define VGXY61_REG_ROI0_END_H …
#define VGXY61_REG_ROI0_END_V …
#define VGXY61_REG_PATGEN_CTRL …
#define VGXY61_PATGEN_LONG_ENABLE …
#define VGXY61_PATGEN_SHORT_ENABLE …
#define VGXY61_PATGEN_LONG_TYPE_SHIFT …
#define VGXY61_PATGEN_SHORT_TYPE_SHIFT …
#define VGXY61_REG_FRAME_CONTENT_CTRL …
#define VGXY61_REG_COARSE_EXPOSURE_LONG …
#define VGXY61_REG_COARSE_EXPOSURE_SHORT …
#define VGXY61_REG_ANALOG_GAIN …
#define VGXY61_REG_DIGITAL_GAIN_LONG …
#define VGXY61_REG_DIGITAL_GAIN_SHORT …
#define VGXY61_REG_FRAME_LENGTH …
#define VGXY61_REG_SIGNALS_CTRL …
#define VGXY61_SIGNALS_GPIO_ID_SHIFT …
#define VGXY61_REG_READOUT_CTRL …
#define VGXY61_REG_HDR_CTRL …
#define VGXY61_REG_PATGEN_LONG_DATA_GR …
#define VGXY61_REG_PATGEN_LONG_DATA_R …
#define VGXY61_REG_PATGEN_LONG_DATA_B …
#define VGXY61_REG_PATGEN_LONG_DATA_GB …
#define VGXY61_REG_PATGEN_SHORT_DATA_GR …
#define VGXY61_REG_PATGEN_SHORT_DATA_R …
#define VGXY61_REG_PATGEN_SHORT_DATA_B …
#define VGXY61_REG_PATGEN_SHORT_DATA_GB …
#define VGXY61_REG_BYPASS_CTRL …
#define VGX661_WIDTH …
#define VGX661_HEIGHT …
#define VGX761_WIDTH …
#define VGX761_HEIGHT …
#define VGX661_DEFAULT_MODE …
#define VGX761_DEFAULT_MODE …
#define VGX661_SHORT_ROT_TERM …
#define VGX761_SHORT_ROT_TERM …
#define VGXY61_EXPOS_ROT_TERM …
#define VGXY61_WRITE_MULTIPLE_CHUNK_MAX …
#define VGXY61_NB_GPIOS …
#define VGXY61_NB_POLARITIES …
#define VGXY61_FRAME_LENGTH_DEF …
#define VGXY61_MIN_FRAME_LENGTH …
#define VGXY61_MIN_EXPOSURE …
#define VGXY61_HDR_LINEAR_RATIO …
#define VGXY61_TIMEOUT_MS …
#define VGXY61_MEDIA_BUS_FMT_DEF …
#define VGXY61_FWPATCH_REVISION_MAJOR …
#define VGXY61_FWPATCH_REVISION_MINOR …
#define VGXY61_FWPATCH_REVISION_MICRO …
static const u8 patch_array[] = …;
static const char * const vgxy61_test_pattern_menu[] = …;
static const char * const vgxy61_hdr_mode_menu[] = …;
static const char * const vgxy61_supply_name[] = …;
static const s64 link_freq[] = …;
enum vgxy61_bin_mode { … };
enum vgxy61_hdr_mode { … };
enum vgxy61_strobe_mode { … };
struct vgxy61_mode_info { … };
struct vgxy61_fmt_desc { … };
static const struct vgxy61_fmt_desc vgxy61_supported_codes[] = …;
static const struct vgxy61_mode_info vgx661_mode_data[] = …;
static const struct vgxy61_mode_info vgx761_mode_data[] = …;
struct vgxy61_dev { … };
static u8 get_bpp_by_code(__u32 code)
{ … }
static u8 get_data_type_by_code(__u32 code)
{ … }
static void compute_pll_parameters_by_freq(u32 freq, u8 *prediv, u8 *mult)
{ … }
static s32 get_pixel_rate(struct vgxy61_dev *sensor)
{ … }
static inline struct vgxy61_dev *to_vgxy61_dev(struct v4l2_subdev *sd)
{ … }
static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
{ … }
static unsigned int get_chunk_size(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_write_array(struct vgxy61_dev *sensor, u32 reg,
unsigned int nb, const u8 *array)
{ … }
static int vgxy61_poll_reg(struct vgxy61_dev *sensor, u32 reg, u8 poll_val,
unsigned int timeout_ms)
{ … }
static int vgxy61_wait_state(struct vgxy61_dev *sensor, int state,
unsigned int timeout_ms)
{ … }
static int vgxy61_check_bw(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_apply_exposure(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_get_regulators(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_apply_reset(struct vgxy61_dev *sensor)
{ … }
static void vgxy61_fill_framefmt(struct vgxy61_dev *sensor,
const struct vgxy61_mode_info *mode,
struct v4l2_mbus_framefmt *fmt, u32 code)
{ … }
static int vgxy61_try_fmt_internal(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *fmt,
const struct vgxy61_mode_info **new_mode)
{ … }
static int vgxy61_get_selection(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_selection *sel)
{ … }
static int vgxy61_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{ … }
static int vgxy61_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *format)
{ … }
static u16 vgxy61_get_vblank_min(struct vgxy61_dev *sensor,
enum vgxy61_hdr_mode hdr)
{ … }
static int vgxy61_enum_frame_size(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_size_enum *fse)
{ … }
static int vgxy61_update_analog_gain(struct vgxy61_dev *sensor, u32 target)
{ … }
static int vgxy61_apply_digital_gain(struct vgxy61_dev *sensor,
u32 digital_gain)
{ … }
static int vgxy61_update_digital_gain(struct vgxy61_dev *sensor, u32 target)
{ … }
static int vgxy61_apply_patgen(struct vgxy61_dev *sensor, u32 index)
{ … }
static int vgxy61_update_patgen(struct vgxy61_dev *sensor, u32 pattern)
{ … }
static int vgxy61_apply_gpiox_strobe_mode(struct vgxy61_dev *sensor,
enum vgxy61_strobe_mode mode,
unsigned int idx)
{ … }
static int vgxy61_update_gpios_strobe_mode(struct vgxy61_dev *sensor,
enum vgxy61_hdr_mode hdr)
{ … }
static int vgxy61_update_gpios_strobe_polarity(struct vgxy61_dev *sensor,
bool polarity)
{ … }
static u32 vgxy61_get_expo_long_max(struct vgxy61_dev *sensor,
unsigned int short_expo_ratio)
{ … }
static int vgxy61_update_exposure(struct vgxy61_dev *sensor, u16 new_expo_long,
enum vgxy61_hdr_mode hdr)
{ … }
static int vgxy61_apply_framelength(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_update_vblank(struct vgxy61_dev *sensor, u16 vblank,
enum vgxy61_hdr_mode hdr)
{ … }
static int vgxy61_apply_hdr(struct vgxy61_dev *sensor,
enum vgxy61_hdr_mode index)
{ … }
static int vgxy61_update_hdr(struct vgxy61_dev *sensor,
enum vgxy61_hdr_mode index)
{ … }
static int vgxy61_apply_settings(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_stream_enable(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_stream_disable(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_s_stream(struct v4l2_subdev *sd, int enable)
{ … }
static int vgxy61_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *format)
{ … }
static int vgxy61_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state)
{ … }
static int vgxy61_s_ctrl(struct v4l2_ctrl *ctrl)
{ … }
static const struct v4l2_ctrl_ops vgxy61_ctrl_ops = …;
static int vgxy61_init_controls(struct vgxy61_dev *sensor)
{ … }
static const struct v4l2_subdev_core_ops vgxy61_core_ops = …;
static const struct v4l2_subdev_video_ops vgxy61_video_ops = …;
static const struct v4l2_subdev_pad_ops vgxy61_pad_ops = …;
static const struct v4l2_subdev_ops vgxy61_subdev_ops = …;
static const struct v4l2_subdev_internal_ops vgxy61_internal_ops = …;
static const struct media_entity_operations vgxy61_subdev_entity_ops = …;
static int vgxy61_tx_from_ep(struct vgxy61_dev *sensor,
struct fwnode_handle *handle)
{ … }
static int vgxy61_configure(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_patch(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_detect_cut_version(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_detect(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_power_on(struct device *dev)
{ … }
static int vgxy61_power_off(struct device *dev)
{ … }
static void vgxy61_fill_sensor_param(struct vgxy61_dev *sensor)
{ … }
static int vgxy61_probe(struct i2c_client *client)
{ … }
static void vgxy61_remove(struct i2c_client *client)
{ … }
static const struct of_device_id vgxy61_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, vgxy61_dt_ids);
static const struct dev_pm_ops vgxy61_pm_ops = …;
static struct i2c_driver vgxy61_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;