drivers/media/i2c/mt9m111.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/mt9m111.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/mt9m111.c- Extension
.c- Size
- 39246 bytes
- Lines
- 1407
- 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/videodev2.hlinux/slab.hlinux/i2c.hlinux/log2.hlinux/delay.hlinux/regulator/consumer.hlinux/v4l2-mediabus.hlinux/module.hlinux/property.hmedia/v4l2-async.hmedia/v4l2-common.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fwnode.h
Detected Declarations
struct mt9m111_contextstruct mt9m111_datafmtstruct mt9m111_mode_infostruct mt9m111enum mt9m111_mode_idfunction reg_page_map_setfunction mt9m111_reg_readfunction mt9m111_reg_writefunction mt9m111_reg_setfunction mt9m111_reg_clearfunction mt9m111_reg_maskfunction mt9m111_set_contextfunction mt9m111_setup_rect_ctxfunction mt9m111_setup_geometryfunction mt9m111_enablefunction mt9m111_resetfunction mt9m111_set_selectionfunction mt9m111_get_selectionfunction mt9m111_get_fmtfunction mt9m111_set_pixfmtfunction mt9m111_set_fmtfunction mt9m111_find_modefunction mt9m111_g_registerfunction mt9m111_s_registerfunction mt9m111_set_flipfunction mt9m111_get_global_gainfunction mt9m111_set_global_gainfunction mt9m111_set_autoexposurefunction mt9m111_set_autowhitebalancefunction mt9m111_set_test_patternfunction mt9m111_set_colorfxfunction mt9m111_s_ctrlfunction mt9m111_suspendfunction mt9m111_restore_statefunction mt9m111_resumefunction mt9m111_initfunction mt9m111_power_onfunction mt9m111_power_offfunction mt9m111_s_powerfunction mt9m111_get_frame_intervalfunction mt9m111_set_frame_intervalfunction mt9m111_enum_mbus_codefunction mt9m111_s_streamfunction mt9m111_init_statefunction mt9m111_get_mbus_configfunction mt9m111_video_probefunction mt9m111_probe_fwfunction mt9m111_probe
Annotated Snippet
struct mt9m111_context {
u16 read_mode;
u16 blanking_h;
u16 blanking_v;
u16 reducer_xzoom;
u16 reducer_yzoom;
u16 reducer_xsize;
u16 reducer_ysize;
u16 output_fmt_ctrl2;
u16 control;
};
static struct mt9m111_context context_a = {
.read_mode = MT9M111_READ_MODE_A,
.blanking_h = MT9M111_HORIZONTAL_BLANKING_A,
.blanking_v = MT9M111_VERTICAL_BLANKING_A,
.reducer_xzoom = MT9M111_REDUCER_XZOOM_A,
.reducer_yzoom = MT9M111_REDUCER_YZOOM_A,
.reducer_xsize = MT9M111_REDUCER_XSIZE_A,
.reducer_ysize = MT9M111_REDUCER_YSIZE_A,
.output_fmt_ctrl2 = MT9M111_OUTPUT_FORMAT_CTRL2_A,
.control = MT9M111_CTXT_CTRL_RESTART,
};
static struct mt9m111_context context_b = {
.read_mode = MT9M111_READ_MODE_B,
.blanking_h = MT9M111_HORIZONTAL_BLANKING_B,
.blanking_v = MT9M111_VERTICAL_BLANKING_B,
.reducer_xzoom = MT9M111_REDUCER_XZOOM_B,
.reducer_yzoom = MT9M111_REDUCER_YZOOM_B,
.reducer_xsize = MT9M111_REDUCER_XSIZE_B,
.reducer_ysize = MT9M111_REDUCER_YSIZE_B,
.output_fmt_ctrl2 = MT9M111_OUTPUT_FORMAT_CTRL2_B,
.control = MT9M111_CTXT_CTRL_RESTART |
MT9M111_CTXT_CTRL_DEFECTCOR_B | MT9M111_CTXT_CTRL_RESIZE_B |
MT9M111_CTXT_CTRL_CTRL2_B | MT9M111_CTXT_CTRL_GAMMA_B |
MT9M111_CTXT_CTRL_READ_MODE_B | MT9M111_CTXT_CTRL_VBLANK_SEL_B |
MT9M111_CTXT_CTRL_HBLANK_SEL_B,
};
/* MT9M111 has only one fixed colorspace per pixelcode */
struct mt9m111_datafmt {
u32 code;
enum v4l2_colorspace colorspace;
};
static const struct mt9m111_datafmt mt9m111_colour_fmts[] = {
{MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_BGR565_2X8_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_BGR565_2X8_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
};
enum mt9m111_mode_id {
MT9M111_MODE_SXGA_8FPS,
MT9M111_MODE_SXGA_15FPS,
MT9M111_MODE_QSXGA_30FPS,
MT9M111_NUM_MODES,
};
struct mt9m111_mode_info {
unsigned int sensor_w;
unsigned int sensor_h;
unsigned int max_image_w;
unsigned int max_image_h;
unsigned int max_fps;
unsigned int reg_val;
unsigned int reg_mask;
};
struct mt9m111 {
struct v4l2_subdev subdev;
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl *gain;
struct mt9m111_context *ctx;
struct v4l2_rect rect; /* cropping rectangle */
struct clk *clk;
unsigned int width; /* output */
unsigned int height; /* sizes */
struct v4l2_fract frame_interval;
const struct mt9m111_mode_info *current_mode;
struct mutex power_lock; /* lock to protect power_count */
Annotation
- Immediate include surface: `linux/clk.h`, `linux/videodev2.h`, `linux/slab.h`, `linux/i2c.h`, `linux/log2.h`, `linux/delay.h`, `linux/regulator/consumer.h`, `linux/v4l2-mediabus.h`.
- Detected declarations: `struct mt9m111_context`, `struct mt9m111_datafmt`, `struct mt9m111_mode_info`, `struct mt9m111`, `enum mt9m111_mode_id`, `function reg_page_map_set`, `function mt9m111_reg_read`, `function mt9m111_reg_write`, `function mt9m111_reg_set`, `function mt9m111_reg_clear`.
- 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.