atirage: add access to internal DAC palette.

This commit is contained in:
Maxim Poliakovski 2020-06-11 01:30:10 +02:00
parent f753bb1911
commit 8094fb30f6
2 changed files with 42 additions and 1 deletions

View File

@ -170,7 +170,17 @@ uint32_t ATIRage::read_reg(uint32_t offset, uint32_t size) {
uint32_t res;
switch (offset & ~3) {
case ATI_GP_IO:
case ATI_DAC_REGS:
if (offset == ATI_DAC_DATA) {
this->block_io_regs[ATI_DAC_DATA] =
this->palette[this->block_io_regs[ATI_DAC_R_INDEX]][this->comp_index];
this->comp_index++; /* move to next color component */
if (this->comp_index >= 3) {
/* autoincrement reading index - move to next palette entry */
(this->block_io_regs[ATI_DAC_R_INDEX])++;
this->comp_index = 0;
}
}
break;
default:
LOG_F(
@ -204,6 +214,30 @@ void ATIRage::write_reg(uint32_t offset, uint32_t value, uint32_t size) {
this->disp_id->read_monitor_sense(gpio_val, gpio_dir));
}
break;
case ATI_DAC_REGS:
switch (offset) {
/* writing to read/write index registers resets color component index */
case ATI_DAC_W_INDEX:
case ATI_DAC_R_INDEX:
this->comp_index = 0;
break;
case ATI_DAC_DATA:
this->palette[this->block_io_regs[ATI_DAC_W_INDEX]][this->comp_index] = value & 0xFF;
this->comp_index++; /* move to next color component */
if (this->comp_index >= 3) {
LOG_F(
INFO,
"ATI DAC palette entry #%d set to R=%X, G=%X, B=%X",
this->block_io_regs[ATI_DAC_W_INDEX],
this->palette[this->block_io_regs[ATI_DAC_W_INDEX]][0],
this->palette[this->block_io_regs[ATI_DAC_W_INDEX]][1],
this->palette[this->block_io_regs[ATI_DAC_W_INDEX]][2]);
/* autoincrement writing index - move to next palette entry */
(this->block_io_regs[ATI_DAC_W_INDEX])++;
this->comp_index = 0;
}
}
break;
default:
LOG_F(
INFO,

View File

@ -80,6 +80,10 @@ enum {
ATI_VGA_RP_SEL = 0x00B8,
ATI_I2C_CNTL_1 = 0x00BC,
ATI_DAC_REGS = 0x00C0,
ATI_DAC_W_INDEX = 0x00C0,
ATI_DAC_DATA = 0x00C1,
ATI_DAC_MASK = 0x00C2,
ATI_DAC_R_INDEX = 0x00C3,
ATI_DAC_CNTL = 0x00C4,
ATI_GEN_TEST_CNTL = 0x00D0,
ATI_CUSTOM_MACRO_CNTL = 0x00D4,
@ -155,5 +159,8 @@ private:
uint32_t aperture_base;
DisplayID* disp_id;
uint8_t palette[256][4]; /* internal DAC palette in RGBA format */
int comp_index; /* color component index for DAC palette access */
};
#endif /* ATI_RAGE_H */