1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-27 23:55:09 +00:00
serenity/Kernel/Graphics/Intel/NativeGraphicsAdapter.h
Liav A 72b144e9e9 Kernel/Graphics: Introduce a new mechanism to initialize a PCI device
Instead of using a clunky switch-case paradigm, we now have all drivers
being declaring two methods for their adapter class - create and probe.
These methods are linked in each PCIGraphicsDriverInitializer structure,
in a new s_initializers static list of them.
Then, when we probe for a PCI device, we use each probe method and if
there's a match, then the corresponding create method is called.

As a result of this change, it's much more easy to add more drivers and
the initialization code is more readable.
2023-01-07 11:51:13 -07:00

37 lines
960 B
C++

/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <Kernel/Bus/PCI/Device.h>
#include <Kernel/Graphics/Definitions.h>
#include <Kernel/Graphics/Intel/NativeDisplayConnector.h>
#include <Kernel/PhysicalAddress.h>
#include <LibEDID/EDID.h>
namespace Kernel {
class IntelNativeGraphicsAdapter final
: public GenericGraphicsAdapter
, public PCI::Device {
public:
static ErrorOr<bool> probe(PCI::DeviceIdentifier const&);
static ErrorOr<NonnullLockRefPtr<GenericGraphicsAdapter>> create(PCI::DeviceIdentifier const&);
virtual ~IntelNativeGraphicsAdapter() = default;
virtual StringView device_name() const override { return "IntelNativeGraphicsAdapter"sv; }
private:
ErrorOr<void> initialize_adapter();
explicit IntelNativeGraphicsAdapter(PCI::Address);
LockRefPtr<IntelNativeDisplayConnector> m_display_connector;
};
}