Home | History | Annotate | Download | only in kgsl
      1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
      2 
      3 /*
      4  * Copyright (C) 2013 Rob Clark <robclark (at) freedesktop.org>
      5  *
      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:
     12  *
     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
     15  * Software.
     16  *
     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
     23  * SOFTWARE.
     24  *
     25  * Authors:
     26  *    Rob Clark <robclark (at) freedesktop.org>
     27  */
     28 
     29 #ifndef KGSL_PRIV_H_
     30 #define KGSL_PRIV_H_
     31 
     32 #include "freedreno_priv.h"
     33 #include "msm_kgsl.h"
     34 #include "kgsl_drm.h"
     35 
     36 struct kgsl_device {
     37 	struct fd_device base;
     38 };
     39 
     40 static inline struct kgsl_device * to_kgsl_device(struct fd_device *x)
     41 {
     42 	return (struct kgsl_device *)x;
     43 }
     44 
     45 struct kgsl_pipe {
     46 	struct fd_pipe base;
     47 
     48 	int fd;
     49 	uint32_t drawctxt_id;
     50 
     51 	/* device properties: */
     52 	struct kgsl_version version;
     53 	struct kgsl_devinfo devinfo;
     54 
     55 	/* list of bo's that are referenced in ringbuffer but not
     56 	 * submitted yet:
     57 	 */
     58 	struct list_head submit_list;
     59 
     60 	/* list of bo's that have been submitted but timestamp has
     61 	 * not passed yet (so still ref'd in active cmdstream)
     62 	 */
     63 	struct list_head pending_list;
     64 
     65 	/* if we are the 2d pipe, and want to wait on a timestamp
     66 	 * from 3d, we need to also internally open the 3d pipe:
     67 	 */
     68 	struct fd_pipe *p3d;
     69 };
     70 
     71 static inline struct kgsl_pipe * to_kgsl_pipe(struct fd_pipe *x)
     72 {
     73 	return (struct kgsl_pipe *)x;
     74 }
     75 
     76 drm_private int is_kgsl_pipe(struct fd_pipe *pipe);
     77 
     78 struct kgsl_bo {
     79 	struct fd_bo base;
     80 	uint64_t offset;
     81 	uint32_t gpuaddr;
     82 	/* timestamp (per pipe) for bo's in a pipe's pending_list: */
     83 	uint32_t timestamp[FD_PIPE_MAX];
     84 	/* list-node for pipe's submit_list or pending_list */
     85 	struct list_head list[FD_PIPE_MAX];
     86 };
     87 
     88 static inline struct kgsl_bo * to_kgsl_bo(struct fd_bo *x)
     89 {
     90 	return (struct kgsl_bo *)x;
     91 }
     92 
     93 
     94 drm_private struct fd_device * kgsl_device_new(int fd);
     95 
     96 drm_private int kgsl_pipe_timestamp(struct kgsl_pipe *kgsl_pipe,
     97 		uint32_t *timestamp);
     98 drm_private void kgsl_pipe_add_submit(struct kgsl_pipe *pipe,
     99 		struct kgsl_bo *bo);
    100 drm_private void kgsl_pipe_pre_submit(struct kgsl_pipe *pipe);
    101 drm_private void kgsl_pipe_post_submit(struct kgsl_pipe *pipe,
    102 		uint32_t timestamp);
    103 drm_private void kgsl_pipe_process_pending(struct kgsl_pipe *pipe,
    104 		uint32_t timestamp);
    105 drm_private struct fd_pipe * kgsl_pipe_new(struct fd_device *dev,
    106 		enum fd_pipe_id id);
    107 
    108 drm_private struct fd_ringbuffer * kgsl_ringbuffer_new(struct fd_pipe *pipe,
    109 		uint32_t size);
    110 
    111 drm_private int kgsl_bo_new_handle(struct fd_device *dev,
    112 		uint32_t size, uint32_t flags, uint32_t *handle);
    113 drm_private struct fd_bo * kgsl_bo_from_handle(struct fd_device *dev,
    114 		uint32_t size, uint32_t handle);
    115 
    116 drm_private uint32_t kgsl_bo_gpuaddr(struct kgsl_bo *bo, uint32_t offset);
    117 drm_private void kgsl_bo_set_timestamp(struct kgsl_bo *bo, uint32_t timestamp);
    118 drm_private uint32_t kgsl_bo_get_timestamp(struct kgsl_bo *bo);
    119 
    120 #endif /* KGSL_PRIV_H_ */
    121