From patchwork Fri Oct 10 03:42:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 571 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067815; bh=4uRJoU/Lo488CcH7R5AM27wjpKwom2VtWlSBZVbV9rU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QzVI0PYvDkYj7VmOYQaT1Fl8wMiTPirtLzD/PHSwQxx1MkUmXLeHKrQ7E3IiIN3Aa 4Xwbym8c0DpKOpqXqT8aF3m2+T72/xmZujFdM5OlU0sCj19a9niPdfJx+rxwimweNI NSGivk0jEookcqZzEuAKiqFv1bVZxy/BaKHURPG71UAghaIGjqhD5dMMpyWngA/sgo gSAABJnue02rsCeZNPGf/DWzA4viC+4bCsqRy5Vj5NyKTy8kJBH3EY9gfboSQPmDeJ UU7sZcpj6rYzuGxxGCHS3ZFacocTwrv6Wlx0gQFVR79Dn9fL5lah11HegGZSpDfQBT ifOwa66C5lDLQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 85E6E67F7F for ; Thu, 9 Oct 2025 21:43:35 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PM2Dae2N0xZD for ; Thu, 9 Oct 2025 21:43:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067814; bh=4uRJoU/Lo488CcH7R5AM27wjpKwom2VtWlSBZVbV9rU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ty9EE+adKHc7/74EehRxgbJCHKZlJqGFaUt2PyWlgau91mnG/VTD+TE0PLPxvnm9L nosJjwEbdN2zNZ6RJdzSPyiMl1iCjzQ/sNEOn/hxCQ4djvSnZ8xCAgknmgnSmYcOM3 Q5lk1YpPptCFF+f4lnPqfJLraU1Rp3QLB4dv9R8XH45KZlzMJLX2jTOTrz+Z4gIvXc J0PrUW7XWIbF85V2fE0siHES267/OMylis50CpBSKYlV9gZAsNM7syg4tZfGS2epCA 5TA36uK5V+Pf5h/XRrz/V7dj6VJdaqzag1E/Y+Q5N+73+pYqHUczJ/4xQaioKYc6oK rMzbCa4hSqpmg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7020E67FF2 for ; Thu, 9 Oct 2025 21:43:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067812; bh=hn8SezsMob9bZCIEvL7tUiBre1snPMrB1xn+U6r+JlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJjT0NGtGvf4QVw4D07iVQGog1QWyoulEBIcGRlC5/3aLQ1r8G1i2GwiDzvH+FvoU D4GXu9g1FihoQ1VXbeARGQ/KcT0+i4fW8eJ3GLIFKUY0roYC0WrBXSjf8PqiVjbkXW 0KqT+3WCyFwCIu6a6+e8yW9YHZGazegYHDhltlnQVZDHb4arO+EK6UWKEJK/A1r/Mz RKcMIYeDufxwm4qnAbOoeR15rKi/xgi5WrpwgdYEc4SM4TuRIsRw/jw2V2+RLoPqPM McMttuVGmoYacS7WVAOCEzF1I8TnyeQueqPc3p0TFMNtDOmJ1pb+GpLdBdZJj4doP/ AsS3ybhtek2uQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 693F967FA3; Thu, 9 Oct 2025 21:43:32 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id dlBCks1XB2DC; Thu, 9 Oct 2025 21:43:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067808; bh=OhvNCdaVALVqdhy3ILvxUp9M7YeontW2j3U38yEZf6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rwm4Nfarr89H49NTpZdqd2P66xDOgk07qCBebljMskFQLOWFJTwaeqX1d5Ln18590 W8kS8cEgbANNvrUf21LYE6egRx+JC/XSx4AFPwYrJCh9G5s42ttXVNqjSwkN6SXxDn lmI8yuHAOb0szg7ec7U51mhzEvyjwh0GgFgmWlfqReC4pF967s8kUUBL+MaodQJv1l LJqd+y5ThMbfn7ujQMIHtMCgVutiV71mdocrwxt3lHC4xRVZuix9i2I2HIoJwM3hac Lr0AcY3yX4ela8+zEFpwYLahKLLCzQBkw2/UX/09SkPeveFFDmiH8bIWkEAgvn1SHZ /qe0QMdDdwlPg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F2E1A68030; Thu, 9 Oct 2025 21:43:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 9 Oct 2025 21:42:33 -0600 Message-ID: <20251010034255.1099728-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251010034255.1099728-1-sjg@u-boot.org> References: <20251010034255.1099728-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YUGY6Q3R63OZ7H5TEIVI7FRQ4EIVMBER X-Message-ID-Hash: YUGY6Q3R63OZ7H5TEIVI7FRQ4EIVMBER X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/18] expo: Provide user-friendly output of scene enums List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a few functions which can convert a flag and an object type to strings. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/scene.c | 42 ++++++++++++++++++++++++++++++++++++++++++ boot/scene_internal.h | 16 ++++++++++++++++ test/boot/expo.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/boot/scene.c b/boot/scene.c index ec0c5899bca..c2e4d8e1330 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -19,6 +19,29 @@ #include #include "scene_internal.h" +static const char *const scene_flag_names[] = { + "hide", + "point", + "open", + "size_valid", + "sync_pos", + "sync_size", + "sync_width", + "sync_bbox", + "manual", + "dirty", +}; + +static const char *const scene_obj_type_names[] = { + "none", + "image", + "text", + "box", + "textedit", + "menu", + "textline", +}; + int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp) { struct scene *scn; @@ -1634,3 +1657,22 @@ int scene_dims_union(struct scene *scn, uint id, struct scene_obj_dims *dims) return 0; } + +const char *scene_flag_name(uint flag) +{ + int bit; + + bit = ffs(flag) - 1; + if (bit < 0 || bit >= ARRAY_SIZE(scene_flag_names)) + return "(none)"; + + return scene_flag_names[bit]; +} + +const char *scene_obj_type_name(enum scene_obj_t type) +{ + if (type >= ARRAY_SIZE(scene_obj_type_names)) + return "unknown"; + + return scene_obj_type_names[type]; +} diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 00696979f7d..9bf2cb8f8f2 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -540,4 +540,20 @@ int scene_calc_arrange(struct scene *scn, struct expo_arrange_info *arr); int scene_txt_generic_init(struct expo *exp, struct scene_txt_generic *gen, const char *name, uint str_id, const char *str); +/** + * scene_flag_name() - Get the name of a scene flag + * + * @flag: Single-bit flag mask (e.g. BIT(7)) + * Return: Flag name, or "(none)" if flag is 0 or out of range + */ +const char *scene_flag_name(uint flag); + +/** + * scene_obj_type_name() - Get the name of a scene object type + * + * @type: Object type + * Return: Type name, or "unknown" if out of range + */ +const char *scene_obj_type_name(enum scene_obj_t type); + #endif /* __SCENE_INTERNAL_H */ diff --git a/test/boot/expo.c b/test/boot/expo.c index 8a401ba9884..7c27da165c5 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1220,3 +1220,41 @@ static int expo_test_calc_fps(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(expo_test_calc_fps, 0); + +/* Test scene_flag_name() */ +static int expo_scene_flag_name(struct unit_test_state *uts) +{ + /* Test valid flags */ + ut_asserteq_str("hide", scene_flag_name(SCENEOF_HIDE)); + ut_asserteq_str("point", scene_flag_name(SCENEOF_POINT)); + ut_asserteq_str("open", scene_flag_name(SCENEOF_OPEN)); + ut_asserteq_str("manual", scene_flag_name(SCENEOF_MANUAL)); + + /* Test invalid flag (0) */ + ut_asserteq_str("(none)", scene_flag_name(0)); + + /* Test invalid flag (out of range) */ + ut_asserteq_str("(none)", scene_flag_name(BIT(20))); + + return 0; +} +BOOTSTD_TEST(expo_scene_flag_name, 0); + +/* Test scene_obj_type_name() */ +static int expo_scene_obj_type_name(struct unit_test_state *uts) +{ + /* Test all valid object types */ + ut_asserteq_str("none", scene_obj_type_name(SCENEOBJT_NONE)); + ut_asserteq_str("image", scene_obj_type_name(SCENEOBJT_IMAGE)); + ut_asserteq_str("text", scene_obj_type_name(SCENEOBJT_TEXT)); + ut_asserteq_str("box", scene_obj_type_name(SCENEOBJT_BOX)); + ut_asserteq_str("menu", scene_obj_type_name(SCENEOBJT_MENU)); + ut_asserteq_str("textline", scene_obj_type_name(SCENEOBJT_TEXTLINE)); + ut_asserteq_str("textedit", scene_obj_type_name(SCENEOBJT_TEXTEDIT)); + + /* Test invalid type (out of range) */ + ut_asserteq_str("unknown", scene_obj_type_name(SCENEOBJT_TEXTLINE + 1)); + + return 0; +} +BOOTSTD_TEST(expo_scene_obj_type_name, 0);