xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/hwi/isp20/TnrStatsStream.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 _TNR_STATS_STREAM_H_
18*4882a593Smuzhiyun #define _TNR_STATS_STREAM_H_
19*4882a593Smuzhiyun #include <map>
20*4882a593Smuzhiyun #include "Stream.h"
21*4882a593Smuzhiyun #include "xcam_thread.h"
22*4882a593Smuzhiyun #include "xcam_mutex.h"
23*4882a593Smuzhiyun #include "NrStatsStream.h"
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun using namespace XCam;
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun namespace RkCam {
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun class TnrProcThread;
30*4882a593Smuzhiyun class TnrStatsStream : public RKStream, public PollCallback
31*4882a593Smuzhiyun {
32*4882a593Smuzhiyun public:
33*4882a593Smuzhiyun     explicit TnrStatsStream (SmartPtr<V4l2Device> dev, int type);
34*4882a593Smuzhiyun     virtual ~TnrStatsStream      ();
35*4882a593Smuzhiyun     void start                  ();
36*4882a593Smuzhiyun     void stop                   ();
37*4882a593Smuzhiyun     void set_device             (CamHwIsp20* camHw, SmartPtr<V4l2SubDevice> dev);
38*4882a593Smuzhiyun     //bool thread_proc            ();
39*4882a593Smuzhiyun     virtual SmartPtr<VideoBuffer> new_video_buffer(SmartPtr<V4l2Buffer> buf, SmartPtr<V4l2Device> dev);
40*4882a593Smuzhiyun     //void cache_sp_buffer        (SmartPtr<SPStatsBufferProxy> buf);
41*4882a593Smuzhiyun     //void return_sp_buffer       ();
42*4882a593Smuzhiyun     //void notify_motion_param(rk_aiq_amd_params_t amd_param);
43*4882a593Smuzhiyun     //void connect_nr_stream (SmartPtr<NrStatsStream> stream);
44*4882a593Smuzhiyun     // from PollCallback
poll_buffer_ready(SmartPtr<VideoBuffer> & buf,int type)45*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)46*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; }
47*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf);
poll_buffer_ready(SmartPtr<V4l2BufferProxy> & buf,int dev_index)48*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)49*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)50*4882a593Smuzhiyun     virtual XCamReturn poll_event_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; }
51*4882a593Smuzhiyun protected:
52*4882a593Smuzhiyun     bool init_tnrbuf            ();
53*4882a593Smuzhiyun     void deinit_tnrbuf          ();
54*4882a593Smuzhiyun     int get_fd_by_index         (uint32_t index);
55*4882a593Smuzhiyun private:
56*4882a593Smuzhiyun     CamHwIsp20* _camHw;
57*4882a593Smuzhiyun     SmartPtr<V4l2SubDevice>  _ispp_dev;
58*4882a593Smuzhiyun     uint32_t _idx_array[64];
59*4882a593Smuzhiyun     int _fd_array[64];
60*4882a593Smuzhiyun     int _buf_num;
61*4882a593Smuzhiyun     bool _fd_init_flag;
62*4882a593Smuzhiyun     std::map<uint32_t, int> _idx_fd_map;
63*4882a593Smuzhiyun     //SmartPtr<TnrProcThread> _proc_thread;
64*4882a593Smuzhiyun     //SmartPtr<NrStatsStream> _nr_stream_unit;
65*4882a593Smuzhiyun     Mutex _list_mutex;
66*4882a593Smuzhiyun };
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun class TnrProcThread
69*4882a593Smuzhiyun     : public Thread
70*4882a593Smuzhiyun {
71*4882a593Smuzhiyun public:
TnrProcThread(TnrStatsStream * handle)72*4882a593Smuzhiyun     TnrProcThread (TnrStatsStream *handle)
73*4882a593Smuzhiyun         : Thread ("TnrProcThread")
74*4882a593Smuzhiyun         , _handle (handle)
75*4882a593Smuzhiyun     {
76*4882a593Smuzhiyun         (void)(_handle);
77*4882a593Smuzhiyun     }
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun protected:
loop()80*4882a593Smuzhiyun     virtual bool loop () {
81*4882a593Smuzhiyun         return  false;//_handle->thread_proc ();
82*4882a593Smuzhiyun     }
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun private:
85*4882a593Smuzhiyun     TnrStatsStream *_handle;
86*4882a593Smuzhiyun };
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun #endif
89