Ignore:
Timestamp:
May 16, 2020, 10:05:07 AM (5 years ago)
Author:
Paul Smedley
Message:

Commit 3..102 changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-linux-3.2.102/alsa-kernel/drivers/dummy.c

    r598 r612  
    2828#include <linux/hrtimer.h>
    2929#include <linux/math64.h>
    30 #include <linux/moduleparam.h>
     30#include <linux/module.h>
    3131#include <sound/core.h>
    3232#include <sound/control.h>
     
    110110};
    111111
     112#define get_dummy_ops(substream) \
     113        (*(const struct dummy_timer_ops **)(substream)->runtime->private_data)
     114
    112115struct dummy_model {
    113116        const char *name;
     
    135138        int mixer_volume[MIXER_ADDR_LAST+1][2];
    136139        int capture_source[MIXER_ADDR_LAST+1][2];
    137         const struct dummy_timer_ops *timer_ops;
    138140};
    139141
     
    229231
    230232struct dummy_systimer_pcm {
     233        /* ops must be the first item */
     234        const struct dummy_timer_ops *timer_ops;
    231235        spinlock_t lock;
    232236        struct timer_list timer;
     
    366370
    367371struct dummy_hrtimer_pcm {
     372        /* ops must be the first item */
     373        const struct dummy_timer_ops *timer_ops;
    368374        ktime_t base_time;
    369375        ktime_t period_time;
     
    414420static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm)
    415421{
     422        hrtimer_cancel(&dpcm->timer);
    416423        tasklet_kill(&dpcm->tasklet);
    417424}
     
    492499static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
    493500{
    494         struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
    495 
    496501        switch (cmd) {
    497502        case SNDRV_PCM_TRIGGER_START:
    498503        case SNDRV_PCM_TRIGGER_RESUME:
    499                 return dummy->timer_ops->start(substream);
     504                return get_dummy_ops(substream)->start(substream);
    500505        case SNDRV_PCM_TRIGGER_STOP:
    501506        case SNDRV_PCM_TRIGGER_SUSPEND:
    502                 return dummy->timer_ops->stop(substream);
     507                return get_dummy_ops(substream)->stop(substream);
    503508        }
    504509        return -EINVAL;
     
    507512static int dummy_pcm_prepare(struct snd_pcm_substream *substream)
    508513{
    509         struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
    510 
    511         return dummy->timer_ops->prepare(substream);
     514        return get_dummy_ops(substream)->prepare(substream);
    512515}
    513516
    514517static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream)
    515518{
    516         struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
    517 
    518         return dummy->timer_ops->pointer(substream);
     519        return get_dummy_ops(substream)->pointer(substream);
    519520}
    520521
     
    562563        struct dummy_model *model = dummy->model;
    563564        struct snd_pcm_runtime *runtime = substream->runtime;
     565        const struct dummy_timer_ops *ops;
    564566        int err;
    565567
    566         dummy->timer_ops = &dummy_systimer_ops;
     568        ops = &dummy_systimer_ops;
    567569#ifdef CONFIG_HIGH_RES_TIMERS
    568570        if (hrtimer)
    569                 dummy->timer_ops = &dummy_hrtimer_ops;
     571                ops = &dummy_hrtimer_ops;
    570572#endif
    571573
    572         err = dummy->timer_ops->create(substream);
     574        err = ops->create(substream);
    573575        if (err < 0)
    574576                return err;
     577        get_dummy_ops(substream) = ops;
    575578
    576579        runtime->hw = dummy->pcm_hw;
     
    594597        }
    595598        if (err < 0) {
    596                 dummy->timer_ops->free(substream);
     599                get_dummy_ops(substream)->free(substream);
    597600                return err;
    598601        }
     
    602605static int dummy_pcm_close(struct snd_pcm_substream *substream)
    603606{
    604         struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
    605         dummy->timer_ops->free(substream);
     607        get_dummy_ops(substream)->free(substream);
    606608        return 0;
    607609}
Note: See TracChangeset for help on using the changeset viewer.