drivers/iio/light/veml6046x00.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/veml6046x00.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/veml6046x00.c- Extension
.c- Size
- 27362 bytes
- Lines
- 1031
- 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/array_size.hlinux/bitfield.hlinux/bits.hlinux/dev_printk.hlinux/err.hlinux/i2c.hlinux/interrupt.hlinux/module.hlinux/mod_devicetable.hlinux/pm_runtime.hlinux/regmap.hlinux/time.hlinux/types.hlinux/units.hasm/byteorder.hlinux/iio/iio.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct veml6046x00_rfstruct veml6046x00_datastruct veml6046x00_gain_pdenum veml6046x00_scanfunction bitsfunction bitsfunction veml6046x00_shutdown_actionfunction veml6046x00_regfield_initfunction veml6046x00_get_it_indexfunction veml6046x00_get_it_usecfunction veml6046x00_set_itfunction veml6046x00_get_val_gain_idxfunction veml6046x00_get_gain_idxfunction veml6046x00_set_scalefunction veml6046x00_get_scalefunction veml6046x00_read_data_readyfunction veml6046x00_wait_data_availablefunction veml6046x00_single_readfunction veml6046x00_read_rawfunction veml6046x00_read_availfunction veml6046x00_write_rawfunction veml6046x00_buffer_preenablefunction veml6046x00_buffer_postdisablefunction veml6046x00_trig_handlerfunction veml6046x00_validate_part_idfunction veml6046x00_setup_devicefunction veml6046x00_probefunction veml6046x00_runtime_suspendfunction veml6046x00_runtime_resume
Annotated Snippet
struct veml6046x00_rf {
struct regmap_field *int_en;
struct regmap_field *mode;
struct regmap_field *trig;
struct regmap_field *it;
struct regmap_field *pers;
};
/**
* struct veml6046x00_data - Private data of driver.
* @regmap: Regmap definition of sensor.
* @trig: Industrial-IO trigger.
* @rf: Regmap field of configuration.
*/
struct veml6046x00_data {
struct regmap *regmap;
struct iio_trigger *trig;
struct veml6046x00_rf rf;
};
/**
* DOC: Valid integration times (IT)
*
* static const int veml6046x00_it contains the array with valid IT.
*
* Register value to be read or written in regmap_field it on veml6046x00 is
* identical with array index.
* This means there is no separate translation table between valid integration
* times and register values needed. The index of the array is identical with
* the register value.
*
* The array is in the form as expected by the callback of the sysfs attribute
* integration_time_available (IIO_CHAN_INFO_INT_TIME). So there is no
* additional conversion needed.
*/
static const int veml6046x00_it[][2] = {
{ 0, 3125 },
{ 0, 6250 },
{ 0, 12500 },
{ 0, 25000 },
{ 0, 50000 },
{ 0, 100000 },
{ 0, 200000 },
{ 0, 400000 },
};
/**
* DOC: Handling of gain and photodiode size (PD)
*
* Gains here in the driver are not exactly the same as in the datasheet of the
* sensor. The gain in the driver is a combination of the gain of the sensor
* with the photodiode size (PD).
* The following combinations are possible:
* gain(driver) = gain(sensor) * PD
* 0.25 = x0.5 * 1/2
* 0.33 = x0.66 * 1/2
* 0.5 = x0.5 * 2/2
* 0.66 = x0.66 * 2/2
* 1 = x1 * 2/2
* 2 = x2 * 2/2
*/
/**
* struct veml6046x00_gain_pd - Translation of gain and photodiode size (PD).
* @gain_sen: Gain used in the sensor as described in the datasheet of the
* sensor
* @pd: Photodiode size in the sensor
*
* This is the translation table from the gain used in the driver (and also used
* by the userspace interface in sysfs) to the gain and PD used in the sensor
* hardware.
*
* There are six gain values visible to the user (0.25 .. 2) which translate to
* two different gains in the sensor hardware (x0.5 .. x2) and two PD (1/2 and
* 2/2). Theoretical are there eight combinations, but gain values 0.5 and 1 are
* doubled and therefore the combination with the larger PD (2/2) is taken as
* more photodiode cells are supposed to deliver a more precise result.
*/
struct veml6046x00_gain_pd {
unsigned int gain_sen;
unsigned int pd;
};
static const struct veml6046x00_gain_pd veml6046x00_gain_pd[] = {
{ .gain_sen = VEML6046X00_GAIN_0_5, .pd = VEML6046X00_PD_1_2 },
{ .gain_sen = VEML6046X00_GAIN_0_66, .pd = VEML6046X00_PD_1_2 },
{ .gain_sen = VEML6046X00_GAIN_0_5, .pd = VEML6046X00_PD_2_2 },
{ .gain_sen = VEML6046X00_GAIN_0_66, .pd = VEML6046X00_PD_2_2 },
{ .gain_sen = VEML6046X00_GAIN_1, .pd = VEML6046X00_PD_2_2 },
{ .gain_sen = VEML6046X00_GAIN_2, .pd = VEML6046X00_PD_2_2 },
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/bits.h`, `linux/dev_printk.h`, `linux/err.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/module.h`.
- Detected declarations: `struct veml6046x00_rf`, `struct veml6046x00_data`, `struct veml6046x00_gain_pd`, `enum veml6046x00_scan`, `function bits`, `function bits`, `function veml6046x00_shutdown_action`, `function veml6046x00_regfield_init`, `function veml6046x00_get_it_index`, `function veml6046x00_get_it_usec`.
- 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.