ERROR: "bad_dma_ops" [sound/core/snd-pcm.ko] undefined!

2016-06-18 Thread kbuild test robot
Hi,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   c141afd1a28793c08c88325aa64b773be6f79ccf
commit: 420520766a796d3607639ba1e4fb1aadeadd [media] media: Kconfig: add 
dependency of HAS_DMA
date:   5 months ago
config: m32r-allmodconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 420520766a796d3607639ba1e4fb1aadeadd
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   ERROR: "bad_dma_ops" [sound/soc/qcom/snd-soc-lpass-platform.ko] undefined!
   ERROR: "dma_common_mmap" [sound/soc/qcom/snd-soc-lpass-platform.ko] 
undefined!
   ERROR: "bad_dma_ops" [sound/soc/kirkwood/snd-soc-kirkwood.ko] undefined!
   ERROR: "bad_dma_ops" [sound/soc/fsl/snd-soc-fsl-asrc.ko] undefined!
   ERROR: "bad_dma_ops" [sound/soc/atmel/snd-soc-atmel-pcm-pdc.ko] undefined!
>> ERROR: "bad_dma_ops" [sound/core/snd-pcm.ko] undefined!
>> ERROR: "dma_common_mmap" [sound/core/snd-pcm.ko] undefined!
>> ERROR: "__ucmpdi2" [lib/842/842_decompress.ko] undefined!
>> ERROR: "__ucmpdi2" [fs/btrfs/btrfs.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/xhci-plat-hcd.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/xhci-mtk.ko] undefined!
   ERROR: "dma_pool_destroy" [drivers/usb/host/xhci-hcd.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/xhci-hcd.ko] undefined!
   ERROR: "dma_pool_free" [drivers/usb/host/xhci-hcd.ko] undefined!
   ERROR: "dma_pool_alloc" [drivers/usb/host/xhci-hcd.ko] undefined!
   ERROR: "dma_pool_create" [drivers/usb/host/xhci-hcd.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/ohci-platform.ko] undefined!
   ERROR: "dma_pool_destroy" [drivers/usb/host/ohci-hcd.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/ohci-hcd.ko] undefined!
   ERROR: "dma_pool_free" [drivers/usb/host/ohci-hcd.ko] undefined!
   ERROR: "dma_pool_alloc" [drivers/usb/host/ohci-hcd.ko] undefined!
   ERROR: "dma_pool_create" [drivers/usb/host/ohci-hcd.ko] undefined!
   ERROR: "dma_pool_create" [drivers/usb/host/fotg210-hcd.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/fotg210-hcd.ko] undefined!
   ERROR: "dma_pool_destroy" [drivers/usb/host/fotg210-hcd.ko] undefined!
   ERROR: "dma_pool_alloc" [drivers/usb/host/fotg210-hcd.ko] undefined!
   ERROR: "dma_pool_free" [drivers/usb/host/fotg210-hcd.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/ehci-platform.ko] undefined!
   ERROR: "dma_pool_destroy" [drivers/usb/host/ehci-hcd.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/host/ehci-hcd.ko] undefined!
   ERROR: "dma_pool_free" [drivers/usb/host/ehci-hcd.ko] undefined!
   ERROR: "dma_pool_alloc" [drivers/usb/host/ehci-hcd.ko] undefined!
   ERROR: "dma_pool_create" [drivers/usb/host/ehci-hcd.ko] undefined!
   ERROR: "usb_gadget_map_request" [drivers/usb/dwc2/dwc2.ko] undefined!
   ERROR: "usb_gadget_unmap_request" [drivers/usb/dwc2/dwc2.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/dwc2/dwc2.ko] undefined!
   ERROR: "dma_pool_destroy" [drivers/usb/core/usbcore.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/usb/core/usbcore.ko] undefined!
   ERROR: "dma_pool_free" [drivers/usb/core/usbcore.ko] undefined!
   ERROR: "dma_pool_alloc" [drivers/usb/core/usbcore.ko] undefined!
   ERROR: "dma_pool_create" [drivers/usb/core/usbcore.ko] undefined!
   ERROR: "dma_pool_alloc" [drivers/scsi/hisi_sas/hisi_sas_v1_hw.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/scsi/hisi_sas/hisi_sas_v1_hw.ko] undefined!
   ERROR: "dma_pool_destroy" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
   ERROR: "dma_pool_free" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
   ERROR: "dma_pool_alloc" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
   ERROR: "dma_pool_create" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
   ERROR: "smp_flush_cache_all" [drivers/misc/lkdtm.ko] undefined!
>> ERROR: "__ucmpdi2" [drivers/media/i2c/adv7842.ko] undefined!
>> ERROR: "__ucmpdi2" [drivers/md/bcache/bcache.ko] undefined!
>> ERROR: "__ucmpdi2" [drivers/iio/imu/inv_mpu6050/inv-mpu6050.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/hwtracing/intel_th/intel_th_msu.ko] undefined!
   ERROR: "bad_dma_ops" [drivers/hwtracing/intel_th/intel_th.ko] undefined!
>> ERROR: "bad_dma_ops" [drivers/fpga/zynq-fpga.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


undefined reference to `bad_dma_ops'

2016-06-18 Thread kbuild test robot
Hi,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   c141afd1a28793c08c88325aa64b773be6f79ccf
commit: 420520766a796d3607639ba1e4fb1aadeadd [media] media: Kconfig: add 
dependency of HAS_DMA
date:   5 months ago
config: m32r-allyesconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 420520766a796d3607639ba1e4fb1aadeadd
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `hisi_sas_slot_task_free':
>> (.text+0x219238): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x21923c): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `hisi_sas_free':
   hisi_sas_main.c:(.text+0x2194cc): undefined reference to `bad_dma_ops'
   hisi_sas_main.c:(.text+0x2194d0): undefined reference to `bad_dma_ops'
   hisi_sas_main.c:(.text+0x219530): undefined reference to `bad_dma_ops'
   drivers/built-in.o:hisi_sas_main.c:(.text+0x219534): more undefined 
references to `bad_dma_ops' follow
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219260): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219260): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219278): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219278): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x21928c): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x21928c): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_free':
   hisi_sas_main.c:(.text+0x219560): undefined reference to `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x219560): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x21956c): undefined reference to `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x21956c): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x219574): undefined reference to `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x219574): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_destroy'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fa4): undefined reference to `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fa4): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fcc): undefined reference to `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fcc): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x21a0fc): undefined reference to `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x21a0fc): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_task_exec.isra.9':
   hisi_sas_main.c:(.text+0x21a834): undefined reference to `dma_pool_alloc'
   hisi_sas_main.c:(.text+0x21a834): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_alloc'
   hisi_sas_main.c:(.text+0x21a860): undefined reference to `dma_pool_alloc'
   hisi_sas_main.c:(.text+0x21a860): additional relocation overflows omitted 
from the output
   hisi_sas_main.c:(.text+0x21a990): undefined reference to `dma_pool_free'
   hisi_sas_main.c:(.text+0x21a9a8): undefined reference to `dma_pool_free'
   hisi_sas_main.c:(.text+0x21a9c8): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `prep_smp_v1_hw':
   hisi_sas_v1_hw.c:(.text+0x21b660): undefined reference to `bad_dma_ops'
   hisi_sas_v1_hw.c:(.text+0x21b668): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `slot_complete_v1_hw':
   hisi_sas_v1_hw.c:(.text+0x21c80c): undefined reference to `bad_dma_ops'
   hisi_sas_v1_hw.c:(.text+0x21c810): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `prep_ssp_v1_hw':
   hisi_sas_v1_hw.c:(.text+0x21ba0c): undefined reference to `dma_po

cron job: media_tree daily build: OK

2016-06-18 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:   Sun Jun 19 04:00:25 CEST 2016
git branch: test
git hash:   59f0bc11848f8f3242bc1fefae670e745929cd7b
gcc version:i686-linux-gcc (GCC) 5.3.0
sparse version: v0.5.0-56-g7647c77
smatch version: v0.5.0-3428-gdfe27cf
host hardware:  x86_64
host os:4.5.0-264

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-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.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-4.3-i686: OK
linux-4.4-i686: OK
linux-4.5-i686: OK
linux-4.6-i686: OK
linux-4.7-rc1-i686: 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
linux-4.3-x86_64: OK
linux-4.4-x86_64: OK
linux-4.5-x86_64: OK
linux-4.6-x86_64: OK
linux-4.7-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: WARNINGS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.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


Re: [very-RFC 0/8] TSN driver for the kernel

2016-06-18 Thread Henrik Austad
On Sat, Jun 18, 2016 at 02:22:13PM +0900, Takashi Sakamoto wrote:
> Hi,

Hi Takashi,

You raise a lot of valid points and questions, I'll try to answer them.

edit: this turned out to be a somewhat lengthy answer. I have tried to 
shorten it down somewhere. it is getting late and I'm getting increasingly 
incoherent (Richard probably knows what I'm talking about ;) so I'll stop 
for now.

Plase post a follow-up with everything that's not clear!
Thanks!

> Sorry to be late. In this weekday, I have little time for this thread
> because working for alsa-lib[1]. Besides, I'm not full-time developer
> for this kind of work. In short, I use my limited private time for this
> discussion.

Thank you for taking the time to reply to this thread then, it is much 
appreciated

> On Jun 15 2016 17:06, Richard Cochran wrote:
> > On Wed, Jun 15, 2016 at 12:15:24PM +0900, Takashi Sakamoto wrote:
> >>> On Mon, Jun 13, 2016 at 01:47:13PM +0200, Richard Cochran wrote:
>  I have seen audio PLL/multiplier chips that will take, for example, a
>  10 kHz input and produce your 48 kHz media clock.  With the right HW
>  design, you can tell your PTP Hardware Clock to produce a 1 PPS,
>  and you will have a synchronized AVB endpoint.  The software is all
>  there already.  Somebody should tell the ALSA guys about it.
> >>
> >> Just from my curiosity, could I ask you more explanation for it in ALSA
> >> side?
> > 
> > (Disclaimer: I really don't know too much about ALSA, expect that is
> > fairly big and complex ;)
> 
> In this morning, I read IEEE 1722:2011 and realized that it quite
> roughly refers to IEC 61883-1/6 and includes much ambiguities to end
> applications.

As far as I know, 1722 aims to describe how the data is wrapped in AVTPDU 
(and likewise for control-data), not how the end-station should implement 
it.

If there are ambiguities, would you mind listing a few? It would serve as a 
useful guide as to look for other pitfalls as well (thanks!)

> (In my opinion, the author just focuses on packet with timestamps,
> without enough considering about how to implement endpoint applications
> which perform semi-real sampling, fetching and queueing and so on, so as
> you. They're satisfied just by handling packet with timestamp, without
> enough consideration about actual hardware/software applications.)

You are correct, none of the standards explain exactly how it should be 
implemented, only what the end result should look like. One target of this 
collection of standards are embedded, dedicated AV equipment and the 
authors have no way of knowing (nor should they care I think) the 
underlying architecture of these.

> > Here is what I think ALSA should provide:
> > 
> > - The DA and AD clocks should appear as attributes of the HW device.

This would be very useful and helpful when determining if the clock of the 
HW time is falling behind or racing ahead of the gPTP time domain. It will 
also help finding the capture time or calculating when a sample in the 
buffer will be played back by the device.

> > - There should be a method for measuring the DA/AD clock rate with
> >   respect to both the system time and the PTP Hardware Clock (PHC)
> >   time.

as above.

> > - There should be a method for adjusting the DA/AD clock rate if
> >   possible.  If not, then ALSA should fall back to sample rate
> >   conversion.

This is not a requirement from the standard, but will help avoid costly 
resampling. At least it should be possible to detect the *need* for 
resampling so that we can try to avoid underruns.

> > - There should be a method to determine the time delay from the point
> >   when the audio data are enqueued into ALSA until they pass through
> >   the D/A converter.  If this cannot be known precisely, then the
> >   library should provide an estimate with an error bound.
> > 
> > - I think some AVB use cases will need to know the time delay from A/D
> >   until the data are available to the local application.  (Distributed
> >   microphones?  I'm not too sure about that.)

yes, if you have multiple microphones that you want to combine into a 
stream and do signal processing, some cases require sample-sync (so within 
1 us accuracy for 48kHz).

> > - If the DA/AD clocks are connected to other clock devices in HW,
> >   there should be a way to find this out in SW.  For example, if SW
> >   can see the PTP-PHC-PLL-DA relationship from the above example, then
> >   it knows how to synchronize the DA clock using the network.
> > 
> >   [ Implementing this point involves other subsystems beyond ALSA.  It
> > isn't really necessary for people designing AVB systems, since
> > they know their designs, but it would be nice to have for writing
> > generic applications that can deal with any kind of HW setup. ]
> 
> Depends on which subsystem decides "AVTP presentation time"[3]. 

Presentation time is either set by
a) Local sound card performing capture (in which case it will be 'capture 
 

Re: [PATCH 0/2] input: add support for HDMI CEC

2016-06-18 Thread Dmitry Torokhov
On Sat, Jun 18, 2016 at 02:44:08PM -0300, Mauro Carvalho Chehab wrote:
> Em Sat, 18 Jun 2016 18:56:24 +0200
> Hans Verkuil  escreveu:
> 
> > On 06/18/2016 06:26 PM, Dmitry Torokhov wrote:
> > > Hi Hans,
> > > 
> > > On Sat, Jun 18, 2016 at 04:50:26PM +0200, Hans Verkuil wrote:  
> > >> From: Hans Verkuil 
> > >>
> > >> Hi Dmitry,
> > >>
> > >> This patch series adds input support for the HDMI CEC bus through which
> > >> remote control keys can be passed from one HDMI device to another.
> > >>
> > >> This has been posted before as part of the HDMI CEC patch series. We are
> > >> going to merge that in linux-media for 4.8, but these two patches have to
> > >> go through linux-input.
> > >>
> > >> Only the rc-cec keymap file depends on this, and we will take care of 
> > >> that
> > >> dependency (we'll postpone merging that until both these input patches 
> > >> and
> > >> our own CEC patches have been merged in mainline).  
> > > 
> > > If it would be easier for you I am perfectly fine with these patches
> > > going through media tree; you have my acks on them.  
> > 
> > You're not expecting any changes to these headers for 4.8 that might
> > cause merge conflicts? That was Mauro's concern.
> > 
> > If not, then I would prefer it to go through the media tree to simplify
> > the dependencies, but it's up to Mauro.
> 
> Hi Dmitry,
> 
> My main concern is with patch 2, as it could conflict with some other
> patch on your tree, as I suspect it should be somewhat common to add
> new keystrokes from time to time, on your tree. As there's just one patch 
> affected by it from Hans CEC patch series, with adds the keymap to be 
> used by the remote controller CEC patch, it won't be a big issue to 
> delay just that patch to be sent upstream after both your and my trees 
> would be merged.

Mauro,

I created an immutable branch "cec-defines" based on 4.6; I'll also
merge it into 4.7.

Thanks.

-- 
Dmitry
--
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 0/2] input: add support for HDMI CEC

2016-06-18 Thread Mauro Carvalho Chehab
Em Sat, 18 Jun 2016 18:56:24 +0200
Hans Verkuil  escreveu:

> On 06/18/2016 06:26 PM, Dmitry Torokhov wrote:
> > Hi Hans,
> > 
> > On Sat, Jun 18, 2016 at 04:50:26PM +0200, Hans Verkuil wrote:  
> >> From: Hans Verkuil 
> >>
> >> Hi Dmitry,
> >>
> >> This patch series adds input support for the HDMI CEC bus through which
> >> remote control keys can be passed from one HDMI device to another.
> >>
> >> This has been posted before as part of the HDMI CEC patch series. We are
> >> going to merge that in linux-media for 4.8, but these two patches have to
> >> go through linux-input.
> >>
> >> Only the rc-cec keymap file depends on this, and we will take care of that
> >> dependency (we'll postpone merging that until both these input patches and
> >> our own CEC patches have been merged in mainline).  
> > 
> > If it would be easier for you I am perfectly fine with these patches
> > going through media tree; you have my acks on them.  
> 
> You're not expecting any changes to these headers for 4.8 that might
> cause merge conflicts? That was Mauro's concern.
> 
> If not, then I would prefer it to go through the media tree to simplify
> the dependencies, but it's up to Mauro.

Hi Dmitry,

My main concern is with patch 2, as it could conflict with some other
patch on your tree, as I suspect it should be somewhat common to add
new keystrokes from time to time, on your tree. As there's just one patch 
affected by it from Hans CEC patch series, with adds the keymap to be 
used by the remote controller CEC patch, it won't be a big issue to 
delay just that patch to be sent upstream after both your and my trees 
would be merged.

Regards,

Thanks,
Mauro
--
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: dvb usb stick Hauppauge WinTV-soloHD

2016-06-18 Thread Thomas Stein

Hi Olli.

Thanks for your answer.

Here we go.

[0.00] Linux version 4.6.2 (root@rather) (gcc version 5.3.0 
(Gentoo 5.3.0 p1.0, pie-0.6.5) ) #3 SMP Sat Jun 18 13:34:40 CEST 2016
[0.00] Command line: BOOT_IMAGE=/kernel-4.6.2 root=/dev/sda3 ro 
net.ifnames=0

[0.00] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[0.00] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating 
point registers'

[0.00] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[0.00] x86/fpu: Enabled xstate features 0x7, context size is 832 
bytes, using 'standard' format.

[0.00] x86/fpu: Using 'eager' FPU context switches.
[0.00] e820: BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x-0x0009cfff] 
usable
[0.00] BIOS-e820: [mem 0x0009d000-0x0009] 
reserved
[0.00] BIOS-e820: [mem 0x000e-0x000f] 
reserved
[0.00] BIOS-e820: [mem 0x0010-0xce20] 
usable
[0.00] BIOS-e820: [mem 0xce21-0xdcd3efff] 
reserved
[0.00] BIOS-e820: [mem 0xdcd3f000-0xdce7efff] 
ACPI NVS
[0.00] BIOS-e820: [mem 0xdce7f000-0xdcefefff] 
ACPI data
[0.00] BIOS-e820: [mem 0xdceff000-0xdfa0] 
reserved
[0.00] BIOS-e820: [mem 0xf800-0xfbff] 
reserved
[0.00] BIOS-e820: [mem 0xfe101000-0xfe112fff] 
reserved
[0.00] BIOS-e820: [mem 0xfec0-0xfec00fff] 
reserved
[0.00] BIOS-e820: [mem 0xfed08000-0xfed08fff] 
reserved
[0.00] BIOS-e820: [mem 0xfed1-0xfed19fff] 
reserved
[0.00] BIOS-e820: [mem 0xfed1c000-0xfed1] 
reserved
[0.00] BIOS-e820: [mem 0xfee0-0xfee00fff] 
reserved
[0.00] BIOS-e820: [mem 0xffc0-0x] 
reserved
[0.00] BIOS-e820: [mem 0x0001-0x00021f5f] 
usable

[0.00] NX (Execute Disable) protection: active
[0.00] SMBIOS 2.7 present.
[0.00] DMI: LENOVO 20A7005MGE/20A7005MGE, BIOS GRET46WW (1.23 ) 
11/04/2015
[0.00] e820: update [mem 0x-0x0fff] usable ==> 
reserved

[0.00] e820: remove [mem 0x000a-0x000f] usable
[0.00] e820: last_pfn = 0x21f600 max_arch_pfn = 0x4
[0.00] MTRR default type: write-back
[0.00] MTRR fixed ranges enabled:
[0.00]   0-9 write-back
[0.00]   A-B uncachable
[0.00]   C-F write-protect
[0.00] MTRR variable ranges enabled:
[0.00]   0 base 00E000 mask 7FE000 uncachable
[0.00]   1 base 00DE00 mask 7FFE00 uncachable
[0.00]   2 base 00DD00 mask 7FFF00 uncachable
[0.00]   3 base 00DCF0 mask 70 uncachable
[0.00]   4 disabled
[0.00]   5 disabled
[0.00]   6 disabled
[0.00]   7 disabled
[0.00]   8 disabled
[0.00]   9 disabled
[0.00] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WC  UC- 
WT

[0.00] e820: last_pfn = 0xce210 max_arch_pfn = 0x4
[0.00] found SMP MP-table at [mem 0x000f0100-0x000f010f] mapped 
at [880f0100]

[0.00] Scanning 1 areas for low memory corruption
[0.00] Base memory trampoline at [88097000] 97000 size 
24576

[0.00] Using GB pages for direct mapping
[0.00] BRK [0x02101000, 0x02101fff] PGTABLE
[0.00] BRK [0x02102000, 0x02102fff] PGTABLE
[0.00] BRK [0x02103000, 0x02103fff] PGTABLE
[0.00] BRK [0x02104000, 0x02104fff] PGTABLE
[0.00] ACPI: Early table checksum verification disabled
[0.00] ACPI: RSDP 0x000F0120 24 (v02 LENOVO)
[0.00] ACPI: XSDT 0xDCEFE170 C4 (v01 LENOVO TP-GR
1230 PTEC 0002)
[0.00] ACPI: FACP 0xDCEF8000 00010C (v05 LENOVO TP-GR
1230 PTEC 0002)
[0.00] ACPI: DSDT 0xDCEDF000 013476 (v01 LENOVO TP-GR
1230 INTL 20120711)

