summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/xorg/xorg_xv.c
diff options
context:
space:
mode:
authorZack Rusin <zackr@vmware.com>2009-09-30 21:22:48 -0400
committerZack Rusin <zackr@vmware.com>2009-10-11 20:02:47 -0400
commit4969d014e5d55985119874c8db7cb98154185802 (patch)
tree04cd537863c4c9c3ccbf5364c15141315eadaa5c /src/gallium/state_trackers/xorg/xorg_xv.c
parentf096cc7dc1cdae1698eb7a340cd8c7f5ea0b1166 (diff)
st/xorg: implement basics of xv
Diffstat (limited to 'src/gallium/state_trackers/xorg/xorg_xv.c')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_xv.c65
1 files changed, 61 insertions, 4 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index 88955d47fd..27d52700ec 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -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;
}