Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
bobseamon authored Mar 8, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 2b4598d + c9fe86e commit ffb85d4
Showing 250 changed files with 24,434 additions and 6,040 deletions.
8 changes: 6 additions & 2 deletions AVInput/AVInput.cpp
Original file line number Diff line number Diff line change
@@ -210,9 +210,13 @@ namespace WPEFramework {
// Thunder plugins communication
std::shared_ptr<WPEFramework::JSONRPC::LinkType<WPEFramework::Core::JSON::IElement> > AVInput::getThunderControllerClient()
{
string token;
Utils::SecurityToken::getSecurityToken(token);
string query = "token=" + token;

// making function local static to be thread safe
Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS)));
static std::shared_ptr<WPEFramework::JSONRPC::LinkType<WPEFramework::Core::JSON::IElement> > thunderClient = make_shared<WPEFramework::JSONRPC::LinkType<WPEFramework::Core::JSON::IElement> >("", "");
static std::shared_ptr<WPEFramework::JSONRPC::LinkType<WPEFramework::Core::JSON::IElement> > thunderClient = make_shared<WPEFramework::JSONRPC::LinkType<WPEFramework::Core::JSON::IElement> >("", "", false, query);
return thunderClient;
}

@@ -259,7 +263,7 @@ namespace WPEFramework {
{
if (p != m_activatedPlugins.end())
{
LOGWARN("Previoulsly active plugin %s appers to be deactivated, removing from the list", callSign);
LOGWARN("Previously active plugin %s appers to be deactivated, removing from the list", callSign);
m_activatedPlugins.erase(p);
}
} else {
2 changes: 2 additions & 0 deletions AVInput/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ add_library(${MODULE_NAME} SHARED
AVInput.cpp
Module.cpp
../helpers/tptimer.cpp
../helpers/utils.cpp
)

set_target_properties(${MODULE_NAME} PROPERTIES
@@ -36,6 +37,7 @@ target_include_directories(${MODULE_NAME} PRIVATE ../helpers)
target_link_libraries(${MODULE_NAME}
PRIVATE
${NAMESPACE}Protocols::${NAMESPACE}Protocols
${NAMESPACE}SecurityUtil
)
find_package(DS)
find_package(IARMBus)
1 change: 1 addition & 0 deletions AVInput/doc/AVInput.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[AVInput Docs](https://wiki.rdkcentral.com/display/RDK/AV+Input)
1 change: 1 addition & 0 deletions ActivityMonitor/doc/ActivityMonitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Activity Monitor docs](https://wiki.rdkcentral.com/display/RDK/ActivityMonitor)
2 changes: 2 additions & 0 deletions Bluetooth/doc/Bluetooth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Bluetooth](https://wiki.rdkcentral.com/display/RDK/Bluetooth)

364 changes: 187 additions & 177 deletions CMakeLists.txt

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions CompositeInput/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set(PLUGIN_NAME CompositeInput)
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})

find_package(${NAMESPACE}Plugins REQUIRED)

add_library(${MODULE_NAME} SHARED
CompositeInput.cpp
Module.cpp
../helpers/utils.cpp)

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES)

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/")

find_package(DS)
find_package(IARMBus)

target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS})
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS})
target_include_directories(${MODULE_NAME} PRIVATE ../helpers)

target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES} )

install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

write_config(${PLUGIN_NAME})
3 changes: 3 additions & 0 deletions CompositeInput/CompositeInput.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set (autostart false)
set (preconditions Platform)
set (callsign "org.rdk.CompositeInput")
286 changes: 286 additions & 0 deletions CompositeInput/CompositeInput.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2019 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#include "CompositeInput.h"
#include "utils.h"

#include "compositeIn.hpp"
#include "exception.hpp"
#include "dsUtl.h"
#include "dsError.h"
#include "dsMgr.h"

#define COMPOSITE_HOT_PLUG_EVENT_CONNECTED 1
#define COMPOSITE_HOT_PLUG_EVENT_DISCONNECTED 0

#define COMPOSITEINPUT_METHOD_GET_COMPOSITE_INPUT_DEVICES "getCompositeInputDevices"
#define COMPOSITEINPUT_METHOD_START_COMPOSITE_INPUT "startCompositeInput"
#define COMPOSITEINPUT_METHOD_STOP_COMPOSITE_INPUT "stopCompositeInput"
#define COMPOSITEINPUT_METHOD_SCALE_COMPOSITE_INPUT "setVideoRectangle"

#define COMPOSITEINPUT_EVENT_ON_DEVICES_CHANGED "onDevicesChanged"

namespace WPEFramework
{
namespace Plugin
{
SERVICE_REGISTRATION(CompositeInput, 1, 0);

CompositeInput* CompositeInput::_instance = nullptr;

CompositeInput::CompositeInput()
: AbstractPlugin()
{
LOGINFO();
CompositeInput::_instance = this;

InitializeIARM();

registerMethod(COMPOSITEINPUT_METHOD_GET_COMPOSITE_INPUT_DEVICES, &CompositeInput::getCompositeInputDevicesWrapper, this);
registerMethod(COMPOSITEINPUT_METHOD_START_COMPOSITE_INPUT, &CompositeInput::startCompositeInput, this);
registerMethod(COMPOSITEINPUT_METHOD_STOP_COMPOSITE_INPUT, &CompositeInput::stopCompositeInput, this);
registerMethod(COMPOSITEINPUT_METHOD_SCALE_COMPOSITE_INPUT, &CompositeInput::setVideoRectangleWrapper, this);
}

CompositeInput::~CompositeInput()
{
LOGINFO();
CompositeInput::_instance = nullptr;

DeinitializeIARM();
}

void CompositeInput::InitializeIARM()
{
LOGINFO();

if (Utils::IARM::init())
{
IARM_Result_t res;
IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, dsCompositeEventHandler) );
}
}

void CompositeInput::DeinitializeIARM()
{
LOGINFO();

if (Utils::IARM::isConnected())
{
IARM_Result_t res;
IARM_CHECK( IARM_Bus_UnRegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG) );
}
}

uint32_t CompositeInput::startCompositeInput(const JsonObject& parameters, JsonObject& response)
{
LOGINFO();
returnIfParamNotFound(parameters, "portId");

string sPortId = parameters["portId"].String();
int portId = 0;
try {
portId = stoi(sPortId);
}catch (const device::Exception& err) {
LOG_DEVICE_EXCEPTION1(sPortId);
returnResponse(false);
}

bool success = true;
try
{
device::CompositeInput::getInstance().selectPort(portId);
}
catch (const device::Exception& err)
{
LOG_DEVICE_EXCEPTION1(sPortId);
success = false;
}
returnResponse(success);

}

uint32_t CompositeInput::stopCompositeInput(const JsonObject& parameters, JsonObject& response)
{
LOGINFO();

bool success = true;
try
{
device::CompositeInput::getInstance().selectPort(-1);
}
catch (const device::Exception& err)
{
LOGWARN("CompositeInputService::stopCompositeInput Failed");
success = false;
}
returnResponse(success);

}

uint32_t CompositeInput::setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFO();

bool result = true;
if (!parameters.HasLabel("x") && !parameters.HasLabel("y"))
{
result = false;
response["message"] = "please specif coordinates (x,y)";
}

if (!parameters.HasLabel("w") && !parameters.HasLabel("h"))
{
result = false;
response["message"] = "please specify window width and height (w,h)";
}

