drivers/media/i2c/ds90ub913.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ds90ub913.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ds90ub913.c- Extension
.c- Size
- 21795 bytes
- Lines
- 902
- 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/bitfield.hlinux/clk-provider.hlinux/clk.hlinux/delay.hlinux/gpio/driver.hlinux/i2c-atr.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/property.hlinux/regmap.hmedia/i2c/ds90ub9xx.hmedia/v4l2-fwnode.hmedia/v4l2-mediabus.hmedia/v4l2-subdev.h
Detected Declarations
struct ub913_datastruct ub913_format_infofunction ub913_readfunction ub913_writefunction ub913_update_bitsfunction ub913_gpio_get_directionfunction ub913_gpio_direction_outfunction ub913_gpio_setfunction ub913_gpio_of_xlatefunction ub913_gpiochip_probefunction ub913_gpiochip_removefunction ub913_enable_streamsfunction ub913_disable_streamsfunction _ub913_set_routingfunction for_each_active_routefunction ub913_set_routingfunction ub913_set_fmtfunction ub913_init_statefunction ub913_log_statusfunction ub913_notify_boundfunction ub913_v4l2_notifier_registerfunction ub913_v4l2_nf_unregisterfunction ub913_register_clkoutfunction ub913_i2c_master_initfunction ub913_add_i2c_adapterfunction ub913_parse_dtfunction ub913_hw_initfunction ub913_subdev_initfunction ub913_subdev_uninitfunction ub913_probefunction ub913_remove
Annotated Snippet
struct ub913_data {
struct i2c_client *client;
struct regmap *regmap;
struct clk *clkin;
struct gpio_chip gpio_chip;
struct v4l2_subdev sd;
struct media_pad pads[2];
struct v4l2_async_notifier notifier;
struct v4l2_subdev *source_sd;
u16 source_sd_pad;
u64 enabled_source_streams;
struct clk_hw *clkout_clk_hw;
struct ds90ub9xx_platform_data *plat_data;
bool pclk_polarity_rising;
};
static inline struct ub913_data *sd_to_ub913(struct v4l2_subdev *sd)
{
return container_of(sd, struct ub913_data, sd);
}
struct ub913_format_info {
u32 incode;
u32 outcode;
};
static const struct ub913_format_info ub913_formats[] = {
/* Only RAW10 with 8-bit payload is supported at the moment */
{ .incode = MEDIA_BUS_FMT_YUYV8_2X8, .outcode = MEDIA_BUS_FMT_YUYV8_1X16 },
{ .incode = MEDIA_BUS_FMT_UYVY8_2X8, .outcode = MEDIA_BUS_FMT_UYVY8_1X16 },
{ .incode = MEDIA_BUS_FMT_VYUY8_2X8, .outcode = MEDIA_BUS_FMT_VYUY8_1X16 },
{ .incode = MEDIA_BUS_FMT_YVYU8_2X8, .outcode = MEDIA_BUS_FMT_YVYU8_1X16 },
};
static const struct ub913_format_info *ub913_find_format(u32 incode)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(ub913_formats); i++) {
if (ub913_formats[i].incode == incode)
return &ub913_formats[i];
}
return NULL;
}
static int ub913_read(const struct ub913_data *priv, u8 reg, u8 *val,
int *err)
{
unsigned int v;
int ret;
if (err && *err)
return *err;
ret = regmap_read(priv->regmap, reg, &v);
if (ret) {
dev_err(&priv->client->dev,
"Cannot read register 0x%02x: %d!\n", reg, ret);
goto out;
}
*val = v;
out:
if (ret && err)
*err = ret;
return ret;
}
static int ub913_write(const struct ub913_data *priv, u8 reg, u8 val,
int *err)
{
int ret;
if (err && *err)
return *err;
ret = regmap_write(priv->regmap, reg, val);
if (ret < 0)
dev_err(&priv->client->dev,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk-provider.h`, `linux/clk.h`, `linux/delay.h`, `linux/gpio/driver.h`, `linux/i2c-atr.h`, `linux/i2c.h`, `linux/kernel.h`.
- Detected declarations: `struct ub913_data`, `struct ub913_format_info`, `function ub913_read`, `function ub913_write`, `function ub913_update_bits`, `function ub913_gpio_get_direction`, `function ub913_gpio_direction_out`, `function ub913_gpio_set`, `function ub913_gpio_of_xlate`, `function ub913_gpiochip_probe`.
- 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.