linux/sound/usb/quirks.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 */

#include <linux/init.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/usb/audio.h>
#include <linux/usb/midi.h>
#include <linux/bits.h>

#include <sound/control.h>
#include <sound/core.h>
#include <sound/info.h>
#include <sound/pcm.h>

#include "usbaudio.h"
#include "card.h"
#include "mixer.h"
#include "mixer_quirks.h"
#include "midi.h"
#include "midi2.h"
#include "quirks.h"
#include "helper.h"
#include "endpoint.h"
#include "pcm.h"
#include "clock.h"
#include "stream.h"

/*
 * handle the quirks for the contained interfaces
 */
static int create_composite_quirk(struct snd_usb_audio *chip,
				  struct usb_interface *iface,
				  struct usb_driver *driver,
				  const struct snd_usb_audio_quirk *quirk_comp)
{}

static int ignore_interface_quirk(struct snd_usb_audio *chip,
				  struct usb_interface *iface,
				  struct usb_driver *driver,
				  const struct snd_usb_audio_quirk *quirk)
{}


static int create_any_midi_quirk(struct snd_usb_audio *chip,
				 struct usb_interface *intf,
				 struct usb_driver *driver,
				 const struct snd_usb_audio_quirk *quirk)
{}

/*
 * create a stream for an interface with proper descriptors
 */
static int create_standard_audio_quirk(struct snd_usb_audio *chip,
				       struct usb_interface *iface,
				       struct usb_driver *driver,
				       const struct snd_usb_audio_quirk *quirk)
{}

/* create the audio stream and the corresponding endpoints from the fixed
 * audioformat object; this is used for quirks with the fixed EPs
 */
static int add_audio_stream_from_fixed_fmt(struct snd_usb_audio *chip,
					   struct audioformat *fp)
{}

/*
 * create a stream for an endpoint/altsetting without proper descriptors
 */
static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
				     struct usb_interface *iface,
				     struct usb_driver *driver,
				     const struct snd_usb_audio_quirk *quirk)
{}

static int create_auto_pcm_quirk(struct snd_usb_audio *chip,
				 struct usb_interface *iface,
				 struct usb_driver *driver)
{}

static int create_yamaha_midi_quirk(struct snd_usb_audio *chip,
				    struct usb_interface *iface,
				    struct usb_driver *driver,
				    struct usb_host_interface *alts)
{}

static int create_roland_midi_quirk(struct snd_usb_audio *chip,
				    struct usb_interface *iface,
				    struct usb_driver *driver,
				    struct usb_host_interface *alts)
{}

static int create_std_midi_quirk(struct snd_usb_audio *chip,
				 struct usb_interface *iface,
				 struct usb_driver *driver,
				 struct usb_host_interface *alts)
{}

static int create_auto_midi_quirk(struct snd_usb_audio *chip,
				  struct usb_interface *iface,
				  struct usb_driver *driver)
{}

static int create_autodetect_quirk(struct snd_usb_audio *chip,
				   struct usb_interface *iface,
				   struct usb_driver *driver,
				   const struct snd_usb_audio_quirk *quirk)
{}

/*
 * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface.  
 * The only way to detect the sample rate is by looking at wMaxPacketSize.
 */
static int create_uaxx_quirk(struct snd_usb_audio *chip,
			     struct usb_interface *iface,
			     struct usb_driver *driver,
			     const struct snd_usb_audio_quirk *quirk)
{}

/*
 * Create a standard mixer for the specified interface.
 */
static int create_standard_mixer_quirk(struct snd_usb_audio *chip,
				       struct usb_interface *iface,
				       struct usb_driver *driver,
				       const struct snd_usb_audio_quirk *quirk)
{}

/*
 * audio-interface quirks
 *
 * returns zero if no standard audio/MIDI parsing is needed.
 * returns a positive value if standard audio/midi interfaces are parsed
 * after this.
 * returns a negative value at error.
 */
int snd_usb_create_quirk(struct snd_usb_audio *chip,
			 struct usb_interface *iface,
			 struct usb_driver *driver,
			 const struct snd_usb_audio_quirk *quirk)
{}

/*
 * boot quirks
 */

#define EXTIGY_FIRMWARE_SIZE_OLD
#define EXTIGY_FIRMWARE_SIZE_NEW

static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf)
{}

static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev)
{}

static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
{}

/*
 * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely
 * documented in the device's data sheet.
 */
static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg, u16 value)
{}

static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
{}

/*
 * CM6206 registers from the CM6206 datasheet rev 2.1
 */
