/* update the position of the given pipe. pipe->position is updated and wrapped within the buffer size. pipe->transferred is updated, too, but the size is not wrapped, so that the caller can check the total transferred size later (to call snd_pcm_period_elapsed).  */
static int vx_update_pipe_position(struct vx_core *chip, struct snd_pcm_runtime *runtime, struct vx_pipe *pipe)
/* update the position of the given pipe. pipe->position is updated and wrapped within the buffer size. pipe->transferred is updated, too, but the size is not wrapped, so that the caller can check the total transferred size later (to call snd_pcm_period_elapsed).  */
static int vx_update_pipe_position(struct vx_core *chip, struct snd_pcm_runtime *runtime, struct vx_pipe *pipe)
{
	struct vx_rmh rmh;
	int err, update;
	u64 count;
	vx_init_rmh(&rmh, CMD_STREAM_SAMPLE_COUNT);
	vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
	err = vx_send_msg(chip, &rmh);
	if (err < 0)
		return err;
	count = ((u64)(rmh.Stat[0] & 0xfffff) << 24) | (u64)rmh.Stat[1];
	update = (int)(count - pipe->cur_count);
	pipe->cur_count = count;
	pipe->position += update;
	if (pipe->position >= (int)runtime->buffer_size)
		pipe->position %= runtime->buffer_size;
	pipe->transferred += update;
	return 0;
}