drivers/iio/light/apds9160.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/apds9160.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/apds9160.c- Extension
.c- Size
- 37487 bytes
- Lines
- 1593
- 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.
- 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/bits.hlinux/bitfield.hlinux/cleanup.hlinux/delay.hlinux/err.hlinux/i2c.hlinux/interrupt.hlinux/module.hlinux/mutex.hlinux/regmap.hlinux/regulator/consumer.hlinux/types.hlinux/units.hlinux/iio/iio.hlinux/iio/events.hlinux/iio/sysfs.hlinux/unaligned.h
Detected Declarations
struct apds9160_scalestruct apds9160_chipfunction apds9160_set_ps_ratefunction apds9160_set_ps_gainfunction apds9160_set_ps_cancellation_levelfunction apds9160_set_ps_analog_cancellationfunction apds9160_set_ps_cancellation_currentfunction apds9160_ps_init_analog_cancellationfunction apds9160_set_ps_currentfunction apds9160_set_als_gainfunction apds9160_set_als_scalefunction apds9160_set_als_resolutionfunction apds9160_set_als_ratefunction apds9160_set_als_int_timefunction apds9160_read_availfunction apds9160_write_raw_get_fmtfunction apds9160_read_rawfunction apds9160_write_rawfunction apds9160_get_thres_regfunction apds9160_read_eventfunction apds9160_write_eventfunction apds9160_read_event_configfunction apds9160_write_event_configfunction apds9160_irq_handlerfunction apds9160_detectfunction apds9160_disablefunction apds9160_chip_initfunction apds9160_regfield_initfunction apds9160_probe
Annotated Snippet
struct apds9160_scale {
int itime;
int gain;
int scale1;
int scale2;
};
/* Scale mapping extracted from datasheet */
static const struct apds9160_scale apds9160_als_scale_map[] = {
{
.itime = 25,
.gain = 1,
.scale1 = 3,
.scale2 = 272000,
},
{
.itime = 25,
.gain = 3,
.scale1 = 1,
.scale2 = 77000,
},
{
.itime = 25,
.gain = 6,
.scale1 = 0,
.scale2 = 525000,
},
{
.itime = 25,
.gain = 18,
.scale1 = 0,
.scale2 = 169000,
},
{
.itime = 25,
.gain = 54,
.scale1 = 0,
.scale2 = 49000,
},
{
.itime = 50,
.gain = 1,
.scale1 = 1,
.scale2 = 639000,
},
{
.itime = 50,
.gain = 3,
.scale1 = 0,
.scale2 = 538000,
},
{
.itime = 50,
.gain = 6,
.scale1 = 0,
.scale2 = 263000,
},
{
.itime = 50,
.gain = 18,
.scale1 = 0,
.scale2 = 84000,
},
{
.itime = 50,
.gain = 54,
.scale1 = 0,
.scale2 = 25000,
},
{
.itime = 100,
.gain = 1,
.scale1 = 0,
.scale2 = 819000,
},
{
.itime = 100,
.gain = 3,
.scale1 = 0,
.scale2 = 269000,
},
{
.itime = 100,
.gain = 6,
.scale1 = 0,
.scale2 = 131000,
},
{
.itime = 100,
.gain = 18,
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/cleanup.h`, `linux/delay.h`, `linux/err.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/module.h`.
- Detected declarations: `struct apds9160_scale`, `struct apds9160_chip`, `function apds9160_set_ps_rate`, `function apds9160_set_ps_gain`, `function apds9160_set_ps_cancellation_level`, `function apds9160_set_ps_analog_cancellation`, `function apds9160_set_ps_cancellation_current`, `function apds9160_ps_init_analog_cancellation`, `function apds9160_set_ps_current`, `function apds9160_set_als_gain`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- 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.