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.
27 #include <sys/types.h>
39 #include "devman_internal.h"
41 #define WD_RESPONSE_TIMEOUT 100 /* 0.1 seconds */
42 #define DISPLAY_WD_PATH "/usr/bin/display_wd"
46 API int display_register_postjob(void)
52 char fifo_path[NAME_MAX];
53 struct pollfd fifo_pollfd;
55 snprintf(fifo_path, NAME_MAX, "%s.%d", DISPLAY_WD_FIFO, getpid());
56 if (access(fifo_path, F_OK) == 0) {
57 ERR("Already registered!");
60 mkfifo(fifo_path, 0700);
64 ERR("Failed to fork child process for LCD On/Off");
69 open_max = sysconf(_SC_OPEN_MAX);
70 for (i = 0; i < open_max; i++) {
74 execl(DISPLAY_WD_PATH, DISPLAY_WD_PATH, NULL);
77 fifo_pollfd.fd = open(fifo_path, O_RDWR | O_NONBLOCK);
78 if (fifo_pollfd.fd < 0) {
79 ERR("Cannot open fifo file");
84 /* get the watch dog ready message. */
85 fifo_pollfd.events = POLLIN;
86 if (poll(&fifo_pollfd, 1, WD_RESPONSE_TIMEOUT) < 0) {
87 ERR("Cannot poll the fifo file");
88 DBG("fifo file path is %s", fifo_path);
89 close(fifo_pollfd.fd);
93 read(fifo_pollfd.fd, buf, sizeof(buf));
95 fifo_fd = fifo_pollfd.fd;
100 API int display_cancel_postjob(void)
105 snprintf(buf, PATH_MAX, "%s.%d", DISPLAY_WD_FIFO, getpid());
106 if (access(buf, F_OK) != 0) {
107 ERR("No registered the post job!");
112 fifo_fd = open(buf, O_WRONLY);
114 ERR("Cannot open the fifo file");
115 DBG("fifo file path is %s", buf);
118 ret = DISPLAY_WD_CANCEL;
119 write(fifo_fd, &ret, sizeof(int));