guacamole: implement camera motor support
* Support camera motor by using a hook into the camera service * TODO: Clean this up. Maybe we can use HAL to implement this?
This commit is contained in:
parent
9b90467bf6
commit
a12ac7946d
|
@ -0,0 +1,27 @@
|
|||
#
|
||||
# Copyright (C) 2017-2019 The LineageOS Project
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := camera_motor.cpp
|
||||
|
||||
LOCAL_MODULE := camera_motor.guacamole
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MULTILIB := 64
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
|
@ -0,0 +1,46 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CAMERA_MOTOR_ENABLE "/sys/devices/platform/vendor/vendor:motor_pl/enable"
|
||||
#define CAMERA_MOTOR_DIRECTION "/sys/devices/platform/vendor/vendor:motor_pl/direction"
|
||||
#define DIRECTION_DOWN "1"
|
||||
#define DIRECTION_UP "0"
|
||||
#define ENABLED "1"
|
||||
#define CAMERA_ID_FRONT 1
|
||||
|
||||
void set_direction(const char *direction) {
|
||||
FILE *fp = fopen(CAMERA_MOTOR_DIRECTION, "w");
|
||||
if (fp != NULL) {
|
||||
fputs(direction, fp);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void trigger_motor() {
|
||||
FILE *fp = fopen(CAMERA_MOTOR_ENABLE, "w");
|
||||
if (fp != NULL) {
|
||||
fputs(ENABLED, fp);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void connect(int cameraId) {
|
||||
if (cameraId != CAMERA_ID_FRONT) return;
|
||||
set_direction(DIRECTION_UP);
|
||||
trigger_motor();
|
||||
}
|
||||
|
||||
void disconnect(int cameraId) {
|
||||
if (cameraId != CAMERA_ID_FRONT) return;
|
||||
set_direction(DIRECTION_DOWN);
|
||||
trigger_motor();
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
if (strcmp(argv[1], "connect")) {
|
||||
connect(atoi(argv[2]));
|
||||
} else {
|
||||
disconnect(atoi(argv[2]));
|
||||
}
|
||||
}
|
|
@ -35,7 +35,8 @@ PRODUCT_COPY_FILES += \
|
|||
|
||||
# Camera
|
||||
PRODUCT_PACKAGES += \
|
||||
Snap
|
||||
Snap \
|
||||
camera_motor.guacamole \
|
||||
|
||||
# Common init scripts
|
||||
PRODUCT_PACKAGES += \
|
||||
|
|
|
@ -2,3 +2,5 @@ on init
|
|||
mount none /system/etc/audio_policy_configuration.xml /vendor/etc/audio/audio_policy_configuration.xml bind
|
||||
mount none /system/etc/media_profiles_vendor.xml /vendor/etc/media_profiles_vendor.xml bind
|
||||
mount none /system/etc/fstab.qcom /vendor/etc/fstab.qcom bind
|
||||
chmod 666 /sys/devices/platform/vendor/vendor:motor_pl/enable
|
||||
chmod 666 /sys/devices/platform/vendor/vendor:motor_pl/direction
|
||||
|
|
|
@ -9,6 +9,9 @@ ro.control_privapp_permissions=log
|
|||
persist.vendor.sys.fp.fod.location.X_Y=595,2527
|
||||
persist.vendor.sys.fp.fod.size.width_height=250,250
|
||||
|
||||
# Motorized Camera
|
||||
persist.vendor.camera.motor_bin=/system/bin/camera_motor.guacamole
|
||||
|
||||
#
|
||||
# system.prop for sdm845
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue