drivers/iio/position/hid-sensor-custom-intel-hinge.c
Source file repositories/reference/linux-study-clean/drivers/iio/position/hid-sensor-custom-intel-hinge.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/position/hid-sensor-custom-intel-hinge.c- Extension
.c- Size
- 10540 bytes
- Lines
- 380
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hid-sensor-hub.hlinux/iio/buffer.hlinux/iio/iio.hlinux/platform_device.hlinux/module.hlinux/mod_devicetable.h../common/hid-sensors/hid-sensor-trigger.h
Detected Declarations
struct hinge_stateenum hinge_channelfunction hinge_adjust_channel_realbitsfunction hinge_read_rawfunction hinge_write_rawfunction hinge_read_labelfunction hinge_proc_eventfunction hinge_capture_samplefunction hinge_parse_reportfunction hid_hinge_probefunction hid_hinge_remove
Annotated Snippet
struct hinge_state {
struct iio_dev *indio_dev;
struct hid_sensor_hub_attribute_info hinge[CHANNEL_SCAN_INDEX_MAX];
struct hid_sensor_hub_callbacks callbacks;
struct hid_sensor_common common_attributes;
const char *labels[CHANNEL_SCAN_INDEX_MAX];
struct {
u32 hinge_val[3];
aligned_s64 timestamp;
} scan;
int scale_pre_decml;
int scale_post_decml;
int scale_precision;
int value_offset;
u64 timestamp;
};
static const u32 hinge_sensitivity_addresses[] = {
HID_USAGE_SENSOR_DATA_FIELD_CUSTOM_VALUE(1),
};
/* Channel definitions */
static const struct iio_chan_spec hinge_channels[] = {
{
.type = IIO_ANGL,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type =
BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS),
.scan_index = CHANNEL_SCAN_INDEX_HINGE_ANGLE,
.scan_type = {
.sign = 's',
.storagebits = 32,
},
}, {
.type = IIO_ANGL,
.indexed = 1,
.channel = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type =
BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS),
.scan_index = CHANNEL_SCAN_INDEX_SCREEN_ANGLE,
.scan_type = {
.sign = 's',
.storagebits = 32,
},
}, {
.type = IIO_ANGL,
.indexed = 1,
.channel = 2,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type =
BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS),
.scan_index = CHANNEL_SCAN_INDEX_KEYBOARD_ANGLE,
.scan_type = {
.sign = 's',
.storagebits = 32,
},
},
IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
};
/* Adjust channel real bits based on report descriptor */
static void hinge_adjust_channel_realbits(struct iio_chan_spec *channels,
int channel, int size)
{
channels[channel].scan_type.realbits = size * 8;
}
/* Channel read_raw handler */
static int hinge_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val, int *val2,
long mask)
{
struct hinge_state *st = iio_priv(indio_dev);
struct hid_sensor_hub_device *hsdev;
int report_id;
s32 min;
hsdev = st->common_attributes.hsdev;
switch (mask) {
case IIO_CHAN_INFO_RAW:
hid_sensor_power_state(&st->common_attributes, true);
report_id = st->hinge[chan->scan_index].report_id;
min = st->hinge[chan->scan_index].logical_minimum;
Annotation
- Immediate include surface: `linux/hid-sensor-hub.h`, `linux/iio/buffer.h`, `linux/iio/iio.h`, `linux/platform_device.h`, `linux/module.h`, `linux/mod_devicetable.h`, `../common/hid-sensors/hid-sensor-trigger.h`.
- Detected declarations: `struct hinge_state`, `enum hinge_channel`, `function hinge_adjust_channel_realbits`, `function hinge_read_raw`, `function hinge_write_raw`, `function hinge_read_label`, `function hinge_proc_event`, `function hinge_capture_sample`, `function hinge_parse_report`, `function hid_hinge_probe`.
- 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.
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.