[0.00] ACPI: FACS 0xDCE6A000 40
[0.00] ACPI: SLIC 0xDCEFD000 000176 (v01 LENOVO TP-GR
1230 PTEC 0001)
[0.00] ACPI: ASF! 0xDCEFC000 A5 (v32 LENOVO TP-GR
1230 PTEC 0002)
[0.00] ACPI: DBGP 0xDCEFB000 34 (v01 LENOVO TP-GR
1230 PTEC 0002)
[0.00] ACPI: ECDT 0xDCEFA000 52 (v01 LENOVO TP-GR
1230 PTEC 0002)
[0.00] ACPI: HPET 0xDCEF7000 38 (v01 LENOVO TP-GR
1230 PTEC 0002)
[0.00] ACPI: APIC 0xDCEF6000 98 (v01 LENOVO TP-GR
1230 PTEC 0002)
[0.00] ACPI: MCFG 0xDCEF5000 3C (v01 LENOVO TP-GR
1230 PTEC 000

Re: [PATCH 0/2] input: add support for HDMI CEC

2016-06-18 Thread Hans Verkuil
On 06/18/2016 06:26 PM, Dmitry Torokhov wrote:
> Hi Hans,
> 
> On Sat, Jun 18, 2016 at 04:50:26PM +0200, Hans Verkuil wrote:
>> From: Hans Verkuil 
>>
>> Hi Dmitry,
>>
>> This patch series adds input support for the HDMI CEC bus through which
>> remote control keys can be passed from one HDMI device to another.
>>
>> This has been posted before as part of the HDMI CEC patch series. We are
>> going to merge that in linux-media for 4.8, but these two patches have to
>> go through linux-input.
>>
>> Only the rc-cec keymap file depends on this, and we will take care of that
>> dependency (we'll postpone merging that until both these input patches and
>> our own CEC patches have been merged in mainline).
> 
> If it would be easier for you I am perfectly fine with these patches
> going through media tree; you have my acks on them.

You're not expecting any changes to these headers for 4.8 that might
cause merge conflicts? That was Mauro's concern.

If not, then I would prefer it to go through the media tree to simplify
the dependencies, but it's up to Mauro.

Regards,

Hans
--
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: dvb usb stick Hauppauge WinTV-soloHD

2016-06-18 Thread Olli Salonen
Hi Thomas,

Please reboot your PC, run w_scan and then send the full output of
dmesg command. Maybe the driver has printed something in the logs that
can help us narrow the cause.

Cheers,
-olli

On 18 June 2016 at 18:55, Thomas Stein  wrote:
> Hello.
>
> I'm trying to get a dvb usb stick Hauppauge WinTV-soloHD running. I saw
> there is general support already in the kernel.
> https://git.linuxtv.org/media_tree.git/commit/?id=1efc21701d94ed0c5b91467b042bed8b8becd5cc
>
> I'm able to use this device for dvb-t but not dvb-t2. I'm living in berlin
> so it should work. w_scan is scanning dvb-t2 and seems
> to find channels:
>
> Scanning DVB-T2...
> Scanning 7MHz frequencies...
> 177500: (time: 02:17.828)
> 184500: (time: 02:19.828)
> 191500: (time: 02:21.876)
> 198500: (time: 02:23.924)
> 205500: (time: 02:25.971)
> 212500: (time: 02:27.971)
> 219500: (time: 02:30.021)
> 226500: (time: 02:32.071)
> Scanning 8MHz frequencies...
> 474000: (time: 02:34.120)
> 482000: (time: 02:36.121)
> 49: (time: 02:38.169)
> 498000: (time: 02:40.219)
> 506000: skipped (already known transponder)
> 514000: (time: 02:42.268)
> 522000: skipped (already known transponder)
> 53: (time: 02:44.318)
> 538000: (time: 02:46.368)
> 546000: (time: 02:48.417)
> 554000: (time: 02:50.417)
> 562000: (time: 02:52.467)
> 57: skipped (already known transponder)
> 578000: (time: 02:54.467)
> 586000: (time: 02:56.469)
> 594000: (time: 02:58.469)
> 602000: (time: 03:00.518)
> 61: (time: 03:02.567)
> 618000: skipped (already known transponder)
> 626000: (time: 03:04.617)
> 634000: (time: 03:06.617)
> 642000: (time: 03:08.667) signal ok:QAM_AUTO f = 642000 kHz
> I999B8C999D999T999G999Y999P0 (0:0:0)
> QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0 (0:0:0) :
> updating transport_stream_id: -> (0:0:16481)
> QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0 (0:0:16481) :
> updating network_id -> (0:12352:16481)
> QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0 (0:12352:16481)
> : updating original_network_id -> (8468:12352:16481)
> updating transponder:
>(QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0
> (8468:12352:16481)) 0x
> to (QAM_AUTO f = 65 kHz I999B8C999D999T32G16Y999P0
> (8468:12352:16481)) 0x4004
> new transponder: (QAM_AUTO f = 642000 kHz I999B8C0D0T32G16Y0P1
> (8468:12352:16497)) 0x4004
> 65: skipped (already known transponder)
> 658000: skipped (already known transponder)
> 666000: (time: 03:10.382)
> 674000: (time: 03:12.429)
> 682000: skipped (already known transponder)
> 69: (time: 03:14.476)
> 698000: (time: 03:16.528)
> 706000: skipped (already known transponder)
> 714000: (time: 03:18.575)
> 722000: (time: 03:20.623)
> 73: (time: 03:22.669)
> 738000: (time: 03:24.716)
> 746000: (time: 03:26.764)
> 754000: skipped (already known transponder)
> 762000: (time: 03:28.811)
> 77: (time: 03:30.860)
> 778000: skipped (already known transponder)
> 786000: (time: 03:32.908)
> 794000: (time: 03:34.953)
> 802000: (time: 03:36.999)
> 81: (time: 03:39.045)
> 818000: (time: 03:41.045)
> 826000: (time: 03:43.091)
> 834000: (time: 03:45.137)
> 842000: (time: 03:47.185)
> 85: (time: 03:49.231)
> 858000: (time: 03:51.277)
>
> So the question is, what is going wrong? When i start vlc with dvb-t2
> channels file for berlin i get:
>
> [7f7e0c01a0e8] ts demux error: cannot peek
>
> Any hints appreciated.
>
> cheers
> t.
--
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 0/2] input: add support for HDMI CEC

2016-06-18 Thread Dmitry Torokhov
Hi Hans,

On Sat, Jun 18, 2016 at 04:50:26PM +0200, Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> Hi Dmitry,
> 
> This patch series adds input support for the HDMI CEC bus through which
> remote control keys can be passed from one HDMI device to another.
> 
> This has been posted before as part of the HDMI CEC patch series. We are
> going to merge that in linux-media for 4.8, but these two patches have to
> go through linux-input.
> 
> Only the rc-cec keymap file depends on this, and we will take care of that
> dependency (we'll postpone merging that until both these input patches and
> our own CEC patches have been merged in mainline).

If it would be easier for you I am perfectly fine with these patches
going through media tree; you have my acks on them.

Thanks.

-- 
Dmitry
--
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: [PATCHv16 08/13] DocBook/media: add CEC documentation

2016-06-18 Thread Dmitry Torokhov
On Fri, Jun 17, 2016 at 08:37:38AM -0300, Mauro Carvalho Chehab wrote:
> Em Fri, 17 Jun 2016 13:09:10 +0200
> Hans Verkuil  escreveu:
> 
> > On 06/17/2016 11:50 AM, Mauro Carvalho Chehab wrote:
> > One area where I am uncertain is when remote control messages are received 
> > and
> > passed on by the framework to the RC input device.
> > 
> > Suppose the application is the one receiving a password, then that password 
> > appears
> > both in the input device and the cec device. What I think will be useful is 
> > if the
> > application can prevent the use of an input device to pass on remote 
> > control messages.
> > 
> > CEC_ADAP_S_LOG_ADDRS has a flags field that I intended for just that 
> > purpose.
> > 
> > Note that RC messages are always passed on to CEC followers even if there 
> > is an
> > input device since some RC messages have additional arguments that the rc 
> > subsystem
> > can't handle. Also I think that it is often easier to handle all messages 
> > from the
> > same CEC device instead of having to read from two devices (cec and input). 
> > I
> > actually considered removing the input support, but it turned out to be 
> > useful in
> > existing video streaming apps since they don't need to add special cec 
> > support to
> > handle remote control presses.
> > 
> > Question: is there a way for applications to get exclusive access to an 
> > input device?
> > Or can anyone always read from it?
> 
> That's a very good question. I did a quick test to check how this is
> currently protected, by running:
> 
> $ strace ir-keytable -t
> ...
> open("/dev/input/event12", O_RDONLY)= -1 EACCES (Permission denied)
> ...
> 
> It turns that the input device was created by udev with those
> permissions:
> 
> crw-rw 1 root input 13, 76 Jun 17 08:26 /dev/input/event12
> 
> Changing access to 666 allowed to run ir-keytable -t without the
> need of being root.
> 
> Yet, maybe there's a way to get exclusive access to input/event
> device, but I never needed to go that deep at the input subsystem.
> Maybe Dmitry could shed some light on that. Adding him in the loop.

EVIOCGRAB ioctl will do what you want.

Thanks.

-- 
Dmitry
--
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


dvb usb stick Hauppauge WinTV-soloHD

2016-06-18 Thread Thomas Stein

Hello.

I'm trying to get a dvb usb stick Hauppauge WinTV-soloHD running. I saw 
there is general support already in the kernel.

https://git.linuxtv.org/media_tree.git/commit/?id=1efc21701d94ed0c5b91467b042bed8b8becd5cc

I'm able to use this device for dvb-t but not dvb-t2. I'm living in 
berlin so it should work. w_scan is scanning dvb-t2 and seems

to find channels:

Scanning DVB-T2...
Scanning 7MHz frequencies...
177500: (time: 02:17.828)
184500: (time: 02:19.828)
191500: (time: 02:21.876)
198500: (time: 02:23.924)
205500: (time: 02:25.971)
212500: (time: 02:27.971)
219500: (time: 02:30.021)
226500: (time: 02:32.071)
Scanning 8MHz frequencies...
474000: (time: 02:34.120)
482000: (time: 02:36.121)
49: (time: 02:38.169)
498000: (time: 02:40.219)
506000: skipped (already known transponder)
514000: (time: 02:42.268)
522000: skipped (already known transponder)
53: (time: 02:44.318)
538000: (time: 02:46.368)
546000: (time: 02:48.417)
554000: (time: 02:50.417)
562000: (time: 02:52.467)
57: skipped (already known transponder)
578000: (time: 02:54.467)
586000: (time: 02:56.469)
594000: (time: 02:58.469)
602000: (time: 03:00.518)
61: (time: 03:02.567)
618000: skipped (already known transponder)
626000: (time: 03:04.617)
634000: (time: 03:06.617)
642000: (time: 03:08.667) signal ok:QAM_AUTO f = 642000 kHz 
I999B8C999D999T999G999Y999P0 (0:0:0)
QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0 (0:0:0) : 
updating transport_stream_id: -> (0:0:16481)
QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0 (0:0:16481) 
: updating network_id -> (0:12352:16481)
QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0 
(0:12352:16481) : updating original_network_id -> (8468:12352:16481)

updating transponder:
   (QAM_AUTO f = 642000 kHz I999B8C999D999T999G999Y999P0 
(8468:12352:16481)) 0x
to (QAM_AUTO f = 65 kHz I999B8C999D999T32G16Y999P0 
(8468:12352:16481)) 0x4004
new transponder: (QAM_AUTO f = 642000 kHz I999B8C0D0T32G16Y0P1 
(8468:12352:16497)) 0x4004

65: skipped (already known transponder)
658000: skipped (already known transponder)
666000: (time: 03:10.382)
674000: (time: 03:12.429)
682000: skipped (already known transponder)
69: (time: 03:14.476)
698000: (time: 03:16.528)
706000: skipped (already known transponder)
714000: (time: 03:18.575)
722000: (time: 03:20.623)
73: (time: 03:22.669)
738000: (time: 03:24.716)
746000: (time: 03:26.764)
754000: skipped (already known transponder)
762000: (time: 03:28.811)
77: (time: 03:30.860)
778000: skipped (already known transponder)
786000: (time: 03:32.908)
794000: (time: 03:34.953)
802000: (time: 03:36.999)
81: (time: 03:39.045)
818000: (time: 03:41.045)
826000: (time: 03:43.091)
834000: (time: 03:45.137)
842000: (time: 03:47.185)
85: (time: 03:49.231)
858000: (time: 03:51.277)

So the question is, what is going wrong? When i start vlc with dvb-t2 
channels file for berlin i get:


[7f7e0c01a0e8] ts demux error: cannot peek

Any hints appreciated.

cheers
t.

0xF5437AA0.asc
Description: application/pgp-keys


Re: [PATCH v3 1/2] media: Driver for Toshiba et8ek8 5MP sensor

2016-06-18 Thread Pali Rohár
On Saturday 18 June 2016 18:04:23 Pavel Machek wrote:
> Hi!
> 
> > > > +   .reglist = {
> > > > +   { .ptr = &mode1_poweron_mode2_16vga_2592x1968_12_07fps 
> > > > },
> > > > +   { .ptr = &mode1_16vga_2592x1968_13_12fps_dpcm10_8 },
> > > > +   { .ptr = &mode3_4vga_1296x984_29_99fps_dpcm10_8 },
> > > > +   { .ptr = &mode4_svga_864x656_29_88fps },
> > > > +   { .ptr = &mode5_vga_648x492_29_93fps },
> > > > +   { .ptr = &mode2_16vga_2592x1968_3_99fps },
> > > > +   { .ptr = &mode_648x492_5fps },
> > > > +   { .ptr = &mode3_4vga_1296x984_5fps },
> > > > +   { .ptr = &mode_4vga_1296x984_25fps_dpcm10_8 },
> > > > +   { .ptr = 0 }
> > > > +   }
> > > > +};
> > > 
> > > I'd say .ptr = NULL.
> > 
> > Anyway, this code was generated from configuration ini files and
> > perl script available from:
> > https://gitorious.org/omap3camera/camera-firmware
> > 
> > Originally in Maemo above C structure is compiled into binary file
> > and via request_firmware() loaded from userspace to kernel driver.
> > 
> > For me this sounds like a big overkill, so I included above reglist
> > code direcly into et8ek8 kernel driver to avoid request_firmware()
> > and separate userspace storage...
> 
> Yep, that makes sense, thanks for explanation. I guess that means
> that we should put a comment on top of the file explaining what is
> going on.
> 
> Best regards,
>   Pavel

Here is that original stingraytsb_v14_simple.ini file:

https://gitorious.org/omap3camera/camera-firmware?p=omap3camera:camera-firmware.git;a=tree;f=ini

Looks like are are some "non simple" stingraytsb_v14 files too, but I
have no idea which modes defines...

Sakari, any idea?
Which we should include into kernel et8ek8 kernel driver?

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH v3 1/2] media: Driver for Toshiba et8ek8 5MP sensor

2016-06-18 Thread Pavel Machek
Hi!

> > > + .reglist = {
> > > + { .ptr = &mode1_poweron_mode2_16vga_2592x1968_12_07fps },
> > > + { .ptr = &mode1_16vga_2592x1968_13_12fps_dpcm10_8 },
> > > + { .ptr = &mode3_4vga_1296x984_29_99fps_dpcm10_8 },
> > > + { .ptr = &mode4_svga_864x656_29_88fps },
> > > + { .ptr = &mode5_vga_648x492_29_93fps },
> > > + { .ptr = &mode2_16vga_2592x1968_3_99fps },
> > > + { .ptr = &mode_648x492_5fps },
> > > + { .ptr = &mode3_4vga_1296x984_5fps },
> > > + { .ptr = &mode_4vga_1296x984_25fps_dpcm10_8 },
> > > + { .ptr = 0 }
> > > + }
> > > +};
> > 
> > I'd say .ptr = NULL.
> > 
> 
> Anyway, this code was generated from configuration ini files and perl 
> script available from: https://gitorious.org/omap3camera/camera-firmware
> 
> Originally in Maemo above C structure is compiled into binary file and 
> via request_firmware() loaded from userspace to kernel driver.
> 
> For me this sounds like a big overkill, so I included above reglist code 
> direcly into et8ek8 kernel driver to avoid request_firmware() and 
> separate userspace storage...

Yep, that makes sense, thanks for explanation. I guess that means that
we should put a comment on top of the file explaining what is going
on.

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: [PATCH] userspace API definitions for auto-focus coil

2016-06-18 Thread Pavel Machek
Hi!

> > Not V4L2_CID_USER_AD5820...?
> 
> The rest of the controls have no USER as part of the macro name, so I
> wouldn't use it here either.

Ok.

> > Ok, separate header file for 2 lines seemed like a bit of overkill,
> > but why not.
> 
> That follows an existing pattern of how controls have been implemented in
> other drivers.

Ok.

> Could you merge this with the driver patch? I've dropped that from my ad5820
> branch as it does not compile.

Yes, merged patch should be in your inbox now.

Thanks,
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


[PATCHv4] support for AD5820 camera auto-focus coil

2016-06-18 Thread Pavel Machek
This adds support for AD5820 autofocus coil, found for example in
Nokia N900 smartphone.

Signed-off-by: Pavel Machek 

---
v2: simple cleanups, fix error paths, simplify probe

v3: more cleanups, remove printk, add include

v4: add uapi definitions

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 993dc50..77313a1 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -279,6 +279,13 @@ config VIDEO_ML86V7667
  To compile this driver as a module, choose M here: the
  module will be called ml86v7667.
 
+config VIDEO_AD5820
+   tristate "AD5820 lens voice coil support"
+   depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
+   ---help---
+ This is a driver for the AD5820 camera lens voice coil.
+ It is used for example in Nokia N900 (RX-51).
+
 config VIDEO_SAA7110
tristate "Philips SAA7110 video decoder"
depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 94f2c99..34434ae 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -19,6 +20,7 @@ obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o
 obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
 obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
 obj-$(CONFIG_VIDEO_SAA6752HS) += saa6752hs.o
+obj-$(CONFIG_VIDEO_AD5820)  += ad5820.o
 obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
 obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
 obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o
diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
new file mode 100644
index 000..a1be956
--- /dev/null
+++ b/drivers/media/i2c/ad5820.c
@@ -0,0 +1,430 @@
+/*
+ * drivers/media/i2c/ad5820.c
+ *
+ * AD5820 DAC driver for camera voice coil focus.
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Copyright (C) 2007 Texas Instruments
+ * Copyright (C) 2016 Pavel Machek 
+ *
+ * Contact: Tuukka Toivonen 
+ * Sakari Ailus 
+ *
+ * Based on af_d88.c by Texas Instruments.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#define AD5820_NAME"ad5820"
+
+/* Register definitions */
+#define AD5820_POWER_DOWN  (1 << 15)
+#define AD5820_DAC_SHIFT   4
+#define AD5820_RAMP_MODE_LINEAR(0 << 3)
+#define AD5820_RAMP_MODE_64_16 (1 << 3)
+
+#define CODE_TO_RAMP_US(s) ((s) == 0 ? 0 : (1 << ((s) - 1)) * 50)
+#define RAMP_US_TO_CODE(c) fls(((c) + ((c)>>1)) / 50)
+
+#define to_ad5820_device(sd)   container_of(sd, struct ad5820_device, subdev)
+
+struct ad5820_device {
+   struct v4l2_subdev subdev;
+   struct ad5820_platform_data *platform_data;
+   struct regulator *vana;
+
+   struct v4l2_ctrl_handler ctrls;
+   u32 focus_absolute;
+   u32 focus_ramp_time;
+   u32 focus_ramp_mode;
+
+   struct mutex power_lock;
+   int power_count;
+
+   int standby : 1;
+};
+
+static int ad5820_write(struct ad5820_device *coil, u16 data)
+{
+   struct i2c_client *client = v4l2_get_subdevdata(&coil->subdev);
+   struct i2c_msg msg;
+   int r;
+
+   if (!client->adapter)
+   return -ENODEV;
+
+   data = cpu_to_be16(data);
+   msg.addr  = client->addr;
+   msg.flags = 0;
+   msg.len   = 2;
+   msg.buf   = (u8 *)&data;
+
+   r = i2c_transfer(client->adapter, &msg, 1);
+   if (r < 0) {
+   dev_err(&client->dev, "write failed, error %d\n", r);
+   return r;
+   }
+
+   return 0;
+}
+
+/*
+ * Calculate status word and write it to the device based on current
+ * values of V4L2 controls. It is assumed that the stored V4L2 control
+ * values are properly limited and rounded.
+ */
+static int ad5820_update_hw(struct ad5820_device *coil)
+{
+   u16 status;
+
+   status = RAMP_US_TO_CODE(coil->focus_ramp_time);
+   status |= coil->focus_ramp_mode
+   ? AD5820_RAMP_MODE_64_16 : AD5820_RAMP_MODE_LINEAR;
+   status |= coil->focus_absolute << AD5820_DAC_SHIFT;
+
+   if (coil->standby)
+   status |= AD5820_POWER_DOWN;
+
+   return ad5820_write(coil, status);
+}
+
+/*
+ * Power handling
+ */
+static int ad5820_power_off(struct ad5820_device *coil, int standby)
+{
+   int ret = 0, ret2;
+
+   /*
+* Go to standby first as real power off my be denied by the hardware
+* (single power line control for both coil and sensor).
+*/
+   if (standby) {
+   coil->standby = 1;
+   ret = ad5820_update_hw(coil);

Re: [PATCH v3 1/2] media: Driver for Toshiba et8ek8 5MP sensor

2016-06-18 Thread Pali Rohár
On Saturday 18 June 2016 17:22:59 Pavel Machek wrote:
> > +/*
> > + *
> > + * Stingray sensor mode settings for Scooby
> > + *
> > + *
> > + */
> 
> I'd fix it to normal comment style... and possibly remove it. Can you
> understand what it says?
> 
> > +   },
> > +   .regs = {
> > +   { ET8EK8_REG_8BIT, 0x1239, 0x4F },  /**/
> > +   { ET8EK8_REG_8BIT, 0x1238, 0x02 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x123B, 0x70 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x123A, 0x05 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x121B, 0x63 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x1220, 0x85 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x1221, 0x00 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x1222, 0x58 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x1223, 0x00 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x121D, 0x63 },  /**/
> > +   { ET8EK8_REG_8BIT, 0x125D, 0x83 },  /**/
> > +   { ET8EK8_REG_TERM, 0, 0}
> > +   }
> 
> I'd remove the empty comments...
> 
> > +struct et8ek8_meta_reglist meta_reglist = {
> > +   .version = "V14 03-June-2008",
> 
> Do we need the version?
> 
> > +   .reglist = {
> > +   { .ptr = &mode1_poweron_mode2_16vga_2592x1968_12_07fps },
> > +   { .ptr = &mode1_16vga_2592x1968_13_12fps_dpcm10_8 },
> > +   { .ptr = &mode3_4vga_1296x984_29_99fps_dpcm10_8 },
> > +   { .ptr = &mode4_svga_864x656_29_88fps },
> > +   { .ptr = &mode5_vga_648x492_29_93fps },
> > +   { .ptr = &mode2_16vga_2592x1968_3_99fps },
> > +   { .ptr = &mode_648x492_5fps },
> > +   { .ptr = &mode3_4vga_1296x984_5fps },
> > +   { .ptr = &mode_4vga_1296x984_25fps_dpcm10_8 },
> > +   { .ptr = 0 }
> > +   }
> > +};
> 
> I'd say .ptr = NULL.
> 

Anyway, this code was generated from configuration ini files and perl 
script available from: https://gitorious.org/omap3camera/camera-firmware

Originally in Maemo above C structure is compiled into binary file and 
via request_firmware() loaded from userspace to kernel driver.

For me this sounds like a big overkill, so I included above reglist code 
direcly into et8ek8 kernel driver to avoid request_firmware() and 
separate userspace storage...

And for smia-sensor (front webcam) in that gitorious repository is also 
reglist structure. It is not needed? Can somebody investigate why it is 
not needed?

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH v3 1/2] media: Driver for Toshiba et8ek8 5MP sensor

