Home | History | Annotate | Download | only in inc
      1 /* Copyright (c) 2011-2012, 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 #ifndef ANDROID_HARDWARE_QUALCOMM_CAMERA_USBCAM_H
     30 #define ANDROID_HARDWARE_QUALCOMM_CAMERA_USBCAM_H
     31 
     32 extern "C" {
     33 #include <sys/time.h>
     34 }
     35 
     36 #include "QCameraHWI.h"
     37 
     38 extern "C" {
     39 
     40 /*#include <hardware/camera.h>*/
     41 
     42     int usbcam_get_number_of_cameras();
     43     int usbcam_get_camera_info(int camera_id, struct camera_info *info);
     44 
     45     int usbcam_camera_device_open(const struct hw_module_t* module, const char* id,
     46           struct hw_device_t** device);
     47 
     48     hw_device_t * usbcam_open_camera_device(int cameraId);
     49 
     50     int usbcam_close_camera_device( hw_device_t *);
     51 
     52 namespace android {
     53 
     54     /** Set the ANativeWindow to which preview frames are sent */
     55     int usbcam_set_preview_window(struct camera_device *,
     56           struct preview_stream_ops *window);
     57 
     58     /** Set the notification and data callbacks */
     59     void usbcam_set_CallBacks(struct camera_device *,
     60           camera_notify_callback notify_cb,
     61           camera_data_callback data_cb,
     62           camera_data_timestamp_callback data_cb_timestamp,
     63           camera_request_memory get_memory,
     64           void *user);
     65 
     66     /**
     67      * The following three functions all take a msg_type, which is a bitmask of
     68      * the messages defined in include/ui/Camera.h
     69      */
     70 
     71     /**
     72      * Enable a message, or set of messages.
     73      */
     74     void usbcam_enable_msg_type(struct camera_device *, int32_t msg_type);
     75 
     76     /**
     77      * Disable a message, or a set of messages.
     78      *
     79      * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
     80      * HAL should not rely on its client to call releaseRecordingFrame() to
     81      * release video recording frames sent out by the cameral HAL before and
     82      * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
     83      * clients must not modify/access any video recording frame after calling
     84      * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
     85      */
     86     void usbcam_disable_msg_type(struct camera_device *, int32_t msg_type);
     87 
     88     /**
     89      * Query whether a message, or a set of messages, is enabled.  Note that
     90      * this is operates as an AND, if any of the messages queried are off, this
     91      * will return false.
     92      */
     93     int usbcam_msg_type_enabled(struct camera_device *, int32_t msg_type);
     94 
     95     /**
     96      * Start preview mode.
     97      */
     98     int usbcam_start_preview(struct camera_device *);
     99 
    100     /**
    101      * Stop a previously started preview.
    102      */
    103     void usbcam_stop_preview(struct camera_device *);
    104 
    105     /**
    106      * Returns true if preview is enabled.
    107      */
    108     int usbcam_preview_enabled(struct camera_device *);
    109 
    110     /**
    111      * Request the camera HAL to store meta data or real YUV data in the video
    112      * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
    113      * it is not called, the default camera HAL behavior is to store real YUV
    114      * data in the video buffers.
    115      *
    116      * This method should be called before startRecording() in order to be
    117      * effective.
    118      *
    119      * If meta data is stored in the video buffers, it is up to the receiver of
    120      * the video buffers to interpret the contents and to find the actual frame
    121      * data with the help of the meta data in the buffer. How this is done is
    122      * outside of the scope of this method.
    123      *
    124      * Some camera HALs may not support storing meta data in the video buffers,
    125      * but all camera HALs should support storing real YUV data in the video
    126      * buffers. If the camera HAL does not support storing the meta data in the
    127      * video buffers when it is requested to do do, INVALID_OPERATION must be
    128      * returned. It is very useful for the camera HAL to pass meta data rather
    129      * than the actual frame data directly to the video encoder, since the
    130      * amount of the uncompressed frame data can be very large if video size is
    131      * large.
    132      *
    133      * @param enable if true to instruct the camera HAL to store
    134      *        meta data in the video buffers; false to instruct
    135      *        the camera HAL to store real YUV data in the video
    136      *        buffers.
    137      *
    138      * @return OK on success.
    139      */
    140     int usbcam_store_meta_data_in_buffers(struct camera_device *, int enable);
    141 
    142     /**
    143      * Start record mode. When a record image is available, a
    144      * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding
    145      * frame. Every record frame must be released by a camera HAL client via
    146      * releaseRecordingFrame() before the client calls
    147      * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
    148      * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
    149      * responsibility to manage the life-cycle of the video recording frames,
    150      * and the client must not modify/access any video recording frames.
    151      */
    152     int usbcam_start_recording(struct camera_device *);
    153 
    154     /**
    155      * Stop a previously started recording.
    156      */
    157     void usbcam_stop_recording(struct camera_device *);
    158 
    159     /**
    160      * Returns true if recording is enabled.
    161      */
    162     int usbcam_recording_enabled(struct camera_device *);
    163 
    164     /**
    165      * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
    166      *
    167      * It is camera HAL client's responsibility to release video recording
    168      * frames sent out by the camera HAL before the camera HAL receives a call
    169      * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
    170      * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
    171      * responsibility to manage the life-cycle of the video recording frames.
    172      */
    173     void usbcam_release_recording_frame(struct camera_device *,
    174                   const void *opaque);
    175 
    176     /**
    177      * Start auto focus, the notification callback routine is called with
    178      * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be
    179      * called again if another auto focus is needed.
    180      */
    181     int usbcam_auto_focus(struct camera_device *);
    182 
    183     /**
    184      * Cancels auto-focus function. If the auto-focus is still in progress,
    185      * this function will cancel it. Whether the auto-focus is in progress or
    186      * not, this function will return the focus position to the default.  If
    187      * the camera does not support auto-focus, this is a no-op.
    188      */
    189     int usbcam_cancel_auto_focus(struct camera_device *);
    190 
    191     /**
    192      * Take a picture.
    193      */
    194     int usbcam_take_picture(struct camera_device *);
    195 
    196     /**
    197      * Cancel a picture that was started with takePicture. Calling this method
    198      * when no picture is being taken is a no-op.
    199      */
    200     int usbcam_cancel_picture(struct camera_device *);
    201 
    202     /**
    203      * Set the camera parameters. This returns BAD_VALUE if any parameter is
    204      * invalid or not supported.
    205      */
    206     int usbcam_set_parameters(struct camera_device *, const char *parms);
    207 
    208     //status_t setParameters(const QCameraParameters& params);
    209     /** Retrieve the camera parameters.  The buffer returned by the camera HAL
    210         must be returned back to it with put_parameters, if put_parameters
    211         is not NULL.
    212      */
    213     char* usbcam_get_parameters(struct camera_device *);
    214 
    215     /** The camera HAL uses its own memory to pass us the parameters when we
    216         call get_parameters.  Use this function to return the memory back to
    217         the camera HAL, if put_parameters is not NULL.  If put_parameters
    218         is NULL, then you have to use free() to release the memory.
    219     */
    220     void usbcam_put_parameters(struct camera_device *, char *);
    221 
    222     /**
    223      * Send command to camera driver.
    224      */
    225     int usbcam_send_command(struct camera_device *,
    226               int32_t cmd, int32_t arg1, int32_t arg2);
    227 
    228     /**
    229      * Release the hardware resources owned by this object.  Note that this is
    230      * *not* done in the destructor.
    231      */
    232     void usbcam_release(struct camera_device *);
    233 
    234     /**
    235      * Dump state of the camera hardware
    236      */
    237     int usbcam_dump(struct camera_device *, int fd);
    238 
    239 }; // namespace android
    240 
    241 } //extern "C"
    242 
    243 #endif
    244