Browse Source

Funktion zum Einstellen des Backlights.

Rind 2 weeks ago
parent
commit
93c53717e5
5 changed files with 55 additions and 4 deletions
  1. 4 1
      README.md
  2. 1 1
      gfaipc.pro
  3. 44 2
      src/appctrl.cpp
  4. 2 0
      src/appctrl.h
  5. 4 0
      src/gfaipc.h

+ 4 - 1
README.md

@@ -1,7 +1,7 @@
 ## libgfaipc  
 
 ***Version:***  
-libgfaipc.so.1.9.0  
+libgfaipc.so.1.11.0  
 
 ***SO-Name:***  
 libgfaipc.so.1
@@ -66,3 +66,6 @@ gfa/shm.h, gfa/mutex.h, gfa/sema.h, gfa/procmem.h, gfa/thread.h
 
 * **1.10.0**<br>
 	Bugfix betreffend Erkennung des Bootmediums.
+
+* **1.11.0**<br>
+	Funktion zum Einstellen des Backlights.

+ 1 - 1
gfaipc.pro

@@ -1,5 +1,5 @@
 TEMPLATE = lib
-VERSION = 1.10
+VERSION = 1.11
 CONFIG -= qt app_bundle
 CONFIG += c++11 shared thread
 

+ 44 - 2
src/appctrl.cpp

@@ -38,6 +38,9 @@
 												pd.nKiBUsed = ps.nKiBUsed
 #define _DELETE_MOUNTPOINT(pd)					memset(pd.szMntPoint, 0, sizeof(pd.szMntPoint))
 
+#define _SYS_FS_TIVA_BACKLIGHT_DUTYCYCLE		"/sys/gfa/tiva/backlight/dutycycle"
+#define _SYS_FS_TIVA_BACKLIGHT_BRIGHTNESS		"/sys/class/leds/backlight/brightness"
+
 /////////////////////////////////////////////////////////////////////////////
 
 static const char *g_pszKnownAppNames[] =
@@ -1427,7 +1430,6 @@ void CAppCtrl::Lock(void)
 {
 	if(m_hShm)
 	{
-//		if(::GfaIpcInterlockedIncrement(m_hShm, &m_nLockCount) == 1)
 		(*m_pfnLockSHM)(m_hShm);
 	}
 }
@@ -1436,7 +1438,6 @@ void CAppCtrl::Unlock(void)
 {
 	if(m_hShm)
 	{
-//		if(::GfaIpcInterlockedDecrement(m_hShm, &m_nLockCount) == 0)
 		(*m_pfnUnlockSHM)(m_hShm);
 	}
 }
@@ -1455,6 +1456,35 @@ void CAppCtrl::SetLockUnlockFunctions(PFN_GFA_IPC_LOCK_SHM pfnLockSHM, PFN_GFA_I
 	}
 }
 
+bool CAppCtrl::SetBacklight(int nPercent)
+{
+	FILE *pf = nullptr;
+
+	if(nPercent < 0)
+		nPercent = 0;
+	else if(nPercent > 100)
+		nPercent = 100;
+
+	if(GfAIpcGetTargetHasTiva())
+	{
+		pf = fopen(_SYS_FS_TIVA_BACKLIGHT_DUTYCYCLE, "w");
+	}
+	else
+	{
+		nPercent = nPercent * 255 / 100;
+		pf = fopen(_SYS_FS_TIVA_BACKLIGHT_BRIGHTNESS, "w");
+	}
+
+	if(pf)
+	{
+		int ret = fprintf(pf, "%d", nPercent) > 0;
+		fclose(pf);
+		return (ret > 0);
+	}
+
+	return false;
+}
+
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
@@ -1836,6 +1866,18 @@ bool GfaIpcAppCtrlSetLockUnlockFunctions(HAPPCTRL hAC, PFN_GFA_IPC_LOCK_SHM pfnL
 	return false;
 }
 
+/////////////////////////////////////////////////////////////////////////////
+
+bool GfaIpcAppCtrlSetBacklight(HAPPCTRL hAC, int nPercent)
+{
+	CAppCtrl *p = reinterpret_cast<CAppCtrl*>(hAC);
+	if(p)
+	{
+		return p->SetBacklight(nPercent);
+	}
+	return false;
+}
+
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////

+ 2 - 0
src/appctrl.h

@@ -174,6 +174,8 @@ public:
 	bool KillApp(appid_t nAppID);
 
 	void SetLockUnlockFunctions(PFN_GFA_IPC_LOCK_SHM pfnLockSHM, PFN_GFA_IPC_UNLOCK_SHM pfnUnlockSHM);
+	
+	bool SetBacklight(int nPercent);
 
 private:
 	int SlotIndexFromAppID(appid_t nAppID);

+ 4 - 0
src/gfaipc.h

@@ -47,6 +47,8 @@ typedef enum
 }GfATargetTypes;
 
 GfATargetTypes	GfAIpcGetTargetType(char *pszTargetType, size_t nCChTargetType);
+#define GfAIpcGetTargetHasTiva()		(::GfAIpcGetTargetType(NULL, 0) == GTT_GfATargetWithTiva)
+
 bool			GfAIpcSystemIsHypervised(void);
 
 /////////////////////////////////////////////////////////////////////////////
@@ -464,6 +466,8 @@ bool			GfaIpcAppCtrlKillApp				(HAPPCTRL hAC, appid_t nAppID);
 bool			GfaIpcAppCtrlSetLockUnlockFunctions	(HAPPCTRL hAC, PFN_GFA_IPC_LOCK_SHM pfnLockSHM, PFN_GFA_IPC_UNLOCK_SHM pfnUnlockSHM);
 bool			GfaIpcAppCtrlSysInfoUpdateStgDevInfo(HAPPCTRL hAC);
 
+bool			GfaIpcAppCtrlSetBacklight			(HAPPCTRL hAC, int nPercent);
+
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////