atirage: fix FB pitch calculation.

This commit is contained in:
Maxim Poliakovski 2024-02-26 14:21:53 +01:00
parent 0c3f399de3
commit b8d0ed39d9

View File

@ -278,11 +278,8 @@ void ATIRage::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size) {
LOG_F(9, "%s: ATI_CRTC_H_TOTAL_DISP set to 0x%08X", this->name.c_str(), value); LOG_F(9, "%s: ATI_CRTC_H_TOTAL_DISP set to 0x%08X", this->name.c_str(), value);
break; break;
case ATI_CRTC_OFF_PITCH: case ATI_CRTC_OFF_PITCH:
if (this->regs[reg_offset] != value) {
this->regs[reg_offset] = value; this->regs[reg_offset] = value;
this->fb_pitch = extract_bits<uint32_t>(value, 22, 10) * 8;
this->fb_ptr = &this->vram_ptr[extract_bits<uint32_t>(value, 0, 20) * 8];
if (bit_set(this->regs[ATI_CRTC_GEN_CNTL], 25) &&
!bit_set(this->regs[ATI_CRTC_GEN_CNTL], 6)) {
this->crtc_update(); this->crtc_update();
} }
break; break;
@ -587,6 +584,13 @@ void ATIRage::crtc_update() {
LOG_F(ERROR, "%s: unsupported pixel format %d", this->name.c_str(), pix_fmt); LOG_F(ERROR, "%s: unsupported pixel format %d", this->name.c_str(), pix_fmt);
} }
static uint8_t bits_per_pixel[8] = {0, 4, 8, 16, 16, 24, 32, 0};
this->fb_pitch = extract_bits<uint32_t>(this->regs[ATI_CRTC_OFF_PITCH], 22, 10) *
(bits_per_pixel[pix_fmt & 7] * 8) >> 3;
this->fb_ptr = &this->vram_ptr[extract_bits<uint32_t>(this->regs[ATI_CRTC_OFF_PITCH], 0, 20) * 8];
LOG_F(INFO, "%s: primary CRT controller enabled:", this->name.c_str()); LOG_F(INFO, "%s: primary CRT controller enabled:", this->name.c_str());
LOG_F(INFO, "Video mode: %s", LOG_F(INFO, "Video mode: %s",
bit_set(this->regs[ATI_CRTC_GEN_CNTL], 24) ? "extended" : "VGA"); bit_set(this->regs[ATI_CRTC_GEN_CNTL], 24) ? "extended" : "VGA");