drivers/media/i2c/max96717.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/max96717.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/max96717.c- Extension
.c- Size
- 29935 bytes
- Lines
- 1105
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/clk.hlinux/clk-provider.hlinux/delay.hlinux/gpio/driver.hlinux/i2c-mux.hlinux/i2c.hlinux/property.hlinux/regmap.hmedia/v4l2-cci.hmedia/v4l2-ctrls.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct max96717_privstruct max96717_pll_predef_freqenum max96717_vpg_modefunction max96717_i2c_mux_selectfunction max96717_i2c_mux_initfunction max96717_start_csifunction max96717_apply_patgen_timingfunction max96717_apply_patgenfunction max96717_s_ctrlfunction max96717_gpiochip_getfunction max96717_gpiochip_setfunction max96717_gpio_get_directionfunction max96717_gpio_direction_outfunction max96717_gpio_direction_infunction max96717_gpiochip_probefunction _max96717_set_routingfunction max96717_set_routingfunction max96717_set_fmtfunction max96717_init_statefunction max96717_pipe_pclkdetfunction max96717_log_statusfunction max96717_enable_streamsfunction max96717_disable_streamsfunction max96717_notify_boundfunction max96717_v4l2_notifier_registerfunction max96717_subdev_initfunction max96717_subdev_uninitfunction max96717_clk_recalc_ratefunction max96717_clk_find_best_indexfunction max96717_clk_determine_ratefunction max96717_clk_set_ratefunction max96717_clk_preparefunction max96717_clk_unpreparefunction max96717_register_clkoutfunction max96717_init_csi_lanesfunction max96717_hw_initfunction max96717_parse_dtfunction max96717_probefunction max96717_remove
Annotated Snippet
struct max96717_priv {
struct i2c_client *client;
struct regmap *regmap;
struct i2c_mux_core *mux;
struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
struct v4l2_subdev sd;
struct media_pad pads[MAX96717_PORTS];
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_async_notifier notifier;
struct v4l2_subdev *source_sd;
u16 source_sd_pad;
u64 enabled_source_streams;
u8 pll_predef_index;
struct clk_hw clk_hw;
struct gpio_chip gpio_chip;
enum max96717_vpg_mode pattern;
};
static inline struct max96717_priv *sd_to_max96717(struct v4l2_subdev *sd)
{
return container_of(sd, struct max96717_priv, sd);
}
static inline struct max96717_priv *clk_hw_to_max96717(struct clk_hw *hw)
{
return container_of(hw, struct max96717_priv, clk_hw);
}
static int max96717_i2c_mux_select(struct i2c_mux_core *mux, u32 chan)
{
return 0;
}
static int max96717_i2c_mux_init(struct max96717_priv *priv)
{
priv->mux = i2c_mux_alloc(priv->client->adapter, &priv->client->dev,
1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE,
max96717_i2c_mux_select, NULL);
if (!priv->mux)
return -ENOMEM;
return i2c_mux_add_adapter(priv->mux, 0, 0);
}
static inline int max96717_start_csi(struct max96717_priv *priv, bool start)
{
return cci_update_bits(priv->regmap, MAX96717_FRONTOP0,
MAX96717_START_PORT_B,
start ? MAX96717_START_PORT_B : 0, NULL);
}
static int max96717_apply_patgen_timing(struct max96717_priv *priv,
struct v4l2_subdev_state *state)
{
struct v4l2_mbus_framefmt *fmt =
v4l2_subdev_state_get_format(state, MAX96717_PAD_SOURCE);
const u32 h_active = fmt->width;
const u32 h_fp = 88;
const u32 h_sw = 44;
const u32 h_bp = 148;
u32 h_tot;
const u32 v_active = fmt->height;
const u32 v_fp = 4;
const u32 v_sw = 5;
const u32 v_bp = 36;
u32 v_tot;
int ret = 0;
h_tot = h_active + h_fp + h_sw + h_bp;
v_tot = v_active + v_fp + v_sw + v_bp;
/* 75 Mhz pixel clock */
cci_update_bits(priv->regmap, MAX96717_VTX1,
MAX96717_PATTERN_CLK_FREQ, 0xa, &ret);
dev_info(&priv->client->dev, "height: %d width: %d\n", fmt->height,
fmt->width);
cci_write(priv->regmap, MAX96717_VTX_VS_DLY, 0, &ret);
cci_write(priv->regmap, MAX96717_VTX_VS_HIGH, v_sw * h_tot, &ret);
cci_write(priv->regmap, MAX96717_VTX_VS_LOW,
(v_active + v_fp + v_bp) * h_tot, &ret);
cci_write(priv->regmap, MAX96717_VTX_HS_HIGH, h_sw, &ret);
cci_write(priv->regmap, MAX96717_VTX_HS_LOW, h_active + h_fp + h_bp,
&ret);
cci_write(priv->regmap, MAX96717_VTX_V2D,
h_tot * (v_sw + v_bp) + (h_sw + h_bp), &ret);
cci_write(priv->regmap, MAX96717_VTX_HS_CNT, v_tot, &ret);
cci_write(priv->regmap, MAX96717_VTX_DE_HIGH, h_active, &ret);
cci_write(priv->regmap, MAX96717_VTX_DE_LOW, h_fp + h_sw + h_bp,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/gpio/driver.h`, `linux/i2c-mux.h`, `linux/i2c.h`, `linux/property.h`.
- Detected declarations: `struct max96717_priv`, `struct max96717_pll_predef_freq`, `enum max96717_vpg_mode`, `function max96717_i2c_mux_select`, `function max96717_i2c_mux_init`, `function max96717_start_csi`, `function max96717_apply_patgen_timing`, `function max96717_apply_patgen`, `function max96717_s_ctrl`, `function max96717_gpiochip_get`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.