/* * Copyright (c) 2022, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace Kernel { class IntelDisplayConnectorGroup; class IntelDisplayTranscoder { public: // Note: This is used to "cache" all the registers we wrote to, because // we might not be able to read them directly from hardware later. struct ShadowRegisters { u32 horizontal_total; u32 horizontal_blank; u32 horizontal_sync; u32 vertical_total; u32 vertical_blank; u32 vertical_sync; u32 exit_line; u32 pipe_source; u32 pipe_border_color_pattern; u32 reserved; u32 vsync_shift; u32 pipe_mult; u32 dpll_reserved_dac_multiplier; u32 dpll_raw_dac_multiplier; u32 dpll_divisor_a0; u32 dpll_divisor_a1; u32 dpll_p1; u32 dpll_control; u32 m1_value; u32 n1_value; u32 m2_value; u32 n2_value; u32 m1_link; u32 n1_link; u32 m2_link; u32 n2_link; }; ErrorOr set_mode_setting_timings(Badge, DisplayConnector::ModeSetting const&); virtual ErrorOr set_dpll_settings(Badge, IntelGraphics::PLLSettings const& settings, size_t dac_multiplier) = 0; virtual ErrorOr enable_dpll_without_vga(Badge) = 0; virtual ErrorOr disable_dpll(Badge) = 0; ShadowRegisters current_registers_state() const; virtual ~IntelDisplayTranscoder() = default; protected: struct [[gnu::packed]] TranscoderRegisters { u32 horizontal_total; u32 horizontal_blank; u32 horizontal_sync; u32 vertical_total; u32 vertical_blank; u32 vertical_sync; u32 exit_line; u32 pipe_source; u32 pipe_border_color_pattern; u32 reserved; u32 vsync_shift; u32 pipe_mult; u32 m1_value; u32 n1_value; u32 m2_value; u32 n2_value; u32 m1_link; u32 n1_link; u32 m2_link; u32 n2_link; }; explicit IntelDisplayTranscoder(Memory::TypedMapping); mutable Spinlock m_access_lock; ShadowRegisters m_shadow_registers {}; Memory::TypedMapping m_transcoder_registers; }; }