1
0
Fork 0
Commit Graph

55 Commits (134bf98c5596605af90f104716ef912e8f7eb56b)

Author SHA1 Message Date
Hans Verkuil 490d84f6d7 media: cec: forgot to cancel delayed work
If the wait for completion was interrupted, then make sure to cancel
any delayed work.

This can only happen if a transmit is waiting for a reply, and you press
Ctrl-C or reboot/poweroff or something like that which interrupts the
thread waiting for the reply and then proceeds to delete the CEC message.

Since the delayed work wasn't canceled, once it would trigger it referred
to stale data and resulted in a kernel oops.

Fixes: 7ec2b3b941 ("cec: add new tx/rx status bits to detect aborts/timeouts")

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org>      # for v4.18 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-15 09:57:52 -04:00
Hans Verkuil 7d867a1b76 media: cec: fix the Signal Free Time calculation
The calculation of the Signal Free Time in the framework was not
correct. If a message was received, then the next transmit should be
considered a New Initiator and use a shorter SFT value.

This was not done with the result that if both sides where continually
sending messages, they both could use the same SFT value and one side
could deny the other side access to the bus.

Note that this fix does not take the corner case into account where
a receive is in progress when you call adap_transmit.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org>      # for v4.18 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-05 11:27:15 -04:00
Hans Verkuil 7ec2b3b941 media: cec: add new tx/rx status bits to detect aborts/timeouts
If the HDMI cable is disconnected or the CEC adapter is manually
unconfigured, then all pending transmits and wait-for-replies are
aborted. Signal this with new status bits (CEC_RX/TX_STATUS_ABORTED).

If due to (usually) a driver bug a transmit never ends (i.e. the
transmit_done was never called by the driver), then when this times
out the message is marked with CEC_TX_STATUS_TIMEOUT.

This should not happen and is an indication of a driver bug.

Without a separate status bit for this it was impossible to detect
this from userspace.

The 'transmit timed out' kernel message is now a warning, so this
should be more prominent in the kernel log as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org>      # for v4.18 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-05 11:22:39 -04:00
Hans Verkuil f94d463f1b media: cec: remove cec-edid.c
Move cec_get_edid_phys_addr() to cec-adap.c. It's not worth keeping
a separate source for this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org>      # for v4.17 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-09-24 09:11:06 -04:00
Hans Verkuil 4786b0d6f3 media: cec: add support for 5V signal testing
Add support for the new 5V CEC events

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25 07:11:48 -04:00
Hans Verkuil 7367815849 media: cec: fix wrong tx/rx_status values when canceling a msg
When a message was canceled it could return tx_status with
both OK and MAX_RETRIES set, which is illegal.

If a canceled message was waiting for a reply, then rx_status
wasn't updated, so set that as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-28 16:25:25 -04:00
Hans Verkuil 6ec1cbf6b1 media: cec: improve CEC pin event handling
It turns out that the struct cec_fh event buffer size of 64 events
(64 for CEC_EVENT_PIN_CEC_LOW and 64 for _HIGH) is too small. It's
about 160 ms worth of events and if the Raspberry Pi is busy, then it
might take too long for the application to be scheduled so that it can
drain the pending events. Increase these buffers to 800 events which
is at least 2 seconds worth of events.

There is also a FIFO in between the interrupt and the cec-pin thread.
The thread passes the events on to the CEC core. It is important that
should this FIFO fill up the cec core will be informed that events
have been lost so this can be communicated to the user by setting
CEC_EVENT_FL_DROPPED_EVENTS.

It is very hard to debug CEC problems if events were lost without
informing the user of that fact.

If events were dropped due to the FIFO filling up, then the debugfs
status file will let you know how many events were dropped.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-22 08:16:52 -04:00
Hans Verkuil 1b3963509a media: cec: improve debugging
cec_transmit_msg_fh() first checked the message for errors, and only
after the message was found to be valid did it log the message contents.

However, that makes it hard to associate an error in the kernel log with
the message since the message contents was never logged in that case.

