sdm710-common: camera_motor: Update for RMX1901
Co-authored-by: luk1337 <priv.luk@gmail.com> Co-authored-by: PeterCxy <peter@typeblog.net>
This commit is contained in:
parent
fd9829737d
commit
ed958c7712
2 changed files with 45 additions and 6 deletions
|
@ -19,7 +19,16 @@
|
|||
#include "CameraMotor.h"
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <fstream>
|
||||
|
||||
#define CAMERA_MOTOR_ENABLE "/sys/bus/platform/devices/vendor:motor_pl/enable"
|
||||
#define CAMERA_MOTOR_DIRECTION "/sys/bus/platform/devices/vendor:motor_pl/direction"
|
||||
#define CAMERA_MOTOR_HALL_CALIBRATION "/sys/bus/platform/devices/vendor:motor_pl/hall_calibration"
|
||||
#define CAMERA_PERSIST_HALL_CALIBRATION "/mnt/vendor/persist/engineermode/hall_calibration"
|
||||
#define DIRECTION_DOWN "0"
|
||||
#define DIRECTION_UP "1"
|
||||
#define HALL_CALIBRATION_DEFAULT "170,170,480,0,0,480,500,0,0,500,1500"
|
||||
#define ENABLED "1"
|
||||
#define CAMERA_ID_FRONT "1"
|
||||
|
||||
namespace vendor {
|
||||
|
@ -29,9 +38,36 @@ namespace motor {
|
|||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
/*
|
||||
* Write value to path and close file.
|
||||
*/
|
||||
template <typename T>
|
||||
static void set(const std::string& path, const T& value) {
|
||||
std::ofstream file(path);
|
||||
file << value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T get(const std::string& path, const T& def) {
|
||||
std::ifstream file(path);
|
||||
T result;
|
||||
|
||||
file >> result;
|
||||
return file.fail() ? def : result;
|
||||
}
|
||||
|
||||
CameraMotor::CameraMotor() {
|
||||
// Load motor hall calibration data
|
||||
set(CAMERA_MOTOR_HALL_CALIBRATION,
|
||||
get<std::string>(CAMERA_PERSIST_HALL_CALIBRATION, HALL_CALIBRATION_DEFAULT));
|
||||
}
|
||||
|
||||
Return<void> CameraMotor::onConnect(const hidl_string& cameraId) {
|
||||
if (cameraId == CAMERA_ID_FRONT) {
|
||||
LOG(INFO) << "Camera is uprising.";
|
||||
LOG(INFO) << "Popping out front camera";
|
||||
|
||||
set(CAMERA_MOTOR_DIRECTION, DIRECTION_UP);
|
||||
set(CAMERA_MOTOR_ENABLE, ENABLED);
|
||||
}
|
||||
|
||||
return Void();
|
||||
|
@ -39,7 +75,10 @@ Return<void> CameraMotor::onConnect(const hidl_string& cameraId) {
|
|||
|
||||
Return<void> CameraMotor::onDisconnect(const hidl_string& cameraId) {
|
||||
if (cameraId == CAMERA_ID_FRONT) {
|
||||
LOG(INFO) << "Camera is descending";
|
||||
LOG(INFO) << "Retracting front camera";
|
||||
|
||||
set(CAMERA_MOTOR_DIRECTION, DIRECTION_DOWN);
|
||||
set(CAMERA_MOTOR_ENABLE, ENABLED);
|
||||
}
|
||||
|
||||
return Void();
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_H
|
||||
#define VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_H
|
||||
#ifndef VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_FINGERPRINTINSCREEN_H
|
||||
#define VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_FINGERPRINTINSCREEN_H
|
||||
|
||||
#include <vendor/lineage/camera/motor/1.0/ICameraMotor.h>
|
||||
|
||||
|
@ -31,7 +31,7 @@ using ::android::hardware::Void;
|
|||
|
||||
class CameraMotor : public ICameraMotor {
|
||||
public:
|
||||
CameraMotor() = default;
|
||||
CameraMotor();
|
||||
|
||||
Return<void> onConnect(const hidl_string& cameraId) override;
|
||||
Return<void> onDisconnect(const hidl_string& cameraId) override;
|
||||
|
@ -44,4 +44,4 @@ class CameraMotor : public ICameraMotor {
|
|||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
|
||||
#endif // VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_H
|
||||
#endif // VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_FINGERPRINTINSCREEN_H
|
||||
|
|
Loading…
Reference in a new issue