2016-06-18 Thread Pavel Machek
Hi!

> The sensor is found in Nokia N900 main camera
> 
> Signed-off-by: Ivaylo Dimitrov 

> +/*
> + *
> + * Register access helpers
> + *
> + */
> +
> +/*
> + * Read a 8/16/32-bit i2c register.  The value is returned in 'val'.
> + * Returns zero if successful, or non-zero otherwise.
> + */

Turn the first comment into "normal" comment style, and merge the two
comments?


> +static int et8ek8_i2c_read_reg(struct i2c_client *client, u16 data_length,
> +u16 reg, u32 *val)
> +{
> + int r;
> + struct i2c_msg msg[1];

Uff. That's a bit non-traditional. Use plain "struct i2c_msg msg;" if
you have just one?

> + /* Now we start writing ... */
> + r = et8ek8_i2c_buffered_write_regs(client, regs, cnt);
> +
> + /* ... and then check that everything was OK */
> + if (r < 0) {
> + dev_err(&client->dev, "i2c transfer error !!!\n");
> + return r;

I'd reduce number of "!"s in the message.

> + /*
> +  * If we ran into a sleep statement when going through
> +  * the list, this is where we snooze for the required time
> +  */
> + if (next->type == ET8EK8_REG_DELAY) {
> + set_current_state(TASK_UNINTERRUPTIBLE);
> + schedule_timeout(msecs_to_jiffies(next->val));

Open-coded set_current_state(), and no restore, makes me
suspicious. Can msleep() be used here?

> +{
> + int r;
> + struct i2c_msg msg[1];

I'd avoid array for single entry. (You'll need to make it &msg below,
but...)

> +/*
> + * Return time of one row in microseconds, .8 fixed point format.
> + * If the sensor is not set to any mode, return zero.
> + */

typedef int fixedfp; then use it where .8 fixed point is used?

> +static int et8ek8_set_test_pattern(struct et8ek8_sensor *sensor, s32 mode)
> +{
...
> + rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x111B,
> + tp_mode << 4);
> + if (rval)
> + goto out;
> +
> + rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1121,
> + cbh_mode << 7);
> + if (rval)
> + goto out;
> +
> + rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1124,
> + cbv_mode << 7);
> + if (rval)
> + goto out;
> +
> + rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x112C, din_sw);
> + if (rval)
> + goto out;
> +
> + rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1420, r1420);
> +
> +out:
> + return rval;
> +}

I'd avoid gotos when all it does is return.

> +/*
> + *
> + * Stingray sensor mode settings for Scooby
> + *
> + *
> + */

I'd fix it to normal comment style... and possibly remove it. Can you
understand what it says?

> + },
> + .regs = {
> + { ET8EK8_REG_8BIT, 0x1239, 0x4F },  /**/
> + { ET8EK8_REG_8BIT, 0x1238, 0x02 },  /**/
> + { ET8EK8_REG_8BIT, 0x123B, 0x70 },  /**/
> + { ET8EK8_REG_8BIT, 0x123A, 0x05 },  /**/
> + { ET8EK8_REG_8BIT, 0x121B, 0x63 },  /**/
> + { ET8EK8_REG_8BIT, 0x1220, 0x85 },  /**/
> + { ET8EK8_REG_8BIT, 0x1221, 0x00 },  /**/
> + { ET8EK8_REG_8BIT, 0x1222, 0x58 },  /**/
> + { ET8EK8_REG_8BIT, 0x1223, 0x00 },  /**/
> + { ET8EK8_REG_8BIT, 0x121D, 0x63 },  /**/
> + { ET8EK8_REG_8BIT, 0x125D, 0x83 },  /**/
> + { ET8EK8_REG_TERM, 0, 0}
> + }

I'd remove the empty comments...

> +struct et8ek8_meta_reglist meta_reglist = {
> + .version = "V14 03-June-2008",

Do we need the version?

> + .reglist = {
> + { .ptr = &mode1_poweron_mode2_16vga_2592x1968_12_07fps },
> + { .ptr = &mode1_16vga_2592x1968_13_12fps_dpcm10_8 },
> + { .ptr = &mode3_4vga_1296x984_29_99fps_dpcm10_8 },
> + { .ptr = &mode4_svga_864x656_29_88fps },
> + { .ptr = &mode5_vga_648x492_29_93fps },
> + { .ptr = &mode2_16vga_2592x1968_3_99fps },
> + { .ptr = &mode_648x492_5fps },
> + { .ptr = &mode3_4vga_1296x984_5fps },
> + { .ptr = &mode_4vga_1296x984_25fps_dpcm10_8 },
> + { .ptr = 0 }
> + }
> +};

I'd say .ptr = NULL.

> +struct v4l2_mbus_framefmt;
> +struct v4l2_subdev_pad_mbus_code_enum;
> +
> +struct et8ek8_mode {
> + /* Physical sensor resolution and current image window */
> + __u16 sensor_width;
> + __u16 sensor_height;
> + __u16 sensor_window_origin_x;
> + __u16 sensor_window_origin_y;
> + __u16 sensor_window_width;
> + __u16 sensor_window_height;

If this can not be included from userland, convert __uX -> uX.

> +#define ET8EK8_MAX_LEN   32
> +struct et8ek8

[PATCH] media: coda: Fix probe() if reset controller is missing

2016-06-18 Thread Alexander Shiyan
Commit 39b4da71ca334354f30941067f214ea2f2b92f3e (reset: use ENOTSUPP
instead of ENOSYS) changed return value for reset controller if it missing.
This patch changes the CODA driver to handle this value.

Signed-off-by: Alexander Shiyan 
---
 drivers/media/platform/coda/coda-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 133ab9f..098653d 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2226,7 +2226,7 @@ static int coda_probe(struct platform_device *pdev)
dev->rstc = devm_reset_control_get_optional(&pdev->dev, NULL);
if (IS_ERR(dev->rstc)) {
ret = PTR_ERR(dev->rstc);
-   if (ret == -ENOENT || ret == -ENOSYS) {
+   if (ret == -ENOENT || ret == -ENOTSUPP) {
dev->rstc = NULL;
} else {
dev_err(&pdev->dev, "failed get reset control: %d\n",
-- 
2.4.9

--
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


[GIT PULL FOR v4.8 v5] Add HDMI CEC framework

2016-06-18 Thread Hans Verkuil
Hi Mauro,

Here is the pull request for the HDMI CEC framework. The code of this pull
request is identical to the v18 patch series.

Regards,

Hans

The following changes since commit 0db5c79989de2c68d5abb7ba891bfdb3cd3b7e05:

  [media] media-devnode.h: Fix documentation (2016-06-16 08:14:56 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git cec18

for you to fetch changes up to b1704235644a511ffeabfb0bc181f01360d04370:

  vivid: add CEC emulation (2016-06-18 16:38:41 +0200)


Hans Verkuil (13):
  input.h: add BUS_CEC type
  cec.txt: add CEC framework documentation
  DocBook/media: add CEC documentation
  cec-edid: add module for EDID CEC helper functions
  cec.h: add cec header
  cec-funcs.h: static inlines to pack/unpack CEC messages
  cec: add HDMI CEC framework
  cec/TODO: add TODO file so we know why this is still in staging
  cec: add compat32 ioctl support
  cec: adv7604: add cec support.
  cec: adv7842: add cec support
  cec: adv7511: add cec support.
  vivid: add CEC emulation

Kamil Debski (2):
  rc: Add HDMI CEC protocol handling
  cec: s5p-cec: Add s5p-cec driver

 Documentation/DocBook/device-drivers.tmpl|3 +
 Documentation/DocBook/media/Makefile |2 +
 Documentation/DocBook/media/v4l/biblio.xml   |   10 +
 Documentation/DocBook/media/v4l/cec-api.xml  |   75 ++
 Documentation/DocBook/media/v4l/cec-func-close.xml   |   64 ++
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml   |   78 ++
 Documentation/DocBook/media/v4l/cec-func-open.xml|  104 ++
 Documentation/DocBook/media/v4l/cec-func-poll.xml|   94 ++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml  |  151 +++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml |  329 ++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |   86 ++
 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml  |  195 
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml   |  255 +
 Documentation/DocBook/media/v4l/cec-ioc-receive.xml  |  265 +
 Documentation/DocBook/media_api.tmpl |6 +-
 Documentation/cec.txt|  267 +
 Documentation/devicetree/bindings/media/s5p-cec.txt  |   31 +
 Documentation/video4linux/vivid.txt  |   36 +-
 MAINTAINERS  |   23 +
 drivers/media/Kconfig|3 +
 drivers/media/Makefile   |2 +
 drivers/media/cec-edid.c |  139 +++
 drivers/media/i2c/Kconfig|   24 +
 drivers/media/i2c/adv7511.c  |  401 ++-
 drivers/media/i2c/adv7604.c  |  332 +-
 drivers/media/i2c/adv7842.c  |  368 +--
 drivers/media/platform/Kconfig   |   10 +
 drivers/media/platform/Makefile  |1 +
 drivers/media/platform/s5p-cec/Makefile  |2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h |   38 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c |  209 
 drivers/media/platform/s5p-cec/regs-cec.h|   96 ++
 drivers/media/platform/s5p-cec/s5p_cec.c |  295 ++
 drivers/media/platform/s5p-cec/s5p_cec.h |   76 ++
 drivers/media/platform/vivid/Kconfig |8 +
 drivers/media/platform/vivid/Makefile|4 +
 drivers/media/platform/vivid/vivid-cec.c |  255 +
 drivers/media/platform/vivid/vivid-cec.h |   33 +
 drivers/media/platform/vivid/vivid-core.c|  118 ++-
 drivers/media/platform/vivid/vivid-core.h|   27 +
 drivers/media/platform/vivid/vivid-kthread-cap.c |   13 +
 drivers/media/platform/vivid/vivid-vid-cap.c |   23 +-
 drivers/media/platform/vivid/vivid-vid-common.c  |7 +
 drivers/media/rc/rc-main.c   |1 +
 drivers/staging/media/Kconfig|2 +
 drivers/staging/media/Makefile   |1 +
 drivers/staging/media/cec/Kconfig|8 +
 drivers/staging/media/cec/Makefile   |1 +
 drivers/staging/media/cec/TODO   |   23 +
 drivers/staging/media/cec/cec.c  | 2512 

 fs/compat_ioctl.c|   12 +
 

[PATCHv18 15/15] vivid: add CEC emulation

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

The vivid driver has been extended to provide CEC adapters for the HDMI
input and HDMI outputs in order to test CEC applications.

This CEC emulation is faithful to the CEC timings (i.e., it all at a
snail's pace).

Signed-off-by: Hans Verkuil 
---
 Documentation/video4linux/vivid.txt  |  36 +++-
 drivers/media/platform/vivid/Kconfig |   8 +
 drivers/media/platform/vivid/Makefile|   4 +
 drivers/media/platform/vivid/vivid-cec.c | 255 +++
 drivers/media/platform/vivid/vivid-cec.h |  33 +++
 drivers/media/platform/vivid/vivid-core.c| 118 ++-
 drivers/media/platform/vivid/vivid-core.h|  27 +++
 drivers/media/platform/vivid/vivid-kthread-cap.c |  13 ++
 drivers/media/platform/vivid/vivid-vid-cap.c |  23 +-
 drivers/media/platform/vivid/vivid-vid-common.c  |   7 +
 10 files changed, 509 insertions(+), 15 deletions(-)
 create mode 100644 drivers/media/platform/vivid/vivid-cec.c
 create mode 100644 drivers/media/platform/vivid/vivid-cec.h

diff --git a/Documentation/video4linux/vivid.txt 
b/Documentation/video4linux/vivid.txt
index 8da5d2a..1b26519 100644
--- a/Documentation/video4linux/vivid.txt
+++ b/Documentation/video4linux/vivid.txt
@@ -74,7 +74,8 @@ Section 11: Cropping, Composing, Scaling
 Section 12: Formats
 Section 13: Capture Overlay
 Section 14: Output Overlay
-Section 15: Some Future Improvements
+Section 15: CEC (Consumer Electronics Control)
+Section 16: Some Future Improvements
 
 
 Section 1: Configuring the driver
@@ -364,7 +365,11 @@ For HDMI inputs it is possible to set the EDID. By default 
a simple EDID
 is provided. You can only set the EDID for HDMI inputs. Internally, however,
 the EDID is shared between all HDMI inputs.
 
-No interpretation is done of the EDID data.
+No interpretation is done of the EDID data with the exception of the
+physical address. See the CEC section for more details.
+
+There is a maximum of 15 HDMI inputs (if there are more, then they will be
+reduced to 15) since that's the limitation of the EDID physical address.
 
 
 Section 3: Video Output
@@ -409,6 +414,9 @@ standard, and for all others a 1:1 pixel aspect ratio is 
returned.
 
 An HDMI output has a valid EDID which can be obtained through VIDIOC_G_EDID.
 
+There is a maximum of 15 HDMI outputs (if there are more, then they will be
+reduced to 15) since that's the limitation of the EDID physical address. See
+also the CEC section for more details.
 
 Section 4: VBI Capture
 --
@@ -1108,7 +1116,26 @@ capabilities will slow down the video loop considerably 
as a lot of checks have
 to be done per pixel.
 
 
-Section 15: Some Future Improvements
+Section 15: CEC (Consumer Electronics Control)
+--
+
+If there are HDMI inputs then a CEC adapter will be created that has
+the same number of input ports. This is the equivalent of e.g. a TV that
+has that number of inputs. Each HDMI output will also create a
+CEC adapter that is hooked up to the corresponding input port, or (if there
+are more outputs than inputs) is not hooked up at all. In other words,
+this is the equivalent of hooking up each output device to an input port of
+the TV. Any remaining output devices remain unconnected.
+
+The EDID that each output reads reports a unique CEC physical address that is
+based on the physical address of the EDID of the input. So if the EDID of the
+receiver has physical address A.B.0.0, then each output will see an EDID
+containing physical address A.B.C.0 where C is 1 to the number of inputs. If
+there are more outputs than inputs then the remaining outputs have a CEC 
adapter
+that is disabled and reports an invalid physical address.
+
+
+Section 16: Some Future Improvements
 
 
 Just as a reminder and in no particular order:
@@ -1121,8 +1148,6 @@ Just as a reminder and in no particular order:
 - Fix sequence/field numbering when looping of video with alternate fields
 - Add support for V4L2_CID_BG_COLOR for video outputs
 - Add ARGB888 overlay support: better testing of the alpha channel
-- Add custom DV timings support
-- Add support for V4L2_DV_FL_REDUCED_FPS
 - Improve pixel aspect support in the tpg code by passing a real v4l2_fract
 - Use per-queue locks and/or per-device locks to improve throughput
 - Add support to loop from a specific output to a specific input across
@@ -1133,3 +1158,4 @@ Just as a reminder and in no particular order:
 - Make a thread for the RDS generation, that would help in particular for the
   "Controls" RDS Rx I/O Mode as the read-only RDS controls could be updated
   in real-time.
+- Changing the EDID should cause hotplug detect emulation to happen.
diff --git a/drivers/media/platform/vivid/Kconfig 
b/drivers/media/platform/vivid/Kconfig
index f535f57..8e6918c 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ b/drivers/media/platform/vivid/Kconfig
@@ -6,6 +6,7 @@ co

[PATCHv18 02/15] rc: Add HDMI CEC protocol handling

2016-06-18 Thread Hans Verkuil
From: Kamil Debski 

Add handling of remote control events coming from the HDMI CEC bus
and the new protocol required for that.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 drivers/media/rc/rc-main.c | 1 +
 include/media/rc-map.h | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 7dfc7c2..c717eaf 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -804,6 +804,7 @@ static const struct {
{ RC_BIT_SHARP, "sharp","ir-sharp-decoder"  },
{ RC_BIT_MCE_KBD,   "mce_kbd",  "ir-mce_kbd-decoder"},
{ RC_BIT_XMP,   "xmp",  "ir-xmp-decoder"},
+   { RC_BIT_CEC,   "cec",  NULL},
 };
 
 /**
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 7844e98..6e6557d 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -31,6 +31,7 @@ enum rc_type {
RC_TYPE_RC6_MCE = 16,   /* MCE (Philips RC6-6A-32 subtype) 
protocol */
RC_TYPE_SHARP   = 17,   /* Sharp protocol */
RC_TYPE_XMP = 18,   /* XMP protocol */
+   RC_TYPE_CEC = 19,   /* CEC protocol */
 };
 
 #define RC_BIT_NONE0ULL
@@ -53,6 +54,7 @@ enum rc_type {
 #define RC_BIT_RC6_MCE (1ULL << RC_TYPE_RC6_MCE)
 #define RC_BIT_SHARP   (1ULL << RC_TYPE_SHARP)
 #define RC_BIT_XMP (1ULL << RC_TYPE_XMP)
+#define RC_BIT_CEC (1ULL << RC_TYPE_CEC)
 
 #define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \
 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
@@ -61,7 +63,7 @@ enum rc_type {
 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \
 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \
-RC_BIT_XMP)
+RC_BIT_XMP | RC_BIT_CEC)
 
 
 #define RC_SCANCODE_UNKNOWN(x) (x)
@@ -123,6 +125,7 @@ void rc_map_init(void);
 #define RC_MAP_BEHOLD_COLUMBUS   "rc-behold-columbus"
 #define RC_MAP_BEHOLD"rc-behold"
 #define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old"
+#define RC_MAP_CEC   "rc-cec"
 #define RC_MAP_CINERGY_1400  "rc-cinergy-1400"
 #define RC_MAP_CINERGY   "rc-cinergy"
 #define RC_MAP_DELOCK_61959  "rc-delock-61959"
-- 
2.8.1

--
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


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

2016-06-18 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 +++
 MAINTAINERS|   7 +
 drivers/media/platform/Kconfig |  10 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/s5p-cec/Makefile|   2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h   |  38 +++
 .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c   | 209 +++
 drivers/media/platform/s5p-cec/regs-cec.h  |  96 +++
 drivers/media/platform/s5p-cec/s5p_cec.c   | 295 +
 drivers/media/platform/s5p-cec/s5p_cec.h   |  76 ++
 10 files changed, 765 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 = <&clock CLK_HDMI_CEC>;
+   clock-names = "hdmicec";
+   samsung,syscon-phandle = <&pmu_system_controller>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&hdmi_cec>;
+   status = "okay";
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index c424596..4ffdc36 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1642,6 +1642,13 @@ L:   linux-media@vger.kernel.org
 S: Maintained
 F: drivers/media/platform/s5p-tv/
 
+ARM/SAMSUNG S5P SERIES HDMI CEC SUBSYSTEM SUPPORT
+M: Kyungmin Park 
+L: linux-arm-ker...@lists.infradead.org
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/platform/s5p-cec/
+
 ARM/SAMSUNG S5P SERIES JPEG CODEC SUPPORT
 M: Andrzej Pietrasiewicz 
 M: Jacek Anaszewski 
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 382f393..5677175 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -108,6 +108,16 @@ 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 && MEDIA_CEC && (PLAT_S5P || ARCH_EXYNOS || 
COMPILE_TEST)
+   ---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"
 source "drivers/media/platform/rcar-vin/Kconfig"
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 99cf315..9a2fe95 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)   += 
m2m-deinterlace.o
 
 obj-$(CONFIG_VIDEO_S3C_CAMIF)  += s3c-camif/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/
+obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC)+= s5p-cec/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG)   += s5p-jpeg/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)+= s5p-mfc/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
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
@@ 

[PATCHv18 03/15] cec.txt: add CEC framework documentation

2016-06-18 Thread Hans Verkuil
From: 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 | 267 ++
 1 file changed, 267 insertions(+)
 create mode 100644 Documentation/cec.txt

diff --git a/Documentation/cec.txt b/Documentation/cec.txt
new file mode 100644
index 000..75155fe
--- /dev/null
+++ b/Documentation/cec.txt
@@ -0,0 +1,267 @@
+CEC Kernel Support
+==
+
+The CEC framework provides a unified kernel interface for use with HDMI CEC
+hardware. It is designed to handle a multiple types of hardware (receivers,
+transmitters, USB dongles). The framework also gives the option to decide
+what to do in the kernel driver and what should be handled by userspace
+applications. In addition it integrates the remote control passthrough
+feature into the kernel's remote control framework.
+
+
+The CEC Protocol
+
+
+The CEC protocol enables consumer electronic devices to communicate with each
+other through the HDMI connection. The protocol uses logical addresses in the
+communication. The logical address is strictly connected with the functionality
+provided by the device. The TV acting as the communication hub is always
+assigned address 0. The physical address is determined by the physical
+connection between devices.
+
+The CEC framework described here is up to date with the CEC 2.0 specification.
+It is documented in the HDMI 1.4 specification with the new 2.0 bits documented
+in the HDMI 2.0 specification. But for most of the features the freely 
available
+HDMI 1.3a specification is sufficient:
+
+http://www.microprocessor.org/HDMISpecification13a.pdf
+
+
+The Kernel Interface
+
+
+CEC Adapter
+---
+
+The struct cec_adapter represents the CEC adapter hardware. It is created by
+calling cec_allocate_adapter() and deleted by calling cec_delete_adapter():
+
+struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
+  void *priv, const char *name, u32 caps, u8 available_las,
+  struct device *parent);
+void cec_delete_adapter(struct cec_adapter *adap);
+
+To create an adapter you need to pass the following information:
+
+ops: adapter operations which are called by the CEC framework and that you
+have to implement.
+
+priv: will be stored in adap->priv and can be used by the adapter ops.
+
+name: the name of the CEC adapter. Note: this name will be copied.
+
+caps: capabilities of the CEC adapter. These capabilities determine the
+   capabilities of the hardware and which parts are to be handled
+   by userspace and which parts are handled by kernelspace. The
+   capabilities are returned by CEC_ADAP_G_CAPS.
+
+available_las: the number of simultaneous logical addresses that this
+   adapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS.
+
+parent: the parent device.
+
+
+To register the /dev/cecX device node and the remote control device (if
+CEC_CAP_RC is set) you call:
+
+int cec_register_adapter(struct cec_adapter *adap);
+
+To unregister the devices call:
+
+void cec_unregister_adapter(struct cec_adapter *adap);
+
+Note: if cec_register_adapter() fails, then call cec_delete_adapter() to
+clean up. But if cec_register_adapter() succeeded, then only call
+cec_unregister_adapter() to clean up, never cec_delete_adapter(). The
+unregister function will delete the adapter automatically once the last user
+of that /dev/cecX device has closed its file handle.
+
+
+Implementing the Low-Level CEC Adapter
+--
+
+The following low-level adapter operations have to be implemented in
+your driver:
+
+struct cec_adap_ops {
+   /* Low-level callbacks */
+   int (*adap_enable)(struct cec_adapter *adap, bool enable);
+   int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable);
+   int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr);
+   int (*adap_transmit)(struct cec_adapter *adap, u8 attempts,
+u32 signal_free_time, struct cec_msg *msg);
+   void (*adap_log_status)(struct cec_adapter *adap);
+
+   /* High-level callbacks */
+   ...
+};
+
+The three low-level ops deal with various aspects of controlling the CEC 
adapter
+hardware:
+
+
+To enable/disable the hardware:
+
+   int (*adap_enable)(struct cec_adapter *adap, bool enable);
+
+This callback enables or disables the CEC hardware. Enabling the CEC hardware
+means powering it up in a state where no logical addresses are claimed. This
+op assumes that the physical address (adap->phys_addr) is valid when enable is
+true and will not change while the CEC adapter remains enabled. The initial
+state of the CEC adapter after calling cec_allocate_adapter() is disabled.
+
+Note that adap_enable must return 0 if enable is false.
+