So swap the order: first log the message (once some very basic checks
are done), and only after that check for errors.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26 08:12:49 -05:00
Hans Verkuil b4e30a9e05 media: cec: add SPDX license info
Replace the old license information with the corresponding SPDX
license.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-14 13:16:03 -05:00
Sean Young 57c642cb45 media: cec: move cec autorepeat handling to rc-core
CEC autorepeat is different than other protocols. Autorepeat is triggered
by the first repeated user control pressed CEC message, rather than a
fixed REP_DELAY.

This change also does away with the KEY_UP event directly after the first
KEY_DOWN event, which was used to stop autorepeat from starting.

See commit a9a249a2c9 ("media: cec: fix remote control passthrough")
for the original change.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-14 10:35:30 -05:00
Hans Verkuil 48ea2e926b media: cec: add the adap_monitor_pin_enable op
Some devices can monitor the CEC pin using an interrupt, but you
only want to enable the interrupt if you actually switch to pin
monitoring mode.

So add a new op that is called when pin monitoring needs to be
switched on or off.

Also fix a small bug where the initial CEC pin event was sent
again when calling S_MODE twice with the same CEC_MODE_MONITOR_PIN
mode.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-08 11:10:00 -05:00
Hans Verkuil 2c21ac0ae4 media: cec-adap: add '0x' prefix when printing status
It's not clear if the transmit status that is printed when debugging
is enabled is hex or decimal. Add 0x prefix to make this explicit.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-08 10:39:38 -05:00
Mauro Carvalho Chehab cf09e3c904 Linux 4.14-rc2
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJZyEIXAAoJEHm+PkMAQRiGNYYH/0VsoYYN4WNYtfetKcHWT27G
 FZYu/yr+MpybcHhB74eiYEGK2qwR6OV1l9H4WVfESrbnT84Dbb7QdDssD2YCD4Lw
 oFMtr8qQmfHBxlRHIlk4UNSrcy+xketMNvuHjPklKqtrLutVQ4D9HR0yLOVKoxyR
 hoxV6F6OnDCekhPjcBQZ+xDYuzTnF8fCqk1szvv4X2DBbffNX9Fvr9eVnS4bgML6
 gfNiEplq4PiUXi3yPP2zRpdwRGDVpw8Wh++iroYgUFZ/LtVURI83GpeLyP0cs/W6
 MygH+joQovOzkJ26MO8/SATdjvXn7NjBcjrDT61GrVhawJOkcnnQQvRpep3ih14=
 =wrF8
 -----END PGP SIGNATURE-----

Merge tag 'v4.14-rc2' into patchwork

Linux 4.14-rc2

* tag 'v4.14-rc2': (12066 commits)
  Linux 4.14-rc2
  tpm: ibmvtpm: simplify crq initialization and document crq format
  tpm: replace msleep() with  usleep_range() in TPM 1.2/2.0 generic drivers
  Documentation: tpm: add powered-while-suspended binding documentation
  tpm: tpm_crb: constify acpi_device_id.
  tpm: vtpm: constify vio_device_id
  security: fix description of values returned by cap_inode_need_killpriv
  x86/asm: Fix inline asm call constraints for Clang
  objtool: Handle another GCC stack pointer adjustment bug
  inet: fix improper empty comparison
  net: use inet6_rcv_saddr to compare sockets
  net: set tb->fast_sk_family
  net: orphan frags on stand-alone ptype in dev_queue_xmit_nit
  MAINTAINERS: update git tree locations for ieee802154 subsystem
  SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags
  SMB3: handle new statx fields
  arch: remove unused *_segments() macros/functions
  parisc: Unbreak bootloader due to gcc-7 optimizations
  parisc: Reintroduce option to gzip-compress the kernel
  apparmor: fix apparmorfs DAC access permissions
  ...
2017-09-29 05:24:10 -04:00
Hans Verkuil 333ef6bd10 media: cec: add CEC_EVENT_PIN_HPD_LOW/HIGH events
Add support for two new low-level events: PIN_HPD_LOW and PIN_HPD_HIGH.

