fixes for bc_cat 1.7.17.783851
authorGrazvydas Ignotas <notasas@gmail.com>
Thu, 3 Jul 2014 21:47:08 +0000 (00:47 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 4 Jul 2014 00:37:50 +0000 (03:37 +0300)
services4/3rdparty/bufferclass_ti/bc_cat.c
services4/system/omap3/sysinfo.h

index 5861e8e..f61578b 100644 (file)
@@ -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
@@ -455,7 +454,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;
@@ -500,7 +500,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;
@@ -601,7 +601,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 */
@@ -620,9 +620,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;
     }
 
@@ -638,18 +637,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);
@@ -661,22 +665,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);
         }
     }
 } 
@@ -958,7 +959,7 @@ static long  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;
index 79766ed..f2234db 100644 (file)
@@ -35,6 +35,6 @@
 
 #define WAIT_TRY_COUNT                         (10000)
 
-#define SYS_DEVICE_COUNT 
+#define SYS_DEVICE_COUNT 15
 
 #endif