Re: Call for help: em28xx: new board id [1f4d:1abe]

2015-09-07 Thread Mauro Carvalho Chehab
Em Sun, 06 Sep 2015 18:58:50 -0500
Ronald Tallent  escreveu:

> Hey Mauro,
> 
> Thanks for the reply. Relieved to know I'm not invisible. =)
> 
> I'm a total noob to linux driver issues, so if I'm  posting this in the
> wrong area, please forgive me. I only posted here because this is where
> linuxtv.org said to go to ask for help. Until now all my hardware has
> just worked. So big thanks to all the people who made that happen! But
> this EasyCap board is kind of kicking my butt.
> 
> You are correct, when I plug this USB device in video capture device is
> not detected and so does not work. As I understand it, all the drivers
> needed to make this Easycap work in linux already exist and are used by
> various forms of Easycap devices already.
> 
> The em2860 USB video bridge chip should be supported by the "em28xx"
> kernel modules, and the Trident SAA7115H chip should be supported by the
> "saa7115" module. My best guess is that the card vendor:product id
> [1f4d:1abe] is simply not "attached" to those drivers or known by those
> drivers so when I plug this USB device in, video drivers are not loaded.
> But my assessment of the situation might be completely off here.
> 
> Couple questions...
> 
> First, if nobody know what to do with the information I've posted, why
> does linuxtv.org/wiki instruct me to post this information here, exactly
> this way? Not a big issue really, just quite confusing.

Feel free to improve the documentation ;)
Just remember that the documentation there should be generic enough for
people having different boards, specially if you're looking into a
generic section of the Wiki.

> Secondly, if all the drivers already exist, what do I need to do to get
> them to "attach" to my hardware? 

Because of two things:

- the USB ID is used to identify the driver that will be used. If
  the driver doesn't know the USB ID, it won't be loaded.

- each hardware is wired on a different way. The saa7113 have 4 different
  video inputs (if I remember correctly). Also, there are several pins used
  on most video hardware called GPIO. They're used to power on and reset the
  other devices. The power on/reset sequence is board-specific.

> Is there some place I can go to learn
> how to do that fairly quickly? Is anyone in this board knowledgeable
> about how that can easily be done? I am competent enough with linux that
> I can perform the steps necessary if I know what those steps are. This
> is new territory for me though.

Wiki is your friend. Also look at other posts on the ML from other
people that had to do the same.

> 
> Any help anyone can offer would be greatly appreciated! =)
> 
> Thanks,
> --Ronald
> 
> 
> 
> On Sun, 2015-09-06 at 16:53 -0300, Mauro Carvalho Chehab wrote:
> > Hi Ronald,
> > 
> > Well, probably nobody knows what to do with that ;)
> > 
> > If I understood well your post, video didn't work, right?
> > 
> > So, either you or someone else with the same hardware as you have would
> > need to make it work and send a patch to the mailing list adding support
> > for this new ID.
> > 
> > Probably, it is just either a GPIO or the video input that it is wrong.
> > In order to fix it, you would either need some help from the manufacturer
> > or to sniff the USB message exchanges from the original driver and check
> > the settings for saa7113 and em28xx. The wiki has some info about how
> > to do it.
> > 
> > Regards,
> > Mauro
> > 
> > 
> > Em Sun, 06 Sep 2015 14:16:48 -0500
> > Ronald Tallent  escreveu:
> > 
> > > Hi, 
> > > 
> > > This is my third attempt to post this information to mailing list in a
> > > little over a week. Am I invisible? Can nobody see my messages? I have
> > > precisely followed the instructions posted on
> > > linuxtv.org/wiki/index.php/Em28xx_devices#How_to_validate_my_vendor.2Fproduct_id_at_upstream_kernel.3F
> > > trying to get my hardware validated. What else do I need to do?  Can
> > > someone answer please and help me. 
> > > 
> > > Thanks,
> > > --Ronald
> > > 
> > > 
> > > I've tested my USB easycap device (Geniatech iGrabber) in Ubuntu
> > > 14.04.
> > > 
> > > Make: Geniatech
> > > Model: iGrabber for MAC
> > > Vendor/Product ID: [1f4d:1abe]
> > > Product website: www.geniatech.com/pa/igrabber.asp
> > > 
> > > Tests Made:
> > > - Audio Capture [worked]
> > > - Video Capture [device not detected]
> > > - DVB [does not have DVB]
> > > 
> > > Tested by:
> > > r...@tallent.ws
> > > 
> > > 
> > > Detailed information on device and system below for reference:
> > > 
> > > uname -a:
> > > 3.13.0-62-generic #102-Ubuntu SMP Tue Aug 11 14:29:36 UTC 2015 x86_64 
> > > x86_64 x86_64 GNU/Linux
> > > 
> > > dmesg:
> > > [] usb 3-3.3: new high-speed USB device number 8 using xhci_hcd
> > > [] usb 3-3.3: New USB device found, idVendor=1f4d, idProduct=1abe
> > > [] usb 3-3.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0
> > > [] usb 3-3.3: Product: USB Device
> > > [] usbcore: registered new interface driver 

[PATCH v1] media: uvcvideo: handle urb completion in a work queue

2015-09-07 Thread Mian Yousaf Kaukab
urb completion callback is executed in host controllers interrupt
context. To keep preempt disable time short, add urbs to a list on
completion and schedule work to process the list.

Moreover, save timestamp and sof number in the urb completion callback
to avoid any delays.

Signed-off-by: Mian Yousaf Kaukab 
---
History:
v1:
 - Use global work queue instead of creating ordered queue.
 - Add completed urbs to a list and process all on the list when work
   is scheduled
 - Save timestamp and sof number in urb completion callback and use
   in uvc_video_clock_decode() and uvc_video_decode_start()
 - Fix race between usb_submit_urb() from uvc_video_complete() and
   usb_kill_urb() from uvc_uninit_video()

 drivers/media/usb/uvc/uvc_isight.c |   3 +-
 drivers/media/usb/uvc/uvc_video.c  | 132 +++--
 drivers/media/usb/uvc/uvcvideo.h   |  17 -
 3 files changed, 113 insertions(+), 39 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_isight.c 
b/drivers/media/usb/uvc/uvc_isight.c
index 8510e725..7f93d09 100644
--- a/drivers/media/usb/uvc/uvc_isight.c
+++ b/drivers/media/usb/uvc/uvc_isight.c
@@ -99,9 +99,10 @@ static int isight_decode(struct uvc_video_queue *queue, 
struct uvc_buffer *buf,
return 0;
 }
 
