From: Jeongmo Yang Date: Thu, 21 Feb 2019 07:36:06 +0000 (+0900) Subject: [camera] Add new API - camera_set_user_buffer_fd() X-Git-Tag: accepted/tizen/unified/20190411.144001^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F200292%2F4;p=platform%2Fcore%2Fmultimedia%2Fmm-hal-interface.git [camera] Add new API - camera_set_user_buffer_fd() [Version] 0.0.20 [Profile] Common [Issue Type] Update Change-Id: I803067a2f19ffc894876883f80b5a83c2ee16295 Signed-off-by: Jeongmo Yang --- diff --git a/include/camera/camera_hal_interface.h b/include/camera/camera_hal_interface.h index f55cdb4..69a6c61 100644 --- a/include/camera/camera_hal_interface.h +++ b/include/camera/camera_hal_interface.h @@ -38,6 +38,7 @@ int camera_hal_interface_add_message_callback(camera_hal_interface *h, camera_me int camera_hal_interface_remove_message_callback(camera_hal_interface *h, uint32_t cb_id); int camera_hal_interface_set_preview_stream_format(camera_hal_interface *h, camera_format_t *format); int camera_hal_interface_get_preview_stream_format(camera_hal_interface *h, camera_format_t *format); +int camera_hal_interface_set_user_buffer_fd(camera_hal_interface *h, int *fds, int number); int camera_hal_interface_start_preview(camera_hal_interface *h, camera_preview_frame_cb callback, void *user_data); int camera_hal_interface_release_preview_buffer(camera_hal_interface *h, int buffer_index); int camera_hal_interface_stop_preview(camera_hal_interface *h); diff --git a/include/camera/tizen-camera.h b/include/camera/tizen-camera.h index 3f501b6..d90e664 100644 --- a/include/camera/tizen-camera.h +++ b/include/camera/tizen-camera.h @@ -557,6 +557,7 @@ typedef struct camera_interface { int (*remove_message_callback)(void *camera_handle, uint32_t cb_id); int (*set_preview_stream_format)(void *camera_handle, camera_format_t *format); int (*get_preview_stream_format)(void *camera_handle, camera_format_t *format); + int (*set_user_buffer_fd)(void *camera_handle, int *fds, int number); int (*start_preview)(void *camera_handle, camera_preview_frame_cb callback, void *user_data); int (*release_preview_buffer)(void *camera_handle, int buffer_index); int (*stop_preview)(void *camera_handle); @@ -711,6 +712,22 @@ int camera_set_preview_stream_format(void *camera_handle, camera_format_t *forma int camera_get_preview_stream_format(void *camera_handle, camera_format_t *format); /** + * @brief Sets the buffer fd from user for preview buffer. + * @since_tizen 5.5 + * @param[in] camera_handle The handle to the camera HAL + * @param[in] fds The array of buffer fd + * @param[in] number The number of buffer + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported + * @pre The camera state must be set to #CAMERA_STATE_OPENED. + * @see camera_start_preview() + */ +int camera_set_user_buffer_fd(void *camera_handle, int *fds, int number); + +/** * @brief Starts preview frames on the screen. * @since_tizen 3.0 * @param[in] camera_handle The handle to the camera HAL diff --git a/packaging/mm-hal-interface.spec b/packaging/mm-hal-interface.spec index f58cb24..424cf14 100755 --- a/packaging/mm-hal-interface.spec +++ b/packaging/mm-hal-interface.spec @@ -1,6 +1,6 @@ Name: mm-hal-interface Summary: Multimedia HAL Interface -Version: 0.0.19 +Version: 0.0.20 Release: 0 Group: Multimedia/Development License: Apache-2.0 diff --git a/src/camera/camera_hal_interface.c b/src/camera/camera_hal_interface.c index ebc92dc..882158a 100644 --- a/src/camera/camera_hal_interface.c +++ b/src/camera/camera_hal_interface.c @@ -85,6 +85,7 @@ int camera_hal_interface_init(camera_hal_interface **h) tmp_h->intf.set_command = dlsym(tmp_h->dl_handle, "camera_set_command"); tmp_h->intf.get_command = dlsym(tmp_h->dl_handle, "camera_get_command"); tmp_h->intf.set_batch_command = dlsym(tmp_h->dl_handle, "camera_set_batch_command"); + tmp_h->intf.set_user_buffer_fd = dlsym(tmp_h->dl_handle, "camera_set_user_buffer_fd"); if (tmp_h->intf.init == NULL || tmp_h->intf.deinit == NULL) { LOGE("could not get mandatory function. %p %p", tmp_h->intf.init, tmp_h->intf.deinit); @@ -155,439 +156,367 @@ int camera_hal_interface_deinit(camera_hal_interface *h) int camera_hal_interface_get_device_info_list(camera_hal_interface *h, camera_device_info_list_t *device_info_list) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.get_device_info_list) { - ret = h->intf.get_device_info_list(device_info_list); - } else { + if (!h->intf.get_device_info_list) { LOGE("camera_get_device_info_list not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.get_device_info_list(device_info_list); } int camera_hal_interface_open_device(camera_hal_interface *h, int device_index) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.open_device) { - ret = h->intf.open_device(h->hal_handle, device_index); - } else { + if (!h->intf.open_device) { LOGE("camera_open_device not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.open_device(h->hal_handle, device_index); } int camera_hal_interface_close_device(camera_hal_interface *h) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.close_device) { - ret = h->intf.close_device(h->hal_handle); - } else { + if (!h->intf.close_device) { LOGE("camera_close_device not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.close_device(h->hal_handle); } int camera_hal_interface_add_message_callback(camera_hal_interface *h, camera_message_cb callback, void *user_data, uint32_t *cb_id) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.add_message_callback) { - ret = h->intf.add_message_callback(h->hal_handle, callback, user_data, cb_id); - } else { + if (!h->intf.add_message_callback) { LOGE("camera_add_message_callback not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.add_message_callback(h->hal_handle, callback, user_data, cb_id); } int camera_hal_interface_remove_message_callback(camera_hal_interface *h, uint32_t cb_id) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.remove_message_callback) { - ret = h->intf.remove_message_callback(h->hal_handle, cb_id); - } else { + if (!h->intf.remove_message_callback) { LOGE("camera_remove_message_callback not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.remove_message_callback(h->hal_handle, cb_id); } int camera_hal_interface_set_preview_stream_format(camera_hal_interface *h, camera_format_t *format) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.set_preview_stream_format) { - ret = h->intf.set_preview_stream_format(h->hal_handle, format); - } else { + if (!h->intf.set_preview_stream_format) { LOGE("camera_set_preview_stream_format not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.set_preview_stream_format(h->hal_handle, format); } int camera_hal_interface_get_preview_stream_format(camera_hal_interface *h, camera_format_t *format) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.get_preview_stream_format) { - ret = h->intf.get_preview_stream_format(h->hal_handle, format); - } else { + if (!h->intf.get_preview_stream_format) { LOGE("camera_get_preview_stream_format not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.get_preview_stream_format(h->hal_handle, format); } -int camera_hal_interface_start_preview(camera_hal_interface *h, camera_preview_frame_cb callback, void *user_data) +int camera_hal_interface_set_user_buffer_fd(camera_hal_interface *h, int *fds, int number) { - int ret = CAMERA_ERROR_NONE; + if (h == NULL) { + LOGE("NULL interface"); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + if (!h->intf.set_user_buffer_fd) { + LOGE("camera_set_user_buffer_fd not implemented"); + return CAMERA_ERROR_NOT_IMPLEMENTED; + } + + return h->intf.set_user_buffer_fd(h->hal_handle, fds, number); +} + +int camera_hal_interface_start_preview(camera_hal_interface *h, camera_preview_frame_cb callback, void *user_data) +{ if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.start_preview) { - ret = h->intf.start_preview(h->hal_handle, callback, user_data); - } else { + if (!h->intf.start_preview) { LOGE("camera_start_preview not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.start_preview(h->hal_handle, callback, user_data); } int camera_hal_interface_release_preview_buffer(camera_hal_interface *h, int buffer_index) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.release_preview_buffer) { - ret = h->intf.release_preview_buffer(h->hal_handle, buffer_index); - } else { + if (!h->intf.release_preview_buffer) { LOGE("camera_release_preview_buffer not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.release_preview_buffer(h->hal_handle, buffer_index); } int camera_hal_interface_stop_preview(camera_hal_interface *h) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.stop_preview) { - ret = h->intf.stop_preview(h->hal_handle); - } else { + if (!h->intf.stop_preview) { LOGE("camera_stop_preview not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.stop_preview(h->hal_handle); } int camera_hal_interface_start_auto_focus(camera_hal_interface *h) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.start_auto_focus) { - ret = h->intf.start_auto_focus(h->hal_handle); - } else { + if (!h->intf.start_auto_focus) { LOGE("camera_start_auto_focus not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.start_auto_focus(h->hal_handle); } int camera_hal_interface_stop_auto_focus(camera_hal_interface *h) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.stop_auto_focus) { - ret = h->intf.stop_auto_focus(h->hal_handle); - } else { + if (!h->intf.stop_auto_focus) { LOGE("camera_stop_auto_focus not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.stop_auto_focus(h->hal_handle); } int camera_hal_interface_start_capture(camera_hal_interface *h, camera_capture_cb callback, void *user_data) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.start_capture) { - ret = h->intf.start_capture(h->hal_handle, callback, user_data); - } else { + if (!h->intf.start_capture) { LOGE("camera_start_capture not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.start_capture(h->hal_handle, callback, user_data); } int camera_hal_interface_stop_capture(camera_hal_interface *h) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.stop_capture) { - ret = h->intf.stop_capture(h->hal_handle); - } else { + if (!h->intf.stop_capture) { LOGE("camera_stop_capture not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.stop_capture(h->hal_handle); } int camera_hal_interface_set_video_stream_format(camera_hal_interface *h, camera_format_t *format) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.set_video_stream_format) { - ret = h->intf.set_video_stream_format(h->hal_handle, format); - } else { + if (!h->intf.set_video_stream_format) { LOGE("camera_set_video_stream_format not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.set_video_stream_format(h->hal_handle, format); } int camera_hal_interface_get_video_stream_format(camera_hal_interface *h, camera_format_t *format) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.get_video_stream_format) { - ret = h->intf.get_video_stream_format(h->hal_handle, format); - } else { + if (!h->intf.get_video_stream_format) { LOGE("camera_get_video_stream_format not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.get_video_stream_format(h->hal_handle, format); } int camera_hal_interface_start_record(camera_hal_interface *h, camera_video_frame_cb callback, void *user_data) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.start_record) { - ret = h->intf.start_record(h->hal_handle, callback, user_data); - } else { + if (!h->intf.start_record) { LOGE("camera_start_record not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.start_record(h->hal_handle, callback, user_data); } int camera_hal_interface_release_video_buffer(camera_hal_interface *h, int buffer_index) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.release_video_buffer) { - ret = h->intf.release_video_buffer(h->hal_handle, buffer_index); - } else { + if (!h->intf.release_video_buffer) { LOGE("camera_release_video_buffer not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.release_video_buffer(h->hal_handle, buffer_index); } int camera_hal_interface_stop_record(camera_hal_interface *h) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.stop_record) { - ret = h->intf.stop_record(h->hal_handle); - } else { + if (!h->intf.stop_record) { LOGE("camera_stop_record not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.stop_record(h->hal_handle); } int camera_hal_interface_set_command(camera_hal_interface *h, int64_t command, void *value) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.set_command) { - ret = h->intf.set_command(h->hal_handle, command, value); - } else { + if (!h->intf.set_command) { LOGE("camera_set_command not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.set_command(h->hal_handle, command, value); } int camera_hal_interface_get_command(camera_hal_interface *h, int64_t command, void **value) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.get_command) { - ret = h->intf.get_command(h->hal_handle, command, value); - } else { + if (!h->intf.get_command) { LOGE("camera_get_command not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.get_command(h->hal_handle, command, value); } int camera_hal_interface_set_batch_command(camera_hal_interface *h, camera_batch_command_control_t *batch_command, int64_t *error_command) { - int ret = CAMERA_ERROR_NONE; - if (h == NULL) { LOGE("NULL interface"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (h->intf.set_batch_command) { - ret = h->intf.set_batch_command(h->hal_handle, batch_command, error_command); - } else { + if (!h->intf.set_batch_command) { LOGE("camera_set_batch_command not implemented"); - ret = CAMERA_ERROR_NOT_IMPLEMENTED; + return CAMERA_ERROR_NOT_IMPLEMENTED; } - return ret; + return h->intf.set_batch_command(h->hal_handle, batch_command, error_command); }