[PATCHv18 06/15] cec.h: add cec header

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

This header contains the CEC public API. Since the CEC framework will
initially be part of staging this header is kept out of include/uapi for
the time being until the CEC framework will be moved out of staging.

Signed-off-by: Hans Verkuil 
---
 include/linux/cec.h | 987 
 1 file changed, 987 insertions(+)
 create mode 100644 include/linux/cec.h

diff --git a/include/linux/cec.h b/include/linux/cec.h
new file mode 100644
index 000..0fd0e31
--- /dev/null
+++ b/include/linux/cec.h
@@ -0,0 +1,987 @@
+/*
+ * cec - HDMI Consumer Electronics Control public header
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _CEC_UAPI_H
+#define _CEC_UAPI_H
+
+#include 
+
+#define CEC_MAX_MSG_SIZE   16
+
+/**
+ * struct cec_msg - CEC message structure.
+ * @ts:Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by 
the
+ * driver. It is set when the message transmission has finished
+ * and it is set when a message was received.
+ * @len:   Length in bytes of the message.
+ * @timeout:   The timeout (in ms) that is used to timeout CEC_RECEIVE.
+ * Set to 0 if you want to wait forever. This timeout can also be
+ * used with CEC_TRANSMIT as the timeout for waiting for a reply.
+ * If 0, then it will use a 1 second timeout instead of waiting
+ * forever as is done with CEC_RECEIVE.
+ * @sequence:  The framework assigns a sequence number to messages that are
+ * sent. This can be used to track replies to previously sent
+ * messages.
+ * @flags: Set to 0.
+ * @rx_status: The message receive status bits. Set by the driver.
+ * @tx_status: The message transmit status bits. Set by the driver.
+ * @msg:   The message payload.
+ * @reply: This field is ignored with CEC_RECEIVE and is only used by
+ * CEC_TRANSMIT. If non-zero, then wait for a reply with this
+ * opcode. Set to CEC_MSG_FEATURE_ABORT if you want to wait for
+ * a possible ABORT reply. If there was an error when sending the
+ * msg or FeatureAbort was returned, then reply is set to 0.
+ * If reply is non-zero upon return, then len/msg are set to
+ * the received message.
+ * If reply is zero upon return and status has the
+ * CEC_TX_STATUS_FEATURE_ABORT bit set, then len/msg are set to
+ * the received feature abort message.
+ * If reply is zero upon return and status has the
+ * CEC_TX_STATUS_MAX_RETRIES bit set, then no reply was seen at
+ * all. If reply is non-zero for CEC_TRANSMIT and the message is a
+ * broadcast, then -EINVAL is returned.
+ * if reply is non-zero, then timeout is set to 1000 (the required
+ * maximum response time).
+ * @tx_arb_lost_cnt: The number of 'Arbitration Lost' events. Set by the 
driver.
+ * @tx_nack_cnt: The number of 'Not Acknowledged' events. Set by the driver.
+ * @tx_low_drive_cnt: The number of 'Low Drive Detected' events. Set by the
+ * driver.
+ * @tx_error_cnt: The number of 'Error' events. Set by the driver.
+ */
+struct cec_msg {
+   __u64 ts;
+   __u32 len;
+   __u32 timeout;
+   __u32 sequence;
+   __u32 flags;
+   __u8 rx_status;
+   __u8 tx_status;
+   __u8 msg[CEC_MAX_MSG_SIZE];
+   __u8 reply;
+   __u8 tx_arb_lost_cnt;
+   __u8 tx_nack_cnt;
+   __u8 tx_low_drive_cnt;
+   __u8 tx_error_cnt;
+};
+
+/**
+ * cec_msg_initiator - return the initiator's logical address.
+ * @msg:   the message structure
+ */
+static inline __u8 cec_msg_initiator(const struct cec_msg *msg)
+{
+   return msg->msg[0] >> 4;
+}
+
+/**
+ * cec_msg_destination - return the destination's logical address.
+ * @msg:   the message structure
+ */
+static inline __u8 cec_msg_destination(const struct cec_msg *msg)
+{
+   return msg->msg[0] & 0xf;
+}
+
+/**
+ * cec_msg_opcode - return the opcode of the message, -1 for poll
+ * @msg:   the message structure
+ */
+static inline int cec_msg_opcode(const struct cec_msg *msg)
+{
+   return msg->le

[PATCHv18 10/15] cec: add compat32 ioctl support

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

The CEC ioctls didn't have compat32 support, so they returned -ENOTTY
when used in a 32 bit application on a 64 bit kernel.

Since all the CEC ioctls are 32-bit compatible adding support for this
API is trivial.

Signed-off-by: Hans Verkuil 
---
 fs/compat_ioctl.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index bd01b92..c1e9f29 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "internal.h"
 
@@ -1377,6 +1378,17 @@ COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
 COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
 COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
 COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
+/* cec */
+COMPATIBLE_IOCTL(CEC_ADAP_G_CAPS)
+COMPATIBLE_IOCTL(CEC_ADAP_G_LOG_ADDRS)
+COMPATIBLE_IOCTL(CEC_ADAP_S_LOG_ADDRS)
+COMPATIBLE_IOCTL(CEC_ADAP_G_PHYS_ADDR)
+COMPATIBLE_IOCTL(CEC_ADAP_S_PHYS_ADDR)
+COMPATIBLE_IOCTL(CEC_G_MODE)
+COMPATIBLE_IOCTL(CEC_S_MODE)
+COMPATIBLE_IOCTL(CEC_TRANSMIT)
+COMPATIBLE_IOCTL(CEC_RECEIVE)
+COMPATIBLE_IOCTL(CEC_DQEVENT)
 
 /* joystick */
 COMPATIBLE_IOCTL(JSIOCGVERSION)
-- 
2.8.1

--
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


[PATCHv18 09/15] cec/TODO: add TODO file so we know why this is still in staging

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

Explain why cec.c is still in staging.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/cec/TODO | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 drivers/staging/media/cec/TODO

diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
new file mode 100644
index 000..e3c384a
--- /dev/null
+++ b/drivers/staging/media/cec/TODO
@@ -0,0 +1,23 @@
+The reason why cec.c is still in staging is that I would like
+to have a bit more confidence in the uABI. The kABI is fine,
+no problem there, but I would like to let the public API mature
+a bit.
+
+Once I'm confident that I didn't miss anything then the cec.c source
+can move to drivers/media and the linux/cec.h and linux/cec-funcs.h
+headers can move to uapi/linux and added to uapi/linux/Kbuild to make
+them public.
+
+Hopefully this will happen later in 2016.
+
+Other TODOs:
+
+- Add a flag to inhibit passing CEC RC messages to the rc subsystem.
+  Applications should be able to choose this when calling S_LOG_ADDRS.
+- Convert cec.txt to sphinx.
+- If the reply field of cec_msg is set then when the reply arrives it
+  is only sent to the filehandle that transmitted the original message
+  and not to any followers. Should this behavior change or perhaps
+  controlled through a cec_msg flag?
+
+Hans Verkuil 
-- 
2.8.1

--
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


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

2016-06-18 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/Kconfig   |   8 +
 drivers/media/i2c/adv7511.c | 401 +++-
 include/media/i2c/adv7511.h |   6 +-
 3 files changed, 402 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 0179d10..ce9006e 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -463,6 +463,7 @@ config VIDEO_ADV7511
tristate "Analog Devices ADV7511 encoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7511 video encoder.
 
@@ -471,6 +472,13 @@ config VIDEO_ADV7511
  To compile this driver as a module, choose M here: the
  module will be called adv7511.
 
+config VIDEO_ADV7511_CEC
+   bool "Enable Analog Devices ADV7511 CEC support"
+   depends on VIDEO_ADV7511 && MEDIA_CEC
+   ---help---
+ When selected the adv7511 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_AD9389B
tristate "Analog Devices AD9389B encoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 39271c3..39d409f 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,20 @@ 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;
+   struct cec_adapter *cec_adap;
+   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;
@@ -227,7 +238,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;
@@ -242,6 +253,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);
@@ -425,16 +464,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 

[PATCHv18 07/15] cec-funcs.h: static inlines to pack/unpack CEC messages

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

This public header contains static inlines to pack and unpack CEC
messages. It is for use in both the kernel and in userspace.

Since the CEC framework will initially be in staging this header is
not yet in include/uapi. Once the framework is moved out of staging
this header should be moved to uapi at the same time.

Signed-off-by: Hans Verkuil 
---
 include/linux/cec-funcs.h | 1875 +
 1 file changed, 1875 insertions(+)
 create mode 100644 include/linux/cec-funcs.h

diff --git a/include/linux/cec-funcs.h b/include/linux/cec-funcs.h
new file mode 100644
index 000..155f6b9
--- /dev/null
+++ b/include/linux/cec-funcs.h
@@ -0,0 +1,1875 @@
+/*
+ * cec - HDMI Consumer Electronics Control message functions
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _CEC_UAPI_FUNCS_H
+#define _CEC_UAPI_FUNCS_H
+
+#include 
+
+/* One Touch Play Feature */
+static inline void cec_msg_active_source(struct cec_msg *msg, __u16 phys_addr)
+{
+   msg->len = 4;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_ACTIVE_SOURCE;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static inline void cec_ops_active_source(const struct cec_msg *msg,
+__u16 *phys_addr)
+{
+   *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+}
+
+static inline void cec_msg_image_view_on(struct cec_msg *msg)
+{
+   msg->len = 2;
+   msg->msg[1] = CEC_MSG_IMAGE_VIEW_ON;
+}
+
+static inline void cec_msg_text_view_on(struct cec_msg *msg)
+{
+   msg->len = 2;
+   msg->msg[1] = CEC_MSG_TEXT_VIEW_ON;
+}
+
+
+/* Routing Control Feature */
+static inline void cec_msg_inactive_source(struct cec_msg *msg,
+  __u16 phys_addr)
+{
+   msg->len = 4;
+   msg->msg[1] = CEC_MSG_INACTIVE_SOURCE;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static inline void cec_ops_inactive_source(const struct cec_msg *msg,
+  __u16 *phys_addr)
+{
+   *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+}
+
+static inline void cec_msg_request_active_source(struct cec_msg *msg,
+bool reply)
+{
+   msg->len = 2;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_REQUEST_ACTIVE_SOURCE;
+   msg->reply = reply ? CEC_MSG_ACTIVE_SOURCE : 0;
+}
+
+static inline void cec_msg_routing_information(struct cec_msg *msg,
+  __u16 phys_addr)
+{
+   msg->len = 4;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_ROUTING_INFORMATION;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static inline void cec_ops_routing_information(const struct cec_msg *msg,
+  __u16 *phys_addr)
+{
+   *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+}
+
+static inline void cec_msg_routing_change(struct cec_msg *msg,
+ bool reply,
+ __u16 orig_phys_addr,
+ __u16 new_phys_addr)
+{
+   msg->len = 6;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_ROUTING_CHANGE;
+   msg->msg[2] = orig_phys_addr >> 8;
+   msg->msg[3] = orig_phys_addr & 0xff;
+   msg->msg[4] = new_phys_addr >> 8;
+   msg->msg[5] = new_phys_addr & 0xff;
+   msg->reply = reply ? CEC_MSG_ROUTING_INFORMATION : 0;
+}
+
+static inline void cec_ops_routing_change(const struct cec_msg *msg,
+ __u16 *orig_phys_addr,
+ __u16 *new_phys_addr)
+{
+   *orig_phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+   *new_phys_addr = (msg->msg[4] << 8) | msg->msg[5];
+}
+
+static inline void cec_msg_set_stream_path(struct cec_msg *msg, __u16 
phys_addr)
+{
+   msg->len = 4;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_SET_STREAM_PATH;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static

[PATCHv18 04/15] DocBook/media: add CEC documentation

2016-06-18 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/device-drivers.tmpl  |   3 +
 Documentation/DocBook/media/Makefile   |   2 +
 Documentation/DocBook/media/v4l/biblio.xml |  10 +
 Documentation/DocBook/media/v4l/cec-api.xml|  75 +
 Documentation/DocBook/media/v4l/cec-func-close.xml |  64 
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml |  78 +
 Documentation/DocBook/media/v4l/cec-func-open.xml  | 104 +++
 Documentation/DocBook/media/v4l/cec-func-poll.xml  |  94 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml  | 151 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml | 329 +
 .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |  86 ++
 .../DocBook/media/v4l/cec-ioc-dqevent.xml  | 195 
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml | 255 
 .../DocBook/media/v4l/cec-ioc-receive.xml  | 265 +
 Documentation/DocBook/media_api.tmpl   |   6 +-
 15 files changed, 1716 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/DocBook/media/v4l/cec-api.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-close.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-ioctl.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-open.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-poll.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-receive.xml

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index de79efd..a20a45b 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -272,6 +272,9 @@ X!Isound/sound_firmware.c
 !Iinclude/media/media-devnode.h
 !Iinclude/media/media-entity.h
 
+Consumer Electronics Control devices
+!Iinclude/media/cec-edid.h
+
 
   
 
diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 2840ff4..fdc1386 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/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/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 9beb30f..87f1d24 100644
--- a/Documentation/DocBook/media/v4l/biblio.xml
+++ b/Documentation/DocBook/media/v4l/biblio.xml
@@ -342,6 +342,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..7062c1f
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/cec-api.xml
@@ -0,0 +1,75 @@
+
+  
+
+  Hans
+  Verkuil
+  
hans.verk...@cisco.com
+  Initial version.
+
+  
+  

[PATCHv18 08/15] cec: add HDMI CEC framework

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

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

Note that the CEC framework is added to staging/media and that the
cec.h and cec-funcs.h headers are not exported yet. While the kABI
is mature, I would prefer to allow the uABI some more time before
it is mainlined in case it needs more tweaks.

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 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 
---
 MAINTAINERS|   16 +
 drivers/staging/media/Kconfig  |2 +
 drivers/staging/media/Makefile |1 +
 drivers/staging/media/cec/Kconfig  |8 +
 drivers/staging/media/cec/Makefile |1 +
 drivers/staging/media/cec/cec.c| 2512 
 include/media/cec.h|  236 
 7 files changed, 2776 insertions(+)
 create mode 100644 drivers/staging/media/cec/Kconfig
 create mode 100644 drivers/staging/media/cec/Makefile
 create mode 100644 drivers/staging/media/cec/cec.c
 create mode 100644 include/media/cec.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 02299fd..c424596 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2847,6 +2847,22 @@ 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: Documentation/cec.txt
+F: Documentation/DocBook/media/v4l/cec*
+F: drivers/staging/media/cec/cec.c
+F: drivers/media/cec-edid.c
+F: drivers/media/rc/keymaps/rc-cec.c
+F: include/media/cec.h
+F: include/media/cec-edid.h
+F: include/linux/cec.h
+F: include/linux/cec-funcs.h
+
 CELL BROADBAND ENGINE ARCHITECTURE
 M: Arnd Bergmann 
 L: linuxppc-...@lists.ozlabs.org
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index ee91868..7ce679e 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -21,6 +21,8 @@ if STAGING_MEDIA
 # Please keep them in alphabetic order
 source "drivers/staging/media/bcm2048/Kconfig"
 
+source "drivers/staging/media/cec/Kconfig"
+
 source "drivers/staging/media/cxd2099/Kconfig"
 
 source "drivers/staging/media/davinci_vpfe/Kconfig"
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 8c05d0a..2d213dd 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_I2C_BCM2048)  += bcm2048/
+obj-$(CONFIG_MEDIA_CEC)+= cec/
 obj-$(CONFIG_DVB_CXD2099)  += cxd2099/
 obj-$(CONFIG_LIRC_STAGING) += lirc/
 obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
diff --git a/drivers/staging/media/cec/Kconfig 
b/drivers/staging/media/cec/Kconfig
new file mode 100644
index 000..3297a54
--- /dev/null
+++ b/drivers/staging/media/cec/Kconfig
@@ -0,0 +1,8 @@
+config MEDIA_CEC
+   tristate "CEC API (EXPERIMENTAL)"
+   select MEDIA_CEC_EDID
+   ---help---
+ Enable the CEC API.
+
+ To compile this driver as a module, choose M here: the
+ module will be called cec.
diff --git a/drivers/staging/media/cec/Makefile 
b/drivers/staging/media/cec/Makefile
new file mode 100644
index 000..7a7532e
--- /dev/null
+++ b/drivers/staging/media/cec/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_MEDIA_CEC) += cec.o
diff --git a/drivers/staging/media/cec/cec.c b/drivers/staging/media/cec/cec.c
new file mode 100644
index 000..8634773
--- /dev/null
+++ b/drivers/staging/media/cec/cec.c
@@ -0,0 +1,2512 @@
+/*
+ * cec - HDMI Consumer Electronics Control framework
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED,

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

2016-06-18 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/Kconfig   |   8 ++
 drivers/media/i2c/adv7604.c | 332 +++-
 2 files changed, 304 insertions(+), 36 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 993dc50..a2c44cb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -209,6 +209,7 @@ config VIDEO_ADV7604
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
depends on GPIOLIB || COMPILE_TEST
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7604 video decoder.
 
@@ -218,6 +219,13 @@ config VIDEO_ADV7604
  To compile this driver as a module, choose M here: the
  module will be called adv7604.
 
+config VIDEO_ADV7604_CEC
+   bool "Enable Analog Devices ADV7604 CEC support"
+   depends on VIDEO_ADV7604 && MEDIA_CEC
+   ---help---
+ When selected the adv7604 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_ADV7842
tristate "Analog Devices ADV7842 decoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index beb2841..3c9f001 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,12 @@ struct adv76xx_state {
u16 spa_port_a[2];
struct v4l2_fract aspect_ratio;
u32 rgb_quantization_range;
+
+   struct cec_adapter *cec_adap;
+   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;
@@ -381,7 +390,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);
 }
@@ -414,6 +424,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);
@@ -872,9 +888,9 @@ 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);
 
-   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,
@@ -1900,6 +1916,210 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
return 0;
 }
 
+#if IS_ENABLED(CONFIG_VIDEO_ADV7604_CEC)
+static void adv76xx_cec_tx_raw_status(struct v4l2_subdev *sd, u8 tx_raw_status)
+{
+   struct adv76xx_state *state = to_state(sd);
+
+   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__);
+   cec_transmit_done(state->cec_adap, CEC_TX_STATUS_ARB_LOST,
+ 1, 0, 0, 0);
+   }
+   if (tx_raw_status & 0x04) {
+   u8 status;
+   u8 nack_cnt;
+   u8 low_drive_cnt;
+
+   v4l2_dbg(1, debug, sd, "%s: tx raw: retry failed\n", __func__);
+   /*
+* We set this status bit since this hardware performs
+* retransmissions.
+*/
+   status = CEC_TX_STATUS_MAX_RETRIES;
+   nack_cnt = cec_read(sd, 0x14) 

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

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7842 driver.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/Kconfig   |   8 +
 drivers/media/i2c/adv7842.c | 368 
 2 files changed, 313 insertions(+), 63 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index a2c44cb..0179d10 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -230,6 +230,7 @@ config VIDEO_ADV7842
tristate "Analog Devices ADV7842 decoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7842 video decoder.
 
@@ -239,6 +240,13 @@ config VIDEO_ADV7842
  To compile this driver as a module, choose M here: the
  module will be called adv7842.
 
+config VIDEO_ADV7842_CEC
+   bool "Enable Analog Devices ADV7842 CEC support"
+   depends on VIDEO_ADV7842 && MEDIA_CEC
+   ---help---
+ When selected the adv7842 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_BT819
tristate "BT819A VideoStream decoder"
depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index ecaacb0..ad7dcfc 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;
+
+   struct cec_adapter *cec_adap;
+   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);
@@ -762,50 +782,18 @@ static int edid_write_vga_segment(struct v4l2_subdev *sd)
return 0;
 }
 
