drivers/hid/hid-elan.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-elan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-elan.c- Extension
.c- Size
- 13460 bytes
- Lines
- 535
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hid.hlinux/input/mt.hlinux/leds.hlinux/module.hlinux/usb.hhid-ids.h
Detected Declarations
struct elan_drvdatafunction is_not_elan_touchpadfunction elan_input_mappingfunction elan_get_device_paramfunction elan_convert_resfunction elan_get_device_paramsfunction elan_input_configuredfunction elan_report_mt_slotfunction elan_usb_report_inputfunction elan_i2c_report_inputfunction elan_raw_eventfunction elan_start_multitouchfunction elan_mute_led_set_brigtnessfunction elan_init_mute_ledfunction elan_probe
Annotated Snippet
struct elan_drvdata {
struct input_dev *input;
u8 prev_report[ELAN_INPUT_REPORT_SIZE];
struct led_classdev mute_led;
u8 mute_led_state;
u16 max_x;
u16 max_y;
u16 res_x;
u16 res_y;
};
static int is_not_elan_touchpad(struct hid_device *hdev)
{
if (hid_is_usb(hdev)) {
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
return (intf->altsetting->desc.bInterfaceNumber !=
ELAN_TP_USB_INTF);
}
return 0;
}
static int elan_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
if (is_not_elan_touchpad(hdev))
return 0;
if (field->report->id == ELAN_SINGLE_FINGER ||
field->report->id == ELAN_MT_FIRST_FINGER ||
field->report->id == ELAN_MT_SECOND_FINGER ||
field->report->id == ELAN_MT_I2C)
return -1;
return 0;
}
static int elan_get_device_param(struct hid_device *hdev,
unsigned char *dmabuf, unsigned char param)
{
int ret;
dmabuf[0] = ELAN_FEATURE_REPORT;
dmabuf[1] = 0x05;
dmabuf[2] = 0x03;
dmabuf[3] = param;
dmabuf[4] = 0x01;
ret = hid_hw_raw_request(hdev, ELAN_FEATURE_REPORT, dmabuf,
ELAN_FEATURE_SIZE, HID_FEATURE_REPORT,
HID_REQ_SET_REPORT);
if (ret != ELAN_FEATURE_SIZE) {
hid_err(hdev, "Set report error for parm %d: %d\n", param, ret);
return ret;
}
ret = hid_hw_raw_request(hdev, ELAN_FEATURE_REPORT, dmabuf,
ELAN_FEATURE_SIZE, HID_FEATURE_REPORT,
HID_REQ_GET_REPORT);
if (ret != ELAN_FEATURE_SIZE) {
hid_err(hdev, "Get report error for parm %d: %d\n", param, ret);
return ret;
}
return 0;
}
static unsigned int elan_convert_res(char val)
{
/*
* (value from firmware) * 10 + 790 = dpi
* dpi * 10 / 254 = dots/mm
*/
return (val * 10 + 790) * 10 / 254;
}
static int elan_get_device_params(struct hid_device *hdev)
{
struct elan_drvdata *drvdata = hid_get_drvdata(hdev);
unsigned char *dmabuf;
int ret;
dmabuf = kmalloc(ELAN_FEATURE_SIZE, GFP_KERNEL);
if (!dmabuf)
return -ENOMEM;
ret = elan_get_device_param(hdev, dmabuf, ELAN_PARAM_MAX_X);
if (ret)
Annotation
- Immediate include surface: `linux/hid.h`, `linux/input/mt.h`, `linux/leds.h`, `linux/module.h`, `linux/usb.h`, `hid-ids.h`.
- Detected declarations: `struct elan_drvdata`, `function is_not_elan_touchpad`, `function elan_input_mapping`, `function elan_get_device_param`, `function elan_convert_res`, `function elan_get_device_params`, `function elan_input_configured`, `function elan_report_mt_slot`, `function elan_usb_report_input`, `function elan_i2c_report_input`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: source implementation candidate.
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.