#define CM6206_REG0_DMA_MASTER
#define CM6206_REG0_SPDIFO_RATE_48K
#define CM6206_REG0_SPDIFO_RATE_96K
/* Bit 4 thru 11 is the S/PDIF category code */
#define CM6206_REG0_SPDIFO_CAT_CODE_GENERAL
#define CM6206_REG0_SPDIFO_EMPHASIS_CD
#define CM6206_REG0_SPDIFO_COPYRIGHT_NA
#define CM6206_REG0_SPDIFO_NON_AUDIO
#define CM6206_REG0_SPDIFO_PRO_FORMAT

#define CM6206_REG1_TEST_SEL_CLK
#define CM6206_REG1_PLLBIN_EN
#define CM6206_REG1_SOFT_MUTE_EN
#define CM6206_REG1_GPIO4_OUT
#define CM6206_REG1_GPIO4_OE
#define CM6206_REG1_GPIO3_OUT
#define CM6206_REG1_GPIO3_OE
#define CM6206_REG1_GPIO2_OUT
#define CM6206_REG1_GPIO2_OE
#define CM6206_REG1_GPIO1_OUT
#define CM6206_REG1_GPIO1_OE
#define CM6206_REG1_SPDIFO_INVALID
#define CM6206_REG1_SPDIF_LOOP_EN
#define CM6206_REG1_SPDIFO_DIS
#define CM6206_REG1_SPDIFI_MIX

#define CM6206_REG2_DRIVER_ON
#define CM6206_REG2_HEADP_SEL_SIDE_CHANNELS
#define CM6206_REG2_HEADP_SEL_SURROUND_CHANNELS
#define CM6206_REG2_HEADP_SEL_CENTER_SUBW
#define CM6206_REG2_HEADP_SEL_FRONT_CHANNELS
#define CM6206_REG2_MUTE_HEADPHONE_RIGHT
#define CM6206_REG2_MUTE_HEADPHONE_LEFT
#define CM6206_REG2_MUTE_REAR_SURROUND_RIGHT
#define CM6206_REG2_MUTE_REAR_SURROUND_LEFT
#define CM6206_REG2_MUTE_SIDE_SURROUND_RIGHT
#define CM6206_REG2_MUTE_SIDE_SURROUND_LEFT
#define CM6206_REG2_MUTE_SUBWOOFER
#define CM6206_REG2_MUTE_CENTER
#define CM6206_REG2_MUTE_RIGHT_FRONT
#define CM6206_REG2_MUTE_LEFT_FRONT
#define CM6206_REG2_EN_BTL
#define CM6206_REG2_MCUCLKSEL_1_5_MHZ
#define CM6206_REG2_MCUCLKSEL_3_MHZ
#define CM6206_REG2_MCUCLKSEL_6_MHZ
#define CM6206_REG2_MCUCLKSEL_12_MHZ

/* Bit 11..13 sets the sensitivity to FLY tuner volume control VP/VD signal */
#define CM6206_REG3_FLYSPEED_DEFAULT
#define CM6206_REG3_VRAP25EN
#define CM6206_REG3_MSEL1
#define CM6206_REG3_SPDIFI_RATE_44_1K
#define CM6206_REG3_SPDIFI_RATE_48K
#define CM6206_REG3_SPDIFI_RATE_32K
#define CM6206_REG3_PINSEL
#define CM6206_REG3_FOE
#define CM6206_REG3_ROE
#define CM6206_REG3_CBOE
#define CM6206_REG3_LOSE
#define CM6206_REG3_HPOE
#define CM6206_REG3_SPDIFI_CANREC

#define CM6206_REG5_DA_RSTN
#define CM6206_REG5_AD_RSTN
#define CM6206_REG5_SPDIFO_AD2SPDO
#define CM6206_REG5_SPDIFO_SEL_FRONT
#define CM6206_REG5_SPDIFO_SEL_SIDE_SUR
#define CM6206_REG5_SPDIFO_SEL_CEN_LFE
#define CM6206_REG5_SPDIFO_SEL_REAR_SUR
#define CM6206_REG5_CODECM
#define CM6206_REG5_EN_HPF
#define CM6206_REG5_T_SEL_DSDA4
#define CM6206_REG5_T_SEL_DSDA3
#define CM6206_REG5_T_SEL_DSDA2
#define CM6206_REG5_T_SEL_DSDA1
#define CM6206_REG5_T_SEL_DSDAD_NORMAL
#define CM6206_REG5_T_SEL_DSDAD_FRONT
#define CM6206_REG5_T_SEL_DSDAD_S_SURROUND
#define CM6206_REG5_T_SEL_DSDAD_CEN_LFE
#define CM6206_REG5_T_SEL_DSDAD_R_SURROUND

static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
{}

/* quirk for Plantronics GameCom 780 with CM6302 chip */
static int snd_usb_gamecon780_boot_quirk(struct usb_device *dev)
{}

/*
 * Novation Twitch DJ controller
 * Focusrite Novation Saffire 6 USB audio card
 */