if (result)
{
int x = 0;
int y = 0;
int w = 0;
int h = 0;

try
{
if (parameters.HasLabel("x"))
{
x = std::stoi(parameters["x"].String());
}
if (parameters.HasLabel("y"))
{
y = std::stoi(parameters["y"].String());
}
if (parameters.HasLabel("w"))
{
w = std::stoi(parameters["w"].String());
}
if (parameters.HasLabel("h"))
{
h = std::stoi(parameters["h"].String());
}
}
catch (...) {
LOGWARN("Invalid Arguments");
response["message"] = "Invalid Arguments";
returnResponse(false);
}

result = setVideoRectangle(x, y, w, h);
if (false == result) {
LOGWARN("CompositeInputService::setVideoRectangle Failed");
response["message"] = "failed to set scale";
}
}

returnResponse(result);

}

bool CompositeInput::setVideoRectangle(int x, int y, int width, int height)
{
bool ret = true;

try
{
device::CompositeInput::getInstance().scaleVideo(x, y, width, height);
}
catch (const device::Exception& err)
{
ret = false;
}

return ret;
}

uint32_t CompositeInput::getCompositeInputDevicesWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFO();

response["devices"] = getCompositeInputDevices();

returnResponse(true);
}

JsonArray CompositeInput::getCompositeInputDevices()
{
JsonArray list;
try
{
int num = device::CompositeInput::getInstance().getNumberOfInputs();
if (num > 0) {
int i = 0;
for (i = 0; i < num; i++) {
//Input ID is aleays 0-indexed, continuous number starting 0
JsonObject hash;
hash["id"] = i;
std::stringstream locator;
locator << "cvbsin://localhost/deviceid/" << i;
hash["locator"] = locator.str();
hash["connected"] = device::CompositeInput::getInstance().isPortConnected(i) ? "true" : "false";
LOGWARN("CompositeInputService::getCompositeInputDevices id %d, locator=[%s], connected=[%s]", i, hash["locator"].String().c_str(), hash["connected"].String().c_str());
list.Add(hash);
}
}
}
catch (const std::exception e) {
LOGWARN("CompositeInputService::getCompositeInputDevices Failed");
}

return list;
}


/**
* @brief This function is used to translate COMPOSITE input hotplug to
* deviceChanged event.
*
* @param[in] input Number of input port integer.
* @param[in] connection status of input port integer.
*/
void CompositeInput::compositeInputHotplug( int input , int connect)
{
LOGWARN("compositeInputHotplug [%d, %d]", input, connect);

JsonObject params;
params["devices"] = getCompositeInputDevices();
sendNotify(COMPOSITEINPUT_EVENT_ON_DEVICES_CHANGED, params);
}

void CompositeInput::dsCompositeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
{
LOGINFO();

if(!CompositeInput::_instance)
return;

if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG == eventId)
{
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
int compositein_hotplug_port = eventData->data.composite_in_connect.port;
int compositein_hotplug_conn = eventData->data.composite_in_connect.isPortConnected;
LOGWARN("Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG event data:%d", compositein_hotplug_port);

CompositeInput::_instance->compositeInputHotplug(compositein_hotplug_port, compositein_hotplug_conn ? COMPOSITE_HOT_PLUG_EVENT_CONNECTED : COMPOSITE_HOT_PLUG_EVENT_DISCONNECTED);
}
}

} // namespace Plugin
} // namespace WPEFramework
79 changes: 79 additions & 0 deletions CompositeInput/CompositeInput.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2019 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#pragma once

#include "libIBus.h"

#include "Module.h"
#include "utils.h"
#include "AbstractPlugin.h"

namespace WPEFramework {

namespace Plugin {

// This is a server for a JSONRPC communication channel.
// For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC.
// By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher.
// This realization of this interface implements, by default, the following methods on this plugin
// - exists
// - register
// - unregister
// Any other methood to be handled by this plugin can be added can be added by using the
// templated methods Register on the PluginHost::JSONRPC class.
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
// will receive a JSONRPC message as a notification, in case this method is called.
class CompositeInput : public AbstractPlugin {
private:

// We do not allow this plugin to be copied !!
CompositeInput(const CompositeInput&) = delete;
CompositeInput& operator=(const CompositeInput&) = delete;

void InitializeIARM();
void DeinitializeIARM();

//Begin methods
uint32_t getCompositeInputDevicesWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t startCompositeInput(const JsonObject& parameters, JsonObject& response);
uint32_t stopCompositeInput(const JsonObject& parameters, JsonObject& response);

uint32_t setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response);
//End methods

JsonArray getCompositeInputDevices();

bool setVideoRectangle(int x, int y, int width, int height);

void compositeInputHotplug( int input , int connect);
static void dsCompositeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);

public:
CompositeInput();
virtual ~CompositeInput();

void terminate();

public:
static CompositeInput* _instance;
};
} // namespace Plugin
} // namespace WPEFramework
9 changes: 9 additions & 0 deletions CompositeInput/CompositeInput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"locator":"libWPEFrameworkCompositeInput.so",
"classname":"CompositeInput",
"precondition":[
"Platform"
],
"callsign":"org.rdk.CompositeInput",
"autostart":false
}
22 changes: 22 additions & 0 deletions CompositeInput/Module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2019 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#include "Module.h"

MODULE_NAME_DECLARATION(BUILD_REFERENCE)
29 changes: 29 additions & 0 deletions CompositeInput/Module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2019 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#pragma once
#ifndef MODULE_NAME
#define MODULE_NAME CompositeInput
#endif

#include <plugins/plugins.h>
#include <tracing/tracing.h>

#undef EXTERNAL
#define EXTERNAL
9 changes: 9 additions & 0 deletions CompositeInput/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----------------
Build:

bitbake wpeframework-service-plugins

-----------------
Test:

curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "CompositeInput.1."}' http://127.0.0.1:9998/jsonrpc
57 changes: 57 additions & 0 deletions CompositeInput/cmake/FindDS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# - Try to find Display Settings library
# Once done this will define
# DS_FOUND - System has DS
# DS_INCLUDE_DIRS - The DS include directories
# DS_LIBRARIES - The libraries needed to use DS
# DS_FLAGS - The flags needed to use DS
#

find_package(PkgConfig)

find_library(DS_LIBRARIES NAMES ds)
find_path(DS_INCLUDE_DIRS NAMES hdmiIn.hpp PATH_SUFFIXES rdk/ds)

set(DS_LIBRARIES ${DS_LIBRARIES})
set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library")
set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS})
set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include")


find_library(DS_LIBRARIES NAMES ds)
#find_library(DSHAL_LIBRARIES NAMES dshalcli)
#find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES rdk/ds)
find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES rdk/ds-hal)
find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rdk/ds-rpc)

#set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES})
#set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library")
set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS})
#set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include")


include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DS DEFAULT_MSG DS_INCLUDE_DIRS DS_LIBRARIES)

mark_as_advanced(
DS_FOUND
DS_INCLUDE_DIRS
DS_LIBRARIES
DS_LIBRARY_DIRS
DS_FLAGS)
44 changes: 44 additions & 0 deletions CompositeInput/cmake/FindIARMBus.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# - Try to find IARMBus
# Once done this will define
# IARMBUS_FOUND - System has IARMBus
# IARMBUS_INCLUDE_DIRS - The IARMBus include directories
# IARMBUS_LIBRARIES - The libraries needed to use IARMBus
# IARMBUS_FLAGS - The flags needed to use IARMBus
#

find_package(PkgConfig)

find_library(IARMBUS_LIBRARIES NAMES IARMBus)
find_path(IARMIR_INCLUDE_DIRS NAMES sysMgr.h PATH_SUFFIXES rdk/iarmmgrs/sysmgr)

