From 2e1549e64a98565327c73f6bcec9ba7f75f11ea1 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Fri, 4 Jul 2014 00:47:08 +0300 Subject: [PATCH] fixes for bc_cat --- services4/3rdparty/bufferclass_ti/bc_cat.c | 37 +++++++++++----------- services4/system/omap3/sysinfo.h | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/services4/3rdparty/bufferclass_ti/bc_cat.c b/services4/3rdparty/bufferclass_ti/bc_cat.c index 79e7b85..e46964c 100644 --- a/services4/3rdparty/bufferclass_ti/bc_cat.c +++ b/services4/3rdparty/bufferclass_ti/bc_cat.c @@ -40,8 +40,7 @@ #define DEVNAME "bccat" #define DRVNAME DEVNAME -#define DEVICE_COUNT 1 -#define BC_EXAMPLE_NUM_BUFFERS 3 +#define DEVICE_COUNT 10 #define BUFFERCLASS_DEVICE_NAME "Example Bufferclass Device (SW)" #ifndef UNREFERENCED_PARAMETER @@ -449,7 +448,8 @@ static PVRSRV_ERROR BC_DestroyBuffers(int id) #endif } - // BCFreeKernelMem(psDevInfo->psSystemBuffer); + BCFreeKernelMem(psDevInfo->psSystemBuffer); + psDevInfo->psSystemBuffer = NULL; psDevInfo->ulNumBuffers = 0; psDevInfo->sBufferInfo.pixelformat = PVRSRV_PIXEL_FORMAT_UNKNOWN; @@ -494,7 +494,7 @@ static PVRSRV_ERROR BC_Register(id) psDevInfo->ulNumBuffers = 0; - psDevInfo->psSystemBuffer = BCAllocKernelMem(sizeof(BC_CAT_BUFFER) * BC_EXAMPLE_NUM_BUFFERS); + psDevInfo->psSystemBuffer = NULL; psDevInfo->sBufferInfo.pixelformat = PVRSRV_PIXEL_FORMAT_UNKNOWN; psDevInfo->sBufferInfo.ui32Width = 0; @@ -595,7 +595,7 @@ if (psDevInfo->psSystemBuffer) static int __init bc_cat_init(void) { struct device *bc_dev; - int id; + int id = 0; /* texture buffer width should be multiple of 8 for OMAP3 ES3.x, * or 32 for ES2.x */ @@ -614,9 +614,8 @@ static int __init bc_cat_init(void) } bc_class = class_create(THIS_MODULE, DEVNAME); - if (IS_ERR(bc_class)) { - printk(KERN_ERR DRVNAME ": upable to create device class\n"); + printk(KERN_ERR DRVNAME ": unable to create device class\n"); goto ExitUnregister; } @@ -632,18 +631,23 @@ static int __init bc_cat_init(void) if (BC_Register(id) != PVRSRV_OK) { printk (KERN_ERR DRVNAME ": can't register BC service %d\n", id); if (id > 0) { - /* lets live with the drivers that we were able to create soi + /* let's live with the drivers that we were able to create so * far, even though it isn't as many as we'd like */ + device_destroy(bc_class, MKDEV(major, id)); break; } - goto ExitUnregister; + goto ExitDestroyClass; } } return 0; ExitDestroyClass: + for (; id >= 0; id--) { + BC_Unregister(id); + device_destroy(bc_class, MKDEV(major, id)); + } class_destroy(bc_class); ExitUnregister: unregister_chrdev(major, DEVNAME); @@ -655,22 +659,19 @@ static void __exit bc_cat_cleanup(void) { int id=0; - for (id = 0; id < DEVICE_COUNT; id++) { -device_destroy(bc_class, MKDEV(major, id)); -} + for (id = 0; id < DEVICE_COUNT; id++) + device_destroy(bc_class, MKDEV(major, id)); class_destroy(bc_class); unregister_chrdev(major, DEVNAME); - for (id = 0; id < DEVICE_COUNT; id++) { + for (id = 0; id < DEVICE_COUNT; id++) { if (BC_DestroyBuffers(id) != PVRSRV_OK) { - printk(KERN_ERR DRVNAME ": can't free texture buffers\n"); - return; + printk(KERN_ERR DRVNAME ": can't free texture buffers, dev %d\n", id); } if (BC_Unregister(id) != PVRSRV_OK) { - printk(KERN_ERR DRVNAME ": can't un-register BC service\n"); - return; + printk(KERN_ERR DRVNAME ": can't un-register BC service, dev %d\n", id); } } } @@ -952,7 +953,7 @@ static int bc_ioctl(struct file *file, return -EFAULT; idx = params->input; - if (idx < 0 || idx > devinfo->ulNumBuffers) { + if (idx < 0 || idx >= devinfo->ulNumBuffers) { printk(KERN_ERR DRVNAME ": BCIOGET_BUFFERADDR - idx out of range\n"); return -EINVAL; diff --git a/services4/system/omap3/sysinfo.h b/services4/system/omap3/sysinfo.h index 79766ed..f2234db 100644 --- a/services4/system/omap3/sysinfo.h +++ b/services4/system/omap3/sysinfo.h @@ -35,6 +35,6 @@ #define WAIT_TRY_COUNT (10000) -#define SYS_DEVICE_COUNT 3 +#define SYS_DEVICE_COUNT 15 #endif -- 2.39.5