1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (c) 2021 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 _RAW_STREAM_CAP_UNIT_H_ 18*4882a593Smuzhiyun #define _RAW_STREAM_CAP_UNIT_H_ 19*4882a593Smuzhiyun #include <map> 20*4882a593Smuzhiyun #include <v4l2_device.h> 21*4882a593Smuzhiyun #include "poll_thread.h" 22*4882a593Smuzhiyun #include "xcam_mutex.h" 23*4882a593Smuzhiyun #include "Stream.h" 24*4882a593Smuzhiyun #include "smart_buffer_priv.h" 25*4882a593Smuzhiyun using namespace XCam; 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun namespace RkCam { 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun class RawStreamProcUnit; 30*4882a593Smuzhiyun class RawStreamCapUnit : public PollCallback 31*4882a593Smuzhiyun { 32*4882a593Smuzhiyun public: 33*4882a593Smuzhiyun explicit RawStreamCapUnit (); 34*4882a593Smuzhiyun explicit RawStreamCapUnit (const rk_sensor_full_info_t *s_info, bool linked_to_isp, int tx_buf_cnt); 35*4882a593Smuzhiyun virtual ~RawStreamCapUnit (); 36*4882a593Smuzhiyun virtual XCamReturn start(int mode); 37*4882a593Smuzhiyun virtual XCamReturn stop (); 38*4882a593Smuzhiyun void set_working_mode(int mode); 39*4882a593Smuzhiyun void set_devices(SmartPtr<V4l2SubDevice> ispdev, CamHwIsp20* handle, RawStreamProcUnit *proc); 40*4882a593Smuzhiyun void set_tx_devices(SmartPtr<V4l2Device> mipi_tx_devs[3]); 41*4882a593Smuzhiyun SmartPtr<V4l2Device> get_tx_device (int index); 42*4882a593Smuzhiyun XCamReturn set_tx_format(const struct v4l2_subdev_format& sns_sd_fmt, uint32_t sns_v4l_pix_fmt); 43*4882a593Smuzhiyun XCamReturn set_tx_format(const struct v4l2_subdev_selection& sns_sd_sel, uint32_t sns_v4l_pix_fmt); 44*4882a593Smuzhiyun XCamReturn prepare(int idx); 45*4882a593Smuzhiyun void prepare_cif_mipi(); 46*4882a593Smuzhiyun void skip_frames(int skip_num, int32_t skip_seq); 47*4882a593Smuzhiyun // from PollCallback poll_buffer_ready(SmartPtr<VideoBuffer> & buf,int type)48*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)49*4882a593Smuzhiyun virtual XCamReturn poll_buffer_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; } poll_buffer_ready(SmartPtr<VideoBuffer> & buf)50*4882a593Smuzhiyun virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf) { return XCAM_RETURN_ERROR_FAILED; } 51*4882a593Smuzhiyun virtual XCamReturn poll_buffer_ready (SmartPtr<V4l2BufferProxy> &buf, int dev_index); poll_event_ready(uint32_t sequence,int type)52*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)53*4882a593Smuzhiyun virtual XCamReturn poll_event_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; } setCamPhyId(int phyId)54*4882a593Smuzhiyun void setCamPhyId(int phyId) { 55*4882a593Smuzhiyun mCamPhyId = phyId; 56*4882a593Smuzhiyun } setSensorCategory(bool sensorState)57*4882a593Smuzhiyun void setSensorCategory(bool sensorState) { 58*4882a593Smuzhiyun _is_1608_stream = sensorState; 59*4882a593Smuzhiyun } 60*4882a593Smuzhiyun XCamReturn reset_hardware(); 61*4882a593Smuzhiyun XCamReturn set_csi_mem_word_big_align(uint32_t width, uint32_t height, uint32_t sns_v4l_pix_fmt, int8_t sns_bpp); 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun enum { 64*4882a593Smuzhiyun ISP_MIPI_HDR_S = 0, 65*4882a593Smuzhiyun ISP_MIPI_HDR_M, 66*4882a593Smuzhiyun ISP_MIPI_HDR_L, 67*4882a593Smuzhiyun ISP_MIPI_HDR_MAX, 68*4882a593Smuzhiyun }; 69*4882a593Smuzhiyun enum RawCapState { 70*4882a593Smuzhiyun RAW_CAP_STATE_INVALID, 71*4882a593Smuzhiyun RAW_CAP_STATE_INITED, 72*4882a593Smuzhiyun RAW_CAP_STATE_PREPARED, 73*4882a593Smuzhiyun RAW_CAP_STATE_STARTED, 74*4882a593Smuzhiyun RAW_CAP_STATE_STOPPED, 75*4882a593Smuzhiyun }; 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun protected: 78*4882a593Smuzhiyun XCAM_DEAD_COPY (RawStreamCapUnit); 79*4882a593Smuzhiyun XCamReturn sync_raw_buf(SmartPtr<V4l2BufferProxy> &buf_s, SmartPtr<V4l2BufferProxy> &buf_m, SmartPtr<V4l2BufferProxy> &buf_l); 80*4882a593Smuzhiyun bool check_skip_frame(int32_t buf_seq); 81*4882a593Smuzhiyun int mCamPhyId; 82*4882a593Smuzhiyun bool _is_1608_stream; 83*4882a593Smuzhiyun protected: 84*4882a593Smuzhiyun SmartPtr<V4l2Device> _dev[3]; 85*4882a593Smuzhiyun SmartPtr<V4l2Device> _dev_bakup[3]; 86*4882a593Smuzhiyun int _dev_index[3]; 87*4882a593Smuzhiyun SmartPtr<RKStream> _stream[3]; 88*4882a593Smuzhiyun Mutex _buf_mutex; 89*4882a593Smuzhiyun int _working_mode; 90*4882a593Smuzhiyun int _mipi_dev_max; 91*4882a593Smuzhiyun int _skip_num; 92*4882a593Smuzhiyun int64_t _skip_to_seq; 93*4882a593Smuzhiyun Mutex _mipi_mutex; 94*4882a593Smuzhiyun enum RawCapState _state; 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun SafeList<V4l2BufferProxy> buf_list[3]; 97*4882a593Smuzhiyun CamHwIsp20* _camHw; 98*4882a593Smuzhiyun SmartPtr<V4l2SubDevice> _isp_core_dev; 99*4882a593Smuzhiyun RawStreamProcUnit *_proc_stream; 100*4882a593Smuzhiyun // 101*4882a593Smuzhiyun SafeList<V4l2BufferProxy> _NrImg_ready_list; 102*4882a593Smuzhiyun }; 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun } 105*4882a593Smuzhiyun #endif 106*4882a593Smuzhiyun 107