set(IARMBUS_LIBRARIES ${IARMBUS_LIBRARIES} CACHE PATH "Path to IARMBus library")
set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${SYSMGR_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS../sysmgr} )
set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${SYSMGR_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS../sysmgr} CACHE PATH "Path to IARMBus include")


include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES)

mark_as_advanced(
IARMBUS_FOUND
IARMBUS_INCLUDE_DIRS
IARMBUS_LIBRARIES
IARMBUS_LIBRARY_DIRS
IARMBUS_FLAGS)
80 changes: 80 additions & 0 deletions CompositeInput/doc/CompositeInput.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

Versions
org.rdk.CompositeInput.1 - initial version of Composite Input API.

------------------------------

Methods

-----------------------------

getCompositeInputDevices (v1)
Description: returns an array of composite input devices.

Arguments: none

Returns:

devices : array - an array of compositeInputDevice object (based on number of Composite Input ports on the device), where compositeInputDevice is:

{
id: number,
location: string,
connected: boolean
}



Request : {"jsonrpc":"2.0", "id":3, "method":"org.rdk.CompositeInput.1.getCompositeInputDevices"}

Response: {"jsonrpc":"2.0","id":3,"result":{"devices":[{"id":0,"locator":"cvbsin://localhost/deviceid/0","connected":"true"},{"id":1,"locator":"cvbsin://localhost/deviceid/1","connected":"false"}],"success":true}}


---------------------------------

startCompositeInput (v1)
Description: Activates selected Composite In Port as primary video source.

Arguments

portId : number - an id of Composite In source. (getCompositeInputDevices (v1) will list available Composite Input devices and portIds)
Returns:

success : bool - result of activating Composite Input
Request : {"jsonrpc":"2.0", "id":3, "method":"org.rdk.CompositeInput.1.startCompositeInput", "params": {"portId":"1"}}

Response: {"jsonrpc":"2.0","id":3,"result":{"success":true}}

---------------------------------

stopCompositeInput (v1)
Description: Deactivates current Composite In Port selected as primary video source.

Returns:

success : bool - result of deactivating Composite Input
Request : {"jsonrpc":"2.0", "id":3, "method":"org.rdk.CompositeInput.1.stopCompositeInput"}

Response: {"jsonrpc":"2.0","id":3,"result":{"success":true}}

--------------------------------

setVideoRectangle (v1)
Description: Sets Composite Input video window

Arguments

x: int - The x-coordinate of the video rectangle.
y: int - The y-coordinate of the video rectangle.
w: int - The width of the video rectangle.
h: int - The height of the video rectangle.
Returns:

success : bool - result of setting Composite Input video window
Request : {"jsonrpc":"2.0","id":"3","method": "org.rdk.CompositeInput.1.setVideoRectangle", "params":{"x":"0","y":"0","w":"1920","h":"1080"}}

Response: {"jsonrpc":"2.0","id":3,"result":{"success":true}}

--------------------------------


2 changes: 2 additions & 0 deletions ContinueWatching/doc/ContinueWatching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Continue Watching](https://wiki.rdkcentral.com/display/RDK/Continue+Watching)

11 changes: 10 additions & 1 deletion ControlService/ControlService.cpp
Original file line number Diff line number Diff line change
@@ -1240,7 +1240,16 @@ namespace WPEFramework {
keypressInfo["remoteId"] = JsonValue((int)lastKeyInfo.controller_id);
keypressInfo["timestamp"] = JsonValue((long long)lastKeyInfo.timestamp); // This timestamp is already in milliseconds
keypressInfo["sourceName"] = std::string(lastKeyInfo.source_name);
keypressInfo["sourceType"] = JsonValue((int)lastKeyInfo.source_type);

if (lastKeyInfo.source_type == IARM_BUS_IRMGR_KEYSRC_RF)
{
keypressInfo["sourceType"] = std::string("RF");
}
else
{
keypressInfo["sourceType"] = std::string("IR");
}

keypressInfo["sourceKeyCode"] = JsonValue((int)lastKeyInfo.source_key_code);
keypressInfo["bIsScreenBindMode"] = JsonValue((bool)lastKeyInfo.is_screen_bind_mode);
keypressInfo["remoteKeypadConfig"] = JsonValue((int)lastKeyInfo.remote_keypad_config);
2 changes: 2 additions & 0 deletions ControlService/doc/ControlService.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Control Service](https://wiki.rdkcentral.com/display/RDK/Control+Service)

2 changes: 2 additions & 0 deletions DataCapture/doc/DataCapture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[DataCapture](https://wiki.rdkcentral.com/display/RDK/DataCapture)

2 changes: 2 additions & 0 deletions DeviceDiagnostics/doc/DeviceDiagnostics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[DeviceDiagnostics](https://wiki.rdkcentral.com/display/RDK/Device+Diagnostics)

24 changes: 21 additions & 3 deletions DeviceIdentification/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -45,9 +45,23 @@ elseif (NEXUS_FOUND)
PRIVATE
NEXUS::NEXUS
NXCLIENT::NXCLIENT)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Nexus/Nexus.cpp)
if (DEVICEIDENTIFICATION_IMPLEMENTATION_PATH)
target_sources(${MODULE_NAME}
PRIVATE
${DEVICEIDENTIFICATION_IMPLEMENTATION_PATH}/Nexus.cpp)
else()
include(GetExternalCode)
set(DEVICEIDENTIFICATION_IMPLEMENTATION_VERSION "master" CACHE STRING "DeviceIdentification implementation version")
set(DEVICEIDENTIFICATION_IMPLEMENTATION_REPOSITORY "https://code.rdkcentral.com/r/soc/broadcom/components/rdkcentral/thundernanoservices/DeviceIdentification" CACHE STRING "DeviceIdentification implementation repository")
GetExternalCode(
GIT_REPOSITORY ${DEVICEIDENTIFICATION_IMPLEMENTATION_REPOSITORY}
GIT_TAG ${DEVICEIDENTIFICATION_IMPLEMENTATION_VERSION}
SOURCE_DIR "Implementation/Nexus"
)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Nexus/Nexus.cpp)
endif()
elseif (BCM_HOST_FOUND)
target_sources(${MODULE_NAME}
PRIVATE
@@ -59,6 +73,10 @@ elseif (BUILD_AMLOGIC)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Amlogic/Amlogic.cpp)
elseif (BUILD_REALTEK)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Realtek/Realtek.cpp)
else ()
message(FATAL_ERROR "There is no platform backend for device identifier plugin")
endif()
160 changes: 0 additions & 160 deletions DeviceIdentification/Implementation/Nexus/Nexus.cpp

This file was deleted.

135 changes: 135 additions & 0 deletions DeviceIdentification/Implementation/Realtek/Realtek.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "../../Module.h"
#include <interfaces/IDeviceIdentification.h>
#include <fstream>

