2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-08-18 12:25:22 +10:00
|
|
|
#pragma once
|
|
|
|
|
2020-08-10 23:59:06 +02:00
|
|
|
#include <AK/Platform.h>
|
|
|
|
#include <stddef.h>
|
2019-08-18 12:25:22 +10:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
ALWAYS_INLINE int fb_get_properties(int fd, FBProperties* info)
|
2019-08-18 12:25:22 +10:00
|
|
|
{
|
2021-09-22 17:13:12 +03:00
|
|
|
return ioctl(fd, FB_IOCTL_GET_PROPERTIES, info);
|
2019-08-18 12:25:22 +10:00
|
|
|
}
|
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
ALWAYS_INLINE int fb_get_head_properties(int fd, FBHeadProperties* info)
|
2019-08-18 12:25:22 +10:00
|
|
|
{
|
2021-09-22 17:13:12 +03:00
|
|
|
return ioctl(fd, FB_IOCTL_GET_HEAD_PROPERTIES, info);
|
2019-08-18 12:25:22 +10:00
|
|
|
}
|
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
ALWAYS_INLINE int fb_get_resolution(int fd, FBHeadResolution* info)
|
2019-08-18 12:25:22 +10:00
|
|
|
{
|
2021-09-22 17:13:12 +03:00
|
|
|
FBHeadProperties head_properties;
|
|
|
|
head_properties.head_index = info->head_index;
|
|
|
|
if (auto rc = ioctl(fd, FB_IOCTL_GET_HEAD_PROPERTIES, &head_properties); rc < 0)
|
|
|
|
return rc;
|
|
|
|
info->head_index = head_properties.head_index;
|
|
|
|
info->pitch = head_properties.pitch;
|
|
|
|
info->width = head_properties.width;
|
|
|
|
info->height = head_properties.height;
|
|
|
|
return 0;
|
2019-08-18 12:25:22 +10:00
|
|
|
}
|
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
ALWAYS_INLINE int fb_set_resolution(int fd, FBHeadResolution* info)
|
2021-07-03 20:36:16 -06:00
|
|
|
{
|
2021-09-22 17:13:12 +03:00
|
|
|
return ioctl(fd, FB_IOCTL_SET_HEAD_RESOLUTION, info);
|
2021-07-03 20:36:16 -06:00
|
|
|
}
|
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
ALWAYS_INLINE int fb_get_head_vertical_offset_buffer(int fd, FBHeadVerticalOffset* vertical_offset)
|
2019-08-18 12:25:22 +10:00
|
|
|
{
|
2021-11-20 17:03:23 +01:00
|
|
|
return ioctl(fd, FB_IOCTL_GET_HEAD_VERTICAL_OFFSET_BUFFER, vertical_offset);
|
2019-08-18 12:25:22 +10:00
|
|
|
}
|
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
ALWAYS_INLINE int fb_set_head_vertical_offset_buffer(int fd, FBHeadVerticalOffset* vertical_offset)
|
2019-08-18 12:25:22 +10:00
|
|
|
{
|
2021-11-20 17:03:23 +01:00
|
|
|
return ioctl(fd, FB_IOCTL_SET_HEAD_VERTICAL_OFFSET_BUFFER, vertical_offset);
|
2019-08-18 12:25:22 +10:00
|
|
|
}
|
|
|
|
|
2021-07-03 12:43:35 -06:00
|
|
|
ALWAYS_INLINE int fb_flush_buffers(int fd, int index, FBRect const* rects, unsigned count)
|
2021-06-12 22:46:54 +10:00
|
|
|
{
|
2021-07-03 12:43:35 -06:00
|
|
|
FBFlushRects fb_flush_rects;
|
|
|
|
fb_flush_rects.buffer_index = index;
|
|
|
|
fb_flush_rects.count = count;
|
|
|
|
fb_flush_rects.rects = rects;
|
2021-09-22 17:13:12 +03:00
|
|
|
return ioctl(fd, FB_IOCTL_FLUSH_HEAD_BUFFERS, &fb_flush_rects);
|
2021-06-12 22:46:54 +10:00
|
|
|
}
|
|
|
|
|
2019-08-18 12:25:22 +10:00
|
|
|
__END_DECLS
|