cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

usbaudio.h (6190B)


      1/* SPDX-License-Identifier: GPL-2.0-or-later */
      2#ifndef __USBAUDIO_H
      3#define __USBAUDIO_H
      4/*
      5 *   (Tentative) USB Audio Driver for ALSA
      6 *
      7 *   Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
      8 */
      9
     10/* handling of USB vendor/product ID pairs as 32-bit numbers */
     11#define USB_ID(vendor, product) (((unsigned int)(vendor) << 16) | (product))
     12#define USB_ID_VENDOR(id) ((id) >> 16)
     13#define USB_ID_PRODUCT(id) ((u16)(id))
     14
     15/*
     16 *
     17 */
     18
     19struct media_device;
     20struct media_intf_devnode;
     21
     22#define MAX_CARD_INTERFACES	16
     23
     24struct snd_usb_audio {
     25	int index;
     26	struct usb_device *dev;
     27	struct snd_card *card;
     28	struct usb_interface *intf[MAX_CARD_INTERFACES];
     29	u32 usb_id;
     30	uint16_t quirk_type;
     31	struct mutex mutex;
     32	unsigned int system_suspend;
     33	atomic_t active;
     34	atomic_t shutdown;
     35	atomic_t usage_count;
     36	wait_queue_head_t shutdown_wait;
     37	unsigned int quirk_flags;
     38	unsigned int need_delayed_register:1; /* warn for delayed registration */
     39	int num_interfaces;
     40	int num_suspended_intf;
     41	int sample_rate_read_error;
     42
     43	int badd_profile;		/* UAC3 BADD profile */
     44
     45	struct list_head pcm_list;	/* list of pcm streams */
     46	struct list_head ep_list;	/* list of audio-related endpoints */
     47	struct list_head iface_ref_list; /* list of interface refcounts */
     48	struct list_head clock_ref_list; /* list of clock refcounts */
     49	int pcm_devs;
     50
     51	struct list_head midi_list;	/* list of midi interfaces */
     52
     53	struct list_head mixer_list;	/* list of mixer interfaces */
     54
     55	int setup;			/* from the 'device_setup' module param */
     56	bool generic_implicit_fb;	/* from the 'implicit_fb' module param */
     57	bool autoclock;			/* from the 'autoclock' module param */
     58
     59	bool lowlatency;		/* from the 'lowlatency' module param */
     60	struct usb_host_interface *ctrl_intf;	/* the audio control interface */
     61	struct media_device *media_dev;
     62	struct media_intf_devnode *ctl_intf_media_devnode;
     63};
     64
     65#define USB_AUDIO_IFACE_UNUSED	((void *)-1L)
     66
     67#define usb_audio_err(chip, fmt, args...) \
     68	dev_err(&(chip)->dev->dev, fmt, ##args)
     69#define usb_audio_warn(chip, fmt, args...) \
     70	dev_warn(&(chip)->dev->dev, fmt, ##args)
     71#define usb_audio_info(chip, fmt, args...) \
     72	dev_info(&(chip)->dev->dev, fmt, ##args)
     73#define usb_audio_dbg(chip, fmt, args...) \
     74	dev_dbg(&(chip)->dev->dev, fmt, ##args)
     75
     76/*
     77 * Information about devices with broken descriptors
     78 */
     79
     80/* special values for .ifnum */
     81#define QUIRK_NODEV_INTERFACE		-3	/* return -ENODEV */
     82#define QUIRK_NO_INTERFACE		-2
     83#define QUIRK_ANY_INTERFACE		-1
     84
     85enum quirk_type {
     86	QUIRK_IGNORE_INTERFACE,
     87	QUIRK_COMPOSITE,
     88	QUIRK_AUTODETECT,
     89	QUIRK_MIDI_STANDARD_INTERFACE,
     90	QUIRK_MIDI_FIXED_ENDPOINT,
     91	QUIRK_MIDI_YAMAHA,
     92	QUIRK_MIDI_ROLAND,
     93	QUIRK_MIDI_MIDIMAN,
     94	QUIRK_MIDI_NOVATION,
     95	QUIRK_MIDI_RAW_BYTES,
     96	QUIRK_MIDI_EMAGIC,
     97	QUIRK_MIDI_CME,
     98	QUIRK_MIDI_AKAI,
     99	QUIRK_MIDI_US122L,
    100	QUIRK_MIDI_FTDI,
    101	QUIRK_MIDI_CH345,
    102	QUIRK_AUDIO_STANDARD_INTERFACE,
    103	QUIRK_AUDIO_FIXED_ENDPOINT,
    104	QUIRK_AUDIO_EDIROL_UAXX,
    105	QUIRK_AUDIO_STANDARD_MIXER,
    106
    107	QUIRK_TYPE_COUNT
    108};
    109
    110struct snd_usb_audio_quirk {
    111	const char *vendor_name;
    112	const char *product_name;
    113	int16_t ifnum;
    114	uint16_t type;
    115	const void *data;
    116};
    117
    118#define combine_word(s)    ((*(s)) | ((unsigned int)(s)[1] << 8))
    119#define combine_triple(s)  (combine_word(s) | ((unsigned int)(s)[2] << 16))
    120#define combine_quad(s)    (combine_triple(s) | ((unsigned int)(s)[3] << 24))
    121
    122int snd_usb_lock_shutdown(struct snd_usb_audio *chip);
    123void snd_usb_unlock_shutdown(struct snd_usb_audio *chip);
    124
    125extern bool snd_usb_use_vmalloc;
    126extern bool snd_usb_skip_validation;
    127
    128/*
    129 * Driver behavior quirk flags, stored in chip->quirk_flags
    130 *
    131 * QUIRK_FLAG_GET_SAMPLE_RATE:
    132 *  Skip reading sample rate for devices, as some devices behave inconsistently
    133 *  or return error
    134 * QUIRK_FLAG_SHARE_MEDIA_DEVICE:
    135 *  Create Media Controller API entries
    136 * QUIRK_FLAG_ALIGN_TRANSFER:
    137 *  Allow alignment on audio sub-slot (channel samples) rather than on audio
    138 *  slots (audio frames)
    139 * QUIRK_TX_LENGTH:
    140 *  Add length specifier to transfers
    141 * QUIRK_FLAG_PLAYBACK_FIRST:
    142 *  Start playback stream at first even in implement feedback mode
    143 * QUIRK_FLAG_SKIP_CLOCK_SELECTOR:
    144 *  Skip clock selector setup; the device may reset to invalid state
    145 * QUIRK_FLAG_IGNORE_CLOCK_SOURCE:
    146 *  Ignore errors from clock source search; i.e. hardcoded clock
    147 * QUIRK_FLAG_ITF_USB_DSD_DAC:
    148 *  Indicates the device is for ITF-USB DSD based DACs that need a vendor cmd
    149 *  to switch between PCM and native DSD mode
    150 * QUIRK_FLAG_CTL_MSG_DELAY:
    151 *  Add a delay of 20ms at each control message handling
    152 * QUIRK_FLAG_CTL_MSG_DELAY_1M:
    153 *  Add a delay of 1-2ms at each control message handling
    154 * QUIRK_FLAG_CTL_MSG_DELAY_5M:
    155 *  Add a delay of 5-6ms at each control message handling
    156 * QUIRK_FLAG_IFACE_DELAY:
    157 *  Add a delay of 50ms at each interface setup
    158 * QUIRK_FLAG_VALIDATE_RATES:
    159 *  Perform sample rate validations at probe
    160 * QUIRK_FLAG_DISABLE_AUTOSUSPEND:
    161 *  Disable runtime PM autosuspend
    162 * QUIRK_FLAG_IGNORE_CTL_ERROR:
    163 *  Ignore errors for mixer access
    164 * QUIRK_FLAG_DSD_RAW:
    165 *  Support generic DSD raw U32_BE format
    166 * QUIRK_FLAG_SET_IFACE_FIRST:
    167 *  Set up the interface at first like UAC1
    168 * QUIRK_FLAG_GENERIC_IMPLICIT_FB
    169 *  Apply the generic implicit feedback sync mode (same as implicit_fb=1 option)
    170 * QUIRK_FLAG_SKIP_IMPLICIT_FB
    171 *  Don't apply implicit feedback sync mode
    172 */
    173
    174#define QUIRK_FLAG_GET_SAMPLE_RATE	(1U << 0)
    175#define QUIRK_FLAG_SHARE_MEDIA_DEVICE	(1U << 1)
    176#define QUIRK_FLAG_ALIGN_TRANSFER	(1U << 2)
    177#define QUIRK_FLAG_TX_LENGTH		(1U << 3)
    178#define QUIRK_FLAG_PLAYBACK_FIRST	(1U << 4)
    179#define QUIRK_FLAG_SKIP_CLOCK_SELECTOR	(1U << 5)
    180#define QUIRK_FLAG_IGNORE_CLOCK_SOURCE	(1U << 6)
    181#define QUIRK_FLAG_ITF_USB_DSD_DAC	(1U << 7)
    182#define QUIRK_FLAG_CTL_MSG_DELAY	(1U << 8)
    183#define QUIRK_FLAG_CTL_MSG_DELAY_1M	(1U << 9)
    184#define QUIRK_FLAG_CTL_MSG_DELAY_5M	(1U << 10)
    185#define QUIRK_FLAG_IFACE_DELAY		(1U << 11)
    186#define QUIRK_FLAG_VALIDATE_RATES	(1U << 12)
    187#define QUIRK_FLAG_DISABLE_AUTOSUSPEND	(1U << 13)
    188#define QUIRK_FLAG_IGNORE_CTL_ERROR	(1U << 14)
    189#define QUIRK_FLAG_DSD_RAW		(1U << 15)
    190#define QUIRK_FLAG_SET_IFACE_FIRST	(1U << 16)
    191#define QUIRK_FLAG_GENERIC_IMPLICIT_FB	(1U << 17)
    192#define QUIRK_FLAG_SKIP_IMPLICIT_FB	(1U << 18)
    193
    194#endif /* __USBAUDIO_H */