This is specifically meant for use with the upcoming cec-gpio driver
and makes it possible to trace when the HPD pin changes. Some HDMI
sinks do strange things with the HPD and this makes it easy to debug
this.

Note that this also moves the initialization of a devnode mutex and
list to the allocate_adapter function: if the HPD is high, then as
soon as the HPD interrupt is created an interrupt occurs and
cec_queue_pin_hpd_event() is called which requires that the devnode
mutex and list are initialized.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-09-23 07:43:04 -04:00
Jose Abreu 845d6524d6 media: cec: Respond to unregistered initiators, when applicable
Running CEC 1.4 compliance test we get the following error on test
11.1.6.2: "ERROR: The DUT did not broadcast a
<Report Physical Address> message to the unregistered device."

Fix this by letting GIVE_PHYSICAL_ADDR message respond to unregistered
device. Also, GIVE_DEVICE_VENDOR_ID and GIVE_FEATURES fall in the
same category so, respond also to these messages.

With this fix we pass CEC 1.4 official compliance.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org>      # for v4.10 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-09-23 07:30:16 -04:00
Andrew Morton c848c49a62 drivers/media/cec/cec-adap.c: fix build with gcc-4.4.4
gcc-4.4.4 has issues with initialization of anonymous unions:

  drivers/media/cec/cec-adap.c: In function 'cec_queue_msg_fh':
  drivers/media/cec/cec-adap.c:184: error: unknown field 'lost_msgs' specified in initializer

work around this.

Fixes: 6b2bbb0874 ("media: cec: rework the cec event handling")
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-09-13 18:53:15 -07:00
Hans Verkuil 152b0a9a3d media: cec: ensure that adap_enable(false) is called from cec_delete_adapter()
When the adapter is removed the cec_delete_adapter() call attempts
to set the physical address to INVALID by calling __cec_s_phys_addr()
and so disabling the adapter.

However, __cec_s_phys_addr checks if the device node was unregistered
and just returns in that case.

This means that the adap_enable callback is never called with 'false'
to disable the CEC adapter. Most drivers don't care, but some need
to do cleanup here.

Change the test so the adapter is correctly disabled, even when the
device node is unregistered.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-26 08:32:15 -04:00
Sean Young 6d741bfed5 media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_*
RC_TYPE is confusing and it's just the protocol. So rename it.

Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sean Young <sean@mess.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 10:02:48 -04:00
Hans Verkuil a9a249a2c9 media: cec: fix remote control passthrough
The 'Press and Hold' operation was not correctly implemented, in
particular the requirement that the repeat doesn't start until
the second identical keypress arrives. The REP_DELAY value also
had to be adjusted (see the comment in the code) to achieve the
desired behavior.

The 'enabled_protocols' field was also never set, fix that too. Since
CEC is a fixed protocol the driver has to set this field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 09:59:34 -04:00
Hans Verkuil 9a6b2a8740 media: cec: rename pin events/function
The CEC_EVENT_PIN_LOW/HIGH defines and the cec_queue_pin_event() function
did not specify that these were about CEC pin events.

Since in the future there will also be HPD pin events it is wise to rename
the event defines and function to CEC_EVENT_PIN_CEC_LOW/HIGH and
cec_queue_pin_cec_event() now before these become part of the ABI.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 08:14:03 -04:00
Mauro Carvalho Chehab 1d54267b23 Linux 4.13-rc4
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJZh8YYAAoJEHm+PkMAQRiG46QIAKOBbLlOY38zIJwDfJs6ydvH
 eFLryznS7RM2w0Gw1RyVAyWS43QS9RUNGDMa4UOb9AvurBHYpK29t1uq6LejQ/hn
 2Uvxuq95qEVVYzN1OA3WzLKUa35g3qRM9rTYFz7xGMRp2Ldk/aPRi/PVJLhSO3YQ
 HFRLsfNMWTkSR4imuxm7NS+cYMcqWbDbanvW5IwQ+RFRPo8Ac1PbFpGUdVtar6+O
 Fm3GLBsRB3dijJwYyWQKeDvtLr608i50by4yS7EIAqbUSfoDpJEyTL57oTCRok7P
 5ZycGpK4bXWF0OpBWpKgrFO5tB7xfzUDa3TmNhS3Q8ep4KLHNXwM3V6p8Y+YZco=
 =FId5
 -----END PGP SIGNATURE-----

