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);
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);
}