-void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
+void uvc_video_decode_isight(struct uvc_urb *uu, struct uvc_streaming *stream,
struct uvc_buffer *buf)
 {
+   struct urb *urb = uu->urb;
int ret, i;
 
for (i = 0; i < urb->number_of_packets; ++i) {
diff --git a/drivers/media/usb/uvc/uvc_video.c 
b/drivers/media/usb/uvc/uvc_video.c
index f839654..71354ec 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -379,15 +379,14 @@ static inline void uvc_video_get_ts(struct timespec *ts)
 
 static void
 uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
-  const __u8 *data, int len)
+  const __u8 *data, int len, u16 host_sof,
+  struct timespec *ts)
 {
struct uvc_clock_sample *sample;
unsigned int header_size;
bool has_pts = false;
bool has_scr = false;
unsigned long flags;
-   struct timespec ts;
-   u16 host_sof;
u16 dev_sof;
 
switch (data[1] & (UVC_STREAM_PTS | UVC_STREAM_SCR)) {
@@ -435,9 +434,6 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct 
uvc_buffer *buf,
 
stream->clock.last_sof = dev_sof;
 
-   host_sof = usb_get_current_frame_number(stream->dev->udev);
-   uvc_video_get_ts();
-
/* The UVC specification allows device implementations that can't obtain
 * the USB frame number to keep their own frame counters as long as they
 * match the size and frequency of the frame number associated with USB
@@ -473,7 +469,7 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct 
uvc_buffer *buf,
sample->dev_stc = get_unaligned_le32([header_size - 6]);
sample->dev_sof = dev_sof;
sample->host_sof = host_sof;
-   sample->host_ts = ts;
+   sample->host_ts = *ts;
 
/* Update the sliding window head and count. */
stream->clock.head = (stream->clock.head + 1) % stream->clock.size;
@@ -964,7 +960,8 @@ static void uvc_video_stats_stop(struct uvc_streaming 
*stream)
  * uvc_video_decode_end will never be called with a NULL buffer.
  */
 static int uvc_video_decode_start(struct uvc_streaming *stream,
-   struct uvc_buffer *buf, const __u8 *data, int len)
+   struct uvc_buffer *buf, const __u8 *data, int len,
+   u16 host_sof, struct timespec *ts)
 {
__u8 fid;
 
@@ -989,7 +986,7 @@ static int uvc_video_decode_start(struct uvc_streaming 
*stream,
uvc_video_stats_update(stream);
}
 
-   uvc_video_clock_decode(stream, buf, data, len);
+   uvc_video_clock_decode(stream, buf, data, len, host_sof, ts);
uvc_video_stats_decode(stream, data, len);
 
/* Store the payload FID bit and return immediately when the buffer is
@@ -1016,8 +1013,6 @@ static int uvc_video_decode_start(struct uvc_streaming 
*stream,
 * when the EOF bit is set to force synchronisation on the next packet.
 */
if (buf->state != UVC_BUF_STATE_ACTIVE) {
-   struct timespec ts;
-
if (fid == stream->last_fid) {
uvc_trace(UVC_TRACE_FRAME, "Dropping payload (out of "
"sync).\n");
@@ -1027,13 +1022,11 @@ static int uvc_video_decode_start(struct uvc_streaming 
*stream,
return -ENODATA;
}
 
-   uvc_video_get_ts();
-
buf->buf.v4l2_buf.field = V4L2_FIELD_NONE;
buf->buf.v4l2_buf.sequence = stream->sequence;
-   buf->buf.v4l2_buf.timestamp.tv_sec = ts.tv_sec;
+   

[PATCHv9 07/15] cec: add HDMI CEC framework

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

The added HDMI CEC framework provides a generic kernel interface for
HDMI CEC devices.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: Merged CEC Updates commit by Hans Verkuil]
[k.deb...@samsung.com: Merged Update author commit by Hans Verkuil]
[k.deb...@samsung.com: change kthread handling when setting logical
address]
[k.deb...@samsung.com: code cleanup and fixes]
[k.deb...@samsung.com: add missing CEC commands to match spec]
[k.deb...@samsung.com: add RC framework support]
[k.deb...@samsung.com: move and edit documentation]
[k.deb...@samsung.com: add vendor id reporting]
[k.deb...@samsung.com: add possibility to clear assigned logical
addresses]
[k.deb...@samsung.com: documentation fixes, clenaup and expansion]
[k.deb...@samsung.com: reorder of API structs and add reserved fields]
[k.deb...@samsung.com: fix handling of events and fix 32/64bit timespec
problem]
[k.deb...@samsung.com: add cec.h to include/uapi/linux/Kbuild]
[k.deb...@samsung.com: add sequence number handling]
[k.deb...@samsung.com: add passthrough mode]
[k.deb...@samsung.com: fix CEC defines, add missing CEC 2.0 commands]
minor additions]
Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 MAINTAINERS|   12 +
 drivers/media/Kconfig  |6 +
 drivers/media/Makefile |2 +
 drivers/media/cec.c| 1921 
 include/media/cec.h|  175 
 include/uapi/linux/Kbuild  |2 +
 include/uapi/linux/cec-funcs.h | 1771 
 include/uapi/linux/cec.h   |  781 
 8 files changed, 4670 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

diff --git a/MAINTAINERS b/MAINTAINERS
index e0946a0..2904a66 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2553,6 +2553,18 @@ 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 
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+W: http://linuxtv.org
+S: Supported
+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 
 L: linuxppc-...@lists.ozlabs.org
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 3ef3d6c..48e44f5 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -15,6 +15,12 @@ if MEDIA_SUPPORT
 
 comment "Multimedia core support"
 
+config CEC
+   tristate "CEC API (EXPERIMENTAL)"
+   select RC_CORE
+   ---help---
+ Enable the CEC API.
+
 #
 # Multimedia support - automatically enable V4L2 and DVB core
 #
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index e608bbc..db66014 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -2,6 +2,8 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
+obj-$(CONFIG_CEC) += cec.o
+
 media-objs := media-device.o media-devnode.o media-entity.o
 
 #
diff --git a/drivers/media/cec.c b/drivers/media/cec.c
new file mode 100644
index 000..7084d2c
--- /dev/null
+++ b/drivers/media/cec.c
@@ -0,0 +1,1921 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CEC_NUM_DEVICES256
+#define CEC_NAME   "cec"
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "debug level (0-2)");
+
+#define dprintk(lvl, fmt, arg...)  \
+   do {\
+   if (lvl <= debug)   \
+   pr_info("cec-%s: " fmt, adap->name, ## arg);\
+   } while (0)
+
+static dev_t cec_dev_t;
+
+/* Active devices */
+static DEFINE_MUTEX(cec_devnode_lock);
+static DECLARE_BITMAP(cec_devnode_nums, CEC_NUM_DEVICES);
+
+/* dev to cec_devnode */
+#define to_cec_devnode(cd) container_of(cd, struct cec_devnode, dev)
+
+static inline struct cec_devnode *cec_devnode_data(struct file *filp)
+{
+   struct cec_fh *fh = filp->private_data;
+
+   return >adap->devnode;
+}
+
+static bool cec_pa_are_adjacent(const struct cec_adapter *adap, u16 pa1, u16 
pa2)
+{
+   u16 mask = 0xf000;
+   int i;
+
+   if (pa1 == CEC_PHYS_ADDR_INVALID || pa2 == CEC_PHYS_ADDR_INVALID)
+   return false;
+   for (i = 0; i < 3; i++) {
+   if ((pa1 & mask) != (pa2 & mask))
+   break;
+   mask = (mask >> 4) | 0xf000;
+ 

[PATCHv9 13/15] cec: adv7511: add cec support.

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7511 driver.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: Merged changes from CEC Updates commit by Hans Verkuil]
Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/adv7511.c | 359 +++-
 include/media/adv7511.h |   6 +-
 2 files changed, 353 insertions(+), 12 deletions(-)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index e4900df..645d4ba 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int debug;
 module_param(debug, int, 0644);
@@ -59,6 +60,8 @@ MODULE_LICENSE("GPL v2");
 #define ADV7511_MIN_PIXELCLOCK 2000
 #define ADV7511_MAX_PIXELCLOCK 22500
 
+#define ADV7511_MAX_ADDRS (3)
+
 /*
 **
 *
@@ -90,12 +93,19 @@ struct adv7511_state {
struct v4l2_ctrl_handler hdl;
int chip_revision;
u8 i2c_edid_addr;
-   u8 i2c_cec_addr;
u8 i2c_pktmem_addr;
+   u8 i2c_cec_addr;
+
+   struct i2c_client *i2c_cec;
+   u8   cec_addr[ADV7511_MAX_ADDRS];
+   u8   cec_valid_addrs;
+   bool cec_enabled_adap;
+
/* Is the adv7511 powered on? */
bool power_on;
/* Did we receive hotplug and rx-sense signals? */
bool have_monitor;
+   bool enabled_irq;
/* timings from s_dv_timings */
struct v4l2_dv_timings dv_timings;
u32 fmt_code;
@@ -225,7 +235,7 @@ static int adv_smbus_read_i2c_block_data(struct i2c_client 
*client,
return ret;
 }
 
-static inline void adv7511_edid_rd(struct v4l2_subdev *sd, u16 len, u8 *buf)
+static void adv7511_edid_rd(struct v4l2_subdev *sd, uint16_t len, uint8_t *buf)
 {
struct adv7511_state *state = get_adv7511_state(sd);
int i;
@@ -240,6 +250,34 @@ static inline void adv7511_edid_rd(struct v4l2_subdev *sd, 
u16 len, u8 *buf)
v4l2_err(sd, "%s: i2c read error\n", __func__);
 }
 
+static inline int adv7511_cec_read(struct v4l2_subdev *sd, u8 reg)
+{
+   struct adv7511_state *state = get_adv7511_state(sd);
+
+   return i2c_smbus_read_byte_data(state->i2c_cec, reg);
+}
+
+static int adv7511_cec_write(struct v4l2_subdev *sd, u8 reg, u8 val)
+{
+   struct adv7511_state *state = get_adv7511_state(sd);
+   int ret;
+   int i;
+
+   for (i = 0; i < 3; i++) {
+   ret = i2c_smbus_write_byte_data(state->i2c_cec, reg, val);
+   if (ret == 0)
+   return 0;
+   }
+   v4l2_err(sd, "%s: I2C Write Problem\n", __func__);
+   return ret;
+}
+
+static inline int adv7511_cec_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 
mask,
+  u8 val)
+{
+   return adv7511_cec_write(sd, reg, (adv7511_cec_read(sd, reg) & mask) | 
val);
+}
+
 static int adv7511_pktmem_rd(struct v4l2_subdev *sd, u8 reg)
 {
struct adv7511_state *state = get_adv7511_state(sd);
@@ -413,16 +451,28 @@ static const struct v4l2_ctrl_ops adv7511_ctrl_ops = {
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 static void adv7511_inv_register(struct v4l2_subdev *sd)
 {
+   struct adv7511_state *state = get_adv7511_state(sd);
+
v4l2_info(sd, "0x000-0x0ff: Main Map\n");
+   if (state->i2c_cec)
+   v4l2_info(sd, "0x100-0x1ff: CEC Map\n");
 }
 
 static int adv7511_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register 
*reg)
 {
+   struct adv7511_state *state = get_adv7511_state(sd);
+
reg->size = 1;
switch (reg->reg >> 8) {
case 0:
reg->val = adv7511_rd(sd, reg->reg & 0xff);
break;
+   case 1:
+   if (state->i2c_cec) {
+   reg->val = adv7511_cec_read(sd, reg->reg & 0xff);
+   break;
+   }
+   /* fall through */
default:
v4l2_info(sd, "Register %03llx not supported\n", reg->reg);
adv7511_inv_register(sd);
@@ -433,10 +483,18 @@ static int adv7511_g_register(struct v4l2_subdev *sd, 
struct v4l2_dbg_register *
 
 static int adv7511_s_register(struct v4l2_subdev *sd, const struct 
v4l2_dbg_register *reg)
 {
+   struct adv7511_state *state = get_adv7511_state(sd);
+
switch (reg->reg >> 8) {
case 0:
adv7511_wr(sd, reg->reg & 0xff, reg->val & 0xff);
break;
+   case 1:
+   if (state->i2c_cec) {
+   adv7511_cec_write(sd, reg->reg & 0xff, reg->val & 0xff);
+   break;
+   }
+   /* fall through */
default:
v4l2_info(sd, "Register %03llx not supported\n", reg->reg);
adv7511_inv_register(sd);
@@ -524,6 +582,7 @@ static int adv7511_log_status(struct 

Re: [PATCH 4/5] [media] uvcvideo: create pad links after subdev registration

2015-09-07 Thread Javier Martinez Canillas
Hello,

On 09/03/2015 06:00 PM, Javier Martinez Canillas wrote:
> The uvc driver creates the pads links before the media entity is
> registered with the media device. This doesn't work now that obj
> IDs are used to create links so the media_device has to be set.
> 
> Move entities registration logic before pads links creation.
> 
> Signed-off-by: Javier Martinez Canillas 
> ---
> 
>  drivers/media/usb/uvc/uvc_entity.c | 16 
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_entity.c 
> b/drivers/media/usb/uvc/uvc_entity.c
> index 429e428ccd93..9dde1f86cc4b 100644
> --- a/drivers/media/usb/uvc/uvc_entity.c
> +++ b/drivers/media/usb/uvc/uvc_entity.c
> @@ -37,6 +37,10 @@ static int uvc_mc_register_entity(struct uvc_video_chain 
> *chain,
>   if (sink == NULL)
>   return 0;
>  
> + ret = v4l2_device_register_subdev(>dev->vdev, >subdev);

Testing this patch on an Exynos Chromebook that has a built-in USB camera, I
noticed that v4l2_device_register_subdev() was wrongly called for UVC entities
with UVC_ENTITY_TYPE() == UVC_TT_STREAMING.

So I have the following [0] v2 patch. This patch was tested on an Exynos5800
Peach Pi Chromebook using qv4l2 to test video capture and the output of the
media-ctl -p command was compared with and without the MC next gen patches
to verify that was identical in both cases.

The media-ctl -p output is: http://hastebin.com/enalitofoz.coffee

And the mc_next_gen -e -i -I -l output is http://hastebin.com/umevuragaq.pas

Normally I would just resend the complete series but since there are so many
in-flight patches, I preferred to only re-send this patch one in this thread.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America


[0]:
>From 8be356e77eeefdc5c0738dd429205f3398c5b76c Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas 
Date: Thu, 3 Sep 2015 13:46:06 +0200
Subject: [PATCH v2 4/5] [media] uvcvideo: create pad links after subdev
 registration

The uvc driver creates the pads links before the media entity is
registered with the media device. This doesn't work now that obj
IDs are used to create links so the media_device has to be set.

Move entities registration logic before pads links creation.

Signed-off-by: Javier Martinez Canillas 
---

Changes since v1:
 - Don't try to register a UVC entity subdev for type UVC_TT_STREAMING.

 drivers/media/usb/uvc/uvc_entity.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_entity.c 
b/drivers/media/usb/uvc/uvc_entity.c
index 429e428ccd93..7f82b65b238e 100644
--- a/drivers/media/usb/uvc/uvc_entity.c
+++ b/drivers/media/usb/uvc/uvc_entity.c
@@ -26,6 +26,15 @@
 static int uvc_mc_register_entity(struct uvc_video_chain *chain,
struct uvc_entity *entity)
 {
+   if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING)
+   return 0;
+
+   return v4l2_device_register_subdev(>dev->vdev, >subdev);
+}
+
+static int uvc_mc_create_pads_links(struct uvc_video_chain *chain,
+   struct uvc_entity *entity)
+{
const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE;
struct media_entity *sink;
unsigned int i;
@@ -62,10 +71,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain 
*chain,
return ret;
}
 
-   if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING)
-   return 0;
-
-   return v4l2_device_register_subdev(>dev->vdev, >subdev);
+   return 0;
 }
 
 static struct v4l2_subdev_ops uvc_subdev_ops = {
@@ -124,5 +130,14 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)
}
}
 
+   list_for_each_entry(entity, >entities, chain) {
+   ret = uvc_mc_create_pads_links(chain, entity);
+   if (ret < 0) {
+   uvc_printk(KERN_INFO, "Failed to create pads links for "
+  "entity %u\n", entity->id);
+   return ret;
+   }
+   }
+
return 0;
 }
-- 
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv9 06/15] rc: Add HDMI CEC protocol handling

2015-09-07 Thread Hans Verkuil
From: Kamil Debski 

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.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 drivers/media/rc/keymaps/Makefile |   1 +
 drivers/media/rc/keymaps/rc-cec.c | 174 ++
 drivers/media/rc/rc-main.c|   1 +
 include/media/rc-core.h   |   1 +
 include/media/rc-map.h|   5 +-
 5 files changed, 181 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/rc/keymaps/rc-cec.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index fbbd3bb..9cffcc6 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -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 \
diff --git a/drivers/media/rc/keymaps/rc-cec.c 
b/drivers/media/rc/keymaps/rc-cec.c
new file mode 100644
index 000..193cdca
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-cec.c
@@ -0,0 +1,174 @@
+/* Keytable for the CEC remote control
+ *
+ * Copyright (c) 2015 by Kamil Debski
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+
+/* CEC Spec "High-Definition Multimedia Interface Specification" can be 
obtained
+ * here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf
+ * The list of control codes is listed in Table 27: User Control Codes p. 95 */
+
+static struct rc_map_table cec[] = {
+   { 0x00, KEY_OK },
+   { 0x01, KEY_UP },
+   { 0x02, KEY_DOWN },
+   { 0x03, KEY_LEFT },
+   { 0x04, KEY_RIGHT },
+   { 0x05, KEY_RIGHT_UP },
+   { 0x06, KEY_RIGHT_DOWN },
+   { 0x07, KEY_LEFT_UP },
+   { 0x08, KEY_LEFT_DOWN },
+   { 0x09, KEY_ROOT_MENU }, /* CEC Spec: Device Root Menu - see Note 2 */
+   /* Note 2: This is the initial display that a device shows. It is
+* device-dependent and can be, for example, a contents menu, setup
+* menu, favorite menu or other menu. The actual menu displayed
+* may also depend on the device's current state. */
+   { 0x0a, KEY_SETUP },
+   { 0x0b, KEY_MENU }, /* CEC Spec: Contents Menu */
+   { 0x0c, KEY_FAVORITES }, /* CEC Spec: Favorite Menu */
+   { 0x0d, KEY_EXIT },
+   /* 0x0e-0x0f: Reserved */
+   { 0x10, KEY_MEDIA_TOP_MENU },
+   { 0x11, KEY_CONTEXT_MENU },
+   /* 0x12-0x1c: Reserved */
+   { 0x1d, KEY_DIGITS }, /* CEC Spec: select/toggle a Number Entry Mode */
+   { 0x1e, KEY_NUMERIC_11 },
+   { 0x1f, KEY_NUMERIC_12 },
+   /* 0x20-0x29: Keys 0 to 9 */
+   { 0x20, KEY_NUMERIC_0 },
+   { 0x21, KEY_NUMERIC_1 },
+   { 0x22, KEY_NUMERIC_2 },
+   { 0x23, KEY_NUMERIC_3 },
+   { 0x24, KEY_NUMERIC_4 },
+   { 0x25, KEY_NUMERIC_5 },
+   { 0x26, KEY_NUMERIC_6 },
+   { 0x27, KEY_NUMERIC_7 },
+   { 0x28, KEY_NUMERIC_8 },
+   { 0x29, KEY_NUMERIC_9 },
+   { 0x2a, KEY_DOT },
+   { 0x2b, KEY_ENTER },
+   { 0x2c, KEY_CLEAR },
+   /* 0x2d-0x2e: Reserved */
+   { 0x2f, KEY_NEXT_FAVORITE }, /* CEC Spec: Next Favorite */
+   { 0x30, KEY_CHANNELUP },
+   { 0x31, KEY_CHANNELDOWN },
+   { 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */
+   { 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */
+   { 0x34, KEY_VIDEO }, /* 0x34: CEC Spec: Input Select */
+   { 0x35, KEY_INFO }, /* CEC Spec: Display Information */
+   { 0x36, KEY_HELP },
+   { 0x37, KEY_PAGEUP },
+   { 0x38, KEY_PAGEDOWN },
+   /* 0x39-0x3f: Reserved */
+   { 0x40, KEY_POWER },
+   { 0x41, KEY_VOLUMEUP },
+   { 0x42, KEY_VOLUMEDOWN },
+   { 0x43, KEY_MUTE },
+   { 0x44, KEY_PLAYCD },
+   { 0x45, KEY_STOPCD },
+   { 0x46, KEY_PAUSECD },
+   { 0x47, KEY_RECORD },
+   { 0x48, KEY_REWIND },
+   { 0x49, KEY_FASTFORWARD },
+   { 0x4a, KEY_EJECTCD }, /* CEC Spec: Eject */
+   { 0x4b, KEY_FORWARD },
+   { 0x4c, KEY_BACK },
+   { 0x4d, KEY_STOP_RECORD }, /* CEC Spec: Stop-Record */
+   { 0x4e, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record */
+   /* 0x4f: Reserved */
+   { 0x50, KEY_ANGLE },
+   { 0x51, KEY_TV2 },
+   { 0x52, KEY_VOD }, /* CEC Spec: Video on Demand */
+   { 0x53, KEY_EPG },
+   { 0x54, KEY_TIME }, /* CEC Spec: Timer */
+   { 

[PATCHv9 12/15] cec: adv7842: add cec support

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7842 driver.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/adv7842.c | 267 +---
 1 file changed, 250 insertions(+), 17 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index b7269b8..b9f3e46 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -79,6 +80,8 @@ MODULE_LICENSE("GPL");
 
 #define ADV7842_OP_SWAP_CB_CR  (1 << 0)
 
+#define ADV7842_MAX_ADDRS (3)
+
 /*
 **
 *
@@ -142,6 +145,11 @@ struct adv7842_state {
struct v4l2_ctrl *free_run_color_ctrl_manual;
struct v4l2_ctrl *free_run_color_ctrl;
struct v4l2_ctrl *rgb_quantization_range_ctrl;
+
+   bool cec_ready;
+   u8   cec_addr[ADV7842_MAX_ADDRS];
+   u8   cec_valid_addrs;
+   bool cec_enabled_adap;
 };
 
 /* Unsupported timings. This device cannot support 720p30. */
@@ -418,9 +426,9 @@ static inline int cec_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return adv_smbus_write_byte_data(state->i2c_cec, reg, val);
 }
 
-static inline int cec_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int cec_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, 
u8 val)
 {
-   return cec_write(sd, reg, (cec_read(sd, reg) & mask) | val);
+   return cec_write(sd, reg, (cec_read(sd, reg) & ~mask) | val);
 }
 
 static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg)
@@ -696,6 +704,18 @@ adv7842_get_dv_timings_cap(struct v4l2_subdev *sd)
 
 /* --- */
 
+static u16 adv7842_read_cable_det(struct v4l2_subdev *sd)
+{
+   u8 reg = io_read(sd, 0x6f);
+   u16 val = 0;
+
+   if (reg & 0x02)
+   val |= 1; /* port A */
+   if (reg & 0x01)
+   val |= 2; /* port B */
+   return val;
+}
+
 static void adv7842_delayed_work_enable_hotplug(struct work_struct *work)
 {
struct delayed_work *dwork = to_delayed_work(work);
@@ -703,8 +723,15 @@ static void adv7842_delayed_work_enable_hotplug(struct 
work_struct *work)
struct adv7842_state, delayed_work_enable_hotplug);
struct v4l2_subdev *sd = >sd;
int present = state->hdmi_edid.present;
+   u16 connected_inputs;
u8 mask = 0;
 
+   if (state->cec_ready) {
+   connected_inputs = present & adv7842_read_cable_det(sd);
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_CONN_INPUTS,
+  _inputs);
+   }
+
v4l2_dbg(2, debug, sd, "%s: enable hotplug on ports: 0x%x\n",
__func__, present);
 
@@ -983,20 +1010,17 @@ static int adv7842_s_register(struct v4l2_subdev *sd,
 static int adv7842_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd)
 {
struct adv7842_state *state = to_state(sd);
-   int prev = v4l2_ctrl_g_ctrl(state->detect_tx_5v_ctrl);
-   u8 reg_io_6f = io_read(sd, 0x6f);
-   int val = 0;
+   u16 cable_det = adv7842_read_cable_det(sd);
+   u16 connected_inputs;
 
-   if (reg_io_6f & 0x02)
-   val |= 1; /* port A */
-   if (reg_io_6f & 0x01)
-   val |= 2; /* port B */
+   v4l2_dbg(1, debug, sd, "%s: 0x%x\n", __func__, cable_det);
 
-   v4l2_dbg(1, debug, sd, "%s: 0x%x -> 0x%x\n", __func__, prev, val);
+   connected_inputs = state->hdmi_edid.present & cable_det;
+   if (state->cec_ready)
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_CONN_INPUTS,
+  _inputs);
 
-   if (val != prev)
-   return v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl, val);
-   return 0;
+   return v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl, cable_det);
 }
 
 static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd,
@@ -2157,6 +2181,194 @@ static void adv7842_irq_enable(struct v4l2_subdev *sd, 
bool enable)
}
 }
 
