summaryrefslogtreecommitdiff
path: root/gralloc_vsync_default.cpp (plain)
blob: 74f11b129fdabd529f8d27aa83ee64e109c6b5dd
1/*
2 * Copyright (C) 2014 ARM Limited. All rights reserved.
3 *
4 * Copyright (C) 2008 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include "gralloc_priv.h"
20#include "gralloc_vsync.h"
21#include "gralloc_vsync_report.h"
22#include <sys/ioctl.h>
23#include <errno.h>
24
25#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
26
27int gralloc_vsync_enable(framebuffer_device_t *dev)
28{
29 return 0;
30}
31
32int gralloc_vsync_disable(framebuffer_device_t *dev)
33{
34 return 0;
35}
36
37int gralloc_wait_for_vsync(framebuffer_device_t *dev)
38{
39 framebuffer_t* fb = reinterpret_cast<framebuffer_t*>(dev);
40 // if this handle was created in this process, then we keep it as is.
41 private_handle_t *hnd = (private_handle_t *)fb->fb_hnd;
42 if (private_handle_t::validate(hnd) < 0)
43 {
44 AERR("Registering invalid buffer 0x%p, returning error", hnd);
45 return -EINVAL;
46 }
47
48 private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
49 framebuffer_mapper_t* m_fb = NULL;
50#ifdef DEBUG_EXTERNAL_DISPLAY_ON_PANEL
51 ALOGD("always alloc from fb0");
52 m_fb = &(m->fb_primary);
53#else
54 if (hnd->usage & GRALLOC_USAGE_EXTERNAL_DISP)
55 {
56 m_fb = &(m->fb_external);
57 }
58 else
59 {
60 m_fb = &(m->fb_primary);
61 }
62#endif
63 if (MALI_DPY_TYPE_CLCD == m->dpy_type || MALI_DPY_TYPE_HDLCD == m->dpy_type)
64 {
65 /* Silently ignore wait for vsync as neither PL111 nor HDLCD implement this IOCTL. */
66 return 0;
67 }
68
69 if ( m->swapInterval )
70 {
71 int crtc = 0;
72 gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT);
73 if (ioctl(m_fb->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0)
74 {
75 gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
76 return -errno;
77 }
78 gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
79 }
80 return 0;
81}
82