xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/hwi/isp20/SPStreamProcUnit.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 _SP_STREAM_PROC_UNIT_H_
18*4882a593Smuzhiyun #define _SP_STREAM_PROC_UNIT_H_
19*4882a593Smuzhiyun #include <v4l2_device.h>
20*4882a593Smuzhiyun #include "poll_thread.h"
21*4882a593Smuzhiyun #include "xcam_mutex.h"
22*4882a593Smuzhiyun #include "TnrStatsStream.h"
23*4882a593Smuzhiyun #include "af_head.h"
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun using namespace XCam;
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun namespace RkCam {
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun enum rkisp_isp_ver {
30*4882a593Smuzhiyun     ISP_V10 = 0x0,
31*4882a593Smuzhiyun     ISP_V11 = 0x1,
32*4882a593Smuzhiyun     ISP_V12 = 0x2,
33*4882a593Smuzhiyun     ISP_V13 = 0x3,
34*4882a593Smuzhiyun     ISP_V20 = 0x4,
35*4882a593Smuzhiyun     ISP_V21 = 0x5,
36*4882a593Smuzhiyun     ISP_V30 = 0x6,
37*4882a593Smuzhiyun     ISP_V32 = 0x7,
38*4882a593Smuzhiyun };
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun class SPImagBufferProxy : public SubV4l2BufferProxy
41*4882a593Smuzhiyun {
42*4882a593Smuzhiyun     public:
SPImagBufferProxy(SmartPtr<V4l2Buffer> & buf,SmartPtr<V4l2Device> & device)43*4882a593Smuzhiyun     explicit SPImagBufferProxy(SmartPtr<V4l2Buffer> &buf, SmartPtr<V4l2Device> &device)
44*4882a593Smuzhiyun              :SubV4l2BufferProxy(buf, device)
45*4882a593Smuzhiyun     {
46*4882a593Smuzhiyun     }
~SPImagBufferProxy()47*4882a593Smuzhiyun     virtual ~SPImagBufferProxy() {}
map()48*4882a593Smuzhiyun     virtual uint8_t *map ()
49*4882a593Smuzhiyun     {
50*4882a593Smuzhiyun         return (uint8_t *)get_v4l2_planar_userptr(0);
51*4882a593Smuzhiyun     }
unmap()52*4882a593Smuzhiyun     virtual bool unmap ()
53*4882a593Smuzhiyun     {
54*4882a593Smuzhiyun         return true;
55*4882a593Smuzhiyun     }
set_buff_fd(int fd)56*4882a593Smuzhiyun     int set_buff_fd(int fd)
57*4882a593Smuzhiyun     {
58*4882a593Smuzhiyun         _buff_fd = fd;
59*4882a593Smuzhiyun         return 0;
60*4882a593Smuzhiyun     }
61*4882a593Smuzhiyun protected:
62*4882a593Smuzhiyun     XCAM_DEAD_COPY (SPImagBufferProxy);
63*4882a593Smuzhiyun };
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun class CamHwIsp20;
66*4882a593Smuzhiyun class SPStreamProcUnit       : public RKStream, public PollCallback
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun public:
69*4882a593Smuzhiyun     explicit SPStreamProcUnit (SmartPtr<V4l2Device> isp_sp_dev, int type, int isp_ver);
70*4882a593Smuzhiyun     virtual ~SPStreamProcUnit ();
71*4882a593Smuzhiyun     virtual void start ();
72*4882a593Smuzhiyun     virtual void stop ();
73*4882a593Smuzhiyun     virtual SmartPtr<VideoBuffer> new_video_buffer(SmartPtr<V4l2Buffer> buf, SmartPtr<V4l2Device> dev);
74*4882a593Smuzhiyun     XCamReturn prepare (CalibDbV2_Af_LdgParam_t *ldg_param, CalibDbV2_Af_HighLightParam_t *highlight, int width = 0, int height = 0, int stride = 0);
75*4882a593Smuzhiyun     void set_devices (CamHwIsp20* camHw, SmartPtr<V4l2SubDevice> isp_core_dev, SmartPtr<V4l2SubDevice> ispp_dev, SmartPtr<V4l2SubDevice> lensdev);
76*4882a593Smuzhiyun     XCamReturn get_sp_resolution(int &width, int &height, int &aligned_w, int &aligned_h);
77*4882a593Smuzhiyun     // from PollCallback
poll_buffer_ready(SmartPtr<VideoBuffer> & buf,int type)78*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)79*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; }
80*4882a593Smuzhiyun     virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf);
poll_buffer_ready(SmartPtr<V4l2BufferProxy> & buf,int dev_index)81*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)82*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)83*4882a593Smuzhiyun     virtual XCamReturn poll_event_failed (int64_t timestamp, const char *msg) { return XCAM_RETURN_ERROR_FAILED; }
84*4882a593Smuzhiyun     void update_af_meas_params(rk_aiq_isp_af_meas_t *sp_meas);
85*4882a593Smuzhiyun     int get_lowpass_fv(uint32_t sequence, SmartPtr<V4l2BufferProxy> buf_proxy);
86*4882a593Smuzhiyun     void set_af_img_size(int w, int h, int w_align, int h_align);
87*4882a593Smuzhiyun protected:
88*4882a593Smuzhiyun     XCAM_DEAD_COPY (SPStreamProcUnit);
89*4882a593Smuzhiyun     bool init_fbcbuf_fd();
90*4882a593Smuzhiyun     bool deinit_fbcbuf_fd();
91*4882a593Smuzhiyun     int get_fd_by_index(int index);
92*4882a593Smuzhiyun protected:
93*4882a593Smuzhiyun     CamHwIsp20* _camHw;
94*4882a593Smuzhiyun     SmartPtr<V4l2SubDevice>  _isp_core_dev;
95*4882a593Smuzhiyun     SmartPtr<V4l2SubDevice> _ispp_dev;
96*4882a593Smuzhiyun     SmartPtr<V4l2SubDevice> _focus_dev;
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun     int _ds_width;
99*4882a593Smuzhiyun     int _ds_height;
100*4882a593Smuzhiyun     int _ds_width_align;
101*4882a593Smuzhiyun     int _ds_height_align;
102*4882a593Smuzhiyun     int _src_width;
103*4882a593Smuzhiyun     int _src_height;
104*4882a593Smuzhiyun     int img_ds_size_x;
105*4882a593Smuzhiyun     int img_ds_size_y;
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun     std::map<int, int> _buf_fd_map;
108*4882a593Smuzhiyun     bool _first;
109*4882a593Smuzhiyun     //SmartPtr<TnrStatsStream> _tnr_stream_unit;
110*4882a593Smuzhiyun     SmartPtr<SubVideoBuffer> _ispgain;
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun     int _isp_ver;
113*4882a593Smuzhiyun     XCam::Mutex _afmeas_param_mutex;
114*4882a593Smuzhiyun     unsigned char ldg_enable;
115*4882a593Smuzhiyun     uint8_t *pAfTmp;
116*4882a593Smuzhiyun     uint32_t sub_shp4_4[RKAIQ_RAWAF_ROI_SUBWINS_NUM];
117*4882a593Smuzhiyun     uint32_t sub_shp8_8[RKAIQ_RAWAF_ROI_SUBWINS_NUM];
118*4882a593Smuzhiyun     uint32_t high_light[RKAIQ_RAWAF_ROI_SUBWINS_NUM];
119*4882a593Smuzhiyun     uint32_t high_light2[RKAIQ_RAWAF_ROI_SUBWINS_NUM];
120*4882a593Smuzhiyun     rk_aiq_af_algo_meas_t _af_meas_params;
121*4882a593Smuzhiyun     rk_aiq_lens_descriptor _lens_des;
122*4882a593Smuzhiyun     int af_img_width;
123*4882a593Smuzhiyun     int af_img_height;
124*4882a593Smuzhiyun     int af_img_width_align;
125*4882a593Smuzhiyun     int af_img_height_align;
126*4882a593Smuzhiyun };
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun }
129*4882a593Smuzhiyun #endif
130*4882a593Smuzhiyun 
131