namespace WPEFramework {
namespace Plugin {

class DeviceImplementation : public Exchange::IDeviceProperties, public PluginHost::ISubSystem::IIdentifier {
static constexpr const TCHAR* CPUInfoFile= _T("/proc/cpuinfo");
static constexpr const TCHAR* VERSIONFile= _T("/version.txt");

public:
DeviceImplementation()
{
UpdateChipset(_chipset);
UpdateFirmwareVersion(_firmwareVersion);
UpdateIdentifier();
}

DeviceImplementation(const DeviceImplementation&) = delete;
DeviceImplementation& operator= (const DeviceImplementation&) = delete;
virtual ~DeviceImplementation()
{
/* Nothing to do here. */
}

public:
// Device Propertirs interface
const string Chipset() const override
{
return _chipset;
}
const string FirmwareVersion() const override
{
return _firmwareVersion;
}

// Identifier interface
uint8_t Identifier(const uint8_t length, uint8_t buffer[]) const override
{
uint8_t result = 0;
if ((_identity.length())) {
result = (_identity.length() > length ? length : _identity.length());
::memcpy(buffer, _identity.c_str(), result);
} else {
SYSLOG(Logging::Notification, (_T("Cannot determine system identity")));
}
return result;
}

BEGIN_INTERFACE_MAP(DeviceImplementation)
INTERFACE_ENTRY(Exchange::IDeviceProperties)
INTERFACE_ENTRY(PluginHost::ISubSystem::IIdentifier)
END_INTERFACE_MAP

private:
inline void UpdateFirmwareVersion(string& firmwareVersion) const
{
string line;
std::ifstream file(VERSIONFile);
if (file.is_open()) {
while (getline(file, line)) {
if (line.find("SDK_VERSION") != std::string::npos) {
std::size_t position = line.find('=');
if (position != std::string::npos) {
firmwareVersion.assign(line.substr(position + 1, string::npos));
break;
}
}
}
file.close();
}
}

inline void UpdateChipset(string& chipset) const
{
string line;
std::ifstream file(CPUInfoFile);
if (file.is_open()) {
while (getline(file, line)) {
if (line.find("Hardware") != std::string::npos) {
std::size_t position = line.find(": ");
if (position != std::string::npos) {
chipset.assign(line.substr(position + 2, string::npos));
}
}
}
file.close();
}
}

inline void UpdateIdentifier()
{
string line;
std::ifstream file(CPUInfoFile);
if (file.is_open()) {
while (getline(file, line)) {
if (line.find("Serial") != std::string::npos) {
std::size_t position = line.find(": ");
if (position != std::string::npos) {
_identity.assign(line.substr(position + 2, string::npos));
}
}
}
file.close();
}
}

private:
string _chipset;
string _firmwareVersion;
string _identity;
};

SERVICE_REGISTRATION(DeviceImplementation, 1, 0);
}
}
2 changes: 1 addition & 1 deletion DeviceInfo/DeviceInfo.cpp
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ namespace Plugin {
JsonData::DeviceInfo::AddressesData& element(addressInfo.Add(newElement));

// get an interface with a public IP address, then we will have a proper MAC address..
Core::IPV4AddressIterator selectedNode(interfaces.Index());
Core::IPV4AddressIterator selectedNode(interfaces.IPV4Addresses());

while (selectedNode.Next() == true) {
Core::JSON::String nodeName;
10 changes: 5 additions & 5 deletions DeviceInfo/DeviceInfo.vcxproj
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;DEVICEINFO_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)../../;$(SolutionDir)thirdparty/windows/include;$(SolutionDir)thirdparty/windows/include/zlib;$(SolutionDir);$(SolutionDir)src/base</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(FrameworkPath);$(ContractsPath);$(WindowsPath);$(WindowsPath)zlib</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -122,7 +122,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;DEVICEINFO_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)../../;$(SolutionDir)thirdparty/windows/include;$(SolutionDir)thirdparty/windows/include/zlib;$(SolutionDir);$(SolutionDir)src/base</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(FrameworkPath);$(ContractsPath);$(WindowsPath);$(WindowsPath)zlib</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -140,7 +140,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;DEVICEINFO_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)../../;$(SolutionDir)thirdparty/windows/include;$(SolutionDir)thirdparty/windows/include/zlib;$(SolutionDir);$(SolutionDir)src/base</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(FrameworkPath);$(ContractsPath);$(WindowsPath);$(WindowsPath)zlib</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -160,7 +160,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;DEVICEINFO_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)../../;$(SolutionDir)thirdparty/windows/include;$(SolutionDir)thirdparty/windows/include/zlib;$(SolutionDir);$(SolutionDir)src/base</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(FrameworkPath);$(ContractsPath);$(WindowsPath);$(WindowsPath)zlib</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -182,4 +182,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
479 changes: 0 additions & 479 deletions DisplayInfo/Amlogic/PlatformImplementation.cpp

This file was deleted.

52 changes: 0 additions & 52 deletions DisplayInfo/Amlogic/amlDrmUtils.h

This file was deleted.

43 changes: 34 additions & 9 deletions DisplayInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ include_directories(${STAGING_INCDIR}/libdrm)

add_library(${MODULE_NAME} SHARED
DisplayInfo.cpp
DisplayInfoJsonRpc.cpp
Module.cpp)

set_target_properties(${MODULE_NAME} PROPERTIES
@@ -51,7 +50,21 @@ if (PLUGIN_DISPLAYINFO_BCM_VERSION_MAJOR)
DISPLAYINFO_BCM_VERSION_MAJOR=${PLUGIN_DISPLAYINFO_BCM_VERSION_MAJOR})
endif()

if (NXCLIENT_FOUND AND NEXUS_FOUND)
if (USE_DEVICESETTINGS)
find_package(DS REQUIRED)
find_package(IARMBus REQUIRED)
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}
${DS_INCLUDE_DIRS}
../helpers)
target_link_libraries(${MODULE_NAME} PRIVATE
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${IARMBUS_LIBRARIES}
${DS_LIBRARIES})
target_sources(${MODULE_NAME}
PRIVATE
DeviceSettings/PlatformImplementation.cpp
../helpers/utils.cpp)
elseif (NXCLIENT_FOUND AND NEXUS_FOUND)
target_sources(${MODULE_NAME}
PRIVATE
Nexus/PlatformImplementation.cpp)
@@ -66,18 +79,30 @@ elseif (BCM_HOST_FOUND)
target_link_libraries(${MODULE_NAME}
PRIVATE
BCM_HOST::BCM_HOST)
elseif (BUILD_AMLOGIC)
else ()
message(FATAL_ERROR "There is no graphic backend for display info plugin")
endif ()

if (BUILD_BROADCOM)
target_sources(${MODULE_NAME}
PRIVATE
Amlogic/PlatformImplementation.cpp)
target_link_libraries(${MODULE_NAME}
DeviceSettings/Broadcom/SoC_abstraction.cpp
)
elseif (BUILD_REALTEK)
target_sources(${MODULE_NAME}
PRIVATE
drm)
else ()
message(FATAL_ERROR "There is no graphic backend for display info plugin")
DeviceSettings/Realtek/SoC_abstraction.cpp
DeviceSettings/Realtek/kms.c
)
elseif (BUILD_AMLOGIC)
target_sources(${MODULE_NAME}
PRIVATE
DeviceSettings/Amlogic/SoC_abstraction.cpp
DeviceSettings/Amlogic/kms.c
)
endif ()

