aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi
diff options
context:
space:
mode:
authorEliot Blennerhassett <eblennerhassett@audioscience.com>2011-04-05 04:55:42 -0400
committerTakashi Iwai <tiwai@suse.de>2011-04-05 05:46:48 -0400
commita6477134db119a22aa30911ff18e440b8db9df65 (patch)
tree72ca7da521291fe3b8ff5050945935fae3a6617f /sound/pci/asihpi
parent550ac6ba4ef0e57f6edbadf2b018d5125d2f7e98 (diff)
ALSA: asihpi: Update debug printing
Debug print full substream ID. Other minor debug print updates. Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r--sound/pci/asihpi/asihpi.c102
1 files changed, 56 insertions, 46 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index edcbe39d6033..434342f874ff 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -57,8 +57,25 @@ MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx");
57 */ 57 */
58#define snd_printddd(format, args...) \ 58#define snd_printddd(format, args...) \
59 __snd_printk(3, __FILE__, __LINE__, format, ##args) 59 __snd_printk(3, __FILE__, __LINE__, format, ##args)
60
61/* copied from pcm_lib.c, hope later patch will make that version public
62and this copy can be removed */
63static void pcm_debug_name(struct snd_pcm_substream *substream,
64 char *name, size_t len)
65{
66 snprintf(name, len, "pcmC%dD%d%c:%d",
67 substream->pcm->card->number,
68 substream->pcm->device,
69 substream->stream ? 'c' : 'p',
70 substream->number);
71}
72#define DEBUG_NAME(substream, name) char name[16]; pcm_debug_name(substream, name, sizeof(name))
73
60#else 74#else
61#define snd_printddd(format, args...) do { } while (0) 75#define snd_printddd(format, args...) do { } while (0)
76#define pcm_debug_name(s, n, l) do { } while (0)
77#define DEBUG_NAME(name, substream) do { } while (0)
78
62#endif 79#endif
63 80
64static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ 81static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
@@ -101,13 +118,6 @@ static int adapter_fs = DEFAULT_SAMPLERATE;
101#define PERIOD_BYTES_MIN 2048 118#define PERIOD_BYTES_MIN 2048
102#define BUFFER_BYTES_MAX (512 * 1024) 119#define BUFFER_BYTES_MAX (512 * 1024)
103 120
104/* convert stream to character */
105#define SCHR(s) ((s == SNDRV_PCM_STREAM_PLAYBACK) ? 'P' : 'C')
106
107/*#define TIMER_MILLISECONDS 20
108#define FORCE_TIMER_JIFFIES ((TIMER_MILLISECONDS * HZ + 999)/1000)
109*/
110
111#define MAX_CLOCKSOURCES (HPI_SAMPLECLOCK_SOURCE_LAST + 1 + 7) 121#define MAX_CLOCKSOURCES (HPI_SAMPLECLOCK_SOURCE_LAST + 1 + 7)
112 122
113struct clk_source { 123struct clk_source {
@@ -288,19 +298,26 @@ static u16 handle_error(u16 err, int line, char *filename)
288#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__) 298#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__)
289 299
290/***************************** GENERAL PCM ****************/ 300/***************************** GENERAL PCM ****************/
291static void print_hwparams(struct snd_pcm_hw_params *p) 301
302static void print_hwparams(struct snd_pcm_substream *substream,
303 struct snd_pcm_hw_params *p)
292{ 304{
293 snd_printd("HWPARAMS \n"); 305 DEBUG_NAME(substream, name);
294 snd_printd("samplerate %d \n", params_rate(p)); 306 snd_printd("%s HWPARAMS\n", name);
295 snd_printd("Channels %d \n", params_channels(p)); 307 snd_printd(" samplerate %d Hz\n", params_rate(p));
296 snd_printd("Format %d \n", params_format(p)); 308 snd_printd(" channels %d\n", params_channels(p));
297 snd_printd("subformat %d \n", params_subformat(p)); 309 snd_printd(" format %d\n", params_format(p));
298 snd_printd("Buffer bytes %d \n", params_buffer_bytes(p)); 310 snd_printd(" subformat %d\n", params_subformat(p));
299 snd_printd("Period bytes %d \n", params_period_bytes(p)); 311 snd_printd(" buffer %d B\n", params_buffer_bytes(p));
300 snd_printd("access %d \n", params_access(p)); 312 snd_printd(" period %d B\n", params_period_bytes(p));
301 snd_printd("period_size %d \n", params_period_size(p)); 313 snd_printd(" access %d\n", params_access(p));
302 snd_printd("periods %d \n", params_periods(p)); 314 snd_printd(" period_size %d\n", params_period_size(p));
303 snd_printd("buffer_size %d \n", params_buffer_size(p)); 315 snd_printd(" periods %d\n", params_periods(p));
316 snd_printd(" buffer_size %d\n", params_buffer_size(p));
317 snd_printd(" %d B/s\n", params_rate(p) *
318 params_channels(p) *
319 snd_pcm_format_width(params_format(p)) / 8);
320
304} 321}
305 322
306static snd_pcm_format_t hpi_to_alsa_formats[] = { 323static snd_pcm_format_t hpi_to_alsa_formats[] = {
@@ -451,7 +468,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
451 int width; 468 int width;
452 unsigned int bytes_per_sec; 469 unsigned int bytes_per_sec;
453 470
454 print_hwparams(params); 471 print_hwparams(substream, params);
455 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); 472 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
456 if (err < 0) 473 if (err < 0)
457 return err; 474 return err;
@@ -459,10 +476,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
459 if (err) 476 if (err)
460 return err; 477 return err;
461 478
462 snd_printdd("format %d, %d chans, %d_hz\n",
463 format, params_channels(params),
464 params_rate(params));
465
466 hpi_handle_error(hpi_format_create(&dpcm->format, 479 hpi_handle_error(hpi_format_create(&dpcm->format,
467 params_channels(params), 480 params_channels(params),
468 format, params_rate(params), 0, 0)); 481 format, params_rate(params), 0, 0));
@@ -509,8 +522,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
509 dpcm->bytes_per_sec = bytes_per_sec; 522 dpcm->bytes_per_sec = bytes_per_sec;
510 dpcm->buffer_bytes = params_buffer_bytes(params); 523 dpcm->buffer_bytes = params_buffer_bytes(params);
511 dpcm->period_bytes = params_period_bytes(params); 524 dpcm->period_bytes = params_period_bytes(params);
512 snd_printdd("buffer_bytes=%d, period_bytes=%d, bps=%d\n",
513 dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec);
514 525
515 return 0; 526 return 0;
516} 527}
@@ -564,9 +575,10 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
564 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 575 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
565 struct snd_pcm_substream *s; 576 struct snd_pcm_substream *s;
566 u16 e; 577 u16 e;
578 DEBUG_NAME(substream, name);
579
580 snd_printdd("%s trigger\n", name);
567 581
568 snd_printdd("%c%d trigger\n",
569 SCHR(substream->stream), substream->number);
570 switch (cmd) { 582 switch (cmd) {
571 case SNDRV_PCM_TRIGGER_START: 583 case SNDRV_PCM_TRIGGER_START:
572 snd_pcm_group_for_each_entry(s, substream) { 584 snd_pcm_group_for_each_entry(s, substream) {
@@ -599,9 +611,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
599 } 611 }
600 612
601 if (card->support_grouping) { 613 if (card->support_grouping) {
602 snd_printdd("\t%c%d group\n", 614 snd_printdd("%d group\n", s->number);
603 SCHR(s->stream),
604 s->number);
605 e = hpi_stream_group_add( 615 e = hpi_stream_group_add(
606 dpcm->h_stream, 616 dpcm->h_stream,
607 ds->h_stream); 617 ds->h_stream);
@@ -636,9 +646,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
636 s->runtime->status->state = SNDRV_PCM_STATE_SETUP; 646 s->runtime->status->state = SNDRV_PCM_STATE_SETUP;
637 647
638 if (card->support_grouping) { 648 if (card->support_grouping) {
639 snd_printdd("\t%c%d group\n", 649 snd_printdd("%d group\n", s->number);
640 SCHR(s->stream),
641 s->number);
642 snd_pcm_trigger_done(s, substream); 650 snd_pcm_trigger_done(s, substream);
643 } else 651 } else
644 break; 652 break;
@@ -732,9 +740,9 @@ static void snd_card_asihpi_timer_function(unsigned long data)
732 int loops = 0; 740 int loops = 0;
733 u16 state; 741 u16 state;
734 u32 buffer_size, bytes_avail, samples_played, on_card_bytes; 742 u32 buffer_size, bytes_avail, samples_played, on_card_bytes;
743 DEBUG_NAME(substream, name);
735 744
736 snd_printdd("%c%d snd_card_asihpi_timer_function\n", 745 snd_printdd("%s snd_card_asihpi_timer_function\n", name);
737 SCHR(substream->stream), substream->number);
738 746
739 /* find minimum newdata and buffer pos in group */ 747 /* find minimum newdata and buffer pos in group */
740 snd_pcm_group_for_each_entry(s, substream) { 748 snd_pcm_group_for_each_entry(s, substream) {
@@ -786,16 +794,18 @@ static void snd_card_asihpi_timer_function(unsigned long data)
786 newdata); 794 newdata);
787 } 795 }
788 796
789 snd_printdd("hw_ptr x%04lX, appl_ptr x%04lX\n", 797 snd_printdd("hw_ptr 0x%04lX, appl_ptr 0x%04lX\n",
790 (unsigned long)frames_to_bytes(runtime, 798 (unsigned long)frames_to_bytes(runtime,
791 runtime->status->hw_ptr), 799 runtime->status->hw_ptr),
792 (unsigned long)frames_to_bytes(runtime, 800 (unsigned long)frames_to_bytes(runtime,
793 runtime->control->appl_ptr)); 801 runtime->control->appl_ptr));
794 802
795 snd_printdd("%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X," 803 snd_printdd("%d S=%d, "
796 " aux=x%04X space=x%04X\n", 804 "rw=0x%04X, dma=0x%04X, left=0x%04X, "
797 loops, SCHR(s->stream), s->number, 805 "aux=0x%04X space=0x%04X\n",
798 state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, 806 s->number, state,
807 ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs,
808 (int)bytes_avail,
799 (int)on_card_bytes, buffer_size-bytes_avail); 809 (int)on_card_bytes, buffer_size-bytes_avail);
800 loops++; 810 loops++;
801 } 811 }
@@ -814,7 +824,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
814 824
815 next_jiffies = max(next_jiffies, 1U); 825 next_jiffies = max(next_jiffies, 1U);
816 dpcm->timer.expires = jiffies + next_jiffies; 826 dpcm->timer.expires = jiffies + next_jiffies;
817 snd_printdd("jif %d buf pos x%04X newdata x%04X xfer x%04X\n", 827 snd_printdd("jif %d buf pos 0x%04X newdata 0x%04X xfer 0x%04X\n",
818 next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); 828 next_jiffies, pcm_buf_dma_ofs, newdata, xfercount);
819 829
820 snd_pcm_group_for_each_entry(s, substream) { 830 snd_pcm_group_for_each_entry(s, substream) {
@@ -863,7 +873,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
863static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, 873static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream,
864 unsigned int cmd, void *arg) 874 unsigned int cmd, void *arg)
865{ 875{
866 snd_printdd(KERN_INFO "Playback ioctl %d\n", cmd); 876 snd_printddd(KERN_INFO "P%d ioctl %d\n", substream->number, cmd);
867 return snd_pcm_lib_ioctl(substream, cmd, arg); 877 return snd_pcm_lib_ioctl(substream, cmd, arg);
868} 878}
869 879
@@ -873,7 +883,7 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream *
873 struct snd_pcm_runtime *runtime = substream->runtime; 883 struct snd_pcm_runtime *runtime = substream->runtime;
874 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 884 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
875 885
876 snd_printdd("playback prepare %d\n", substream->number); 886 snd_printdd("P%d prepare\n", substream->number);
877 887
878 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); 888 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream));
879 dpcm->pcm_buf_host_rw_ofs = 0; 889 dpcm->pcm_buf_host_rw_ofs = 0;
@@ -890,7 +900,7 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream)
890 snd_pcm_uframes_t ptr; 900 snd_pcm_uframes_t ptr;
891 901
892 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); 902 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
893 snd_printddd("playback_pointer=x%04lx\n", (unsigned long)ptr); 903 snd_printddd("P%d pointer = 0x%04lx\n", substream->number, (unsigned long)ptr);
894 return ptr; 904 return ptr;
895} 905}
896 906