Blame freedreno/freedreno_pipe.c

Packit Service 103f6b
/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
Packit Service 103f6b
Packit Service 103f6b
/*
Packit Service 103f6b
 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
Packit Service 103f6b
 *
Packit Service 103f6b
 * Permission is hereby granted, free of charge, to any person obtaining a
Packit Service 103f6b
 * copy of this software and associated documentation files (the "Software"),
Packit Service 103f6b
 * to deal in the Software without restriction, including without limitation
Packit Service 103f6b
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Packit Service 103f6b
 * and/or sell copies of the Software, and to permit persons to whom the
Packit Service 103f6b
 * Software is furnished to do so, subject to the following conditions:
Packit Service 103f6b
 *
Packit Service 103f6b
 * The above copyright notice and this permission notice (including the next
Packit Service 103f6b
 * paragraph) shall be included in all copies or substantial portions of the
Packit Service 103f6b
 * Software.
Packit Service 103f6b
 *
Packit Service 103f6b
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit Service 103f6b
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit Service 103f6b
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
Packit Service 103f6b
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Packit Service 103f6b
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Packit Service 103f6b
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit Service 103f6b
 * SOFTWARE.
Packit Service 103f6b
 *
Packit Service 103f6b
 * Authors:
Packit Service 103f6b
 *    Rob Clark <robclark@freedesktop.org>
Packit Service 103f6b
 */
Packit Service 103f6b
Packit Service 103f6b
#include "freedreno_drmif.h"
Packit Service 103f6b
#include "freedreno_priv.h"
Packit Service 103f6b
Packit Service 103f6b
/**
Packit Service 103f6b
 * priority of zero is highest priority, and higher numeric values are
Packit Service 103f6b
 * lower priorities
Packit Service 103f6b
 */
Packit Service 103f6b
drm_public struct fd_pipe *
Packit Service 103f6b
fd_pipe_new2(struct fd_device *dev, enum fd_pipe_id id, uint32_t prio)
Packit Service 103f6b
{
Packit Service 103f6b
	struct fd_pipe *pipe;
Packit Service 103f6b
	uint64_t val;
Packit Service 103f6b
Packit Service 103f6b
	if (id > FD_PIPE_MAX) {
Packit Service 103f6b
		ERROR_MSG("invalid pipe id: %d", id);
Packit Service 103f6b
		return NULL;
Packit Service 103f6b
	}
Packit Service 103f6b
Packit Service 103f6b
	if ((prio != 1) && (fd_device_version(dev) < FD_VERSION_SUBMIT_QUEUES)) {
Packit Service 103f6b
		ERROR_MSG("invalid priority!");
Packit Service 103f6b
		return NULL;
Packit Service 103f6b
	}
Packit Service 103f6b
Packit Service 103f6b
	pipe = dev->funcs->pipe_new(dev, id, prio);
Packit Service 103f6b
	if (!pipe) {
Packit Service 103f6b
		ERROR_MSG("allocation failed");
Packit Service 103f6b
		return NULL;
Packit Service 103f6b
	}
Packit Service 103f6b
Packit Service 103f6b
	pipe->dev = dev;
Packit Service 103f6b
	pipe->id = id;
Packit Service 103f6b
	atomic_set(&pipe->refcnt, 1);
Packit Service 103f6b
Packit Service 103f6b
	fd_pipe_get_param(pipe, FD_GPU_ID, &val;;
Packit Service 103f6b
	pipe->gpu_id = val;
Packit Service 103f6b
Packit Service 103f6b
	return pipe;
Packit Service 103f6b
}
Packit Service 103f6b
Packit Service 103f6b
drm_public struct fd_pipe *
Packit Service 103f6b
fd_pipe_new(struct fd_device *dev, enum fd_pipe_id id)
Packit Service 103f6b
{
Packit Service 103f6b
	return fd_pipe_new2(dev, id, 1);
Packit Service 103f6b
}
Packit Service 103f6b
Packit Service 103f6b
drm_public struct fd_pipe * fd_pipe_ref(struct fd_pipe *pipe)
Packit Service 103f6b
{
Packit Service 103f6b
	atomic_inc(&pipe->refcnt);
Packit Service 103f6b
	return pipe;
Packit Service 103f6b
}
Packit Service 103f6b
Packit Service 103f6b
drm_public void fd_pipe_del(struct fd_pipe *pipe)
Packit Service 103f6b
{
Packit Service 103f6b
	if (!atomic_dec_and_test(&pipe->refcnt))
Packit Service 103f6b
		return;
Packit Service 103f6b
	pipe->funcs->destroy(pipe);
Packit Service 103f6b
}
Packit Service 103f6b
Packit Service 103f6b
drm_public int fd_pipe_get_param(struct fd_pipe *pipe,
Packit Service 103f6b
				 enum fd_param_id param, uint64_t *value)
Packit Service 103f6b
{
Packit Service 103f6b
	return pipe->funcs->get_param(pipe, param, value);
Packit Service 103f6b
}
Packit Service 103f6b
Packit Service 103f6b
drm_public int fd_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp)
Packit Service 103f6b
{
Packit Service 103f6b
	return fd_pipe_wait_timeout(pipe, timestamp, ~0);
Packit Service 103f6b
}
Packit Service 103f6b
Packit Service 103f6b
drm_public int fd_pipe_wait_timeout(struct fd_pipe *pipe, uint32_t timestamp,
Packit Service 103f6b
		uint64_t timeout)
Packit Service 103f6b
{
Packit Service 103f6b
	return pipe->funcs->wait(pipe, timestamp, timeout);
Packit Service 103f6b
}