display: Add hook for triggering screen update

DSI command mode panels do not need to be refreshed on each
vsync. Due to one frame latency in CABL LUT calculation, when CABL is
enabled for DSI command mode panels, the LUT doesnt get updated for last
frame. Triggering an extra update for DSI command mode panels fixes it.

Change-Id: I7a22e338609430746dda4d3081ff199109a95035
diff --git a/libqservice/IQClient.cpp b/libqservice/IQClient.cpp
index 4ff67dc..30fbb64 100644
--- a/libqservice/IQClient.cpp
+++ b/libqservice/IQClient.cpp
@@ -41,12 +41,14 @@
     BpQClient(const sp<IBinder>& impl)
         : BpInterface<IQClient>(impl) {}
 
-    virtual void notifyCallback(uint32_t msg, uint32_t value) {
+    virtual status_t notifyCallback(uint32_t msg, uint32_t value) {
         Parcel data, reply;
         data.writeInterfaceToken(IQClient::getInterfaceDescriptor());
         data.writeInt32(msg);
         data.writeInt32(value);
         remote()->transact(NOTIFY_CALLBACK, data, &reply);
+        status_t result = reply.readInt32();
+        return result;
     }
 };
 
diff --git a/libqservice/IQClient.h b/libqservice/IQClient.h
index 68d8275..a28f826 100644
--- a/libqservice/IQClient.h
+++ b/libqservice/IQClient.h
@@ -33,7 +33,7 @@
 {
 public:
     DECLARE_META_INTERFACE(QClient);
-    virtual void notifyCallback(uint32_t msg, uint32_t value) = 0;
+    virtual android::status_t notifyCallback(uint32_t msg, uint32_t value) = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/libqservice/IQService.cpp b/libqservice/IQService.cpp
index 7a88bdf..6c6f7b6 100644
--- a/libqservice/IQService.cpp
+++ b/libqservice/IQService.cpp
@@ -63,6 +63,14 @@
         data.writeStrongBinder(client->asBinder());
         remote()->transact(CONNECT, data, &reply);
     }
+
+    virtual status_t screenRefresh() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IQService::getInterfaceDescriptor());
+        remote()->transact(SCREEN_REFRESH, data, &reply);
+        status_t result = reply.readInt32();
+        return result;
+    }
 };
 
 IMPLEMENT_META_INTERFACE(QService, "android.display.IQService");
@@ -88,7 +96,8 @@
     switch(code) {
         case SECURING: {
             if(!permission) {
-                ALOGE("display.qservice SECURING access denied: pid=%d uid=%d process=%s",
+                ALOGE("display.qservice SECURING access denied: \
+                      pid=%d uid=%d process=%s",
                       callerPid, callerUid, callingProcName);
                 return PERMISSION_DENIED;
             }
@@ -99,7 +108,8 @@
         } break;
         case UNSECURING: {
             if(!permission) {
-                ALOGE("display.qservice UNSECURING access denied: pid=%d uid=%d process=%s",
+                ALOGE("display.qservice UNSECURING access denied: \
+                      pid=%d uid=%d process=%s",
                       callerPid, callerUid, callingProcName);
                 return PERMISSION_DENIED;
             }
@@ -111,7 +121,8 @@
         case CONNECT: {
             CHECK_INTERFACE(IQService, data, reply);
             if(callerUid != AID_GRAPHICS) {
-                ALOGE("display.qservice CONNECT access denied: pid=%d uid=%d process=%s",
+                ALOGE("display.qservice CONNECT access denied: \
+                      pid=%d uid=%d process=%s",
                       callerPid, callerUid, callingProcName);
                 return PERMISSION_DENIED;
             }
@@ -120,6 +131,16 @@
             connect(client);
             return NO_ERROR;
         } break;
+        case SCREEN_REFRESH: {
+            CHECK_INTERFACE(IQService, data, reply);
+            if(callerUid != AID_GRAPHICS) {
+                ALOGE("display.qservice SCREEN_REFRESH access denied: \
+                      pid=%d uid=%d process=%s",callerPid,
+                      callerUid, callingProcName);
+                return PERMISSION_DENIED;
+            }
+            return screenRefresh();
+        } break;
         default:
             return BBinder::onTransact(code, data, reply, flags);
     }
diff --git a/libqservice/IQService.h b/libqservice/IQService.h
index 70e6c64..79e831d 100644
--- a/libqservice/IQService.h
+++ b/libqservice/IQService.h
@@ -40,6 +40,7 @@
         SECURING = android::IBinder::FIRST_CALL_TRANSACTION,
         UNSECURING, // Hardware unsecuring start/end notification
         CONNECT,
+        SCREEN_REFRESH,
     };
     enum {
         END = 0,
@@ -48,6 +49,7 @@
     virtual void securing(uint32_t startEnd) = 0;
     virtual void unsecuring(uint32_t startEnd) = 0;
     virtual void connect(const android::sp<qClient::IQClient>& client) = 0;
+    virtual android::status_t screenRefresh() = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/libqservice/QService.cpp b/libqservice/QService.cpp
index 8fc7319..54e285c 100644
--- a/libqservice/QService.cpp
+++ b/libqservice/QService.cpp
@@ -63,6 +63,14 @@
     mClient = client;
 }
 
+android::status_t QService::screenRefresh() {
+    status_t result = NO_ERROR;
+    if(mClient.get()) {
+        result = mClient->notifyCallback(SCREEN_REFRESH, 0);
+    }
+    return result;
+}
+
 void QService::init()
 {
     if(!sQService) {
diff --git a/libqservice/QService.h b/libqservice/QService.h
index 4f7e570..268bf81 100644
--- a/libqservice/QService.h
+++ b/libqservice/QService.h
@@ -48,6 +48,7 @@
     virtual void securing(uint32_t startEnd);
     virtual void unsecuring(uint32_t startEnd);
     virtual void connect(const android::sp<qClient::IQClient>& client);
+    virtual android::status_t screenRefresh();
     static void init();
 private:
     QService();