4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: DongGi Jang <dg0402.jang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
29 #include <linux/limits.h>
34 #include <vconf-keys.h>
38 #include "devman_internal.h"
40 char fifo_path[NAME_MAX];
41 struct pollfd fifo_pollfd;
43 static void sig_quit(int signo)
45 fprintf(stderr, "[DISPLAY_WD] display_wd will be exit for signal %d\n", signo);
46 if(fifo_pollfd.fd >= 0)
47 close(fifo_pollfd.fd);
48 if (access(fifo_path, F_OK) == 0)
57 int auto_brightness_state = -1;
61 signal(SIGPIPE, sig_quit);
63 snprintf(fifo_path, NAME_MAX, "%s.%d", DISPLAY_WD_FIFO, getppid());
64 fifo_pollfd.fd = open(fifo_path, O_WRONLY);
65 if (fifo_pollfd.fd < 0) {
66 fprintf(stderr, "[DISPLAY_WD] Cannot open the fifo file - %s.\n",
71 /* waitting for parent process ready */
73 ret = write(fifo_pollfd.fd, "ack", strlen("ack") + 1);
75 close(fifo_pollfd.fd);
77 fifo_pollfd.fd = open(fifo_path, O_RDONLY);
78 if (fifo_pollfd.fd < 0) {
79 fprintf(stderr, "[DISPLAY_WD] Cannot open the fifo file - %s.\n",
84 fifo_pollfd.events = (POLLIN | POLLHUP);
86 while (ret != DISPLAY_WD_CANCEL) {
87 if (poll(&fifo_pollfd, 1, -1) < 0) {
89 "[DISPLAY_WD] Cannot poll the fifo file - %s\n",
91 close(fifo_pollfd.fd);
94 if (fifo_pollfd.revents & POLLIN) {
95 read(fifo_pollfd.fd, &ret, sizeof(int));
96 if (ret == DISPLAY_WD_CANCEL) {
98 "[DISPLAY_WD] Canceled. - %s, %d\n",
100 close(fifo_pollfd.fd);
104 if (fifo_pollfd.revents & POLLHUP)
107 close(fifo_pollfd.fd);
110 ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &val);
112 if (ret == 0 && val > 0) {
113 device_set_property(DEVTYPE_DISPLAY0, DISPLAY_PROP_BRIGHTNESS, val);
114 device_set_property(DEVTYPE_LED, LED_PROP_BRIGHTNESS, 0);
117 if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &auto_brightness_state) == 0) {
118 if (auto_brightness_state == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) {
119 vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);