Commit graph

40 commits

Author SHA1 Message Date
Liav A 50429d3b22 LibC+Kernel: Move GPU-related API methods to a LibC header file
The Kernel/API directory in general shouldn't include userspace code,
but structure definitions that both are shared between the Kernel and
userspace.

All users of the ioctl API obviously use LibC so LibC is the most common
and shared library for the affected programs.
2023-09-15 11:05:25 -06:00
Hendiadyoin1 05c959e40b AK: Change standard casting method of FixedPoint to truncation
This matches what floats do.

Also fix typo `trunk`->`trunc`
2023-08-14 14:20:45 -06:00
Nico Weber 66e210e406 Everywhere: Use nested namespace qualifiers 2023-07-12 10:05:42 +03:30
Nico Weber a2f33fdcef LibEDID: Use AssertSize<> for ExtensionBlock 2023-07-12 10:05:42 +03:30
Timothy Flynn c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Liav A 7c0540a229 Everywhere: Move global Kernel pattern code to Kernel/Library directory
This has KString, KBuffer, DoubleBuffer, KBufferBuilder, IOWindow,
UserOrKernelBuffer and ScopedCritical classes being moved to the
Kernel/Library subdirectory.

Also, move the panic and assertions handling code to that directory.
2023-06-04 21:32:34 +02:00
Emily Trau 332bb8a299 LibEDID: Fix compiler error when ENABLE_PNP_IDS_DOWNLOAD=OFF 2023-04-06 10:26:21 -04:00
Liav A 56b799c556 LibEDID: Return proper errno codes for kernel code 2023-02-10 09:14:20 +00:00
Timothy Flynn 4a916cd379 Everywhere: Remove needless copies of Error / ErrorOr instances
Either take the underlying objects with release_* methods or move() the
instances around.
2023-02-10 09:08:52 +00:00
Linus Groh 6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00:00
Andrew Kaster 7ab37ee22c Everywhere: Remove string.h include from AK/Traits.h and resolve fallout
A lot of places were relying on AK/Traits.h to give it strnlen, memcmp,
memcpy and other related declarations.

In the quest to remove inclusion of LibC headers from Kernel files, deal
with all the fallout of this included-everywhere header including less
things.
2023-01-21 10:43:59 -07:00
ericLemanissier 55405105a8 LibEDID: Propagate errors using TRY 2023-01-02 11:04:38 -05:00
Moustafa Raafat ae2abcebbb Everywhere: Use C++ concepts instead of requires clauses 2022-12-09 11:25:30 +00:00
Linus Groh 6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Linus Groh d26aabff04 Everywhere: Run clang-format 2022-12-03 23:52:23 +00:00
Tim Schumacher 7834e26ddb Everywhere: Explicitly link all binaries against the LibC target
Even though the toolchain implicitly links against -lc, it does not know
where it should get LibC from except for the sysroot. In the case of
Clang this causes it to pick up the LibC stub instead, which might be
slightly outdated and feature missing symbols.

This is currently not an issue that manifests because we pass through
the dependency on LibC and other libraries by accident, which causes
CMake to link against the LibC target (instead of just the library),
and thus points the linker at the build output directory.

Since we are looking to fix that in the upcoming commits, let's make
sure that everything will still be able to find the proper LibC first.
2022-11-01 14:49:09 +00:00
Nico Weber 2af028132a AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most places
Doesn't use them in libc headers so that those don't have to pull in
AK/Platform.h.

AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is
defined in clang builds as well.) Using AK_COMPILER_GCC simplifies
things some.

