diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c index 61df3476cf70..cdc9b5374689 100644 --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c @@ -15,6 +15,10 @@ u32 virtsnd_msg_timeout_ms = MSEC_PER_SEC; module_param_named(msg_timeout_ms, virtsnd_msg_timeout_ms, uint, 0644); MODULE_PARM_DESC(msg_timeout_ms, "Message completion timeout in milliseconds"); +u32 virtsnd_verbose = 0; +module_param_named(verbose, virtsnd_verbose, uint, 0644); +MODULE_PARM_DESC(verbose, "Verbose log enable or not"); + static void virtsnd_remove(struct virtio_device *vdev); /** diff --git a/sound/virtio/virtio_card.h b/sound/virtio/virtio_card.h index 3ceee4e416fc..2b0712e363c0 100644 --- a/sound/virtio/virtio_card.h +++ b/sound/virtio/virtio_card.h @@ -79,6 +79,7 @@ struct virtio_snd { /* Message completion timeout in milliseconds (module parameter). */ extern u32 virtsnd_msg_timeout_ms; +extern u32 virtsnd_verbose; static inline struct virtio_snd_queue * virtsnd_control_queue(struct virtio_snd *snd) diff --git a/sound/virtio/virtio_pcm.c b/sound/virtio/virtio_pcm.c index 0cb2c74dab19..4a1053e35597 100644 --- a/sound/virtio/virtio_pcm.c +++ b/sound/virtio/virtio_pcm.c @@ -309,8 +309,17 @@ static void virtsnd_pcm_period_elapsed(struct work_struct *work) { struct virtio_pcm_substream *vss = container_of(work, struct virtio_pcm_substream, elapsed_period); + struct virtio_snd *snd = vss->snd; + struct virtio_device *vdev = snd->vdev; + struct snd_pcm_runtime *runtime = vss->substream->runtime; snd_pcm_period_elapsed(vss->substream); + + if (virtsnd_verbose) { + dev_info(&vdev->dev, "%s, SID: %u, runtime hw=%ld, app=%ld\n", + __func__, vss->sid, (unsigned long)runtime->status->hw_ptr, + (unsigned long)runtime->control->appl_ptr); + } } /** @@ -513,7 +522,7 @@ void virtsnd_pcm_event(struct virtio_snd *snd, struct virtio_snd_event *event) break; } } -#ifdef CONFIG_VIRTIO_IVSHMEM +#if defined(CONFIG_VIRTIO_IVSHMEM) && defined(CONFIG_SND_VIRTIO) bool virtsnd_pcm_is_ivshmem_region(struct snd_pcm_substream *substream) { struct snd_card *card; @@ -532,4 +541,4 @@ bool virtsnd_pcm_is_ivshmem_region(struct snd_pcm_substream *substream) return false; } -#endif \ No newline at end of file +#endif diff --git a/sound/virtio/virtio_pcm_msg.c b/sound/virtio/virtio_pcm_msg.c index 542446c4c7ba..6782d866a384 100644 --- a/sound/virtio/virtio_pcm_msg.c +++ b/sound/virtio/virtio_pcm_msg.c @@ -302,6 +302,8 @@ static void virtsnd_pcm_msg_complete(struct virtio_pcm_msg *msg, size_t written_bytes) { struct virtio_pcm_substream *vss = msg->substream; + struct virtio_snd *snd = vss->snd; + struct virtio_device *vdev = snd->vdev; /* * hw_ptr always indicates the buffer position of the first I/O message @@ -339,6 +341,12 @@ static void virtsnd_pcm_msg_complete(struct virtio_pcm_msg *msg, wake_up_all(&vss->msg_empty); } spin_unlock(&vss->lock); + + if (virtsnd_verbose) + dev_info(&vdev->dev, "%s msg complete, SID %u, vss_hw=%lu\n", + vss->direction ? "capture" : "playback", + vss->sid, vss->hw_ptr); + } /** diff --git a/sound/virtio/virtio_pcm_ops.c b/sound/virtio/virtio_pcm_ops.c index ad12aae52fc3..38f7f4818d65 100644 --- a/sound/virtio/virtio_pcm_ops.c +++ b/sound/virtio/virtio_pcm_ops.c @@ -159,6 +159,8 @@ static int virtsnd_pcm_dev_set_params(struct virtio_pcm_substream *vss, { struct virtio_snd_msg *msg; struct virtio_snd_pcm_set_params *request; + struct virtio_snd *snd = vss->snd; + struct virtio_device *vdev = snd->vdev; unsigned int i; int vformat = -1; int vrate = -1; @@ -200,6 +202,11 @@ static int virtsnd_pcm_dev_set_params(struct virtio_pcm_substream *vss, request->features |= cpu_to_le32(1U << VIRTIO_SND_PCM_F_EVT_XRUNS); + if (virtsnd_verbose) { + dev_info(&vdev->dev, "%s, SID: %u, command=SET_PARAMS\n", + __func__, vss->sid); + } + return virtsnd_ctl_msg_send_sync(vss->snd, msg); } @@ -309,6 +316,11 @@ static int virtsnd_pcm_prepare(struct snd_pcm_substream *substream) if (!msg) return -ENOMEM; + if (virtsnd_verbose) { + dev_info(&vdev->dev, "%s, SID: %u, command=PREPARE\n", + __func__, vss->sid); + } + return virtsnd_ctl_msg_send_sync(vss->snd, msg); } @@ -325,6 +337,7 @@ static int virtsnd_pcm_trigger(struct snd_pcm_substream *substream, int command) { struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); struct virtio_snd *snd = vss->snd; + struct virtio_device *vdev = snd->vdev; struct virtio_snd_queue *queue; struct virtio_snd_msg *msg; unsigned long flags; @@ -356,6 +369,11 @@ static int virtsnd_pcm_trigger(struct snd_pcm_substream *substream, int command) return -ENOMEM; } + if (virtsnd_verbose) { + dev_info(&vdev->dev, "%s, SID: %u, command=START\n", + __func__, vss->sid); + } + return virtsnd_ctl_msg_send_sync(snd, msg); case SNDRV_PCM_TRIGGER_SUSPEND: vss->suspended = true; @@ -373,6 +391,11 @@ static int virtsnd_pcm_trigger(struct snd_pcm_substream *substream, int command) if (!msg) return -ENOMEM; + if (virtsnd_verbose) { + dev_info(&vdev->dev, "%s, SID: %u, command=STOP\n", + __func__, vss->sid); + } + return virtsnd_ctl_msg_send_sync(snd, msg); default: return -EINVAL; @@ -393,6 +416,7 @@ static int virtsnd_pcm_sync_stop(struct snd_pcm_substream *substream) { struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); struct virtio_snd *snd = vss->snd; + struct virtio_device *vdev = snd->vdev; struct virtio_snd_msg *msg; unsigned int js = msecs_to_jiffies(virtsnd_msg_timeout_ms); int rc; @@ -407,6 +431,11 @@ static int virtsnd_pcm_sync_stop(struct snd_pcm_substream *substream) if (!msg) return -ENOMEM; + if (virtsnd_verbose) { + dev_info(&vdev->dev, "%s, SID: %u, command=RELEASE\n", + __func__, vss->sid); + } + rc = virtsnd_ctl_msg_send_sync(snd, msg); if (rc) return rc;