2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-08-17 23:25:22 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-08-10 18:59:06 -03:00
|
|
|
#include <AK/Platform.h>
|
|
|
|
|
#include <stddef.h>
|
2019-08-17 23:25:22 -03:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
2020-08-10 18:59:06 -03:00
|
|
|
ALWAYS_INLINE int fb_get_size_in_bytes(int fd, size_t* out)
|
2019-08-17 23:25:22 -03:00
|
|
|
{
|
|
|
|
|
return ioctl(fd, FB_IOCTL_GET_SIZE_IN_BYTES, out);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 18:59:06 -03:00
|
|
|
ALWAYS_INLINE int fb_get_resolution(int fd, FBResolution* info)
|
2019-08-17 23:25:22 -03:00
|
|
|
{
|
|
|
|
|
return ioctl(fd, FB_IOCTL_GET_RESOLUTION, info);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 18:59:06 -03:00
|
|
|
ALWAYS_INLINE int fb_set_resolution(int fd, FBResolution* info)
|
2019-08-17 23:25:22 -03:00
|
|
|
{
|
|
|
|
|
return ioctl(fd, FB_IOCTL_SET_RESOLUTION, info);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-03 23:36:16 -03:00
|
|
|
ALWAYS_INLINE int fb_get_buffer_offset(int fd, int index, unsigned* offset)
|
|
|
|
|
{
|
|
|
|
|
FBBufferOffset fb_buffer_offset;
|
|
|
|
|
fb_buffer_offset.buffer_index = index;
|
|
|
|
|
int result = ioctl(fd, FB_IOCTL_GET_BUFFER_OFFSET, &fb_buffer_offset);
|
|
|
|
|
if (result == 0)
|
|
|
|
|
*offset = fb_buffer_offset.offset;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 18:59:06 -03:00
|
|
|
ALWAYS_INLINE int fb_get_buffer(int fd, int* index)
|
2019-08-17 23:25:22 -03:00
|
|
|
{
|
|
|
|
|
return ioctl(fd, FB_IOCTL_GET_BUFFER, index);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 18:59:06 -03:00
|
|
|
ALWAYS_INLINE int fb_set_buffer(int fd, int index)
|
2019-08-17 23:25:22 -03:00
|
|
|
{
|
|
|
|
|
return ioctl(fd, FB_IOCTL_SET_BUFFER, index);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-03 15:43:35 -03:00
|
|
|
ALWAYS_INLINE int fb_flush_buffers(int fd, int index, FBRect const* rects, unsigned count)
|
2021-06-12 09:46:54 -03:00
|
|
|
{
|
2021-07-03 15:43:35 -03:00
|
|
|
FBFlushRects fb_flush_rects;
|
|
|
|
|
fb_flush_rects.buffer_index = index;
|
|
|
|
|
fb_flush_rects.count = count;
|
|
|
|
|
fb_flush_rects.rects = rects;
|
|
|
|
|
return ioctl(fd, FB_IOCTL_FLUSH_BUFFERS, &fb_flush_rects);
|
2021-06-12 09:46:54 -03:00
|
|
|
}
|
|
|
|
|
|
2019-08-17 23:25:22 -03:00
|
|
|
__END_DECLS
|