+static void adv7842_cec_tx_raw_status(struct v4l2_subdev *sd, u8 tx_raw_status)
+{
+   if ((cec_read(sd, 0x11) & 0x01) == 0) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: tx disabled\n", __func__);
+   return;
+   }
+
+   if (tx_raw_status & 0x02) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: arbitration lost\n",
+__func__);
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE,
+  (void *)CEC_TX_STATUS_ARB_LOST);
+   return;
+   }
+   if (tx_raw_status & 0x04) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: retry failed\n", __func__);
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE,
+  (void 

[PATCHv9 11/15] cec: adv7604: add cec support.

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7604 driver.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: Merged changes from CEC Updates commit by Hans Verkuil]
[k.deb...@samsung.com: add missing methods cec/io_write_and_or]
[k.deb...@samsung.com: change adv7604 to adv76xx in added functions]
[hansv...@cisco.com: use _clr_set instead of _and_or]
---
 drivers/media/i2c/adv7604.c | 254 +++-
 1 file changed, 250 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 5631ec0..c8142c2 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -40,6 +40,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -80,6 +81,8 @@ MODULE_LICENSE("GPL");
 
 #define ADV76XX_OP_SWAP_CB_CR  (1 << 0)
 
+#define ADV76XX_MAX_ADDRS (3)
+
 enum adv76xx_type {
ADV7604,
ADV7611,
@@ -184,6 +187,11 @@ struct adv76xx_state {
u16 spa_port_a[2];
struct v4l2_fract aspect_ratio;
u32 rgb_quantization_range;
+   bool cec_ready;
+   u8   cec_addr[ADV76XX_MAX_ADDRS];
+   u8   cec_valid_addrs;
+   bool cec_enabled_adap;
+
struct workqueue_struct *work_queues;
struct delayed_work delayed_work_enable_hotplug;
bool restart_stdi_once;
@@ -430,7 +438,8 @@ static inline int io_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return regmap_write(state->regmap[ADV76XX_PAGE_IO], reg, val);
 }
 
-static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask,
+  u8 val)
 {
return io_write(sd, reg, (io_read(sd, reg) & ~mask) | val);
 }