install(TARGETS ${MODULE_NAME}
install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

write_config(${PLUGIN_NAME})
180 changes: 180 additions & 0 deletions DisplayInfo/DeviceSettings/Amlogic/SoC_abstraction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string>
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "kms.h"

#define MEM_PROCFS "/proc/meminfo"
#define TOTAL_MEM_PARAM_STR "MemTotal:"
#define FREE_MEM_PARAM_STR "MemFree:"
#define DEFAULT_DEVICE "/dev/dri/card0"

using namespace std;

static uint64_t parseLine(const char * line);
static uint64_t getMemInfo(const char * param);
static void getPrimaryPlane(int drm_fd, kms_ctx *kms, drmModePlane **plane);
static void getGraphicSize(uint32_t &w, uint32_t &h);

static uint64_t parseLine(const char * line)
{
string str(line);
uint64_t val = 0;
size_t begin = str.find_first_of("0123456789");
size_t end = string::npos;

if (string::npos != begin)
end = str.find_first_not_of("0123456789", begin);

if (string::npos != begin && string::npos != end)
{

str = str.substr(begin, end);
val = strtoul(str.c_str(), NULL, 10);

}
else
{
cout << "Failed to parse: " << line << endl;
}

return val;
}

static uint64_t getMemInfo(const char * param)
{
FILE *meminfoFile = fopen(MEM_PROCFS, "r");
uint64_t memVal = 0;
if (NULL == meminfoFile)
{
cout << "Failed to open " << MEM_PROCFS << ", error: " << strerror(errno) << endl;
}
else
{
vector <char> buf;
buf.resize(1024);

while (fgets(buf.data(), buf.size(), meminfoFile))
{
if ( strstr(buf.data(), param ) == buf.data())
{
memVal = parseLine(buf.data()) * 1000;
break;
}
}

fclose(meminfoFile);
}
return memVal;
}

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)
printf("fb id : %d\n", (*plane)->fb_id);
}

static void getGraphicSize(uint32_t &w, uint32_t &h)
{
int drm_fd;
kms_ctx *kms = NULL;
drmModePlane *plane = NULL;
int trytimes = 0;

do {
/* Setup buffer information */
drm_fd = open( DEFAULT_DEVICE, O_RDWR);

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

/* Get primary buffer */
getPrimaryPlane(drm_fd, kms, &plane);
if( !plane) {
cout << "[Amlogic] fail to getPrimaryPlane" << endl;
break;
}

/* get fb */
drmModeFB *fb = drmModeGetFB(drm_fd, plane->fb_id);
while(!fb) {
getPrimaryPlane(drm_fd, kms, &plane);
fb = drmModeGetFB(drm_fd, plane->fb_id);
if (trytimes++ > 100) {
cout << "[Amlogic] fail to getPrimaryPlane" << endl;
break;
}
}

/* Get the width and height */
if(fb) {
w = fb->width;
h = fb->height;
drmModeFreeFB(fb);
}
} while(0);

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

cout << "[getGraphicSize] width : " << w << endl;
cout << "[getGraphicSize] height : " << h << endl;
}


uint64_t SoC_GetTotalGpuRam()
{
return getMemInfo(TOTAL_MEM_PARAM_STR);
}

uint64_t SoC_GetFreeGpuRam()
{
return getMemInfo(FREE_MEM_PARAM_STR);
}

uint32_t SoC_GetGraphicsWidth()
{
uint32_t w, h;
getGraphicSize(w, h);
return w;
}

uint32_t SoC_GetGraphicsHeight()
{
uint32_t w, h;
getGraphicSize(w, h);
return h;
}
211 changes: 211 additions & 0 deletions DisplayInfo/DeviceSettings/Amlogic/kms.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "kms.h"

void kms_setup_encoder( int fd, kms_ctx *kms )
{
int crtcId = 0;

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

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

if ( kms->encoder && ( kms->encoder->encoder_id == kms->connector->encoder_id ) ) {

kms->encoder_id = kms->encoder->encoder_id;
return;
}


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

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

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

crtcId = kms->res->crtcs[j];
kms->encoder->crtc_id = kms->crtc_id = j;
goto exit;
}
}
}

exit:
return;
}




void kms_setup_connector( int fd, kms_ctx *kms )
{
int i = 0, j = 0;
drmModeConnector *connector;

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

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

if( connector->count_modes && ( connector->connection == DRM_MODE_CONNECTED ) ) {
break;
}
}
}

if ( connector ) {

kms->connector = connector;
kms->connector_id = connector->connector_id;
}

return;
}


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

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

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

kms->current_info = kms->crtc->mode;
kms->crtc_id = kms->encoder->crtc_id;
}
}

return;
}


kms_ctx* kms_setup( int fd )
{
kms_ctx *kms = NULL;
kms = (kms_ctx*)calloc(1,sizeof(*kms));
if( !kms )
assert(0);

kms->res = drmModeGetResources(fd);

kms_setup_connector(fd, kms);
kms_setup_encoder(fd, kms);
kms_setup_crtc(fd, kms);
return kms;
}


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

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

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

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


uint32_t kms_get_properties(int fd, drmModeObjectProperties *props, const char *name)
{
drmModePropertyPtr property;
uint32_t i, id = 0;

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

property = drmModeGetProperty(fd, props->props[i]);
if (!strcmp(property->name, name))
id = property->prop_id;

drmModeFreeProperty(property);

if ( id )
return id;
}
}



void kms_get_plane( int fd, kms_ctx *kms )
{
int len = 0, n = 0, j = 0, plane_index = -1;

drmModePlane *plane = NULL;
drmModePlaneRes *planeRes = NULL;
drmModePropertyRes *prop = NULL;
drmModeObjectProperties *props = NULL;

drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);

kms->primary_plane_id = kms->overlay_plane_id = -1;

planeRes = drmModeGetPlaneResources( fd );
if ( planeRes ) {

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

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

if ( plane ) {

props = drmModeObjectGetProperties( fd, planeRes->planes[n], DRM_MODE_OBJECT_PLANE );
if ( props ) {

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

prop = drmModeGetProperty( fd, props->props[j] );
if ( prop ) {

len = strlen(prop->name);
if ( !strcmp( prop->name, "type") ) {

if ( ( props->prop_values[j] == DRM_PLANE_TYPE_PRIMARY ) && ( kms->primary_plane_id == -1 ) )
kms->primary_plane_id = planeRes->planes[n];

else if ( ( props->prop_values[j] == DRM_PLANE_TYPE_OVERLAY ) && ( kms->overlay_plane_id == -1 ) )
kms->overlay_plane_id = planeRes->planes[n];
}
}

drmModeFreeProperty( prop );
}
}

drmModeFreeObjectProperties( props );
}

drmModeFreePlane( plane );
}

}

drmModeFreePlaneResources( planeRes );
}
139 changes: 139 additions & 0 deletions DisplayInfo/DeviceSettings/Amlogic/kms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __DRM_KMS_H__
#define __DRM_KMS_H__

#include <xf86drm.h>
#include <xf86drmMode.h>
#include <drm_mode.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _kms_ctx {

drmModeRes *res;
drmModeConnector *connector;
drmModeEncoder *encoder;
drmModeCrtc *crtc;

drmModeCrtc *previous_crtc;
drmModeModeInfo current_info;

uint32_t connector_id; /**< Connector id which will be use in program */
uint32_t crtc_id;
uint32_t encoder_id;
uint32_t primary_plane_id;
uint32_t overlay_plane_id;

/* atomic properties */
uint32_t active_property;
uint32_t mode_id_property;
uint32_t crtc_id_property;
uint32_t blob_id;

uint32_t fb_id_property;
uint32_t crtc_x_property;
uint32_t crtc_y_property;
uint32_t crtc_h_property;
uint32_t crtc_w_property;
uint32_t src_x_property;
uint32_t src_y_property;
uint32_t src_w_property;
uint32_t src_h_property;

drmModeAtomicReq *req;

} kms_ctx;

/**
* @brief Create kms context
*
* @param[in] fd drm file descriptor
*
*
* @retval kms context
*/
kms_ctx* kms_setup(int fd);



/**
* @brief Cleanup kms context
*
* @param[in] kms kms context
*
*/
void kms_cleanup_context(kms_ctx *kms);

/**
* @brief Set and get possible encoder id
*
* @param[in] fd drm file descriptor
* @param[in] kms kms context
*
*/
void kms_setup_encoder(int fd, kms_ctx *kms);


