hardware/intel/common/libva
Révision | 9c512edec4e4010a14981b497adb9f86b4a368ed (tree) |
---|---|
l'heure | 2017-11-22 14:38:52 |
Auteur | Mark Thompson <sw@jkqx...> |
Commiter | Xiang, Haihao |
Add message callbacks for drivers to use
This adds a mechanism for drivers to propagate arbitrary log messages
back to the API user. It is intended to be used to replace all use of
logging to stdout/stderr in drivers.
Signed-off-by: Mark Thompson <sw@jkqxz.net>
@@ -261,6 +261,24 @@ void va_infoMessage(VADisplay dpy, const char *msg, ...) | ||
261 | 261 | #endif |
262 | 262 | } |
263 | 263 | |
264 | +static void va_driverErrorCallback(VADriverContextP ctx, | |
265 | + const char *message) | |
266 | +{ | |
267 | + VADisplayContextP dctx = ctx->pDisplayContext; | |
268 | + if (!dctx) | |
269 | + return; | |
270 | + dctx->error_callback(dctx->error_callback_user_context, message); | |
271 | +} | |
272 | + | |
273 | +static void va_driverInfoCallback(VADriverContextP ctx, | |
274 | + const char *message) | |
275 | +{ | |
276 | + VADisplayContextP dctx = ctx->pDisplayContext; | |
277 | + if (!dctx) | |
278 | + return; | |
279 | + dctx->info_callback(dctx->info_callback_user_context, message); | |
280 | +} | |
281 | + | |
264 | 282 | VADisplayContextP va_newDisplayContext(void) |
265 | 283 | { |
266 | 284 | VADisplayContextP dctx = calloc(1, sizeof(*dctx)); |
@@ -282,6 +300,10 @@ VADriverContextP va_newDriverContext(VADisplayContextP dctx) | ||
282 | 300 | return NULL; |
283 | 301 | |
284 | 302 | dctx->pDriverContext = ctx; |
303 | + ctx->pDisplayContext = dctx; | |
304 | + | |
305 | + ctx->error_callback = va_driverErrorCallback; | |
306 | + ctx->info_callback = va_driverInfoCallback; | |
285 | 307 | |
286 | 308 | return ctx; |
287 | 309 | } |
@@ -552,7 +552,48 @@ struct VADriverContext | ||
552 | 552 | |
553 | 553 | char *override_driver_name; |
554 | 554 | |
555 | - unsigned long reserved[41]; /* reserve for future add-ins, decrease the subscript accordingly */ | |
555 | + void *pDisplayContext; | |
556 | + | |
557 | + /** | |
558 | + * Error callback. | |
559 | + * | |
560 | + * This is set by libva when the driver is opened, and will not be | |
561 | + * changed thereafter. The driver can call it with an error message, | |
562 | + * which will be propagated to the API user through their error | |
563 | + * callbacks, or sent to a default output if no callback is available. | |
564 | + * | |
565 | + * It is expected that end users will always be able to see these | |
566 | + * messages, so it should be called only for serious errors. For | |
567 | + * example, hardware problems or fatal configuration errors. | |
568 | + * | |
569 | + * @param pDriverContext Pointer to the driver context structure | |
570 | + * being used by the current driver. | |
571 | + * @param message Message to send to the API user. This must be a | |
572 | + * null-terminated string. | |
573 | + */ | |
574 | + void (*error_callback)(VADriverContextP pDriverContext, | |
575 | + const char *message); | |
576 | + /** | |
577 | + * Info callback. | |
578 | + * | |
579 | + * This has the same behaviour as the error callback, but has its | |
580 | + * own set of callbacks to the API user. | |
581 | + * | |
582 | + * It should be used for informational messages which may be useful | |
583 | + * for an application programmer or for debugging. For example, minor | |
584 | + * configuration errors, or information about the reason when another | |
585 | + * API call generates an error return. It is not expected that end | |
586 | + * users will see these messages. | |
587 | + * | |
588 | + * @param pDriverContext Pointer to the driver context structure | |
589 | + * being used by the current driver. | |
590 | + * @param message Message to send to the API user. This must be a | |
591 | + * null-terminated string. | |
592 | + */ | |
593 | + void (*info_callback)(VADriverContextP pDriverContext, | |
594 | + const char *message); | |
595 | + | |
596 | + unsigned long reserved[38]; /* reserve for future add-ins, decrease the subscript accordingly */ | |
556 | 597 | }; |
557 | 598 | |
558 | 599 | #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ |