From 4cfaede767ef7ef81fecd6ba4181eb0c7c851e75 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 5 May 2025 09:21:21 +0200 Subject: [PATCH] ac/uvd: Add ac_uvd_alloc_stream_handle Cc: mesa-stable Reviewed-by: Ruijing Dong Part-of: (cherry picked from commit 69455e82088fa2e0d9c95706bbb628035360274e) --- .pick_status.json | 2 +- src/amd/common/ac_uvd_dec.c | 33 +++++++++++++++++++++++++++++++++ src/amd/common/ac_uvd_dec.h | 8 ++++++++ src/amd/common/meson.build | 1 + 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/amd/common/ac_uvd_dec.c diff --git a/.pick_status.json b/.pick_status.json index 6aecbf3f51a..cb994fe30d9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2994,7 +2994,7 @@ "description": "ac/uvd: Add ac_uvd_alloc_stream_handle", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/common/ac_uvd_dec.c b/src/amd/common/ac_uvd_dec.c new file mode 100644 index 00000000000..7eb16bfff21 --- /dev/null +++ b/src/amd/common/ac_uvd_dec.c @@ -0,0 +1,33 @@ +/************************************************************************** + * + * Copyright 2025 Advanced Micro Devices, Inc. + * + * SPDX-License-Identifier: MIT + * + **************************************************************************/ + +#include + +#include "ac_uvd_dec.h" +#include "util/os_time.h" +#include "util/detect_os.h" +#include "util/bitpack_helpers.h" + +#if DETECT_OS_POSIX +#include +#endif + +void ac_uvd_init_stream_handle(struct ac_uvd_stream_handle *handle) +{ +#if DETECT_OS_POSIX + handle->base = util_bitreverse(getpid() ^ os_time_get()); +#else + handle->base = util_bitreverse(os_time_get()); +#endif + handle->counter = 0; +} + +unsigned ac_uvd_alloc_stream_handle(struct ac_uvd_stream_handle *handle) +{ + return handle->base ^ ++handle->counter; +} diff --git a/src/amd/common/ac_uvd_dec.h b/src/amd/common/ac_uvd_dec.h index 94cf8a9a0cc..b37b699cb7e 100644 --- a/src/amd/common/ac_uvd_dec.h +++ b/src/amd/common/ac_uvd_dec.h @@ -406,4 +406,12 @@ struct ruvd_msg { } body; }; +struct ac_uvd_stream_handle { + uint32_t base; + uint32_t counter; +}; + +void ac_uvd_init_stream_handle(struct ac_uvd_stream_handle *handle); +unsigned ac_uvd_alloc_stream_handle(struct ac_uvd_stream_handle *handle); + #endif diff --git a/src/amd/common/meson.build b/src/amd/common/meson.build index 09ad382e1b6..cd69d63fa32 100644 --- a/src/amd/common/meson.build +++ b/src/amd/common/meson.build @@ -91,6 +91,7 @@ amd_common_files = files( 'ac_vcn_av1_default.h', 'ac_vcn_dec.c', 'ac_vcn_enc.c', + 'ac_uvd_dec.c', 'nir/ac_nir.c', 'nir/ac_nir.h', 'nir/ac_nir_helpers.h',