b84ad15be5
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmbCv24ACgkQONu9yGCS aT7lNRAAzP2lSCUHROaMTldoQdahqoWqwFSiMI9p32HYLTerpg1GHVsi1IUvD+pv zhmUG9w+ACbSbZ9337G61FeEDCIBzgqaIXLCtbK2Be9nWMa9I1ZtMSFUKoSmVJBw YbrI/UOscJmAf44G6DeMp+N+/S2o7INK463u51SYjufo/zhFF8KsYElm23p06kgn lTkkUAoo9mSVvEr64zbjwLrWyBWTlcvYH/xrkWeJWXl+hBv0K5Ig9IBm0sc0DSQR fErADzDLFkmD9pduZbMwbzUUzC8ST41KKjTgClaHQhSMeoLoWT8CJM5Swwds4XVE JkoClkqnj3+stYFpLFm9UUgZ12wu/9slzgRCN6fTraSNT8gE9F9BRJXFGL+3S5OO oHKZYEEPTZDsD3PihgufJ4Ft27+KpMUzAgQUmVH/y47wrVJ2pf4fCK8LKT0MbjBi pjZaDRCxwo1aORL3+jYJBVRecrNqQ0DhacYOKznhb2KKeaHojIwLaE6k/W/0Q8U5 1uMYv+NJ3LWDNzGcNUTCfNtuDELOpkp24Xc8RN0MK2iMMMyfjMpgKssjSBZtz0QW NH0UVpfiWKECKH+m03NeFnYdMuK8/VyM8vatkcemz0FfgJP2UazeiVwSujfS2r2S 0TtsCMPP3kgKa9mAnni7lQs4wkG+OTNDNZqbuDqFZ1rHUS2Usrg= =8i2e -----END PGP SIGNATURE----- Merge 5.10.224 into android12-5.10-lts Changes in 5.10.224 EDAC/skx_common: Add new ADXL components for 2-level memory EDAC, i10nm: make skx_common.o a separate module platform/chrome: cros_ec_debugfs: fix wrong EC message version hfsplus: fix to avoid false alarm of circular locking x86/of: Return consistent error type from x86_of_pci_irq_enable() x86/pci/intel_mid_pci: Fix PCIBIOS_* return code handling x86/pci/xen: Fix PCIBIOS_* return code handling x86/platform/iosf_mbi: Convert PCIBIOS_* return codes to errnos hwmon: (adt7475) Fix default duty on fan is disabled pwm: stm32: Always do lazy disabling hwmon: (max6697) Fix underflow when writing limit attributes hwmon: (max6697) Fix swapped temp{1,8} critical alarms arm64: dts: qcom: sdm845: add power-domain to UFS PHY soc: qcom: rpmh-rsc: Ensure irqs aren't disabled by rpmh_rsc_send_data() callers arm64: dts: qcom: msm8996: specify UFS core_clk frequencies soc: qcom: pdr: protect locator_addr with the main mutex soc: qcom: pdr: fix parsing of domains lists arm64: dts: rockchip: Increase VOP clk rate on RK3328 ARM: dts: imx6qdl-kontron-samx6i: move phy reset into phy-node ARM: dts: imx6qdl-kontron-samx6i: fix PHY reset ARM: dts: imx6qdl-kontron-samx6i: fix board reset ARM: dts: imx6qdl-kontron-samx6i: fix SPI0 chip selects ARM: dts: imx6qdl-kontron-samx6i: fix PCIe reset polarity arm64: dts: mediatek: mt8183-kukui: Drop bogus output-enable property arm64: dts: mediatek: mt7622: fix "emmc" pinctrl mux arm64: dts: amlogic: gx: correct hdmi clocks m68k: atari: Fix TT bootup freeze / unexpected (SCU) interrupt messages x86/xen: Convert comma to semicolon m68k: cmpxchg: Fix return value for default case in __arch_xchg() ARM: pxa: spitz: use gpio descriptors for audio ARM: spitz: fix GPIO assignment for backlight firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout() firmware: turris-mox-rwtm: Initialize completion before mailbox wifi: brcmsmac: LCN PHY code is used for BCM4313 2G-only device selftests/bpf: Fix prog numbers in test_sockmap net: esp: cleanup esp_output_tail_tcp() in case of unsupported ESPINTCP net/smc: Allow SMC-D 1MB DMB allocations net/smc: set rmb's SG_MAX_SINGLE_ALLOC limitation only when CONFIG_ARCH_NO_SG_CHAIN is defined selftests/bpf: Check length of recv in test_sockmap lib: objagg: Fix general protection fault mlxsw: spectrum_acl_erp: Fix object nesting warning mlxsw: spectrum_acl_bloom_filter: Make mlxsw_sp_acl_bf_key_encode() more flexible mlxsw: spectrum_acl: Fix ACL scale regression and firmware errors ath11k: dp: stop rx pktlog before suspend wifi: ath11k: fix wrong handling of CCMP256 and GCMP ciphers wifi: cfg80211: fix typo in cfg80211_calculate_bitrate_he() wifi: cfg80211: handle 2x996 RU allocation in cfg80211_calculate_bitrate_he() net: fec: Refactor: #define magic constants net: fec: Fix FEC_ECR_EN1588 being cleared on link-down ipvs: Avoid unnecessary calls to skb_is_gso_sctp netfilter: nf_tables: rise cap on SELinux secmark context perf/x86/intel/pt: Fix pt_topa_entry_for_page() address calculation perf: Fix perf_aux_size() for greater-than 32-bit size perf: Prevent passing zero nr_pages to rb_alloc_aux() qed: Improve the stack space of filter_config() wifi: virt_wifi: avoid reporting connection success with wrong SSID gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey wifi: virt_wifi: don't use strlen() in const context selftests/bpf: Close fd in error path in drop_on_reuseport bpf: annotate BTF show functions with __printf bna: adjust 'name' buf size of bna_tcb and bna_ccb structures bpf: Eliminate remaining "make W=1" warnings in kernel/bpf/btf.o selftests: forwarding: devlink_lib: Wait for udev events after reloading xdp: fix invalid wait context of page_pool_destroy() drm/panel: boe-tv101wum-nl6: If prepare fails, disable GPIO before regulators drm/panel: boe-tv101wum-nl6: Check for errors on the NOP in prepare() media: dvb-usb: Fix unexpected infinite loop in dvb_usb_read_remote_control() media: imon: Fix race getting ictx->lock saa7134: Unchecked i2c_transfer function result fixed media: uvcvideo: Allow entity-defined get_info and get_cur media: uvcvideo: Override default flags media: renesas: vsp1: Fix _irqsave and _irq mix media: renesas: vsp1: Store RPF partition configuration per RPF instance leds: trigger: Unregister sysfs attributes before calling deactivate() perf report: Fix condition in sort__sym_cmp() drm/etnaviv: fix DMA direction handling for cached RW buffers drm/qxl: Add check for drm_cvt_mode Revert "leds: led-core: Fix refcount leak in of_led_get()" ext4: fix infinite loop when replaying fast_commit media: venus: flush all buffers in output plane streamoff mfd: omap-usb-tll: Use struct_size to allocate tll xprtrdma: Rename frwr_release_mr() xprtrdma: Fix rpcrdma_reqs_reset() SUNRPC: avoid soft lockup when transmitting UDP to reachable server. ext4: avoid writing unitialized memory to disk in EA inodes sparc64: Fix incorrect function signature and add prototype for prom_cif_init SUNRPC: Fixup gss_status tracepoint error output PCI: Fix resource double counting on remove & rescan coresight: Fix ref leak when of_coresight_parse_endpoint() fails Input: qt1050 - handle CHIP_ID reading error RDMA/mlx4: Fix truncated output warning in mad.c RDMA/mlx4: Fix truncated output warning in alias_GUID.c RDMA/rxe: Don't set BTH_ACK_MASK for UC or UD QPs ASoC: max98088: Check for clk_prepare_enable() error mtd: make mtd_test.c a separate module RDMA/device: Return error earlier if port in not valid Input: elan_i2c - do not leave interrupt disabled on suspend failure MIPS: Octeron: remove source file executable bit powerpc/xmon: Fix disassembly CPU feature checks macintosh/therm_windtunnel: fix module unload. RDMA/hns: Fix missing pagesize and alignment check in FRMR bnxt_re: Fix imm_data endianness netfilter: ctnetlink: use helper function to calculate expect ID net: dsa: mv88e6xxx: Limit chip-wide frame size config to CPU ports net: dsa: b53: Limit chip-wide jumbo frame config to CPU ports pinctrl: rockchip: update rk3308 iomux routes pinctrl: core: fix possible memory leak when pinctrl_enable() fails pinctrl: single: fix possible memory leak when pinctrl_enable() fails pinctrl: ti: ti-iodelay: Drop if block with always false condition pinctrl: ti: ti-iodelay: fix possible memory leak when pinctrl_enable() fails pinctrl: freescale: mxs: Fix refcount of child fs/proc/task_mmu: indicate PM_FILE for PMD-mapped file THP fs/nilfs2: remove some unused macros to tame gcc nilfs2: avoid undefined behavior in nilfs_cnt32_ge macro rtc: interface: Add RTC offset to alarm after fix-up dt-bindings: thermal: correct thermal zone node name limit tick/broadcast: Make takeover of broadcast hrtimer reliable net: netconsole: Disable target before netpoll cleanup af_packet: Handle outgoing VLAN packets without hardware offloading ipv6: take care of scope when choosing the src addr sched/fair: set_load_weight() must also call reweight_task() for SCHED_IDLE tasks char: tpm: Fix possible memory leak in tpm_bios_measurements_open() media: venus: fix use after free in vdec_close hfs: fix to initialize fields of hfs_inode_info after hfs_alloc_inode() ext2: Verify bitmap and itable block numbers before using them drm/gma500: fix null pointer dereference in cdv_intel_lvds_get_modes drm/gma500: fix null pointer dereference in psb_intel_lvds_get_modes scsi: qla2xxx: Fix optrom version displayed in FDMI drm/amd/display: Check for NULL pointer sched/fair: Use all little CPUs for CPU-bound workloads apparmor: use kvfree_sensitive to free data->data task_work: s/task_work_cancel()/task_work_cancel_func()/ task_work: Introduce task_work_cancel() again udf: Avoid using corrupted block bitmap buffer m68k: amiga: Turn off Warp1260 interrupts during boot ext4: check dot and dotdot of dx_root before making dir indexed ext4: make sure the first directory block is not a hole wifi: mwifiex: Fix interface type change leds: ss4200: Convert PCIBIOS_* return codes to errnos jbd2: make jbd2_journal_get_max_txn_bufs() internal KVM: VMX: Split out the non-virtualization part of vmx_interrupt_blocked() tools/memory-model: Fix bug in lock.cat hwrng: amd - Convert PCIBIOS_* return codes to errnos PCI: hv: Return zero, not garbage, when reading PCI_INTERRUPT_PIN PCI: rockchip: Use GPIOD_OUT_LOW flag while requesting ep_gpio binder: fix hang of unregistered readers dev/parport: fix the array out-of-bounds risk scsi: qla2xxx: Return ENOBUFS if sg_cnt is more than one for ELS cmds f2fs: fix to don't dirty inode for readonly filesystem clk: davinci: da8xx-cfgchip: Initialize clk_init_data before use ubi: eba: properly rollback inside self_check_eba decompress_bunzip2: fix rare decompression failure kbuild: Fix '-S -c' in x86 stack protector scripts kobject_uevent: Fix OOB access within zap_modalias_env() devres: Fix devm_krealloc() wasting memory rtc: cmos: Fix return value of nvmem callbacks scsi: qla2xxx: During vport delete send async logout explicitly scsi: qla2xxx: Fix for possible memory corruption scsi: qla2xxx: Fix flash read failure scsi: qla2xxx: Complete command early within lock scsi: qla2xxx: validate nvme_local_port correctly perf/x86/intel/pt: Fix topa_entry base length perf/x86/intel/pt: Fix a topa_entry base address calculation rtc: isl1208: Fix return value of nvmem callbacks watchdog/perf: properly initialize the turbo mode timestamp and rearm counter platform: mips: cpu_hwmon: Disable driver on unsupported hardware RDMA/iwcm: Fix a use-after-free related to destroying CM IDs selftests/sigaltstack: Fix ppc64 GCC build rbd: don't assume rbd_is_lock_owner() for exclusive mappings MIPS: ip30: ip30-console: Add missing include MIPS: Loongson64: env: Hook up Loongsson-2K drm/panfrost: Mark simple_ondemand governor as softdep rbd: rename RBD_LOCK_STATE_RELEASING and releasing_wait rbd: don't assume RBD_LOCK_STATE_LOCKED for exclusive mappings Bluetooth: btusb: Add RTL8852BE device 0489:e125 to device tables Bluetooth: btusb: Add Realtek RTL8852BE support ID 0x13d3:0x3591 nilfs2: handle inconsistent state in nilfs_btnode_create_block() io_uring/io-wq: limit retrying worker initialisation kernel: rerun task_work while freezing in get_signal() kdb: address -Wformat-security warnings kdb: Use the passed prompt in kdb_position_cursor() jfs: Fix array-index-out-of-bounds in diFree um: time-travel: fix time-travel-start option f2fs: fix start segno of large section libbpf: Fix no-args func prototype BTF dumping syntax dma: fix call order in dmam_free_coherent MIPS: SMP-CPS: Fix address for GCR_ACCESS register for CM3 and later ipv4: Fix incorrect source address in Record Route option net: bonding: correctly annotate RCU in bond_should_notify_peers() netfilter: nft_set_pipapo_avx2: disable softinterrupts tipc: Return non-zero value from tipc_udp_addr2str() on error net: stmmac: Correct byte order of perfect_match net: nexthop: Initialize all fields in dumped nexthops bpf: Fix a segment issue when downgrading gso_size mISDN: Fix a use after free in hfcmulti_tx() apparmor: Fix null pointer deref when receiving skb during sock creation powerpc: fix a file leak in kvm_vcpu_ioctl_enable_cap() lirc: rc_dev_get_from_fd(): fix file leak ASoC: Intel: use soc_intel_is_byt_cr() only when IOSF_MBI is reachable ceph: fix incorrect kmalloc size of pagevec mempool nvme: split command copy into a helper nvme-pci: add missing condition check for existence of mapped data fs: don't allow non-init s_user_ns for filesystems without FS_USERNS_MOUNT powerpc/configs: Update defconfig with now user-visible CONFIG_FSL_IFC fuse: name fs_context consistently fuse: verify {g,u}id mount options correctly sysctl: always initialize i_uid/i_gid ext4: factor out a common helper to query extent map ext4: check the extent status again before inserting delalloc block soc: xilinx: move PM_INIT_FINALIZE to zynqmp_pm_domains driver drivers: soc: xilinx: check return status of get_api_version() driver core: Cast to (void *) with __force for __percpu pointer devres: Fix memory leakage caused by driver API devm_free_percpu() genirq: Allow the PM device to originate from irq domain irqchip/imx-irqsteer: Constify irq_chip struct irqchip/imx-irqsteer: Add runtime PM support irqchip/imx-irqsteer: Handle runtime power management correctly remoteproc: imx_rproc: ignore mapping vdev regions remoteproc: imx_rproc: Fix ignoring mapping vdev regions remoteproc: imx_rproc: Skip over memory region when node value is NULL drm/nouveau: prime: fix refcount underflow drm/vmwgfx: Fix overlay when using Screen Targets sched: act_ct: take care of padding in struct zones_ht_key net/iucv: fix use after free in iucv_sock_close() net/mlx5e: Add a check for the return value from mlx5_port_set_eth_ptys ipv6: fix ndisc_is_useropt() handling for PIO riscv/mm: Add handling for VM_FAULT_SIGSEGV in mm_fault_error() platform/chrome: cros_ec_proto: Lock device when updating MKBP version HID: wacom: Modify pen IDs protect the fetch of ->fd[fd] in do_dup2() from mispredictions ALSA: usb-audio: Correct surround channels in UAC1 channel map ALSA: hda/realtek: Add quirk for Acer Aspire E5-574G net: usb: sr9700: fix uninitialized variable use in sr_mdio_read r8169: don't increment tx_dropped in case of NETDEV_TX_BUSY mptcp: fix duplicate data handling netfilter: ipset: Add list flush to cancel_gc genirq: Allow irq_chip registration functions to take a const irq_chip irqchip/mbigen: Fix mbigen node address layout x86/mm: Fix pti_clone_pgtable() alignment assumption x86/mm: Fix pti_clone_entry_text() for i386 sctp: move hlist_node and hashent out of sctp_ep_common sctp: Fix null-ptr-deref in reuseport_add_sock(). net: usb: qmi_wwan: fix memory leak for not ip packets net: linkwatch: use system_unbound_wq Bluetooth: l2cap: always unlock channel in l2cap_conless_channel() net: dsa: bcm_sf2: Fix a possible memory leak in bcm_sf2_mdio_register() l2tp: fix lockdep splat net: fec: Stop PPS on driver remove rcutorture: Fix rcu_torture_fwd_cb_cr() data race md: do not delete safemode_timer in mddev_suspend md/raid5: avoid BUG_ON() while continue reshape after reassembling clocksource/drivers/sh_cmt: Address race condition for clock events ACPI: battery: create alarm sysfs attribute atomically ACPI: SBS: manage alarm sysfs attribute through psy core selftests/bpf: Fix send_signal test with nested CONFIG_PARAVIRT PCI: Add Edimax Vendor ID to pci_ids.h udf: prevent integer overflow in udf_bitmap_free_blocks() wifi: nl80211: don't give key data to userspace btrfs: fix bitmap leak when loading free space cache on duplicate entry drm/amdgpu: Fix the null pointer dereference to ras_manager drm/amdgpu/pm: Fix the null pointer dereference in apply_state_adjust_rules media: uvcvideo: Ignore empty TS packets media: uvcvideo: Fix the bandwdith quirk on USB 3.x jbd2: avoid memleak in jbd2_journal_write_metadata_buffer s390/sclp: Prevent release of buffer in I/O SUNRPC: Fix a race to wake a sync task sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime ext4: fix wrong unit use in ext4_mb_find_by_goal arm64: cpufeature: Force HWCAP to be based on the sysreg visible to user-space arm64: Add Neoverse-V2 part arm64: cputype: Add Cortex-X4 definitions arm64: cputype: Add Neoverse-V3 definitions arm64: errata: Add workaround for Arm errata 3194386 and 3312417 arm64: cputype: Add Cortex-X3 definitions arm64: cputype: Add Cortex-A720 definitions arm64: cputype: Add Cortex-X925 definitions arm64: errata: Unify speculative SSBS errata logic arm64: errata: Expand speculative SSBS workaround arm64: cputype: Add Cortex-X1C definitions arm64: cputype: Add Cortex-A725 definitions arm64: errata: Expand speculative SSBS workaround (again) i2c: smbus: Improve handling of stuck alerts ASoC: codecs: wsa881x: Correct Soundwire ports mask i2c: smbus: Send alert notifications to all devices if source not found bpf: kprobe: remove unused declaring of bpf_kprobe_override kprobes: Fix to check symbol prefixes correctly spi: spi-fsl-lpspi: Fix scldiv calculation ALSA: usb-audio: Re-add ScratchAmp quirk entries drm/client: fix null pointer dereference in drm_client_modeset_probe ALSA: line6: Fix racy access to midibuf ALSA: hda: Add HP MP9 G4 Retail System AMS to force connect list ALSA: hda/hdmi: Yet more pin fix for HP EliteDesk 800 G4 usb: vhci-hcd: Do not drop references before new references are gained USB: serial: debug: do not echo input by default usb: gadget: core: Check for unset descriptor usb: gadget: u_serial: Set start_delayed during suspend scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic tick/broadcast: Move per CPU pointer access into the atomic section ntp: Clamp maxerror and esterror to operating range driver core: Fix uevent_show() vs driver detach race ntp: Safeguard against time_constant overflow scsi: mpt3sas: Remove scsi_dma_map() error messages scsi: mpt3sas: Avoid IOMMU page faults on REPORT ZONES irqchip/meson-gpio: support more than 8 channels gpio irq irqchip/meson-gpio: Convert meson_gpio_irq_controller::lock to 'raw_spinlock_t' serial: core: check uartclk for zero to avoid divide by zero irqchip/xilinx: Fix shift out of bounds genirq/irqdesc: Honor caller provided affinity in alloc_desc() power: supply: axp288_charger: Fix constant_charge_voltage writes power: supply: axp288_charger: Round constant_charge_voltage writes down tracing: Fix overflow in get_free_elt() padata: Fix possible divide-by-0 panic in padata_mt_helper() x86/mtrr: Check if fixed MTRRs exist before saving them drm/bridge: analogix_dp: properly handle zero sized AUX transactions drm/mgag200: Set DDC timeout in milliseconds mptcp: sched: check both directions for backup mptcp: distinguish rcv vs sent backup flag in requests mptcp: fix NL PM announced address accounting mptcp: mib: count MPJ with backup flag mptcp: export local_address mptcp: pm: fix backup support in signal endpoints samples: Add fs error monitoring example samples: Make fs-monitor depend on libc and headers Add gitignore file for samples/fanotify/ subdirectory Fix gcc 4.9 build issue in 5.10.y PCI/DPC: Fix use-after-free on concurrent DPC and hot-removal netfilter: nf_tables: set element extended ACK reporting support netfilter: nf_tables: use timestamp to check for set element timeout netfilter: nf_tables: allow clone callbacks to sleep netfilter: nf_tables: prefer nft_chain_validate drm/i915/gem: Fix Virtual Memory mapping boundaries calculation powerpc: Avoid nmi_enter/nmi_exit in real mode interrupt. arm64: cpufeature: Fix the visibility of compat hwcaps media: uvcvideo: Use entity get_cur in uvc_ctrl_set exec: Fix ToCToU between perm check and set-uid/gid usage nvme/pci: Add APST quirk for Lenovo N60z laptop vdpa: Make use of PFN_PHYS/PFN_UP/PFN_DOWN helper macro vhost-vdpa: switch to use vmf_insert_pfn() in the fault handler wifi: cfg80211: restrict NL80211_ATTR_TXQ_QUANTUM values ARM: dts: imx6qdl-kontron-samx6i: fix phy-mode media: Revert "media: dvb-usb: Fix unexpected infinite loop in dvb_usb_read_remote_control()" Linux 5.10.224 Change-Id: I7cd19d506c4c86df918a280598946060a494a161 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1244 lines
32 KiB
C
1244 lines
32 KiB
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/audio-v2.h>
|
|
#include <linux/usb/audio-v3.h>
|
|
|
|
#include <sound/core.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/control.h>
|
|
#include <sound/tlv.h>
|
|
|
|
#include "usbaudio.h"
|
|
#include "card.h"
|
|
#include "proc.h"
|
|
#include "quirks.h"
|
|
#include "endpoint.h"
|
|
#include "pcm.h"
|
|
#include "helper.h"
|
|
#include "format.h"
|
|
#include "clock.h"
|
|
#include "stream.h"
|
|
#include "power.h"
|
|
#include "media.h"
|
|
|
|
static void audioformat_free(struct audioformat *fp)
|
|
{
|
|
list_del(&fp->list); /* unlink for avoiding double-free */
|
|
kfree(fp->rate_table);
|
|
kfree(fp->chmap);
|
|
kfree(fp);
|
|
}
|
|
|
|
/*
|
|
* free a substream
|
|
*/
|
|
static void free_substream(struct snd_usb_substream *subs)
|
|
{
|
|
struct audioformat *fp, *n;
|
|
|
|
if (!subs->num_formats)
|
|
return; /* not initialized */
|
|
list_for_each_entry_safe(fp, n, &subs->fmt_list, list)
|
|
audioformat_free(fp);
|
|
kfree(subs->rate_list.list);
|
|
kfree(subs->str_pd);
|
|
snd_media_stream_delete(subs);
|
|
}
|
|
|
|
|
|
/*
|
|
* free a usb stream instance
|
|
*/
|
|
static void snd_usb_audio_stream_free(struct snd_usb_stream *stream)
|
|
{
|
|
free_substream(&stream->substream[0]);
|
|
free_substream(&stream->substream[1]);
|
|
list_del(&stream->list);
|
|
kfree(stream);
|
|
}
|
|
|
|
static void snd_usb_audio_pcm_free(struct snd_pcm *pcm)
|
|
{
|
|
struct snd_usb_stream *stream = pcm->private_data;
|
|
struct snd_usb_audio *chip;
|
|
if (stream) {
|
|
mutex_lock(&stream->chip->dev_lock);
|
|
chip = stream->chip;
|
|
stream->pcm = NULL;
|
|
snd_usb_audio_stream_free(stream);
|
|
mutex_unlock(&chip->dev_lock);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* initialize the substream instance.
|
|
*/
|
|
|
|
static void snd_usb_init_substream(struct snd_usb_stream *as,
|
|
int stream,
|
|
struct audioformat *fp,
|
|
struct snd_usb_power_domain *pd)
|
|
{
|
|
struct snd_usb_substream *subs = &as->substream[stream];
|
|
|
|
INIT_LIST_HEAD(&subs->fmt_list);
|
|
spin_lock_init(&subs->lock);
|
|
|
|
subs->stream = as;
|
|
subs->direction = stream;
|
|
subs->dev = as->chip->dev;
|
|
subs->txfr_quirk = as->chip->txfr_quirk;
|
|
subs->tx_length_quirk = as->chip->tx_length_quirk;
|
|
subs->speed = snd_usb_get_speed(subs->dev);
|
|
subs->pkt_offset_adj = 0;
|
|
subs->stream_offset_adj = 0;
|
|
|
|
snd_usb_set_pcm_ops(as->pcm, stream);
|
|
|
|
list_add_tail(&fp->list, &subs->fmt_list);
|
|
subs->formats |= fp->formats;
|
|
subs->num_formats++;
|
|
subs->fmt_type = fp->fmt_type;
|
|
subs->ep_num = fp->endpoint;
|
|
if (fp->channels > subs->channels_max)
|
|
subs->channels_max = fp->channels;
|
|
|
|
if (pd) {
|
|
subs->str_pd = pd;
|
|
/* Initialize Power Domain to idle status D1 */
|
|
snd_usb_power_domain_set(subs->stream->chip, pd,
|
|
UAC3_PD_STATE_D1);
|
|
}
|
|
|
|
snd_usb_preallocate_buffer(subs);
|
|
}
|
|
|
|
/* kctl callbacks for usb-audio channel maps */
|
|
static int usb_chmap_ctl_info(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_info *uinfo)
|
|
{
|
|
struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
|
|
struct snd_usb_substream *subs = info->private_data;
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
uinfo->count = subs->channels_max;
|
|
uinfo->value.integer.min = 0;
|
|
uinfo->value.integer.max = SNDRV_CHMAP_LAST;
|
|
return 0;
|
|
}
|
|
|
|
/* check whether a duplicated entry exists in the audiofmt list */
|
|
static bool have_dup_chmap(struct snd_usb_substream *subs,
|
|
struct audioformat *fp)
|
|
{
|
|
struct audioformat *prev = fp;
|
|
|
|
list_for_each_entry_continue_reverse(prev, &subs->fmt_list, list) {
|
|
if (prev->chmap &&
|
|
!memcmp(prev->chmap, fp->chmap, sizeof(*fp->chmap)))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
static int usb_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
|
|
unsigned int size, unsigned int __user *tlv)
|
|
{
|
|
struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
|
|
struct snd_usb_substream *subs = info->private_data;
|
|
struct audioformat *fp;
|
|
unsigned int __user *dst;
|
|
int count = 0;
|
|
|
|
if (size < 8)
|
|
return -ENOMEM;
|
|
if (put_user(SNDRV_CTL_TLVT_CONTAINER, tlv))
|
|
return -EFAULT;
|
|
size -= 8;
|
|
dst = tlv + 2;
|
|
list_for_each_entry(fp, &subs->fmt_list, list) {
|
|
int i, ch_bytes;
|
|
|
|
if (!fp->chmap)
|
|
continue;
|
|
if (have_dup_chmap(subs, fp))
|
|
continue;
|
|
/* copy the entry */
|
|
ch_bytes = fp->chmap->channels * 4;
|
|
if (size < 8 + ch_bytes)
|
|
return -ENOMEM;
|
|
if (put_user(SNDRV_CTL_TLVT_CHMAP_FIXED, dst) ||
|
|
put_user(ch_bytes, dst + 1))
|
|
return -EFAULT;
|
|
dst += 2;
|
|
for (i = 0; i < fp->chmap->channels; i++, dst++) {
|
|
if (put_user(fp->chmap->map[i], dst))
|
|
return -EFAULT;
|
|
}
|
|
|
|
count += 8 + ch_bytes;
|
|
size -= 8 + ch_bytes;
|
|
}
|
|
if (put_user(count, tlv + 1))
|
|
return -EFAULT;
|
|
return 0;
|
|
}
|
|
|
|
static int usb_chmap_ctl_get(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
{
|
|
struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
|
|
struct snd_usb_substream *subs = info->private_data;
|
|
struct snd_pcm_chmap_elem *chmap = NULL;
|
|
int i = 0;
|
|
|
|
if (subs->cur_audiofmt)
|
|
chmap = subs->cur_audiofmt->chmap;
|
|
if (chmap) {
|
|
for (i = 0; i < chmap->channels; i++)
|
|
ucontrol->value.integer.value[i] = chmap->map[i];
|
|
}
|
|
for (; i < subs->channels_max; i++)
|
|
ucontrol->value.integer.value[i] = 0;
|
|
return 0;
|
|
}
|
|
|
|
/* create a chmap kctl assigned to the given USB substream */
|
|
static int add_chmap(struct snd_pcm *pcm, int stream,
|
|
struct snd_usb_substream *subs)
|
|
{
|
|
struct audioformat *fp;
|
|
struct snd_pcm_chmap *chmap;
|
|
struct snd_kcontrol *kctl;
|
|
int err;
|
|
|
|
list_for_each_entry(fp, &subs->fmt_list, list)
|
|
if (fp->chmap)
|
|
goto ok;
|
|
/* no chmap is found */
|
|
return 0;
|
|
|
|
ok:
|
|
err = snd_pcm_add_chmap_ctls(pcm, stream, NULL, 0, 0, &chmap);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
/* override handlers */
|
|
chmap->private_data = subs;
|
|
kctl = chmap->kctl;
|
|
kctl->info = usb_chmap_ctl_info;
|
|
kctl->get = usb_chmap_ctl_get;
|
|
kctl->tlv.c = usb_chmap_ctl_tlv;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* convert from USB ChannelConfig bits to ALSA chmap element */
|
|
static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits,
|
|
int protocol)
|
|
{
|
|
static const unsigned int uac1_maps[] = {
|
|
SNDRV_CHMAP_FL, /* left front */
|
|
SNDRV_CHMAP_FR, /* right front */
|
|
SNDRV_CHMAP_FC, /* center front */
|
|
SNDRV_CHMAP_LFE, /* LFE */
|
|
SNDRV_CHMAP_RL, /* left surround */
|
|
SNDRV_CHMAP_RR, /* right surround */
|
|
SNDRV_CHMAP_FLC, /* left of center */
|
|
SNDRV_CHMAP_FRC, /* right of center */
|
|
SNDRV_CHMAP_RC, /* surround */
|
|
SNDRV_CHMAP_SL, /* side left */
|
|
SNDRV_CHMAP_SR, /* side right */
|
|
SNDRV_CHMAP_TC, /* top */
|
|
0 /* terminator */
|
|
};
|
|
static const unsigned int uac2_maps[] = {
|
|
SNDRV_CHMAP_FL, /* front left */
|
|
SNDRV_CHMAP_FR, /* front right */
|
|
SNDRV_CHMAP_FC, /* front center */
|
|
SNDRV_CHMAP_LFE, /* LFE */
|
|
SNDRV_CHMAP_RL, /* back left */
|
|
SNDRV_CHMAP_RR, /* back right */
|
|
SNDRV_CHMAP_FLC, /* front left of center */
|
|
SNDRV_CHMAP_FRC, /* front right of center */
|
|
SNDRV_CHMAP_RC, /* back center */
|
|
SNDRV_CHMAP_SL, /* side left */
|
|
SNDRV_CHMAP_SR, /* side right */
|
|
SNDRV_CHMAP_TC, /* top center */
|
|
SNDRV_CHMAP_TFL, /* top front left */
|
|
SNDRV_CHMAP_TFC, /* top front center */
|
|
SNDRV_CHMAP_TFR, /* top front right */
|
|
SNDRV_CHMAP_TRL, /* top back left */
|
|
SNDRV_CHMAP_TRC, /* top back center */
|
|
SNDRV_CHMAP_TRR, /* top back right */
|
|
SNDRV_CHMAP_TFLC, /* top front left of center */
|
|
SNDRV_CHMAP_TFRC, /* top front right of center */
|
|
SNDRV_CHMAP_LLFE, /* left LFE */
|
|
SNDRV_CHMAP_RLFE, /* right LFE */
|
|
SNDRV_CHMAP_TSL, /* top side left */
|
|
SNDRV_CHMAP_TSR, /* top side right */
|
|
SNDRV_CHMAP_BC, /* bottom center */
|
|
SNDRV_CHMAP_RLC, /* back left of center */
|
|
SNDRV_CHMAP_RRC, /* back right of center */
|
|
0 /* terminator */
|
|
};
|
|
struct snd_pcm_chmap_elem *chmap;
|
|
const unsigned int *maps;
|
|
int c;
|
|
|
|
if (channels > ARRAY_SIZE(chmap->map))
|
|
return NULL;
|
|
|
|
chmap = kzalloc(sizeof(*chmap), GFP_KERNEL);
|
|
if (!chmap)
|
|
return NULL;
|
|
|
|
maps = protocol == UAC_VERSION_2 ? uac2_maps : uac1_maps;
|
|
chmap->channels = channels;
|
|
c = 0;
|
|
|
|
if (bits) {
|
|
for (; bits && *maps; maps++, bits >>= 1) {
|
|
if (bits & 1)
|
|
chmap->map[c++] = *maps;
|
|
if (c == chmap->channels)
|
|
break;
|
|
}
|
|
} else {
|
|
/* If we're missing wChannelConfig, then guess something
|
|
to make sure the channel map is not skipped entirely */
|
|
if (channels == 1)
|
|
chmap->map[c++] = SNDRV_CHMAP_MONO;
|
|
else
|
|
for (; c < channels && *maps; maps++)
|
|
chmap->map[c++] = *maps;
|
|
}
|
|
|
|
for (; c < channels; c++)
|
|
chmap->map[c] = SNDRV_CHMAP_UNKNOWN;
|
|
|
|
return chmap;
|
|
}
|
|
|
|
/* UAC3 device stores channels information in Cluster Descriptors */
|
|
static struct
|
|
snd_pcm_chmap_elem *convert_chmap_v3(struct uac3_cluster_header_descriptor
|
|
*cluster)
|
|
{
|
|
unsigned int channels = cluster->bNrChannels;
|
|
struct snd_pcm_chmap_elem *chmap;
|
|
void *p = cluster;
|
|
int len, c;
|
|
|
|
if (channels > ARRAY_SIZE(chmap->map))
|
|
return NULL;
|
|
|
|
chmap = kzalloc(sizeof(*chmap), GFP_KERNEL);
|
|
if (!chmap)
|
|
return NULL;
|
|
|
|
len = le16_to_cpu(cluster->wLength);
|
|
c = 0;
|
|
p += sizeof(struct uac3_cluster_header_descriptor);
|
|
|
|
while (((p - (void *)cluster) < len) && (c < channels)) {
|
|
struct uac3_cluster_segment_descriptor *cs_desc = p;
|
|
u16 cs_len;
|
|
u8 cs_type;
|
|
|
|
cs_len = le16_to_cpu(cs_desc->wLength);
|
|
cs_type = cs_desc->bSegmentType;
|
|
|
|
if (cs_type == UAC3_CHANNEL_INFORMATION) {
|
|
struct uac3_cluster_information_segment_descriptor *is = p;
|
|
unsigned char map;
|
|
|
|
/*
|
|
* TODO: this conversion is not complete, update it
|
|
* after adding UAC3 values to asound.h
|
|
*/
|
|
switch (is->bChRelationship) {
|
|
case UAC3_CH_MONO:
|
|
map = SNDRV_CHMAP_MONO;
|
|
break;
|
|
case UAC3_CH_LEFT:
|
|
case UAC3_CH_FRONT_LEFT:
|
|
case UAC3_CH_HEADPHONE_LEFT:
|
|
map = SNDRV_CHMAP_FL;
|
|
break;
|
|
case UAC3_CH_RIGHT:
|
|
case UAC3_CH_FRONT_RIGHT:
|
|
case UAC3_CH_HEADPHONE_RIGHT:
|
|
map = SNDRV_CHMAP_FR;
|
|
break;
|
|
case UAC3_CH_FRONT_CENTER:
|
|
map = SNDRV_CHMAP_FC;
|
|
break;
|
|
case UAC3_CH_FRONT_LEFT_OF_CENTER:
|
|
map = SNDRV_CHMAP_FLC;
|
|
break;
|
|
case UAC3_CH_FRONT_RIGHT_OF_CENTER:
|
|
map = SNDRV_CHMAP_FRC;
|
|
break;
|
|
case UAC3_CH_SIDE_LEFT:
|
|
map = SNDRV_CHMAP_SL;
|
|
break;
|
|
case UAC3_CH_SIDE_RIGHT:
|
|
map = SNDRV_CHMAP_SR;
|
|
break;
|
|
case UAC3_CH_BACK_LEFT:
|
|
map = SNDRV_CHMAP_RL;
|
|
break;
|
|
case UAC3_CH_BACK_RIGHT:
|
|
map = SNDRV_CHMAP_RR;
|
|
break;
|
|
case UAC3_CH_BACK_CENTER:
|
|
map = SNDRV_CHMAP_RC;
|
|
break;
|
|
case UAC3_CH_BACK_LEFT_OF_CENTER:
|
|
map = SNDRV_CHMAP_RLC;
|
|
break;
|
|
case UAC3_CH_BACK_RIGHT_OF_CENTER:
|
|
map = SNDRV_CHMAP_RRC;
|
|
break;
|
|
case UAC3_CH_TOP_CENTER:
|
|
map = SNDRV_CHMAP_TC;
|
|
break;
|
|
case UAC3_CH_TOP_FRONT_LEFT:
|
|
map = SNDRV_CHMAP_TFL;
|
|
break;
|
|
case UAC3_CH_TOP_FRONT_RIGHT:
|
|
map = SNDRV_CHMAP_TFR;
|
|
break;
|
|
case UAC3_CH_TOP_FRONT_CENTER:
|
|
map = SNDRV_CHMAP_TFC;
|
|
break;
|
|
case UAC3_CH_TOP_FRONT_LOC:
|
|
map = SNDRV_CHMAP_TFLC;
|
|
break;
|
|
case UAC3_CH_TOP_FRONT_ROC:
|
|
map = SNDRV_CHMAP_TFRC;
|
|
break;
|
|
case UAC3_CH_TOP_SIDE_LEFT:
|
|
map = SNDRV_CHMAP_TSL;
|
|
break;
|
|
case UAC3_CH_TOP_SIDE_RIGHT:
|
|
map = SNDRV_CHMAP_TSR;
|
|
break;
|
|
case UAC3_CH_TOP_BACK_LEFT:
|
|
map = SNDRV_CHMAP_TRL;
|
|
break;
|
|
case UAC3_CH_TOP_BACK_RIGHT:
|
|
map = SNDRV_CHMAP_TRR;
|
|
break;
|
|
case UAC3_CH_TOP_BACK_CENTER:
|
|
map = SNDRV_CHMAP_TRC;
|
|
break;
|
|
case UAC3_CH_BOTTOM_CENTER:
|
|
map = SNDRV_CHMAP_BC;
|
|
break;
|
|
case UAC3_CH_LOW_FREQUENCY_EFFECTS:
|
|
map = SNDRV_CHMAP_LFE;
|
|
break;
|
|
case UAC3_CH_LFE_LEFT:
|
|
map = SNDRV_CHMAP_LLFE;
|
|
break;
|
|
case UAC3_CH_LFE_RIGHT:
|
|
map = SNDRV_CHMAP_RLFE;
|
|
break;
|
|
case UAC3_CH_RELATIONSHIP_UNDEFINED:
|
|
default:
|
|
map = SNDRV_CHMAP_UNKNOWN;
|
|
break;
|
|
}
|
|
chmap->map[c++] = map;
|
|
}
|
|
p += cs_len;
|
|
}
|
|
|
|
if (channels < c)
|
|
pr_err("%s: channel number mismatch\n", __func__);
|
|
|
|
chmap->channels = channels;
|
|
|
|
for (; c < channels; c++)
|
|
chmap->map[c] = SNDRV_CHMAP_UNKNOWN;
|
|
|
|
return chmap;
|
|
}
|
|
|
|
/*
|
|
* add this endpoint to the chip instance.
|
|
* if a stream with the same endpoint already exists, append to it.
|
|
* if not, create a new pcm stream. note, fp is added to the substream
|
|
* fmt_list and will be freed on the chip instance release. do not free
|
|
* fp or do remove it from the substream fmt_list to avoid double-free.
|
|
*/
|
|
static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip,
|
|
int stream,
|
|
struct audioformat *fp,
|
|
struct snd_usb_power_domain *pd)
|
|
|
|
{
|
|
struct snd_usb_stream *as;
|
|
struct snd_usb_substream *subs;
|
|
struct snd_pcm *pcm;
|
|
int err;
|
|
|
|
list_for_each_entry(as, &chip->pcm_list, list) {
|
|
if (as->fmt_type != fp->fmt_type)
|
|
continue;
|
|
subs = &as->substream[stream];
|
|
if (subs->ep_num == fp->endpoint) {
|
|
list_add_tail(&fp->list, &subs->fmt_list);
|
|
subs->num_formats++;
|
|
subs->formats |= fp->formats;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
if (chip->card->registered)
|
|
chip->need_delayed_register = true;
|
|
|
|
/* look for an empty stream */
|
|
list_for_each_entry(as, &chip->pcm_list, list) {
|
|
if (as->fmt_type != fp->fmt_type)
|
|
continue;
|
|
subs = &as->substream[stream];
|
|
if (subs->ep_num)
|
|
continue;
|
|
err = snd_pcm_new_stream(as->pcm, stream, 1);
|
|
if (err < 0)
|
|
return err;
|
|
snd_usb_init_substream(as, stream, fp, pd);
|
|
return add_chmap(as->pcm, stream, subs);
|
|
}
|
|
|
|
/* create a new pcm */
|
|
as = kzalloc(sizeof(*as), GFP_KERNEL);
|
|
if (!as)
|
|
return -ENOMEM;
|
|
as->pcm_index = chip->pcm_devs;
|
|
as->chip = chip;
|
|
as->fmt_type = fp->fmt_type;
|
|
err = snd_pcm_new(chip->card, "USB Audio", chip->pcm_devs,
|
|
stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0,
|
|
stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1,
|
|
&pcm);
|
|
if (err < 0) {
|
|
kfree(as);
|
|
return err;
|
|
}
|
|
as->pcm = pcm;
|
|
pcm->private_data = as;
|
|
pcm->private_free = snd_usb_audio_pcm_free;
|
|
pcm->info_flags = 0;
|
|
if (chip->pcm_devs > 0)
|
|
sprintf(pcm->name, "USB Audio #%d", chip->pcm_devs);
|
|
else
|
|
strcpy(pcm->name, "USB Audio");
|
|
|
|
snd_usb_init_substream(as, stream, fp, pd);
|
|
|
|
/*
|
|
* Keep using head insertion for M-Audio Audiophile USB (tm) which has a
|
|
* fix to swap capture stream order in conf/cards/USB-audio.conf
|
|
*/
|
|
if (chip->usb_id == USB_ID(0x0763, 0x2003))
|
|
list_add(&as->list, &chip->pcm_list);
|
|
else
|
|
list_add_tail(&as->list, &chip->pcm_list);
|
|
|
|
chip->pcm_devs++;
|
|
|
|
snd_usb_proc_pcm_format_add(as);
|
|
|
|
return add_chmap(pcm, stream, &as->substream[stream]);
|
|
}
|
|
|
|
int snd_usb_add_audio_stream(struct snd_usb_audio *chip,
|
|
int stream,
|
|
struct audioformat *fp)
|
|
{
|
|
return __snd_usb_add_audio_stream(chip, stream, fp, NULL);
|
|
}
|
|
|
|
static int snd_usb_add_audio_stream_v3(struct snd_usb_audio *chip,
|
|
int stream,
|
|
struct audioformat *fp,
|
|
struct snd_usb_power_domain *pd)
|
|
{
|
|
return __snd_usb_add_audio_stream(chip, stream, fp, pd);
|
|
}
|
|
|
|
static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
|
|
struct usb_host_interface *alts,
|
|
int protocol, int iface_no)
|
|
{
|
|
/* parsed with a v1 header here. that's ok as we only look at the
|
|
* header first which is the same for both versions */
|
|
struct uac_iso_endpoint_descriptor *csep;
|
|
struct usb_interface_descriptor *altsd = get_iface_desc(alts);
|
|
int attributes = 0;
|
|
|
|
csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT);
|
|
|
|
/* Creamware Noah has this descriptor after the 2nd endpoint */
|
|
if (!csep && altsd->bNumEndpoints >= 2)
|
|
csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT);
|
|
|
|
/*
|
|
* If we can't locate the USB_DT_CS_ENDPOINT descriptor in the extra
|
|
* bytes after the first endpoint, go search the entire interface.
|
|
* Some devices have it directly *before* the standard endpoint.
|
|
*/
|
|
if (!csep)
|
|
csep = snd_usb_find_desc(alts->extra, alts->extralen, NULL, USB_DT_CS_ENDPOINT);
|
|
|
|
if (!csep || csep->bLength < 7 ||
|
|
csep->bDescriptorSubtype != UAC_EP_GENERAL)
|
|
goto error;
|
|
|
|
if (protocol == UAC_VERSION_1) {
|
|
attributes = csep->bmAttributes;
|
|
} else if (protocol == UAC_VERSION_2) {
|
|
struct uac2_iso_endpoint_descriptor *csep2 =
|
|
(struct uac2_iso_endpoint_descriptor *) csep;
|
|
|
|
if (csep2->bLength < sizeof(*csep2))
|
|
goto error;
|
|
attributes = csep->bmAttributes & UAC_EP_CS_ATTR_FILL_MAX;
|
|
|
|
/* emulate the endpoint attributes of a v1 device */
|
|
if (csep2->bmControls & UAC2_CONTROL_PITCH)
|
|
attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL;
|
|
} else { /* UAC_VERSION_3 */
|
|
struct uac3_iso_endpoint_descriptor *csep3 =
|
|
(struct uac3_iso_endpoint_descriptor *) csep;
|
|
|
|
if (csep3->bLength < sizeof(*csep3))
|
|
goto error;
|
|
/* emulate the endpoint attributes of a v1 device */
|
|
if (le32_to_cpu(csep3->bmControls) & UAC2_CONTROL_PITCH)
|
|
attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL;
|
|
}
|
|
|
|
return attributes;
|
|
|
|
error:
|
|
usb_audio_warn(chip,
|
|
"%u:%d : no or invalid class specific endpoint descriptor\n",
|
|
iface_no, altsd->bAlternateSetting);
|
|
return 0;
|
|
}
|
|
|
|
/* find an input terminal descriptor (either UAC1 or UAC2) with the given
|
|
* terminal id
|
|
*/
|
|
static void *
|
|
snd_usb_find_input_terminal_descriptor(struct usb_host_interface *ctrl_iface,
|
|
int terminal_id, int protocol)
|
|
{
|
|
struct uac2_input_terminal_descriptor *term = NULL;
|
|
|
|
while ((term = snd_usb_find_csint_desc(ctrl_iface->extra,
|
|
ctrl_iface->extralen,
|
|
term, UAC_INPUT_TERMINAL))) {
|
|
if (!snd_usb_validate_audio_desc(term, protocol))
|
|
continue;
|
|
if (term->bTerminalID == terminal_id)
|
|
return term;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static void *
|
|
snd_usb_find_output_terminal_descriptor(struct usb_host_interface *ctrl_iface,
|
|
int terminal_id, int protocol)
|
|
{
|
|
/* OK to use with both UAC2 and UAC3 */
|
|
struct uac2_output_terminal_descriptor *term = NULL;
|
|
|
|
while ((term = snd_usb_find_csint_desc(ctrl_iface->extra,
|
|
ctrl_iface->extralen,
|
|
term, UAC_OUTPUT_TERMINAL))) {
|
|
if (!snd_usb_validate_audio_desc(term, protocol))
|
|
continue;
|
|
if (term->bTerminalID == terminal_id)
|
|
return term;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static struct audioformat *
|
|
audio_format_alloc_init(struct snd_usb_audio *chip,
|
|
struct usb_host_interface *alts,
|
|
int protocol, int iface_no, int altset_idx,
|
|
int altno, int num_channels, int clock)
|
|
{
|
|
struct audioformat *fp;
|
|
|
|
fp = kzalloc(sizeof(*fp), GFP_KERNEL);
|
|
if (!fp)
|
|
return NULL;
|
|
|
|
fp->iface = iface_no;
|
|
fp->altsetting = altno;
|
|
fp->altset_idx = altset_idx;
|
|
fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
|
|
fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
|
|
fp->datainterval = snd_usb_parse_datainterval(chip, alts);
|
|
fp->protocol = protocol;
|
|
fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
|
|
fp->channels = num_channels;
|
|
if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH)
|
|
fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1)
|
|
* (fp->maxpacksize & 0x7ff);
|
|
fp->clock = clock;
|
|
INIT_LIST_HEAD(&fp->list);
|
|
|
|
return fp;
|
|
}
|
|
|
|
static struct audioformat *
|
|
snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,
|
|
struct usb_host_interface *alts,
|
|
int protocol, int iface_no, int altset_idx,
|
|
int altno, int stream, int bm_quirk)
|
|
{
|
|
struct usb_device *dev = chip->dev;
|
|
struct uac_format_type_i_continuous_descriptor *fmt;
|
|
unsigned int num_channels = 0, chconfig = 0;
|
|
struct audioformat *fp;
|
|
int clock = 0;
|
|
u64 format;
|
|
|
|
/* get audio formats */
|
|
if (protocol == UAC_VERSION_1) {
|
|
struct uac1_as_header_descriptor *as =
|
|
snd_usb_find_csint_desc(alts->extra, alts->extralen,
|
|
NULL, UAC_AS_GENERAL);
|
|
struct uac_input_terminal_descriptor *iterm;
|
|
|
|
if (!as) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : UAC_AS_GENERAL descriptor not found\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
if (as->bLength < sizeof(*as)) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : invalid UAC_AS_GENERAL desc\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
format = le16_to_cpu(as->wFormatTag); /* remember the format value */
|
|
|
|
iterm = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf,
|
|
as->bTerminalLink,
|
|
protocol);
|
|
if (iterm) {
|
|
num_channels = iterm->bNrChannels;
|
|
chconfig = le16_to_cpu(iterm->wChannelConfig);
|
|
}
|
|
} else { /* UAC_VERSION_2 */
|
|
struct uac2_input_terminal_descriptor *input_term;
|
|
struct uac2_output_terminal_descriptor *output_term;
|
|
struct uac2_as_header_descriptor *as =
|
|
snd_usb_find_csint_desc(alts->extra, alts->extralen,
|
|
NULL, UAC_AS_GENERAL);
|
|
|
|
if (!as) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : UAC_AS_GENERAL descriptor not found\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
if (as->bLength < sizeof(*as)) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : invalid UAC_AS_GENERAL desc\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
num_channels = as->bNrChannels;
|
|
format = le32_to_cpu(as->bmFormats);
|
|
chconfig = le32_to_cpu(as->bmChannelConfig);
|
|
|
|
/*
|
|
* lookup the terminal associated to this interface
|
|
* to extract the clock
|
|
*/
|
|
input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf,
|
|
as->bTerminalLink,
|
|
protocol);
|
|
if (input_term) {
|
|
clock = input_term->bCSourceID;
|
|
if (!chconfig && (num_channels == input_term->bNrChannels))
|
|
chconfig = le32_to_cpu(input_term->bmChannelConfig);
|
|
goto found_clock;
|
|
}
|
|
|
|
output_term = snd_usb_find_output_terminal_descriptor(chip->ctrl_intf,
|
|
as->bTerminalLink,
|
|
protocol);
|
|
if (output_term) {
|
|
clock = output_term->bCSourceID;
|
|
goto found_clock;
|
|
}
|
|
|
|
dev_err(&dev->dev,
|
|
"%u:%d : bogus bTerminalLink %d\n",
|
|
iface_no, altno, as->bTerminalLink);
|
|
return NULL;
|
|
}
|
|
|
|
found_clock:
|
|
/* get format type */
|
|
fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen,
|
|
NULL, UAC_FORMAT_TYPE);
|
|
if (!fmt) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : no UAC_FORMAT_TYPE desc\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
if (((protocol == UAC_VERSION_1) && (fmt->bLength < 8))
|
|
|| ((protocol == UAC_VERSION_2) &&
|
|
(fmt->bLength < 6))) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : invalid UAC_FORMAT_TYPE desc\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* Blue Microphones workaround: The last altsetting is
|
|
* identical with the previous one, except for a larger
|
|
* packet size, but is actually a mislabeled two-channel
|
|
* setting; ignore it.
|
|
*
|
|
* Part 2: analyze quirk flag and format
|
|
*/
|
|
if (bm_quirk && fmt->bNrChannels == 1 && fmt->bSubframeSize == 2)
|
|
return NULL;
|
|
|
|
fp = audio_format_alloc_init(chip, alts, protocol, iface_no,
|
|
altset_idx, altno, num_channels, clock);
|
|
if (!fp)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol,
|
|
iface_no);
|
|
|
|
/* some quirks for attributes here */
|
|
snd_usb_audioformat_attributes_quirk(chip, fp, stream);
|
|
|
|
/* ok, let's parse further... */
|
|
if (snd_usb_parse_audio_format(chip, fp, format,
|
|
fmt, stream) < 0) {
|
|
audioformat_free(fp);
|
|
return NULL;
|
|
}
|
|
|
|
/* Create chmap */
|
|
if (fp->channels != num_channels)
|
|
chconfig = 0;
|
|
|
|
fp->chmap = convert_chmap(fp->channels, chconfig, protocol);
|
|
|
|
return fp;
|
|
}
|
|
|
|
static struct audioformat *
|
|
snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
|
|
struct usb_host_interface *alts,
|
|
struct snd_usb_power_domain **pd_out,
|
|
int iface_no, int altset_idx,
|
|
int altno, int stream)
|
|
{
|
|
struct usb_device *dev = chip->dev;
|
|
struct uac3_input_terminal_descriptor *input_term;
|
|
struct uac3_output_terminal_descriptor *output_term;
|
|
struct uac3_cluster_header_descriptor *cluster;
|
|
struct uac3_as_header_descriptor *as = NULL;
|
|
struct uac3_hc_descriptor_header hc_header;
|
|
struct snd_pcm_chmap_elem *chmap;
|
|
struct snd_usb_power_domain *pd;
|
|
unsigned char badd_profile;
|
|
u64 badd_formats = 0;
|
|
unsigned int num_channels;
|
|
struct audioformat *fp;
|
|
u16 cluster_id, wLength;
|
|
int clock = 0;
|
|
int err;
|
|
|
|
badd_profile = chip->badd_profile;
|
|
|
|
if (badd_profile >= UAC3_FUNCTION_SUBCLASS_GENERIC_IO) {
|
|
unsigned int maxpacksize =
|
|
le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
|
|
|
|
switch (maxpacksize) {
|
|
default:
|
|
dev_err(&dev->dev,
|
|
"%u:%d : incorrect wMaxPacketSize for BADD profile\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
case UAC3_BADD_EP_MAXPSIZE_SYNC_MONO_16:
|
|
case UAC3_BADD_EP_MAXPSIZE_ASYNC_MONO_16:
|
|
badd_formats = SNDRV_PCM_FMTBIT_S16_LE;
|
|
num_channels = 1;
|
|
break;
|
|
case UAC3_BADD_EP_MAXPSIZE_SYNC_MONO_24:
|
|
case UAC3_BADD_EP_MAXPSIZE_ASYNC_MONO_24:
|
|
badd_formats = SNDRV_PCM_FMTBIT_S24_3LE;
|
|
num_channels = 1;
|
|
break;
|
|
case UAC3_BADD_EP_MAXPSIZE_SYNC_STEREO_16:
|
|
case UAC3_BADD_EP_MAXPSIZE_ASYNC_STEREO_16:
|
|
badd_formats = SNDRV_PCM_FMTBIT_S16_LE;
|
|
num_channels = 2;
|
|
break;
|
|
case UAC3_BADD_EP_MAXPSIZE_SYNC_STEREO_24:
|
|
case UAC3_BADD_EP_MAXPSIZE_ASYNC_STEREO_24:
|
|
badd_formats = SNDRV_PCM_FMTBIT_S24_3LE;
|
|
num_channels = 2;
|
|
break;
|
|
}
|
|
|
|
chmap = kzalloc(sizeof(*chmap), GFP_KERNEL);
|
|
if (!chmap)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
if (num_channels == 1) {
|
|
chmap->map[0] = SNDRV_CHMAP_MONO;
|
|
} else {
|
|
chmap->map[0] = SNDRV_CHMAP_FL;
|
|
chmap->map[1] = SNDRV_CHMAP_FR;
|
|
}
|
|
|
|
chmap->channels = num_channels;
|
|
clock = UAC3_BADD_CS_ID9;
|
|
goto found_clock;
|
|
}
|
|
|
|
as = snd_usb_find_csint_desc(alts->extra, alts->extralen,
|
|
NULL, UAC_AS_GENERAL);
|
|
if (!as) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : UAC_AS_GENERAL descriptor not found\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
if (as->bLength < sizeof(*as)) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : invalid UAC_AS_GENERAL desc\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
cluster_id = le16_to_cpu(as->wClusterDescrID);
|
|
if (!cluster_id) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : no cluster descriptor\n",
|
|
iface_no, altno);
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* Get number of channels and channel map through
|
|
* High Capability Cluster Descriptor
|
|
*
|
|
* First step: get High Capability header and
|
|
* read size of Cluster Descriptor
|
|
*/
|
|
err = snd_usb_ctl_msg(chip->dev,
|
|
usb_rcvctrlpipe(chip->dev, 0),
|
|
UAC3_CS_REQ_HIGH_CAPABILITY_DESCRIPTOR,
|
|
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
|
|
cluster_id,
|
|
snd_usb_ctrl_intf(chip),
|
|
&hc_header, sizeof(hc_header));
|
|
if (err < 0)
|
|
return ERR_PTR(err);
|
|
else if (err != sizeof(hc_header)) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : can't get High Capability descriptor\n",
|
|
iface_no, altno);
|
|
return ERR_PTR(-EIO);
|
|
}
|
|
|
|
/*
|
|
* Second step: allocate needed amount of memory
|
|
* and request Cluster Descriptor
|
|
*/
|
|
wLength = le16_to_cpu(hc_header.wLength);
|
|
cluster = kzalloc(wLength, GFP_KERNEL);
|
|
if (!cluster)
|
|
return ERR_PTR(-ENOMEM);
|
|
err = snd_usb_ctl_msg(chip->dev,
|
|
usb_rcvctrlpipe(chip->dev, 0),
|
|
UAC3_CS_REQ_HIGH_CAPABILITY_DESCRIPTOR,
|
|
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
|
|
cluster_id,
|
|
snd_usb_ctrl_intf(chip),
|
|
cluster, wLength);
|
|
if (err < 0) {
|
|
kfree(cluster);
|
|
return ERR_PTR(err);
|
|
} else if (err != wLength) {
|
|
dev_err(&dev->dev,
|
|
"%u:%d : can't get Cluster Descriptor\n",
|
|
iface_no, altno);
|
|
kfree(cluster);
|
|
return ERR_PTR(-EIO);
|
|
}
|
|
|
|
num_channels = cluster->bNrChannels;
|
|
chmap = convert_chmap_v3(cluster);
|
|
kfree(cluster);
|
|
|
|
/*
|
|
* lookup the terminal associated to this interface
|
|
* to extract the clock
|
|
*/
|
|
input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf,
|
|
as->bTerminalLink,
|
|
UAC_VERSION_3);
|
|
if (input_term) {
|
|
clock = input_term->bCSourceID;
|
|
goto found_clock;
|
|
}
|
|
|
|
output_term = snd_usb_find_output_terminal_descriptor(chip->ctrl_intf,
|
|
as->bTerminalLink,
|
|
UAC_VERSION_3);
|
|
if (output_term) {
|
|
clock = output_term->bCSourceID;
|
|
goto found_clock;
|
|
}
|
|
|
|
dev_err(&dev->dev, "%u:%d : bogus bTerminalLink %d\n",
|
|
iface_no, altno, as->bTerminalLink);
|
|
kfree(chmap);
|
|
return NULL;
|
|
|
|
found_clock:
|
|
fp = audio_format_alloc_init(chip, alts, UAC_VERSION_3, iface_no,
|
|
altset_idx, altno, num_channels, clock);
|
|
if (!fp) {
|
|
kfree(chmap);
|
|
return ERR_PTR(-ENOMEM);
|
|
}
|
|
|
|
fp->chmap = chmap;
|
|
|
|
if (badd_profile >= UAC3_FUNCTION_SUBCLASS_GENERIC_IO) {
|
|
fp->attributes = 0; /* No attributes */
|
|
|
|
fp->fmt_type = UAC_FORMAT_TYPE_I;
|
|
fp->formats = badd_formats;
|
|
|
|
fp->nr_rates = 0; /* SNDRV_PCM_RATE_CONTINUOUS */
|
|
fp->rate_min = UAC3_BADD_SAMPLING_RATE;
|
|
fp->rate_max = UAC3_BADD_SAMPLING_RATE;
|
|
fp->rates = SNDRV_PCM_RATE_CONTINUOUS;
|
|
|
|
pd = kzalloc(sizeof(*pd), GFP_KERNEL);
|
|
if (!pd) {
|
|
audioformat_free(fp);
|
|
return NULL;
|
|
}
|
|
pd->pd_id = (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
|
|
UAC3_BADD_PD_ID10 : UAC3_BADD_PD_ID11;
|
|
pd->pd_d1d0_rec = UAC3_BADD_PD_RECOVER_D1D0;
|
|
pd->pd_d2d0_rec = UAC3_BADD_PD_RECOVER_D2D0;
|
|
|
|
} else {
|
|
fp->attributes = parse_uac_endpoint_attributes(chip, alts,
|
|
UAC_VERSION_3,
|
|
iface_no);
|
|
|
|
pd = snd_usb_find_power_domain(chip->ctrl_intf,
|
|
as->bTerminalLink);
|
|
|
|
/* ok, let's parse further... */
|
|
if (snd_usb_parse_audio_format_v3(chip, fp, as, stream) < 0) {
|
|
kfree(pd);
|
|
audioformat_free(fp);
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
if (pd)
|
|
*pd_out = pd;
|
|
|
|
return fp;
|
|
}
|
|
|
|
static int __snd_usb_parse_audio_interface(struct snd_usb_audio *chip,
|
|
int iface_no,
|
|
bool *has_non_pcm, bool non_pcm)
|
|
{
|
|
struct usb_device *dev;
|
|
struct usb_interface *iface;
|
|
struct usb_host_interface *alts;
|
|
struct usb_interface_descriptor *altsd;
|
|
int i, altno, err, stream;
|
|
struct audioformat *fp = NULL;
|
|
struct snd_usb_power_domain *pd = NULL;
|
|
int num, protocol;
|
|
|
|
dev = chip->dev;
|
|
|
|
/* parse the interface's altsettings */
|
|
iface = usb_ifnum_to_if(dev, iface_no);
|
|
|
|
num = iface->num_altsetting;
|
|
|
|
/*
|
|
* Dallas DS4201 workaround: It presents 5 altsettings, but the last
|
|
* one misses syncpipe, and does not produce any sound.
|
|
*/
|
|
if (chip->usb_id == USB_ID(0x04fa, 0x4201) && num >= 4)
|
|
num = 4;
|
|
|
|
for (i = 0; i < num; i++) {
|
|
alts = &iface->altsetting[i];
|
|
altsd = get_iface_desc(alts);
|
|
protocol = altsd->bInterfaceProtocol;
|
|
/* skip invalid one */
|
|
if (((altsd->bInterfaceClass != USB_CLASS_AUDIO ||
|
|
(altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING &&
|
|
altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC)) &&
|
|
altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||
|
|
altsd->bNumEndpoints < 1 ||
|
|
le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0)
|
|
continue;
|
|
/* must be isochronous */
|
|
if ((get_endpoint(alts, 0)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
|
|
USB_ENDPOINT_XFER_ISOC)
|
|
continue;
|
|
/* check direction */
|
|
stream = (get_endpoint(alts, 0)->bEndpointAddress & USB_DIR_IN) ?
|
|
SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
|
|
altno = altsd->bAlternateSetting;
|
|
|
|
if (snd_usb_apply_interface_quirk(chip, iface_no, altno))
|
|
continue;
|
|
|
|
/*
|
|
* Roland audio streaming interfaces are marked with protocols
|
|
* 0/1/2, but are UAC 1 compatible.
|
|
*/
|
|
if (USB_ID_VENDOR(chip->usb_id) == 0x0582 &&
|
|
altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
|
|
protocol <= 2)
|
|
protocol = UAC_VERSION_1;
|
|
|
|
switch (protocol) {
|
|
default:
|
|
dev_dbg(&dev->dev, "%u:%d: unknown interface protocol %#02x, assuming v1\n",
|
|
iface_no, altno, protocol);
|
|
protocol = UAC_VERSION_1;
|
|
fallthrough;
|
|
case UAC_VERSION_1:
|
|
case UAC_VERSION_2: {
|
|
int bm_quirk = 0;
|
|
|
|
/*
|
|
* Blue Microphones workaround: The last altsetting is
|
|
* identical with the previous one, except for a larger
|
|
* packet size, but is actually a mislabeled two-channel
|
|
* setting; ignore it.
|
|
*
|
|
* Part 1: prepare quirk flag
|
|
*/
|
|
if (altno == 2 && num == 3 &&
|
|
fp && fp->altsetting == 1 && fp->channels == 1 &&
|
|
fp->formats == SNDRV_PCM_FMTBIT_S16_LE &&
|
|
protocol == UAC_VERSION_1 &&
|
|
le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) ==
|
|
fp->maxpacksize * 2)
|
|
bm_quirk = 1;
|
|
|
|
fp = snd_usb_get_audioformat_uac12(chip, alts, protocol,
|
|
iface_no, i, altno,
|
|
stream, bm_quirk);
|
|
break;
|
|
}
|
|
case UAC_VERSION_3:
|
|
fp = snd_usb_get_audioformat_uac3(chip, alts, &pd,
|
|
iface_no, i, altno, stream);
|
|
break;
|
|
}
|
|
|
|
if (!fp)
|
|
continue;
|
|
else if (IS_ERR(fp))
|
|
return PTR_ERR(fp);
|
|
|
|
if (fp->fmt_type != UAC_FORMAT_TYPE_I)
|
|
*has_non_pcm = true;
|
|
if ((fp->fmt_type == UAC_FORMAT_TYPE_I) == non_pcm) {
|
|
audioformat_free(fp);
|
|
kfree(pd);
|
|
fp = NULL;
|
|
pd = NULL;
|
|
continue;
|
|
}
|
|
|
|
dev_dbg(&dev->dev, "%u:%d: add audio endpoint %#x\n", iface_no, altno, fp->endpoint);
|
|
if (protocol == UAC_VERSION_3)
|
|
err = snd_usb_add_audio_stream_v3(chip, stream, fp, pd);
|
|
else
|
|
err = snd_usb_add_audio_stream(chip, stream, fp);
|
|
|
|
if (err < 0) {
|
|
audioformat_free(fp);
|
|
kfree(pd);
|
|
return err;
|
|
}
|
|
/* try to set the interface... */
|
|
usb_set_interface(chip->dev, iface_no, altno);
|
|
snd_usb_init_pitch(chip, iface_no, alts, fp);
|
|
snd_usb_init_sample_rate(chip, iface_no, alts, fp, fp->rate_max);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
|
|
{
|
|
int err;
|
|
bool has_non_pcm = false;
|
|
|
|
/* parse PCM formats */
|
|
err = __snd_usb_parse_audio_interface(chip, iface_no, &has_non_pcm, false);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
if (has_non_pcm) {
|
|
/* parse non-PCM formats */
|
|
err = __snd_usb_parse_audio_interface(chip, iface_no, &has_non_pcm, true);
|
|
if (err < 0)
|
|
return err;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|