summaryrefslogtreecommitdiff
path: root/amvdec/ionvideo.c (plain)
blob: 4660363b7a11de294cf9edb530dd1d4295ddd946
1/*
2 * Copyright (c) 2014 Amlogic, Inc. All rights reserved.
3 *
4 * This source code is subject to the terms and conditions defined in the
5 * file 'LICENSE' which is part of this source code package.
6 *
7 * Description:
8 */
9
10
11#include <sys/types.h>
12#include <sys/stat.h>
13#include <fcntl.h>
14#include <ionvideo.h>
15#include "ionvdec_priv.h"
16#include "ionv4l.h"
17
18ionvideo_dev_t *new_ionvideo(int flags)
19{
20 ionvideo_dev_t *dev = NULL;
21 if (flags & FLAGS_V4L_MODE) {
22 dev = new_ionv4l();
23 if (dev) {
24 dev->mode = FLAGS_V4L_MODE;
25 }
26 }
27 return dev;
28}
29int ionvideo_setparameters(ionvideo_dev_t *dev, int cmd, void * parameters)
30{
31 return 0;
32}
33int ionvideo_getparameters(ionvideo_dev_t *dev, int *width, int *height, int *pixelformat)
34{
35 struct v4l2_format v4lfmt;
36 int ret = 0;
37
38 v4lfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
39 if (dev->ops.getparameters) {
40 ret = dev->ops.getparameters(dev, &v4lfmt);
41 if (ret) {
42 return ret;
43 }
44 *width = v4lfmt.fmt.pix.width;
45 *height = v4lfmt.fmt.pix.height;
46 *pixelformat = v4lfmt.fmt.pix.pixelformat;
47 }
48 return 0;
49}
50int ionvideo_init(ionvideo_dev_t *dev, int flags, int width, int height, int fmt, int buffernum)
51{
52 int ret = -1;
53 if (dev->ops.init) {
54 ret = dev->ops.init(dev, O_RDWR | O_NONBLOCK, width, height, fmt, buffernum);
55 }
56 return ret;
57}
58int ionvideo_start(ionvideo_dev_t *dev)
59{
60 if (dev->ops.start) {
61 return dev->ops.start(dev);
62 }
63 return 0;
64}
65int ionvideo_stop(ionvideo_dev_t *dev)
66{
67 if (dev->ops.stop) {
68 return dev->ops.stop(dev);
69 }
70 return 0;
71}
72int ionvideo_release(ionvideo_dev_t *dev)
73{
74 if (dev->mode == FLAGS_V4L_MODE) {
75 ionv4l_release(dev);
76 }
77 return 0;
78}
79int ionv4l_dequeuebuf(ionvideo_dev_t *dev, vframebuf_t*vf)
80{
81 if (dev->ops.dequeuebuf) {
82 return dev->ops.dequeuebuf(dev, vf);
83 }
84 return -1;
85}
86int ionv4l_queuebuf(ionvideo_dev_t *dev, vframebuf_t*vf)
87{
88 if (dev->ops.queuebuf) {
89 return dev->ops.queuebuf(dev, vf);
90 }
91 return 0;
92}
93