Added buf_lock and buf_unlock APIs in copycodec and yuvcopy test cases.
[glsdk/omapdrmtest.git] / copycodectest.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;
 }