drivers/staging/media/max96712/max96712.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/max96712/max96712.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/max96712/max96712.c- Extension
.c- Size
- 12482 bytes
- Lines
- 488
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/delay.hlinux/i2c.hlinux/module.hlinux/of_graph.hlinux/regmap.hmedia/v4l2-ctrls.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct max96712_infostruct max96712_privenum max96712_patternfunction max96712_writefunction max96712_update_bitsfunction max96712_write_bulkfunction max96712_write_bulk_valuefunction max96712_resetfunction max96712_mipi_enablefunction max96712_mipi_configurefunction max96712_pattern_enablefunction max96712_s_streamfunction max96712_init_statefunction max96712_s_ctrlfunction max96712_v4l2_registerfunction max96712_parse_dtfunction max96712_probefunction max96712_remove
Annotated Snippet
struct max96712_info {
unsigned int dpllfreq;
bool have_debug_extra;
};
struct max96712_priv {
struct i2c_client *client;
struct regmap *regmap;
struct gpio_desc *gpiod_pwdn;
const struct max96712_info *info;
bool cphy;
struct v4l2_mbus_config_mipi_csi2 mipi;
struct v4l2_subdev sd;
struct v4l2_ctrl_handler ctrl_handler;
struct media_pad pads[1];
enum max96712_pattern pattern;
};
static int max96712_write(struct max96712_priv *priv, unsigned int reg, u8 val)
{
int ret;
ret = regmap_write(priv->regmap, reg, val);
if (ret)
dev_err(&priv->client->dev, "write 0x%04x failed\n", reg);
return ret;
}
static int max96712_update_bits(struct max96712_priv *priv, unsigned int reg,
u8 mask, u8 val)
{
int ret;
ret = regmap_update_bits(priv->regmap, reg, mask, val);
if (ret)
dev_err(&priv->client->dev, "update 0x%04x failed\n", reg);
return ret;
}
static int max96712_write_bulk(struct max96712_priv *priv, unsigned int reg,
const void *val, size_t val_count)
{
int ret;
ret = regmap_bulk_write(priv->regmap, reg, val, val_count);
if (ret)
dev_err(&priv->client->dev, "bulk write 0x%04x failed\n", reg);
return ret;
}
static int max96712_write_bulk_value(struct max96712_priv *priv,
unsigned int reg, unsigned int val,
size_t val_count)
{
unsigned int i;
u8 values[4];
for (i = 1; i <= val_count; i++)
values[i - 1] = (val >> ((val_count - i) * 8)) & 0xff;
return max96712_write_bulk(priv, reg, &values, val_count);
}
static void max96712_reset(struct max96712_priv *priv)
{
max96712_update_bits(priv, 0x13, 0x40, 0x40);
msleep(20);
}
static void max96712_mipi_enable(struct max96712_priv *priv, bool enable)
{
if (enable) {
max96712_update_bits(priv, 0x40b, 0x02, 0x02);
max96712_update_bits(priv, 0x8a0, 0x80, 0x80);
} else {
max96712_update_bits(priv, 0x8a0, 0x80, 0x00);
max96712_update_bits(priv, 0x40b, 0x02, 0x00);
}
}
static void max96712_mipi_configure(struct max96712_priv *priv)
{
unsigned int i;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/module.h`, `linux/of_graph.h`, `linux/regmap.h`, `media/v4l2-ctrls.h`, `media/v4l2-fwnode.h`, `media/v4l2-subdev.h`.
- Detected declarations: `struct max96712_info`, `struct max96712_priv`, `enum max96712_pattern`, `function max96712_write`, `function max96712_update_bits`, `function max96712_write_bulk`, `function max96712_write_bulk_value`, `function max96712_reset`, `function max96712_mipi_enable`, `function max96712_mipi_configure`.
- Atlas domain: Driver Families / drivers/staging.
- 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.