summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungjae Cho <y0.cho@samsung.com>2019-10-18 10:53:34 +0900
committerYoungjae Cho <y0.cho@samsung.com>2019-10-18 10:59:09 +0900
commit13b595176f25fc8a42b59aeae518703613270bcb (patch)
tree466667c7153513ea0c9163169ea4bcb7e2104af8
parent0ee8b0a3fd8001d5743816ca4d4d675440303de1 (diff)
downloaddevice-manager-plugin-odroid-13b595176f25fc8a42b59aeae518703613270bcb.tar.gz
device-manager-plugin-odroid-13b595176f25fc8a42b59aeae518703613270bcb.tar.bz2
device-manager-plugin-odroid-13b595176f25fc8a42b59aeae518703613270bcb.zip
Add dummy display HAL
Change-Id: I6fa9b2f13594d8097a1d3051e8948e4daa9150bf Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
-rw-r--r--hw/display/display.c67
1 files changed, 65 insertions, 2 deletions
diff --git a/hw/display/display.c b/hw/display/display.c
index 8869ec9..5fd0e68 100644
--- a/hw/display/display.c
+++ b/hw/display/display.c
@@ -17,24 +17,87 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <errno.h>
#include <hw/display.h>
+#define DUMMY_MAX_BRIGHTNESS 100
+
+static enum display_state dummy_state;
+static int dummy_brightness;
+
+static int dummy_display_get_max_brightness(int *val)
+{
+ if (!val)
+ return -EINVAL;
+
+ *val = DUMMY_MAX_BRIGHTNESS;
+ return 0;
+}
+
+static int dummy_display_get_brightness(int *brightness)
+{
+ if (!brightness)
+ return -EINVAL;
+
+ *brightness = dummy_brightness;
+ return 0;
+}
+
+static int dummy_display_set_brightness(int brightness)
+{
+ if (brightness < 0 || brightness > DUMMY_MAX_BRIGHTNESS)
+ return -EINVAL;
+
+ dummy_brightness = brightness;
+ return 0;
+}
+
+static int dummy_display_get_state(enum display_state *state)
+{
+ *state = dummy_state;
+ return 0;
+}
+
+static int dummy_display_set_state(enum display_state state)
+{
+ dummy_state = state;
+ return 0;
+}
+
static int display_open(struct hw_info *info,
const char *id, struct hw_common **common)
{
+ struct display_device *display_dev;
+
if (!info || !common)
return -EINVAL;
- *common = NULL;
+ display_dev = calloc(1, sizeof(struct display_device));
+ if (!display_dev)
+ return -ENOMEM;
+
+ dummy_state = DISPLAY_ON;
+ dummy_brightness = 100;
+
+ display_dev->common.info = info;
+ display_dev->get_max_brightness = dummy_display_get_max_brightness;
+ display_dev->get_brightness = dummy_display_get_brightness;
+ display_dev->set_brightness = dummy_display_set_brightness;
+
+ display_dev->get_state = dummy_display_get_state;
+ display_dev->set_state = dummy_display_set_state;
+
+ *common = (struct hw_common *)display_dev;
return 0;
}
static int display_close(struct hw_common *common)
{
- if (common) /* we use NULL display_dev */
+ if (!common)
return -EINVAL;
+ free(common);
return 0;
}