drivers/video/backlight/qcom-wled.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/qcom-wled.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/qcom-wled.c- Extension
.c- Size
- 44569 bytes
- Lines
- 1795
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/interrupt.hlinux/ktime.hlinux/kernel.hlinux/backlight.hlinux/module.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct wled_var_cfgstruct wled_u32_optsstruct wled_bool_optsstruct wled_configstruct wledfunction wled3_set_brightnessfunction wled4_set_brightnessfunction wled5_set_brightnessfunction wled_ovp_workfunction wled_module_enablefunction wled3_sync_togglefunction wled5_mod_sync_togglefunction wled_ovp_fault_statusfunction wled4_ovp_delayfunction wled5_ovp_delayfunction wled_update_statusfunction wled4_cabc_configfunction wled5_cabc_configfunction wled_short_irq_handlerfunction wled_auto_string_detectionfunction wled4_auto_detection_requiredfunction wled5_auto_detection_requiredfunction wled_auto_detection_at_initfunction wled_ovp_irq_handlerfunction wled3_setupfunction wled4_setupfunction wled5_setupfunction wled5_boost_i_limit_values_fnfunction wled5_ovp_values_fnfunction wled3_switch_freq_values_fnfunction wled_valuesfunction wled_configurefunction wled_configure_short_irqfunction wled_configure_ovp_irqfunction wled_probefunction wled_remove
Annotated Snippet
struct wled_var_cfg {
const u32 *values;
u32 (*fn)(u32);
int size;
};
struct wled_u32_opts {
const char *name;
u32 *val_ptr;
const struct wled_var_cfg *cfg;
};
struct wled_bool_opts {
const char *name;
bool *val_ptr;
};
struct wled_config {
u32 boost_i_limit;
u32 ovp;
u32 switch_freq;
u32 num_strings;
u32 string_i_limit;
u32 enabled_strings[WLED_MAX_STRINGS];
u32 mod_sel;
u32 cabc_sel;
bool cs_out_en;
bool ext_gen;
bool cabc;
bool external_pfet;
bool auto_detection_enabled;
};
struct wled {
const char *name;
struct device *dev;
struct regmap *regmap;
struct mutex lock; /* Lock to avoid race from thread irq handler */
ktime_t last_short_event;
ktime_t start_ovp_fault_time;
u16 ctrl_addr;
u16 sink_addr;
u16 max_string_count;
u16 auto_detection_ovp_count;
u32 brightness;
u32 max_brightness;
u32 short_count;
u32 auto_detect_count;
u32 version;
bool disabled_by_short;
bool has_short_detect;
bool cabc_disabled;
int short_irq;
int ovp_irq;
struct wled_config cfg;
struct delayed_work ovp_work;
/* Configures the brightness. Applicable for wled3, wled4 and wled5 */
int (*wled_set_brightness)(struct wled *wled, u16 brightness);
/* Configures the cabc register. Applicable for wled4 and wled5 */
int (*wled_cabc_config)(struct wled *wled, bool enable);
/*
* Toggles the sync bit for the brightness update to take place.
* Applicable for WLED3, WLED4 and WLED5.
*/
int (*wled_sync_toggle)(struct wled *wled);
/*
* Time to wait before checking the OVP status after wled module enable.
* Applicable for WLED4 and WLED5.
*/
int (*wled_ovp_delay)(struct wled *wled);
/*
* Determines if the auto string detection is required.
* Applicable for WLED4 and WLED5
*/
bool (*wled_auto_detection_required)(struct wled *wled);
};
static int wled3_set_brightness(struct wled *wled, u16 brightness)
{
int rc, i;
__le16 v;
v = cpu_to_le16(brightness & WLED3_SINK_REG_BRIGHT_MAX);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/interrupt.h`, `linux/ktime.h`, `linux/kernel.h`, `linux/backlight.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct wled_var_cfg`, `struct wled_u32_opts`, `struct wled_bool_opts`, `struct wled_config`, `struct wled`, `function wled3_set_brightness`, `function wled4_set_brightness`, `function wled5_set_brightness`, `function wled_ovp_work`, `function wled_module_enable`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.