1 /*
2 * Copyright © 2022 Imagination Technologies Ltd.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * 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 THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 /* TODO: This file is currently hand-maintained. However, the intention is to
25 * auto-generate it in the future based on the hwdefs.
26 */
27
28 #include <assert.h>
29 #include <errno.h>
30
31 #include "pvr_device_info.h"
32
33 #include "device_info/gx6250.h"
34 #include "device_info/axe-1-16m.h"
35 #include "device_info/bxs-4-64.h"
36
37 /**
38 * Initialize PowerVR device information.
39 *
40 * \param info Device info structure to initialize.
41 * \param bvnc Packed BVNC.
42 * \return
43 * * 0 on success, or
44 * * -%ENODEV if the device is not supported.
45 */
pvr_device_info_init(struct pvr_device_info * info,uint64_t bvnc)46 int pvr_device_info_init(struct pvr_device_info *info, uint64_t bvnc)
47 {
48 #define CASE_PACKED_BVNC_DEVICE_INFO(_b, _v, _n, _c) \
49 case PVR_BVNC_PACK(_b, _v, _n, _c): \
50 info->ident = pvr_device_ident_##_b##_V_##_n##_##_c; \
51 info->ident.b = _b; \
52 info->ident.n = _n; \
53 info->ident.v = _v; \
54 info->ident.c = _c; \
55 info->features = pvr_device_features_##_b##_V_##_n##_##_c; \
56 info->enhancements = pvr_device_enhancements_##_b##_##_v##_##_n##_##_c; \
57 info->quirks = pvr_device_quirks_##_b##_##_v##_##_n##_##_c; \
58 return 0
59
60 switch (bvnc) {
61 CASE_PACKED_BVNC_DEVICE_INFO(4, 40, 2, 51);
62 CASE_PACKED_BVNC_DEVICE_INFO(33, 15, 11, 3);
63 }
64
65 #undef CASE_PACKED_BVNC_DEVICE_INFO
66
67 assert(!"Unsupported Device");
68
69 return -ENODEV;
70 }
71