diff options
author | Jaroslav Kysela <perex@perex.cz> | 2010-08-09 14:38:46 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2010-08-09 14:38:46 +0200 |
commit | 9af8f3935136173d7eae25c0c77f172318f14c16 (patch) | |
tree | 83a5942a9ffff254fc0e279a89ca6c10a358a1a6 | |
parent | c6fb61b47384f83ad909bc201a8d9439cd3f960f (diff) | |
download | alsa-driver-build-unstable-9af8f3935136173d7eae25c0c77f172318f14c16.tar.gz |
core: compilation fix for new QoS API, move snd-aloop code to alsa-kernel tree
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r-- | acore/pcm_native.patch | 71 | ||||
-rw-r--r-- | drivers/Makefile | 3 | ||||
-rw-r--r-- | drivers/aloop-kernel.c | 1055 | ||||
-rw-r--r-- | drivers/aloop.c | 2 | ||||
-rw-r--r-- | include/sound/pcm.patch | 22 |
5 files changed, 47 insertions, 1106 deletions
diff --git a/acore/pcm_native.patch b/acore/pcm_native.patch index 02f4946b1..fafef52ec 100644 --- a/acore/pcm_native.patch +++ b/acore/pcm_native.patch @@ -1,5 +1,5 @@ ---- ../alsa-kernel/core/pcm_native.c 2010-05-21 16:36:59.457637275 +0200 -+++ pcm_native.c 2010-05-21 17:01:24.502137046 +0200 +--- ../alsa-kernel/core/pcm_native.c 2010-08-09 14:25:42.000000000 +0200 ++++ pcm_native.c 2010-08-09 14:35:06.000000000 +0200 @@ -1,3 +1,5 @@ +#define __NO_VERSION__ +#include "adriver.h" @@ -17,7 +17,7 @@ #include <linux/time.h> #include <linux/pm_qos_params.h> #include <linux/uio.h> -@@ -369,7 +371,10 @@ +@@ -369,7 +371,10 @@ static int period_to_usecs(struct snd_pc return usecs; } @@ -29,35 +29,34 @@ struct snd_pcm_hw_params *params) { struct snd_pcm_runtime *runtime; -@@ -451,6 +456,7 @@ +@@ -451,11 +456,20 @@ static int snd_pcm_hw_params(struct snd_ snd_pcm_timer_resolution_change(substream); runtime->status->state = SNDRV_PCM_STATE_SETUP; +#ifdef CONFIG_SND_HAVE_PM_QOS_REQUEST - if (substream->latency_pm_qos_req) { - pm_qos_remove_request(substream->latency_pm_qos_req); - substream->latency_pm_qos_req = NULL; -@@ -458,6 +464,13 @@ + if (pm_qos_request_active(&substream->latency_pm_qos_req)) + pm_qos_remove_request(&substream->latency_pm_qos_req); ++ if ((usecs = period_to_usecs(runtime)) >= 0) - substream->latency_pm_qos_req = pm_qos_add_request( - PM_QOS_CPU_DMA_LATENCY, usecs); + pm_qos_add_request(&substream->latency_pm_qos_req, + PM_QOS_CPU_DMA_LATENCY, usecs); +#else + pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, + substream->latency_id); + if ((usecs = period_to_usecs(runtime)) >= 0) + pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, -+ substream->latency_id, usecs); ++ substream->latency_id, usecs); +#endif return 0; _error: /* hardware might be unuseable from this time, -@@ -512,8 +525,13 @@ +@@ -510,7 +524,13 @@ static int snd_pcm_hw_free(struct snd_pc if (substream->ops->hw_free) result = substream->ops->hw_free(substream); runtime->status->state = SNDRV_PCM_STATE_OPEN; +#ifdef CONFIG_SND_HAVE_PM_QOS_REQUEST - pm_qos_remove_request(substream->latency_pm_qos_req); - substream->latency_pm_qos_req = NULL; + pm_qos_remove_request(&substream->latency_pm_qos_req); ++ substream->latency_pm_qos_req = NULL; +#else + pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, + substream->latency_id); @@ -65,7 +64,7 @@ return result; } -@@ -1549,7 +1567,11 @@ +@@ -1546,7 +1566,11 @@ static struct file *snd_pcm_file_fd(int file = fget(fd); if (!file) return NULL; @@ -77,7 +76,7 @@ if (!S_ISCHR(inode->i_mode) || imajor(inode) != snd_major) { fput(file); -@@ -2806,25 +2828,50 @@ +@@ -2803,25 +2827,50 @@ static ssize_t snd_pcm_write(struct file struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; @@ -135,7 +134,7 @@ { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; -@@ -2834,7 +2881,11 @@ +@@ -2831,7 +2880,11 @@ static ssize_t snd_pcm_aio_read(struct k void __user **bufs; snd_pcm_uframes_t frames; @@ -147,7 +146,7 @@ substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; -@@ -2858,8 +2909,13 @@ +@@ -2855,8 +2908,13 @@ static ssize_t snd_pcm_aio_read(struct k return result; } @@ -161,7 +160,7 @@ { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; -@@ -2869,7 +2925,11 @@ +@@ -2866,7 +2924,11 @@ static ssize_t snd_pcm_aio_write(struct void __user **bufs; snd_pcm_uframes_t frames; @@ -173,7 +172,7 @@ substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; -@@ -2891,6 +2951,7 @@ +@@ -2888,6 +2950,7 @@ static ssize_t snd_pcm_aio_write(struct kfree(bufs); return result; } @@ -181,7 +180,7 @@ static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) { -@@ -2978,6 +3039,22 @@ +@@ -2975,6 +3038,22 @@ static unsigned int snd_pcm_capture_poll * mmap support */ @@ -204,7 +203,7 @@ /* * Only on coherent architectures, we can mmap the status and the control records * for effcient data transfer. On others, we have to use HWSYNC ioctl... -@@ -2986,6 +3063,7 @@ +@@ -2983,6 +3062,7 @@ static unsigned int snd_pcm_capture_poll /* * mmap status record */ @@ -212,7 +211,7 @@ static int snd_pcm_mmap_status_fault(struct vm_area_struct *area, struct vm_fault *vmf) { -@@ -2999,10 +3077,49 @@ +@@ -2996,10 +3076,49 @@ static int snd_pcm_mmap_status_fault(str get_page(vmf->page); return 0; } @@ -262,7 +261,7 @@ }; static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, -@@ -3017,7 +3134,11 @@ +@@ -3014,7 +3133,11 @@ static int snd_pcm_mmap_status(struct sn if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_status; @@ -274,7 +273,7 @@ area->vm_flags |= VM_RESERVED; return 0; } -@@ -3025,6 +3146,7 @@ +@@ -3022,6 +3145,7 @@ static int snd_pcm_mmap_status(struct sn /* * mmap control record */ @@ -282,7 +281,7 @@ static int snd_pcm_mmap_control_fault(struct vm_area_struct *area, struct vm_fault *vmf) { -@@ -3038,10 +3160,50 @@ +@@ -3035,10 +3159,50 @@ static int snd_pcm_mmap_control_fault(st get_page(vmf->page); return 0; } @@ -333,7 +332,7 @@ }; static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, -@@ -3056,7 +3218,11 @@ +@@ -3053,7 +3217,11 @@ static int snd_pcm_mmap_control(struct s if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_control; @@ -345,7 +344,7 @@ area->vm_flags |= VM_RESERVED; return 0; } -@@ -3097,9 +3263,16 @@ +@@ -3094,9 +3262,16 @@ snd_pcm_default_page_ops(struct snd_pcm_ return virt_to_page(vaddr); } @@ -362,7 +361,7 @@ static int snd_pcm_mmap_data_fault(struct vm_area_struct *area, struct vm_fault *vmf) { -@@ -3126,6 +3299,59 @@ +@@ -3123,6 +3298,59 @@ static int snd_pcm_mmap_data_fault(struc vmf->page = page; return 0; } @@ -422,7 +421,7 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data = { .open = snd_pcm_mmap_data_open, -@@ -3135,7 +3361,14 @@ +@@ -3132,7 +3360,14 @@ static const struct vm_operations_struct static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = { .open = snd_pcm_mmap_data_open, .close = snd_pcm_mmap_data_close, @@ -437,7 +436,7 @@ }; #ifndef ARCH_HAS_DMA_MMAP_COHERENT -@@ -3183,11 +3416,26 @@ +@@ -3180,11 +3415,26 @@ int snd_pcm_lib_mmap_iomem(struct snd_pc area->vm_page_prot = pgprot_noncached(area->vm_page_prot); area->vm_flags |= VM_IO; size = area->vm_end - area->vm_start; @@ -465,7 +464,7 @@ return 0; } -@@ -3231,7 +3479,7 @@ +@@ -3228,7 +3478,7 @@ int snd_pcm_mmap_data(struct snd_pcm_sub runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) return -EINVAL; size = area->vm_end - area->vm_start; @@ -474,7 +473,7 @@ dma_bytes = PAGE_ALIGN(runtime->dma_bytes); if ((size_t)size > dma_bytes) return -EINVAL; -@@ -3239,7 +3487,11 @@ +@@ -3236,7 +3486,11 @@ int snd_pcm_mmap_data(struct snd_pcm_sub return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_data; @@ -486,7 +485,7 @@ if (substream->ops->mmap) err = substream->ops->mmap(substream, area); else -@@ -3262,7 +3514,7 @@ +@@ -3259,7 +3513,7 @@ static int snd_pcm_mmap(struct file *fil if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; @@ -495,7 +494,7 @@ switch (offset) { case SNDRV_PCM_MMAP_OFFSET_STATUS: if (pcm_file->no_compat_mmap) -@@ -3295,12 +3547,34 @@ +@@ -3292,12 +3546,34 @@ static int snd_pcm_fasync(int fd, struct /* * ioctl32 compat */ @@ -531,7 +530,7 @@ /* * To be removed helpers to keep binary compatibility */ -@@ -3439,31 +3713,55 @@ +@@ -3436,31 +3712,55 @@ static unsigned long snd_pcm_get_unmappe const struct file_operations snd_pcm_f_ops[2] = { { diff --git a/drivers/Makefile b/drivers/Makefile index 600408a06..129181d8b 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -10,10 +10,7 @@ include $(SND_TOPDIR)/Makefile.conf clean-files := mts64.c portman2x4.c snd-serialmidi-objs := serialmidi.o -snd-aloop-objs := aloop.o - obj-$(CONFIG_SND_SERIALMIDI) += snd-serialmidi.o -obj-$(CONFIG_SND_LOOPBACK) += snd-aloop.o include $(SND_TOPDIR)/alsa-kernel/drivers/Makefile diff --git a/drivers/aloop-kernel.c b/drivers/aloop-kernel.c deleted file mode 100644 index 3123a15d2..000000000 --- a/drivers/aloop-kernel.c +++ /dev/null @@ -1,1055 +0,0 @@ -/* - * Loopback soundcard - * - * Original code: - * Copyright (c) by Jaroslav Kysela <perex@perex.cz> - * - * More accurate positioning and full-duplex support: - * Copyright (c) Ahmet İnan <ainan at mathematik.uni-freiburg.de> - * - * Major (almost complete) rewrite: - * Copyright (c) by Takashi Iwai <tiwai@suse.de> - * - * A next major update in 2010 (separate timers for playback and capture): - * Copyright (c) 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 <linux/init.h> -#include <linux/jiffies.h> -#include <linux/slab.h> -#include <linux/time.h> -#include <linux/wait.h> -#include <linux/moduleparam.h> -#include <linux/platform_device.h> -#include <sound/core.h> -#include <sound/control.h> -#include <sound/pcm.h> -#include <sound/initval.h> - -MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); -MODULE_DESCRIPTION("A loopback soundcard"); -MODULE_LICENSE("GPL"); -MODULE_SUPPORTED_DEVICE("{{ALSA,Loopback soundcard}}"); - -#define MAX_PCM_SUBSTREAMS 8 - -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; -static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; -static int pcm_notify[SNDRV_CARDS]; - -module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for loopback soundcard."); -module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for loopback soundcard."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable this loopback soundcard."); -module_param_array(pcm_substreams, int, NULL, 0444); -MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-8) for loopback driver."); -module_param_array(pcm_notify, int, NULL, 0444); -MODULE_PARM_DESC(pcm_notify, "Break capture when PCM format/rate/channels changes."); - -#define NO_PITCH 100000 - -struct loopback_pcm; - -struct loopback_cable { - spinlock_t lock; - struct loopback_pcm *streams[2]; - struct snd_pcm_hardware hw; - /* flags */ - unsigned int valid; - unsigned int running; -}; - -struct loopback_setup { - unsigned int notify: 1; - unsigned int rate_shift; - unsigned int format; - unsigned int rate; - unsigned int channels; - struct snd_ctl_elem_id active_id; - struct snd_ctl_elem_id format_id; - struct snd_ctl_elem_id rate_id; - struct snd_ctl_elem_id channels_id; -}; - -struct loopback { - struct snd_card *card; - struct mutex cable_lock; - struct loopback_cable *cables[MAX_PCM_SUBSTREAMS][2]; - struct snd_pcm *pcm[2]; - struct loopback_setup setup[MAX_PCM_SUBSTREAMS][2]; -}; - -struct loopback_pcm { - struct loopback *loopback; - struct snd_pcm_substream *substream; - struct loopback_cable *cable; - unsigned int pcm_buffer_size; - unsigned int buf_pos; /* position in buffer */ - unsigned int silent_size; - /* PCM parameters */ - unsigned int pcm_period_size; - unsigned int pcm_bps; /* bytes per second */ - unsigned int pcm_salign; /* bytes per sample * channels */ - unsigned int pcm_rate_shift; /* rate shift value */ - /* flags */ - unsigned int period_update_pending :1; - /* timer stuff */ - unsigned int irq_pos; /* fractional IRQ position */ - unsigned int period_size_frac; - unsigned long last_jiffies; - struct timer_list timer; -}; - -static struct platform_device *devices[SNDRV_CARDS]; - -static inline unsigned int byte_pos(struct loopback_pcm *dpcm, unsigned int x) -{ - if (dpcm->pcm_rate_shift == NO_PITCH) { - x /= HZ; - } else { - x = div_u64(NO_PITCH * (unsigned long long)x, - HZ * (unsigned long long)dpcm->pcm_rate_shift); - } - return x - (x % dpcm->pcm_salign); -} - -static inline unsigned int frac_pos(struct loopback_pcm *dpcm, unsigned int x) -{ - if (dpcm->pcm_rate_shift == NO_PITCH) { /* no pitch */ - return x * HZ; - } else { - x = div_u64(dpcm->pcm_rate_shift * (unsigned long long)x * HZ, - NO_PITCH); - } - return x; -} - -static inline struct loopback_setup *get_setup(struct loopback_pcm *dpcm) -{ - int device = dpcm->substream->pstr->pcm->device; - - if (dpcm->substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - device ^= 1; - return &dpcm->loopback->setup[dpcm->substream->number][device]; -} - -static inline unsigned int get_notify(struct loopback_pcm *dpcm) -{ - return get_setup(dpcm)->notify; -} - -static inline unsigned int get_rate_shift(struct loopback_pcm *dpcm) -{ - return get_setup(dpcm)->rate_shift; -} - -static void loopback_timer_start(struct loopback_pcm *dpcm) -{ - unsigned long tick; - unsigned int rate_shift = get_rate_shift(dpcm); - - if (rate_shift != dpcm->pcm_rate_shift) { - dpcm->pcm_rate_shift = rate_shift; - dpcm->period_size_frac = frac_pos(dpcm, dpcm->pcm_period_size); - } - tick = dpcm->period_size_frac - dpcm->irq_pos; - tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps; - dpcm->timer.expires = jiffies + tick; - add_timer(&dpcm->timer); -} - -static inline void loopback_timer_stop(struct loopback_pcm *dpcm) -{ - del_timer(&dpcm->timer); -} - -#define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK) -#define CABLE_VALID_CAPTURE (1 << SNDRV_PCM_STREAM_CAPTURE) -#define CABLE_VALID_BOTH (CABLE_VALID_PLAYBACK|CABLE_VALID_CAPTURE) - -static int loopback_check_format(struct loopback_cable *cable, int stream) -{ - struct snd_pcm_runtime *runtime; - struct loopback_setup *setup; - struct snd_card *card; - int check; - - if (cable->valid != CABLE_VALID_BOTH) { - if (stream == SNDRV_PCM_STREAM_PLAYBACK) - goto __notify; - return 0; - } - runtime = cable->streams[SNDRV_PCM_STREAM_PLAYBACK]-> - substream->runtime; - check = cable->hw.formats != (1ULL << runtime->format) || - cable->hw.rate_min != runtime->rate || - cable->hw.rate_max != runtime->rate || - cable->hw.channels_min != runtime->channels || - cable->hw.channels_max != runtime->channels; - if (!check) - return 0; - if (stream == SNDRV_PCM_STREAM_CAPTURE) { - return -EIO; - } else { - snd_pcm_stop(cable->streams[SNDRV_PCM_STREAM_CAPTURE]-> - substream, SNDRV_PCM_STATE_DRAINING); - __notify: - runtime = cable->streams[SNDRV_PCM_STREAM_PLAYBACK]-> - substream->runtime; - setup = get_setup(cable->streams[SNDRV_PCM_STREAM_PLAYBACK]); - card = cable->streams[SNDRV_PCM_STREAM_PLAYBACK]->loopback->card; - if (setup->format != runtime->format) { - snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, - &setup->format_id); - setup->format = runtime->format; - } - if (setup->rate != runtime->rate) { - snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, - &setup->rate_id); - setup->rate = runtime->rate; - } - if (setup->channels != runtime->channels) { - snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, - &setup->channels_id); - setup->channels = runtime->channels; - } - } - return 0; -} - -static void loopback_active_notify(struct loopback_pcm *dpcm) -{ - snd_ctl_notify(dpcm->loopback->card, - SNDRV_CTL_EVENT_MASK_VALUE, - &get_setup(dpcm)->active_id); -} - -static int loopback_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct loopback_pcm *dpcm = runtime->private_data; - struct loopback_cable *cable = dpcm->cable; - int err; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - err = loopback_check_format(cable, substream->stream); - if (err < 0) - return err; - dpcm->last_jiffies = jiffies; - dpcm->pcm_rate_shift = 0; - loopback_timer_start(dpcm); - cable->running |= (1 << substream->stream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - loopback_active_notify(dpcm); - break; - case SNDRV_PCM_TRIGGER_STOP: - cable->running &= ~(1 << substream->stream); - loopback_timer_stop(dpcm); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - loopback_active_notify(dpcm); - break; - default: - return -EINVAL; - } - return 0; -} - -static int loopback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct loopback_pcm *dpcm = runtime->private_data; - struct loopback_cable *cable = dpcm->cable; - unsigned int bps, salign; - - salign = (snd_pcm_format_width(runtime->format) * - runtime->channels) / 8; - bps = salign * runtime->rate; - if (bps <= 0 || salign <= 0) - return -EINVAL; - - dpcm->buf_pos = 0; - dpcm->pcm_buffer_size = frames_to_bytes(runtime, runtime->buffer_size); - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - /* clear capture buffer */ - dpcm->silent_size = dpcm->pcm_buffer_size; - snd_pcm_format_set_silence(runtime->format, runtime->dma_area, - runtime->buffer_size * runtime->channels); - } - - dpcm->irq_pos = 0; - dpcm->period_update_pending = 0; - dpcm->pcm_bps = bps; - dpcm->pcm_salign = salign; - dpcm->pcm_period_size = frames_to_bytes(runtime, runtime->period_size); - - mutex_lock(&dpcm->loopback->cable_lock); - if (!(cable->valid & ~(1 << substream->stream))) { - cable->hw.formats = (1ULL << runtime->format); - cable->hw.rate_min = runtime->rate; - cable->hw.rate_max = runtime->rate; - cable->hw.channels_min = runtime->channels; - cable->hw.channels_max = runtime->channels; - } - cable->valid |= 1 << substream->stream; - mutex_unlock(&dpcm->loopback->cable_lock); - - return 0; -} - -static void clear_capture_buf(struct loopback_pcm *dpcm, unsigned int bytes) -{ - struct snd_pcm_runtime *runtime = dpcm->substream->runtime; - char *dst = runtime->dma_area; - unsigned int dst_off = dpcm->buf_pos; - - if (dpcm->silent_size >= dpcm->pcm_buffer_size) - return; - if (dpcm->silent_size + bytes > dpcm->pcm_buffer_size) - bytes = dpcm->pcm_buffer_size - dpcm->silent_size; - - for (;;) { - unsigned int size = bytes; - if (dst_off + size > dpcm->pcm_buffer_size) - size = dpcm->pcm_buffer_size - dst_off; - snd_pcm_format_set_silence(runtime->format, dst + dst_off, - bytes_to_frames(runtime, size) * - runtime->channels); - dpcm->silent_size += size; - bytes -= size; - if (!bytes) - break; - dst_off = 0; - } -} - -static void copy_play_buf(struct loopback_pcm *play, - struct loopback_pcm *capt, - unsigned int bytes) -{ - struct snd_pcm_runtime *runtime = play->substream->runtime; - char *src = play->substream->runtime->dma_area; - char *dst = capt->substream->runtime->dma_area; - unsigned int src_off = play->buf_pos; - unsigned int dst_off = capt->buf_pos; - unsigned int clear_bytes = 0; - - /* check if playback is draining, trim the capture copy size - * when our pointer is at the end of playback ring buffer */ - if (runtime->status->state == SNDRV_PCM_STATE_DRAINING && - snd_pcm_playback_hw_avail(runtime) < runtime->buffer_size) { - snd_pcm_uframes_t appl_ptr, appl_ptr1, diff; - appl_ptr = appl_ptr1 = runtime->control->appl_ptr; - appl_ptr1 -= appl_ptr1 % runtime->buffer_size; - appl_ptr1 += play->buf_pos / play->pcm_salign; - if (appl_ptr < appl_ptr1) - appl_ptr1 -= runtime->buffer_size; - diff = (appl_ptr - appl_ptr1) * play->pcm_salign; - if (diff < bytes) { - clear_bytes = bytes - diff; - bytes = diff; - } - } - - for (;;) { - unsigned int size = bytes; - if (src_off + size > play->pcm_buffer_size) - size = play->pcm_buffer_size - src_off; - if (dst_off + size > capt->pcm_buffer_size) - size = capt->pcm_buffer_size - dst_off; - memcpy(dst + dst_off, src + src_off, size); - capt->silent_size = 0; - bytes -= size; - if (!bytes) - break; - src_off = (src_off + size) % play->pcm_buffer_size; - dst_off = (dst_off + size) % capt->pcm_buffer_size; - } - - if (clear_bytes > 0) - clear_capture_buf(capt, clear_bytes); -} - -#define BYTEPOS_UPDATE_POSONLY 0 -#define BYTEPOS_UPDATE_CLEAR 1 -#define BYTEPOS_UPDATE_COPY 2 - -static void loopback_bytepos_update(struct loopback_pcm *dpcm, - unsigned int delta, - unsigned int cmd) -{ - unsigned int count; - unsigned long last_pos; - - last_pos = byte_pos(dpcm, dpcm->irq_pos); - dpcm->irq_pos += delta * dpcm->pcm_bps; - count = byte_pos(dpcm, dpcm->irq_pos) - last_pos; - if (!count) - return; - if (cmd == BYTEPOS_UPDATE_CLEAR) - clear_capture_buf(dpcm, count); - else if (cmd == BYTEPOS_UPDATE_COPY) - copy_play_buf(dpcm->cable->streams[SNDRV_PCM_STREAM_PLAYBACK], - dpcm->cable->streams[SNDRV_PCM_STREAM_CAPTURE], - count); - dpcm->buf_pos += count; - dpcm->buf_pos %= dpcm->pcm_buffer_size; - if (dpcm->irq_pos >= dpcm->period_size_frac) { - dpcm->irq_pos %= dpcm->period_size_frac; - dpcm->period_update_pending = 1; - } -} - -static void loopback_pos_update(struct loopback_cable *cable) -{ - struct loopback_pcm *dpcm_play = - cable->streams[SNDRV_PCM_STREAM_PLAYBACK]; - struct loopback_pcm *dpcm_capt = - cable->streams[SNDRV_PCM_STREAM_CAPTURE]; - unsigned long delta_play = 0, delta_capt = 0; - - spin_lock(&cable->lock); - if (cable->running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { - delta_play = jiffies - dpcm_play->last_jiffies; - dpcm_play->last_jiffies += delta_play; - } - - if (cable->running & (1 << SNDRV_PCM_STREAM_CAPTURE)) { - delta_capt = jiffies - dpcm_capt->last_jiffies; - dpcm_capt->last_jiffies += delta_capt; - } - - if (delta_play == 0 && delta_capt == 0) { - spin_unlock(&cable->lock); - return; - } - - if (delta_play > delta_capt) { - loopback_bytepos_update(dpcm_play, delta_play - delta_capt, - BYTEPOS_UPDATE_POSONLY); - delta_play = delta_capt; - } else if (delta_play < delta_capt) { - loopback_bytepos_update(dpcm_capt, delta_capt - delta_play, - BYTEPOS_UPDATE_CLEAR); - delta_capt = delta_play; - } - - if (delta_play == 0 && delta_capt == 0) { - spin_unlock(&cable->lock); - return; - } - /* note delta_capt == delta_play at this moment */ - loopback_bytepos_update(dpcm_capt, delta_capt, BYTEPOS_UPDATE_COPY); - loopback_bytepos_update(dpcm_play, delta_play, BYTEPOS_UPDATE_POSONLY); - spin_unlock(&cable->lock); -} - -static void loopback_timer_function(unsigned long data) -{ - struct loopback_pcm *dpcm = (struct loopback_pcm *)data; - int stream; - - loopback_pos_update(dpcm->cable); - stream = dpcm->substream->stream; - if (dpcm->cable->running & (1 << stream)) - loopback_timer_start(dpcm); - if (dpcm->period_update_pending) { - dpcm->period_update_pending = 0; - if (dpcm->cable->running & (1 << stream)) - snd_pcm_period_elapsed(dpcm->substream); - } -} - -static snd_pcm_uframes_t loopback_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct loopback_pcm *dpcm = runtime->private_data; - - loopback_pos_update(dpcm->cable); - return bytes_to_frames(runtime, dpcm->buf_pos); -} - -static struct snd_pcm_hardware loopback_pcm_hardware = -{ - .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID), - .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | - SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE | - SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE), - .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_192000, - .rate_min = 8000, - .rate_max = 192000, - .channels_min = 1, - .channels_max = 32, - .buffer_bytes_max = 2 * 1024 * 1024, - .period_bytes_min = 64, - .period_bytes_max = 2 * 1024 * 1024, - .periods_min = 1, - .periods_max = 1024, - .fifo_size = 0, -}; - -static void loopback_runtime_free(struct snd_pcm_runtime *runtime) -{ - struct loopback_pcm *dpcm = runtime->private_data; - kfree(dpcm); -} - -static int loopback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); -} - -static int loopback_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct loopback_pcm *dpcm = runtime->private_data; - struct loopback_cable *cable = dpcm->cable; - - mutex_lock(&dpcm->loopback->cable_lock); - cable->valid &= ~(1 << substream->stream); - mutex_unlock(&dpcm->loopback->cable_lock); - return snd_pcm_lib_free_pages(substream); -} - -static unsigned int get_cable_index(struct snd_pcm_substream *substream) -{ - if (!substream->pcm->device) - return substream->stream; - else - return !substream->stream; -} - -static int loopback_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct loopback *loopback = substream->private_data; - struct loopback_pcm *dpcm; - struct loopback_cable *cable; - int err = 0; - int dev = get_cable_index(substream); - - mutex_lock(&loopback->cable_lock); - dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); - if (!dpcm) { - err = -ENOMEM; - goto unlock; - } - dpcm->loopback = loopback; - dpcm->substream = substream; - setup_timer(&dpcm->timer, loopback_timer_function, - (unsigned long)dpcm); - - cable = loopback->cables[substream->number][dev]; - if (!cable) { - cable = kzalloc(sizeof(*cable), GFP_KERNEL); - if (!cable) { - kfree(dpcm); - err = -ENOMEM; - goto unlock; - } - spin_lock_init(&cable->lock); - cable->hw = loopback_pcm_hardware; - loopback->cables[substream->number][dev] = cable; - } - dpcm->cable = cable; - cable->streams[substream->stream] = dpcm; - - snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); - - runtime->private_data = dpcm; - runtime->private_free = loopback_runtime_free; - if (get_notify(dpcm) && - substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw = loopback_pcm_hardware; - } else { - runtime->hw = cable->hw; - } - unlock: - mutex_unlock(&loopback->cable_lock); - return err; -} - -static int loopback_close(struct snd_pcm_substream *substream) -{ - struct loopback *loopback = substream->private_data; - struct loopback_pcm *dpcm = substream->runtime->private_data; - struct loopback_cable *cable; - int dev = get_cable_index(substream); - - loopback_timer_stop(dpcm); - mutex_lock(&loopback->cable_lock); - cable = loopback->cables[substream->number][dev]; - if (cable->streams[!substream->stream]) { - /* other stream is still alive */ - cable->streams[substream->stream] = NULL; - } else { - /* free the cable */ - loopback->cables[substream->number][dev] = NULL; - kfree(cable); - } - mutex_unlock(&loopback->cable_lock); - return 0; -} - -static struct snd_pcm_ops loopback_playback_ops = { - .open = loopback_open, - .close = loopback_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = loopback_hw_params, - .hw_free = loopback_hw_free, - .prepare = loopback_prepare, - .trigger = loopback_trigger, - .pointer = loopback_pointer, -}; - -static struct snd_pcm_ops loopback_capture_ops = { - .open = loopback_open, - .close = loopback_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = loopback_hw_params, - .hw_free = loopback_hw_free, - .prepare = loopback_prepare, - .trigger = loopback_trigger, - .pointer = loopback_pointer, -}; - -static int __devinit loopback_pcm_new(struct loopback *loopback, - int device, int substreams) -{ - struct snd_pcm *pcm; - int err; - - err = snd_pcm_new(loopback->card, "Loopback PCM", device, - substreams, substreams, &pcm); - if (err < 0) - return err; - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &loopback_playback_ops); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &loopback_capture_ops); - - pcm->private_data = loopback; - pcm->info_flags = 0; - strcpy(pcm->name, "Loopback PCM"); - - loopback->pcm[device] = pcm; - - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - snd_dma_continuous_data(GFP_KERNEL), - 0, 2 * 1024 * 1024); - return 0; -} - -static int loopback_rate_shift_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 80000; - uinfo->value.integer.max = 120000; - uinfo->value.integer.step = 1; - return 0; -} - -static int loopback_rate_shift_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - - ucontrol->value.integer.value[0] = - loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].rate_shift; - return 0; -} - -static int loopback_rate_shift_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - unsigned int val; - int change = 0; - - val = ucontrol->value.integer.value[0]; - if (val < 80000) - val = 80000; - if (val > 120000) - val = 120000; - mutex_lock(&loopback->cable_lock); - if (val != loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].rate_shift) { - loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].rate_shift = val; - change = 1; - } - mutex_unlock(&loopback->cable_lock); - return change; -} - -static int loopback_notify_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - - ucontrol->value.integer.value[0] = - loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].notify; - return 0; -} - -static int loopback_notify_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - unsigned int val; - int change = 0; - - val = ucontrol->value.integer.value[0] ? 1 : 0; - if (val != loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].notify) { - loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].notify = val; - change = 1; - } - return change; -} - -static int loopback_active_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - struct loopback_cable *cable = loopback->cables - [kcontrol->id.subdevice][kcontrol->id.device]; - unsigned int val = 0; - - if (cable != NULL) - val = (cable->running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) ? - 1 : 0; - ucontrol->value.integer.value[0] = val; - return 0; -} - -static int loopback_format_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = SNDRV_PCM_FORMAT_LAST; - uinfo->value.integer.step = 1; - return 0; -} - -static int loopback_format_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - - ucontrol->value.integer.value[0] = - loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].format; - return 0; -} - -static int loopback_rate_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 192000; - uinfo->value.integer.step = 1; - return 0; -} - -static int loopback_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - - ucontrol->value.integer.value[0] = - loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].rate; - return 0; -} - -static int loopback_channels_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 1; - uinfo->value.integer.max = 1024; - uinfo->value.integer.step = 1; - return 0; -} - -static int loopback_channels_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct loopback *loopback = snd_kcontrol_chip(kcontrol); - - ucontrol->value.integer.value[0] = - loopback->setup[kcontrol->id.subdevice] - [kcontrol->id.device].rate; - return 0; -} - -static struct snd_kcontrol_new loopback_controls[] __devinitdata = { -{ - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "PCM Rate Shift 100000", - .info = loopback_rate_shift_info, - .get = loopback_rate_shift_get, - .put = loopback_rate_shift_put, -}, -{ - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "PCM Notify", - .info = snd_ctl_boolean_mono_info, - .get = loopback_notify_get, - .put = loopback_notify_put, -}, -#define ACTIVE_IDX 2 -{ - .access = SNDRV_CTL_ELEM_ACCESS_READ, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "PCM Slave Active", - .info = snd_ctl_boolean_mono_info, - .get = loopback_active_get, -}, -#define FORMAT_IDX 3 -{ - .access = SNDRV_CTL_ELEM_ACCESS_READ, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "PCM Slave Format", - .info = loopback_format_info, - .get = loopback_format_get -}, -#define RATE_IDX 4 -{ - .access = SNDRV_CTL_ELEM_ACCESS_READ, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "PCM Slave Rate", - .info = loopback_rate_info, - .get = loopback_rate_get -}, -#define CHANNELS_IDX 5 -{ - .access = SNDRV_CTL_ELEM_ACCESS_READ, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "PCM Slave Channels", - .info = loopback_channels_info, - .get = loopback_channels_get -} -}; - -static int __devinit loopback_mixer_new(struct loopback *loopback, int notify) -{ - struct snd_card *card = loopback->card; - struct snd_pcm *pcm; - struct snd_kcontrol *kctl; - struct loopback_setup *setup; - int err, dev, substr, substr_count, idx; - - strcpy(card->mixername, "Loopback Mixer"); - for (dev = 0; dev < 2; dev++) { - pcm = loopback->pcm[dev]; - substr_count = - pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count; - for (substr = 0; substr < substr_count; substr++) { - setup = &loopback->setup[substr][dev]; - setup->notify = notify; - setup->rate_shift = NO_PITCH; - setup->format = SNDRV_PCM_FORMAT_S16_LE; - setup->rate = 48000; - setup->channels = 2; - for (idx = 0; idx < ARRAY_SIZE(loopback_controls); - idx++) { - kctl = snd_ctl_new1(&loopback_controls[idx], - loopback); - if (!kctl) - return -ENOMEM; - kctl->id.device = dev; - kctl->id.subdevice = substr; - switch (idx) { - case ACTIVE_IDX: - setup->active_id = kctl->id; - break; - case FORMAT_IDX: - setup->format_id = kctl->id; - break; - case RATE_IDX: - setup->rate_id = kctl->id; - break; - case CHANNELS_IDX: - setup->channels_id = kctl->id; - break; - default: - break; - } - err = snd_ctl_add(card, kctl); - if (err < 0) - return err; - } - } - } - return 0; -} - -static int __devinit loopback_probe(struct platform_device *devptr) -{ - struct snd_card *card; - struct loopback *loopback; - int dev = devptr->id; - int err; - - err = snd_card_create(index[dev], id[dev], THIS_MODULE, - sizeof(struct loopback), &card); - if (err < 0) - return err; - loopback = card->private_data; - - if (pcm_substreams[dev] < 1) - pcm_substreams[dev] = 1; - if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS) - pcm_substreams[dev] = MAX_PCM_SUBSTREAMS; - - loopback->card = card; - mutex_init(&loopback->cable_lock); - - err = loopback_pcm_new(loopback, 0, pcm_substreams[dev]); - if (err < 0) - goto __nodev; - err = loopback_pcm_new(loopback, 1, pcm_substreams[dev]); - if (err < 0) - goto __nodev; - err = loopback_mixer_new(loopback, pcm_notify[dev] ? 1 : 0); - if (err < 0) - goto __nodev; - strcpy(card->driver, "Loopback"); - strcpy(card->shortname, "Loopback"); - sprintf(card->longname, "Loopback %i", dev + 1); - err = snd_card_register(card); - if (!err) { - platform_set_drvdata(devptr, card); - return 0; - } - __nodev: - snd_card_free(card); - return err; -} - -static int __devexit loopback_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); - return 0; -} - -#ifdef CONFIG_PM -static int loopback_suspend(struct platform_device *pdev, - pm_message_t state) -{ - struct snd_card *card = platform_get_drvdata(pdev); - struct loopback *loopback = card->private_data; - - snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); - - snd_pcm_suspend_all(loopback->pcm[0]); - snd_pcm_suspend_all(loopback->pcm[1]); - return 0; -} - -static int loopback_resume(struct platform_device *pdev) -{ - struct snd_card *card = platform_get_drvdata(pdev); - - snd_power_change_state(card, SNDRV_CTL_POWER_D0); - return 0; -} -#endif - -#define SND_LOOPBACK_DRIVER "snd_aloop" - -static struct platform_driver loopback_driver = { - .probe = loopback_probe, - .remove = __devexit_p(loopback_remove), -#ifdef CONFIG_PM - .suspend = loopback_suspend, - .resume = loopback_resume, -#endif - .driver = { - .name = SND_LOOPBACK_DRIVER - }, -}; - -static void loopback_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&loopback_driver); -} - -static int __init alsa_card_loopback_init(void) -{ - int i, err, cards; - - err = platform_driver_register(&loopback_driver); - if (err < 0) - return err; - - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (!enable[i]) - continue; - device = platform_device_register_simple(SND_LOOPBACK_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "aloop: No loopback enabled\n"); -#endif - loopback_unregister_all(); - return -ENODEV; - } - return 0; -} - -static void __exit alsa_card_loopback_exit(void) -{ - loopback_unregister_all(); -} - -module_init(alsa_card_loopback_init) -module_exit(alsa_card_loopback_exit) diff --git a/drivers/aloop.c b/drivers/aloop.c index 5f6dcff8f..6e6962ead 100644 --- a/drivers/aloop.c +++ b/drivers/aloop.c @@ -1,3 +1,3 @@ #include "adriver.h" -#include "aloop-kernel.c" +#include "../alsa-kernel/drivers/aloop.c" EXPORT_NO_SYMBOLS; diff --git a/include/sound/pcm.patch b/include/sound/pcm.patch index 87918a730..10bec019c 100644 --- a/include/sound/pcm.patch +++ b/include/sound/pcm.patch @@ -1,6 +1,6 @@ ---- ../../alsa-kernel/include/pcm.h 2010-06-28 09:42:39.000000000 +0200 -+++ pcm.h 2010-06-28 10:00:49.000000000 +0200 -@@ -277,9 +277,12 @@ struct snd_pcm_runtime { +--- ../../alsa-kernel/include/pcm.h 2010-08-09 14:25:40.000000000 +0200 ++++ pcm.h 2010-08-09 14:29:54.000000000 +0200 +@@ -277,9 +277,12 @@ snd_pcm_uframes_t avail_max; snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */ snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time */ @@ -14,7 +14,7 @@ /* -- HW params -- */ snd_pcm_access_t access; /* access mode */ snd_pcm_format_t format; /* SNDRV_PCM_FORMAT_* */ -@@ -289,6 +292,9 @@ struct snd_pcm_runtime { +@@ -289,6 +292,9 @@ snd_pcm_uframes_t period_size; /* period size */ unsigned int periods; /* periods */ snd_pcm_uframes_t buffer_size; /* buffer size */ @@ -24,7 +24,7 @@ snd_pcm_uframes_t min_align; /* Min alignment for the format */ size_t byte_align; unsigned int frame_bits; -@@ -300,6 +306,10 @@ struct snd_pcm_runtime { +@@ -300,6 +306,10 @@ /* -- SW params -- */ int tstamp_mode; /* mmap timestamp is updated */ unsigned int period_step; @@ -35,7 +35,7 @@ snd_pcm_uframes_t start_threshold; snd_pcm_uframes_t stop_threshold; snd_pcm_uframes_t silence_threshold; /* Silence filling happens when -@@ -317,9 +327,18 @@ struct snd_pcm_runtime { +@@ -317,9 +327,18 @@ struct snd_pcm_mmap_control *control; /* -- locking / scheduling -- */ @@ -54,7 +54,7 @@ struct fasync_struct *fasync; /* -- private section -- */ -@@ -336,8 +355,9 @@ struct snd_pcm_runtime { +@@ -336,8 +355,9 @@ /* -- timer -- */ unsigned int timer_resolution; /* timer resolution */ @@ -65,7 +65,7 @@ /* -- DMA -- */ unsigned char *dma_area; /* DMA area */ dma_addr_t dma_addr; /* physical bus address (not accessible from main CPU) */ -@@ -353,6 +373,24 @@ struct snd_pcm_runtime { +@@ -353,6 +373,24 @@ #ifdef CONFIG_SND_PCM_XRUN_DEBUG struct snd_pcm_hwptr_log *hwptr_log; #endif @@ -90,19 +90,19 @@ }; struct snd_pcm_group { /* keep linked substreams */ -@@ -370,7 +408,11 @@ struct snd_pcm_substream { +@@ -370,7 +408,11 @@ int number; char name[32]; /* substream name */ int stream; /* stream (direction) */ +#ifdef CONFIG_SND_HAVE_PM_QOS_REQUEST - struct pm_qos_request_list *latency_pm_qos_req; /* pm_qos request */ + struct pm_qos_request_list latency_pm_qos_req; /* pm_qos request */ +#else + char latency_id[20]; +#endif size_t buffer_bytes_max; /* limit ring buffer size */ struct snd_dma_buffer dma_buffer; unsigned int dma_buf_id; -@@ -382,6 +424,9 @@ struct snd_pcm_substream { +@@ -382,6 +424,9 @@ /* -- timer section -- */ struct snd_timer *timer; /* timer */ unsigned timer_running: 1; /* time is running */ |