* otherwise 0
*/
int is_feature_display_state_supported(void);
+
+/**
+ * @brief Change display white balance value.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/display
+ * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display \n
+ * @param[in] display_index The index of the display \n
+* It can be greater than or equal to @c 0 and less than the number of displays returned by device_display_get_numbers(). \n
+* The index zero is always assigned to the main display
+ * @param[in] white_balance_type The type to adjust white balance value
+ * @param[in] value The value to be set for white balance type
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported in this device
+ * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see device_display_get_numbers()
+ */
+int device_display_set_white_balance(int display_index, display_white_balance_e white_balance_type, int value);
+
+/**
+ * @brief Get display white balance value.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/display
+ * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display \n
+ * @param[in] display_index The index of the display \n
+* It can be greater than or equal to @c 0 and less than the number of displays returned by device_display_get_numbers(). \n
+* The index zero is always assigned to the main display
+ * @param[in] white_balance_type The type to get current white balance value
+ * @param[out] value The white balance type value of the display
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported in this device
+ * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation not permitted
+ * @see device_display_get_numbers()
+ */
+int device_display_get_white_balance(int display_index, display_white_balance_e white_balance_type, int *value);
+
#ifdef __cplusplus
}
#endif
#define METHOD_SET_BRIGHTNESS "SetBrightness"
#define METHOD_CHANGE_STATE "changestate"
#define METHOD_CHANGE_STATE_BY_REASON "ChangeStateByReason"
+#define METHOD_GET_WHITE_BALANCE "GetWhiteBalance"
+#define METHOD_SET_WHITE_BALANCE "SetWhiteBalance"
#define STR_LCD_OFF "lcdoff"
#define STR_LCD_DIM "lcddim"
#define STR_LCD_ON "lcdon"
+#define DISPLAY_WHITE_BALANCE_GAIN_MAX 2047
+#define DISPLAY_WHITE_BALANCE_GAIN_MIN 0
+#define DISPLAY_WHITE_BALANCE_OFFSET_MAX 2047
+#define DISPLAY_WHITE_BALANCE_OFFSET_MIN 0
+
static int display_cnt = -1;
struct display {
int normal_max;
} else
return true;
}
+
+int device_display_set_white_balance(int display_index, display_white_balance_e white_balance_type, int value)
+{
+ int ret;
+
+ if (!is_feature_display_supported())
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
+ if (display_cnt < 0) {
+ ret = device_display_get_numbers(&display_cnt);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+ }
+
+ if (display_index < 0 || display_index >= display_cnt)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ switch (white_balance_type) {
+ case DISPLAY_WHITE_BALANCE_R_GAIN:
+ case DISPLAY_WHITE_BALANCE_G_GAIN:
+ case DISPLAY_WHITE_BALANCE_B_GAIN:
+ if (value < DISPLAY_WHITE_BALANCE_GAIN_MIN || value > DISPLAY_WHITE_BALANCE_GAIN_MAX) {
+ _E("Invalid value of white balance gain (%d)", white_balance_type);
+ return DEVICE_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case DISPLAY_WHITE_BALANCE_R_OFFSET:
+ case DISPLAY_WHITE_BALANCE_G_OFFSET:
+ case DISPLAY_WHITE_BALANCE_B_OFFSET:
+ if (value < DISPLAY_WHITE_BALANCE_OFFSET_MIN || value > DISPLAY_WHITE_BALANCE_OFFSET_MAX) {
+ _E("Invalid value of white balance offset (%d)", white_balance_type);
+ return DEVICE_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ _E("Unknown white balance type");
+ return DEVICE_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = gdbus_call_sync_with_reply_int(DEVICED_BUS_NAME,
+ DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
+ METHOD_SET_WHITE_BALANCE, g_variant_new("(ii)",
+ (int)white_balance_type, value),
+ NULL);
+
+ if (ret < 0)
+ return errno_to_device_error(ret);
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_display_get_white_balance(int display_index, display_white_balance_e white_balance_type, int *value)
+{
+ int ret, reply;
+
+ if (!is_feature_display_supported())
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
+ if (display_cnt < 0) {
+ ret = device_display_get_numbers(&display_cnt);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+ }
+
+ if (display_index < 0 || display_index >= display_cnt)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ switch (white_balance_type) {
+ case DISPLAY_WHITE_BALANCE_R_GAIN:
+ case DISPLAY_WHITE_BALANCE_G_GAIN:
+ case DISPLAY_WHITE_BALANCE_B_GAIN:
+ case DISPLAY_WHITE_BALANCE_R_OFFSET:
+ case DISPLAY_WHITE_BALANCE_G_OFFSET:
+ case DISPLAY_WHITE_BALANCE_B_OFFSET:
+ break;
+ default:
+ _E("Unknown white balance type");
+ return DEVICE_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = gdbus_call_sync_with_reply_int(DEVICED_BUS_NAME,
+ DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
+ METHOD_GET_WHITE_BALANCE, g_variant_new("(i)",
+ (int)white_balance_type),
+ &reply);
+
+ if (ret < 0)
+ return errno_to_device_error(ret);
+
+ if (reply < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ *value = reply;
+
+ return DEVICE_ERROR_NONE;
+}
\ No newline at end of file