1d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian/*
2d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * Copyright (C) 2011 The Android Open Source Project
3d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian *
4d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * you may not use this file except in compliance with the License.
6d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * You may obtain a copy of the License at
7d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian *
8d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian *
10d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * Unless required by applicable law or agreed to in writing, software
11d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * See the License for the specific language governing permissions and
14d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian * limitations under the License.
15d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian */
16d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian
17d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <stdint.h>
18d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <sys/types.h>
19d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian
20d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <fcntl.h>
21d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <sys/ioctl.h>
22d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <linux/fb.h>
23d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <errno.h>
24d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <string.h>
25d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#include <stdio.h>
26ee9701744a01acb558cb1082de9cc1415d0dbaffNanik Tolaram#include <unistd.h>
27d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian
28d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#ifndef FBIO_WAITFORVSYNC
29d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#define FBIO_WAITFORVSYNC   _IOW('F', 0x20, __u32)
30d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian#endif
31d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian
32d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopianint main(int argc, char** argv) {
33d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian    int fd = open("/dev/graphics/fb0", O_RDWR);
34d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian    if (fd >= 0) {
35d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian        do {
36d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian            uint32_t crt = 0;
37d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian           int err = ioctl(fd, FBIO_WAITFORVSYNC, &crt);
38d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian           if (err < 0) {
39d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian               printf("FBIO_WAITFORVSYNC error: %s\n", strerror(errno));
40d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian               break;
41d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian           }
42d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian        } while(1);
43d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian        close(fd);
44d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian    }
45d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian    return 0;
46d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian}
47