hwcomposer2: few changes for refresh rate switching
- getSupportedDisplayVsyncPeriods was removed as the vsync period
can be obtained by getDisplayAttribute for each individual config.
- renamed setActiveConfigAndVsyncPeriod -> setActiveConfigWithConstraints
to better describe what this function does.
- added VsyncPeriodChangeTimeline and onVsyncPeriodTimingChanged
Test: rev up composer to 2.4 and test refresh rate switching
Bug: 141329414
Change-Id: Ifec51c893bb9038e9ac48d02c1c7b0fe9e25c108
diff --git a/include/hardware/hwcomposer2.h b/include/hardware/hwcomposer2.h
index 7db2aba..6400a7c 100644
--- a/include/hardware/hwcomposer2.h
+++ b/include/hardware/hwcomposer2.h
@@ -50,6 +50,11 @@
* the device may return -1 instead */
HWC2_ATTRIBUTE_DPI_X = 4,
HWC2_ATTRIBUTE_DPI_Y = 5,
+
+ /* The configuration group this config is associated to.
+ * Switching between configurations within the same group may be done seamlessly
+ * in some conditions via setActiveConfigWithConstraints. */
+ HWC2_ATTRIBUTE_CONFIG_GROUP = 7,
} hwc2_attribute_t;
/* Blend modes, settable per layer */
@@ -74,6 +79,7 @@
HWC2_CALLBACK_REFRESH = 2,
HWC2_CALLBACK_VSYNC = 3,
HWC2_CALLBACK_VSYNC_2_4 = 4,
+ HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED = 5,
} hwc2_callback_descriptor_t;
/* Optional capabilities which may be supported by some devices. The particular
@@ -221,7 +227,7 @@
HWC2_ERROR_NO_RESOURCES,
HWC2_ERROR_NOT_VALIDATED,
HWC2_ERROR_UNSUPPORTED,
- HWC2_ERROR_BAD_VSYNC_PERIOD,
+ HWC2_ERROR_SEAMLESS_NOT_ALLOWED,
HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
} hwc2_error_t;
@@ -294,9 +300,8 @@
// composer 2.4
HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
- HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS,
HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
- HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD,
+ HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS,
} hwc2_function_descriptor_t;
/* Layer requests returned from getDisplayRequests */
@@ -443,6 +448,7 @@
case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
+ case HWC2_ATTRIBUTE_CONFIG_GROUP: return "ConfigGroup";
default: return "Unknown";
}
}
@@ -464,6 +470,8 @@
case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
case HWC2_CALLBACK_REFRESH: return "Refresh";
case HWC2_CALLBACK_VSYNC: return "Vsync";
+ case HWC2_CALLBACK_VSYNC_2_4: return "Vsync2.4";
+ case HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED: return "VsyncPeriodTimingChanged";
default: return "Unknown";
}
}
@@ -543,7 +551,7 @@
case HWC2_ERROR_NO_RESOURCES: return "NoResources";
case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
- case HWC2_ERROR_BAD_VSYNC_PERIOD: return "BadVsyncPeriod";
+ case HWC2_ERROR_SEAMLESS_NOT_ALLOWED: return "SeamlessNotAllowed";
case HWC2_ERROR_SEAMLESS_NOT_POSSIBLE: return "SeamlessNotPossible";
default: return "Unknown";
}
@@ -630,9 +638,8 @@
// composer 2.4
case HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE: return "GetDisplayConnectionType";
- case HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS: return "getSupportedDisplayVsyncPeriods";
- case HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD: return "getDisplayVsyncPeriod";
- case HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD: return "setActiveConfigAndVsyncPeriod";
+ case HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD: return "GetDisplayVsyncPeriod";
+ case HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS: return "SetActiveConfigWithConstraints";
default: return "Unknown";
}
@@ -740,6 +747,7 @@
VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
DpiX = HWC2_ATTRIBUTE_DPI_X,
DpiY = HWC2_ATTRIBUTE_DPI_Y,
+ ConfigGroup = HWC2_ATTRIBUTE_CONFIG_GROUP,
};
TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
@@ -757,6 +765,7 @@
Refresh = HWC2_CALLBACK_REFRESH,
Vsync = HWC2_CALLBACK_VSYNC,
Vsync_2_4 = HWC2_CALLBACK_VSYNC_2_4,
+ VsyncPeriodTimingChanged = HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED,
};
TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
@@ -816,7 +825,7 @@
NoResources = HWC2_ERROR_NO_RESOURCES,
NotValidated = HWC2_ERROR_NOT_VALIDATED,
Unsupported = HWC2_ERROR_UNSUPPORTED,
- BadVsyncPeriod = HWC2_ERROR_BAD_VSYNC_PERIOD,
+ SeamlessNotAllowed = HWC2_ERROR_SEAMLESS_NOT_ALLOWED,
SeamlessNotPossible = HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
};
TO_STRING(hwc2_error_t, Error, getErrorName)
@@ -889,9 +898,8 @@
// composer 2.4
GetDisplayConnectionType = HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
- getSupportedDisplayVsyncPeriods = HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS,
- getDisplayVsyncPeriod = HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
- setActiveConfigAndVsyncPeriod = HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD,
+ GetDisplayVsyncPeriod = HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
+ SetActiveConfigWithConstraints = HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS,
};
TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
@@ -1101,6 +1109,25 @@
typedef void (*HWC2_PFN_VSYNC_2_4)(hwc2_callback_data_t callbackData,
hwc2_display_t display, int64_t timestamp, hwc2_vsync_period_t vsyncPeriodNanos);
+/* vsyncPeriodTimingChanged(..., display, updated_timeline)
+ * Descriptor: HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED
+ * Optional for HWC2 devices for composer 2.4
+ *
+ * Notifies the client that the previously reported timing for vsync period change has been
+ * updated. This may occur if the composer missed the deadline for changing the vsync period
+ * or the client submitted a refresh frame too late.
+ *
+ * This callback should be triggered from a thread of at least
+ * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
+ * less than 0.5 ms. This thread is guaranteed not to call back into the device.
+ *
+ * Parameters:
+ * display - the display which has received a vsync event
+ * updated_timeline - new timeline for the vsync period change
+ */
+typedef void (*HWC2_PFN_VSYNC_PERIOD_TIMING_CHANGED)(hwc2_callback_data_t callbackData,
+ hwc2_display_t display, hwc_vsync_period_change_timeline_t* updated_timeline);
+
/*
* Device Functions
*
@@ -2814,30 +2841,6 @@
hwc2_device_t* device, hwc2_display_t display,
uint32_t* /*hwc2_display_connection_type_t*/ outType);
-/* getSupportedDisplayVsyncPeriods(..., outNumVsyncPeriods, outVsyncPeriods)
- * Descriptor: HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS
- * Required for HWC2 devices for composer 2.4
- *
- * Returns a array of supported vsync periods the display can refresh at a given configuration.
- *
- * outVsyncPeriods may be NULL to retrieve the number of elements which will be returned.
- *
- * Parameters:
- * outNumVsyncPeriods - if outVsyncPeriods was NULL, the number of vsync periods which
- * would have been returned; if outVsyncPeriods was not NULL, the number of
- * vsync periods returned, which must not exceed the value stored in
- * outNumVsyncPeriods prior to the call; pointer will be non-NULL
- * outVsyncPeriods - an array of vsync periods
- *
- * Returns HWC2_ERROR_NONE or one of the following errors:
- * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
- * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
- * this display
- */
-typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS)(
- hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
- uint32_t* outNumVsyncPeriods, hwc2_vsync_period_t* outVsyncPeriods);
-
/* getDisplayVsyncPeriod(..., outVsyncPeriods)
* Descriptor: HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD
* Required for HWC2 devices for composer 2.4
@@ -2846,7 +2849,7 @@
*
* If no display configuration is currently active, this function must
* return BAD_CONFIG. If a vsync period is about to change due to a
- * setActiveConfigAndVsyncPeriod call, this function must return the current vsync period
+ * setActiveConfigWithConstraints call, this function must return the current vsync period
* until the change has taken place.
*
* Parameters:
@@ -2859,13 +2862,16 @@
typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_VSYNC_PERIOD)(
hwc2_device_t* device, hwc2_display_t display, hwc2_vsync_period_t* outVsyncPeriod);
-/* setActiveConfigAndVsyncPeriod(..., config, vsyncPeriodNanos,
- * vsyncPeriodChangeConstraints, outNewVsyncAppliedTime)
- * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD
+/* setActiveConfigWithConstraints(...,
+ * config,
+ * vsyncPeriodChangeConstraints,
+ * outTimeline)
+ * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS
* Required for HWC2 devices for composer 2.4
*
* Sets the active configuration and the refresh rate for this display.
- * If the config is the same as the current config, only the vsync period shall change.
+ * If the new config shares the same config group as the current config,
+ * only the vsync period shall change.
* Upon returning, the given display configuration, except vsync period, must be active and
* remain so until either this function is called again or the display is disconnected.
* When the display starts to refresh at the new vsync period, onVsync_2_4 callback must be
@@ -2873,7 +2879,6 @@
*
* Parameters:
* config - the new display configuration.
- * vsyncPeriodNanos - the new display vsync period.
* vsyncPeriodChangeConstraints - constraints required for changing vsync period:
* desiredTimeNanos - the time in CLOCK_MONOTONIC after
* which the vsync period may change
@@ -2882,22 +2887,21 @@
* seamlessRequired - if true, requires that the vsync period
* change must happen seamlessly without
* a noticeable visual artifact.
- * outNewVsyncAppliedTime - the time in CLOCK_MONOTONIC when the new display will start to
- * refresh at the new vsync period.
+ * outTimeline - the timeline for the vsync period change.
*
* Returns HWC2_ERROR_NONE or one of the following errors:
* HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in.
* HWC2_ERROR_BAD_CONFIG - an invalid configuration handle passed in.
- * HWC2_ERROR_BAD_VSYNC_PERIOD - an invalid vsync period is passed in.
+ * HWC2_ERROR_SEAMLESS_NOT_ALLOWED - when seamlessRequired was true but config provided doesn't
+ * share the same config group as the current config.
* HWC2_ERROR_SEAMLESS_NOT_POSSIBLE - when seamlessRequired was true but the display cannot
* achieve the vsync period change without a noticeable
* visual artifact.
*/
-typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD)(
+typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS)(
hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
- hwc2_vsync_period_t vsyncPeriodNanos,
hwc_vsync_period_change_constraints_t* vsyncPeriodChangeConstraints,
- int64_t* outNewVsyncAppliedTime);
+ hwc_vsync_period_change_timeline_t* outTimeline);
__END_DECLS