@@ -73,10 +73,8 @@
HwComposerBackend *
HwComposerBackend::create()
{
-#ifndef HWC_PLUGIN_HAVE_HWCOMPOSER2_API
hw_module_t *hwc_module = NULL;
hw_device_t *hwc_device = NULL;
-#endif
void *libminisf;
void (*startMiniSurfaceFlinger)(void) = NULL;
@@ -106,85 +104,97 @@
}
#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER2_API
- // Create hwcomposer backend directly without opening hardware module
- // which is not needed and does not even exist on some hwc2 devices
- return new HwComposerBackend_v20(NULL, libminisf);
-#else
- // Open hardware composer
- HWC_PLUGIN_ASSERT_ZERO(hw_get_module(HWC_HARDWARE_MODULE_ID, (const hw_module_t **)(&hwc_module)));
+ if (!qEnvironmentVariableIsEmpty("QT_QPA_FORCE_HWC2")) {
+ // Create hwcomposer backend directly without opening hardware module
+ // because on some devices loading hwc2 module twice breaks graphics
+ // (The first load is in the composer android service.)
+ return new HwComposerBackend_v20(NULL, libminisf);
+ }
+#endif
- fprintf(stderr, "== hwcomposer module ==\n");
- fprintf(stderr, " * Address: %p\n", hwc_module);
- fprintf(stderr, " * Module API Version: %x\n", hwc_module->module_api_version);
- fprintf(stderr, " * HAL API Version: %x\n", hwc_module->hal_api_version); /* should be zero */
- fprintf(stderr, " * Identifier: %s\n", hwc_module->id);
- fprintf(stderr, " * Name: %s\n", hwc_module->name);
- fprintf(stderr, " * Author: %s\n", hwc_module->author);
- fprintf(stderr, "== hwcomposer module ==\n");
-
- // Open hardware composer device
- HWC_PLUGIN_ASSERT_ZERO(hwc_module->methods->open(hwc_module, HWC_HARDWARE_COMPOSER, &hwc_device));
-
- uint32_t version = interpreted_version(hwc_device);
-
- fprintf(stderr, "== hwcomposer device ==\n");
- fprintf(stderr, " * Version: %x (interpreted as %x)\n", hwc_device->version, version);
- fprintf(stderr, " * Module: %p\n", hwc_device->module);
- fprintf(stderr, "== hwcomposer device ==\n");
+ // Open hardware composer
+ if (hw_get_module(HWC_HARDWARE_MODULE_ID, (const hw_module_t **)(&hwc_module)) == 0) {
+ fprintf(stderr, "== hwcomposer module ==\n");
+ fprintf(stderr, " * Address: %p\n", hwc_module);
+ fprintf(stderr, " * Module API Version: %x\n", hwc_module->module_api_version);
+ fprintf(stderr, " * HAL API Version: %x\n", hwc_module->hal_api_version); /* should be zero */
+ fprintf(stderr, " * Identifier: %s\n", hwc_module->id);
+ fprintf(stderr, " * Name: %s\n", hwc_module->name);
+ fprintf(stderr, " * Author: %s\n", hwc_module->author);
+ fprintf(stderr, "== hwcomposer module ==\n");
+
+ // Open hardware composer device
+ HWC_PLUGIN_ASSERT_ZERO(hwc_module->methods->open(hwc_module, HWC_HARDWARE_COMPOSER, &hwc_device));
+
+ uint32_t version = interpreted_version(hwc_device);
+
+ fprintf(stderr, "== hwcomposer device ==\n");
+ fprintf(stderr, " * Version: %x (interpreted as %x)\n", hwc_device->version, version);
+ fprintf(stderr, " * Module: %p\n", hwc_device->module);
+ fprintf(stderr, "== hwcomposer device ==\n");
#ifdef HWC_DEVICE_API_VERSION_0_1
- // Special-case for old hw adaptations that have the version encoded in
- // legacy format, we have to check hwc_device->version directly, because
- // the constants are actually encoded in the old format
- if ((hwc_device->version == HWC_DEVICE_API_VERSION_0_1) ||
- (hwc_device->version == HWC_DEVICE_API_VERSION_0_2) ||
- (hwc_device->version == HWC_DEVICE_API_VERSION_0_3)) {
- return new HwComposerBackend_v0(hwc_module, hwc_device, libminisf);
- }
+ // Special-case for old hw adaptations that have the version encoded in
+ // legacy format, we have to check hwc_device->version directly, because
+ // the constants are actually encoded in the old format
+ if ((hwc_device->version == HWC_DEVICE_API_VERSION_0_1) ||
+ (hwc_device->version == HWC_DEVICE_API_VERSION_0_2) ||
+ (hwc_device->version == HWC_DEVICE_API_VERSION_0_3)) {
+ return new HwComposerBackend_v0(hwc_module, hwc_device, libminisf);
+ }
#endif
- // Determine which backend we use based on the supported module API version
- switch (version) {
+ // Determine which backend we use based on the supported module API version
+ switch (version) {
#ifdef HWC_DEVICE_API_VERSION_0_1
- case HWC_DEVICE_API_VERSION_0_1:
- case HWC_DEVICE_API_VERSION_0_2:
- case HWC_DEVICE_API_VERSION_0_3:
- return new HwComposerBackend_v0(hwc_module, hwc_device, libminisf);
- break;
+ case HWC_DEVICE_API_VERSION_0_1:
+ case HWC_DEVICE_API_VERSION_0_2:
+ case HWC_DEVICE_API_VERSION_0_3:
+ return new HwComposerBackend_v0(hwc_module, hwc_device, libminisf);
#endif
#ifdef HWC_DEVICE_API_VERSION_1_0
- case HWC_DEVICE_API_VERSION_1_0:
- return new HwComposerBackend_v10(hwc_module, hwc_device, libminisf);
- break;
+ case HWC_DEVICE_API_VERSION_1_0:
+ return new HwComposerBackend_v10(hwc_module, hwc_device, libminisf);
#endif /* HWC_DEVICE_API_VERSION_1_0 */
#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER1_API
- case HWC_DEVICE_API_VERSION_1_1:
+ case HWC_DEVICE_API_VERSION_1_1:
#ifdef HWC_DEVICE_API_VERSION_1_2
- case HWC_DEVICE_API_VERSION_1_2:
+ case HWC_DEVICE_API_VERSION_1_2:
#endif
#ifdef HWC_DEVICE_API_VERSION_1_3
- case HWC_DEVICE_API_VERSION_1_3:
+ case HWC_DEVICE_API_VERSION_1_3:
#endif
#ifdef HWC_DEVICE_API_VERSION_1_4
- case HWC_DEVICE_API_VERSION_1_4:
+ case HWC_DEVICE_API_VERSION_1_4:
#endif
#ifdef HWC_DEVICE_API_VERSION_1_5
- case HWC_DEVICE_API_VERSION_1_5:
+ case HWC_DEVICE_API_VERSION_1_5:
#endif
- // HWC_NUM_DISPLAY_TYPES is the actual size of the array, otherwise
- // underrun/overruns happen
- return new HwComposerBackend_v11(hwc_module, hwc_device, libminisf, HWC_NUM_DISPLAY_TYPES);
- break;
+ // HWC_NUM_DISPLAY_TYPES is the actual size of the array, otherwise
+ // underrun/overruns happen
+ return new HwComposerBackend_v11(hwc_module, hwc_device, libminisf, HWC_NUM_DISPLAY_TYPES);
#endif /* HWC_PLUGIN_HAVE_HWCOMPOSER1_API */
- default:
- fprintf(stderr, "Unknown hwcomposer API: 0x%x/0x%x/0x%x\n",
- hwc_module->module_api_version,
- hwc_device->version,
- version);
- return NULL;
- break;
+#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER2_API
+ case HWC_DEVICE_API_VERSION_2_0:
+ return new HwComposerBackend_v20(NULL, libminisf);
+#endif
+ default:
+ fprintf(stderr, "Unknown hwcomposer API: 0x%x/0x%x/0x%x\n",
+ hwc_module->module_api_version,
+ hwc_device->version,
+ version);
+ return NULL;
+ }
+ }
+#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER2_API
+ else {
+ // Create hwc2 backend directly if opening hardware module fails
+ return new HwComposerBackend_v20(NULL, libminisf);
}
#endif
+
+ fprintf(stderr, "Unable to load hwcomposer module\n");
+ return NULL;
}
void
|
@@ -71,6 +71,7 @@
struct HwcProcs_v20 : public HWC2EventListener
{
HwComposerBackend_v20 *backend;
+ hwc2_display_t primaryDisplayId;
};
void hwc2_callback_vsync(HWC2EventListener* listener, int32_t /*sequenceId*/,
@@ -96,6 +97,10 @@
connected ? "connected" : "disconnected",
primaryDisplay ? "primary" : "external");
+ if (primaryDisplay) {
+ static_cast<HwcProcs_v20 *>(listener)->primaryDisplayId = display;
+ }
+
static_cast<const HwcProcs_v20 *>(listener)->backend->onHotplugReceived(
sequenceId, display, connected, primaryDisplay);
}
@@ -223,6 +228,11 @@
procs->on_hotplug_received = hwc2_callback_hotplug;
procs->on_refresh_received = hwc2_callback_refresh;
procs->backend = this;
+ // primaryDisplayId is not changed in this constructor
+ // but it may be changed by hwc2_callback_hotplug and thus the
+ // hwc2_compat_device_get_display_by_id loop will request the
+ // correct primary diplay once primaryDisplayId has been set.
+ procs->primaryDisplayId = 0;
hwc2_device = hwc2_compat_device_new(false);
HWC_PLUGIN_ASSERT_NOT_NULL(hwc2_device);
@@ -233,7 +243,7 @@
for (int i = 0; i < 5 * 1000; ++i) {
// Wait at most 5s for hotplug events
if ((hwc2_primary_display =
- hwc2_compat_device_get_display_by_id(hwc2_device, 0)))
+ hwc2_compat_device_get_display_by_id(hwc2_device, procs->primaryDisplayId)))
break;
usleep(1000);
}
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.23.tar.bz2/hwcomposer/hwcomposer_context.cpp
^
|
@@ -52,24 +52,8 @@
#include <qcoreapplication.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-
-#include <inttypes.h>
-#include <unistd.h>
-#include <signal.h>
-
-
QT_BEGIN_NAMESPACE
-
-static void exit_qt_gracefully(int sig)
-{
- qDebug("Exiting on signal: %d", sig);
- QCoreApplication::exit(0);
-}
-
HwComposerContext::HwComposerContext()
: info(NULL)
, backend(NULL)
@@ -77,16 +61,6 @@
, window_created(false)
, fps(0)
{
- // We need to catch the SIGTERM and SIGINT signals, so that we can do a
- // proper shutdown of Qt and the plugin, and avoid crashes, hangs and
- // reboots in cases where we don't properly close the hwcomposer.
- struct sigaction new_action;
- new_action.sa_handler = exit_qt_gracefully;
- sigemptyset(&new_action.sa_mask);
- new_action.sa_flags = 0;
- sigaction(SIGTERM, &new_action, NULL);
- sigaction(SIGINT, &new_action, NULL);
-
// This actually opens the hwcomposer device
backend = HwComposerBackend::create();
HWC_PLUGIN_ASSERT_NOT_NULL(backend);
@@ -198,6 +172,4 @@
return false;
}
-
-
QT_END_NAMESPACE
|