appleramdac: Add other vendor id.

This commit is contained in:
joevt 2024-02-18 05:00:47 -08:00 committed by dingusdev
parent e3e065a6d7
commit 2f63a2fa17
2 changed files with 13 additions and 3 deletions

View File

@ -43,7 +43,7 @@ uint16_t AppleRamdac::iodev_read(uint32_t address) {
case RamdacRegs::PLL_CTRL:
return this->pll_cr;
case RamdacRegs::VENDOR_ID:
return DACULA_VENDOR_SIERRA;
return this->dac_vendor;
default:
LOG_F(WARNING, "%s: read from unsupported multi-register at 0x%X",
this->name.c_str(), this->dac_addr);
@ -142,7 +142,15 @@ int AppleRamdac::get_dot_freq() {
uint8_t p = this->clk_pn[this->pll_cr & 1] >> 5;
uint8_t n = this->clk_pn[this->pll_cr & 1] & 0x1F;
double dot_freq = 14318180.0f * (double)m / ((double)n * (double)(1 << p));
double dot_freq;
if (this->dac_vendor == DACULA_VENDOR_OTHER)
dot_freq = 15000000.0f * (double)m / ((double)n + 2) / (double)(1 << p);
else if (this->dac_vendor == DACULA_VENDOR_SIERRA)
dot_freq = 14318180.0f * (double)m / ((double)n * (double)(1 << p));
else {
dot_freq = 14318180.0f * (double)m / (double)n / (double)(1 << p);
LOG_F(ERROR, "%s: unknown VENDOR_ID", this->name.c_str());
}
return static_cast<int>(dot_freq + 0.5f);
}

View File

@ -35,7 +35,8 @@ enum DacFlavour {
DACULA,
};
#define DACULA_VENDOR_SIERRA 0x3C
#define DACULA_VENDOR_SIERRA 0x3C // 14.3 MHz
#define DACULA_VENDOR_OTHER 0x84 // 15 MHz
constexpr auto VIDEO_XTAL = 14318180.0f; // external crystal oscillator frequency
@ -109,6 +110,7 @@ protected:
uint8_t clk_m[2] = {};
uint8_t clk_pn[2] = {};
uint8_t pll_cr = 0;
uint8_t dac_vendor = DACULA_VENDOR_SIERRA;
uint8_t comp_index = 0;
uint8_t clut_color[3] = {};
uint32_t cursor_clut[8] = {};