sound/usb/fcp.c
Source file repositories/reference/linux-study-clean/sound/usb/fcp.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/fcp.c- Extension
.c- Size
- 27653 bytes
- Lines
- 1128
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/slab.hlinux/usb.hsound/control.hsound/hwdep.hsound/tlv.huapi/sound/fcp.husbaudio.hmixer.hhelper.hfcp.h
Detected Declarations
struct fcp_notifystruct fcp_datastruct fcp_usb_packetfunction fcp_fill_request_headerfunction fcp_usb_txfunction fcp_usb_rxfunction fcp_usbfunction fcp_reinitfunction fcp_add_new_ctlfunction fcp_meter_ctl_infofunction fcp_meter_ctl_getfunction fcp_meter_tlv_callbackfunction fcp_ioctl_initfunction fcp_validate_cmdfunction fcp_ioctl_cmdfunction validate_meter_mapfunction fcp_ioctl_set_meter_mapfunction fcp_ioctl_set_meter_labelsfunction fcp_hwdep_openfunction fcp_hwdep_ioctlfunction fcp_hwdep_readfunction scoped_guardfunction fcp_hwdep_pollfunction fcp_hwdep_releasefunction fcp_hwdep_initfunction fcp_cleanup_urbfunction fcp_private_freefunction fcp_private_suspendfunction fcp_notifyfunction fcp_init_notifyfunction fcp_initfunction fcp_init_privatefunction interfacefunction snd_fcp_init
Annotated Snippet
struct fcp_notify {
wait_queue_head_t queue;
u32 event;
spinlock_t lock;
};
struct fcp_data {
struct usb_mixer_interface *mixer;
struct mutex mutex; /* serialise access to the device */
struct completion cmd_done; /* wait for command completion */
struct file *file; /* hwdep file */
struct fcp_notify notify;
u8 bInterfaceNumber;
u8 bEndpointAddress;
u16 wMaxPacketSize;
u8 bInterval;
uint16_t step0_resp_size;
uint16_t step2_resp_size;
uint32_t init1_opcode;
uint32_t init2_opcode;
u8 init;
u16 seq;
u8 num_meter_slots;
s16 *meter_level_map;
__le32 *meter_levels;
struct snd_kcontrol *meter_ctl;
unsigned int *meter_labels_tlv;
int meter_labels_tlv_size;
};
/*** USB Interactions ***/
/* FCP Command ACK notification bit */
#define FCP_NOTIFY_ACK 1
/* Vendor-specific USB control requests */
#define FCP_USB_REQ_STEP0 0
#define FCP_USB_REQ_CMD_TX 2
#define FCP_USB_REQ_CMD_RX 3
/* Focusrite Control Protocol opcodes that the kernel side needs to
* know about
*/
#define FCP_USB_REBOOT 0x00000003
#define FCP_USB_GET_METER 0x00001001
#define FCP_USB_FLASH_ERASE 0x00004002
#define FCP_USB_FLASH_WRITE 0x00004004
#define FCP_USB_METER_LEVELS_GET_MAGIC 1
#define FCP_SEGMENT_APP_GOLD 0
/* Forward declarations */
static int fcp_init(struct usb_mixer_interface *mixer,
void *step0_resp, void *step2_resp);
/* FCP command request/response format */
struct fcp_usb_packet {
__le32 opcode;
__le16 size;
__le16 seq;
__le32 error;
__le32 pad;
u8 data[];
};
static void fcp_fill_request_header(struct fcp_data *private,
struct fcp_usb_packet *req,
u32 opcode, u16 req_size)
{
/* sequence must go up by 1 for each request */
u16 seq = private->seq++;
req->opcode = cpu_to_le32(opcode);
req->size = cpu_to_le16(req_size);
req->seq = cpu_to_le16(seq);
req->error = 0;
req->pad = 0;
}
static int fcp_usb_tx(struct usb_device *dev, int interface,
void *buf, u16 size)
{
Annotation
- Immediate include surface: `linux/slab.h`, `linux/usb.h`, `sound/control.h`, `sound/hwdep.h`, `sound/tlv.h`, `uapi/sound/fcp.h`, `usbaudio.h`, `mixer.h`.
- Detected declarations: `struct fcp_notify`, `struct fcp_data`, `struct fcp_usb_packet`, `function fcp_fill_request_header`, `function fcp_usb_tx`, `function fcp_usb_rx`, `function fcp_usb`, `function fcp_reinit`, `function fcp_add_new_ctl`, `function fcp_meter_ctl_info`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.