drivers/video/backlight/aw99706.c

Source file repositories/reference/linux-study-clean/drivers/video/backlight/aw99706.c

File Facts

System
Linux kernel
Corpus path
drivers/video/backlight/aw99706.c
Extension
.c
Size
11888 bytes
Lines
472
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 aw99706_dt_prop {
	const char * const name;
	int (*lookup)(const struct aw99706_dt_prop *prop, u32 dt_val, u8 *val);
	const u32 * const lookup_tbl;
	u8 tbl_size;
	u8 reg;
	u8 mask;
	u32 def_val;
};

static int aw99706_dt_property_lookup(const struct aw99706_dt_prop *prop,
				      u32 dt_val, u8 *val)
{
	int i;

	if (!prop->lookup_tbl) {
		*val = dt_val;
		return 0;
	}

	for (i = 0; i < prop->tbl_size; i++)
		if (prop->lookup_tbl[i] == dt_val)
			break;

	*val = i;

	return i == prop->tbl_size ? -1 : 0;
}

#define MIN_ILED_MAX	5000
#define MAX_ILED_MAX	50000
#define STEP_ILED_MAX	500

static int
aw99706_dt_property_iled_max_convert(const struct aw99706_dt_prop *prop,
				     u32 dt_val, u8 *val)
{
	if (dt_val > MAX_ILED_MAX || dt_val < MIN_ILED_MAX)
		return -1;

	*val = (dt_val - MIN_ILED_MAX) / STEP_ILED_MAX;

	return (dt_val - MIN_ILED_MAX) % STEP_ILED_MAX;
}

static const struct aw99706_dt_prop aw99706_dt_props[] = {
	{
		"awinic,dim-mode", aw99706_dt_property_lookup,
		NULL, 0,
		AW99706_CFG0_REG, AW99706_DIM_MODE_MASK, 1,
	},
	{
		"awinic,sw-freq", aw99706_dt_property_lookup,
		aw99706_sw_freq_tbl, ARRAY_SIZE(aw99706_sw_freq_tbl),
		AW99706_CFG1_REG, AW99706_SW_FREQ_MASK, 750000,
	},
	{
		"awinic,sw-ilmt", aw99706_dt_property_lookup,
		aw99706_sw_ilmt_tbl, ARRAY_SIZE(aw99706_sw_ilmt_tbl),
		AW99706_CFG1_REG, AW99706_SW_ILMT_MASK, 3000000,
	},
	{
		"awinic,iled-max", aw99706_dt_property_iled_max_convert,
		NULL, 0,
		AW99706_CFG2_REG, AW99706_ILED_MAX_MASK, 20000,

	},
	{
		"awinic,uvlo-thres", aw99706_dt_property_lookup,
		aw99706_ulvo_thres_tbl, ARRAY_SIZE(aw99706_ulvo_thres_tbl),
		AW99706_CFG2_REG, AW99706_UVLOSEL_MASK, 2200000,
	},
	{
		"awinic,ramp-ctl", aw99706_dt_property_lookup,
		NULL, 0,
		AW99706_CFG6_REG, AW99706_RAMP_CTL_MASK, 2,
	}
};

struct reg_init_data {
	u8 reg;
	u8 mask;
	u8 val;
};

struct aw99706_device {
	struct i2c_client *client;
	struct device *dev;
	struct regmap *regmap;
	struct backlight_device *bl_dev;

Annotation

Implementation Notes