sound/usb/caiaq/midi.c
Source file repositories/reference/linux-study-clean/sound/usb/caiaq/midi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/caiaq/midi.c- Extension
.c- Size
- 3849 bytes
- Lines
- 163
- Domain
- Driver Families
- Bucket
- sound/usb
- 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/usb.hlinux/gfp.hsound/rawmidi.hsound/core.hsound/pcm.hdevice.hmidi.h
Detected Declarations
function Copyrightfunction snd_usb_caiaq_midi_input_closefunction snd_usb_caiaq_midi_input_triggerfunction snd_usb_caiaq_midi_output_openfunction snd_usb_caiaq_midi_output_closefunction snd_usb_caiaq_midi_sendfunction snd_usb_caiaq_midi_output_triggerfunction snd_usb_caiaq_midi_handle_inputfunction snd_usb_caiaq_midi_initfunction snd_usb_caiaq_midi_output_done
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2006,2007 Daniel Mack
*/
#include <linux/device.h>
#include <linux/usb.h>
#include <linux/gfp.h>
#include <sound/rawmidi.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include "device.h"
#include "midi.h"
static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream)
{
return 0;
}
static int snd_usb_caiaq_midi_input_close(struct snd_rawmidi_substream *substream)
{
return 0;
}
static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
{
struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data;
if (!cdev)
return;
cdev->midi_receive_substream = up ? substream : NULL;
}
static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substream)
{
return 0;
}
static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
{
struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data;
if (cdev->midi_out_active) {
usb_kill_urb(&cdev->midi_out_urb);
cdev->midi_out_active = 0;
}
return 0;
}
static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *cdev,
struct snd_rawmidi_substream *substream)
{
int len, ret;
struct device *dev = caiaqdev_to_dev(cdev);
cdev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
cdev->midi_out_buf[1] = 0; /* port */
len = snd_rawmidi_transmit(substream, cdev->midi_out_buf + 3,
EP1_BUFSIZE - 3);
if (len <= 0)
return;
cdev->midi_out_buf[2] = len;
cdev->midi_out_urb.transfer_buffer_length = len+3;
ret = usb_submit_urb(&cdev->midi_out_urb, GFP_ATOMIC);
if (ret < 0)
dev_err(dev,
"snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
"ret=%d, len=%d\n", substream, ret, len);
else
cdev->midi_out_active = 1;
}
static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
{
struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data;
if (up) {
cdev->midi_out_substream = substream;
if (!cdev->midi_out_active)
snd_usb_caiaq_midi_send(cdev, substream);
} else {
cdev->midi_out_substream = NULL;
}
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/usb.h`, `linux/gfp.h`, `sound/rawmidi.h`, `sound/core.h`, `sound/pcm.h`, `device.h`, `midi.h`.
- Detected declarations: `function Copyright`, `function snd_usb_caiaq_midi_input_close`, `function snd_usb_caiaq_midi_input_trigger`, `function snd_usb_caiaq_midi_output_open`, `function snd_usb_caiaq_midi_output_close`, `function snd_usb_caiaq_midi_send`, `function snd_usb_caiaq_midi_output_trigger`, `function snd_usb_caiaq_midi_handle_input`, `function snd_usb_caiaq_midi_init`, `function snd_usb_caiaq_midi_output_done`.
- Atlas domain: Driver Families / sound/usb.
- 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.