1 /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __MM_CAMERA_MUXER_H__ 31 #define __MM_CAMERA_MUXER_H__ 32 33 // System dependencies 34 #include <media/msmb_camera.h> 35 36 // Camera dependencies 37 #include "cam_intf.h" 38 #include "mm_camera.h" 39 40 /*Frame sync node structure*/ 41 typedef struct mm_frame_sync_queue_node { 42 /*Number of objects*/ 43 uint8_t num_objs; 44 /*Super buffer for different objects*/ 45 mm_camera_super_buf_t super_buf[MAX_OBJS_FOR_FRAME_SYNC]; 46 /*FrameID of these super buffers*/ 47 uint32_t frame_idx; 48 /*Is this matched?*/ 49 uint8_t matched; 50 } mm_frame_sync_queue_node_t; 51 52 53 /*Utility Functions for dual camera*/ 54 uint8_t mm_camera_util_get_index_by_num(uint8_t cam_num, uint32_t handler); 55 uint32_t mm_camera_util_get_handle_by_num(uint8_t num1, uint32_t handle); 56 uint32_t mm_camera_util_generate_handler_by_num(uint8_t cam_num, uint8_t index); 57 const char *mm_camera_util_get_dev_name_by_num(uint8_t cam_num, uint32_t cam_handle); 58 59 /*Function to handle command from client for Auxillary Cameras*/ 60 int32_t mm_camera_muxer_camera_open(uint8_t camera_idx, 61 mm_camera_obj_t *cam_obj); 62 int32_t mm_camera_muxer_query_capability(uint32_t camera_handle, 63 mm_camera_obj_t *cam_obj); 64 int32_t mm_camera_muxer_register_event_notify(uint32_t camera_handle, 65 mm_camera_event_notify_t evt_cb, 66 void *user_data, mm_camera_obj_t *cam_obj); 67 int32_t mm_camera_muxer_close_camera(uint32_t camera_handle, 68 mm_camera_obj_t *cam_obj); 69 int32_t mm_camera_muxer_map_buf(uint32_t camera_handle, uint8_t buf_type, 70 int fd, size_t size, void *buffer, mm_camera_obj_t *cam_obj); 71 int32_t mm_camera_muxer_map_bufs(uint32_t camera_handle, 72 const cam_buf_map_type_list *buf_map_list, 73 mm_camera_obj_t *cam_obj); 74 int32_t mm_camera_muxer_unmap_buf(uint32_t camera_handle, 75 uint8_t buf_type, mm_camera_obj_t *cam_obj); 76 int32_t mm_camera_muxer_set_parms(uint32_t camera_handle, 77 parm_buffer_t *parms, mm_camera_obj_t *cam_obj); 78 int32_t mm_camera_muxer_get_parms(uint32_t camera_handle, 79 parm_buffer_t *parms, mm_camera_obj_t *cam_obj); 80 int32_t mm_camera_muxer_do_auto_focus(uint32_t camera_handle, 81 mm_camera_obj_t *cam_obj); 82 int32_t mm_camera_muxer_cancel_auto_focus(uint32_t camera_handle, 83 mm_camera_obj_t *cam_obj); 84 int32_t mm_camera_muxer_prepare_snapshot(uint32_t camera_handle, 85 int32_t do_af_flag, mm_camera_obj_t *cam_obj); 86 int32_t mm_camera_muxer_start_zsl_snapshot(uint32_t camera_handle, 87 uint32_t ch_id, mm_camera_obj_t *cam_obj); 88 int32_t mm_camera_muxer_stop_zsl_snapshot(uint32_t camera_handle, 89 uint32_t ch_id, mm_camera_obj_t *cam_obj); 90 uint32_t mm_camera_muxer_add_channel(uint32_t camera_handle, 91 mm_camera_channel_attr_t *attr, mm_camera_buf_notify_t channel_cb, 92 void *userdata, uint32_t src_id, mm_camera_obj_t *cam_obj); 93 int32_t mm_camera_muxer_delete_channel(uint32_t camera_handle, uint32_t ch_id, 94 mm_camera_obj_t *cam_obj); 95 int32_t mm_camera_muxer_get_bundle_info(uint32_t camera_handle, uint32_t ch_id, 96 cam_bundle_config_t *bundle_info, mm_camera_obj_t *cam_obj); 97 uint32_t mm_camera_muxer_add_stream(uint32_t camera_handle, 98 uint32_t ch_id, uint32_t src__ch_id, uint32_t src_stream_id, 99 mm_camera_obj_t *cam_obj); 100 int32_t mm_camera_muxer_delete_stream(uint32_t camera_handle, 101 uint32_t ch_id, uint32_t stream_id, 102 mm_camera_obj_t *cam_obj); 103 int32_t mm_camera_muxer_link_stream(uint32_t camera_handle, 104 uint32_t ch_id, uint32_t stream_id, uint32_t linked_ch_id, 105 mm_camera_obj_t *cam_obj); 106 int32_t mm_camera_muxer_config_stream(uint32_t camera_handle, 107 uint32_t ch_id, uint32_t stream_id, mm_camera_stream_config_t *config, 108 mm_camera_obj_t *cam_obj); 109 int32_t mm_camera_muxer_map_stream_buf(uint32_t camera_handle, 110 uint32_t ch_id, uint32_t stream_id, 111 uint8_t buf_type, uint32_t buf_idx, int32_t plane_idx, int fd, 112 size_t size, void *buffer, mm_camera_obj_t *cam_obj); 113 int32_t mm_camera_muxer_map_stream_bufs(uint32_t camera_handle, 114 uint32_t ch_id, const cam_buf_map_type_list *buf_map_list, 115 mm_camera_obj_t *cam_obj); 116 int32_t mm_camera_muxer_unmap_stream_buf(uint32_t camera_handle, 117 uint32_t ch_id, uint32_t stream_id, 118 uint8_t buf_type, uint32_t buf_idx, 119 int32_t plane_idx, mm_camera_obj_t *cam_obj); 120 int32_t mm_camera_muxer_set_stream_parms(uint32_t camera_handle, 121 uint32_t ch_id, uint32_t s_id, cam_stream_parm_buffer_t *parms, 122 mm_camera_obj_t *cam_obj); 123 int32_t mm_camera_muxer_get_stream_parms(uint32_t camera_handle, 124 uint32_t ch_id, uint32_t s_id, cam_stream_parm_buffer_t *parms, 125 mm_camera_obj_t *cam_obj); 126 int32_t mm_camera_muxer_start_channel(uint32_t camera_handle, 127 uint32_t ch_id, mm_camera_obj_t *cam_obj); 128 int32_t mm_camera_muxer_stop_channel(uint32_t camera_handle, 129 uint32_t ch_id, mm_camera_obj_t *cam_obj); 130 int32_t mm_camera_muxer_qbuf(uint32_t camera_handle, uint32_t ch_id, 131 mm_camera_buf_def_t *buf, mm_camera_obj_t *cam_obj); 132 int32_t mm_camera_muxer_get_queued_buf_count(uint32_t camera_handle, 133 uint32_t ch_id, uint32_t stream_id, 134 mm_camera_obj_t *cam_obj); 135 int32_t mm_camera_muxer_request_super_buf(uint32_t ch_id, 136 mm_camera_req_buf_t *buf, mm_camera_obj_t *cam_obj); 137 int32_t mm_camera_muxer_cancel_super_buf_request(uint32_t camera_handle, 138 uint32_t ch_id, 139 mm_camera_obj_t *cam_obj); 140 int32_t mm_camera_muxer_flush_super_buf_queue(uint32_t camera_handle, 141 uint32_t ch_id, 142 uint32_t frame_idx, mm_camera_obj_t *cam_obj); 143 int32_t mm_camera_muxer_configure_notify_mode(uint32_t camera_handle, 144 uint32_t ch_id, mm_camera_super_buf_notify_mode_t notify_mode, 145 mm_camera_obj_t *cam_obj); 146 int32_t mm_camera_muxer_process_advanced_capture(uint32_t camera_handle, 147 uint32_t ch_id, mm_camera_advanced_capture_t type, 148 int8_t start_flag, void *in_value, mm_camera_obj_t *cam_obj); 149 int32_t mm_camera_muxer_get_session_id(uint32_t camera_handle, 150 uint32_t* sessionid, mm_camera_obj_t *cam_obj); 151 int32_t mm_camera_muxer_flush(uint32_t camera_handle, mm_camera_obj_t *cam_obj); 152 int32_t mm_camera_muxer_register_stream_buf_cb(uint32_t camera_handle, 153 uint32_t ch_id, uint32_t stream_id, mm_camera_buf_notify_t buf_cb, 154 mm_camera_stream_cb_type cb_type, void *userdata, mm_camera_obj_t *cam_obj); 155 int32_t mm_camera_muxer_reg_frame_sync(mm_camera_obj_t *cam_obj, 156 uint32_t ch_id, uint32_t stream_id, 157 mm_camera_intf_frame_sync_t *sync_attr); 158 int32_t mm_camera_muxer_set_dual_cam_cmd(uint32_t camera_handle, 159 mm_camera_obj_t *cam_obj); 160 161 /*Muxer internal functions*/ 162 void mm_camera_muxer_stream_frame_sync(mm_camera_super_buf_t *super_buf, 163 void *user_data); 164 void mm_camera_muxer_channel_frame_sync(mm_camera_super_buf_t *super_buf, 165 void *user_data); 166 int32_t mm_camera_muxer_do_frame_sync( 167 mm_frame_sync_queue_t *queue, mm_camera_super_buf_t *buffer, 168 mm_frame_sync_queue_node_t *dispatch_buf); 169 void mm_camera_muxer_buf_done(mm_camera_super_buf_t *buffer); 170 int32_t mm_muxer_frame_sync_queue_init(mm_frame_sync_queue_t *queue); 171 int32_t mm_muxer_frame_sync_queue_deinit(mm_frame_sync_queue_t *queue); 172 int32_t mm_camera_muxer_get_stream_bufs(mm_stream_t *my_obj); 173 int32_t mm_camera_muxer_put_stream_bufs(mm_stream_t *my_obj); 174 int32_t mm_camera_muxer_stream_frame_sync_flush(mm_stream_t *str_obj); 175 int32_t mm_camera_muxer_channel_frame_sync_flush(mm_channel_t *my_obj); 176 mm_frame_sync_queue_node_t *mm_camera_muxer_frame_sync_dequeue( 177 mm_frame_sync_queue_t *queue, uint8_t matched_only); 178 int32_t mm_camera_muxer_channel_req_data_cb(mm_camera_req_buf_t *req_buf, 179 mm_channel_t *ch_obj); 180 int32_t mm_camera_map_stream_buf_ops(uint32_t buf_idx, 181 int32_t plane_idx, int fd, size_t size, 182 void *buffer, cam_mapping_buf_type type, 183 void *userdata); 184 int32_t mm_camera_bundled_map_stream_buf_ops( 185 const cam_buf_map_type_list *buf_map_list, 186 void *userdata); 187 int32_t mm_camera_unmap_stream_buf_ops(uint32_t buf_idx, 188 int32_t plane_idx, cam_mapping_buf_type type, void *userdata); 189 190 #endif /*__MM_CAMERA_MUXER_H */ 191