@@ -463,6 +472,12 @@ static inline int cec_write(struct v4l2_subdev *sd, u8 
reg, u8 val)
return regmap_write(state->regmap[ADV76XX_PAGE_CEC], reg, val);
 }
 
+static inline int cec_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask,
+  u8 val)
+{
+   return cec_write(sd, reg, (cec_read(sd, reg) & ~mask) | val);
+}
+
 static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg)
 {
struct adv76xx_state *state = to_state(sd);
@@ -550,8 +565,15 @@ static inline int edid_write_block(struct v4l2_subdev *sd,
 
 static void adv76xx_set_hpd(struct adv76xx_state *state, unsigned int hpd)
 {
+   u16 connected_inputs;
unsigned int i;
 
+   if (state->cec_ready) {
+   connected_inputs = hpd & 
state->info->read_cable_det(>sd);
+   v4l2_subdev_notify(>sd, V4L2_SUBDEV_CEC_CONN_INPUTS,
+  _inputs);
+   }
+
for (i = 0; i < state->info->num_dv_ports; ++i)
gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i));
 
@@ -891,9 +913,14 @@ static int adv76xx_s_detect_tx_5v_ctrl(struct v4l2_subdev 
*sd)
 {
struct adv76xx_state *state = to_state(sd);
const struct adv76xx_chip_info *info = state->info;
+   u16 cable_det = info->read_cable_det(sd);
+   u16 connected_inputs = state->edid.present & cable_det;
+
+   if (state->cec_ready)
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_CONN_INPUTS,
+  _inputs);
 
-   return v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl,
-   info->read_cable_det(sd));
+   return v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl, cable_det);
 }
 
 static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd,
@@ -1914,6 +1941,198 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
return 0;
 }
 
+static void adv76xx_cec_tx_raw_status(struct v4l2_subdev *sd, u8 tx_raw_status)
+{
+   if ((cec_read(sd, 0x11) & 0x01) == 0) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: tx disabled\n", __func__);
+   return;
+   }
+
+   if (tx_raw_status & 0x02) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: arbitration lost\n",
+__func__);
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE,
+  (void *)CEC_TX_STATUS_ARB_LOST);
+   return;
+   }
+   if (tx_raw_status & 0x04) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: retry failed\n", __func__);
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE,
+  (void *)CEC_TX_STATUS_RETRY_TIMEOUT);
+   return;
+   }
+   if (tx_raw_status & 0x01) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: ready ok\n", __func__);
+   v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE,
+  (void *)CEC_TX_STATUS_OK);
+   return;
+   }
+}
+
+static void adv76xx_cec_isr(struct v4l2_subdev *sd, bool *handled)
+{
+   u8 cec_irq;
+
+   /* cec controller */
+   

[PATCHv9 09/15] DocBook/media: add CEC documentation

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

Add DocBook documentation for the CEC API.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: add documentation for passthrough mode]
[k.deb...@samsung.com: minor fixes and change of reserved field sizes]
Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 Documentation/DocBook/media/Makefile   |   2 +
 Documentation/DocBook/media/v4l/biblio.xml |  10 +
 Documentation/DocBook/media/v4l/cec-api.xml|  76 +
 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  | 161 +++
 .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml | 306 +
 .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |  78 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-state.xml |  87 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-vendor-id.xml |  70 +
 Documentation/DocBook/media/v4l/cec-ioc-claim.xml  |  71 +
 .../DocBook/media/v4l/cec-ioc-dqevent.xml  | 208 ++
 .../DocBook/media/v4l/cec-ioc-g-monitor.xml|  86 ++
 .../DocBook/media/v4l/cec-ioc-g-passthrough.xml|  81 ++
 .../DocBook/media/v4l/cec-ioc-receive.xml  | 185 +
 Documentation/DocBook/media_api.tmpl   |   8 +-
 18 files changed, 1742 insertions(+), 2 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-claim.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-monitor.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-passthrough.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-receive.xml

diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 08527e7..b97fb71 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -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)
 
