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