drivers/iio/light/tsl2772.c

Source file repositories/reference/linux-study-clean/drivers/iio/light/tsl2772.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/light/tsl2772.c
Extension
.c
Size
49022 bytes
Lines
1944
Domain
Driver Families
Bucket
drivers/iio
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 tsl2772_als_info {
	u16 als_ch0;
	u16 als_ch1;
	u16 lux;
};

struct tsl2772_chip_info {
	int chan_table_elements;
	struct iio_chan_spec channel_with_events[4];
	struct iio_chan_spec channel_without_events[4];
	const struct iio_info *info;
};

static const int tsl2772_led_currents[][2] = {
	{ 100000, TSL2772_100_mA },
	{  50000, TSL2772_50_mA },
	{  25000, TSL2772_25_mA },
	{  13000, TSL2772_13_mA },
	{      0, 0 }
};

struct tsl2772_chip {
	kernel_ulong_t id;
	struct mutex prox_mutex;
	struct mutex als_mutex;
	struct i2c_client *client;
	struct regulator_bulk_data supplies[TSL2772_NUM_SUPPLIES];
	u16 prox_data;
	struct tsl2772_als_info als_cur_info;
	struct tsl2772_settings settings;
	struct tsl2772_platform_data *pdata;
	int als_gain_time_scale;
	int als_saturation;
	int tsl2772_chip_status;
	u8 tsl2772_config[TSL2772_MAX_CONFIG_REG];
	const struct tsl2772_chip_info	*chip_info;
	const struct iio_info *info;
	s64 event_timestamp;
	/*
	 * This structure is intentionally large to accommodate
	 * updates via sysfs.
	 * Sized to 9 = max 8 segments + 1 termination segment
	 */
	struct tsl2772_lux tsl2772_device_lux[TSL2772_MAX_LUX_TABLE_SIZE];
};

/*
 * Different devices require different coefficients, and these numbers were
 * derived from the 'Lux Equation' section of the various device datasheets.
 * All of these coefficients assume a Glass Attenuation (GA) factor of 1.
 * The coefficients are multiplied by 1000 to avoid floating point operations.
 * The two rows in each table correspond to the Lux1 and Lux2 equations from
 * the datasheets.
 */
static const struct tsl2772_lux tsl2x71_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
	{ 53000, 106000 },
	{ 31800,  53000 },
	{ 0,          0 },
};

static const struct tsl2772_lux tmd2x71_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
	{ 24000,  48000 },
	{ 14400,  24000 },
	{ 0,          0 },
};

static const struct tsl2772_lux tsl2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
	{ 60000, 112200 },
	{ 37800,  60000 },
	{     0,      0 },
};

static const struct tsl2772_lux tmd2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
	{ 20000,  35000 },
	{ 12600,  20000 },
	{     0,      0 },
};

static const struct tsl2772_lux apds9930_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
	{ 52000,  96824 },
	{ 38792,  67132 },
	{     0,      0 },
};

static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = {
	[tsl2571] = tsl2x71_lux_table,
	[tsl2671] = tsl2x71_lux_table,
	[tmd2671] = tmd2x71_lux_table,
	[tsl2771] = tsl2x71_lux_table,
	[tmd2771] = tmd2x71_lux_table,

Annotation

Implementation Notes