- Timestamp:
- May 16, 2020, 10:05:07 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-linux-3.2.102/alsa-kernel/drivers/dummy.c
r598 r612 28 28 #include <linux/hrtimer.h> 29 29 #include <linux/math64.h> 30 #include <linux/module param.h>30 #include <linux/module.h> 31 31 #include <sound/core.h> 32 32 #include <sound/control.h> … … 110 110 }; 111 111 112 #define get_dummy_ops(substream) \ 113 (*(const struct dummy_timer_ops **)(substream)->runtime->private_data) 114 112 115 struct dummy_model { 113 116 const char *name; … … 135 138 int mixer_volume[MIXER_ADDR_LAST+1][2]; 136 139 int capture_source[MIXER_ADDR_LAST+1][2]; 137 const struct dummy_timer_ops *timer_ops;138 140 }; 139 141 … … 229 231 230 232 struct dummy_systimer_pcm { 233 /* ops must be the first item */ 234 const struct dummy_timer_ops *timer_ops; 231 235 spinlock_t lock; 232 236 struct timer_list timer; … … 366 370 367 371 struct dummy_hrtimer_pcm { 372 /* ops must be the first item */ 373 const struct dummy_timer_ops *timer_ops; 368 374 ktime_t base_time; 369 375 ktime_t period_time; … … 414 420 static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm) 415 421 { 422 hrtimer_cancel(&dpcm->timer); 416 423 tasklet_kill(&dpcm->tasklet); 417 424 } … … 492 499 static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 493 500 { 494 struct snd_dummy *dummy = snd_pcm_substream_chip(substream);495 496 501 switch (cmd) { 497 502 case SNDRV_PCM_TRIGGER_START: 498 503 case SNDRV_PCM_TRIGGER_RESUME: 499 return dummy->timer_ops->start(substream);504 return get_dummy_ops(substream)->start(substream); 500 505 case SNDRV_PCM_TRIGGER_STOP: 501 506 case SNDRV_PCM_TRIGGER_SUSPEND: 502 return dummy->timer_ops->stop(substream);507 return get_dummy_ops(substream)->stop(substream); 503 508 } 504 509 return -EINVAL; … … 507 512 static int dummy_pcm_prepare(struct snd_pcm_substream *substream) 508 513 { 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); 512 515 } 513 516 514 517 static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream) 515 518 { 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); 519 520 } 520 521 … … 562 563 struct dummy_model *model = dummy->model; 563 564 struct snd_pcm_runtime *runtime = substream->runtime; 565 const struct dummy_timer_ops *ops; 564 566 int err; 565 567 566 dummy->timer_ops = &dummy_systimer_ops;568 ops = &dummy_systimer_ops; 567 569 #ifdef CONFIG_HIGH_RES_TIMERS 568 570 if (hrtimer) 569 dummy->timer_ops = &dummy_hrtimer_ops;571 ops = &dummy_hrtimer_ops; 570 572 #endif 571 573 572 err = dummy->timer_ops->create(substream);574 err = ops->create(substream); 573 575 if (err < 0) 574 576 return err; 577 get_dummy_ops(substream) = ops; 575 578 576 579 runtime->hw = dummy->pcm_hw; … … 594 597 } 595 598 if (err < 0) { 596 dummy->timer_ops->free(substream);599 get_dummy_ops(substream)->free(substream); 597 600 return err; 598 601 } … … 602 605 static int dummy_pcm_close(struct snd_pcm_substream *substream) 603 606 { 604 struct snd_dummy *dummy = snd_pcm_substream_chip(substream); 605 dummy->timer_ops->free(substream); 607 get_dummy_ops(substream)->free(substream); 606 608 return 0; 607 609 }
Note:
See TracChangeset
for help on using the changeset viewer.