aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>2015-02-13 16:14:07 -0500
committerTakashi Iwai <tiwai@suse.de>2015-02-20 11:30:06 -0500
commit9e94df3a624b1b485f2c2ac5ab94032da01e45b3 (patch)
treebe9e24bfccd220394e2150934e0d64adf4811c32 /sound/pci
parent3179f62001880e588e229db3006a59ad87b7792a (diff)
ALSA: hda: replace .wallclock by .get_time_info
No real functional change, only take wall clock and system time in same routine and add accuracy report. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_controller.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index dfcb5e929f9f..7806f1d297cb 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -732,17 +732,32 @@ static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
732 azx_get_position(chip, azx_dev)); 732 azx_get_position(chip, azx_dev));
733} 733}
734 734
735static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream, 735static int azx_get_time_info(struct snd_pcm_substream *substream,
736 struct timespec *ts) 736 struct timespec *system_ts, struct timespec *audio_ts,
737 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
738 struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
737{ 739{
738 struct azx_dev *azx_dev = get_azx_dev(substream); 740 struct azx_dev *azx_dev = get_azx_dev(substream);
739 u64 nsec; 741 u64 nsec;
740 742
741 nsec = timecounter_read(&azx_dev->azx_tc); 743 if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
742 nsec = div_u64(nsec, 3); /* can be optimized */ 744 (audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
743 nsec = azx_adjust_codec_delay(substream, nsec);
744 745
745 *ts = ns_to_timespec(nsec); 746 snd_pcm_gettime(substream->runtime, system_ts);
747
748 nsec = timecounter_read(&azx_dev->azx_tc);
749 nsec = div_u64(nsec, 3); /* can be optimized */
750 if (audio_tstamp_config->report_delay)
751 nsec = azx_adjust_codec_delay(substream, nsec);
752
753 *audio_ts = ns_to_timespec(nsec);
754
755 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
756 audio_tstamp_report->accuracy_report = 1; /* rest of structure is valid */
757 audio_tstamp_report->accuracy = 42; /* 24 MHz WallClock == 42ns resolution */
758
759 } else
760 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
746 761
747 return 0; 762 return 0;
748} 763}
@@ -756,7 +771,8 @@ static struct snd_pcm_hardware azx_pcm_hw = {
756 /* SNDRV_PCM_INFO_RESUME |*/ 771 /* SNDRV_PCM_INFO_RESUME |*/
757 SNDRV_PCM_INFO_PAUSE | 772 SNDRV_PCM_INFO_PAUSE |
758 SNDRV_PCM_INFO_SYNC_START | 773 SNDRV_PCM_INFO_SYNC_START |
759 SNDRV_PCM_INFO_HAS_WALL_CLOCK | 774 SNDRV_PCM_INFO_HAS_WALL_CLOCK | /* legacy */
775 SNDRV_PCM_INFO_HAS_LINK_ATIME |
760 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP), 776 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
761 .formats = SNDRV_PCM_FMTBIT_S16_LE, 777 .formats = SNDRV_PCM_FMTBIT_S16_LE,
762 .rates = SNDRV_PCM_RATE_48000, 778 .rates = SNDRV_PCM_RATE_48000,
@@ -842,10 +858,12 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
842 return -EINVAL; 858 return -EINVAL;
843 } 859 }
844 860
845 /* disable WALLCLOCK timestamps for capture streams 861 /* disable LINK_ATIME timestamps for capture streams
846 until we figure out how to handle digital inputs */ 862 until we figure out how to handle digital inputs */
847 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) 863 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
848 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; 864 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; /* legacy */
865 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME;
866 }
849 867
850 spin_lock_irqsave(&chip->reg_lock, flags); 868 spin_lock_irqsave(&chip->reg_lock, flags);
851 azx_dev->substream = substream; 869 azx_dev->substream = substream;
@@ -877,7 +895,7 @@ static struct snd_pcm_ops azx_pcm_ops = {
877 .prepare = azx_pcm_prepare, 895 .prepare = azx_pcm_prepare,
878 .trigger = azx_pcm_trigger, 896 .trigger = azx_pcm_trigger,
879 .pointer = azx_pcm_pointer, 897 .pointer = azx_pcm_pointer,
880 .wall_clock = azx_get_wallclock_tstamp, 898 .get_time_info = azx_get_time_info,
881 .mmap = azx_pcm_mmap, 899 .mmap = azx_pcm_mmap,
882 .page = snd_pcm_sgbuf_ops_page, 900 .page = snd_pcm_sgbuf_ops_page,
883}; 901};