return 0;
}
+static int get_image_effect(enum display_image_effect *effect)
+{
+ int ret;
+ enum display_image_effect val;
+
+ if (!display_dev || !display_dev->get_image_effect) {
+ _E("There is no display device");
+ return -ENOENT;
+ }
+
+ ret = display_dev->get_image_effect(&val);
+ if (ret < 0) {
+ _E("Failed to get image effect: %d", ret);
+ return ret;
+ }
+
+ *effect = val;
+
+ return 0;
+}
+
+static int set_image_effect(enum display_image_effect effect)
+{
+ int ret;
+
+ if (!display_dev || !display_dev->set_image_effect) {
+ _E("There is no display device");
+ return -ENOENT;
+ }
+
+ ret = display_dev->set_image_effect(effect);
+ if (ret < 0) {
+ _E("Failed to set image effect: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static int get_frame_rate(int *rate)
{
if (!rate)
backlight_ops.set_brightness = set_brightness;
backlight_ops.get_brightness = get_brightness;
backlight_ops.get_brightness_by_light_sensor = get_brightness_by_light_sensor;
+ backlight_ops.get_image_effect = get_image_effect;
+ backlight_ops.set_image_effect = set_image_effect;
backlight_ops.get_frame_rate = get_frame_rate;
backlight_ops.set_frame_rate = set_frame_rate;
--- /dev/null
+/*
+ * deviced
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <device-node.h>
+#include <vconf.h>
+#include <hw/display.h>
+#include <libgdbus/dbus-system.h>
+
+#include "display/core.h"
+#include "display/display-ops.h"
+#include "core/devices.h"
+#include "core/log.h"
+#include "core/common.h"
+#include "core/device-notifier.h"
+
+#define VCONF_HIGH_CONTRAST VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST
+#define VCONF_GREYSCALE VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE
+
+static bool negative_status;
+static bool greyscale_status;
+
+static int enhance_update_state(void)
+{
+ int state;
+
+ _I("Greyscale %d negative %d", greyscale_status, negative_status);
+
+ if (greyscale_status) {
+ if (negative_status)
+ state = DISPLAY_IMAGE_EFFECT_GREY_NEGATIVE;
+ else
+ state = DISPLAY_IMAGE_EFFECT_GREY;
+ } else if (negative_status)
+ state = DISPLAY_IMAGE_EFFECT_NEGATIVE;
+ else
+ state = DISPLAY_IMAGE_EFFECT_STANDARD;
+
+ backlight_ops.set_image_effect(state);
+
+ return state;
+}
+
+static void enhance_greyscale_cb(keynode_t *in_key, void *data)
+{
+ int val, ret;
+
+ ret = vconf_get_bool(VCONF_GREYSCALE, &val);
+ if (ret < 0) {
+ _E("Failed to get %s", VCONF_GREYSCALE);
+ return;
+ }
+
+ _I("Set greyscale scenario (%d)", val);
+ greyscale_status = val;
+
+ enhance_update_state();
+}
+
+static void enhance_high_contrast_cb(keynode_t *in_key, void *data)
+{
+ int val, ret;
+
+ ret = vconf_get_bool(VCONF_HIGH_CONTRAST, &val);
+ if (ret < 0) {
+ _E("Failed to get %s", VCONF_HIGH_CONTRAST);
+ return;
+ }
+
+ _I("Set negative scenario (%d)", val);
+ negative_status = val;
+
+ enhance_update_state();
+}
+
+static int enhance_lcd_state_changed(void *data)
+{
+ int state;
+
+ state = DATA_VALUE_INT(data);
+
+ if (state == S_NORMAL)
+ enhance_update_state();
+
+ return 0;
+}
+
+static int enhance_ultrapowersaving_changed(void *data)
+{
+ bool mode;
+
+ mode = DATA_VALUE_BOOL(data);
+
+ greyscale_status = mode;
+
+ enhance_update_state();
+ _I("Set ultra power saving mode.");
+
+ return 0;
+
+}
+
+static void enhance_init(void *data)
+{
+ int val, ret;
+ int state;
+
+ /* register notifier */
+ register_notifier(DEVICE_NOTIFIER_LCD, enhance_lcd_state_changed);
+ register_notifier(DEVICE_NOTIFIER_ULTRAPOWERSAVING,
+ enhance_ultrapowersaving_changed);
+
+ ret = vconf_notify_key_changed(VCONF_HIGH_CONTRAST,
+ enhance_high_contrast_cb, NULL);
+ if (ret < 0)
+ _E("Failed to register notify: %s", VCONF_HIGH_CONTRAST);
+
+ ret = vconf_get_bool(VCONF_HIGH_CONTRAST, &val);
+ if (ret < 0)
+ _E("Failed to get high contrast!");
+
+ /* update negative status */
+ _I("Set high contrast (%d)", val);
+ negative_status = val;
+
+ ret = vconf_notify_key_changed(VCONF_GREYSCALE,
+ enhance_greyscale_cb, NULL);
+ if (ret < 0)
+ _E("Failed to register notify: %s", VCONF_GREYSCALE);
+
+ ret = vconf_get_bool(VCONF_GREYSCALE, &val);
+ if (ret < 0) {
+ _E("Failed to get high contrast!");
+ return;
+ }
+ greyscale_status = val;
+
+ state = enhance_update_state();
+
+ ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY,
+ DEVICED_INTERFACE_DISPLAY,
+ "Enhance",
+ g_variant_new("(i)", state));
+ if (ret < 0)
+ _E("Failed to send dbus signal.");
+}
+
+static void enhance_exit(void *data)
+{
+ /* unregister notifier */
+ unregister_notifier(DEVICE_NOTIFIER_LCD, enhance_lcd_state_changed);
+ unregister_notifier(DEVICE_NOTIFIER_ULTRAPOWERSAVING,
+ enhance_ultrapowersaving_changed);
+
+ vconf_ignore_key_changed(VCONF_HIGH_CONTRAST, enhance_high_contrast_cb);
+ vconf_ignore_key_changed(VCONF_GREYSCALE, enhance_greyscale_cb);
+}
+
+static const struct display_ops display_enhance_ops = {
+ .name = "enhance",
+ .init = enhance_init,
+ .exit = enhance_exit,
+};
+
+DISPLAY_OPS_REGISTER(&display_enhance_ops)