/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */1/*2* Focusrite Control Protocol Driver for ALSA3*4* Copyright (c) 2024-2025 by Geoffrey D. Bennett <g at b4.vu>5*/6/*7* DOC: FCP (Focusrite Control Protocol) User-Space API8*9* This header defines the interface between the FCP kernel driver and10* user-space programs to enable the use of the proprietary features11* available in Focusrite USB audio interfaces. This includes Scarlett12* 2nd Gen, 3rd Gen, 4th Gen, Clarett USB, Clarett+, and Vocaster13* series devices.14*15* The interface is provided via ALSA's hwdep interface. Opening the16* hwdep device requires CAP_SYS_RAWIO privileges as this interface17* provides near-direct access.18*19* For details on the FCP protocol, refer to the kernel scarlett220* driver in sound/usb/mixer_scarlett2.c and the fcp-support project21* at https://github.com/geoffreybennett/fcp-support22*23* For examples of using these IOCTLs, see the fcp-server source in24* the fcp-support project.25*26* IOCTL Interface27* --------------28* FCP_IOCTL_PVERSION:29* Returns the protocol version supported by the driver.30*31* FCP_IOCTL_INIT:32* Initialises the protocol and synchronises sequence numbers33* between the driver and device. Must be called at least once34* before sending commands. Can be safely called again at any time.35*36* FCP_IOCTL_CMD:37* Sends an FCP command to the device and returns the response.38* Requires prior initialisation via FCP_IOCTL_INIT.39*40* FCP_IOCTL_SET_METER_MAP:41* Configures the Level Meter control's mapping between device42* meters and control channels. Requires FCP_IOCTL_INIT to have been43* called first. The map size and number of slots cannot be changed44* after initial configuration, although the map itself can be45* updated. Once configured, the Level Meter remains functional even46* after the hwdep device is closed.47*48* FCP_IOCTL_SET_METER_LABELS:49* Set the labels for the Level Meter control. Requires50* FCP_IOCTL_SET_METER_MAP to have been called first. labels[]51* should contain a sequence of null-terminated labels corresponding52* to the control's channels.53*/54#ifndef __UAPI_SOUND_FCP_H55#define __UAPI_SOUND_FCP_H5657#include <linux/types.h>58#include <linux/ioctl.h>5960#define FCP_HWDEP_MAJOR 261#define FCP_HWDEP_MINOR 062#define FCP_HWDEP_SUBMINOR 06364#define FCP_HWDEP_VERSION \65((FCP_HWDEP_MAJOR << 16) | \66(FCP_HWDEP_MINOR << 8) | \67FCP_HWDEP_SUBMINOR)6869#define FCP_HWDEP_VERSION_MAJOR(v) (((v) >> 16) & 0xFF)70#define FCP_HWDEP_VERSION_MINOR(v) (((v) >> 8) & 0xFF)71#define FCP_HWDEP_VERSION_SUBMINOR(v) ((v) & 0xFF)7273/* Get protocol version */74#define FCP_IOCTL_PVERSION _IOR('S', 0x60, int)7576/* Start the protocol */7778/* Step 0 and step 2 responses are variable length and placed in79* resp[] one after the other.80*/81struct fcp_init {82__u16 step0_resp_size;83__u16 step2_resp_size;84__u32 init1_opcode;85__u32 init2_opcode;86__u8 resp[];87} __attribute__((packed));8889#define FCP_IOCTL_INIT _IOWR('S', 0x64, struct fcp_init)9091/* Perform a command */9293/* The request data is placed in data[] and the response data will94* overwrite it.95*/96struct fcp_cmd {97__u32 opcode;98__u16 req_size;99__u16 resp_size;100__u8 data[];101} __attribute__((packed));102#define FCP_IOCTL_CMD _IOWR('S', 0x65, struct fcp_cmd)103104/* Set the meter map */105struct fcp_meter_map {106__u16 map_size;107__u16 meter_slots;108__s16 map[];109} __attribute__((packed));110#define FCP_IOCTL_SET_METER_MAP _IOW('S', 0x66, struct fcp_meter_map)111112/* Set the meter labels */113struct fcp_meter_labels {114__u16 labels_size;115char labels[];116} __attribute__((packed));117#define FCP_IOCTL_SET_METER_LABELS _IOW('S', 0x67, struct fcp_meter_labels)118119#endif /* __UAPI_SOUND_FCP_H */120121122