| 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 |
#include <string.h> |
| 31 |
|
| 32 |
#include "pvr_device_info.h" |
| 33 |
|
| 34 |
#include "device_info/g6110.h" |
| 35 |
#include "device_info/gx6250.h" |
| 36 |
#include "device_info/gx6650.h" |
| 37 |
#include "device_info/ge7800.h" |
| 38 |
#include "device_info/ge8300.h" |
| 39 |
#include "device_info/axe-1-16m.h" |
| 40 |
#include "device_info/bxe-2-32.h" |
| 41 |
#include "device_info/bxe-4-32.h" |
| 42 |
#include "device_info/bxm-4-64.h" |
| 43 |
#include "device_info/bxs-4-64.h" |
| 44 |
|
| 45 |
#include "util/u_string.h" |
| 46 |
|
| 47 |
static const struct pvr_device_info *device_infos[] = { |
| 48 |
/* clang-format off */ |
| 49 |
&pvr_device_info_4_40_2_51, |
| 50 |
&pvr_device_info_4_45_2_58, |
| 51 |
&pvr_device_info_4_46_6_62, |
| 52 |
&pvr_device_info_5_9_1_46, |
| 53 |
&pvr_device_info_15_5_1_64, |
| 54 |
&pvr_device_info_22_67_54_30, |
| 55 |
&pvr_device_info_22_68_54_30, |
| 56 |
&pvr_device_info_22_102_54_38, |
| 57 |
&pvr_device_info_33_15_11_3, |
| 58 |
&pvr_device_info_36_29_52_182, |
| 59 |
&pvr_device_info_36_50_54_182, |
| 60 |
&pvr_device_info_36_52_104_182, |
| 61 |
&pvr_device_info_36_53_104_796, |
| 62 |
&pvr_device_info_36_56_104_183, |
| 63 |
/* clang-format on */ |
| 64 |
}; |
| 65 |
|
| 66 |
/** |
| 67 |
* Initialize PowerVR device information. |
| 68 |
* |
| 69 |
* \param info Device info structure to initialize. |
| 70 |
* \param bvnc Packed BVNC. |
| 71 |
* \return |
| 72 |
* * 0 on success, or |
| 73 |
* * -%ENODEV if the device is not supported. |
| 74 |
*/ |
| 75 |
int pvr_device_info_init(struct pvr_device_info *info, uint64_t bvnc) |
| 76 |
{ |
| 77 |
#define CASE_PACKED_BVNC_DEVICE_INFO(_b, _v, _n, _c) \ |
| 78 |
case PVR_BVNC_PACK(_b, _v, _n, _c): \ |
| 79 |
*info = pvr_device_info_##_b##_##_v##_##_n##_##_c; \ |
| 80 |
return 0 |
| 81 |
|
| 82 |
switch (bvnc) { |
| 83 |
CASE_PACKED_BVNC_DEVICE_INFO(4, 40, 2, 51); |
| 84 |
CASE_PACKED_BVNC_DEVICE_INFO(4, 45, 2, 58); |
| 85 |
CASE_PACKED_BVNC_DEVICE_INFO(4, 46, 6, 62); |
| 86 |
CASE_PACKED_BVNC_DEVICE_INFO(5, 9, 1, 46); |
| 87 |
CASE_PACKED_BVNC_DEVICE_INFO(15, 5, 1, 64); |
| 88 |
CASE_PACKED_BVNC_DEVICE_INFO(22, 67, 54, 30); |
| 89 |
CASE_PACKED_BVNC_DEVICE_INFO(22, 68, 54, 30); |
| 90 |
CASE_PACKED_BVNC_DEVICE_INFO(22, 102, 54, 38); |
| 91 |
CASE_PACKED_BVNC_DEVICE_INFO(33, 15, 11, 3); |
| 92 |
CASE_PACKED_BVNC_DEVICE_INFO(36, 29, 52, 182); |
| 93 |
CASE_PACKED_BVNC_DEVICE_INFO(36, 50, 54, 182); |
| 94 |
CASE_PACKED_BVNC_DEVICE_INFO(36, 52, 104, 182); |
| 95 |
CASE_PACKED_BVNC_DEVICE_INFO(36, 53, 104, 796); |
| 96 |
CASE_PACKED_BVNC_DEVICE_INFO(36, 56, 104, 183); |
| 97 |
} |
| 98 |
|
| 99 |
#undef CASE_PACKED_BVNC_DEVICE_INFO |
| 100 |
|
| 101 |
assert(!"Unsupported Device"); |
| 102 |
|
| 103 |
return -ENODEV; |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* Initialize PowerVR device information from a public name. |
| 108 |
* |
| 109 |
* \param info Device info structure to initialize. |
| 110 |
* \param public_name Device public name. |
| 111 |
* \return True if successful. |
| 112 |
*/ |
| 113 |
bool pvr_device_info_init_public_name(struct pvr_device_info *info, |
| 114 |
const char *public_name) |
| 115 |
{ |
| 116 |
for (unsigned d = 0; d < ARRAY_SIZE(device_infos); ++d) { |
| 117 |
if (strcasecmp(public_name, device_infos[d]->ident.public_name)) |
| 118 |
continue; |
| 119 |
|
| 120 |
memcpy(info, device_infos[d], sizeof(*info)); |
| 121 |
return true; |
| 122 |
} |
| 123 |
|
| 124 |
return false; |
| 125 |
} |