* refs/heads/tmp-60fbe70:
UPSTREAM: sched/psi: Fix OOB write when writing 0 bytes to PSI files
UPSTREAM: psi: Fix a division error in psi poll()
UPSTREAM: sched/psi: Fix sampling error and rare div0 crashes with cgroups and high uptime
UPSTREAM: sched/psi: Correct overly pessimistic size calculation
Linux 4.9.215
s390/mm: Explicitly compare PAGE_DEFAULT_KEY against zero in storage_key_init_range
xen: Enable interrupts when calling _cond_resched()
ata: ahci: Add shutdown to freeze hardware resources of ahci
netfilter: xt_hashlimit: limit the max size of hashtable
ALSA: seq: Fix concurrent access to queue current tick/time
ALSA: seq: Avoid concurrent access to queue flags
ALSA: rawmidi: Avoid bit fields for state flags
ecryptfs: replace BUG_ON with error handling code
staging: greybus: use after free in gb_audio_manager_remove_all()
usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus
scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session"
scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout"
Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
KVM: apic: avoid calculating pending eoi from an uninitialized val
KVM: nVMX: Check IO instruction VM-exit conditions
KVM: nVMX: Refactor IO bitmap checks into helper function
ext4: fix race between writepages and enabling EXT4_EXTENTS_FL
ext4: rename s_journal_flag_rwsem to s_writepages_rwsem
ext4: fix mount failure with quota configured as module
ext4: add cond_resched() to __ext4_find_entry()
ext4: fix a data race in EXT4_I(inode)->i_disksize
netfilter: xt_bpf: add overflow checks
KVM: nVMX: Don't emulate instructions in guest mode
lib/stackdepot.c: fix global out-of-bounds in stack_slabs
vt: vt_ioctl: fix race in VT_RESIZEX
VT_RESIZEX: get rid of field-by-field copyin
KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI
xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms
Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()"
tty: serial: imx: setup the correct sg entry for tx dma
tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode
x86/mce/amd: Fix kobject lifetime
x86/mce/amd: Publish the bank pointer only after setup has succeeded
staging: rtl8188eu: Fix potential overuse of kernel memory
staging: rtl8188eu: Fix potential security hole
USB: hub: Don't record a connect-change event during reset-resume
USB: Fix novation SourceControl XL after suspend
usb: uas: fix a plug & unplug racing
xhci: Force Maximum Packet size for Full-speed bulk devices to valid range.
staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi.
staging: android: ashmem: Disallow ashmem memory from being remapped
vt: selection, handle pending signals in paste_selection
floppy: check FDC index for errors before assigning it
net/sched: flower: add missing validation of TCA_FLOWER_FLAGS
net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS
enic: prevent waking up stopped tx queues over watchdog reset
selinux: ensure we cleanup the internal AVC counters on error in avc_update()
help_next should increase position index
brd: check and limit max_part par
microblaze: Prevent the overflow of the start
iwlwifi: mvm: Fix thermal zone registration
irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL
bcache: explicity type cast in bset_bkey_last()
reiserfs: prevent NULL pointer dereference in reiserfs_insert_item()
lib/scatterlist.c: adjust indentation in __sg_alloc_table
ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans()
radeon: insert 10ms sleep in dce5_crtc_load_lut
trigger_next should increase position index
ftrace: fpid_next() should increase position index
drm/nouveau/disp/nv50-: prevent oops when no channel method map provided
irqchip/gic-v3: Only provision redistributors that are enabled in ACPI
cifs: fix NULL dereference in match_prepath
iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop
hostap: Adjust indentation in prism2_hostapd_add_sta
ARM: 8951/1: Fix Kexec compilation issue.
jbd2: switch to use jbd2_journal_abort() when failed to submit the commit record
powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV
ALSA: hda - Add docking station support for Lenovo Thinkpad T420s
driver core: platform: fix u32 greater or equal to zero comparison
s390/ftrace: generate traced function stack frame
x86/decoder: Add TEST opcode to Group3-2
remoteproc: Initialize rproc_class before use
ide: serverworks: potential overflow in svwks_set_pio_mode()
cmd64x: potential buffer overflow in cmd64x_program_timings()
pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctional
arm64: fix alternatives with LLVM's integrated assembler
scsi: iscsi: Don't destroy session if there are outstanding connections
iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE
usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue
drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
drm/nouveau: Fix copy-paste error in nouveau_fence_wait_uevent_handler
drm/nouveau/gr/gk20a,gm200-: add terminators to method lists read from fw
vme: bridges: reduce stack usage
driver core: Print device when resources present in really_probe()
driver core: platform: Prevent resouce overflow from causing infinite loops
tty: synclink_gt: Adjust indentation in several functions
tty: synclinkmp: Adjust indentation in several functions
ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m
wan: ixp4xx_hss: fix compile-testing on 64-bit
Input: edt-ft5x06 - work around first register access error
rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls
soc/tegra: fuse: Correct straps' address for older Tegra124 device trees
udf: Fix free space reporting for metadata and virtual partitions
usbip: Fix unsafe unaligned pointer usage
tools lib api fs: Fix gcc9 stringop-truncation compilation error
ALSA: sh: Fix compile warning wrt const
RDMA/rxe: Fix error type of mmap_offset
pinctrl: sh-pfc: sh7269: Fix CAN function GPIOs
PM / devfreq: rk3399_dmc: Add COMPILE_TEST and HAVE_ARM_SMCCC dependency
x86/vdso: Provide missing include file
ARM: dts: r8a7779: Add device node for ARM global timer
drm/mediatek: handle events when enabling/disabling crtc
scsi: aic7xxx: Adjust indentation in ahc_find_syncrate
ACPICA: Disassembler: create buffer fields in ACPI_PARSE_LOAD_PASS1
orinoco: avoid assertion in case of NULL pointer
rtlwifi: rtl_pci: Fix -Wcast-function-type
iwlegacy: Fix -Wcast-function-type
ipw2x00: Fix -Wcast-function-type
b43legacy: Fix -Wcast-function-type
ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_status
reiserfs: Fix spurious unlock in reiserfs_fill_super() error handling
media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros
NFC: port100: Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu().
PCI/IOV: Fix memory leak in pci_iov_add_virtfn()
net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
regulator: rk808: Lower log level on optional GPIOs being not available
drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table
clk: qcom: rcg2: Don't crash if our parent can't be found; return an error
kconfig: fix broken dependency in randconfig-generated .config
ext4, jbd2: ensure panic when aborting with zero errno
tracing: Fix very unlikely race of registering two stat tracers
tracing: Fix tracing_stat return values in error handling paths
x86/sysfb: Fix check for bad VRAM size
jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal
usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe()
uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()
sparc: Add .exit.data section.
MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
efi/x86: Map the entire EFI vendor string before copying it
pinctrl: baytrail: Do not clear IRQ flags on direct-irq enabled pins
media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run()
gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_irq_map/unmap()
powerpc/powernv/iov: Ensure the pdn for VFs always contains a valid PE number
media: i2c: mt9v032: fix enum mbus codes and frame sizes
pxa168fb: Fix the function used to release some memory in an error handling path
pinctrl: sh-pfc: sh7264: Fix CAN function GPIOs
gianfar: Fix TX timestamping with a stacked DSA driver
brcmfmac: Fix use after free in brcmf_sdio_readframes()
cpu/hotplug, stop_machine: Fix stop_machine vs hotplug order
drm/gma500: Fixup fbdev stolen size usage evaluation
Revert "KVM: VMX: Add non-canonical check on writes to RTIT address MSRs"
scsi: qla2xxx: fix a potential NULL pointer dereference
btrfs: print message when tree-log replay starts
jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer
jbd2: move the clearing of b_modified flag to the journal_unmap_buffer()
hwmon: (pmbus/ltc2978) Fix PMBus polling of MFR_COMMON definitions.
perf/x86/intel: Fix inaccurate period in context switch for auto-reload
s390/time: Fix clk type in get_tod_clock
padata: Remove broken queue flushing
perf/x86/amd: Add missing L2 misses event spec to AMD Family 17h's event map
btrfs: log message when rw remount is attempted with unclean tree-log
Btrfs: fix race between using extent maps and merging them
ext4: improve explanation of a mount failure caused by a misconfigured kernel
ext4: fix checksum errors with indexed dirs
ext4: don't assume that mmp_nodename/bdevname have NUL
ALSA: usb-audio: Apply sample rate quirk for Audioengine D1
ecryptfs: fix a memory leak bug in ecryptfs_init_messaging()
ecryptfs: fix a memory leak bug in parse_tag_1_packet()
ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs
KVM: x86: emulate RDPID
x86/vdso: Use RDPID in preference to LSL when available
Conflicts:
drivers/usb/host/xhci-mem.c
Change-Id: I96eafddc50120464633c0f4815302cbca0921df8
Signed-off-by: jianzhou <jianzhou@codeaurora.org>
194 lines
6.2 KiB
C
194 lines
6.2 KiB
C
#ifndef __SOUND_RAWMIDI_H
|
|
#define __SOUND_RAWMIDI_H
|
|
|
|
/*
|
|
* Abstract layer for MIDI v1.0 stream
|
|
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>
|
|
*
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
|
|
#include <sound/asound.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/wait.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/workqueue.h>
|
|
#include <linux/device.h>
|
|
|
|
#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
|
|
#include <sound/seq_device.h>
|
|
#endif
|
|
|
|
/*
|
|
* Raw MIDI interface
|
|
*/
|
|
|
|
#define SNDRV_RAWMIDI_DEVICES 8
|
|
|
|
#define SNDRV_RAWMIDI_LFLG_OUTPUT (1<<0)
|
|
#define SNDRV_RAWMIDI_LFLG_INPUT (1<<1)
|
|
#define SNDRV_RAWMIDI_LFLG_OPEN (3<<0)
|
|
#define SNDRV_RAWMIDI_LFLG_APPEND (1<<2)
|
|
|
|
struct snd_rawmidi;
|
|
struct snd_rawmidi_substream;
|
|
struct snd_seq_port_info;
|
|
struct pid;
|
|
|
|
struct snd_rawmidi_ops {
|
|
int (*open) (struct snd_rawmidi_substream * substream);
|
|
int (*close) (struct snd_rawmidi_substream * substream);
|
|
void (*trigger) (struct snd_rawmidi_substream * substream, int up);
|
|
void (*drain) (struct snd_rawmidi_substream * substream);
|
|
};
|
|
|
|
struct snd_rawmidi_global_ops {
|
|
int (*dev_register) (struct snd_rawmidi * rmidi);
|
|
int (*dev_unregister) (struct snd_rawmidi * rmidi);
|
|
void (*get_port_info)(struct snd_rawmidi *rmidi, int number,
|
|
struct snd_seq_port_info *info);
|
|
};
|
|
|
|
struct snd_rawmidi_runtime {
|
|
struct snd_rawmidi_substream *substream;
|
|
unsigned int drain: 1, /* drain stage */
|
|
oss: 1; /* OSS compatible mode */
|
|
/* midi stream buffer */
|
|
unsigned char *buffer; /* buffer for MIDI data */
|
|
size_t buffer_size; /* size of buffer */
|
|
size_t appl_ptr; /* application pointer */
|
|
size_t hw_ptr; /* hardware pointer */
|
|
size_t avail_min; /* min avail for wakeup */
|
|
size_t avail; /* max used buffer for wakeup */
|
|
size_t xruns; /* over/underruns counter */
|
|
/* misc */
|
|
spinlock_t lock;
|
|
struct mutex realloc_mutex;
|
|
wait_queue_head_t sleep;
|
|
/* event handler (new bytes, input only) */
|
|
void (*event)(struct snd_rawmidi_substream *substream);
|
|
/* defers calls to event [input] or ops->trigger [output] */
|
|
struct work_struct event_work;
|
|
/* private data */
|
|
void *private_data;
|
|
void (*private_free)(struct snd_rawmidi_substream *substream);
|
|
};
|
|
|
|
struct snd_rawmidi_substream {
|
|
struct list_head list; /* list of all substream for given stream */
|
|
int stream; /* direction */
|
|
int number; /* substream number */
|
|
bool opened; /* open flag */
|
|
bool append; /* append flag (merge more streams) */
|
|
bool active_sensing; /* send active sensing when close */
|
|
int use_count; /* use counter (for output) */
|
|
size_t bytes;
|
|
struct snd_rawmidi *rmidi;
|
|
struct snd_rawmidi_str *pstr;
|
|
char name[32];
|
|
struct snd_rawmidi_runtime *runtime;
|
|
struct pid *pid;
|
|
/* hardware layer */
|
|
struct snd_rawmidi_ops *ops;
|
|
};
|
|
|
|
struct snd_rawmidi_file {
|
|
struct snd_rawmidi *rmidi;
|
|
struct snd_rawmidi_substream *input;
|
|
struct snd_rawmidi_substream *output;
|
|
};
|
|
|
|
struct snd_rawmidi_str {
|
|
unsigned int substream_count;
|
|
unsigned int substream_opened;
|
|
struct list_head substreams;
|
|
};
|
|
|
|
struct snd_rawmidi {
|
|
struct snd_card *card;
|
|
struct list_head list;
|
|
unsigned int device; /* device number */
|
|
unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */
|
|
char id[64];
|
|
char name[80];
|
|
|
|
#ifdef CONFIG_SND_OSSEMUL
|
|
int ossreg;
|
|
#endif
|
|
|
|
const struct snd_rawmidi_global_ops *ops;
|
|
|
|
struct snd_rawmidi_str streams[2];
|
|
|
|
void *private_data;
|
|
void (*private_free) (struct snd_rawmidi *rmidi);
|
|
|
|
struct mutex open_mutex;
|
|
wait_queue_head_t open_wait;
|
|
|
|
struct device dev;
|
|
|
|
struct snd_info_entry *proc_entry;
|
|
|
|
#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
|
|
struct snd_seq_device *seq_dev;
|
|
#endif
|
|
};
|
|
|
|
/* main rawmidi functions */
|
|
|
|
int snd_rawmidi_new(struct snd_card *card, char *id, int device,
|
|
int output_count, int input_count,
|
|
struct snd_rawmidi **rmidi);
|
|
void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
|
|
struct snd_rawmidi_ops *ops);
|
|
|
|
/* callbacks */
|
|
|
|
int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
|
|
const unsigned char *buffer, int count);
|
|
int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream);
|
|
int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
|
|
unsigned char *buffer, int count);
|
|
int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count);
|
|
int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
|
|
unsigned char *buffer, int count);
|
|
int __snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
|
|
unsigned char *buffer, int count);
|
|
int __snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream,
|
|
int count);
|
|
|
|
/* main midi functions */
|
|
|
|
int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info);
|
|
int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
|
|
int mode, struct snd_rawmidi_file *rfile);
|
|
int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile);
|
|
int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
|
|
struct snd_rawmidi_params *params);
|
|
int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
|
|
struct snd_rawmidi_params *params);
|
|
int snd_rawmidi_drop_output(struct snd_rawmidi_substream *substream);
|
|
int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream);
|
|
int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream);
|
|
long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream,
|
|
unsigned char *buf, long count);
|
|
long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream,
|
|
const unsigned char *buf, long count);
|
|
|
|
#endif /* __SOUND_RAWMIDI_H */
|