/**
* @brief Set and get possible connector id
*
* @param[in] fd drm file descriptor
* @para,[in] kms kms context
*
*/
void kms_setup_connector(int fd, kms_ctx *kms);

/**
* @brief Set and get possible crtc id
*
* @param[in] fd drm file descriptor
* @param[in] kms kms context
*
*/
void kms_setup_crtc(int fd, kms_ctx *kms);

/**
* @brief Get the specific object properties
*
* @param[in] fd drm file descriptor
* @param[in] props all object properties
* @param[in] name the property name which want to be queried
*
*/
uint32_t kms_get_properties(int fd, drmModeObjectProperties *props, const char *name);


/**
* @brief Get primary and overlay plane.
* The plane id will set to -1 if cannot get.
*
* @param[in] fd drm file descriptor
* @param[in] kms kms context
*
*/
void kms_get_plane( int fd, kms_ctx *kms);

#ifdef __cplusplus
}
#endif
#endif
233 changes: 233 additions & 0 deletions DisplayInfo/DeviceSettings/Broadcom/SoC_abstraction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdint.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>

#include "utils.h"

#define GRAPHICS_RESOLUTION_LOC 4
#define WIDTH 0
#define HEIGHT 1
#define PROC_BRCM_CORE_PATH "/proc/brcm/core"
#define PROC_BRCM_DISPLAY_PATH "/proc/brcm/display"

using namespace std;
using namespace WPEFramework;

/**
* Sanitizeline
*
* @brief : Remove extra white spaces in between words
*
* @param : line to santize.
* @return : void
*/
void sanitizeLine(string& line)
{
for(int i = 0; i < line.size(); i++)
{
while(line[i] == ' ' && line[i+1] == ' ')
{
line.erase(i,1);
}
}
}

/**
* tokenize
*
* @brief : split line into tokens using delimitter
*
* @param : line
* @param : tokens array
* @param : delimitter
* @return : void
*/
void tokenize(string line, vector<string>& tokens, char delim)
{
istringstream iss(line);
string token;
while (getline(iss, token, delim))
{
tokens.push_back(token);
}
}

/**
* parse_proc_brcm_core
*
* @brief : parse profs to obtain GPU ram details
*
* @param : columnHeader
* @param : bufferName
* @return : value
*/
string parse_proc_brcm_core(string columnHeader)
{
LOGINFO();

ifstream procfile(PROC_BRCM_CORE_PATH);
string line, value;
vector<string> tokens;
int column = 0;

if (procfile.is_open())
{
while (getline(procfile,line))
{
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)
{
tokens.clear();
sanitizeLine(line);
tokenize(line, tokens, ' ');
value = tokens.at(column); //fetch the value in the corresponding column
}
}
procfile.close();
}
else LOGERR("could not open file %s", PROC_BRCM_CORE_PATH);
return value;
}

/**
* parse_proc_brcm_display
*
* @brief : parse profs to obtain Graphics resolution details
* @return : value
*/
string parse_proc_brcm_display()
{
LOGINFO();

ifstream procfile(PROC_BRCM_DISPLAY_PATH);
string line, value;
vector<string> tokens;
if (procfile.is_open())
{
while (getline(procfile,line))
{
if(line.find("graphics") != string::npos)
{
tokens.clear();
sanitizeLine(line);
tokenize(line, tokens, ' ');
if (tokens.size() >= GRAPHICS_RESOLUTION_LOC )
value = tokens.at(GRAPHICS_RESOLUTION_LOC);
}
}
procfile.close();
}
else LOGERR("could not open file %s", PROC_BRCM_DISPLAY_PATH);
return value;
}

uint64_t SoC_GetTotalGpuRam()
{
string value = parse_proc_brcm_core("MB");
uint64_t ret = 0;
try
{
ret = stoi(value) * 1024 * 1024;
LOGINFO("total GPU ram returned from proc = %s MB", value.c_str());
}
catch(...)
{
LOGERR("Unable to process Total Gpu ram", value.c_str());
}
return ret;
}

uint64_t SoC_GetFreeGpuRam()
{
LOGINFO();

string value = parse_proc_brcm_core("used");
uint64_t ret = 0;
int usedPercentage = 0;
try
{
usedPercentage = stoi(value);
LOGINFO("percentage of GPU memory used = %s", value.c_str());
}
catch(...)
{
LOGERR("Unable to process Free Gpu ram", value.c_str());
}

ret = (100 - usedPercentage) * 0.01 * SoC_GetTotalGpuRam();
return ret;
}

uint32_t SoC_GetGraphicsWidth()
{
vector<string> resolution;
uint32_t ret = 0;
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)
{
try
{
ret = stoi(resolution.at(WIDTH));
LOGINFO("graphics plane width = %d", ret);
}
catch(...)
{
LOGERR("Unable to process gfx plane width");
}
}

return ret;
}

uint32_t SoC_GetGraphicsHeight()
{
vector<string> resolution;
uint32_t ret = 0;
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)
{
try
{
ret = stoi(resolution.at(HEIGHT));
LOGINFO("graphics plane height = %d", ret);
}
catch(...)
{
LOGERR("Unable to process gfx plane height");
}
}
return ret;
}
579 changes: 579 additions & 0 deletions DisplayInfo/DeviceSettings/PlatformImplementation.cpp

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletions DisplayInfo/DeviceSettings/Realtek/SoC_abstraction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string>
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "kms.h"

#define MEM_PROCFS "/proc/meminfo"
#define TOTAL_MEM_PARAM_STR "MemTotal:"
#define FREE_MEM_PARAM_STR "MemFree:"
#define DEFAULT_DEVICE "/dev/dri/card0"

using namespace std;

static uint64_t parseLine(const char * line);
static uint64_t getMemInfo(const char * param);
static void getPrimaryPlane(int drm_fd, kms_ctx *kms, drmModePlane **plane);
static void getGraphicSize(uint32_t &w, uint32_t &h);

static uint64_t parseLine(const char * line)
{
string str(line);
uint64_t val = 0;
size_t begin = str.find_first_of("0123456789");
size_t end = string::npos;

if (string::npos != begin)
end = str.find_first_not_of("0123456789", begin);

if (string::npos != begin && string::npos != end)
{

str = str.substr(begin, end);
val = strtoul(str.c_str(), NULL, 10);

}
else
{
cout << "Failed to parse: " << line << endl;
}

return val;
}

static uint64_t getMemInfo(const char * param)
{
FILE *meminfoFile = fopen(MEM_PROCFS, "r");
uint64_t memVal = 0;
if (NULL == meminfoFile)
{
cout << "Failed to open " << MEM_PROCFS << ", error: " << strerror(errno) << endl;
}
else
{
vector <char> buf;
buf.resize(1024);

while (fgets(buf.data(), buf.size(), meminfoFile))
{
if ( strstr(buf.data(), param ) == buf.data())
{
memVal = parseLine(buf.data()) * 1000;
break;
}
}

fclose(meminfoFile);
}
return memVal;
}

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)
printf("fb id : %d\n", (*plane)->fb_id);
}

static void getGraphicSize(uint32_t &w, uint32_t &h)
{
int drm_fd;
kms_ctx *kms = NULL;
drmModePlane *plane = NULL;
int trytimes = 0;

do {
/* Setup buffer information */
drm_fd = open( DEFAULT_DEVICE, O_RDWR);

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

/* Get primary buffer */
getPrimaryPlane(drm_fd, kms, &plane);
if( !plane) {
cout << "[Realtek] fail to getPrimaryPlane" << endl;
break;
}

/* get fb */
drmModeFB *fb = drmModeGetFB(drm_fd, plane->fb_id);
while(!fb) {
getPrimaryPlane(drm_fd, kms, &plane);
fb = drmModeGetFB(drm_fd, plane->fb_id);
if (trytimes++ > 100) {
cout << "[Realtek] fail to getPrimaryPlane" << endl;
break;
}
}

/* Get the width and height */
if(fb) {
w = fb->width;
h = fb->height;
drmModeFreeFB(fb);
}
} while(0);

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

cout << "[getGraphicSize] width : " << w << endl;
cout << "[getGraphicSize] height : " << h << endl;
}


