sdm: Identify device node path before opening.
- Check existence of /dev/graphic/fb* and /dev/fb* path and open appropriate device node. CRs-Fixed: 1062882 Change-Id: Icd1f2a3f444a748eb05a7abbe9f98eae25cf254a
This commit is contained in:
@@ -54,6 +54,7 @@ class Sys {
|
|||||||
#else
|
#else
|
||||||
typedef int (*ioctl)(int, int, ...);
|
typedef int (*ioctl)(int, int, ...);
|
||||||
#endif
|
#endif
|
||||||
|
typedef int (*access)(const char *, int);
|
||||||
typedef int (*open)(const char *, int, ...);
|
typedef int (*open)(const char *, int, ...);
|
||||||
typedef int (*close)(int);
|
typedef int (*close)(int);
|
||||||
typedef int (*poll)(struct pollfd *, nfds_t, int);
|
typedef int (*poll)(struct pollfd *, nfds_t, int);
|
||||||
@@ -68,6 +69,7 @@ class Sys {
|
|||||||
static bool getline_(fstream &fs, std::string &line); // NOLINT
|
static bool getline_(fstream &fs, std::string &line); // NOLINT
|
||||||
|
|
||||||
static ioctl ioctl_;
|
static ioctl ioctl_;
|
||||||
|
static access access_;
|
||||||
static open open_;
|
static open open_;
|
||||||
static close close_;
|
static close close_;
|
||||||
static poll poll_;
|
static poll poll_;
|
||||||
|
|||||||
@@ -107,12 +107,28 @@ HWDevice::HWDevice(BufferSyncHandler *buffer_sync_handler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DisplayError HWDevice::Init() {
|
DisplayError HWDevice::Init() {
|
||||||
char device_name[64] = {0};
|
|
||||||
|
|
||||||
// Read the fb node index
|
// Read the fb node index
|
||||||
fb_node_index_ = GetFBNodeIndex(device_type_);
|
fb_node_index_ = GetFBNodeIndex(device_type_);
|
||||||
if (fb_node_index_ == -1) {
|
if (fb_node_index_ == -1) {
|
||||||
DLOGE("%s should be present", device_name_);
|
DLOGE("device type = %d should be present", device_type_);
|
||||||
|
return kErrorHardware;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dev_name = NULL;
|
||||||
|
vector<string> dev_paths = {"/dev/graphics/fb", "/dev/fb"};
|
||||||
|
for (size_t i = 0; i < dev_paths.size(); i++) {
|
||||||
|
dev_paths[i] += to_string(fb_node_index_);
|
||||||
|
if (Sys::access_(dev_paths[i].c_str(), F_OK) >= 0) {
|
||||||
|
dev_name = dev_paths[i].c_str();
|
||||||
|
DLOGI("access(%s) successful", dev_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLOGI("access(%s), errno = %d, error = %s", dev_paths[i].c_str(), errno, strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dev_name) {
|
||||||
|
DLOGE("access() failed for all possible paths");
|
||||||
return kErrorHardware;
|
return kErrorHardware;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,10 +138,9 @@ DisplayError HWDevice::Init() {
|
|||||||
hw_resource_ = HWResourceInfo();
|
hw_resource_ = HWResourceInfo();
|
||||||
hw_info_intf_->GetHWResourceInfo(&hw_resource_);
|
hw_info_intf_->GetHWResourceInfo(&hw_resource_);
|
||||||
|
|
||||||
snprintf(device_name, sizeof(device_name), "%s%d", "/dev/graphics/fb", fb_node_index_);
|
device_fd_ = Sys::open_(dev_name, O_RDWR);
|
||||||
device_fd_ = Sys::open_(device_name, O_RDWR);
|
|
||||||
if (device_fd_ < 0) {
|
if (device_fd_ < 0) {
|
||||||
DLOGE("open %s failed err = %d errstr = %s", device_name, errno, strerror(errno));
|
DLOGE("open %s failed errno = %d, error = %s", dev_name, errno, strerror(errno));
|
||||||
return kErrorResources;
|
return kErrorResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ int PthreadCancel(pthread_t /* thread */) {
|
|||||||
|
|
||||||
// Pointer to actual driver interfaces.
|
// Pointer to actual driver interfaces.
|
||||||
Sys::ioctl Sys::ioctl_ = ::ioctl;
|
Sys::ioctl Sys::ioctl_ = ::ioctl;
|
||||||
|
Sys::access Sys::access_ = ::access;
|
||||||
Sys::open Sys::open_ = ::open;
|
Sys::open Sys::open_ = ::open;
|
||||||
Sys::close Sys::close_ = ::close;
|
Sys::close Sys::close_ = ::close;
|
||||||
Sys::poll Sys::poll_ = ::poll;
|
Sys::poll Sys::poll_ = ::poll;
|
||||||
|
|||||||
Reference in New Issue
Block a user