mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-22 04:05:31 -04:00
universal7885: camera: Make a neater function for remap
- Also enable camera id 2 back, the front AUX
This commit is contained in:
parent
6b313d15c4
commit
4382d1d2cd
3 changed files with 34 additions and 37 deletions
|
|
@ -34,7 +34,6 @@ SamsungCameraProvider::SamsungCameraProvider()
|
|||
mExtraIDs.push_back(23);
|
||||
mExtraIDs.push_back(50);
|
||||
mExtraIDs.push_back(52);
|
||||
mDisabledIDs.push_back(2);
|
||||
if (!mInitFailed) {
|
||||
for (int i : mExtraIDs) {
|
||||
struct camera_info info;
|
||||
|
|
@ -65,29 +64,3 @@ SamsungCameraProvider::SamsungCameraProvider()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Return<void> SamsungCameraProvider::getCameraIdList(
|
||||
const ICameraProvider::getCameraIdList_cb &_hidl_cb) {
|
||||
std::vector<hidl_string> deviceNameList;
|
||||
for (auto const &deviceNamePair : mCameraDeviceNames) {
|
||||
int id = std::stoi(deviceNamePair.first);
|
||||
if (id >= mNumberOfLegacyCameras ||
|
||||
std::find(mDisabledIDs.begin(), mDisabledIDs.end(), id) !=
|
||||
mDisabledIDs.end()) {
|
||||
// External camera devices must be reported through the device status
|
||||
// change callback, not in this list. Linux4: Also skip disabled camera
|
||||
// IDs.
|
||||
continue;
|
||||
}
|
||||
if (mCameraStatusMap[deviceNamePair.first] ==
|
||||
CAMERA_DEVICE_STATUS_PRESENT) {
|
||||
deviceNameList.push_back(deviceNamePair.second);
|
||||
}
|
||||
}
|
||||
hidl_vec<hidl_string> hidlDeviceNameList(deviceNameList);
|
||||
_hidl_cb(::android::hardware::camera::common::V1_0::Status::OK,
|
||||
hidlDeviceNameList);
|
||||
return Void();
|
||||
}
|
||||
|
||||
SamsungCameraProvider::~SamsungCameraProvider() {}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,9 @@ using ::android::hardware::camera::provider::V2_5::implementation::
|
|||
class SamsungCameraProvider : public LegacyCameraProviderImpl_2_5 {
|
||||
public:
|
||||
SamsungCameraProvider();
|
||||
~SamsungCameraProvider();
|
||||
|
||||
Return<void> getCameraIdList(const ICameraProvider::getCameraIdList_cb &_hidl_cb);
|
||||
|
||||
private:
|
||||
std::vector<int> mExtraIDs;
|
||||
std::vector<int> mDisabledIDs;
|
||||
};
|
||||
|
||||
#endif // SAMSUNG_CAMERA_PROVIDER_H
|
||||
|
|
|
|||
|
|
@ -12,6 +12,38 @@
|
|||
#include <include/convert.h>
|
||||
#include <log/log.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace remapper {
|
||||
|
||||
// Reversed means changing second to first
|
||||
static void applyRemap(std::pair<int, int> config, int *intversion, std::string *stringversion)
|
||||
{
|
||||
int cameraid = 0, selectedFromConfig = 0;
|
||||
|
||||
if (intversion != nullptr)
|
||||
cameraid = *intversion;
|
||||
else if (stringversion != nullptr)
|
||||
cameraid = std::stoi(*stringversion);
|
||||
else return;
|
||||
|
||||
if (config.first == cameraid)
|
||||
selectedFromConfig = config.second;
|
||||
else if (config.second == cameraid)
|
||||
selectedFromConfig = config.first;
|
||||
else return;
|
||||
|
||||
if (intversion != nullptr)
|
||||
*intversion = selectedFromConfig;
|
||||
if (stringversion != nullptr) {
|
||||
std::vector<char> buf(2 /* single digit and null char */);
|
||||
std::snprintf(buf.data(), buf.size(), "%d", selectedFromConfig);
|
||||
*stringversion = std::string(buf.begin(), buf.end());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace remapper
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace camera {
|
||||
|
|
@ -28,8 +60,7 @@ Return<void> CameraDevice::getCameraCharacteristics(
|
|||
if (status == Status::OK) {
|
||||
// Module 2.1+ codepath.
|
||||
struct camera_info info;
|
||||
if (mCameraIdInt == 1)
|
||||
mCameraIdInt = 2;
|
||||
remapper::applyRemap(std::make_pair(1, 2), &mCameraIdInt, nullptr);
|
||||
int ret = mModule->getCameraInfo(mCameraIdInt, &info);
|
||||
if (ret == OK) {
|
||||
convertToHidl(info.static_camera_characteristics, &cameraCharacteristics);
|
||||
|
|
@ -78,10 +109,7 @@ Return<void> CameraDevice::open(const sp<ICameraDeviceCallback> &callback,
|
|||
camera3_device_t *device;
|
||||
|
||||
std::string mCameraID = mCameraId;
|
||||
if (mCameraIdInt == 1)
|
||||
mCameraIdInt = 2;
|
||||
if (mCameraID == "1")
|
||||
mCameraID = "2";
|
||||
remapper::applyRemap(std::make_pair(1, 2), &mCameraIdInt, &mCameraID);
|
||||
|
||||
res = mModule->open(mCameraID.c_str(),
|
||||
reinterpret_cast<hw_device_t **>(&device));
|
||||
|
|
|
|||
Loading…
Reference in a new issue