All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] HDMI-CEC proposal
@ 2011-03-01  9:59 Martin Bugge (marbugge)
  2011-03-01 12:28 ` Mauro Carvalho Chehab
                   ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: Martin Bugge (marbugge) @ 2011-03-01  9:59 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Author: Martin Bugge <marbugge@cisco.com>
Date:  Tue, 1 March 2010
======================

This is a proposal for adding a Consumer Electronic Control (CEC) API to 
V4L2.
This document describes the changes and new ioctls needed.

Version 1.0 (This is first version)

Background
==========
CEC is a protocol that provides high-level control functions between 
various audiovisual products.
It is an optional supplement to the High-Definition Multimedia Interface 
Specification (HDMI).
Physical layer is a one-wire bidirectional serial bus that uses the 
industry-standard AV.link protocol.

In short: CEC uses pin 13 on the HDMI connector to transmit and receive 
small data-packets
           (maximum 16 bytes including a 1 byte header) at low data 
rates (~400 bits/s).

A CEC device may have any of 15 logical addresses (0 - 14).
(address 15 is broadcast and some addresses are reserved)


References
==========
[1] High-Definition Multimedia Interface Specification version 1.3a,
     Supplement 1 Consumer Electronic Control (CEC).
     http://www.hdmi.org/manufacturer/specification.aspx

[2] 
http://www.hdmi.org/pdf/whitepaper/DesigningCECintoYourNextHDMIProduct.pdf


Proposed solution
=================

Two new ioctls:
     VIDIOC_CEC_CAP (read)
     VIDIOC_CEC_CMD (read/write)

VIDIOC_CEC_CAP:
---------------

struct vl2_cec_cap {
        __u32 logicaldevices;
        __u32 reserved[7];
};

The capability ioctl will return the number of logical devices/addresses 
which can be
simultaneously supported on this HW.
     0:       This HW don't support CEC.
     1 -> 14: This HW supports n logical devices simultaneously.

VIDIOC_CEC_CMD:
---------------

struct v4l2_cec_cmd {
     __u32 cmd;
     __u32 reserved[7];
     union {
         struct {
             __u32 index;
             __u32 enable;
             __u32 addr;
         } conf;
         struct {
             __u32 len;
             __u8  msg[16];
             __u32 status;
         } data;
         __u32 raw[8];
     };
};

Alternatively the data struct could be:
         struct {
             __u8  initiator;
             __u8  destination;
             __u8  len;
             __u8  msg[15];
             __u32 status;
         } data;

Commands:

#define V4L2_CEC_CMD_CONF  (1)
#define V4L2_CEC_CMD_TX    (2)
#define V4L2_CEC_CMD_RX    (3)

Tx status field:

#define V4L2_CEC_STAT_TX_OK            (0)
#define V4L2_CEC_STAT_TX_ARB_LOST      (1)
#define V4L2_CEC_STAT_TX_RETRY_TIMEOUT (2)

The command ioctl is used both for configuration and to receive/transmit 
data.

* The configuration command must be done for each logical device address
   which is to be enabled on this HW. Maximum number of logical devices
   is found with the capability ioctl.
     conf:
          index:  0 -> number_of_logical_devices-1
          enable: true/false
          addr:   logical address

   By default all logical devices are disabled.

* Tx/Rx command
     data:
          len:    length of message (data + header)
          msg:    the raw CEC message received/transmitted
          status: when the driver is in blocking mode it gives the 
result for transmit.

Events
------

In the case of non-blocking mode the driver will issue the following events:

V4L2_EVENT_CEC_TX
V4L2_EVENT_CEC_RX

V4L2_EVENT_CEC_TX
-----------------
  * transmit is complete with the following status:
Add an additional struct to the struct v4l2_event

struct v4l2_event_cec_tx {
        __u32 status;
}

V4L2_EVENT_CEC_RX
-----------------
  * received a complete message


Comments ?

            Martin Bugge

--
Martin Bugge - Tandberg (now a part of Cisco)
--


^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [RFC] HDMI-CEC proposal
@ 2012-04-12 15:24 Florian Fainelli
  2012-04-12 20:36 ` Oliver Schinagl
  0 siblings, 1 reply; 25+ messages in thread
