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 <daniel.vetter@ffwll.ch>
main
Eric Anholt 2012-01-03 13:05:57 -08:00
parent a9dd34a7ee
commit ea33a231d5
2 changed files with 14 additions and 2 deletions

View File

@ -34,6 +34,7 @@
#ifndef INTEL_BUFMGR_H #ifndef INTEL_BUFMGR_H
#define INTEL_BUFMGR_H #define INTEL_BUFMGR_H
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
struct drm_clip_rect; struct drm_clip_rect;
@ -199,6 +200,7 @@ void drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
int dump_past_end); int dump_past_end);
void drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx, void drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
uint32_t head, uint32_t tail); uint32_t head, uint32_t tail);
void drm_intel_decode_set_output_file(struct drm_intel_decode *ctx, FILE *out);
void drm_intel_decode(struct drm_intel_decode *ctx); void drm_intel_decode(struct drm_intel_decode *ctx);

View File

@ -33,6 +33,9 @@
/* Struct for tracking drm_intel_decode state. */ /* Struct for tracking drm_intel_decode state. */
struct drm_intel_decode { struct drm_intel_decode {
/** stdio file where the output should land. Defaults to stdout. */
FILE *out;
/** PCI device ID. */ /** PCI device ID. */
uint32_t devid; uint32_t devid;
@ -3558,6 +3561,7 @@ drm_intel_decode_context_alloc(uint32_t devid)
return NULL; return NULL;
ctx->devid = devid; ctx->devid = devid;
ctx->out = stdout;
return ctx; return ctx;
} }
@ -3592,6 +3596,13 @@ drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
ctx->tail = tail; 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. * 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; devid = ctx->devid;
head_offset = ctx->head; head_offset = ctx->head;
tail_offset = ctx->tail; tail_offset = ctx->tail;
out = ctx->out;
saved_s2_set = 0; saved_s2_set = 0;
saved_s4_set = 1; saved_s4_set = 1;
out = stdout;
while (index < count) { while (index < count) {
switch ((data[index] & 0xe0000000) >> 29) { switch ((data[index] & 0xe0000000) >> 29) {
case 0x0: case 0x0: