summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vdpau
diff options
context:
space:
mode:
authorThomas Balling Sørensen <[email protected]>2010-07-14 00:34:56 +0200
committerThomas Balling Sørensen <tball@tball-laptop.(none)>2010-07-14 00:36:17 +0200
commit3299997bcc5a672617095adb560b3834dced39a6 (patch)
tree70f63a9f2049636fa3b249ce522c779173e66a13 /src/gallium/state_trackers/vdpau
parent15bc635499589dc3490e5bdc198dfd376ce6fb1f (diff)
vdpau changes
Diffstat (limited to 'src/gallium/state_trackers/vdpau')
-rw-r--r--src/gallium/state_trackers/vdpau/Makefile9
-rw-r--r--src/gallium/state_trackers/vdpau/device.c8
-rw-r--r--src/gallium/state_trackers/vdpau/ftab.c2
-rw-r--r--src/gallium/state_trackers/vdpau/query.c57
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h107
5 files changed, 175 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile
index 346cce9d43b..53378a9c1ff 100644
--- a/src/gallium/state_trackers/vdpau/Makefile
+++ b/src/gallium/state_trackers/vdpau/Makefile
@@ -3,6 +3,10 @@ include $(TOP)/configs/current
LIBNAME = vdpautracker
+VDPAU_MAJOR = 1
+VDPAU_MINOR = 0
+LIBRARY_DEFINES = -DVER_MAJOR=$(VDPAU_MAJOR) -DVER_MINOR=$(VDPAU_MINOR) $(STATE_TRACKER_DEFINES)
+
LIBRARY_INCLUDES = \
$(shell pkg-config --cflags-only-I vdpau) \
-I$(TOP)/src/gallium/winsys/g3dvl
@@ -10,6 +14,9 @@ LIBRARY_INCLUDES = \
C_SOURCES = htab.c \
ftab.c \
device.c \
- query.c
+ query.c \
+ surface.c
+
include ../../Makefile.template
+
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index 83fcaff0282..ba91e16a43f 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -37,7 +37,8 @@ PUBLIC VdpStatus
vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address)
{
VdpStatus ret;
- vlVdpDevice *dev;
+ vlVdpDevice *dev = NULL;
+ struct vl_screen *vlscreen = NULL;
if (!(display && device && get_proc_address))
return VDP_STATUS_INVALID_POINTER;
@@ -47,11 +48,14 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe
goto no_htab;
}
- dev = CALLOC(1, sizeof(vlVdpDevice));
+ dev = CALLOC(0, sizeof(vlVdpDevice));
if (!dev) {
ret = VDP_STATUS_RESOURCES;
goto no_dev;
}
+ dev->display = display;
+ dev->screen = screen;
+
*device = vlAddDataHTAB(dev);
if (*device == 0) {
diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c
index a8a29857df7..7e476e5ee28 100644
--- a/src/gallium/state_trackers/vdpau/ftab.c
+++ b/src/gallium/state_trackers/vdpau/ftab.c
@@ -39,7 +39,7 @@ static void* ftab[67] =
0, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */
&vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */
&vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */
- 0, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */
+ &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */
0, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */
0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */
0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */
diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c
index 57bd7fb7526..71793cc8ad5 100644
--- a/src/gallium/state_trackers/vdpau/query.c
+++ b/src/gallium/state_trackers/vdpau/query.c
@@ -26,6 +26,11 @@
**************************************************************************/
#include "vdpau_private.h"
+#include <vl_winsys.h>
+#include <assert.h>
+#include <pipe/p_screen.h>
+#include <math.h>
+
VdpStatus
vlVdpGetApiVersion(uint32_t *api_version)
@@ -43,7 +48,7 @@ vlVdpGetInformationString(char const **information_string)
if (!information_string)
return VDP_STATUS_INVALID_POINTER;
- *information_string = "VDPAU-G3DVL";
+ *information_string = INFORMATION_STRING;
return VDP_STATUS_OK;
}
@@ -51,10 +56,40 @@ VdpStatus
vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
{
+ uint32_t max_2d_texture_level;
+ VdpStatus ret;
+
if (!(is_supported && max_width && max_height))
return VDP_STATUS_INVALID_POINTER;
- return VDP_STATUS_NO_IMPLEMENTATION;
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ if (!dev->vlscreen)
+ dev->vlscreen = vl_screen_create(dev->display, dev->screen);
+ if (!dev->vlscreen)
+ return VDP_STATUS_RESOURCES;
+
+ /* XXX: Current limits */
+ *is_supported = true;
+ if (surface_chroma_type != VDP_CHROMA_TYPE_420) {
+ *is_supported = false;
+ goto no_sup;
+ }
+
+ max_2d_texture_level = dev->vlscreen->pscreen->get_param( dev->vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS );
+ if (!max_2d_texture_level) {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_sup;
+ }
+
+ /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */
+ *max_width = *max_height = pow(2,max_2d_texture_level-1);
+
+ return VDP_STATUS_OK;
+ no_sup:
+ return ret;
}
VdpStatus
@@ -65,7 +100,23 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp
if (!is_supported)
return VDP_STATUS_INVALID_POINTER;
- return VDP_STATUS_NO_IMPLEMENTATION;
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ if (!dev->vlscreen)
+ dev->vlscreen = vl_screen_create(dev->display, dev->screen);
+ if (!dev->vlscreen)
+ return VDP_STATUS_RESOURCES;
+
+ if (bits_ycbcr_format != VDP_YCBCR_FORMAT_Y8U8V8A8)
+ *is_supported = dev->vlscreen->pscreen->is_format_supported(dev->vlscreen->pscreen,
+ FormatToPipe(bits_ycbcr_format),
+ PIPE_TEXTURE_2D,
+ PIPE_BIND_RENDER_TARGET,
+ PIPE_TEXTURE_GEOM_NON_SQUARE );
+
+ return VDP_STATUS_OK;
}
VdpStatus
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 8f54ae657ce..27793892185 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -25,14 +25,112 @@
*
**************************************************************************/
+#ifndef VDPAU_PRIVATE_H
+#define VDPAU_PRIVATE_H
+
+
#include <vdpau/vdpau.h>
#include <pipe/p_compiler.h>
+#include <vl_winsys.h>
+#include <assert.h>
+
+#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
+#define QUOTEME(x) #x
+#define TOSTRING(x) QUOTEME(x)
+#define INFORMATION_STRING TOSTRING(INFORMATION)
+#define VL_HANDLES
+
+static enum pipe_video_chroma_format TypeToPipe(VdpChromaType vdpau_type)
+{
+ switch (vdpau_type) {
+ case VDP_CHROMA_TYPE_420:
+ return PIPE_VIDEO_CHROMA_FORMAT_420;
+ case VDP_CHROMA_TYPE_422:
+ return PIPE_VIDEO_CHROMA_FORMAT_422;
+ case VDP_CHROMA_TYPE_444:
+ return PIPE_VIDEO_CHROMA_FORMAT_444;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static VdpChromaType PipeToType(enum pipe_video_chroma_format pipe_type)
+{
+ switch (pipe_type) {
+ case PIPE_VIDEO_CHROMA_FORMAT_420:
+ return VDP_CHROMA_TYPE_420;
+ case PIPE_VIDEO_CHROMA_FORMAT_422:
+ return VDP_CHROMA_TYPE_422;
+ case PIPE_VIDEO_CHROMA_FORMAT_444:
+ return VDP_CHROMA_TYPE_444;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static enum pipe_format FormatToPipe(VdpYCbCrFormat vdpau_format)
+{
+ switch (vdpau_format) {
+ case VDP_YCBCR_FORMAT_NV12:
+ return PIPE_FORMAT_NV12;
+ case VDP_YCBCR_FORMAT_YV12:
+ return PIPE_FORMAT_YV12;
+ case VDP_YCBCR_FORMAT_UYVY:
+ return PIPE_FORMAT_UYVY;
+ case VDP_YCBCR_FORMAT_YUYV:
+ return PIPE_FORMAT_YUYV;
+ case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */
+ return 0;
+ case VDP_YCBCR_FORMAT_V8U8Y8A8:
+ return PIPE_FORMAT_VUYA;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static VdpYCbCrFormat PipeToFormat(enum pipe_format p_format)
+{
+ switch (p_format) {
+ case PIPE_FORMAT_NV12:
+ return VDP_YCBCR_FORMAT_NV12;
+ case PIPE_FORMAT_YV12:
+ return VDP_YCBCR_FORMAT_YV12;
+ case PIPE_FORMAT_UYVY:
+ return VDP_YCBCR_FORMAT_UYVY;
+ case PIPE_FORMAT_YUYV:
+ return VDP_YCBCR_FORMAT_YUYV;
+ //case PIPE_FORMAT_YUVA:
+ // return VDP_YCBCR_FORMAT_Y8U8V8A8;
+ case PIPE_FORMAT_VUYA:
+ return VDP_YCBCR_FORMAT_V8U8Y8A8;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
typedef struct
{
- int dummy;
+ void *display;
+ int screen;
+ struct vl_screen *vlscreen;
+ struct vl_context *vctx;
} vlVdpDevice;
+typedef struct
+{
+ struct vl_screen *vlscreen;
+ struct pipe_surface *psurface;
+ enum pipe_video_chroma_format chroma_format;
+} vlVdpSurface;
+
typedef uint32_t vlHandle;
boolean vlCreateHTAB(void);
@@ -57,3 +155,10 @@ VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
+VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
+VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
+VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
+VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
+VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
+
+#endif // VDPAU_PRIVATE_H \ No newline at end of file