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
|
|
|
}
|
|
|
|
|
2022-04-29 17:56:24 +03:00
|
|
|
// FIXME: Remove this once framebuffer devices are removed.
|
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
|
|
|
}
|
|
|
|
|
2022-04-29 17:56:24 +03:00
|
|
|
// FIXME: Remove this once framebuffer devices are removed.
|
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
|
|
|
}
|
|
|
|
|
2022-04-29 17:56:24 +03:00
|
|
|
// FIXME: Remove this once framebuffer devices are removed.
|
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-12-31 22:02:55 -07:00
|
|
|
ALWAYS_INLINE int fb_get_head_edid(int fd, FBHeadEDID* info)
|
|
|
|
{
|
|
|
|
return ioctl(fd, FB_IOCTL_GET_HEAD_EDID, info);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-04-29 17:56:24 +03:00
|
|
|
ALWAYS_INLINE int fb_set_head_mode_setting(int fd, FBHeadModeSetting* mode_setting)
|
|
|
|
{
|
|
|
|
return ioctl(fd, FB_IOCTL_SET_HEAD_MODE_SETTING, mode_setting);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE int fb_get_head_mode_setting(int fd, FBHeadModeSetting* mode_setting)
|
|
|
|
{
|
|
|
|
FBHeadModeSetting head_mode_setting;
|
|
|
|
if (auto rc = ioctl(fd, FB_IOCTL_GET_HEAD_MODE_SETTING, &head_mode_setting); rc < 0)
|
|
|
|
return rc;
|
|
|
|
mode_setting->horizontal_stride = head_mode_setting.horizontal_stride;
|
|
|
|
mode_setting->pixel_clock_in_khz = head_mode_setting.pixel_clock_in_khz;
|
|
|
|
mode_setting->horizontal_active = head_mode_setting.horizontal_active;
|
|
|
|
mode_setting->horizontal_front_porch_pixels = head_mode_setting.horizontal_front_porch_pixels;
|
|
|
|
mode_setting->horizontal_sync_time_pixels = head_mode_setting.horizontal_sync_time_pixels;
|
|
|
|
mode_setting->horizontal_blank_pixels = head_mode_setting.horizontal_blank_pixels;
|
|
|
|
mode_setting->vertical_active = head_mode_setting.vertical_active;
|
|
|
|
mode_setting->vertical_front_porch_lines = head_mode_setting.vertical_front_porch_lines;
|
|
|
|
mode_setting->vertical_sync_time_lines = head_mode_setting.vertical_sync_time_lines;
|
|
|
|
mode_setting->vertical_blank_lines = head_mode_setting.vertical_blank_lines;
|
|
|
|
mode_setting->horizontal_offset = head_mode_setting.horizontal_offset;
|
|
|
|
mode_setting->vertical_offset = head_mode_setting.vertical_offset;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|