I checked in initial support for Lua force_analog_av in r5475
result=force_analog_av(state)
where state 0 = don't force, 1 = on, 2 = off
result true if implemented by port (ANALOG_AV_FLAG defined), otherwise false.
Tested on D10, SX160, ELPH130, ELPH180, SX710, G7X. A few other cameras have the bit defined, but I don't know if it's verified. It is only meaningful on cameras with analog NTSC/PAL output, and not (some of?) the early ones with a A/V plug separate from the USB port.
Known issues:
On elph130 and sx160, sending force_analog_av(1) while chdkptp live view is running results in the PTP connection stalling. It's possible to reset the connection and reconnect. I suspect something in the switching process blocks PTP in some way. Turning off the live avoid this. This only appears to affect the first time analog AV is enabled.
On elph130 and sx160, switching to record after using force_analog_av(1) fails. The lens extends, but the camera isn't in rec mode, and shuts down a few seconds later with an assert in LensController.c, LensControll0 task triggered by WaitForAnyEventFlagStrictly.
This can be avoid by switching to rec before enabling analog AV. Subsequent rec/play switches seem OK.
I don't have a good idea what the mechanism behind this is.
On SX710, chdkptp live view hits a lua error "width > buffer_width" when turning analog AV off with live view running. This has to do with the buffer dimensions being updated in update_screen_dimensions (called periodically from mode_get) while the width comes directly from _GetVRAMHPixelsSize, called when the frame is requested. There error is harmless, aside from popping up a dialog. It might make sense to call update_screen_dimensions in live_view_get_data
Viewport dimensions are incorrect on many cameras in some modes (
https://chdk.setepontos.com/index.php?topic=13451.msg142423#msg142423)
This applies to using the real AV connector too. It could be fixed on a per port basis.