summaryrefslogtreecommitdiff
path: root/include/media/cec.h
AgeCommit message (Collapse)Author
2017-09-23media: cec.h: initialize *parent and *port in cec_phys_addr_validateHans Verkuil
Make sure these values are set to avoid 'uninitialized variable' warnings. Hasn't happened yet, but better safe than sorry. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-09-23media: cec: add CEC_EVENT_PIN_HPD_LOW/HIGH eventsHans Verkuil
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-08-26media: cec: replace pin->cur_value by adap->cec_pin_is_highHans Verkuil
The current CEC pin value (0 or 1) was part of the cec_pin struct, but that assumes that CEC pin monitoring can only be used with a driver that uses the low-level CEC pin framework. But hardware that has both a high-level API and can monitor the CEC pin at low-level at the same time does not need to depend on the cec pin framework. To support such devices remove the cur_value field from struct cec_pin and add a cec_pin_is_high field to cec_adapter. This also makes it possible to drop the '#ifdef CONFIG_CEC_PIN' in cec-api.c. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20media: cec: fix remote control passthroughHans Verkuil
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-20media: rc-core: rename input_name to device_nameSean Young
When an ir-spi is registered, you get this message. rc rc0: Unspecified device as /devices/platform/soc/3f215080.spi/spi_master/spi32766/spi32766.128/rc/rc0 "Unspecified device" refers to input_name, which makes no sense for IR TX only devices. So, rename to device_name. Also make driver_name const char* so that no casts are needed anywhere. Now ir-spi reports: rc rc0: IR SPI as /devices/platform/soc/3f215080.spi/spi_master/spi32766/spi32766.128/rc/rc0 Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20media: cec: rename pin events/functionHans Verkuil
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-09media: media/cec.h: add CEC_CAP_DEFAULTSHans Verkuil
The CEC_CAP_LOG_ADDRS, CEC_CAP_TRANSMIT, CEC_CAP_PASSTHROUGH and CEC_CAP_RC capabilities are normally always present. Add a CEC_CAP_DEFAULTS define that ORs these four caps to simplify drivers. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18media: cec: move cec_register_cec_notifier to cec-notifier.hHans Verkuil
The cec_register_cec_notifier function was in media/cec.h, but it has to be in cec-notifier.h. While we are at it, also document it and add a stub function for when the notifier is disabled or the CEC core code is unreachable. Based on an earlier patch from Jose Abreu <Jose.Abreu@synopsys.com>. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-18media: cec-pin: add low-level pin hardware supportHans Verkuil
Add support for CEC hardware that relies on low-level pin polling or GPIO interrupts. One example is the Allwinner SoC. But any GPIO-based CEC implementation can use this as well. A GPIO implementation is very suitable as well for debugging: it can use interrupts to detect state changes and report it. Userspace can then verify if the bus traffic is correct. This also makes error injection possible. The disadvantage is that it is hard to get the timings right since linux isn't a hard realtime system. In general on an idle system it works quite well, but under load the timer will miss its mark every so often. The debugfs file /sys/kernel/debug/cec/cecX/status gives some statistics with respect to the timer overruns. When the adapter is unconfigured and the low-level driver supports interrupts, then the interrupt will be used to detect changes. This should be quite accurate. But when the adapter is configured a hrtimer has to be used. The hrtimer implements a state machine where for each state the code will read the bus or drive the bus and go on to the next state. It will re-arm the timer with a delay based on the next state. 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-18media: cec: add core support for low-level CEC pin monitoringHans Verkuil
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-18media: cec: rework the cec event handlingHans Verkuil
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-18media: cec: add adap_free opHans Verkuil
This is needed for CEC adapters that allocate resources that have to be freed before the cec_adapter is deleted. 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-18media: cec: add *_ts variants for transmit_done/received_msgHans Verkuil
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-18media: cec: improve transmit timeout loggingHans Verkuil
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-06-20Merge tag 'v4.12-rc6' into patchworkMauro Carvalho Chehab
Linux 4.12-rc6 * tag 'v4.12-rc6': (813 commits) Linux 4.12-rc6 mm: larger stack guard gap, between vmas virtio_balloon: disable VIOMMU support mm: correct the comment when reclaimed pages exceed the scanned pages userfaultfd: shmem: handle coredumping in handle_userfault() mm: numa: avoid waiting on freed migrated pages swap: cond_resched in swap_cgroup_prepare() mm/memory-failure.c: use compound_head() flags for huge pages perf unwind: Report module before querying isactivation in dwfl unwind fs: pass on flags in compat_writev objtool: Add fortify_panic as __noreturn function powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks drm: mxsfb_crtc: Reset the eLCDIF controller drm/mgag200: Fix to always set HiPri for G200e4 V2 i2c: ismt: fix wrong device address when unmap the data buffer i2c: rcar: use correct length when unmapping DMA powerpc/xive: Fix offset for store EOI MMIOs drm/tegra: Correct idr_alloc() minimum id drm/tegra: Fix lockup on a use of staging API ... Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20[media] cec: add CEC_CAP_NEEDS_HPDHans Verkuil
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[media] cec: add cec_transmit_attempt_done helper functionHans Verkuil
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[media] cec: add cec_phys_addr_invalidate() helper functionHans Verkuil
Simplifies setting the physical address to CEC_PHYS_ADDR_INVALID. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Hans Verkuil <hansverk@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20[media] cec: add cec_s_phys_addr_from_edid helper functionHans Verkuil
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-08[media] media/cec.h: use IS_REACHABLE instead of IS_ENABLEDHans Verkuil
Fix messages like this: adv7842.c:(.text+0x2edadd): undefined reference to `cec_unregister_adapter' when CEC_CORE=m but the driver including media/cec.h is built-in. In that case the static inlines provided in media/cec.h should be used by that driver. Reported-by: Randy Dunlap <rdunlap@infradead.org> Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-04[media] cec: rename MEDIA_CEC_NOTIFIER to CEC_NOTIFIERHans Verkuil
This config option is strictly speaking independent of the media subsystem since it can be used by drm as well. Besides, it looks odd when drivers select CEC_CORE and MEDIA_CEC_NOTIFIER, that's inconsistent naming. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-19[media] cec.h: merge cec-edid.h into cec.hHans Verkuil
Drop the separate cec-edid.h header and merge it into cec.h. There was really no need to have a separate header for this. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-19[media] cec: Kconfig cleanupHans Verkuil
The Kconfig options for the CEC subsystem were a bit messy. In addition there were two cec sources (cec-edid.c and cec-notifier.c) that were outside of the media/cec directory, which was weird. Move those sources to media/cec as well. The cec-edid and cec-notifier functionality is now part of the cec module and these are no longer separate modules. Also remove the MEDIA_CEC_EDID config option and include it with the main CEC config option (which defined CEC_EDID anyway). Added static inlines to cec-edid.h for dummy functions when CEC_CORE isn't defined. CEC drivers should now depend on CEC_CORE. CEC drivers that need the cec-notifier functionality must explicitly select CEC_NOTIFIER. The s5p-cec and stih-cec drivers depended on VIDEO_DEV instead of CEC_CORE, fix that as well. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Benjamin Gaignard <benjamin.gaignard@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-10[media] cec: integrate CEC notifier supportHans Verkuil
Support the CEC notifier framework, simplifying drivers that depend on this. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Benjamin Gaignard <benjamin.gaignard@linaro.org> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-05[media] cec: Add cec_get_drvdata()Jose Abreu
Add a helper function to get driver private data from CEC adapter. This helps the readability a little bit and allows to change the 'priv' field name to something else without needing to touch all drivers. Signed-off-by: Jose Abreu <joabreu@synopsys.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-29[media] cec: pass parent device in register(), not allocate()Hans Verkuil
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. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-16[media] cec: move the CEC framework out of staging and to mediaHans Verkuil
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. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-22[media] cec: rename cec_devnode fhs_lock to just lockHans Verkuil
This lock will be used to protect more than just the fhs list. So rename it to just 'lock'. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-19[media] cec: limit the size of the transmit queueHans Verkuil
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. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-06-28[media] cec: add HDMI CEC framework (core)Hans Verkuil
The added HDMI CEC framework provides a generic kernel interface for HDMI CEC devices. Note that the CEC framework is added to staging/media and that the cec.h and cec-funcs.h headers are not exported yet. While the kABI is mature, I would prefer to allow the uABI some more time before it is mainlined in case it needs more tweaks. This adds the cec-core.c, media/cec.h and cec-priv.h sources. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> [k.debski@samsung.com: Merged CEC Updates commit by Hans Verkuil] [k.debski@samsung.com: Merged Update author commit by Hans Verkuil] [k.debski@samsung.com: code cleanup and fixes] [k.debski@samsung.com: add missing CEC commands to match spec] [k.debski@samsung.com: add RC framework support] [k.debski@samsung.com: move and edit documentation] [k.debski@samsung.com: add vendor id reporting] [k.debski@samsung.com: reorder of API structs and add reserved fields] [k.debski@samsung.com: fix handling of events and fix 32/64bit timespec problem] [k.debski@samsung.com: add sequence number handling] [k.debski@samsung.com: add passthrough mode] [k.debski@samsung.com: fix CEC defines, add missing CEC 2.0 commands] Signed-off-by: Kamil Debski <kamil@wypas.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>