Skip to content

Commit

Permalink
Syncup of Metrological plugins from Metrological version
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Feb 15, 2024
1 parent 5dff08c commit 6f27bab
Show file tree
Hide file tree
Showing 86 changed files with 3,674 additions and 2,003 deletions.
60 changes: 32 additions & 28 deletions DeviceIdentification/DeviceIdentification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,55 +94,59 @@ namespace Plugin {
message = _T("DeviceIdentification plugin could not be instantiated.");
}

#ifndef USE_THUNDER_R4
if (message.length() != 0) {
Deinitialize(service);
}
#endif

return message;
}

/* virtual */ void DeviceIdentification::Deinitialize(PluginHost::IShell* service)
{
ASSERT(_service == service);
if (_service != nullptr) {
ASSERT(_service == service);

_service->Unregister(&_notification);
_service->Unregister(&_notification);

if (_deviceId.empty() != true) {
if (_deviceId.empty() != true) {
#ifndef DISABLE_DEVICEID_CONTROL
service->SubSystems()->Set(PluginHost::ISubSystem::IDENTIFIER, nullptr);
service->SubSystems()->Set(PluginHost::ISubSystem::IDENTIFIER, nullptr);
#endif
_deviceId.clear();
}
if(_identifier != nullptr) {
_deviceId.clear();
}
if (_identifier != nullptr) {

UnregisterAll();
UnregisterAll();

// Stop processing:
RPC::IRemoteConnection* connection = service->RemoteConnection(_connectionId);
// Stop processing:
RPC::IRemoteConnection* connection = service->RemoteConnection(_connectionId);

VARIABLE_IS_NOT_USED uint32_t result = _identifier->Release();
_identifier = nullptr;
VARIABLE_IS_NOT_USED uint32_t result = _identifier->Release();
_identifier = nullptr;

// It should have been the last reference we are releasing,
// so it should endup in a DESTRUCTION_SUCCEEDED, if not we
// are leaking...
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED);
// It should have been the last reference we are releasing,
// so it should endup in a DESTRUCTION_SUCCEEDED, if not we
// are leaking...
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED);

// If this was running in a (container) process...
if (connection != nullptr) {
// Lets trigger the cleanup sequence for
// out-of-process code. Which will guard
// that unwilling processes, get shot if
// not stopped friendly :-)
connection->Terminate();
connection->Release();
// If this was running in a (container) process...
if (connection != nullptr) {
// Lets trigger the cleanup sequence for
// out-of-process code. Which will guard
// that unwilling processes, get shot if
// not stopped friendly :-)
connection->Terminate();
connection->Release();
}
}
}

_connectionId = 0;
_connectionId = 0;

_service->Release();
_service = nullptr;
_service->Release();
_service = nullptr;
}
}