-static int edid_spa_location(const u8 *edid)
-{
-   u8 d;
-
-   /*
-* TODO, improve and update for other CEA extensions
-* currently only for 1 segment (256 bytes),
-* i.e. 1 extension block and CEA revision 3.
-*/
-   if ((edid[0x7e] != 1) ||
-   (edid[0x80] != 0x02) ||
-   (edid[0x81] != 0x03)) {
-   return -EINVAL;
-   }
-   /*
-* search Vendor Specific Data Block (tag 3)
-*/
-   d = edid[0x82] & 0x7f;
-   if (d > 4) {
-   int i = 0x84;
-   int end = 0x80 + d;
-   do {
-   u8 tag = edid[i]>>5;
-   u8 len = edid[i] & 0x1f;
-
-   if ((tag == 3) && (len >= 5))
-   return i + 4;
-   i += len + 1;
-   } while (i < end);
-   }
-   return -EINVAL;
-}
-
 static int edid_write_hdmi_segment(struct v4l2_subdev *sd, u8 port)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct adv7842_state *state = to_state(sd);
-   const u8 *val = state->hdmi_edid.edid;
-   int spa_loc = edid_spa_location(val);
+   const u8 *edid = state->hdmi_edid.edid;
+   int spa_loc;
+   u16 pa;
int err = 0;
int i;
 
-   v4l2_dbg(2, debug, sd, "%s: write EDID on port %c (spa at 0x%x)\n",
-   __func__, (port == ADV7842_EDID_PORT_A) ? 'A' : 'B', 
spa_loc);
+   v4l2_dbg(2, debug, sd, "%s: write EDID on port %c\n",
+   __func__, (port == ADV7842_EDID_PORT_A) ? 'A' : 'B');
 
/* HPA disable on port A and B */
   

[PATCHv18 05/15] cec-edid: add module for EDID CEC helper functions

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

The cec-edid module contains helper functions to find and manipulate
the CEC physical address inside an EDID. Even if the CEC support itself
is disabled, drivers will still need these functions. Which is the
reason this is module is separate from the upcoming CEC framework.

Signed-off-by: Hans Verkuil 
---
 drivers/media/Kconfig|   3 +
 drivers/media/Makefile   |   2 +
 drivers/media/cec-edid.c | 139 +++
 include/media/cec-edid.h | 104 +++
 4 files changed, 248 insertions(+)
 create mode 100644 drivers/media/cec-edid.c
 create mode 100644 include/media/cec-edid.h

diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index a8518fb..052dcf7 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -80,6 +80,9 @@ config MEDIA_RC_SUPPORT
 
  Say Y when you have a TV or an IR device.
 
+config MEDIA_CEC_EDID
+   tristate
+
 #
 # Media controller
 #  Selectable only for webcam/grabbers, as other drivers don't use it
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index e608bbc..b56f013 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -2,6 +2,8 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
+obj-$(CONFIG_MEDIA_CEC_EDID) += cec-edid.o
+
 media-objs := media-device.o media-devnode.o media-entity.o
 
 #
diff --git a/drivers/media/cec-edid.c b/drivers/media/cec-edid.c
new file mode 100644
index 000..ce3b915
--- /dev/null
+++ b/drivers/media/cec-edid.c
@@ -0,0 +1,139 @@
+/*
+ * cec-edid - HDMI Consumer Electronics Control EDID & CEC helper functions
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static unsigned int cec_get_edid_spa_location(const u8 *edid, unsigned int 
size)
+{
+   u8 d;
+
+   if (size < 256)
+   return 0;
+
+   if (edid[0x7e] != 1 || edid[0x80] != 0x02 || edid[0x81] != 0x03)
+   return 0;
+
+   /* search Vendor Specific Data Block (tag 3) */
+   d = edid[0x82] & 0x7f;
+   if (d > 4) {
+   int i = 0x84;
+   int end = 0x80 + d;
+
+   do {
+   u8 tag = edid[i] >> 5;
+   u8 len = edid[i] & 0x1f;
+
+   if (tag == 3 && len >= 5)
+   return i + 4;
+   i += len + 1;
+   } while (i < end);
+   }
+   return 0;
+}
+
+u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size,
+  unsigned int *offset)
+{
+   unsigned int loc = cec_get_edid_spa_location(edid, size);
+
+   if (offset)
+   *offset = loc;
+   if (loc == 0)
+   return CEC_PHYS_ADDR_INVALID;
+   return (edid[loc] << 8) | edid[loc + 1];
+}
+EXPORT_SYMBOL_GPL(cec_get_edid_phys_addr);
+
+void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr)
+{
+   unsigned int loc = cec_get_edid_spa_location(edid, size);
+   u8 sum = 0;
+   unsigned int i;
+
+   if (loc == 0)
+   return;
+   edid[loc] = phys_addr >> 8;
+   edid[loc + 1] = phys_addr & 0xff;
+   loc &= ~0x7f;
+
+   /* update the checksum */
+   for (i = loc; i < loc + 127; i++)
+   sum += edid[i];
+   edid[i] = 256 - sum;
+}
+EXPORT_SYMBOL_GPL(cec_set_edid_phys_addr);
+
+u16 cec_phys_addr_for_input(u16 phys_addr, u8 input)
+{
+   /* Check if input is sane */
+   if (WARN_ON(input == 0 || input > 0xf))
+   return CEC_PHYS_ADDR_INVALID;
+
+   if (phys_addr == 0)
+   return input << 12;
+
+   if ((phys_addr & 0x0fff) == 0)
+   return phys_addr | (input << 8);
+
+   if ((phys_addr & 0x00ff) == 0)
+   return phys_addr | (input << 4);
+
+   if ((phys_addr & 0x000f) == 0)
+   return phys_addr | input;
+
+   /*
+* All nibbles are used so no valid physical addresses can be assigned
+* to the input.
+*/
+   return CEC_PHYS_ADDR_INVALID;
+}
+EXPORT_SYMBOL_GPL(cec_phys_addr_for_input);
+
+int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port)
+{
+   int i;
+
+  

[PATCHv18 01/15] input.h: add BUS_CEC type

2016-06-18 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 0111384..c514941 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -247,6 +247,7 @@ struct input_mask {
 #define BUS_ATARI  0x1B
 #define BUS_SPI0x1C
 #define BUS_RMI0x1D
+#define BUS_CEC0x1E
 
 /*
  * MT_TOOL types
-- 
2.8.1

--
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


[PATCHv18 00/15] HDMI CEC framework

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

Final 18th patch series. Changes since v17:

Split the rc patch into two: one adding the new RC CEC protocol support
and one adding the rc-cec keymap. This rc-cec keymap is not included in
this patch series since it depends on the new HID CEC key defines which
will go through linux-input (patch series has been posted for that to
linux-input).

The rc-cec patch will be posted separately and merging it will have to be
postponed until both this series and the linux-input changes are merged
since it depends on both.

The patch adding the HID CEC defines has been dropped from this patch series
accordingly.

Note: the patch adding BUS_CEC goes through both linux-input and linux-media
as it is very unlikely this will cause a conflict.

There are two more changes since v17:

- The 'default n' line was dropped from the Kconfigs (as suggested by Mauro)
  since that's the default anyway.
- Fixed two compiler warnings in s5p-cec that I missed. This is the change
  for that:

--- a/drivers/media/platform/s5p-cec/s5p_cec.c
+++ b/drivers/media/platform/s5p-cec/s5p_cec.c
@@ -180,12 +180,12 @@ static int s5p_cec_probe(struct platform_device *pdev)
cec->dev = dev;
 
cec->irq = platform_get_irq(pdev, 0);
-   if (IS_ERR_VALUE(cec->irq))
+   if (cec->irq < 0)
return cec->irq;
 
ret = devm_request_threaded_irq(dev, cec->irq, s5p_cec_irq_handler,
s5p_cec_irq_handler_thread, 0, pdev->name, cec);
-   if (IS_ERR_VALUE(ret))
+   if (ret)
return ret;
 
cec->clk = devm_clk_get(dev, "hdmicec");

Regards,

Hans

Hans Verkuil (13):
  input.h: add BUS_CEC type
  cec.txt: add CEC framework documentation
  DocBook/media: add CEC documentation
  cec-edid: add module for EDID CEC helper functions
  cec.h: add cec header
  cec-funcs.h: static inlines to pack/unpack CEC messages
  cec: add HDMI CEC framework
  cec/TODO: add TODO file so we know why this is still in staging
  cec: add compat32 ioctl support
  cec: adv7604: add cec support.
  cec: adv7842: add cec support
  cec: adv7511: add cec support.
  vivid: add CEC emulation

Kamil Debski (2):
  rc: Add HDMI CEC protocol handling
  cec: s5p-cec: Add s5p-cec driver

 Documentation/DocBook/device-drivers.tmpl  |3 +
 Documentation/DocBook/media/Makefile   |2 +
 Documentation/DocBook/media/v4l/biblio.xml |   10 +
 Documentation/DocBook/media/v4l/cec-api.xml|   75 +
 Documentation/DocBook/media/v4l/cec-func-close.xml |   64 +
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml |   78 +
 Documentation/DocBook/media/v4l/cec-func-open.xml  |  104 +
 Documentation/DocBook/media/v4l/cec-func-poll.xml  |   94 +
 .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml  |  151 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml |  329 +++
 .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |   86 +
 .../DocBook/media/v4l/cec-ioc-dqevent.xml  |  195 ++
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml |  255 ++
 .../DocBook/media/v4l/cec-ioc-receive.xml  |  265 +++
 Documentation/DocBook/media_api.tmpl   |6 +-
 Documentation/cec.txt  |  267 +++
 .../devicetree/bindings/media/s5p-cec.txt  |   31 +
 Documentation/video4linux/vivid.txt|   36 +-
 MAINTAINERS|   23 +
 drivers/media/Kconfig  |3 +
 drivers/media/Makefile |2 +
 drivers/media/cec-edid.c   |  139 ++
 drivers/media/i2c/Kconfig  |   24 +
 drivers/media/i2c/adv7511.c|  401 +++-
 drivers/media/i2c/adv7604.c|  332 ++-
 drivers/media/i2c/adv7842.c|  368 ++-
 drivers/media/platform/Kconfig |   10 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/s5p-cec/Makefile|2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h   |   38 +
 .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c   |  209 ++
 drivers/media/platform/s5p-cec/regs-cec.h  |   96 +
 drivers/media/platform/s5p-cec/s5p_cec.c   |  295 +++
 drivers/media/platform/s5p-cec/s5p_cec.h   |   76 +
 drivers/media/platform/vivid/Kconfig   |8 +
 drivers/media/platform/vivid/Makefile  |4 +
 drivers/media/platform/vivid/vivid-cec.c   |  255 ++
 drivers/media/platform/vivid/vivid-cec.h   |   33 +
 drivers/media/platform/vivid/vivid-core.c  |  118 +-
 drivers/media/platform/vivid/vivid-core.h  |   27 +
 drivers/media/platform/vivid/vivid-kthread-cap.c   |   13 +
 drivers/media/platform/vivid/vivid-vid-cap.c   |   23 +-
 drivers/media/platform/vivid/vivid-vid-common.c|7 +
 drivers/media/rc/rc-main.c |1 +
 drivers/staging/media/Kconfig 

[PATCH 0/2] input: add support for HDMI CEC

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

Hi Dmitry,

This patch series adds input support for the HDMI CEC bus through which
remote control keys can be passed from one HDMI device to another.

This has been posted before as part of the HDMI CEC patch series. We are
going to merge that in linux-media for 4.8, but these two patches have to
go through linux-input.

Only the rc-cec keymap file depends on this, and we will take care of that
dependency (we'll postpone merging that until both these input patches and
our own CEC patches have been merged in mainline).

Regards,

Hans

Hans Verkuil (1):
  input.h: add BUS_CEC type

Kamil Debski (1):
  HID: add HDMI CEC specific keycodes

 include/uapi/linux/input-event-codes.h | 31 +++
 include/uapi/linux/input.h |  1 +
 2 files changed, 32 insertions(+)

-- 
2.8.1

--
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


[PATCH 1/2] input.h: add BUS_CEC type

2016-06-18 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 0111384..c514941 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -247,6 +247,7 @@ struct input_mask {
 #define BUS_ATARI  0x1B
 #define BUS_SPI0x1C
 #define BUS_RMI0x1D
+#define BUS_CEC0x1E
 
 /*
  * MT_TOOL types
-- 
2.8.1

--
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


[PATCH 2/2] HID: add HDMI CEC specific keycodes

2016-06-18 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 
Acked-by: Dmitry Torokhov 
---
 include/uapi/linux/input-event-codes.h | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/include/uapi/linux/input-event-codes.h 
b/include/uapi/linux/input-event-codes.h
index 87cf351..737fa32 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -611,6 +611,37 @@
 #define KEY_KBDINPUTASSIST_ACCEPT  0x264
 #define KEY_KBDINPUTASSIST_CANCEL  0x265
 
+/* Diagonal movement keys */
+#define KEY_RIGHT_UP   0x266
+#define KEY_RIGHT_DOWN 0x267
+#define KEY_LEFT_UP0x268
+#define KEY_LEFT_DOWN  0x269
+
+#define KEY_ROOT_MENU  0x26a /* Show Device's Root Menu */
+/* Show Top Menu of the Media (e.g. DVD) */
+#define KEY_MEDIA_TOP_MENU 0x26b
+#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.8.1

--
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 v3 2/2] media: et8ek8: Add documentation

2016-06-18 Thread Pavel Machek
On Wed 2016-06-15 22:24:40, Ivaylo Dimitrov wrote:
> 
> 
> On 15.06.2016 21:41, Rob Herring wrote:
> >On Tue, Jun 14, 2016 at 11:31 PM, Sakari Ailus  wrote:
> >>Hi Rob,
> >>
> >>On Tue, Jun 14, 2016 at 05:05:17PM -0500, Rob Herring wrote:
> >>>On Sat, Jun 11, 2016 at 06:39:53PM +0300, Ivaylo Dimitrov wrote:
> Add DT bindings description
> >>>
> >>>Not exactly the best commit msg.
> >>>
> 
> will elaborate a bit more in the next patch version

And you can add my Acked-by to the next version :-).

Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: [PATCH] V4L: fix the Z16 format definition

2016-06-18 Thread Sakari Ailus
On Fri, Jun 17, 2016 at 07:38:01PM +0200, Guennadi Liakhovetski wrote:
> A copy paste error created that format with the same one-line
> description as Y8I and Y12I, whereas Z16 is quite different from them
> both.
> 
> Signed-off-by: Guennadi Liakhovetski 

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
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] Diffs between the CEC pull request and v17 patch series

2016-06-18 Thread Mauro Carvalho Chehab
Em Sat, 18 Jun 2016 14:18:07 +0200
Hans Verkuil  escreveu:

> Mauro,
> 
> This patch is the diff between my previous CEC pull request and the upcoming 
> patch series 17.
> 
> It contains all the non-codingstyle changes made since the original pull 
> request to avoid you
> having to dig through the new patch series for the changes.
> 
> This should take care of all your comments (I hope!).

Sounds ok. Just a minor nitpick.

