1 /* Copyright (c) 2012-2013, 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_INTERFACE_H__
31 #define __MM_CAMERA_INTERFACE_H__
32 #include <linux/msm_ion.h>
33 #include <linux/videodev2.h>
34 #include <media/msmb_camera.h>
35 #include "cam_intf.h"
36 #include "cam_queue.h"
37 
38 #define MM_CAMERA_MAX_NUM_SENSORS MSM_MAX_CAMERA_SENSORS
39 #define MM_CAMERA_MAX_NUM_FRAMES CAM_MAX_NUM_BUFS_PER_STREAM
40 /* num of channels allowed in a camera obj */
41 #define MM_CAMERA_CHANNEL_MAX 16
42 
43 #define PAD_TO_SIZE(size, padding) ((size + padding - 1) & ~(padding - 1))
44 
45 /** mm_camera_buf_def_t: structure for stream frame buf
46 *    @stream_id : stream handler to uniquely identify a stream
47 *               object
48 *    @buf_idx : index of the buf within the stream bufs, to be
49 *               filled during mem allocation
50 *    @timespec_ts : time stamp, to be filled when DQBUF is
51 *                 called
52 *    @frame_idx : frame sequence num, to be filled when DQBUF
53 *    @num_planes : num of planes for the frame buffer, to be
54 *               filled during mem allocation
55 *    @planes : plane info for the frame buffer, to be filled
56 *               during mem allocation
57 *    @fd : file descriptor of the frame buffer, to be filled
58 *        during mem allocation
59 *    @buffer : pointer to the frame buffer, to be filled during
60 *            mem allocation
61 *    @frame_len : length of the whole frame, to be filled during
62 *               mem allocation
63 *    @mem_info : user specific pointer to additional mem info
64 **/
65 typedef struct {
66     uint32_t stream_id;
67     cam_stream_type_t stream_type;
68     int8_t buf_idx;
69     uint8_t is_uv_subsampled;
70     struct timespec ts;
71     uint32_t frame_idx;
72     int8_t num_planes;
73     struct v4l2_plane planes[VIDEO_MAX_PLANES];
74     int fd;
75     void *buffer;
76     uint32_t frame_len;
77     void *mem_info;
78 } mm_camera_buf_def_t;
79 
80 /** mm_camera_super_buf_t: super buf structure for bundled
81 *   stream frames
82 *    @camera_handle : camera handler to uniquely identify
83 *              a camera object
84 *    @ch_id : channel handler to uniquely ideentify a channel
85 *           object
86 *    @num_bufs : number of buffers in the super buf, should not
87 *              exceeds MAX_STREAM_NUM_IN_BUNDLE
88 *    @bufs : array of buffers in the bundle
89 **/
90 typedef struct {
91     uint32_t camera_handle;
92     uint32_t ch_id;
93     uint8_t num_bufs;
94     uint8_t bUnlockAEC;
95     uint8_t bReadyForPrepareSnapshot;
96     mm_camera_buf_def_t* bufs[MAX_STREAM_NUM_IN_BUNDLE];
97 } mm_camera_super_buf_t;
98 
99 /** mm_camera_event_t: structure for event
100 *    @server_event_type : event type from serer
101 *    @status : status of an event, value could be
102 *              CAM_STATUS_SUCCESS
103 *              CAM_STATUS_FAILED
104 **/
105 typedef struct {
106     cam_event_type_t server_event_type;
107     uint32_t status;
108 } mm_camera_event_t;
109 
110 /** mm_camera_event_notify_t: function definition for event
111 *   notify handling
112 *    @camera_handle : camera handler
113 *    @evt : pointer to an event struct
114 *    @user_data: user data pointer
115 **/
116 typedef void (*mm_camera_event_notify_t)(uint32_t camera_handle,
117                                          mm_camera_event_t *evt,
118                                          void *user_data);
119 
120 /** mm_camera_buf_notify_t: function definition for frame notify
121 *   handling
122 *    @mm_camera_super_buf_t : received frame buffers
123 *    @user_data: user data pointer
124 **/
125 typedef void (*mm_camera_buf_notify_t) (mm_camera_super_buf_t *bufs,
126                                         void *user_data);
127 
128 /** map_stream_buf_op_t: function definition for operation of
129 *   mapping stream buffers via domain socket
130 *    @frame_idx : buffer index within stream buffers
131 *    @plane_idx    : plane index. If all planes share the same
132 *                   fd, plane_idx = -1; otherwise, plean_idx is
133 *                   the index to plane (0..num_of_planes)
134 *    @fd : file descriptor of the stream buffer
135 *    @size: size of the stream buffer
136 *    @userdata : user data pointer
137 **/
138 typedef int32_t (*map_stream_buf_op_t) (uint32_t frame_idx,
139                                         int32_t plane_idx,
140                                         int fd,
141                                         uint32_t size,
142                                         void *userdata);
143 
144 /** unmap_stream_buf_op_t: function definition for operation of
145 *                          unmapping stream buffers via domain
146 *                          socket
147 *    @frame_idx : buffer index within stream buffers
148 *    @plane_idx : plane index. If all planes share the same
149 *                 fd, plane_idx = -1; otherwise, plean_idx is
150 *                 the index to plane (0..num_of_planes)
151 *    @userdata : user data pointer
152 **/
153 typedef int32_t (*unmap_stream_buf_op_t) (uint32_t frame_idx,
154                                           int32_t plane_idx,
155                                           void *userdata);
156 
157 /** mm_camera_map_unmap_ops_tbl_t: virtual table
158 *                      for mapping/unmapping stream buffers via
159 *                      domain socket
160 *    @map_ops : operation for mapping
161 *    @unmap_ops : operation for unmapping
162 *    @userdata: user data pointer
163 **/
164 typedef struct {
165     map_stream_buf_op_t map_ops;
166     unmap_stream_buf_op_t unmap_ops;
167     void *userdata;
168 } mm_camera_map_unmap_ops_tbl_t;
169 
170 /** mm_camera_stream_mem_vtbl_t: virtual table for stream
171 *                      memory allocation and deallocation
172 *    @get_bufs : function definition for allocating
173 *                stream buffers
174 *    @put_bufs : function definition for deallocating
175 *                stream buffers
176 *    @user_data: user data pointer
177 **/
178 typedef struct {
179   void *user_data;
180   int32_t (*get_bufs) (cam_frame_len_offset_t *offset,
181                        uint8_t *num_bufs,
182                        uint8_t **initial_reg_flag,
183                        mm_camera_buf_def_t **bufs,
184                        mm_camera_map_unmap_ops_tbl_t *ops_tbl,
185                        void *user_data);
186   int32_t (*put_bufs) (mm_camera_map_unmap_ops_tbl_t *ops_tbl,
187                        void *user_data);
188   int32_t (*invalidate_buf)(int index, void *user_data);
189   int32_t (*clean_invalidate_buf)(int index, void *user_data);
190 } mm_camera_stream_mem_vtbl_t;
191 
192 /** mm_camera_stream_config_t: structure for stream
193 *                              configuration
194 *    @stream_info : pointer to a stream info structure
195 *    @padding_info: padding info obtained from querycapability
196 *    @mem_tbl : memory operation table for
197 *              allocating/deallocating stream buffers
198 *    @stream_cb : callback handling stream frame notify
199 *    @userdata : user data pointer
200 **/
201 typedef struct {
202     cam_stream_info_t *stream_info;
203     cam_padding_info_t padding_info;
204     mm_camera_stream_mem_vtbl_t mem_vtbl;
205     mm_camera_buf_notify_t stream_cb;
206     void *userdata;
207 } mm_camera_stream_config_t;
208 
209 /** mm_camera_super_buf_notify_mode_t: enum for super uffer
210 *                                      notification mode
211 *    @MM_CAMERA_SUPER_BUF_NOTIFY_BURST :
212 *       ZSL use case: get burst of frames
213 *    @MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS :
214 *       get continuous frames: when the super buf is ready
215 *       dispatch it to HAL
216 **/
217 typedef enum {
218     MM_CAMERA_SUPER_BUF_NOTIFY_BURST = 0,
219     MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS,
220     MM_CAMERA_SUPER_BUF_NOTIFY_MAX
221 } mm_camera_super_buf_notify_mode_t;
222 
223 /** mm_camera_super_buf_priority_t: enum for super buffer
224 *                                   matching priority
225 *    @MM_CAMERA_SUPER_BUF_PRIORITY_NORMAL :
226 *       Save the frame no matter focused or not. Currently only
227 *       this type is supported.
228 *    @MM_CAMERA_SUPER_BUF_PRIORITY_FOCUS :
229 *       only queue the frame that is focused. Will enable meta
230 *       data header to carry focus info
231 *    @MM_CAMERA_SUPER_BUF_PRIORITY_EXPOSURE_BRACKETING :
232 *       after shutter, only queue matched exposure index
233 **/
234 typedef enum {
235     MM_CAMERA_SUPER_BUF_PRIORITY_NORMAL = 0,
236     MM_CAMERA_SUPER_BUF_PRIORITY_FOCUS,
237     MM_CAMERA_SUPER_BUF_PRIORITY_EXPOSURE_BRACKETING,
238     MM_CAMERA_SUPER_BUF_PRIORITY_MAX
239 } mm_camera_super_buf_priority_t;
240 
241 /** mm_camera_advanced_capture_t: enum for advanced capture type.
242 *    @MM_CAMERA_AF_BRACKETING :
243 *       to enable AF Bracketig.
244 *    @MM_CAMERA_AE_BRACKETING :
245 *       to enable AF Bracketing.
246 *    @MM_CAMERA_FLASH_BRACKETING :
247 *       to enable Flash Bracketing.
248 *    @MM_CAMERA_ZOOM_1X :
249 *       to enable zoom 1x capture request
250 **/
251 typedef enum {
252    MM_CAMERA_AF_BRACKETING = 0,
253    MM_CAMERA_AE_BRACKETING,
254    MM_CAMERA_FLASH_BRACKETING,
255    MM_CAMERA_ZOOM_1X,
256 } mm_camera_advanced_capture_t;
257 
258 /** mm_camera_channel_attr_t: structure for defining channel
259 *                             attributes
260 *    @notify_mode : notify mode: burst or continuous
261 *    @water_mark : queue depth. Only valid for burst mode
262 *    @look_back : look back how many frames from last buf.
263 *                 Only valid for burst mode
264 *    @post_frame_skip : after send first frame to HAL, how many
265 *                     frames needing to be skipped for next
266 *                     delivery. Only valid for burst mode
267 *    @max_unmatched_frames : max number of unmatched frames in
268 *                     queue
269 *    @priority : save matched priority frames only
270 **/
271 typedef struct {
272     mm_camera_super_buf_notify_mode_t notify_mode;
273     uint8_t water_mark;
274     uint8_t look_back;
275     uint8_t post_frame_skip;
276     uint8_t max_unmatched_frames;
277     mm_camera_super_buf_priority_t priority;
278 } mm_camera_channel_attr_t;
279 
280 typedef struct {
281     /** query_capability: fucntion definition for querying static
282      *                    camera capabilities
283      *    @camera_handle : camer handler
284      *  Return value: 0 -- success
285      *                -1 -- failure
286      *  Note: would assume cam_capability_t is already mapped
287      **/
288     int32_t (*query_capability) (uint32_t camera_handle);
289 
290     /** register_event_notify: fucntion definition for registering
291      *                         for event notification
292      *    @camera_handle : camer handler
293      *    @evt_cb : callback for event notify
294      *    @user_data : user data poiner
295      *  Return value: 0 -- success
296      *                -1 -- failure
297      **/
298     int32_t (*register_event_notify) (uint32_t camera_handle,
299                                       mm_camera_event_notify_t evt_cb,
300                                       void *user_data);
301 
302     /** close_camera: fucntion definition for closing a camera
303      *    @camera_handle : camer handler
304      *  Return value: 0 -- success
305      *                -1 -- failure
306      **/
307     int32_t (*close_camera) (uint32_t camera_handle);
308 
309     /** map_buf: fucntion definition for mapping a camera buffer
310      *           via domain socket
311      *    @camera_handle : camer handler
312      *    @buf_type : type of mapping buffers, can be value of
313      *                CAM_MAPPING_BUF_TYPE_CAPABILITY
314      *                CAM_MAPPING_BUF_TYPE_SETPARM_BUF
315      *                CAM_MAPPING_BUF_TYPE_GETPARM_BUF
316      *    @fd : file descriptor of the stream buffer
317      *    @size :  size of the stream buffer
318      *  Return value: 0 -- success
319      *                -1 -- failure
320      **/
321     int32_t (*map_buf) (uint32_t camera_handle,
322                         uint8_t buf_type,
323                         int fd,
324                         uint32_t size);
325 
326     /** unmap_buf: fucntion definition for unmapping a camera buffer
327      *           via domain socket
328      *    @camera_handle : camer handler
329      *    @buf_type : type of mapping buffers, can be value of
330      *                CAM_MAPPING_BUF_TYPE_CAPABILITY
331      *                CAM_MAPPING_BUF_TYPE_SETPARM_BUF
332      *                CAM_MAPPING_BUF_TYPE_GETPARM_BUF
333      *  Return value: 0 -- success
334      *                -1 -- failure
335      **/
336     int32_t (*unmap_buf) (uint32_t camera_handle,
337                           uint8_t buf_type);
338 
339     /** set_parms: fucntion definition for setting camera
340      *             based parameters to server
341      *    @camera_handle : camer handler
342      *    @parms : batch for parameters to be set, stored in
343      *               parm_buffer_t
344      *  Return value: 0 -- success
345      *                -1 -- failure
346      *  Note: would assume parm_buffer_t is already mapped, and
347      *       according parameter entries to be set are filled in the
348      *       buf before this call
349      **/
350     int32_t (*set_parms) (uint32_t camera_handle,
351                           parm_buffer_t *parms);
352 
353     /** get_parms: fucntion definition for querying camera
354      *             based parameters from server
355      *    @camera_handle : camer handler
356      *    @parms : batch for parameters to be queried, stored in
357      *               parm_buffer_t
358      *  Return value: 0 -- success
359      *                -1 -- failure
360      *  Note: would assume parm_buffer_t is already mapped, and
361      *       according parameter entries to be queried are filled in
362      *       the buf before this call
363      **/
364     int32_t (*get_parms) (uint32_t camera_handle,
365                           parm_buffer_t *parms);
366 
367     /** do_auto_focus: fucntion definition for performing auto focus
368      *    @camera_handle : camer handler
369      *  Return value: 0 -- success
370      *                -1 -- failure
371      *  Note: if this call success, we will always assume there will
372      *        be an auto_focus event following up.
373      **/
374     int32_t (*do_auto_focus) (uint32_t camera_handle);
375 
376     /** cancel_auto_focus: fucntion definition for cancelling
377      *                     previous auto focus request
378      *    @camera_handle : camer handler
379     *  Return value: 0 -- success
380     *                -1 -- failure
381      **/
382     int32_t (*cancel_auto_focus) (uint32_t camera_handle);
383 
384     /** prepare_snapshot: fucntion definition for preparing hardware
385      *                    for snapshot.
386      *    @camera_handle : camer handler
387      *    @do_af_flag    : flag indicating if AF needs to be done
388      *                     0 -- no AF needed
389      *                     1 -- AF needed
390      *  Return value: 0 -- success
391      *                -1 -- failure
392      **/
393     int32_t (*prepare_snapshot) (uint32_t camera_handle,
394                                  int32_t do_af_flag);
395 
396     /** start_zsl_snapshot: function definition for starting
397      *                    zsl snapshot.
398      *    @camera_handle : camer handler
399      *    @ch_id         : channel id
400      *  Return value: 0 -- success
401      *                -1 -- failure
402      **/
403     int32_t (*start_zsl_snapshot) (uint32_t camera_handle, uint32_t ch_id);
404 
405     /** stop_zsl_snapshot: function definition for stopping
406      *                    zsl snapshot.
407      *    @camera_handle : camer handler
408      *    @ch_id         : channel id
409      *  Return value: 0 -- success
410      *                -1 -- failure
411      **/
412     int32_t (*stop_zsl_snapshot) (uint32_t camera_handle, uint32_t ch_id);
413 
414     /** add_channel: fucntion definition for adding a channel
415      *    @camera_handle : camer handler
416      *    @ch_id : channel handler
417      *    @attr : pointer to channel attribute structure
418      *    @channel_cb : callbak to handle bundled super buffer
419      *    @userdata : user data pointer
420      *  Return value: channel id, zero is invalid ch_id
421      * Note: attr, channel_cb, and userdata can be NULL if no
422      *       superbufCB is needed
423      **/
424     uint32_t (*add_channel) (uint32_t camera_handle,
425                              mm_camera_channel_attr_t *attr,
426                              mm_camera_buf_notify_t channel_cb,
427                              void *userdata);
428 
429     /** delete_channel: fucntion definition for deleting a channel
430      *    @camera_handle : camer handler
431      *    @ch_id : channel handler
432      *  Return value: 0 -- success
433      *                -1 -- failure
434      **/
435     int32_t (*delete_channel) (uint32_t camera_handle,
436                                uint32_t ch_id);
437 
438     /** get_bundle_info: function definition for querying bundle
439      *  info of the channel
440      *    @camera_handle : camera handler
441      *    @ch_id         : channel handler
442      *    @bundle_info   : bundle info to be filled in
443      *  Return value: 0 -- success
444      *                -1 -- failure
445      **/
446     int32_t (*get_bundle_info) (uint32_t camera_handle,
447                                 uint32_t ch_id,
448                                 cam_bundle_config_t *bundle_info);
449 
450     /** add_stream: fucntion definition for adding a stream
451      *    @camera_handle : camer handler
452      *    @ch_id : channel handler
453      *  Return value: stream_id. zero is invalid stream_id
454      **/
455     uint32_t (*add_stream) (uint32_t camera_handle,
456                             uint32_t ch_id);
457 
458     /** delete_stream: fucntion definition for deleting a stream
459      *    @camera_handle : camer handler
460      *    @ch_id : channel handler
461      *    @stream_id : stream handler
462      *  Return value: 0 -- success
463      *                -1 -- failure
464      **/
465     int32_t (*delete_stream) (uint32_t camera_handle,
466                               uint32_t ch_id,
467                               uint32_t stream_id);
468 
469     /** config_stream: fucntion definition for configuring a stream
470      *    @camera_handle : camer handler
471      *    @ch_id : channel handler
472      *    @stream_id : stream handler
473      *    @confid : pointer to a stream configuration structure
474      *  Return value: 0 -- success
475      *                -1 -- failure
476      **/
477     int32_t (*config_stream) (uint32_t camera_handle,
478                               uint32_t ch_id,
479                               uint32_t stream_id,
480                               mm_camera_stream_config_t *config);
481 
482     /** map_stream_buf: fucntion definition for mapping
483      *                 stream buffer via domain socket
484      *    @camera_handle : camer handler
485      *    @ch_id : channel handler
486      *    @stream_id : stream handler
487      *    @buf_type : type of mapping buffers, can be value of
488      *             CAM_MAPPING_BUF_TYPE_STREAM_BUF
489      *             CAM_MAPPING_BUF_TYPE_STREAM_INFO
490      *             CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF
491      *    @buf_idx : buffer index within the stream buffers
492      *    @plane_idx : plane index. If all planes share the same fd,
493      *               plane_idx = -1; otherwise, plean_idx is the
494      *               index to plane (0..num_of_planes)
495      *    @fd : file descriptor of the stream buffer
496      *    @size :  size of the stream buffer
497      *  Return value: 0 -- success
498      *                -1 -- failure
499      **/
500     int32_t (*map_stream_buf) (uint32_t camera_handle,
501                                uint32_t ch_id,
502                                uint32_t stream_id,
503                                uint8_t buf_type,
504                                uint32_t buf_idx,
505                                int32_t plane_idx,
506                                int fd,
507                                uint32_t size);
508 
509     /** unmap_stream_buf: fucntion definition for unmapping
510      *                 stream buffer via domain socket
511      *    @camera_handle : camer handler
512      *    @ch_id : channel handler
513      *    @stream_id : stream handler
514      *    @buf_type : type of mapping buffers, can be value of
515      *             CAM_MAPPING_BUF_TYPE_STREAM_BUF
516      *             CAM_MAPPING_BUF_TYPE_STREAM_INFO
517      *             CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF
518      *    @buf_idx : buffer index within the stream buffers
519      *    @plane_idx : plane index. If all planes share the same fd,
520      *               plane_idx = -1; otherwise, plean_idx is the
521      *               index to plane (0..num_of_planes)
522      *  Return value: 0 -- success
523      *                -1 -- failure
524      **/
525     int32_t (*unmap_stream_buf) (uint32_t camera_handle,
526                                  uint32_t ch_id,
527                                  uint32_t stream_id,
528                                  uint8_t buf_type,
529                                  uint32_t buf_idx,
530                                  int32_t plane_idx);
531 
532     /** set_stream_parms: fucntion definition for setting stream
533      *                    specific parameters to server
534      *    @camera_handle : camer handler
535      *    @ch_id : channel handler
536      *    @stream_id : stream handler
537      *    @parms : batch for parameters to be set
538      *  Return value: 0 -- success
539      *                -1 -- failure
540      *  Note: would assume parm buffer is already mapped, and
541      *       according parameter entries to be set are filled in the
542      *       buf before this call
543      **/
544     int32_t (*set_stream_parms) (uint32_t camera_handle,
545                                  uint32_t ch_id,
546                                  uint32_t s_id,
547                                  cam_stream_parm_buffer_t *parms);
548 
549     /** get_stream_parms: fucntion definition for querying stream
550      *                    specific parameters from server
551      *    @camera_handle : camer handler
552      *    @ch_id : channel handler
553      *    @stream_id : stream handler
554      *    @parms : batch for parameters to be queried
555      *  Return value: 0 -- success
556      *                -1 -- failure
557      *  Note: would assume parm buffer is already mapped, and
558      *       according parameter entries to be queried are filled in
559      *       the buf before this call
560      **/
561     int32_t (*get_stream_parms) (uint32_t camera_handle,
562                                  uint32_t ch_id,
563                                  uint32_t s_id,
564                                  cam_stream_parm_buffer_t *parms);
565 
566     /** start_channel: fucntion definition for starting a channel
567      *    @camera_handle : camer handler
568      *    @ch_id : channel handler
569      *  Return value: 0 -- success
570      *                -1 -- failure
571      * This call will start all streams belongs to the channel
572      **/
573     int32_t (*start_channel) (uint32_t camera_handle,
574                               uint32_t ch_id);
575 
576     /** stop_channel: fucntion definition for stopping a channel
577      *    @camera_handle : camer handler
578      *    @ch_id : channel handler
579      *  Return value: 0 -- success
580      *                -1 -- failure
581      * This call will stop all streams belongs to the channel
582      **/
583     int32_t (*stop_channel) (uint32_t camera_handle,
584                              uint32_t ch_id);
585 
586     /** qbuf: fucntion definition for queuing a frame buffer back to
587      *        kernel for reuse
588      *    @camera_handle : camer handler
589      *    @ch_id : channel handler
590      *    @buf : a frame buffer to be queued back to kernel
591      *  Return value: 0 -- success
592      *                -1 -- failure
593      **/
594     int32_t (*qbuf) (uint32_t camera_handle,
595                      uint32_t ch_id,
596                      mm_camera_buf_def_t *buf);
597 
598     /** request_super_buf: fucntion definition for requesting frames
599      *                     from superbuf queue in burst mode
600      *    @camera_handle : camer handler
601      *    @ch_id : channel handler
602      *    @num_buf_requested : number of super buffers requested
603      *    @num_retro_buf_requested : number of retro buffers requested
604      *  Return value: 0 -- success
605      *                -1 -- failure
606      **/
607     int32_t (*request_super_buf) (uint32_t camera_handle,
608                                   uint32_t ch_id,
609                                   uint32_t num_buf_requested,
610                                   uint32_t num_retro_buf_requested);
611 
612     /** cancel_super_buf_request: fucntion definition for canceling
613      *                     frames dispatched from superbuf queue in
614      *                     burst mode
615      *    @camera_handle : camer handler
616      *    @ch_id : channel handler
617      *  Return value: 0 -- success
618      *                -1 -- failure
619      **/
620     int32_t (*cancel_super_buf_request) (uint32_t camera_handle,
621                                          uint32_t ch_id);
622 
623     /** flush_super_buf_queue: function definition for flushing out
624      *                     all frames in the superbuf queue up to frame_idx,
625      *                     even if frames with frame_idx come in later than
626      *                     this call.
627      *    @camera_handle : camer handler
628      *    @ch_id : channel handler
629      *    @frame_idx : frame index up until which all superbufs are flushed
630      *  Return value: 0 -- success
631      *                -1 -- failure
632      **/
633     int32_t (*flush_super_buf_queue) (uint32_t camera_handle,
634                                       uint32_t ch_id, uint32_t frame_idx);
635 
636     /** configure_notify_mode: function definition for configuring the
637      *                         notification mode of channel
638      *    @camera_handle : camera handler
639      *    @ch_id : channel handler
640      *    @notify_mode : notification mode
641      *  Return value: 0 -- success
642      *                -1 -- failure
643      **/
644     int32_t (*configure_notify_mode) (uint32_t camera_handle,
645                                       uint32_t ch_id,
646                                       mm_camera_super_buf_notify_mode_t notify_mode);
647 
648      /** process_advanced_capture: function definition for start/stop advanced capture
649      *                    for snapshot.
650      *    @camera_handle : camera handle
651      *    @type :  advanced capture type.
652      *    @ch_id : channel handler
653      *    @start_flag    : flag indicating if advanced capture needs to be done
654      *                     0 -- stop advanced capture
655      *                     1 -- start advanced capture
656      *  Return value: 0 -- success
657      *                -1 -- failure
658      **/
659      int32_t (*process_advanced_capture) (uint32_t camera_handle,
660                                           mm_camera_advanced_capture_t type,
661                                           uint32_t ch_id,
662                                           int8_t start_flag);
663 } mm_camera_ops_t;
664 
665 /** mm_camera_vtbl_t: virtual table for camera operations
666 *    @camera_handle : camera handler which uniquely identifies a
667 *                   camera object
668 *    @ops : API call table
669 **/
670 typedef struct {
671     uint32_t camera_handle;
672     mm_camera_ops_t *ops;
673 } mm_camera_vtbl_t;
674 
675 /* return number of cameras */
676 uint8_t get_num_of_cameras();
677 
678 /* return reference pointer of camera vtbl */
679 mm_camera_vtbl_t * camera_open(uint8_t camera_idx);
680 
681 /* helper functions */
682 int32_t mm_stream_calc_offset_preview(cam_format_t fmt,
683         cam_dimension_t *dim,
684         cam_stream_buf_plane_info_t *buf_planes);
685 
686 int32_t mm_stream_calc_offset_post_view(cam_format_t fmt,
687         cam_dimension_t *dim,
688         cam_stream_buf_plane_info_t *buf_planes);
689 
690 int32_t mm_stream_calc_offset_snapshot(cam_format_t fmt,
691         cam_dimension_t *dim,
692         cam_padding_info_t *padding,
693         cam_stream_buf_plane_info_t *buf_planes);
694 
695 int32_t mm_stream_calc_offset_raw(cam_format_t fmt,
696         cam_dimension_t *dim,
697         cam_padding_info_t *padding,
698         cam_stream_buf_plane_info_t *buf_planes);
699 
700 int32_t mm_stream_calc_offset_video(cam_dimension_t *dim,
701         cam_stream_buf_plane_info_t *buf_planes);
702 
703 int32_t mm_stream_calc_offset_metadata(cam_dimension_t *dim,
704         cam_padding_info_t *padding,
705         cam_stream_buf_plane_info_t *buf_planes);
706 
707 int32_t mm_stream_calc_offset_postproc(cam_stream_info_t *stream_info,
708         cam_padding_info_t *padding,
709         cam_stream_buf_plane_info_t *buf_planes);
710 
711 struct camera_info *get_cam_info(int camera_id);
712 #endif /*__MM_CAMERA_INTERFACE_H__*/
713