2020-01-18 08:38:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2021-07-05 19:14:38 +00:00
|
|
|
* Copyright (c) 2021, Edwin Hoksberg <mail@edwinhoksberg.nl>
|
2020-01-18 08:38:21 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 08:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2018-11-16 12:11:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-01-07 20:52:06 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2019-08-18 02:22:49 +00:00
|
|
|
|
|
|
|
struct winsize {
|
|
|
|
unsigned short ws_row;
|
|
|
|
unsigned short ws_col;
|
2020-06-08 19:40:22 +00:00
|
|
|
unsigned short ws_xpixel;
|
|
|
|
unsigned short ws_ypixel;
|
2019-08-18 02:22:49 +00:00
|
|
|
};
|
|
|
|
|
2022-04-30 11:54:46 +00:00
|
|
|
struct GraphicsConnectorProperties {
|
2021-10-27 21:26:03 +00:00
|
|
|
unsigned char multihead_support;
|
|
|
|
unsigned char doublebuffer_support;
|
|
|
|
unsigned char flushing_support;
|
|
|
|
unsigned char partial_flushing_support;
|
Kernel/Graphics: Introduce the DisplayConnector class
The DisplayConnector class is meant to replace the FramebufferDevice
class. The advantage of this class over the FramebufferDevice class is:
1. It removes the mmap interface entirely. This interface is unsafe, as
multiple processes could try to use it, and when switching to and from
text console mode, there's no "good" way to revoke a memory mapping from
this interface, let alone when there are multiple processes that call
this interface. Therefore, in the DisplayConnector class there's no
implementation for this method at all.
2. The class uses a new real-world structure called ModeSetting, which
takes into account the fact that real hardware requires more than width,
height and pitch settings to mode-set the display resolution.
3. The class assumes all instances should supply some sort of EDID,
so it facilitates such mechanism to do so. Even if a given driver does
not know what is the actual EDID, it will ask to create default-generic
EDID blob.
3. This class shifts the responsibilies of switching between console
mode and graphical mode from a GraphicsAdapter to the DisplayConnector
class, so when doing the switch, the GraphicsManagement code actually
asks each DisplayConnector object to do the switch and doesn't rely on
the GraphicsAdapter objects at all.
2022-04-29 09:44:46 +00:00
|
|
|
unsigned char refresh_rate_support;
|
2022-09-24 13:55:46 +00:00
|
|
|
unsigned max_buffer_bytes;
|
2021-09-22 14:13:12 +00:00
|
|
|
};
|
|
|
|
|
2022-04-30 11:54:46 +00:00
|
|
|
struct GraphicsHeadModeSetting {
|
Kernel/Graphics: Introduce the DisplayConnector class
The DisplayConnector class is meant to replace the FramebufferDevice
class. The advantage of this class over the FramebufferDevice class is:
1. It removes the mmap interface entirely. This interface is unsafe, as
multiple processes could try to use it, and when switching to and from
text console mode, there's no "good" way to revoke a memory mapping from
this interface, let alone when there are multiple processes that call
this interface. Therefore, in the DisplayConnector class there's no
implementation for this method at all.
2. The class uses a new real-world structure called ModeSetting, which
takes into account the fact that real hardware requires more than width,
height and pitch settings to mode-set the display resolution.
3. The class assumes all instances should supply some sort of EDID,
so it facilitates such mechanism to do so. Even if a given driver does
not know what is the actual EDID, it will ask to create default-generic
EDID blob.
3. This class shifts the responsibilies of switching between console
mode and graphical mode from a GraphicsAdapter to the DisplayConnector
class, so when doing the switch, the GraphicsManagement code actually
asks each DisplayConnector object to do the switch and doesn't rely on
the GraphicsAdapter objects at all.
2022-04-29 09:44:46 +00:00
|
|
|
int horizontal_stride;
|
|
|
|
int pixel_clock_in_khz;
|
|
|
|
int horizontal_active;
|
|
|
|
int horizontal_front_porch_pixels;
|
|
|
|
int horizontal_sync_time_pixels;
|
|
|
|
int horizontal_blank_pixels;
|
|
|
|
int vertical_active;
|
|
|
|
int vertical_front_porch_lines;
|
|
|
|
int vertical_sync_time_lines;
|
|
|
|
int vertical_blank_lines;
|
|
|
|
int horizontal_offset;
|
|
|
|
int vertical_offset;
|
|
|
|
};
|
|
|
|
|
2022-04-30 11:54:46 +00:00
|
|
|
struct GraphicsHeadEDID {
|
2022-01-01 05:02:55 +00:00
|
|
|
unsigned char* bytes;
|
|
|
|
unsigned bytes_size;
|
|
|
|
};
|
|
|
|
|
2022-04-30 11:54:46 +00:00
|
|
|
struct GraphicsHeadVerticalOffset {
|
2021-09-22 14:13:12 +00:00
|
|
|
int head_index;
|
2021-11-20 16:10:57 +00:00
|
|
|
int offsetted;
|
2019-08-18 02:25:22 +00:00
|
|
|
};
|
|
|
|
|
2021-06-12 12:46:54 +00:00
|
|
|
struct FBRect {
|
2021-09-22 14:13:12 +00:00
|
|
|
int head_index;
|
2021-06-12 12:46:54 +00:00
|
|
|
unsigned x;
|
|
|
|
unsigned y;
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
};
|
|
|
|
|
2021-07-04 02:36:16 +00:00
|
|
|
struct FBBufferOffset {
|
|
|
|
int buffer_index;
|
|
|
|
unsigned offset;
|
|
|
|
};
|
|
|
|
|
2021-07-03 18:43:35 +00:00
|
|
|
struct FBFlushRects {
|
|
|
|
int buffer_index;
|
2021-06-26 17:04:01 +00:00
|
|
|
unsigned count;
|
2021-06-29 03:39:18 +00:00
|
|
|
struct FBRect const* rects;
|
2021-06-26 17:04:01 +00:00
|
|
|
};
|
|
|
|
|
2022-04-28 07:17:32 +00:00
|
|
|
enum ConsoleModes {
|
|
|
|
KD_TEXT = 0x00,
|
|
|
|
KD_GRAPHICS = 0x01,
|
|
|
|
};
|
|
|
|
|
2023-01-07 20:52:06 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2019-08-18 02:22:49 +00:00
|
|
|
|
2019-06-07 15:13:23 +00:00
|
|
|
enum IOCtlNumber {
|
2018-11-16 12:11:21 +00:00
|
|
|
TIOCGPGRP,
|
|
|
|
TIOCSPGRP,
|
2018-11-16 14:41:48 +00:00
|
|
|
TCGETS,
|
|
|
|
TCSETS,
|
|
|
|
TCSETSW,
|
|
|
|
TCSETSF,
|
2020-07-11 04:19:08 +00:00
|
|
|
TCFLSH,
|
2018-11-29 02:45:23 +00:00
|
|
|
TIOCGWINSZ,
|
2019-01-15 07:49:24 +00:00
|
|
|
TIOCSCTTY,
|
2021-03-31 20:58:41 +00:00
|
|
|
TIOCSTI,
|
2019-01-15 07:49:24 +00:00
|
|
|
TIOCNOTTY,
|
2019-02-20 22:32:33 +00:00
|
|
|
TIOCSWINSZ,
|
2022-02-15 19:31:17 +00:00
|
|
|
TIOCGPTN,
|
2022-04-30 11:49:51 +00:00
|
|
|
GRAPHICS_IOCTL_GET_PROPERTIES,
|
|
|
|
GRAPHICS_IOCTL_SET_HEAD_VERTICAL_OFFSET_BUFFER,
|
|
|
|
GRAPHICS_IOCTL_GET_HEAD_VERTICAL_OFFSET_BUFFER,
|
|
|
|
GRAPHICS_IOCTL_FLUSH_HEAD_BUFFERS,
|
|
|
|
GRAPHICS_IOCTL_FLUSH_HEAD,
|
|
|
|
GRAPHICS_IOCTL_SET_HEAD_MODE_SETTING,
|
|
|
|
GRAPHICS_IOCTL_GET_HEAD_MODE_SETTING,
|
|
|
|
GRAPHICS_IOCTL_SET_SAFE_HEAD_MODE_SETTING,
|
2022-06-10 11:16:28 +00:00
|
|
|
GRAPHICS_IOCTL_SET_RESPONSIBLE,
|
|
|
|
GRAPHICS_IOCTL_UNSET_RESPONSIBLE,
|
2021-07-05 19:14:38 +00:00
|
|
|
KEYBOARD_IOCTL_GET_NUM_LOCK,
|
|
|
|
KEYBOARD_IOCTL_SET_NUM_LOCK,
|
|
|
|
KEYBOARD_IOCTL_GET_CAPS_LOCK,
|
|
|
|
KEYBOARD_IOCTL_SET_CAPS_LOCK,
|
2022-12-15 09:42:40 +00:00
|
|
|
MOUNT_IOCTL_SET_MOUNT_SPECIFIC_FLAG,
|
2021-12-01 21:47:50 +00:00
|
|
|
SIOCATMARK,
|
2019-09-23 17:06:03 +00:00
|
|
|
SIOCSIFADDR,
|
|
|
|
SIOCGIFADDR,
|
2019-10-02 16:20:11 +00:00
|
|
|
SIOCGIFHWADDR,
|
2023-01-13 21:05:18 +00:00
|
|
|
SIOCGIFNAME,
|
|
|
|
SIOCGIFINDEX,
|
2021-04-16 15:48:41 +00:00
|
|
|
SIOCGIFNETMASK,
|
2020-03-14 19:00:49 +00:00
|
|
|
SIOCSIFNETMASK,
|
2021-04-16 15:48:41 +00:00
|
|
|
SIOCGIFBRDADDR,
|
|
|
|
SIOCGIFMTU,
|
|
|
|
SIOCGIFFLAGS,
|
|
|
|
SIOCGIFCONF,
|
2020-03-11 20:30:41 +00:00
|
|
|
SIOCADDRT,
|
2021-01-30 20:12:49 +00:00
|
|
|
SIOCDELRT,
|
2021-07-25 00:04:11 +00:00
|
|
|
SIOCSARP,
|
|
|
|
SIOCDARP,
|
2021-03-28 15:50:08 +00:00
|
|
|
FIBMAP,
|
|
|
|
FIONBIO,
|
2021-07-27 05:06:22 +00:00
|
|
|
FIONREAD,
|
2022-04-26 12:32:12 +00:00
|
|
|
FIOCLEX,
|
|
|
|
FIONCLEX,
|
2021-06-06 23:15:07 +00:00
|
|
|
KCOV_SETBUFSIZE,
|
|
|
|
KCOV_ENABLE,
|
|
|
|
KCOV_DISABLE,
|
2021-08-18 22:04:03 +00:00
|
|
|
SOUNDCARD_IOCTL_SET_SAMPLE_RATE,
|
2021-10-08 20:20:26 +00:00
|
|
|
SOUNDCARD_IOCTL_GET_SAMPLE_RATE,
|
|
|
|
STORAGE_DEVICE_GET_SIZE,
|
2021-10-09 09:19:51 +00:00
|
|
|
STORAGE_DEVICE_GET_BLOCK_SIZE,
|
2022-03-10 02:04:48 +00:00
|
|
|
VIRGL_IOCTL_CREATE_CONTEXT,
|
2022-02-18 05:32:02 +00:00
|
|
|
VIRGL_IOCTL_CREATE_RESOURCE,
|
|
|
|
VIRGL_IOCTL_SUBMIT_CMD,
|
|
|
|
VIRGL_IOCTL_TRANSFER_DATA,
|
2022-04-28 07:17:32 +00:00
|
|
|
KDSETMODE,
|
|
|
|
KDGETMODE,
|
2018-11-16 12:11:21 +00:00
|
|
|
};
|
2020-06-03 20:56:46 +00:00
|
|
|
|
|
|
|
#define TIOCGPGRP TIOCGPGRP
|
|
|
|
#define TIOCSPGRP TIOCSPGRP
|
|
|
|
#define TCGETS TCGETS
|
|
|
|
#define TCSETS TCSETS
|
|
|
|
#define TCSETSW TCSETSW
|
|
|
|
#define TCSETSF TCSETSF
|
2020-07-11 04:19:08 +00:00
|
|
|
#define TCFLSH TCFLSH
|
2020-06-03 20:56:46 +00:00
|
|
|
#define TIOCGWINSZ TIOCGWINSZ
|
|
|
|
#define TIOCSCTTY TIOCSCTTY
|
2021-03-31 20:58:41 +00:00
|
|
|
#define TIOCSTI TIOCSTI
|
2020-06-03 20:56:46 +00:00
|
|
|
#define TIOCNOTTY TIOCNOTTY
|
|
|
|
#define TIOCSWINSZ TIOCSWINSZ
|
2022-02-15 19:31:17 +00:00
|
|
|
#define TIOCGPTN TIOCGPTN
|
2022-04-30 11:49:51 +00:00
|
|
|
#define GRAPHICS_IOCTL_GET_PROPERTIES GRAPHICS_IOCTL_GET_PROPERTIES
|
|
|
|
#define GRAPHICS_IOCTL_SET_HEAD_VERTICAL_OFFSET_BUFFER GRAPHICS_IOCTL_SET_HEAD_VERTICAL_OFFSET_BUFFER
|
|
|
|
#define GRAPHICS_IOCTL_GET_HEAD_VERTICAL_OFFSET_BUFFER GRAPHICS_IOCTL_GET_HEAD_VERTICAL_OFFSET_BUFFER
|
|
|
|
#define GRAPHICS_IOCTL_FLUSH_HEAD_BUFFERS GRAPHICS_IOCTL_FLUSH_HEAD_BUFFERS
|
|
|
|
#define GRAPHICS_IOCTL_FLUSH_HEAD GRAPHICS_IOCTL_FLUSH_HEAD
|
|
|
|
#define GRAPHICS_IOCTL_SET_HEAD_MODE_SETTING GRAPHICS_IOCTL_SET_HEAD_MODE_SETTING
|
|
|
|
#define GRAPHICS_IOCTL_GET_HEAD_MODE_SETTING GRAPHICS_IOCTL_GET_HEAD_MODE_SETTING
|
|
|
|
#define GRAPHICS_IOCTL_SET_SAFE_HEAD_MODE_SETTING GRAPHICS_IOCTL_SET_SAFE_HEAD_MODE_SETTING
|
2022-06-10 11:16:28 +00:00
|
|
|
#define GRAPHICS_IOCTL_SET_RESPONSIBLE GRAPHICS_IOCTL_SET_RESPONSIBLE
|
|
|
|
#define GRAPHICS_IOCTL_UNSET_RESPONSIBLE GRAPHICS_IOCTL_UNSET_RESPONSIBLE
|
2021-07-05 19:14:38 +00:00
|
|
|
#define KEYBOARD_IOCTL_GET_NUM_LOCK KEYBOARD_IOCTL_GET_NUM_LOCK
|
|
|
|
#define KEYBOARD_IOCTL_SET_NUM_LOCK KEYBOARD_IOCTL_SET_NUM_LOCK
|
|
|
|
#define KEYBOARD_IOCTL_GET_CAPS_LOCK KEYBOARD_IOCTL_GET_CAPS_LOCK
|
|
|
|
#define KEYBOARD_IOCTL_SET_CAPS_LOCK KEYBOARD_IOCTL_SET_CAPS_LOCK
|
2021-12-01 21:47:50 +00:00
|
|
|
#define SIOCATMARK SIOCATMARK
|
2020-06-03 20:56:46 +00:00
|
|
|
#define SIOCSIFADDR SIOCSIFADDR
|
|
|
|
#define SIOCGIFADDR SIOCGIFADDR
|
|
|
|
#define SIOCGIFHWADDR SIOCGIFHWADDR
|
2021-04-16 15:48:41 +00:00
|
|
|
#define SIOCGIFNETMASK SIOCGIFNETMASK
|
2023-01-13 21:05:18 +00:00
|
|
|
#define SIOCGIFNAME SIOCGIFNAME
|
|
|
|
#define SIOCGIFINDEX SIOCGIFINDEX
|
2020-06-03 20:56:46 +00:00
|
|
|
#define SIOCSIFNETMASK SIOCSIFNETMASK
|
2021-04-16 15:48:41 +00:00
|
|
|
#define SIOCGIFBRDADDR SIOCGIFBRDADDR
|
|
|
|
#define SIOCGIFMTU SIOCGIFMTU
|
|
|
|
#define SIOCGIFFLAGS SIOCGIFFLAGS
|
|
|
|
#define SIOCGIFCONF SIOCGIFCONF
|
2020-06-03 20:56:46 +00:00
|
|
|
#define SIOCADDRT SIOCADDRT
|
|
|
|
#define SIOCDELRT SIOCDELRT
|
2021-07-25 00:04:11 +00:00
|
|
|
#define SIOCSARP SIOCSARP
|
|
|
|
#define SIOCDARP SIOCDARP
|
2021-01-30 20:12:49 +00:00
|
|
|
#define FIBMAP FIBMAP
|
2021-03-28 15:50:08 +00:00
|
|
|
#define FIONBIO FIONBIO
|
2021-07-27 05:06:22 +00:00
|
|
|
#define FIONREAD FIONREAD
|
2022-12-15 09:42:40 +00:00
|
|
|
#define MOUNT_IOCTL_SET_MOUNT_SPECIFIC_FLAG MOUNT_IOCTL_SET_MOUNT_SPECIFIC_FLAG
|
2021-08-18 22:04:03 +00:00
|
|
|
#define SOUNDCARD_IOCTL_SET_SAMPLE_RATE SOUNDCARD_IOCTL_SET_SAMPLE_RATE
|
|
|
|
#define SOUNDCARD_IOCTL_GET_SAMPLE_RATE SOUNDCARD_IOCTL_GET_SAMPLE_RATE
|
2021-10-08 20:20:26 +00:00
|
|
|
#define STORAGE_DEVICE_GET_SIZE STORAGE_DEVICE_GET_SIZE
|
2021-10-09 09:19:51 +00:00
|
|
|
#define STORAGE_DEVICE_GET_BLOCK_SIZE STORAGE_DEVICE_GET_BLOCK_SIZE
|
2022-03-10 02:04:48 +00:00
|
|
|
#define VIRGL_IOCTL_CREATE_CONTEXT VIRGL_IOCTL_CREATE_CONTEXT
|
2022-02-18 05:32:02 +00:00
|
|
|
#define VIRGL_IOCTL_CREATE_RESOURCE VIRGL_IOCTL_CREATE_RESOURCE
|
|
|
|
#define VIRGL_IOCTL_SUBMIT_CMD VIRGL_IOCTL_SUBMIT_CMD
|
|
|
|
#define VIRGL_IOCTL_TRANSFER_DATA VIRGL_IOCTL_TRANSFER_DATA
|
2022-04-28 07:17:32 +00:00
|
|
|
#define KDSETMODE KDSETMODE
|
|
|
|
#define KDGETMODE KDGETMODE
|