Skip to content

Commit

Permalink
Added dummy conexant video encoder device
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Aug 21, 2024
1 parent fa5d740 commit c1cccd8
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 9 additions & 1 deletion src/hw/machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -24,7 +25,7 @@ concept is_cpu_t = std::is_same_v<T, cpu_t *>;
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)) {
Expand Down Expand Up @@ -60,6 +61,9 @@ class machine {
if (!m_smc.init()) {
return false;
}
if (!m_conexant.init()) {
return false;
}
return true;
}
void deinit()
Expand Down Expand Up @@ -110,6 +114,9 @@ class machine {
else if constexpr (std::is_same_v<T, adm>) {
return m_adm;
}
else if constexpr (std::is_same_v<T, conexant>) {
return m_conexant;
}
else if constexpr (std::is_same_v<T, nv2a>) {
return m_nv2a;
}
Expand Down Expand Up @@ -193,4 +200,5 @@ class machine {
eeprom m_eeprom;
smc m_smc;
adm m_adm;
conexant m_conexant;
};
1 change: 1 addition & 0 deletions src/hw/smbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ smbus::init()
m_devs[0x54] = &m_machine->get<eeprom>(); // eeprom
m_devs[0x10] = &m_machine->get<smc>(); // smc
m_devs[0x4C] = &m_machine->get<adm>(); // adm
m_devs[0x45] = &m_machine->get<conexant>(); // conexant video encoder
reset();
return true;
}
66 changes: 66 additions & 0 deletions src/hw/video/conexant.cpp
Original file line number Diff line number Diff line change
@@ -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<uint16_t>
conexant::quick_command(bool command)
{
return 0;
}

std::optional<uint16_t>
conexant::receive_byte()
{
return 0;
}

std::optional<uint16_t>
conexant::send_byte(uint8_t data)
{
return 0;
}

std::optional<uint16_t>
conexant::read_byte(uint8_t command)
{
return m_regs[command];
}

std::optional<uint16_t>
conexant::write_byte(uint8_t command, uint8_t data)
{
m_regs[command] = data;
return 0;
}

std::optional<uint16_t>
conexant::read_word(uint8_t command)
{
return m_regs[command] | ((uint16_t)m_regs[command + 1] << 8);
}

std::optional<uint16_t>
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;
}
26 changes: 26 additions & 0 deletions src/hw/video/conexant.hpp
Original file line number Diff line number Diff line change
@@ -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<uint16_t> quick_command(bool command) override;
std::optional<uint16_t> receive_byte() override;
std::optional<uint16_t> send_byte(uint8_t data) override;
std::optional<uint16_t> read_byte(uint8_t command) override;
std::optional<uint16_t> write_byte(uint8_t command, uint8_t data) override;
std::optional<uint16_t> read_word(uint8_t command) override;
std::optional<uint16_t> write_word(uint8_t command, uint16_t data) override;

private:
uint8_t m_regs[256];
};
2 changes: 2 additions & 0 deletions src/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum class log_module : int32_t {
eeprom,
smc,
adm,
conexant,
max,
};

Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit c1cccd8

Please sign in to comment.