AK_COMPILER_CLANG isn't as much of a win, other than that it's
consistent with AK_COMPILER_GCC.
2022-10-04 23:35:07 +01:00
Liav A 50ed50752f LibEDID: Remove head index when retrieving an EDID from DisplayConnector
We simply don't need that field anymore, as it was used when one
FramebufferDevice could contain multiple framebuffers within it, each
for a connected screen head.
2022-09-24 15:36:19 +01:00
Tim Schumacher 8763dbcccc Everywhere: Remove a bunch of dead write-only variables
LLVM 15 now warns (and thus errors) about this, and there is really no
point in keeping them.
2022-09-16 05:39:28 +00:00
Liav A 1968aba69b Kernel+Userland: Rename FB.h => Graphics.h
This header file represents the entire interface between the kernel and
userland, and as such, no longer should be called FB.h but something
that represents the whole graphics subsystem.
2022-07-23 10:42:08 +01:00
Liav A b5e5b299c4 Userland: Remove stale remainders of old framebuffer devices 2022-07-23 10:42:08 +01:00
sin-ack e5f09ea170 Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
Liav A 1a641f9af7 LibEDID: Return "Unknown" string if failed to determine the manufacturer
Before of this patch, It happened that the return string could be "@@@",
as a result of doing mathematical addition of ASCII '@' with bits when
decoding the packed manufacturer ID bytes from the EDID.
To avoid this, consider m_legacy_manufacturer_id to be invalid until we
successfully decode the packed bytes.
2022-06-10 22:32:54 +01:00
Liav A aad968cc5e Everywhere: Rename fb prefix function names => graphics_connector 2022-05-05 20:55:57 +02:00
Liav A 10adc27eda Everywhere: Rename FB prefix structure names => Graphics 2022-05-05 20:55:57 +02:00
Liav A 3a3700f95e LibEDID: Export common structures into a header file
This will be used later in the kernel code to simplify the EDID handling
code.
2022-05-05 20:55:57 +02:00
Idan Horowitz 086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Liav A df5fa20bee LibEDID: Fix DetailedTiming::pixel_clock_khz result
The stored value is in units of 10 kHz, which means that to get the
value in kHz, we need to multiply it by 10 and not 10000.
2022-03-08 22:07:59 +01:00
Idan Horowitz 410183a7b0 LibEDID: Exclude DMT::MonitorTiming::name() from the Kernel
This API is only used by userland and it uses infallible Strings, so
let's just ifdef it out of the Kernel.
2022-02-16 22:21:37 +01:00
Idan Horowitz 7923b3b884 LibEDID: Exclude display_product_{name, serial_number} from the Kernel
These APIs return Strings, which are OOM-infallibe, and as such, not
appropriate for Kernel use. Since these APIs are only used by userland
at the moment, we can just ifdef them out of the Kernel.
2022-02-16 22:21:37 +01:00
Idan Horowitz 13f5d1c037 LibEDID: Store manufacturer id instead of allocating on each call
This also let's us use a KString instead of a string when we're in the
Kernel, which opens the path for OOM-failure propagation.
2022-02-16 22:21:37 +01:00
Idan Horowitz 4a15ed6164 LibEDID: Store EDID version instead of allocating on each getter call
This also let's us use a KString instead of a string when we're in the
Kernel, which opens the path for OOM-failure propagation.
2022-02-16 22:21:37 +01:00
Timothy Flynn 99c8dadcec LibEDID: Use correct paths for LibEDID generated files
Code generators that generate their files for both Lagom and Serenity
have a blob in their CMake file like this:

    set(TIME_ZONE_DATA_HEADER LibTimeZone/TimeZoneData.h)
    set(TIME_ZONE_DATA_IMPLEMENTATION LibTimeZone/TimeZoneData.cpp)
    set(TIME_ZONE_META_TARGET_PREFIX LibTimeZone_)

    if (CMAKE_CURRENT_BINARY_DIR MATCHES ".*/LibTimeZone")
        # Serenity build.
        set(TIME_ZONE_DATA_HEADER TimeZoneData.h)
        set(TIME_ZONE_DATA_IMPLEMENTATION TimeZoneData.cpp)
        set(TIME_ZONE_META_TARGET_PREFIX "")
    endif()

LibEDID generates files only for Serenity, but was using the Lagom build
version of the _HEADER, _IMPLEMENTATION, and _PREFIX variables. Thus if
pnp_ids.cmake was ever touched, the following error would be raised:

    Userland/Libraries/LibEDID/EDID.cpp:18:18: fatal error:
    LibEDID/PnpIDs.h: No such file or directory
        18 | #        include <LibEDID/LibEDID/PnpIDs.h>

Use the Serenity paths in pnp_ids.cmake and in the #include within
LibEDID itself.
2022-01-26 16:37:38 +01:00
Sam Atkins 45cf40653a Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr
Apologies for the enormous commit, but I don't see a way to split this
up nicely. In the vast majority of cases it's a simple change. A few
extra places can use TRY instead of manual error checking though. :^)
2022-01-24 22:36:09 +01:00
Tom a821aa5f50 LibEDID: Fix handling extension maps
We weren't properly iterating the extension blocks and thought we
encountered an unexpected extension map block, when we really should
have just skipped over it.
2022-01-24 19:29:06 +00:00
Tom 18fc54fc34 LibEDID: Fix calculating height and refresh rate for interlaced modes
The vertical values need to be multiplied with 2 for interlaced modes.
2022-01-24 19:29:06 +00:00
Tom 869c20b05d Meta+LibEDID: Download and generate the PNP ID database
This downloads the UEFI's published PNP ID database and generates a
lookup table for use in LibEDID. The lookup table isn't optimized at
all, but this can be easily done at a later point if needed.
2022-01-23 22:45:21 +00:00
Tom 49c902d581 LibEDID: Add API for conveniently querying EDID from framebuffer device 2022-01-23 22:45:21 +00:00
Tom 8184870f93 LibEDID: Add a library to parse EDID blobs
This library can be used (for the most part) by kernel drivers as well
as user mode. For this reason FixedPoint is used rather than floating
point, but kept to a minimum.
2022-01-23 22:45:21 +00:00