drivers/media/v4l2-core/v4l2-flash-led-class.c
Source file repositories/reference/linux-study-clean/drivers/media/v4l2-core/v4l2-flash-led-class.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/v4l2-core/v4l2-flash-led-class.c- Extension
.c- Size
- 20522 bytes
- Lines
- 746
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/led-class-flash.hlinux/module.hlinux/mutex.hlinux/property.hlinux/slab.hlinux/types.hmedia/v4l2-flash-led-class.h
Detected Declarations
enum ctrl_init_data_idfunction __intensity_to_led_brightnessfunction __led_brightness_to_intensityfunction v4l2_flash_set_led_brightnessfunction v4l2_flash_update_led_brightnessfunction v4l2_flash_g_volatile_ctrlfunction __software_strobe_mode_inactivefunction v4l2_flash_s_ctrlfunction __lfs_to_v4l2_ctrl_configfunction __fill_ctrl_init_datafunction v4l2_flash_init_controlsfunction __sync_device_with_v4l2_controlsfunction v4l2_flash_openfunction v4l2_flash_closefunction v4l2_flash_releaseexport v4l2_flash_initexport v4l2_flash_indicator_initexport v4l2_flash_release
Annotated Snippet
switch (c->val) {
case V4L2_FLASH_LED_MODE_NONE:
led_set_brightness_sync(led_cdev, LED_OFF);
return led_set_flash_strobe(fled_cdev, false);
case V4L2_FLASH_LED_MODE_FLASH:
/* Turn the torch LED off */
led_set_brightness_sync(led_cdev, LED_OFF);
if (ctrls[STROBE_SOURCE]) {
external_strobe = (ctrls[STROBE_SOURCE]->val ==
V4L2_FLASH_STROBE_SOURCE_EXTERNAL);
ret = call_flash_op(v4l2_flash,
external_strobe_set,
external_strobe);
}
return ret;
case V4L2_FLASH_LED_MODE_TORCH:
if (ctrls[STROBE_SOURCE]) {
ret = call_flash_op(v4l2_flash,
external_strobe_set,
false);
if (ret < 0)
return ret;
}
/* Stop flash strobing */
ret = led_set_flash_strobe(fled_cdev, false);
if (ret < 0)
return ret;
return v4l2_flash_set_led_brightness(v4l2_flash,
ctrls[TORCH_INTENSITY]);
}
break;
case V4L2_CID_FLASH_STROBE_SOURCE:
external_strobe = (c->val == V4L2_FLASH_STROBE_SOURCE_EXTERNAL);
/*
* For some hardware arrangements setting strobe source may
* affect torch mode. Therefore, if not in the flash mode,
* cache only this setting. It will be applied upon switching
* to flash mode.
*/
if (ctrls[LED_MODE]->val != V4L2_FLASH_LED_MODE_FLASH)
return 0;
return call_flash_op(v4l2_flash, external_strobe_set,
external_strobe);
case V4L2_CID_FLASH_STROBE:
if (__software_strobe_mode_inactive(ctrls))
return -EBUSY;
return led_set_flash_strobe(fled_cdev, true);
case V4L2_CID_FLASH_STROBE_STOP:
if (__software_strobe_mode_inactive(ctrls))
return -EBUSY;
return led_set_flash_strobe(fled_cdev, false);
case V4L2_CID_FLASH_TIMEOUT:
/*
* No conversion is needed as LED Flash class also uses
* microseconds for flash timeout units.
*/
return led_set_flash_timeout(fled_cdev, c->val);
case V4L2_CID_FLASH_INTENSITY:
/*
* No conversion is needed as LED Flash class also uses
* microamperes for flash intensity units.
*/
return led_set_flash_brightness(fled_cdev, c->val);
}
return -EINVAL;
}
static const struct v4l2_ctrl_ops v4l2_flash_ctrl_ops = {
.g_volatile_ctrl = v4l2_flash_g_volatile_ctrl,
.s_ctrl = v4l2_flash_s_ctrl,
};
static void __lfs_to_v4l2_ctrl_config(struct led_flash_setting *s,
struct v4l2_ctrl_config *c)
{
c->min = s->min;
c->max = s->max;
c->step = s->step;
c->def = s->val;
}
static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
struct v4l2_flash_config *flash_cfg,
struct v4l2_flash_ctrl_data *ctrl_init_data)
{
struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
Annotation
- Immediate include surface: `linux/led-class-flash.h`, `linux/module.h`, `linux/mutex.h`, `linux/property.h`, `linux/slab.h`, `linux/types.h`, `media/v4l2-flash-led-class.h`.
- Detected declarations: `enum ctrl_init_data_id`, `function __intensity_to_led_brightness`, `function __led_brightness_to_intensity`, `function v4l2_flash_set_led_brightness`, `function v4l2_flash_update_led_brightness`, `function v4l2_flash_g_volatile_ctrl`, `function __software_strobe_mode_inactive`, `function v4l2_flash_s_ctrl`, `function __lfs_to_v4l2_ctrl_config`, `function __fill_ctrl_init_data`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.