Added buf_lock and buf_unlock APIs in copycodec and yuvcopy test cases.
authorPradeep Venkatasubbarao <pradeepv@ti.com>
Thu, 27 Mar 2014 12:31:40 +0000 (18:01 +0530)
committerAmarinder Bindra <a-bindra@ti.com>
Thu, 27 Mar 2014 14:09:17 +0000 (19:39 +0530)
Fixed the issue of copycodec failure. omap_dmabuf_map was
not not done on input and output buffers

Signed-off-by: Pradeep Venkatasubbarao <pradeepv@ti.com>
copycodectest.c
yuvcopytest.c

index 757e2a8bba3b215650e9bf1ca8a8ee9b644fada5..b54bf14ba52704d0b92170c4fc689ae242f52fc2 100644 (file)
@@ -47,9 +47,11 @@ struct decoder {
        VIDDEC2_OutArgs *outArgs;
        char *input;
        char *output;
-        int input_sz, output_sz;
-        XDAS_Int8 **outBuffer;
-        XDAS_Int32 *outBufSizes;
+       struct omap_bo *input_bo;
+       struct omap_bo *output_bo;
+    int input_sz, output_sz;
+    XDAS_Int8 **outBuffer;
+    XDAS_Int32 *outBufSizes;
 };
 
 static void
@@ -59,16 +61,18 @@ decoder_close(struct decoder *decoder)
        if (decoder->params)         dsp_dce_free(decoder->params);
        if (decoder->dynParams)      dsp_dce_free(decoder->dynParams);
        if (decoder->status)         dsp_dce_free(decoder->status);
-       if (decoder->inBufs) 
+       if (decoder->inBufs)
     {
+        dsp_dce_buf_unlock(1, &(decoder->inBufs->descs[0].buf));
         close(decoder->inBufs->descs[0].buf);
         dsp_dce_free(decoder->inBufs);
     }
        if (decoder->outBufs)        dsp_dce_free(decoder->outBufs);
        if (decoder->inArgs)         dsp_dce_free(decoder->inArgs);
        if (decoder->outArgs)        dsp_dce_free(decoder->outArgs);
-       if (decoder->input)          dsp_dce_free(decoder->input);
-       if (decoder->output)         dsp_dce_free(decoder->output);
+       if (decoder->input_bo)       omap_bo_del(decoder->input_bo);
+       if (decoder->output_bo)      omap_bo_del(decoder->output_bo);
+
        if (decoder->outBuffer)
     {
         close(decoder->outBuffer[0]);
@@ -77,6 +81,7 @@ decoder_close(struct decoder *decoder)
        if (decoder->outBufSizes)    dsp_dce_free(decoder->outBufSizes);
        if (decoder->codec)          VIDDEC2_delete(decoder->codec);
        if (decoder->engine)         Engine_close(decoder->engine);
+
        free(decoder);
 bailout:
        if (dev)                             dce_deinit(dev);
@@ -107,10 +112,12 @@ decoder_open(int pattern)
                goto fail;
        }
        decoder->input_sz = width * height;
-       decoder->input = omap_bo_new(dev, decoder->input_sz, OMAP_BO_WC);
+       decoder->input_bo = omap_bo_new(dev, decoder->input_sz, OMAP_BO_WC);
+       decoder->input = omap_bo_map(decoder->input_bo);
 
        decoder->output_sz = width * height;
-       decoder->output = omap_bo_new(dev, decoder->output_sz, OMAP_BO_WC);
+       decoder->output_bo = omap_bo_new(dev, decoder->output_sz, OMAP_BO_WC);
+       decoder->output = omap_bo_map(decoder->output_bo);
 
        decoder->params = dsp_dce_alloc(sizeof(IVIDDEC2_Params));
        decoder->params->size = sizeof(IVIDDEC2_Params);
@@ -144,11 +151,13 @@ decoder_open(int pattern)
        }
     decoder->outBuffer = dsp_dce_alloc(sizeof(XDAS_Int8*) * MAX_IO_BUFS);
     decoder->outBufSizes = dsp_dce_alloc(sizeof(XDAS_Int32)* MAX_IO_BUFS);
