drivers/media/i2c/tc358743.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/tc358743.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/tc358743.c- Extension
.c- Size
- 65397 bytes
- Lines
- 2386
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/module.hlinux/slab.hlinux/i2c.hlinux/clk.hlinux/delay.hlinux/gpio/consumer.hlinux/interrupt.hlinux/timer.hlinux/of_graph.hlinux/videodev2.hlinux/workqueue.hlinux/v4l2-dv-timings.hlinux/hdmi.hmedia/cec.hmedia/v4l2-dv-timings.hmedia/v4l2-device.hmedia/v4l2-ctrls.hmedia/v4l2-event.hmedia/v4l2-fwnode.hmedia/i2c/tc358743.htc358743_regs.h
Detected Declarations
struct tc358743_statefunction i2c_rdfunction i2c_wrfunction i2c_rdreg_errfunction i2c_rdregfunction i2c_wrregfunction i2c_rd8function i2c_wr8function i2c_wr8_and_orfunction i2c_rd16function i2c_rd16_errfunction i2c_wr16function i2c_wr16_and_orfunction i2c_rd32function i2c_wr32function is_hdmifunction tx_5v_power_presentfunction no_signalfunction no_syncfunction audio_presentfunction get_audio_sampling_ratefunction fpsfunction tc358743_get_detected_timingsfunction tc358743_delayed_work_enable_hotplugfunction tc358743_set_hdmi_hdcpfunction tc358743_disable_edidfunction tc358743_enable_edidfunction tc358743_erase_bksvfunction tc358743_debugfs_if_readfunction print_infoframesfunction tc358743_s_ctrl_detect_tx_5vfunction tc358743_s_ctrl_audio_sampling_ratefunction tc358743_s_ctrl_audio_presentfunction tc358743_update_controlsfunction tc358743_reset_phyfunction tc358743_resetfunction tc358743_sleep_modefunction enable_streamfunction tc358743_set_pllfunction tc358743_set_ref_clkfunction tc358743_set_csi_color_spacefunction tc358743_num_csi_lanes_neededfunction tc358743_set_csifunction tc358743_set_hdmi_phyfunction tc358743_set_hdmi_audiofunction tc358743_set_hdmi_info_frame_modefunction tc358743_initial_setupfunction tc358743_cec_adap_enable
Annotated Snippet
struct tc358743_state {
struct tc358743_platform_data pdata;
struct v4l2_mbus_config_mipi_csi2 bus;
struct v4l2_subdev sd;
struct media_pad pad;
struct v4l2_ctrl_handler hdl;
struct i2c_client *i2c_client;
/* CONFCTL is modified in ops and tc358743_hdmi_sys_int_handler */
struct mutex confctl_mutex;
/* controls */
struct v4l2_ctrl *detect_tx_5v_ctrl;
struct v4l2_ctrl *audio_sampling_rate_ctrl;
struct v4l2_ctrl *audio_present_ctrl;
struct delayed_work delayed_work_enable_hotplug;
struct timer_list timer;
struct work_struct work_i2c_poll;
/* debugfs */
struct dentry *debugfs_dir;
struct v4l2_debugfs_if *infoframes;
/* edid */
u8 edid_blocks_written;
struct v4l2_dv_timings timings;
u32 mbus_fmt_code;
u8 csi_lanes_in_use;
struct gpio_desc *reset_gpio;
struct cec_adapter *cec_adap;
};
static void tc358743_enable_interrupts(struct v4l2_subdev *sd,
bool cable_connected);
static int tc358743_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd);
static inline struct tc358743_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct tc358743_state, sd);
}
/* --------------- I2C --------------- */
static int i2c_rd(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n)
{
struct tc358743_state *state = to_state(sd);
struct i2c_client *client = state->i2c_client;
int err;
u8 buf[2] = { reg >> 8, reg & 0xff };
struct i2c_msg msgs[] = {
{
.addr = client->addr,
.flags = 0,
.len = 2,
.buf = buf,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = n,
.buf = values,
},
};
err = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (err != ARRAY_SIZE(msgs)) {
v4l2_err(sd, "%s: reading register 0x%x from 0x%x failed: %d\n",
__func__, reg, client->addr, err);
}
return err != ARRAY_SIZE(msgs);
}
static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n)
{
struct tc358743_state *state = to_state(sd);
struct i2c_client *client = state->i2c_client;
int err, i;
struct i2c_msg msg;
u8 data[I2C_MAX_XFER_SIZE];
if ((2 + n) > I2C_MAX_XFER_SIZE) {
n = I2C_MAX_XFER_SIZE - 2;
v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n",
reg, 2 + n);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/i2c.h`, `linux/clk.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`.
- Detected declarations: `struct tc358743_state`, `function i2c_rd`, `function i2c_wr`, `function i2c_rdreg_err`, `function i2c_rdreg`, `function i2c_wrreg`, `function i2c_rd8`, `function i2c_wr8`, `function i2c_wr8_and_or`, `function i2c_rd16`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.