summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2010-12-15 14:57:04 +1000
committerBen Skeggs <bskeggs@redhat.com>2010-12-15 14:57:04 +1000
commitad5b4cfe388a102a0c93f7281cb4bba532b1796b (patch)
tree01fa78aced39c2a795eaf4d42d04966371fc5abc
parent1942a81c0eb592972d4a3e8c46b80192ae8d1a59 (diff)
parentb6cb21b91f7d0409794a14ddbdd606728d4d49e3 (diff)
downloadxorg-driver-xf86-video-nouveau-ad5b4cfe388a102a0c93f7281cb4bba532b1796b.tar.gz
Merge branch 'master' into nvc0
-rw-r--r--src/drmmode_display.c40
-rw-r--r--src/nouveau_xv.c31
-rw-r--r--src/nv50_accel.c48
-rw-r--r--src/nv50_accel.h10
-rw-r--r--src/nv50_xv.c136
-rw-r--r--src/nv_driver.c1
-rw-r--r--src/nv_proto.h2
7 files changed, 207 insertions, 61 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index c5b57eb..d14dd80 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -187,22 +187,18 @@ void
drmmode_fbcon_copy(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
NVPtr pNv = NVPTR(pScrn);
+#if XORG_VERSION_CURRENT >= 10999001
ExaDriverPtr exa = pNv->EXADriverPtr;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
struct nouveau_bo *bo = NULL;
PixmapPtr pspix, pdpix;
drmModeFBPtr fb;
unsigned w = pScrn->virtualX, h = pScrn->virtualY;
int i, ret, fbcon_id = 0;
- if (pNv->NoAccel) {
- if (nouveau_bo_map(pNv->scanout, NOUVEAU_BO_WR))
- return;
- memset(pNv->scanout->map, 0x00, pNv->scanout->size);
- nouveau_bo_unmap(pNv->scanout);
- return;
- }
+ if (pNv->NoAccel)
+ goto fallback;
for (i = 0; i < xf86_config->num_crtc; i++) {
drmmode_crtc_private_ptr drmmode_crtc =
@@ -213,32 +209,27 @@ drmmode_fbcon_copy(ScreenPtr pScreen)
}
if (!fbcon_id)
- return;
+ goto fallback;
fb = drmModeGetFB(nouveau_device(pNv->dev)->fd, fbcon_id);
if (!fb) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Failed to retrieve fbcon fb: id %d\n", fbcon_id);
- return;
+ goto fallback;
}
- if (fb->depth != pScrn->depth) {
+ if (fb->depth != pScrn->depth || fb->width != w || fb->height != h) {
drmFree(fb);
- return;
+ goto fallback;
}
- if (w > fb->width)
- w = fb->width;
- if (h > fb->height)
- h = fb->height;
-
ret = nouveau_bo_wrap(pNv->dev, fb->handle, &bo);
if (ret) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Failed to retrieve fbcon buffer: handle=0x%08x\n",
fb->handle);
drmFree(fb);
- return;
+ goto fallback;
}
pspix = drmmode_pixmap_wrap(pScreen, fb->width, fb->height,
@@ -248,7 +239,7 @@ drmmode_fbcon_copy(ScreenPtr pScreen)
if (!pspix) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Failed to create pixmap for fbcon contents\n");
- return;
+ goto fallback;
}
pdpix = drmmode_pixmap_wrap(pScreen, pScrn->virtualX,
@@ -260,7 +251,7 @@ drmmode_fbcon_copy(ScreenPtr pScreen)
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Failed to init scanout pixmap for fbcon mirror\n");
pScreen->DestroyPixmap(pspix);
- return;
+ goto fallback;
}
exa->PrepareCopy(pspix, pdpix, 0, 0, GXcopy, ~0);
@@ -276,6 +267,15 @@ drmmode_fbcon_copy(ScreenPtr pScreen)
pScreen->DestroyPixmap(pdpix);
pScreen->DestroyPixmap(pspix);
+ pScreen->canDoBGNoneRoot = TRUE;
+ return;
+
+fallback:
+#endif
+ if (nouveau_bo_map(pNv->scanout, NOUVEAU_BO_WR))
+ return;
+ memset(pNv->scanout->map, 0x00, pNv->scanout->size);
+ nouveau_bo_unmap(pNv->scanout);
}
static Bool
diff --git a/src/nouveau_xv.c b/src/nouveau_xv.c
index 695c620..dba153c 100644
--- a/src/nouveau_xv.c
+++ b/src/nouveau_xv.c
@@ -137,6 +137,17 @@ XF86AttributeRec NVTexturedAttributes[NUM_TEXTURED_ATTRIBUTES] =
{XvSettable | XvGettable, 0, 1, "XV_SYNC_TO_VBLANK"}
};
+#define NUM_TEXTURED_ATTRIBUTES_NV50 7
+XF86AttributeRec NVTexturedAttributesNV50[NUM_TEXTURED_ATTRIBUTES_NV50] =
+{
+ { XvSettable , 0, 0, "XV_SET_DEFAULTS" },
+ { XvSettable | XvGettable, 0, 1, "XV_SYNC_TO_VBLANK" },
+ { XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS" },
+ { XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST" },
+ { XvSettable | XvGettable, -1000, 1000, "XV_SATURATION" },
+ { XvSettable | XvGettable, -1000, 1000, "XV_HUE" },
+ { XvSettable | XvGettable, 0, 1, "XV_ITURBT_709" }
+};
#define NUM_IMAGES_YUV 4
#define NUM_IMAGES_ALL 5
@@ -1999,8 +2010,8 @@ NV50SetupTexturedVideo (ScreenPtr pScreen)
for(i = 0; i < NUM_TEXTURE_PORTS; i++)
adapt->pPortPrivates[i].ptr = (pointer)(pPriv);
- adapt->pAttributes = NVTexturedAttributes;
- adapt->nAttributes = NUM_TEXTURED_ATTRIBUTES;
+ adapt->pAttributes = NVTexturedAttributesNV50;
+ adapt->nAttributes = NUM_TEXTURED_ATTRIBUTES_NV50;
adapt->pImages = NV50TexturedImages;
adapt->nImages = sizeof(NV50TexturedImages) /
sizeof(NV50TexturedImages[0]);
@@ -2015,14 +2026,16 @@ NV50SetupTexturedVideo (ScreenPtr pScreen)
adapt->PutImage = NVPutImage;
adapt->QueryImageAttributes = NVQueryImageAttributes;
- pPriv->videoStatus = 0;
- pPriv->grabbedByV4L = FALSE;
- pPriv->blitter = FALSE;
- pPriv->texture = TRUE;
- pPriv->doubleBuffer = FALSE;
- pPriv->SyncToVBlank = TRUE;
-
pNv->textureAdaptor[0] = adapt;
+
+ nv50_xv_set_port_defaults(pScrn, pPriv);
+ nv50_xv_csc_update(pScrn, pPriv);
+
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvContrast = MAKE_ATOM("XV_CONTRAST");
+ xvSaturation = MAKE_ATOM("XV_SATURATION");
+ xvHue = MAKE_ATOM("XV_HUE");
+ xvITURBT709 = MAKE_ATOM("XV_ITURBT_709");
return adapt;
}
diff --git a/src/nv50_accel.c b/src/nv50_accel.c
index 95d1886..0369839 100644
--- a/src/nv50_accel.c
+++ b/src/nv50_accel.c
@@ -352,42 +352,35 @@ NVAccelInitNV50TCL(ScrnInfoPtr pScrn)
OUT_RING (chan, (0 << NV50TCL_CB_DEF_SET_BUFFER_SHIFT) | 0x4000);
BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
OUT_RING (chan, 0);
- BEGIN_RING_NI(chan, tesla, NV50TCL_CB_DATA(0), 34);
+ BEGIN_RING_NI(chan, tesla, NV50TCL_CB_DATA(0), 28);
OUT_RING (chan, 0x80000008);
OUT_RING (chan, 0x90000408);
OUT_RING (chan, 0x82010400);
OUT_RING (chan, 0x82020404);
OUT_RING (chan, 0xf0400001);
OUT_RING (chan, 0x00008784);
- OUT_RING (chan, 0xc0080001);
- OUT_RING (chan, 0x03f9507f);
- OUT_RING (chan, 0xb013000d);
- OUT_RING (chan, 0x0bf5ee3b);
- OUT_RING (chan, 0xb02f0011);
- OUT_RING (chan, 0x03f078ff);
- OUT_RING (chan, 0xb0220015);
- OUT_RING (chan, 0x0bf8a677);
+ OUT_RING (chan, 0xc0800014);
+ OUT_RING (chan, 0xb0810a0c);
+ OUT_RING (chan, 0xb0820a10);
+ OUT_RING (chan, 0xb0830a14);
OUT_RING (chan, 0x82030400);
OUT_RING (chan, 0x82040404);
OUT_RING (chan, 0xf0400201);
OUT_RING (chan, 0x0000c784);
- OUT_RING (chan, 0xc0160009);
- OUT_RING (chan, 0x0bec890f);
- OUT_RING (chan, 0xb0000411);
- OUT_RING (chan, 0x00010780);
- OUT_RING (chan, 0xc0070009);
- OUT_RING (chan, 0x0400116b);
- OUT_RING (chan, 0xc02d0201);
- OUT_RING (chan, 0x03fcc433);
- OUT_RING (chan, 0xc0370205);
- OUT_RING (chan, 0x0bf501a3);
- OUT_RING (chan, 0xb0000001);
- OUT_RING (chan, 0x0000c780);
- OUT_RING (chan, 0xb0000205);
- OUT_RING (chan, 0x00010780);
- OUT_RING (chan, 0xb0000409);
- OUT_RING (chan, 0x00014781);
-
+ OUT_RING (chan, 0xc0840008);
+ OUT_RING (chan, 0xb002060c);
+ OUT_RING (chan, 0xc0850008);
+ OUT_RING (chan, 0xb0020810);
+ OUT_RING (chan, 0xc0860008);
+ OUT_RING (chan, 0xb0020a14);
+ OUT_RING (chan, 0xc0870208);
+ OUT_RING (chan, 0xb0020600);
+ OUT_RING (chan, 0xc0890208);
+ OUT_RING (chan, 0xb0020a08);
+ OUT_RING (chan, 0xc0880205);
+ OUT_RING (chan, 0x00000780);
+ OUT_RING (chan, 0xb0000805);
+ OUT_RING (chan, 0x00004781);
/* HPOS.xy = ($o0, $o1), HPOS.zw = (0.0, 1.0), then map $o2 - $o5 */
BEGIN_RING(chan, tesla, NV50TCL_VP_RESULT_MAP(0), 2);
OUT_RING (chan, 0x41400100);
@@ -415,6 +408,9 @@ NVAccelInitNV50TCL(ScrnInfoPtr pScrn)
OUT_RING (chan, 8192 << NV50TCL_SCREEN_SCISSOR_HORIZ_W_SHIFT);
OUT_RING (chan, 8192 << NV50TCL_SCREEN_SCISSOR_VERT_H_SHIFT);
+ BEGIN_RING(chan, tesla, NV50TCL_SET_PROGRAM_CB, 1);
+ OUT_RING (chan, 0x00000031 | (CB_PFP << 12));
+
return TRUE;
}
diff --git a/src/nv50_accel.h b/src/nv50_accel.h
index f5ccd92..9cdbbab 100644
--- a/src/nv50_accel.h
+++ b/src/nv50_accel.h
@@ -2,10 +2,11 @@
#define __NV50_ACCEL_H__
/* "Tesla scratch buffer" offsets */
-#define PVP_OFFSET 0x00000000 /* Vertex program */
-#define PFP_OFFSET 0x00001000 /* Fragment program */
-#define TIC_OFFSET 0x00002000 /* Texture Image Control */
-#define TSC_OFFSET 0x00003000 /* Texture Sampler Control */
+#define PVP_OFFSET 0x00000000 /* Vertex program */
+#define PFP_OFFSET 0x00001000 /* Fragment program */
+#define TIC_OFFSET 0x00002000 /* Texture Image Control */
+#define TSC_OFFSET 0x00003000 /* Texture Sampler Control */
+#define PFP_DATA 0x00004000 /* FP constbuf */
/* Fragment programs */
#define PFP_S 0x0000 /* (src) */
@@ -19,6 +20,7 @@
/* Constant buffer assignments */
#define CB_TSC 0
#define CB_TIC 1
+#define CB_PFP 2
static __inline__ void
VTX1s(NVPtr pNv, float sx, float sy, unsigned dx, unsigned dy)
diff --git a/src/nv50_xv.c b/src/nv50_xv.c
index e02f86d..1538cdc 100644
--- a/src/nv50_xv.c
+++ b/src/nv50_xv.c
@@ -37,6 +37,8 @@
#include "nv50_texture.h"
extern Atom xvSyncToVBlank, xvSetDefaults;
+extern Atom xvBrightness, xvContrast, xvHue, xvSaturation;
+extern Atom xvITURBT709;
static Bool
nv50_xv_check_image_put(PixmapPtr ppix)
@@ -349,6 +351,97 @@ nv50_xv_video_stop(ScrnInfoPtr pScrn, pointer data, Bool exit)
{
}
+/* Reference color space transform data */
+struct REF_TRANSFORM {
+ float RefLuma;
+ float RefRCb;
+ float RefRCr;
+ float RefGCb;
+ float RefGCr;
+ float RefBCb;
+ float RefBCr;
+} trans[] = {
+ { 1.1643, 0.0, 1.5960, -0.3918, -0.8129, 2.0172, 0.0 }, /* BT.601 */
+ { 1.1643, 0.0, 1.7927, -0.2132, -0.5329, 2.1124, 0.0 } /* BT.709 */
+};
+
+#define RTFSaturation(a) (1.0 + ((a)*1.0)/1000.0)
+#define RTFBrightness(a) (((a)*1.0)/2000.0)
+#define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0)
+#define RTFHue(a) (((a)*3.1416)/1000.0)
+
+void
+nv50_xv_csc_update(ScrnInfoPtr pScrn, NVPortPrivPtr pPriv)
+{
+ NVPtr pNv = NVPTR(pScrn);
+ struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_grobj *tesla = pNv->Nv3D;
+ const float Loff = -0.0627;
+ const float Coff = -0.502;
+ float yco, off[3], uco[3], vco[3];
+ float uvcosf, uvsinf;
+ float bright, cont;
+ int ref = pPriv->iturbt_709;
+
+ cont = RTFContrast(pPriv->contrast);
+ bright = RTFBrightness(pPriv->brightness);
+ uvcosf = RTFSaturation(pPriv->saturation) * cos(RTFHue(pPriv->hue));
+ uvsinf = RTFSaturation(pPriv->saturation) * sin(RTFHue(pPriv->hue));
+
+ yco = trans[ref].RefLuma * cont;
+ uco[0] = -trans[ref].RefRCr * uvsinf;
+ uco[1] = trans[ref].RefGCb * uvcosf - trans[ref].RefGCr * uvsinf;
+ uco[2] = trans[ref].RefBCb * uvcosf;
+ vco[0] = trans[ref].RefRCr * uvcosf;
+ vco[1] = trans[ref].RefGCb * uvsinf + trans[ref].RefGCr * uvcosf;
+ vco[2] = trans[ref].RefBCb * uvsinf;
+ off[0] = Loff * yco + Coff * (uco[0] + vco[0]) + bright;
+ off[1] = Loff * yco + Coff * (uco[1] + vco[1]) + bright;
+ off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright;
+
+ if (MARK_RING(chan, 64, 2))
+ return;
+
+ BEGIN_RING(chan, tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
+ if (OUT_RELOCh(chan, pNv->tesla_scratch, PFP_DATA,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR) ||
+ OUT_RELOCl(chan, pNv->tesla_scratch, PFP_DATA,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR)) {
+ MARK_UNDO(chan);
+ return;
+ }
+ OUT_RING (chan, (CB_PFP << NV50TCL_CB_DEF_SET_BUFFER_SHIFT) | 0x4000);
+ BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
+ OUT_RING (chan, CB_PFP);
+ BEGIN_RING_NI(chan, tesla, NV50TCL_CB_DATA(0), 10);
+ OUT_RINGf (chan, yco);
+ OUT_RINGf (chan, off[0]);
+ OUT_RINGf (chan, off[1]);
+ OUT_RINGf (chan, off[2]);
+ OUT_RINGf (chan, uco[0]);
+ OUT_RINGf (chan, uco[1]);
+ OUT_RINGf (chan, uco[2]);
+ OUT_RINGf (chan, vco[0]);
+ OUT_RINGf (chan, vco[1]);
+ OUT_RINGf (chan, vco[2]);
+}
+
+void
+nv50_xv_set_port_defaults(ScrnInfoPtr pScrn, NVPortPrivPtr pPriv)
+{
+ pPriv->videoStatus = 0;
+ pPriv->grabbedByV4L = FALSE;
+ pPriv->blitter = FALSE;
+ pPriv->texture = TRUE;
+ pPriv->doubleBuffer = FALSE;
+ pPriv->SyncToVBlank = TRUE;
+ pPriv->brightness = 0;
+ pPriv->contrast = 0;
+ pPriv->saturation = 0;
+ pPriv->hue = 0;
+ pPriv->iturbt_709 = 0;
+}
+
int
nv50_xv_port_attribute_set(ScrnInfoPtr pScrn, Atom attribute,
INT32 value, pointer data)
@@ -360,11 +453,37 @@ nv50_xv_port_attribute_set(ScrnInfoPtr pScrn, Atom attribute,
return BadValue;
pPriv->SyncToVBlank = value;
} else
+ if (attribute == xvBrightness) {
+ if (value < -1000 || value > 1000)
+ return BadValue;
+ pPriv->brightness = value;
+ } else
+ if (attribute == xvContrast) {
+ if (value < -1000 || value > 1000)
+ return BadValue;
+ pPriv->contrast = value;
+ } else
+ if (attribute == xvSaturation) {
+ if (value < -1000 || value > 1000)
+ return BadValue;
+ pPriv->saturation = value;
+ } else
+ if (attribute == xvHue) {
+ if (value < -1000 || value > 1000)
+ return BadValue;
+ pPriv->hue = value;
+ } else
+ if (attribute == xvITURBT709) {
+ if (value < 0 || value > 1)
+ return BadValue;
+ pPriv->iturbt_709 = value;
+ } else
if (attribute == xvSetDefaults) {
- pPriv->SyncToVBlank = true;
+ nv50_xv_set_port_defaults(pScrn, pPriv);
} else
return BadMatch;
+ nv50_xv_csc_update(pScrn, pPriv);
return Success;
}
@@ -377,6 +496,21 @@ nv50_xv_port_attribute_get(ScrnInfoPtr pScrn, Atom attribute,
if (attribute == xvSyncToVBlank)
*value = (pPriv->SyncToVBlank) ? 1 : 0;
else
+ if (attribute == xvBrightness)
+ *value = pPriv->brightness;
+ else
+ if (attribute == xvContrast)
+ *value = pPriv->contrast;
+ else
+ if (attribute == xvSaturation)
+ *value = pPriv->saturation;
+ else
+ if (attribute == xvHue)
+ *value = pPriv->hue;
+ else
+ if (attribute == xvITURBT709)
+ *value = pPriv->iturbt_709;
+ else
return BadMatch;
return Success;
diff --git a/src/nv_driver.c b/src/nv_driver.c
index b7edf53..91b2be8 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -1212,7 +1212,6 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
drmmode_screen_init(pScreen);
-
return TRUE;
}
diff --git a/src/nv_proto.h b/src/nv_proto.h
index 61a7b5b..5821444 100644
--- a/src/nv_proto.h
+++ b/src/nv_proto.h
@@ -183,6 +183,8 @@ int nv50_xv_image_put(ScrnInfoPtr, struct nouveau_bo *, int, int, int, int,
void nv50_xv_video_stop(ScrnInfoPtr, pointer, Bool);
int nv50_xv_port_attribute_set(ScrnInfoPtr, Atom, INT32, pointer);
int nv50_xv_port_attribute_get(ScrnInfoPtr, Atom, INT32 *, pointer);
+void nv50_xv_set_port_defaults(ScrnInfoPtr, NVPortPrivPtr);
+void nv50_xv_csc_update(ScrnInfoPtr, NVPortPrivPtr);
/* To support EXA 2.0, 2.1 has this in the header */
#ifndef exaMoveInPixmap