]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/omapdrmtest.git/blob - util/vpe-common.c
VPE: util: Add NV12 support to VPE library
[glsdk/omapdrmtest.git] / util / vpe-common.c
1 /*
2  *  Copyright (c) 2013-2014, Texas Instruments Incorporated
3  *  Author: alaganraj <alaganraj.s@ti.com>
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *  *  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *
12  *  *  Redistributions in binary form must reproduce the above copyright
13  *     notice, this list of conditions and the following disclaimer in the
14  *     documentation and/or other materials provided with the distribution.
15  *
16  *  *  Neither the name of Texas Instruments Incorporated nor the names of
17  *     its contributors may be used to endorse or promote products derived
18  *     from this software without specific prior written permission.
19  *
20  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  *  Contact information for paper mail:
33  *  Texas Instruments
34  *  Post Office Box 655303
35  *  Dallas, Texas 75265
36  *  Contact information:
37  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
38  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
39  *  ============================================================================
40  *
41  */
43 /*
44  * @File        vpe-common.c
45  * @Brief       vpe specific common functions, used to integrate vpe 
46  *              with other modules.
47  *
48  *              Input buffer must be allocated in application, queue it to vpe 
49  *              by passing buffer index
50  *              
51  *              Output buffer allocated in vpe_output_init() as vpe output intended
52  *              to display on LCD.
53  */
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <fcntl.h>
57 #include <unistd.h>
58 #include <stdint.h>
59 #include <string.h>
60 #include <errno.h>
62 #include <linux/videodev2.h>
63 #include <linux/v4l2-controls.h>
65 #include <sys/mman.h>
66 #include <sys/ioctl.h>
68 #include <xf86drm.h>
69 #include <omap_drm.h>
70 #include <omap_drmif.h>
72 #include "util.h"
74 #define pexit(fmt, arg...) { \
75                 printf(fmt, ## arg); \
76                 exit(1); \
77 }
79 #define V4L2_CID_TRANS_NUM_BUFS         (V4L2_CID_PRIVATE_BASE)
80 #define NUMBUF                          6
82 //#define vpe_debug
84 #ifdef vpe_debug
85 #define dprintf(fmt, arg...) printf(fmt, ## arg)
86 #else
87 #define dprintf(fmt, arg...) do {} while(0)
88 #endif
90 struct image_params {
91         int width;
92         int height;
93         int fourcc;
94         int size;
95         int size_uv;
96         int coplanar;
97         enum v4l2_colorspace colorspace;
98         int numbuf;
99 };
101 struct vpe {
102         int fd;
103         int field;
104         int deint;
105         int translen;
106         struct image_params src;
107         struct image_params dst;
108         struct  v4l2_crop crop;
109         int input_buf_dmafd[NUMBUF];
110         int input_buf_dmafd_uv[NUMBUF];
111         int output_buf_dmafd[NUMBUF];
112         int output_buf_dmafd_uv[NUMBUF];
113         struct display *disp;
114         struct buffer **disp_bufs;
115 };
117 /**
118  *****************************************************************************
119  * @brief:  open the device
120  *
121  * @return: vpe  struct vpe pointer 
122  *****************************************************************************
123 */
124 struct vpe *vpe_open(void)
126         char devname[20] = "/dev/video0";
127         struct vpe *vpe;
129         vpe = calloc(1, sizeof(*vpe));
131         vpe->fd =  open(devname, O_RDWR);
132         if(vpe->fd < 0)
133                 pexit("Cant open %s\n", devname);
135         printf("vpe:%s open success!!!\n", devname);
137         return vpe;
140 /**
141  *****************************************************************************
142  * @brief:  close the device and free memory
143  *
144  * @param:  vpe  struct vpe pointer
145  *
146  * @return: 0 on success 
147  *****************************************************************************
148 */
149 int vpe_close(struct vpe *vpe)
151         close(vpe->fd);
152         free(vpe);
153         
154         return 0;
157 /**
158  *****************************************************************************
159  * @brief:  fills 4cc, size, coplanar, colorspace based on command line input 
160  *
161  * @param:  format  char pointer
162  * @param:  image  struct image_params pointer
163  *
164  * @return: 0 on success 
165  *****************************************************************************
166 */
167 int describeFormat (char *format, struct image_params *image)
169         image->size   = -1;
170         image->fourcc = -1;
171         if (strcmp (format, "rgb24") == 0) {
172                 image->fourcc = V4L2_PIX_FMT_RGB24;
173                 image->size = image->height * image->width * 3;
174                 image->coplanar = 0;
175                 image->colorspace = V4L2_COLORSPACE_SRGB;
177         } else if (strcmp (format, "bgr24") == 0) {
178                 image->fourcc = V4L2_PIX_FMT_BGR24;
179                 image->size = image->height * image->width * 3;
180                 image->coplanar = 0;
181                 image->colorspace = V4L2_COLORSPACE_SRGB;
183         } else if (strcmp (format, "argb32") == 0) {
184                 image->fourcc = V4L2_PIX_FMT_RGB32;
185                 image->size = image->height * image->width * 4;
186                 image->coplanar = 0;
187                 image->colorspace = V4L2_COLORSPACE_SRGB;
189         } else if (strcmp (format, "abgr32") == 0) {
190                 image->fourcc = V4L2_PIX_FMT_BGR32;
191                 image->size = image->height * image->width * 4;
192                 image->coplanar = 0;
193                 image->colorspace = V4L2_COLORSPACE_SRGB;
195         } else if (strcmp (format, "yuv444") == 0) {
196                 image->fourcc = V4L2_PIX_FMT_YUV444;
197                 image->size = image->height * image->width * 3;
198                 image->coplanar = 0;
199                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
201         } else if (strcmp (format, "yvyu") == 0) {
202                 image->fourcc = V4L2_PIX_FMT_YVYU;
203                 image->size = image->height * image->width * 2;
204                 image->coplanar = 0;
205                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
207         } else if (strcmp (format, "yuyv") == 0) {
208                 image->fourcc = V4L2_PIX_FMT_YUYV;
209                 image->size = image->height * image->width * 2;
210                 image->coplanar = 0;
211                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
213         } else if (strcmp (format, "uyvy") == 0) {
214                 image->fourcc = V4L2_PIX_FMT_UYVY;
215                 image->size = image->height * image->width * 2;
216                 image->coplanar = 0;
217                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
219         } else if (strcmp (format, "vyuy") == 0) {
220                 image->fourcc = V4L2_PIX_FMT_VYUY;
221                 image->size = image->height * image->width * 2;
222                 image->coplanar = 0;
223                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
225         } else if (strcmp (format, "nv16") == 0) {
226                 image->fourcc = V4L2_PIX_FMT_NV16;
227                 image->size = image->height * image->width * 2;
228                 image->coplanar = 0;
229                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
231         } else if (strcmp (format, "nv61") == 0) {
232                 image->fourcc = V4L2_PIX_FMT_NV61;
233                 image->size = image->height * image->width * 2;
234                 image->coplanar = 0;
235                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
237         } else if (strcmp (format, "nv12") == 0) {
238                 image->fourcc = V4L2_PIX_FMT_NV12;
239                 image->size = image->height * image->width * 1.5;
240                 image->coplanar = 1;
241                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
243         } else if (strcmp (format, "nv21") == 0) {
244                 image->fourcc = V4L2_PIX_FMT_NV21;
245                 image->size = image->height * image->width * 1.5;
246                 image->coplanar = 1;
247                 image->colorspace = V4L2_COLORSPACE_SMPTE170M;
249         } else {
250                 return 0;
252         }
254         return 1;
257 /**
258  *****************************************************************************
259  * @brief:  sets crop parameters 
260  *
261  * @param:  vpe  struct vpe pointer
262  *
263  * @return: 0 on success 
264  *****************************************************************************
265 */
266 static int set_crop(struct vpe *vpe)
268         int ret = 0;
269         
270         if ((vpe->crop.c.top == 0) && (vpe->crop.c.left == 0) &&
271             (vpe->crop.c.width == 0) && (vpe->crop.c.height == 0)) {
272                 dprintf("setting default crop params\n");
273                 vpe->crop.c.top = 0;
274                 vpe->crop.c.left = 0;
275                 vpe->crop.c.width = vpe->src.width;
276                 vpe->crop.c.height = vpe->src.height;
277                 vpe->crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
278         }
280         ret = ioctl(vpe->fd, VIDIOC_S_CROP, &vpe->crop);
281         if (ret < 0)
282                 pexit("error setting crop\n");
283         
284         return 0;
287 /**
288  *****************************************************************************
289  * @brief:  sets control, howmany jobs to be handled on multi instance 
290  *
291  * @param:  vpe  struct vpe pointer
292  *
293  * @return: 0 on success 
294  *****************************************************************************
295 */
296 static int set_ctrl(struct vpe *vpe)
298         int ret;
299         struct  v4l2_control ctrl;
301         memset(&ctrl, 0, sizeof(ctrl));
302         ctrl.id = V4L2_CID_TRANS_NUM_BUFS;
303         ctrl.value = vpe->translen;
304         ret = ioctl(vpe->fd, VIDIOC_S_CTRL, &ctrl);
305         if (ret < 0)
306                 pexit("vpe: S_CTRL failed\n");
307         
308         return 0;
311 /**
312  *****************************************************************************
313  * @brief:  Intialize the vpe input by calling set_control, set_format,
314  *          set_crop, refbuf ioctls
315  *
316  * @param:  vpe  struct vpe pointer
317  *
318  * @return: 0 on success 
319  *****************************************************************************
320 */
321 int vpe_input_init(struct vpe *vpe)
323         int ret;
324         struct v4l2_format fmt;
325         struct v4l2_requestbuffers rqbufs;
327         set_ctrl(vpe);
328                 
329         memset(&fmt, 0, sizeof fmt);
330         fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
332         ret = ioctl(vpe->fd, VIDIOC_G_FMT, &fmt);
333         if (ret < 0)
334                 pexit( "vpe i/p: G_FMT_1 failed: %s\n", strerror(errno));
336         fmt.fmt.pix_mp.width = vpe->src.width;
337         fmt.fmt.pix_mp.height = vpe->src.height;
338         fmt.fmt.pix_mp.pixelformat = vpe->src.fourcc;
340         switch (vpe->deint) {
341         case 1:
342                 fmt.fmt.pix_mp.field = V4L2_FIELD_ALTERNATE;
343                 break;
344         case 2:
345                 fmt.fmt.pix_mp.field = V4L2_FIELD_SEQ_TB;
346                 break;
347         case 0:
348         default:
349                 fmt.fmt.pix_mp.field = V4L2_FIELD_ANY;
350                 break;
351         }
353         ret = ioctl(vpe->fd, VIDIOC_S_FMT, &fmt);
354         if (ret < 0) {
355                 pexit( "vpe i/p: S_FMT failed: %s\n", strerror(errno));
356         } else {
357                 vpe->src.size = fmt.fmt.pix_mp.plane_fmt[0].sizeimage;
358                 vpe->src.size_uv = fmt.fmt.pix_mp.plane_fmt[1].sizeimage;
359         }
361         ret = ioctl(vpe->fd, VIDIOC_G_FMT, &fmt);
362         if (ret < 0)
363                 pexit( "vpe i/p: G_FMT_2 failed: %s\n", strerror(errno));
365         printf("vpe i/p: G_FMT: width = %u, height = %u, 4cc = %.4s\n",
366                         fmt.fmt.pix_mp.width, fmt.fmt.pix_mp.height,
367                         (char*)&fmt.fmt.pix_mp.pixelformat);
369         set_crop(vpe);
371         memset(&rqbufs, 0, sizeof(rqbufs));
372         rqbufs.count = NUMBUF;
373         rqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
374         rqbufs.memory = V4L2_MEMORY_DMABUF;
376         ret = ioctl(vpe->fd, VIDIOC_REQBUFS, &rqbufs);
377         if (ret < 0)
378                 pexit( "vpe i/p: REQBUFS failed: %s\n", strerror(errno));
380         vpe->src.numbuf = rqbufs.count;
381         dprintf("vpe i/p: allocated buffers = %d\n", rqbufs.count);
382         
383         return 0;
387 /**
388  *****************************************************************************
389  * @brief:  Initialize vpe output by calling set_format, reqbuf ioctls.
390  *          Also allocates buffer to display the vpe output. 
391  *
392  * @param:  vpe  struct vpe pointer
393  *
394  * @return: 0 on success 
395  *****************************************************************************
396 */
397 int vpe_output_init(struct vpe *vpe)
399         int ret, i;
400         struct v4l2_format fmt;
401         struct v4l2_requestbuffers rqbufs;
403         memset(&fmt, 0, sizeof fmt);
404         fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
406         ret = ioctl(vpe->fd, VIDIOC_G_FMT, &fmt);
407         if (ret < 0)
408                 pexit( "vpe o/p: G_FMT_1 failed: %s\n", strerror(errno));
410         fmt.fmt.pix_mp.width = vpe->dst.width;
411         fmt.fmt.pix_mp.height = vpe->dst.height;
412         fmt.fmt.pix_mp.pixelformat = vpe->dst.fourcc;
413         fmt.fmt.pix_mp.field = V4L2_FIELD_ANY;
415         ret = ioctl(vpe->fd, VIDIOC_S_FMT, &fmt);
416         if (ret < 0)
417                 pexit( "vpe o/p: S_FMT failed: %s\n", strerror(errno));
419         ret = ioctl(vpe->fd, VIDIOC_G_FMT, &fmt);
420         if (ret < 0)
421                 pexit( "vpe o/p: G_FMT_2 failed: %s\n", strerror(errno));
423         printf("vpe o/p: G_FMT: width = %u, height = %u, 4cc = %.4s\n",
424                         fmt.fmt.pix_mp.width, fmt.fmt.pix_mp.height,
425                         (char*)&fmt.fmt.pix_mp.pixelformat);
427         memset(&rqbufs, 0, sizeof(rqbufs));
428         rqbufs.count = NUMBUF;
429         rqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
430         rqbufs.memory = V4L2_MEMORY_DMABUF;
432         ret = ioctl(vpe->fd, VIDIOC_REQBUFS, &rqbufs);
433         if (ret < 0)
434                 pexit( "vpe o/p: REQBUFS failed: %s\n", strerror(errno));
436         vpe->dst.numbuf = rqbufs.count;
437         dprintf("vpe o/p: allocated buffers = %d\n", rqbufs.count);
438         
439         vpe->disp_bufs = disp_get_vid_buffers(vpe->disp, NUMBUF, vpe->dst.fourcc, 
440                                               vpe->dst.width, vpe->dst.height);
441         if (!vpe->disp_bufs)
442                 pexit("allocating display buffer failed\n");
444         for (i = 0; i < NUMBUF; i++) {
445                 vpe->output_buf_dmafd[i] = omap_bo_dmabuf(vpe->disp_bufs[i]->bo[0]);
446                 vpe->disp_bufs[i]->fd[0] = vpe->output_buf_dmafd[i];
448                 if(vpe->dst.coplanar) {
449                         vpe->output_buf_dmafd_uv[i] = omap_bo_dmabuf(vpe->disp_bufs[i]->bo[1]);
450                         vpe->disp_bufs[i]->fd[1] = vpe->output_buf_dmafd_uv[i];
451                 }
452                 /* display only image widthxheight, no full screen */
453                 vpe->disp_bufs[i]->noScale = true;
454                 dprintf("vpe->disp_bufs_fd[%d] = %d\n", i, vpe->output_buf_dmafd[i]);
455         }
457         dprintf("allocating display buffer success\n");
458         return 0;
461 /**
462  *****************************************************************************
463  * @brief:  queue buffer to vpe input 
464  *
465  * @param:  vpe  struct vpe pointer
466  * @param:  index  buffer index to queue
467  *
468  * @return: 0 on success 
469  *****************************************************************************
470 */
471 int vpe_input_qbuf(struct vpe *vpe, int index)
473         int ret, i;
474         struct v4l2_buffer buf;
475         struct v4l2_plane planes[2];
477         dprintf("vpe input buffer queue\n");
479         memset(&buf, 0, sizeof buf);
480         memset(&planes, 0, sizeof planes);
482         planes[0].length = planes[0].bytesused = vpe->src.size;
483         if(vpe->src.coplanar)
484                 planes[1].length = planes[1].bytesused = vpe->src.size_uv;
486         planes[0].data_offset = planes[1].data_offset = 0;
488         buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
489         buf.memory = V4L2_MEMORY_DMABUF;
490         buf.index = index;
491         buf.m.planes = &planes;
492         buf.field = vpe->field;
493         if(vpe->src.coplanar)
494                 buf.length = 2;
495         else
496                 buf.length = 1;
498         buf.m.planes[0].m.fd = vpe->input_buf_dmafd[index];
499         if(vpe->src.coplanar)
500                 buf.m.planes[1].m.fd = vpe->input_buf_dmafd_uv[index];
502         ret = ioctl(vpe->fd, VIDIOC_QBUF, &buf);
503         if (ret < 0)
504                 pexit( "vpe i/p: QBUF failed: %s, index = %d\n",
505                         strerror(errno), index);
507         return 0;
510 /**
511  *****************************************************************************
512  * @brief:  queue buffer to vpe output 
513  *
514  * @param:  vpe  struct vpe pointer
515  * @param:  index  buffer index to queue
516  *
517  * @return: 0 on success 
518  *****************************************************************************
519 */
520 int vpe_output_qbuf(struct vpe *vpe, int index)
522         int ret, i;
523         struct v4l2_buffer buf;
524         struct v4l2_plane planes[2];
526         dprintf("vpe output buffer queue\n");
528         memset(&buf, 0, sizeof buf);
529         memset(&planes, 0, sizeof planes);
531         buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
532         buf.memory = V4L2_MEMORY_DMABUF;
533         buf.index = index;
534         buf.m.planes = &planes;
535         if(vpe->dst.coplanar)
536                 buf.length = 2;
537         else
538                 buf.length = 1;
540         buf.m.planes[0].m.fd = vpe->output_buf_dmafd[index];
542         if(vpe->dst.coplanar)
543                 buf.m.planes[1].m.fd = vpe->output_buf_dmafd_uv[index];
545         ret = ioctl(vpe->fd, VIDIOC_QBUF, &buf);
546         if (ret < 0)
547                 pexit( "vpe o/p: QBUF failed: %s, index = %d\n",
548                         strerror(errno), index);
550         return 0;
553 /**
554  *****************************************************************************
555  * @brief:  start stream 
556  *
557  * @param:  fd  device fd
558  * @param:  type  buffer type (CAPTURE or OUTPUT)
559  *
560  * @return: 0 on success 
561  *****************************************************************************
562 */
563 int stream_ON(int fd, int type)
565         int ret;
567         ret = ioctl(fd, VIDIOC_STREAMON, &type);
568         if (ret < 0)
569                 pexit("STREAMON failed,  %d: %s\n", type, strerror(errno));
571         dprintf("stream ON: done! fd = %d,  type = %d\n", fd, type);
573         return 0;
576 /**
577  *****************************************************************************
578  * @brief:  stop stream 
579  *
580  * @param:  fd  device fd
581  * @param:  type  buffer type (CAPTURE or OUTPUT)
582  *
583  * @return: 0 on success 
584  *****************************************************************************
585 */
586 int stream_OFF(int fd, int type)
588         int ret;
590         ret = ioctl(fd, VIDIOC_STREAMOFF, &type);
591         if (ret < 0)
592                 pexit("STREAMOFF failed, %d: %s\n", type, strerror(errno));
594         dprintf("stream OFF: done! fd = %d,  type = %d\n", fd, type);
596         return 0;
599 /**
600  *****************************************************************************
601  * @brief:  dequeue vpe input buffer  
602  *
603  * @param:  vpe  struct vpe pointer
604  *
605  * @return: buf.index index of dequeued buffer
606  *****************************************************************************
607 */
608 int vpe_input_dqbuf(struct vpe *vpe)
610         int ret;
611         struct v4l2_buffer buf;
612         struct v4l2_plane planes[2];
613         
614         dprintf("vpe input dequeue buffer\n");
615         
616         memset(&buf, 0, sizeof buf);
617         memset(&planes, 0, sizeof planes);
619         buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
620         buf.memory = V4L2_MEMORY_DMABUF;
621         buf.m.planes = &planes;
622         if(vpe->src.coplanar)
623                 buf.length = 2;
624         else
625                 buf.length = 1;
626         ret = ioctl(vpe->fd, VIDIOC_DQBUF, &buf);
627         if (ret < 0)
628                 pexit("vpe i/p: DQBUF failed: %s\n", strerror(errno));
630         dprintf("vpe i/p: DQBUF index = %d\n", buf.index);
632         return buf.index;
635 /**
636  *****************************************************************************
637  * @brief:  dequeue vpe output buffer
638  *
639  * @param:  vpe  struct vpe pointer
640  *
641  * @return: buf.index index of dequeued buffer
642  *****************************************************************************
643 */
644 int vpe_output_dqbuf(struct vpe *vpe)
646         int ret;
647         struct v4l2_buffer buf;
648         struct v4l2_plane planes[2];
650         dprintf("vpe output dequeue buffer\n");
652         memset(&buf, 0, sizeof buf);
653         memset(&planes, 0, sizeof planes);
655         buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
656         buf.memory = V4L2_MEMORY_DMABUF;
657         buf.m.planes = &planes;
658         if(vpe->dst.coplanar)
659                 buf.length = 2;
660         else
661                 buf.length = 1;
662         ret = ioctl(vpe->fd, VIDIOC_DQBUF, &buf);
663         if (ret < 0)
664                 pexit("vpe o/p: DQBUF failed: %s\n", strerror(errno));
666         dprintf("vpe o/p: DQBUF index = %d\n", buf.index);
668         return buf.index;
671 /**
672  *****************************************************************************
673  * @brief:  buffer retried by index and displays the contents
674  *
675  * @param:  vpe  struct vpe pointer
676  * @param: index index of dequeued output buffer
677  *
678  * @return: 0 on success 
679  *****************************************************************************
680 */
681 int display_buffer(struct vpe *vpe, int index)
683         int ret;
684         struct buffer *buf;
685         
686         buf = vpe->disp_bufs[index];
687         ret = disp_post_vid_buffer(vpe->disp, buf, 0, 0, vpe->dst.width,
688                                    vpe->dst.height);
689         if (ret)
690                 pexit("disp post vid buf failed\n");
692         return 0;