msm_priv.h revision 3f012e29
1e88f27b3Smrg/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */ 2e88f27b3Smrg 3e88f27b3Smrg/* 4e88f27b3Smrg * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org> 5e88f27b3Smrg * 6e88f27b3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7e88f27b3Smrg * copy of this software and associated documentation files (the "Software"), 8e88f27b3Smrg * to deal in the Software without restriction, including without limitation 9e88f27b3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10e88f27b3Smrg * and/or sell copies of the Software, and to permit persons to whom the 11e88f27b3Smrg * Software is furnished to do so, subject to the following conditions: 12e88f27b3Smrg * 13e88f27b3Smrg * The above copyright notice and this permission notice (including the next 14e88f27b3Smrg * paragraph) shall be included in all copies or substantial portions of the 15e88f27b3Smrg * Software. 16e88f27b3Smrg * 17e88f27b3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18e88f27b3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19e88f27b3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20e88f27b3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21e88f27b3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22e88f27b3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23e88f27b3Smrg * SOFTWARE. 24e88f27b3Smrg * 25e88f27b3Smrg * Authors: 26e88f27b3Smrg * Rob Clark <robclark@freedesktop.org> 27e88f27b3Smrg */ 28e88f27b3Smrg 29e88f27b3Smrg#ifndef MSM_PRIV_H_ 30e88f27b3Smrg#define MSM_PRIV_H_ 31e88f27b3Smrg 32e88f27b3Smrg#include "freedreno_priv.h" 33e88f27b3Smrg 34e88f27b3Smrg#ifndef __user 35e88f27b3Smrg# define __user 36e88f27b3Smrg#endif 37e88f27b3Smrg 38e88f27b3Smrg#include "msm_drm.h" 39e88f27b3Smrg 40e88f27b3Smrgstruct msm_device { 41e88f27b3Smrg struct fd_device base; 423f012e29Smrg struct fd_bo_cache ring_cache; 433f012e29Smrg unsigned ring_cnt; 44e88f27b3Smrg}; 45e88f27b3Smrg 46e88f27b3Smrgstatic inline struct msm_device * to_msm_device(struct fd_device *x) 47e88f27b3Smrg{ 48e88f27b3Smrg return (struct msm_device *)x; 49e88f27b3Smrg} 50e88f27b3Smrg 51e6188e58Smrgdrm_private struct fd_device * msm_device_new(int fd); 52e88f27b3Smrg 53e88f27b3Smrgstruct msm_pipe { 54e88f27b3Smrg struct fd_pipe base; 55e88f27b3Smrg uint32_t pipe; 56e88f27b3Smrg uint32_t gpu_id; 57e88f27b3Smrg uint32_t gmem; 58baaff307Smrg uint32_t chip_id; 59e88f27b3Smrg}; 60e88f27b3Smrg 61e88f27b3Smrgstatic inline struct msm_pipe * to_msm_pipe(struct fd_pipe *x) 62e88f27b3Smrg{ 63e88f27b3Smrg return (struct msm_pipe *)x; 64e88f27b3Smrg} 65e88f27b3Smrg 66e6188e58Smrgdrm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev, 67e6188e58Smrg enum fd_pipe_id id); 68e88f27b3Smrg 69e6188e58Smrgdrm_private struct fd_ringbuffer * msm_ringbuffer_new(struct fd_pipe *pipe, 70e88f27b3Smrg uint32_t size); 71e88f27b3Smrg 72e88f27b3Smrgstruct msm_bo { 73e88f27b3Smrg struct fd_bo base; 74e88f27b3Smrg uint64_t offset; 75e88f27b3Smrg uint64_t presumed; 763f012e29Smrg /* to avoid excess hashtable lookups, cache the ring this bo was 773f012e29Smrg * last emitted on (since that will probably also be the next ring 783f012e29Smrg * it is emitted on) 793f012e29Smrg */ 803f012e29Smrg unsigned current_ring_seqno; 813f012e29Smrg uint32_t idx; 82e88f27b3Smrg}; 83e88f27b3Smrg 84e88f27b3Smrgstatic inline struct msm_bo * to_msm_bo(struct fd_bo *x) 85e88f27b3Smrg{ 86e88f27b3Smrg return (struct msm_bo *)x; 87e88f27b3Smrg} 88e88f27b3Smrg 89e6188e58Smrgdrm_private int msm_bo_new_handle(struct fd_device *dev, 90e88f27b3Smrg uint32_t size, uint32_t flags, uint32_t *handle); 91e6188e58Smrgdrm_private struct fd_bo * msm_bo_from_handle(struct fd_device *dev, 92e88f27b3Smrg uint32_t size, uint32_t handle); 93e88f27b3Smrg 943f012e29Smrgstatic inline void get_abs_timeout(struct drm_msm_timespec *tv, uint64_t ns) 95e88f27b3Smrg{ 96e88f27b3Smrg struct timespec t; 973f012e29Smrg uint32_t s = ns / 1000000000; 98e88f27b3Smrg clock_gettime(CLOCK_MONOTONIC, &t); 99e88f27b3Smrg tv->tv_sec = t.tv_sec + s; 1003f012e29Smrg tv->tv_nsec = t.tv_nsec + ns - (s * 1000000000); 101e88f27b3Smrg} 102e88f27b3Smrg 103e88f27b3Smrg#endif /* MSM_PRIV_H_ */ 104