Merge tag 'v4.13-rc4' into patchwork

Linux 4.13-rc4

* tag 'v4.13-rc4': (863 commits)
  Linux 4.13-rc4
  Fix compat_sys_sigpending breakage
  ext4: fix copy paste error in ext4_swap_extents()
  ext4: fix overflow caused by missing cast in ext4_resize_fs()
  ext4, project: expand inode extra size if possible
  ext4: cleanup ext4_expand_extra_isize_ea()
  ext4: restructure ext4_expand_extra_isize
  ext4: fix forgetten xattr lock protection in ext4_expand_extra_isize
  ext4: make xattr inode reads faster
  ext4: inplace xattr block update fails to deduplicate blocks
  ext4: remove unused mode parameter
  ext4: fix warning about stack corruption
  ext4: fix dir_nlink behaviour
  ext4: silence array overflow warning
  ext4: fix SEEK_HOLE/SEEK_DATA for blocksize < pagesize
  platform/x86: intel-vbtn: match power button on press rather than release
  ext4: release discard bio after sending discard commands
  sparc64: Fix exception handling in UltraSPARC-III memcpy.
  arm64: avoid overflow in VA_START and PAGE_OFFSET
  arm64: Fix potential race with hardware DBM in ptep_set_access_flags()
  ...
2017-08-08 05:38:41 -04:00
Hans Verkuil bd34ca8758 media: cec: cec_transmit_attempt_done: ignore CEC_TX_STATUS_MAX_RETRIES
The switch in cec_transmit_attempt_done() should ignore the
CEC_TX_STATUS_MAX_RETRIES status bit.

Calling this function with e.g. CEC_TX_STATUS_NACK | CEC_TX_STATUS_MAX_RETRIES
is perfectly legal and should not trigger the WARN(1).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-26 05:46:43 -04:00
Hans Verkuil 688318c35a media: cec: be smarter about detecting the number of attempts made
Some hardware does more than one attempt. So when it calls
cec_transmit_done when an error occurred it will e.g. use an error count
of 2 instead of 1.

The framework always assumed a single attempt, but now it is smarter
and will sum the counters to detect how many attempts were made.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18 12:58:56 -03:00
Hans Verkuil b8d62f50b1 media: cec: add core support for low-level CEC pin monitoring
Add support for the new MONITOR_PIN mode.

Add the cec_pin_event function that the CEC pin code will call to queue pin
change events.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18 12:55:38 -03:00
Hans Verkuil 6b2bbb0874 media: cec: rework the cec event handling
Event handling was always fairly simplistic since there were only
two events. With the addition of pin events this needed to be redesigned.

The state_change and lost_msgs events are now core events with the
guarantee that the last state is always available. The new pin events
are a queue of events (up to 64 for each event) and the oldest event
will be dropped if the application cannot keep up. Lost events are
marked with a new event flag.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18 12:49:36 -03:00
Hans Verkuil 0861ad14c6 media: cec: add *_ts variants for transmit_done/received_msg
Currently the transmit_(attempt_)done and received_msg functions set
the timestamp themselves. For the upcoming low-level pin API we need
to pass this as an argument instead. So make _ts variants that allow
the caller to specify the timestamp.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18 12:47:02 -03:00
Hans Verkuil bb789e03f2 media: cec: improve transmit timeout logging
Kernel logging messes up the upcoming low-level CEC monitoring support
which is very time-sensitive. So change the debug level of this message
but keep a counter that is shown in the debugfs status log.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18 12:45:50 -03:00
Hans Verkuil 15e809e961 media: cec: only increase the seqnr if CEC_TRANSMIT would return 0
The transmit code would increase the sequence number first thing, even though
CEC_TRANSMIT would return an error due to a malformatted cec_msg struct later
on.

While valid behavior, this had the disadvantage of producing holes in the
sequence list that made debugging harder.

