13d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
23d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *
33d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * Redistribution and use in source and binary forms, with or without
43d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * modification, are permitted provided that the following conditions are
53d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * met:
63d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *     * Redistributions of source code must retain the above copyright
73d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *       notice, this list of conditions and the following disclaimer.
83d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *     * Redistributions in binary form must reproduce the above
93d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *       copyright notice, this list of conditions and the following
103d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *       disclaimer in the documentation and/or other materials provided
113d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *       with the distribution.
123d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *     * Neither the name of The Linux Foundation nor the names of its
133d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *       contributors may be used to endorse or promote products derived
143d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *       from this software without specific prior written permission.
153d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *
163d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
173d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
183d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
193d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
203d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
213d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
223d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
233d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
243d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
253d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
263d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel *
283d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel */
293d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
303d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#ifndef __MM_CAMERA_SHIMLAYER_H_
313d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#define __MM_CAMERA_SHIMLAYER_H_
323d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
333d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#include "cam_intf.h"
343d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
353d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel/*
363d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * MCT shim layer APIs
373d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel */
383d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#define SHIMLAYER_LIB "/system/vendor/lib/libmmcamera2_mct_shimlayer.so"
393d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
403d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelstruct cam_shim_packet;
413d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
423d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel/*
433d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel* Bundled events structure.
443d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel*/
453d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct {
463d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    uint8_t cmd_count;            /* Total number of events in this packet */
473d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    struct cam_shim_packet *cmd;  /*Events to process*/
483d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} cam_shim_cmd_packet_t;
493d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
503d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel/*
513d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel* Bundled stream event structure
523d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel*/
533d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct {
543d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    uint8_t stream_count;                                /*Number of streams in a bundle*/
553d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    cam_shim_cmd_packet_t stream_event[MAX_NUM_STREAMS]; /*Event for different streams*/
563d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} cam_shim_stream_cmd_packet_t;
573d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
583d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel/*
593d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel* Command types to process in shim layer
603d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel*/
613d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef enum {
623d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    CAM_SHIM_SET_PARM,   /*v4l2 set parameter*/
633d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    CAM_SHIM_GET_PARM,   /*v4l2 get parameter*/
643d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    CAM_SHIM_REG_BUF,    /*Reg/unreg buffers with back-end*/
653d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    CAM_SHIM_BUNDLE_CMD, /*Bundled command for streams*/
663d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} cam_shim_cmd_type;
673d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
683d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct {
693d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    uint32_t command;    /*V4L2 or private command*/
703d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    uint32_t stream_id;  /*streamID*/
713d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    void *value;          /*command value/data*/
723d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} cam_shim_cmd_data;
733d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
743d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel/*
753d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel* Structure to communicate command with shim layer
763d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel*/
773d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct cam_shim_packet {
783d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    uint32_t session_id;
793d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    cam_shim_cmd_type cmd_type;                 /*Command type to process*/
803d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    union {
813d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel        cam_shim_cmd_data cmd_data;             /*get/set parameter structure*/
823d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel        cam_reg_buf_t reg_buf;                  /*Buffer register and unregister*/
833d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel        cam_shim_stream_cmd_packet_t bundle_cmd;/*Bundled command*/
843d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    };
853d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} cam_shim_packet_t;
863d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
873d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef int32_t (*mm_camera_shim_event_handler_func)(uint32_t session_id,
883d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel        cam_event_t *event);
893d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
903d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct {
913d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    cam_status_t (*mm_camera_shim_open_session) (int session,
923d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel            mm_camera_shim_event_handler_func evt_cb);
933d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    int32_t (*mm_camera_shim_close_session)(int session);
943d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel    int32_t (*mm_camera_shim_send_cmd)(cam_shim_packet_t *event);
953d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} mm_camera_shim_ops_t;
963d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
973d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelint32_t (*mm_camera_shim_module_init)(mm_camera_shim_ops_t *shim_ops);
983d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel
993d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#endif  /*__MM_CAMERA_SHIMLAYER_H_*/
100