- 24 Aug, 2018 26 commits
-
-
spiiroin authored
Implement enter/leave mass-storage mode functionality also for the configfs backend. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Gadget is programmed according to mtp_mode requirements regardless of availability of mtp daemon - which leaves non-functional mtp_mode supposedly active. Switch to fallback mode if mtp daemon can't be started. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Using MODE_CHARGING_FALLBACK as mode switch failure fallback causes retriggering of "ask" mode. And overriding only higher level state data leads to subtle issues later on. Use MODE_CHARGING as failure fallback, and override both high and low level mode state info when requested mode can't be activated. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Mode transition blocks udev event processing. If user disconnects and reconnects the cable multiple times during the blockade, usb-moded will act on stale events that might not reflect the actual state of the usb connection. Handle disconnects immediately, but delay acting on connects so that sequences of multiple disconnects and connects get compressed into single transition to undefined mode possibly followed by single transition to appropriated connected mode. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Especially switch to mtp_mode can take a long time to finish. Use transitional "busy" mode as an enabler for ui showing a spinner when mode change takes long enough to cause confusion for users. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
The mtp functionality is started roughly as follows: 1. usb-moded completes whole gadget configuration, and then 2. signals mtp mode activation on D-Bus 3. msyncd sees the mode change and loads mtp plugin 4. mtp plugin writes endpoint configuration, and then 5. scans storage ares to enumerate files exposed via mtp, but 6. does not really respond to ptp/mtp requests until storages are ready The problems are: While the above sequence has worked with with android usb, it does cause timing issues for usb enumeration and longer than expected response times from pc side mtp initiator point of view. Additionally when configfs is used, the gadget configuration can't even be completed before mtp daemon gets a chance to write configuration data to the control endpoint. To remedy the situation the following changes are made: 1. buteo-mtp-qt5-sync-plugin package is removed from the system -> mtp functionality is no longer handled by msyncd process 2. mtp daemon is made to enumerate storage content before writing config data to control endpoint -> when usb enumeration is possible, mtp daemon is already ready to handle commands from initiator 3. usb-moded explicitly starts/stops mtp daemon when it is about to activate/deactivate mtp_mode -> usb stays configured in charging mode until it is ready to handle mtp This patch handles step (3). Step (2) is in buteo-mtp-qt5 >= 0.5.0, and (1) needs to be fixed in device specific package configuration. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Writing empty string gets ignored. This causes problems for example when switching from mass-storage mode to charging only as the lua/file attribute does not get cleared. Use a wrapper function to append a linefeed to strings written to sysfs. This avoids zero length writes and makes behavior similar to how redirected echo from command line works. Also tweak unexpected-sysfs-content-change tracker so that it ignores changes in whitespace. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Code duplication and interleaving of kernel module vs android usb logic makes it difficult to add support for configfs based systems. Use helper functions for common tasks. Use explicit checks for what backend should be used. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
All "normal" modes ignore syfs_path and sysfs_reset_value configuration values. Remove redundant lines from sample configuration files and adjust configuration file sanity checking rules. Also fix a GKeyFile leak on error path in dynconfig_read_mode_file(). Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Long member and key names, and interleaved debug logging makes the config parsing code difficult to read. Add whitespace to increase ease visual inspection. Move debug logging to occur after each configuration block has been parsed. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Line buffer allocated/managed by getline() is not released. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Handling "connected to pc" and "connected to charger" as separate boolean states just complicates things. Move cable_state_t enumeration values from udev module to usb_moded.h to make them generally available. Utilize cable_state_t also within usb_moded.c module. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
If gadget configuration / other mode selection related activites fail, usb-moded attempts to activate charging only configuration / does fallback to undefined mode. This situation is not propagated upwards and thus incorrect information is exposed over D-Bus. Add feedback function that lower level functionality can use to signal failures / successfully completed mode change, and delay broadcasting of D-Bus signals until completing the change. As the mode change actions can potentially block for extended periods of time and render usb-moded unresponsive, mark places where worker thread signaling could be utilized instead of function calls. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Looks like trigger_udev_sysname variable stays valid only because udev_device_new_from_syspath() return value is leaked in trigger_init(). Take a copy of udev_device_get_sysname() return value instead on relying on borrowed string pointer staying valid. Remove all mid-function returns, release unneeded resources on success, and all acquired resources in case of failure. Having a boolean function return false on success / true on failure is a bit confusing, so rectify that while at it. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Static variables do not have unique names and are shadowed by function parameters even within this compilation module. Make the code easier to follow by using common prefix for module variables. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
When usb-moded is compiled with MEEGOLOCK feature enabled, only limited functionality is available while device is locked. However the scattered use of MEEGOLOCK compilation time conditionals makes the code unnecessarily difficult to read. Add a utility function to handle evaluation of the can-export state and remove the now unnecessary preprocessor conditionals. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
The USB_CONNECTED_DIALOG_SHOW signal is sent just before the usb mode changes to MODE_ASK. Handling it as a part of activity on mode change instead of as precursor to mode change makes the logic more robust and a bit simpler. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Cable connect/disconnect is detected at udev module - handling the related dbus signaling in the same place allows simplifying the usb mode related logic. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
The "softconnect" attributes were used to configure android usb specific enable/disable sysfs controls. These attributes are no longer used, and at least in theory the same config files can be used for both android usb and configfs based systems. Remove unused attributes. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Split mode switching to three layers: Tracking cable connection state, choosing target mode, and performing required actions to activate the chosen mode. Try to minimize places where layer borders are crossed - which should work also as an enabler for moving blocking actions to separate thread later on. Arrange logic in such manner that usb gadget is always configured as being able to serve some function - fallback being the dummy mass_storage function used for charging. Deprecate command line options that serve no useful purpose after the changes. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Configfs wants to have numbers in '0xbeef' form while android usb wants to have 'beef'. Normalizing the output to expected format allows either form to be used in usb-moded configuration files. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Make it logically match what is available in configfs module. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
The target is to always have android usb enabled with valid function, so this workaround is not relevant anymore. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Just to make it easier for editor to handle automatic indentation, make all C comment continuation lines start with whitespace followed by '*'. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
The "buteo-mtp" package name is probably old qt4 package that does not exist anymore. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Add custom Makefile for faster smoke-test rebuilds without spending time in configure, autotools, document generation and/or rolling rpm packages. Add multiple include protection to all header files. Move function prototypes away from header files that included in the development package. Mass rename functions to have a prefix giving context for the function. For the most part the prefix is derived from the name of the compilation module containing the function. Mass normalize indentation to four spaces in all source files. Augment author lists on each source file based on git committers. Remove "inline" attributes from not-really-inlineable functions. Remove .gitignore. Remove unused modules-android.c source file. Define _GNU_SOURCE for whole build rather than in individual files. Fix resource leaks here and there. Try to avoid hard-coding android usb paths. Add configfs backend for usb cadget configuration. Probe supported backends (configfs, android usb, or kmod) on usb-moded startup and make them mutually exclusive with each other. Allow configfs and android usb control structures some time to show up if usb-moded is started during device bootup. Refactor udev event listener to utilize a state machine. Simplifies book keeping and makes pc/charger detection heuristics easier to control. Refactor mode selection to utilize three interconnected mini state machines. Allows separating logically wanted mode from mode programmed to usb and mode exposed over D-Bus. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
- 06 Jun, 2018 2 commits
-
-
spiiroin authored
-
- 05 Jun, 2018 3 commits
-
-
spiiroin authored
On some devices enumeration fails on the 1st connect after bootup unless android usb has already been set up for some function at least once. Add --android-bootup-function option that can be used on such devices to force usb-moded to program some function and then clear the function list when usb-moded is executed during device bootup. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Improves readability on narrow console sessions and allows writing multi-line explanations when/if needed. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
There are situations where usb-moded needs to behave in slightly different manner depending on whether it is executed as a part of device starup sequence or (restarted) after the device is already fully booted up. Make the related init-done functions available to all modules within usb-moded source tree. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
- 04 Apr, 2018 2 commits
-
-
spiiroin authored
-
- 29 Mar, 2018 3 commits
-
-
spiiroin authored
There were non-unique dsme message type identifiers: 0x00000320 = SET_THERMAL_STATUS = BATTERY_EMPTY_IND 0x00000506 = PROCESSWD_PING = PROCESSWD_PONG Replace custom get-message-type-name functions with common functionality made available from libdsme. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
-
- 28 Mar, 2018 4 commits
-
-
spiiroin authored
The charging_fallback() function has multiple return paths and does not always clear timer id variable "charging_timeout". This can later on lead to attempts to remove stale timer id - which causes glib to emit warnings. Clear the bookkeeping variable on entry to callback rather than just one of the possible return points. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Compilation options such as: -Wno-unused-parameter and -Wno-unused-result easily hide genuine issues. Remove such relaxations and deal with issues that surface. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
If variables are used only from one source file, make them static. If variables are truly global, put extern declaration to relevant header. Drop completely unused variables. Explicitly initialize variables to sane defaults. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-
spiiroin authored
Fix warnings about undocumented function arguments during documentation build. Fix incorrectly tagged structure/enum members. Signed-off-by:
Simo Piiroinen <simo.piiroinen@jollamobile.com>
-