Skip to content

Commit b912c45

Browse files
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.
1 parent e4cadd0 commit b912c45

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

src/arm/linux/chipset.c

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

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

2892+
/* Check s5eXXXX (Samsung Exynos) signature */
2893+
if (match_s5e(board, board_end, &chipset)) {
2894+
cpuinfo_log_debug(
2895+
"matched S5E (Samsung Exynos) signature in ro.product.board string \"%.*s\"",
2896+
(int)board_length,
2897+
board);
2898+
return chipset;
2899+
}
2900+
28402901
#if CPUINFO_ARCH_ARM
28412902
/* Check SMDK (Samsung Exynos) signature */
28422903
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)