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 _NR_STATS_STREAM_H_ 18 #define _NR_STATS_STREAM_H_ 19 #include <map> 20 #include "xcam_thread.h" 21 #include "xcam_mutex.h" 22 #include "Stream.h" 23 #include "smart_buffer_priv.h" 24 using namespace XCam; 25 26 namespace RkCam { 27 28 class NrParamProcThread; 29 class NrStatsStream : public RKStream, public PollCallback 30 { 31 public: 32 explicit NrStatsStream (SmartPtr<V4l2Device> dev, int type); 33 virtual ~NrStatsStream (); 34 void start (); 35 void stop (); 36 void set_device (CamHwIsp20* camHw, SmartPtr<V4l2SubDevice> dev); 37 virtual SmartPtr<VideoBuffer> new_video_buffer(SmartPtr<V4l2Buffer> buf, SmartPtr<V4l2Device> dev); 38 int queue_NRImg_fd(int fd, uint32_t frameid); 39 int get_NRImg_fd(uint32_t frameid); 40 // from PollCallback poll_buffer_ready(SmartPtr<VideoBuffer> & buf,int type)41 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 virtual XCamReturn poll_buffer_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; } 43 virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf); poll_buffer_ready(SmartPtr<V4l2BufferProxy> & buf,int dev_index)44 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 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 virtual XCamReturn poll_event_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; } 47 protected: 48 bool init_nrbuf_fd (); 49 bool deinit_nrbuf_fd (); 50 int get_NRimg_fd_by_index(int index); 51 private: 52 SmartPtr<V4l2SubDevice> _ispp_dev; 53 struct v4l2_subdev_format _ispp_fmt; 54 int _fd_array[16]; 55 int _idx_array[16]; 56 int _buf_num; 57 bool _fd_init_flag; 58 //SmartPtr<NrParamProcThread> _proc_thread; 59 Mutex _list_mutex; 60 CamHwIsp20* _camHw; 61 SmartPtr<VideoBuffer> _NrImage; 62 std::map<uint32_t, int> _NrImg_ready_map; 63 }; 64 65 class NrParamProcThread 66 : public Thread 67 { 68 public: NrParamProcThread(NrStatsStream * handle)69 NrParamProcThread (NrStatsStream *handle) 70 : Thread ("NrParamProcThread") 71 , _handle (handle) 72 { 73 (void)(_handle); 74 } 75 76 protected: loop()77 virtual bool loop () { 78 return false;//_handle->thread_proc (); 79 } 80 81 private: 82 NrStatsStream *_handle; 83 }; 84 } 85 #endif 86