summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2025-03-29 11:20:29 (GMT)
committerChristian Pointner <equinox@helsinki.at>2025-03-29 11:20:29 (GMT)
commit2f0f51426a2331873c2f3795c2ea2290ad04fcab (patch)
treec32f0fba22c91457a6dd0459a3b67af321de982a
parent73b1ed36085870e0cf1abf892479b47404ca23f4 (diff)
snd-pcxhr: import refreshed version of patchset
-rw-r--r--snd-pcxhr-dkms/src/Makefile4
-rw-r--r--snd-pcxhr-dkms/src/pcxhr.c303
-rw-r--r--snd-pcxhr-dkms/src/pcxhr.h28
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_clock_monitoring.c38
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_clock_monitoring.h15
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_core.c244
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_core.h17
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_hrtimer.c15
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_hrtimer.h15
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_hwdep.c61
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_hwdep.h15
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_mix22.c75
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_mix22.h15
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_mixer.c72
-rw-r--r--snd-pcxhr-dkms/src/pcxhr_mixer.h15
15 files changed, 364 insertions, 568 deletions
diff --git a/snd-pcxhr-dkms/src/Makefile b/snd-pcxhr-dkms/src/Makefile
index aba3878..4d0bcf8 100644
--- a/snd-pcxhr-dkms/src/Makefile
+++ b/snd-pcxhr-dkms/src/Makefile
@@ -1,5 +1,5 @@
-
-snd-pcxhr-objs := pcxhr.o pcxhr_hwdep.o pcxhr_mixer.o pcxhr_core.o pcxhr_mix22.o pcxhr_hrtimer.o
+# SPDX-License-Identifier: GPL-2.0-only
+snd-pcxhr-y := pcxhr.o pcxhr_hwdep.o pcxhr_mixer.o pcxhr_core.o pcxhr_mix22.o pcxhr_hrtimer.o
# pcxhr_clock_monitoring.o
obj-$(CONFIG_SND_PCXHR) += snd-pcxhr.o
diff --git a/snd-pcxhr-dkms/src/pcxhr.c b/snd-pcxhr-dkms/src/pcxhr.c
index aa33a56..0793e69 100644
--- a/snd-pcxhr-dkms/src/pcxhr.c
+++ b/snd-pcxhr-dkms/src/pcxhr.c
@@ -1,23 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* main file with alsa callbacks
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -51,10 +38,6 @@
#define DRIVER_NAME "pcxhr"
-/* Workaround for kernel version >= 5.5 */
-#ifndef snd_dma_pci_data
- #define snd_dma_pci_data(pci) (&(pci)->dev)
-#endif
MODULE_AUTHOR("Gilbert Passador <www.digigram.com>, "
"Loïc Boissy <www.digigram.com>");
@@ -180,7 +163,7 @@ struct board_parameters {
short fw_file_set;
short firmware_num;
};
-static struct board_parameters pcxhr_board_params[] = {
+static const struct board_parameters pcxhr_board_params[] = {
[PCI_ID_VX882HR] = { "VX882HR", 4, 4, 0, 41 },
[PCI_ID_PCX882HR] = { "PCX882HR", 4, 4, 0, 41 },
[PCI_ID_VX881HR] = { "VX881HR", 4, 4, 0, 41 },
@@ -325,7 +308,7 @@ static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate,
rmh.cmd_len = 3;
err = pcxhr_send_msg(mgr, &rmh);
if (err < 0) {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"error CMD_ACCESS_IO_WRITE "
"for PLL register : %x!\n", err);
return err;
@@ -398,7 +381,7 @@ static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr,
return err;
}
/* set the new frequency */
- snd_printdd("clock register : set %x\n", val);
+ dev_dbg(&mgr->pci->dev, "clock register : set %x\n", val);
err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK,
val, changed);
if (err)
@@ -421,7 +404,7 @@ static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr,
mgr->codec_speed = speed; /* save new codec speed */
}
- snd_printdd("pcxhr_sub_set_clock to %dHz (realfreq=%d)\n",
+ dev_dbg(&mgr->pci->dev, "%s to %dHz (realfreq=%d)\n", __func__,
rate, realfreq);
return 0;
}
@@ -521,7 +504,7 @@ static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr,
case REG_STATUS_SYNC_192000 : rate = 192000; break;
default: rate = 0;
}
- snd_printdd("External clock is at %d Hz\n", rate);
+ dev_dbg(&mgr->pci->dev, "External clock is at %d Hz\n", rate);
*sample_rate = rate;
return 0;
}
@@ -542,10 +525,10 @@ int pcxhr_get_external_clock(struct pcxhr_mgr *mgr,
/*
* start or stop playback/capture substream
*/
-static int pcxhr_set_stream_state(struct pcxhr_stream *stream)
+static int pcxhr_set_stream_state(struct snd_pcxhr *chip,
+ struct pcxhr_stream *stream)
{
int err;
- struct snd_pcxhr *chip;
struct pcxhr_rmh rmh;
int stream_mask, start;
@@ -553,8 +536,8 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream)
start = 1;
else {
if (stream->status != PCXHR_STREAM_STATUS_SCHEDULE_STOP) {
- snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state "
- "CANNOT be stopped\n");
+ dev_err(chip->card->dev,
+ "%s CANNOT be stopped\n", __func__);
return -EINVAL;
}
start = 0;
@@ -578,8 +561,8 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream)
err = pcxhr_send_msg(chip->mgr, &rmh);
if (err)
- snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state err=%x;\n",
- err);
+ dev_err(chip->card->dev,
+ "ERROR %s err=%x;\n", __func__, err);
stream->status =
start ? PCXHR_STREAM_STATUS_STARTED : PCXHR_STREAM_STATUS_STOPPED;
return err;
@@ -601,6 +584,7 @@ static int pcxhr_set_format(struct pcxhr_stream *stream)
struct pcxhr_rmh rmh;
unsigned int header;
+ chip = snd_pcm_substream_chip(stream->substream);
switch (stream->format) {
case SNDRV_PCM_FORMAT_U8:
header = HEADER_FMT_BASE_LIN;
@@ -623,11 +607,10 @@ static int pcxhr_set_format(struct pcxhr_stream *stream)
header = HEADER_FMT_BASE_FLOAT | HEADER_FMT_INTEL;
break;
default:
- snd_printk(KERN_ERR
- "error pcxhr_set_format() : unknown format\n");
+ dev_err(chip->card->dev,
+ "error %s() : unknown format\n", __func__);
return -EINVAL;
}
- chip = snd_pcm_substream_chip(stream->substream);
sample_rate = chip->mgr->sample_rate;
if (sample_rate <= 32000 && sample_rate !=0) {
@@ -669,7 +652,8 @@ static int pcxhr_set_format(struct pcxhr_stream *stream)
rmh.cmd[rmh.cmd_len++] = (header & 0xff) << 16;
err = pcxhr_send_msg(chip->mgr, &rmh);
if (err)
- snd_printk(KERN_ERR "ERROR pcxhr_set_format err=%x;\n", err);
+ dev_err(chip->card->dev,
+ "ERROR %s err=%x;\n", __func__, err);
return err;
}
@@ -683,11 +667,11 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
is_capture = (subs->stream == SNDRV_PCM_STREAM_CAPTURE);
stream_num = is_capture ? 0 : subs->number;
- snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : "
- "addr(%p) bytes(%lx) subs(%d)\n",
- is_capture ? 'c' : 'p',
- chip->chip_idx, (void *)(long)subs->runtime->dma_addr,
- subs->runtime->dma_bytes, subs->number);
+ dev_dbg(chip->card->dev,
+ "%s(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n", __func__,
+ is_capture ? 'c' : 'p',
+ chip->chip_idx, (void *)(long)subs->runtime->dma_addr,
+ subs->runtime->dma_bytes, subs->number);
pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS);
pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio,
@@ -706,7 +690,7 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
rmh.cmd_len = 4;
err = pcxhr_send_msg(chip->mgr, &rmh);
if (err)
- snd_printk(KERN_ERR
+ dev_err(chip->card->dev,
"ERROR CMD_UPDATE_R_BUFFERS err=%x;\n", err);
return err;
}
@@ -727,7 +711,7 @@ static int pcxhr_pipe_sample_count(struct pcxhr_stream *stream,
*sample_count = ((snd_pcm_uframes_t)rmh.stat[0]) << 24;
*sample_count += (snd_pcm_uframes_t)rmh.stat[1];
}
- snd_printdd("PIPE_SAMPLE_COUNT = %lx\n", *sample_count);
+ dev_dbg(chip->card->dev, "PIPE_SAMPLE_COUNT = %lx\n", *sample_count);
return err;
}
#endif
@@ -742,19 +726,18 @@ static inline int pcxhr_stream_scheduled_get_pipe(struct pcxhr_stream *stream,
return 0;
}
-static void pcxhr_trigger_tasklet(unsigned long arg)
+static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
{
- unsigned long flags;
int i, j, err;
struct pcxhr_pipe *pipe;
struct snd_pcxhr *chip;
- struct pcxhr_mgr *mgr = (struct pcxhr_mgr*)(arg);
int capture_mask = 0;
int playback_mask = 0;
#ifdef CONFIG_SND_DEBUG_VERBOSE
- struct timespec64 start_date, end_date, delta_t;
- ktime_get_real_ts64(&start_date);
+ ktime_t start_time, stop_time, diff_time;
+
+ start_time = ktime_get();
#endif
mutex_lock(&mgr->setup_mutex);
@@ -776,21 +759,20 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
}
if (capture_mask == 0 && playback_mask == 0) {
mutex_unlock(&mgr->setup_mutex);
- snd_printk(KERN_ERR "pcxhr_trigger_tasklet : no pipes\n");
+ dev_err(&mgr->pci->dev, "%s : no pipes\n", __func__);
return;
}
- snd_printdd("pcxhr_trigger_tasklet : "
- "playback_mask=%x capture_mask=%x\n",
- playback_mask, capture_mask);
+ dev_dbg(&mgr->pci->dev, "%s : playback_mask=%x capture_mask=%x\n",
+ __func__, playback_mask, capture_mask);
/* synchronous stop of all the pipes concerned */
err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
if (err) {
mutex_unlock(&mgr->setup_mutex);
- snd_printk(KERN_ERR "pcxhr_trigger_tasklet : "
+ dev_err(&mgr->pci->dev, "%s : "
"error stop pipes (P%x C%x)\n",
- playback_mask, capture_mask);
+ __func__, playback_mask, capture_mask);
return;
}
@@ -820,12 +802,12 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
for (j = 0; j < chip->nb_streams_capt; j++) {
stream = &chip->capture_stream[j];
if (pcxhr_stream_scheduled_get_pipe(stream, &pipe))
- err = pcxhr_set_stream_state(stream);
+ err = pcxhr_set_stream_state(chip, stream);
}
for (j = 0; j < chip->nb_streams_play; j++) {
stream = &chip->playback_stream[j];
if (pcxhr_stream_scheduled_get_pipe(stream, &pipe))
- err = pcxhr_set_stream_state(stream);
+ err = pcxhr_set_stream_state(chip, stream);
}
}
@@ -833,16 +815,16 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
if (err) {
mutex_unlock(&mgr->setup_mutex);
- snd_printk(KERN_ERR "pcxhr_trigger_tasklet : "
+ dev_err(&mgr->pci->dev, "%s : "
"error start pipes (P%x C%x)\n",
- playback_mask, capture_mask);
+ __func__, playback_mask, capture_mask);
return;
}
/* put the streams into the running state now
* (increment pointer by interrupt)
*/
- spin_lock_irqsave(&mgr->lock, flags);
+ mutex_lock(&mgr->lock);
for ( i =0; i < mgr->num_cards; i++) {
struct pcxhr_stream *stream;
chip = mgr->chip[i];
@@ -860,15 +842,15 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
}
}
}
- spin_unlock_irqrestore(&mgr->lock, flags);
+ mutex_unlock(&mgr->lock);
mutex_unlock(&mgr->setup_mutex);
#ifdef CONFIG_SND_DEBUG_VERBOSE
- ktime_get_real_ts64(&end_date);
- delta_t = timespec64_sub(end_date, start_date);
- snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n",
- (long)delta_t.tv_nsec/1000, err);
+ stop_time = ktime_get();
+ diff_time = ktime_sub(stop_time, start_time);
+ dev_dbg(&mgr->pci->dev, "***TRIGGER START*** TIME = %ld (err = %x)\n",
+ (long)(ktime_to_ns(diff_time)), err);
#endif
}
@@ -880,12 +862,12 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
{
struct pcxhr_stream *stream;
struct snd_pcm_substream *s;
+ struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
- snd_printdd("SNDRV_PCM_TRIGGER_START\n");
+ dev_dbg(chip->card->dev, "SNDRV_PCM_TRIGGER_START\n");
if (snd_pcm_stream_linked(subs)) {
- struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
snd_pcm_group_for_each_entry(s, subs) {
if (snd_pcm_substream_chip(s) != chip)
continue;
@@ -894,10 +876,10 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
PCXHR_STREAM_STATUS_SCHEDULE_RUN;
snd_pcm_trigger_done(s, subs);
}
- tasklet_schedule(&chip->mgr->trigger_taskq);
+ pcxhr_start_linked_stream(chip->mgr);
} else {
stream = subs->runtime->private_data;
- snd_printdd("Only one Substream %c %d\n",
+ dev_dbg(chip->card->dev, "Only one Substream %c %d\n",
stream->pipe->is_capture ? 'C' : 'P',
stream->pipe->first_audio);
if (pcxhr_set_format(stream))
@@ -906,17 +888,17 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
return -EINVAL;
stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN;
- if (pcxhr_set_stream_state(stream))
+ if (pcxhr_set_stream_state(chip, stream))
return -EINVAL;
stream->status = PCXHR_STREAM_STATUS_RUNNING;
}
break;
case SNDRV_PCM_TRIGGER_STOP:
- snd_printdd("SNDRV_PCM_TRIGGER_STOP\n");
+ dev_dbg(chip->card->dev, "SNDRV_PCM_TRIGGER_STOP\n");
snd_pcm_group_for_each_entry(s, subs) {
stream = s->runtime->private_data;
stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP;
- if (pcxhr_set_stream_state(stream))
+ if (pcxhr_set_stream_state(chip, stream))
return -EINVAL;
snd_pcm_trigger_done(s, subs);
}
@@ -945,7 +927,7 @@ static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start, unsigned int r
}
err = pcxhr_send_msg(mgr, &rmh);
if (err < 0)
- snd_printk(KERN_ERR "error pcxhr_hardware_timer err(%x)\n",
+ dev_err(&mgr->pci->dev, "error %s err(%x)\n", __func__,
err);
pcxhr_hr_timer_trig(mgr, start, rate);
@@ -962,7 +944,8 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
struct pcxhr_mgr *mgr = chip->mgr;
int err = 0;
- snd_printdd("pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n",
+ dev_dbg(chip->card->dev,
+ "%s : period_size(%lx) periods(%x) buffer_size(%lx)\n", __func__,
subs->runtime->period_size, subs->runtime->periods,
subs->runtime->buffer_size);
@@ -997,32 +980,16 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs,
struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
struct pcxhr_mgr *mgr = chip->mgr;
struct pcxhr_stream *stream = subs->runtime->private_data;
- snd_pcm_format_t format;
- int err;
- int channels;
-
- /* set up channels */
- channels = params_channels(hw);
-
- /* set up format for the stream */
- format = params_format(hw);
mutex_lock(&mgr->setup_mutex);
- stream->channels = channels;
- stream->format = format;
-
- /* allocate buffer */
- err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw));
+ /* set up channels */
+ stream->channels = params_channels(hw);
+ /* set up format for the stream */
+ stream->format = params_format(hw);
mutex_unlock(&mgr->setup_mutex);
- return err;
-}
-
-static int pcxhr_hw_free(struct snd_pcm_substream *subs)
-{
- snd_pcm_lib_free_pages(subs);
return 0;
}
@@ -1030,7 +997,7 @@ static int pcxhr_hw_free(struct snd_pcm_substream *subs)
/*
* CONFIGURATION SPACE for all pcms, mono pcm must update channels_max
*/
-static struct snd_pcm_hardware pcxhr_caps =
+static const struct snd_pcm_hardware pcxhr_caps =
{
.info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_INTERLEAVED |
@@ -1071,12 +1038,12 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
runtime->hw = pcxhr_caps;
if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) {
- snd_printdd("pcxhr_open playback chip%d subs%d\n",
- chip->chip_idx, subs->number);
+ dev_dbg(chip->card->dev, "%s playback chip%d subs%d\n",
+ __func__, chip->chip_idx, subs->number);
stream = &chip->playback_stream[subs->number];
} else {
- snd_printdd("pcxhr_open capture chip%d subs%d\n",
- chip->chip_idx, subs->number);
+ dev_dbg(chip->card->dev, "%s capture chip%d subs%d\n",
+ __func__, chip->chip_idx, subs->number);
if (mgr->mono_capture)
runtime->hw.channels_max = 1;
else
@@ -1085,8 +1052,8 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
}
if (stream->status != PCXHR_STREAM_STATUS_FREE){
/* streams in use */
- snd_printk(KERN_ERR "pcxhr_open chip%d subs%d in use\n",
- chip->chip_idx, subs->number);
+ dev_err(chip->card->dev, "%s chip%d subs%d in use\n",
+ __func__, chip->chip_idx, subs->number);
mutex_unlock(&mgr->setup_mutex);
return -EBUSY;
}
@@ -1151,7 +1118,7 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
mutex_lock(&mgr->setup_mutex);
- snd_printdd("pcxhr_close chip%d subs%d\n",
+ dev_dbg(chip->card->dev, "%s chip%d subs%d\n", __func__,
chip->chip_idx, subs->number);
/* sample rate released */
@@ -1171,33 +1138,30 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
static snd_pcm_uframes_t pcxhr_stream_pointer(struct snd_pcm_substream *subs)
{
- unsigned long flags;
u_int32_t timer_period_frag;
int timer_buf_periods;
struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
struct snd_pcm_runtime *runtime = subs->runtime;
struct pcxhr_stream *stream = runtime->private_data;
- spin_lock_irqsave(&chip->mgr->lock, flags);
+ mutex_lock(&chip->mgr->lock);
/* get the period fragment and the nb of periods in the buffer */
timer_period_frag = stream->timer_period_frag;
timer_buf_periods = stream->timer_buf_periods;
- spin_unlock_irqrestore(&chip->mgr->lock, flags);
+ mutex_unlock(&chip->mgr->lock);
return (snd_pcm_uframes_t)((timer_buf_periods * runtime->period_size) +
timer_period_frag);
}
-static struct snd_pcm_ops pcxhr_ops = {
+static const struct snd_pcm_ops pcxhr_ops = {
.open = pcxhr_open,
.close = pcxhr_close,
- .ioctl = snd_pcm_lib_ioctl,
.prepare = pcxhr_prepare,
.hw_params = pcxhr_hw_params,
- .hw_free = pcxhr_hw_free,
.trigger = pcxhr_trigger,
.pointer = pcxhr_stream_pointer,
};
@@ -1210,11 +1174,12 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip)
struct snd_pcm *pcm;
char name[32];
- sprintf(name, "pcxhr %d", chip->chip_idx);
- if ((err = snd_pcm_new(chip->card, name, 0,
- chip->nb_streams_play,
- chip->nb_streams_capt, &pcm)) < 0) {
- snd_printk(KERN_ERR "cannot create pcm %s\n", name);
+ snprintf(name, sizeof(name), "pcxhr %d", chip->chip_idx);
+ err = snd_pcm_new(chip->card, name, 0,
+ chip->nb_streams_play,
+ chip->nb_streams_capt, &pcm);
+ if (err < 0) {
+ dev_err(chip->card->dev, "cannot create pcm %s\n", name);
return err;
}
pcm->private_data = chip;
@@ -1225,11 +1190,12 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcxhr_ops);
pcm->info_flags = 0;
+ pcm->nonatomic = true;
strcpy(pcm->name, name);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
- snd_dma_pci_data(chip->mgr->pci),
- 32*1024, 32*1024);
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
+ &chip->mgr->pci->dev,
+ 32*1024, 32*1024);
chip->pcm = pcm;
return 0;
}
@@ -1254,19 +1220,18 @@ static int pcxhr_create(struct pcxhr_mgr *mgr,
{
int err;
struct snd_pcxhr *chip;
- static struct snd_device_ops ops = {
+ static const struct snd_device_ops ops = {
.dev_free = pcxhr_chip_dev_free,
};
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
- if (! chip) {
- snd_printk(KERN_ERR "cannot allocate chip\n");
+ if (!chip)
return -ENOMEM;
- }
chip->card = card;
chip->chip_idx = idx;
chip->mgr = mgr;
+ card->sync_irq = mgr->irq;
if (idx < mgr->playback_chips)
/* stereo or mono streams */
@@ -1279,13 +1244,13 @@ static int pcxhr_create(struct pcxhr_mgr *mgr,
chip->nb_streams_capt = 1; /* or 1 stereo stream */
}
- if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+ err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+ if (err < 0) {
pcxhr_chip_free(chip);
return err;
}
mgr->chip[idx] = chip;
- snd_card_set_dev(card, &mgr->pci->dev);
return 0;
}
@@ -1297,7 +1262,8 @@ static void pcxhr_proc_info(struct snd_info_entry *entry,
struct snd_pcxhr *chip = entry->private_data;
struct pcxhr_mgr *mgr = chip->mgr;
int i = 0;
- snd_iprintf(buffer, "\n%s\n", mgr->longname);
+
+ snd_iprintf(buffer, "\n%s\n", mgr->name);
/* stats available when embedded DSP is running */
if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) {
@@ -1447,7 +1413,7 @@ static void pcxhr_proc_sync(struct snd_info_entry *entry,
max_clock = PCXHR_CLOCK_TYPE_MAX;
}
- snd_iprintf(buffer, "\n%s\n", mgr->longname);
+ snd_iprintf(buffer, "\n%s\n", mgr->name);
snd_iprintf(buffer, "Current Sample Clock\t: %s\n",
texts[mgr->cur_clock_type]);
snd_iprintf(buffer, "Current Sample Rate\t= %d\n",
@@ -1564,21 +1530,14 @@ static void pcxhr_proc_ltc(struct snd_info_entry *entry,
static void pcxhr_proc_init(struct snd_pcxhr *chip)
{
- struct snd_info_entry *entry;
-
- if (! snd_card_proc_new(chip->card, "info", &entry))
- snd_info_set_text_ops(entry, chip, pcxhr_proc_info);
- if (! snd_card_proc_new(chip->card, "sync", &entry))
- snd_info_set_text_ops(entry, chip, pcxhr_proc_sync);
+ snd_card_ro_proc_new(chip->card, "info", chip, pcxhr_proc_info);
+ snd_card_ro_proc_new(chip->card, "sync", chip, pcxhr_proc_sync);
/* gpio available on stereo sound cards only */
- if (chip->mgr->is_hr_stereo &&
- !snd_card_proc_new(chip->card, "gpio", &entry)) {
- snd_info_set_text_ops(entry, chip, pcxhr_proc_gpio_read);
- entry->c.text.write = pcxhr_proc_gpo_write;
- entry->mode |= S_IWUSR;
- }
- if (!snd_card_proc_new(chip->card, "ltc", &entry))
- snd_info_set_text_ops(entry, chip, pcxhr_proc_ltc);
+ if (chip->mgr->is_hr_stereo)
+ snd_card_rw_proc_new(chip->card, "gpio", chip,
+ pcxhr_proc_gpio_read,
+ pcxhr_proc_gpo_write);
+ snd_card_ro_proc_new(chip->card, "ltc", chip, pcxhr_proc_ltc);
}
/* end of proc interface */
@@ -1597,7 +1556,7 @@ static int pcxhr_free(struct pcxhr_mgr *mgr)
/* reset board if some firmware was loaded */
if(mgr->dsp_loaded) {
pcxhr_reset_board(mgr);
- snd_printdd("reset pcxhr !\n");
+ dev_dbg(&mgr->pci->dev, "reset pcxhr !\n");
}
pcxhr_hr_timer_kill(mgr);
@@ -1621,7 +1580,6 @@ static int pcxhr_free(struct pcxhr_mgr *mgr)
return 0;
}
-
/*
* probe function - creates the card manager
*/
@@ -1645,14 +1603,15 @@ static int pcxhr_probe(struct pci_dev *pci,
}
/* enable PCI device */
- if ((err = pci_enable_device(pci)) < 0)
+ err = pci_enable_device(pci);
+ if (err < 0)
return err;
pci_set_master(pci);
/* check if we can restrict PCI DMA transfers to 32 bits */
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
- snd_printk(KERN_ERR "architecture does not support "
- "32bit PCI busmaster DMA\n");
+ dev_err(&pci->dev,
+ "architecture does not support 32bit PCI busmaster DMA\n");
pci_disable_device(pci);
return -ENXIO;
}
@@ -1674,17 +1633,17 @@ static int pcxhr_probe(struct pci_dev *pci,
if (pcxhr_is_device_IE (pci->subsystem_device, PCXHR_DEVICE_IE5_ID))
{
mgr->board_revision = PCXHR_BOARD_REVISION_5;
- snd_printk(KERN_INFO"%s(): probed IE5 board\n", __FUNCTION__);
+ dev_info(&pci->dev, "%s(): probed IE5 board\n", __FUNCTION__);
}
else if (pcxhr_is_device_IE (pci->subsystem_device, PCXHR_DEVICE_IE7_ID))
{
mgr->board_revision = PCXHR_BOARD_REVISION_7;
- snd_printk(KERN_INFO"%s(): probed IE7 board\n", __FUNCTION__);
+ dev_info(&pci->dev, "%s(): probed IE7 board\n", __FUNCTION__);
}
else
{
mgr->board_revision= PCXHR_BOARD_REVISION_BEFORE_5;
- snd_printk(KERN_INFO"%s(): probed pre-IE5 board\n", __FUNCTION__);
+ dev_info(&pci->dev, "%s(): probed pre-IE5 board\n", __FUNCTION__);
}
//Select the right registers' addresses offset
@@ -1711,7 +1670,8 @@ static int pcxhr_probe(struct pci_dev *pci,
mgr->granularity = PCXHR_GRANULARITY;
/* resource assignment */
- if ((err = pci_request_regions(pci, card_name)) < 0) {
+ err = pci_request_regions(pci, card_name);
+ if (err < 0) {
kfree(mgr);
pci_disable_device(pci);
return err;
@@ -1738,33 +1698,27 @@ static int pcxhr_probe(struct pci_dev *pci,
// printk(KERN_ERR "%s MSI = %d\n", __func__, msi);
- if (request_irq(pci->irq, pcxhr_interrupt, IRQF_SHARED,
- KBUILD_MODNAME, mgr)) {
- snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+ if (request_threaded_irq(pci->irq, pcxhr_interrupt,
+ pcxhr_threaded_irq, IRQF_SHARED,
+ KBUILD_MODNAME, mgr)) {
+ dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq);
pcxhr_free(mgr);
return -EBUSY;
}
mgr->irq = pci->irq;
- sprintf(mgr->shortname, "Digigram %s", card_name);
- sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, 0x%lx irq %i",
- mgr->shortname,
- mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq);
+ snprintf(mgr->name, sizeof(mgr->name),
+ "Digigram at 0x%lx & 0x%lx, 0x%lx irq %i",
+ mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq);
- /* ISR spinlock */
- spin_lock_init(&mgr->lock);
- spin_lock_init(&mgr->msg_lock);
+ /* ISR lock */
+ mutex_init(&mgr->lock);
+ mutex_init(&mgr->msg_lock);
/* init setup mutex*/
mutex_init(&mgr->setup_mutex);
- /* init taslket */
- tasklet_init(&mgr->msg_taskq, pcxhr_msg_tasklet,
- (unsigned long) mgr);
- tasklet_init(&mgr->trigger_taskq, pcxhr_trigger_tasklet,
- (unsigned long) mgr);
-
- mgr->prmh = kmalloc(sizeof(*mgr->prmh) +
+ mgr->prmh = kmalloc(sizeof(*mgr->prmh) +
sizeof(u32) * (PCXHR_SIZE_MAX_LONG_STATUS -
PCXHR_SIZE_MAX_STATUS),
GFP_KERNEL);
@@ -1789,28 +1743,23 @@ static int pcxhr_probe(struct pci_dev *pci,
snprintf(tmpid, sizeof(tmpid), "%s-%d",
id[dev] ? id[dev] : card_name, i);
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
- snd_printk(KERN_ERR "kernel not supported\n");
- err = -1;
-#elif HAVE_SND_CARD_NEW
- err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
- 0, &card);
-#else
- err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card);
-#endif
+ err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
+ 0, &card);
if (err < 0) {
- snd_printk(KERN_ERR "cannot allocate the card %d\n", i);
+ dev_err(&pci->dev, "cannot allocate the card %d\n", i);
pcxhr_free(mgr);
return err;
}
strcpy(card->driver, DRIVER_NAME);
- sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i);
- sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
+ snprintf(card->shortname, sizeof(card->shortname),
+ "Digigram [PCM #%d]", i);
+ snprintf(card->longname, sizeof(card->longname),
+ "%s [PCM #%d]", mgr->name, i);
- if ((err = pcxhr_create(mgr, card, i)) < 0) {
+ err = pcxhr_create(mgr, card, i);
+ if (err < 0) {
snd_card_free(card);
pcxhr_free(mgr);
return err;
@@ -1820,7 +1769,8 @@ static int pcxhr_probe(struct pci_dev *pci,
/* init proc interface only for chip0 */
pcxhr_proc_init(mgr->chip[i]);
- if ((err = snd_card_register(card)) < 0) {
+ err = snd_card_register(card);
+ if (err < 0) {
pcxhr_free(mgr);
return err;
}
@@ -1828,7 +1778,7 @@ static int pcxhr_probe(struct pci_dev *pci,
/* create hostport purgebuffer */
size = PAGE_ALIGN(sizeof(struct pcxhr_hostport));
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
size, &mgr->hostport) < 0) {
pcxhr_free(mgr);
return -ENOMEM;
@@ -1851,7 +1801,6 @@ static int pcxhr_probe(struct pci_dev *pci,
static void pcxhr_remove(struct pci_dev *pci)
{
pcxhr_free(pci_get_drvdata(pci));
- pci_set_drvdata(pci, NULL);
}
static struct pci_driver pcxhr_driver = {
diff --git a/snd-pcxhr-dkms/src/pcxhr.h b/snd-pcxhr-dkms/src/pcxhr.h
index d559471..bd7c40d 100644
--- a/snd-pcxhr-dkms/src/pcxhr.h
+++ b/snd-pcxhr-dkms/src/pcxhr.h
@@ -1,23 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Driver for Digigram pcxhr soundcards
*
* main header file
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_H
@@ -29,7 +16,7 @@
#include "pcxhr_hrtimer.h"
/* Driver version : 2.0.13 */
-#define PCXHR_DRIVER_VERSION 0x020013
+#define PCXHR_DRIVER_VERSION 0x020013
#define PCXHR_DRIVER_VERSION_STRING "2.0.13"
/* Workaround for CentOS/RHEL */
@@ -104,17 +91,12 @@ struct pcxhr_mgr {
unsigned long dsp_reg_offset;
/* share the name */
- char shortname[32]; /* short name of this soundcard */
- char longname[96]; /* name of this soundcard */
+ char name[40]; /* name of this soundcard */
- /* message tasklet */
- struct tasklet_struct msg_taskq;
struct pcxhr_rmh *prmh;
- /* trigger tasklet */
- struct tasklet_struct trigger_taskq;
- spinlock_t lock; /* interrupt spinlock */
- spinlock_t msg_lock; /* message spinlock */
+ struct mutex lock; /* interrupt lock */
+ struct mutex msg_lock; /* message lock */
struct mutex setup_mutex; /* mutex used in hw_params, open and close */
struct mutex mixer_mutex; /* mutex for mixer */
diff --git a/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.c b/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.c
index 2be208d..74043c0 100644
--- a/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.c
+++ b/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.c
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -47,7 +34,7 @@ void clock_monitoring_treatment(struct pcxhr_mgr *mgr) {
if( mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL ) { //on est cencé être sur de l AES
pcxhr_get_external_clock(mgr,mgr->use_clock_type,&rate);
if( rate == 0 ) {
- snd_printk(KERN_ERR "\tpcxhr_clock_monitoring_tasklet external clock disappears...\n");
+ dev_err(&mgr->pci->dev, "\tpcxhr_clock_monitoring_tasklet external clock disappears...\n");
mgr->expected_clock_type = mgr->use_clock_type;
mgr->use_clock_type = PCXHR_CLOCK_TYPE_INTERNAL;
pcxhr_set_clock(mgr, mgr->sample_rate_real);
@@ -56,14 +43,14 @@ void clock_monitoring_treatment(struct pcxhr_mgr *mgr) {
else { //on est déjà sur l horloge interne on test si l aes est de retour
pcxhr_get_external_clock(mgr,mgr->expected_clock_type,&rate);
if( rate != 0) {
- snd_printk(KERN_ERR "\tpcxhr_clock_monitoring_tasklet external clock reappears...\n");
+ dev_err(&mgr->pci->dev, "\tpcxhr_clock_monitoring_tasklet external clock reappears...\n");
mgr->use_clock_type = mgr->expected_clock_type;
pcxhr_set_clock(mgr, rate);
}
}
mutex_unlock(&mgr->timer_mutex);
}else {
- snd_printk(KERN_ERR "\tclock_monitoring_treatment mgr pointer null\n");
+ dev_err(&mgr->pci->dev, "\tclock_monitoring_treatment mgr pointer null\n");
}
}
@@ -74,10 +61,9 @@ int clock_monitoring_thread(void *ptr) {
while (1){
set_current_state(TASK_INTERRUPTIBLE);
schedule();
- //snd_printk(KERN_ERR "+");
clock_monitoring_treatment(mgr);
}
- snd_printk(KERN_INFO "clock_monitoring_thread on sort\n");
+ dev_info(&mgr->pci->dev, "clock_monitoring_thread on sort\n");
return 0;
}
@@ -87,7 +73,7 @@ int clock_monitoring_thread_init(struct pcxhr_mgr *mgr) {
mgr->thread = kthread_create(clock_monitoring_thread,mgr,our_thread);
if(mgr->thread == NULL) {
- snd_printk(KERN_ERR "clock_monitoring_thread_init kthread_create FAILED\n");
+ dev_err(&mgr->pci->dev, "clock_monitoring_thread_init kthread_create FAILED\n");
return -ENOMEM;
}
wake_up_process(mgr->thread);
@@ -106,7 +92,7 @@ static void clockMonitor_timedout(unsigned long ptr) {
}
if(mgr->timer_state == 0) {
- snd_printk(KERN_INFO "\tclockMonitor_timedout timer should stop do not reload it\n");
+ dev_info(&mgr->pci->dev, "\tclockMonitor_timedout timer should stop do not reload it\n");
}
}
@@ -115,7 +101,7 @@ int clockMonitor_stop(struct pcxhr_mgr *mgr){
int result = 0;
mutex_lock(&mgr->timer_mutex);
- snd_printk(KERN_INFO " clockMonitor_stop %s\n", mgr->shortname);
+ dev_info(&mgr->pci->dev, " clockMonitor_stop %s\n", mgr->shortname);
if((mgr->clockMonitor_timer != NULL)&& (mgr->timer_state == 1)) {
// result = del_timer(mgr->clockMonitor_timer);
result = del_timer_sync(mgr->clockMonitor_timer);
@@ -128,7 +114,7 @@ int clockMonitor_stop(struct pcxhr_mgr *mgr){
int clockMonitor_start(struct pcxhr_mgr *mgr){
mutex_lock(&mgr->timer_mutex);
if(mgr->timer_state == 0) { //déjà était démarré...
- snd_printk(KERN_INFO "clockMonitor_start %s\n", mgr->shortname);
+ dev_info(&mgr->pci->dev, "clockMonitor_start %s\n", mgr->shortname);
init_timer(mgr->clockMonitor_timer);
mgr->clockMonitor_timer->function = clockMonitor_timedout;
@@ -143,13 +129,13 @@ int clockMonitor_start(struct pcxhr_mgr *mgr){
int clockMonitor_init(struct pcxhr_mgr *mgr){
- snd_printk(KERN_INFO "clockMonitor_init %s\n", mgr->shortname);
+ dev_info(&mgr->pci->dev, "clockMonitor_init %s\n", mgr->shortname);
mutex_init(&mgr->timer_mutex);
mgr->clockMonitor_timer = (struct timer_list*) kmalloc(sizeof(struct timer_list), GFP_KERNEL);
if(mgr->clockMonitor_timer == NULL){
- snd_printk(KERN_INFO "clockMonitor_init failed mgr->clockMonitor_timer NULL\n");
+ dev_info(&mgr->pci->dev, "clockMonitor_init failed mgr->clockMonitor_timer NULL\n");
return -ENOMEM;
}
//init_timer(mgr->clockMonitor_timer);
@@ -160,7 +146,7 @@ int clockMonitor_init(struct pcxhr_mgr *mgr){
}
int clockMonitor_free(struct pcxhr_mgr *mgr){
- snd_printk(KERN_INFO "clockMonitor_free %s\n", mgr->shortname);
+ dev_info(&mgr->pci->dev, "clockMonitor_free %s\n", mgr->shortname);
if (mgr->clockMonitor_timer != NULL)
{
diff --git a/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.h b/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.h
index 89bc542..9825f9d 100644
--- a/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.h
+++ b/snd-pcxhr-dkms/src/pcxhr_clock_monitoring.h
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
diff --git a/snd-pcxhr-dkms/src/pcxhr_core.c b/snd-pcxhr-dkms/src/pcxhr_core.c
index 7ef9b6d..020088b 100644
--- a/snd-pcxhr-dkms/src/pcxhr_core.c
+++ b/snd-pcxhr-dkms/src/pcxhr_core.c
@@ -1,30 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* low level interface with interrupt and message handling implementation
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
-#include <asm/io.h>
+#include <linux/io.h>
#include <sound/core.h>
#include "pcxhr.h"
#include "pcxhr_mixer.h"
@@ -89,14 +76,14 @@ static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int bar, unsigned
*read = PCXHR_INPB(mgr, bar, reg);
if ((*read & mask) == bit) {
if (i > 100)
- snd_printdd("ATTENTION! check_reg(%x) "
- "loopcount=%d\n",
+ dev_dbg(&mgr->pci->dev,
+ "ATTENTION! check_reg(%x) loopcount=%d\n",
reg, i);
return 0;
}
i++;
} while (time_after_eq(end_time, jiffies));
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"pcxhr_check_reg_bit: timeout, bar=%x reg=%x, mask=0x%x, val=%x\n",
bar, reg, mask, *read);
return -EIO;
@@ -173,7 +160,7 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr,
err = pcxhr_check_reg_bit(mgr, PCXHR_DSP, PCXHR_DSP_CVR, PCXHR_CVR_HI08_HC, 0,
PCXHR_TIMEOUT_DSP, &reg);
if (err) {
- snd_printk(KERN_ERR "pcxhr_send_it_dsp : TIMEOUT CVR\n");
+ dev_err(&mgr->pci->dev, "pcxhr_send_it_dsp : TIMEOUT CVR\n");
return err;
}
if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) {
@@ -184,7 +171,7 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr,
PCXHR_TIMEOUT_DSP,
&reg);
if (err) {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"pcxhr_send_it_dsp : TIMEOUT HF5\n");
return err;
}
@@ -265,7 +252,7 @@ int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr,
*/
if(second) {
if ((chipsc & PCXHR_CHIPSC_GPI_USERI) == 0) {
- snd_printk(KERN_ERR "error loading first xilinx\n");
+ dev_err(&mgr->pci->dev, "error loading first xilinx\n");
return -EINVAL;
}
/* activate second xilinx */
@@ -331,7 +318,7 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp)
PCXHR_ISR_HI08_TRDY,
PCXHR_TIMEOUT_DSP, &dummy);
if (err) {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"dsp loading error at position %d\n", i);
return err;
}
@@ -367,7 +354,7 @@ int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr,
msleep(PCXHR_WAIT_DEFAULT);
PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_DSP_ICR, reg);
msleep(PCXHR_WAIT_DEFAULT);
- snd_printdd("no need to load eeprom boot\n");
+ dev_dbg(&mgr->pci->dev, "no need to load eeprom boot\n");
return 0;
}
PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_DSP_ICR, reg);
@@ -449,7 +436,7 @@ enum {
/*
* Array of DSP commands
*/
-static struct pcxhr_cmd_info pcxhr_dsp_cmds[] = {
+static const struct pcxhr_cmd_info pcxhr_dsp_cmds[] = {
[CMD_VERSION] = { 0x010000, 1, RMH_SSIZE_FIXED },
[CMD_SUPPORTED] = { 0x020000, 4, RMH_SSIZE_FIXED },
[CMD_TEST_IT] = { 0x040000, 1, RMH_SSIZE_FIXED },
@@ -480,7 +467,7 @@ static struct pcxhr_cmd_info pcxhr_dsp_cmds[] = {
};
#ifdef CONFIG_SND_DEBUG_VERBOSE
-static char* cmd_names[] = {
+static const char * const cmd_names[] = {
[CMD_VERSION] = "CMD_VERSION",
[CMD_SUPPORTED] = "CMD_SUPPORTED",
[CMD_TEST_IT] = "CMD_TEST_IT",
@@ -532,9 +519,9 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
PCXHR_ISR_HI08_RXDF,
PCXHR_TIMEOUT_DSP, &reg);
if (err) {
- snd_printk(KERN_ERR "ERROR RMH stat: "
- "ISR:RXDF=1 (ISR = %x; i=%d )\n",
- reg, i);
+ dev_err(&mgr->pci->dev,
+ "ERROR RMH stat: ISR:RXDF=1 (ISR = %x; i=%d )\n",
+ reg, i);
return err;
}
/* read data */
@@ -562,13 +549,13 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
}
#ifdef CONFIG_SND_DEBUG_VERBOSE
if (rmh->cmd_idx < CMD_LAST_INDEX)
- snd_printdd(" stat[%d]=%x\n", i, data);
+ dev_dbg(&mgr->pci->dev, " stat[%d]=%x\n", i, data);
#endif
if (i < max_stat_len)
rmh->stat[i] = data;
}
if (rmh->stat_len > max_stat_len) {
- snd_printdd("PCXHR : rmh->stat_len=%x too big\n",
+ dev_dbg(&mgr->pci->dev, "PCXHR : rmh->stat_len=%x too big\n",
rmh->stat_len);
rmh->stat_len = max_stat_len;
}
@@ -586,7 +573,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
return -EINVAL;
err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1);
if (err) {
- snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n");
+ dev_err(&mgr->pci->dev,
+ "pcxhr_send_message : ED_DSP_CRASHED\n");
return err;
}
/* wait for chk bit */
@@ -612,7 +600,7 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
data &= 0xff7fff; /* MASK_1_WORD_COMMAND */
#ifdef CONFIG_SND_DEBUG_VERBOSE
if (rmh->cmd_idx < CMD_LAST_INDEX)
- snd_printdd("MSG cmd[0]=%x (%s)\n",
+ dev_dbg(&mgr->pci->dev, "MSG cmd[0]=%x (%s)\n",
data, cmd_names[rmh->cmd_idx]);
#endif
@@ -642,7 +630,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
data = rmh->cmd[i];
#ifdef CONFIG_SND_DEBUG_VERBOSE
if (rmh->cmd_idx < CMD_LAST_INDEX)
- snd_printdd(" cmd[%d]=%x\n", i, data);
+ dev_dbg(&mgr->pci->dev,
+ " cmd[%d]=%x\n", i, data);
#endif
err = pcxhr_check_reg_bit(mgr, PCXHR_DSP, PCXHR_DSP_ISR,
PCXHR_ISR_HI08_TRDY,
@@ -668,14 +657,15 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
PCXHR_ISR_HI08_RXDF,
PCXHR_TIMEOUT_DSP, &reg);
if (err) {
- snd_printk(KERN_ERR "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg);
+ dev_err(&mgr->pci->dev,
+ "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg);
return err;
}
/* read error code */
data = PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_DSP_TXH) << 16;
data |= PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_DSP_TXM) << 8;
data |= PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_DSP_TXL);
- snd_printk(KERN_ERR "ERROR RMH(%d): 0x%x\n",
+ dev_err(&mgr->pci->dev, "ERROR RMH(%d): 0x%x\n",
rmh->cmd_idx, data);
err = -EINVAL;
} else {
@@ -734,11 +724,11 @@ void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh *rmh, int capture,
*/
int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
{
- unsigned long flags;
int err;
- spin_lock_irqsave(&mgr->msg_lock, flags);
+
+ mutex_lock(&mgr->msg_lock);
err = pcxhr_send_msg_nolock(mgr, rmh);
- spin_unlock_irqrestore(&mgr->msg_lock, flags);
+ mutex_unlock(&mgr->msg_lock);
return err;
}
@@ -751,7 +741,7 @@ static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr)
* (PCXHR_PIPE_STATE_CAPTURE_OFFSET)
*/
start_mask &= 0x00ffffff;
- snd_printdd("CMD_PIPE_STATE MBOX2=0x%06x\n", start_mask);
+ dev_dbg(&mgr->pci->dev, "CMD_PIPE_STATE MBOX2=0x%06x\n", start_mask);
return start_mask;
}
@@ -780,7 +770,7 @@ static int pcxhr_prepair_pipe_start(struct pcxhr_mgr *mgr,
}
err = pcxhr_send_msg(mgr, &rmh);
if (err) {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"error pipe start "
"(CMD_CAN_START_PIPE) err=%x!\n",
err);
@@ -818,7 +808,7 @@ static int pcxhr_stop_pipes(struct pcxhr_mgr *mgr, int audio_mask)
}
err = pcxhr_send_msg(mgr, &rmh);
if (err) {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"error pipe stop "
"(CMD_STOP_PIPE) err=%x!\n", err);
return err;
@@ -847,7 +837,7 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask)
1 << (audio - PCXHR_PIPE_STATE_CAPTURE_OFFSET));
err = pcxhr_send_msg(mgr, &rmh);
if (err) {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"error pipe start "
"(CMD_CONF_PIPE) err=%x!\n", err);
return err;
@@ -860,7 +850,7 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask)
pcxhr_init_rmh(&rmh, CMD_SEND_IRQA);
err = pcxhr_send_msg(mgr, &rmh);
if (err) {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"error pipe start (CMD_SEND_IRQA) err=%x!\n",
err);
return err;
@@ -877,15 +867,16 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
int audio_mask;
#ifdef CONFIG_SND_DEBUG_VERBOSE
- struct timespec64 start_date, end_date, delta_t;
- ktime_get_real_ts64(&start_date);
+ ktime_t start_time, stop_time, diff_time;
+
+ start_time = ktime_get();
#endif
-
audio_mask = (playback_mask |
(capture_mask << PCXHR_PIPE_STATE_CAPTURE_OFFSET));
/* current pipe state (playback + record) */
state = pcxhr_pipes_running(mgr);
- snd_printdd("pcxhr_set_pipe_state %s (mask %x current %x)\n",
+ dev_dbg(&mgr->pci->dev,
+ "pcxhr_set_pipe_state %s (mask %x current %x)\n",
start ? "START" : "STOP", audio_mask, state);
if (start) {
/* start only pipes that are not yet started */
@@ -916,7 +907,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
if ((state & audio_mask) == (start ? audio_mask : 0))
break;
if (++i >= MAX_WAIT_FOR_DSP * 100) {
- snd_printk(KERN_ERR "error pipe start/stop\n");
+ dev_err(&mgr->pci->dev, "error pipe start/stop\n");
return -EBUSY;
}
udelay(10); /* wait 10 microseconds */
@@ -927,10 +918,10 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
return err;
}
#ifdef CONFIG_SND_DEBUG_VERBOSE
- ktime_get_real_ts64(&end_date);
- delta_t = timespec64_sub(end_date, start_date);
- snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n",
- (long)delta_t.tv_nsec/1000, err);
+ stop_time = ktime_get();
+ diff_time = ktime_sub(stop_time, start_time);
+ dev_dbg(&mgr->pci->dev, "***SET PIPE STATE*** TIME = %ld (err = %x)\n",
+ (long)(ktime_to_ns(diff_time)), err);
#endif
return 0;
}
@@ -939,16 +930,16 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
unsigned int value, int *changed)
{
struct pcxhr_rmh rmh;
- unsigned long flags;
int err;
- spin_lock_irqsave(&mgr->msg_lock, flags);
+ mutex_lock(&mgr->msg_lock);
if ((mgr->io_num_reg_cont & mask) == value) {
- snd_printdd("IO_NUM_REG_CONT mask %x already is set to %x\n",
+ dev_dbg(&mgr->pci->dev,
+ "IO_NUM_REG_CONT mask %x already is set to %x\n",
mask, value);
if (changed)
*changed = 0;
- spin_unlock_irqrestore(&mgr->msg_lock, flags);
+ mutex_unlock(&mgr->msg_lock);
return 0; /* already programmed */
}
pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE);
@@ -963,7 +954,7 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
if (changed)
*changed = 1;
}
- spin_unlock_irqrestore(&mgr->msg_lock, flags);
+ mutex_unlock(&mgr->msg_lock);
return err;
}
@@ -985,7 +976,7 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err,
enum pcxhr_async_err_src err_src, int pipe,
int is_capture)
{
- static char* err_src_name[] = {
+ static const char * const err_src_name[] = {
[PCXHR_ERR_PIPE] = "Pipe",
[PCXHR_ERR_STREAM] = "Stream",
[PCXHR_ERR_AUDIO] = "Audio"
@@ -997,7 +988,7 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err,
err = ((err >> 12) & 0xfff);
if (!err)
return 0;
- snd_printdd("CMD_ASYNC : Error %s %s Pipe %d err=%x\n",
+ dev_dbg(&mgr->pci->dev, "CMD_ASYNC : Error %s %s Pipe %d err=%x\n",
err_src_name[err_src],
is_capture ? "Record" : "Play", pipe, err);
if (err == 0xe01)
@@ -1010,28 +1001,31 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err,
}
-void pcxhr_msg_tasklet(unsigned long arg)
+static void pcxhr_msg_thread(struct pcxhr_mgr *mgr)
{
- struct pcxhr_mgr *mgr = (struct pcxhr_mgr *)(arg);
struct pcxhr_rmh *prmh = mgr->prmh;
int err;
int i, j;
if (mgr->src_it_dsp & PCXHR_IRQ_FREQ_CHANGE)
-// printk(KERN_WARNING "TASKLET : PCXHR_IRQ_FREQ_CHANGE event occurred\n");
+ dev_dbg(&mgr->pci->dev,
+ "PCXHR_IRQ_FREQ_CHANGE event occurred\n");
if (mgr->src_it_dsp & PCXHR_IRQ_TIME_CODE)
-// printk(KERN_WARNING "TASKLET : PCXHR_IRQ_TIME_CODE event occurred\n");
+ dev_dbg(&mgr->pci->dev,
+ "PCXHR_IRQ_TIME_CODE event occurred\n");
if (mgr->src_it_dsp & PCXHR_IRQ_NOTIFY)
-// printk(KERN_WARNING "TASKLET : PCXHR_IRQ_NOTIFY event occurred\n");
+ dev_dbg(&mgr->pci->dev,
+ "PCXHR_IRQ_NOTIFY event occurred\n");
if (mgr->src_it_dsp & (PCXHR_IRQ_FREQ_CHANGE | PCXHR_IRQ_TIME_CODE)) {
/* clear events FREQ_CHANGE and TIME_CODE */
pcxhr_init_rmh(prmh, CMD_TEST_IT);
err = pcxhr_send_msg(mgr, prmh);
-// printk(KERN_ERR "CMD_TEST_IT : err=%x, stat=%x\n",
-// err, prmh->stat[0]);
+ dev_dbg(&mgr->pci->dev, "CMD_TEST_IT : err=%x, stat=%x\n",
+ err, prmh->stat[0]);
}
if (mgr->src_it_dsp & PCXHR_IRQ_ASYNC) {
- printk(KERN_ERR "TASKLET : PCXHR_IRQ_ASYNC event occurred\n");
+ dev_dbg(&mgr->pci->dev,
+ "PCXHR_IRQ_ASYNC event occurred\n");
pcxhr_init_rmh(prmh, CMD_ASYNC);
prmh->cmd[0] |= 1; /* add SEL_ASYNC_EVENTS */
@@ -1039,7 +1033,7 @@ void pcxhr_msg_tasklet(unsigned long arg)
prmh->stat_len = PCXHR_SIZE_MAX_LONG_STATUS;
err = pcxhr_send_msg(mgr, prmh);
if (err)
- snd_printk(KERN_ERR "ERROR pcxhr_msg_tasklet=%x;\n",
+ dev_err(&mgr->pci->dev, "ERROR pcxhr_msg_thread=%x;\n",
err);
i = 1;
while (i < prmh->stat_len) {
@@ -1052,7 +1046,8 @@ void pcxhr_msg_tasklet(unsigned long arg)
u32 err2;
if (prmh->stat[i] & 0x800000) { /* if BIT_END */
- printk(KERN_WARNING "TASKLET : End%sPipe %d\n",
+ dev_dbg(&mgr->pci->dev,
+ "TASKLET : End%sPipe %d\n",
is_capture ? "Record" : "Play",
pipe);
}
@@ -1109,7 +1104,8 @@ static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr,
hw_sample_count = ((u_int64_t)rmh.stat[0]) << 24;
hw_sample_count += (u_int64_t)rmh.stat[1];
- snd_printdd("stream %c%d : abs samples real(%llu) timer(%llu)\n",
+ dev_dbg(&mgr->pci->dev,
+ "stream %c%d : abs samples real(%llu) timer(%llu)\n",
stream->pipe->is_capture ? 'C' : 'P',
stream->substream->number,
hw_sample_count,
@@ -1120,7 +1116,7 @@ static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr,
static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr,
struct pcxhr_stream *stream,
- int samples_to_add, unsigned long flags)
+ int samples_to_add)
{
if (stream->substream &&
(stream->status == PCXHR_STREAM_STATUS_RUNNING)) {
@@ -1175,15 +1171,15 @@ static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr,
(u_int32_t)(new_sample_count -
stream->timer_abs_periods);
} else {
- snd_printk(KERN_ERR
+ dev_err(&mgr->pci->dev,
"ERROR new_sample_count too small ??? %ld\n",
(long unsigned int)new_sample_count);
}
if (elapsed) {
- spin_unlock_irqrestore(&mgr->lock, flags);
+ mutex_unlock(&mgr->lock);
snd_pcm_period_elapsed(stream->substream);
- spin_lock_irqsave(&mgr->lock, flags);
+ mutex_lock(&mgr->lock);
}
}
}
@@ -1191,11 +1187,9 @@ static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr,
irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
{
struct pcxhr_mgr *mgr = dev_id;
- unsigned long flags;
unsigned int reg = 0;
unsigned int tmp;
- int i, j;
- struct snd_pcxhr *chip;
+ bool wake_thread = false;
mgr->dbg_cpt.interrupts_all++;
@@ -1208,15 +1202,11 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
//*************************ATTENTION*************************//
- spin_lock_irqsave(&mgr->lock, flags);
- //spin_lock(&mgr->lock);
//mgr->dbg_cpt.interrupts_all++;
if (irq) {
reg = PCXHR_INPL(mgr, PCXHR_PLX, PCXHR_PLX_IRQCS);
if (! (reg & PCXHR_IRQCS_ACTIVE_PCIDB)) {
- spin_unlock_irqrestore(&mgr->lock, flags);
- //spin_unlock(&mgr->lock);
mgr->dbg_cpt.interrupts_none++;
/* this device did not cause the interrupt */
return IRQ_NONE;
@@ -1240,6 +1230,44 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
/* timer irq occurred */
if (reg & PCXHR_IRQ_TIMER) {
int timer_toggle = reg & PCXHR_IRQ_TIMER;
+ if (timer_toggle == mgr->timer_toggle) {
+ dev_dbg(&mgr->pci->dev, "ERROR TIMER TOGGLE\n");
+ mgr->dsp_time_err++;
+ }
+
+ mgr->timer_toggle = timer_toggle;
+ mgr->src_it_dsp = reg;
+ wake_thread = true;
+ }
+
+ /* other irq's handled in the thread */
+ if (reg & PCXHR_IRQ_MASK) {
+ if (reg & PCXHR_IRQ_ASYNC) {
+ /* as we didn't request any async notifications,
+ * some kind of xrun error will probably occurred
+ */
+ /* better resynchronize all streams next interrupt : */
+ mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID;
+ }
+ mgr->src_it_dsp = reg;
+ wake_thread = true;
+ }
+#ifdef CONFIG_SND_DEBUG_VERBOSE
+ if (reg & PCXHR_FATAL_DSP_ERR)
+ dev_dbg(&mgr->pci->dev, "FATAL DSP ERROR : %x\n", reg);
+#endif
+
+ return wake_thread ? IRQ_WAKE_THREAD : IRQ_HANDLED;
+}
+
+irqreturn_t pcxhr_threaded_irq(int irq, void *dev_id)
+{
+ struct pcxhr_mgr *mgr = dev_id;
+ int i, j;
+ struct snd_pcxhr *chip;
+
+ mutex_lock(&mgr->lock);
+ if (mgr->src_it_dsp & PCXHR_IRQ_TIMER) {
/* is a 24 bit counter */
int dsp_time_new =
PCXHR_INPL(mgr, PCXHR_PLX, PCXHR_PLX_MBOX4) & PCXHR_DSP_TIME_MASK;
@@ -1249,72 +1277,54 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
(mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID)) {
/* handle dsp counter wraparound without resync */
int tmp_diff = dsp_time_diff + PCXHR_DSP_TIME_MASK + 1;
- snd_printdd("WARNING DSP timestamp old(%d) new(%d)",
+ dev_dbg(&mgr->pci->dev,
+ "WARNING DSP timestamp old(%d) new(%d)",
mgr->dsp_time_last, dsp_time_new);
if (tmp_diff > 0 && tmp_diff <= (2*mgr->granularity)) {
- snd_printdd("-> timestamp wraparound OK: "
+ dev_dbg(&mgr->pci->dev,
+ "-> timestamp wraparound OK: "
"diff=%d\n", tmp_diff);
dsp_time_diff = tmp_diff;
} else {
- snd_printdd("-> resynchronize all streams\n");
+ dev_dbg(&mgr->pci->dev,
+ "-> resynchronize all streams\n");
mgr->dsp_time_err++;
}
}
#ifdef CONFIG_SND_DEBUG_VERBOSE
if (dsp_time_diff == 0)
- snd_printdd("ERROR DSP TIME NO DIFF time(%d)\n",
+ dev_dbg(&mgr->pci->dev,
+ "ERROR DSP TIME NO DIFF time(%d)\n",
dsp_time_new);
else if (dsp_time_diff >= (2*mgr->granularity))
- snd_printdd("ERROR DSP TIME TOO BIG old(%d) add(%d)\n",
+ dev_dbg(&mgr->pci->dev,
+ "ERROR DSP TIME TOO BIG old(%d) add(%d)\n",
mgr->dsp_time_last,
dsp_time_new - mgr->dsp_time_last);
else if (dsp_time_diff % mgr->granularity)
- snd_printdd("ERROR DSP TIME increased by %d\n",
+ dev_dbg(&mgr->pci->dev,
+ "ERROR DSP TIME increased by %d\n",
dsp_time_diff);
#endif
mgr->dsp_time_last = dsp_time_new;
- if (timer_toggle == mgr->timer_toggle) {
- snd_printdd("ERROR TIMER TOGGLE\n");
- mgr->dsp_time_err++;
- }
- mgr->timer_toggle = timer_toggle;
-
- reg &= ~PCXHR_IRQ_TIMER;
for (i = 0; i < mgr->num_cards; i++) {
chip = mgr->chip[i];
for (j = 0; j < chip->nb_streams_capt; j++)
pcxhr_update_timer_pos(mgr,
&chip->capture_stream[j],
- dsp_time_diff, flags);
+ dsp_time_diff);
}
for (i = 0; i < mgr->num_cards; i++) {
chip = mgr->chip[i];
for (j = 0; j < chip->nb_streams_play; j++)
pcxhr_update_timer_pos(mgr,
&chip->playback_stream[j],
- dsp_time_diff, flags);
+ dsp_time_diff);
}
}
- /* other irq's handled in the tasklet */
- if (reg & PCXHR_IRQ_MASK) {
- mgr->dbg_cpt.interrupts_irq++;
- if (reg & PCXHR_IRQ_ASYNC) {
- /* as we didn't request any async notifications,
- * some kind of xrun error will probably occurred
- */
- /* better resynchronize all streams next interrupt : */
- mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID;
- mgr->dbg_cpt.interrupts_async++;
- }
- mgr->src_it_dsp = reg;
- tasklet_schedule(&mgr->msg_taskq);
- }
-#ifdef CONFIG_SND_DEBUG_VERBOSE
- if (reg & PCXHR_FATAL_DSP_ERR)
- snd_printdd("FATAL DSP ERROR : %x\n", reg);
-#endif
- spin_unlock_irqrestore(&mgr->lock, flags);
- mgr->dbg_cpt.interrupts_handled++;
- return IRQ_HANDLED; /* this device caused the interrupt */
+
+ pcxhr_msg_thread(mgr);
+ mutex_unlock(&mgr->lock);
+ return IRQ_HANDLED;
}
diff --git a/snd-pcxhr-dkms/src/pcxhr_core.h b/snd-pcxhr-dkms/src/pcxhr_core.h
index 98bedb1..c0ec553 100644
--- a/snd-pcxhr-dkms/src/pcxhr_core.h
+++ b/snd-pcxhr-dkms/src/pcxhr_core.h
@@ -1,23 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Driver for Digigram pcxhr compatible soundcards
*
* low level interface with interrupt and message handling
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_CORE_H
@@ -200,7 +187,7 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
/* interrupt handling */
irqreturn_t pcxhr_interrupt(int irq, void *dev_id);
-void pcxhr_msg_tasklet(unsigned long arg);
+irqreturn_t pcxhr_threaded_irq(int irq, void *dev_id);
/* access to the card */
diff --git a/snd-pcxhr-dkms/src/pcxhr_hrtimer.c b/snd-pcxhr-dkms/src/pcxhr_hrtimer.c
index 172b713..4ccc1bf 100644
--- a/snd-pcxhr-dkms/src/pcxhr_hrtimer.c
+++ b/snd-pcxhr-dkms/src/pcxhr_hrtimer.c
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
diff --git a/snd-pcxhr-dkms/src/pcxhr_hrtimer.h b/snd-pcxhr-dkms/src/pcxhr_hrtimer.h
index cfb9874..b54d864 100644
--- a/snd-pcxhr-dkms/src/pcxhr_hrtimer.h
+++ b/snd-pcxhr-dkms/src/pcxhr_hrtimer.h
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PCXHR_PCX_HRTIMER_H_
diff --git a/snd-pcxhr-dkms/src/pcxhr_hwdep.c b/snd-pcxhr-dkms/src/pcxhr_hwdep.c
index c9c3752..da67207 100644
--- a/snd-pcxhr-dkms/src/pcxhr_hwdep.c
+++ b/snd-pcxhr-dkms/src/pcxhr_hwdep.c
@@ -1,23 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* hwdep device manager
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/interrupt.h>
@@ -26,7 +13,7 @@
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
#include <sound/core.h>
#include <sound/hwdep.h>
#include "pcxhr.h"
@@ -73,7 +60,8 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
/* test max nb substream per pipe */
if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS)
return -EINVAL;
- snd_printdd("supported formats : playback=%x capture=%x\n",
+ dev_dbg(&mgr->pci->dev,
+ "supported formats : playback=%x capture=%x\n",
rmh.stat[2], rmh.stat[3]);
pcxhr_init_rmh(&rmh, CMD_VERSION);
@@ -85,7 +73,8 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
err = pcxhr_send_msg(mgr, &rmh);
if (err)
return err;
- snd_printdd("PCXHR DSP version is %d.%d.%d\n", (rmh.stat[0]>>16)&0xff,
+ dev_dbg(&mgr->pci->dev,
+ "PCXHR DSP version is %d.%d.%d\n", (rmh.stat[0]>>16)&0xff,
(rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff);
mgr->dsp_version = rmh.stat[0];
@@ -180,7 +169,7 @@ static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr,
stream_count = PCXHR_PLAYBACK_STREAMS;
audio_count = 2; /* always stereo */
}
- snd_printdd("snd_add_ref_pipe pin(%d) pcm%c0\n",
+ dev_dbg(&mgr->pci->dev, "snd_add_ref_pipe pin(%d) pcm%c0\n",
pin, is_capture ? 'c' : 'p');
pipe->is_capture = is_capture;
pipe->first_audio = pin;
@@ -195,7 +184,7 @@ static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr,
}
err = pcxhr_send_msg(mgr, &rmh);
if (err < 0) {
- snd_printk(KERN_ERR "error pipe allocation "
+ dev_err(&mgr->pci->dev, "error pipe allocation "
"(CMD_RES_PIPE) err=%x!\n", err);
return err;
}
@@ -223,14 +212,14 @@ static int pcxhr_dsp_free_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe)
/* stop one pipe */
err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
if (err < 0)
- snd_printk(KERN_ERR "error stopping pipe!\n");
+ dev_err(&mgr->pci->dev, "error stopping pipe!\n");
/* release the pipe */
pcxhr_init_rmh(&rmh, CMD_FREE_PIPE);
pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio,
0, 0);
err = pcxhr_send_msg(mgr, &rmh);
if (err < 0)
- snd_printk(KERN_ERR "error pipe release "
+ dev_err(&mgr->pci->dev, "error pipe release "
"(CMD_FREE_PIPE) err(%x)\n", err);
pipe->status = PCXHR_PIPE_UNDEFINED;
return err;
@@ -290,7 +279,8 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
{
int err, card_index;
- snd_printdd("loading dsp [%d] size = %lu\n", index, dsp->size);
+ dev_dbg(&mgr->pci->dev,
+ "loading dsp [%d] size = %zd\n", index, dsp->size);
switch (index) {
case PCXHR_FIRMWARE_XLX_INT_INDEX:
@@ -314,41 +304,45 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
return err;
break; /* continue with first init */
default:
- snd_printk(KERN_ERR "wrong file index\n");
+ dev_err(&mgr->pci->dev, "wrong file index\n");
return -EFAULT;
} /* end of switch file index*/
/* first communication with embedded */
err = pcxhr_init_board(mgr);
if (err < 0) {
- snd_printk(KERN_ERR "pcxhr could not be set up\n");
+ dev_err(&mgr->pci->dev, "pcxhr could not be set up\n");
return err;
}
err = pcxhr_config_pipes(mgr);
if (err < 0) {
- snd_printk(KERN_ERR "pcxhr pipes could not be set up\n");
+ dev_err(&mgr->pci->dev, "pcxhr pipes could not be set up\n");
return err;
}
/* create devices and mixer in accordance with HW options*/
for (card_index = 0; card_index < mgr->num_cards; card_index++) {
struct snd_pcxhr *chip = mgr->chip[card_index];
- if ((err = pcxhr_create_pcm(chip)) < 0)
+ err = pcxhr_create_pcm(chip);
+ if (err < 0)
return err;
if (card_index == 0) {
- if ((err = pcxhr_create_mixer(chip->mgr)) < 0)
+ err = pcxhr_create_mixer(chip->mgr);
+ if (err < 0)
return err;
}
- if ((err = snd_card_register(chip->card)) < 0)
+ err = snd_card_register(chip->card);
+ if (err < 0)
return err;
}
err = pcxhr_start_pipes(mgr);
if (err < 0) {
- snd_printk(KERN_ERR "pcxhr pipes could not be started\n");
+ dev_err(&mgr->pci->dev, "pcxhr pipes could not be started\n");
return err;
}
- snd_printdd("pcxhr firmware downloaded and successfully set up\n");
+ dev_dbg(&mgr->pci->dev,
+ "pcxhr firmware downloaded and successfully set up\n");
return 0;
}
@@ -359,7 +353,7 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
static int get_xilinx_version(struct pcxhr_mgr *mgr){
if (pcxhr_is_device_compatible_IE (mgr->pci->subsystem_device, PCXHR_DEVICE_IE5_ID)){
int xlx_version = cpu_to_be32(PCXHR_INPL(mgr, PCXHR_DSP, PCXHR_XLX_VERSION));
- snd_printk(KERN_DEBUG "Magic : %04x Version : %04x\n", xlx_version>>16, xlx_version&0x00ff);
+ dev_err(&mgr->pci->dev, "Magic : %04x Version : %04x\n", xlx_version>>16, xlx_version&0x00ff);
}
return 0;
}
@@ -369,7 +363,7 @@ static int get_xilinx_version(struct pcxhr_mgr *mgr){
*/
int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
{
- static char *fw_files[][5] = {
+ static const char *fw_files[][5] = {
/* xilinx 1 xilinx 2 eeprom boot dsp */
[0] = { "xlxint.dat", "xlxc882hr.dat", "dspe882.e56", "dspb882hr.b56", "dspd882.d56" },
[1] = { "xlxint.dat", "xlxc882e.dat", "dspe882.e56", "dspb882e.b56", "dspd882.d56" },
@@ -398,7 +392,8 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
}
sprintf(path, "pcxhr/%s", fw_files[fw_set][i]);
if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
- snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n",
+ dev_err(&mgr->pci->dev,
+ "pcxhr: can't load firmware %s\n",
path);
return -ENOENT;
}
diff --git a/snd-pcxhr-dkms/src/pcxhr_hwdep.h b/snd-pcxhr-dkms/src/pcxhr_hwdep.h
index f561909..f7a440e 100644
--- a/snd-pcxhr-dkms/src/pcxhr_hwdep.h
+++ b/snd-pcxhr-dkms/src/pcxhr_hwdep.h
@@ -1,23 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Driver for Digigram pcxhr compatible soundcards
*
* definitions and makros for basic card access
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_HWDEP_H
diff --git a/snd-pcxhr-dkms/src/pcxhr_mix22.c b/snd-pcxhr-dkms/src/pcxhr_mix22.c
index 7548cee..57972ff 100644
--- a/snd-pcxhr-dkms/src/pcxhr_mix22.c
+++ b/snd-pcxhr-dkms/src/pcxhr_mix22.c
@@ -1,27 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Digigram pcxhr compatible soundcards
*
* mixer interface for stereo cards
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/delay.h>
#include <linux/io.h>
+#include <linux/pci.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/tlv.h>
@@ -62,7 +50,6 @@
#define AKM_LEFT_LEVEL_CMD 0xA600
#define AKM_RIGHT_LEVEL_CMD 0xA700
-
/* values for PCHR_XLX_STATUS register - READ */
#define PCXHR_STAT_SRC_LOCK 0x01
#define PCXHR_STAT_LEVEL_IN 0x02
@@ -277,9 +264,9 @@ static void hr222_write_to_codec(struct pcxhr_mgr *mgr, unsigned short toWrite)
unsigned short bit_mask = 0x8000;
- snd_printdd("%s() CALLED\n", __FUNCTION__);
+ dev_dbg(&mgr->pci->dev, "%s() CALLED\n", __FUNCTION__);
- snd_printdd("%s() to write : 0x%x\n", __FUNCTION__, toWrite);
+ dev_dbg(&mgr->pci->dev, "%s() to write : 0x%x\n", __FUNCTION__, toWrite);
/* activate access to codec registers */
PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_XLX_HIFREQ);
@@ -303,9 +290,6 @@ static inline unsigned int pcxhr_ti_is_valid_output_gain_level (const int level)
// Return the TI DAC gain value from the given level value.
static unsigned int pcxhr_ti_gain_level_to_register_value(const unsigned int level)
{
-
- snd_printdd("%s() : level:%u\n",__FUNCTION__,level);
-
if (level == 0)
return PCXHR_PCM1796_MUTE_OUTPUT_GAIN_VALUE;
@@ -353,7 +337,8 @@ static int hr222_set_akm_hw_playback_level(struct pcxhr_mgr *mgr,
{
unsigned short cmd;
- snd_printdd("%s(channel:%d, level:%d) CALLED\n", __FUNCTION__, channel_id, level);
+ dev_dbg(&mgr->pci->dev,
+ "%s(channel:%d, level:%d) CALLED\n", __FUNCTION__, channel_id, level);
if (channel_id > 1 ||
level < 0 ||
@@ -372,6 +357,7 @@ static int hr222_set_akm_hw_playback_level(struct pcxhr_mgr *mgr,
return 0;
}
+
static int hr222_set_hw_capture_level(struct pcxhr_mgr *mgr,
int level_l, int level_r, int level_mic)
{
@@ -409,14 +395,14 @@ static void hr222_micro_boost(struct pcxhr_mgr *mgr, int level)
PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_XLX_SELMIC, mgr->xlx_selmic);
- snd_printdd("hr222_micro_boost : set %x\n", boost_mask);
+ dev_dbg(&mgr->pci->dev, "hr222_micro_boost : set %x\n", boost_mask);
}
static int hr222_ti_sub_init (struct pcxhr_mgr *mgr)
{
- snd_printdd("%s() CALLED\n", __FUNCTION__);
+ dev_dbg(&mgr->pci->dev, "%s() CALLED\n", __FUNCTION__);
//set the PCM1796 specific values
mgr->pcm1796_operation_reg_value = PCXHR_PCM1796_OPER_RESET_VALUE;
@@ -430,7 +416,7 @@ static int hr222_ti_sub_init (struct pcxhr_mgr *mgr)
static int hr222_akm_sub_init (struct pcxhr_mgr *mgr)
{
- snd_printdd("%s() CALLED\n", __FUNCTION__);
+ dev_dbg(&mgr->pci->dev, "%s() CALLED\n", __FUNCTION__);
/* config AKM */
hr222_write_to_codec(mgr, AKM_POWER_CONTROL_CMD);
hr222_write_to_codec(mgr, AKM_CLOCK_INF_55K_CMD);
@@ -450,7 +436,8 @@ int hr222_sub_init(struct pcxhr_mgr *mgr)
reg = PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_XLX_STATUS);
if (reg & PCXHR_STAT_MIC_CAPS)
mgr->board_has_mic = 1; /* microphone available */
- snd_printdd("MIC input available = %d\n", mgr->board_has_mic);
+ dev_dbg(&mgr->pci->dev,
+ "MIC input available = %d\n", mgr->board_has_mic);
/* reset codec */
PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_DSP_RESET,
@@ -468,14 +455,17 @@ int hr222_sub_init(struct pcxhr_mgr *mgr)
PCXHR_TI_CODECS_SETTLING_TIME_MS :
PCXHR_AKM_CODECS_SETTLING_TIME_MS);
- snd_printdd("init board %s\n", pcxhr_is_board_revision (mgr, PCXHR_BOARD_REVISION_7) ? "IE7" : "IE5");
+ dev_dbg(&mgr->pci->dev, "init board %s\n",
+ pcxhr_is_board_revision (mgr, PCXHR_BOARD_REVISION_7) ? "IE7" : "IE5");
pcxhr_is_board_revision (mgr, PCXHR_BOARD_REVISION_7) ? hr222_ti_sub_init(mgr) : hr222_akm_sub_init(mgr);
/* init micro boost */
hr222_micro_boost(mgr, 0);
+
return 0;
}
+
/* calc PLL register */
/* TODO : there is a very similar fct in pcxhr.c */
static int hr222_compute_pll_freq_register(unsigned int freq,
@@ -621,17 +611,15 @@ int hr222_sub_set_clock(struct pcxhr_mgr *mgr,
mgr->sample_rate_real = realfreq;
mgr->cur_clock_type = mgr->use_clock_type;
-
+
if (changed)
*changed = 1;
-
- snd_printdd("set_clock to %dHz (realfreq=%d pllreg=%x)\n",
- rate, realfreq, pllreg);
+ dev_dbg(&mgr->pci->dev, "set_clock to %dHz (realfreq=%d pllreg=%x)\n",
+ rate, realfreq, pllreg);
return 0;
}
-
int hr222_get_external_clock(struct pcxhr_mgr *mgr,
enum pcxhr_clock_type clock_type,
int *sample_rate)
@@ -653,13 +641,15 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
reg = PCXHR_STAT_FREQ_UER1_MASK;
} else {
- snd_printdd("get_external_clock : type %d not supported\n",
+ dev_dbg(&mgr->pci->dev,
+ "get_external_clock : type %d not supported\n",
clock_type);
return -EINVAL; /* other clocks not supported */
}
if ((PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_XLX_CSUER) & mask) != mask) {
- snd_printdd("get_external_clock(%d) = 0 Hz\n", clock_type);
+ dev_dbg(&mgr->pci->dev,
+ "get_external_clock(%d) = 0 Hz\n", clock_type);
*sample_rate = 0;
return 0; /* no external clock locked */
}
@@ -717,7 +707,7 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
else
rate = 0;
- snd_printdd("External clock is at %d Hz (measured %d Hz)\n",
+ dev_dbg(&mgr->pci->dev, "External clock is at %d Hz (measured %d Hz)\n",
rate, calc_rate);
*sample_rate = rate;
return 0;
@@ -750,7 +740,6 @@ int hr222_write_gpo(struct pcxhr_mgr *mgr, int value)
return 0;
}
-
int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable)
{
if (enable)
@@ -762,12 +751,12 @@ int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable)
return 0;
}
-
int hr222_update_analog_audio_level(struct snd_pcxhr *chip,
int is_capture, int channel)
{
- snd_printdd("hr222_update_analog_audio_level(%s chan=%d)\n",
- is_capture ? "capture" : "playback", channel);
+ dev_dbg(chip->card->dev,
+ "hr222_update_analog_audio_level(%s chan=%d)\n",
+ snd_pcm_direction_name(is_capture), channel);
if (is_capture) {
int level_l, level_r, level_mic;
/* we have to update all levels */
@@ -869,7 +858,7 @@ int hr222_iec958_capture_byte(struct snd_pcxhr *chip,
if (PCXHR_INPB(chip->mgr, PCXHR_DSP, PCXHR_XLX_CSUER) & mask)
temp |= 1;
}
- snd_printdd("read iec958 AES %d byte %d = 0x%x\n",
+ dev_dbg(chip->card->dev, "read iec958 AES %d byte %d = 0x%x\n",
chip->chip_idx, aes_idx, temp);
*aes_bits = temp;
return 0;
@@ -908,7 +897,7 @@ static void hr222_phantom_power(struct pcxhr_mgr *mgr, int power)
PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_XLX_SELMIC, mgr->xlx_selmic);
- snd_printdd("hr222_phantom_power : set %d\n", power);
+ dev_dbg(&mgr->pci->dev, "hr222_phantom_power : set %d\n", power);
}
@@ -951,7 +940,7 @@ static int hr222_mic_vol_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new hr222_control_mic_level = {
+static const struct snd_kcontrol_new hr222_control_mic_level = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -1001,7 +990,7 @@ static int hr222_mic_boost_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new hr222_control_mic_boost = {
+static const struct snd_kcontrol_new hr222_control_mic_boost = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -1043,7 +1032,7 @@ static int hr222_phantom_power_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new hr222_phantom_power_switch = {
+static const struct snd_kcontrol_new hr222_phantom_power_switch = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Phantom Power Switch",
.info = hr222_phantom_power_info,
diff --git a/snd-pcxhr-dkms/src/pcxhr_mix22.h b/snd-pcxhr-dkms/src/pcxhr_mix22.h
index 5971b99..b1e4ffc 100644
--- a/snd-pcxhr-dkms/src/pcxhr_mix22.h
+++ b/snd-pcxhr-dkms/src/pcxhr_mix22.h
@@ -1,23 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Driver for Digigram pcxhr compatible soundcards
*
* low level interface with interrupt ans message handling
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_MIX22_H
diff --git a/snd-pcxhr-dkms/src/pcxhr_mixer.c b/snd-pcxhr-dkms/src/pcxhr_mixer.c
index fec0493..aec5094 100644
--- a/snd-pcxhr-dkms/src/pcxhr_mixer.c
+++ b/snd-pcxhr-dkms/src/pcxhr_mixer.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
#define __NO_VERSION__
/*
* Driver for Digigram pcxhr compatible soundcards
@@ -5,20 +6,6 @@
* mixer callbacks
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/time.h>
@@ -72,7 +59,8 @@ static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip,
rmh.cmd_len = 3;
err = pcxhr_send_msg(chip->mgr, &rmh);
if (err < 0) {
- snd_printk(KERN_DEBUG "error update_analog_audio_level card(%d)"
+ dev_dbg(chip->card->dev,
+ "error update_analog_audio_level card(%d)"
" is_capture(%d) err(%x)\n",
chip->chip_idx, is_capture, err);
return -EINVAL;
@@ -184,7 +172,7 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new pcxhr_control_analog_level = {
+static const struct snd_kcontrol_new pcxhr_control_analog_level = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -234,7 +222,7 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new pcxhr_control_output_switch = {
+static const struct snd_kcontrol_new pcxhr_control_output_switch = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
.info = pcxhr_sw_info, /* shared */
@@ -284,7 +272,7 @@ static int pcxhr_update_playback_stream_level(struct snd_pcxhr* chip, int idx)
err = pcxhr_send_msg(chip->mgr, &rmh);
if (err < 0) {
- snd_printk(KERN_DEBUG "error update_playback_stream_level "
+ dev_dbg(chip->card->dev, "error update_playback_stream_level "
"card(%d) err(%x)\n", chip->chip_idx, err);
return -EINVAL;
}
@@ -335,7 +323,8 @@ static int pcxhr_update_audio_pipe_level(struct snd_pcxhr *chip,
err = pcxhr_send_msg(chip->mgr, &rmh);
if (err < 0) {
- snd_printk(KERN_DEBUG "error update_audio_level(%d) err=%x\n",
+ dev_dbg(chip->card->dev,
+ "error update_audio_level(%d) err=%x\n",
chip->chip_idx, err);
return -EINVAL;
}
@@ -407,7 +396,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new snd_pcxhr_pcm_vol =
+static const struct snd_kcontrol_new snd_pcxhr_pcm_vol =
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
@@ -458,7 +447,7 @@ static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new pcxhr_control_pcm_switch = {
+static const struct snd_kcontrol_new pcxhr_control_pcm_switch = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "PCM Playback Switch",
.count = PCXHR_PLAYBACK_STREAMS,
@@ -507,7 +496,7 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new pcxhr_control_monitor_vol = {
+static const struct snd_kcontrol_new pcxhr_control_monitor_vol = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -560,7 +549,7 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol,
return (changed != 0);
}
-static struct snd_kcontrol_new pcxhr_control_monitor_sw = {
+static const struct snd_kcontrol_new pcxhr_control_monitor_sw = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Monitoring Playback Switch",
.info = pcxhr_sw_info, /* shared */
@@ -658,14 +647,7 @@ static int pcxhr_audio_src_info(struct snd_kcontrol *kcontrol,
if (chip->mgr->board_has_mic)
i = 5; /* Mic and MicroMix available */
}
- uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
- uinfo->count = 1;
- uinfo->value.enumerated.items = i;
- if (uinfo->value.enumerated.item > (i-1))
- uinfo->value.enumerated.item = i-1;
- strcpy(uinfo->value.enumerated.name,
- texts[uinfo->value.enumerated.item]);
- return 0;
+ return snd_ctl_enum_info(uinfo, 1, i, texts);
}
static int pcxhr_audio_src_get(struct snd_kcontrol *kcontrol,
@@ -702,7 +684,7 @@ static int pcxhr_audio_src_put(struct snd_kcontrol *kcontrol,
return ret;
}
-static struct snd_kcontrol_new pcxhr_control_audio_src = {
+static const struct snd_kcontrol_new pcxhr_control_audio_src = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Capture Source",
.info = pcxhr_audio_src_info,
@@ -754,14 +736,7 @@ static int pcxhr_clock_type_info(struct snd_kcontrol *kcontrol,
texts = textsPCXHR;
snd_BUG_ON(clock_items > (PCXHR_CLOCK_TYPE_MAX+1));
}
- uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
- uinfo->count = 1;
- uinfo->value.enumerated.items = clock_items;
- if (uinfo->value.enumerated.item >= clock_items)
- uinfo->value.enumerated.item = clock_items-1;
- strcpy(uinfo->value.enumerated.name,
- texts[uinfo->value.enumerated.item]);
- return 0;
+ return snd_ctl_enum_info(uinfo, 1, clock_items, texts);
}
static int pcxhr_clock_type_get(struct snd_kcontrol *kcontrol,
@@ -810,7 +785,7 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
return ret;
}
-static struct snd_kcontrol_new pcxhr_control_clock_type = {
+static const struct snd_kcontrol_new pcxhr_control_clock_type = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Clock Mode",
.info = pcxhr_clock_type_info,
@@ -854,7 +829,7 @@ static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol,
return 0;
}
-static struct snd_kcontrol_new pcxhr_control_clock_rate = {
+static const struct snd_kcontrol_new pcxhr_control_clock_rate = {
.access = SNDRV_CTL_ELEM_ACCESS_READ,
.iface = SNDRV_CTL_ELEM_IFACE_CARD,
.name = "Clock Rates",
@@ -930,7 +905,7 @@ static int pcxhr_iec958_capture_byte(struct snd_pcxhr *chip,
temp |= 1;
}
}
- snd_printdd("read iec958 AES %d byte %d = 0x%x\n",
+ dev_dbg(chip->card->dev, "read iec958 AES %d byte %d = 0x%x\n",
chip->chip_idx, aes_idx, temp);
*aes_bits = temp;
return 0;
@@ -992,7 +967,8 @@ static int pcxhr_iec958_update_byte(struct snd_pcxhr *chip,
rmh.cmd[0] |= IO_NUM_REG_CUER;
rmh.cmd[1] = cmd;
rmh.cmd_len = 2;
- snd_printdd("write iec958 AES %d byte %d bit %d (cmd %x)\n",
+ dev_dbg(chip->card->dev,
+ "write iec958 AES %d byte %d bit %d (cmd %x)\n",
chip->chip_idx, aes_idx, i, cmd);
err = pcxhr_send_msg(chip->mgr, &rmh);
if (err)
@@ -1028,14 +1004,14 @@ static int pcxhr_iec958_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new pcxhr_control_playback_iec958_mask = {
+static const struct snd_kcontrol_new pcxhr_control_playback_iec958_mask = {
.access = SNDRV_CTL_ELEM_ACCESS_READ,
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),
.info = pcxhr_iec958_info,
.get = pcxhr_iec958_mask_get
};
-static struct snd_kcontrol_new pcxhr_control_playback_iec958 = {
+static const struct snd_kcontrol_new pcxhr_control_playback_iec958 = {
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
.info = pcxhr_iec958_info,
@@ -1044,14 +1020,14 @@ static struct snd_kcontrol_new pcxhr_control_playback_iec958 = {
.private_value = 0 /* playback */
};
-static struct snd_kcontrol_new pcxhr_control_capture_iec958_mask = {
+static const struct snd_kcontrol_new pcxhr_control_capture_iec958_mask = {
.access = SNDRV_CTL_ELEM_ACCESS_READ,
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = SNDRV_CTL_NAME_IEC958("",CAPTURE,MASK),
.info = pcxhr_iec958_info,
.get = pcxhr_iec958_mask_get
};
-static struct snd_kcontrol_new pcxhr_control_capture_iec958 = {
+static const struct snd_kcontrol_new pcxhr_control_capture_iec958 = {
.access = SNDRV_CTL_ELEM_ACCESS_READ,
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT),
diff --git a/snd-pcxhr-dkms/src/pcxhr_mixer.h b/snd-pcxhr-dkms/src/pcxhr_mixer.h
index 4348d0e..9c08620 100644
--- a/snd-pcxhr-dkms/src/pcxhr_mixer.h
+++ b/snd-pcxhr-dkms/src/pcxhr_mixer.h
@@ -1,23 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Driver for Digigram pcxhr compatible soundcards
*
* include file for mixer
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_MIXER_H