1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* mfc codec encoding example application
* Andrzej Hajda <a.hajda@samsung.com>
*
* I/O device header file.
*
* Copyright 2012 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IO_DEV_H
#define IO_DEV_H
#include <linux/videodev2.h>
#include "common.h"
struct dev_buffers {
int count; /* number of buffers */
int nplanes; /* number of planes per buffer */
int *lengths; /* array of plane lengths */
/* array of plane addresses, address of plane p in buffer b
is at addr[nplanes * b + p] */
char **addr;
/* array of bytes used by plane, bytesused of plane p in buffer b
is at bytesused[nplanes * b + p] */
int *bytesused;
};
struct ring_buffer {
int begin;
int end;
int size;
int data[0];
};
enum io_type { IO_NONE, IO_FUNC, IO_MMAP, IO_USERPTR };
enum io_dir { DIR_IN = 0, DIR_OUT = 1};
enum func_state { FS_OFF, FS_BUSY, FS_READY, FS_EVENT, FS_END };
struct io_dev_ops;
struct io_dev;
struct io_port {
enum io_type type;
enum func_state state;
int counter; /* total number of dequeued buffers */
int nbufs; /* number of buffers in queue */
int limit; /* after dequeuing limit buffers state is changed to END */
struct dev_buffers *bufs;
struct ring_buffer *queue; /* used by non V4L devices */
};
struct io_dev {
int fd;
int event;
/* in and out parts of device */
struct io_port io[2];
struct io_dev_ops *ops;
void *priv;
};
struct io_dev_ops {
int (*read)(struct io_dev *dev, int nbufs, char **bufs, int *lens);
int (*write)(struct io_dev *dev, int nbufs, char **bufs, int *lens);
int (*req_bufs)(struct io_dev *dev, enum io_dir dir, int nelem);
int (*deq_buf)(struct io_dev *dev, enum io_dir dir);
int (*enq_buf)(struct io_dev *dev, enum io_dir dir, int idx);
int (*deq_event)(struct io_dev *dev);
int (*destroy)(struct io_dev *dev);
};
enum v4l2_buf_type io_dir_to_type(enum io_dir dir);
int dev_copy_fmt(int src_fd, enum io_dir src_dir, int dst_fd,
enum io_dir dst_dir);
int process_chain(struct io_dev *chain[], int nelem);
#endif
|