Commit a6477134 authored by Eliot Blennerhassett's avatar Eliot Blennerhassett Committed by Takashi Iwai

ALSA: asihpi: Update debug printing

Debug print full substream ID.
Other minor debug print updates.
Signed-off-by: default avatarEliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 550ac6ba
...@@ -57,8 +57,25 @@ MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); ...@@ -57,8 +57,25 @@ MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx");
*/ */
#define snd_printddd(format, args...) \ #define snd_printddd(format, args...) \
__snd_printk(3, __FILE__, __LINE__, format, ##args) __snd_printk(3, __FILE__, __LINE__, format, ##args)
/* copied from pcm_lib.c, hope later patch will make that version public
and this copy can be removed */
static void pcm_debug_name(struct snd_pcm_substream *substream,
char *name, size_t len)
{
snprintf(name, len, "pcmC%dD%d%c:%d",
substream->pcm->card->number,
substream->pcm->device,
substream->stream ? 'c' : 'p',
substream->number);
}
#define DEBUG_NAME(substream, name) char name[16]; pcm_debug_name(substream, name, sizeof(name))
#else #else
#define snd_printddd(format, args...) do { } while (0) #define snd_printddd(format, args...) do { } while (0)
#define pcm_debug_name(s, n, l) do { } while (0)
#define DEBUG_NAME(name, substream) do { } while (0)
#endif #endif
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
...@@ -101,13 +118,6 @@ static int adapter_fs = DEFAULT_SAMPLERATE; ...@@ -101,13 +118,6 @@ static int adapter_fs = DEFAULT_SAMPLERATE;
#define PERIOD_BYTES_MIN 2048 #define PERIOD_BYTES_MIN 2048
#define BUFFER_BYTES_MAX (512 * 1024) #define BUFFER_BYTES_MAX (512 * 1024)
/* convert stream to character */
#define SCHR(s) ((s == SNDRV_PCM_STREAM_PLAYBACK) ? 'P' : 'C')
/*#define TIMER_MILLISECONDS 20
#define FORCE_TIMER_JIFFIES ((TIMER_MILLISECONDS * HZ + 999)/1000)
*/
#define MAX_CLOCKSOURCES (HPI_SAMPLECLOCK_SOURCE_LAST + 1 + 7) #define MAX_CLOCKSOURCES (HPI_SAMPLECLOCK_SOURCE_LAST + 1 + 7)
struct clk_source { struct clk_source {
...@@ -288,19 +298,26 @@ static u16 handle_error(u16 err, int line, char *filename) ...@@ -288,19 +298,26 @@ static u16 handle_error(u16 err, int line, char *filename)
#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__) #define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__)
/***************************** GENERAL PCM ****************/ /***************************** GENERAL PCM ****************/
static void print_hwparams(struct snd_pcm_hw_params *p)
static void print_hwparams(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *p)
{ {
snd_printd("HWPARAMS \n"); DEBUG_NAME(substream, name);
snd_printd("samplerate %d \n", params_rate(p)); snd_printd("%s HWPARAMS\n", name);
snd_printd("Channels %d \n", params_channels(p)); snd_printd(" samplerate %d Hz\n", params_rate(p));
snd_printd("Format %d \n", params_format(p)); snd_printd(" channels %d\n", params_channels(p));
snd_printd("subformat %d \n", params_subformat(p)); snd_printd(" format %d\n", params_format(p));
snd_printd("Buffer bytes %d \n", params_buffer_bytes(p)); snd_printd(" subformat %d\n", params_subformat(p));
snd_printd("Period bytes %d \n", params_period_bytes(p)); snd_printd(" buffer %d B\n", params_buffer_bytes(p));
snd_printd("access %d \n", params_access(p)); snd_printd(" period %d B\n", params_period_bytes(p));
snd_printd("period_size %d \n", params_period_size(p)); snd_printd(" access %d\n", params_access(p));
snd_printd("periods %d \n", params_periods(p)); snd_printd(" period_size %d\n", params_period_size(p));
snd_printd("buffer_size %d \n", params_buffer_size(p)); snd_printd(" periods %d\n", params_periods(p));
snd_printd(" buffer_size %d\n", params_buffer_size(p));
snd_printd(" %d B/s\n", params_rate(p) *
params_channels(p) *
snd_pcm_format_width(params_format(p)) / 8);
} }
static snd_pcm_format_t hpi_to_alsa_formats[] = { static 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,7 +468,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
int width; int width;
unsigned int bytes_per_sec; unsigned int bytes_per_sec;
print_hwparams(params); print_hwparams(substream, params);
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
if (err < 0) if (err < 0)
return err; return err;
...@@ -459,10 +476,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -459,10 +476,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
if (err) if (err)
return err; return err;
snd_printdd("format %d, %d chans, %d_hz\n",
format, params_channels(params),
params_rate(params));
hpi_handle_error(hpi_format_create(&dpcm->format, hpi_handle_error(hpi_format_create(&dpcm->format,
params_channels(params), params_channels(params),
format, params_rate(params), 0, 0)); format, params_rate(params), 0, 0));
...@@ -509,8 +522,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -509,8 +522,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
dpcm->bytes_per_sec = bytes_per_sec; dpcm->bytes_per_sec = bytes_per_sec;
dpcm->buffer_bytes = params_buffer_bytes(params); dpcm->buffer_bytes = params_buffer_bytes(params);
dpcm->period_bytes = params_period_bytes(params); dpcm->period_bytes = params_period_bytes(params);
snd_printdd("buffer_bytes=%d, period_bytes=%d, bps=%d\n",
dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec);
return 0; return 0;
} }
...@@ -564,9 +575,10 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, ...@@ -564,9 +575,10 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
struct snd_pcm_substream *s; struct snd_pcm_substream *s;
u16 e; u16 e;
DEBUG_NAME(substream, name);
snd_printdd("%s trigger\n", name);
snd_printdd("%c%d trigger\n",
SCHR(substream->stream), substream->number);
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
snd_pcm_group_for_each_entry(s, substream) { snd_pcm_group_for_each_entry(s, substream) {
...@@ -599,9 +611,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, ...@@ -599,9 +611,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
} }
if (card->support_grouping) { if (card->support_grouping) {
snd_printdd("\t%c%d group\n", snd_printdd("%d group\n", s->number);
SCHR(s->stream),
s->number);
e = hpi_stream_group_add( e = hpi_stream_group_add(
dpcm->h_stream, dpcm->h_stream,
ds->h_stream); ds->h_stream);
...@@ -636,9 +646,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, ...@@ -636,9 +646,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
s->runtime->status->state = SNDRV_PCM_STATE_SETUP; s->runtime->status->state = SNDRV_PCM_STATE_SETUP;
if (card->support_grouping) { if (card->support_grouping) {
snd_printdd("\t%c%d group\n", snd_printdd("%d group\n", s->number);
SCHR(s->stream),
s->number);
snd_pcm_trigger_done(s, substream); snd_pcm_trigger_done(s, substream);
} else } else
break; break;
...@@ -732,9 +740,9 @@ static void snd_card_asihpi_timer_function(unsigned long data) ...@@ -732,9 +740,9 @@ static void snd_card_asihpi_timer_function(unsigned long data)
int loops = 0; int loops = 0;
u16 state; u16 state;
u32 buffer_size, bytes_avail, samples_played, on_card_bytes; u32 buffer_size, bytes_avail, samples_played, on_card_bytes;
DEBUG_NAME(substream, name);
snd_printdd("%c%d snd_card_asihpi_timer_function\n", snd_printdd("%s snd_card_asihpi_timer_function\n", name);
SCHR(substream->stream), substream->number);
/* find minimum newdata and buffer pos in group */ /* find minimum newdata and buffer pos in group */
snd_pcm_group_for_each_entry(s, substream) { snd_pcm_group_for_each_entry(s, substream) {
...@@ -786,16 +794,18 @@ static void snd_card_asihpi_timer_function(unsigned long data) ...@@ -786,16 +794,18 @@ static void snd_card_asihpi_timer_function(unsigned long data)
newdata); newdata);
} }
snd_printdd("hw_ptr x%04lX, appl_ptr x%04lX\n", snd_printdd("hw_ptr 0x%04lX, appl_ptr 0x%04lX\n",
(unsigned long)frames_to_bytes(runtime, (unsigned long)frames_to_bytes(runtime,
runtime->status->hw_ptr), runtime->status->hw_ptr),
(unsigned long)frames_to_bytes(runtime, (unsigned long)frames_to_bytes(runtime,
runtime->control->appl_ptr)); runtime->control->appl_ptr));
snd_printdd("%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X," snd_printdd("%d S=%d, "
" aux=x%04X space=x%04X\n", "rw=0x%04X, dma=0x%04X, left=0x%04X, "
loops, SCHR(s->stream), s->number, "aux=0x%04X space=0x%04X\n",
state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, s->number, state,
ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs,
(int)bytes_avail,
(int)on_card_bytes, buffer_size-bytes_avail); (int)on_card_bytes, buffer_size-bytes_avail);
loops++; loops++;
} }
...@@ -814,7 +824,7 @@ static void snd_card_asihpi_timer_function(unsigned long data) ...@@ -814,7 +824,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
next_jiffies = max(next_jiffies, 1U); next_jiffies = max(next_jiffies, 1U);
dpcm->timer.expires = jiffies + next_jiffies; dpcm->timer.expires = jiffies + next_jiffies;
snd_printdd("jif %d buf pos x%04X newdata x%04X xfer x%04X\n", snd_printdd("jif %d buf pos 0x%04X newdata 0x%04X xfer 0x%04X\n",
next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); next_jiffies, pcm_buf_dma_ofs, newdata, xfercount);
snd_pcm_group_for_each_entry(s, substream) { snd_pcm_group_for_each_entry(s, substream) {
...@@ -863,7 +873,7 @@ static void snd_card_asihpi_timer_function(unsigned long data) ...@@ -863,7 +873,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg) unsigned int cmd, void *arg)
{ {
snd_printdd(KERN_INFO "Playback ioctl %d\n", cmd); snd_printddd(KERN_INFO "P%d ioctl %d\n", substream->number, cmd);
return snd_pcm_lib_ioctl(substream, cmd, arg); return snd_pcm_lib_ioctl(substream, cmd, arg);
} }
...@@ -873,7 +883,7 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream * ...@@ -873,7 +883,7 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream *
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_card_asihpi_pcm *dpcm = runtime->private_data; struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
snd_printdd("playback prepare %d\n", substream->number); snd_printdd("P%d prepare\n", substream->number);
hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); hpi_handle_error(hpi_outstream_reset(dpcm->h_stream));
dpcm->pcm_buf_host_rw_ofs = 0; dpcm->pcm_buf_host_rw_ofs = 0;
...@@ -890,7 +900,7 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) ...@@ -890,7 +900,7 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream)
snd_pcm_uframes_t ptr; snd_pcm_uframes_t ptr;
ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
snd_printddd("playback_pointer=x%04lx\n", (unsigned long)ptr); snd_printddd("P%d pointer = 0x%04lx\n", substream->number, (unsigned long)ptr);
return ptr; return ptr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment