Commit graph

590157 commits

Author SHA1 Message Date
Hans Verkuil
b015448549 [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.

Change-Id: I161f021c2a2959bdafac38f54e5b232ae4e57188
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 52bc30fda9622f492427d484bd4dd8ee42cc4667
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:20 +08:00
Hans Verkuil
6071f25b03 [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.

Change-Id: I90608740aa37869dadcb068c93896be2cb77697e
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 7af26f889eb67db272021a939f7d4a57e96dd961
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:19 +08:00
Hans Verkuil
6ab2edc21a [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.

Change-Id: I6bdf5e08e075cf071b7f5e0b3996bc111d1f89a7
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: a24f56d47930492c94ef6875bf45adf7607ca1a4
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:19 +08:00
Hans Verkuil
bfcc5ee94d [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.

Change-Id: Id1c8a7910e6a9966f8a9ffc679845005f78e0e30
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 120476123646ba3619c90db7bcbc6f8eea53c990
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:18 +08:00
Hans Verkuil
cdbf73bc82 [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.

Change-Id: I123cc5fc2b6baca8cb2910bc687489329e81ca73
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: f3854973f196baad5be6b62d8f5ea24b0346b63f
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:18 +08:00
Hans Verkuil
d62107c2c6 [media] cec: pass parent device in register(), not allocate()
The cec_allocate_adapter function doesn't need the parent device, only the
cec_register_adapter function needs it.

Drop the cec_devnode parent field, since devnode.dev.parent can be used
instead.

This change makes the framework consistent with other frameworks where the
parent device is not used until the device is registered.

Conflicts:
	Documentation/media/kapi/cec-core.rst
	drivers/media/i2c/adv7511.c
	drivers/media/i2c/adv7604.c
	drivers/media/i2c/adv7842.c
	drivers/media/platform/vivid/vivid-cec.c
	drivers/media/platform/vivid/vivid-cec.h
	drivers/media/platform/vivid/vivid-core.c
	drivers/media/usb/pulse8-cec/pulse8-cec.c
	drivers/staging/media/s5p-cec/s5p_cec.c
	drivers/staging/media/st-cec/stih-cec.c

Change-Id: Id7a687308c4d3f2bc63ed2e8a55229b4e71fd8ed
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: f51e80804f084de269954d875c0892b081b7df3c
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
[rayz@codeaurora.org: make some changes to fix the cherry-pick conflicts: (1)
 discard the CEC documentation change. (2) discard the CEC adapter driver
 changes for other vendors.]
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:17 +08:00
Hans Verkuil
e509ffb5cc [media] cec: ignore messages that we initiated
Some CEC adapters will receive messages that they initiated. Add a
check that will ignore such messages.

Most hardware behaves correctly in this respect, but I have seen
adapters that don't, so just filter this out in the framework.

Change-Id: I5f5f361ef9135445382764659280583fa1cbe10c
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 3f98da9636029486b86eb63f0b57b91dcbd880b0
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:17 +08:00
Hans Verkuil
0f9cbbd5c3 [media] cec: zero counters in cec_received_msg()
Make sure the TX counters are zeroed in the cec_msg struct.
Non-zero TX counters make no sense when a message is received,
and applications should not see non-zero values here.

Change-Id: I36309acfe19b42b672d7b2051adf5cf514123cba
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 8991a63d1a8a01938932319c8b98f5a3420a0bb2
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:16 +08:00
Hans Verkuil
7e4ec7df7c [media] cec: an inner loop clobbered the outer loop variable
An inner for-loop reused the outer loop variable. This was
only noticeable with CEC adapters supporting more than one
logical address.

Change-Id: Ib5cd7c3130b544a991bbc188a762e330ddee2eba
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: a161bef04286e1344cd469098213a972af8fa7d6
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:16 +08:00
Hans Verkuil
5b959979fb [media] cec: sanitize msg.flags
The CEC_MSG_FL_REPLY_TO_FOLLOWERS message flag only makes sense for transmitted
messages where you want to wait for the reply.

Clear the flag in all other cases.

Change-Id: Icb52984770fe442416a8e46dff717b0849a7bdb4
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 7ae2a888eedd5a6b03849614eddd55f31793eeae
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:15 +08:00
Hans Verkuil
9764547814 [media] cec: move the CEC framework out of staging and to media
The last open issues have been addressed, so it is time to move
this out of staging and into the mainline and to move the public
cec headers to include/uapi/linux.

Conflicts:
	Documentation/media/Makefile
	drivers/media/i2c/Kconfig
	drivers/media/platform/vivid/Kconfig
	drivers/staging/media/Makefile
	drivers/staging/media/pulse8-cec/Kconfig
	drivers/staging/media/s5p-cec/Kconfig
	drivers/staging/media/st-cec/Kconfig

Change-Id: Ie46e780a7d29d773dbb9bd642059695eb580e8ad
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 0dbacebede1e4e44bf500f94d692fad05eb2c293
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
[rayz@codeaurora.org: make some modifications to the original patch to fix
 the cherry-pick conflicts. (1) discard the changes in Documentation. (2)
 discard the CEC adapter driver changes for other vendors because they are
 not needed.]
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:15 +08:00
Hans Verkuil
f2a6b60635 [media] cec: add proper support for CDC-Only CEC devices
CDC-Only CEC devices are CEC devices that can only handle CDC messages,
all other messages are ignored.

Add a flag to signal that this is a CDC-Only device and act accordingly.

Also add helper functions to identify if a CEC device is configured as a
CDC-Only device, a second TV, a switch or a processor, since these variations
cannot be determined by the logical address alone.

Change-Id: I9b814a5da3bca913d784bfe5fc508cdf06a5fea4
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: a69a168a1bd470cb8a8c5f2ff4b54463de615226
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:14 +08:00
Hans Verkuil
69a950e1e3 [media] cec: accept two replies for CEC_MSG_INITIATE_ARC
The CEC_MSG_INITIATE_ARC message is special since it is the ONLY
CEC message that accepts two possible valid replies:

CEC_MSG_REPORT_ARC_INITIATED and CEC_MSG_REPORT_ARC_TERMINATED.

So if the transmitted message is CEC_MSG_INITIATE_ARC and the remote
side replied with CEC_MSG_REPORT_ARC_INITIATED or CEC_MSG_REPORT_ARC_TERMINATED,
then a msg->reply value of CEC_MSG_REPORT_ARC_INITIATED or
CEC_MSG_REPORT_ARC_TERMINATED will match either reply.

I thought about either adding a second reply2 field, but that's ugly
for all other messages that have only one reply, and what if in the
future a new message is added that can have three replies?

Another option would be to add a cec_msg flag, but really, the combination
of CEC_MSG_REPORT_ARC_INITIATED and a reply value of one of the two
possible replies already functions as a flag.

Another advantage of this approach is that it is safe to re-use a
cec_msg struct. No need to zero a flags field or a reply2 field.

So since this really is an exception in the CEC specification, I
decided to implement it as an exception as well.

Change-Id: I844a263703d2d2e56dd1922579910ba35c2d70bf
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: f5580d8d6fd07a569e468fca51f435aa5b122fc4
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
[rayz@codeaurora.org: remove documents in the original patch to fix conflicts]
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:13 +08:00
Hans Verkuil
15ce31c79f [media] cec: filter invalid messages
As per the CEC specification:

- CEC messages with a too-small payload should be ignored.
- Broadcast messages that are only allowed as directed messages
  should be ignored.
- Directed messages that are only allowed as broadcast messages
  should be ignored.

Implement this in the core CEC framework.

Change-Id: Ia4507d7bded5857fa0c110bca64349cf5955f8bb
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 3074fe4a7da5775bcf31675d6d9e2687c434fef2
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:13 +08:00
Hans Verkuil
7f145a1a08 [media] cec: add CEC_MSG_FL_REPLY_TO_FOLLOWERS
Give the caller more control over how replies to a transmit are
handled. By default the reply will only go to the filehandle that
called CEC_TRANSMIT. If this new flag is set, then the reply will
also go to all followers.

Change-Id: I3464ff0980bf5625ebd869eeeafced07c760f741
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: adc0c622783978ab0c740af77f98fc8f65c87d66
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
[rayz@codeaurora.org: remove documents in the original patch to fix conflicts]
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:12 +08:00
Hans Verkuil
9fc0297bd2 [media] cec: add flag to cec_log_addrs to enable RC passthrough
By default the CEC_MSG_USER_CONTROL_PRESSED/RELEASED messages
are passed on to the follower(s) only. If the new
CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU flag is set in the
flags field of struct cec_log_addrs then these messages are also
passed on to the remote control input subsystem and they will appear
as keystrokes.

This used to be the default behavior, but now you have to explicitly
enable it. This is done to force the caller to think about possible
security issues (e.g. if these messages are used to enter passwords).

Change-Id: I349b67e4456cefa604c58c3cb2d94f004d206e00
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: f4062625ede8f0280d8246437f4070c8eb7fe9f3
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
[rayz@codeaurora.org: remove documents in the original patch to fix conflicts]
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:12 +08:00
Jean Delvare
10d295f458 [media] cec: fix Kconfig help text
MEDIA_CEC is no longer a tristate option, so the user can't actually
choose M. Whether the code is built-in or built as a module is
decided somewhere else.

Fixes: 5bb2399a4fe4 ("[media] cec: fix Kconfig dependency problems")

Change-Id: Ib996ee20c4063e01658fc8f842319bb703d855db
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: a58d1191ca04ffa8b14dcda5df0c87a2a642d3c7
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:12 +08:00
Hans Verkuil
e285adf424 [media] cec: fix ioctl return code when not registered
Don't return the confusing -EIO error code when the device is not registered,
instead return -ENODEV which is the proper thing to do in this situation.

Change-Id: Iaf12028cfe4d8b58d4fb09ff06ce680769188d16
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 60815d4a78204915f5cdf79a536bc96d5d23ae5f
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:11 +08:00
Hans Verkuil
4901a43583 [media] cec: don't Feature Abort broadcast msgs when unregistered
If the adapter is configured as 'Unregistered', then cec_receive_notify
incorrectly thinks that broadcast messages are directed messages. The
destination for broadcast messages is 0xf, and the logical address
assigned to Unregistered devices is also 0xf and the logic didn't handle
that correctly.

Change-Id: Idaedf31ec471b5d4bbc982b714e1c08e4935ec6c
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: a179b69359feb26ddb148bb6a2c0c53a8d1dc5be
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:11 +08:00
Johan Fjeldtvedt
98e53e0449 [media] cec: allow configuration both from within driver and from user space
It makes sense for adapters such as the Pulse-Eight to be configurable
both from within the driver and from user space, so remove the
requirement that drivers only can call cec_s_log_addrs or
cec_s_phys_addr if they don't expose those capabilities to user space.

Change-Id: I5780af75ef005dc3d345ee981cb8289d898c997f
Signed-off-by: Johan Fjeldtvedt <jaffe1@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: a2fdc9df5e02ac3ab91d7888372cbe9512273171
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:10 +08:00
Markus Elfring
621f559c73 [media] cec: Delete an unnecessary check before the function call "rc_free_device"
The rc_free_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Change-Id: I97bf16b32365189255fd50973e330f7b8de30f32
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: d8eddb15e4e436ec44464783687f0057a38fb013
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:10 +08:00
Hans Verkuil
a90ab17785 [media] cec-funcs.h: add missing vendor-specific messages
The cec-funcs.h header was missing support for these three vendor-specific messages:

CEC_MSG_VENDOR_COMMAND
CEC_MSG_VENDOR_COMMAND_WITH_ID
CEC_MSG_VENDOR_REMOTE_BUTTON_DOWN

Add wrappers for these messages.

I originally postponed adding these wrappers due to the fact that the argument is
just a byte array which cec-ctl couldn't handle at the time, and then I just forgot
to add them once the CEC framework was finalized.

It wasn't until an attempt to transmit a vendor specific command was made that I
realized that these wrappers were missing.

Change-Id: I0fb17f79f179310110310d372513aea475970054
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 4808f721627c2a23b5d749f9bbd20d4529ea2b8d
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:09 +08:00
Hans Verkuil
ffd4fa2c1c [media] cec-edid: check for IEEE identifier
The cec_get_edid_spa_location() function did not verify that the IEEE
identifier in the Vendor Specific Data Block matched the HDMI-LLC
identifier. This could result in the wrong VSDB block being returned.

For example, for HDMI 2.0 EDIDs there is also a HDMI Forum VSDB.

So check the IEEE identifier as well.

Change-Id: I4e8ea260ffd38846ec977a0a6c6b855afa2edeec
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 8ac6a1a53e9f195e8c4336a7edfba2e102fc14bb
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:08 +08:00
Hans Verkuil
14af6dc683 [media] cec: ignore messages when log_addr_mask == 0
Most CEC adapters will still receive broadcast messages, even if no logical
addresses are claimed. But those messages should only be passed on for
monitoring purposes, but not for processing by either kernel or userspace
if userspace didn't call CEC_ADAP_S_LOG_ADDRS first.

So if adap->log_addrs.log_addr_mask is 0, then just return before passing
the received message on to the processing code.

Change-Id: I2f7099c4f67db9f3f83ebeb181ad2956099c29ab
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 3e92d8b238e48dfb539e8112bb2cc463e35e1b71
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:08 +08:00
Hans Verkuil
96c5a32e58 [media] cec: add item to TODO
Change-Id: Ie7d8cbc24df16887abca783defaf4796558a5701
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 260ff1144a9dd1afb85cf5da462672d68412cbc4
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:07 +08:00
Hans Verkuil
bbb3e5fd19 [media] cec: set unclaimed addresses to CEC_LOG_ADDR_INVALID
Up to 4 logical addresses can be claimed. Make sure that any
unclaimed logical addresses are set to CEC_LOG_ADDR_INVALID as
per the documentation.

Take special care in the unregistered case: when falling back to
unregistered num_log_addrs may be > 1, so mark those as invalid.

Change-Id: Ice29d220b658a942ddbec09afc89777178681904
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 0c1d61b0e4ed68d125b21fed375c38b6e3c2a658
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:07 +08:00
Hans Verkuil
a86a0e6978 [media] cec: add CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK flag
Currently if none of the requested logical addresses can be claimed, the
framework will fall back to the Unregistered logical address.

Add a flag to enable this explicitly. By default it will just go back to
the unconfigured state.

Usually Unregistered is not something you want since the functionality is
very limited. Unless the application has support for this, it will fail
to work correctly. So require that the application explicitly requests
this.

Change-Id: Ic658a6cf7bdd127172701a5a5354222dbacdc7ea
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: dcceb1eaf210096831b14471bc87678375b086ed
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
[rayz@codeaurora.org: remove the documents in original patch to fix conflicts]
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:06 +08:00
Hans Verkuil
ddce08c665 [media] cec-funcs.h: add reply argument for Record On/Off
A reply parameter is added to the cec_msg_record_on/off functions in
cec-funcs.h. The standard mandates that Record Status shall be replied
to Record On, and it may be replied to Record Off.

Change-Id: Ic143eb3706b4da9d414390b14ab93307eec25a40
Signed-off-by: Johan Fjeldtvedt <jaffe1@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 31dc8b7302f1e48952ec8e90cd49dca843146cd0
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:06 +08:00
Hans Verkuil
3079fa0f0b [media] cec-funcs.h: fix typo: && should be &
Fix typo where logical AND was used instead of bitwise AND.

Change-Id: Ic184559541646f87052b78d54efedcd1b0a2ce40
Reported-by: David Binderman <linuxdev.baldrick@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 9ebf1945d757433a089ab3ee940673503e3e11ec
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:05 +08:00
Hans Verkuil
f7d8be4b2c [media] cec: improve locking
- The global lock was used in cec_get_device when it should have
  used the devnode lock.
- cec_put_device also took the global lock, but since the release
  function takes that lock as well this could lead to a deadlock.
  Just don't take the lock here since there is no reason for it.
- cec_devnode_register() should take the global lock when clearing
  the bit in the global bitmap.
- In cec_devnode_unregister() place the devnode->(un)register tests
  and assignments under the devnode lock as well: this has to be
  in a critical block.

Change-Id: I229e6136937003f99153028d12780c0162620bef
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 2ab25d35a91098ef0f42d478cc37f6a5591a4ab0
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:05 +08:00
Hans Verkuil
6c7199a66e [media] cec: rename cec_devnode fhs_lock to just lock
This lock will be used to protect more than just the fhs list.
So rename it to just 'lock'.

Change-Id: I6a2623b1231154be2a4d764ad2086fc73015a3af
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 62148f0930a8e9bd5c5614f8387222f0220d7d47
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:05 +08:00
Hans Verkuil
4b2e6bd1d6 [media] cec: fix off-by-one memset
The unused bytes of the features array should be zeroed, but the start index was one
byte too early. This caused the device features byte to be overwritten by 0.

The compliance test for the CEC_S_LOG_ADDRS ioctl didn't catch this because it tested
byte continuation with the second device features byte being 0 :-(

Change-Id: Ibe07ad9376fa7bebed57c99892ce0e5520cfa170
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 292eaf50c7df4ae2ae8aaa9e1ce3f1240a353ee8
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:04 +08:00
Hans Verkuil
5a129a6e4a [media] cec: always check all_device_types and features
Even when the adapter is configured for CEC 1.4, we still check and
use the CEC 2.0 parts of struct cec_log_addrs. Although these aren't
used in CEC messages, the information contained in them is still of
use in the CEC framework itself, so keep this information.

Also zero the unused trailing features[] data and unused logical address
data so the contents isn't random data.

Change-Id: Id8f226b730188b72abe0e81a50d540beee9418e2
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 009a620848218d521f008141c62f56bf19294dd9
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:04 +08:00
Hans Verkuil
fd4d3bb6fe [media] cec: poll should check if there is room in the tx queue
For POLLOUT poll only checked if the adapter was configured, not
if there was room in the transmit queue. Add that check.

Change-Id: I56fc0585999f4c5ac313305fe43c54a2a1592879
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: b7cbc892532316f2abd880186301e57239a17f28
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:03 +08:00
Hans Verkuil
69333ef727 [media] cec: fix test for unconfigured adapter in main message loop
The main message loop checks if the physical address was valid, and if
not it is assumed that the adapter had been unconfigured.

However, this check is no longer correct, instead it should check
that both adap->is_configured and adap->is_configuring are false.

Change-Id: I178c46bf4e7f2324786a26e4c50d31899c866bc6
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 58ecc29b5e829c2072fe3a98a93ef163bdb36dd9
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:03 +08:00
Hans Verkuil
4f7db561ed [media] cec: limit the size of the transmit queue
The size of the transmit queue was unlimited, which meant that
in non-blocking mode you could flood the CEC adapter with messages
to be transmitted.

Limit this to 18 messages.

Also print the number of pending transmits and the timeout value
in the status debugfs file.

Change-Id: I5cdadee7854e62d5a823b7dc53448860ba73228a
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 11065f8531ed33d5e847a36ad64231ee599d4996
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:02 +08:00
Hans Verkuil
4b7d386d20 [media] cec: zero unused msg part after msg->len
Ensure that the unused part of the msg array is zeroed. This is
required by CEC 2.0 when receiving shorter messages than expected.
In that case the remaining bytes are assumed to be 0.

There are no such CEC messages yet, but it is required to be future proof.

And since we're doing it for received messages, do it for transmitted
messages as well. It's unambiguous this way.

Change-Id: I780888724448c24f432c5d9753d6c5289f725682
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 045344c3c1478f8d03a1a589d645fe10c3a23f77
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:02 +08:00
Hans Verkuil
e55c38515a [media] cec: don't set fh to NULL in CEC_TRANSMIT
The filehandle was set to NULL when in non-blocking mode or when
no reply is needed.

This is wrong: the filehandle is needed in non-blocking mode to ensure
that the result of the transmit can be obtained through CEC_RECEIVE.

And the 'reply' check was also incorrect since it should have checked the
timeout field (the reply can be 0). In any case, when in blocking mode
there is no need to set the fh to NULL either.

Change-Id: I8225959283d34f9a44439ab34ee291b87b5d4922
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 4eef404fd91543dc82be2bd05d3b29919ec6c0e6
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:01 +08:00
Hans Verkuil
60238b2dd3 [media] cec: clear all status fields before transmit and always fill in sequence
Before transmitting a message clear all status fields and always fill
in the sequence number. Make sure the sequence number is never 0.

Change-Id: Ia8ad9b79935cad0e88371f00137a59326a336ffc
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 40df3a7e586df59190547fe0e7d9928da735eada
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:01 +08:00
Hans Verkuil
a743a520d1 [media] cec: CEC_RECEIVE overwrote the timeout field
When CEC_RECEIVE returns a message the original timeout field
was overwritten. Restore the timeout field.

Change-Id: Ida65e37e1424745e3e4cf9d0108e10dc75e642ed
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: e883b4d02670ae83ab24e9af969de1af756959f8
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:00 +08:00
Hans Verkuil
b58d42ad60 [media] cec/TODO: drop comment about sphinx documentation
The CEC documentation has been converted to sphinx, so this
TODO item can be dropped.

Change-Id: I7a0fa38382a5533fd9e3643613d63595881b2b78
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: bddb4952506d0e84c443a04840143ea98b610557
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:22:00 +08:00
Hans Verkuil
5ab280ffae [media] cec: set timestamp for selfie transmits
Attempts to send CEC messages to yourself are detected in the framework and
returned with a NACK error. However, the tx_ts was never filled in that case.
So just set it.

Change-Id: Ifd8be78030778d3d99b88b353905879c2079c2c5
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 9a3f14ea802fd0d8848d8e16566b769e4ce09d68
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:59 +08:00
Hans Verkuil
a293351e1c [media] cec: don't zero reply and timeout on error
There is really no reason to zero the reply and timeout fields if an
error occurs. This is a left-over from earlier versions where that
was used to signal errors, but this is now handled by the rx/tx_status
fields.

Change-Id: I2064f6b2dcb3affe4097ebdf7270eb8c6bc7e21d
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 86e3577f11d0aa8a5d3c6199f9e3f23cdbd0c0ac
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:59 +08:00
Hans Verkuil
72b6c6a39f [media] cec: split the timestamp into an rx and tx timestamp
When transmitting a message and waiting for a reply it would be good
to know the time between when the message was transmitted and when
the reply arrived. With only one timestamp field it was set to when
the reply arrived and the original transmit time was overwritten.

Just taking the timestamp in userspace right before CEC_TRANSMIT is
called is not reliable, since the actual transmit can be delayed if
the CEC bus is busy. Only the driver can fill this in accurately.

So split up the ts field into an rx_ts and a tx_ts. Also move the
status fields to after the 'reply' field: they were placed in a
strange position and make much more sense when grouped with the
other status-related fields.

This patch also makes sure that the timestamp is taken as soon as
possible.

Change-Id: I643006cc32cbc6073b6ce8fa7ae03b63b3b0e266
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 980e0b36b55985dd0a37acd25d29c8f21482db32
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:58 +08:00
Hans Verkuil
61423ca8a0 [media] cec: add sanity check for msg->len
Check (and warn) if the msg->len is too long or if it is 0.

Should never happen, but just in case...

Change-Id: I784aca0acdc74511b42b51ae01e57be0c04799b1
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 52d802d65b56a399aa67a9d3f26f232116d3e256
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:58 +08:00
Andrew Morton
185a8562ea [media] cec-adap.c: work around gcc-4.4.4 anon union initializer bug
drivers/staging/media/cec/cec-adap.c: In function 'cec_queue_msg_fh':
drivers/staging/media/cec/cec-adap.c:141: error: unknown field 'lost_msgs' specified in initializer

Fixes: 9881fe0ca187c21 ("[media] cec: add HDMI CEC framework (adapter)")

Change-Id: I5e577cde445313876f3615666df8274d82a8e6b5
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Kamil Debski <kamil@wypas.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 6a91d60aba671cf8756a56d6157a9c971d2a5222
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:57 +08:00
Hans Verkuil
0df37e07fd [media] cec: CEC_RECEIVE is allowed in monitor mode
When the device is in monitor mode, then you should always be able to
call CEC_RECEIVE, even it the device is unconfigured.

Change-Id: I1d11a8cbb26d19197b7f3a4a77ed8d6ce00f1853
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: ca00033c9fc8b5f178573a76887c89296ed5b398
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:57 +08:00
Hans Verkuil
468ef730e2 [media] cec: add check if adapter is unregistered
CEC USB dongles can be unplugged at any time, and at that point they will
be unregistered. Make sure that any attempt afterwards to set the physical
or logical addresses will be ignored.

Change-Id: If15d1e3f3447c6a844eaee27cfdfd65a3341062e
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: c000e5dad17d20c644bbf3ead52c334025d11ada
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:57 +08:00
Hans Verkuil
ae758ae16b [media] cec-funcs.h: add missing 'reply' for short audio descriptor
The cec_msg_request_short_audio_descriptor function was missing the reply
argument. That's needed if you want the framework to wait for the reply
message.

Change-Id: Id099aa3ec932beb7d49af56cd9f761ee66b2727e
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 9ad52b4db79d168867a2ca105eca00fb9cb28fe5
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:56 +08:00
Hans Verkuil
dd752bd97b [media] cec-funcs.h: add missing const modifier
The cec_ops_* functions never touch cec_msg, so mark it as const.

This was done for some of the cec_ops_ functions, but not all.

Change-Id: Ibf4c85faac86588e937107bd1bc7648841060bab
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 0c1f8569942695b7a2735301efe45ecd69e2a41f
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 11:21:56 +08:00