Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sound/virtio/virtio_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
1 change: 1 addition & 0 deletions sound/virtio/virtio_card.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions sound/virtio/virtio_pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down Expand Up @@ -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;
Expand All @@ -532,4 +541,4 @@ bool virtsnd_pcm_is_ivshmem_region(struct snd_pcm_substream *substream)

return false;
}
#endif
#endif
8 changes: 8 additions & 0 deletions sound/virtio/virtio_pcm_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

}

/**
Expand Down
29 changes: 29 additions & 0 deletions sound/virtio/virtio_pcm_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down