xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/hwi/isp20/NrStatsStream.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *  Copyright (c) 2019 Rockchip Corporation
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Licensed under the Apache License, Version 2.0 (the "License");
5*4882a593Smuzhiyun  * you may not use this file except in compliance with the License.
6*4882a593Smuzhiyun  * You may obtain a copy of the License at
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  *      http://www.apache.org/licenses/LICENSE-2.0
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Unless required by applicable law or agreed to in writing, software
11*4882a593Smuzhiyun  * distributed under the License is distributed on an "AS IS" BASIS,
12*4882a593Smuzhiyun  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4882a593Smuzhiyun  * See the License for the specific language governing permissions and
14*4882a593Smuzhiyun  * limitations under the License.
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  */
17*4882a593Smuzhiyun #ifndef _NR_STATS_STREAM_H_
18*4882a593Smuzhiyun #define _NR_STATS_STREAM_H_
19*4882a593Smuzhiyun #include <map>
20*4882a593Smuzhiyun #include "xcam_thread.h"
21*4882a593Smuzhiyun #include "xcam_mutex.h"
22*4882a593Smuzhiyun #include "Stream.h"
23*4882a593Smuzhiyun #include "smart_buffer_priv.h"
24*4882a593Smuzhiyun using namespace XCam;
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun namespace RkCam {
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun class NrParamProcThread;
29*4882a593Smuzhiyun class NrStatsStream  : public RKStream, public PollCallback
30*4882a593Smuzhiyun {
31*4882a593Smuzhiyun public:
32*4882a593Smuzhiyun     explicit NrStatsStream      (SmartPtr<V4l2Device> dev, int type);
33*4882a593Smuzhiyun     virtual ~NrStatsStream      ();
34*4882a593Smuzhiyun     void start                  ();
35*4882a593Smuzhiyun     void stop                   ();
36*4882a593Smuzhiyun     void set_device             (CamHwIsp20* camHw, SmartPtr<V4l2SubDevice> dev);
37*4882a593Smuzhiyun     virtual SmartPtr<VideoBuffer> new_video_buffer(SmartPtr<V4l2Buffer> buf, SmartPtr<V4l2Device> dev);
38*4882a593Smuzhiyun     int queue_NRImg_fd(int fd, uint32_t frameid);
39*4882a593Smuzhiyun     int get_NRImg_fd(uint32_t frameid);
40*4882a593Smuzhiyun     // from PollCallback
poll_buffer_ready(SmartPtr<VideoBuffer> & buf,int type)41*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf, int type) { return XCAM_RETURN_ERROR_FAILED; }
poll_buffer_failed(int64_t timestamp,const char * msg)42*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; }
43*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf);
poll_buffer_ready(SmartPtr<V4l2BufferProxy> & buf,int dev_index)44*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_ready (SmartPtr<V4l2BufferProxy> &buf, int dev_index) { return XCAM_RETURN_ERROR_FAILED; }
poll_event_ready(uint32_t sequence,int type)45*4882a593Smuzhiyun     virtual XCamReturn poll_event_ready (uint32_t sequence, int type) { return XCAM_RETURN_ERROR_FAILED; }
poll_event_failed(int64_t timestamp,const char * msg)46*4882a593Smuzhiyun     virtual XCamReturn poll_event_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; }
47*4882a593Smuzhiyun protected:
48*4882a593Smuzhiyun     bool init_nrbuf_fd          ();
49*4882a593Smuzhiyun     bool deinit_nrbuf_fd        ();
50*4882a593Smuzhiyun     int get_NRimg_fd_by_index(int index);
51*4882a593Smuzhiyun private:
52*4882a593Smuzhiyun     SmartPtr<V4l2SubDevice> _ispp_dev;
53*4882a593Smuzhiyun     struct v4l2_subdev_format _ispp_fmt;
54*4882a593Smuzhiyun     int _fd_array[16];
55*4882a593Smuzhiyun     int _idx_array[16];
56*4882a593Smuzhiyun     int _buf_num;
57*4882a593Smuzhiyun     bool _fd_init_flag;
58*4882a593Smuzhiyun     //SmartPtr<NrParamProcThread> _proc_thread;
59*4882a593Smuzhiyun     Mutex _list_mutex;
60*4882a593Smuzhiyun     CamHwIsp20* _camHw;
61*4882a593Smuzhiyun     SmartPtr<VideoBuffer> _NrImage;
62*4882a593Smuzhiyun     std::map<uint32_t, int> _NrImg_ready_map;
63*4882a593Smuzhiyun };
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun class NrParamProcThread
66*4882a593Smuzhiyun     : public Thread
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun public:
NrParamProcThread(NrStatsStream * handle)69*4882a593Smuzhiyun     NrParamProcThread (NrStatsStream *handle)
70*4882a593Smuzhiyun         : Thread ("NrParamProcThread")
71*4882a593Smuzhiyun         , _handle (handle)
72*4882a593Smuzhiyun     {
73*4882a593Smuzhiyun         (void)(_handle);
74*4882a593Smuzhiyun     }
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun protected:
loop()77*4882a593Smuzhiyun     virtual bool loop () {
78*4882a593Smuzhiyun         return  false;//_handle->thread_proc ();
79*4882a593Smuzhiyun     }
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun private:
82*4882a593Smuzhiyun     NrStatsStream *_handle;
83*4882a593Smuzhiyun };
84*4882a593Smuzhiyun }
85*4882a593Smuzhiyun #endif
86