1*7688df22SAndroid Build Coastguard Worker /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2*7688df22SAndroid Build Coastguard Worker
3*7688df22SAndroid Build Coastguard Worker /*
4*7688df22SAndroid Build Coastguard Worker * Copyright (C) 2013 Rob Clark <[email protected]>
5*7688df22SAndroid Build Coastguard Worker *
6*7688df22SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a
7*7688df22SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"),
8*7688df22SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation
9*7688df22SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10*7688df22SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the
11*7688df22SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions:
12*7688df22SAndroid Build Coastguard Worker *
13*7688df22SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next
14*7688df22SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the
15*7688df22SAndroid Build Coastguard Worker * Software.
16*7688df22SAndroid Build Coastguard Worker *
17*7688df22SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18*7688df22SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*7688df22SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20*7688df22SAndroid Build Coastguard Worker * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21*7688df22SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22*7688df22SAndroid Build Coastguard Worker * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23*7688df22SAndroid Build Coastguard Worker * SOFTWARE.
24*7688df22SAndroid Build Coastguard Worker *
25*7688df22SAndroid Build Coastguard Worker * Authors:
26*7688df22SAndroid Build Coastguard Worker * Rob Clark <[email protected]>
27*7688df22SAndroid Build Coastguard Worker */
28*7688df22SAndroid Build Coastguard Worker
29*7688df22SAndroid Build Coastguard Worker #ifndef KGSL_PRIV_H_
30*7688df22SAndroid Build Coastguard Worker #define KGSL_PRIV_H_
31*7688df22SAndroid Build Coastguard Worker
32*7688df22SAndroid Build Coastguard Worker #include "freedreno_priv.h"
33*7688df22SAndroid Build Coastguard Worker #include "msm_kgsl.h"
34*7688df22SAndroid Build Coastguard Worker #include "kgsl_drm.h"
35*7688df22SAndroid Build Coastguard Worker
36*7688df22SAndroid Build Coastguard Worker struct kgsl_device {
37*7688df22SAndroid Build Coastguard Worker struct fd_device base;
38*7688df22SAndroid Build Coastguard Worker };
39*7688df22SAndroid Build Coastguard Worker
to_kgsl_device(struct fd_device * x)40*7688df22SAndroid Build Coastguard Worker static inline struct kgsl_device * to_kgsl_device(struct fd_device *x)
41*7688df22SAndroid Build Coastguard Worker {
42*7688df22SAndroid Build Coastguard Worker return (struct kgsl_device *)x;
43*7688df22SAndroid Build Coastguard Worker }
44*7688df22SAndroid Build Coastguard Worker
45*7688df22SAndroid Build Coastguard Worker struct kgsl_pipe {
46*7688df22SAndroid Build Coastguard Worker struct fd_pipe base;
47*7688df22SAndroid Build Coastguard Worker
48*7688df22SAndroid Build Coastguard Worker int fd;
49*7688df22SAndroid Build Coastguard Worker uint32_t drawctxt_id;
50*7688df22SAndroid Build Coastguard Worker
51*7688df22SAndroid Build Coastguard Worker /* device properties: */
52*7688df22SAndroid Build Coastguard Worker struct kgsl_version version;
53*7688df22SAndroid Build Coastguard Worker struct kgsl_devinfo devinfo;
54*7688df22SAndroid Build Coastguard Worker
55*7688df22SAndroid Build Coastguard Worker /* list of bo's that are referenced in ringbuffer but not
56*7688df22SAndroid Build Coastguard Worker * submitted yet:
57*7688df22SAndroid Build Coastguard Worker */
58*7688df22SAndroid Build Coastguard Worker struct list_head submit_list;
59*7688df22SAndroid Build Coastguard Worker
60*7688df22SAndroid Build Coastguard Worker /* list of bo's that have been submitted but timestamp has
61*7688df22SAndroid Build Coastguard Worker * not passed yet (so still ref'd in active cmdstream)
62*7688df22SAndroid Build Coastguard Worker */
63*7688df22SAndroid Build Coastguard Worker struct list_head pending_list;
64*7688df22SAndroid Build Coastguard Worker
65*7688df22SAndroid Build Coastguard Worker /* if we are the 2d pipe, and want to wait on a timestamp
66*7688df22SAndroid Build Coastguard Worker * from 3d, we need to also internally open the 3d pipe:
67*7688df22SAndroid Build Coastguard Worker */
68*7688df22SAndroid Build Coastguard Worker struct fd_pipe *p3d;
69*7688df22SAndroid Build Coastguard Worker };
70*7688df22SAndroid Build Coastguard Worker
to_kgsl_pipe(struct fd_pipe * x)71*7688df22SAndroid Build Coastguard Worker static inline struct kgsl_pipe * to_kgsl_pipe(struct fd_pipe *x)
72*7688df22SAndroid Build Coastguard Worker {
73*7688df22SAndroid Build Coastguard Worker return (struct kgsl_pipe *)x;
74*7688df22SAndroid Build Coastguard Worker }
75*7688df22SAndroid Build Coastguard Worker
76*7688df22SAndroid Build Coastguard Worker drm_private int is_kgsl_pipe(struct fd_pipe *pipe);
77*7688df22SAndroid Build Coastguard Worker
78*7688df22SAndroid Build Coastguard Worker struct kgsl_bo {
79*7688df22SAndroid Build Coastguard Worker struct fd_bo base;
80*7688df22SAndroid Build Coastguard Worker uint64_t offset;
81*7688df22SAndroid Build Coastguard Worker uint32_t gpuaddr;
82*7688df22SAndroid Build Coastguard Worker /* timestamp (per pipe) for bo's in a pipe's pending_list: */
83*7688df22SAndroid Build Coastguard Worker uint32_t timestamp[FD_PIPE_MAX];
84*7688df22SAndroid Build Coastguard Worker /* list-node for pipe's submit_list or pending_list */
85*7688df22SAndroid Build Coastguard Worker struct list_head list[FD_PIPE_MAX];
86*7688df22SAndroid Build Coastguard Worker };
87*7688df22SAndroid Build Coastguard Worker
to_kgsl_bo(struct fd_bo * x)88*7688df22SAndroid Build Coastguard Worker static inline struct kgsl_bo * to_kgsl_bo(struct fd_bo *x)
89*7688df22SAndroid Build Coastguard Worker {
90*7688df22SAndroid Build Coastguard Worker return (struct kgsl_bo *)x;
91*7688df22SAndroid Build Coastguard Worker }
92*7688df22SAndroid Build Coastguard Worker
93*7688df22SAndroid Build Coastguard Worker
94*7688df22SAndroid Build Coastguard Worker drm_private struct fd_device * kgsl_device_new(int fd);
95*7688df22SAndroid Build Coastguard Worker
96*7688df22SAndroid Build Coastguard Worker drm_private int kgsl_pipe_timestamp(struct kgsl_pipe *kgsl_pipe,
97*7688df22SAndroid Build Coastguard Worker uint32_t *timestamp);
98*7688df22SAndroid Build Coastguard Worker drm_private void kgsl_pipe_add_submit(struct kgsl_pipe *pipe,
99*7688df22SAndroid Build Coastguard Worker struct kgsl_bo *bo);
100*7688df22SAndroid Build Coastguard Worker drm_private void kgsl_pipe_pre_submit(struct kgsl_pipe *pipe);
101*7688df22SAndroid Build Coastguard Worker drm_private void kgsl_pipe_post_submit(struct kgsl_pipe *pipe,
102*7688df22SAndroid Build Coastguard Worker uint32_t timestamp);
103*7688df22SAndroid Build Coastguard Worker drm_private void kgsl_pipe_process_pending(struct kgsl_pipe *pipe,
104*7688df22SAndroid Build Coastguard Worker uint32_t timestamp);
105*7688df22SAndroid Build Coastguard Worker drm_private struct fd_pipe * kgsl_pipe_new(struct fd_device *dev,
106*7688df22SAndroid Build Coastguard Worker enum fd_pipe_id id, uint32_t prio);
107*7688df22SAndroid Build Coastguard Worker
108*7688df22SAndroid Build Coastguard Worker drm_private struct fd_ringbuffer * kgsl_ringbuffer_new(struct fd_pipe *pipe,
109*7688df22SAndroid Build Coastguard Worker uint32_t size, enum fd_ringbuffer_flags flags);
110*7688df22SAndroid Build Coastguard Worker
111*7688df22SAndroid Build Coastguard Worker drm_private int kgsl_bo_new_handle(struct fd_device *dev,
112*7688df22SAndroid Build Coastguard Worker uint32_t size, uint32_t flags, uint32_t *handle);
113*7688df22SAndroid Build Coastguard Worker drm_private struct fd_bo * kgsl_bo_from_handle(struct fd_device *dev,
114*7688df22SAndroid Build Coastguard Worker uint32_t size, uint32_t handle);
115*7688df22SAndroid Build Coastguard Worker
116*7688df22SAndroid Build Coastguard Worker drm_private uint32_t kgsl_bo_gpuaddr(struct kgsl_bo *bo, uint32_t offset);
117*7688df22SAndroid Build Coastguard Worker drm_private void kgsl_bo_set_timestamp(struct kgsl_bo *bo, uint32_t timestamp);
118*7688df22SAndroid Build Coastguard Worker drm_private uint32_t kgsl_bo_get_timestamp(struct kgsl_bo *bo);
119*7688df22SAndroid Build Coastguard Worker
120*7688df22SAndroid Build Coastguard Worker #endif /* KGSL_PRIV_H_ */
121