uint64_t SoC_GetTotalGpuRam()
{
return getMemInfo(TOTAL_MEM_PARAM_STR);
}

uint64_t SoC_GetFreeGpuRam()
{
return getMemInfo(FREE_MEM_PARAM_STR);
}

uint32_t SoC_GetGraphicsWidth()
{
uint32_t w, h;
getGraphicSize(w, h);
return w;
}

uint32_t SoC_GetGraphicsHeight()
{
uint32_t w, h;
getGraphicSize(w, h);
return h;
}
211 changes: 211 additions & 0 deletions DisplayInfo/DeviceSettings/Realtek/kms.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "kms.h"

void kms_setup_encoder( int fd, kms_ctx *kms )
{
int crtcId = 0;

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

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

if ( kms->encoder && ( kms->encoder->encoder_id == kms->connector->encoder_id ) ) {

kms->encoder_id = kms->encoder->encoder_id;
return;
}


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

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

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

crtcId = kms->res->crtcs[j];
kms->encoder->crtc_id = kms->crtc_id = j;
goto exit;
}
}
}

exit:
return;
}




void kms_setup_connector( int fd, kms_ctx *kms )
{
int i = 0, j = 0;
drmModeConnector *connector;

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

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

if( connector->count_modes && ( connector->connection == DRM_MODE_CONNECTED ) ) {
break;
}
}
}

if ( connector ) {

kms->connector = connector;
kms->connector_id = connector->connector_id;
}

return;
}


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

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

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

kms->current_info = kms->crtc->mode;
kms->crtc_id = kms->encoder->crtc_id;
}
}

return;
}


kms_ctx* kms_setup( int fd )
{
kms_ctx *kms = NULL;
kms = (kms_ctx*)calloc(1,sizeof(*kms));
if( !kms )
assert(0);

kms->res = drmModeGetResources(fd);

kms_setup_connector(fd, kms);
kms_setup_encoder(fd, kms);
kms_setup_crtc(fd, kms);
return kms;
}


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

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

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

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


uint32_t kms_get_properties(int fd, drmModeObjectProperties *props, const char *name)
{
drmModePropertyPtr property;
uint32_t i, id = 0;

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

property = drmModeGetProperty(fd, props->props[i]);
if (!strcmp(property->name, name))
id = property->prop_id;

drmModeFreeProperty(property);

if ( id )
return id;
}
}



void kms_get_plane( int fd, kms_ctx *kms )
{
int len = 0, n = 0, j = 0, plane_index = -1;

drmModePlane *plane = NULL;
drmModePlaneRes *planeRes = NULL;
drmModePropertyRes *prop = NULL;
drmModeObjectProperties *props = NULL;

drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);

kms->primary_plane_id = kms->overlay_plane_id = -1;

planeRes = drmModeGetPlaneResources( fd );
if ( planeRes ) {

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

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

if ( plane ) {

props = drmModeObjectGetProperties( fd, planeRes->planes[n], DRM_MODE_OBJECT_PLANE );
if ( props ) {

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

prop = drmModeGetProperty( fd, props->props[j] );
if ( prop ) {

len = strlen(prop->name);
if ( !strcmp( prop->name, "type") ) {

if ( ( props->prop_values[j] == DRM_PLANE_TYPE_PRIMARY ) && ( kms->primary_plane_id == -1 ) )
kms->primary_plane_id = planeRes->planes[n];

else if ( ( props->prop_values[j] == DRM_PLANE_TYPE_OVERLAY ) && ( kms->overlay_plane_id == -1 ) )
kms->overlay_plane_id = planeRes->planes[n];
}
}

drmModeFreeProperty( prop );
}
}

drmModeFreeObjectProperties( props );
}

drmModeFreePlane( plane );
}

}

drmModeFreePlaneResources( planeRes );
}
139 changes: 139 additions & 0 deletions DisplayInfo/DeviceSettings/Realtek/kms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __DRM_KMS_H__
#define __DRM_KMS_H__

#include <xf86drm.h>
#include <xf86drmMode.h>
#include <drm_mode.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _kms_ctx {

drmModeRes *res;
drmModeConnector *connector;
drmModeEncoder *encoder;
drmModeCrtc *crtc;

drmModeCrtc *previous_crtc;
drmModeModeInfo current_info;

uint32_t connector_id; /**< Connector id which will be use in program */
uint32_t crtc_id;
uint32_t encoder_id;
uint32_t primary_plane_id;
uint32_t overlay_plane_id;

/* atomic properties */
uint32_t active_property;
uint32_t mode_id_property;
uint32_t crtc_id_property;
uint32_t blob_id;

uint32_t fb_id_property;
uint32_t crtc_x_property;
uint32_t crtc_y_property;
uint32_t crtc_h_property;
uint32_t crtc_w_property;
uint32_t src_x_property;
uint32_t src_y_property;
uint32_t src_w_property;
uint32_t src_h_property;

drmModeAtomicReq *req;

} kms_ctx;

/**
* @brief Create kms context
*
* @param[in] fd drm file descriptor
*
*
* @retval kms context
*/
kms_ctx* kms_setup(int fd);



/**
* @brief Cleanup kms context
*
* @param[in] kms kms context
*
*/
void kms_cleanup_context(kms_ctx *kms);

/**
* @brief Set and get possible encoder id
*
* @param[in] fd drm file descriptor
* @param[in] kms kms context
*
*/
void kms_setup_encoder(int fd, kms_ctx *kms);


/**
* @brief Set and get possible connector id
*
* @param[in] fd drm file descriptor
* @para,[in] kms kms context
*
*/
void kms_setup_connector(int fd, kms_ctx *kms);

/**
* @brief Set and get possible crtc id
*
* @param[in] fd drm file descriptor
* @param[in] kms kms context
*
*/
void kms_setup_crtc(int fd, kms_ctx *kms);

/**
* @brief Get the specific object properties
*
* @param[in] fd drm file descriptor
* @param[in] props all object properties
* @param[in] name the property name which want to be queried
*
*/
uint32_t kms_get_properties(int fd, drmModeObjectProperties *props, const char *name);


/**
* @brief Get primary and overlay plane.
* The plane id will set to -1 if cannot get.
*
* @param[in] fd drm file descriptor
* @param[in] kms kms context
*
*/
void kms_get_plane( int fd, kms_ctx *kms);

#ifdef __cplusplus
}
#endif
#endif
Original file line number Diff line number Diff line change
@@ -17,4 +17,29 @@
* limitations under the License.
*/

#pragma once
#include <stdint.h>

/** @brief returns the total GPU memory available in
* the platform in bytes
* @param void
* @return memory in bytes.
*/
uint64_t SoC_GetTotalGpuRam();

/** @brief returns the current free GPU memory
* @param void
* @return memory in bytes.
*/
uint64_t SoC_GetFreeGpuRam();

/** @brief returns the width of the graphics plane in pixels
* @param void
* @return pixel width of graphics plane.
*/
uint32_t SoC_GetGraphicsWidth();

