• Hans Verkuil's avatar
    media: cec: keep track of outstanding transmits · b13f60e7
    Hans Verkuil authored
    commit 32804fcb upstream.
    
    I noticed that repeatedly running 'cec-ctl --playback' would occasionally
    select 'Playback Device 2' instead of 'Playback Device 1', even though there
    were no other Playback devices in the HDMI topology. This happened both with
    'real' hardware and with the vivid CEC emulation, suggesting that this was an
    issue in the core code that claims a logical address.
    
    What 'cec-ctl --playback' does is to first clear all existing logical addresses,
    and immediately after that configure the new desired device type.
    
    The core code will poll the logical addresses trying to find a free address.
    When found it will issue a few standard messages as per the CEC spec and return.
    Those messages are queued up and will be transmitted asynchronously.
    
    What happens is that if you run two 'cec-ctl --playback' commands in quick
    succession, there is still a message of the first cec-ctl command being transmitted
    when you reconfigure the adapter again in the second cec-ctl command.
    
    When the logical addresses are cleared, then all information about outstanding
    transmits inside the CEC core is also cleared, and the core is no longer aware
    that there is still a transmit in flight.
    
    When the hardware finishes the transmit it calls transmit_done and the CEC core
    thinks it is actually in response of a POLL messages that is trying to find a
    free logical address. The result of all this is that the core thinks that the
    logical address for Playback Device 1 is in use, when it is really an earlier
    transmit that ended.
    
    The main transmit thread looks at adap->transmitting to check if a transmit
    is in progress, but that is set to NULL when the adapter is unconfigured.
    adap->transmitting represents the view of userspace, not that of the hardware.
    So when unconfiguring the adapter the message is marked aborted from the point
    of view of userspace, but seen from the PoV of the hardware it is still ongoing.
    
    So introduce a new bool transmit_in_progress that represents the hardware state
    and use that instead of adap->transmitting. Now the CEC core waits until the
    hardware finishes the transmit before starting a new transmit.
    Signed-off-by: 's avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
    Cc: <stable@vger.kernel.org>      # for v4.18 and up
    Signed-off-by: 's avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    b13f60e7
Name
Last commit
Last update
..
davinci Loading commit data...
drv-intf Loading commit data...
i2c Loading commit data...
tpg Loading commit data...
cec-notifier.h Loading commit data...
cec-pin.h Loading commit data...
cec.h Loading commit data...
demux.h Loading commit data...
dmxdev.h Loading commit data...
dvb-usb-ids.h Loading commit data...
dvb_ca_en50221.h Loading commit data...
dvb_demux.h Loading commit data...
dvb_frontend.h Loading commit data...
dvb_math.h Loading commit data...
dvb_net.h Loading commit data...
dvb_ringbuffer.h Loading commit data...
dvb_vb2.h Loading commit data...
dvbdev.h Loading commit data...
imx.h Loading commit data...
media-device.h Loading commit data...
media-devnode.h Loading commit data...
media-entity.h Loading commit data...
media-request.h Loading commit data...
mpeg2-ctrls.h Loading commit data...
rc-core.h Loading commit data...
rc-map.h Loading commit data...
rcar-fcp.h Loading commit data...
soc_camera.h Loading commit data...
tuner-types.h Loading commit data...
tuner.h Loading commit data...
tveeprom.h Loading commit data...
v4l2-async.h Loading commit data...
v4l2-clk.h Loading commit data...
v4l2-common.h Loading commit data...
v4l2-ctrls.h Loading commit data...
v4l2-dev.h Loading commit data...
v4l2-device.h Loading commit data...
v4l2-dv-timings.h Loading commit data...
v4l2-event.h Loading commit data...
v4l2-fh.h Loading commit data...
v4l2-flash-led-class.h Loading commit data...
v4l2-fwnode.h Loading commit data...
v4l2-image-sizes.h Loading commit data...
v4l2-ioctl.h Loading commit data...
v4l2-mc.h Loading commit data...
v4l2-mediabus.h Loading commit data...
v4l2-mem2mem.h Loading commit data...
v4l2-rect.h Loading commit data...
v4l2-subdev.h Loading commit data...
videobuf-core.h Loading commit data...
videobuf-dma-contig.h Loading commit data...
videobuf-dma-sg.h Loading commit data...
videobuf-vmalloc.h Loading commit data...
videobuf2-core.h Loading commit data...
videobuf2-dma-contig.h Loading commit data...
videobuf2-dma-sg.h Loading commit data...
videobuf2-dvb.h Loading commit data...
videobuf2-memops.h Loading commit data...
videobuf2-v4l2.h Loading commit data...
videobuf2-vmalloc.h Loading commit data...
vsp1.h Loading commit data...