drivers/media/i2c/lm3560.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/lm3560.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/lm3560.c- Extension
.c- Size
- 18545 bytes
- Lines
- 730
- 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/bitmap.hlinux/delay.hlinux/module.hlinux/gpio/consumer.hlinux/i2c.hlinux/slab.hlinux/mod_devicetable.hlinux/mutex.hlinux/pm_runtime.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/videodev2.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-subdev.h
Detected Declarations
struct lm3560_flash_configstruct lm3560_flashenum lm3560_led_idenum lm3560_peak_currentenum led_enablefunction lm3560_mode_ctrlfunction lm3560_enable_ctrlfunction lm3560_torch_brt_ctrlfunction lm3560_flash_brt_ctrlfunction lm3560_get_ctrlfunction lm3560_set_ctrlfunction lm3560_led1_get_ctrlfunction lm3560_led1_set_ctrlfunction lm3560_led0_get_ctrlfunction lm3560_led0_set_ctrlfunction lm3560_init_controlsfunction lm3560_subdev_initfunction lm3560_init_devicefunction lm3560_power_offfunction lm3560_power_onfunction lm3560_subdev_cleanupfunction for_each_set_bitfunction lm3560_probefunction device_for_each_child_node_scopedfunction lm3560_remove
Annotated Snippet
struct lm3560_flash_config {
u32 flash_brt_min_ua;
u32 flash_brt_max_ua;
u32 flash_brt_step_ua;
u32 torch_brt_min_ua;
u32 torch_brt_max_ua;
u32 torch_brt_step_ua;
};
/**
* struct lm3560_flash
*
* @dev: pointer to &struct device
* @regmap: reg. map for i2c
* @lock: muxtex for serial access.
* @hwen_gpio: line connected to HWEN pin
* @vin_supply: line connected to IN supply (2.5V - 5.5V)
* @led_mode: V4L2 LED mode
* @ctrls_led: V4L2 controls
* @subdev_led: V4L2 subdev
* @led_id: LED status holder
* @peak: peak current
* @max_flash_timeout: flash timeout
* @max_flash_brt: flash mode led brightness
* @max_torch_brt: torch mode led brightness
* @config: device specific current configuration
*/
struct lm3560_flash {
struct device *dev;
struct regmap *regmap;
struct mutex lock;
struct gpio_desc *hwen_gpio;
struct regulator *vin_supply;
enum v4l2_flash_led_mode led_mode;
struct v4l2_ctrl_handler ctrls_led[LM3560_LED_MAX];
struct v4l2_subdev subdev_led[LM3560_LED_MAX];
DECLARE_BITMAP(led_id, LM3560_LED_MAX);
enum lm3560_peak_current peak;
u32 max_flash_timeout;
u32 max_flash_brt[LM3560_LED_MAX];
u32 max_torch_brt[LM3560_LED_MAX];
const struct lm3560_flash_config *config;
};
#define to_lm3560_flash(_ctrl, _no) \
container_of(_ctrl->handler, struct lm3560_flash, ctrls_led[_no])
/* enable mode control */
static int lm3560_mode_ctrl(struct lm3560_flash *flash)
{
int rval = -EINVAL;
switch (flash->led_mode) {
case V4L2_FLASH_LED_MODE_NONE:
rval = regmap_update_bits(flash->regmap,
REG_ENABLE, 0x03, MODE_SHDN);
break;
case V4L2_FLASH_LED_MODE_TORCH:
rval = regmap_update_bits(flash->regmap,
REG_ENABLE, 0x03, MODE_TORCH);
break;
case V4L2_FLASH_LED_MODE_FLASH:
rval = regmap_update_bits(flash->regmap,
REG_ENABLE, 0x03, MODE_FLASH);
break;
}
return rval;
}
/* led1/2 enable/disable */
static int lm3560_enable_ctrl(struct lm3560_flash *flash,
enum lm3560_led_id led_no, bool on)
{
int rval;
if (led_no == LM3560_LED0) {
if (on)
rval = regmap_update_bits(flash->regmap,
REG_ENABLE, 0x08, 0x08);
else
rval = regmap_update_bits(flash->regmap,
REG_ENABLE, 0x08, 0x00);
} else {
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/delay.h`, `linux/module.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/slab.h`, `linux/mod_devicetable.h`, `linux/mutex.h`.
- Detected declarations: `struct lm3560_flash_config`, `struct lm3560_flash`, `enum lm3560_led_id`, `enum lm3560_peak_current`, `enum led_enable`, `function lm3560_mode_ctrl`, `function lm3560_enable_ctrl`, `function lm3560_torch_brt_ctrl`, `function lm3560_flash_brt_ctrl`, `function lm3560_get_ctrl`.
- 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.