-    decoder->inBufs = dsp_dce_alloc(sizeof(XDM1_BufDesc)); 
+    decoder->inBufs = dsp_dce_alloc(sizeof(XDM1_BufDesc));
     decoder->inBufs->numBufs = 1;
-    decoder->inBufs->descs[0].buf =    (XDAS_Int8 *)omap_bo_dmabuf((struct omap_bo*) decoder->input);
+    decoder->inBufs->descs[0].buf =    (XDAS_Int8 *)omap_bo_dmabuf((struct omap_bo*) decoder->input_bo);
     decoder->inBufs->descs[0].bufSize = width * height;
-    decoder->outBuffer[0] = (XDAS_Int8*)omap_bo_dmabuf((struct omap_bo*) decoder->output);
+    dsp_dce_buf_lock(1, &(decoder->inBufs->descs[0].buf));
+
+    decoder->outBuffer[0] = (XDAS_Int8*)omap_bo_dmabuf((struct omap_bo*) decoder->output_bo);
     decoder->outBuffer[1] = decoder->outBuffer[0];
     decoder->outBufSizes[0] = width * height;
     decoder->outBufSizes[1] = decoder->outBufSizes[0];
@@ -156,6 +165,7 @@ decoder_open(int pattern)
        decoder->outBufs->numBufs = 2;
        decoder->outBufs->bufs = (XDAS_Int8**)decoder->outBuffer;
     decoder->outBufs->bufSizes = &decoder->outBufSizes[0];
+    dsp_dce_buf_lock(1, &decoder->outBuffer[0]);
 
        decoder->inArgs = dsp_dce_alloc(sizeof(IVIDDEC2_InArgs));
        decoder->inArgs->size = sizeof(IVIDDEC2_InArgs);
@@ -164,8 +174,8 @@ decoder_open(int pattern)
        decoder->outArgs->size = sizeof(IVIDDEC2_OutArgs);
 
     // Fill input buffer with a pattern for testing */
-    MSG("Fill first 10 bytes of input buffer with pattern %d\n", pattern);
-    for(i = 0; i < 10 ; i++)
+    MSG("Fill input buffer with pattern %d\n", pattern);
+    for(i = 0; i < decoder->input_sz ; i++)
         decoder->input[i] = pattern;
 
        return decoder;
@@ -186,7 +196,8 @@ decoder_process(struct decoder *decoder)
     XDM_BufDesc *outBufs = decoder->outBufs;
     VIDDEC2_InArgs *inArgs = decoder->inArgs;
     VIDDEC2_OutArgs *outArgs = decoder->outArgs;
-    XDAS_Int32 err = XDM_EOK, j;
+    XDAS_Int32 err = XDM_EOK, j,success = XDAS_TRUE;
+    char *src,*dst;
 
     err = VIDDEC2_process(decoder->codec, inBufs, outBufs, inArgs, outArgs);
     if (err) {
@@ -194,14 +205,24 @@ decoder_process(struct decoder *decoder)
        return -1;
       }
 
+    dsp_dce_buf_unlock(1, &decoder->outBuffer[0]);
+
     MSG("Verifing the UniversalCopy algorithm\n");
-    MSG("First 10 bytes of Output buffer\n");
 
-    for(j= 0 ; j < 10 ; j++){
-        MSG("%d\t", decoder->output[j]);
+    src = (char*)decoder->input;
+    dst = (char*)decoder->output;
+    for(j= 0 ; j < decoder->input_sz ; j++){
+       if(*src != *dst){
+            MSG("copycodectest failed at %d, 0x%x, 0x%x\n", j, *src, *dst);
+            success = XDAS_FALSE;
+            break;
+          }
+          src++;
+          dst++;
      }
+      if(success ==XDAS_TRUE)
+           MSG("copycodectest executed successfully\n");
 
-    MSG("Tested UniversalCopy successfully\n");
        return 0;
 }
 
