HDMI CEC framework
Subsystems (13)
v13 cover HDMI CEC framework
Hi all,
The thirteenth version of this patchset addresses problems I found when using this patch series in real situations. This also made me realize that this is not quite ready yet to be merged, although it is getting close.
See the changelog below.
The cec-ctl and cec-compliance utilities used to test the CEC framework can be found here:
http://git.linuxtv.org/cgit.cgi/hverkuil/v4l-utils.git/log/?h=cec
Note that I started the first steps towards a proper CEC compliance test where I can put a CEC adapter in follower mode (where it replies to messages emulating a device) and/or initiator mode where the device sends messages to remote CEC adapters, testing those.
Early days yet, but very useful in designing the new CEC_G/S_MODE ioctls to replace the old CLAIM/RELEASE, G/S_MONITOR and G_PASSTHROUGH ioctls. The new ioctls made much more sense and are a good fit with CEC protocol.
The TODO items on my list are:
- think more carefully about the relationship between setting the physical address, enabling/disabling the adapter and setting logical addresses. I.e. setting physical address f.f.f.f should automatically switch the CEC adapter to the Unregistered logical address. You would also like the adapter to automatically re-register its logical addresses when needed.
- The ARC and CDC HPD support will probably have to be left out from the final version: I think I will have to test with this with actual hardware in order to check if what is happening now is actually correct. I'm not confident of that right now.
- More documentation tweaks
The low-level kernel API towards the actual CEC adapter drivers is pretty stable. I now have support for s5p, adv7604, adv7842, adv7511, tc358840 (new upcoming driver, not yet in the kernel but posted today) and one other that I can't yet tell about :-)
I've also played with the omap4 CEC adapter for a pandaboard, but that isn't working yet.
Best regards,
Hans
Changes since v12
=================
- Added driver and name fields to the cec_caps struct. Without this it was very difficult to tell CEC adapters apart in a human readable manner.
- Renamed CEC_CAP_IO to CEC_CAP_TRANSMIT, which better describes this capability.
- Added the CEC_ADAP_LOG_STATUS to log the current status of the CEC adapter. Very useful when debugging.
- Added comments to the cec.c source.
- Added a timeout when waiting for a transmit to finish. Without the timeout the state machine could lock up when dealing with broken CEC adapter drivers or just unlucky situations.
- Commenting the code also found a number of bugs which have been fixed.
- Trying to poll yourself is now handled by the framework since different hardware would give different results. The framework will just NACK it.
- Disabling the CEC adapter doesn't clear the physical address anymore. This turned out to be quite painful for applications.
- Merged the CLAIM/RELEASE, G/S_MONITOR and G_PASSTHROUGH ioctls into two G/S_MODE ioctls. This allows you to tell the driver which initiator and follower modes you want, and greatly simplifies how these modes are handled.
Changes since v11
=================
- Add a new CEC_EVENT_PHYS_ADDR_CHANGED to report when the physical address of the CEC adapter changes. Since the physical address is obtained from the EDID the application has to be informed when the kernel (or userspace for that matter) sets that.
- Add a new internal cec_set_phys_addr() function to change the physical address and post the event.
- Modified the retry-transmit mechanism: the framework will do the retry if the low-level driver returns a TX_STATUS error, but does not set the CEC_TX_STATUS_MAX_RETRIES status bit. In that case the framework assumes that there is no hardware retry and it will retry itself. This used to be through the 'retries' pointer argument (set to 0 if there is no retry support) but that doesn't work for hardware that does retry for some error conditions but not for others.
- Added the missing CEC_TX_STATUS_LOW_DRIVE bit and low_drive_cnt error counter. I missed that potential CEC bus error condition.
- By passing a NULL pointer to cec_claim_log_addrs() drivers can clear the logical addresses.
- When a source loses the HPD the source has to clear the logical addresses and update its physical address. Implement this in the cobalt driver.
- Improve tx_status handling in the various low-level drivers.
Changes since v10
=================
- Split the msg.status field into tx_status and rx_status.
- Add counters for various CEC protocol errors that can occur during transmit.
- Add tx_status bits for the ARB_LOST and NACK status and add a generic CEC_TX_STATUS_ERROR bit.
- Add retry support to the CEC framework for hardware that does not have retry support.
- Improve event handling: on open() generate events that report the initial CEC adapter status and the number of connected inputs. Also ensure that you never loose important events (intermediate events may be lost, but never the last event). The basic mechanism has been taken from the V4L2 event implementation which works very well.
- CEC emulation support was added to vivid which makes it much easier to test CEC applications without having hardware present.
- Improve handling of timings and timeouts in the cec framework.
- Improve locking.
- Fixed buggy rc cleanup.
- All CEC messages are now fully supported in cec-funcs.h (specifically handling of UI Commands and short audio descriptors).
Changes since v9
================
- Updated cec.txt
- Added a promiscuous capability to signal those adapters that can monitor all CEC traffic, not just directed and broadcast messages. I have one adapter that can do this. Added code in the framework to handle such messages correctly.
- The status field is now value and no longer a bitmask.
- Renamed the kernel config from CEC to MEDIA_CEC
- The adap_transmit() callback now has a retries argument.
- Use the new CEC_MAX_MSG_SIZE define instead of hardcoding it as 16
- Add support to wait for a reply after a broadcast message: this was forbidden, but it is a valid use-case.
- Make sure you can't send a message to yourself.
- Waiting for a transmit to succeed would never timeout (and couldn't be interrupted). Fixed.
- The message status was not updated correctly if it was CEC_MSG_FEATURE_ABORTed.
- Fixed a nasty kernel oops when deleting a cec adapter.
- Removed the owner check: the module owner is NULL if it is compiled into the kernel instead of as a module.
- Added separate register/unregister calls: this is safer and actually made it possible to drop the ugly 'cec_ready' v4l2_subdev op. Suggested by Russell, and that was a good idea.
- Added missing support for 32-bit to 64-bit ioctl conversion.
- Move the v4l2_subdev cec ops into a v4l2_subdev_cec_ops struct.
Changes since v8
================
- Addressed the comments Russell King made about how the cec character devices should be allocated/freed.
- Updated the DocBook documentation.
Changes since v7
================
- I thought that the core thread could handle out-of-order messages, but that turned out to be wrong. After careful analysis I realized that I had to rewrite this part in cec.c in order to make it work.
- Added new CEC-specific keys to input.h and use them in the CEC rc keymap. Replaced KEY_PLAY/PAUSE/STOP with KEY_PLAYCD/PAUSECD/STOPCD to clarify that these are media operations and not the Pause key on the keyboard.
- Added CEC_PHYS_ADDR_INVALID (0xffff)
- Added monitor support to monitor CEC traffic
- Replaced CAP_TRANSMIT and CAP_RECEIVE by a single CAP_IO.
- Replaced CAP_CDC by CAP_CDC_HPD since this only applies to the HPD part of the CDC messages.
- Add CAP_IS_SOURCE.
- Add ninputs field to cec_caps to export the number of inputs of the device.
- Drop CEC_LOG_ADDRS_FL_HANDLE_MSGS and the flags field (see next change for more info).
- Add CEC_CLAIM and CEC_RELEASE to explicitly start/stop processing CEC messages. This also implies ownership of the CEC interface, so other filehandles can only receive but not transmit.
- Reworked event handling: report adapter state changes, input changes and if the message receive queue is full.
- cec-funcs.h: added CDC HEC support.
- Renamed G/S_ADAP ioctls to ADAP_G/S: this made it clearer which ioctls deal with the adapter configuration and which deal with CEC messages/events.
- Clarified which CEC messages are passed on to userspace and which aren't. Specifically if CAP_ARC is set, then all ARC messages are handled by the kernel. If CAP_CDC_HPD is set, then all CDC hotplug messages are handled by the kernel. Otherwise these messages are passed on to userspace.
Changes since v6
================
- added cec-funcs.h to provide wrapper functions that fill in the cec_msg struct. This header is needed both by the kernel and by applications.
- fix a missing rc_unregister_device call.
- added CEC support for the adv7842 and cobalt drivers.
- added CEC operand defines. Rename CEC message defines to CEC_MSG_ and operand defines now use CEC_OP_.
- the CEC_VERSION defines are dropped since we now have the CEC_OP_VERSION defines.
- ditto: CEC_PRIM_DEVTYPE_ is now CEC_OP_PRIM_DEVTYPE.
- ditto: CEC_FL_ALL_DEVTYPE_ is now CEC_OP_ALL_DEVTYPE.
- cec-ioc-g-adap-log-addrs.xml: document cec_versions field.
- cec-ioc-g-caps.xml: drop vendor_id and version fields.
- add MAINTAINERS entry.
- add CDC support (not yet fully functional).
- add a second debug level for message debugging.
- fix a nasty kernel Oops in cec_transmit_msg while waiting for transmit completion (adap->tx_queue[idx].func wasn't set to NULL).
- add support for CEC_MSG_REPORT_FEATURES (CEC 2.0 only).
- correctly abort unsupported messages.
- add support for the device power status feature.
- add support for the audio return channel (preliminary).
- add support for the CDC hotplug message (preliminary).
- added osd_name to struct cec_log_addrs.
- reported physical addresses are stored internally.
- fix enabling/disabling the CEC adapter (internal fields weren't cleared correctly).
- zero reserved fields.
- return an error if you try to receive/transmit and the adapter isn't configured.
- when creating the adapter provide the owner module and the parent device.
- add a CEC_VENDOR_ID_NONE define to signal if no vendor ID was set.
- add new capabilities: RC (remote control), ARC (audio return channel) and CDC (Capability Discovery and Control).
- applications that want to handle messages for a logical address need to set the CEC_LOG_ADDRS_FL_HANDLE_MSGS flag. Otherwise the CEC core will be the one handling all messages.
- Each logical address has its own all_device_types value. So this should be an array, not a single value.
- I'm sure I've forgotten some changes...
Changes since v5
================
- drop struct cec_timeval in favour of a __u64 that keeps the timestamp in ns
- remove userspace documentation from Documentation/cec.txt as userspace API is described in the DocBook
- add missing documentation for the passthrough mode to the DocBook
- add information about the number of events that can be queued
- fix misspelling of reply
- fix behaviour of posting an event in cec_received_msg, such that the behaviour is consistent with the documentation
Changes since v4
================
- add sequence numbering to transmitted messages
- add sequence number handling to event hanlding
- add passthrough mode
- change reserved field sizes
- fixed CEC version defines and addec CEC 2.0 commands
- add DocBook documentation
Changes since v3
================
- remove the promiscuous mode
- rewrite the devicetree patches
- fixes, expansion and partial rewrite of the documentation
- reorder of API structures and addition of reserved fields
- use own struct to report time (32/64 bit safe)
- fix of handling events
- add cec.h to include/uapi/linux/Kbuild
- fixes in the adv76xx driver (add missing methods, change adv7604 to adv76xx)
- cleanup of debug messages in s5p-cec driver
- remove non necessary claiming of a gpio in the s5p-cec driver
- cleanup headers of the s5p-cec driver
Changes since v2
===============-
- added promiscuous mode
- added new key codes to the input framework
- add vendor ID reporting
- add the possibility to clear assigned logical addresses
- cleanup of the rc cec map
Changes since v1
================
- documentation edited and moved to the Documentation folder
- added key up/down message handling
- add missing CEC commands to the cec.h file
Background
==========
The work on a common CEC framework was started over three years ago by Hans Verkuil. Unfortunately the work has stalled. As I have received the task of creating a driver for the CEC interface module present on the Exynos range of SoCs, I got in touch with Hans. He replied that the work stalled due to his lack of time.
Original RFC by Hans Verkuil/Martin Bugge
=========================================
https://www.mail-archive.com/[email protected]/msg28735.html
Hans Verkuil (11):
input.h: add BUS_CEC type
cec: add HDMI CEC framework
cec: add compat32 ioctl support
cec.txt: add CEC framework documentation
DocBook/media: add CEC documentation
v4l2-subdev: add HDMI CEC ops
cec: adv7604: add cec support.
cec: adv7842: add cec support
cec: adv7511: add cec support.
cobalt: add cec support
vivid: add CEC emulation
Kamil Debski (5):
dts: exynos4*: add HDMI CEC pin definition to pinctrl
dts: exynos4: add node for the HDMI CEC device
HID: add HDMI CEC specific keycodes
rc: Add HDMI CEC protocol handling
cec: s5p-cec: Add s5p-cec driver
Marek Szyprowski (1):
dts: exynos4412-odroid*: enable the HDMI CEC device
Documentation/DocBook/device-drivers.tmpl | 3 + Documentation/DocBook/media/Makefile | 2 + Documentation/DocBook/media/v4l/biblio.xml | 10 + Documentation/DocBook/media/v4l/cec-api.xml | 75 + Documentation/DocBook/media/v4l/cec-func-close.xml | 59 + Documentation/DocBook/media/v4l/cec-func-ioctl.xml | 73 + Documentation/DocBook/media/v4l/cec-func-open.xml | 94 + Documentation/DocBook/media/v4l/cec-func-poll.xml | 89 + .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml | 174 ++ .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml | 306 +++ .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml | 81 + .../DocBook/media/v4l/cec-ioc-adap-g-state.xml | 88 + .../DocBook/media/v4l/cec-ioc-adap-g-vendor-id.xml | 71 + .../DocBook/media/v4l/cec-ioc-adap-log-status.xml | 51 + .../DocBook/media/v4l/cec-ioc-dqevent.xml | 280 ++ Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml | 286 ++ .../DocBook/media/v4l/cec-ioc-receive.xml | 261 ++ Documentation/DocBook/media_api.tmpl | 6 +- Documentation/cec.txt | 391 +++ .../devicetree/bindings/media/s5p-cec.txt | 31 + Documentation/video4linux/vivid.txt | 36 +- MAINTAINERS | 21 + arch/arm/boot/dts/exynos4.dtsi | 12 + arch/arm/boot/dts/exynos4210-pinctrl.dtsi | 7 + arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 4 + arch/arm/boot/dts/exynos4x12-pinctrl.dtsi | 7 + drivers/media/Kconfig | 5 + drivers/media/Makefile | 2 + drivers/media/cec.c | 2774 ++++++++++++++++++++ drivers/media/i2c/Kconfig | 6 +- drivers/media/i2c/adv7511.c | 356 ++- drivers/media/i2c/adv7604.c | 294 ++- drivers/media/i2c/adv7842.c | 331 ++- drivers/media/pci/cobalt/Kconfig | 1 + drivers/media/pci/cobalt/cobalt-driver.c | 115 +- drivers/media/pci/cobalt/cobalt-driver.h | 2 + drivers/media/pci/cobalt/cobalt-irq.c | 3 + drivers/media/pci/cobalt/cobalt-v4l2.c | 126 +- drivers/media/pci/cobalt/cobalt-v4l2.h | 2 + drivers/media/platform/Kconfig | 12 + drivers/media/platform/Makefile | 1 + drivers/media/platform/s5p-cec/Makefile | 2 + drivers/media/platform/s5p-cec/exynos_hdmi_cec.h | 38 + .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c | 210 ++ drivers/media/platform/s5p-cec/regs-cec.h | 96 + drivers/media/platform/s5p-cec/s5p_cec.c | 295 +++ drivers/media/platform/s5p-cec/s5p_cec.h | 76 + drivers/media/platform/vivid/Kconfig | 1 + drivers/media/platform/vivid/vivid-core.c | 361 ++- drivers/media/platform/vivid/vivid-core.h | 27 + drivers/media/platform/vivid/vivid-kthread-cap.c | 11 + drivers/media/platform/vivid/vivid-vid-cap.c | 31 + drivers/media/platform/vivid/vivid-vid-common.c | 7 + drivers/media/rc/keymaps/Makefile | 1 + drivers/media/rc/keymaps/rc-cec.c | 174 ++ drivers/media/rc/rc-main.c | 1 + fs/compat_ioctl.c | 17 + include/media/cec.h | 220 ++ include/media/i2c/adv7511.h | 6 +- include/media/rc-map.h | 5 +- include/media/v4l2-subdev.h | 22 + include/uapi/linux/Kbuild | 2 + include/uapi/linux/cec-funcs.h | 1852 +++++++++++++ include/uapi/linux/cec.h | 946 +++++++ include/uapi/linux/input-event-codes.h | 30 + include/uapi/linux/input.h | 1 + 66 files changed, 10824 insertions(+), 156 deletions(-) create mode 100644 Documentation/DocBook/media/v4l/cec-api.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-close.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-ioctl.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-open.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-poll.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-state.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-vendor-id.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-log-status.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-receive.xml create mode 100644 Documentation/cec.txt create mode 100644 Documentation/devicetree/bindings/media/s5p-cec.txt create mode 100644 drivers/media/cec.c create mode 100644 drivers/media/platform/s5p-cec/Makefile create mode 100644 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h create mode 100644 drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c create mode 100644 drivers/media/platform/s5p-cec/regs-cec.h create mode 100644 drivers/media/platform/s5p-cec/s5p_cec.c create mode 100644 drivers/media/platform/s5p-cec/s5p_cec.h create mode 100644 drivers/media/rc/keymaps/rc-cec.c create mode 100644 include/media/cec.h create mode 100644 include/uapi/linux/cec-funcs.h create mode 100644 include/uapi/linux/cec.h
Signature · 1 line
2.7.0
PATCH v13 1/17 dts: exynos4*: add HDMI CEC pin definition to pinctrl
From: Kamil Debski <[email protected]>
Add pinctrl nodes for the HDMI CEC device to the Exynos4210 and Exynos4x12 SoCs. These are required by the HDMI CEC device.
--- arch/arm/boot/dts/exynos4210-pinctrl.dtsi | 7 +++++++ arch/arm/boot/dts/exynos4x12-pinctrl.dtsi | 7 +++++++ 2 files changed, 14 insertions(+)
arch/arm/boot/dts/exynos4210-pinctrl.dtsi +7 -0
@@ -820,6 +820,13 @@ samsung,pin-pud = <1>; samsung,pin-drv = <0>; }; + + hdmi_cec: hdmi-cec { + samsung,pins = "gpx3-6"; + samsung,pin-function = <3>; + samsung,pin-pud = <0>; + samsung,pin-drv = <0>; + }; }; pinctrl@03860000 {
arch/arm/boot/dts/exynos4x12-pinctrl.dtsi +7 -0
@@ -885,6 +885,13 @@ samsung,pin-pud = <0>; samsung,pin-drv = <0>; }; + + hdmi_cec: hdmi-cec { + samsung,pins = "gpx3-6"; + samsung,pin-function = <3>; + samsung,pin-pud = <0>; + samsung,pin-drv = <0>; + }; }; pinctrl_2: pinctrl@03860000 {
Signature · 1 line
2.7.0
Re: [PATCHv13 01/17] dts: exynos4*: add HDMI CEC pin definition to pinctrl
Quoted 5 lines · Hans Verkuil
From: Kamil Debski <[email protected]>
Add pinctrl nodes for the HDMI CEC device to the Exynos4210 and Exynos4x12 SoCs. These are required by the HDMI CEC device.
Quoted 7 lines
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Hans Verkuil <[email protected]>--- arch/arm/boot/dts/exynos4210-pinctrl.dtsi | 7 +++++++ arch/arm/boot/dts/exynos4x12-pinctrl.dtsi | 7 +++++++ 2 files changed, 14 insertions(+)
Hi Hans,
I see you have been carrying these three patches for a long time. Initially I thought that there are some dependencies... but maybe there are not?
Can I take these Exynos DTS patches to samsung-soc?
Best regards,
Krzysztof
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCHv13 01/17] dts: exynos4*: add HDMI CEC pin definition to pinctrl
Quoted 14 lines · Krzysztof Kozlowski
Quoted 5 lines · Hans Verkuil
From: Kamil Debski <[email protected]>
Add pinctrl nodes for the HDMI CEC device to the Exynos4210 and Exynos4x12 SoCs. These are required by the HDMI CEC device.
Quoted 7 lines
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Hans Verkuil <[email protected]>--- arch/arm/boot/dts/exynos4210-pinctrl.dtsi | 7 +++++++ arch/arm/boot/dts/exynos4x12-pinctrl.dtsi | 7 +++++++ 2 files changed, 14 insertions(+)
Quoted 7 lines
Hi Hans,
I see you have been carrying these three patches for a long time. Initially I thought that there are some dependencies... but maybe there are not?
Can I take these Exynos DTS patches to samsung-soc?
That would be very nice!
BTW, it would be nice if someone from Samsung could try to improve the s5p CEC driver from this patch series.
The problem is that it expects userspace to tell it the physical address, which is read from the EDID. But the HDMI driver in the kernel already knows this, so requiring userspace to handle this is not nice.
Basically the CEC driver needs to know when a new EDID has been read and when the hotplug detect goes low (EDID has been lost).
If someone who actually knows the HDMI code could provide me with a patch, then I can fix the CEC driver. I have an odroid to test with, so I can check the code.
Regards,
Hans
Re: [PATCHv13 01/17] dts: exynos4*: add HDMI CEC pin definition to pinctrl
Quoted 17 lines · Hans Verkuil
Quoted 16 lines · Krzysztof Kozlowski
Quoted 5 lines · Hans Verkuil
From: Kamil Debski <[email protected]>
Add pinctrl nodes for the HDMI CEC device to the Exynos4210 and Exynos4x12 SoCs. These are required by the HDMI CEC device.
Quoted 7 lines
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Hans Verkuil <[email protected]>--- arch/arm/boot/dts/exynos4210-pinctrl.dtsi | 7 +++++++ arch/arm/boot/dts/exynos4x12-pinctrl.dtsi | 7 +++++++ 2 files changed, 14 insertions(+)Hi Hans,
Quoted 7 lines
Quoted 5 lines
I see you have been carrying these three patches for a long time. Initially I thought that there are some dependencies... but maybe there are not?
Can I take these Exynos DTS patches to samsung-soc?
That would be very nice!
I'll apply them after merge window.
Quoted 7 lines
BTW, it would be nice if someone from Samsung could try to improve the s5p CEC driver from this patch series.
The problem is that it expects userspace to tell it the physical address, which is read from the EDID. But the HDMI driver in the kernel already knows this, so requiring userspace to handle this is not nice.
Quoted 6 lines
Basically the CEC driver needs to know when a new EDID has been read and when the hotplug detect goes low (EDID has been lost).
If someone who actually knows the HDMI code could provide me with a patch, then I can fix the CEC driver. I have an odroid to test with, so I can check the code.
Not quite my area of knowledge but I'll keep it in mind.
Best regards,
Krzysztof
PATCH v13 2/17 dts: exynos4: add node for the HDMI CEC device
In reply to Hans VerkuilFrom: Kamil Debski <[email protected]>
This patch adds HDMI CEC node specific to the Exynos4210/4x12 SoC series.
--- arch/arm/boot/dts/exynos4.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/boot/dts/exynos4.dtsi +12 -0
@@ -751,6 +751,18 @@ status = "disabled"; }; + hdmicec: cec@100B0000 { + compatible = "samsung,s5p-cec"; + reg = <0x100B0000 0x200>; + interrupts = <0 114 0>; + clocks = <&clock CLK_HDMI_CEC>; + clock-names = "hdmicec"; + samsung,syscon-phandle = <&pmu_system_controller>; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_cec>; + status = "disabled"; + }; + mixer: mixer@12C10000 { compatible = "samsung,exynos4210-mixer"; interrupts = <0 91 0>;
Signature · 1 line
2.7.0
PATCH v13 3/17 dts: exynos4412-odroid*: enable the HDMI CEC device
In reply to Hans VerkuilFrom: Marek Szyprowski <[email protected]>
Add a dts node entry and enable the HDMI CEC device present in the Exynos4 family of SoCs.
--- arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/exynos4412-odroid-common.dtsi +4 -0
@@ -500,3 +500,7 @@ &watchdog { status = "okay"; }; + +&hdmicec { + status = "okay"; +};
Signature · 1 line
2.7.0
PATCH v13 4/17 input.h: add BUS_CEC type
In reply to Hans VerkuilInputs can come in over the HDMI CEC bus, so add a new type for this.
--- include/uapi/linux/input.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/input.h +1 -0
@@ -246,6 +246,7 @@ struct input_mask {#define BUS_GSC 0x1A#define BUS_ATARI 0x1B#define BUS_SPI 0x1C +#define BUS_CEC 0x1D/* * MT_TOOL types
Signature · 1 line
2.7.0
PATCH v13 5/17 HID: add HDMI CEC specific keycodes
In reply to Hans VerkuilFrom: Kamil Debski <[email protected]>
Add HDMI CEC specific keycodes to the keycodes definition.
--- include/uapi/linux/input-event-codes.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
include/uapi/linux/input-event-codes.h +30 -0
@@ -611,6 +611,36 @@#define KEY_KBDINPUTASSIST_ACCEPT 0x264#define KEY_KBDINPUTASSIST_CANCEL 0x265 +/* Diagonal movement keys */ +#define KEY_RIGHT_UP 0x266 +#define KEY_RIGHT_DOWN 0x267 +#define KEY_LEFT_UP 0x268 +#define KEY_LEFT_DOWN 0x269 + +#define KEY_ROOT_MENU 0x26a/* Show Device's Root Menu */ +#define KEY_MEDIA_TOP_MENU 0x26b/* Show Top Menu of the Media (e.g. DVD) */ +#define KEY_NUMERIC_11 0x26c +#define KEY_NUMERIC_12 0x26d +/* +* Toggle Audio Description: refers to an audio service that helps blind and +* visually impaired consumers understand the action in a program. Note: in +* some countries this is referred to as "Video Description". +*/ +#define KEY_AUDIO_DESC 0x26e +#define KEY_3D_MODE 0x26f +#define KEY_NEXT_FAVORITE 0x270 +#define KEY_STOP_RECORD 0x271 +#define KEY_PAUSE_RECORD 0x272 +#define KEY_VOD 0x273/* Video on Demand */ +#define KEY_UNMUTE 0x274 +#define KEY_FASTREVERSE 0x275 +#define KEY_SLOWREVERSE 0x276 +/* +* Control a data application associated with the currently viewed channel, +* e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.) +*/ +#define KEY_DATA 0x275 +#define BTN_TRIGGER_HAPPY 0x2c0#define BTN_TRIGGER_HAPPY1 0x2c0#define BTN_TRIGGER_HAPPY2 0x2c1
Signature · 1 line
2.7.0
Re: [PATCHv13 05/17] HID: add HDMI CEC specific keycodes
Hi Dmitry,
Can you Ack this? I don't expect this to change anymore. Your comments have been incorporated (added the "Diagonal movement keys" comment).
Thanks!
Hans
Quoted 52 lines · Hans Verkuil
From: Kamil Debski <[email protected]>
Add HDMI CEC specific keycodes to the keycodes definition.
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Hans Verkuil <[email protected]>--- include/uapi/linux/input-event-codes.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)include/uapi/linux/input-event-codes.h +30
-0@@ -611,6 +611,36 @@#define KEY_KBDINPUTASSIST_ACCEPT 0x264#define KEY_KBDINPUTASSIST_CANCEL 0x265 +/* Diagonal movement keys */ +#define KEY_RIGHT_UP 0x266 +#define KEY_RIGHT_DOWN 0x267 +#define KEY_LEFT_UP 0x268 +#define KEY_LEFT_DOWN 0x269 + +#define KEY_ROOT_MENU 0x26a/* Show Device's Root Menu */ +#define KEY_MEDIA_TOP_MENU 0x26b/* Show Top Menu of the Media (e.g. DVD) */ +#define KEY_NUMERIC_11 0x26c +#define KEY_NUMERIC_12 0x26d +/* +* Toggle Audio Description: refers to an audio service that helps blind and +* visually impaired consumers understand the action in a program. Note: in +* some countries this is referred to as "Video Description". +*/ +#define KEY_AUDIO_DESC 0x26e +#define KEY_3D_MODE 0x26f +#define KEY_NEXT_FAVORITE 0x270 +#define KEY_STOP_RECORD 0x271 +#define KEY_PAUSE_RECORD 0x272 +#define KEY_VOD 0x273/* Video on Demand */ +#define KEY_UNMUTE 0x274 +#define KEY_FASTREVERSE 0x275 +#define KEY_SLOWREVERSE 0x276 +/* +* Control a data application associated with the currently viewed channel, +* e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.) +*/ +#define KEY_DATA 0x275 +#define BTN_TRIGGER_HAPPY 0x2c0#define BTN_TRIGGER_HAPPY1 0x2c0#define BTN_TRIGGER_HAPPY2 0x2c1
PATCH v13 6/17 rc: Add HDMI CEC protocol handling
In reply to Hans VerkuilFrom: Kamil Debski <[email protected]>
Add handling of remote control events coming from the HDMI CEC bus. This patch includes a new keymap that maps values found in the CEC messages to the keys pressed and released. Also, a new protocol has been added to the core.
--- drivers/media/rc/keymaps/Makefile | 1 + drivers/media/rc/keymaps/rc-cec.c | 174 ++++++++++++++++++++++++++++++++++++++ drivers/media/rc/rc-main.c | 1 + include/media/rc-map.h | 5 +- 4 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 drivers/media/rc/keymaps/rc-cec.c
drivers/media/rc/keymaps/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-behold.o \ rc-behold-columbus.o \ rc-budget-ci-old.o \ + rc-cec.o \ rc-cinergy-1400.o \ rc-cinergy.o \ rc-delock-61959.o \
drivers/media/rc/keymaps/rc-cec.c new file +174 -0
174 lines not on this page · raw message
drivers/media/rc/rc-main.c +1 -0
@@ -804,6 +804,7 @@ static const struct { { RC_BIT_SHARP, "sharp", "ir-sharp-decoder" }, { RC_BIT_MCE_KBD, "mce_kbd", "ir-mce_kbd-decoder" }, { RC_BIT_XMP, "xmp", "ir-xmp-decoder" }, + { RC_BIT_CEC, "cec", NULL }, };/**
include/media/rc-map.h +4 -1
@@ -31,6 +31,7 @@ enum rc_type {RC_TYPE_RC6_MCE =16 ,/* MCE (Philips RC6-6A-32 subtype) protocol */ RC_TYPE_SHARP =17 ,/* Sharp protocol */ RC_TYPE_XMP =18 ,/* XMP protocol */ + RC_TYPE_CEC = 19, /* CEC protocol */ };#define RC_BIT_NONE 0ULL
@@ -53,6 +54,7 @@ enum rc_type {#define RC_BIT_RC6_MCE (1ULL << RC_TYPE_RC6_MCE)#define RC_BIT_SHARP (1ULL << RC_TYPE_SHARP)#define RC_BIT_XMP (1ULL << RC_TYPE_XMP) +#define RC_BIT_CEC (1ULL << RC_TYPE_CEC)#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \ RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
@@ -61,7 +63,7 @@ enum rc_type { RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \ RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \ - RC_BIT_XMP) + RC_BIT_XMP | RC_BIT_CEC)#define RC_SCANCODE_UNKNOWN (x) (x)
@@ -123,6 +125,7 @@ void rc_map_init(void);#define RC_MAP_BEHOLD_COLUMBUS "rc-behold-columbus"#define RC_MAP_BEHOLD "rc-behold"#define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old" +#define RC_MAP_CEC "rc-cec"#define RC_MAP_CINERGY_1400 "rc-cinergy-1400"#define RC_MAP_CINERGY "rc-cinergy"#define RC_MAP_DELOCK_61959 "rc-delock-61959"
Signature · 1 line
2.7.0
PATCH v13 7/17 cec: add HDMI CEC framework
In reply to Hans VerkuilFrom: Hans Verkuil <[email protected]>
The added HDMI CEC framework provides a generic kernel interface for HDMI CEC devices.
[[email protected]: change kthread handling when setting logical address]
[[email protected]: code cleanup and fixes] [[email protected]: add missing CEC commands to match spec] [[email protected]: add RC framework support] [[email protected]: move and edit documentation] [[email protected]: add vendor id reporting] [[email protected]: add possibility to clear assigned logical addresses]
[[email protected]: documentation fixes, clenaup and expansion] [[email protected]: reorder of API structs and add reserved fields] [[email protected]: fix handling of events and fix 32/64bit timespec problem]
[[email protected]: add cec.h to include/uapi/linux/Kbuild] [[email protected]: add sequence number handling] [[email protected]: add passthrough mode] [[email protected]: fix CEC defines, add missing CEC 2.0 commands] minor additions]
--- MAINTAINERS | 14 + drivers/media/Kconfig | 5 + drivers/media/Makefile | 2 + drivers/media/cec.c | 2774 ++++++++++++++++++++++++++++++++++++++++ include/media/cec.h | 220 ++++ include/uapi/linux/Kbuild | 2 + include/uapi/linux/cec-funcs.h | 1852 +++++++++++++++++++++++++++ include/uapi/linux/cec.h | 946 ++++++++++++++ 8 files changed, 5815 insertions(+) create mode 100644 drivers/media/cec.c create mode 100644 include/media/cec.h create mode 100644 include/uapi/linux/cec-funcs.h create mode 100644 include/uapi/linux/cec.h
MAINTAINERS +14 -0
@@ -2704,6 +2704,20 @@ F: drivers/net/ieee802154/cc2520.c F: include/linux/spi/cc2520.h F: Documentation/devicetree/bindings/net/ieee802154/cc2520.txt +CEC DRIVER +M: Hans Verkuil <[email protected]> +L: [email protected] +T: git git://linuxtv.org/media_tree.git +W: http://linuxtv.org +S: Supported +F: Documentation/cec.txt +F: Documentation/DocBook/media/v4l/cec* +F: drivers/media/cec.c +F: drivers/media/rc/keymaps/rc-cec.c +F: include/media/cec.h +F: include/uapi/linux/cec.h +F: include/uapi/linux/cec-funcs.h + CELL BROADBAND ENGINE ARCHITECTURE M: Arnd Bergmann <[email protected]> L: [email protected]
drivers/media/Kconfig +5 -0
@@ -80,6 +80,11 @@ config MEDIA_RC_SUPPORT Say Y when you have a TV or an IR device. +config MEDIA_CEC + tristate "CEC API (EXPERIMENTAL)" + ---help--- + Enable the CEC API. + # # Media controller # Selectable only for webcam/grabbers, as other drivers don't use it
drivers/media/Makefile +2 -0
@@ -2,6 +2,8 @@ # Makefile for the kernel multimedia device drivers. # +obj-$(CONFIG_MEDIA_CEC) += cec.o + media-objs := media-device.o media-devnode.o media-entity.o #
drivers/media/cec.c new file +2774 -0
2,774 lines not on this page · raw message
include/media/cec.h new file +220 -0
187 lines not on this page · raw message
include/uapi/linux/cec-funcs.h new file +1852 -0
1,852 lines not on this page · raw message
include/uapi/linux/cec.h new file +946 -0
946 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.0
Part of the diff is not shown here. View the raw message.
PATCH v13 8/17 cec: add compat32 ioctl support
In reply to Hans VerkuilThe CEC ioctls didn't have compat32 support, so they returned -ENOTTY when used in a 32 bit application on a 64 bit kernel.
Since all the CEC ioctls are 32-bit compatible adding support for this API is trivial.
--- fs/compat_ioctl.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/compat_ioctl.c +17 -0
@@ -57,6 +57,7 @@#include <linux/i2c-dev.h> #include <linux/atalk.h> #include <linux/gfp.h> +#include <linux/cec.h> #include "internal.h"
@@ -1399,6 +1400,22 @@ COMPATIBLE_IOCTL(VIDEO_GET_NAVI) COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES) COMPATIBLE_IOCTL(VIDEO_GET_SIZE) COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE) +/* cec */ +COMPATIBLE_IOCTL(CEC_ADAP_G_CAPS) +COMPATIBLE_IOCTL(CEC_ADAP_LOG_STATUS) +COMPATIBLE_IOCTL(CEC_ADAP_G_LOG_ADDRS) +COMPATIBLE_IOCTL(CEC_ADAP_S_LOG_ADDRS) +COMPATIBLE_IOCTL(CEC_ADAP_G_STATE) +COMPATIBLE_IOCTL(CEC_ADAP_S_STATE) +COMPATIBLE_IOCTL(CEC_ADAP_G_PHYS_ADDR) +COMPATIBLE_IOCTL(CEC_ADAP_S_PHYS_ADDR) +COMPATIBLE_IOCTL(CEC_ADAP_G_VENDOR_ID) +COMPATIBLE_IOCTL(CEC_ADAP_S_VENDOR_ID) +COMPATIBLE_IOCTL(CEC_G_MODE) +COMPATIBLE_IOCTL(CEC_S_MODE) +COMPATIBLE_IOCTL(CEC_TRANSMIT) +COMPATIBLE_IOCTL(CEC_RECEIVE) +COMPATIBLE_IOCTL(CEC_DQEVENT) /* joystick */ COMPATIBLE_IOCTL(JSIOCGVERSION)
Signature · 1 line
2.7.0
PATCH v13 9/17 cec.txt: add CEC framework documentation
In reply to Hans VerkuilFrom: Hans Verkuil <[email protected]>
Document the new HDMI CEC framework.
[[email protected]: add DocBook documentation by Hans Verkuil, with
--- Documentation/cec.txt | 391 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 391 insertions(+) create mode 100644 Documentation/cec.txt
Documentation/cec.txt new file +391 -0
@@ -0,0 +1,391 @@ +CEC Kernel Support +================== + +The CEC framework provides a unified kernel interface for use with HDMI CEC +hardware. It is designed to handle a multiple types of hardware (receivers, +transmitters, USB dongles). The framework also gives the option to decide +what to do in the kernel driver and what should be handled by userspace +applications. In addition it integrates the remote control passthrough +feature into the kernel's remote control framework. + + +The CEC Protocol +---------------- + +The CEC protocol enables consumer electronic devices to communicate with each +other through the HDMI connection. The protocol uses logical addresses in the +communication. The logical address is strictly connected with the functionality +provided by the device. The TV acting as the communication hub is always +assigned address 0. The physical address is determined by the physical +connection between devices. + +The CEC framework described here is up to date with the CEC 2.0 specification. +It is documented in the HDMI 1.4 specification with the new 2.0 bits documented +in the HDMI 2.0 specification. But for most of the features the freely available +HDMI 1.3a specification is sufficient: + +http://www.microprocessor.org/HDMISpecification13a.pdf + + +The Kernel Interface +==================== + +CEC Adapter +----------- + +The struct cec_adapter represents the CEC adapter hardware. It is created by +calling cec_create_adapter() and deleted by calling cec_delete_adapter(): + +struct cec_adapter *cec_create_adapter(const struct cec_adap_ops *ops, + void *priv, const char *name, u32 caps, + u8 ninputs, struct device *parent); +void cec_delete_adapter(struct cec_adapter *adap); + +To create an adapter you need to pass the following information: + +ops: adapter operations which are called by the CEC framework and that you +have to implement. + +priv: will be stored in adap->priv and can be used by the adapter ops. + +name: the name of the CEC adapter. Note: this name will be copied. + +caps: capabilities of the CEC adapter. These capabilities determine the + capabilities of the hardware and which parts are to be handled + by userspace and which parts are handled by kernelspace. The + capabilities are returned by CEC_ADAP_G_CAPS. + +ninputs: the number of HDMI inputs of the device. This may be 0. This + is returned by CEC_ADAP_G_CAPS. + +parent: the parent device. + + +After creating the adapter the driver can modify the following fields +in struct cec_adapter: + + u8 available_log_addrs; + +This determines the number of simultaneous logical addresses the hardware +can program. Often this is 1, which is also the default. + + u8 pwr_state; + +The CEC_MSG_GIVE_DEVICE_POWER_STATUS power state. By default this is +CEC_OP_POWER_STATUS_ON (0). The driver can change this to signal power +state transitions. + + u16 phys_addr; + +By default this is 0xffff, but drivers can change this using the cec_set_phys_addr +function. The phys_addr field must be set before the CEC adapter is enabled (see +the adap_enable op below). While the CEC adapter remains enabled it cannot be +changed. Drivers never set this if CEC_CAP_PHYS_ADDR is set. + + u32 vendor_id; + +By default this is CEC_VENDOR_ID_NONE (0xffffffff). It should not be changed +once the adapter is configured. Drivers never set this if CEC_CAP_VENDOR_ID +is set. + + u8 cec_version; + +The CEC version that the framework should support. By default this is the +latest version, but it can be changed to an older version, causing attempts +to use later extensions to fail. Obviously this should be set before the +CEC adapter is enabled. + +To register the /dev/cecX device node and the remote control device (if +CEC_CAP_RC is set) you call: + +int cec_register_adapter(struct cec_adapter *adap); + +To unregister the devices call: + +void cec_unregister_adapter(struct cec_adapter *adap); + +Note: if cec_register_adapter() fails, then call cec_delete_adapter() to +clean up. But if cec_register_adapter() succeeded, then only call +cec_unregister_adapter() to clean up, never cec_delete_adapter(). The +unregister function will delete the adapter automatically once the last user +of that /dev/cecX device has closed its file handle. + + +Implementing the Low-Level CEC Adapter +-------------------------------------- + +The following low-level adapter operations have to be implemented in +your driver: + +struct cec_adap_ops { + /* Low-level callbacks */ + int (*adap_enable)(struct cec_adapter *adap, bool enable); + int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); + int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); + int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, + u32 signal_free_time, struct cec_msg *msg); + void (*adap_log_status)(struct cec_adapter *adap); + + /* High-level callbacks */ + ... +}; + +The three low-level ops deal with various aspects of controlling the CEC adapter +hardware: + + +To enable/disable the hardware: + + int (*adap_enable)(struct cec_adapter *adap, bool enable); + +This callback enables or disables the CEC hardware. Enabling the CEC hardware +means powering it up in a state where no logical addresses are claimed. This +op assumes that the physical address (adap->phys_addr) is valid when enable is +true and will not change while the CEC adapter remains enabled. The initial +state of the CEC adapter after calling cec_create_adapter() is disabled. + +Note that adap_enable must return 0 if enable is false. + + +To enable/disable the 'monitor all' mode: + + int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); + +If enabled, then the adapter should be put in a mode to also monitor messages +that not for us. Not all hardware supports this and this function is only +called if the CEC_CAP_MONITOR_ALL capability is set. This callback is optional +(some hardware may always be in 'monitor all' mode). + +Note that adap_monitor_all_enable must return 0 if enable is false. + + +To program a new logical address: + + int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); + +If logical_addr == CEC_LOG_ADDR_INVALID then all programmed logical addresses +are to be erased. Otherwise the given logical address should be programmed. +If the maximum number of available logical addresses is exceeded, then it +should return -ENXIO. Once a logical address is programmed the CEC hardware +can start receiving messages. + +Note that adap_log_addr must return 0 if logical_addr is CEC_LOG_ADDR_INVALID. + + +To transmit a new message: + + int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, + u32 signal_free_time, struct cec_msg *msg); + +This transmits a new message. The attempts argument is the suggested number of +attempts for the transmit. + +The signal_free_time is the number of data bit periods that the adapter should +wait when the line is free before attempting to send a message. This value +depends on whether this transmit is a retry, a message from a new initiator or +a new message for the same initiator. Most hardware will handle this +automatically, but in some cases this information is needed. + +The CEC_FREE_TIME_TO_USEC macro can be used to convert signal_free_time to +microseconds (one data bit period is 2.4 ms). + + +To log the current CEC hardware status: + + void (*log_status)(struct cec_adapter *adap); + +This optional callback can be used to log the status of the CEC hardware. +It will be called from the CEC_ADAP_LOG_STATUS ioctl. + + +Your adapter driver will also have to react to events (typically interrupt +driven) by calling into the framework in the following situations: + +When a transmit finished (successfully or otherwise): + +void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, + u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt); + +The status can be one of: + +CEC_TX_STATUS_OK: the transmit was successful. +CEC_TX_STATUS_ARB_LOST: arbitration was lost: another CEC initiator +took control of the CEC line and you lost the arbitration. +CEC_TX_STATUS_NACK: the message was nacked (for a directed message) or +acked (for a broadcast message). A retransmission is needed. +CEC_TX_STATUS_LOW_DRIVE: low drive was detected on the CEC bus. This +indicates that a follower detected an error on the bus and requested a +retransmission. +CEC_TX_STATUS_ERROR: some unspecified error occurred: this can be one of +the previous two if the hardware cannot differentiate or something else +entirely. +CEC_TX_STATUS_MAX_RETRIES: could not transmit the message after +trying multiple times. Should only be set by the driver if it has hardware +support for retrying messages. If set, then the framework assumes that it +doesn't have to make another attempt to transmit the message since the +hardware did that already. + +The *_cnt arguments are the number of error conditions that were seen. +This may be 0 if no information is available. Drivers that do not support +hardware retry can just set the counter corresponding to the transmit error +to 1, if the hardware does support retry then either set these counters to +0 if the hardware provides no feedback of which errors occurred and how many +times, or fill in the correct values as reported by the hardware. + +When a CEC message was received: + +void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg); + +Speaks for itself. + +When the number connected inputs changes: + +void cec_connected_inputs(struct cec_adapter *adap, u16 connected_inputs); + +The connected_inputs argument is a bit mask where bit 0 refers to HDMI input 0, +etc. Only the first ninputs (see CEC_ADAP_G_CAPS) bits can be 1, the remainder +are always 0. This function should be called when the HDMI receiver driver +detects when a new device is connected or disconnected from a given input. + +The CEC framework will pass this information on to the user. + +Implementing the High-Level CEC Adapter +--------------------------------------- + +The low-level operations drive the hardware, the high-level operations are +CEC protocol driven. The following high-level callbacks are available: + +struct cec_adap_ops { + /* Low-level callbacks */ + ... + + /* High-level CEC message callback */ + int (*received)(struct cec_adapter *adap, struct cec_msg *msg); + + /* High-level CDC Hotplug Detect callbacks */ + u8 (*source_cdc_hpd)(struct cec_adapter *adap, u8 cdc_hpd_state); + void (*sink_cdc_hpd)(struct cec_adapter *adap, u8 cdc_hpd_state, u8 cdc_hpd_error); + + /* High-level Audio Return Channel callbacks */ + int (*sink_initiate_arc)(struct cec_adapter *adap); + int (*sink_terminate_arc)(struct cec_adapter *adap); + int (*source_arc_initiated)(struct cec_adapter *adap); + int (*source_arc_terminated)(struct cec_adapter *adap); +}; + +The received() callback allows the driver to optionally handle a newly +received CEC message + + int (*received)(struct cec_adapter *adap, struct cec_msg *msg); + +If the driver wants to process a CEC message, then it can implement this +callback. If it doesn't want to handle this message, then it should return +-ENOMSG, otherwise the CEC framework assumes it processed this message and +it will not no anything with it. + +The other callbacks deal with two CEC features: CDC Hotplug Detect and +Audio Return Channel. Here the framework takes care of handling these +messages and it calls the callbacks to notify the driver when it needs +to take action. + +CDC Hotplug Support +------------------- + +A source received a hotplug state change message: + + u8 (*source_cdc_hpd)(struct cec_adapter *adap, u8 cdc_hpd_state); + +A source received a CEC_MSG_CDC_HPD_SET_STATE message. The framework will +reply with a CEC_MSG_CDC_HPD_REPORT_STATE message and this callback is used +to fill in the HPD Error Code Operand of the REPORT_STATE message. In addition, +the driver can act in this callback on the hotplug state change. + +Only implement if CEC_CAP_CDC_HPD is set. + +A sink received a hotplug report state message: + + void (*sink_cdc_hpd)(struct cec_adapter *adap, u8 cdc_hpd_state, u8 cdc_hpd_error); + +A sink received a CEC_MSG_CDC_HPD_REPORT_STATE message. This callback will +do anything necessary to implement this hotplug change. The two arguments +are the HPD Error State and HPD Error Code Operands from the CEC_MSG_CDC_HPD_REPORT_STATE +message. + + +Audio Return Channel Support +---------------------------- + +Called if a CEC_MSG_INITIATE_ARC message is received by an HDMI sink. +This callback should start sending audio over the audio return channel. If +successful it should return 0. + + int (*sink_initiate_arc)(struct cec_adapter *adap); + +Called if a CEC_MSG_TERMINATE_ARC message is received by an HDMI sink. +This callback should stop sending audio over the audio return channel. If +successful it should return 0. + + void (*sink_terminate_arc)(struct cec_adapter *adap); + +Called if a CEC_MSG_REPORT_ARC_INITIATED message is received by an +HDMI source. This callback can be used to enable receiving audio from +the audio return channel. + + void (*source_arc_initiated)(struct cec_adapter *adap); + +Called if a CEC_MSG_REPORT_ARC_TERMINATED message is received by an +HDMI source. This callback can be used to disable receiving audio from +the audio return channel. + + void (*source_arc_terminated)(struct cec_adapter *adap); + + +CEC framework functions +----------------------- + +CEC Adapter drivers can call the following CEC framework functions: + +int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg, + bool block); + +Transmit a CEC message. If block is true, then wait until the message has been +transmitted, otherwise just queue it and return. + +void cec_set_phys_addr(struct cec_adapter *adap, u16 phys_addr); + +Change the physical address. This function will set adap->phys_addr and +send an event if it has changed. + +int cec_claim_log_addrs(struct cec_adapter *adap, + struct cec_log_addrs *log_addrs, bool block); + +Claim the CEC logical addresses. Should never be called if CEC_CAP_LOG_ADDRS +is set. If block is true, then wait until the logical addresses have been +claimed, otherwise just queue it and return. To unconfigure all logical +addresses call this function with log_addrs set to NULL or with +log_addrs->num_log_addrs set to 0. The block argument is ignored when +unconfiguring. + +int _cec_enable(struct cec_adapter *adap, bool enable); +int cec_enable(struct cec_adapter *adap, bool enable); + +Enable or disable the CEC adapter. HDMI transmitters will typically disable +the adapter when the hotplug signal goes down and enable it after it went up +again and the EDID was read containing the new physical address. Should never +be called if CEC_CAP_STATE is set. The _cec_enable is the unlocked variant and +cec_enable takes the adap->lock mutex and calls _cec_enable. + +u8 cec_sink_cdc_hpd(struct cec_adapter *adap, u8 input_port, u8 cdc_hpd_state); + +If an HDMI receiver supports hotplug signalling over CDC (CEC_CAP_CDC_HPD is +set), then the driver should call this function whenever the hotplug state +changes for an input. This call will send an appropriate CDC message over +the CEC line. It returns CEC_OP_HPD_ERROR_NONE on success, if the adapter +is unconfigured it returns CEC_OP_HPD_ERROR_INITIATOR_WRONG_STATE and if +the cec_transmit fails it returns CEC_OP_HPD_ERROR_OTHER. + +void cec_log_status(struct cec_adapter *adap); + +This logs the current CEC adapter status in the kernel log. Useful for +debugging. It is called from the CEC_ADAP_LOG_STATUS ioctl, but it can +also be called from e.g. the V4L2 VIDIOC_LOG_STATUS ioctl.
Signature · 1 line
2.7.0
PATCH v13 10/17 DocBook/media: add CEC documentation
In reply to Hans VerkuilAdd DocBook documentation for the CEC API.
--- Documentation/DocBook/device-drivers.tmpl | 3 + Documentation/DocBook/media/Makefile | 2 + Documentation/DocBook/media/v4l/biblio.xml | 10 + Documentation/DocBook/media/v4l/cec-api.xml | 75 +++++ Documentation/DocBook/media/v4l/cec-func-close.xml | 59 ++++ Documentation/DocBook/media/v4l/cec-func-ioctl.xml | 73 +++++ Documentation/DocBook/media/v4l/cec-func-open.xml | 94 +++++++ Documentation/DocBook/media/v4l/cec-func-poll.xml | 89 ++++++ .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml | 174 ++++++++++++ .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml | 306 +++++++++++++++++++++ .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml | 81 ++++++ .../DocBook/media/v4l/cec-ioc-adap-g-state.xml | 88 ++++++ .../DocBook/media/v4l/cec-ioc-adap-g-vendor-id.xml | 71 +++++ .../DocBook/media/v4l/cec-ioc-adap-log-status.xml | 51 ++++ .../DocBook/media/v4l/cec-ioc-dqevent.xml | 280 +++++++++++++++++++ Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml | 286 +++++++++++++++++++ .../DocBook/media/v4l/cec-ioc-receive.xml | 261 ++++++++++++++++++ Documentation/DocBook/media_api.tmpl | 6 +- 18 files changed, 2008 insertions(+), 1 deletion(-) create mode 100644 Documentation/DocBook/media/v4l/cec-api.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-close.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-ioctl.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-open.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-poll.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-state.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-vendor-id.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-log-status.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-receive.xml
Documentation/DocBook/device-drivers.tmpl +3 -0
@@ -269,6 +269,9 @@ X!Isound/sound_firmware.c !Iinclude/media/media-devnode.h !Iinclude/media/media-entity.h </sect1> + <sect1><title>Consumer Electronics Control devices</title> +!Iinclude/media/cec.h + </sect1> </chapter>
Documentation/DocBook/media/Makefile +2 -0
@@ -64,6 +64,7 @@ IOCTLS = \ $(shell perl -ne 'print "$$1 " if /\#define\s+([A-Z][^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/net.h) \ $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/video.h) \ $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/media.h) \ + $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/cec.h) \ $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \ DEFINES = \
@@ -100,6 +101,7 @@ STRUCTS = \ $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/ && !/_old/)' $(srctree)/include/uapi/linux/dvb/net.h) \ $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/video.h) \ $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/media.h) \ + $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/cec.h) \ $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \ $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-mediabus.h)
Documentation/DocBook/media/v4l/biblio.xml +10 -0
@@ -342,6 +342,16 @@ in the frequency range from 87,5 to 108,0 MHz</title> <subtitle>Specification Version 1.4a</subtitle> </biblioentry> + <biblioentry id="hdmi2"> + <abbrev>HDMI2</abbrev> + <authorgroup> + <corpauthor>HDMI Licensing LLC +(<ulink url="http://www.hdmi.org">http://www.hdmi.org</ulink>)</corpauthor> + </authorgroup> + <title>High-Definition Multimedia Interface</title> + <subtitle>Specification Version 2.0</subtitle> + </biblioentry> + <biblioentry id="dp"> <abbrev>DP</abbrev> <authorgroup>
Documentation/DocBook/media/v4l/cec-api.xml new file +75 -0
75 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-func-close.xml new file +59 -0
59 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-func-ioctl.xml new file +73 -0
73 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-func-open.xml new file +94 -0
94 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-func-poll.xml new file +89 -0
89 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml new file +174 -0
174 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml new file +306 -0
306 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml new file +81 -0
81 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-adap-g-state.xml new file +88 -0
88 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-adap-g-vendor-id.xml new file +71 -0
71 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-adap-log-status.xml new file +51 -0
51 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml new file +280 -0
280 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml new file +286 -0
286 lines not on this page · raw message
Documentation/DocBook/media/v4l/cec-ioc-receive.xml new file +261 -0
261 lines not on this page · raw message
Documentation/DocBook/media_api.tmpl +5 -1
@@ -75,7 +75,7 @@ </mediaobject> </figure> <para>The media infrastructure API was designed to control such - devices. It is divided into four parts.</para> + devices. It is divided into five parts.</para> <para>The first part covers radio, video capture and output, cameras, analog TV devices and codecs.</para> <para>The second part covers the
@@ -87,6 +87,7 @@ <xref linkend="fe-delivery-system-t" />.</para> <para>The third part covers the Remote Controller API.</para> <para>The fourth part covers the Media Controller API.</para> + <para>The fifth part covers the CEC (Consumer Electronics Control) API.</para> <para>It should also be noted that a media device may also have audio components, like mixers, PCM capture, PCM playback, etc, which are controlled via ALSA API.</para>
@@ -107,6 +108,9 @@ <part id="media_common"> &sub-media-controller; </part> +<part id="cec"> +&sub-cec-api; +</part> <chapter id="gen_errors"> &sub-gen-errors;
Signature · 1 line
2.7.0
PATCH v13 11/17 v4l2-subdev: add HDMI CEC ops
In reply to Hans VerkuilAdd CEC callbacks to the new v4l2_subdev_cec_ops struct. These are the low-level CEC ops that subdevs that support CEC have to implement.
--- include/media/v4l2-subdev.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
include/media/v4l2-subdev.h +22 -0
@@ -42,6 +42,18 @@#define V4L2_DEVICE_NOTIFY_EVENT _IOW('v', 2, struct v4l2_event) +struct v4l2_subdev_cec_tx_done { +u8 status; +u8 arb_lost_cnt; +u8 nack_cnt; +u8 low_drive_cnt; +u8 error_cnt; +}; + +#define V4L2_SUBDEV_CEC_TX_DONE _IOW('v', 3, struct v4l2_subdev_cec_tx_done) +#define V4L2_SUBDEV_CEC_RX_MSG _IOW('v', 4, struct cec_msg) +#define V4L2_SUBDEV_CEC_CONN_INPUTS _IOW('v', 5, u16) +struct v4l2_device ;struct v4l2_ctrl_handler ;struct v4l2_event ;
@@ -51,6 +63,7 @@ struct v4l2_subdev;struct v4l2_subdev_fh ;struct tuner_setup ;struct v4l2_mbus_frame_desc ; +struct cec_msg ;/* decode_vbi_line */ struct v4l2_decode_vbi_line {
@@ -645,6 +658,14 @@ struct v4l2_subdev_pad_ops { struct v4l2_mbus_frame_desc *fd); }; +struct v4l2_subdev_cec_ops { +unsigned (*adap_available_log_addrs)(struct v4l2_subdev *sd); +int (*adap_enable)(struct v4l2_subdev *sd,bool enable); +int (*adap_log_addr)(struct v4l2_subdev *sd,u8 logical_addr); +int (*adap_transmit)(struct v4l2_subdev *sd,u8 attempts, +u32 signal_free_time,struct cec_msg *msg); +}; +struct v4l2_subdev_ops {const struct v4l2_subdev_core_ops *core;const struct v4l2_subdev_tuner_ops *tuner;
@@ -654,6 +675,7 @@ struct v4l2_subdev_ops {const struct v4l2_subdev_ir_ops *ir;const struct v4l2_subdev_sensor_ops *sensor;const struct v4l2_subdev_pad_ops *pad; +const struct v4l2_subdev_cec_ops *cec; };/*
Signature · 1 line
2.7.0
PATCH v13 12/17 cec: adv7604: add cec support.
In reply to Hans VerkuilAdd CEC support to the adv7604 driver.
--- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/adv7604.c | 294 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 259 insertions(+), 37 deletions(-)
drivers/media/i2c/Kconfig +1 -1
@@ -206,7 +206,7 @@ config VIDEO_ADV7183 config VIDEO_ADV7604 tristate "Analog Devices ADV7604 decoder" - depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && MEDIA_CEC depends on GPIOLIB || COMPILE_TEST select HDMI ---help---
drivers/media/i2c/adv7604.c +258 -36
392 lines not on this page · raw message
Signature · 1 line
2.7.0
PATCH v13 13/17 cec: adv7842: add cec support
In reply to Hans VerkuilAdd CEC support to the adv7842 driver.
--- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/adv7842.c | 331 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 270 insertions(+), 63 deletions(-)
drivers/media/i2c/Kconfig +1 -1
@@ -220,7 +220,7 @@ config VIDEO_ADV7604 config VIDEO_ADV7842 tristate "Analog Devices ADV7842 decoder" - depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && MEDIA_CEC select HDMI ---help--- Support for the Analog Devices ADV7842 video decoder.
drivers/media/i2c/adv7842.c +269 -62
453 lines not on this page · raw message
Signature · 1 line
2.7.0
PATCH v13 14/17 cec: adv7511: add cec support.
In reply to Hans VerkuilAdd CEC support to the adv7511 driver.
--- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/adv7511.c | 356 +++++++++++++++++++++++++++++++++++++++++++- include/media/i2c/adv7511.h | 6 +- 3 files changed, 350 insertions(+), 14 deletions(-)
drivers/media/i2c/Kconfig +1 -1
@@ -445,7 +445,7 @@ config VIDEO_ADV7393 config VIDEO_ADV7511 tristate "Analog Devices ADV7511 encoder" - depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && MEDIA_CEC select HDMI ---help--- Support for the Analog Devices ADV7511 video encoder.
drivers/media/i2c/adv7511.c +348 -8
552 lines not on this page · raw message
include/media/i2c/adv7511.h +1 -5
@@ -32,11 +32,7 @@ struct adv7511_monitor_detect {struct adv7511_edid_detect {int present;int segment; -}; - -struct adv7511_cec_arg { -void *arg; -u32 f_flags; +uint16_t phys_addr; };struct adv7511_platform_data {
Signature · 1 line
2.7.0
PATCH v13 15/17 cobalt: add cec support
In reply to Hans VerkuilAdd CEC support to the cobalt driver.
--- drivers/media/pci/cobalt/Kconfig | 1 + drivers/media/pci/cobalt/cobalt-driver.c | 115 +++++++++++++++++++++++----- drivers/media/pci/cobalt/cobalt-driver.h | 2 + drivers/media/pci/cobalt/cobalt-irq.c | 3 + drivers/media/pci/cobalt/cobalt-v4l2.c | 126 ++++++++++++++++++++++++++++--- drivers/media/pci/cobalt/cobalt-v4l2.h | 2 + 6 files changed, 223 insertions(+), 26 deletions(-)
drivers/media/pci/cobalt/Kconfig +1 -0
@@ -4,6 +4,7 @@ config VIDEO_COBALT depends on PCI_MSI && MTD_COMPLEX_MAPPINGS depends on GPIOLIB || COMPILE_TEST depends on SND + select MEDIA_CEC select I2C_ALGOBIT select VIDEO_ADV7604 select VIDEO_ADV7511
drivers/media/pci/cobalt/cobalt-driver.c +98 -17
229 lines not on this page · raw message
drivers/media/pci/cobalt/cobalt-driver.h +2 -0
@@ -31,6 +31,7 @@#include <linux/workqueue.h> #include <linux/mutex.h> +#include <media/cec.h> #include <media/v4l2-common.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-device.h>
@@ -223,6 +224,7 @@ struct cobalt_stream {struct list_head bufs;struct i2c_adapter *i2c_adap;struct v4l2_subdev *sd; +struct cec_adapter *cec_adap;struct mutex lock;spinlock_t irqlock;struct v4l2_dv_timings timings;
drivers/media/pci/cobalt/cobalt-irq.c +3 -0
@@ -234,6 +234,9 @@ void cobalt_irq_log_status(struct cobalt *cobalt)u32 mask;int i; +cobalt_info ("irq: edge=%08x mask=%08x\n" , +cobalt_read_bar1 (cobalt,COBALT_SYS_STAT_EDGE ), +cobalt_read_bar1 (cobalt,COBALT_SYS_STAT_MASK ));cobalt_info ("irq: adv1=%u adv2=%u advout=%u none=%u full=%u\n" , cobalt->irq_adv1, cobalt->irq_adv2, cobalt->irq_advout, cobalt->irq_none, cobalt->irq_full_fifo);
drivers/media/pci/cobalt/cobalt-v4l2.c +117 -9
181 lines not on this page · raw message
drivers/media/pci/cobalt/cobalt-v4l2.h +2 -0
@@ -18,5 +18,7 @@* SOFTWARE. */ +extern const struct cec_adap_ops cobalt_cec_adap_ops; +int cobalt_nodes_register (struct cobalt *cobalt);void cobalt_nodes_unregister (struct cobalt *cobalt);
Signature · 1 line
2.7.0
PATCH v13 16/17 cec: s5p-cec: Add s5p-cec driver
In reply to Hans VerkuilFrom: Kamil Debski <[email protected]>
Add CEC interface driver present in the Samsung Exynos range of SoCs.
The following files were based on work by SangPil Moon:
- exynos_hdmi_cec.h
- exynos_hdmi_cecctl.c
--- .../devicetree/bindings/media/s5p-cec.txt | 31 +++ MAINTAINERS | 7 + drivers/media/platform/Kconfig | 12 + drivers/media/platform/Makefile | 1 + drivers/media/platform/s5p-cec/Makefile | 2 + drivers/media/platform/s5p-cec/exynos_hdmi_cec.h | 38 +++ .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c | 210 +++++++++++++++ drivers/media/platform/s5p-cec/regs-cec.h | 96 +++++++ drivers/media/platform/s5p-cec/s5p_cec.c | 295 +++++++++++++++++++++ drivers/media/platform/s5p-cec/s5p_cec.h | 76 ++++++ 10 files changed, 768 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/s5p-cec.txt create mode 100644 drivers/media/platform/s5p-cec/Makefile create mode 100644 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h create mode 100644 drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c create mode 100644 drivers/media/platform/s5p-cec/regs-cec.h create mode 100644 drivers/media/platform/s5p-cec/s5p_cec.c create mode 100644 drivers/media/platform/s5p-cec/s5p_cec.h
Documentation/devicetree/bindings/media/s5p-cec.txt new file +31 -0
@@ -0,0 +1,31 @@ +* Samsung HDMI CEC driver + +The HDMI CEC module is present is Samsung SoCs and its purpose is to +handle communication between HDMI connected devices over the CEC bus. + +Required properties: + - compatible : value should be following + "samsung,s5p-cec" + + - reg : Physical base address of the IP registers and length of memory + mapped region. + + - interrupts : HDMI CEC interrupt number to the CPU. + - clocks : from common clock binding: handle to HDMI CEC clock. + - clock-names : from common clock binding: must contain "hdmicec", + corresponding to entry in the clocks property. + - samsung,syscon-phandle - phandle to the PMU system controller + +Example: + +hdmicec: cec@100B0000 { + compatible = "samsung,s5p-cec"; + reg = <0x100B0000 0x200>; + interrupts = <0 114 0>; + clocks = <&clock CLK_HDMI_CEC>; + clock-names = "hdmicec"; + samsung,syscon-phandle = <&pmu_system_controller>; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_cec>; + status = "okay"; +};
MAINTAINERS +7 -0
@@ -1543,6 +1543,13 @@ L: [email protected] S: Maintained F: drivers/media/platform/s5p-tv/ +ARM/SAMSUNG S5P SERIES HDMI CEC SUBSYSTEM SUPPORT +M: Kyungmin Park <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: drivers/media/platform/s5p-cec/ + ARM/SAMSUNG S5P SERIES JPEG CODEC SUPPORT M: Andrzej Pietrasiewicz <[email protected]> M: Jacek Anaszewski <[email protected]>
drivers/media/platform/Kconfig +12 -0
@@ -108,6 +108,18 @@ config VIDEO_S3C_CAMIF source "drivers/media/platform/soc_camera/Kconfig" source "drivers/media/platform/exynos4-is/Kconfig" source "drivers/media/platform/s5p-tv/Kconfig" + +config VIDEO_SAMSUNG_S5P_CEC + tristate "Samsung S5P CEC driver" + depends on VIDEO_DEV && VIDEO_V4L2 && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) + select MEDIA_CEC + default n + ---help--- + This is a driver for Samsung S5P HDMI CEC interface. It uses the + generic CEC framework interface. + CEC bus is present in the HDMI connector and enables communication + between compatible devices. + source "drivers/media/platform/am437x/Kconfig" source "drivers/media/platform/xilinx/Kconfig"
drivers/media/platform/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE) += m2m-deinterlace.o obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif/ obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/ +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
drivers/media/platform/s5p-cec/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec.o +s5p-cec-y += s5p_cec.o exynos_hdmi_cecctrl.o
drivers/media/platform/s5p-cec/exynos_hdmi_cec.h new file +38 -0
@@ -0,0 +1,38 @@ +/* drivers/media/platform/s5p-cec/exynos_hdmi_cec.h +* +* Copyright (c) 2010, 2014 Samsung Electronics +* http://www.samsung.com/ +* +* Header file for interface of Samsung Exynos hdmi cec hardware +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _EXYNOS_HDMI_CEC_H_ +#define _EXYNOS_HDMI_CEC_H_ __FILE__ + +#include <linux/regmap.h> +#include <linux/miscdevice.h> +#include "s5p_cec.h" + +void s5p_cec_set_divider (struct s5p_cec_dev *cec); +void s5p_cec_enable_rx (struct s5p_cec_dev *cec); +void s5p_cec_mask_rx_interrupts (struct s5p_cec_dev *cec); +void s5p_cec_unmask_rx_interrupts (struct s5p_cec_dev *cec); +void s5p_cec_mask_tx_interrupts (struct s5p_cec_dev *cec); +void s5p_cec_unmask_tx_interrupts (struct s5p_cec_dev *cec); +void s5p_cec_reset (struct s5p_cec_dev *cec); +void s5p_cec_tx_reset (struct s5p_cec_dev *cec); +void s5p_cec_rx_reset (struct s5p_cec_dev *cec); +void s5p_cec_threshold (struct s5p_cec_dev *cec); +void s5p_cec_copy_packet (struct s5p_cec_dev *cec,char *data, +size_t count,u8 retries); +void s5p_cec_set_addr (struct s5p_cec_dev *cec,u32 addr); +u32 s5p_cec_get_status (struct s5p_cec_dev *cec); +void s5p_clr_pending_tx (struct s5p_cec_dev *cec); +void s5p_clr_pending_rx (struct s5p_cec_dev *cec); +void s5p_cec_get_rx_buf (struct s5p_cec_dev *cec,u32 size,u8 *buffer); + +#endif /* _EXYNOS_HDMI_CEC_H_ */
drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c new file +210 -0
210 lines not on this page · raw message
drivers/media/platform/s5p-cec/regs-cec.h new file +96 -0
96 lines not on this page · raw message
drivers/media/platform/s5p-cec/s5p_cec.c new file +295 -0
295 lines not on this page · raw message
drivers/media/platform/s5p-cec/s5p_cec.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.7.0
PATCH v13 17/17 vivid: add CEC emulation
In reply to Hans VerkuilThe vivid driver has been extended to provide CEC adapters for the HDMI input and HDMI outputs in order to test CEC applications.
This CEC emulation is faithful to the CEC timings (i.e., it all at a snail's pace).
--- Documentation/video4linux/vivid.txt | 36 ++- drivers/media/platform/vivid/Kconfig | 1 + drivers/media/platform/vivid/vivid-core.c | 361 ++++++++++++++++++++++- drivers/media/platform/vivid/vivid-core.h | 27 ++ drivers/media/platform/vivid/vivid-kthread-cap.c | 11 + drivers/media/platform/vivid/vivid-vid-cap.c | 31 ++ drivers/media/platform/vivid/vivid-vid-common.c | 7 + 7 files changed, 460 insertions(+), 14 deletions(-)
Documentation/video4linux/vivid.txt +31 -5
@@ -74,7 +74,8 @@ Section 11: Cropping, Composing, Scaling Section 12: Formats Section 13: Capture Overlay Section 14: Output Overlay -Section 15: Some Future Improvements +Section 15: CEC (Consumer Electronics Control) +Section 16: Some Future Improvements Section 1: Configuring the driver
@@ -364,7 +365,11 @@ For HDMI inputs it is possible to set the EDID. By default a simple EDID is provided. You can only set the EDID for HDMI inputs. Internally, however, the EDID is shared between all HDMI inputs. -No interpretation is done of the EDID data. +No interpretation is done of the EDID data with the exception of the +physical address. See the CEC section for more details. + +There is a maximum of 15 HDMI inputs (if there are more, then they will be +reduced to 15) since that's the limitation of the EDID physical address. Section 3: Video Output
@@ -409,6 +414,9 @@ standard, and for all others a 1:1 pixel aspect ratio is returned. An HDMI output has a valid EDID which can be obtained through VIDIOC_G_EDID. +There is a maximum of 15 HDMI outputs (if there are more, then they will be +reduced to 15) since that's the limitation of the EDID physical address. See +also the CEC section for more details. Section 4: VBI Capture ----------------------
@@ -1108,7 +1116,26 @@ capabilities will slow down the video loop considerably as a lot of checks have to be done per pixel. -Section 15: Some Future Improvements +Section 15: CEC (Consumer Electronics Control) +---------------------------------------------- + +If there are HDMI inputs then a CEC adapter will be created that has +the same number of input ports. This is the equivalent of e.g. a TV that +has that number of inputs. Each HDMI output will also create a +CEC adapter that is hooked up to the corresponding input port, or (if there +are more outputs than inputs) is not hooked up at all. In other words, +this is the equivalent of hooking up each output device to an input port of +the TV. Any remaining output devices remain unconnected. + +The EDID that each output reads reports a unique CEC physical address that is +based on the physical address of the EDID of the input. So if the EDID of the +receiver has physical address A.B.0.0, then each output will see an EDID +containing physical address A.B.C.0 where C is 1 to the number of inputs. If +there are more outputs than inputs then the remaining outputs have a CEC adapter +that is disabled and reports an invalid physical address. + + +Section 16: Some Future Improvements ------------------------------------ Just as a reminder and in no particular order:
@@ -1121,8 +1148,6 @@ Just as a reminder and in no particular order: - Fix sequence/field numbering when looping of video with alternate fields - Add support for V4L2_CID_BG_COLOR for video outputs - Add ARGB888 overlay support: better testing of the alpha channel -- Add custom DV timings support -- Add support for V4L2_DV_FL_REDUCED_FPS - Improve pixel aspect support in the tpg code by passing a real v4l2_fract - Use per-queue locks and/or per-device locks to improve throughput - Add support to loop from a specific output to a specific input across
@@ -1133,3 +1158,4 @@ Just as a reminder and in no particular order: - Make a thread for the RDS generation, that would help in particular for the "Controls" RDS Rx I/O Mode as the read-only RDS controls could be updated in real-time. +- Changing the EDID should cause hotplug detect emulation to happen.
drivers/media/platform/vivid/Kconfig +1 -0
@@ -6,6 +6,7 @@ config VIDEO_VIVID select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT + select MEDIA_CEC select VIDEOBUF2_VMALLOC default n ---help---
drivers/media/platform/vivid/vivid-core.c +352 -9
469 lines not on this page · raw message
drivers/media/platform/vivid/vivid-core.h +27 -0
@@ -21,6 +21,8 @@#define _VIVID_CORE_H_#include <linux/fb.h> +#include <linux/workqueue.h> +#include <media/cec.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-device.h> #include <media/v4l2-dev.h>
@@ -132,6 +134,17 @@ enum vivid_colorspace {#define VIVID_INVALID_SIGNAL (mode) \ ((mode) == NO_SIGNAL || (mode) == NO_LOCK || (mode) == OUT_OF_RANGE) +struct vivid_cec_work { +struct list_head list; +struct delayed_work work; +struct cec_adapter *adap; +struct vivid_dev *dev; +unsigned usecs; +unsigned timeout_ms; +u8 tx_status; +struct cec_msg msg; +}; +struct vivid_dev {unsigned inst;struct v4l2_device v4l2_dev;
@@ -497,6 +510,20 @@ struct vivid_dev {/* Shared between radio receiver and transmitter */ bool radio_rds_loop;struct timespec radio_rds_init_ts; + +/* CEC */ +struct cec_adapter *cec_rx_adap; +struct cec_adapter *cec_tx_adap[MAX_OUTPUTS ]; +struct workqueue_struct *cec_workqueue; +spinlock_t cec_slock; +struct list_head cec_work_list; +unsigned cec_xfer_time_jiffies; +unsigned long cec_xfer_start_jiffies; +u8 cec_output2bus_map[MAX_OUTPUTS ]; + +/* CEC OSD String */ +char osd[14 ]; +unsigned long osd_jiffies; };static inline bool vivid_is_webcam (const struct vivid_dev *dev)
drivers/media/platform/vivid/vivid-kthread-cap.c +11 -0
@@ -551,6 +551,17 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf)snprintf (str,sizeof (str)," button pressed!" );tpg_gen_text (tpg, basep, line++ * line_height,16 , str); } +if (dev->osd[0 ]) { +if (vivid_is_hdmi_cap (dev)) { +snprintf (str,sizeof (str)," OSD \"%s\"" , dev->osd); +tpg_gen_text (tpg, basep, line++ * line_height,16 , str); + } +if (dev->osd_jiffies && +time_is_before_jiffies (dev->osd_jiffies +5 *HZ )) { + dev->osd[0 ] =0 ; + dev->osd_jiffies =0 ; + } + } }/*
drivers/media/platform/vivid/vivid-vid-cap.c +31 -0
@@ -1700,6 +1700,9 @@ int vidioc_s_edid(struct file *file, void *_fh, struct v4l2_edid *edid) {struct vivid_dev *dev =video_drvdata (file); +u16 phys_addr; +unsigned shift; +unsigned i;memset (edid->reserved,0 ,sizeof (edid->reserved));if (edid->pad >= dev->num_inputs)
@@ -1714,8 +1717,36 @@ int vidioc_s_edid(struct file *file, void *_fh, edid->blocks = dev->edid_max_blocks;return -E2BIG ; } + phys_addr =cec_get_edid_phys_addr (edid->edid, edid->blocks *128 ,NULL ); +/* +* All nibbles are used so no valid physical addresses can be assigned +* to the inputs. +*/ +if (phys_addr &0xf ) + phys_addr =CEC_PHYS_ADDR_INVALID ; + +if (vb2_is_busy (&dev->vb_vid_cap_q)) +return -EBUSY ; + dev->edid_blocks = edid->blocks;memcpy (dev->edid, edid->edid, edid->blocks *128 ); + +/* TODO: a proper hotplug detect cycle should be emulated here */ +cec_set_phys_addr (dev->cec_rx_adap, phys_addr); + +if (phys_addr ==CEC_PHYS_ADDR_INVALID ) { +for (i =0 ; i <MAX_OUTPUTS && dev->cec_tx_adap[i]; i++) +cec_set_phys_addr (dev->cec_tx_adap[i], phys_addr); +return 0 ; + } + +/* Note: we already checked above that the lowest nibble == 0 */ +for (shift =4 ; shift <16 ; shift +=4 ) +if (phys_addr & (0xf << shift)) +break ; + shift -=4 ; +for (i =0 ; i <MAX_OUTPUTS && dev->cec_tx_adap[i]; i++) +cec_set_phys_addr (dev->cec_tx_adap[i], phys_addr | ((i +1 ) << shift));return 0 ; }
drivers/media/platform/vivid/vivid-vid-common.c +7 -0
@@ -908,6 +908,7 @@ int vidioc_g_edid(struct file *file, void *_fh, {struct vivid_dev *dev =video_drvdata (file);struct video_device *vdev =video_devdata (file); +struct cec_adapter *adap;memset (edid->reserved,0 ,sizeof (edid->reserved));if (vdev->vfl_dir ==VFL_DIR_RX ) {
@@ -915,11 +916,16 @@ int vidioc_g_edid(struct file *file, void *_fh,return -EINVAL ;if (dev->input_type[edid->pad] !=HDMI )return -EINVAL ; + adap = dev->cec_rx_adap; }else { +unsigned bus_idx; +if (edid->pad >= dev->num_outputs)return -EINVAL ;if (dev->output_type[edid->pad] !=HDMI )return -EINVAL ; + bus_idx = dev->cec_output2bus_map[edid->pad]; + adap = dev->cec_tx_adap[bus_idx]; }if (edid->start_block ==0 && edid->blocks ==0 ) { edid->blocks = dev->edid_blocks;
@@ -932,5 +938,6 @@ int vidioc_g_edid(struct file *file, void *_fh,if (edid->start_block + edid->blocks > dev->edid_blocks) edid->blocks = dev->edid_blocks - edid->start_block;memcpy (edid->edid, dev->edid, edid->blocks *128 ); +cec_set_edid_phys_addr (edid->edid, edid->blocks *128 , adap->phys_addr);return 0 ; }
Signature · 1 line
2.7.0