Composite RCOutput class

I’m slowly porting ardupilot to a new Linux target and trying to mainline separable chunks that can be useful for everybody. One such point is DShot support on Linux and I’d love some architectural feedback on what I’m about to do so that it conforms with the others’ code and is generally sound.

In Linux there are several RCOutput classes depending on the board unlike the ChibiOS HAL. So if I was to add DShot I’d need to specifically pick a specific backend to nest it under which would make the code immediately non portable. Moreover there can be several DShot generation options depending on the platform too, so we end up with NxM matrix. My take on this is the following:

  1. Create a new RCOutput_Composite abstraction that inherits the normal RCOutput.
  2. Instead of implementing a specific logic the instance of that class would consume two or several specific backend RCOutput instances, e.g. one is RCOutput_SysFs and one is the upcoming RCOutput_DShot_GPIO.
  3. Each of the backends gets its set of the channels to work on. That can be either a static list during the initialization, or something like taking MOT_PWM_TYPE into account and dynamically distributing the channels between a DShot and non-DShot class, like the ChibiOS sort of does to report the RC banner.
  4. The incoming calls on the composite instance are routed according to the internal map of the channels to the final implementation instances.

E.g. something like this in pseudocode for the static version:

#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_SOMENEWBOARD
static RCOutput_Sysfs rcoutPwmDriver(<...>);
static RCOutput_DShot_GPIO rcoutDShotDriver(<...>);
static RCOutputComposite rcoutDriver {
    { rcoutPwmDriver, { 5, 6, 7, 8 } },
    { rcoutDShotDriver, { 1, 2, 3, 4 } },
};

This could also be useful for other more exotic scenarios like a board having 2 good HW PWM outputs that can be accessed directly via sysfs and for the rest we use PCA (yes I know you can get PCA to show up under sysfs via a kernel driver, just thinking aloud).

Is this a good idea?