/* * Copyright (c) 2021, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace Kernel { class GraphicsManagement; class VMWareDisplayConnector; class VMWareGraphicsAdapter final : public GenericGraphicsAdapter , public PCI::Device { friend class GraphicsManagement; public: static ErrorOr probe(PCI::DeviceIdentifier const&); static ErrorOr> create(PCI::DeviceIdentifier const&); virtual ~VMWareGraphicsAdapter() = default; virtual StringView device_name() const override { return "VMWareGraphicsAdapter"sv; } ErrorOr modeset_primary_screen_resolution(Badge, size_t width, size_t height); size_t primary_screen_width(Badge) const; size_t primary_screen_height(Badge) const; size_t primary_screen_pitch(Badge) const; void primary_screen_flush(Badge, size_t current_width, size_t current_height); private: ErrorOr initialize_adapter(); ErrorOr initialize_fifo_registers(); ErrorOr negotiate_device_version(); u32 read_io_register(VMWareDisplayRegistersOffset) const; void write_io_register(VMWareDisplayRegistersOffset, u32 value); void print_svga_capabilities() const; void modeset_primary_screen_resolution(size_t width, size_t height); VMWareGraphicsAdapter(PCI::DeviceIdentifier const&, NonnullOwnPtr registers_io_window); Memory::TypedMapping m_fifo_registers; LockRefPtr m_display_connector; mutable NonnullOwnPtr m_registers_io_window; mutable Spinlock m_io_access_lock {}; mutable RecursiveSpinlock m_operation_lock {}; }; }