#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/fwnode.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/i2c-mux.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <media/v4l2-cci.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>
#define MAX96714_DEVICE_ID …
#define MAX96714F_DEVICE_ID …
#define MAX96714_NPORTS …
#define MAX96714_PAD_SINK …
#define MAX96714_PAD_SOURCE …
#define MAX96714_REG13 …
#define MAX96714_DEV_REV …
#define MAX96714_DEV_REV_MASK …
#define MAX96714_LINK_LOCK …
#define MAX96714_LINK_LOCK_BIT …
#define MAX96714_IO_CHK0 …
#define MAX96714_PATTERN_CLK_FREQ …
#define MAX96714_VIDEO_RX8 …
#define MAX96714_VID_LOCK …
#define MAX96714_PATGEN_0 …
#define MAX96714_PATGEN_1 …
#define MAX96714_PATGEN_MODE …
#define MAX96714_PATGEN_VS_DLY …
#define MAX96714_PATGEN_VS_HIGH …
#define MAX96714_PATGEN_VS_LOW …
#define MAX96714_PATGEN_V2H …
#define MAX96714_PATGEN_HS_HIGH …
#define MAX96714_PATGEN_HS_LOW …
#define MAX96714_PATGEN_HS_CNT …
#define MAX96714_PATGEN_V2D …
#define MAX96714_PATGEN_DE_HIGH …
#define MAX96714_PATGEN_DE_LOW …
#define MAX96714_PATGEN_DE_CNT …
#define MAX96714_PATGEN_GRAD_INC …
#define MAX96714_PATGEN_CHKB_COLOR_A …
#define MAX96714_PATGEN_CHKB_COLOR_B …
#define MAX96714_PATGEN_CHKB_RPT_CNT_A …
#define MAX96714_PATGEN_CHKB_RPT_CNT_B …
#define MAX96714_PATGEN_CHKB_ALT …
#define MAX96714_BACKTOP25 …
#define CSI_DPLL_FREQ_MASK …
#define MAX96714_MIPI_PHY0 …
#define MAX96714_FORCE_CSI_OUT …
#define MAX96714_MIPI_STDBY_N …
#define MAX96714_MIPI_STDBY_MASK …
#define MAX96714_MIPI_LANE_MAP …
#define MAX96714_MIPI_POLARITY …
#define MAX96714_MIPI_POLARITY_MASK …
#define MAX96714_MIPI_LANE_CNT …
#define MAX96714_CSI2_LANE_CNT_MASK …
#define MAX96714_MIPI_TX52 …
#define MAX96714_TUN_EN …
#define MHZ(v) …
enum max96714_vpg_mode { … };
struct max96714_rxport { … };
struct max96714_txport { … };
struct max96714_priv { … };
static inline struct max96714_priv *sd_to_max96714(struct v4l2_subdev *sd)
{ … }
static int max96714_enable_tx_port(struct max96714_priv *priv)
{ … }
static int max96714_disable_tx_port(struct max96714_priv *priv)
{ … }
static bool max96714_tx_port_enabled(struct max96714_priv *priv)
{ … }
static int max96714_apply_patgen_timing(struct max96714_priv *priv,
struct v4l2_subdev_state *state)
{ … }
static int max96714_apply_patgen(struct max96714_priv *priv,
struct v4l2_subdev_state *state)
{ … }
static int max96714_s_ctrl(struct v4l2_ctrl *ctrl)
{ … }
static const char * const max96714_test_pattern[] = …;
static const struct v4l2_ctrl_ops max96714_ctrl_ops = …;
static int max96714_enable_streams(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
u32 source_pad, u64 streams_mask)
{ … }
static int max96714_disable_streams(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
u32 source_pad, u64 streams_mask)
{ … }
static int max96714_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
struct v4l2_subdev_format *format)
{ … }
static int _max96714_set_routing(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
enum v4l2_subdev_format_whence which,
struct v4l2_subdev_krouting *routing)
{ … }
static int max96714_set_routing(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
enum v4l2_subdev_format_whence which,
struct v4l2_subdev_krouting *routing)
{ … }
static int max96714_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{ … }
static const struct v4l2_subdev_pad_ops max96714_pad_ops = …;
static bool max96714_link_locked(struct max96714_priv *priv)
{ … }
static void max96714_link_status(struct max96714_priv *priv)
{ … }
static bool max96714_pipe_locked(struct max96714_priv *priv)
{ … }
static void max96714_pipe_status(struct max96714_priv *priv)
{ … }
static void max96714_csi_status(struct max96714_priv *priv)
{ … }
static int max96714_log_status(struct v4l2_subdev *sd)
{ … }
static const struct v4l2_subdev_core_ops max96714_subdev_core_ops = …;
static const struct v4l2_subdev_video_ops max96714_video_ops = …;
static const struct v4l2_subdev_internal_ops max96714_internal_ops = …;
static const struct v4l2_subdev_ops max96714_subdev_ops = …;
static const struct media_entity_operations max96714_entity_ops = …;
static int max96714_notify_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *subdev,
struct v4l2_async_connection *asd)
{ … }
static const struct v4l2_async_notifier_operations max96714_notify_ops = …;
static int max96714_v4l2_notifier_register(struct max96714_priv *priv)
{ … }
static int max96714_create_subdev(struct max96714_priv *priv)
{
struct device *dev = &priv->client->dev;
int ret;
v4l2_i2c_subdev_init(&priv->sd, priv->client, &max96714_subdev_ops);
priv->sd.internal_ops = &max96714_internal_ops;
v4l2_ctrl_handler_init(&priv->ctrl_handler, 1);
priv->sd.ctrl_handler = &priv->ctrl_handler;
v4l2_ctrl_new_int_menu(&priv->ctrl_handler, NULL, V4L2_CID_LINK_FREQ,
0, 0, &priv->tx_link_freq);
v4l2_ctrl_new_std_menu_items(&priv->ctrl_handler,
&max96714_ctrl_ops,
V4L2_CID_TEST_PATTERN,
ARRAY_SIZE(max96714_test_pattern) - 1,
0, 0, max96714_test_pattern);
if (priv->ctrl_handler.error) {
ret = priv->ctrl_handler.error;
goto err_free_ctrl;
}
priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_STREAMS;
priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
priv->sd.entity.ops = &max96714_entity_ops;
priv->pads[MAX96714_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
priv->pads[MAX96714_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
ret = media_entity_pads_init(&priv->sd.entity,
MAX96714_NPORTS,
priv->pads);
if (ret)
goto err_free_ctrl;
priv->sd.state_lock = priv->sd.ctrl_handler->lock;
ret = v4l2_subdev_init_finalize(&priv->sd);
if (ret)
goto err_entity_cleanup;
ret = max96714_v4l2_notifier_register(priv);
if (ret) {
dev_err(dev, "v4l2 subdev notifier register failed: %d\n", ret);
goto err_subdev_cleanup;
}
ret = v4l2_async_register_subdev(&priv->sd);
if (ret) {
dev_err(dev, "v4l2_async_register_subdev error: %d\n", ret);
goto err_unreg_notif;
}
return 0;
err_unreg_notif:
v4l2_async_nf_unregister(&priv->notifier);
v4l2_async_nf_cleanup(&priv->notifier);
err_subdev_cleanup:
v4l2_subdev_cleanup(&priv->sd);
err_entity_cleanup:
media_entity_cleanup(&priv->sd.entity);
err_free_ctrl:
v4l2_ctrl_handler_free(&priv->ctrl_handler);
return ret;
};
static void max96714_destroy_subdev(struct max96714_priv *priv)
{ … }
static int max96714_i2c_mux_select(struct i2c_mux_core *mux, u32 chan)
{ … }
static int max96714_i2c_mux_init(struct max96714_priv *priv)
{ … }
static int max96714_init_tx_port(struct max96714_priv *priv)
{ … }
static int max96714_rxport_enable_poc(struct max96714_priv *priv)
{ … }
static int max96714_rxport_disable_poc(struct max96714_priv *priv)
{ … }
static int max96714_parse_dt_txport(struct max96714_priv *priv)
{ … }
static int max96714_parse_dt_rxport(struct max96714_priv *priv)
{ … }
static int max96714_parse_dt(struct max96714_priv *priv)
{ … }
static int max96714_enable_core_hw(struct max96714_priv *priv)
{ … }
static void max96714_disable_core_hw(struct max96714_priv *priv)
{ … }
static int max96714_get_hw_resources(struct max96714_priv *priv)
{ … }
static int max96714_probe(struct i2c_client *client)
{ … }
static void max96714_remove(struct i2c_client *client)
{ … }
static const struct of_device_id max96714_of_ids[] = …;
MODULE_DEVICE_TABLE(of, max96714_of_ids);
static struct i2c_driver max96714_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;