drivers/input/joystick/iforce/iforce-ff.c
Source file repositories/reference/linux-study-clean/drivers/input/joystick/iforce/iforce-ff.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/joystick/iforce/iforce-ff.c- Extension
.c- Size
- 14519 bytes
- Lines
- 521
- Domain
- Driver Families
- Bucket
- drivers/input
- 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
iforce.h
Detected Declarations
function Copyrightfunction make_period_modifierfunction make_envelope_modifierfunction make_condition_modifierfunction find_buttonfunction need_condition_modifierfunction need_magnitude_modifierfunction need_envelope_modifierfunction need_period_modifierfunction need_corefunction make_corefunction iforce_upload_periodicfunction iforce_upload_constantfunction iforce_upload_condition
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
* Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
*
* USB/RS232 I-Force joysticks and wheels.
*/
#include "iforce.h"
/*
* Set the magnitude of a constant force effect
* Return error code
*
* Note: caller must ensure exclusive access to device
*/
static int make_magnitude_modifier(struct iforce* iforce,
struct resource* mod_chunk, int no_alloc, __s16 level)
{
unsigned char data[3];
if (!no_alloc) {
guard(mutex)(&iforce->mem_mutex);
if (allocate_resource(&iforce->device_memory, mod_chunk, 2,
iforce->device_memory.start,
iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC;
}
data[0] = LO(mod_chunk->start);
data[1] = HI(mod_chunk->start);
data[2] = HIFIX80(level);
iforce_send_packet(iforce, FF_CMD_MAGNITUDE, data);
iforce_dump_packet(iforce, "magnitude", FF_CMD_MAGNITUDE, data);
return 0;
}
/*
* Upload the component of an effect dealing with the period, phase and magnitude
*/
static int make_period_modifier(struct iforce* iforce,
struct resource* mod_chunk, int no_alloc,
__s16 magnitude, __s16 offset, u16 period, u16 phase)
{
unsigned char data[7];
period = TIME_SCALE(period);
if (!no_alloc) {
guard(mutex)(&iforce->mem_mutex);
if (allocate_resource(&iforce->device_memory, mod_chunk, 0x0c,
iforce->device_memory.start,
iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC;
}
data[0] = LO(mod_chunk->start);
data[1] = HI(mod_chunk->start);
data[2] = HIFIX80(magnitude);
data[3] = HIFIX80(offset);
data[4] = HI(phase);
data[5] = LO(period);
data[6] = HI(period);
iforce_send_packet(iforce, FF_CMD_PERIOD, data);
return 0;
}
/*
* Uploads the part of an effect setting the envelope of the force
*/
static int make_envelope_modifier(struct iforce* iforce,
struct resource* mod_chunk, int no_alloc,
u16 attack_duration, __s16 initial_level,
u16 fade_duration, __s16 final_level)
{
unsigned char data[8];
Annotation
- Immediate include surface: `iforce.h`.
- Detected declarations: `function Copyright`, `function make_period_modifier`, `function make_envelope_modifier`, `function make_condition_modifier`, `function find_button`, `function need_condition_modifier`, `function need_magnitude_modifier`, `function need_envelope_modifier`, `function need_period_modifier`, `function need_core`.
- Atlas domain: Driver Families / drivers/input.
- 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.