1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +00:00

Kernel: Split I2C functionality from IntelNativeDisplayConnector code

Splitting the I2C-related code lets the DisplayConnector code to utilize
I2C operations without caring about the specific details of the hardware
and allow future expansion of the driver to other newer generations
sharing the same GMBus code.

We should require a timeout for GMBus operations always, because faulty
hardware could let us just spin forever. Also, if nothing is listening
to the bus (which should result in a NAK), we could also spin forever.
This commit is contained in:
Liav A 2022-02-03 18:16:44 +02:00 committed by Andrew Kaster
parent ddc5c41253
commit 0c64abb5e3
5 changed files with 190 additions and 119 deletions

View file

@ -10,6 +10,7 @@
#include <Kernel/Graphics/Console/GenericFramebufferConsole.h>
#include <Kernel/Graphics/Definitions.h>
#include <Kernel/Graphics/DisplayConnector.h>
#include <Kernel/Graphics/Intel/Auxiliary/GMBusConnector.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Memory/TypedMapping.h>
@ -54,25 +55,6 @@ struct PLLParameterLimit {
struct PLLMaxSettings {
PLLParameterLimit dot_clock, vco, n, m, m1, m2, p, p1, p2;
};
enum GMBusPinPair : u8 {
None = 0,
DedicatedControl = 1,
DedicatedAnalog = 0b10,
IntegratedDigital = 0b11,
sDVO = 0b101,
Dconnector = 0b111,
};
enum class GMBusStatus {
TransactionCompletion,
HardwareReady,
};
enum GMBusCycle {
Wait = 1,
Stop = 4,
};
}
class IntelNativeDisplayConnector final
@ -101,11 +83,10 @@ private:
// Note: Paravirtualized hardware doesn't require a defined refresh rate for modesetting.
virtual bool refresh_rate_support() const override { return true; }
ErrorOr<void> initialize_gmbus_settings_and_read_edid();
IntelNativeDisplayConnector(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, NonnullOwnPtr<Memory::Region> registers_region);
IntelNativeDisplayConnector(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, NonnullOwnPtr<GMBusConnector>, NonnullOwnPtr<Memory::Region> registers_region);
ErrorOr<void> create_attached_framebuffer_console();
ErrorOr<void> initialize_gmbus_settings_and_read_edid();
void write_to_register(IntelGraphics::RegisterIndex, u32 value) const;
u32 read_from_register(IntelGraphics::RegisterIndex) const;
@ -142,14 +123,7 @@ private:
bool wait_for_disabled_pipe_a(size_t milliseconds_timeout) const;
bool wait_for_disabled_pipe_b(size_t milliseconds_timeout) const;
void set_gmbus_default_rate();
void set_gmbus_pin_pair(IntelGraphics::GMBusPinPair pin_pair);
// FIXME: It would be better if we generalize the I2C access later on
void gmbus_read_edid();
void gmbus_write(unsigned address, u32 byte);
void gmbus_read(unsigned address, u8* buf, size_t length);
bool gmbus_wait_for(IntelGraphics::GMBusStatus desired_status, Optional<size_t> milliseconds_timeout);
Optional<IntelGraphics::PLLSettings> create_pll_settings(u64 target_frequency, u64 reference_clock, IntelGraphics::PLLMaxSettings const&);
@ -158,5 +132,6 @@ private:
const PhysicalAddress m_registers;
NonnullOwnPtr<Memory::Region> m_registers_region;
NonnullOwnPtr<GMBusConnector> m_gmbus_connector;
};
}