drivers/input/joystick/iforce/iforce.h
Source file repositories/reference/linux-study-clean/drivers/input/joystick/iforce/iforce.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/joystick/iforce/iforce.h- Extension
.h- Size
- 4341 bytes
- Lines
- 148
- 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
linux/kernel.hlinux/slab.hlinux/input.hlinux/module.hlinux/spinlock.hlinux/circ_buf.hlinux/mutex.hlinux/ioport.h
Detected Declarations
struct iforce_core_effectstruct iforce_devicestruct iforcestruct iforce_xport_opsstruct iforcefunction iforce_get_id_packetfunction iforce_clear_xmit_and_wake
Annotated Snippet
struct iforce_core_effect {
/* Information about where modifiers are stored in the device's memory */
struct resource mod1_chunk;
struct resource mod2_chunk;
unsigned long flags[BITS_TO_LONGS(FF_MODCORE_CNT)];
};
#define FF_CMD_EFFECT 0x010e
#define FF_CMD_ENVELOPE 0x0208
#define FF_CMD_MAGNITUDE 0x0303
#define FF_CMD_PERIOD 0x0407
#define FF_CMD_CONDITION 0x050a
#define FF_CMD_AUTOCENTER 0x4002
#define FF_CMD_PLAY 0x4103
#define FF_CMD_ENABLE 0x4201
#define FF_CMD_GAIN 0x4301
#define FF_CMD_QUERY 0xff01
/* Buffer for async write */
#define XMIT_SIZE 256
#define XMIT_INC(var, n) (var)+=n; (var)&= XMIT_SIZE -1
/* iforce::xmit_flags */
#define IFORCE_XMIT_RUNNING 0
#define IFORCE_XMIT_AGAIN 1
struct iforce_device {
u16 idvendor;
u16 idproduct;
char *name;
signed short *btn;
signed short *abs;
signed short *ff;
};
struct iforce;
struct iforce_xport_ops {
void (*xmit)(struct iforce *iforce);
int (*get_id)(struct iforce *iforce, u8 id,
u8 *response_data, size_t *response_len);
int (*start_io)(struct iforce *iforce);
void (*stop_io)(struct iforce *iforce);
};
struct iforce {
struct input_dev *dev; /* Input device interface */
struct iforce_device *type;
const struct iforce_xport_ops *xport_ops;
spinlock_t xmit_lock;
/* Buffer used for asynchronous sending of bytes to the device */
struct circ_buf xmit;
unsigned char xmit_data[XMIT_SIZE];
unsigned long xmit_flags[1];
/* Force Feedback */
wait_queue_head_t wait;
struct resource device_memory;
struct iforce_core_effect core_effects[IFORCE_EFFECTS_MAX];
struct mutex mem_mutex;
};
/* Get hi and low bytes of a 16-bits int */
#define HI(a) ((unsigned char)((a) >> 8))
#define LO(a) ((unsigned char)((a) & 0xff))
/* For many parameters, it seems that 0x80 is a special value that should
* be avoided. Instead, we replace this value by 0x7f
*/
#define HIFIX80(a) ((unsigned char)(((a)<0? (a)+255 : (a))>>8))
/* Encode a time value */
#define TIME_SCALE(a) (a)
static inline int iforce_get_id_packet(struct iforce *iforce, u8 id,
u8 *response_data, size_t *response_len)
{
return iforce->xport_ops->get_id(iforce, id,
response_data, response_len);
}
static inline void iforce_clear_xmit_and_wake(struct iforce *iforce)
{
clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
wake_up_all(&iforce->wait);
}
/* Public functions */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/input.h`, `linux/module.h`, `linux/spinlock.h`, `linux/circ_buf.h`, `linux/mutex.h`, `linux/ioport.h`.
- Detected declarations: `struct iforce_core_effect`, `struct iforce_device`, `struct iforce`, `struct iforce_xport_ops`, `struct iforce`, `function iforce_get_id_packet`, `function iforce_clear_xmit_and_wake`.
- 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.