drivers/hid/hid-prodikeys.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-prodikeys.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-prodikeys.c- Extension
.c- Size
- 20417 bytes
- Lines
- 871
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/device.hlinux/module.hlinux/usb.hlinux/mutex.hlinux/hid.hsound/core.hsound/initval.hsound/rawmidi.hhid-ids.h
Detected Declarations
struct pcmidi_sndstruct pcmidi_sustainstruct pcmidi_sndfunction show_channelfunction store_channelfunction show_sustainfunction store_sustainfunction show_octavefunction store_octavefunction pcmidi_send_notefunction pcmidi_sustained_note_releasefunction init_sustain_timersfunction stop_sustain_timersfunction pcmidi_get_output_reportfunction list_for_each_entryfunction pcmidi_submit_output_reportfunction pcmidi_handle_report1function pcmidi_handle_report3function pcmidi_handle_report4function pcmidi_handle_reportfunction pcmidi_setup_extra_keysfunction pcmidi_set_operationalfunction pcmidi_snd_freefunction pcmidi_in_openfunction pcmidi_in_closefunction pcmidi_in_triggerfunction pcmidi_snd_initialisefunction pcmidi_snd_terminatefunction pk_input_mappingfunction pk_raw_eventfunction pk_probefunction pk_remove
Annotated Snippet
struct pcmidi_sustain {
unsigned long in_use;
struct pcmidi_snd *pm;
struct timer_list timer;
unsigned char status;
unsigned char note;
unsigned char velocity;
};
#define PCMIDI_SUSTAINED_MAX 32
struct pcmidi_snd {
struct hid_device *hdev;
unsigned short ifnum;
struct hid_report *pcmidi_report6;
struct input_dev *input_ep82;
unsigned short midi_mode;
unsigned short midi_sustain_mode;
unsigned short midi_sustain;
unsigned short midi_channel;
short midi_octave;
struct pcmidi_sustain sustained_notes[PCMIDI_SUSTAINED_MAX];
unsigned short fn_state;
unsigned short last_key[24];
spinlock_t rawmidi_in_lock;
struct snd_card *card;
struct snd_rawmidi *rwmidi;
struct snd_rawmidi_substream *in_substream;
unsigned long in_triggered;
};
#define PK_QUIRK_NOGET 0x00010000
#define PCMIDI_MIDDLE_C 60
#define PCMIDI_CHANNEL_MIN 0
#define PCMIDI_CHANNEL_MAX 15
#define PCMIDI_OCTAVE_MIN (-2)
#define PCMIDI_OCTAVE_MAX 2
#define PCMIDI_SUSTAIN_MIN 0
#define PCMIDI_SUSTAIN_MAX 5000
static const char shortname[] = "PC-MIDI";
static const char longname[] = "Prodikeys PC-MIDI Keyboard";
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
module_param_array(index, int, NULL, 0444);
module_param_array(id, charp, NULL, 0444);
module_param_array(enable, bool, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for the PC-MIDI virtual audio driver");
MODULE_PARM_DESC(id, "ID string for the PC-MIDI virtual audio driver");
MODULE_PARM_DESC(enable, "Enable for the PC-MIDI virtual audio driver");
/* Output routine for the sysfs channel file */
static ssize_t show_channel(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct hid_device *hdev = to_hid_device(dev);
struct pcmidi_snd *pm = hid_get_drvdata(hdev);
dbg_hid("pcmidi sysfs read channel=%u\n", pm->midi_channel);
return sprintf(buf, "%u (min:%u, max:%u)\n", pm->midi_channel,
PCMIDI_CHANNEL_MIN, PCMIDI_CHANNEL_MAX);
}
/* Input routine for the sysfs channel file */
static ssize_t store_channel(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct hid_device *hdev = to_hid_device(dev);
struct pcmidi_snd *pm = hid_get_drvdata(hdev);
unsigned channel = 0;
if (sscanf(buf, "%u", &channel) > 0 && channel <= PCMIDI_CHANNEL_MAX) {
dbg_hid("pcmidi sysfs write channel=%u\n", channel);
pm->midi_channel = channel;
return strlen(buf);
}
return -EINVAL;
}
static DEVICE_ATTR(channel, S_IRUGO | S_IWUSR | S_IWGRP , show_channel,
store_channel);
static struct device_attribute *sysfs_device_attr_channel = {
&dev_attr_channel,
};
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/usb.h`, `linux/mutex.h`, `linux/hid.h`, `sound/core.h`, `sound/initval.h`, `sound/rawmidi.h`.
- Detected declarations: `struct pcmidi_snd`, `struct pcmidi_sustain`, `struct pcmidi_snd`, `function show_channel`, `function store_channel`, `function show_sustain`, `function store_sustain`, `function show_octave`, `function store_octave`, `function pcmidi_send_note`.
- Atlas domain: Driver Families / drivers/hid.
- 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.