add display_set_timeout api to resolve build break issue 69/15269/1
authorjy910.yun <jy910.yun@samsung.com>
Thu, 20 Jun 2013 03:58:49 +0000 (12:58 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Fri, 17 Jan 2014 13:10:49 +0000 (14:10 +0100)
Change-Id: I22e9aa301a2d8d53188afa2bc7cecc1cb9118be9
Signed-off-by: jy910.yun <jy910.yun@samsung.com>
src/deviced/dd-display.h
src/shared/display.c

index 434d417..0eaed12 100644 (file)
@@ -48,6 +48,9 @@ extern "C" {
 #define PM_RESET_TIMER 0x1     /**< reset timer for unlock */
 #define PM_KEEP_TIMER  0x2     /**< keep timer for unlock */
 
+/* parameter for display_set_timeout */
+#define CUSTOM_TIMEOUT  0x1
+
 int display_get_count(void);
 int display_get_max_brightness(void);
 int display_get_min_brightness(void);
index 86c6373..1758c88 100644 (file)
 #define DISPLAY_MIN_BRIGHTNESS  1
 #define DISPLAY_DIM_BRIGHTNESS  0
 
+#define SOCK_PATH                      "/tmp/pm_sock"
+#define SHIFT_UNLOCK                   4
+#define SHIFT_UNLOCK_PARAMETER         12
+#define SHIFT_CHANGE_STATE             8
+#define SHIFT_LOCK_FLAG                        16
+#define SHIFT_CHANGE_TIMEOUT           20
+#define TIMEOUT_RESET_BIT              0x80
 #define HOLDKEY_BLOCK_BIT              0x1
 #define STANDBY_MODE_BIT               0x2
+#define CUSTOM_HOLDKEY_BIT             0x2
 
 #define METHOD_SET_FRAME_RATE          "setframerate"
 #define METHOD_LOCK_STATE              "lockstate"
 #define STR_RESET_TIMER  "resettimer"
 #define STR_KEEP_TIMER   "keeptimer"
 
+struct disp_lock_msg {
+       pid_t pid;
+       unsigned int cond;
+       unsigned int timeout;
+       unsigned int timeout2;
+};
+
+
 API int display_get_count(void)
 {
        DBusError err;
@@ -435,3 +451,49 @@ API int display_unlock_state(unsigned int s_bits, unsigned int flag)
        return val;
 
 }
+
+static int send_msg(unsigned int s_bits, unsigned int timeout, unsigned int timeout2)
+{
+       int rc = 0;
+       int sock;
+       struct disp_lock_msg p;
+       struct sockaddr_un remote;
+
+       p.pid = getpid();
+       p.cond = s_bits;
+       p.timeout = timeout;
+       p.timeout2 = timeout2;
+
+       sock = socket(AF_UNIX, SOCK_DGRAM, 0);
+       if (sock == -1) {
+               _E("pm socket() failed: %s", strerror(errno));
+               return sock;
+       }
+
+       remote.sun_family = AF_UNIX;
+       if(strlen(SOCK_PATH) >= sizeof(remote.sun_path)) {
+               _E("socket path is vey long");
+               close(sock);
+               return -ENAMETOOLONG;
+       }
+       strncpy(remote.sun_path, SOCK_PATH, sizeof(remote.sun_path));
+
+       rc = sendto(sock, (void *)&p, sizeof(p), 0, (struct sockaddr *)&remote,
+                   sizeof(struct sockaddr_un));
+       if (rc == -1)
+               _E("pm socket sendto() failed: %s", strerror(errno));
+
+       close(sock);
+       return (rc > 0 ? 0 : rc);
+}
+
+API void display_set_timeout(unsigned int normal, unsigned int dim, unsigned int lock)
+{
+       unsigned int s_bits = CUSTOM_TIMEOUT;
+
+       if (lock == HOLD_KEY_BLOCK)
+               s_bits += CUSTOM_HOLDKEY_BIT;
+
+       s_bits = (s_bits << SHIFT_CHANGE_TIMEOUT);
+       send_msg(s_bits, normal, dim);
+}