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.

Dependency Surface

Detected Declarations

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

Implementation Notes