xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/xcore/fake_v4l2_device.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * v4l2_device.h - v4l2 device
3  *
4  *  Copyright (c) 2014-2015 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Wind Yuan <feng.yuan@intel.com>
19  */
20 
21 #ifndef XCAM_FAKE_V4L2_DEVICE_H
22 #define XCAM_FAKE_V4L2_DEVICE_H
23 
24 #include <v4l2_device.h>
25 #include "rk_aiq_types_priv.h"
26 
27 namespace XCam {
28 class FakeV4l2Device : public V4l2Device
29 {
30 public:
FakeV4l2Device()31     FakeV4l2Device () : V4l2Device("/dev/zero")
32     {
33         _pipe_fd[0] = -1;
34         _pipe_fd[1] = -1;
35         _use_type = 0;
36     }
~FakeV4l2Device()37     virtual ~FakeV4l2Device () {
38     }
39     virtual XCamReturn open (bool nonblock = false) override;
40     virtual XCamReturn close () override;
41     int create_notify_pipe ();
42     void destroy_notify_pipe ();
43     virtual XCamReturn start(bool prepared = false) override;
44     virtual XCamReturn stop() override;
45     virtual XCamReturn get_format (struct v4l2_format &format) override;
46     virtual int poll_event (int timeout_msec, int stop_fd) override;
47     virtual XCamReturn dequeue_buffer (SmartPtr<V4l2Buffer> &buf) override;
48     // use as less as possible
49     virtual int io_control (unsigned long cmd, void *arg) override;
50     void on_timer_proc();
51     void enqueue_rawbuffer(struct rk_aiq_vbuf_info *vbinfo);
get_use_type()52     virtual int get_use_type() override {return _use_type;}
set_use_type(int type)53     virtual void set_use_type(int type) override {_use_type = type;}
54 protected:
55     Mutex _mutex;
56     int _pipe_fd[2];
57     std::list<struct rk_aiq_vbuf_info> _buf_list;
58     XCAM_DEAD_COPY (FakeV4l2Device);
59     uint32_t get_available_buffer_index ();
60     int _use_type;
61 };
62 
63 }
64 #endif // XCAM_FAKE_V4L2_DEVICE_H
65 
66