hardware/intel/common/libva
修订版 | 69d3a3c349b0b8c4aad4f8bb6454b3a8033c25de (tree) |
---|---|
时间 | 2009-06-20 03:20:52 |
作者 | Austin Yuan <shengquan.yuan@inte...> |
Commiter | Austin Yuan |
Proposed new vaCreateSurfaceFromV4L2Buffer to replace origin vaCreateSurfaceFromMrstV4L2 buffer to make it more generic
Signed-off-by: Austin Yuan <shengquan.yuan@intel.com>
@@ -1154,11 +1154,17 @@ VAStatus dummy_SetDisplayAttributes ( | ||
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | |
1157 | -VAStatus dummy_DbgCopySurfaceToBuffer( | |
1157 | +VAStatus dummy_CopySurfaceToBuffer( | |
1158 | 1158 | VADriverContextP ctx, |
1159 | 1159 | VASurfaceID surface, |
1160 | - void **buffer, /* out */ | |
1161 | - unsigned int *stride /* out */ | |
1160 | + unsigned int *fourcc, /* following are output argument */ | |
1161 | + unsigned int *luma_stride, | |
1162 | + unsigned int *chroma_u_stride, | |
1163 | + unsigned int *chroma_v_stride, | |
1164 | + unsigned int *luma_offset, | |
1165 | + unsigned int *chroma_u_offset, | |
1166 | + unsigned int *chroma_v_offset, | |
1167 | + void **buffer | |
1162 | 1168 | ) |
1163 | 1169 | { |
1164 | 1170 | /* TODO */ |
@@ -1266,7 +1272,7 @@ VAStatus __vaDriverInit_0_29( VADriverContextP ctx ) | ||
1266 | 1272 | ctx->vtable.vaGetDisplayAttributes = dummy_GetDisplayAttributes; |
1267 | 1273 | ctx->vtable.vaSetDisplayAttributes = dummy_SetDisplayAttributes; |
1268 | 1274 | |
1269 | - ctx->vtable.vaDbgCopySurfaceToBuffer = dummy_DbgCopySurfaceToBuffer; | |
1275 | + ctx->vtable.vaCopySurfaceToBuffer = dummy_CopySurfaceToBuffer; | |
1270 | 1276 | |
1271 | 1277 | driver_data = (struct dummy_driver_data *) malloc( sizeof(*driver_data) ); |
1272 | 1278 | ctx->pDriverData = (void *) driver_data; |
@@ -34,6 +34,8 @@ | ||
34 | 34 | #include <dlfcn.h> |
35 | 35 | #include <unistd.h> |
36 | 36 | |
37 | +#include <linux/videodev2.h> | |
38 | + | |
37 | 39 | #define VA_STR_VERSION VA_BUILD_DATE VA_BUILD_GIT |
38 | 40 | |
39 | 41 | #define VA_MAJOR_VERSION 0 |
@@ -1222,7 +1224,14 @@ VAStatus vaSetDisplayAttributes ( | ||
1222 | 1224 | return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes ); |
1223 | 1225 | } |
1224 | 1226 | |
1225 | - | |
1227 | +/* Wrap a CI (camera imaging) frame as a VA surface to share captured video between camear | |
1228 | + * and VA encode. With frame_id, VA driver need to call CI interfaces to get the information | |
1229 | + * of the frame, and to determine if the frame can be wrapped as a VA surface | |
1230 | + * | |
1231 | + * Application should make sure the frame is idle before the frame is passed into VA stack | |
1232 | + * and also a vaSyncSurface should be called before application tries to access the frame | |
1233 | + * from CI stack | |
1234 | + */ | |
1226 | 1235 | VAStatus vaCreateSurfaceFromCIFrame ( |
1227 | 1236 | VADisplay dpy, |
1228 | 1237 | unsigned long frame_id, |
@@ -1242,33 +1251,42 @@ VAStatus vaCreateSurfaceFromCIFrame ( | ||
1242 | 1251 | } |
1243 | 1252 | |
1244 | 1253 | |
1245 | -VAStatus vaCreateSurfaceFromMrstV4L2Buf( | |
1254 | +/* Wrap a V4L2 buffer as a VA surface, so that V4L2 camera, VA encode | |
1255 | + * can share the data without copy | |
1256 | + * The VA driver should query the camera device from v4l2_fd to see | |
1257 | + * if camera device memory/buffer can be wrapped into a VA surface | |
1258 | + * Buffer information is passed in by v4l2_fmt and v4l2_buf structure, | |
1259 | + * VA driver also needs do further check if the buffer can meet encode | |
1260 | + * hardware requirement, such as dimension, fourcc, stride, etc | |
1261 | + * | |
1262 | + * Application should make sure the buffer is idle before the frame into VA stack | |
1263 | + * and also a vaSyncSurface should be called before application tries to access the frame | |
1264 | + * from V4L2 stack | |
1265 | + */ | |
1266 | +VAStatus vaCreateSurfaceFromV4L2Buf( | |
1246 | 1267 | VADisplay dpy, |
1247 | - unsigned int width, | |
1248 | - unsigned int height, | |
1249 | - unsigned int size, | |
1250 | - unsigned int fourcc, | |
1251 | - unsigned int luma_stride, | |
1252 | - unsigned int chroma_u_stride, | |
1253 | - unsigned int chroma_v_stride, | |
1254 | - unsigned int luma_offset, | |
1255 | - unsigned int chroma_u_offset, | |
1256 | - unsigned int chroma_v_offset, | |
1257 | - VASurfaceID *surface /* out */ | |
1268 | + int v4l2_fd, /* file descriptor of V4L2 device */ | |
1269 | + struct v4l2_format *v4l2_fmt, /* format of V4L2 */ | |
1270 | + struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */ | |
1271 | + VASurfaceID *surface /* out */ | |
1258 | 1272 | ) |
1259 | 1273 | { |
1260 | 1274 | VADriverContextP ctx; |
1261 | 1275 | CHECK_DISPLAY(dpy); |
1262 | 1276 | ctx = CTX(dpy); |
1263 | 1277 | |
1264 | - TRACE(vtable.vaCreateSurfaceFromMrstV4L2Buf); | |
1278 | + TRACE(vtable.vaCreateSurfaceFromV4L2Buf); | |
1265 | 1279 | |
1266 | - if (ctx->vtable.vaCreateSurfaceFromMrstV4L2Buf) | |
1267 | - return ctx->vtable.vaCreateSurfaceFromMrstV4L2Buf( ctx, width, height, size, fourcc, luma_stride, chroma_u_stride, chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset, surface ); | |
1280 | + if (ctx->vtable.vaCreateSurfaceFromV4L2Buf) | |
1281 | + return ctx->vtable.vaCreateSurfaceFromV4L2Buf( ctx, v4l2_fd, v4l2_fmt, v4l2_buf, surface ); | |
1268 | 1282 | else |
1269 | 1283 | return VA_STATUS_ERROR_UNKNOWN; |
1270 | 1284 | } |
1271 | 1285 | |
1286 | +/* It is a debug interface, and isn't exported in core VAAPI | |
1287 | + * It is used to dump surface data into system memory | |
1288 | + * Application should explicitly call free to release the buffer memory | |
1289 | + */ | |
1272 | 1290 | |
1273 | 1291 | VAStatus vaCopySurfaceToBuffer(VADisplay dpy, |
1274 | 1292 | VASurfaceID surface, |
@@ -38,6 +38,7 @@ | ||
38 | 38 | #endif |
39 | 39 | |
40 | 40 | #include <stdlib.h> |
41 | +#include <linux/videodev2.h> | |
41 | 42 | |
42 | 43 | |
43 | 44 | typedef struct VADriverContext *VADriverContextP; |
@@ -382,19 +383,12 @@ struct VADriverVTable | ||
382 | 383 | ); |
383 | 384 | |
384 | 385 | |
385 | - VAStatus (*vaCreateSurfaceFromMrstV4L2Buf) ( | |
386 | - VADriverContextP ctx, | |
387 | - unsigned int width, | |
388 | - unsigned int height, | |
389 | - unsigned int size, | |
390 | - unsigned int fourcc, | |
391 | - unsigned int luma_stride, | |
392 | - unsigned int chroma_u_stride, | |
393 | - unsigned int chroma_v_stride, | |
394 | - unsigned int luma_offset, | |
395 | - unsigned int chroma_u_offset, | |
396 | - unsigned int chroma_v_offset, | |
397 | - VASurfaceID *surface /* out */ | |
386 | + VAStatus (*vaCreateSurfaceFromV4L2Buf) ( | |
387 | + VADriverContextP ctx, | |
388 | + int v4l2_fd, /* file descriptor of V4L2 device */ | |
389 | + struct v4l2_format *v4l2_fmt, /* format of V4L2 */ | |
390 | + struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */ | |
391 | + VASurfaceID *surface /* out */ | |
398 | 392 | ); |
399 | 393 | |
400 | 394 | VAStatus (*vaCopySurfaceToBuffer) ( |