From: bsegovia Date: Thu, 28 Jul 2011 06:19:05 +0000 (+0000) Subject: Started to remove genx_driver files X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb7fb2dc18ac367778d850260cc962f1c962adda;p=contrib%2Fbeignet.git Started to remove genx_driver files --- diff --git a/src/cl_context.c b/src/cl_context.c index 08b32fa..06fdd25 100644 --- a/src/cl_context.c +++ b/src/cl_context.c @@ -123,7 +123,7 @@ cl_context_new(void) cl_context ctx = NULL; TRY_ALLOC_NO_ERR (ctx, CALLOC(struct _cl_context)); - TRY_ALLOC_NO_ERR (ctx->intel_drv, cl_genx_driver_new()); + TRY_ALLOC_NO_ERR (ctx->intel_drv, cl_intel_driver_new()); ctx->magic = CL_MAGIC_CONTEXT_HEADER; ctx->ref_n = 1; pthread_mutex_init(&ctx->program_lock, NULL); @@ -155,7 +155,7 @@ cl_context_delete(cl_context ctx) assert(ctx->programs == NULL); assert(ctx->buffers == NULL); assert(ctx->intel_drv); - cl_genx_driver_delete(ctx->intel_drv); + cl_intel_driver_delete(ctx->intel_drv); ctx->magic = CL_MAGIC_DEAD_HEADER; /* For safety */ cl_free(ctx); } diff --git a/src/cl_context.h b/src/cl_context.h index 98fb94c..051a857 100644 --- a/src/cl_context.h +++ b/src/cl_context.h @@ -27,13 +27,13 @@ #include /* DRI device created at create context */ -struct genx_driver; +struct intel_driver; /* Encapsulate the whole device */ struct _cl_context { uint64_t magic; /* To identify it as a context */ volatile int ref_n; /* We reference count this object */ - struct genx_driver *intel_drv; /* Handles the real HW */ + struct intel_driver *intel_drv; /* Handles the real HW */ cl_device_id device; /* All information about the GPU device */ cl_command_queue queues; /* All command queues currently allocated */ cl_program programs; /* All programs currently allocated */ diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 25106ae..b617a4f 100644 --- a/src/cl_device_id.c +++ b/src/cl_device_id.c @@ -69,7 +69,7 @@ LOCAL cl_device_id cl_get_gt_device(void) { cl_device_id ret = NULL; - int device_id = cl_intel_get_device_id(); + const int device_id = cl_intel_get_device_id(); if (device_id == PCI_CHIP_IVYBRIDGE_GT1 || device_id == PCI_CHIP_IVYBRIDGE_M_GT1 || diff --git a/src/cl_genx_driver.h b/src/cl_genx_driver.h index 672f9df..4fa35cb 100644 --- a/src/cl_genx_driver.h +++ b/src/cl_genx_driver.h @@ -17,17 +17,17 @@ * Author: Benjamin Segovia */ -#ifndef __CL_GENX_DRIVER_H__ -#define __CL_GENX_DRIVER_H__ +#ifndef __CL_INTEL_DRIVER_H__ +#define __CL_INTEL_DRIVER_H__ /* They are mostly wrapper around C++ delete / new to avoid c++ in c files */ -struct genx_driver; +struct intel_driver; /* Allocate and initialize the gen driver */ -extern struct genx_driver* cl_genx_driver_new(void); +extern struct intel_driver* cl_intel_driver_new(void); /* Destroy and deallocate the gen driver */ -extern void cl_genx_driver_delete(struct genx_driver*); +extern void cl_intel_driver_delete(struct intel_driver*); -#endif /* __CL_GENX_DRIVER_H__ */ +#endif /* __CL_INTEL_DRIVER_H__ */ diff --git a/src/intel/genx_driver.c b/src/intel/genx_driver.c index 0db2ccb..8f76ede 100644 --- a/src/intel/genx_driver.c +++ b/src/intel/genx_driver.c @@ -102,7 +102,7 @@ genx_driver_terminate(genx_driver_t *genx) genx->dri_ctx = NULL; genx->x11_display = NULL; } - +#if 0 LOCAL int cl_intel_get_device_id(void) { @@ -142,4 +142,5 @@ cl_genx_driver_delete(genx_driver_t *driver) genx_driver_terminate(driver); genx_driver_delete(driver); } +#endif diff --git a/src/intel/genx_driver.h b/src/intel/genx_driver.h index c2ab0c3..88b15ee 100644 --- a/src/intel/genx_driver.h +++ b/src/intel/genx_driver.h @@ -23,9 +23,6 @@ #include "intel_driver.h" #include -struct dri_state; -typedef struct _XDisplay Display; - /* Provides more functionnalitites to setup gen state while using X */ typedef struct genx_driver { diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c index b4e8735..2da8b15 100644 --- a/src/intel/intel_driver.c +++ b/src/intel/intel_driver.c @@ -29,16 +29,9 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include "cl_utils.h" #include "cl_alloc.h" - -#ifdef __cplusplus -} -#endif /* __cplusplus */ +#include "cl_genx_driver.h" #define SET_BLOCKED_SIGSET(DRIVER) do { \ sigset_t bl_mask; \ @@ -123,7 +116,7 @@ intel_driver_init(intel_driver_t *driver, int dev_fd) else FATAL ("Unsupported Gen for emulation"); #else - if (IS_GEN&(driver->device_id)) + if (IS_GEN7(driver->device_id)) driver->gen_ver = 7; else if (IS_GEN6(driver->device_id)) driver->gen_ver = 6; @@ -134,6 +127,49 @@ intel_driver_init(intel_driver_t *driver, int dev_fd) #endif /* EMULATE_GEN */ } +LOCAL void +intel_driver_open(intel_driver_t *intel) +{ + int cardi; + intel->x11_display = XOpenDisplay(":0.0"); + + if(intel->x11_display) { + if((intel->dri_ctx = getDRI2State(intel->x11_display, + DefaultScreen(intel->x11_display), + NULL))) + intel_driver_init_shared(intel, intel->dri_ctx); + else + printf("X server found. dri2 connection failed! \n"); + } else { + printf("Can't find X server!\n"); + } + + if(!intel_driver_is_active(intel)) { + printf("Trying to open directly..."); + char card_name[20]; + for(cardi = 0; cardi < 16; cardi++) { + sprintf(card_name, "/dev/dri/card%d", cardi); + if(intel_driver_init_master(intel, card_name)) { + printf("Success at %s.\n", card_name); + break; + } + } + } + if(!intel_driver_is_active(intel)) { + printf("Device open failed\n"); + exit(-1); + } +} + +LOCAL void +intel_driver_close(intel_driver_t *intel) +{ + if(intel->dri_ctx) dri_state_release(intel->dri_ctx); + if(intel->x11_display) XCloseDisplay(intel->x11_display); + intel->dri_ctx = NULL; + intel->x11_display = NULL; +} + LOCAL int intel_driver_get_param(intel_driver_t *driver, int param, int *value) { @@ -252,3 +288,44 @@ intel_driver_get_buf(intel_driver_t *drv) return drv->bufmgr; } +LOCAL int +cl_intel_get_device_id(void) +{ + intel_driver_t *driver = NULL; + int intel_device_id; + + driver = intel_driver_new(); + assert(driver != NULL); + intel_driver_open(driver); + intel_device_id = driver->device_id; + intel_driver_close(driver); + intel_driver_delete(driver); + + return intel_device_id; +} + +LOCAL void +cl_intel_driver_delete(intel_driver_t *driver) +{ + if (driver == NULL) + return; + intel_driver_close(driver); + intel_driver_terminate(driver); + intel_driver_delete(driver); +} + +LOCAL intel_driver_t* +cl_intel_driver_new(void) +{ + intel_driver_t *driver = NULL; + TRY_ALLOC_NO_ERR (driver, intel_driver_new()); + intel_driver_open(driver); + +exit: + return driver; +error: + cl_intel_driver_delete(driver); + driver = NULL; + goto exit; +} + diff --git a/src/intel/intel_driver.h b/src/intel/intel_driver.h index fab7827..8bea7ad 100644 --- a/src/intel/intel_driver.h +++ b/src/intel/intel_driver.h @@ -49,6 +49,7 @@ #define BR13_8888 (0x3 << 24) struct dri_state; +typedef struct _XDisplay Display; typedef struct intel_driver { @@ -60,6 +61,8 @@ typedef struct intel_driver pthread_mutex_t ctxmutex; int locked; int master; + Display *x11_display; + struct dri_state *dri_ctx; } intel_driver_t; /* create / destroy device */ diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c index 5ac140c..81d5ced 100644 --- a/src/intel/intel_gpgpu.c +++ b/src/intel/intel_gpgpu.c @@ -213,7 +213,6 @@ typedef struct gen6_vfe_state_inline uint32_t pad22:22; uint32_t scoreboard_type:1; /* 0 stalling, 1 - non-stalling */ uint32_t scoreboard_enable:1; /* 0 disabled, 1 enabled */ - } vfe4; struct { @@ -302,8 +301,6 @@ struct opaque_sampler_state { }; #define MAX_IF_DESC 32 -#define MAX_THREADS 72 -#define MAX_SCRATCH_KB 12 /* Device abstraction */ struct intel_driver; @@ -504,8 +501,9 @@ gpgpu_batch_end(intel_gpgpu_t *state, int32_t flush_mode) /* Insert the performance counter command */ if (state->perf_b.bo) { BEGIN_BATCH(state->batch, 3); - OUT_BATCH(state->batch, (0x28 << 23) | /* MI_REPORT_PERF_COUNT */ - (3 - 2)); /* length-2 */ + OUT_BATCH(state->batch, + (0x28 << 23) | /* MI_REPORT_PERF_COUNT */ + (3 - 2)); /* length-2 */ OUT_RELOC(state->batch, state->perf_b.bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,