• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2016 Broadcom
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef V3D_CHIP_H
25 #define V3D_CHIP_H
26 
27 #include <stdbool.h>
28 #include <stdint.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /**
35  * Struct for tracking features of the V3D chip across driver and compiler.
36  */
37 struct v3d_device_info {
38         /** Simple V3D version: major * 10 + minor */
39         uint8_t ver;
40 
41         /** V3D revision number */
42         uint8_t rev;
43 
44         /** V3D compatitiblity revision number */
45         uint8_t compat_rev;
46 
47         /** Maximum number of performance counters for a given V3D version **/
48         uint8_t max_perfcnt;
49 
50         /** Size of the VPM, in bytes. */
51         int vpm_size;
52 
53         /** NSLC * QUPS from the core's IDENT registers. */
54         int qpu_count;
55 
56         /** If the hw has accumulator registers */
57         bool has_accumulators;
58 
59         /** Granularity for the Clipper XY Scaling */
60         float clipper_xy_granularity;
61 
62         /** The Control List Executor (CLE) pre-fetches V3D_CLE_READAHEAD
63          *  bytes from the Control List buffer. The usage of these last bytes
64          *  should be avoided or the CLE would pre-fetch the data after the
65          *  end of the CL buffer, reporting the kernel "MMU error from client
66          *  CLE".
67          */
68         uint32_t cle_readahead;
69 
70         /** Minimum size for a buffer storing the Control List Executor (CLE) */
71         uint32_t cle_buffer_min_size;
72 };
73 
74 typedef int (*v3d_ioctl_fun)(int fd, unsigned long request, void *arg);
75 
76 bool
77 v3d_get_device_info(int fd, struct v3d_device_info* devinfo, v3d_ioctl_fun fun);
78 
79 static inline bool
v3d_device_has_draw_index(const struct v3d_device_info * devinfo)80 v3d_device_has_draw_index(const struct v3d_device_info *devinfo)
81 {
82         return devinfo->ver > 71 || (devinfo->ver == 71 && devinfo->rev >= 10);
83 }
84 
85 static inline bool
v3d_device_has_unpack_sat(const struct v3d_device_info * devinfo)86 v3d_device_has_unpack_sat(const struct v3d_device_info *devinfo)
87 {
88         return devinfo->ver > 45 || (devinfo->ver == 45 && devinfo->rev >= 7);
89 }
90 
91 static inline bool
v3d_device_has_unpack_max0(const struct v3d_device_info * devinfo)92 v3d_device_has_unpack_max0(const struct v3d_device_info *devinfo)
93 {
94         return devinfo->ver > 71 ||
95                (devinfo->ver == 71 &&
96                 (devinfo->rev >= 7 ||
97                  (devinfo->rev == 6 && devinfo->compat_rev >= 4)));
98 }
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif
105