Commit graph

590235 commits

Author SHA1 Message Date
Ray Zhang
aabbd64ef4 drm/msm: add irq mapping for cec in hdmi driver
Make HDMI device as the interrupt parent of CEC device, so add
the new IRQ domain in HDMI driver dealing with the necessary
IRQ mapping.

Change-Id: Id935da1d1e488ccee01b831b9f085a83d67268f2
Signed-off-by: Ray Zhang <rayz@codeaurora.org>
2017-05-25 15:32:04 +08:00
Vijayavardhan Vennapusa
2d7a7965be f_audio_source: Use f_audiosource as first device name
Keep first instance name as f_audiosource and change name
for next intance as per number of instance.

Change-Id: I9888d10e1faceff16f950f20ac42261417f1d8e8
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
2017-05-25 12:45:36 +05:30
Andy Sun
49f15c63f7 ais: increase CCI timeout value to 600 msec
On some ADP board, after writing CCI command to sensor, msm_cci_wait
timeout issue happens sometimes during b2b stress testing.

All the error cases indicate needing 510 msec to get completion from irq,
so change the timeout value from 500 msec to 600 msec.

CRs-fixed: 2052210

Change-Id: Ie70a86de6b2d7eab823ad700be5ee748a3f5e800
Signed-off-by: Andy Sun <bins@codeaurora.org>
2017-05-25 14:43:55 +08:00
Rajesh Kemisetti
ef93af2324 msm: kgsl: Update QoS settings for A508 VBIF as recommended
Update QoS settings for A508 VBIF based on recommendation.
VBIF_GATE_OFF_WRREQ_EN register needs to be programmed by SW.

Change-Id: I7d41c8350ad09c595f288bd2a2b45fc2abef15f8
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
2017-05-25 11:39:25 +05:30
Andy Sun
84119e679b ARM: dts: msm: add clock-cntl-support for msm8996 ispif
Without clock-cntl-support setting, some of ispif clocks will be
enabled without set rate.
Have to add clock-cntl-support to let clock-control setting in device
node to take care of which ones should init rate.

Change-Id: I836cf1578f198d7370e347336f334e9929b57994
Signed-off-by: Andy Sun <bins@codeaurora.org>
2017-05-25 12:43:04 +08:00
Terence Ho
2cad8aa2f2 msm: ais: Fix kernel overwrite GET_BUF_BY_IDX ioctl
Assign address of buf_info into ioctl_ptr.
Previously we were copying first 8 bytes of buf_info (content)
into ioctl_ptr. Which is dereferenced and written later causing
kernel overwrite vulnerability.

CRs-fixed: 2013631
Change-Id: Ia27dafe003c2c4d7a59dc2976bee2cfc15978403
Signed-off-by: Terence Ho <terenceh@codeaurora.org>
Signed-off-by: Andy Sun <bins@codeaurora.org>
2017-05-25 12:37:28 +08:00
Terence Ho
7630704aee ARM: dts: msm: correct voltage range values for msm8996 ADP camera
The digital and analogue voltages could vary on different platforms
and update the same for automotive ADP board.

Change-Id: I2b6874f8bcc5c6e780cece82014a969812b683fa
Signed-off-by: Terence Ho <terenceh@codeaurora.org>
Signed-off-by: Andy Sun <bins@codeaurora.org>
2017-05-25 12:27:28 +08:00
Terence Ho
4462dc66e3 ais: enable ais build for automotive
Enable ais build for automotive platforms.

Change-Id: If24cf52e35aacd167081712516d2d0cf18a6e283
Signed-off-by: Terence Ho <terenceh@codeaurora.org>
Signed-off-by: Andy Sun <bins@codeaurora.org>
2017-05-25 12:18:10 +08:00
Hans Verkuil
9aa58c717d [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.

Change-Id: I01b5d4fef7caa370b0f4fb154360495a7dce5332
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: 42980da2eb7eb9695d8efc0c0ef145cbbb993b2c
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:22 +08:00
Hans Verkuil
913877c128 [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.

Change-Id: I3d0f3f6bea3045808333cfde55ecd677e7799ce2
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: f9f96fc10c09ca16e336854c08bc1563eed97985
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:21 +08:00
Hans Verkuil
359324cb0f [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.

Change-Id: I554811aa51e6781e6f9141d59f38d7c540ed5b10
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: f60f35609f89ef4fee73776bc1ef697923251995
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:21 +08:00
Hans Verkuil
27d4bcaf69 [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.

Change-Id: Ic5c134e40abbb7d3b4d008c4dcf703852c2d7b0f
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Git-commit: d3d64bc7408f1ff0b0ff8354056e2a48eda5886d
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
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