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