]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/omapdrmtest.git/blob - dmabuftest.c
add NOCONFIGURE support to autogen.sh
[glsdk/omapdrmtest.git] / dmabuftest.c
1 /*
2  * Copyright (C) 2011 Texas Instruments
3  * Author: Rob Clark <rob.clark@linaro.org>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published by
7  * the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
19 #include "util.h"
21 #define NBUF 3
22 #define CNT  500
24 static void
25 usage(char *name)
26 {
27         MSG("Usage: %s [OPTION]...", name);
28         MSG("Test of buffer passing between v4l2 camera and display.");
29         MSG("");
30         disp_usage();
31         v4l2_usage();
32 }
34 int
35 main(int argc, char **argv)
36 {
37         struct display *disp;
38         struct v4l2 *v4l2;
39         struct buffer *framebuf;
40         struct buffer **buffers;
41         uint32_t fourcc, width, height;
42         int ret, i;
44         MSG("Opening Display..");
45         disp = disp_open(argc, argv);
46         if (!disp) {
47                 usage(argv[0]);
48                 return 1;
49         }
51         MSG("Opening V4L2..");
52         v4l2 = v4l2_open(argc, argv, &fourcc, &width, &height);
53         if (!v4l2) {
54                 usage(argv[0]);
55                 return 1;
56         }
58         if (check_args(argc, argv)) {
59                 /* remaining args.. print usage msg */
60                 usage(argv[0]);
61                 return 0;
62         }
64         framebuf = disp_get_fb(disp);
66         buffers = disp_get_vid_buffers(disp, NBUF, fourcc, width, height);
67         if (!buffers) {
68                 return 1;
69         }
71         ret = v4l2_reqbufs(v4l2, buffers, NBUF);
72         if (ret) {
73                 return 1;
74         }
76         v4l2_qbuf(v4l2, buffers[0]);
77         v4l2_streamon(v4l2);
78         for (i = 1; i < CNT; i++) {
79                 v4l2_qbuf(v4l2, buffers[i % NBUF]);
80                 ret = disp_post_vid_buffer(disp, v4l2_dqbuf(v4l2),
81                                 0, 0, width, height);
82                 if (ret) {
83                         return ret;
84                 }
85         }
86         v4l2_streamoff(v4l2);
87         v4l2_dqbuf(v4l2);
89         MSG("Ok!");
91         return ret;
92 }