diff --git a/Documentation/DocBook/media/v4l/biblio.xml 
b/Documentation/DocBook/media/v4l/biblio.xml
index fdee6b3..bed940b 100644
--- a/Documentation/DocBook/media/v4l/biblio.xml
+++ b/Documentation/DocBook/media/v4l/biblio.xml
@@ -324,6 +324,16 @@ in the frequency range from 87,5 to 108,0 MHz
   Specification Version 1.4a
 
 
+
+  HDMI2
+  
+   HDMI Licensing LLC
+(http://www.hdmi.org;>http://www.hdmi.org)
+  
+  High-Definition Multimedia Interface
+  Specification Version 2.0
+
+
 
   DP
   
diff --git a/Documentation/DocBook/media/v4l/cec-api.xml 
b/Documentation/DocBook/media/v4l/cec-api.xml
new file mode 100644
index 000..0e68f75
--- /dev/null
+++ 

[PATCHv9 15/15] cobalt: add cec support

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the cobalt driver.

Signed-off-by: Hans Verkuil 
---
 drivers/media/pci/cobalt/Kconfig |   1 +
 drivers/media/pci/cobalt/cobalt-driver.c |  51 --
 drivers/media/pci/cobalt/cobalt-driver.h |   2 +
 drivers/media/pci/cobalt/cobalt-irq.c|   3 +
 drivers/media/pci/cobalt/cobalt-v4l2.c   | 113 +--
 5 files changed, 159 insertions(+), 11 deletions(-)

diff --git a/drivers/media/pci/cobalt/Kconfig b/drivers/media/pci/cobalt/Kconfig
index 1f88ccc..46483ee 100644
--- a/drivers/media/pci/cobalt/Kconfig
+++ b/drivers/media/pci/cobalt/Kconfig
@@ -4,6 +4,7 @@ config VIDEO_COBALT
depends on PCI_MSI && MTD_COMPLEX_MAPPINGS
depends on GPIOLIB || COMPILE_TEST
depends on SND
+   select CEC
select I2C_ALGOBIT
select VIDEO_ADV7604
select VIDEO_ADV7511
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c 
b/drivers/media/pci/cobalt/cobalt-driver.c
index 8fed61e..ed53781 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -76,6 +76,7 @@ static u8 edid[256] = {
0x0A, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x68,
+
0x02, 0x03, 0x1a, 0xc0, 0x48, 0xa2, 0x10, 0x04,
0x02, 0x01, 0x21, 0x14, 0x13, 0x23, 0x09, 0x07,
0x07, 0x65, 0x03, 0x0c, 0x00, 0x10, 0x00, 0xe2,
@@ -149,17 +150,58 @@ static void cobalt_notify(struct v4l2_subdev *sd,
struct cobalt *cobalt = to_cobalt(sd->v4l2_dev);
unsigned sd_nr = cobalt_get_sd_nr(sd);
struct cobalt_stream *s = >streams[sd_nr];
-   bool hotplug = arg ? *((int *)arg) : false;
 
-   if (s->is_output)
+   switch (notification) {
+   case V4L2_SUBDEV_CEC_TX_DONE:
+   cec_transmit_done(s->cec_adap, (unsigned long)arg);
+   return;
+   case V4L2_SUBDEV_CEC_RX_MSG:
+   cec_received_msg(s->cec_adap, arg);
+   return;
+   case V4L2_SUBDEV_CEC_CONN_INPUTS:
+   cec_connected_inputs(s->cec_adap, *(u16 *)arg);
+   return;
+   default:
+   break;
+   }
+
+   if (s->is_output) {
+   switch (notification) {
+   case ADV7511_EDID_DETECT: {
+   struct adv7511_edid_detect *ed = arg;
+
+   s->cec_adap->phys_addr = ed->phys_addr;
+   if (!ed->present) {
+   cec_enable(s->cec_adap, false);
+   break;
+   }
+   cec_enable(s->cec_adap, true);
+   break;
+   }
+   case ADV7511_MONITOR_DETECT: {
+   struct adv7511_monitor_detect *md = arg;
+
+   if (!md->present) {
+   cec_enable(s->cec_adap, false);
+   break;
+   }
+   break;
+   }
+   }
return;
+   }
 
switch (notification) {
-   case ADV76XX_HOTPLUG:
+   case ADV76XX_HOTPLUG: {
+   bool hotplug = arg ? *((int *)arg) : false;
+
cobalt_s_bit_sysctrl(cobalt,
COBALT_SYS_CTRL_HPD_TO_CONNECTOR_BIT(sd_nr), hotplug);
+   if (s->cec_adap)
+   cec_connected_inputs(s->cec_adap, hotplug);
cobalt_dbg(1, "Set hotplug for adv %d to %d\n", sd_nr, hotplug);
break;
+   }
case V4L2_DEVICE_NOTIFY_EVENT:
cobalt_dbg(1, "Format changed for adv %d\n", sd_nr);
v4l2_event_queue(>vdev, arg);
@@ -627,8 +669,9 @@ static int cobalt_subdevs_hsma_init(struct cobalt *cobalt)
s->sd = v4l2_i2c_new_subdev_board(>v4l2_dev,
s->i2c_adap, _info, NULL);
if (s->sd) {
-   int err = v4l2_subdev_call(s->sd, pad, set_edid, _edid);
+   int err;
 
+   err = v4l2_subdev_call(s->sd, pad, set_edid, _edid);
if (err)
return err;
err = v4l2_subdev_call(s->sd, pad, set_fmt, NULL,
diff --git a/drivers/media/pci/cobalt/cobalt-driver.h 
b/drivers/media/pci/cobalt/cobalt-driver.h
index c206df9..55a8c0d 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.h
+++ b/drivers/media/pci/cobalt/cobalt-driver.h
@@ -31,6 +31,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -221,6 +222,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;
diff --git a/drivers/media/pci/cobalt/cobalt-irq.c 

[PATCHv9 03/15] dts: exynos4412-odroid*: enable the HDMI CEC device

2015-09-07 Thread Hans Verkuil
From: Kamil Debski 

Add a dts node entry and enable the HDMI CEC device present in the Exynos4
family of SoCs.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
Acked-by: Krzysztof Kozlowski 
---
 arch/arm/boot/dts/exynos4210-universal_c210.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-universal_c210.dts 
b/arch/arm/boot/dts/exynos4210-universal_c210.dts
index d4f2b11..06df693 100644
--- a/arch/arm/boot/dts/exynos4210-universal_c210.dts
+++ b/arch/arm/boot/dts/exynos4210-universal_c210.dts
@@ -515,6 +515,10 @@
enable-active-high;
};
 
+   cec@100B {
+   status = "okay";
+   };
+
hdmi_ddc: i2c-ddc {
compatible = "i2c-gpio";
gpios = < 2 0  3 0>;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv9 14/15] cec: s5p-cec: Add s5p-cec driver

2015-09-07 Thread Hans Verkuil
From: Kamil Debski 

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

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 .../devicetree/bindings/media/s5p-cec.txt  |  31 +++
 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   |  37 +++
 .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c   | 208 +++
 drivers/media/platform/s5p-cec/regs-cec.h  |  96 +++
 drivers/media/platform/s5p-cec/s5p_cec.c   | 284 +
 drivers/media/platform/s5p-cec/s5p_cec.h   |  76 ++
 9 files changed, 747 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

diff --git a/Documentation/devicetree/bindings/media/s5p-cec.txt 
b/Documentation/devicetree/bindings/media/s5p-cec.txt
new file mode 100644
index 000..925ab4d
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/s5p-cec.txt
@@ -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@100B {
+   compatible = "samsung,s5p-cec";
+   reg = <0x100B 0x200>;
+   interrupts = <0 114 0>;
+   clocks = < CLK_HDMI_CEC>;
+   clock-names = "hdmicec";
+   samsung,syscon-phandle = <_system_controller>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_cec>;
+   status = "okay";
+};
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index dc75694..58346e6 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -117,6 +117,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 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"
 
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index efa0295..957af5f 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -27,6 +27,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/
diff --git a/drivers/media/platform/s5p-cec/Makefile 
b/drivers/media/platform/s5p-cec/Makefile
new file mode 100644
index 000..0e2cf45
--- /dev/null
+++ b/drivers/media/platform/s5p-cec/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC)+= s5p-cec.o
+s5p-cec-y += s5p_cec.o exynos_hdmi_cecctrl.o
diff --git a/drivers/media/platform/s5p-cec/exynos_hdmi_cec.h 
b/drivers/media/platform/s5p-cec/exynos_hdmi_cec.h
new file mode 100644
index 000..d008695
--- /dev/null
+++ b/drivers/media/platform/s5p-cec/exynos_hdmi_cec.h
@@ -0,0 +1,37 @@
+/* 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 

[PATCHv9 08/15] cec.txt: add CEC framework documentation

2015-09-07 Thread Hans Verkuil
Document the new HDMI CEC framework.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: add DocBook documentation by Hans Verkuil, with
Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 Documentation/cec.txt | 166 ++
 1 file changed, 166 insertions(+)
 create mode 100644 Documentation/cec.txt

diff --git a/Documentation/cec.txt b/Documentation/cec.txt
new file mode 100644
index 000..b298249
--- /dev/null
+++ b/Documentation/cec.txt
@@ -0,0 +1,166 @@
+CEC Kernel Support
+==
+
+The CEC framework provides a unified kernel interface for use with HDMI CEC
+hardware. It is designed to handle a multiple variants of hardware. Adding to
+the flexibility of the framework it enables to set which parts of the CEC
+protocol processing is handled by the hardware, by the driver and by the
+userspace application.
+
+
+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 protocol enables control of compatible devices with a single remote.
+Synchronous power on/standby, instant playback with changing the content source
+on the TV.
+
+The Kernel Interface
+
+
+CEC Adapter
+---
+
+#define CEC_LOG_ADDR_INVALID 0xff
+
+/* The maximum number of logical addresses one device can be assigned to.
+ * The CEC 2.0 spec allows for only 2 logical addresses at the moment. The
+ * Analog Devices CEC hardware supports 3. So let's go wild and go for 4. */
+#define CEC_MAX_LOG_ADDRS 4
+
+/* The "Primary Device Type" */
+#define CEC_OP_PRIM_DEVTYPE_TV 0
+#define CEC_OP_PRIM_DEVTYPE_RECORD 1
+#define CEC_OP_PRIM_DEVTYPE_TUNER  3
+#define CEC_OP_PRIM_DEVTYPE_PLAYBACK   4
+#define CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM5
+#define CEC_OP_PRIM_DEVTYPE_SWITCH 6
+#define CEC_OP_PRIM_DEVTYPE_VIDEOPROC  7
+
+/* The "All Device Types" flags (CEC 2.0) */
+#define CEC_OP_ALL_DEVTYPE_TV  (1 << 7)
+#define CEC_OP_ALL_DEVTYPE_RECORD  (1 << 6)
+#define CEC_OP_ALL_DEVTYPE_TUNER   (1 << 5)
+#define CEC_OP_ALL_DEVTYPE_PLAYBACK(1 << 4)
+#define CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM (1 << 3)
+#define CEC_OP_ALL_DEVTYPE_SWITCH  (1 << 2)
+/* And if you wondering what happened to VIDEOPROC devices: those should
+ * be mapped to a SWITCH. */
+
+/* The logical address types that the CEC device wants to claim */
+#define CEC_LOG_ADDR_TYPE_TV   0
+#define CEC_LOG_ADDR_TYPE_RECORD   1
+#define CEC_LOG_ADDR_TYPE_TUNER2
+#define CEC_LOG_ADDR_TYPE_PLAYBACK 3
+#define CEC_LOG_ADDR_TYPE_AUDIOSYSTEM  4
+#define CEC_LOG_ADDR_TYPE_SPECIFIC 5
+#define CEC_LOG_ADDR_TYPE_UNREGISTERED 6
+/* Switches should use UNREGISTERED.
+ * Video processors should use SPECIFIC. */
+
+/* The CEC version */
+#define CEC_OP_CEC_VERSION_1_3A4
+#define CEC_OP_CEC_VERSION_1_4 5
+#define CEC_OP_CEC_VERSION_2_0 6
+
+struct cec_adapter {
+   /* internal fields removed */
+
+   u16 phys_addr;
+   u32 capabilities;
+   u8 version;
+   u8 num_log_addrs;
+   u8 prim_device[CEC_MAX_LOG_ADDRS];
+   u8 log_addr_type[CEC_MAX_LOG_ADDRS];
+   u8 log_addr[CEC_MAX_LOG_ADDRS];
+
+   int (*adap_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, struct cec_msg *msg);
+   void (*adap_transmit_timed_out)(struct cec_adapter *adap);
+
+   void (*claimed_log_addr)(struct cec_adapter *adap, u8 idx);
+   int (*received)(struct cec_adapter *adap, struct cec_msg *msg);
+};
+
+int cec_create_adapter(struct cec_adapter *adap, u32 caps);
+void cec_delete_adapter(struct cec_adapter *adap);
+int cec_transmit_msg(struct cec_adapter *adap, struct cec_data *data, bool 
block);
+
+/* Called by the adapter */
+void cec_transmit_done(struct cec_adapter *adap, u32 status);
+void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg);
+
+int cec_receive_msg(struct cec_adapter *adap, struct cec_msg *msg, bool block);
+int cec_claim_log_addrs(struct cec_adapter *adap, struct cec_log_addrs 
*log_addrs, bool block);
+
+The device type defines are defined by the CEC standard.
+
+The cec_adapter structure represents the adapter. It has a number of
+operations that have to be implemented in the driver: adap_enable() enables
+or disables the physical adapter, adap_log_addr() tells the driver which
+logical address should be configured. This may be called multiple times

[PATCHv9 02/15] dts: exynos4: add node for the HDMI CEC device

2015-09-07 Thread Hans Verkuil
From: Kamil Debski 

This patch adds HDMI CEC node specific to the Exynos4210/4x12 SoC series.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
Acked-by: Krzysztof Kozlowski 
---
 arch/arm/boot/dts/exynos4.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index b0d52b1..0d5319e 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -719,6 +719,18 @@
status = "disabled";
};
 
+   hdmicec: cec@100B {
+   compatible = "samsung,s5p-cec";
+   reg = <0x100B 0x200>;
+   interrupts = <0 114 0>;
+   clocks = < CLK_HDMI_CEC>;
+   clock-names = "hdmicec";
+   samsung,syscon-phandle = <_system_controller>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_cec>;
+   status = "disabled";
+   };
+
mixer: mixer@12C1 {
compatible = "samsung,exynos4210-mixer";
interrupts = <0 91 0>;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv9 00/15] HDMI CEC framework

2015-09-07 Thread Hans Verkuil
Hi all,

The ninth version of this patchset addresses comments I received from
Russell King.

As far as I am concerned this version is code complete (but I said that
before) and the only thing missing is that the cec.txt documentation is
out-of-sync with the current implementation.

So there will be a v10 fixing that.

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

Best regards,

Hans

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 (0x)
- 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


[PATCHv9 05/15] HID: add HDMI CEC specific keycodes

2015-09-07 Thread Hans Verkuil
From: Kamil Debski 

Add HDMI CEC specific keycodes to the keycodes definition.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 include/uapi/linux/input.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index a32bff1..5e7019a 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -752,6 +752,34 @@ struct input_keymap_entry {
 #define KEY_KBDINPUTASSIST_ACCEPT  0x264
 #define KEY_KBDINPUTASSIST_CANCEL  0x265
 
+#define KEY_RIGHT_UP   0x266
+#define KEY_RIGHT_DOWN 0x267
+#define KEY_LEFT_UP0x268
+#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_MODE0x26f
+#define KEY_NEXT_FAVORITE  0x270
+#define KEY_STOP_RECORD0x271
+#define KEY_PAUSE_RECORD   0x272
+#define KEY_VOD0x273 /* Video on Demand */
+#define KEY_UNMUTE 0x274
+#define KEY_FASTREVERSE0x275
+#define KEY_SLOWREVERSE0x276
+/*
+ * 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
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv9 01/15] dts: exynos4*: add HDMI CEC pin definition to pinctrl

2015-09-07 Thread Hans Verkuil
From: Kamil Debski 

Add pinctrl nodes for the HDMI CEC device to the Exynos4210 and
Exynos4x12 SoCs. These are required by the HDMI CEC device.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
Acked-by: Krzysztof Kozlowski 
---
 arch/arm/boot/dts/exynos4210-pinctrl.dtsi | 7 +++
 arch/arm/boot/dts/exynos4x12-pinctrl.dtsi | 7 +++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-pinctrl.dtsi 
b/arch/arm/boot/dts/exynos4210-pinctrl.dtsi
index a7c2128..9331c62 100644
--- a/arch/arm/boot/dts/exynos4210-pinctrl.dtsi
+++ b/arch/arm/boot/dts/exynos4210-pinctrl.dtsi
@@ -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@0386 {
diff --git a/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi 
b/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi
index bac25c6..856b292 100644
--- a/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi
+++ b/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi
@@ -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@0386 {
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv9 04/15] input.h: add BUS_CEC type

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

Inputs can come in over the HDMI CEC bus, so add a new type for this.

Signed-off-by: Hans Verkuil 
Acked-by: Dmitry Torokhov 
---
 include/uapi/linux/input.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index 731417c..a32bff1 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -972,6 +972,7 @@ struct input_keymap_entry {
 #define BUS_GSC0x1A
 #define BUS_ATARI  0x1B
 #define BUS_SPI0x1C
+#define BUS_CEC0x1D
 
 /*
  * MT_TOOL types
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv9 10/15] v4l2-subdev: add HDMI CEC ops

2015-09-07 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC callbacks to the v4l2_subdev_video_ops. These are the low-level CEC
ops that subdevs that support CEC have to implement.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: Merged changes from CEC Updates commit by Hans Verkuil]
Signed-off-by: Kamil Debski 
---
 include/media/v4l2-subdev.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index b273cf9..3adddc7 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -42,6 +42,10 @@
 
 #defineV4L2_DEVICE_NOTIFY_EVENT_IOW('v', 2, struct 
v4l2_event)
 
+#define V4L2_SUBDEV_CEC_TX_DONE_IOW('v', 3, u32)
+#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 +55,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 {
@@ -421,6 +426,11 @@ struct v4l2_subdev_video_ops {
 const struct v4l2_mbus_config *cfg);
int (*s_rx_buffer)(struct v4l2_subdev *sd, void *buf,
   unsigned int *size);
+   void (*cec_ready)(struct v4l2_subdev *sd);
+   unsigned (*cec_available_log_addrs)(struct v4l2_subdev *sd);
+   int (*cec_enable)(struct v4l2_subdev *sd, bool enable);
+   int (*cec_log_addr)(struct v4l2_subdev *sd, u8 logical_addr);
+   int (*cec_transmit)(struct v4l2_subdev *sd, u32 timeout_ms, struct 
cec_msg *msg);
 };
 
 /**
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/7] [media] vimc: sen: Integrate the tpg on the sensor

2015-09-07 Thread Helen Fornazier
Hi, thank you all for your review

On Fri, Aug 14, 2015 at 9:15 AM, Hans Verkuil  wrote:
> On 08/06/2015 10:26 PM, Helen Fornazier wrote:
>> Initialize the test pattern generator on the sensor
>> Generate a colored bar image instead of a grey one
>
> You don't want to put the tpg in every sensor and have all the blocks in
> between process the video. This is all virtual, so all that is necessary
> is to put the tpg in every DMA engine (video node) but have the subdevs
> modify the tpg setting when you start the pipeline.
>
> So the source would set the width/height to the sensor resolution, and it
> will initialize the crop/compose rectangles. Every other entity in the
> pipeline will continue modifying according to what they do. E.g. a scaler
> will just change the compose rectangle.
>
> When you start streaming the tpg will generate the image based on all those
> settings as if all the entities would actually do the work.
>
> Of course, this assumes the processing the entities do map to what the tpg
> can do, but that's true for vimc.
>
> An additional advantage is that the entities can use a wide range of
> mediabus formats since the tpg can generate basically anything. Implementing
> multiplanar is similarly easy. This would be much harder if you had to write
> the image processing code for the entities since you'd either have to support
> lots of different formats (impractical) or limit yourself to just a few.
>
>>
>> Signed-off-by: Helen Fornazier 
>> ---
>>  drivers/media/platform/vimc/Kconfig   |  1 +
>>  drivers/media/platform/vimc/vimc-sensor.c | 44 
>> +--
>>  2 files changed, 43 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/platform/vimc/Kconfig 
>> b/drivers/media/platform/vimc/Kconfig
>> index 81279f4..7cf7e84 100644
>> --- a/drivers/media/platform/vimc/Kconfig
>> +++ b/drivers/media/platform/vimc/Kconfig
>> @@ -1,6 +1,7 @@
>>  config VIDEO_VIMC
>>   tristate "Virtual Media Controller Driver (VIMC)"
>>   select VIDEO_V4L2_SUBDEV_API
>> + select VIDEO_TPG
>>   default n
>>   ---help---
>> Skeleton driver for Virtual Media Controller
>> diff --git a/drivers/media/platform/vimc/vimc-sensor.c 
>> b/drivers/media/platform/vimc/vimc-sensor.c
>> index d613792..a2879ad 100644
>> --- a/drivers/media/platform/vimc/vimc-sensor.c
>> +++ b/drivers/media/platform/vimc/vimc-sensor.c
>> @@ -16,15 +16,19 @@
>>   */
>>
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>>
>>  #include "vimc-sensor.h"
>>
>> +#define VIMC_SEN_FRAME_MAX_WIDTH 4096
>> +
>>  struct vimc_sen_device {
>>   struct vimc_ent_device ved;
>>   struct v4l2_subdev sd;
>> + struct tpg_data tpg;
>>   struct v4l2_device *v4l2_dev;
>>   struct device *dev;
>>   struct task_struct *kthread_sen;
>> @@ -87,6 +91,29 @@ static int vimc_sen_get_fmt(struct v4l2_subdev *sd,
>>   return 0;
>>  }
>>
>> +static void vimc_sen_tpg_s_format(struct vimc_sen_device *vsen)
>> +{
>> + const struct vimc_pix_map *vpix;
>> +
>> + vpix = vimc_pix_map_by_code(vsen->mbus_format.code);
>> + /* This should never be NULL, as we won't allow any format other then
>> +  * the ones in the vimc_pix_map_list table */
>> + BUG_ON(!vpix);
>> +
>> + tpg_s_bytesperline(>tpg, 0,
>> +vsen->mbus_format.width * vpix->bpp);
>> + tpg_s_buf_height(>tpg, vsen->mbus_format.height);
>> + tpg_s_fourcc(>tpg, vpix->pixelformat);
>> + /* TODO: check why the tpg_s_field need this third argument if
>> +  * it is already receiving the field */
>> + tpg_s_field(>tpg, vsen->mbus_format.field,
>> + vsen->mbus_format.field == V4L2_FIELD_ALTERNATE);
>
> Actually the second argument argument cannot be FIELD_ALTERNATE. If it
> is field ALTERNATE, then the second argument must be either FIELD_TOP or
> FIELD_BOTTOM: i.e. it tells the generator which field comes first in the
> FIELD_ALTERNATE case.
>
> And in case you are wondering: it's always FIELD_TOP except for 60 Hz SDTV
> formats where it is FIELD_BOTTOM.

I am not really familiar to SDTV, but it seems to me to be a different
structure API. Thus can I put FIELD_TOP directly in the second
argument?

tpg_s_field(>tpg, V4L2_FIELD_TOP,
vsen->mbus_format.field == V4L2_FIELD_ALTERNATE);

Or is there a way to check if the format is SDTV? I didn't find it
defined on V4L2_PIX_FMT_

>
>> + tpg_s_colorspace(>tpg, vsen->mbus_format.colorspace);
>> + tpg_s_ycbcr_enc(>tpg, vsen->mbus_format.ycbcr_enc);
>> + tpg_s_quantization(>tpg, vsen->mbus_format.quantization);
>> + tpg_s_xfer_func(>tpg, vsen->mbus_format.xfer_func);
>> +}
>> +
>>  static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = {
>>   .enum_mbus_code = vimc_sen_enum_mbus_code,
>>   .enum_frame_size= vimc_sen_enum_frame_size,
>> @@ -112,7 +139,7 @@ static int vimc_thread_sen(void *data)
>>   

Re: [PATCH v8 49/55] [media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl

2015-09-07 Thread Sakari Ailus
Hi Mauro,

A few comments below.

On Sun, Sep 06, 2015 at 09:03:09AM -0300, Mauro Carvalho Chehab wrote:
> Add support for the new MEDIA_IOC_G_TOPOLOGY ioctl, according
> with the RFC for the MC next generation.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 5b2c9f7fcd45..96a476eeb16e 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -232,6 +232,156 @@ static long media_device_setup_link(struct media_device 
> *mdev,
>   return ret;
>  }
>  
> +static long __media_device_get_topology(struct media_device *mdev,
> +   struct media_v2_topology *topo)
> +{
> + struct media_entity *entity;
> + struct media_interface *intf;
> + struct media_pad *pad;
> + struct media_link *link;
> + struct media_v2_entity uentity;
> + struct media_v2_interface uintf;
> + struct media_v2_pad upad;
> + struct media_v2_link ulink;
> + int ret = 0, i;

I think i wants to be unsigned.

> +
> + topo->topology_version = mdev->topology_version;
> +
> + /* Get entities and number of entities */
> + i = 0;
> + media_device_for_each_entity(entity, mdev) {
> + i++;
> +
> + if (ret || !topo->entities)
> + continue;
> +
> + if (i > topo->num_entities) {
> + ret = -ENOSPC;
> + continue;
> + }
> +
> + /* Copy fields to userspace struct if not error */
> + memset(, 0, sizeof(uentity));
> + uentity.id = entity->graph_obj.id;
> + strncpy(uentity.name, entity->name,
> + sizeof(uentity.name));
> +
> + if (copy_to_user(>entities[i - 1], , 
> sizeof(uentity)))
> + ret = -EFAULT;
> + }
> + topo->num_entities = i;
> +
> + /* Get interfaces and number of interfaces */
> + i = 0;
> + media_device_for_each_intf(intf, mdev) {
> + i++;
> +
> + if (ret || !topo->interfaces)
> + continue;
> +
> + if (i > topo->num_interfaces) {
> + ret = -ENOSPC;
> + continue;
> + }
> +
> + memset(, 0, sizeof(uintf));
> +
> + /* Copy intf fields to userspace struct */
> + uintf.id = intf->graph_obj.id;
> + uintf.intf_type = intf->type;
> + uintf.flags = intf->flags;
> +
> + if (media_type(>graph_obj) == MEDIA_GRAPH_INTF_DEVNODE) {
> + struct media_intf_devnode *devnode;
> +
> + devnode = intf_to_devnode(intf);
> +
> + uintf.devnode.major = devnode->major;
> + uintf.devnode.minor = devnode->minor;
> + }
> +
> + if (copy_to_user(>interfaces[i - 1], , 
> sizeof(uintf)))
> + ret = -EFAULT;
> + }
> + topo->num_interfaces = i;
> +
> + /* Get pads and number of pads */
> + i = 0;
> + media_device_for_each_pad(pad, mdev) {
> + i++;
> +
> + if (ret || !topo->pads)
> + continue;
> +
> + if (i > topo->num_pads) {
> + ret = -ENOSPC;
> + continue;
> + }
> +
> + memset(, 0, sizeof(upad));
> +
> + /* Copy pad fields to userspace struct */
> + upad.id = pad->graph_obj.id;

How about the pad index? Shouldn't that be also passed to the user space for
every pad?

> + upad.entity_id = pad->entity->graph_obj.id;
> + upad.flags = pad->flags;
> +
> + if (copy_to_user(>pads[i - 1], , sizeof(upad)))
> + ret = -EFAULT;
> + }
> + topo->num_pads = i;
> +
> + /* Get links and number of links */
> + i = 0;
> + media_device_for_each_link(link, mdev) {
> + i++;
> +
> + if (ret || !topo->links)
> + continue;
> +
> + if (i > topo->num_links) {
> + ret = -ENOSPC;
> + continue;
> + }
> +
> + memset(, 0, sizeof(ulink));
> +
> + /* Copy link fields to userspace struct */
> + ulink.id = link->graph_obj.id;
> + ulink.source_id = link->gobj0->id;
> + ulink.sink_id = link->gobj1->id;
> + ulink.flags = link->flags;
> +
> + if (media_type(link->gobj0) != MEDIA_GRAPH_PAD)
> + ulink.flags |= MEDIA_LNK_FL_INTERFACE_LINK;
> +
> + if (copy_to_user(>links[i - 1], , sizeof(ulink)))
> + ret = -EFAULT;
> + }
> + topo->num_links = i;
> +
> + return ret;
> +}
> +
> +static long media_device_get_topology(struct media_device *mdev,
> +   struct media_v2_topology 

Re: [PATCH v6 2/8] [media] media: add a common struct to be embed on media graph objects

2015-09-07 Thread Laurent Pinchart
Hi Hans,

On Friday 21 August 2015 10:07:36 Hans Verkuil wrote:
> On 08/21/2015 03:02 AM, Laurent Pinchart wrote:
> > On Wednesday 19 August 2015 08:01:49 Mauro Carvalho Chehab wrote:
> >> +/* Enums used internally at the media controller to represent graphs */
> >> +
> >> +/**
> >> + * enum media_gobj_type - type of a graph element
> > 
> > Let's try to standardize the vocabulary, should it be called graph object
> > or graph element ? In the first case let's document it as graph object.
> > In the second case it would be more consistent to refer to it as enum
> > media_gelem_type (and struct media_gelem below).
> 
> For what it is worth, I prefer the term graph object.

So do I.

> >> + *
> >> + */
> >> +enum media_gobj_type {
> >> +   /* FIXME: add the types here, as we embed media_gobj */
> >> +  MEDIA_GRAPH_NONE
> >> +};
> >> +
> >> +#define MEDIA_BITS_PER_TYPE   8
> >> +#define MEDIA_BITS_PER_LOCAL_ID   (32 - MEDIA_BITS_PER_TYPE)
> >> +#define MEDIA_LOCAL_ID_MASK
> >> GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 
0)
> >> +
> >> +/* Structs to represent the objects that belong to a media graph */
> >> +
> >> +/**
> >> + * struct media_gobj - Define a graph object.
> >> + *
> >> + * @id:   Non-zero object ID identifier. The ID should be unique
> >> + *inside a media_device, as it is composed by
> >> + *MEDIA_BITS_PER_TYPE to store the type plus
> >> + *MEDIA_BITS_PER_LOCAL_ID to store a per-type ID
> >> + *(called as "local ID").
> > 
> > I'd very much prefer using a single ID range and adding a type field.
> > Abusing bits of the ID field to store the type will just makes IDs
> > impractical to use. Let's do it properly.
> 
> Why is that impractical? I think it is more practical. Why waste memory on
> something that is easy to encode in the ID?
> 
> I'm not necessarily opposed to splitting this up (Mauro's initial patch
> series used a separate type field if I remember correctly), but it's not
> clear to me what the benefits are. Keeping it in a single u32 makes
> describing links also very easy since you just give it the two objects that
> are linked and it is immediately clear which object types are linked: no
> need to either store the types in the link struct or look up each object to
> find the type.
> 
> >> + * All elements on the media graph should have this struct embedded
> > 
> > All elements (objects) or only the ones that need an ID ? Or maybe we'll
> > define graph element (object) as an element (object) that has an ID,
> > making some "elements" not elements.
> 
> Yes, all objects have an ID. I see no reason to special-case this.
> 
> You wrote this at 3 am, so you were probably sleep-deprived when you wrote
> the second sentence as I can't wrap my head around that one :-)

It's always 3:00am in some time zone, but it wasn't in Seattle ;-)

The question was whether every element is required to have an ID. If some of 
what we currently call element doesn't need an ID, then we'll have to either 
modify the quoted documentation, or redefine "element" to only include the 
elements that have an ID, making the graph objects that don't have an ID not 
"elements".

> >> + */
> >> +struct media_gobj {
> >> +  u32 id;
> >> +};

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 49/55] [media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl

2015-09-07 Thread Mauro Carvalho Chehab
Em Tue, 8 Sep 2015 01:18:30 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> A few comments below.

Thanks for review!

> 
> On Sun, Sep 06, 2015 at 09:03:09AM -0300, Mauro Carvalho Chehab wrote:
> > Add support for the new MEDIA_IOC_G_TOPOLOGY ioctl, according
> > with the RFC for the MC next generation.
> > 
> > Signed-off-by: Mauro Carvalho Chehab 
> > 
> > diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> > index 5b2c9f7fcd45..96a476eeb16e 100644
> > --- a/drivers/media/media-device.c
> > +++ b/drivers/media/media-device.c
> > @@ -232,6 +232,156 @@ static long media_device_setup_link(struct 
> > media_device *mdev,
> > return ret;
> >  }
> >  
> > +static long __media_device_get_topology(struct media_device *mdev,
> > + struct media_v2_topology *topo)
> > +{
> > +   struct media_entity *entity;
> > +   struct media_interface *intf;
> > +   struct media_pad *pad;
> > +   struct media_link *link;
> > +   struct media_v2_entity uentity;
> > +   struct media_v2_interface uintf;
> > +   struct media_v2_pad upad;
> > +   struct media_v2_link ulink;
> > +   int ret = 0, i;
> 
> I think i wants to be unsigned.

Yes, "i" can be unsigned. I'll change that.

> 
> > +
> > +   topo->topology_version = mdev->topology_version;
> > +
> > +   /* Get entities and number of entities */
> > +   i = 0;
> > +   media_device_for_each_entity(entity, mdev) {
> > +   i++;
> > +
> > +   if (ret || !topo->entities)
> > +   continue;
> > +
> > +   if (i > topo->num_entities) {
> > +   ret = -ENOSPC;
> > +   continue;
> > +   }
> > +
> > +   /* Copy fields to userspace struct if not error */
> > +   memset(, 0, sizeof(uentity));
> > +   uentity.id = entity->graph_obj.id;
> > +   strncpy(uentity.name, entity->name,
> > +   sizeof(uentity.name));
> > +
> > +   if (copy_to_user(>entities[i - 1], , 
> > sizeof(uentity)))
> > +   ret = -EFAULT;
> > +   }
> > +   topo->num_entities = i;
> > +
> > +   /* Get interfaces and number of interfaces */
> > +   i = 0;
> > +   media_device_for_each_intf(intf, mdev) {
> > +   i++;
> > +
> > +   if (ret || !topo->interfaces)
> > +   continue;
> > +
> > +   if (i > topo->num_interfaces) {
> > +   ret = -ENOSPC;
> > +   continue;
> > +   }
> > +
> > +   memset(, 0, sizeof(uintf));
> > +
> > +   /* Copy intf fields to userspace struct */
> > +   uintf.id = intf->graph_obj.id;
> > +   uintf.intf_type = intf->type;
> > +   uintf.flags = intf->flags;
> > +
> > +   if (media_type(>graph_obj) == MEDIA_GRAPH_INTF_DEVNODE) {
> > +   struct media_intf_devnode *devnode;
> > +
> > +   devnode = intf_to_devnode(intf);
> > +
> > +   uintf.devnode.major = devnode->major;
> > +   uintf.devnode.minor = devnode->minor;
> > +   }
> > +
> > +   if (copy_to_user(>interfaces[i - 1], , 
> > sizeof(uintf)))
> > +   ret = -EFAULT;
> > +   }
> > +   topo->num_interfaces = i;
> > +
> > +   /* Get pads and number of pads */
> > +   i = 0;
> > +   media_device_for_each_pad(pad, mdev) {
> > +   i++;
> > +
> > +   if (ret || !topo->pads)
> > +   continue;
> > +
> > +   if (i > topo->num_pads) {
> > +   ret = -ENOSPC;
> > +   continue;
> > +   }
> > +
> > +   memset(, 0, sizeof(upad));
> > +
> > +   /* Copy pad fields to userspace struct */
> > +   upad.id = pad->graph_obj.id;
> 
> How about the pad index? Shouldn't that be also passed to the user space for
> every pad?

We've agreed to not pass the pad index to userspace at the MC workshop.

There are two aspects here to consider:

a) to properly represent the topology (e. g. TOPOLOGY)

Writing the userspace code to support it, I didn't find any need to
pass it to userspace, as the data links are connected via the PAD object 
ID.

The PAD index for userspace is just a number that it uses when
generating the dot graph. See:
https://mchehab.fedorapeople.org/mc-next-gen/au0828.png

This was generated by this tool:

http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-utils.git/tree/contrib/test/mc_nextgen_test.c

And no pad index was required at all. What the tool does is that it
generates the pad numbers just when the --dot option is used,
at the media_show_graphviz() function.

Also, please notice that having a pad index makes harder to support
dynamic PAD addition/removal, as the pad index numberspace will
be discontinued.

b) using the PAD index to setup a link.

As I argued with Hans on one of his reviews, I don't think that
an index is always the best way to refer to a PAD. 

See 

cron job: media_tree daily build: OK

2015-09-07 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Tue Sep  8 04:00:17 CEST 2015
git branch: test
git hash:   50ef28a6ac216fd8b796257a3768fef8f57b917d
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-51-ga53cea2
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:4.0.0-3.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1.1-i686: OK
linux-4.2-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-x86_64: OK
linux-4.1.1-x86_64: OK
linux-4.2-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Tuesday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Tuesday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[no subject]

2015-09-07 Thread Mary Williams
ARE YOU IN NEED OF LOAN @ 3% INTEREST RATE FOR BUSINESS AND  PRIVATE PURPOSES?
IF YES: FILL AND RETURN
Name: ===
Amount needed: ===
Duration: =
country ==
Mobile number===
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html