drivers/leds/flash/leds-aat1290.c
Source file repositories/reference/linux-study-clean/drivers/leds/flash/leds-aat1290.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/flash/leds-aat1290.c- Extension
.c- Size
- 14611 bytes
- Lines
- 551
- Domain
- Driver Families
- Bucket
- drivers/leds
- 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.
- 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/cleanup.hlinux/delay.hlinux/gpio/consumer.hlinux/led-class-flash.hlinux/leds.hlinux/module.hlinux/mutex.hlinux/of.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/slab.hmedia/v4l2-flash-led-class.h
Detected Declarations
struct aat1290_led_config_datastruct aat1290_ledfunction aat1290_as2cwire_writefunction aat1290_set_flash_safety_timerfunction aat1290_led_brightness_setfunction aat1290_led_flash_strobe_setfunction aat1290_led_flash_timeout_setfunction aat1290_led_parse_dtfunction aat1290_led_validate_mm_currentfunction init_mm_current_scalefunction aat1290_led_get_configurationfunction aat1290_init_flash_timeoutfunction aat1290_intensity_to_brightnessfunction aat1290_brightness_to_intensityfunction aat1290_led_external_strobe_setfunction aat1290_init_v4l2_flash_configfunction aat1290_init_v4l2_flash_configfunction aat1290_led_probefunction aat1290_led_remove
Annotated Snippet
struct aat1290_led_config_data {
/* maximum LED current in movie mode */
u32 max_mm_current;
/* maximum LED current in flash mode */
u32 max_flash_current;
/* maximum flash timeout */
u32 max_flash_tm;
/* external strobe capability */
bool has_external_strobe;
/* max LED brightness level */
enum led_brightness max_brightness;
};
struct aat1290_led {
/* platform device data */
struct platform_device *pdev;
/* secures access to the device */
struct mutex lock;
/* corresponding LED Flash class device */
struct led_classdev_flash fled_cdev;
/* V4L2 Flash device */
struct v4l2_flash *v4l2_flash;
/* FLEN pin */
struct gpio_desc *gpio_fl_en;
/* EN|SET pin */
struct gpio_desc *gpio_en_set;
/* movie mode current scale */
int *mm_current_scale;
/* device mode */
bool movie_mode;
};
static struct aat1290_led *fled_cdev_to_led(
struct led_classdev_flash *fled_cdev)
{
return container_of(fled_cdev, struct aat1290_led, fled_cdev);
}
static struct led_classdev_flash *led_cdev_to_fled_cdev(
struct led_classdev *led_cdev)
{
return container_of(led_cdev, struct led_classdev_flash, led_cdev);
}
static void aat1290_as2cwire_write(struct aat1290_led *led, int addr, int value)
{
int i;
gpiod_direction_output(led->gpio_fl_en, 0);
gpiod_direction_output(led->gpio_en_set, 0);
udelay(AAT1290_FLEN_OFF_DELAY_TIME_US);
/* write address */
for (i = 0; i < addr; ++i) {
udelay(AAT1290_EN_SET_TICK_TIME_US);
gpiod_direction_output(led->gpio_en_set, 0);
udelay(AAT1290_EN_SET_TICK_TIME_US);
gpiod_direction_output(led->gpio_en_set, 1);
}
usleep_range(AAT1290_LATCH_TIME_MIN_US, AAT1290_LATCH_TIME_MAX_US);
/* write data */
for (i = 0; i < value; ++i) {
udelay(AAT1290_EN_SET_TICK_TIME_US);
gpiod_direction_output(led->gpio_en_set, 0);
udelay(AAT1290_EN_SET_TICK_TIME_US);
gpiod_direction_output(led->gpio_en_set, 1);
}
usleep_range(AAT1290_LATCH_TIME_MIN_US, AAT1290_LATCH_TIME_MAX_US);
}
static void aat1290_set_flash_safety_timer(struct aat1290_led *led,
unsigned int micro_sec)
{
struct led_classdev_flash *fled_cdev = &led->fled_cdev;
struct led_flash_setting *flash_tm = &fled_cdev->timeout;
int flash_tm_reg = AAT1290_FLASH_TM_NUM_LEVELS -
(micro_sec / flash_tm->step) + 1;
aat1290_as2cwire_write(led, AAT1290_FLASH_SAFETY_TIMER_ADDR,
flash_tm_reg);
}
/* LED subsystem callbacks */
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/led-class-flash.h`, `linux/leds.h`, `linux/module.h`, `linux/mutex.h`, `linux/of.h`.
- Detected declarations: `struct aat1290_led_config_data`, `struct aat1290_led`, `function aat1290_as2cwire_write`, `function aat1290_set_flash_safety_timer`, `function aat1290_led_brightness_set`, `function aat1290_led_flash_strobe_set`, `function aat1290_led_flash_timeout_set`, `function aat1290_led_parse_dt`, `function aat1290_led_validate_mm_current`, `function init_mm_current_scale`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: source 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.