@@ -3492,9 +3492,20 @@ struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_chipname(
34923492 };
34933493}
34943494
3495+ /*
3496+ * Decodes chipset name from ro.soc.model Android system property.
3497+ *
3498+ * @param[in] soc_model - ro.soc.model value.
3499+ *
3500+ * @returns Decoded chipset name. If chipset could not be decoded, the resulting
3501+ * structure would use `unknown` vendor and series identifiers.
3502+ */
34953503struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_soc_model (
34963504 const char soc_model [restrict static CPUINFO_BUILD_PROP_VALUE_MAX ]) {
3497- struct cpuinfo_arm_chipset chipset ;
3505+ struct cpuinfo_arm_chipset chipset = {
3506+ .vendor = cpuinfo_arm_chipset_vendor_unknown ,
3507+ .series = cpuinfo_arm_chipset_series_unknown ,
3508+ };
34983509 const size_t soc_model_length = strnlen (soc_model , CPUINFO_BUILD_PROP_VALUE_MAX );
34993510 const char * soc_model_end = soc_model + soc_model_length ;
35003511
@@ -3516,10 +3527,28 @@ struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_soc_model(
35163527 return chipset ;
35173528 }
35183529
3519- return (struct cpuinfo_arm_chipset ){
3520- .vendor = cpuinfo_arm_chipset_vendor_unknown ,
3521- .series = cpuinfo_arm_chipset_series_unknown ,
3522- };
3530+ if (soc_model [0 ] != '\0' ) {
3531+ if (strncmp (soc_model , "Tensor" , 6 ) == 0 ) {
3532+ chipset .vendor = cpuinfo_arm_chipset_vendor_google ;
3533+ chipset .series = cpuinfo_arm_chipset_series_google_tensor ;
3534+ const char * suffix_start = soc_model + 6 ;
3535+ while (* suffix_start == ' ' ) {
3536+ suffix_start ++ ;
3537+ }
3538+ const size_t suffix_length = strnlen (suffix_start , CPUINFO_ARM_CHIPSET_SUFFIX_MAX );
3539+ if (suffix_length > 0 ) {
3540+ strncpy (chipset .suffix , suffix_start , suffix_length );
3541+ }
3542+ return chipset ;
3543+ } else if (strncmp (soc_model , "GS201" , 5 ) == 0 ) {
3544+ chipset .vendor = cpuinfo_arm_chipset_vendor_google ;
3545+ chipset .series = cpuinfo_arm_chipset_series_google_tensor ;
3546+ strncpy (chipset .suffix , "G2" , 2 );
3547+ return chipset ;
3548+ }
3549+ }
3550+
3551+ return chipset ;
35233552}
35243553#endif /* __ANDROID__ */
35253554
@@ -3858,6 +3887,7 @@ static const char* chipset_vendor_string[cpuinfo_arm_chipset_vendor_max] = {
38583887 [cpuinfo_arm_chipset_vendor_texas_instruments ] = "Texas Instruments" ,
38593888 [cpuinfo_arm_chipset_vendor_unisoc ] = "Unisoc" ,
38603889 [cpuinfo_arm_chipset_vendor_wondermedia ] = "WonderMedia" ,
3890+ [cpuinfo_arm_chipset_vendor_google ] = "Google" ,
38613891};
38623892
38633893/* Map from ARM chipset series ID to its string representation */
@@ -3895,6 +3925,7 @@ static const char* chipset_series_string[cpuinfo_arm_chipset_series_max] = {
38953925 [cpuinfo_arm_chipset_series_unisoc_t ] = "T" ,
38963926 [cpuinfo_arm_chipset_series_unisoc_ums ] = "UMS" ,
38973927 [cpuinfo_arm_chipset_series_wondermedia_wm ] = "WM" ,
3928+ [cpuinfo_arm_chipset_series_google_tensor ] = "Tensor" ,
38983929};
38993930
39003931/* Convert chipset name represented by cpuinfo_arm_chipset structure to a string
@@ -3913,14 +3944,35 @@ void cpuinfo_arm_chipset_to_string(
39133944 const char * vendor_string = chipset_vendor_string [vendor ];
39143945 const char * series_string = chipset_series_string [series ];
39153946 const uint32_t model = chipset -> model ;
3947+ const size_t suffix_length = strnlen (chipset -> suffix , CPUINFO_ARM_CHIPSET_SUFFIX_MAX );
39163948 if (model == 0 ) {
3917- if (series == cpuinfo_arm_chipset_series_unknown ) {
3918- strncpy (name , vendor_string , CPUINFO_ARM_CHIPSET_NAME_MAX );
3949+ if (suffix_length > 0 ) {
3950+ if (series == cpuinfo_arm_chipset_series_unknown ) {
3951+ snprintf (
3952+ name ,
3953+ CPUINFO_ARM_CHIPSET_NAME_MAX ,
3954+ "%s %.*s" ,
3955+ vendor_string ,
3956+ (int )suffix_length ,
3957+ chipset -> suffix );
3958+ } else {
3959+ snprintf (
3960+ name ,
3961+ CPUINFO_ARM_CHIPSET_NAME_MAX ,
3962+ "%s %s %.*s" ,
3963+ vendor_string ,
3964+ series_string ,
3965+ (int )suffix_length ,
3966+ chipset -> suffix );
3967+ }
39193968 } else {
3920- snprintf (name , CPUINFO_ARM_CHIPSET_NAME_MAX , "%s %s" , vendor_string , series_string );
3969+ if (series == cpuinfo_arm_chipset_series_unknown ) {
3970+ strncpy (name , vendor_string , CPUINFO_ARM_CHIPSET_NAME_MAX );
3971+ } else {
3972+ snprintf (name , CPUINFO_ARM_CHIPSET_NAME_MAX , "%s %s" , vendor_string , series_string );
3973+ }
39213974 }
39223975 } else {
3923- const size_t suffix_length = strnlen (chipset -> suffix , CPUINFO_ARM_CHIPSET_SUFFIX_MAX );
39243976 snprintf (
39253977 name ,
39263978 CPUINFO_ARM_CHIPSET_NAME_MAX ,
@@ -4051,7 +4103,6 @@ static enum cpuinfo_arm_chipset_vendor disambiguate_chipset_vendor(
40514103 (vendor_a == cpuinfo_arm_chipset_vendor_spreadtrum && vendor_b == cpuinfo_arm_chipset_vendor_unisoc )) {
40524104 return cpuinfo_arm_chipset_vendor_unisoc ;
40534105 }
4054-
40554106 return cpuinfo_arm_chipset_vendor_unknown ;
40564107}
40574108
0 commit comments