VGACompatibleAdapter.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/String.h>
  8. #include <AK/Types.h>
  9. #include <Kernel/Bus/PCI/Device.h>
  10. #include <Kernel/Graphics/Console/Console.h>
  11. #include <Kernel/Graphics/FramebufferDevice.h>
  12. #include <Kernel/Graphics/GraphicsDevice.h>
  13. #include <Kernel/PhysicalAddress.h>
  14. namespace Kernel {
  15. class VGACompatibleAdapter : public GraphicsDevice
  16. , public PCI::Device {
  17. AK_MAKE_ETERNAL
  18. public:
  19. static NonnullRefPtr<VGACompatibleAdapter> initialize_with_preset_resolution(PCI::Address, PhysicalAddress, size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch);
  20. static NonnullRefPtr<VGACompatibleAdapter> initialize(PCI::Address);
  21. virtual bool framebuffer_devices_initialized() const override { return !m_framebuffer_device.is_null(); }
  22. virtual bool modesetting_capable() const override { return false; }
  23. virtual bool double_framebuffering_capable() const override { return false; }
  24. virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) override;
  25. virtual bool set_y_offset(size_t output_port_index, size_t y) override;
  26. protected:
  27. explicit VGACompatibleAdapter(PCI::Address);
  28. private:
  29. VGACompatibleAdapter(PCI::Address, PhysicalAddress, size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch);
  30. // ^GraphicsDevice
  31. virtual void initialize_framebuffer_devices() override;
  32. virtual Type type() const override { return Type::VGACompatible; }
  33. virtual void enable_consoles() override;
  34. virtual void disable_consoles() override;
  35. protected:
  36. PhysicalAddress m_framebuffer_address;
  37. size_t m_framebuffer_width { 0 };
  38. size_t m_framebuffer_height { 0 };
  39. size_t m_framebuffer_pitch { 0 };
  40. RefPtr<FramebufferDevice> m_framebuffer_device;
  41. RefPtr<Graphics::Console> m_framebuffer_console;
  42. };
  43. }