};
-int camera_hal_interface_init(camera_hal_interface **h)
+int camera_hal_interface_init(camera_hal_interface **h, const char *hal_name)
{
int ret = CAMERA_ERROR_NONE;
camera_hal_interface *tmp_h = NULL;
+ gchar *path = NULL;
if (h == NULL) {
LOGE("invalid parameter for camera_hal_interface");
}
tmp_h = g_new0(camera_hal_interface, 1);
- if (tmp_h == NULL) {
- LOGE("failed to allocate hal interface");
- return CAMERA_ERROR_OUT_OF_MEMORY;
- }
- tmp_h->dl_handle = dlopen(LIB_TIZEN_CAMERA, RTLD_NOW);
+ if (hal_name)
+ path = g_strdup_printf("%s/%s", PATH_LIBDIR, hal_name);
+ else
+ path = g_strdup_printf("%s", LIB_TIZEN_CAMERA);
+
+ LOGD("HAL path[%s]", path);
+
+ tmp_h->dl_handle = dlopen(path, RTLD_NOW);
if (tmp_h->dl_handle) {
tmp_h->intf.init = dlsym(tmp_h->dl_handle, "camera_init");
tmp_h->intf.deinit = dlsym(tmp_h->dl_handle, "camera_deinit");
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);
ret = CAMERA_ERROR_INTERNAL;
- goto _CAMERA_HAL_INTERFACE_GET_FAILED;
- }
-
- if (tmp_h->intf.init) {
+ } else {
ret = tmp_h->intf.init(&tmp_h->hal_handle);
- if (ret != CAMERA_ERROR_NONE) {
+ if (ret != CAMERA_ERROR_NONE)
LOGE("camera_init failed 0x%x", ret);
- goto _CAMERA_HAL_INTERFACE_GET_FAILED;
- }
- } else {
- LOGE("no camera_init function");
- ret = CAMERA_ERROR_INTERNAL;
- goto _CAMERA_HAL_INTERFACE_GET_FAILED;
}
} else {
- LOGE("dlopen failed [%s][errno %d]", LIB_TIZEN_CAMERA, errno);
+ LOGE("dlopen[%s] failed[%s]", LIB_TIZEN_CAMERA, dlerror());
ret = CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
- goto _CAMERA_HAL_INTERFACE_GET_FAILED;
}
- *h = tmp_h;
-
- return ret;
-
-_CAMERA_HAL_INTERFACE_GET_FAILED:
- if (tmp_h) {
+ if (ret == CAMERA_ERROR_NONE) {
+ LOGI("interface[%p,%p]", tmp_h, tmp_h->dl_handle);
+ *h = tmp_h;
+ } else {
if (tmp_h->dl_handle)
dlclose(tmp_h->dl_handle);
g_free(tmp_h);
}
+ g_free(path);
+
return ret;
}
system_info_get_platform_bool("http://tizen.org/feature/camera", &camera_supported);
- ret = camera_hal_interface_init(&h);
+ ret = camera_hal_interface_init(&h, NULL);
if (ret != CAMERA_ERROR_NONE) {
cout << "camera hal init failed " << ret << endl;
return;
CAMERA_SUPPORT_CHECK;
- ret = camera_hal_interface_init(&hal_handle);
+ ret = camera_hal_interface_init(&hal_handle, NULL);
EXPECT_EQ(ret, CAMERA_ERROR_NONE);
EXPECT_NE(hal_handle, nullptr);