static int snd_usb_novation_boot_quirk(struct usb_device *dev)
{}

/*
 * This call will put the synth in "USB send" mode, i.e it will send MIDI
 * messages through USB (this is disabled at startup). The synth will
 * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB
 * sign on its LCD. Values here are chosen based on sniffing USB traffic
 * under Windows.
 */
static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev)
{}

/*
 * Some sound cards from Native Instruments are in fact compliant to the USB
 * audio standard of version 2 and other approved USB standards, even though
 * they come up as vendor-specific device when first connected.
 *
 * However, they can be told to come up with a new set of descriptors
 * upon their next enumeration, and the interfaces announced by the new
 * descriptors will then be handled by the kernel's class drivers. As the
 * product ID will also change, no further checks are required.
 */

static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev)
{}

static void mbox2_setup_48_24_magic(struct usb_device *dev)
{}

/* Digidesign Mbox 2 needs to load firmware onboard
 * and driver must wait a few seconds for initialisation.
 */

#define MBOX2_FIRMWARE_SIZE
#define MBOX2_BOOT_LOADING
#define MBOX2_BOOT_READY

static int snd_usb_mbox2_boot_quirk(struct usb_device *dev)
{}

static int snd_usb_axefx3_boot_quirk(struct usb_device *dev)
{}

static void mbox3_setup_defaults(struct usb_device *dev)
{}

#define MBOX3_DESCRIPTOR_SIZE

static int snd_usb_mbox3_boot_quirk(struct usb_device *dev)
{}

#define MICROBOOK_BUF_SIZE

static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf,
						int buf_size, int *length)
{}

static int snd_usb_motu_microbookii_boot_quirk(struct usb_device *dev)
{}

static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev)
{}

/*
 * Setup quirks
 */
#define MAUDIO_SET
#define MAUDIO_SET_COMPATIBLE
#define MAUDIO_SET_DTS
#define MAUDIO_SET_96K
#define MAUDIO_SET_24B
#define MAUDIO_SET_DI
#define MAUDIO_SET_MASK
#define MAUDIO_SET_24B_48K_DI
#define MAUDIO_SET_24B_48K_NOTDI
#define MAUDIO_SET_16B_48K_DI
#define MAUDIO_SET_16B_48K_NOTDI

static int quattro_skip_setting_quirk(struct snd_usb_audio *chip,
				      int iface, int altno)
{}

static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
					 int iface,
					 int altno)
{}

static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
					   int iface, int altno)
{}

static int s1810c_skip_setting_quirk(struct snd_usb_audio *chip,
					   int iface, int altno)
{}

int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip,
				  int iface,
				  int altno)
{}

int snd_usb_apply_boot_quirk(struct usb_device *dev,
			     struct usb_interface *intf,
			     const struct snd_usb_audio_quirk *quirk,
			     unsigned int id)
{}

int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
				  struct usb_interface *intf,
				  const struct snd_usb_audio_quirk *quirk,
				  unsigned int id)
{}

/*
 * check if the device uses big-endian samples
 */
int snd_usb_is_big_endian_format(struct snd_usb_audio *chip,
				 const struct audioformat *fp)
{}

/*
 * For E-Mu 0404USB/0202USB/TrackerPre/0204 sample rate should be set for device,
 * not for interface.
 */

enum {};

static void set_format_emu_quirk(struct snd_usb_substream *subs,
				 const struct audioformat *fmt)
{}

static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs,
					u16 windex)
{}

static void mbox3_set_format_quirk(struct snd_usb_substream *subs,
				const struct audioformat *fmt)
{}

void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
			      const struct audioformat *fmt)
{}

int snd_usb_select_mode_quirk(struct snd_usb_audio *chip,
			      const struct audioformat *fmt)
{}

void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
{}

/* quirk applied after snd_usb_ctl_msg(); not applied during boot quirks */
void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
			   __u8 request, __u8 requesttype, __u16 value,
			   __u16 index, void *data, __u16 size)
{}

/*
 * snd_usb_interface_dsd_format_quirks() is called from format.c to
 * augment the PCM format bit-field for DSD types. The UAC standards
 * don't have a designated bit field to denote DSD-capable interfaces,
 * hence all hardware that is known to support this format has to be
 * listed here.
 */
u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
					struct audioformat *fp,
					unsigned int sample_bytes)
{}

void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
					  struct audioformat *fp,
					  int stream)
{}

/*
 * driver behavior quirk flags
 */
struct usb_audio_quirk_flags_table {};

#define DEVICE_FLG(vid, pid, _flags)
#define VENDOR_FLG(vid, _flags)

static const struct usb_audio_quirk_flags_table quirk_flags_table[] =;

void snd_usb_init_quirk_flags(struct snd_usb_audio *chip)
{}