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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/errno.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/property.hlinux/slab.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/platform_data/tsl2772.hlinux/regulator/consumer.h
Detected Declarations
struct tsl2772_als_infostruct tsl2772_chip_infostruct tsl2772_chipfunction tsl2772_read_statusfunction tsl2772_write_control_regfunction tsl2772_read_autoinc_regsfunction tsl2772_get_luxfunction tsl2772_get_proxfunction tsl2772_read_prox_led_currentfunction tsl2772_read_prox_diodesfunction tsl2772_parse_dtfunction tsl2772_defaultsfunction tsl2772_als_calibratefunction tsl2772_disable_regulators_actionfunction tsl2772_chip_onfunction tsl2772_chip_offfunction tsl2772_chip_off_actionfunction tsl2772_invoke_changefunction tsl2772_prox_calfunction tsl2772_read_availfunction in_illuminance0_target_input_showfunction in_illuminance0_target_input_storefunction in_illuminance0_calibrate_storefunction in_illuminance0_lux_table_showfunction in_illuminance0_lux_table_storefunction in_proximity0_calibrate_storefunction tsl2772_read_interrupt_configfunction tsl2772_write_interrupt_configfunction tsl2772_write_event_valuefunction tsl2772_read_event_valuefunction tsl2772_read_rawfunction tsl2772_write_rawfunction tsl2772_device_id_veriffunction tsl2772_event_handlerfunction tsl2772_probefunction tsl2772_suspendfunction tsl2772_resume
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
- Immediate include surface: `linux/delay.h`, `linux/errno.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/property.h`.
- Detected declarations: `struct tsl2772_als_info`, `struct tsl2772_chip_info`, `struct tsl2772_chip`, `function tsl2772_read_status`, `function tsl2772_write_control_reg`, `function tsl2772_read_autoinc_regs`, `function tsl2772_get_lux`, `function tsl2772_get_prox`, `function tsl2772_read_prox_led_current`, `function tsl2772_read_prox_diodes`.
- Atlas domain: Driver Families / drivers/iio.
- 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.