From b54461f39296454dd32075e8ed84983199ce8d88 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 18 Feb 2020 13:41:52 +0900 Subject: [PATCH] Use mtp-responder-dummy.socket when there is no mtp-responser.socket The mtp-responder.socket is special in the configfs environment. If mtp-responder.socket is missing, gadget configuration will fail. As a result, all usb operations do not work properly. So in environments that mtp doesn't support, use dummy mtp. Applied target : XU3, Artik headless, RPI4 Change-Id: I34bee7c1837ada478959407cd7c6500e219f28bc (cherry picked from commit 0202291b7c1b3be3db32bba3001d51d7efe6a362) --- CMakeLists.txt | 6 ++++++ hw/usb_gadget_common.c | 12 ++++++++++++ mtp-responder-dummy/descs | Bin 0 -> 80 bytes mtp-responder-dummy/mtp-responder-dummy.service | 12 ++++++++++++ mtp-responder-dummy/mtp-responder-dummy.socket | 6 ++++++ mtp-responder-dummy/strs | Bin 0 -> 30 bytes packaging/libdevice-node.spec | 4 ++++ 7 files changed, 40 insertions(+) create mode 100644 mtp-responder-dummy/descs create mode 100644 mtp-responder-dummy/mtp-responder-dummy.service create mode 100644 mtp-responder-dummy/mtp-responder-dummy.socket create mode 100644 mtp-responder-dummy/strs diff --git a/CMakeLists.txt b/CMakeLists.txt index 452fae7..4646bb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,12 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hw/ DESTINATION include/hw CONFIGURE_FILE(hwcommon.pc.in hwcommon.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hwcommon.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +# dummy mtp responder +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/strs DESTINATION /etc/mtp-responder-dummy) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/descs DESTINATION /etc/mtp-responder-dummy) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/mtp-responder-dummy.socket DESTINATION /usr/lib/systemd/system) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/mtp-responder-dummy.service DESTINATION /usr/lib/systemd/system) + IF(BUILD_GTESTS STREQUAL on) ADD_SUBDIRECTORY(unittest) ENDIF() diff --git a/hw/usb_gadget_common.c b/hw/usb_gadget_common.c index 2ecef99..fb6a986 100644 --- a/hw/usb_gadget_common.c +++ b/hw/usb_gadget_common.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -522,6 +523,17 @@ int simple_translator_open(struct hw_info *info, simple_translator->id_to_gadget = simple_id_to_gadget; simple_translator->cleanup_gadget = simple_cleanup_gadget; + /* Use mtp-responder-dummy.socket when there is no mtp-responser.socket. + * + * The mtp-responder.socket is special in the configfs environment. + * If mtp-responder.socket is missing, gadget configuration will fail. + * As a result, all usb operations do not work properly. + * So in environments that mtp doesn't support, use dummy mtp. + */ + if (access("/usr/lib/systemd/system/mtp-responder.socket", F_OK)) { + _available_funcs[USB_FUNCTION_IDX_MTP]->ffs_service = "mtp-responder-dummy"; + } + *common = &simple_translator->common; return 0; } diff --git a/mtp-responder-dummy/descs b/mtp-responder-dummy/descs new file mode 100644 index 0000000000000000000000000000000000000000..0bffd510200d70837af85cee78b0767780ab3636 GIT binary patch literal 80 zcmZQ(U|GBAN2pEiTPVSMUu9U;qFiAOs%( literal 0 HcmV?d00001 diff --git a/packaging/libdevice-node.spec b/packaging/libdevice-node.spec index 2f9b9f0..809904f 100644 --- a/packaging/libdevice-node.spec +++ b/packaging/libdevice-node.spec @@ -54,6 +54,10 @@ make %{?jobs:-j%jobs} %manifest %{name}.manifest %license LICENSE.Apache-2.0 %{_libdir}/*.so.* +%{_unitdir}/mtp-responder-dummy.socket +%{_unitdir}/mtp-responder-dummy.service +/etc/mtp-responder-dummy/strs +/etc/mtp-responder-dummy/descs %files devel %manifest %{name}.manifest -- 2.34.1