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_SHIMLAYER_H_
31 #define __MM_CAMERA_SHIMLAYER_H_
32 
33 #include "cam_intf.h"
34 
35 /*
36  * MCT shim layer APIs
37  */
38 #define SHIMLAYER_LIB "/system/vendor/lib/libmmcamera2_mct_shimlayer.so"
39 
40 struct cam_shim_packet;
41 
42 /*
43 * Bundled events structure.
44 */
45 typedef struct {
46     uint8_t cmd_count;            /* Total number of events in this packet */
47     struct cam_shim_packet *cmd;  /*Events to process*/
48 } cam_shim_cmd_packet_t;
49 
50 /*
51 * Bundled stream event structure
52 */
53 typedef struct {
54     uint8_t stream_count;                                /*Number of streams in a bundle*/
55     cam_shim_cmd_packet_t stream_event[MAX_NUM_STREAMS]; /*Event for different streams*/
56 } cam_shim_stream_cmd_packet_t;
57 
58 /*
59 * Command types to process in shim layer
60 */
61 typedef enum {
62     CAM_SHIM_SET_PARM,   /*v4l2 set parameter*/
63     CAM_SHIM_GET_PARM,   /*v4l2 get parameter*/
64     CAM_SHIM_REG_BUF,    /*Reg/unreg buffers with back-end*/
65     CAM_SHIM_BUNDLE_CMD, /*Bundled command for streams*/
66 } cam_shim_cmd_type;
67 
68 typedef struct {
69     uint32_t command;    /*V4L2 or private command*/
70     uint32_t stream_id;  /*streamID*/
71     void *value;          /*command value/data*/
72 } cam_shim_cmd_data;
73 
74 /*
75 * Structure to communicate command with shim layer
76 */
77 typedef struct cam_shim_packet {
78     uint32_t session_id;
79     cam_shim_cmd_type cmd_type;                 /*Command type to process*/
80     union {
81         cam_shim_cmd_data cmd_data;             /*get/set parameter structure*/
82         cam_reg_buf_t reg_buf;                  /*Buffer register and unregister*/
83         cam_shim_stream_cmd_packet_t bundle_cmd;/*Bundled command*/
84     };
85 } cam_shim_packet_t;
86 
87 typedef int32_t (*mm_camera_shim_event_handler_func)(uint32_t session_id,
88         cam_event_t *event);
89 
90 typedef struct {
91     cam_status_t (*mm_camera_shim_open_session) (int session,
92             mm_camera_shim_event_handler_func evt_cb);
93     int32_t (*mm_camera_shim_close_session)(int session);
94     int32_t (*mm_camera_shim_send_cmd)(cam_shim_packet_t *event);
95 } mm_camera_shim_ops_t;
96 
97 int32_t (*mm_camera_shim_module_init)(mm_camera_shim_ops_t *shim_ops);
98 
99 #endif  /*__MM_CAMERA_SHIMLAYER_H_*/
100