From ea33a231d530540ddcb9e0bac08ef15f625f744a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 3 Jan 2012 13:05:57 -0800 Subject: intel: Add an interface for setting the output file for decode. Consumers often want to choose stdout vs stderr, and for testing I want to output to an open_memstream file. Reviewed-by: Daniel Vetter --- intel/intel_decode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'intel/intel_decode.c') diff --git a/intel/intel_decode.c b/intel/intel_decode.c index e80e8401..81ef712e 100644 --- a/intel/intel_decode.c +++ b/intel/intel_decode.c @@ -33,6 +33,9 @@ /* Struct for tracking drm_intel_decode state. */ struct drm_intel_decode { + /** stdio file where the output should land. Defaults to stdout. */ + FILE *out; + /** PCI device ID. */ uint32_t devid; @@ -3558,6 +3561,7 @@ drm_intel_decode_context_alloc(uint32_t devid) return NULL; ctx->devid = devid; + ctx->out = stdout; return ctx; } @@ -3592,6 +3596,13 @@ drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx, ctx->tail = tail; } +void +drm_intel_decode_set_output_file(struct drm_intel_decode *ctx, + FILE *out) +{ + ctx->out = out; +} + /** * Decodes an i830-i915 batch buffer, writing the output to stdout. * @@ -3618,12 +3629,11 @@ drm_intel_decode(struct drm_intel_decode *ctx) devid = ctx->devid; head_offset = ctx->head; tail_offset = ctx->tail; + out = ctx->out; saved_s2_set = 0; saved_s4_set = 1; - out = stdout; - while (index < count) { switch ((data[index] & 0xe0000000) >> 29) { case 0x0: -- cgit v1.2.3