1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
4 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Rob Clark <robclark@freedesktop.org>
29 #ifndef FREEDRENO_PRIV_H_
30 #define FREEDRENO_PRIV_H_
38 #include <sys/ioctl.h>
43 #include "xf86atomic.h"
47 #include "freedreno_drmif.h"
55 /* tables to keep track of bo's, to avoid "evil-twin" fd_bo objects:
57 * handle_table: maps handle to fd_bo
58 * name_table: maps flink name to fd_bo
60 * We end up needing two tables, because DRM_IOCTL_GEM_OPEN always
61 * returns a new handle. So we need to figure out if the bo is already
62 * open in the process first, before calling gem-open.
64 void *handle_table, *name_table;
68 struct fd_device *dev;
73 /* device properties: */
74 struct kgsl_version version;
75 struct kgsl_devinfo devinfo;
77 /* list of bo's that are referenced in ringbuffer but not
80 struct list_head submit_list;
82 /* list of bo's that have been submitted but timestamp has
83 * not passed yet (so still ref'd in active cmdstream)
85 struct list_head pending_list;
87 /* if we are the 2d pipe, and want to wait on a timestamp
88 * from 3d, we need to also internally open the 3d pipe:
93 void fd_pipe_add_submit(struct fd_pipe *pipe, struct fd_bo *bo);
94 void fd_pipe_pre_submit(struct fd_pipe *pipe);
95 void fd_pipe_post_submit(struct fd_pipe *pipe, uint32_t timestamp);
96 void fd_pipe_process_pending(struct fd_pipe *pipe, uint32_t timestamp);
99 struct fd_device *dev;
106 /* timestamp (per pipe) for bo's in a pipe's pending_list: */
107 uint32_t timestamp[FD_PIPE_MAX];
108 /* list-node for pipe's submit_list or pending_list */
109 struct list_head list[FD_PIPE_MAX];
113 /* not exposed publicly, because won't be needed when we have
114 * a proper kernel driver
116 uint32_t fd_bo_gpuaddr(struct fd_bo *bo, uint32_t offset);
117 void fb_bo_set_timestamp(struct fd_bo *bo, uint32_t timestamp);
118 uint32_t fd_bo_get_timestamp(struct fd_bo *bo);
120 #define ALIGN(v,a) (((v) + (a) - 1) & ~((a) - 1))
121 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
123 #define enable_debug 1 /* TODO make dynamic */
125 #define INFO_MSG(fmt, ...) \
126 do { drmMsg("[I] "fmt " (%s:%d)\n", \
127 ##__VA_ARGS__, __FUNCTION__, __LINE__); } while (0)
128 #define DEBUG_MSG(fmt, ...) \
129 do if (enable_debug) { drmMsg("[D] "fmt " (%s:%d)\n", \
130 ##__VA_ARGS__, __FUNCTION__, __LINE__); } while (0)
131 #define WARN_MSG(fmt, ...) \
132 do { drmMsg("[W] "fmt " (%s:%d)\n", \
133 ##__VA_ARGS__, __FUNCTION__, __LINE__); } while (0)
134 #define ERROR_MSG(fmt, ...) \
135 do { drmMsg("[E] " fmt " (%s:%d)\n", \
136 ##__VA_ARGS__, __FUNCTION__, __LINE__); } while (0)
138 #endif /* FREEDRENO_PRIV_H_ */