Add asus-motor, to be called from cameraserver to control ZF6 cam

This commit is contained in:
Pierre-Hugues Husson 2019-10-01 13:32:49 +02:00 committed by tboy1991
parent 4ae39bd367
commit c1a8456084
5 changed files with 45 additions and 0 deletions

View File

@ -143,3 +143,5 @@ PRODUCT_COPY_FILES += \
PRODUCT_COPY_FILES += \
device/phh/treble/ld.config.26.txt:system/etc/ld.config.26.txt \
PRODUCT_PACKAGES += \
asus-motor

View File

@ -151,3 +151,10 @@ cc_binary {
"libhidlbase",
],
}
cc_binary {
name: "asus-motor",
srcs: [
"asus-motor.cpp",
],
}

30
cmds/asus-motor.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
typedef struct {
int dir;
int angle;
int speed;
} motorDrvManualConfig_t;
#define ASUS_MOTOR_NAME_SIZE 32
#define ASUS_MOTOR_DATA_SIZE 4
#define ASUS_MOTOR_DRV_DEV_PATH ("/dev/asusMotoDrv")
#define ASUS_MOTOR_DRV_IOC_MAGIC ('M')
#define ASUS_MOTOR_DRV_AUTO_MODE _IOW(ASUS_MOTOR_DRV_IOC_MAGIC, 1, int)
#define ASUS_MOTOR_DRV_MANUAL_MODE _IOW(ASUS_MOTOR_DRV_IOC_MAGIC, 2, motorDrvManualConfig_t)
int main(int argc, char **argv) {
if(argc != 2) return 1;
int fd = open("/dev/asusMotoDrv", O_RDWR);
motorDrvManualConfig_t cfg;
cfg.dir = atoi(argv[1]);
cfg.angle = 180;
cfg.speed = 4;
ioctl(fd, ASUS_MOTOR_DRV_MANUAL_MODE, &cfg);
}

5
sepolicy/asus.te Normal file
View File

@ -0,0 +1,5 @@
allow cameraserver phhsu_exec:file rx_file_perms;
type asus_motor_device, file_type;
allow cameraserver asus_motor_device:chr_file { open read write ioctl };
allowxperm cameraserver asus_motor_device:chr_file ioctl { 0x4d02 };

View File

@ -3,6 +3,7 @@
/system/etc/usb_audio_policy_configuration.xml u:object_r:vendor_configs_file:s0
/system/bin/rw-system.sh u:object_r:phhsu_exec:s0
/system/bin/phh-on-boot.sh u:object_r:phhsu_exec:s0
/system/bin/asus-motor u:object_r:phhsu_exec:s0
#/system/bin/fsck\.exfat u:object_r:fsck_exec:s0
/system/bin/fsck\.ntfs u:object_r:fsck_exec:s0