Only increase the sequence number when the whole message is validated.
When debugging (i.e. with cec-ctl -M) the sequence numbering is now nicely
increasing by 1 per message.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18 12:37:21 -03:00
Hans Verkuil 299708e45e media: cec: clear all cec_log_addrs fields
The CEC version, vendor ID and OSD name were not cleared when clearing the
current set of logical addresses. This was unexpected and somewhat confusing,
so reset all these fields to their default values. Also document this since
the documentation wasn't quite clear either.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18 12:36:19 -03:00
Hans Verkuil f902c1e95d [media] cec: add CEC_CAP_NEEDS_HPD
Add a new capability CEC_CAP_NEEDS_HPD. If this capability is set
then the hardware can only use CEC if the HDMI Hotplug Detect pin
is high. Such hardware cannot handle the corner case in the CEC specification
where it is possible to transmit messages even if no hotplug signal is
present (needed for some displays that turn off the HPD when in standby,
but still have CEC enabled).

Typically hardware that needs this capability have the HPD wired to the CEC
block, often to a 'power' or 'active' pin.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 06:54:34 -03:00
Hans Verkuil c94cdc1e0c [media] cec: add cec_transmit_attempt_done helper function
A simpler variant of cec_transmit_done to be used where the HW does
just a single attempt at a transmit. So if the status indicates an
error, then the corresponding error count will always be 1 and this
function figures that out based on the status argument.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 06:52:33 -03:00
Hans Verkuil 23111ec304 [media] cec: add cec_s_phys_addr_from_edid helper function
This function simplifies the integration of CEC in DRM drivers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 06:51:21 -03:00
Hans Verkuil a7a04b5b2c [media] cec: improve debug messages
- use __func__ instead of writing the full function name
- drop debug message in cec_config_log_addr since the same information
  will be reported later
- use debug level 1 for errors and infrequent events, use level 2 for
  debugging CEC message traffic
- log when a transmit is retried, very useful to know when debugging
- debug messages now all start with lower case

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-07 09:29:08 -03:00
Hans Verkuil 20249f8423 [media] cec: drop MEDIA_CEC_DEBUG
Just depend on DEBUG_FS, no need to invent a new kernel config.
Especially since CEC can be enabled by drm without enabling
MEDIA_SUPPORT.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-04 15:23:36 -03:00
Hans Verkuil 5f2c467c54 [media] cec: add MEDIA_CEC_RC config option
Add an explicit config option to select whether the CEC remote control
messages are to be passed on to the RC subsystem or not.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-19 06:54:15 -03:00
Hans Verkuil a8e97e531a [media] cec: don't Feature Abort msgs from Unregistered
Feature Abort shouldn't be sent in reply to messages from Unregistered,
since that would make it a broadcast message.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-22 11:15:55 -03:00
Hans Verkuil 79cabaa320 [media] cec: log reason for returning -EINVAL
When validating the struct cec_s_log_addrs input a debug message is printed
for all except two of the 'return -EINVAL' paths.

Also log the reason for the missing two paths.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-22 11:15:23 -03:00
Hans Verkuil 25c2107896 [media] cec: improve cec_transmit_msg_fh logging
Several error paths didn't log why an error was returned. Add this.

Also handle the corner case of "adapter is unconfigured AND the message
is from Unregistered to TV AND reply is non-zero" separately and return
EINVAL in that case, since it really is an invalid value and not an
unconfigured CEC device.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-22 11:14:45 -03:00
Hans Verkuil 5a137df1d6 [media] cec: use __func__ in log messages
The hardcoded function name is actually wrong. Use __func__ instead.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-22 11:13:58 -03:00
Hans Verkuil 533a3f7bc7 [media] cec: allow specific messages even when unconfigured
The CEC specifications explicitly allows you to send poll messages and
Image/Text View On messages to a TV, even when unconfigured (i.e. there is
no hotplug signal detected). Some TVs will pull the HPD low when switching
to another input, or when going into standby, but CEC should still be
allowed to wake up such a display.

Add support for sending messages with initiator 0xf (Unregistered) and
destination 0 (TV) when no physical address is present.

