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 __QCAMERA_HAL_PP_H__
31#define __QCAMERA_HAL_PP_H__
32
33// Camera dependencies
34#include "QCamera2HWI.h"
35#include "QCameraPostProc.h"
36
37// STL dependencies
38#include <unordered_map>
39#include <vector>
40#include <sys/stat.h>
41extern "C" {
42#include "mm_camera_interface.h"
43#include "mm_jpeg_interface.h"
44}
45
46namespace qcamera {
47
48/** halPPBufNotify: function definition for frame notify
49*   handling
50*    @pOutput  : received qcamera_hal_pp_data_t data
51*    @pUserData: user data pointer
52**/
53typedef void (*halPPBufNotify) (qcamera_hal_pp_data_t *pOutput,
54                                        void *pUserData);
55
56/** halPPGetOutput: function definition for get output buffer
57*    @frameIndex: output frame index should match input frame index
58*    @pUserData: user data pointer
59**/
60typedef void (*halPPGetOutput) (uint32_t frameIndex, void *pUserData);
61
62class QCameraHALPP
63{
64public:
65    virtual ~QCameraHALPP();
66    virtual int32_t init(halPPBufNotify bufNotifyCb, halPPGetOutput getOutputCb, void *pUserData, void *pStaticParam) = 0;
67    virtual int32_t init(halPPBufNotify bufNotifyCb, halPPGetOutput getOutputCb, void *pUserData);
68    virtual int32_t deinit();
69    virtual int32_t start();
70    virtual int32_t stop();
71    virtual int32_t flushQ();
72    virtual int32_t initQ();
73    virtual int32_t feedInput(qcamera_hal_pp_data_t *pInputData) = 0;
74    virtual int32_t feedOutput(qcamera_hal_pp_data_t *pOutputData) = 0;
75    virtual int32_t process() = 0;
76
77protected:
78    QCameraHALPP();
79    virtual bool canProcess() = 0;
80    virtual void releaseData(qcamera_hal_pp_data_t *pData);
81    std::vector<qcamera_hal_pp_data_t*>* getFrameVector(uint32_t frameIndex);
82    static void releaseInputDataCb(void *pData, void *pUserData);
83    static void releaseOngoingDataCb(void *pData, void *pUserData);
84    void dumpYUVtoFile(const uint8_t* pBuf, const char *name, ssize_t buf_len);
85
86protected:
87    QCameraQueue m_iuputQ;
88    QCameraQueue m_outgoingQ;
89
90    // hash map with frame index as key, and vecotr of input frames as value
91    std::unordered_map<uint32_t, std::vector<qcamera_hal_pp_data_t*>*> m_frameMap;
92
93    halPPBufNotify m_halPPBufNotifyCB;
94    halPPGetOutput m_halPPGetOutputCB;
95    QCameraPostProcessor *m_pQCameraPostProc;
96}; // QCameraHALPP class
97}; // namespace qcamera
98
99#endif /* __QCAMERA_HAL_PP_H__ */
100
101
102
103