summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2018-07-17 17:22:45 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2018-08-03 16:13:03 +0900
commit3e579a1062d4906953cad1f797ad80825c3ea697 (patch)
tree3c07257b01e26088d7eb0d7a829e3f1b72a0b447 /src
parentac1b407783d9d954d4bf51b041d1a52489b2605b (diff)
downloadcamera-3e579a1062d4906953cad1f797ad80825c3ea697.tar.gz
camera-3e579a1062d4906953cad1f797ad80825c3ea697.tar.bz2
camera-3e579a1062d4906953cad1f797ad80825c3ea697.zip
- Add send message function for 2 parameters - Initialize display interface handle when camera handle is created [Version] 0.4.10 [Profile] Common [Issue Type] Update [Dependency module] N/A Change-Id: I2c8bb4a396d9a0e465d7f15f0fdd1bd2d53d85bc Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/camera.c150
1 files changed, 97 insertions, 53 deletions
diff --git a/src/camera.c b/src/camera.c
index d2881e7..5a8e1e7 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -46,6 +46,8 @@ static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
int *ret, int timeout);
static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
int *ret, camera_msg_param *param, int timeout);
+static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
static void _camera_release_imported_bo(tbm_bo *bo);
static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
@@ -666,6 +668,65 @@ static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
}
+static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
+{
+ int func_ret = CAMERA_ERROR_NONE;
+ int send_ret = 0;
+ char *msg = NULL;
+
+ if (!cb_info || !param0 || !param1) {
+ LOGE("invalid ptr %p %p %p : api %d",
+ cb_info, param0, param1, api);
+ func_ret = CAMERA_ERROR_INVALID_PARAMETER;
+ goto _SEND_PARAM2_INT_DONE;
+ }
+
+ /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
+ api,
+ param0->name, param0->value.value_INT,
+ param1->name, param1->value.value_INT);*/
+
+ msg = muse_core_msg_new(api,
+ param0->type, param0->name, param0->value.value_INT,
+ param1->type, param1->name, param1->value.value_INT,
+ NULL);
+ if (!msg) {
+ LOGE("msg failed: api %d", api);
+ func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto _SEND_PARAM2_INT_DONE;
+ }
+
+ /*LOGD("send msg [%s]", msg);*/
+
+ if (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ LOGE("msg send failed");
+
+ func_ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
+ }
+
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+_SEND_PARAM2_INT_DONE:
+ if (ret)
+ *ret = func_ret;
+
+ return;
+}
+
+
int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
{
if (in_format <= MM_PIXEL_FORMAT_INVALID ||
@@ -2387,6 +2448,7 @@ int camera_create(camera_device_e device, camera_h *camera)
if (ret == CAMERA_ERROR_NONE) {
intptr_t handle = 0;
+
muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
if (handle == 0) {
LOGE("Receiving Handle Failed!!");
@@ -2404,7 +2466,18 @@ int camera_create(camera_device_e device, camera_h *camera)
}
LOGD("camera create 0x%x", pc->remote_handle);
+
*camera = (camera_h)pc;
+
+ /* get display interface handle */
+ if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
+ LOGW("display interface init failed");
+
+ /* get default preview format */
+ if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
+ LOGW("get default preview format failed");
+ pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
+ }
} else {
goto ErrorExit;
}
@@ -2520,7 +2593,8 @@ int camera_start_preview(camera_h camera)
return CAMERA_ERROR_INVALID_PARAMETER;
}
- LOGD("Enter");
+ LOGD("Enter : preview format %d, display type %d",
+ pc->cb_info->preview_format, pc->cb_info->dp_type);
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
@@ -2914,13 +2988,13 @@ int camera_cancel_focusing(camera_h camera)
int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
{
int ret = CAMERA_ERROR_NONE;
+ int parent_id = 0;
camera_cli_s *pc = (camera_cli_s *)camera;
camera_cb_info_s *cb_info = NULL;
- muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
camera_state_e current_state = CAMERA_STATE_NONE;
- camera_msg_param param;
- char *msg = NULL;
- int length = 0;
+ camera_msg_param param0;
+ camera_msg_param param1;
+ muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
if (!pc || !pc->cb_info) {
LOGE("NULL handle");
@@ -2950,20 +3024,16 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ
return CAMERA_ERROR_INVALID_STATE;
}
- LOGD("Enter - display : %p", display);
+ LOGD("Enter - type : %d, display : %p", type, display);
- if (type == CAMERA_DISPLAY_TYPE_NONE) {
- LOGD("display type NONE");
- } else {
- /* display interface handle */
+ if (type != CAMERA_DISPLAY_TYPE_NONE) {
+ /* check display interface handle */
if (!cb_info->dp_interface) {
- if (mm_display_interface_init(&cb_info->dp_interface) != MM_ERROR_NONE) {
- LOGE("display interface init failed");
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+ LOGE("display interface not supported");
+ return CAMERA_ERROR_NOT_SUPPORTED;
}
- ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &cb_info->parent_id);
+ ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
if (ret != MM_ERROR_NONE) {
LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
return CAMERA_ERROR_INVALID_OPERATION;
@@ -2998,50 +3068,21 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ
}
}
- if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
- int send_ret = 0;
+ cb_info->parent_id = parent_id;
- length = sizeof(camera_wl_info_s) / sizeof(int) + \
- (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
+ CAMERA_MSG_PARAM_SET(param0, INT, type);
+ CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
- msg = muse_core_msg_new(api,
- MUSE_TYPE_INT, "type", type,
- MUSE_TYPE_INT, "parent_id", cb_info->parent_id,
- NULL);
- if (!msg) {
- LOGE("msg creation failed: api %d", api);
- return CAMERA_ERROR_OUT_OF_MEMORY;
- }
-
- if (pc->cb_info->is_server_connected) {
- __camera_update_api_waiting(pc->cb_info, api, 1);
-
- g_mutex_lock(&pc->cb_info->fd_lock);
- send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
- g_mutex_unlock(&pc->cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- LOGE("message send failed");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
- }
-
- __camera_update_api_waiting(pc->cb_info, api, -1);
+ _camera_msg_send_param2_int(api, cb_info, &ret,
+ &param0, &param1, CAMERA_CB_TIMEOUT);
- muse_core_msg_free(msg);
- } else {
- CAMERA_MSG_PARAM_SET(param, INT, type);
+ if (ret == CAMERA_ERROR_NONE) {
+ pc->cb_info->dp_type = type;
- _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+ if (type == CAMERA_DISPLAY_TYPE_EVAS)
+ SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
}
- if (ret != CAMERA_ERROR_NONE)
- LOGE("set display error 0x%x", ret);
- else if (type == CAMERA_DISPLAY_TYPE_EVAS)
- SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
-
return ret;
}
@@ -3162,6 +3203,9 @@ int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
_camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+ if (ret == CAMERA_ERROR_NONE)
+ pc->cb_info->preview_format = set_format;
+
LOGD("ret : 0x%x", ret);
return ret;