From: Florian Fainelli @ 2012-04-12 15:24 UTC (permalink / raw)
  To: linux-media, marbugge, hverkuil

Hi Hans, Martin,

Sorry to jump in so late in the HDMI-CEC discussion, here are some 
comments from my perspective on your proposal:

- the HDMI-CEC implementation deserves its own bus and class of devices 
because by definition it is a physical bus, which is even electrically 
independant from the rest of the HDMI bus (A/V path)

- I don't think it is a good idea to tight it so closely to v4l, because 
one can perfectly have CEC-capable hardware without video, or at least 
not use v4l and have HDMI-CEC hardware

- it was suggested to use sockets at some point, I think it is 
over-engineered and should only lead

- processing messages in user-space is definitively the way to go, even 
input can be either re-injected using an uinput driver, or be handled in 
user-space entirely, eventually we might want to install "filters" based 
on opcodes to divert some opcodes to a kernel consumer, and the others 
to an user-space one

Right now, I have a very simple implementation that I developed for the 
company I work for which can be found here: 
https://github.com/ffainelli/linux-hdmi-cec

It is designed like this:

1) A core module, which registers a cec bus, and provides an abstraction 
for a CEC adapter (both device & driver):
- basic CEC adapter operations: logical address setting, queueing management
- counters, rx filtering
- host attaching/detaching in case the hardware is capable of 
self-processing CEC messages (for wakeup in particular)

2) A character device module, which exposes a character device per CEC 
adapter and only allows one consumer at a time and exposes the following 
ioctl's:

- SET_LOGICAL_ADDRESS
- RESET_DEVICE
- GET_COUNTERS
- SET_RX_MODE (my adapter can be set in a promiscuous mode)

the character device supports read/write/poll, which are the prefered 
ways for transfering/receiving data

3) A CEC adapter implementation which registers and calls into the core 
module when receiving a CEC message, and which the core module calls in 
response to the IOCTLs described below.

At first I thought about defining a generic netlink family in order to 
allow multiple user-space listeners receive CEC messages, but in the end 
having only one consumer per adapter device is fine by me and a more 
traditionnal approach for programmers.

I am relying on external components for knowing my HDMI physical address.

Hope this is not too late to (re)start the discussion on HDMI-CEC.

Thank you very much.
--
Florian

^ permalink raw reply	[flat|nested] 25+ messages in thread
[parent not found: <CAH-Z1=WtUrS0HYMsOb9CarAcXhR72cO8QWAnUJdP+zDuj92Rxg@mail.gmail.com>]

end of thread, other threads:[~2012-05-10 12:11 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-01  9:59 [RFC] HDMI-CEC proposal Martin Bugge (marbugge)
2011-03-01 12:28 ` Mauro Carvalho Chehab
2011-03-01 14:38   ` Hans Verkuil
2011-03-01 15:20     ` Mauro Carvalho Chehab
2011-03-01 15:49       ` Hans Verkuil
2011-03-01 16:19         ` Mauro Carvalho Chehab
2011-03-01 17:09           ` Hans Verkuil
2011-03-01 13:47 ` Andy Walls
2011-03-01 14:59   ` Martin Bugge (marbugge)
2011-03-01 17:31     ` Hans Verkuil
2011-03-01 17:52 ` Alex Deucher
2011-03-02  9:13   ` Hans Verkuil
2011-03-02 15:49     ` Alex Deucher
2011-03-01 23:38 ` Daniel Glöckner
2011-03-02  9:34   ` Martin Bugge (marbugge)
2011-03-03 10:37 ` Laurent Pinchart
2011-03-03 12:11   ` Martin Bugge (marbugge)
2012-04-12 15:24 Florian Fainelli
2012-04-12 20:36 ` Oliver Schinagl
2012-04-13  5:03   ` Hans Verkuil
2012-04-13  9:27     ` Florian Fainelli
2012-04-17 13:31   ` Anssi Hannula
2012-04-17 13:44     ` Oliver Schinagl
     [not found] <CAH-Z1=WtUrS0HYMsOb9CarAcXhR72cO8QWAnUJdP+zDuj92Rxg@mail.gmail.com>
2012-05-10 11:43 ` Florian Fainelli
2012-05-10 12:11   ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.