/* virtual */ string DeviceIdentification::Information() const
Expand Down
3 changes: 3 additions & 0 deletions DeviceIdentification/DeviceIdentification.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ namespace Plugin {
{
_parent.Deactivated(connectionId);
}
void Terminated(RPC::IRemoteConnection* /* connection */) override
{
}

BEGIN_INTERFACE_MAP(Notification)
INTERFACE_ENTRY(RPC::IRemoteConnection::INotification)
Expand Down
31 changes: 25 additions & 6 deletions DeviceIdentification/Implementation/Amlogic/Amlogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
namespace WPEFramework {
namespace Plugin {
class DeviceImplementation : public PluginHost::ISubSystem::IIdentifier {
static constexpr const TCHAR* ChipsetInfo= _T("T962X3");
static constexpr const TCHAR* ChipsetInfo= _T("T962X3");
static constexpr const TCHAR* VERSIONFile = _T("/version.txt");
static constexpr const TCHAR* CMDLineFile = _T("/proc/cmdline");

public:
DeviceImplementation()
: _chipset()
, _firmwareVersion()
, _identity()
{
UpdateChipset(_chipset);
UpdateFirmwareVersion(_firmwareVersion);
Expand Down Expand Up @@ -88,11 +92,26 @@ namespace Plugin {

inline void UpdateIdentifier()
{
/*
* @TODO : Update proper code for identifier when SOC ID is made
* available for Amlogic boards
*/
_identity.assign("");
string line;
std::ifstream file(CMDLineFile);
if (file.is_open()) {
while (getline(file, line)) {
std::size_t position;
if ((position = line.find("serialno")) != std::string::npos) {
position = line.find("=", position);
if (position != std::string::npos) {
std::size_t begin = position + 2;
std::size_t end = line.find(' ', begin);
_identity.assign(line.substr(begin, (end - begin)));
break;
}
}
}
file.close();
}
if (_identity.empty() == true) {
TRACE(Trace::Error, (_T("There is no any valid identifier available")));
}
}

private:
Expand Down
4 changes: 1 addition & 3 deletions DeviceIdentification/Implementation/RPI/RPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ namespace Plugin {
}
inline void UpdateDeviceIdentifier(string& identifier) const
{
string fileName = SerialInfoPath;
WPEFramework::Core::File serialFile(fileName);

WPEFramework::Core::File serialFile(SerialInfoPath);
if (serialFile.Open(true) == true) {
uint8_t serialInfo[serialFile.Size()];
uint32_t size = serialFile.Read(serialInfo, static_cast<uint32_t>(sizeof(serialInfo)));
Expand Down
2 changes: 0 additions & 2 deletions DisplayInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES)

target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME})

target_link_libraries(${MODULE_NAME}
PRIVATE
CompileSettingsDebug::CompileSettingsDebug
Expand Down
12 changes: 6 additions & 6 deletions DisplayInfo/DeviceSettings/Amlogic/SoC_abstraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static void getPrimaryPlane(int drm_fd, kms_ctx *kms, drmModePlane **plane)
kms_get_plane(drm_fd, kms);
cout << "Primary Plane ID : "<< kms->primary_plane_id << endl;
*plane = drmModeGetPlane(drm_fd, kms->primary_plane_id );
if(*plane)
if (*plane)
printf("fb id : %d\n", (*plane)->fb_id);
}

Expand All @@ -113,14 +113,14 @@ static void getGraphicSize(uint32_t &w, uint32_t &h)

/* Setup KMS */
kms = kms_setup(drm_fd);
if(!kms || !kms->crtc ) {
if (!kms || !kms->crtc ) {
cout << "[Amlogic] kms_setup fail" << endl;
break;
}

/* Get primary buffer */
getPrimaryPlane(drm_fd, kms, &plane);
if( !plane) {
if ( !plane) {
cout << "[Amlogic] fail to getPrimaryPlane" << endl;
break;
}
Expand All @@ -137,7 +137,7 @@ static void getGraphicSize(uint32_t &w, uint32_t &h)
}

/* Get the width and height */
if(fb) {
if (fb) {
w = fb->width;
h = fb->height;
drmModeFreeFB(fb);
Expand All @@ -146,14 +146,14 @@ static void getGraphicSize(uint32_t &w, uint32_t &h)

/* release */
/* Cleanup buffer info */
if(kms) {
if (kms) {
kms_cleanup_context(kms);
free(kms);
}

cout << "[getGraphicSize] width : " << w << endl;
cout << "[getGraphicSize] height : " << h << endl;
if(drm_fd >= 0){
if (drm_fd >= 0) {
close(drm_fd);
}
}
Expand Down
32 changes: 16 additions & 16 deletions DisplayInfo/DeviceSettings/Amlogic/kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

void kms_setup_encoder( int fd, kms_ctx *kms )
{
for( int i = 0; i < kms->res->count_encoders; i++ ) {
for ( int i = 0; i < kms->res->count_encoders; i++ ) {

kms->encoder = drmModeGetEncoder(fd,kms->res->encoders[i]);

if(!kms->encoder){
if ( !kms->encoder ) {
return;
}

Expand All @@ -40,9 +40,9 @@ void kms_setup_encoder( int fd, kms_ctx *kms )
}


for( int j = 0; j < kms->res->count_crtcs; j++ ) {
for ( int j = 0; j < kms->res->count_crtcs; j++ ) {

if( kms->encoder->possible_crtcs & ( 1 << j ) ) {
if ( kms->encoder->possible_crtcs & ( 1 << j ) ) {

drmModeFreeEncoder( kms->encoder );
kms->encoder = drmModeGetEncoder(fd, kms->res->encoders[j]);
Expand All @@ -65,12 +65,12 @@ void kms_setup_connector( int fd, kms_ctx *kms )
int i = 0;
drmModeConnector *connector = NULL;

for( i = 0; i < kms->res->count_connectors; i++ ) {
for ( i = 0; i < kms->res->count_connectors; i++ ) {

connector = drmModeGetConnector(fd, kms->res->connectors[i]);
if( connector ) {
if ( connector ) {

if( connector->count_modes && ( connector->connection == DRM_MODE_CONNECTED ) ) {
if ( connector->count_modes && ( connector->connection == DRM_MODE_CONNECTED ) ) {
break;
}
}
Expand All @@ -88,11 +88,11 @@ void kms_setup_connector( int fd, kms_ctx *kms )

void kms_setup_crtc( int fd, kms_ctx *kms )
{
if( kms->encoder ) {
if ( kms->encoder ) {

kms->crtc = drmModeGetCrtc(fd, kms->encoder->crtc_id);

if( kms->crtc && kms->crtc->mode_valid ) {
if ( kms->crtc && kms->crtc->mode_valid ) {

kms->current_info = kms->crtc->mode;
kms->crtc_id = kms->encoder->crtc_id;
Expand All @@ -107,7 +107,7 @@ kms_ctx* kms_setup( int fd )
{
kms_ctx *kms = NULL;
kms = (kms_ctx*)calloc(1,sizeof(*kms));
if( !kms )
if ( !kms )
assert(0);

kms->res = drmModeGetResources(fd);
Expand All @@ -121,16 +121,16 @@ kms_ctx* kms_setup( int fd )

void kms_cleanup_context( kms_ctx *kms )
{
if( kms->connector )
if ( kms->connector )
drmModeFreeConnector(kms->connector);

if( kms->encoder )
if ( kms->encoder )
drmModeFreeEncoder(kms->encoder);

if( kms->crtc )
if ( kms->crtc )
drmModeFreeCrtc(kms->crtc);

if( kms->res )
if ( kms->res )
drmModeFreeResources(kms->res);
}

Expand Down Expand Up @@ -172,7 +172,7 @@ void kms_get_plane( int fd, kms_ctx *kms )
planeRes = drmModeGetPlaneResources( fd );
if ( planeRes ) {

for( n= 0; n < planeRes->count_planes; ++n ) {
for ( n= 0; n < planeRes->count_planes; ++n ) {

plane = drmModeGetPlane( fd, planeRes->planes[n] );

Expand All @@ -181,7 +181,7 @@ void kms_get_plane( int fd, kms_ctx *kms )
props = drmModeObjectGetProperties( fd, planeRes->planes[n], DRM_MODE_OBJECT_PLANE );
if ( props ) {

for( j= 0; j < props->count_props; ++j ) {
for ( j= 0; j < props->count_props; ++j ) {

prop = drmModeGetProperty( fd, props->props[j] );
if ( prop ) {
Expand Down
12 changes: 6 additions & 6 deletions DisplayInfo/DeviceSettings/Broadcom/SoC_abstraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ string parse_proc_brcm_core(string columnHeader)
{
while (getline(procfile,line))
{
if(line.find(columnHeader) != string::npos)
if (line.find(columnHeader) != string::npos)
{
tokens.clear();
sanitizeLine(line);
tokenize(line, tokens, ' ');
column = find(tokens.begin(), tokens.end(), columnHeader) - tokens.begin(); //found the column where the data can be found
}
if(line.find("GFX") != string::npos)
if (line.find("GFX") != string::npos)
{
tokens.clear();
sanitizeLine(line);
Expand Down Expand Up @@ -132,7 +132,7 @@ string parse_proc_brcm_display()
{
while (getline(procfile,line))
{
if(line.find("graphics") != string::npos)
if (line.find("graphics") != string::npos)
{
tokens.clear();
sanitizeLine(line);
Expand Down Expand Up @@ -189,7 +189,7 @@ uint32_t SoC_GetGraphicsWidth()
string value = parse_proc_brcm_display();
LOGINFO("graphics plane dimensions returned from proc = %s" , value.c_str());
tokenize(value, resolution, 'x'); // graphics resolution is in the format 1280x720
if(resolution.size() > WIDTH)
if (resolution.size() > WIDTH)
{
try
{
Expand All @@ -212,7 +212,7 @@ uint32_t SoC_GetGraphicsHeight()
string value = parse_proc_brcm_display();
LOGINFO("graphics plane dimensions returned from proc = %s" , value.c_str());
tokenize(value, resolution, 'x'); // graphics resolution is in the format 1280x720
if(resolution.size() > HEIGHT)
if (resolution.size() > HEIGHT)
{
try
{
Expand All @@ -225,4 +225,4 @@ uint32_t SoC_GetGraphicsHeight()
}
}
return ret;
}
}
Loading

0 comments on commit 6f27bab

Please sign in to comment.