/** @brief returns the height of the graphics plane in pixels
* @param void
* @return pixel height of graphics plane.
*/
uint32_t SoC_GetGraphicsHeight();
69 changes: 57 additions & 12 deletions DisplayInfo/DisplayInfo.cpp
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "DisplayInfo.h"

namespace WPEFramework {
@@ -47,7 +47,18 @@ namespace Plugin {
_connectionProperties->Release();
_connectionProperties = nullptr;
} else {
_notification.Initialize(_connectionProperties);
_hdrProperties = _connectionProperties->QueryInterface<Exchange::IHDRProperties>();
if (_hdrProperties == nullptr) {
_connectionProperties->Release();
_connectionProperties = nullptr;
_graphicsProperties->Release();
_graphicsProperties = nullptr;
} else {
_notification.Initialize(_connectionProperties);
Exchange::JGraphicsProperties::Register(*this, _graphicsProperties);
Exchange::JConnectionProperties::Register(*this, _connectionProperties);
Exchange::JHDRProperties::Register(*this, _hdrProperties);
}
}
}

@@ -62,6 +73,9 @@ namespace Plugin {
{
ASSERT(_connectionProperties != nullptr);

Exchange::JHDRProperties::Unregister(*this);
Exchange::JConnectionProperties::Unregister(*this);

_notification.Deinitialize();

ASSERT(_graphicsProperties != nullptr);
@@ -76,6 +90,10 @@ namespace Plugin {
_connectionProperties = nullptr;
}

if (_hdrProperties != nullptr) {
_hdrProperties->Release();
_hdrProperties = nullptr;
}
_connectionId = 0;
}

@@ -122,16 +140,43 @@ namespace Plugin {

void DisplayInfo::Info(JsonData::DisplayInfo::DisplayinfoData& displayInfo) const
{
displayInfo.Totalgpuram = _graphicsProperties->TotalGpuRam();
displayInfo.Freegpuram = _graphicsProperties->FreeGpuRam();

displayInfo.Audiopassthrough = _connectionProperties->IsAudioPassthrough();
displayInfo.Connected = _connectionProperties->Connected();
displayInfo.Width = _connectionProperties->Width();
displayInfo.Height = _connectionProperties->Height();
displayInfo.Hdcpprotection = static_cast<JsonData::DisplayInfo::DisplayinfoData::HdcpprotectionType>(_connectionProperties->HDCPProtection());
displayInfo.Hdrtype = static_cast<JsonData::DisplayInfo::DisplayinfoData::HdrtypeType>(_connectionProperties->Type());
uint64_t ram = 0;
if (_graphicsProperties->TotalGpuRam(ram) == Core::ERROR_NONE) {
displayInfo.Totalgpuram = ram;
}
ram = 0;
if (_graphicsProperties->FreeGpuRam(ram) == Core::ERROR_NONE) {
displayInfo.Freegpuram = ram;
}

bool status = false;
if (_connectionProperties->IsAudioPassthrough(status) == Core::ERROR_NONE) {
displayInfo.Audiopassthrough = status;
}
status = false;
if (_connectionProperties->Connected(status) == Core::ERROR_NONE) {
displayInfo.Connected = status;
}

uint32_t value = 0;
if (_connectionProperties->Width(value) == Core::ERROR_NONE) {
displayInfo.Width = value;
}
value = 0;
if (_connectionProperties->Height(value) == Core::ERROR_NONE) {
displayInfo.Height = value;
}

Exchange::IConnectionProperties::HDCPProtectionType hdcpProtection(Exchange::IConnectionProperties::HDCPProtectionType::HDCP_Unencrypted);
if (_connectionProperties->HDCPProtection(hdcpProtection) == Core::ERROR_NONE) {
displayInfo.Hdcpprotection = static_cast<JsonData::DisplayInfo::DisplayinfoData::HdcpprotectionType>(hdcpProtection);
}

Exchange::IHDRProperties::HDRType hdrType(Exchange::IHDRProperties::HDRType::HDR_OFF);
if (_hdrProperties->HDRSetting(hdrType) == Core::ERROR_NONE) {
displayInfo.Hdrtype = static_cast<JsonData::DisplayInfo::DisplayinfoData::HdrtypeType>(hdrType);
}
}

} // namespace Plugin
} // namespace WPEFramework
} // namespace WPEFramework
29 changes: 11 additions & 18 deletions DisplayInfo/DisplayInfo.h
Original file line number Diff line number Diff line change
@@ -16,18 +16,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include "Module.h"
#include <interfaces/IDisplayInfo.h>
#include <interfaces/json/JsonData_DisplayInfo.h>
#include <interfaces/json/JGraphicsProperties.h>
#include <interfaces/json/JConnectionProperties.h>
#include <interfaces/json/JHDRProperties.h>

namespace WPEFramework {
namespace Plugin {

class DisplayInfo : public PluginHost::IPlugin, public PluginHost::IWeb, public PluginHost::JSONRPC {
private:private:
private:
class Notification : protected Exchange::IConnectionProperties::INotification {
private:
Notification() = delete;
@@ -60,9 +62,9 @@ namespace Plugin {
_client = nullptr;
}
}
void Updated() override
void Updated(const Exchange::IConnectionProperties::INotification::Source event) override
{
_parent.Updated();
Exchange::JConnectionProperties::Event::Updated(_parent, event);
}
BEGIN_INTERFACE_MAP(Notification)
INTERFACE_ENTRY(Exchange::IConnectionProperties::INotification)
@@ -82,21 +84,21 @@ namespace Plugin {
, _connectionId(0)
, _graphicsProperties(nullptr)
, _connectionProperties(nullptr)
, _hdrProperties(nullptr)
, _notification(this)
{
RegisterAll();
}

virtual ~DisplayInfo()
{
UnregisterAll();
}

BEGIN_INTERFACE_MAP(DisplayInfo)
INTERFACE_ENTRY(PluginHost::IPlugin)
INTERFACE_ENTRY(PluginHost::IWeb)
INTERFACE_AGGREGATE(Exchange::IGraphicsProperties, _graphicsProperties)
INTERFACE_AGGREGATE(Exchange::IConnectionProperties, _connectionProperties)
INTERFACE_AGGREGATE(Exchange::IHDRProperties, _hdrProperties)
INTERFACE_ENTRY(PluginHost::IDispatcher)
END_INTERFACE_MAP

@@ -112,17 +114,7 @@ namespace Plugin {
virtual void Inbound(Web::Request& request) override;
virtual Core::ProxyType<Web::Response> Process(const Web::Request& request) override;

void Updated()
{
event_updated();
}

private:
// JsonRpc
void RegisterAll();
void UnregisterAll();
uint32_t get_displayinfo(JsonData::DisplayInfo::DisplayinfoData&) const;
void event_updated();

void Info(JsonData::DisplayInfo::DisplayinfoData&) const;

@@ -131,8 +123,9 @@ namespace Plugin {
uint32_t _connectionId;
Exchange::IGraphicsProperties* _graphicsProperties;
Exchange::IConnectionProperties* _connectionProperties;
Exchange::IHDRProperties* _hdrProperties;
Core::Sink<Notification> _notification;
};

} // namespace Plugin
} // namespace WPEFramework
} // namespace WPEFramework
2 changes: 1 addition & 1 deletion DisplayInfo/DisplayInfoPlugin.json
Original file line number Diff line number Diff line change
@@ -9,6 +9,6 @@
"version": "1.0"
},
"interface": {
"$ref": "{interfacedir}/DisplayInfo.json#"
"$cppref": "{cppinterfacedir}/IDisplayInfo.h"
}
}
Loading

0 comments on commit ffb85d4

Please sign in to comment.