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 
310     /** error_close_camera: function definition for closing
311      *                      the camera backend on an unrecoverable
312      *                      error
313      *    @camera_handle : camera handler
314      *  Return value: 0 -- success
315      *                -1 -- failure
316      **/
317     int32_t (*error_close_camera) (uint32_t camera_handle);
318 
319     /** map_buf: fucntion definition for mapping a camera buffer
320      *           via domain socket
321      *    @camera_handle : camer handler
322      *    @buf_type : type of mapping buffers, can be value of
323      *                CAM_MAPPING_BUF_TYPE_CAPABILITY
324      *                CAM_MAPPING_BUF_TYPE_SETPARM_BUF
325      *                CAM_MAPPING_BUF_TYPE_GETPARM_BUF
326      *    @fd : file descriptor of the stream buffer
327      *    @size :  size of the stream buffer
328      *  Return value: 0 -- success
329      *                -1 -- failure
330      **/
331     int32_t (*map_buf) (uint32_t camera_handle,
332                         uint8_t buf_type,
333                         int fd,
334                         uint32_t size);
335 
336     /** unmap_buf: fucntion definition for unmapping a camera buffer
337      *           via domain socket
338      *    @camera_handle : camer handler
339      *    @buf_type : type of mapping buffers, can be value of
340      *                CAM_MAPPING_BUF_TYPE_CAPABILITY
341      *                CAM_MAPPING_BUF_TYPE_SETPARM_BUF
342      *                CAM_MAPPING_BUF_TYPE_GETPARM_BUF
343      *  Return value: 0 -- success
344      *                -1 -- failure
345      **/
346     int32_t (*unmap_buf) (uint32_t camera_handle,
347                           uint8_t buf_type);
348 
349     /** set_parms: fucntion definition for setting camera
350      *             based parameters to server
351      *    @camera_handle : camer handler
352      *    @parms : batch for parameters to be set, stored in
353      *               parm_buffer_t
354      *  Return value: 0 -- success
355      *                -1 -- failure
356      *  Note: would assume parm_buffer_t is already mapped, and
357      *       according parameter entries to be set are filled in the
358      *       buf before this call
359      **/
360     int32_t (*set_parms) (uint32_t camera_handle,
361                           parm_buffer_t *parms);
362 
363     /** get_parms: fucntion definition for querying camera
364      *             based parameters from server
365      *    @camera_handle : camer handler
366      *    @parms : batch for parameters to be queried, stored in
367      *               parm_buffer_t
368      *  Return value: 0 -- success
369      *                -1 -- failure
370      *  Note: would assume parm_buffer_t is already mapped, and
371      *       according parameter entries to be queried are filled in
372      *       the buf before this call
373      **/
374     int32_t (*get_parms) (uint32_t camera_handle,
375                           parm_buffer_t *parms);
376 
377     /** do_auto_focus: fucntion definition for performing auto focus
378      *    @camera_handle : camer handler
379      *  Return value: 0 -- success
380      *                -1 -- failure
381      *  Note: if this call success, we will always assume there will
382      *        be an auto_focus event following up.
383      **/
384     int32_t (*do_auto_focus) (uint32_t camera_handle);
385 
386     /** cancel_auto_focus: fucntion definition for cancelling
387      *                     previous auto focus request
388      *    @camera_handle : camer handler
389     *  Return value: 0 -- success
390     *                -1 -- failure
391      **/
392     int32_t (*cancel_auto_focus) (uint32_t camera_handle);
393 
394     /** prepare_snapshot: fucntion definition for preparing hardware
395      *                    for snapshot.
396      *    @camera_handle : camer handler
397      *    @do_af_flag    : flag indicating if AF needs to be done
398      *                     0 -- no AF needed
399      *                     1 -- AF needed
400      *  Return value: 0 -- success
401      *                -1 -- failure
402      **/
403     int32_t (*prepare_snapshot) (uint32_t camera_handle,
404                                  int32_t do_af_flag);
405 
406     /** start_zsl_snapshot: function definition for starting
407      *                    zsl snapshot.
408      *    @camera_handle : camer handler
409      *    @ch_id         : channel id
410      *  Return value: 0 -- success
411      *                -1 -- failure
412      **/
413     int32_t (*start_zsl_snapshot) (uint32_t camera_handle, uint32_t ch_id);
414 
415     /** stop_zsl_snapshot: function definition for stopping
416      *                    zsl snapshot.
417      *    @camera_handle : camer handler
418      *    @ch_id         : channel id
419      *  Return value: 0 -- success
420      *                -1 -- failure
421      **/
422     int32_t (*stop_zsl_snapshot) (uint32_t camera_handle, uint32_t ch_id);
423 
424     /** add_channel: fucntion definition for adding a channel
425      *    @camera_handle : camer handler
426      *    @ch_id : channel handler
427      *    @attr : pointer to channel attribute structure
428      *    @channel_cb : callbak to handle bundled super buffer
429      *    @userdata : user data pointer
430      *  Return value: channel id, zero is invalid ch_id
431      * Note: attr, channel_cb, and userdata can be NULL if no
432      *       superbufCB is needed
433      **/
434     uint32_t (*add_channel) (uint32_t camera_handle,
435                              mm_camera_channel_attr_t *attr,
436                              mm_camera_buf_notify_t channel_cb,
437                              void *userdata);
438 
439     /** delete_channel: fucntion definition for deleting a channel
440      *    @camera_handle : camer handler
441      *    @ch_id : channel handler
442      *  Return value: 0 -- success
443      *                -1 -- failure
444      **/
445     int32_t (*delete_channel) (uint32_t camera_handle,
446                                uint32_t ch_id);
447 
448     /** get_bundle_info: function definition for querying bundle
449      *  info of the channel
450      *    @camera_handle : camera handler
451      *    @ch_id         : channel handler
452      *    @bundle_info   : bundle info to be filled in
453      *  Return value: 0 -- success
454      *                -1 -- failure
455      **/
456     int32_t (*get_bundle_info) (uint32_t camera_handle,
457                                 uint32_t ch_id,
458                                 cam_bundle_config_t *bundle_info);
459 
460     /** add_stream: fucntion definition for adding a stream
461      *    @camera_handle : camer handler
462      *    @ch_id : channel handler
463      *  Return value: stream_id. zero is invalid stream_id
464      **/
465     uint32_t (*add_stream) (uint32_t camera_handle,
466                             uint32_t ch_id);
467 
468     /** delete_stream: fucntion definition for deleting a stream
469      *    @camera_handle : camer handler
470      *    @ch_id : channel handler
471      *    @stream_id : stream handler
472      *  Return value: 0 -- success
473      *                -1 -- failure
474      **/
475     int32_t (*delete_stream) (uint32_t camera_handle,
476                               uint32_t ch_id,
477                               uint32_t stream_id);
478 
479     /** config_stream: fucntion definition for configuring a stream
480      *    @camera_handle : camer handler
481      *    @ch_id : channel handler
482      *    @stream_id : stream handler
483      *    @confid : pointer to a stream configuration structure
484      *  Return value: 0 -- success
485      *                -1 -- failure
486      **/
487     int32_t (*config_stream) (uint32_t camera_handle,
488                               uint32_t ch_id,
489                               uint32_t stream_id,
490                               mm_camera_stream_config_t *config);
491 
492     /** map_stream_buf: fucntion definition for mapping
493      *                 stream buffer via domain socket
494      *    @camera_handle : camer handler
495      *    @ch_id : channel handler
496      *    @stream_id : stream handler
497      *    @buf_type : type of mapping buffers, can be value of
498      *             CAM_MAPPING_BUF_TYPE_STREAM_BUF
499      *             CAM_MAPPING_BUF_TYPE_STREAM_INFO
500      *             CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF
501      *    @buf_idx : buffer index within the stream buffers
502      *    @plane_idx : plane index. If all planes share the same fd,
503      *               plane_idx = -1; otherwise, plean_idx is the
504      *               index to plane (0..num_of_planes)
505      *    @fd : file descriptor of the stream buffer
506      *    @size :  size of the stream buffer
507      *  Return value: 0 -- success
508      *                -1 -- failure
509      **/
510     int32_t (*map_stream_buf) (uint32_t camera_handle,
511                                uint32_t ch_id,
512                                uint32_t stream_id,
513                                uint8_t buf_type,
514                                uint32_t buf_idx,
515                                int32_t plane_idx,
516                                int fd,
517                                uint32_t size);
518 
519     /** unmap_stream_buf: fucntion definition for unmapping
520      *                 stream buffer via domain socket
521      *    @camera_handle : camer handler
522      *    @ch_id : channel handler
523      *    @stream_id : stream handler
524      *    @buf_type : type of mapping buffers, can be value of
525      *             CAM_MAPPING_BUF_TYPE_STREAM_BUF
526      *             CAM_MAPPING_BUF_TYPE_STREAM_INFO
527      *             CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF
528      *    @buf_idx : buffer index within the stream buffers
529      *    @plane_idx : plane index. If all planes share the same fd,
530      *               plane_idx = -1; otherwise, plean_idx is the
531      *               index to plane (0..num_of_planes)
532      *  Return value: 0 -- success
533      *                -1 -- failure
534      **/
535     int32_t (*unmap_stream_buf) (uint32_t camera_handle,
536                                  uint32_t ch_id,
537                                  uint32_t stream_id,
538                                  uint8_t buf_type,
539                                  uint32_t buf_idx,
540                                  int32_t plane_idx);
541 
542     /** set_stream_parms: fucntion definition for setting stream
543      *                    specific parameters to server
544      *    @camera_handle : camer handler
545      *    @ch_id : channel handler
546      *    @stream_id : stream handler
547      *    @parms : batch for parameters to be set
548      *  Return value: 0 -- success
549      *                -1 -- failure
550      *  Note: would assume parm buffer is already mapped, and
551      *       according parameter entries to be set are filled in the
552      *       buf before this call
553      **/
554     int32_t (*set_stream_parms) (uint32_t camera_handle,
555                                  uint32_t ch_id,
556                                  uint32_t s_id,
557                                  cam_stream_parm_buffer_t *parms);
558 
559     /** get_stream_parms: fucntion definition for querying stream
560      *                    specific parameters from server
561      *    @camera_handle : camer handler
562      *    @ch_id : channel handler
563      *    @stream_id : stream handler
564      *    @parms : batch for parameters to be queried
565      *  Return value: 0 -- success
566      *                -1 -- failure
567      *  Note: would assume parm buffer is already mapped, and
568      *       according parameter entries to be queried are filled in
569      *       the buf before this call
570      **/
571     int32_t (*get_stream_parms) (uint32_t camera_handle,
572                                  uint32_t ch_id,
573                                  uint32_t s_id,
574                                  cam_stream_parm_buffer_t *parms);
575 
576     /** start_channel: fucntion definition for starting a channel
577      *    @camera_handle : camer handler
578      *    @ch_id : channel handler
579      *  Return value: 0 -- success
580      *                -1 -- failure
581      * This call will start all streams belongs to the channel
582      **/
583     int32_t (*start_channel) (uint32_t camera_handle,
584                               uint32_t ch_id);
585 
586     /** stop_channel: fucntion definition for stopping a channel
587      *    @camera_handle : camer handler
588      *    @ch_id : channel handler
589      *  Return value: 0 -- success
590      *                -1 -- failure
591      * This call will stop all streams belongs to the channel
592      **/
593     int32_t (*stop_channel) (uint32_t camera_handle,
594                              uint32_t ch_id);
595 
596     /** qbuf: fucntion definition for queuing a frame buffer back to
597      *        kernel for reuse
598      *    @camera_handle : camer handler
599      *    @ch_id : channel handler
600      *    @buf : a frame buffer to be queued back to kernel
601      *  Return value: 0 -- success
602      *                -1 -- failure
603      **/
604     int32_t (*qbuf) (uint32_t camera_handle,
605                      uint32_t ch_id,
606                      mm_camera_buf_def_t *buf);
607 
608     /** request_super_buf: fucntion definition for requesting frames
609      *                     from superbuf queue in burst mode
610      *    @camera_handle : camer handler
611      *    @ch_id : channel handler
612      *    @num_buf_requested : number of super buffers requested
613      *    @num_retro_buf_requested : number of retro buffers requested
614      *  Return value: 0 -- success
615      *                -1 -- failure
616      **/
617     int32_t (*request_super_buf) (uint32_t camera_handle,
618                                   uint32_t ch_id,
619                                   uint32_t num_buf_requested,
620                                   uint32_t num_retro_buf_requested);
621 
622     /** cancel_super_buf_request: fucntion definition for canceling
623      *                     frames dispatched from superbuf queue in
624      *                     burst mode
625      *    @camera_handle : camer handler
626      *    @ch_id : channel handler
627      *  Return value: 0 -- success
628      *                -1 -- failure
629      **/
630     int32_t (*cancel_super_buf_request) (uint32_t camera_handle,
631                                          uint32_t ch_id);
632 
633     /** flush_super_buf_queue: function definition for flushing out
634      *                     all frames in the superbuf queue up to frame_idx,
635      *                     even if frames with frame_idx come in later than
636      *                     this call.
637      *    @camera_handle : camer handler
638      *    @ch_id : channel handler
639      *    @frame_idx : frame index up until which all superbufs are flushed
640      *  Return value: 0 -- success
641      *                -1 -- failure
642      **/
643     int32_t (*flush_super_buf_queue) (uint32_t camera_handle,
644                                       uint32_t ch_id, uint32_t frame_idx);
645 
646     /** configure_notify_mode: function definition for configuring the
647      *                         notification mode of channel
648      *    @camera_handle : camera handler
649      *    @ch_id : channel handler
650      *    @notify_mode : notification mode
651      *  Return value: 0 -- success
652      *                -1 -- failure
653      **/
654     int32_t (*configure_notify_mode) (uint32_t camera_handle,
655                                       uint32_t ch_id,
656                                       mm_camera_super_buf_notify_mode_t notify_mode);
657 
658      /** process_advanced_capture: function definition for start/stop advanced capture
659      *                    for snapshot.
660      *    @camera_handle : camera handle
661      *    @type :  advanced capture type.
662      *    @ch_id : channel handler
663      *    @start_flag    : flag indicating if advanced capture needs to be done
664      *                     0 -- stop advanced capture
665      *                     1 -- start advanced capture
666      *  Return value: 0 -- success
667      *                -1 -- failure
668      **/
669      int32_t (*process_advanced_capture) (uint32_t camera_handle,
670                                           mm_camera_advanced_capture_t type,
671                                           uint32_t ch_id,
672                                           int8_t start_flag);
673 } mm_camera_ops_t;
674 
675 /** mm_camera_vtbl_t: virtual table for camera operations
676 *    @camera_handle : camera handler which uniquely identifies a
677 *                   camera object
678 *    @ops : API call table
679 **/
680 typedef struct {
681     uint32_t camera_handle;
682     mm_camera_ops_t *ops;
683 } mm_camera_vtbl_t;
684 
685 /* return number of cameras */
686 uint8_t get_num_of_cameras();
687 
688 /* return reference pointer of camera vtbl */
689 mm_camera_vtbl_t * camera_open(uint8_t camera_idx);
690 
691 /* helper functions */
692 int32_t mm_stream_calc_offset_preview(cam_format_t fmt,
693         cam_dimension_t *dim,
694         cam_stream_buf_plane_info_t *buf_planes);
695 
696 int32_t mm_stream_calc_offset_post_view(cam_format_t fmt,
697         cam_dimension_t *dim,
698         cam_stream_buf_plane_info_t *buf_planes);
699 
700 int32_t mm_stream_calc_offset_snapshot(cam_format_t fmt,
701         cam_dimension_t *dim,
702         cam_padding_info_t *padding,
703         cam_stream_buf_plane_info_t *buf_planes);
704 
705 int32_t mm_stream_calc_offset_raw(cam_format_t fmt,
706         cam_dimension_t *dim,
707         cam_padding_info_t *padding,
708         cam_stream_buf_plane_info_t *buf_planes);
709 
710 int32_t mm_stream_calc_offset_video(cam_dimension_t *dim,
711         cam_stream_buf_plane_info_t *buf_planes);
712 
713 int32_t mm_stream_calc_offset_metadata(cam_dimension_t *dim,
714         cam_padding_info_t *padding,
715         cam_stream_buf_plane_info_t *buf_planes);
716 
717 int32_t mm_stream_calc_offset_postproc(cam_stream_info_t *stream_info,
718         cam_padding_info_t *padding,
719         cam_stream_buf_plane_info_t *buf_planes);
720 
721 struct camera_info *get_cam_info(int camera_id);
722 #endif /*__MM_CAMERA_INTERFACE_H__*/
723