gralloc: Refactor gralloc4.0 for some concerns in code review
There were some concerns raised in the intern code review process. Since
Qualcomm has merged their Gralloc4.0 changes into their codebase, the
patch created another standlane change to address the concerns within
the code review.
Bug: 141596968
Test: VtsHalGraphicsMapperV4_0TargetTest
Change-Id: I33905f5f1198089a1e3fe16e1fd46a8f614e8679
(cherry picked from commit 3dfff2a5af39b14422ede072e3e9d95596e5fc3f)
diff --git a/gralloc/QtiGralloc.cpp b/gralloc/QtiGralloc.cpp
index 19ff2ab..912d360 100644
--- a/gralloc/QtiGralloc.cpp
+++ b/gralloc/QtiGralloc.cpp
@@ -33,6 +33,7 @@
namespace qtigralloc {
using android::hardware::graphics::mapper::V4_0::IMapper;
+
static sp<IMapper> getInstance() {
static sp<IMapper> mapper = IMapper::getService();
return mapper;
@@ -84,7 +85,7 @@
return Error::BAD_VALUE;
}
out->resize(UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
- memcpy(out->data(), &in[0], UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
+ memcpy(out->data(), in, UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
return Error::NONE;
}
diff --git a/gralloc/QtiGralloc.h b/gralloc/QtiGralloc.h
index 37593e5..08053cc 100644
--- a/gralloc/QtiGralloc.h
+++ b/gralloc/QtiGralloc.h
@@ -62,7 +62,7 @@
};
// Metadata
-const std::string VENDOR_QTI = "QTI";
+static const std::string VENDOR_QTI = "QTI";
Error get(void *buffer, uint32_t type, void *param);
Error set(void *buffer, uint32_t type, void *param);
diff --git a/libqdmetadata/qdMetaData.cpp b/libqdmetadata/qdMetaData.cpp
index 3577586..a3141f0 100644
--- a/libqdmetadata/qdMetaData.cpp
+++ b/libqdmetadata/qdMetaData.cpp
@@ -55,7 +55,10 @@
} else if (in.colorPrimaries == ColorPrimaries_BT709_5) {
*out = ITU_R_709;
} else {
- ALOGE("Cannot convert ColorMetaData to ColorSpace_t");
+ ALOGE(
+ "Cannot convert ColorMetaData to ColorSpace_t. "
+ "Primaries = %d, Range = %d",
+ in.colorPrimaries, in.range);
return -1;
}
@@ -86,7 +89,7 @@
out->range = Range_Full;
break;
default:
- ALOGE("Cannot convert ColorSpace_t to ColorMetaData");
+ ALOGE("Cannot convert ColorSpace_t %d to ColorMetaData", in);
return -1;
break;
}
@@ -180,8 +183,9 @@
ColorMetaData color = {};
if (!colorSpaceToColorMetadata(*((ColorSpace_t *)param), &color)) {
data->color = color;
+ break;
}
- break;
+ return -EINVAL;
}
case MAP_SECURE_BUFFER:
data->mapSecureBuffer = *((int32_t *)param);
@@ -335,8 +339,8 @@
ColorSpace_t color_space;
if (!colorMetaDataToColorSpace(data->color, &color_space)) {
*((ColorSpace_t *)param) = color_space;
- }
ret = 0;
+ }
}
break;
case GET_MAP_SECURE_BUFFER:
diff --git a/libqdmetadata/qd_utils.cpp b/libqdmetadata/qd_utils.cpp
index ceeed60..ac5d094 100644
--- a/libqdmetadata/qd_utils.cpp
+++ b/libqdmetadata/qd_utils.cpp
@@ -84,56 +84,6 @@
return -1;
}
-static int querySDEInfoFB(HWQueryType type, int *value) {
- FILE *fileptr = NULL;
- const char *featureName;
- char stringBuffer[MAX_STRING_LENGTH];
- uint32_t tokenCount = 0;
- const uint32_t maxCount = 10;
- char *tokens[maxCount] = { NULL };
-
- switch(type) {
- case HAS_UBWC:
- featureName = "ubwc";
- break;
- case HAS_WB_UBWC:
- featureName = "wb_ubwc";
- break;
- default:
- ALOGE("Invalid query type %d", type);
- return -EINVAL;
- }
-
- fileptr = fopen("/sys/devices/virtual/graphics/fb0/mdp/caps", "rb");
- if (!fileptr) {
- ALOGE("File '%s' not found", stringBuffer);
- return -EINVAL;
- }
-
- size_t len = MAX_STRING_LENGTH;
- ssize_t read;
- char *line = stringBuffer;
- while ((read = getline(&line, &len, fileptr)) != -1) {
- // parse the line and update information accordingly
- if (parseLine(line, tokens, maxCount, &tokenCount)) {
- continue;
- }
-
- if (strncmp(tokens[0], "features", strlen("features"))) {
- continue;
- }
-
- for (uint32_t i = 0; i < tokenCount; i++) {
- if (!strncmp(tokens[i], featureName, strlen(featureName))) {
- *value = 1;
- }
- }
- }
- fclose(fileptr);
-
- return 0;
-}
-
int getHDMINode(void) {
return getExternalNode("dtv panel");
}