#include <hal/hal-common.h>
#include "hal-device-display-interface.h"
+#include "hal-device-display-ipc.h"
+#include "hal-device-display-passthrough.h"
+
#include "common.h"
-static hal_backend_device_display_funcs *hal_device_display_funcs = NULL;
+static enum hal_common_transport g_hal_transport = HAL_TRANSPORT;
int hal_device_display_get_backend(void)
{
- int ret;
-
- if (hal_device_display_funcs)
- return 0;
-
- hal_device_display_funcs = calloc(1, sizeof(hal_backend_device_display_funcs));
- if (!hal_device_display_funcs)
- return -ENOMEM;
-
- ret = hal_common_get_backend(HAL_MODULE_DEVICE_DISPLAY, (void **)&hal_device_display_funcs);
- if (ret < 0) {
- _E("Failed to get device-display backend");
- free(hal_device_display_funcs);
- hal_device_display_funcs = NULL;
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_backend();
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_backend();
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
}
-
- return 0;
}
int hal_device_display_put_backend(void)
{
- int ret = 0;
-
- if (!hal_device_display_funcs)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_put_backend();
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_put_backend();
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- ret = hal_common_put_backend(HAL_MODULE_DEVICE_DISPLAY, (void *)hal_device_display_funcs);
- if (ret < 0) {
- _E("Failed to put device-display backend");
- return ret;
}
-
- free(hal_device_display_funcs);
- hal_device_display_funcs = NULL;
-
- return 0;
}
int hal_device_display_get_max_brightness(int *brightness)
{
- int ret = 0;
-
if (!brightness)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_max_brightness)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_max_brightness(brightness);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_max_brightness(brightness);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_max_brightness(brightness);
+ }
}
int hal_device_display_get_brightness(int *brightness)
{
- int ret = 0;
-
if (!brightness)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_brightness)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_brightness(brightness);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_brightness(brightness);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_brightness(brightness);
+ }
}
int hal_device_display_set_brightness(int brightness)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_brightness)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_set_brightness(brightness);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_brightness(brightness);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_brightness(brightness);
+ }
}
int hal_device_display_set_multi_brightness(int brightness, int step, int delay)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_multi_brightness)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_passthrough_set_multi_brightness(brightness, step, delay);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_multi_brightness(brightness, step, delay);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_multi_brightness(brightness, step, delay);
+ }
}
int hal_device_display_get_auto_brightness(float lmax, float lmin, float light, int *brightness)
{
- int ret = 0;
-
- if (!brightness)
- return -EINVAL;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_auto_brightness)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_auto_brightness(lmax, lmin, light, brightness);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_auto_brightness(lmax, lmin, light, brightness);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_auto_brightness(lmax, lmin, light, brightness);
+ }
}
int hal_device_display_get_state(hal_device_display_state_e *state)
{
- int ret = 0;
-
if (!state)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_state)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_state(state);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_state(state);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_state(state);
+ }
}
int hal_device_display_set_state(hal_device_display_state_e state)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_state)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_set_state(state);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_state(state);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_state(state);
+ }
}
int hal_device_display_get_image_effect(hal_device_display_image_effect_e *effect)
{
- int ret = 0;
-
if (!effect)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_image_effect)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_image_effect(effect);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_image_effect(effect);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_image_effect(effect);
+ }
}
int hal_device_display_set_image_effect(hal_device_display_image_effect_e effect)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_image_effect)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_set_image_effect(effect);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_image_effect(effect);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_image_effect(effect);
+ }
}
int hal_device_display_get_panel_mode(hal_device_display_panel_mode_e *mode)
{
- int ret = 0;
-
if (!mode)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_panel_mode)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_panel_mode(mode);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_panel_mode(mode);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_panel_mode(mode);
+ }
}
int hal_device_display_set_panel_mode(hal_device_display_panel_mode_e mode)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_panel_mode)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_set_panel_mode(mode);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_panel_mode(mode);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_panel_mode(mode);
+ }
}
int hal_device_display_get_aod_mode(hal_device_display_aod_mode_e *mode)
{
- int ret = 0;
-
if (!mode)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_aod_mode)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_aod_mode(mode);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_aod_mode(mode);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_aod_mode(mode);
+ }
}
int hal_device_display_get_aod_brightness(int *max, int *normal, int *min, int *charging)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!max ||!normal ||!min ||!charging)
+ return -EINVAL;
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_aod_brightness)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_aod_brightness(max, normal, min, charging);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_aod_brightness(max, normal, min, charging);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_aod_brightness(max, normal, min, charging);
+ }
}
int hal_device_display_get_max_frame_rate(int *rate)
{
- int ret = 0;
-
if (!rate)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_max_frame_rate)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_max_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_max_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_max_frame_rate(rate);
+ }
}
int hal_device_display_get_min_frame_rate(int *rate)
{
- int ret = 0;
-
if (!rate)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_min_frame_rate)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_min_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_min_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_min_frame_rate(rate);
+ }
}
int hal_device_display_get_frame_rate(int *rate)
{
- int ret = 0;
-
if (!rate)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_frame_rate)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_frame_rate(rate);
+ }
}
int hal_device_display_set_frame_rate(int rate)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_frame_rate)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_set_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_frame_rate(rate);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_frame_rate(rate);
+ }
}
int hal_device_display_set_white_balance(hal_device_display_white_balance_e white_balance_type, int value)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_white_balance)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_set_white_balance(white_balance_type, value);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_white_balance(white_balance_type, value);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_white_balance(white_balance_type, value);
+ }
}
int hal_device_display_get_white_balance(hal_device_display_white_balance_e white_balance_type, int* value)
{
- int ret = 0;
-
if (!value)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_white_balance)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_white_balance(white_balance_type, value);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_white_balance(white_balance_type, value);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_white_balance(white_balance_type, value);
+ }
}
int hal_device_display_get_rotation_angle(int display_index, hal_device_display_rotation_angle_e *angle)
{
- int ret = 0;
-
if (!angle)
return -EINVAL;
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_rotation_angle)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_get_rotation_angle(display_index, angle);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_get_rotation_angle(display_index, angle);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->get_rotation_angle(display_index, angle);
+ }
}
int hal_device_display_set_rotation_angle(int display_index,
hal_device_display_rotation_angle_e angle,
hal_device_display_rotation_direction_e direction)
{
- int ret = 0;
-
- if (!hal_device_display_funcs) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
- if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_rotation_angle)
+ switch (g_hal_transport) {
+ case HAL_COMMON_TRANSPORT_IPC:
+ return hal_device_display_ipc_set_rotation_angle(display_index, angle, direction);
+ case HAL_COMMON_TRANSPORT_PASSTHROUGH:
+ return hal_device_display_passthrough_set_rotation_angle(display_index, angle, direction);
+ case HAL_COMMON_TRANSPORT_UNKNOWN:
+ default:
return -ENOTSUP;
-
- return hal_device_display_funcs->set_rotation_angle(display_index, angle, direction);
-}
+ }
+}
\ No newline at end of file