Mailinglist Archive: radeonhd (265 mails)
| < Previous | Next > |
[radeonhd] [PATCH] LUT precision fix
- From: "Yang Zhao" <yang@xxxxxxxxxx>
- Date: Fri, 2 Jan 2009 20:58:07 -0800
- Message-id: <40a7b1aa0901022058g63450c1dme4fc813b7d380ef@xxxxxxxxxxxxxx>
Attached are patches to correct LUT precision handling.
0002-*.patch correctly enables 10-bit precision for setting LUT
entries. Only applies to 8, 24, and 32 bpp depths, as 15 and 16bbp
seems to be handled differently. Confirmed to work as expected using
xgamma and ArgyllCMS; the latter used to result in corrupt gamma
ramps.
0001-*.patch adds a -l option to rhd_dump wich prints out the current
LUTs in hardware.
Tested on RV770 and M54.
--
Yang Zhao
From 8e851881a798bf657bdbca5ba55cac4011e29ff9 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Fri, 2 Jan 2009 14:20:56 -0800
Subject: [PATCH] rhd_dump: add LUT printing support
rhd_dump -l {0|1} <pci_id>
Argument to -l is lower and upper half of LUT for 0 and 1, respectively
---
utils/conntest/rhd_dump.c | 38 +++++++++++++++++++++++++++++++++++---
1 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/utils/conntest/rhd_dump.c b/utils/conntest/rhd_dump.c
index 54c3e23..41459ad 100644
--- a/utils/conntest/rhd_dump.c
+++ b/utils/conntest/rhd_dump.c
@@ -363,7 +363,7 @@ print_help(const char* progname, const char* message, const
char* msgarg)
{
if (message != NULL)
fprintf(stderr, "%s %s\n", message, msgarg);
- fprintf(stderr, "Usage: %s [-r start,end | -w addr val] PCI-tag\n"
+ fprintf(stderr, "Usage: %s [-r start,end | -w addr val | -l {0|1}]
PCI-tag\n"
" PCI-tag: bus:dev.func\n\n",
progname);
}
@@ -389,7 +389,8 @@ main(int argc, char *argv[])
enum {
NONE,
READ,
- WRITE
+ WRITE,
+ LUT
} action = READ; /* default */
int i;
@@ -432,7 +433,7 @@ main(int argc, char *argv[])
action = WRITE;
if (++i < argc)
- ret = sscanf(argv[i++], "%x", &addr);
+ ret = sscanf(argv[i++], "%d", &addr);
else {
i--;
ret = 0;
@@ -451,6 +452,21 @@ main(int argc, char *argv[])
i--;
ret = 0;
}
+ } else if (!strncmp("-l", argv[i], 3)) {
+ action = LUT;
+
+ if (++i < argc)
+ ret = sscanf(argv[i], "%d", &addr);
+ else {
+ i--;
+ ret = 0;
+ }
+
+ if (addr > 1) ret = 0;
+ if (ret != 1) {
+ print_help(argv[0], "Invalid LUT id:", argv[i]);
+ return 1;
+ }
} else if (!strncmp("-",argv[i],1)) {
print_help(argv[0], "Unknown option", argv[i]);
return 1;
@@ -524,6 +540,22 @@ main(int argc, char *argv[])
val = RegRead(io, addr);
printf("New value: 0x%4.4X: 0x%8.8X\n",addr, val);
}
+ else if (action == LUT) {
+ RegWrite(io, 0x6480, addr); /* lower half of LUT */
+ RegWrite(io, 0x6484, 0); /* table mode */
+ RegWrite(io, 0x6488, 0); /* start at 0 */
+
+ CARD32 r, g, b;
+
+ printf("Printing LUT %d\n", addr);
+ printf(" R G B\n");
+ for (j = 0; j < 256; j++) {
+ r = RegRead(io, 0x648C) >> 6;
+ g = RegRead(io, 0x648C) >> 6;
+ b = RegRead(io, 0x648C) >> 6;
+ printf("%02X: %3X %3X %3X\n", j, r, g, b);
+ }
+ }
return 0;
}
--
1.6.0.6
From e5af9aac3e44eb826eaae28ae1b99d2f2fca153a Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Fri, 2 Jan 2009 19:58:28 -0800
Subject: [PATCH] Fix LUT precision handling for 8, 24, and 32bit depth
Properly advertise 10bit precision for LUT entries, and adjust
truncation routines appropriately.
Also fix rhdRRCrtcGammaSet() path such that it does not pass on 16-bit
precision entries onto LUTxSet()
---
src/rhd_driver.c | 3 ++-
src/rhd_lut.c | 10 +++++-----
src/rhd_randr.c | 6 +++---
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index 538534a..e97adab 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -1212,7 +1212,8 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv)
if(!miCreateDefColormap(pScreen))
return FALSE;
/* fixme */
- if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits,
+ /* Support 10-bits of precision in LUT */
+ if (!xf86HandleColormaps(pScreen, 256, 10,
RHDLoadPalette, NULL,
CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH))
return FALSE;
diff --git a/src/rhd_lut.c b/src/rhd_lut.c
index 448127b..0df0511 100644
--- a/src/rhd_lut.c
+++ b/src/rhd_lut.c
@@ -158,8 +158,8 @@ LUTxSet(struct rhdLUT *LUT, int numColors, int *indices,
LOCO *colors)
for (i = 0; i < numColors; i++) {
index = indices[i];
RHDRegWrite(LUT, DC_LUT_RW_INDEX, index);
- RHDRegWrite(LUT, DC_LUT_30_COLOR, (colors[index].red << 22) |
- (colors[index].green << 12) | (colors[index].blue <<
2));
+ RHDRegWrite(LUT, DC_LUT_30_COLOR, (colors[index].red << 20) |
+ (colors[index].green << 10) | (colors[index].blue));
}
break;
case 16:
@@ -333,9 +333,9 @@ RHDLUTCopyForRR(struct rhdLUT *LUT)
entry = RHDRegRead(LUT, DC_LUT_30_COLOR);
- colors[i].red = (entry >> 22) & 0xFF;
- colors[i].green = (entry >> 12) & 0xFF;
- colors[i].blue = (entry >> 2) & 0xFF;
+ colors[i].red = (entry >> 20) & 0x3FF;
+ colors[i].green = (entry >> 10) & 0x3FF;
+ colors[i].blue = (entry) & 0x3FF;
}
LUT->Set(LUT, 0x100, indices, colors);
break;
diff --git a/src/rhd_randr.c b/src/rhd_randr.c
index 7045b61..273b988 100644
--- a/src/rhd_randr.c
+++ b/src/rhd_randr.c
@@ -494,9 +494,9 @@ rhdRRCrtcGammaSet(xf86CrtcPtr crtc, CARD16 *red, CARD16
*green, CARD16 *blue,
/* thanks so very much */
for (i = 0; i < size; i++) {
indices[i] = i;
- colors[i].red = red[i];
- colors[i].green = green[i];
- colors[i].blue = blue[i];
+ colors[i].red = red[i] >> 6;
+ colors[i].green = green[i] >> 6;
+ colors[i].blue = blue[i] >> 6;
}
rhdCrtc->LUT->Set(rhdCrtc->LUT, size, indices, colors);
--
1.6.0.6
0002-*.patch correctly enables 10-bit precision for setting LUT
entries. Only applies to 8, 24, and 32 bpp depths, as 15 and 16bbp
seems to be handled differently. Confirmed to work as expected using
xgamma and ArgyllCMS; the latter used to result in corrupt gamma
ramps.
0001-*.patch adds a -l option to rhd_dump wich prints out the current
LUTs in hardware.
Tested on RV770 and M54.
--
Yang Zhao
From 8e851881a798bf657bdbca5ba55cac4011e29ff9 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Fri, 2 Jan 2009 14:20:56 -0800
Subject: [PATCH] rhd_dump: add LUT printing support
rhd_dump -l {0|1} <pci_id>
Argument to -l is lower and upper half of LUT for 0 and 1, respectively
---
utils/conntest/rhd_dump.c | 38 +++++++++++++++++++++++++++++++++++---
1 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/utils/conntest/rhd_dump.c b/utils/conntest/rhd_dump.c
index 54c3e23..41459ad 100644
--- a/utils/conntest/rhd_dump.c
+++ b/utils/conntest/rhd_dump.c
@@ -363,7 +363,7 @@ print_help(const char* progname, const char* message, const
char* msgarg)
{
if (message != NULL)
fprintf(stderr, "%s %s\n", message, msgarg);
- fprintf(stderr, "Usage: %s [-r start,end | -w addr val] PCI-tag\n"
+ fprintf(stderr, "Usage: %s [-r start,end | -w addr val | -l {0|1}]
PCI-tag\n"
" PCI-tag: bus:dev.func\n\n",
progname);
}
@@ -389,7 +389,8 @@ main(int argc, char *argv[])
enum {
NONE,
READ,
- WRITE
+ WRITE,
+ LUT
} action = READ; /* default */
int i;
@@ -432,7 +433,7 @@ main(int argc, char *argv[])
action = WRITE;
if (++i < argc)
- ret = sscanf(argv[i++], "%x", &addr);
+ ret = sscanf(argv[i++], "%d", &addr);
else {
i--;
ret = 0;
@@ -451,6 +452,21 @@ main(int argc, char *argv[])
i--;
ret = 0;
}
+ } else if (!strncmp("-l", argv[i], 3)) {
+ action = LUT;
+
+ if (++i < argc)
+ ret = sscanf(argv[i], "%d", &addr);
+ else {
+ i--;
+ ret = 0;
+ }
+
+ if (addr > 1) ret = 0;
+ if (ret != 1) {
+ print_help(argv[0], "Invalid LUT id:", argv[i]);
+ return 1;
+ }
} else if (!strncmp("-",argv[i],1)) {
print_help(argv[0], "Unknown option", argv[i]);
return 1;
@@ -524,6 +540,22 @@ main(int argc, char *argv[])
val = RegRead(io, addr);
printf("New value: 0x%4.4X: 0x%8.8X\n",addr, val);
}
+ else if (action == LUT) {
+ RegWrite(io, 0x6480, addr); /* lower half of LUT */
+ RegWrite(io, 0x6484, 0); /* table mode */
+ RegWrite(io, 0x6488, 0); /* start at 0 */
+
+ CARD32 r, g, b;
+
+ printf("Printing LUT %d\n", addr);
+ printf(" R G B\n");
+ for (j = 0; j < 256; j++) {
+ r = RegRead(io, 0x648C) >> 6;
+ g = RegRead(io, 0x648C) >> 6;
+ b = RegRead(io, 0x648C) >> 6;
+ printf("%02X: %3X %3X %3X\n", j, r, g, b);
+ }
+ }
return 0;
}
--
1.6.0.6
From e5af9aac3e44eb826eaae28ae1b99d2f2fca153a Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Fri, 2 Jan 2009 19:58:28 -0800
Subject: [PATCH] Fix LUT precision handling for 8, 24, and 32bit depth
Properly advertise 10bit precision for LUT entries, and adjust
truncation routines appropriately.
Also fix rhdRRCrtcGammaSet() path such that it does not pass on 16-bit
precision entries onto LUTxSet()
---
src/rhd_driver.c | 3 ++-
src/rhd_lut.c | 10 +++++-----
src/rhd_randr.c | 6 +++---
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index 538534a..e97adab 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -1212,7 +1212,8 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv)
if(!miCreateDefColormap(pScreen))
return FALSE;
/* fixme */
- if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits,
+ /* Support 10-bits of precision in LUT */
+ if (!xf86HandleColormaps(pScreen, 256, 10,
RHDLoadPalette, NULL,
CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH))
return FALSE;
diff --git a/src/rhd_lut.c b/src/rhd_lut.c
index 448127b..0df0511 100644
--- a/src/rhd_lut.c
+++ b/src/rhd_lut.c
@@ -158,8 +158,8 @@ LUTxSet(struct rhdLUT *LUT, int numColors, int *indices,
LOCO *colors)
for (i = 0; i < numColors; i++) {
index = indices[i];
RHDRegWrite(LUT, DC_LUT_RW_INDEX, index);
- RHDRegWrite(LUT, DC_LUT_30_COLOR, (colors[index].red << 22) |
- (colors[index].green << 12) | (colors[index].blue <<
2));
+ RHDRegWrite(LUT, DC_LUT_30_COLOR, (colors[index].red << 20) |
+ (colors[index].green << 10) | (colors[index].blue));
}
break;
case 16:
@@ -333,9 +333,9 @@ RHDLUTCopyForRR(struct rhdLUT *LUT)
entry = RHDRegRead(LUT, DC_LUT_30_COLOR);
- colors[i].red = (entry >> 22) & 0xFF;
- colors[i].green = (entry >> 12) & 0xFF;
- colors[i].blue = (entry >> 2) & 0xFF;
+ colors[i].red = (entry >> 20) & 0x3FF;
+ colors[i].green = (entry >> 10) & 0x3FF;
+ colors[i].blue = (entry) & 0x3FF;
}
LUT->Set(LUT, 0x100, indices, colors);
break;
diff --git a/src/rhd_randr.c b/src/rhd_randr.c
index 7045b61..273b988 100644
--- a/src/rhd_randr.c
+++ b/src/rhd_randr.c
@@ -494,9 +494,9 @@ rhdRRCrtcGammaSet(xf86CrtcPtr crtc, CARD16 *red, CARD16
*green, CARD16 *blue,
/* thanks so very much */
for (i = 0; i < size; i++) {
indices[i] = i;
- colors[i].red = red[i];
- colors[i].green = green[i];
- colors[i].blue = blue[i];
+ colors[i].red = red[i] >> 6;
+ colors[i].green = green[i] >> 6;
+ colors[i].blue = blue[i] >> 6;
}
rhdCrtc->LUT->Set(rhdCrtc->LUT, size, indices, colors);
--
1.6.0.6
| < Previous | Next > |