improved check SOC

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-07-26 22:30:49 +08:00
parent d9d06eba11
commit c8620f8d6a
2 changed files with 27 additions and 2 deletions

View File

@ -29,6 +29,18 @@ namespace hgl
ENUM_CLASS_RANGE(Unknow,JLQ) ENUM_CLASS_RANGE(Unknow,JLQ)
}; };
constexpr const char *SOCVendorName[16]=
{
"Unknow",
"Qualcomm",
"Hisilicon",
"Samsung",
"MediaTek",
"Unisoc",
"Spreadtrum",
"JLQ",
};
enum class CpuArch enum class CpuArch
{ {
Unknow=0, Unknow=0,

View File

@ -24,7 +24,7 @@ namespace
p+=3; p+=3;
while(!hgl::isalpha(*p))++p; //碰到字母再停下来 while(!hgl::isalnum(*p))++p; //碰到字母再停下来
hgl::strcpy(soc.model,sizeof(soc.model),p); hgl::strcpy(soc.model,sizeof(soc.model),p);
} }
@ -38,7 +38,17 @@ namespace
bool isMediaTek(SOCModel &soc,const char *soc_name) bool isMediaTek(SOCModel &soc,const char *soc_name)
{ {
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"MT",2); const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"MTK ",4);
if(p)
{
p+=4;
hgl::strcpy(soc.model,sizeof(soc.model),p);
return(true);
}
p=hgl::stristr(soc_name,hgl::strlen(soc_name),"MT",2);
if(!p) if(!p)
return(false); return(false);
@ -144,6 +154,8 @@ namespace hgl
{ {
bool ParseSOCModel(SOCModel &soc,const char *soc_name) bool ParseSOCModel(SOCModel &soc,const char *soc_name)
{ {
hgl_zero(soc);
if(hgl::strlen(soc_name)>0) if(hgl::strlen(soc_name)>0)
{ {
if(isQualcomm (soc,soc_name))return(true); if(isQualcomm (soc,soc_name))return(true);
@ -156,6 +168,7 @@ namespace hgl
} }
soc.vendor=SOCVendor::Unknow; soc.vendor=SOCVendor::Unknow;
return(false); return(false);
} }
}//namespace hgl }//namespace hgl