diff --git a/CMakeLists.txt b/CMakeLists.txt index 89dd70b..8e697a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ set(HEADERS "${NXBX_ROOT_DIR}/src/hw/pit.hpp" "${NXBX_ROOT_DIR}/src/hw/smbus.hpp" "${NXBX_ROOT_DIR}/src/hw/smc.hpp" + "${NXBX_ROOT_DIR}/src/hw/video/conexant.hpp" "${NXBX_ROOT_DIR}/src/hw/video/vga.hpp" "${NXBX_ROOT_DIR}/src/hw/video/gpu/nv2a.hpp" "${NXBX_ROOT_DIR}/src/hw/video/gpu/nv2a_defs.hpp" @@ -106,6 +107,7 @@ set(SOURCES "${NXBX_ROOT_DIR}/src/hw/pit.cpp" "${NXBX_ROOT_DIR}/src/hw/smbus.cpp" "${NXBX_ROOT_DIR}/src/hw/smc.cpp" + "${NXBX_ROOT_DIR}/src/hw/video/conexant.cpp" "${NXBX_ROOT_DIR}/src/hw/video/vga.cpp" "${NXBX_ROOT_DIR}/src/hw/video/gpu/nv2a.cpp" "${NXBX_ROOT_DIR}/src/hw/video/gpu/pbus.cpp" diff --git a/src/hw/machine.hpp b/src/hw/machine.hpp index c3125b2..bf37d8f 100644 --- a/src/hw/machine.hpp +++ b/src/hw/machine.hpp @@ -14,6 +14,7 @@ #include "eeprom.hpp" #include "smc.hpp" #include "adm.hpp" +#include "video/conexant.hpp" #include "video/vga.hpp" #include "video/gpu/nv2a.hpp" @@ -24,7 +25,7 @@ concept is_cpu_t = std::is_same_v; class machine { public: machine() : m_cpu(this), m_pit(this), m_pic{ {this, 0, "MASTER PIC"}, {this, 1, "SLAVE PIC"} }, m_pci(this), m_cmos(this), m_nv2a(this), - m_vga(this), m_smbus(this), m_eeprom(log_module::eeprom), m_smc(this, log_module::smc), m_adm(log_module::adm) {} + m_vga(this), m_smbus(this), m_eeprom(log_module::eeprom), m_smc(this, log_module::smc), m_adm(log_module::adm), m_conexant(log_module::conexant) {} bool init(const init_info_t &init_info) { if (!m_cpu.init(init_info)) { @@ -60,6 +61,9 @@ class machine { if (!m_smc.init()) { return false; } + if (!m_conexant.init()) { + return false; + } return true; } void deinit() @@ -110,6 +114,9 @@ class machine { else if constexpr (std::is_same_v) { return m_adm; } + else if constexpr (std::is_same_v) { + return m_conexant; + } else if constexpr (std::is_same_v) { return m_nv2a; } @@ -193,4 +200,5 @@ class machine { eeprom m_eeprom; smc m_smc; adm m_adm; + conexant m_conexant; }; diff --git a/src/hw/smbus.cpp b/src/hw/smbus.cpp index 2e7d4f1..5eaee93 100644 --- a/src/hw/smbus.cpp +++ b/src/hw/smbus.cpp @@ -299,6 +299,7 @@ smbus::init() m_devs[0x54] = &m_machine->get(); // eeprom m_devs[0x10] = &m_machine->get(); // smc m_devs[0x4C] = &m_machine->get(); // adm + m_devs[0x45] = &m_machine->get(); // conexant video encoder reset(); return true; } diff --git a/src/hw/video/conexant.cpp b/src/hw/video/conexant.cpp new file mode 100644 index 0000000..fa3e79b --- /dev/null +++ b/src/hw/video/conexant.cpp @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +// SPDX-FileCopyrightText: 2024 ergo720 + +#include "machine.hpp" + +#define MODULE_NAME conexant + + +std::optional +conexant::quick_command(bool command) +{ + return 0; +} + +std::optional +conexant::receive_byte() +{ + return 0; +} + +std::optional +conexant::send_byte(uint8_t data) +{ + return 0; +} + +std::optional +conexant::read_byte(uint8_t command) +{ + return m_regs[command]; +} + +std::optional +conexant::write_byte(uint8_t command, uint8_t data) +{ + m_regs[command] = data; + return 0; +} + +std::optional +conexant::read_word(uint8_t command) +{ + return m_regs[command] | ((uint16_t)m_regs[command + 1] << 8); +} + +std::optional +conexant::write_word(uint8_t command, uint16_t data) +{ + m_regs[command] = data & 0xFF; + m_regs[command + 1] = data >> 8; + return 0; +} + +void +conexant::reset() +{ + std::fill(std::begin(m_regs), std::end(m_regs), 0); +} + +bool +conexant::init() +{ + reset(); + return true; +} diff --git a/src/hw/video/conexant.hpp b/src/hw/video/conexant.hpp new file mode 100644 index 0000000..bc6a327 --- /dev/null +++ b/src/hw/video/conexant.hpp @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +// SPDX-FileCopyrightText: 2024 ergo720 + +#pragma once + +#include "smbus.hpp" + + +class conexant : public smbus_device { +public: + conexant(log_module module_name) : smbus_device(module_name) {} + bool init(); + void deinit() override {} + void reset(); + std::optional quick_command(bool command) override; + std::optional receive_byte() override; + std::optional send_byte(uint8_t data) override; + std::optional read_byte(uint8_t command) override; + std::optional write_byte(uint8_t command, uint8_t data) override; + std::optional read_word(uint8_t command) override; + std::optional write_word(uint8_t command, uint16_t data) override; + +private: + uint8_t m_regs[256]; +}; diff --git a/src/logger.hpp b/src/logger.hpp index 9d23ce0..d4a8ad2 100644 --- a/src/logger.hpp +++ b/src/logger.hpp @@ -57,6 +57,7 @@ enum class log_module : int32_t { eeprom, smc, adm, + conexant, max, }; @@ -86,6 +87,7 @@ inline constexpr std::array module_to_str = { "EEPROM -> ", "SMC -> ", "ADM -> ", + "CONEXANT -> " }; static_assert(module_to_str.size() == (uint32_t)(log_module::max));