Changes in 4.9.331 uas: add no-uas quirk for Hiksemi usb_disk usb-storage: Add Hiksemi USB3-FW to IGNORE_UAS uas: ignore UAS for Thinkplus chips net: usb: qmi_wwan: Add new usb-id for Dell branded EM7455 ntfs: fix BUG_ON in ntfs_lookup_inode_by_name() mmc: moxart: fix 4-bit bus width and remove 8-bit bus width mm: prevent page_frag_alloc() from corrupting the memory Revert "drm: bridge: analogix/dp: add panel prepare/unprepare in suspend/resume time" Input: melfas_mip4 - fix return value check in mip4_probe() usbnet: Fix memory leak in usbnet_disconnect() nvme: add new line after variable declatation nvme: Fix IOC_PR_CLEAR and IOC_PR_RELEASE ioctls for nvme devices selftests: Fix the if conditions of in test_extra_filter() clk: iproc: Minor tidy up of iproc pll data structures clk: iproc: Do not rely on node name for correct PLL setup Makefile.extrawarn: Move -Wcast-function-type-strict to W=1 ARM: fix function graph tracer and unwinder dependencies fs: fix UAF/GPF bug in nilfs_mdt_destroy dmaengine: xilinx_dma: cleanup for fetching xlnx,num-fstores property dmaengine: xilinx_dma: Report error in case of dma_set_mask_and_coherent API failure ARM: dts: fix Moxa SDIO 'compatible', remove 'sdhci' misnomer net/ieee802154: fix uninit value bug in dgram_sendmsg um: Cleanup syscall_handler_t cast in syscalls_32.h um: Cleanup compiler warning in arch/x86/um/tls_32.c usb: mon: make mmapped memory read only USB: serial: ftdi_sio: fix 300 bps rate for SIO nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level() nilfs2: fix leak of nilfs_root in case of writer thread creation failure nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure ceph: don't truncate file in atomic_open random: clamp credited irq bits to maximum mixed ALSA: hda: Fix position reporting on Poulsbo scsi: stex: Properly zero out the passthrough command structure USB: serial: qcserial: add new usb-id for Dell branded EM7455 random: avoid reading two cache lines on irq randomness wifi: mac80211_hwsim: avoid mac80211 warning on bad rate random: restore O_NONBLOCK support Input: xpad - add supported devices as contributed on github Input: xpad - fix wireless 360 controller breaking after suspend random: use expired timer rather than wq for mixing fast pool ALSA: oss: Fix potential deadlock at unregistration ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free() ALSA: usb-audio: Fix potential memory leaks ALSA: usb-audio: Fix NULL dererence at error path iio: dac: ad5593r: Fix i2c read protocol requirements fs: dlm: fix race between test_bit() and queue_work() fs: dlm: handle -EBUSY first in lock arg validation quota: Check next/prev free block number after reading from quota file regulator: qcom_rpm: Fix circular deferral regression parisc: fbdev/stifb: Align graphics memory size to 4MB UM: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK PCI: Sanitise firmware BAR assignments behind a PCI-PCI bridge fbdev: smscufx: Fix use-after-free in ufx_ops_open() nilfs2: fix use-after-free bug of struct nilfs_root ext4: avoid crash when inline data creation follows DIO write ext4: fix null-ptr-deref in ext4_write_info ext4: make ext4_lazyinit_thread freezable ext4: place buffer head allocation before handle start ring-buffer: Allow splice to read previous partially read pages ring-buffer: Check pending waiters when doing wake ups as well ring-buffer: Fix race between reset page and reading page KVM: x86/emulator: Fix handing of POP SS to correctly set interruptibility selinux: use "grep -E" instead of "egrep" sh: machvec: Use char[] for section boundaries wifi: ath10k: add peer map clean up for peer delete in ath10k_sta_state() wifi: mac80211: allow bw change during channel switch in mesh wifi: rtl8xxxu: tighten bounds checking in rtl8xxxu_read_efuse() spi: qup: add missing clk_disable_unprepare on error in spi_qup_resume() spi: qup: add missing clk_disable_unprepare on error in spi_qup_pm_resume_runtime() wifi: rtl8xxxu: gen2: Fix mistake in path B IQ calibration net: fs_enet: Fix wrong check in do_pd_setup spi/omap100k:Fix PM disable depth imbalance in omap1_spi100k_probe mISDN: fix use-after-free bugs in l1oip timer handlers tcp: fix tcp_cwnd_validate() to not forget is_cwnd_limited net: rds: don't hold sock lock when cancelling work from rds_tcp_reset_callbacks() bnx2x: fix potential memory leak in bnx2x_tpa_stop() drm/mipi-dsi: Detach devices when removing the host platform/x86: msi-laptop: Fix old-ec check for backlight registering mmc: au1xmmc: Fix an error handling path in au1xmmc_probe() ASoC: eureka-tlv320: Hold reference returned from of_find_xxx API ALSA: dmaengine: increment buffer pointer atomically memory: of: Fix refcount leak bug in of_get_ddr_timings() soc: qcom: smsm: Fix refcount leak bugs in qcom_smsm_probe() soc: qcom: smem_state: Add refcounting for the 'state->of_node' ARM: dts: kirkwood: lsxl: fix serial line ARM: dts: kirkwood: lsxl: remove first ethernet port ARM: Drop CMDLINE_* dependency on ATAGS ARM: dts: exynos: fix polarity of VBUS GPIO of Origen iio: adc: at91-sama5d2_adc: fix AT91_SAMA5D2_MR_TRACKTIM_MAX iio: inkern: only release the device node when done with it iio: ABI: Fix wrong format of differential capacitance channel ABI. clk: tegra: Fix refcount leak in tegra210_clock_init clk: tegra: Fix refcount leak in tegra114_clock_init clk: tegra20: Fix refcount leak in tegra20_clock_init HSI: omap_ssi: Fix refcount leak in ssi_probe HSI: omap_ssi_port: Fix dma_map_sg error check media: exynos4-is: fimc-is: Add of_node_put() when breaking out of loop tty: xilinx_uartps: Fix the ignore_status media: xilinx: vipp: Fix refcount leak in xvip_graph_dma_init RDMA/rxe: Fix "kernel NULL pointer dereference" error RDMA/rxe: Fix the error caused by qp->sk dyndbg: fix module.dyndbg handling dyndbg: let query-modname override actual module name ata: fix ata_id_sense_reporting_enabled() and ata_id_has_sense_reporting() ata: fix ata_id_has_devslp() ata: fix ata_id_has_ncq_autosense() ata: fix ata_id_has_dipm() drivers: serial: jsm: fix some leaks in probe firmware: google: Test spinlock on panic path to avoid lockups serial: 8250: Fix restoring termios speed after suspend mfd: intel_soc_pmic: Fix an error handling path in intel_soc_pmic_i2c_probe() mfd: lp8788: Fix an error handling path in lp8788_probe() mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init() mfd: sm501: Add check for platform_driver_register() dmaengine: ioat: stop mod_timer from resurrecting deleted timer in __cleanup() clk: bcm2835: fix bcm2835_clock_rate_from_divisor declaration clk: ti: dra7-atl: Fix reference leak in of_dra7_atl_clk_probe powerpc/math_emu/efp: Include module.h powerpc/pci_dn: Add missing of_node_put() powerpc: Fix SPE Power ISA properties for e500v1 platforms iommu/omap: Fix buffer overflow in debugfs f2fs: fix race condition on setting FI_NO_EXTENT flag ACPI: video: Add Toshiba Satellite/Portege Z830 quirk MIPS: BCM47XX: Cast memcmp() of function to (void *) powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash openvswitch: Fix double reporting of drops in dropwatch openvswitch: Fix overreporting of drops in dropwatch tcp: annotate data-race around tcp_md5sig_pool_populated xfrm: Update ipcomp_scratches with NULL when freed Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create() Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times can: bcm: check the result of can_send() in bcm_can_tx() wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620 Bluetooth: L2CAP: Fix user-after-free r8152: Rate limit overflow messages drm: Use size_t type for len variable in drm_copy_field() drm: Prevent drm_copy_field() to attempt copying a NULL pointer platform/x86: msi-laptop: Change DMI match / alias strings to fix module autoloading drm/amdgpu: fix initial connector audio value ARM: dts: imx7d-sdb: config the max pressure for tsc2046 ARM: dts: imx6q: add missing properties for sram ARM: dts: imx6dl: add missing properties for sram ARM: dts: imx6qp: add missing properties for sram ARM: dts: imx6sl: add missing properties for sram media: cx88: Fix a null-ptr-deref bug in buffer_prepare() scsi: 3w-9xxx: Avoid disabling device if failing to enable it HID: roccat: Fix use-after-free in roccat_read() usb: host: xhci: Fix potential memory leak in xhci_alloc_stream_info() usb: musb: Fix musb_gadget.c rxstate overflow bug Revert "usb: storage: Add quirk for Samsung Fit flash" usb: idmouse: fix an uninit-value in idmouse_open perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc net: ieee802154: return -EINVAL for unknown addr type net/ieee802154: don't warn zero-sized raw_sendmsg() ext4: continue to expand file system when the target size doesn't reach inet: fully convert sk->sk_rx_dst to RCU rules thermal: intel_powerclamp: Use first online CPU as control_cpu gcov: support GCC 12.1 and newer compilers Linux 4.9.331 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I105d6215a29d200abe3330f328ce3c2009ba0df9
384 lines
12 KiB
C
384 lines
12 KiB
C
/*
|
|
* Copyright (C) 2012, Analog Devices Inc.
|
|
* Author: Lars-Peter Clausen <lars@metafoo.de>
|
|
*
|
|
* Based on:
|
|
* imx-pcm-dma-mx2.c, Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de>
|
|
* mxs-pcm.c, Copyright (C) 2011 Freescale Semiconductor, Inc.
|
|
* ep93xx-pcm.c, Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
|
|
* Copyright (C) 2006 Applied Data Systems
|
|
*
|
|
* 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.
|
|
*
|
|
* 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.,
|
|
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/dmaengine.h>
|
|
#include <linux/slab.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/pcm_params.h>
|
|
#include <sound/soc.h>
|
|
|
|
#include <sound/dmaengine_pcm.h>
|
|
|
|
struct dmaengine_pcm_runtime_data {
|
|
struct dma_chan *dma_chan;
|
|
dma_cookie_t cookie;
|
|
|
|
unsigned int pos;
|
|
};
|
|
|
|
static inline struct dmaengine_pcm_runtime_data *substream_to_prtd(
|
|
const struct snd_pcm_substream *substream)
|
|
{
|
|
return substream->runtime->private_data;
|
|
}
|
|
|
|
struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
|
|
return prtd->dma_chan;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_get_chan);
|
|
|
|
/**
|
|
* snd_hwparams_to_dma_slave_config - Convert hw_params to dma_slave_config
|
|
* @substream: PCM substream
|
|
* @params: hw_params
|
|
* @slave_config: DMA slave config
|
|
*
|
|
* This function can be used to initialize a dma_slave_config from a substream
|
|
* and hw_params in a dmaengine based PCM driver implementation.
|
|
*/
|
|
int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream,
|
|
const struct snd_pcm_hw_params *params,
|
|
struct dma_slave_config *slave_config)
|
|
{
|
|
enum dma_slave_buswidth buswidth;
|
|
int bits;
|
|
|
|
bits = params_physical_width(params);
|
|
if (bits < 8 || bits > 64)
|
|
return -EINVAL;
|
|
else if (bits == 8)
|
|
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
|
|
else if (bits == 16)
|
|
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
|
|
else if (bits == 24)
|
|
buswidth = DMA_SLAVE_BUSWIDTH_3_BYTES;
|
|
else if (bits <= 32)
|
|
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
|
else
|
|
buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES;
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
|
slave_config->direction = DMA_MEM_TO_DEV;
|
|
slave_config->dst_addr_width = buswidth;
|
|
} else {
|
|
slave_config->direction = DMA_DEV_TO_MEM;
|
|
slave_config->src_addr_width = buswidth;
|
|
}
|
|
|
|
slave_config->device_fc = false;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_set_config_from_dai_data() - Initializes a dma slave config
|
|
* using DAI DMA data.
|
|
* @substream: PCM substream
|
|
* @dma_data: DAI DMA data
|
|
* @slave_config: DMA slave configuration
|
|
*
|
|
* Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width and
|
|
* slave_id fields of the DMA slave config from the same fields of the DAI DMA
|
|
* data struct. The src and dst fields will be initialized depending on the
|
|
* direction of the substream. If the substream is a playback stream the dst
|
|
* fields will be initialized, if it is a capture stream the src fields will be
|
|
* initialized. The {dst,src}_addr_width field will only be initialized if the
|
|
* SND_DMAENGINE_PCM_DAI_FLAG_PACK flag is set or if the addr_width field of
|
|
* the DAI DMA data struct is not equal to DMA_SLAVE_BUSWIDTH_UNDEFINED. If
|
|
* both conditions are met the latter takes priority.
|
|
*/
|
|
void snd_dmaengine_pcm_set_config_from_dai_data(
|
|
const struct snd_pcm_substream *substream,
|
|
const struct snd_dmaengine_dai_dma_data *dma_data,
|
|
struct dma_slave_config *slave_config)
|
|
{
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
|
slave_config->dst_addr = dma_data->addr;
|
|
slave_config->dst_maxburst = dma_data->maxburst;
|
|
if (dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK)
|
|
slave_config->dst_addr_width =
|
|
DMA_SLAVE_BUSWIDTH_UNDEFINED;
|
|
if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED)
|
|
slave_config->dst_addr_width = dma_data->addr_width;
|
|
} else {
|
|
slave_config->src_addr = dma_data->addr;
|
|
slave_config->src_maxburst = dma_data->maxburst;
|
|
if (dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK)
|
|
slave_config->src_addr_width =
|
|
DMA_SLAVE_BUSWIDTH_UNDEFINED;
|
|
if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED)
|
|
slave_config->src_addr_width = dma_data->addr_width;
|
|
}
|
|
|
|
slave_config->slave_id = dma_data->slave_id;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_set_config_from_dai_data);
|
|
|
|
static void dmaengine_pcm_dma_complete(void *arg)
|
|
{
|
|
unsigned int new_pos;
|
|
struct snd_pcm_substream *substream = arg;
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
|
|
new_pos = prtd->pos + snd_pcm_lib_period_bytes(substream);
|
|
if (new_pos >= snd_pcm_lib_buffer_bytes(substream))
|
|
new_pos = 0;
|
|
prtd->pos = new_pos;
|
|
|
|
snd_pcm_period_elapsed(substream);
|
|
}
|
|
|
|
static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
struct dma_chan *chan = prtd->dma_chan;
|
|
struct dma_async_tx_descriptor *desc;
|
|
enum dma_transfer_direction direction;
|
|
unsigned long flags = DMA_CTRL_ACK;
|
|
|
|
direction = snd_pcm_substream_to_dma_direction(substream);
|
|
|
|
if (!substream->runtime->no_period_wakeup)
|
|
flags |= DMA_PREP_INTERRUPT;
|
|
|
|
prtd->pos = 0;
|
|
desc = dmaengine_prep_dma_cyclic(chan,
|
|
substream->runtime->dma_addr,
|
|
snd_pcm_lib_buffer_bytes(substream),
|
|
snd_pcm_lib_period_bytes(substream), direction, flags);
|
|
|
|
if (!desc)
|
|
return -ENOMEM;
|
|
|
|
desc->callback = dmaengine_pcm_dma_complete;
|
|
desc->callback_param = substream;
|
|
prtd->cookie = dmaengine_submit(desc);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_trigger - dmaengine based PCM trigger implementation
|
|
* @substream: PCM substream
|
|
* @cmd: Trigger command
|
|
*
|
|
* Returns 0 on success, a negative error code otherwise.
|
|
*
|
|
* This function can be used as the PCM trigger callback for dmaengine based PCM
|
|
* driver implementations.
|
|
*/
|
|
int snd_dmaengine_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
int ret;
|
|
|
|
switch (cmd) {
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
ret = dmaengine_pcm_prepare_and_submit(substream);
|
|
if (ret)
|
|
return ret;
|
|
dma_async_issue_pending(prtd->dma_chan);
|
|
break;
|
|
case SNDRV_PCM_TRIGGER_RESUME:
|
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
|
dmaengine_resume(prtd->dma_chan);
|
|
break;
|
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
|
if (runtime->info & SNDRV_PCM_INFO_PAUSE)
|
|
dmaengine_pause(prtd->dma_chan);
|
|
else
|
|
dmaengine_terminate_async(prtd->dma_chan);
|
|
break;
|
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
|
dmaengine_pause(prtd->dma_chan);
|
|
break;
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
|
dmaengine_terminate_async(prtd->dma_chan);
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_trigger);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_pointer_no_residue - dmaengine based PCM pointer implementation
|
|
* @substream: PCM substream
|
|
*
|
|
* This function is deprecated and should not be used by new drivers, as its
|
|
* results may be unreliable.
|
|
*/
|
|
snd_pcm_uframes_t snd_dmaengine_pcm_pointer_no_residue(struct snd_pcm_substream *substream)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
return bytes_to_frames(substream->runtime, prtd->pos);
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_pointer_no_residue);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_pointer - dmaengine based PCM pointer implementation
|
|
* @substream: PCM substream
|
|
*
|
|
* This function can be used as the PCM pointer callback for dmaengine based PCM
|
|
* driver implementations.
|
|
*/
|
|
snd_pcm_uframes_t snd_dmaengine_pcm_pointer(struct snd_pcm_substream *substream)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
struct dma_tx_state state;
|
|
enum dma_status status;
|
|
unsigned int buf_size;
|
|
unsigned int pos = 0;
|
|
|
|
status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state);
|
|
if (status == DMA_IN_PROGRESS || status == DMA_PAUSED) {
|
|
buf_size = snd_pcm_lib_buffer_bytes(substream);
|
|
if (state.residue > 0 && state.residue <= buf_size)
|
|
pos = buf_size - state.residue;
|
|
}
|
|
|
|
return bytes_to_frames(substream->runtime, pos);
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_pointer);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_request_channel - Request channel for the dmaengine PCM
|
|
* @filter_fn: Filter function used to request the DMA channel
|
|
* @filter_data: Data passed to the DMA filter function
|
|
*
|
|
* Returns NULL or the requested DMA channel.
|
|
*
|
|
* This function request a DMA channel for usage with dmaengine PCM.
|
|
*/
|
|
struct dma_chan *snd_dmaengine_pcm_request_channel(dma_filter_fn filter_fn,
|
|
void *filter_data)
|
|
{
|
|
dma_cap_mask_t mask;
|
|
|
|
dma_cap_zero(mask);
|
|
dma_cap_set(DMA_SLAVE, mask);
|
|
dma_cap_set(DMA_CYCLIC, mask);
|
|
|
|
return dma_request_channel(mask, filter_fn, filter_data);
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_request_channel);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_open - Open a dmaengine based PCM substream
|
|
* @substream: PCM substream
|
|
* @chan: DMA channel to use for data transfers
|
|
*
|
|
* Returns 0 on success, a negative error code otherwise.
|
|
*
|
|
* The function should usually be called from the pcm open callback. Note that
|
|
* this function will use private_data field of the substream's runtime. So it
|
|
* is not available to your pcm driver implementation.
|
|
*/
|
|
int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,
|
|
struct dma_chan *chan)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd;
|
|
int ret;
|
|
|
|
if (!chan)
|
|
return -ENXIO;
|
|
|
|
ret = snd_pcm_hw_constraint_integer(substream->runtime,
|
|
SNDRV_PCM_HW_PARAM_PERIODS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
|
|
if (!prtd)
|
|
return -ENOMEM;
|
|
|
|
prtd->dma_chan = chan;
|
|
|
|
substream->runtime->private_data = prtd;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_open);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_open_request_chan - Open a dmaengine based PCM substream and request channel
|
|
* @substream: PCM substream
|
|
* @filter_fn: Filter function used to request the DMA channel
|
|
* @filter_data: Data passed to the DMA filter function
|
|
*
|
|
* Returns 0 on success, a negative error code otherwise.
|
|
*
|
|
* This function will request a DMA channel using the passed filter function and
|
|
* data. The function should usually be called from the pcm open callback. Note
|
|
* that this function will use private_data field of the substream's runtime. So
|
|
* it is not available to your pcm driver implementation.
|
|
*/
|
|
int snd_dmaengine_pcm_open_request_chan(struct snd_pcm_substream *substream,
|
|
dma_filter_fn filter_fn, void *filter_data)
|
|
{
|
|
return snd_dmaengine_pcm_open(substream,
|
|
snd_dmaengine_pcm_request_channel(filter_fn, filter_data));
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_open_request_chan);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_close - Close a dmaengine based PCM substream
|
|
* @substream: PCM substream
|
|
*/
|
|
int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
|
|
dmaengine_synchronize(prtd->dma_chan);
|
|
kfree(prtd);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close);
|
|
|
|
/**
|
|
* snd_dmaengine_pcm_release_chan_close - Close a dmaengine based PCM substream and release channel
|
|
* @substream: PCM substream
|
|
*
|
|
* Releases the DMA channel associated with the PCM substream.
|
|
*/
|
|
int snd_dmaengine_pcm_close_release_chan(struct snd_pcm_substream *substream)
|
|
{
|
|
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
|
|
|
dmaengine_synchronize(prtd->dma_chan);
|
|
dma_release_channel(prtd->dma_chan);
|
|
kfree(prtd);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close_release_chan);
|
|
|
|
MODULE_LICENSE("GPL");
|