This also required another change: the CEC adapter has to stay enabled as
long as 1) the CEC device is configured or 2) at least one filehandle is open
for the CEC device.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-22 11:11:17 -03:00
Hans Verkuil b39f93efc6 [media] cec: improve flushing queue
When the adapter is unloaded or unconfigured, then all transmits and
pending waits should be flushed.

Move this code into its own function and improve the code that cancels
delayed work to avoid having to unlock adap->lock.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-22 11:09:04 -03:00
Hans Verkuil 42980da2eb [media] cec: initiator should be the same as the destination for, poll
Poll messages that are used to allocate a logical address should
use the same initiator as the destination. Instead, it expected that
the initiator was 0xf which is not according to the standard.

This also had consequences for the message checks in cec_transmit_msg_fh
that incorrectly rejected poll messages with the same initiator and
destination.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-13 14:34:11 -02:00
Hans Verkuil f9f96fc10c [media] cec: fix wrong last_la determination
Due to an incorrect condition the last_la used for the initial attempt at
claiming a logical address could be wrong.

The last_la wasn't converted to a mask when ANDing with type2mask, so that
test was broken.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30 11:42:31 -02:00
Hans Verkuil f60f35609f [media] cec: fix race between configuring and unconfiguring
This race was discovered by running cec-compliance -A with the cec module debug
parameter set to 2: suddenly the test would fail.

It turns out that this happens when the test configures the adapter in
non-blocking mode, then it waits for the CEC_EVENT_STATE_CHANGE event and once
the event is received it unconfigures the adapter.

What happened was that the unconfigure was executed while the configure was
still transmitting the Report Features and Report Physical Address messages.
This messed up the internal state of the cec_adapter.

The fix is to transmit those messages with the adap->lock mutex held (this will
just queue them up in the internal transmit queue, and not actually transmit
anything yet). Only unlock the mutex once everything is done. The main thread
will dequeue the messages from the internal transmit queue and transmit them
one by one, unless an unconfigure was done, and in that case any messages are
just dropped.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-21 07:03:27 -02:00
Hans Verkuil d3d64bc740 [media] cec: move cec_report_phys_addr into cec_config_thread_func
It's only a small function and this makes it easier to switch to
transmitting the message with adap->lock held in the next patch.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-21 07:02:36 -02:00
Hans Verkuil 52bc30fda9 [media] cec: replace cec_report_features by cec_fill_msg_report_features
The fill function just fills in the cec_msg struct, it doesn't transmit
the message. This is now done explicitly.

This makes it possible to switch to transmitting this message with adap->lock
held.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-21 07:01:59 -02:00
Hans Verkuil 7af26f889e [media] cec: update log_addr[] before finishing configuration
The loop that sets the unused logical addresses to INVALID should be
done before 'configured' is set to true. This ensures that cec_log_addrs
is consistent before it will be used.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-21 07:01:12 -02:00
Hans Verkuil a24f56d479 [media] cec: CEC_MSG_GIVE_FEATURES should abort for CEC version < 2
This is a 2.0 only message, so it should return Feature Abort if the
adapter is configured for CEC version 1.4.

Right now it does nothing, which means that the sender will time out.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-21 07:00:46 -02:00
Hans Verkuil 1204761236 [media] cec: when canceling a message, don't overwrite old status info
When a pending message was canceled (e.g. due to a timeout), then the
old tx_status info was overwritten instead of ORed. The same happened
with the tx_error_cnt field. So just modify them instead of overwriting
them.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-21 06:59:57 -02:00
Hans Verkuil f3854973f1 [media] cec: fix report_current_latency
In the (very) small print of the REPORT_CURRENT_LATENCY message there is a
line that says that the last byte of the message (audio out delay) is only
present if the 'audio out compensated' value is 3.

I missed this, and so if this message was sent with a total length of 6 (i.e.
without the audio out delay byte), then it was rejected by the framework
since a minimum length of 7 was expected.

Fix this minimum length check and update the wrappers in cec-funcs.h to do
the right thing based on the message length.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-21 06:59:13 -02:00