|
Packit Service |
103f6b |
/*
|
|
Packit Service |
103f6b |
* Copyright (C) 2014-2015 Etnaviv Project
|
|
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 |
* Christian Gmeiner <christian.gmeiner@gmail.com>
|
|
Packit Service |
103f6b |
*/
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
#include "etnaviv_priv.h"
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
drm_public int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms)
|
|
Packit Service |
103f6b |
{
|
|
Packit Service |
103f6b |
return etna_pipe_wait_ns(pipe, timestamp, ms * 1000000);
|
|
Packit Service |
103f6b |
}
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
drm_public int etna_pipe_wait_ns(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns)
|
|
Packit Service |
103f6b |
{
|
|
Packit Service |
103f6b |
struct etna_device *dev = pipe->gpu->dev;
|
|
Packit Service |
103f6b |
int ret;
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
struct drm_etnaviv_wait_fence req = {
|
|
Packit Service |
103f6b |
.pipe = pipe->gpu->core,
|
|
Packit Service |
103f6b |
.fence = timestamp,
|
|
Packit Service |
103f6b |
};
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
if (ns == 0)
|
|
Packit Service |
103f6b |
req.flags |= ETNA_WAIT_NONBLOCK;
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
get_abs_timeout(&req.timeout, ns);
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
ret = drmCommandWrite(dev->fd, DRM_ETNAVIV_WAIT_FENCE, &req, sizeof(req));
|
|
Packit Service |
103f6b |
if (ret) {
|
|
Packit Service |
103f6b |
ERROR_MSG("wait-fence failed! %d (%s)", ret, strerror(errno));
|
|
Packit Service |
103f6b |
return ret;
|
|
Packit Service |
103f6b |
}
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
return 0;
|
|
Packit Service |
103f6b |
}
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
drm_public void etna_pipe_del(struct etna_pipe *pipe)
|
|
Packit Service |
103f6b |
{
|
|
Packit Service |
103f6b |
free(pipe);
|
|
Packit Service |
103f6b |
}
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
drm_public struct etna_pipe *etna_pipe_new(struct etna_gpu *gpu, enum etna_pipe_id id)
|
|
Packit Service |
103f6b |
{
|
|
Packit Service |
103f6b |
struct etna_pipe *pipe;
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
pipe = calloc(1, sizeof(*pipe));
|
|
Packit Service |
103f6b |
if (!pipe) {
|
|
Packit Service |
103f6b |
ERROR_MSG("allocation failed");
|
|
Packit Service |
103f6b |
goto fail;
|
|
Packit Service |
103f6b |
}
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
pipe->id = id;
|
|
Packit Service |
103f6b |
pipe->gpu = gpu;
|
|
Packit Service |
103f6b |
|
|
Packit Service |
103f6b |
return pipe;
|
|
Packit Service |
103f6b |
fail:
|
|
Packit Service |
103f6b |
return NULL;
|
|
Packit Service |
103f6b |
}
|