Skip to content

Commit 37b484a

Browse files
Fix Samsung Exynos 2000 series chipset detection (#309)
* Fix Samsung Exynos 2000 series chipset detection Add support for "s5e" prefix pattern matching in `ro.product.board` property to correctly identify Samsung Exynos 2000 series chipsets. These chipsets use generic identifiers (e.g., `s5e9925`) instead of marketing names like "Exynos 2200", but can still be identified and mapped to their corresponding models using external resources. Implements `match_s5e()` function to parse the s5e<4-digit-model> format. * Clean up whitespace in chipset.c --------- Co-authored-by: Byoungchan Lee <daniel.l@hpcnt.com>
1 parent 877328f commit 37b484a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/arm/linux/chipset.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,56 @@ static bool match_universal(const char* start, const char* end, struct cpuinfo_a
468468
return true;
469469
}
470470

471+
/**
472+
* Tries to match /s5e\d{4}$/ signature for Samsung Exynos chipsets.
473+
* If match successful, extracts model information into \p chipset argument.
474+
*
475+
* @param start - start of the platform identifier (ro.product.board or
476+
* ro.board.platform) to match.
477+
* @param end - end of the platform identifier (ro.product.board or
478+
* ro.board.platform) to match.
479+
* @param[out] chipset - location where chipset information will be stored upon
480+
* a successful match.
481+
*
482+
* @returns true if signature matched, false otherwise.
483+
*/
484+
static bool match_s5e(const char* start, const char* end, struct cpuinfo_arm_chipset chipset[restrict static 1]) {
485+
/* Expect exactly 7 symbols: "s5e" (3 symbols) + 4-digit model number */
486+
if (start + 7 != end) {
487+
return false;
488+
}
489+
490+
/* Check that string starts with "s5e" */
491+
if (start[0] != 's') {
492+
return false;
493+
}
494+
495+
/* Load next 2 bytes as little endian 16-bit word */
496+
const uint16_t expected_5e = load_u16le(start + 1);
497+
if (expected_5e != UINT16_C(0x6535) /* "e5" = reverse("5e") */) {
498+
return false;
499+
}
500+
501+
/* Check and parse 4-digit model number */
502+
uint32_t model = 0;
503+
for (uint32_t i = 3; i < 7; i++) {
504+
const uint32_t digit = (uint32_t)(uint8_t)start[i] - '0';
505+
if (digit >= 10) {
506+
/* Not really a digit */
507+
return false;
508+
}
509+
model = model * 10 + digit;
510+
}
511+
512+
/* Return parsed chipset. */
513+
*chipset = (struct cpuinfo_arm_chipset){
514+
.vendor = cpuinfo_arm_chipset_vendor_samsung,
515+
.series = cpuinfo_arm_chipset_series_samsung_exynos,
516+
.model = model,
517+
};
518+
return true;
519+
}
520+
471521
/**
472522
* Compares, case insensitively, a string to known values "SMDK4210" and
473523
* "SMDK4x12" for Samsung Exynos chipsets. If platform identifier matches one of
@@ -2837,6 +2887,15 @@ struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_product_bo
28372887
return chipset;
28382888
}
28392889

2890+
/* Check s5eXXXX (Samsung Exynos) signature */
2891+
if (match_s5e(board, board_end, &chipset)) {
2892+
cpuinfo_log_debug(
2893+
"matched S5E (Samsung Exynos) signature in ro.product.board string \"%.*s\"",
2894+
(int)board_length,
2895+
board);
2896+
return chipset;
2897+
}
2898+
28402899
#if CPUINFO_ARCH_ARM
28412900
/* Check SMDK (Samsung Exynos) signature */
28422901
if (match_and_parse_smdk(board, board_end, cores, &chipset)) {

test/name/ro-product-board.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ TEST(RO_PRODUCT_BOARD, samsung_universal) {
169169
EXPECT_EQ("Samsung Exynos 8895", parse_ro_product_board("universal8895"));
170170
}
171171

172+
TEST(PROC_CPUINFO_HARDWARE, samsung_s5e) {
173+
EXPECT_EQ("Samsung Exynos 9925", parse_ro_product_board("s5e9925"));
174+
}
175+
172176
#if CPUINFO_ARCH_ARM
173177
TEST(RO_PRODUCT_BOARD, samsung_smdk) {
174178
EXPECT_EQ("Samsung Exynos 4212", parse_ro_product_board("smdk4x12", 2));

0 commit comments

Comments
 (0)