> 
> Changes since the original pull request:
> 
> - checkpatch changes (not included in this patch). There are still a number 
> of 80-char limit
>   warnings, but splitting those up makes the code harder to read IMHO.
> - Dropped media/cec.h from Documentation/DocBook/device-drivers.tmpl
>   (cec-edid.h isn't staging, so that stayed)
> - Added notes to the cec DocBook files that mentions that this is a proposed 
> API.
> - Updated the DocBook files incorporating the review comments
> - Disable CEC support by default in Kconfig for HDMI drivers since cec is 
> still staging.
> - CEC_DQEVENT didn't block waiting for events in blocking mode. Fixed this. 
> The documentation
>   was correct, but it was never implemented.
> - Monitor mode now requires CAP_NET_ADMIN.
> - Three fixes in cec-funcs.h: the language string wasn't zero-terminated and 
> the
>   latency messages are broadcast messages, not directed messages.
> - Remove the cec.h dependency from cec-edid.h. Partially because cec.h 
> belongs to the
>   staging driver, partially because it really isn't necessary.
> - Updated the TODO file
> - Fixed vivid-cec.c top-level comment & copyright year.
> 
> Regards,
> 
>   Hans
> 
> diff --git a/Documentation/DocBook/device-drivers.tmpl 
> b/Documentation/DocBook/device-drivers.tmpl
> index 5b77199..de79efd 100644
> --- a/Documentation/DocBook/device-drivers.tmpl
> +++ b/Documentation/DocBook/device-drivers.tmpl
> @@ -272,10 +272,6 @@ X!Isound/sound_firmware.c
>  !Iinclude/media/media-devnode.h
>  !Iinclude/media/media-entity.h
>  
>   Consumer Electronics Control devices
> -!Iinclude/media/cec.h
>  !Iinclude/media/cec-edid.h
>   
> 
> diff --git a/Documentation/DocBook/media/v4l/cec-api.xml 
> b/Documentation/DocBook/media/v4l/cec-api.xml
> index caa04c0..7062c1f 100644
> --- a/Documentation/DocBook/media/v4l/cec-api.xml
> +++ b/Documentation/DocBook/media/v4l/cec-api.xml
> @@ -30,6 +30,10 @@
> 
>
>  Introduction
> +
> +  Note: this documents the proposed CEC API. This API is not yet 
> finalized and
> +  is currently only available as a staging kernel module.
> +
>  HDMI connectors provide a single pin for use by the Consumer 
> Electronics
>  Control protocol. This protocol allows different devices connected by an 
> HDMI cable
>  to communicate. The protocol for CEC version 1.4 is defined in 
> supplements 1 (CEC)
> @@ -48,8 +52,7 @@
>  In addition, CEC can be implemented in HDMI receivers, 
> transmitters and in USB
>  devices that have an HDMI input and an HDMI output and that control just 
> the CEC pin.
> 
> -Drivers that support CEC and that allow (or require) userspace to 
> handle CEC
> -messages and/or configure the CEC adapter will create a CEC device node 
> (/dev/cecX)
> +Drivers that support CEC will create a CEC device node (/dev/cecX)
>  to give userspace access to the CEC adapter. The &CEC-ADAP-G-CAPS; ioctl 
> will tell userspace
>  what it is allowed to do.
>
> diff --git a/Documentation/DocBook/media/v4l/cec-func-close.xml 
> b/Documentation/DocBook/media/v4l/cec-func-close.xml
> index c3978af..0812c8c 100644
> --- a/Documentation/DocBook/media/v4l/cec-func-close.xml
> +++ b/Documentation/DocBook/media/v4l/cec-func-close.xml
> @@ -35,6 +35,11 @@
>
>  Description
> 
> +
> +  Note: this documents the proposed CEC API. This API is not yet 
> finalized and
> +  is currently only available as a staging kernel module.
> +
> +
>  Closes the cec device. Resources associated with the file 
> descriptor
>  are freed. The device configuration remain unchanged.
>
> diff --git a/Documentation/DocBook/media/v4l/cec-func-ioctl.xml 
> b/Documentation/DocBook/media/v4l/cec-func-ioctl.xml
> index 0480eeb..f92817a 100644
> --- a/Documentation/DocBook/media/v4l/cec-func-ioctl.xml
> +++ b/Documentation/DocBook/media/v4l/cec-func-ioctl.xml
> @@ -49,6 +49,11 @@
> 
>
>  Description
> +
> +  Note: this documents the proposed CEC API. This API is not yet 
> finalized and
> +  is currently only available as a staging kernel module.
> +
> +
>  The ioctl() function manipulates cec device
>  parameters. The argument fd must be an open file
>  descriptor.
> diff --git a/Documentation/DocBook/media/v4l/cec-func-open.xml 
> b/Documentation/DocBook/media/v4l/cec-func-open.xml
> index d814847..2edc555 100644
> --- a/Documentation/DocBook/media/v4l/cec-func-open.xml
> +++ b/Documentation/DocBook/media/v4l/cec-func-open.xml
> @@ -33,14 +33,24 @@
>   

[GIT PULL FOR v4.8 v4] Add HDMI CEC framework

2016-06-18 Thread Hans Verkuil
Hi Mauro,

Here is the pull request for the HDMI CEC framework. The code of this pull
request is identical to the v17 patch series.

The cec DocBook documentation is here:

https://hverkuil.home.xs4all.nl/cec.html#cec

The latest cec utilities are here:

http://git.linuxtv.org/hverkuil/v4l-utils.git/log/?h=cec-johan

Regards,

Hans

The following changes since commit 0db5c79989de2c68d5abb7ba891bfdb3cd3b7e05:

  [media] media-devnode.h: Fix documentation (2016-06-16 08:14:56 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git cec17

for you to fetch changes up to b632db2b7979e1d4d52d964a2dd82384b5ed0b2e:

  vivid: add CEC emulation (2016-06-18 13:59:27 +0200)


Hans Verkuil (13):
  input.h: add BUS_CEC type
  cec.txt: add CEC framework documentation
  DocBook/media: add CEC documentation
  cec-edid: add module for EDID CEC helper functions
  cec.h: add cec header
  cec-funcs.h: static inlines to pack/unpack CEC messages
  cec: add HDMI CEC framework
  cec/TODO: add TODO file so we know why this is still in staging
  cec: add compat32 ioctl support
  cec: adv7604: add cec support.
  cec: adv7842: add cec support
  cec: adv7511: add cec support.
  vivid: add CEC emulation

Kamil Debski (3):
  HID: add HDMI CEC specific keycodes
  rc: Add HDMI CEC protocol handling
  cec: s5p-cec: Add s5p-cec driver

 Documentation/DocBook/device-drivers.tmpl|3 +
 Documentation/DocBook/media/Makefile |2 +
 Documentation/DocBook/media/v4l/biblio.xml   |   10 +
 Documentation/DocBook/media/v4l/cec-api.xml  |   75 ++
 Documentation/DocBook/media/v4l/cec-func-close.xml   |   64 ++
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml   |   78 ++
 Documentation/DocBook/media/v4l/cec-func-open.xml|  104 ++
 Documentation/DocBook/media/v4l/cec-func-poll.xml|   94 ++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml  |  151 +++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml |  329 ++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |   86 ++
 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml  |  195 
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml   |  255 +
 Documentation/DocBook/media/v4l/cec-ioc-receive.xml  |  265 +
 Documentation/DocBook/media_api.tmpl |6 +-
 Documentation/cec.txt|  267 +
 Documentation/devicetree/bindings/media/s5p-cec.txt  |   31 +
 Documentation/video4linux/vivid.txt  |   36 +-
 MAINTAINERS  |   23 +
 drivers/media/Kconfig|3 +
 drivers/media/Makefile   |2 +
 drivers/media/cec-edid.c |  139 +++
 drivers/media/i2c/Kconfig|   27 +
 drivers/media/i2c/adv7511.c  |  401 ++-
 drivers/media/i2c/adv7604.c  |  332 +-
 drivers/media/i2c/adv7842.c  |  368 +--
 drivers/media/platform/Kconfig   |   11 +
 drivers/media/platform/Makefile  |1 +
 drivers/media/platform/s5p-cec/Makefile  |2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h |   38 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c |  209 
 drivers/media/platform/s5p-cec/regs-cec.h|   96 ++
 drivers/media/platform/s5p-cec/s5p_cec.c |  295 ++
 drivers/media/platform/s5p-cec/s5p_cec.h |   76 ++
 drivers/media/platform/vivid/Kconfig |9 +
 drivers/media/platform/vivid/Makefile|4 +
 drivers/media/platform/vivid/vivid-cec.c |  255 +
 drivers/media/platform/vivid/vivid-cec.h |   33 +
 drivers/media/platform/vivid/vivid-core.c|  118 ++-
 drivers/media/platform/vivid/vivid-core.h|   27 +
 drivers/media/platform/vivid/vivid-kthread-cap.c |   13 +
 drivers/media/platform/vivid/vivid-vid-cap.c |   23 +-
 drivers/media/platform/vivid/vivid-vid-common.c  |7 +
 drivers/media/rc/keymaps/Makefile|1 +
 drivers/media/rc/keymaps/rc-cec.c|  182 
 drivers/media/rc/rc-main.c   |1 +
 drivers/staging/media/Kconfig|2 +
 drivers/staging/media/Makefile   |1 +
 drivers/staging/media/cec/

[PATCHv17 10/16] cec/TODO: add TODO file so we know why this is still in staging

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

Explain why cec.c is still in staging.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/cec/TODO | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 drivers/staging/media/cec/TODO

diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
new file mode 100644
index 000..e3c384a
--- /dev/null
+++ b/drivers/staging/media/cec/TODO
@@ -0,0 +1,23 @@
+The reason why cec.c is still in staging is that I would like
+to have a bit more confidence in the uABI. The kABI is fine,
+no problem there, but I would like to let the public API mature
+a bit.
+
+Once I'm confident that I didn't miss anything then the cec.c source
+can move to drivers/media and the linux/cec.h and linux/cec-funcs.h
+headers can move to uapi/linux and added to uapi/linux/Kbuild to make
+them public.
+
+Hopefully this will happen later in 2016.
+
+Other TODOs:
+
+- Add a flag to inhibit passing CEC RC messages to the rc subsystem.
+  Applications should be able to choose this when calling S_LOG_ADDRS.
+- Convert cec.txt to sphinx.
+- If the reply field of cec_msg is set then when the reply arrives it
+  is only sent to the filehandle that transmitted the original message
+  and not to any followers. Should this behavior change or perhaps
+  controlled through a cec_msg flag?
+
+Hans Verkuil 
-- 
2.8.1

--
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


[PATCHv17 16/16] vivid: add CEC emulation

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

The vivid driver has been extended to provide CEC adapters for the HDMI
input and HDMI outputs in order to test CEC applications.

This CEC emulation is faithful to the CEC timings (i.e., it all at a
snail's pace).

Signed-off-by: Hans Verkuil 
---
 Documentation/video4linux/vivid.txt  |  36 +++-
 drivers/media/platform/vivid/Kconfig |   9 +
 drivers/media/platform/vivid/Makefile|   4 +
 drivers/media/platform/vivid/vivid-cec.c | 255 +++
 drivers/media/platform/vivid/vivid-cec.h |  33 +++
 drivers/media/platform/vivid/vivid-core.c| 118 ++-
 drivers/media/platform/vivid/vivid-core.h|  27 +++
 drivers/media/platform/vivid/vivid-kthread-cap.c |  13 ++
 drivers/media/platform/vivid/vivid-vid-cap.c |  23 +-
 drivers/media/platform/vivid/vivid-vid-common.c  |   7 +
 10 files changed, 510 insertions(+), 15 deletions(-)
 create mode 100644 drivers/media/platform/vivid/vivid-cec.c
 create mode 100644 drivers/media/platform/vivid/vivid-cec.h

diff --git a/Documentation/video4linux/vivid.txt 
b/Documentation/video4linux/vivid.txt
index 8da5d2a..1b26519 100644
--- a/Documentation/video4linux/vivid.txt
+++ b/Documentation/video4linux/vivid.txt
@@ -74,7 +74,8 @@ Section 11: Cropping, Composing, Scaling
 Section 12: Formats
 Section 13: Capture Overlay
 Section 14: Output Overlay
-Section 15: Some Future Improvements
+Section 15: CEC (Consumer Electronics Control)
+Section 16: Some Future Improvements
 
 
 Section 1: Configuring the driver
@@ -364,7 +365,11 @@ For HDMI inputs it is possible to set the EDID. By default 
a simple EDID
 is provided. You can only set the EDID for HDMI inputs. Internally, however,
 the EDID is shared between all HDMI inputs.
 
-No interpretation is done of the EDID data.
+No interpretation is done of the EDID data with the exception of the
+physical address. See the CEC section for more details.
+
+There is a maximum of 15 HDMI inputs (if there are more, then they will be
+reduced to 15) since that's the limitation of the EDID physical address.
 
 
 Section 3: Video Output
@@ -409,6 +414,9 @@ standard, and for all others a 1:1 pixel aspect ratio is 
returned.
 
 An HDMI output has a valid EDID which can be obtained through VIDIOC_G_EDID.
 
+There is a maximum of 15 HDMI outputs (if there are more, then they will be
+reduced to 15) since that's the limitation of the EDID physical address. See
+also the CEC section for more details.
 
 Section 4: VBI Capture
 --
@@ -1108,7 +1116,26 @@ capabilities will slow down the video loop considerably 
as a lot of checks have
 to be done per pixel.
 
 
-Section 15: Some Future Improvements
+Section 15: CEC (Consumer Electronics Control)
+--
+
+If there are HDMI inputs then a CEC adapter will be created that has
+the same number of input ports. This is the equivalent of e.g. a TV that
+has that number of inputs. Each HDMI output will also create a
+CEC adapter that is hooked up to the corresponding input port, or (if there
+are more outputs than inputs) is not hooked up at all. In other words,
+this is the equivalent of hooking up each output device to an input port of
+the TV. Any remaining output devices remain unconnected.
+
+The EDID that each output reads reports a unique CEC physical address that is
+based on the physical address of the EDID of the input. So if the EDID of the
+receiver has physical address A.B.0.0, then each output will see an EDID
+containing physical address A.B.C.0 where C is 1 to the number of inputs. If
+there are more outputs than inputs then the remaining outputs have a CEC 
adapter
+that is disabled and reports an invalid physical address.
+
+
+Section 16: Some Future Improvements
 
 
 Just as a reminder and in no particular order:
@@ -1121,8 +1148,6 @@ Just as a reminder and in no particular order:
 - Fix sequence/field numbering when looping of video with alternate fields
 - Add support for V4L2_CID_BG_COLOR for video outputs
 - Add ARGB888 overlay support: better testing of the alpha channel
-- Add custom DV timings support
-- Add support for V4L2_DV_FL_REDUCED_FPS
 - Improve pixel aspect support in the tpg code by passing a real v4l2_fract
 - Use per-queue locks and/or per-device locks to improve throughput
 - Add support to loop from a specific output to a specific input across
@@ -1133,3 +1158,4 @@ Just as a reminder and in no particular order:
 - Make a thread for the RDS generation, that would help in particular for the
   "Controls" RDS Rx I/O Mode as the read-only RDS controls could be updated
   in real-time.
+- Changing the EDID should cause hotplug detect emulation to happen.
diff --git a/drivers/media/platform/vivid/Kconfig 
b/drivers/media/platform/vivid/Kconfig
index f535f57..dbb1584 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ b/drivers/media/platform/vivid/Kconfig
@@ -6,6 +6,7 @@ co

[PATCHv17 11/16] cec: add compat32 ioctl support

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

The CEC ioctls didn't have compat32 support, so they returned -ENOTTY
when used in a 32 bit application on a 64 bit kernel.

Since all the CEC ioctls are 32-bit compatible adding support for this
API is trivial.

Signed-off-by: Hans Verkuil 
---
 fs/compat_ioctl.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index bd01b92..c1e9f29 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "internal.h"
 
@@ -1377,6 +1378,17 @@ COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
 COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
 COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
 COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
+/* cec */
+COMPATIBLE_IOCTL(CEC_ADAP_G_CAPS)
+COMPATIBLE_IOCTL(CEC_ADAP_G_LOG_ADDRS)
+COMPATIBLE_IOCTL(CEC_ADAP_S_LOG_ADDRS)
+COMPATIBLE_IOCTL(CEC_ADAP_G_PHYS_ADDR)
+COMPATIBLE_IOCTL(CEC_ADAP_S_PHYS_ADDR)
+COMPATIBLE_IOCTL(CEC_G_MODE)
+COMPATIBLE_IOCTL(CEC_S_MODE)
+COMPATIBLE_IOCTL(CEC_TRANSMIT)
+COMPATIBLE_IOCTL(CEC_RECEIVE)
+COMPATIBLE_IOCTL(CEC_DQEVENT)
 
 /* joystick */
 COMPATIBLE_IOCTL(JSIOCGVERSION)
-- 
2.8.1

--
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


[PATCHv17 04/16] cec.txt: add CEC framework documentation

2016-06-18 Thread Hans Verkuil
From: 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 | 267 ++
 1 file changed, 267 insertions(+)
 create mode 100644 Documentation/cec.txt

diff --git a/Documentation/cec.txt b/Documentation/cec.txt
new file mode 100644
index 000..75155fe
--- /dev/null
+++ b/Documentation/cec.txt
@@ -0,0 +1,267 @@
+CEC Kernel Support
+==
+
+The CEC framework provides a unified kernel interface for use with HDMI CEC
+hardware. It is designed to handle a multiple types of hardware (receivers,
+transmitters, USB dongles). The framework also gives the option to decide
+what to do in the kernel driver and what should be handled by userspace
+applications. In addition it integrates the remote control passthrough
+feature into the kernel's remote control framework.
+
+
+The CEC Protocol
+
+
+The CEC protocol enables consumer electronic devices to communicate with each
+other through the HDMI connection. The protocol uses logical addresses in the
+communication. The logical address is strictly connected with the functionality
+provided by the device. The TV acting as the communication hub is always
+assigned address 0. The physical address is determined by the physical
+connection between devices.
+
+The CEC framework described here is up to date with the CEC 2.0 specification.
+It is documented in the HDMI 1.4 specification with the new 2.0 bits documented
+in the HDMI 2.0 specification. But for most of the features the freely 
available
+HDMI 1.3a specification is sufficient:
+
+http://www.microprocessor.org/HDMISpecification13a.pdf
+
+
+The Kernel Interface
+
+
+CEC Adapter
+---
+
+The struct cec_adapter represents the CEC adapter hardware. It is created by
+calling cec_allocate_adapter() and deleted by calling cec_delete_adapter():
+
+struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
+  void *priv, const char *name, u32 caps, u8 available_las,
+  struct device *parent);
+void cec_delete_adapter(struct cec_adapter *adap);
+
+To create an adapter you need to pass the following information:
+
+ops: adapter operations which are called by the CEC framework and that you
+have to implement.
+
+priv: will be stored in adap->priv and can be used by the adapter ops.
+
+name: the name of the CEC adapter. Note: this name will be copied.
+
+caps: capabilities of the CEC adapter. These capabilities determine the
+   capabilities of the hardware and which parts are to be handled
+   by userspace and which parts are handled by kernelspace. The
+   capabilities are returned by CEC_ADAP_G_CAPS.
+
+available_las: the number of simultaneous logical addresses that this
+   adapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS.
+
+parent: the parent device.
+
+
+To register the /dev/cecX device node and the remote control device (if
+CEC_CAP_RC is set) you call:
+
+int cec_register_adapter(struct cec_adapter *adap);
+
+To unregister the devices call:
+
+void cec_unregister_adapter(struct cec_adapter *adap);
+
+Note: if cec_register_adapter() fails, then call cec_delete_adapter() to
+clean up. But if cec_register_adapter() succeeded, then only call
+cec_unregister_adapter() to clean up, never cec_delete_adapter(). The
+unregister function will delete the adapter automatically once the last user
+of that /dev/cecX device has closed its file handle.
+
+
+Implementing the Low-Level CEC Adapter
+--
+
+The following low-level adapter operations have to be implemented in
+your driver:
+
+struct cec_adap_ops {
+   /* Low-level callbacks */
+   int (*adap_enable)(struct cec_adapter *adap, bool enable);
+   int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable);
+   int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr);
+   int (*adap_transmit)(struct cec_adapter *adap, u8 attempts,
+u32 signal_free_time, struct cec_msg *msg);
+   void (*adap_log_status)(struct cec_adapter *adap);
+
+   /* High-level callbacks */
+   ...
+};
+
+The three low-level ops deal with various aspects of controlling the CEC 
adapter
+hardware:
+
+
+To enable/disable the hardware:
+
+   int (*adap_enable)(struct cec_adapter *adap, bool enable);
+
+This callback enables or disables the CEC hardware. Enabling the CEC hardware
+means powering it up in a state where no logical addresses are claimed. This
+op assumes that the physical address (adap->phys_addr) is valid when enable is
+true and will not change while the CEC adapter remains enabled. The initial
+state of the CEC adapter after calling cec_allocate_adapter() is disabled.
+
+Note that adap_enable must return 0 if enable is false.
+

[PATCHv17 09/16] cec: add HDMI CEC framework

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

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

Note that the CEC framework is added to staging/media and that the
cec.h and cec-funcs.h headers are not exported yet. While the kABI
is mature, I would prefer to allow the uABI some more time before
it is mainlined in case it needs more tweaks.

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 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 
---
 MAINTAINERS|   16 +
 drivers/staging/media/cec/Kconfig  |8 +
 drivers/staging/media/cec/Makefile |1 +
 drivers/staging/media/cec/cec.c| 2512 
 include/media/cec.h|  236 
 5 files changed, 2773 insertions(+)
 create mode 100644 drivers/staging/media/cec/Kconfig
 create mode 100644 drivers/staging/media/cec/Makefile
 create mode 100644 drivers/staging/media/cec/cec.c
 create mode 100644 include/media/cec.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 02299fd..c424596 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2847,6 +2847,22 @@ 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: Documentation/cec.txt
+F: Documentation/DocBook/media/v4l/cec*
+F: drivers/staging/media/cec/cec.c
+F: drivers/media/cec-edid.c
+F: drivers/media/rc/keymaps/rc-cec.c
+F: include/media/cec.h
+F: include/media/cec-edid.h
+F: include/linux/cec.h
+F: include/linux/cec-funcs.h
+
 CELL BROADBAND ENGINE ARCHITECTURE
 M: Arnd Bergmann 
 L: linuxppc-...@lists.ozlabs.org
