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