drivers/media/i2c/mt9t112.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/mt9t112.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/mt9t112.c- Extension
.c- Size
- 28508 bytes
- Lines
- 1130
- 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/init.hlinux/module.hlinux/slab.hlinux/v4l2-mediabus.hlinux/videodev2.hmedia/i2c/mt9t112.hmedia/v4l2-common.hmedia/v4l2-image-sizes.hmedia/v4l2-subdev.h
Detected Declarations
struct mt9t112_formatstruct mt9t112_privfunction __mt9t112_reg_readfunction __mt9t112_reg_writefunction __mt9t112_reg_mask_setfunction __mt9t112_mcu_readfunction __mt9t112_mcu_writefunction __mt9t112_mcu_mask_setfunction mt9t112_resetfunction mt9t112_clock_infofunction mt9t112_set_a_frame_sizefunction mt9t112_set_pll_dividersfunction mt9t112_init_pllfunction mt9t112_init_settingfunction mt9t112_auto_focus_settingfunction mt9t112_auto_focus_triggerfunction mt9t112_init_camerafunction mt9t112_g_registerfunction mt9t112_s_registerfunction mt9t112_power_onfunction mt9t112_power_offfunction mt9t112_s_powerfunction mt9t112_s_streamfunction mt9t112_set_paramsfunction mt9t112_get_selectionfunction mt9t112_set_selectionfunction mt9t112_get_fmtfunction mt9t112_s_fmtfunction mt9t112_set_fmtfunction mt9t112_enum_mbus_codefunction mt9t112_camera_probefunction mt9t112_probefunction mt9t112_remove
Annotated Snippet
struct mt9t112_format {
u32 code;
enum v4l2_colorspace colorspace;
u16 fmt;
u16 order;
};
struct mt9t112_priv {
struct v4l2_subdev subdev;
struct mt9t112_platform_data *info;
struct i2c_client *client;
struct v4l2_rect frame;
struct clk *clk;
struct gpio_desc *standby_gpio;
const struct mt9t112_format *format;
int num_formats;
bool init_done;
};
/************************************************************************
* supported format
***********************************************************************/
static const struct mt9t112_format mt9t112_cfmts[] = {
{
.code = MEDIA_BUS_FMT_UYVY8_2X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.fmt = 1,
.order = 0,
}, {
.code = MEDIA_BUS_FMT_VYUY8_2X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.fmt = 1,
.order = 1,
}, {
.code = MEDIA_BUS_FMT_YUYV8_2X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.fmt = 1,
.order = 2,
}, {
.code = MEDIA_BUS_FMT_YVYU8_2X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.fmt = 1,
.order = 3,
}, {
.code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE,
.colorspace = V4L2_COLORSPACE_SRGB,
.fmt = 8,
.order = 2,
}, {
.code = MEDIA_BUS_FMT_RGB565_2X8_LE,
.colorspace = V4L2_COLORSPACE_SRGB,
.fmt = 4,
.order = 2,
},
};
/************************************************************************
* general function
***********************************************************************/
static struct mt9t112_priv *to_mt9t112(const struct i2c_client *client)
{
return container_of(i2c_get_clientdata(client),
struct mt9t112_priv,
subdev);
}
static int __mt9t112_reg_read(const struct i2c_client *client, u16 command)
{
struct i2c_msg msg[2];
u8 buf[2];
int ret;
command = swab16(command);
msg[0].addr = client->addr;
msg[0].flags = 0;
msg[0].len = 2;
msg[0].buf = (u8 *)&command;
msg[1].addr = client->addr;
msg[1].flags = I2C_M_RD;
msg[1].len = 2;
msg[1].buf = buf;
/*
* If return value of this function is < 0, it means error, else,
* below 16bit is valid data.
*/
ret = i2c_transfer(client->adapter, msg, 2);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/init.h`, `linux/module.h`, `linux/slab.h`, `linux/v4l2-mediabus.h`.
- Detected declarations: `struct mt9t112_format`, `struct mt9t112_priv`, `function __mt9t112_reg_read`, `function __mt9t112_reg_write`, `function __mt9t112_reg_mask_set`, `function __mt9t112_mcu_read`, `function __mt9t112_mcu_write`, `function __mt9t112_mcu_mask_set`, `function mt9t112_reset`, `function mt9t112_clock_info`.
- 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.