MODULE_DESCRIPTION("AudioScience ALSA ASI5xxx ASI6xxx ASI87xx ASI89xx "
HPI_VER_STRING);
-#if defined CONFIG_SND_DEBUG_VERBOSE
-/**
- * snd_printddd - very verbose debug printk
- * @format: format string
- *
- * Works like snd_printk() for debugging purposes.
- * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set.
- * Must set snd module debug parameter to 3 to enable at runtime.
- */
-#define snd_printddd(format, args...) \
- __snd_printk(3, __FILE__, __LINE__, format, ##args)
+#ifdef ASIHPI_VERBOSE_DEBUG
+#define asihpi_dbg(format, args...) pr_debug(format, ##args)
#else
-#define snd_printddd(format, args...) do { } while (0)
+#define asihpi_dbg(format, args...) do { } while (0)
#endif
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
static u16 handle_error(u16 err, int line, char *filename)
{
if (err)
- printk(KERN_WARNING
- "in file %s, line %d: HPI error %d\n",
+ pr_warn("in file %s, line %d: HPI error %d\n",
filename, line, err);
return err;
}
static void print_hwparams(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *p)
{
+ struct device *dev = substream->pcm->card->dev;
char name[16];
+
snd_pcm_debug_name(substream, name, sizeof(name));
- snd_printdd("%s HWPARAMS\n", name);
- snd_printdd(" samplerate=%dHz channels=%d format=%d subformat=%d\n",
+ dev_dbg(dev, "%s HWPARAMS\n", name);
+ dev_dbg(dev, " samplerate=%dHz channels=%d format=%d subformat=%d\n",
params_rate(p), params_channels(p),
params_format(p), params_subformat(p));
- snd_printdd(" buffer=%dB period=%dB period_size=%dB periods=%d\n",
+ dev_dbg(dev, " buffer=%dB period=%dB period_size=%dB periods=%d\n",
params_buffer_bytes(p), params_period_bytes(p),
params_period_size(p), params_periods(p));
- snd_printdd(" buffer_size=%d access=%d data_rate=%dB/s\n",
+ dev_dbg(dev, " buffer_size=%d access=%d data_rate=%dB/s\n",
params_buffer_size(p), params_access(p),
params_rate(p) * params_channels(p) *
snd_pcm_format_width(params_format(p)) / 8);
};
-static int snd_card_asihpi_format_alsa2hpi(snd_pcm_format_t alsa_format,
+static int snd_card_asihpi_format_alsa2hpi(struct snd_card_asihpi *asihpi,
+ snd_pcm_format_t alsa_format,
u16 *hpi_format)
{
u16 format;
}
}
- snd_printd(KERN_WARNING "failed match for alsa format %d\n",
- alsa_format);
+ dev_dbg(asihpi->card->dev, "failed match for alsa format %d\n",
+ alsa_format);
*hpi_format = 0;
return -EINVAL;
}
unsigned int bytes_per_sec;
print_hwparams(substream, params);
- err = snd_card_asihpi_format_alsa2hpi(params_format(params), &format);
+ err = snd_card_asihpi_format_alsa2hpi(card, params_format(params), &format);
if (err)
return err;
err = hpi_stream_host_buffer_attach(dpcm->h_stream,
params_buffer_bytes(params), runtime->dma_addr);
if (err == 0) {
- snd_printdd(
+ dev_dbg(card->card->dev,
"stream_host_buffer_attach success %u %lu\n",
params_buffer_bytes(params),
(unsigned long)runtime->dma_addr);
} else {
- snd_printd("stream_host_buffer_attach error %d\n",
- err);
+ dev_dbg(card->card->dev,
+ "stream_host_buffer_attach error %d\n", err);
return -ENOMEM;
}
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
- snd_printdd("%s trigger start\n", name);
+ dev_dbg(card->card->dev, "%s trigger start\n", name);
snd_pcm_group_for_each_entry(s, substream) {
struct snd_pcm_runtime *runtime = s->runtime;
struct snd_card_asihpi_pcm *ds = runtime->private_data;
* data??
*/
unsigned int preload = ds->period_bytes * 1;
- snd_printddd("%d preload %d\n", s->number, preload);
+ asihpi_dbg("%d preload %d\n", s->number, preload);
hpi_handle_error(hpi_outstream_write_buf(
ds->h_stream,
&runtime->dma_area[0],
}
if (card->support_grouping) {
- snd_printdd("%d group\n", s->number);
+ dev_dbg(card->card->dev, "%d group\n", s->number);
e = hpi_stream_group_add(
dpcm->h_stream,
ds->h_stream);
break;
case SNDRV_PCM_TRIGGER_STOP:
- snd_printdd("%s trigger stop\n", name);
+ dev_dbg(card->card->dev, "%s trigger stop\n", name);
card->pcm_stop(substream);
snd_pcm_group_for_each_entry(s, substream) {
if (snd_pcm_substream_chip(s) != card)
__snd_pcm_set_state(s->runtime, SNDRV_PCM_STATE_SETUP);
if (card->support_grouping) {
- snd_printdd("%d group\n", s->number);
+ dev_dbg(card->card->dev, "%d group\n", s->number);
snd_pcm_trigger_done(s, substream);
} else
break;
break;
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- snd_printdd("%s trigger pause release\n", name);
+ dev_dbg(card->card->dev, "%s trigger pause release\n", name);
card->pcm_start(substream);
hpi_handle_error(hpi_stream_start(dpcm->h_stream));
break;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- snd_printdd("%s trigger pause push\n", name);
+ dev_dbg(card->card->dev, "%s trigger pause push\n", name);
card->pcm_stop(substream);
hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
break;
default:
- snd_printd(KERN_ERR "\tINVALID\n");
+ dev_dbg(card->card->dev, "\tINVALID\n");
return -EINVAL;
}
if (state == HPI_STATE_STOPPED) {
if (bytes_avail == 0) {
hpi_handle_error(hpi_stream_start(ds->h_stream));
- snd_printdd("P%d start\n", s->number);
+ dev_dbg(card->card->dev,
+ "P%d start\n", s->number);
ds->drained_count = 0;
}
} else if (state == HPI_STATE_DRAINED) {
- snd_printd(KERN_WARNING "P%d drained\n",
- s->number);
+ dev_dbg(card->card->dev,
+ "P%d drained\n", s->number);
ds->drained_count++;
if (ds->drained_count > 20) {
snd_pcm_stop_xrun(s);
newdata);
}
- snd_printddd(
+ asihpi_dbg(
"timer1, %s, %d, S=%d, elap=%d, rw=%d, dsp=%d, left=%d, aux=%d, space=%d, hw_ptr=%ld, appl_ptr=%ld\n",
name, s->number, state,
ds->pcm_buf_elapsed_dma_ofs,
next_jiffies = max(next_jiffies, 1U);
dpcm->timer.expires = jiffies + next_jiffies;
- snd_printddd("timer2, jif=%d, buf_pos=%d, newdata=%d, xfer=%d\n",
+ asihpi_dbg("timer2, jif=%d, buf_pos=%d, newdata=%d, xfer=%d\n",
next_jiffies, pcm_buf_dma_ofs, newdata, xfercount);
snd_pcm_group_for_each_entry(s, substream) {
}
if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- snd_printddd("write1, P=%d, xfer=%d, buf_ofs=%d\n",
+ asihpi_dbg("write1, P=%d, xfer=%d, buf_ofs=%d\n",
s->number, xfer1, buf_ofs);
hpi_handle_error(
hpi_outstream_write_buf(
if (xfer2) {
pd = s->runtime->dma_area;
- snd_printddd("write2, P=%d, xfer=%d, buf_ofs=%d\n",
+ asihpi_dbg("write2, P=%d, xfer=%d, buf_ofs=%d\n",
s->number,
xfercount - xfer1, buf_ofs);
hpi_handle_error(
&ds->format));
}
} else {
- snd_printddd("read1, C=%d, xfer=%d\n",
+ asihpi_dbg("read1, C=%d, xfer=%d\n",
s->number, xfer1);
hpi_handle_error(
hpi_instream_read_buf(
pd, xfer1));
if (xfer2) {
pd = s->runtime->dma_area;
- snd_printddd("read2, C=%d, xfer=%d\n",
+ asihpi_dbg("read2, C=%d, xfer=%d\n",
s->number, xfer2);
hpi_handle_error(
hpi_instream_read_buf(
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
- snd_printdd("P%d prepare\n", substream->number);
-
hpi_handle_error(hpi_outstream_reset(dpcm->h_stream));
dpcm->pcm_buf_host_rw_ofs = 0;
dpcm->pcm_buf_dma_ofs = 0;
snd_pcm_debug_name(substream, name, sizeof(name));
ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
- snd_printddd("%s, pointer=%ld\n", name, (unsigned long)ptr);
+ asihpi_dbg("%s, pointer=%ld\n", name, (unsigned long)ptr);
return ptr;
}
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
card->update_interval_frames, UINT_MAX);
- snd_printdd("playback open\n");
-
return 0;
}
struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
hpi_handle_error(hpi_outstream_close(dpcm->h_stream));
- snd_printdd("playback close\n");
-
return 0;
}
char name[16];
snd_pcm_debug_name(substream, name, sizeof(name));
- snd_printddd("%s, pointer=%d\n", name, dpcm->pcm_buf_dma_ofs);
+ asihpi_dbg("%s, pointer=%d\n", name, dpcm->pcm_buf_dma_ofs);
/* NOTE Unlike playback can't use actual samples_played
for the capture position, because those samples aren't yet in
the local buffer available for reading.
dpcm->pcm_buf_dma_ofs = 0;
dpcm->pcm_buf_elapsed_dma_ofs = 0;
- snd_printdd("Capture Prepare %d\n", substream->number);
return 0;
}
if (dpcm == NULL)
return -ENOMEM;
- snd_printdd("capture open adapter %d stream %d\n",
- card->hpi->adapter->index, substream->number);
+
+ dev_dbg(card->card->dev, "capture open adapter %d stream %d\n",
+ card->hpi->adapter->index, substream->number);
err = hpi_handle_error(
hpi_instream_open(card->hpi->adapter->index,
hpi_ctl->src_node_index,
dir, name);
}
- /* printk(KERN_INFO "Adding %s %d to %d ", hpi_ctl->name,
- hpi_ctl->wSrcNodeType, hpi_ctl->wDstNodeType); */
}
/*------------------------------------------------------------
return 0;
}
}
- snd_printd(KERN_WARNING
- "Control %x failed to match mux source %hu %hu\n",
- h_control, source_type, source_index);
+ pr_warn("%s: Control %x failed to match mux source %hu %hu\n",
+ __func__, h_control, source_type, source_index);
ucontrol->value.enumerated.item[0] = 0;
return 0;
}