From 55d363e02ef45fbf57c5ef46706a8ed69ee6e0dd Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Tue, 11 Jul 2023 00:43:57 +0900 Subject: [PATCH] asahi: decode: Add a function to construct decode_params from a chip_id Should be useful on macOS later to properly support detecting the right GPU, but for now just hardcode T8103/G13G. Signed-off-by: Asahi Lina Part-of: --- src/asahi/lib/decode.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index ab94c68..9db43a8 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -755,6 +755,46 @@ agxdecode_gfx(uint32_t *cmdbuf, uint64_t encoder, bool verbose, } } +static void +chip_id_to_params(decoder_params *params, uint32_t chip_id) +{ + switch (chip_id) { + case 0x6000 ... 0x6002: + *params = (decoder_params){ + .gpu_generation = 13, + .gpu_variant = "SCD"[chip_id & 15], + .chip_id = chip_id, + .num_clusters_total = 2 << (chip_id & 15), + }; + break; + case 0x6020 ... 0x6022: + *params = (decoder_params){ + .gpu_generation = 14, + .gpu_variant = "SCD"[chip_id & 15], + .chip_id = chip_id, + .num_clusters_total = 2 << (chip_id & 15), + }; + break; + case 0x8112: + *params = (decoder_params){ + .gpu_generation = 14, + .gpu_variant = 'G', + .chip_id = chip_id, + .num_clusters_total = 1, + }; + break; + case 0x8103: + default: + *params = (decoder_params){ + .gpu_generation = 13, + .gpu_variant = 'G', + .chip_id = chip_id, + .num_clusters_total = 1, + }; + break; + } +} + #ifdef __APPLE__ void @@ -787,12 +827,9 @@ agxdecode_cmdstream(unsigned cmdbuf_handle, unsigned map_handle, bool verbose) DUMP_CL(IOGPU_ATTACHMENT, ptr, "Attachment"); } - struct drm_asahi_params_global params = { - .gpu_generation = 13, - .gpu_variant = 'G', - .chip_id = 0x8103, - .num_clusters_total = 1, - }; + struct drm_asahi_params_global params; + + chip_id_to_params(¶ms, 0x8103); if (cmd.unk_5 == 3) agxdecode_cs((uint32_t *)cmdbuf->ptr.cpu, cmd.encoder, verbose, ¶ms); -- 2.7.4