drivers/media/i2c/mt9v111.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/mt9v111.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/mt9v111.c- Extension
.c- Size
- 32515 bytes
- Lines
- 1283
- 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.
- 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/of.hlinux/slab.hlinux/videodev2.hlinux/v4l2-mediabus.hlinux/module.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-fwnode.hmedia/v4l2-image-sizes.hmedia/v4l2-subdev.h
Detected Declarations
struct mt9v111_devfunction __mt9v111_readfunction __mt9v111_writefunction __mt9v111_addr_space_selectfunction mt9v111_readfunction mt9v111_writefunction mt9v111_updatefunction __mt9v111_power_onfunction __mt9v111_power_offfunction __mt9v111_hw_resetfunction __mt9v111_sw_resetfunction mt9v111_calc_frame_ratefunction mt9v111_hw_configfunction mt9v111_s_powerfunction mt9v111_s_streamfunction mt9v111_set_frame_intervalfunction mt9v111_get_frame_intervalfunction mt9v111_enum_mbus_codefunction mt9v111_enum_frame_intervalfunction mt9v111_enum_frame_sizefunction mt9v111_get_formatfunction mt9v111_set_formatfunction mt9v111_init_statefunction mt9v111_s_ctrlfunction mt9v111_chip_probefunction mt9v111_probefunction mt9v111_remove
Annotated Snippet
struct mt9v111_dev {
struct device *dev;
struct i2c_client *client;
u8 addr_space;
struct v4l2_subdev sd;
struct media_pad pad;
struct v4l2_ctrl *auto_awb;
struct v4l2_ctrl *auto_exp;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl_handler ctrls;
/* Output image format and sizes. */
struct v4l2_mbus_framefmt fmt;
unsigned int fps;
/* Protects power up/down sequences. */
struct mutex pwr_mutex;
int pwr_count;
/* Protects stream on/off sequences. */
struct mutex stream_mutex;
bool streaming;
/* Flags to mark HW settings as not yet applied. */
bool pending;
/* Clock provider and system clock frequency. */
struct clk *clk;
u32 sysclk;
struct gpio_desc *oe;
struct gpio_desc *standby;
struct gpio_desc *reset;
};
#define sd_to_mt9v111(__sd) container_of((__sd), struct mt9v111_dev, sd)
/*
* mt9v111_mbus_fmt - List all media bus formats supported by the driver.
*
* Only list the media bus code here. The image sizes are freely configurable
* in the pixel array sizes range.
*
* The desired frame interval, in the supported frame interval range, is
* obtained by configuring blanking as the sensor does not have a PLL but
* only a fixed clock divider that generates the output pixel clock.
*/
static struct mt9v111_mbus_fmt {
u32 code;
} mt9v111_formats[] = {
{
.code = MEDIA_BUS_FMT_UYVY8_2X8,
},
{
.code = MEDIA_BUS_FMT_YUYV8_2X8,
},
{
.code = MEDIA_BUS_FMT_VYUY8_2X8,
},
{
.code = MEDIA_BUS_FMT_YVYU8_2X8,
},
};
static u32 mt9v111_frame_intervals[] = {5, 10, 15, 20, 30};
/*
* mt9v111_frame_sizes - List sensor's supported resolutions.
*
* Resolution generated through decimation in the IFP block from the
* full VGA pixel array.
*/
static struct v4l2_rect mt9v111_frame_sizes[] = {
{
.width = 640,
.height = 480,
},
{
.width = 352,
.height = 288
},
{
.width = 320,
.height = 240,
},
{
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/of.h`, `linux/slab.h`, `linux/videodev2.h`, `linux/v4l2-mediabus.h`.
- Detected declarations: `struct mt9v111_dev`, `function __mt9v111_read`, `function __mt9v111_write`, `function __mt9v111_addr_space_select`, `function mt9v111_read`, `function mt9v111_write`, `function mt9v111_update`, `function __mt9v111_power_on`, `function __mt9v111_power_off`, `function __mt9v111_hw_reset`.
- 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.
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.