drivers/hid/hid-gfrm.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-gfrm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-gfrm.c- Extension
.c- Size
- 3771 bytes
- Lines
- 151
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/hid.hlinux/input.hlinux/module.hhid-ids.h
Detected Declarations
function gfrm_input_mappingfunction gfrm_raw_eventfunction gfrm_input_configuredfunction gfrm_probe
Annotated Snippet
if (usage->hid == (HID_UP_CONSUMER | 0x4)) {
/* Consumer.0004 -> KEY_INFO */
hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_INFO);
return 1;
}
if (usage->hid == (HID_UP_CONSUMER | 0x41)) {
/* Consumer.0041 -> KEY_OK */
hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_OK);
return 1;
}
}
return 0;
}
static int gfrm_raw_event(struct hid_device *hdev, struct hid_report *report,
u8 *data, int size)
{
const struct hid_device_id *id = hid_get_drvdata(hdev);
unsigned long hdev_type = id->driver_data;
int ret = 0;
if (hdev_type != GFRM100)
return 0;
if (size < 2 || data[0] != GFRM100_SEARCH_KEY_REPORT_ID)
return 0;
/*
* Convert GFRM100 Search key reports into Consumer.0221 (Key.Search)
* reports. Ignore audio data.
*/
switch (data[1]) {
case GFRM100_SEARCH_KEY_DOWN:
ret = hid_report_raw_event(hdev, HID_INPUT_REPORT, search_key_dn,
sizeof(search_key_dn), sizeof(search_key_dn), 1);
break;
case GFRM100_SEARCH_KEY_AUDIO_DATA:
break;
case GFRM100_SEARCH_KEY_UP:
ret = hid_report_raw_event(hdev, HID_INPUT_REPORT, search_key_up,
sizeof(search_key_up), sizeof(search_key_up), 1);
break;
default:
break;
}
return (ret < 0) ? ret : -1;
}
static int gfrm_input_configured(struct hid_device *hid, struct hid_input *hidinput)
{
/*
* Enable software autorepeat with:
* - repeat delay: 400 msec
* - repeat period: 100 msec
*/
input_enable_softrepeat(hidinput->input, 400, 100);
return 0;
}
static int gfrm_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
int ret;
hid_set_drvdata(hdev, (void *)id);
ret = hid_parse(hdev);
if (ret)
goto done;
if (id->driver_data == GFRM100) {
/*
* GFRM100 HID Report Descriptor does not describe the Search
* key reports. Thus, we need to add it manually here, so that
* those reports reach gfrm_raw_event() from hid_input_report().
*/
if (!hid_register_report(hdev, HID_INPUT_REPORT,
GFRM100_SEARCH_KEY_REPORT_ID, 0)) {
ret = -ENOMEM;
goto done;
}
}
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
done:
Annotation
- Immediate include surface: `linux/device.h`, `linux/hid.h`, `linux/input.h`, `linux/module.h`, `hid-ids.h`.
- Detected declarations: `function gfrm_input_mapping`, `function gfrm_raw_event`, `function gfrm_input_configured`, `function gfrm_probe`.
- 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.