drivers/media/i2c/ov2732.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ov2732.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ov2732.c- Extension
.c- Size
- 21086 bytes
- Lines
- 791
- 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/clk.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/regulator/consumer.hmedia/v4l2-cci.hmedia/v4l2-common.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-fwnode.h
Detected Declarations
struct ov2732_modestruct ov2732function ov2732_power_onfunction ov2732_power_offfunction ov2732_identify_chipfunction ov2732_enum_mbus_codefunction ov2732_enum_frame_sizefunction ov2732_set_fmtfunction ov2732_get_selectionfunction ov2732_enable_streamsfunction ov2732_disable_streamsfunction ov2732_init_statefunction ov2732_set_ctrlfunction ov2732_init_controlsfunction ov2632_probe_dtfunction ov2732_get_regulatorsfunction ov2732_probefunction ov2732_remove
Annotated Snippet
struct ov2732_mode {
u32 width;
u32 height;
u32 vts;
};
static const struct ov2732_mode supported_modes[] = {
{
.width = 1920,
.height = 1080,
.vts = 1184,
},
};
struct ov2732 {
struct device *dev;
struct regmap *regmap;
struct media_pad pad;
struct v4l2_subdev sd;
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *exposure;
struct clk *xvclk;
u32 xvclk_freq;
struct gpio_desc *powerdown_gpio;
struct gpio_desc *reset_gpio;
struct regulator_bulk_data supplies[ARRAY_SIZE(ov2732_supply_names)];
};
#define to_ov2732(_sd) container_of(_sd, struct ov2732, sd)
static const s64 link_freq_menu_items[] = {
OV2732_LINK_FREQ_DEFAULT,
};
static const char * const ov2732_test_pattern_menu[] = {
"Disabled",
"Vertical Color Bar Type 1",
"Vertical Color Bar Type 2",
"Vertical Color Bar Type 3",
"Vertical Color Bar Type 4",
"Vertical Color Bar Type 5",
"Random",
"Color Squares",
"Black and White Squares",
};
static const int ov2732_test_pattern_val[] = {
OV2732_TEST_PATTERN_DISABLE,
OV2732_TEST_PATTERN_BAR1,
OV2732_TEST_PATTERN_BAR2,
OV2732_TEST_PATTERN_BAR3,
OV2732_TEST_PATTERN_BAR4,
OV2732_TEST_PATTERN_BAR5,
OV2732_TEST_PATTERN_RANDOM,
OV2732_TEST_PATTERN_SQUARES_C,
OV2732_TEST_PATTERN_SQUARES_BW,
};
static int ov2732_power_on(struct device *dev)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct ov2732 *ov2732 = to_ov2732(sd);
int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(ov2732_supply_names),
ov2732->supplies);
if (ret) {
dev_err(dev, "failed to enable regulators\n");
return ret;
}
ret = clk_prepare_enable(ov2732->xvclk);
if (ret) {
dev_err(dev, "failed to enable clock\n");
goto reg_off;
}
/* Wait 10ms before power up, as per datasheet. */
fsleep(10 * USEC_PER_MSEC);
gpiod_set_value_cansleep(ov2732->reset_gpio, 0);
gpiod_set_value_cansleep(ov2732->powerdown_gpio, 0);
/* Datasheet requires an 8192 cycles wait, but that isn't enough. */
fsleep(OV2732_DELAY_US(OV2732_POWER_UP_DELAY_CYCLES * 2));
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/of.h`, `linux/pm_runtime.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct ov2732_mode`, `struct ov2732`, `function ov2732_power_on`, `function ov2732_power_off`, `function ov2732_identify_chip`, `function ov2732_enum_mbus_code`, `function ov2732_enum_frame_size`, `function ov2732_set_fmt`, `function ov2732_get_selection`, `function ov2732_enable_streams`.
- 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.