st/xorg: implement basics of xv
authorZack Rusin <zackr@vmware.com>
Thu, 1 Oct 2009 01:22:48 +0000 (21:22 -0400)
committerZack Rusin <zackr@vmware.com>
Mon, 12 Oct 2009 00:02:47 +0000 (20:02 -0400)
src/gallium/state_trackers/xorg/Makefile
src/gallium/state_trackers/xorg/xorg_crtc.c
src/gallium/state_trackers/xorg/xorg_driver.c
src/gallium/state_trackers/xorg/xorg_xv.c

index 27a1990724d4cfa220091a2afa3a56608ebfefe7..030bac5fff2f74fbad933d822c48fb99c9e15d29 100644 (file)
@@ -5,6 +5,7 @@ LIBNAME = xorgtracker
 
 LIBRARY_INCLUDES = \
        -DHAVE_CONFIG_H \
+        -DHAVE_XEXTPROTO_71=1 \
        $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
        -I$(TOP)/src/gallium/include \
        -I$(TOP)/src/gallium/auxiliary \
index 67fe29a69dab535eed641bdf6fc9d14d5a2e492e..95973586da88aa7f6610c0a01702c51a8ff4a020 100644 (file)
 #include "xf86Modes.h"
 
 #ifdef HAVE_XEXTPROTO_71
-#include <X11/extensions/dpmsconst.h>
+#include "X11/extensions/dpmsconst.h"
 #else
 #define DPMS_SERVER
-#include <X11/extensions/dpms.h>
+#include "X11/extensions/dpmsconst.h"
 #endif
 
 #include "pipe/p_inlines.h"
index 4bc87aa613d083ab3bc454666fc627a3cb26544f..ab6c3d755807bce9acc2d6599f3639900b3618f5 100644 (file)
@@ -560,6 +560,8 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     ms->exa = xorg_exa_init(pScrn);
     ms->debug_fallback = debug_get_bool_option("XORG_DEBUG_FALLBACK", TRUE);
 
+    xorg_init_video(pScreen);
+
     miInitializeBackingStore(pScreen);
     xf86SetBackingStore(pScreen);
     xf86SetSilkenMouse(pScreen);
index 88955d47fd39542969cf9825ad0774ce140c72b9..27d52700ec7fda822600cbbc718f6af5129b5aba 100644 (file)
@@ -40,26 +40,54 @@ static XF86ImageRec Images[NUM_IMAGES] = {
 
 struct xorg_xv_port_priv {
    RegionRec clip;
+
+   int brightness;
+   int contrast;
 };
 
 
 static void
 stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
 {
+   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
+
+   REGION_EMPTY(pScrn->pScreen, &priv->clip);
 }
 
 static int
 set_port_attribute(ScrnInfoPtr pScrn,
                    Atom attribute, INT32 value, pointer data)
 {
-   return 0;
+   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
+
+   if (attribute == xvBrightness) {
+      if ((value < -128) || (value > 127))
+         return BadValue;
+      priv->brightness = value;
+   } else if (attribute == xvContrast) {
+      if ((value < 0) || (value > 255))
+         return BadValue;
+      priv->contrast = value;
+   } else
+      return BadMatch;
+
+   return Success;
 }
 
 static int
 get_port_attribute(ScrnInfoPtr pScrn,
                    Atom attribute, INT32 * value, pointer data)
 {
-   return 0;
+   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
+
+   if (attribute == xvBrightness)
+      *value = priv->brightness;
+   else if (attribute == xvContrast)
+      *value = priv->contrast;
+   else
+      return BadMatch;
+
+   return Success;
 }
 
 static void
@@ -69,6 +97,13 @@ query_best_size(ScrnInfoPtr pScrn,
                 short drw_w, short drw_h,
                 unsigned int *p_w, unsigned int *p_h, pointer data)
 {
+   if (vid_w > (drw_w << 1))
+      drw_w = vid_w >> 1;
+   if (vid_h > (drw_h << 1))
+      drw_h = vid_h >> 1;
+
+   *p_w = drw_w;
+   *p_h = drw_h;
 }
 
 static int
@@ -91,7 +126,29 @@ query_image_attributes(ScrnInfoPtr pScrn,
                        unsigned short *w, unsigned short *h,
                        int *pitches, int *offsets)
 {
-   return 0;
+   int size;
+
+   if (*w > IMAGE_MAX_WIDTH)
+      *w = IMAGE_MAX_WIDTH;
+   if (*h > IMAGE_MAX_HEIGHT)
+      *h = IMAGE_MAX_HEIGHT;
+
+   *w = (*w + 1) & ~1;
+   if (offsets)
+      offsets[0] = 0;
+
+   switch (id) {
+   case FOURCC_UYVY:
+   case FOURCC_YUY2:
+   default:
+      size = *w << 1;
+      if (pitches)
+        pitches[0] = size;
+      size *= *h;
+      break;
+   }
+
+   return size;
 }
 
 static struct xorg_xv_port_priv *
@@ -106,7 +163,7 @@ port_priv_create(ScreenPtr pScreen)
    if (!priv)
       return NULL;
 
-    REGION_NULL(pScreen, &priv->clip);
+   REGION_NULL(pScreen, &priv->clip);
 
    return priv;
 }