drivers/media/i2c/adv7180.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/adv7180.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/adv7180.c- Extension
.c- Size
- 46310 bytes
- Lines
- 1676
- 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/mod_devicetable.hlinux/module.hlinux/init.hlinux/errno.hlinux/kernel.hlinux/interrupt.hlinux/i2c.hlinux/slab.hlinux/of.hlinux/gpio/consumer.hlinux/videodev2.hmedia/v4l2-ioctl.hmedia/v4l2-event.hmedia/v4l2-device.hmedia/v4l2-ctrls.hlinux/mutex.hlinux/delay.h
Detected Declarations
struct adv7180_statestruct adv7180_chip_infostruct adv7180_stateenum adv7182_input_typefunction adv7180_select_pagefunction adv7180_writefunction adv7180_readfunction adv7180_csi_writefunction adv7180_set_video_standardfunction adv7180_vpp_writefunction adv7180_set_powerfunction adv7180_std_to_v4l2function v4l2_std_to_adv7180function adv7180_status_to_v4l2function __adv7180_statusfunction adv7180_querystdfunction adv7180_s_routingfunction adv7180_g_input_statusfunction adv7180_program_stdfunction adv7180_s_stdfunction adv7180_g_stdfunction adv7180_get_frame_intervalfunction adv7180_set_power_pinfunction adv7180_set_reset_pinfunction adv7180_test_patternfunction adv7180_s_ctrlfunction adv7180_init_controlsfunction adv7180_exit_controlsfunction adv7180_enum_mbus_codefunction adv7180_mbus_fmtfunction adv7180_set_field_modefunction adv7180_get_pad_formatfunction adv7180_set_pad_formatfunction adv7180_init_statefunction adv7180_get_mbus_configfunction adv7180_get_skip_framesfunction adv7180_g_tvnormsfunction init_devicefunction adv7180_reset_devicefunction adv7180_s_streamfunction adv7180_subscribe_eventfunction adv7180_g_registerfunction adv7180_s_registerfunction adv7180_irqfunction adv7180_initfunction adv7180_set_stdfunction adv7180_select_inputfunction adv7182_init
Annotated Snippet
struct adv7180_chip_info {
unsigned int flags;
unsigned int valid_input_mask;
int (*set_std)(struct adv7180_state *st, unsigned int std);
int (*select_input)(struct adv7180_state *st, unsigned int input);
int (*init)(struct adv7180_state *state);
};
struct adv7180_state {
struct v4l2_ctrl_handler ctrl_hdl;
struct v4l2_subdev sd;
struct media_pad pad;
struct mutex mutex; /* mutual excl. when accessing chip */
int irq;
struct gpio_desc *pwdn_gpio;
struct gpio_desc *rst_gpio;
v4l2_std_id curr_norm;
bool streaming;
u8 input;
struct i2c_client *client;
unsigned int register_page;
struct i2c_client *csi_client;
struct i2c_client *vpp_client;
const struct adv7180_chip_info *chip_info;
enum v4l2_field field;
bool force_bt656_4;
};
#define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \
struct adv7180_state, \
ctrl_hdl)->sd)
static int adv7180_select_page(struct adv7180_state *state, unsigned int page)
{
if (state->register_page != page) {
i2c_smbus_write_byte_data(state->client, ADV7180_REG_CTRL,
page);
state->register_page = page;
}
return 0;
}
static int adv7180_write(struct adv7180_state *state, unsigned int reg,
unsigned int value)
{
lockdep_assert_held(&state->mutex);
adv7180_select_page(state, reg >> 8);
return i2c_smbus_write_byte_data(state->client, reg & 0xff, value);
}
static int adv7180_read(struct adv7180_state *state, unsigned int reg)
{
lockdep_assert_held(&state->mutex);
adv7180_select_page(state, reg >> 8);
return i2c_smbus_read_byte_data(state->client, reg & 0xff);
}
static int adv7180_csi_write(struct adv7180_state *state, unsigned int reg,
unsigned int value)
{
return i2c_smbus_write_byte_data(state->csi_client, reg, value);
}
static int adv7180_set_video_standard(struct adv7180_state *state,
unsigned int std)
{
return state->chip_info->set_std(state, std);
}
static int adv7180_vpp_write(struct adv7180_state *state, unsigned int reg,
unsigned int value)
{
return i2c_smbus_write_byte_data(state->vpp_client, reg, value);
}
static int adv7180_set_power(struct adv7180_state *state, bool on)
{
u8 val;
int ret;
if (on)
val = ADV7180_PWR_MAN_ON;
else
val = ADV7180_PWR_MAN_OFF;
ret = adv7180_write(state, ADV7180_REG_PWR_MAN, val);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/module.h`, `linux/init.h`, `linux/errno.h`, `linux/kernel.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/slab.h`.
- Detected declarations: `struct adv7180_state`, `struct adv7180_chip_info`, `struct adv7180_state`, `enum adv7182_input_type`, `function adv7180_select_page`, `function adv7180_write`, `function adv7180_read`, `function adv7180_csi_write`, `function adv7180_set_video_standard`, `function adv7180_vpp_write`.
- 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.