Changes in 4.9.249 spi: bcm2835aux: Fix use-after-free on unbind spi: bcm2835aux: Restore err assignment in bcm2835aux_spi_probe iwlwifi: pcie: limit memory read spin time arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 boards. ARC: stack unwinding: don't assume non-current task is sleeping platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE Input: cm109 - do not stomp on control URB Input: i8042 - add Acer laptops to the i8042 reset list pinctrl: amd: remove debounce filter setting in IRQ type setting scsi: be2iscsi: Revert "Fix a theoretical leak in beiscsi_create_eqs()" spi: Prevent adding devices below an unregistering controller net/mlx4_en: Avoid scheduling restart task if it is already running tcp: fix cwnd-limited bug for TSO deferral where we send nothing net: stmmac: delete the eee_ctrl_timer after napi disabled net: stmmac: dwmac-meson8b: fix mask definition of the m250_sel mux net: bridge: vlan: fix error return code in __vlan_add() mac80211: mesh: fix mesh_pathtbl_init() error path USB: dummy-hcd: Fix uninitialized array use in init() USB: add RESET_RESUME quirk for Snapscan 1212 ALSA: usb-audio: Fix potential out-of-bounds shift ALSA: usb-audio: Fix control 'access overflow' errors from chmap xhci: Give USB2 ports time to enter U3 in bus suspend USB: sisusbvga: Make console support depend on BROKEN ALSA: pcm: oss: Fix potential out-of-bounds shift serial: 8250_omap: Avoid FIFO corruption caused by MDR1 access pinctrl: merrifield: Set default bias in case no particular value given pinctrl: baytrail: Avoid clearing debounce value when turning it off scsi: bnx2i: Requires MMU can: softing: softing_netdev_open(): fix error handling RDMA/cm: Fix an attempt to use non-valid pointer when cleaning timewait kernel/cpu: add arch override for clear_tasks_mm_cpumask() mm handling drm/tegra: sor: Disable clocks on error in tegra_sor_init() scsi: mpt3sas: Increase IOCInit request timeout to 30s dm table: Remove BUG_ON(in_interrupt()) soc/tegra: fuse: Fix index bug in get_process_id USB: serial: option: add interface-number sanity check to flag handling USB: gadget: f_acm: add support for SuperSpeed Plus USB: gadget: f_midi: setup SuperSpeed Plus descriptors USB: gadget: f_rndis: fix bitrate for SuperSpeed and above usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to imx6ul ARM: dts: exynos: fix roles of USB 3.0 ports on Odroid XU ARM: dts: exynos: fix USB 3.0 VBUS control and over-current pins on Exynos5410 ARM: dts: exynos: fix USB 3.0 pins supply being turned off on Odroid XU HID: i2c-hid: add Vero K147 to descriptor override serial_core: Check for port state when tty is in error state media: msi2500: assign SPI bus number dynamically md: fix a warning caused by a race between concurrent md_ioctl()s Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt() drm/gma500: fix double free of gma_connector RDMA/rxe: Compute PSN windows correctly ARM: p2v: fix handling of LPAE translation in BE mode crypto: talitos - Fix return type of current_desc_hdr() spi: img-spfi: fix reference leak in img_spfi_resume ASoC: pcm: DRAIN support reactivation arm64: dts: exynos: Correct psci compatible used on Exynos7 Bluetooth: Fix null pointer dereference in hci_event_packet() spi: spi-ti-qspi: fix reference leak in ti_qspi_setup spi: tegra20-slink: fix reference leak in slink ops of tegra20 spi: tegra20-sflash: fix reference leak in tegra_sflash_resume spi: tegra114: fix reference leak in tegra spi ops RDMa/mthca: Work around -Wenum-conversion warning MIPS: BCM47XX: fix kconfig dependency bug for BCM47XX_BCMA staging: greybus: codecs: Fix reference counter leak in error handling media: solo6x10: fix missing snd_card_free in error handling case drm/omap: dmm_tiler: fix return error code in omap_dmm_probe() Input: ads7846 - fix integer overflow on Rt calculation Input: ads7846 - fix unaligned access on 7845 powerpc/feature: Fix CPU_FTRS_ALWAYS by removing CPU_FTRS_GENERIC_32 crypto: omap-aes - Fix PM disable depth imbalance in omap_aes_probe soc: ti: knav_qmss: fix reference leak in knav_queue_probe soc: ti: Fix reference imbalance in knav_dma_probe drivers: soc: ti: knav_qmss_queue: Fix error return code in knav_queue_probe RDMA/cxgb4: Validate the number of CQEs memstick: fix a double-free bug in memstick_check ARM: dts: at91: sama5d4_xplained: add pincontrol for USB Host ARM: dts: at91: sama5d3_xplained: add pincontrol for USB Host orinoco: Move context allocation after processing the skb cw1200: fix missing destroy_workqueue() on error in cw1200_init_common media: siano: fix memory leak of debugfs members in smsdvb_hotplug mips: cdmm: fix use-after-free in mips_cdmm_bus_discover HSI: omap_ssi: Don't jump to free ID in ssi_add_controller() ARM: dts: at91: at91sam9rl: fix ADC triggers NFSv4.2: condition READDIR's mask for security label based on LSM state SUNRPC: xprt_load_transport() needs to support the netid "rdma6" lockd: don't use interval-based rebinding over TCP NFS: switch nfsiod to be an UNBOUND workqueue. vfio-pci: Use io_remap_pfn_range() for PCI IO memory media: saa7146: fix array overflow in vidioc_s_audio() clocksource/drivers/cadence_ttc: Fix memory leak in ttc_setup_clockevent() pinctrl: falcon: add missing put_device() call in pinctrl_falcon_probe() memstick: r592: Fix error return in r592_probe() ASoC: jz4740-i2s: add missed checks for clk_get() dm ioctl: fix error return code in target_message clocksource/drivers/arm_arch_timer: Correct fault programming of CNTKCTL_EL1.EVNTI cpufreq: highbank: Add missing MODULE_DEVICE_TABLE cpufreq: st: Add missing MODULE_DEVICE_TABLE cpufreq: loongson1: Add missing MODULE_ALIAS cpufreq: scpi: Add missing MODULE_ALIAS scsi: pm80xx: Fix error return in pm8001_pci_probe() seq_buf: Avoid type mismatch for seq_buf_init scsi: fnic: Fix error return code in fnic_probe() powerpc/pseries/hibernation: drop pseries_suspend_begin() from suspend ops usb: ehci-omap: Fix PM disable depth umbalance in ehci_hcd_omap_probe usb: oxu210hp-hcd: Fix memory leak in oxu_create speakup: fix uninitialized flush_lock nfsd: Fix message level for normal termination nfs_common: need lock during iterate through the list x86/kprobes: Restore BTF if the single-stepping is cancelled clk: tegra: Fix duplicated SE clock entry extcon: max77693: Fix modalias string ASoC: wm_adsp: remove "ctl" from list on error in wm_adsp_create_control() irqchip/alpine-msi: Fix freeing of interrupts on allocation error path um: chan_xterm: Fix fd leak nfc: s3fwrn5: Release the nfc firmware powerpc/ps3: use dma_mapping_error() checkpatch: fix unescaped left brace net: bcmgenet: Fix a resource leak in an error handling path in the probe functin net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function net: korina: fix return value watchdog: qcom: Avoid context switch in restart handler clk: ti: Fix memleak in ti_fapll_synth_setup perf record: Fix memory leak when using '--user-regs=?' to list registers qlcnic: Fix error code in probe clk: s2mps11: Fix a resource leak in error handling paths in the probe function cfg80211: initialize rekey_data Input: cros_ec_keyb - send 'scancodes' in addition to key events Input: goodix - add upside-down quirk for Teclast X98 Pro tablet media: gspca: Fix memory leak in probe media: sunxi-cir: ensure IR is handled when it is continuous media: netup_unidvb: Don't leak SPI master in probe error path Input: cyapa_gen6 - fix out-of-bounds stack access Revert "ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources walks" ACPI: PNP: compare the string length in the matching_id() ALSA: pcm: oss: Fix a few more UBSAN fixes ALSA: usb-audio: Disable sample read check if firmware doesn't give back s390/dasd: prevent inconsistent LCU device data s390/dasd: fix list corruption of pavgroup group list s390/dasd: fix list corruption of lcu list staging: comedi: mf6x4: Fix AI end-of-conversion detection powerpc/perf: Exclude kernel samples while counting events in user space. USB: serial: mos7720: fix parallel-port state restore USB: serial: keyspan_pda: fix dropped unthrottle interrupts USB: serial: keyspan_pda: fix write deadlock USB: serial: keyspan_pda: fix stalled writes USB: serial: keyspan_pda: fix write-wakeup use-after-free USB: serial: keyspan_pda: fix tx-unthrottle use-after-free USB: serial: keyspan_pda: fix write unthrottling btrfs: quota: Set rescan progress to (u64)-1 if we hit last leaf btrfs: scrub: Don't use inode page cache in scrub_handle_errored_block() Btrfs: fix selftests failure due to uninitialized i_mode in test inodes btrfs: fix return value mixup in btrfs_get_extent ext4: fix a memory leak of ext4_free_data KVM: arm64: Introduce handling of AArch32 TTBCR2 traps powerpc/xmon: Change printk() to pr_cont() ceph: fix race in concurrent __ceph_remove_cap invocations jffs2: Fix GC exit abnormally jfs: Fix array index bounds check in dbAdjTree drm/dp_aux_dev: check aux_dev before use in drm_dp_aux_dev_get_by_minor() spi: spi-sh: Fix use-after-free on unbind spi: davinci: Fix use-after-free on unbind spi: pic32: Don't leak DMA channels in probe error path spi: rb4xx: Don't leak SPI master in probe error path spi: sc18is602: Don't leak SPI master in probe error path spi: st-ssc4: Fix unbalanced pm_runtime_disable() in probe error path soc: qcom: smp2p: Safely acquire spinlock without IRQs mtd: parser: cmdline: Fix parsing of part-names with colons iio: buffer: Fix demux update iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume iio:pressure:mpl3115: Force alignment of buffer clk: mvebu: a3700: fix the XTAL MODE pin to MPP1_9 xen-blkback: set ring->xenblkd to NULL after kthread_stop() PCI: Fix pci_slot_release() NULL pointer dereference Linux 4.9.249 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I4829a32e2ea6e76eefea716f35f42ee02b75c265
420 lines
10 KiB
C
420 lines
10 KiB
C
/*
|
|
* Copyright (C) 2010-2013 Bluecherry, LLC <http://www.bluecherrydvr.com>
|
|
*
|
|
* Original author:
|
|
* Ben Collins <bcollins@ubuntu.com>
|
|
*
|
|
* Additional work by:
|
|
* John Brooks <john.brooks@bluecherry.net>
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/mempool.h>
|
|
#include <linux/poll.h>
|
|
#include <linux/kthread.h>
|
|
#include <linux/freezer.h>
|
|
#include <linux/module.h>
|
|
#include <linux/slab.h>
|
|
|
|
#include <sound/core.h>
|
|
#include <sound/initval.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/control.h>
|
|
|
|
#include "solo6x10.h"
|
|
#include "solo6x10-tw28.h"
|
|
|
|
#define G723_FDMA_PAGES 32
|
|
#define G723_PERIOD_BYTES 48
|
|
#define G723_PERIOD_BLOCK 1024
|
|
#define G723_FRAMES_PER_PAGE 48
|
|
|
|
/* Sets up channels 16-19 for decoding and 0-15 for encoding */
|
|
#define OUTMODE_MASK 0x300
|
|
|
|
#define SAMPLERATE 8000
|
|
#define BITRATE 25
|
|
|
|
/* The solo writes to 1k byte pages, 32 pages, in the dma. Each 1k page
|
|
* is broken down to 20 * 48 byte regions (one for each channel possible)
|
|
* with the rest of the page being dummy data. */
|
|
#define PERIODS G723_FDMA_PAGES
|
|
#define G723_INTR_ORDER 4 /* 0 - 4 */
|
|
|
|
struct solo_snd_pcm {
|
|
int on;
|
|
spinlock_t lock;
|
|
struct solo_dev *solo_dev;
|
|
u8 *g723_buf;
|
|
dma_addr_t g723_dma;
|
|
};
|
|
|
|
static void solo_g723_config(struct solo_dev *solo_dev)
|
|
{
|
|
int clk_div;
|
|
|
|
clk_div = (solo_dev->clock_mhz * 1000000)
|
|
/ (SAMPLERATE * (BITRATE * 2) * 2);
|
|
|
|
solo_reg_write(solo_dev, SOLO_AUDIO_SAMPLE,
|
|
SOLO_AUDIO_BITRATE(BITRATE)
|
|
| SOLO_AUDIO_CLK_DIV(clk_div));
|
|
|
|
solo_reg_write(solo_dev, SOLO_AUDIO_FDMA_INTR,
|
|
SOLO_AUDIO_FDMA_INTERVAL(1)
|
|
| SOLO_AUDIO_INTR_ORDER(G723_INTR_ORDER)
|
|
| SOLO_AUDIO_FDMA_BASE(SOLO_G723_EXT_ADDR(solo_dev) >> 16));
|
|
|
|
solo_reg_write(solo_dev, SOLO_AUDIO_CONTROL,
|
|
SOLO_AUDIO_ENABLE
|
|
| SOLO_AUDIO_I2S_MODE
|
|
| SOLO_AUDIO_I2S_MULTI(3)
|
|
| SOLO_AUDIO_MODE(OUTMODE_MASK));
|
|
}
|
|
|
|
void solo_g723_isr(struct solo_dev *solo_dev)
|
|
{
|
|
struct snd_pcm_str *pstr =
|
|
&solo_dev->snd_pcm->streams[SNDRV_PCM_STREAM_CAPTURE];
|
|
struct snd_pcm_substream *ss;
|
|
struct solo_snd_pcm *solo_pcm;
|
|
|
|
for (ss = pstr->substream; ss != NULL; ss = ss->next) {
|
|
if (snd_pcm_substream_chip(ss) == NULL)
|
|
continue;
|
|
|
|
/* This means open() hasn't been called on this one */
|
|
if (snd_pcm_substream_chip(ss) == solo_dev)
|
|
continue;
|
|
|
|
/* Haven't triggered a start yet */
|
|
solo_pcm = snd_pcm_substream_chip(ss);
|
|
if (!solo_pcm->on)
|
|
continue;
|
|
|
|
snd_pcm_period_elapsed(ss);
|
|
}
|
|
}
|
|
|
|
static int snd_solo_hw_params(struct snd_pcm_substream *ss,
|
|
struct snd_pcm_hw_params *hw_params)
|
|
{
|
|
return snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw_params));
|
|
}
|
|
|
|
static int snd_solo_hw_free(struct snd_pcm_substream *ss)
|
|
{
|
|
return snd_pcm_lib_free_pages(ss);
|
|
}
|
|
|
|
static const struct snd_pcm_hardware snd_solo_pcm_hw = {
|
|
.info = (SNDRV_PCM_INFO_MMAP |
|
|
SNDRV_PCM_INFO_INTERLEAVED |
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
|
SNDRV_PCM_INFO_MMAP_VALID),
|
|
.formats = SNDRV_PCM_FMTBIT_U8,
|
|
.rates = SNDRV_PCM_RATE_8000,
|
|
.rate_min = SAMPLERATE,
|
|
.rate_max = SAMPLERATE,
|
|
.channels_min = 1,
|
|
.channels_max = 1,
|
|
.buffer_bytes_max = G723_PERIOD_BYTES * PERIODS,
|
|
.period_bytes_min = G723_PERIOD_BYTES,
|
|
.period_bytes_max = G723_PERIOD_BYTES,
|
|
.periods_min = PERIODS,
|
|
.periods_max = PERIODS,
|
|
};
|
|
|
|
static int snd_solo_pcm_open(struct snd_pcm_substream *ss)
|
|
{
|
|
struct solo_dev *solo_dev = snd_pcm_substream_chip(ss);
|
|
struct solo_snd_pcm *solo_pcm;
|
|
|
|
solo_pcm = kzalloc(sizeof(*solo_pcm), GFP_KERNEL);
|
|
if (solo_pcm == NULL)
|
|
goto oom;
|
|
|
|
solo_pcm->g723_buf = pci_alloc_consistent(solo_dev->pdev,
|
|
G723_PERIOD_BYTES,
|
|
&solo_pcm->g723_dma);
|
|
if (solo_pcm->g723_buf == NULL)
|
|
goto oom;
|
|
|
|
spin_lock_init(&solo_pcm->lock);
|
|
solo_pcm->solo_dev = solo_dev;
|
|
ss->runtime->hw = snd_solo_pcm_hw;
|
|
|
|
snd_pcm_substream_chip(ss) = solo_pcm;
|
|
|
|
return 0;
|
|
|
|
oom:
|
|
kfree(solo_pcm);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
static int snd_solo_pcm_close(struct snd_pcm_substream *ss)
|
|
{
|
|
struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
|
|
|
|
snd_pcm_substream_chip(ss) = solo_pcm->solo_dev;
|
|
pci_free_consistent(solo_pcm->solo_dev->pdev, G723_PERIOD_BYTES,
|
|
solo_pcm->g723_buf, solo_pcm->g723_dma);
|
|
kfree(solo_pcm);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int snd_solo_pcm_trigger(struct snd_pcm_substream *ss, int cmd)
|
|
{
|
|
struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
|
|
struct solo_dev *solo_dev = solo_pcm->solo_dev;
|
|
int ret = 0;
|
|
|
|
spin_lock(&solo_pcm->lock);
|
|
|
|
switch (cmd) {
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
if (solo_pcm->on == 0) {
|
|
/* If this is the first user, switch on interrupts */
|
|
if (atomic_inc_return(&solo_dev->snd_users) == 1)
|
|
solo_irq_on(solo_dev, SOLO_IRQ_G723);
|
|
solo_pcm->on = 1;
|
|
}
|
|
break;
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
|
if (solo_pcm->on) {
|
|
/* If this was our last user, switch them off */
|
|
if (atomic_dec_return(&solo_dev->snd_users) == 0)
|
|
solo_irq_off(solo_dev, SOLO_IRQ_G723);
|
|
solo_pcm->on = 0;
|
|
}
|
|
break;
|
|
default:
|
|
ret = -EINVAL;
|
|
}
|
|
|
|
spin_unlock(&solo_pcm->lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int snd_solo_pcm_prepare(struct snd_pcm_substream *ss)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static snd_pcm_uframes_t snd_solo_pcm_pointer(struct snd_pcm_substream *ss)
|
|
{
|
|
struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
|
|
struct solo_dev *solo_dev = solo_pcm->solo_dev;
|
|
snd_pcm_uframes_t idx = solo_reg_read(solo_dev, SOLO_AUDIO_STA) & 0x1f;
|
|
|
|
return idx * G723_FRAMES_PER_PAGE;
|
|
}
|
|
|
|
static int snd_solo_pcm_copy(struct snd_pcm_substream *ss, int channel,
|
|
snd_pcm_uframes_t pos, void __user *dst,
|
|
snd_pcm_uframes_t count)
|
|
{
|
|
struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
|
|
struct solo_dev *solo_dev = solo_pcm->solo_dev;
|
|
int err, i;
|
|
|
|
for (i = 0; i < (count / G723_FRAMES_PER_PAGE); i++) {
|
|
int page = (pos / G723_FRAMES_PER_PAGE) + i;
|
|
|
|
err = solo_p2m_dma_t(solo_dev, 0, solo_pcm->g723_dma,
|
|
SOLO_G723_EXT_ADDR(solo_dev) +
|
|
(page * G723_PERIOD_BLOCK) +
|
|
(ss->number * G723_PERIOD_BYTES),
|
|
G723_PERIOD_BYTES, 0, 0);
|
|
if (err)
|
|
return err;
|
|
|
|
err = copy_to_user(dst + (i * G723_PERIOD_BYTES),
|
|
solo_pcm->g723_buf, G723_PERIOD_BYTES);
|
|
|
|
if (err)
|
|
return -EFAULT;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct snd_pcm_ops snd_solo_pcm_ops = {
|
|
.open = snd_solo_pcm_open,
|
|
.close = snd_solo_pcm_close,
|
|
.ioctl = snd_pcm_lib_ioctl,
|
|
.hw_params = snd_solo_hw_params,
|
|
.hw_free = snd_solo_hw_free,
|
|
.prepare = snd_solo_pcm_prepare,
|
|
.trigger = snd_solo_pcm_trigger,
|
|
.pointer = snd_solo_pcm_pointer,
|
|
.copy = snd_solo_pcm_copy,
|
|
};
|
|
|
|
static int snd_solo_capture_volume_info(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_info *info)
|
|
{
|
|
info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
info->count = 1;
|
|
info->value.integer.min = 0;
|
|
info->value.integer.max = 15;
|
|
info->value.integer.step = 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int snd_solo_capture_volume_get(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *value)
|
|
{
|
|
struct solo_dev *solo_dev = snd_kcontrol_chip(kcontrol);
|
|
u8 ch = value->id.numid - 1;
|
|
|
|
value->value.integer.value[0] = tw28_get_audio_gain(solo_dev, ch);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int snd_solo_capture_volume_put(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *value)
|
|
{
|
|
struct solo_dev *solo_dev = snd_kcontrol_chip(kcontrol);
|
|
u8 ch = value->id.numid - 1;
|
|
u8 old_val;
|
|
|
|
old_val = tw28_get_audio_gain(solo_dev, ch);
|
|
if (old_val == value->value.integer.value[0])
|
|
return 0;
|
|
|
|
tw28_set_audio_gain(solo_dev, ch, value->value.integer.value[0]);
|
|
|
|
return 1;
|
|
}
|
|
|
|
static struct snd_kcontrol_new snd_solo_capture_volume = {
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
.name = "Capture Volume",
|
|
.info = snd_solo_capture_volume_info,
|
|
.get = snd_solo_capture_volume_get,
|
|
.put = snd_solo_capture_volume_put,
|
|
};
|
|
|
|
static int solo_snd_pcm_init(struct solo_dev *solo_dev)
|
|
{
|
|
struct snd_card *card = solo_dev->snd_card;
|
|
struct snd_pcm *pcm;
|
|
struct snd_pcm_substream *ss;
|
|
int ret;
|
|
int i;
|
|
|
|
ret = snd_pcm_new(card, card->driver, 0, 0, solo_dev->nr_chans,
|
|
&pcm);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
|
|
&snd_solo_pcm_ops);
|
|
|
|
snd_pcm_chip(pcm) = solo_dev;
|
|
pcm->info_flags = 0;
|
|
strcpy(pcm->name, card->shortname);
|
|
|
|
for (i = 0, ss = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
|
|
ss; ss = ss->next, i++)
|
|
sprintf(ss->name, "Camera #%d Audio", i);
|
|
|
|
ret = snd_pcm_lib_preallocate_pages_for_all(pcm,
|
|
SNDRV_DMA_TYPE_CONTINUOUS,
|
|
snd_dma_continuous_data(GFP_KERNEL),
|
|
G723_PERIOD_BYTES * PERIODS,
|
|
G723_PERIOD_BYTES * PERIODS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
solo_dev->snd_pcm = pcm;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int solo_g723_init(struct solo_dev *solo_dev)
|
|
{
|
|
static struct snd_device_ops ops = { NULL };
|
|
struct snd_card *card;
|
|
struct snd_kcontrol_new kctl;
|
|
char name[32];
|
|
int ret;
|
|
|
|
atomic_set(&solo_dev->snd_users, 0);
|
|
|
|
/* Allows for easier mapping between video and audio */
|
|
sprintf(name, "Softlogic%d", solo_dev->vfd->num);
|
|
|
|
ret = snd_card_new(&solo_dev->pdev->dev,
|
|
SNDRV_DEFAULT_IDX1, name, THIS_MODULE, 0,
|
|
&solo_dev->snd_card);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
card = solo_dev->snd_card;
|
|
|
|
strcpy(card->driver, SOLO6X10_NAME);
|
|
strcpy(card->shortname, "SOLO-6x10 Audio");
|
|
sprintf(card->longname, "%s on %s IRQ %d", card->shortname,
|
|
pci_name(solo_dev->pdev), solo_dev->pdev->irq);
|
|
|
|
ret = snd_device_new(card, SNDRV_DEV_LOWLEVEL, solo_dev, &ops);
|
|
if (ret < 0)
|
|
goto snd_error;
|
|
|
|
/* Mixer controls */
|
|
strcpy(card->mixername, "SOLO-6x10");
|
|
kctl = snd_solo_capture_volume;
|
|
kctl.count = solo_dev->nr_chans;
|
|
|
|
ret = snd_ctl_add(card, snd_ctl_new1(&kctl, solo_dev));
|
|
if (ret < 0)
|
|
goto snd_error;
|
|
|
|
ret = solo_snd_pcm_init(solo_dev);
|
|
if (ret < 0)
|
|
goto snd_error;
|
|
|
|
ret = snd_card_register(card);
|
|
if (ret < 0)
|
|
goto snd_error;
|
|
|
|
solo_g723_config(solo_dev);
|
|
|
|
dev_info(&solo_dev->pdev->dev, "Alsa sound card as %s\n", name);
|
|
|
|
return 0;
|
|
|
|
snd_error:
|
|
snd_card_free(card);
|
|
return ret;
|
|
}
|
|
|
|
void solo_g723_exit(struct solo_dev *solo_dev)
|
|
{
|
|
if (!solo_dev->snd_card)
|
|
return;
|
|
|
|
solo_reg_write(solo_dev, SOLO_AUDIO_CONTROL, 0);
|
|
solo_irq_off(solo_dev, SOLO_IRQ_G723);
|
|
|
|
snd_card_free(solo_dev->snd_card);
|
|
solo_dev->snd_card = NULL;
|
|
}
|