diff --git a/drivers/staging/media/cec/Kconfig 
b/drivers/staging/media/cec/Kconfig
new file mode 100644
index 000..3297a54
--- /dev/null
+++ b/drivers/staging/media/cec/Kconfig
@@ -0,0 +1,8 @@
+config MEDIA_CEC
+   tristate "CEC API (EXPERIMENTAL)"
+   select MEDIA_CEC_EDID
+   ---help---
+ Enable the CEC API.
+
+ To compile this driver as a module, choose M here: the
+ module will be called cec.
diff --git a/drivers/staging/media/cec/Makefile 
b/drivers/staging/media/cec/Makefile
new file mode 100644
index 000..7a7532e
--- /dev/null
+++ b/drivers/staging/media/cec/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_MEDIA_CEC) += cec.o
diff --git a/drivers/staging/media/cec/cec.c b/drivers/staging/media/cec/cec.c
new file mode 100644
index 000..8634773
--- /dev/null
+++ b/drivers/staging/media/cec/cec.c
@@ -0,0 +1,2512 @@
+/*
+ * cec - HDMI Consumer Electronics Control framework
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#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)");
+
+/*
+ * 400 ms is the time it takes for one 16 byte message to be
+ * transferred and 5 is the maximum number of retries. Add
+ * another 100 ms as a margin. So if the transmit doesn't
+ * finish before that time something is real

[PATCHv17 15/16] cec: s5p-cec: Add s5p-cec driver

2016-06-18 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 +++
 MAINTAINERS|   7 +
 drivers/media/platform/Kconfig |  11 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/s5p-cec/Makefile|   2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h   |  38 +++
 .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c   | 209 +++
 drivers/media/platform/s5p-cec/regs-cec.h  |  96 +++
 drivers/media/platform/s5p-cec/s5p_cec.c   | 295 +
 drivers/media/platform/s5p-cec/s5p_cec.h   |  76 ++
 10 files changed, 766 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 = <&clock CLK_HDMI_CEC>;
+   clock-names = "hdmicec";
+   samsung,syscon-phandle = <&pmu_system_controller>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&hdmi_cec>;
+   status = "okay";
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index c424596..4ffdc36 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1642,6 +1642,13 @@ L:   linux-media@vger.kernel.org
 S: Maintained
 F: drivers/media/platform/s5p-tv/
 
+ARM/SAMSUNG S5P SERIES HDMI CEC SUBSYSTEM SUPPORT
+M: Kyungmin Park 
+L: linux-arm-ker...@lists.infradead.org
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/platform/s5p-cec/
+
 ARM/SAMSUNG S5P SERIES JPEG CODEC SUPPORT
 M: Andrzej Pietrasiewicz 
 M: Jacek Anaszewski 
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 382f393..3957e24 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -108,6 +108,17 @@ 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 && MEDIA_CEC && (PLAT_S5P || ARCH_EXYNOS || 
COMPILE_TEST)
+   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"
 source "drivers/media/platform/rcar-vin/Kconfig"
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 99cf315..9a2fe95 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)   += 
m2m-deinterlace.o
 
 obj-$(CONFIG_VIDEO_S3C_CAMIF)  += s3c-camif/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/
+obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC)+= s5p-cec/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG)   += s5p-jpeg/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)+= s5p-mfc/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
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/s5

[PATCHv17 12/16] cec: adv7604: add cec support.

2016-06-18 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/Kconfig   |   9 ++
 drivers/media/i2c/adv7604.c | 332 +++-
 2 files changed, 305 insertions(+), 36 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 993dc50..b7e3c8a 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -209,6 +209,7 @@ config VIDEO_ADV7604
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
depends on GPIOLIB || COMPILE_TEST
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7604 video decoder.
 
@@ -218,6 +219,14 @@ config VIDEO_ADV7604
  To compile this driver as a module, choose M here: the
  module will be called adv7604.
 
+config VIDEO_ADV7604_CEC
+   bool "Enable Analog Devices ADV7604 CEC support"
+   depends on VIDEO_ADV7604 && MEDIA_CEC
+   default n
+   ---help---
+ When selected the adv7604 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_ADV7842
tristate "Analog Devices ADV7842 decoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index beb2841..3c9f001 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,12 @@ struct adv76xx_state {
u16 spa_port_a[2];
struct v4l2_fract aspect_ratio;
u32 rgb_quantization_range;
+
+   struct cec_adapter *cec_adap;
+   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;
@@ -381,7 +390,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);
 }
@@ -414,6 +424,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);
@@ -872,9 +888,9 @@ 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);
 
-   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,
@@ -1900,6 +1916,210 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
return 0;
 }
 
+#if IS_ENABLED(CONFIG_VIDEO_ADV7604_CEC)
+static void adv76xx_cec_tx_raw_status(struct v4l2_subdev *sd, u8 tx_raw_status)
+{
+   struct adv76xx_state *state = to_state(sd);
+
+   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__);
+   cec_transmit_done(state->cec_adap, CEC_TX_STATUS_ARB_LOST,
+ 1, 0, 0, 0);
+   }
+   if (tx_raw_status & 0x04) {
+   u8 status;
+   u8 nack_cnt;
+   u8 low_drive_cnt;
+
+   v4l2_dbg(1, debug, sd, "%s: tx raw: retry failed\n", __func__);
+   /*
+* We set this status bit since this hardware performs
+* retransmissions.
+*/
+   status = CEC_TX_STATUS_MAX_RETRIES;
+   nack_cnt = c

[PATCHv17 14/16] cec: adv7511: add cec support.

2016-06-18 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/Kconfig   |   9 +
 drivers/media/i2c/adv7511.c | 401 +++-
 include/media/i2c/adv7511.h |   6 +-
 3 files changed, 403 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index c575ee7..929c500 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -465,6 +465,7 @@ config VIDEO_ADV7511
tristate "Analog Devices ADV7511 encoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7511 video encoder.
 
@@ -473,6 +474,14 @@ config VIDEO_ADV7511
  To compile this driver as a module, choose M here: the
  module will be called adv7511.
 
+config VIDEO_ADV7511_CEC
+   bool "Enable Analog Devices ADV7511 CEC support"
+   depends on VIDEO_ADV7511 && MEDIA_CEC
+   default n
+   ---help---
+ When selected the adv7511 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_AD9389B
tristate "Analog Devices AD9389B encoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 39271c3..39d409f 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,20 @@ 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;
+   struct cec_adapter *cec_adap;
+   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;
@@ -227,7 +238,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;
@@ -242,6 +253,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);
@@ -425,16 +464,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;
+   }
+ 

[PATCHv17 13/16] cec: adv7842: add cec support

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7842 driver.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/Kconfig   |   9 ++
 drivers/media/i2c/adv7842.c | 368 
 2 files changed, 314 insertions(+), 63 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index b7e3c8a..c575ee7 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -231,6 +231,7 @@ config VIDEO_ADV7842
tristate "Analog Devices ADV7842 decoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7842 video decoder.
 
@@ -240,6 +241,14 @@ config VIDEO_ADV7842
  To compile this driver as a module, choose M here: the
  module will be called adv7842.
 
+config VIDEO_ADV7842_CEC
+   bool "Enable Analog Devices ADV7842 CEC support"
+   depends on VIDEO_ADV7842 && MEDIA_CEC
+   default n
+   ---help---
+ When selected the adv7842 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_BT819
tristate "BT819A VideoStream decoder"
depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index ecaacb0..ad7dcfc 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;
+
+   struct cec_adapter *cec_adap;
+   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);
@@ -762,50 +782,18 @@ static int edid_write_vga_segment(struct v4l2_subdev *sd)
return 0;
 }
 
-static int edid_spa_location(const u8 *edid)
-{
-   u8 d;
-
-   /*
-* TODO, improve and update for other CEA extensions
-* currently only for 1 segment (256 bytes),
-* i.e. 1 extension block and CEA revision 3.
-*/
-   if ((edid[0x7e] != 1) ||
-   (edid[0x80] != 0x02) ||
-   (edid[0x81] != 0x03)) {
-   return -EINVAL;
-   }
-   /*
-* search Vendor Specific Data Block (tag 3)
-*/
-   d = edid[0x82] & 0x7f;
-   if (d > 4) {
-   int i = 0x84;
-   int end = 0x80 + d;
-   do {
-   u8 tag = edid[i]>>5;
-   u8 len = edid[i] & 0x1f;
-
-   if ((tag == 3) && (len >= 5))
-   return i + 4;
-   i += len + 1;
-   } while (i < end);
-   }
-   return -EINVAL;
-}
-
 static int edid_write_hdmi_segment(struct v4l2_subdev *sd, u8 port)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct adv7842_state *state = to_state(sd);
-   const u8 *val = state->hdmi_edid.edid;
-   int spa_loc = edid_spa_location(val);
+   const u8 *edid = state->hdmi_edid.edid;
+   int spa_loc;
+   u16 pa;
int err = 0;
int i;
 
-   v4l2_dbg(2, debug, sd, "%s: write EDID on port %c (spa at 0x%x)\n",
-   __func__, (port == ADV7842_EDID_PORT_A) ? 'A' : 'B', 
spa_loc);
+   v4l2_dbg(2, debug, sd, "%s: write EDID on port %c\n",
+   __func__, (port == ADV7842_EDID_PORT_A) ? 'A' : 'B');
 