index c90cabba1dbe735599611ec21fa0df5ba0aef724..5a892e970ea5d27435fac18dfdcd9bc9a55a93e8 100644 (file)
@@ -78,6 +78,7 @@ decoder_close(struct decoder *decoder)
        if (decoder->status)         dsp_dce_free(decoder->status);
        if (decoder->inBufs)
     {
+        dsp_dce_buf_unlock(1, &(decoder->inBufs->descs[0].buf));
         close(decoder->inBufs->descs[0].buf);
         dsp_dce_free(decoder->inBufs);
     }
@@ -144,9 +145,9 @@ decoder_open(int argc, char** argv)
                 argv[i] = NULL;
                 height = atoi(argv[i+1]);
                 argv[i+1] = NULL;
-            } 
+            }
         }
-        
+
         MSG("width = %d, height = %d\n", width, height);
        if (check_args(argc, argv) || !infile)
                goto usage;
@@ -168,7 +169,7 @@ decoder_open(int argc, char** argv)
         decoder->input = omap_bo_map(decoder->input_bo);
         decoder->framebuf = disp_get_fb(decoder->disp);
 
-        MSG("Fill input buffer with yuv luma data\n"); 
+        MSG("Fill input buffer with yuv luma data\n");
         {
             FILE *fd;
             fd = fopen(infile, "rb");
@@ -224,7 +225,7 @@ decoder_open(int argc, char** argv)
       if (err) {
          ERROR("%p: fail: %d", decoder, err);
         goto fail;
-      } 
+      }
 
       decoder->outBuffer = dsp_dce_alloc(sizeof(XDAS_Int8*) * MAX_IO_BUFS);
       decoder->outBufSizes = dsp_dce_alloc(sizeof(XDAS_Int32)* MAX_IO_BUFS);
@@ -233,6 +234,7 @@ decoder_open(int argc, char** argv)
       decoder->inBufs->numBufs = 1;
       decoder->inBufs->descs[0].buf =  (XDAS_Int8 *)omap_bo_dmabuf(decoder->input_bo);
       decoder->inBufs->descs[0].bufSize = omap_bo_size(decoder->input_bo);
+      dsp_dce_buf_lock(1, &(decoder->inBufs->descs[0].buf));
 
       decoder->outBufs = dsp_dce_alloc(sizeof(XDM_BufDesc));
       decoder->outBufs->numBufs = 2;
@@ -277,6 +279,7 @@ decoder_process(struct decoder *decoder)
 
        decoder->outBuffer[0] = buf->fd[0];
        decoder->outBuffer[1] = (buf->multiplanar) ? buf->fd[1]:(XDAS_Int8 *)((decoder->outBuffer[0]));
+    dsp_dce_buf_lock(2,&decoder->outBuffer[0]);
 
        decoder->outBufSizes[0] = decoder->padded_width * decoder->padded_height;
        decoder->outBufSizes[1] = decoder->padded_width * (decoder->padded_height/2);
@@ -287,6 +290,7 @@ decoder_process(struct decoder *decoder)
                ERROR("%p: process returned error: %d", decoder, err);
                return -1;
        }
+    dsp_dce_buf_unlock(2, &decoder->outBuffer[0]);
 
        disp_post_vid_buffer(decoder->disp, buf, 0, 0, width, height);
         /* Display the output buffer for 10 seconds */
@@ -296,7 +300,7 @@ decoder_process(struct decoder *decoder)
 
         src = (char*)decoder->input;
         dst = (char*)omap_bo_map(buf->bo[0]);
+
         MSG("Comparing output buffer with input buffer\n");
 
         for(i = 0; i < decoder->input_sz; i++){
@@ -320,11 +324,11 @@ main(int argc, char **argv)
 {
     struct decoder *decoder = NULL;
     int i;
-    for (i = 1; i < argc; i++) 
+    for (i = 1; i < argc; i++)
        if ( !strcmp(argv[i], "--help")) {
             usage(argv[0]);
            exit(0);
-    } 
+    }
     decoder = decoder_open(argc,argv);
 
     if(decoder)