CMPlatform/src/SOC/SOC.cpp

162 lines
3.7 KiB
C++
Raw Normal View History

#include<hgl/type/StrChar.h>
#include<hgl/platform/SOC.h>
using namespace hgl;
namespace
{
2023-07-17 20:36:05 +08:00
bool isQualcomm(SOCModel &soc,const char *soc_name)
{
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"Qualcomm ",9);
if(!p)
return(false);
soc.vendor=SOCVendor::Qualcomm;
p+=9;
if(*p=='T') //"Qualcomm Technologies, Inc" 但是里面有写逗号的有写句号的所以我找最后的Inc
{
2023-07-13 21:10:46 +08:00
p=hgl::stristr(p,hgl::strlen(p),"Inc",3);
if(!p)
return(false);
2023-07-13 21:10:46 +08:00
p+=3;
while(!hgl::isalpha(*p))++p; //碰到字母再停下来
hgl::strcpy(soc.model,sizeof(soc.model),p);
}
else //如“Qualcomm APQ8084”这种
{
hgl::strcpy(soc.model,sizeof(soc.model),p);
}
return(true);
}
2023-07-17 20:36:05 +08:00
bool isMediaTek(SOCModel &soc,const char *soc_name)
{
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"MT",2);
if(!p)
return(false);
soc.vendor=SOCVendor::MediaTek;
p+=2;
hgl::strcpy(soc.model,sizeof(soc.model),p,4);
return(true);
}
2023-07-17 20:36:05 +08:00
bool isUnisoc(SOCModel &soc,const char *soc_name)
{
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"Unisoc",6);
if(!p)
return(false);
soc.vendor=SOCVendor::Unisoc;
if(p==soc_name) //就在最前面,"Unisoc ...."结构
{
hgl::strcpy(soc.model,sizeof(soc.model),p+7);
}
else //在型号后面,"Txxx-Unisoc"结构
{
hgl::strcpy(soc.model,sizeof(soc.model),soc_name,p-soc_name-1);
}
return(true);
}
2023-07-17 20:36:05 +08:00
bool isKirin(SOCModel &soc,const char *soc_name)
{
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"Kirin",5);
if(!p)
return(false);
soc.vendor=SOCVendor::Hisilicon;
hgl::strcpy(soc.model,sizeof(soc.model),p+5);
return(true);
}
2023-07-17 20:36:05 +08:00
bool isExynos(SOCModel &soc,const char *soc_name)
{
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"Exynos",6);
if(!p)
return(false);
soc.vendor=SOCVendor::Samsung;
p+=6;
if(*p==' ')++p;
hgl::strcpy(soc.model,sizeof(soc.model),p);
return(true);
}
2023-07-17 20:36:05 +08:00
bool isSpreadtrum(SOCModel &soc,const char *soc_name)
{
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"Spreadtrum",10);
if(!p)
return(false);
soc.vendor=SOCVendor::Spreadtrum;
p+=10;
if(*p==' ')++p;
hgl::strcpy(soc.model,sizeof(soc.model),p);
return(true);
}
2023-07-17 20:36:05 +08:00
bool isJLQ(SOCModel &soc,const char *soc_name)
{
const char *p=hgl::stristr(soc_name,hgl::strlen(soc_name),"JLQ ",4);
if(!p)
return(false);
soc.vendor=SOCVendor::JLQ;
p+=4;
hgl::strcpy(soc.model,sizeof(soc.model),p);
return(true);
}
}//namespace
namespace hgl
{
2023-07-17 20:36:05 +08:00
bool ParseSOCModel(SOCModel &soc,const char *soc_name)
{
if(hgl::strlen(soc_name)>0)
{
if(isQualcomm (soc,soc_name))return(true);
if(isKirin (soc,soc_name))return(true);
if(isMediaTek (soc,soc_name))return(true);
if(isUnisoc (soc,soc_name))return(true);
if(isExynos (soc,soc_name))return(true);
if(isSpreadtrum (soc,soc_name))return(true);
if(isJLQ (soc,soc_name))return(true);
}
soc.vendor=SOCVendor::Unknow;
return(false);
}
}//namespace hgl