/* HPA disable on 

[PATCHv17 07/16] cec.h: add cec header

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

This header contains the CEC public API. Since the CEC framework will
initially be part of staging this header is kept out of include/uapi for
the time being until the CEC framework will be moved out of staging.

Signed-off-by: Hans Verkuil 
---
 include/linux/cec.h | 987 
 1 file changed, 987 insertions(+)
 create mode 100644 include/linux/cec.h

diff --git a/include/linux/cec.h b/include/linux/cec.h
new file mode 100644
index 000..0fd0e31
--- /dev/null
+++ b/include/linux/cec.h
@@ -0,0 +1,987 @@
+/*
+ * cec - HDMI Consumer Electronics Control public header
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _CEC_UAPI_H
+#define _CEC_UAPI_H
+
+#include 
+
+#define CEC_MAX_MSG_SIZE   16
+
+/**
+ * struct cec_msg - CEC message structure.
+ * @ts:Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by 
the
+ * driver. It is set when the message transmission has finished
+ * and it is set when a message was received.
+ * @len:   Length in bytes of the message.
+ * @timeout:   The timeout (in ms) that is used to timeout CEC_RECEIVE.
+ * Set to 0 if you want to wait forever. This timeout can also be
+ * used with CEC_TRANSMIT as the timeout for waiting for a reply.
+ * If 0, then it will use a 1 second timeout instead of waiting
+ * forever as is done with CEC_RECEIVE.
+ * @sequence:  The framework assigns a sequence number to messages that are
+ * sent. This can be used to track replies to previously sent
+ * messages.
+ * @flags: Set to 0.
+ * @rx_status: The message receive status bits. Set by the driver.
+ * @tx_status: The message transmit status bits. Set by the driver.
+ * @msg:   The message payload.
+ * @reply: This field is ignored with CEC_RECEIVE and is only used by
+ * CEC_TRANSMIT. If non-zero, then wait for a reply with this
+ * opcode. Set to CEC_MSG_FEATURE_ABORT if you want to wait for
+ * a possible ABORT reply. If there was an error when sending the
+ * msg or FeatureAbort was returned, then reply is set to 0.
+ * If reply is non-zero upon return, then len/msg are set to
+ * the received message.
+ * If reply is zero upon return and status has the
+ * CEC_TX_STATUS_FEATURE_ABORT bit set, then len/msg are set to
+ * the received feature abort message.
+ * If reply is zero upon return and status has the
+ * CEC_TX_STATUS_MAX_RETRIES bit set, then no reply was seen at
+ * all. If reply is non-zero for CEC_TRANSMIT and the message is a
+ * broadcast, then -EINVAL is returned.
+ * if reply is non-zero, then timeout is set to 1000 (the required
+ * maximum response time).
+ * @tx_arb_lost_cnt: The number of 'Arbitration Lost' events. Set by the 
driver.
+ * @tx_nack_cnt: The number of 'Not Acknowledged' events. Set by the driver.
+ * @tx_low_drive_cnt: The number of 'Low Drive Detected' events. Set by the
+ * driver.
+ * @tx_error_cnt: The number of 'Error' events. Set by the driver.
+ */
+struct cec_msg {
+   __u64 ts;
+   __u32 len;
+   __u32 timeout;
+   __u32 sequence;
+   __u32 flags;
+   __u8 rx_status;
+   __u8 tx_status;
+   __u8 msg[CEC_MAX_MSG_SIZE];
+   __u8 reply;
+   __u8 tx_arb_lost_cnt;
+   __u8 tx_nack_cnt;
+   __u8 tx_low_drive_cnt;
+   __u8 tx_error_cnt;
+};
+
+/**
+ * cec_msg_initiator - return the initiator's logical address.
+ * @msg:   the message structure
+ */
+static inline __u8 cec_msg_initiator(const struct cec_msg *msg)
+{
+   return msg->msg[0] >> 4;
+}
+
+/**
+ * cec_msg_destination - return the destination's logical address.
+ * @msg:   the message structure
+ */
+static inline __u8 cec_msg_destination(const struct cec_msg *msg)
+{
+   return msg->msg[0] & 0xf;
+}
+
+/**
+ * cec_msg_opcode - return the opcode of the message, -1 for poll
+ * @msg:   the message structure
+ */
+static inline int cec_msg_opcode(const struct cec_msg *msg)
+{
+   return msg->le

[PATCHv17 08/16] cec-funcs.h: static inlines to pack/unpack CEC messages

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

This public header contains static inlines to pack and unpack CEC
messages. It is for use in both the kernel and in userspace.

Since the CEC framework will initially be in staging this header is
not yet in include/uapi. Once the framework is moved out of staging
this header should be moved to uapi at the same time.

Signed-off-by: Hans Verkuil 
---
 include/linux/cec-funcs.h | 1875 +
 1 file changed, 1875 insertions(+)
 create mode 100644 include/linux/cec-funcs.h

diff --git a/include/linux/cec-funcs.h b/include/linux/cec-funcs.h
new file mode 100644
index 000..155f6b9
--- /dev/null
+++ b/include/linux/cec-funcs.h
@@ -0,0 +1,1875 @@
+/*
+ * cec - HDMI Consumer Electronics Control message functions
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _CEC_UAPI_FUNCS_H
+#define _CEC_UAPI_FUNCS_H
+
+#include 
+
+/* One Touch Play Feature */
+static inline void cec_msg_active_source(struct cec_msg *msg, __u16 phys_addr)
+{
+   msg->len = 4;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_ACTIVE_SOURCE;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static inline void cec_ops_active_source(const struct cec_msg *msg,
+__u16 *phys_addr)
+{
+   *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+}
+
+static inline void cec_msg_image_view_on(struct cec_msg *msg)
+{
+   msg->len = 2;
+   msg->msg[1] = CEC_MSG_IMAGE_VIEW_ON;
+}
+
+static inline void cec_msg_text_view_on(struct cec_msg *msg)
+{
+   msg->len = 2;
+   msg->msg[1] = CEC_MSG_TEXT_VIEW_ON;
+}
+
+
+/* Routing Control Feature */
+static inline void cec_msg_inactive_source(struct cec_msg *msg,
+  __u16 phys_addr)
+{
+   msg->len = 4;
+   msg->msg[1] = CEC_MSG_INACTIVE_SOURCE;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static inline void cec_ops_inactive_source(const struct cec_msg *msg,
+  __u16 *phys_addr)
+{
+   *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+}
+
+static inline void cec_msg_request_active_source(struct cec_msg *msg,
+bool reply)
+{
+   msg->len = 2;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_REQUEST_ACTIVE_SOURCE;
+   msg->reply = reply ? CEC_MSG_ACTIVE_SOURCE : 0;
+}
+
+static inline void cec_msg_routing_information(struct cec_msg *msg,
+  __u16 phys_addr)
+{
+   msg->len = 4;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_ROUTING_INFORMATION;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static inline void cec_ops_routing_information(const struct cec_msg *msg,
+  __u16 *phys_addr)
+{
+   *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+}
+
+static inline void cec_msg_routing_change(struct cec_msg *msg,
+ bool reply,
+ __u16 orig_phys_addr,
+ __u16 new_phys_addr)
+{
+   msg->len = 6;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_ROUTING_CHANGE;
+   msg->msg[2] = orig_phys_addr >> 8;
+   msg->msg[3] = orig_phys_addr & 0xff;
+   msg->msg[4] = new_phys_addr >> 8;
+   msg->msg[5] = new_phys_addr & 0xff;
+   msg->reply = reply ? CEC_MSG_ROUTING_INFORMATION : 0;
+}
+
+static inline void cec_ops_routing_change(const struct cec_msg *msg,
+ __u16 *orig_phys_addr,
+ __u16 *new_phys_addr)
+{
+   *orig_phys_addr = (msg->msg[2] << 8) | msg->msg[3];
+   *new_phys_addr = (msg->msg[4] << 8) | msg->msg[5];
+}
+
+static inline void cec_msg_set_stream_path(struct cec_msg *msg, __u16 
phys_addr)
+{
+   msg->len = 4;
+   msg->msg[0] |= 0xf; /* broadcast */
+   msg->msg[1] = CEC_MSG_SET_STREAM_PATH;
+   msg->msg[2] = phys_addr >> 8;
+   msg->msg[3] = phys_addr & 0xff;
+}
+
+static

[PATCHv17 06/16] cec-edid: add module for EDID CEC helper functions

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

The cec-edid module contains helper functions to find and manipulate
the CEC physical address inside an EDID. Even if the CEC support itself
is disabled, drivers will still need these functions. Which is the
reason this is module is separate from the upcoming CEC framework.

Signed-off-by: Hans Verkuil 
---
 drivers/media/Kconfig  |   3 +
 drivers/media/Makefile |   2 +
 drivers/media/cec-edid.c   | 139 +
 drivers/staging/media/Kconfig  |   2 +
 drivers/staging/media/Makefile |   1 +
 include/media/cec-edid.h   | 104 ++
 6 files changed, 251 insertions(+)
 create mode 100644 drivers/media/cec-edid.c
 create mode 100644 include/media/cec-edid.h

diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index a8518fb..052dcf7 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -80,6 +80,9 @@ config MEDIA_RC_SUPPORT
 
  Say Y when you have a TV or an IR device.
 
+config MEDIA_CEC_EDID
+   tristate
+
 #
 # Media controller
 #  Selectable only for webcam/grabbers, as other drivers don't use it
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index e608bbc..b56f013 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -2,6 +2,8 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
+obj-$(CONFIG_MEDIA_CEC_EDID) += cec-edid.o
+
 media-objs := media-device.o media-devnode.o media-entity.o
 
 #
diff --git a/drivers/media/cec-edid.c b/drivers/media/cec-edid.c
new file mode 100644
index 000..ce3b915
--- /dev/null
+++ b/drivers/media/cec-edid.c
@@ -0,0 +1,139 @@
+/*
+ * cec-edid - HDMI Consumer Electronics Control EDID & CEC helper functions
+ *
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static unsigned int cec_get_edid_spa_location(const u8 *edid, unsigned int 
size)
+{
+   u8 d;
+
+   if (size < 256)
+   return 0;
+
+   if (edid[0x7e] != 1 || edid[0x80] != 0x02 || edid[0x81] != 0x03)
+   return 0;
+
+   /* search Vendor Specific Data Block (tag 3) */
+   d = edid[0x82] & 0x7f;
+   if (d > 4) {
+   int i = 0x84;
+   int end = 0x80 + d;
+
+   do {
+   u8 tag = edid[i] >> 5;
+   u8 len = edid[i] & 0x1f;
+
+   if (tag == 3 && len >= 5)
+   return i + 4;
+   i += len + 1;
+   } while (i < end);
+   }
+   return 0;
+}
+
+u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size,
+  unsigned int *offset)
+{
+   unsigned int loc = cec_get_edid_spa_location(edid, size);
+
+   if (offset)
+   *offset = loc;
+   if (loc == 0)
+   return CEC_PHYS_ADDR_INVALID;
+   return (edid[loc] << 8) | edid[loc + 1];
+}
+EXPORT_SYMBOL_GPL(cec_get_edid_phys_addr);
+
+void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr)
+{
+   unsigned int loc = cec_get_edid_spa_location(edid, size);
+   u8 sum = 0;
+   unsigned int i;
+
+   if (loc == 0)
+   return;
+   edid[loc] = phys_addr >> 8;
+   edid[loc + 1] = phys_addr & 0xff;
+   loc &= ~0x7f;
+
+   /* update the checksum */
+   for (i = loc; i < loc + 127; i++)
+   sum += edid[i];
+   edid[i] = 256 - sum;
+}
+EXPORT_SYMBOL_GPL(cec_set_edid_phys_addr);
+
+u16 cec_phys_addr_for_input(u16 phys_addr, u8 input)
+{
+   /* Check if input is sane */
+   if (WARN_ON(input == 0 || input > 0xf))
+   return CEC_PHYS_ADDR_INVALID;
+
+   if (phys_addr == 0)
+   return input << 12;
+
+   if ((phys_addr & 0x0fff) == 0)
+   return phys_addr | (input << 8);
+
+   if ((phys_addr & 0x00ff) == 0)
+   return phys_addr | (input << 4);
+
+   if ((phys_addr & 0x000f) == 0)
+   return phys_addr | input;
+
+   /*
+* All nibbles are used so no valid physical addresses can be assigned
+* to the input.
+*/
+   return CEC_PHYS_ADDR_INVALID;
+}
+EXPORT_SYMBOL_GPL(cec_phys_addr_for_input);
+
+

[PATCHv17 00/16] HDMI CEC framework

2016-06-18 Thread Hans Verkuil
From: Hans Verkuil 

This 17th version of the patch series incorporates the review comments
from Mauro. To simplify reviewing I've posted the diff with the relevant
non-checkpatch changes separately:

https://patchwork.linuxtv.org/patch/34656/

That mail also describes the changes since v16.

This patch series also reorganizes things a bit: the docs now come before
the code and I've split up the large patch 04/13 into separate patches
for cec-edid, linux/cec.h, cec-funcs.h and the cec framework source code.

Note that I did not see any merge conflicts w.r.t. the input headers
(patch 1 and 2) in linux-next. I'm not sure if I did something wrong
there since Mauro reported problems with that. For now the input
changes are still part of this patch series.

Regards,

Hans

Hans Verkuil (13):
  input.h: add BUS_CEC type
  cec.txt: add CEC framework documentation
  DocBook/media: add CEC documentation
  cec-edid: add module for EDID CEC helper functions
  cec.h: add cec header
  cec-funcs.h: static inlines to pack/unpack CEC messages
  cec: add HDMI CEC framework
  cec/TODO: add TODO file so we know why this is still in staging
  cec: add compat32 ioctl support
  cec: adv7604: add cec support.
  cec: adv7842: add cec support
  cec: adv7511: add cec support.
  vivid: add CEC emulation

Kamil Debski (3):
  HID: add HDMI CEC specific keycodes
  rc: Add HDMI CEC protocol handling
  cec: s5p-cec: Add s5p-cec driver

 Documentation/DocBook/device-drivers.tmpl  |3 +
 Documentation/DocBook/media/Makefile   |2 +
 Documentation/DocBook/media/v4l/biblio.xml |   10 +
 Documentation/DocBook/media/v4l/cec-api.xml|   75 +
 Documentation/DocBook/media/v4l/cec-func-close.xml |   64 +
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml |   78 +
 Documentation/DocBook/media/v4l/cec-func-open.xml  |  104 +
 Documentation/DocBook/media/v4l/cec-func-poll.xml  |   94 +
 .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml  |  151 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml |  329 +++
 .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |   86 +
 .../DocBook/media/v4l/cec-ioc-dqevent.xml  |  195 ++
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml |  255 ++
 .../DocBook/media/v4l/cec-ioc-receive.xml  |  265 +++
 Documentation/DocBook/media_api.tmpl   |6 +-
 Documentation/cec.txt  |  267 +++
 .../devicetree/bindings/media/s5p-cec.txt  |   31 +
 Documentation/video4linux/vivid.txt|   36 +-
 MAINTAINERS|   23 +
 drivers/media/Kconfig  |3 +
 drivers/media/Makefile |2 +
 drivers/media/cec-edid.c   |  139 ++
 drivers/media/i2c/Kconfig  |   27 +
 drivers/media/i2c/adv7511.c|  401 +++-
 drivers/media/i2c/adv7604.c|  332 ++-
 drivers/media/i2c/adv7842.c|  368 ++-
 drivers/media/platform/Kconfig |   11 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/s5p-cec/Makefile|2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h   |   38 +
 .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c   |  209 ++
 drivers/media/platform/s5p-cec/regs-cec.h  |   96 +
 drivers/media/platform/s5p-cec/s5p_cec.c   |  295 +++
 drivers/media/platform/s5p-cec/s5p_cec.h   |   76 +
 drivers/media/platform/vivid/Kconfig   |9 +
 drivers/media/platform/vivid/Makefile  |4 +
 drivers/media/platform/vivid/vivid-cec.c   |  255 ++
 drivers/media/platform/vivid/vivid-cec.h   |   33 +
 drivers/media/platform/vivid/vivid-core.c  |  118 +-
 drivers/media/platform/vivid/vivid-core.h  |   27 +
 drivers/media/platform/vivid/vivid-kthread-cap.c   |   13 +
 drivers/media/platform/vivid/vivid-vid-cap.c   |   23 +-
 drivers/media/platform/vivid/vivid-vid-common.c|7 +
 drivers/media/rc/keymaps/Makefile  |1 +
 drivers/media/rc/keymaps/rc-cec.c  |  182 ++
 drivers/media/rc/rc-main.c |1 +
 drivers/staging/media/Kconfig  |2 +
 drivers/staging/media/Makefile |1 +
 drivers/staging/media/cec/Kconfig  |8 +
 drivers/staging/media/cec/Makefile |1 +
 drivers/staging/media/cec/TODO |   23 +
 drivers/staging/media/cec/cec.c| 2512 
 fs/compat_ioctl.c  |   12 +
 include/linux/cec-funcs.h  | 1875 +++
 include/linux/cec.h|  987 
 include/media/cec-edid.h   |  104 +
 include/media/cec.h|  236 ++
 include/media/i2c/

[PATCHv17 05/16] DocBook/media: add CEC documentation

2016-06-18 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/device-drivers.tmpl  |   3 +
 Documentation/DocBook/media/Makefile   |   2 +
 Documentation/DocBook/media/v4l/biblio.xml |  10 +
 Documentation/DocBook/media/v4l/cec-api.xml|  75 +
 Documentation/DocBook/media/v4l/cec-func-close.xml |  64 
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml |  78 +
 Documentation/DocBook/media/v4l/cec-func-open.xml  | 104 +++
 Documentation/DocBook/media/v4l/cec-func-poll.xml  |  94 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml  | 151 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml | 329 +
 .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |  86 ++
 .../DocBook/media/v4l/cec-ioc-dqevent.xml  | 195 
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml | 255 
 .../DocBook/media/v4l/cec-ioc-receive.xml  | 265 +
 Documentation/DocBook/media_api.tmpl   |   6 +-
 15 files changed, 1716 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/DocBook/media/v4l/cec-api.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-close.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-ioctl.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-open.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-poll.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-receive.xml

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index de79efd..a20a45b 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -272,6 +272,9 @@ X!Isound/sound_firmware.c
 !Iinclude/media/media-devnode.h
 !Iinclude/media/media-entity.h
 
+Consumer Electronics Control devices
+!Iinclude/media/cec-edid.h
+
 
   
 
diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 2840ff4..fdc1386 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/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/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 9beb30f..87f1d24 100644
--- a/Documentation/DocBook/media/v4l/biblio.xml
+++ b/Documentation/DocBook/media/v4l/biblio.xml
@@ -342,6 +342,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..7062c1f
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/cec-api.xml
@@ -0,0 +1,75 @@
+
+  
+
+  Hans
+  Verkuil
+  
hans.verk...@cisco.com
+  Initial version.
+
+  
+  

[PATCHv17 03/16] rc: Add HDMI CEC protocol handling

2016-06-18 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 | 182 ++
 drivers/media/rc/rc-main.c|   1 +
 include/media/rc-map.h|   5 +-
 4 files changed, 188 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..354c8e7
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-cec.c
@@ -0,0 +1,182 @@
+/* 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 */
+   { 0x55, KEY_CONFIG },
+   /*
+* The following codes are hard to impl

[PATCHv17 01/16] input.h: add BUS_CEC type

2016-06-18 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 0111384..c514941 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -247,6 +247,7 @@ struct input_mask {
 #define BUS_ATARI  0x1B
 #define BUS_SPI0x1C
 #define BUS_RMI0x1D
+#define BUS_CEC0x1E
 
 /*
  * MT_TOOL types
-- 
2.8.1

--
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


[PATCHv17 02/16] HID: add HDMI CEC specific keycodes

2016-06-18 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 
Acked-by: Dmitry Torokhov 
---
 include/uapi/linux/input-event-codes.h | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/include/uapi/linux/input-event-codes.h 
b/include/uapi/linux/input-event-codes.h
index 87cf351..737fa32 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -611,6 +611,37 @@
 #define KEY_KBDINPUTASSIST_ACCEPT  0x264
 #define KEY_KBDINPUTASSIST_CANCEL  0x265
 
+/* Diagonal movement keys */
+#define KEY_RIGHT_UP   0x266
+#define KEY_RIGHT_DOWN 0x267
+#define KEY_LEFT_UP0x268
+#define KEY_LEFT_DOWN  0x269
+
+#define KEY_ROOT_MENU  0x26a /* Show Device's Root Menu */
+/* Show Top Menu of the Media (e.g. DVD) */
+#define KEY_MEDIA_TOP_MENU 0x26b
+#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.8.1

--
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


[PATCH] Diffs between the CEC pull request and v17 patch series

2016-06-18 Thread Hans Verkuil
Mauro,

This patch is the diff between my previous CEC pull request and the upcoming 
patch series 17.

It contains all the non-codingstyle changes made since the original pull 
request to avoid you
having to dig through the new patch series for the changes.

This should take care of all your comments (I hope!).

Changes since the original pull request:

- checkpatch changes (not included in this patch). There are still a number of 
80-char limit
  warnings, but splitting those up makes the code harder to read IMHO.
- Dropped media/cec.h from Documentation/DocBook/device-drivers.tmpl
  (cec-edid.h isn't staging, so that stayed)
- Added notes to the cec DocBook files that mentions that this is a proposed 
API.
- Updated the DocBook files incorporating the review comments
- Disable CEC support by default in Kconfig for HDMI drivers since cec is still 
staging.
- CEC_DQEVENT didn't block waiting for events in blocking mode. Fixed this. The 
documentation
  was correct, but it was never implemented.
- Monitor mode now requires CAP_NET_ADMIN.
- Three fixes in cec-funcs.h: the language string wasn't zero-terminated and the
  latency messages are broadcast messages, not directed messages.
- Remove the cec.h dependency from cec-edid.h. Partially because cec.h belongs 
to the
  staging driver, partially because it really isn't necessary.
- Updated the TODO file
- Fixed vivid-cec.c top-level comment & copyright year.

Regards,

Hans

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index 5b77199..de79efd 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -272,10 +272,6 @@ X!Isound/sound_firmware.c
 !Iinclude/media/media-devnode.h
 !Iinclude/media/media-entity.h
 
  Consumer Electronics Control devices
-!Iinclude/media/cec.h
 !Iinclude/media/cec-edid.h
  

diff --git a/Documentation/DocBook/media/v4l/cec-api.xml 
b/Documentation/DocBook/media/v4l/cec-api.xml
index caa04c0..7062c1f 100644
--- a/Documentation/DocBook/media/v4l/cec-api.xml
+++ b/Documentation/DocBook/media/v4l/cec-api.xml
@@ -30,6 +30,10 @@

   
 Introduction
+
+  Note: this documents the proposed CEC API. This API is not yet finalized 
and
+  is currently only available as a staging kernel module.
+
 HDMI connectors provide a single pin for use by the Consumer 
Electronics
 Control protocol. This protocol allows different devices connected by an 
HDMI cable
 to communicate. The protocol for CEC version 1.4 is defined in supplements 
1 (CEC)
@@ -48,8 +52,7 @@
 In addition, CEC can be implemented in HDMI receivers, transmitters 
and in USB
 devices that have an HDMI input and an HDMI output and that control just 
the CEC pin.

-Drivers that support CEC and that allow (or require) userspace to 
handle CEC
-messages and/or configure the CEC adapter will create a CEC device node 
(/dev/cecX)
+Drivers that support CEC will create a CEC device node (/dev/cecX)
 to give userspace access to the CEC adapter. The &CEC-ADAP-G-CAPS; ioctl 
will tell userspace
 what it is allowed to do.
   
diff --git a/Documentation/DocBook/media/v4l/cec-func-close.xml 
b/Documentation/DocBook/media/v4l/cec-func-close.xml
index c3978af..0812c8c 100644
--- a/Documentation/DocBook/media/v4l/cec-func-close.xml
+++ b/Documentation/DocBook/media/v4l/cec-func-close.xml
@@ -35,6 +35,11 @@
   
 Description

+
+  Note: this documents the proposed CEC API. This API is not yet finalized 
and
+  is currently only available as a staging kernel module.
+
+
 Closes the cec device. Resources associated with the file descriptor
 are freed. The device configuration remain unchanged.
   
diff --git a/Documentation/DocBook/media/v4l/cec-func-ioctl.xml 
b/Documentation/DocBook/media/v4l/cec-func-ioctl.xml
index 0480eeb..f92817a 100644
--- a/Documentation/DocBook/media/v4l/cec-func-ioctl.xml
+++ b/Documentation/DocBook/media/v4l/cec-func-ioctl.xml
@@ -49,6 +49,11 @@

   
 Description
+
+  Note: this documents the proposed CEC API. This API is not yet finalized 
and
+  is currently only available as a staging kernel module.
+
+
 The ioctl() function manipulates cec device
 parameters. The argument fd must be an open file
 descriptor.
diff --git a/Documentation/DocBook/media/v4l/cec-func-open.xml 
b/Documentation/DocBook/media/v4l/cec-func-open.xml
index d814847..2edc555 100644
--- a/Documentation/DocBook/media/v4l/cec-func-open.xml
+++ b/Documentation/DocBook/media/v4l/cec-func-open.xml
@@ -33,14 +33,24 @@
   
flags

- Open flags. Access mode must be either 
O_RDONLY
- or O_RDWR. Other flags have no effect.
+ Open flags. Access mode must be O_RDWR.
+ 
+ When the O_NONBLOCK flag is
+given, the &CEC-RECEIVE; ioctl will return &EAGAIN; when no message is
+available, and the &CEC-TRANSMIT;, &CEC-ADAP-S-PHYS-

Re: [PATCH 1/1] v4l: Add camera voice coil lens control class, current control

2016-06-18 Thread Pavel Machek
Hi!

> If someone has analyzed the existing voice coil lens controllers and could 
> share the result, in term of what parameters need to be controlled by the 
> system and how they should be controlled, that would be very appreciated. 
> Even 
> better would be a real userspace implementation of a voice coil lens control 
> algorithm.

Userspace implementation exists, it is called fcam-dev. What it
does... Starts capture, selects focus speed, makes it go through focus
range, looks for the sharpest image in the stream.

Then it computes time when the image was sharpest and thus lens
position, and goes back there.

So for ad5820, we need basically focus position and focus speed. (And
some 16/64 option).

Other coil drivers also have PWM vs. linear option.

Best regards,

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: tchellRe: [19/38] ARM: dts: imx6-sabrelite: add video capture ports and connections

2016-06-18 Thread Hans Verkuil
On 06/17/2016 09:00 PM, Steve Longerbeam wrote:
> 
> 
> On 06/17/2016 08:18 AM, Gary Bisson wrote:
>> Steve, All,
>>
>> On Thu, Jun 16, 2016 at 10:32:31AM +0200, Gary Bisson wrote:
>>> Steve, All,
>>>
>>> On Tue, Jun 14, 2016 at 03:49:15PM -0700, Steve Longerbeam wrote:
 Defines the host video capture device node and an OV5642 camera sensor
 node on i2c2. The host capture device connects to the OV5642 via the
 parallel-bus mux input on the ipu1_csi0_mux.

 Note there is a pin conflict with GPIO6. This pin functions as a power
 input pin to the OV5642, but ENET requires it to wake-up the ARM cores
 on normal RX and TX packet done events (see 6261c4c8). So by default,
 capture is disabled, enable by uncommenting __OV5642_CAPTURE__ macro.
 Ethernet will still work just not quite as well.
>>> Actually the following patch fixes this issue and has already been
>>> applied on Shawn's tree:
>>> https://patchwork.kernel.org/patch/9153523/
>>>
>>> Also, this follow-up patch declared the HW workaround for SabreLite:
>>> https://patchwork.kernel.org/patch/9153525/
>>>
>>> So ideally, once those two patches land on your base tree, you could get
>>> rid of the #define and remove the HW workaround declaration.
>>>
>>> Finally, I'll test the series on Sabre-Lite this week.
>> I've applied this series on top of Shawn tree (for-next branch) in order
>> not to worry about the GPIO6 workaround.
>>
>> Although the camera seems to get enumerated properly, I can't seem to
>> get anything from it. See log:
>> http://pastebin.com/xnw1ujUq
> 
> Hi Gary, the driver does not implement vidioc_cropcap, it has
> switched to the new selection APIs and v4l2src should be using
> vidioc_g_selection instead of vidioc_cropcap.

The v4l2 core should emulate cropcap on top of the selection API,
so this should work (except for the known 4.7 regression, hopefully
that fix will be merged soon).

The only remaining need for cropcap would be to fill in the pixelaspect
ratio if the pixels aren't square.

Regards,

Hans

> 
>>
>> In your cover letter, you said that you have not run through
>> v4l2-compliance. How have you tested the capture?
> 
> I use v4l2-ctl, and have used v4l2src in the past, but that was before
> switching to the selection APIs. Try the attached hack that adds
> vidioc_cropcap back in, and see how far you get on SabreLite with
> v4l2src. I tried  the following on SabreAuto:
> 
> gst-launch-1.0 v4l2src io_mode=4 ! 
> "video/x-raw,format=RGB16,width=640,height=480" ! fbdevsink
> 
>>
>> Also, why isn't the OV5640 MIPI camera declared on the SabreLite device
>> tree?
> 
> See Jack Mitchell's patch at http://ix.io/TTg. Thanks Jack! I will work on
> incorporating it.
> 
> 
> Steve
> 
> 
--
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 00/38] i.MX5/6 Video Capture

2016-06-18 Thread Hans Verkuil
On 06/17/2016 07:35 PM, Steve Longerbeam wrote:
> 
> 
> On 06/17/2016 12:10 AM, Hans Verkuil wrote:
>> On 06/16/2016 07:02 PM, Steve Longerbeam wrote:
>>> On 06/16/2016 02:49 AM, Jack Mitchell wrote:
 On 16/06/16 02:37, Steve Longerbeam wrote:
> Hi Jack,
>
> On 06/15/2016 03:43 AM, Jack Mitchell wrote:
>> 
>> Trying to use a user pointer rather than mmap also fails and causes a 
>> kernel splat.
>>
> Hmm, I've tested userptr with the mem2mem driver, but maybe never
> with video capture. I tried "v4l2-ctl -d/dev/video0 --stream-user=8" but
> that returns "VIDIOC_QBUF: failed: Invalid argument", haven't tracked
> down why (could be a bug in v4l2-ctl). Can you share the splat?
>
 On re-checking the splat was the same v4l_cropcap that was mentioned 
 before so I don't think it's related. The error I get back is:

 VIDIOC_QBUF error 22, Invalid argument

 I'm using the example program the the v4l2 docs [1].
>>> I found the cause at least in my case. After enabling dynamic debug in
>>> videobuf2-dma-contig.c, "v4l2-ctl -d/dev/video0 --stream-user=8" gives
>>> me
>>>
>>> [  468.826046] user data must be aligned to 64 bytes
>>>
>>>
>>>
>>> But even getting past that alignment issue, I've only tested userptr (in 
>>> mem2mem
>>> driver) by giving the driver a user address of a mmap'ed kernel contiguous
>>> buffer. A true discontiguous user buffer may not work, the IPU DMA does not
>>> support scatter-gather.
>> I don't think VB2_USERPTR should be enabled in this case due to the DMA 
>> limitations.
>> It won't allow you to use malloc()ed memory and the hack that allows you to 
>> pass
>> contiguous memory is superseded by the DMABUF mode.
> 
> Hi Hans, yes, I was going to suggest that. I will remove USERPTR
> from both capture and mem2mem io_modes flags. Although I can
> see where userptr support is still useful, that is for legacy middleware
> that are still using mmap'ed userptrs and have not yet converted to
> passing around dmabuf fd's.
> 
> But I've been perplexed for while on this, why vb2_dc_get_userptr() 
> resorts to
> scatter-gather (when the given user buffer is found not to have valid 
> pfn's).
> Shouldn't it be assumed that driver users of the vb2 dma-contig allocator
> only support contiguous dma as the name implies? Maybe the issue is that
> users that set VB2_USERPTR are implying they support scatter/gather, but
> users of vb2-dma-contig could also be implying they do not, and would be
> using vb2-dma-sg if that were the case.

At the end of the vb2_dc_get_userptr() function it checks if the result
is physically contiguous (the call to vb2_dc_get_contiguous_size). If not,
then it returns an error.

I hate it that dma_contig accepts user pointers at all, it should never
have been implemented like that. There is no way for applications to know
that even though the driver support USERPTR, the buffer still has to be
phys. contig. :-(

Regards,

Hans
--
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 v3] [media] omap3isp: support 64-bit version of omap3isp_stat_data

2016-06-18 Thread kbuild test robot
Hi,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.7-rc3 next-20160617]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Arnd-Bergmann/omap3isp-support-64-bit-version-of-omap3isp_stat_data/20160618-045121
base:   git://linuxtv.org/media_tree.git master
config: arm-allyesconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/media/platform/omap3isp/ispstat.c: In function 
'omap3isp_stat_request_statistics':
>> drivers/media/platform/omap3isp/ispstat.c:499:6: error: 'struct 
>> omap3isp_stat_data' has no member named 'ts'
 data->ts = buf->ts;
 ^
   drivers/media/platform/omap3isp/ispstat.c: In function 
'omap3isp_stat_request_statistics_time32':
   drivers/media/platform/omap3isp/ispstat.c:519:26: error: 'struct 
omap3isp_stat_data' has no member named 'ts'
 data->ts.tv_sec = data64.ts.tv_sec;
 ^
   drivers/media/platform/omap3isp/ispstat.c:520:27: error: 'struct 
omap3isp_stat_data' has no member named 'ts'
 data->ts.tv_usec = data64.ts.tv_usec;
  ^

vim +499 drivers/media/platform/omap3isp/ispstat.c

68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
493   buf = isp_stat_buf_get(stat, data);
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
494   if (IS_ERR(buf)) {
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
495   mutex_unlock(&stat->ioctl_lock);
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
496   return PTR_ERR(buf);
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
497   }
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
498  
5ba0e2c3a drivers/media/platform/omap3isp/ispstat.c Arnd Bergmann 2015-09-17 
@499   data->ts = buf->ts;
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
500   data->config_counter = buf->config_counter;
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
501   data->frame_number = buf->frame_number;
68e342b30 drivers/media/video/omap3isp/ispstat.cDavid Cohen   2011-02-12  
502   data->buf_size = buf->buf_size;

:: The code at line 499 was first introduced by commit
:: 5ba0e2c3ad4c049b19f6cad7ec62e59424a55183 [media] use v4l2_get_timestamp 
where possible

:: TO: Arnd Bergmann 
:: CC: Mauro Carvalho Chehab 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data