[RFC PATCH] v4l2-pci-skeleton: add a V4L2 PCI skeleton driver

2014-01-26 Thread Hans Verkuil
I will be giving a presentation about the V4L2 frameworks during FOSDEM 2014.
While working on that presentation I thought it would be very useful to actually
show some code, so I put together this V4L2 PCI skeleton driver that can 
function
as the starting point for a new PCI driver. It is completely up to date as far
as frameworks is concerned.

This is the first version of such a driver. I plan to extend it to include
sub-devices. I also plan to create a USB skeleton driver. Although if someone
else would be interested in doing that, that would be nice. I'm not sure how
much time I can actually spend on a USB skeleton driver.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/pci/Kconfig  |   1 +
 drivers/media/pci/Makefile |   2 +
 drivers/media/pci/skeleton/Kconfig |  10 +
 drivers/media/pci/skeleton/Makefile|   1 +
 drivers/media/pci/skeleton/v4l2-pci-skeleton.c | 882 +
 5 files changed, 896 insertions(+)
 create mode 100644 drivers/media/pci/skeleton/Kconfig
 create mode 100644 drivers/media/pci/skeleton/Makefile
 create mode 100644 drivers/media/pci/skeleton/v4l2-pci-skeleton.c

diff --git a/drivers/media/pci/Kconfig b/drivers/media/pci/Kconfig
index 53196f1..1717a91 100644
--- a/drivers/media/pci/Kconfig
+++ b/drivers/media/pci/Kconfig
@@ -19,6 +19,7 @@ if MEDIA_ANALOG_TV_SUPPORT
 source drivers/media/pci/ivtv/Kconfig
 source drivers/media/pci/zoran/Kconfig
 source drivers/media/pci/saa7146/Kconfig
+source drivers/media/pci/skeleton/Kconfig
 endif
 
 if MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT
diff --git a/drivers/media/pci/Makefile b/drivers/media/pci/Makefile
index 35cc578..ec08f46 100644
--- a/drivers/media/pci/Makefile
+++ b/drivers/media/pci/Makefile
@@ -11,11 +11,13 @@ obj-y+= ttpci/  \
ngene/  \
ddbridge/   \
b2c2/   \
+   skeleton/   \
saa7146/
 
 obj-$(CONFIG_VIDEO_IVTV) += ivtv/
 obj-$(CONFIG_VIDEO_ZORAN) += zoran/
 obj-$(CONFIG_VIDEO_CX18) += cx18/
+obj-$(CONFIG_VIDEO_PCI_SKELETON) += skeleton/
 obj-$(CONFIG_VIDEO_CX23885) += cx23885/
 obj-$(CONFIG_VIDEO_CX25821) += cx25821/
 obj-$(CONFIG_VIDEO_CX88) += cx88/
diff --git a/drivers/media/pci/skeleton/Kconfig 
b/drivers/media/pci/skeleton/Kconfig
new file mode 100644
index 000..f804955
--- /dev/null
+++ b/drivers/media/pci/skeleton/Kconfig
@@ -0,0 +1,10 @@
+config VIDEO_PCI_SKELETON
+   tristate V4L2 PCI Skeleton Driver
+   select VIDEOBUF2_DMA_CONTIG
+   depends on PCI  VIDEO_V4L2
+   help
+ Say Y for support for this PCI Skeleton Driver capture
+ device.
+
+ To compile this driver as a module, choose M here: the
+ module will be called v4l2-pci-skeleton.
diff --git a/drivers/media/pci/skeleton/Makefile 
b/drivers/media/pci/skeleton/Makefile
new file mode 100644
index 000..3a935ca
--- /dev/null
+++ b/drivers/media/pci/skeleton/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_PCI_SKELETON) += v4l2-pci-skeleton.o
diff --git a/drivers/media/pci/skeleton/v4l2-pci-skeleton.c 
b/drivers/media/pci/skeleton/v4l2-pci-skeleton.c
new file mode 100644
index 000..dcc7e5e
--- /dev/null
+++ b/drivers/media/pci/skeleton/v4l2-pci-skeleton.c
@@ -0,0 +1,882 @@
+/*
+ * This is a V4L2 PCI Skeleton Driver. It gives an initial skeleton source
+ * for use with other PCI drivers.
+ *
+ * This skeleton PCI driver assumes that the card has an S-Video connector as
+ * input 0 and an HDMI connector as input 1.
+ *
+ * Copyright 2014 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 linux/types.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/init.h
+#include linux/kmod.h
+#include linux/mutex.h
+#include linux/pci.h
+#include linux/interrupt.h
+#include linux/videodev2.h
+#include linux/v4l2-dv-timings.h
+#include media/v4l2-device.h
+#include media/v4l2-dev.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-dv-timings.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-event.h
+#include media/videobuf2-dma-contig.h
+
+MODULE_DESCRIPTION(V4L2 PCI Skeleton Driver);
+MODULE_AUTHOR(Hans Verkuil);
+MODULE_LICENSE(GPL v2);

Re: Conexant PCI-8604PW 4 channel BNC Video capture card (bttv)

2014-01-26 Thread Robert Longbottom

On 25/01/14 15:23, Daniel Glöckner wrote:

On Thu, Jan 23, 2014 at 02:29:19PM +, Robert Longbottom wrote:

Jan 23 14:24:48 quad kernel: [154562.493224] bits: FMTCHG* VSYNC
HSYNC OFLOW FBUS   NUML = 625
Jan 23 14:24:49 quad kernel: [154562.994015] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW
Jan 23 14:24:49 quad kernel: [154563.496010] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW
Jan 23 14:24:50 quad kernel: [154563.997020] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW
Jan 23 14:24:50 quad kernel: [154564.498018] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW
Jan 23 14:24:51 quad kernel: [154564.999023] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW
Jan 23 14:24:51 quad kernel: [154565.500024] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW
Jan 23 14:24:52 quad kernel: [154566.001014] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW
Jan 23 14:24:52 quad kernel: [154566.502016] bttv: 0: timeout:
drop=0 irq=1868/1868, risc=146da000, bits: VSYNC HSYNC OFLOW


The chip didn't lock to the input signal.
What kind of input are you feeding into the card?


Ah, for most of the testing I've done during the week I haven't had 
anything plugged in.  Though (obviously) I have tried with some cameras 
plugged in.  I have 3 bullet cams and one mini security camera.  All 
just standard wired video outputs, PAL, colour.  They work fine on the 
IVC capture card I have.


I've rerun the test with irq_debug=1 and the /var/log/messages output is 
here: http://pastebin.com/AJSLBhtY  I don't think it looks any better 
(/different).



Can you run the attached program while xawtv is running?
It will dump most of the registers of the bt8xx video function.


Sure, output below.  It didn't print out anything until I ran it as root 
(failed on fd = open(path, O_RDWR|O_SYNC);).  The output remains pretty 
much the same over multiple runs except these two values:


0E8 FCAP flips between a few values
100 INT_STAT changes from 0A0C to 0B0C and back.

Full output with xawtv running, bttv module loaded with no params.

sudo ./dumpbt8xx /dev/video0

000 0092 DSTATUS
004 0053 IFORM
008  TDEC
00C 00D2 E_CROP
010 00FE E_VDELAY_LO
014 00E0 E_VACTIVE_LO
018 0078 E_HDELAY_LO
01C 0080 E_HACTIVE_LO
020 0002 E_HSCALE_HI
024 00AC E_HSCALE_LO
028  BRIGHT
02C 0022 E_CONTROL
030 00D8 CONTRAST_LO
034  SAT_U_LO
038 00B5 SAT_V_LO
03C  HUE
040  E_SCLOOP
044 00CF WC_UP
048 0006 OFORM
04C 0020 E_VSCALE_HI
050  E_VSCALE_LO
054 0001 TEST
058  ARESET
060 007F ADELAY
064 0072 BDELAY
068 0081 ADC
06C  E_VTC
078 007F WC_DOWN
080 007F TGLB
084 0008 TGCTRL
08C 00D2 O_CROP
090 00FE O_VDELAY_LO
094 00E0 O_VACTIVE_LO
098 0078 O_HDELAY_LO
09C 0080 O_HACTIVE_LO
0A0 0002 O_HSCALE_HI
0A4 00AC O_HSCALE_LO
0AC 0022 O_CONTROL
0B0  VTOTAL_LO
0B4  VTOTAL_HI
0C0  O_SCLOOP
0CC 0020 O_VSCALE_HI
0D0  O_VSCALE_LO
0D4  COLOR_FMT
0D8 0010 COLOR_CTL
0DC 0003 CAP_CTL
0E0 00FF VBI_PACK_SIZE
0E4 0001 VBI_PACK_DEL
0E8 0011 FCAP
0EC  O_VTC
0F0 00F9 PLL_F_LO
0F4 00DC PLL_F_HI
0F8 008E PLL_XCI
0FC  DVSIF
100 0A0C INT_STAT
104 000C0B13 INT_MASK
10C C0AF GPIO_DMA_CTL
110 0003 I2C
114 30B35000 RISC_STRT_ADD
118  GPIO_OUT_EN
11C  GPIO_REG_INP
120 30B35000 RISC_COUNT
200 000F GPIO_DATA

Thanks,
Rob.

--
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: Conexant PCI-8604PW 4 channel BNC Video capture card (bttv)

2014-01-26 Thread Daniel Glöckner
On Sun, Jan 26, 2014 at 11:21:31AM +, Robert Longbottom wrote:
 0F0 00F9 PLL_F_LO
 0F4 00DC PLL_F_HI
 0F8 008E PLL_XCI

The PLL is enabled and configured for a 28.63636MHz input clock.
With the default board config these registers are not touched
at all, so this must be a remnant of testing with another board
number. Please repeat with pll=35,35,35,35 .

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


Your Unclaimed Fund Payment

2014-01-26 Thread Ellie Smit


GOODnbsp;NEWS.pdf
Description: Adobe PDF document


Re: Developers blogs

2014-01-26 Thread Antti Palosaari

Hi Jahn

On 22.01.2014 11:16, Jahn wrote:

  Hi everyone,
I am a newbie in V4L fields so I
   search for various info about V4L to study available details
  I am happy I found few blogs that provides
  interesting  information
  e.g.
  http://blog.palosaari.fi/


=) My plan has been share some hardware level information, mostly from 
consumer market USB DTV devices, as those are the devices I am familiar. 
Give some general info how these sticks are are build on a level chips 
are interconnected, from the driver developer point of view. One thing 
what I have tried to tell is how to gather needed information using some 
common reverse-engineering techniques, needed by about every Linux 
developer working with these devices.


One thing I would like to do is demodulator reverse-engineering 
tutorial. Unfortunately I haven't found suitable example yet, as it 
should be some DVB USB device having existing drivers for USB interface 
and RF tuner, and simple USB protocol. EC100/EC168 is one very good 
example, but unfortunately I have done its driver ages back. Maybe I 
should rewrite it from the scratch :)




  http://www.kernellabs.com/blog/?page_id=2066


Especially I like to read those articles related of sniffing hardware 
directly from the bus (I2C, IF, ...).




  but if I found even more 


I think it would be a good idea  if anyone
  in the vger.kernel.org list could provide his blog's ( website) address
  so that we can share knowledge   together.
  What do you think?



regards
Antti

--
http://palosaari.fi/
--
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: Conexant PCI-8604PW 4 channel BNC Video capture card (bttv)

2014-01-26 Thread Robert Longbottom

On 26/01/14 12:55, Daniel Glöckner wrote:

On Sun, Jan 26, 2014 at 11:21:31AM +, Robert Longbottom wrote:

0F0 00F9 PLL_F_LO
0F4 00DC PLL_F_HI
0F8 008E PLL_XCI


The PLL is enabled and configured for a 28.63636MHz input clock.
With the default board config these registers are not touched
at all, so this must be a remnant of testing with another board
number. Please repeat with pll=35,35,35,35 .


Ah, yes, sorry about that, it will be the result of me messing around 
trying different things in the hope I can stumble across something that 
works.


robert@quad ~ $ sudo rmmod bttv
robert@quad ~ $ sudo modprobe bttv pll=35,35,35,35
robert@quad ~ $ xawtv -c /dev/video0

robert@quad ~/dev/8604PW $ sudo ./dumpbt8xx /dev/video0  dumpbt8xx.data

produces:

000 00D7 DSTATUS
004 0053 IFORM
008  TDEC
00C 00D2 E_CROP
010 00FE E_VDELAY_LO
014 00E0 E_VACTIVE_LO
018 0078 E_HDELAY_LO
01C 0080 E_HACTIVE_LO
020 0002 E_HSCALE_HI
024 00AC E_HSCALE_LO
028  BRIGHT
02C 0022 E_CONTROL
030 00D8 CONTRAST_LO
034  SAT_U_LO
038 00B5 SAT_V_LO
03C  HUE
040  E_SCLOOP
044 00CF WC_UP
048 0006 OFORM
04C 0020 E_VSCALE_HI
050  E_VSCALE_LO
054 0001 TEST
058  ARESET
060 007F ADELAY
064 0072 BDELAY
068 0081 ADC
06C  E_VTC
078 007F WC_DOWN
080 007F TGLB
084  TGCTRL
08C 00D2 O_CROP
090 00FE O_VDELAY_LO
094 00E0 O_VACTIVE_LO
098 0078 O_HDELAY_LO
09C 0080 O_HACTIVE_LO
0A0 0002 O_HSCALE_HI
0A4 00AC O_HSCALE_LO
0AC 0022 O_CONTROL
0B0  VTOTAL_LO
0B4  VTOTAL_HI
0C0  O_SCLOOP
0CC 0020 O_VSCALE_HI
0D0  O_VSCALE_LO
0D4  COLOR_FMT
0D8 0010 COLOR_CTL
0DC 0003 CAP_CTL
0E0 00FF VBI_PACK_SIZE
0E4 0001 VBI_PACK_DEL
0E8 0082 FCAP
0EC  O_VTC
0F0  PLL_F_LO
0F4  PLL_F_HI
0F8  PLL_XCI
0FC  DVSIF
100 0A0C INT_STAT
104 000C0B13 INT_MASK
10C C0AF GPIO_DMA_CTL
110 0003 I2C
114 32734000 RISC_STRT_ADD
118  GPIO_OUT_EN
11C  GPIO_REG_INP
120 32734000 RISC_COUNT
200 000F GPIO_DATA

and /var/log/messages still fills up with timeouts

Jan 26 16:13:59 quad sudo:   robert : TTY=pts/1 ; PWD=/home/robert ; 
USER=root ; COMMAND=/sbin/modprobe bttv pll=35,35,35,35
Jan 26 16:13:59 quad sudo: pam_unix(sudo:session): session opened for 
user root by robert(uid=0)
Jan 26 16:13:59 quad kernel: [13524.035909] bttv: driver version 0.9.19 
loaded
Jan 26 16:13:59 quad kernel: [13524.035918] bttv: using 8 buffers with 
2080k (520 pages) each for capture

Jan 26 16:13:59 quad kernel: [13524.036015] bttv: Bt8xx card found (0)
Jan 26 16:13:59 quad kernel: [13524.036050] bttv: 0: Bt878 (rev 17) at 
:02:0c.0, irq: 16, latency: 32, mmio: 0xd500
Jan 26 16:13:59 quad kernel: [13524.036639] bttv: 0: using:  *** 
UNKNOWN/GENERIC ***  [card=0,autodetected]

Jan 26 16:13:59 quad kernel: [13524.082056] bttv: 0: tuner type unset
Jan 26 16:13:59 quad kernel: [13524.082366] bttv: 0: registered device 
video0

Jan 26 16:13:59 quad kernel: [13524.082418] bttv: 0: registered device vbi0
Jan 26 16:13:59 quad kernel: [13524.082447] bttv: 0: PLL can sleep, 
using XTAL (35468950)

Jan 26 16:13:59 quad kernel: [13524.086752] bttv: Bt8xx card found (1)
Jan 26 16:13:59 quad kernel: [13524.086804] bttv: 1: Bt878 (rev 17) at 
:02:0d.0, irq: 17, latency: 32, mmio: 0xd5002000
Jan 26 16:13:59 quad kernel: [13524.086933] bttv: 1: using:  *** 
UNKNOWN/GENERIC ***  [card=0,autodetected]
Jan 26 16:13:59 quad kernel: [13524.088195] tveeprom 5-0050: Huh, no 
eeprom present (err=-6)?

Jan 26 16:13:59 quad kernel: [13524.088206] bttv: 1: tuner type unset
Jan 26 16:13:59 quad kernel: [13524.088317] bttv: 1: registered device 
video1

Jan 26 16:13:59 quad kernel: [13524.088350] bttv: 1: registered device vbi1
Jan 26 16:13:59 quad kernel: [13524.088373] bttv: 1: PLL can sleep, 
using XTAL (35468950)

Jan 26 16:13:59 quad kernel: [13524.092691] bttv: Bt8xx card found (2)
Jan 26 16:13:59 quad kernel: [13524.092729] bttv: 2: Bt878 (rev 17) at 
:02:0e.0, irq: 18, latency: 32, mmio: 0xd5004000
Jan 26 16:13:59 quad kernel: [13524.092802] bttv: 2: using:  *** 
UNKNOWN/GENERIC ***  [card=0,autodetected]
Jan 26 16:13:59 quad kernel: [13524.093704] tveeprom 6-0050: Huh, no 
eeprom present (err=-6)?

Jan 26 16:13:59 quad kernel: [13524.093711] bttv: 2: tuner type unset
Jan 26 16:13:59 quad kernel: [13524.093854] bttv: 2: registered device 
video2

Jan 26 16:13:59 quad kernel: [13524.093904] bttv: 2: registered device vbi2
Jan 26 16:13:59 quad kernel: [13524.093932] bttv: 2: PLL can sleep, 
using XTAL (35468950)

Jan 26 16:13:59 quad kernel: [13524.102337] bttv: Bt8xx card found (3)
Jan 26 16:13:59 quad kernel: [13524.102364] bttv: 3: Bt878 (rev 17) at 
:02:0f.0, irq: 19, latency: 32, mmio: 0xd5006000
Jan 26 16:13:59 quad kernel: [13524.102405] bttv: 3: using:  *** 
UNKNOWN/GENERIC ***  

FINANCE

2014-01-26 Thread FINANCE
Are you in any financial difficulty? or you want to start a new Business , 
Company , etc apply for Loan at 3% , EMAIL; adibfinan...@manager.in.th
--
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


[RFCv2 PATCH 0/5] rc: Add generic sysfs interface for handling wakeup codes

2014-01-26 Thread Antti Seppälä
I'm resending the patch series as it seems that my initial attempt was 
not delivered to patchwork or linux-media list. Apologies for duplicate 
emails to people who may have received the first attempt.


Patches 1  2 in this series introduce a simple sysfs file interface for
reading and writing wakeup scancodes or ir samples to rc drivers.

The interface is designed to be flexible yet easy enough to adapt to. It
can support almost any kind of known wakeup scancode and sample formats.

Patches 3-5 in the series port some existing drivers to use this 
interface.

Changes in v2:
 - Added wakeup_protocols file to control which protocol to use with 
wakeup
 - Renamed interface to wakeup_code
 - Clean-up device attribute registration
 - Ported winbond-cir to use this interface
 - Brought interface closer to 
https://patchwork.linuxtv.org/patch/21625/

Antti Seppälä (5):
  rc-core: Add defintions needed for sysfs callback
  rc-core: Add support for reading/writing wakeup codes via sysfs
  rc-loopback: Add support for reading/writing wakeup scancodes via
sysfs
  nuvoton-cir: Add support for reading/writing wakeup samples via sysfs
  winbond-cir: Add support for reading/writing wakeup scancodes via
sysfs

 drivers/media/rc/nuvoton-cir.c | 118 +++
 drivers/media/rc/nuvoton-cir.h |   2 +
 drivers/media/rc/rc-loopback.c |  40 +
 drivers/media/rc/rc-main.c | 179 +
 drivers/media/rc/winbond-cir.c |  66 ++-
 include/media/rc-core.h|  17 
 6 files changed, 390 insertions(+), 32 deletions(-)

-- 
1.8.3.2

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


[RFCv2 PATCH 3/5] rc-loopback: Add support for reading/writing wakeup scancodes via sysfs

2014-01-26 Thread Antti Seppälä
This patch adds sample support for reading/writing the wakeup scancodes
to rc-loopback device driver.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 drivers/media/rc/rc-loopback.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 53d0282..46e76ad 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -26,6 +26,7 @@
 #include linux/device.h
 #include linux/module.h
 #include linux/sched.h
+#include linux/slab.h
 #include media/rc-core.h
 
 #define DRIVER_NAMErc-loopback
@@ -45,6 +46,7 @@ struct loopback_dev {
bool carrierreport;
u32 rxcarriermin;
u32 rxcarriermax;
+   u32 wakeup_scancode;
 };
 
 static struct loopback_dev loopdev;
@@ -176,6 +178,41 @@ static int loop_set_carrier_report(struct rc_dev *dev, int 
enable)
return 0;
 }
 
+static int loop_wakeup_codes(struct rc_dev *dev,
+struct list_head *wakeup_code_list, int write)
+{
+   u32 value = 0;
+   struct rc_wakeup_code *code;
+   struct loopback_dev *lodev = dev-priv;
+
+   dprintk(%sing wakeup codes\n, write ? writ : read);
+
+   if (write) {
+   code = list_first_entry_or_null(wakeup_code_list,
+   struct rc_wakeup_code,
+   list_item);
+   if (code)
+   value = code-value;
+
+   if (dev-enabled_wake_protos  RC_BIT_RC5) {
+   if (value  0xFFF)
+   return -EINVAL;
+   } else if (dev-enabled_wake_protos  RC_BIT_RC6_0) {
+   if (value  0x)
+   return -EINVAL;
+   }
+
+   lodev-wakeup_scancode = value;
+   } else {
+   code = kmalloc(sizeof(struct rc_wakeup_code), GFP_KERNEL);
+   if (!code)
+   return -ENOMEM;
+   code-value = lodev-wakeup_scancode;
+   list_add_tail(code-list_item, wakeup_code_list);
+   }
+   return 0;
+}
+
 static int __init loop_init(void)
 {
struct rc_dev *rc;
@@ -196,6 +233,8 @@ static int __init loop_init(void)
rc-priv= loopdev;
rc-driver_type = RC_DRIVER_IR_RAW;
rc-allowed_protos  = RC_BIT_ALL;
+   rc-allowed_wake_protos = RC_BIT_RC6_0 | RC_BIT_RC5;
+   rc-enabled_wake_protos = RC_BIT_RC6_0;
rc-timeout = 100 * 1000 * 1000; /* 100 ms */
rc-min_timeout = 1;
rc-max_timeout = UINT_MAX;
@@ -209,6 +248,7 @@ static int __init loop_init(void)
rc-s_idle  = loop_set_idle;
rc-s_learning_mode = loop_set_learning_mode;
rc-s_carrier_report= loop_set_carrier_report;
+   rc-s_wakeup_codes  = loop_wakeup_codes;
 
loopdev.txmask  = RXMASK_REGULAR;
loopdev.txcarrier   = 36000;
-- 
1.8.3.2

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


[RFCv2 PATCH 5/5] winbond-cir: Add support for reading/writing wakeup scancodes via sysfs

2014-01-26 Thread Antti Seppälä
This patch adds support for reading/writing wakeup scancodes via sysfs
to nuvoton-cir hardware.

The existing mechanism of setting wakeup scancodes by using module
parameters is left untouched. If set the module parameters function as
default values for sysfs files.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 drivers/media/rc/winbond-cir.c | 66 ++
 1 file changed, 48 insertions(+), 18 deletions(-)

diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 904baf4..c63a56e 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -683,6 +683,29 @@ wbcir_tx(struct rc_dev *dev, unsigned *b, unsigned count)
return count;
 }
 
+static int wbcir_wakeup_codes(struct rc_dev *dev,
+ struct list_head *wakeup_code_list, int write)
+{
+   u32 value = 0x800F040C;
+   struct rc_wakeup_code *code;
+   if (write) {
+   code = list_first_entry_or_null(wakeup_code_list,
+   struct rc_wakeup_code,
+   list_item);
+   if (code)
+   value = code-value;
+
+   wake_sc = value;
+   } else {
+   code = kmalloc(sizeof(struct rc_wakeup_code), GFP_KERNEL);
+   if (!code)
+   return -ENOMEM;
+   code-value = wake_sc;
+   list_add_tail(code-list_item, wakeup_code_list);
+   }
+   return 0;
+}
+
 /*
  *
  * SETUP/INIT/SUSPEND/RESUME FUNCTIONS
@@ -708,12 +731,11 @@ wbcir_shutdown(struct pnp_dev *device)
goto finish;
}
 
-   switch (protocol) {
-   case IR_PROTOCOL_RC5:
+   if (data-dev-enabled_wake_protos  RC_BIT_RC5) {
if (wake_sc  0xFFF) {
do_wake = false;
dev_err(dev, RC5 - Invalid wake scancode\n);
-   break;
+   goto finish;
}
 
/* Mask = 13 bits, ex toggle */
@@ -726,13 +748,11 @@ wbcir_shutdown(struct pnp_dev *device)
if (!(wake_sc  0x0040)) /* 2nd start bit  */
match[1] |= 0x10;
 
-   break;
-
-   case IR_PROTOCOL_NEC:
+   } else if (data-dev-enabled_wake_protos  RC_BIT_NEC) {
if (wake_sc  0xFF) {
do_wake = false;
dev_err(dev, NEC - Invalid wake scancode\n);
-   break;
+   goto finish;
}
 
mask[0] = mask[1] = mask[2] = mask[3] = 0xFF;
@@ -745,16 +765,12 @@ wbcir_shutdown(struct pnp_dev *device)
match[2] = bitrev8((wake_sc  0xFF)  16);
else
match[2] = ~match[3];
-
-   break;
-
-   case IR_PROTOCOL_RC6:
-
+   } else if (data-dev-enabled_wake_protos  RC_BIT_RC6_0) {
if (wake_rc6mode == 0) {
if (wake_sc  0x) {
do_wake = false;
dev_err(dev, RC6 - Invalid wake scancode\n);
-   break;
+   goto finish;
}
 
/* Command */
@@ -810,7 +826,7 @@ wbcir_shutdown(struct pnp_dev *device)
} else {
do_wake = false;
dev_err(dev, RC6 - Invalid wake scancode\n);
-   break;
+   goto finish;
}
 
/* Header */
@@ -824,11 +840,8 @@ wbcir_shutdown(struct pnp_dev *device)
dev_err(dev, RC6 - Invalid wake mode\n);
}
 
-   break;
-
-   default:
+   } else {
do_wake = false;
-   break;
}
 
 finish:
@@ -1077,12 +1090,29 @@ wbcir_probe(struct pnp_dev *device, const struct 
pnp_device_id *dev_id)
data-dev-s_carrier_report = wbcir_set_carrier_report;
data-dev-s_tx_mask = wbcir_txmask;
data-dev-s_tx_carrier = wbcir_txcarrier;
+   data-dev-s_wakeup_codes = wbcir_wakeup_codes;
data-dev-tx_ir = wbcir_tx;
data-dev-priv = data;
data-dev-dev.parent = device-dev;
data-dev-timeout = MS_TO_NS(100);
data-dev-rx_resolution = US_TO_NS(2);
data-dev-allowed_protos = RC_BIT_ALL;
+   data-dev-allowed_wake_protos = RC_BIT_RC5 | RC_BIT_RC6_0 | RC_BIT_NEC;
+   /* Utilize default protocol from module parameter */
+   switch (protocol) {
+   case IR_PROTOCOL_RC5:
+   data-dev-enabled_wake_protos = RC_BIT_RC5;
+   break;
+   case IR_PROTOCOL_RC6:
+   

[RFCv2 PATCH 4/5] nuvoton-cir: Add support for reading/writing wakeup samples via sysfs

2014-01-26 Thread Antti Seppälä
This patch adds support for reading/writing wakeup samples via sysfs
to nuvoton-cir hardware.

The sysfs interface for nuvoton-cir contains raw IR pulse/space lengths.
If value is negative it is a space, otherwise it is a pulse.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 drivers/media/rc/nuvoton-cir.c | 118 +
 drivers/media/rc/nuvoton-cir.h |   2 +
 2 files changed, 120 insertions(+)

diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 21ee0dc..015f3a8 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -531,6 +531,121 @@ static int nvt_set_tx_carrier(struct rc_dev *dev, u32 
carrier)
return 0;
 }
 
+static int nvt_validate_wakeup_codes(struct list_head *wakeup_code_list)
+{
+   int i = 0;
+   const int MAX_SAMPLE = US_TO_NS(BUF_LEN_MASK * SAMPLE_PERIOD);
+   struct rc_wakeup_code *code;
+   list_for_each_entry(code, wakeup_code_list, list_item) {
+
+   /* Prevent writing too many or invalid codes */
+   if (++i  WAKE_FIFO_LEN)
+   return -EINVAL;
+   if (abs(code-value)  MAX_SAMPLE)
+   return -EINVAL;
+   }
+
+   return i;
+}
+
+static int nvt_wakeup_codes(struct rc_dev *dev,
+   struct list_head *wakeup_code_list, int write)
+{
+   int i = 0;
+   u8 cnt, val, reg, reg_learn_mode;
+   unsigned long flags;
+   struct rc_wakeup_code *code;
+   struct nvt_dev *nvt = dev-priv;
+
+   nvt_dbg_wake(%sing wakeup codes, write ? writ : read);
+
+   if (write) {
+
+   /* Validate wake codes (count and values) */
+   i = nvt_validate_wakeup_codes(wakeup_code_list);
+   if (i  0)
+   return -EINVAL;
+
+   reg = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
+   reg_learn_mode = reg  ~CIR_WAKE_IRCON_MODE0;
+   reg_learn_mode |= CIR_WAKE_IRCON_MODE1;
+
+   /* Lock the learn area to prevent racing with wake-isr */
+   spin_lock_irqsave(nvt-nvt_lock, flags);
+
+   /* Enable fifo writes */
+   nvt_cir_wake_reg_write(nvt, reg_learn_mode, CIR_WAKE_IRCON);
+
+   /* Clear cir wake rx fifo */
+   nvt_clear_cir_wake_fifo(nvt);
+
+   pr_info(Wake samples (%d) =, i);
+
+   /* Write wake samples to fifo */
+   list_for_each_entry(code, wakeup_code_list, list_item) {
+
+   /* Convert to driver format */
+   val = DIV_ROUND_UP(abs(code-value), 1000L)
+   / SAMPLE_PERIOD;
+
+   if (code-value  0)
+   val |= BUF_PULSE_BIT;
+
+   pr_cont( %02x, val);
+   nvt_cir_wake_reg_write(nvt, val,
+  CIR_WAKE_WR_FIFO_DATA);
+   }
+   pr_cont(\n);
+
+   /* Switch cir to wakeup mode and disable fifo writing */
+   nvt_cir_wake_reg_write(nvt, reg, CIR_WAKE_IRCON);
+
+   /* Set number of bytes needed for wake */
+   nvt_cir_wake_reg_write(nvt, i ? i :
+  CIR_WAKE_FIFO_CMP_BYTES,
+  CIR_WAKE_FIFO_CMP_DEEP);
+
+   spin_unlock_irqrestore(nvt-nvt_lock, flags);
+
+   } else {
+
+   /* Scroll to index 0 */
+   while (nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)) {
+   nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY);
+
+   /* Stuck index guardian */
+   if (++i  255) {
+   nvt_dbg_wake(Idx reg is stuck!);
+   break;
+   }
+   }
+
+   /* Get size of wake fifo and allocate memory for the bytes */
+   cnt = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT);
+
+   for (i = 0; i  cnt; i++) {
+   code = kmalloc(sizeof(struct rc_wakeup_code),
+  GFP_KERNEL | GFP_ATOMIC);
+   if (!code)
+   return -ENOMEM;
+
+   val = nvt_cir_wake_reg_read(nvt,
+   CIR_WAKE_RD_FIFO_ONLY);
+
+   /* Convert to human readable sample-pulse format */
+   code-value = US_TO_NS((val  BUF_LEN_MASK)
+  * SAMPLE_PERIOD);
+   if (!(val  BUF_PULSE_BIT))
+   code-value *= -1;
+
+   list_add_tail(code-list_item, wakeup_code_list);
+   }
+
+   return cnt;
+   }
+
+   return 0;
+}
 /*
  * nvt_tx_ir
  *
@@ 

[RFCv2 PATCH 1/5] rc-core: Add defintions needed for sysfs callback

2014-01-26 Thread Antti Seppälä
Introduce a list for wake code values and add callback for reading
/ writing it via sysfs.

Also introduce bitfields for setting which protocols are allowed and
enabled for wakeup.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 include/media/rc-core.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 2f6f1f7..e0e5699 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -20,6 +20,7 @@
 #include linux/kfifo.h
 #include linux/time.h
 #include linux/timer.h
+#include linux/list.h
 #include media/rc-map.h
 
 extern int rc_core_debug;
@@ -35,6 +36,16 @@ enum rc_driver_type {
 };
 
 /**
+ * struct rc_wakeup_code - represents a single IR scancode or pulse/space
+ * @value: scan code value or pulse (+) / space (-) length
+ * @list: linked list pointer
+ */
+struct rc_wakeup_code {
+   s32 value;
+   struct list_headlist_item;
+};
+
+/**
  * struct rc_dev - represents a remote control device
  * @dev: driver model's view of this device
  * @input_name: name of the input child device
@@ -52,6 +63,8 @@ enum rc_driver_type {
  * @idle: used to keep track of RX state
  * @allowed_protos: bitmask with the supported RC_BIT_* protocols
  * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols
+ * @allowed_wake_protos: bitmask with the supported RC_BIT_* protocols for 
wakeup
+ * @enabled_wake_protos: bitmask with the enabled RC_BIT_* protocols for wakeup
  * @scanmask: some hardware decoders are not capable of providing the full
  * scancode to the application. As this is a hardware limit, we can't do
  * anything with it. Yet, as the same keycode table can be used with other
@@ -84,6 +97,7 @@ enum rc_driver_type {
  * device doesn't interrupt host until it sees IR pulses
  * @s_learning_mode: enable wide band receiver used for learning
  * @s_carrier_report: enable carrier reports
+ * @s_wakeup_codes: set/get IR scancode to wake hardware from sleep states
  */
 struct rc_dev {
struct device   dev;
@@ -101,6 +115,8 @@ struct rc_dev {
boolidle;
u64 allowed_protos;
u64 enabled_protocols;
+   u64 allowed_wake_protos;
+   u64 enabled_wake_protos;
u32 users;
u32 scanmask;
void*priv;
@@ -127,6 +143,7 @@ struct rc_dev {
void(*s_idle)(struct rc_dev *dev, bool 
enable);
int (*s_learning_mode)(struct rc_dev *dev, 
int enable);
int (*s_carrier_report) (struct rc_dev 
*dev, int enable);
+   int (*s_wakeup_codes) (struct rc_dev *dev, 
struct list_head *wakeup_code_list, int write);
 };
 
 #define to_rc_dev(d) container_of(d, struct rc_dev, dev)
-- 
1.8.3.2

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


[RFCv2 PATCH 2/5] rc-core: Add support for reading/writing wakeup codes via sysfs

2014-01-26 Thread Antti Seppälä
This patch adds support for two files in sysfs controlling the wakeup
(scan)codes that are written to hardware.

* /sys/class/rc/rc?/wakeup_protocols:

This file has the same syntax as rc protocols file
(/sys/class/rc/rc?/protocols). When read it displays the wakeup
protocols the underlying IR driver supports. Protocol can be changed by
writing it to the file. The active protocol defines how actual
wakeup_code is to be interpreted.

Note: Only one protocol can be active at a time.

* /sys/class/rc/rc?/wakeup_codes:

This file contains the currently active wakeup (scan)code(s).
New values can be written to activate a new wakeup code.

The contents of the wakeup_code file are simply white space separated
values.

Note: Protocol other has a special meaning: if activated then
wakeup_codes file will contain raw IR samples. Positive values
represent pulses and negative values spaces.

How to read:
 cat /sys/class/rc/rc?/wakeup_codes

How to write:
 echo rc-6  /sys/class/rc/rc?/wakeup_protocols
 echo 0xd1ab  /sys/class/rc/rc?/wakeup_codes

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 drivers/media/rc/rc-main.c | 179 +
 1 file changed, 165 insertions(+), 14 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 02e2f38..cde17e2 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -797,7 +797,7 @@ static struct {
 /**
  * show_protocols() - shows the current IR protocol(s)
  * @device:the device descriptor
- * @mattr: the device attribute struct (unused)
+ * @mattr: the device attribute struct
  * @buf:   a pointer to the output buffer
  *
  * This routine is a callback routine for input read the IR protocol type(s).
@@ -822,14 +822,19 @@ static ssize_t show_protocols(struct device *device,
 
mutex_lock(dev-lock);
 
-   enabled = dev-enabled_protocols;
-   if (dev-driver_type == RC_DRIVER_SCANCODE)
-   allowed = dev-allowed_protos;
-   else if (dev-raw)
-   allowed = ir_raw_get_allowed_protocols();
-   else {
-   mutex_unlock(dev-lock);
-   return -ENODEV;
+   if (strcmp(mattr-attr.name, wakeup_protocols) == 0) {
+   enabled = dev-enabled_wake_protos;
+   allowed = dev-allowed_wake_protos;
+   } else {
+   enabled = dev-enabled_protocols;
+   if (dev-driver_type == RC_DRIVER_SCANCODE)
+   allowed = dev-allowed_protos;
+   else if (dev-raw)
+   allowed = ir_raw_get_allowed_protocols();
+   else {
+   mutex_unlock(dev-lock);
+   return -ENODEV;
+   }
}
 
IR_dprintk(1, allowed - 0x%llx, enabled - 0x%llx\n,
@@ -858,7 +863,7 @@ static ssize_t show_protocols(struct device *device,
 /**
  * store_protocols() - changes the current IR protocol(s)
  * @device:the device descriptor
- * @mattr: the device attribute struct (unused)
+ * @mattr: the device attribute struct
  * @buf:   a pointer to the input buffer
  * @len:   length of the input buffer
  *
@@ -884,7 +889,7 @@ static ssize_t store_protocols(struct device *device,
const char *tmp;
u64 type;
u64 mask;
-   int rc, i, count = 0;
+   int rc, i, wake = 0, count = 0, enablecount = 0;
ssize_t ret;
 
/* Device is being removed */
@@ -898,7 +903,13 @@ static ssize_t store_protocols(struct device *device,
ret = -EINVAL;
goto out;
}
-   type = dev-enabled_protocols;
+
+   if (strcmp(mattr-attr.name, wakeup_protocols) == 0) {
+   wake = 1;
+   type = dev-enabled_wake_protos;
+   } else {
+   type = dev-enabled_protocols;
+   }
 
while ((tmp = strsep((char **) data,  \n)) != NULL) {
if (!*tmp)
@@ -920,6 +931,8 @@ static ssize_t store_protocols(struct device *device,
for (i = 0; i  ARRAY_SIZE(proto_names); i++) {
if (!strcasecmp(tmp, proto_names[i].name)) {
mask = proto_names[i].type;
+   if (wake  (enable || (!enable  !disable)))
+   enablecount++;
break;
}
}
@@ -946,7 +959,7 @@ static ssize_t store_protocols(struct device *device,
goto out;
}
 
-   if (dev-change_protocol) {
+   if (dev-change_protocol  !wake) {
rc = dev-change_protocol(dev, type);
if (rc  0) {
IR_dprintk(1, Error setting protocols to 0x%llx\n,
@@ -956,7 +969,16 @@ static ssize_t store_protocols(struct device *device,
}
}
 
-   dev-enabled_protocols = type;
+   if (wake  enablecount  1) {
+   IR_dprintk(1, Only one 

Re: [PATCH] uvc: update uvc_endpoint_max_bpi to handle USB_SPEED_WIRELESS devices

2014-01-26 Thread Laurent Pinchart
Hi Thomas,

Thank you for the patch.

On Friday 24 January 2014 15:17:28 Thomas Pugliese wrote:
 Isochronous endpoints on devices with speed == USB_SPEED_WIRELESS can
 have a max packet size ranging from 1-3584 bytes.  Add a case to
 uvc_endpoint_max_bpi to handle USB_SPEED_WIRELESS.  Otherwise endpoints
 for those devices will fall to the default case which masks off any
 values  2047.  This causes uvc_init_video to underestimate the
 bandwidth available and fail to find a suitable alt setting for high
 bandwidth video streams.

I'm not too familiar with wireless USB, but shouldn't the value be multiplied 
by bMaxBurst from the endpoint companion descriptor ? Superspeed devices 
provide the multiplied value in their endpoint companion descriptor's 
wBytesPerInterval field, but there's no such field for wireless devices.

Out of curiosity, which device have you tested this with ?

 Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
 ---
  drivers/media/usb/uvc/uvc_video.c | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/drivers/media/usb/uvc/uvc_video.c
 b/drivers/media/usb/uvc/uvc_video.c index 898c208..103cd4e 100644
 --- a/drivers/media/usb/uvc/uvc_video.c
 +++ b/drivers/media/usb/uvc/uvc_video.c
 @@ -1453,6 +1453,9 @@ static unsigned int uvc_endpoint_max_bpi(struct
 usb_device *dev, case USB_SPEED_HIGH:
   psize = usb_endpoint_maxp(ep-desc);
   return (psize  0x07ff) * (1 + ((psize  11)  3));
 + case USB_SPEED_WIRELESS:
 + psize = usb_endpoint_maxp(ep-desc);
 + return psize;
   default:
   psize = usb_endpoint_maxp(ep-desc);
   return psize  0x07ff;

-- 
Regards,

Laurent Pinchart

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


Kind Regards

2014-01-26 Thread Abdul Nasser
Greetings,
My name is Abdul Nasser Sokariah and I am writing you from Syria, I choose to 
contact you directly as I need a reliable person to trust who can help me 
handle my huge deposit  with a vault company in EUROPE, and based on my present 
situation in Syria, I need you urgently to take possession of everything and 
further modalities/directives will follow.Please reply to my private  Email: 
nasserabdul...@yahoo.com

I wait for your response.

Yours truly,
Abdul Nasser Sokariah
--
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


Kind Regards

2014-01-26 Thread Abdul Nasser
Greetings,
My name is Abdul Nasser Sokariah and I am writing you from Syria, I choose to 
contact you directly as I need a reliable person to trust who can help me 
handle my huge deposit  with a vault company in EUROPE, and based on my present 
situation in Syria, I need you urgently to take possession of everything and 
further modalities/directives will follow.Please reply to my private  Email: 
nasserabdul...@yahoo.com

I wait for your response.

Yours truly,
Abdul Nasser Sokariah
--
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


Kind Regards

2014-01-26 Thread Abdul Nasser
Greetings,
My name is Abdul Nasser Sokariah and I am writing you from Syria, I choose to 
contact you directly as I need a reliable person to trust who can help me 
handle my huge deposit  with a vault company in EUROPE, and based on my present 
situation in Syria, I need you urgently to take possession of everything and 
further modalities/directives will follow.Please reply to my private  Email: 
nasserabdul...@yahoo.com

I wait for your response.

Yours truly,
Abdul Nasser Sokariah
--
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/3] e4000: convert DVB tuner to I2C driver model

2014-01-26 Thread Antti Palosaari
Driver conversion from proprietary DVB tuner model to more
general I2C driver model.

Cc: Jean Delvare kh...@linux-fr.org
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/e4000.c| 115 
 drivers/media/tuners/e4000.h|  21 ++
 drivers/media/tuners/e4000_priv.h   |   5 +-
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c |  41 +---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.h |   1 +
 5 files changed, 111 insertions(+), 72 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 40c1da7..0153169 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -31,7 +31,7 @@ static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 
*val, int len)
u8 buf[MAX_XFER_SIZE];
struct i2c_msg msg[1] = {
{
-   .addr = priv-cfg-i2c_addr,
+   .addr = priv-client-addr,
.flags = 0,
.len = 1 + len,
.buf = buf,
@@ -39,7 +39,7 @@ static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 
*val, int len)
};
 
if (1 + len  sizeof(buf)) {
-   dev_warn(priv-i2c-dev,
+   dev_warn(priv-client-dev,
 %s: i2c wr reg=%04x: len=%d is too big!\n,
 KBUILD_MODNAME, reg, len);
return -EINVAL;
@@ -48,11 +48,11 @@ static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, 
u8 *val, int len)
buf[0] = reg;
memcpy(buf[1], val, len);
 
-   ret = i2c_transfer(priv-i2c, msg, 1);
+   ret = i2c_transfer(priv-client-adapter, msg, 1);
if (ret == 1) {
ret = 0;
} else {
-   dev_warn(priv-i2c-dev,
+   dev_warn(priv-client-dev,
%s: i2c wr failed=%d reg=%02x len=%d\n,
KBUILD_MODNAME, ret, reg, len);
ret = -EREMOTEIO;
@@ -67,12 +67,12 @@ static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, 
u8 *val, int len)
u8 buf[MAX_XFER_SIZE];
struct i2c_msg msg[2] = {
{
-   .addr = priv-cfg-i2c_addr,
+   .addr = priv-client-addr,
.flags = 0,
.len = 1,
.buf = reg,
}, {
-   .addr = priv-cfg-i2c_addr,
+   .addr = priv-client-addr,
.flags = I2C_M_RD,
.len = len,
.buf = buf,
@@ -80,18 +80,18 @@ static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, 
u8 *val, int len)
};
 
if (len  sizeof(buf)) {
-   dev_warn(priv-i2c-dev,
+   dev_warn(priv-client-dev,
 %s: i2c rd reg=%04x: len=%d is too big!\n,
 KBUILD_MODNAME, reg, len);
return -EINVAL;
}
 
-   ret = i2c_transfer(priv-i2c, msg, 2);
+   ret = i2c_transfer(priv-client-adapter, msg, 2);
if (ret == 2) {
memcpy(val, buf, len);
ret = 0;
} else {
-   dev_warn(priv-i2c-dev,
+   dev_warn(priv-client-dev,
%s: i2c rd failed=%d reg=%02x len=%d\n,
KBUILD_MODNAME, ret, reg, len);
ret = -EREMOTEIO;
@@ -117,7 +117,7 @@ static int e4000_init(struct dvb_frontend *fe)
struct e4000_priv *priv = fe-tuner_priv;
int ret;
 
-   dev_dbg(priv-i2c-dev, %s:\n, __func__);
+   dev_dbg(priv-client-dev, %s:\n, __func__);
 
if (fe-ops.i2c_gate_ctrl)
fe-ops.i2c_gate_ctrl(fe, 1);
@@ -186,7 +186,7 @@ err:
if (fe-ops.i2c_gate_ctrl)
fe-ops.i2c_gate_ctrl(fe, 0);
 
-   dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
 
@@ -195,7 +195,7 @@ static int e4000_sleep(struct dvb_frontend *fe)
struct e4000_priv *priv = fe-tuner_priv;
int ret;
 
-   dev_dbg(priv-i2c-dev, %s:\n, __func__);
+   dev_dbg(priv-client-dev, %s:\n, __func__);
 
if (fe-ops.i2c_gate_ctrl)
fe-ops.i2c_gate_ctrl(fe, 1);
@@ -212,7 +212,7 @@ err:
if (fe-ops.i2c_gate_ctrl)
fe-ops.i2c_gate_ctrl(fe, 0);
 
-   dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
 
@@ -224,7 +224,7 @@ static int e4000_set_params(struct dvb_frontend *fe)
unsigned int f_vco;
u8 buf[5], i_data[4], q_data[4];
 
-   dev_dbg(priv-i2c-dev,
+   dev_dbg(priv-client-dev,
%s: delivery_system=%d frequency=%d bandwidth_hz=%d\n,

[PATCH 3/3] rtl2832_sdr: expose E4000 gain controls to user space

2014-01-26 Thread Antti Palosaari
Provide E4000 gain controls to userspace via V4L2 API. LNA, Mixer
and IF gain controls are offered, each one both manual and automode.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/staging/media/rtl2832u_sdr/Makefile  |   1 +
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 115 +--
 2 files changed, 88 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/Makefile 
b/drivers/staging/media/rtl2832u_sdr/Makefile
index 1009276..7e00a0d 100644
--- a/drivers/staging/media/rtl2832u_sdr/Makefile
+++ b/drivers/staging/media/rtl2832u_sdr/Makefile
@@ -2,4 +2,5 @@ obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
 
 ccflags-y += -Idrivers/media/dvb-core
 ccflags-y += -Idrivers/media/dvb-frontends
+ccflags-y += -Idrivers/media/tuners
 ccflags-y += -Idrivers/media/usb/dvb-usb-v2
diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index fccb16f..ee72233 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -25,6 +25,7 @@
 #include dvb_frontend.h
 #include rtl2832_sdr.h
 #include dvb_usb.h
+#include e4000.h
 
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
@@ -147,9 +148,14 @@ struct rtl2832_sdr_state {
u32 pixelformat;
 
/* Controls */
-   struct v4l2_ctrl_handler ctrl_handler;
+   struct v4l2_ctrl_handler hdl;
+   struct v4l2_ctrl *lna_gain_auto;
+   struct v4l2_ctrl *lna_gain;
+   struct v4l2_ctrl *mixer_gain_auto;
+   struct v4l2_ctrl *mixer_gain;
+   struct v4l2_ctrl *if_gain_auto;
+   struct v4l2_ctrl *if_gain;
struct v4l2_ctrl *ctrl_tuner_bw;
-   struct v4l2_ctrl *ctrl_tuner_gain;
 
/* for sample rate calc */
unsigned int sample;
@@ -917,10 +923,49 @@ err:
return;
 };
 
+static int rtl2832_sdr_set_gain_e4000(struct rtl2832_sdr_state *s)
+{
+   int ret;
+   struct dvb_frontend *fe = s-fe;
+   struct e4000_ctrl ctrl;
+   dev_dbg(s-udev-dev, %s: lna=%d mixer=%d if=%d\n, __func__,
+   s-lna_gain-val, s-mixer_gain-val, s-if_gain-val);
+
+   ctrl.lna_gain = s-lna_gain_auto-val ? INT_MIN : s-lna_gain-val;
+   ctrl.mixer_gain = s-mixer_gain_auto-val ? INT_MIN : 
s-mixer_gain-val;
+   ctrl.if_gain = s-if_gain_auto-val ? INT_MIN : s-if_gain-val;
+
+   if (fe-ops.tuner_ops.set_config) {
+   ret = fe-ops.tuner_ops.set_config(fe, ctrl);
+   if (ret)
+   goto err;
+   }
+
+   return 0;
+err:
+   dev_dbg(s-udev-dev, %s: failed %d\n, __func__, ret);
+   return ret;
+};
+
+static int rtl2832_sdr_set_gain(struct rtl2832_sdr_state *s)
+{
+   int ret;
+
+   switch (s-cfg-tuner) {
+   case RTL2832_TUNER_E4000:
+   ret = rtl2832_sdr_set_gain_e4000(s);
+   break;
+   default:
+   ret = 0;
+   }
+   return ret;
+}
+
 static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state *s)
 {
struct dvb_frontend *fe = s-fe;
struct dtv_frontend_properties *c = fe-dtv_property_cache;
+   int ret;
 
/*
 * tuner RF (Hz)
@@ -932,14 +977,9 @@ static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state 
*s)
 */
unsigned int bandwidth = s-ctrl_tuner_bw-val;
 
-   /*
-* gain (dB)
-*/
-   int gain = s-ctrl_tuner_gain-val;
-
dev_dbg(s-udev-dev,
-   %s: f_rf=%u bandwidth=%d gain=%d\n,
-   __func__, f_rf, bandwidth, gain);
+   %s: f_rf=%u bandwidth=%d\n,
+   __func__, f_rf, bandwidth);
 
if (f_rf == 0)
return 0;
@@ -961,6 +1001,8 @@ static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state 
*s)
if (fe-ops.tuner_ops.set_params)
fe-ops.tuner_ops.set_params(fe);
 
+   ret = rtl2832_sdr_set_gain(s);
+
return 0;
 };
 
@@ -1290,7 +1332,7 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
 {
struct rtl2832_sdr_state *s =
container_of(ctrl-handler, struct rtl2832_sdr_state,
-   ctrl_handler);
+   hdl);
int ret;
dev_dbg(s-udev-dev,
%s: id=%d name=%s val=%d min=%d max=%d step=%d\n,
@@ -1302,6 +1344,15 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
case RTL2832_SDR_CID_TUNER_GAIN:
ret = rtl2832_sdr_set_tuner(s);
break;
+   case  V4L2_CID_LNA_GAIN_AUTO:
+   case  V4L2_CID_LNA_GAIN:
+   case  V4L2_CID_MIXER_GAIN_AUTO:
+   case  V4L2_CID_MIXER_GAIN:
+   case  V4L2_CID_IF_GAIN_AUTO:
+   case  V4L2_CID_IF_GAIN:
+   dev_dbg(s-udev-dev, %s: GAIN IOCTL\n, __func__);
+   ret = rtl2832_sdr_set_gain(s);
+   break;
default:
ret = -EINVAL;
 

[PATCH 2/3] e4000: add manual gain controls

2014-01-26 Thread Antti Palosaari
Add gain control for LNA, Mixer and IF. Expose controls via DVB
frontend .set_config callback.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/e4000.c  | 68 +++
 drivers/media/tuners/e4000.h  |  6 
 drivers/media/tuners/e4000_priv.h | 63 
 3 files changed, 137 insertions(+)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 0153169..651de11 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -385,6 +385,73 @@ static int e4000_get_if_frequency(struct dvb_frontend *fe, 
u32 *frequency)
return 0;
 }
 
+static int e4000_set_config(struct dvb_frontend *fe, void *priv_cfg)
+{
+   struct e4000_priv *priv = fe-tuner_priv;
+   struct e4000_ctrl *ctrl = priv_cfg;
+   int ret;
+   u8 buf[2];
+   u8 u8tmp;
+   dev_dbg(priv-client-dev, %s: lna=%d mixer=%d if=%d\n, __func__,
+   ctrl-lna_gain, ctrl-mixer_gain, ctrl-if_gain);
+
+   if (fe-ops.i2c_gate_ctrl)
+   fe-ops.i2c_gate_ctrl(fe, 1);
+
+   if (ctrl-lna_gain == INT_MIN  ctrl-if_gain == INT_MIN)
+   u8tmp = 0x17;
+   else if (ctrl-lna_gain == INT_MIN)
+   u8tmp = 0x19;
+   else if (ctrl-if_gain == INT_MIN)
+   u8tmp = 0x16;
+   else
+   u8tmp = 0x10;
+
+   ret = e4000_wr_reg(priv, 0x1a, u8tmp);
+   if (ret)
+   goto err;
+
+   if (ctrl-mixer_gain == INT_MIN)
+   u8tmp = 0x15;
+   else
+   u8tmp = 0x14;
+
+   ret = e4000_wr_reg(priv, 0x20, u8tmp);
+   if (ret)
+   goto err;
+
+   if (ctrl-lna_gain != INT_MIN) {
+   ret = e4000_wr_reg(priv, 0x14, ctrl-lna_gain);
+   if (ret)
+   goto err;
+   }
+
+   if (ctrl-mixer_gain != INT_MIN) {
+   ret = e4000_wr_reg(priv, 0x15, ctrl-mixer_gain);
+   if (ret)
+   goto err;
+   }
+
+   if (ctrl-if_gain != INT_MIN) {
+   buf[0] = e4000_if_gain_lut[ctrl-if_gain].reg16_val;
+   buf[1] = e4000_if_gain_lut[ctrl-if_gain].reg17_val;
+   ret = e4000_wr_regs(priv, 0x16, buf, 2);
+   if (ret)
+   goto err;
+   }
+
+   if (fe-ops.i2c_gate_ctrl)
+   fe-ops.i2c_gate_ctrl(fe, 0);
+
+   return 0;
+err:
+   if (fe-ops.i2c_gate_ctrl)
+   fe-ops.i2c_gate_ctrl(fe, 0);
+
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
+   return ret;
+}
+
 static const struct dvb_tuner_ops e4000_tuner_ops = {
.info = {
.name   = Elonics E4000,
@@ -395,6 +462,7 @@ static const struct dvb_tuner_ops e4000_tuner_ops = {
.init = e4000_init,
.sleep = e4000_sleep,
.set_params = e4000_set_params,
+   .set_config = e4000_set_config,
 
.get_if_frequency = e4000_get_if_frequency,
 };
diff --git a/drivers/media/tuners/e4000.h b/drivers/media/tuners/e4000.h
index e74b8b2..d95c472 100644
--- a/drivers/media/tuners/e4000.h
+++ b/drivers/media/tuners/e4000.h
@@ -40,4 +40,10 @@ struct e4000_config {
u32 clock;
 };
 
+struct e4000_ctrl {
+   int lna_gain;
+   int mixer_gain;
+   int if_gain;
+};
+
 #endif
diff --git a/drivers/media/tuners/e4000_priv.h 
b/drivers/media/tuners/e4000_priv.h
index 8f45a30..a75a383 100644
--- a/drivers/media/tuners/e4000_priv.h
+++ b/drivers/media/tuners/e4000_priv.h
@@ -145,4 +145,67 @@ static const struct e4000_if_filter e4000_if_filter_lut[] 
= {
{ 0x, 0x00, 0x20 },
 };
 
+struct e4000_if_gain {
+   u8 reg16_val;
+   u8 reg17_val;
+};
+
+static const struct e4000_if_gain e4000_if_gain_lut[] = {
+   {0x00, 0x00},
+   {0x20, 0x00},
+   {0x40, 0x00},
+   {0x02, 0x00},
+   {0x22, 0x00},
+   {0x42, 0x00},
+   {0x04, 0x00},
+   {0x24, 0x00},
+   {0x44, 0x00},
+   {0x01, 0x00},
+   {0x21, 0x00},
+   {0x41, 0x00},
+   {0x03, 0x00},
+   {0x23, 0x00},
+   {0x43, 0x00},
+   {0x05, 0x00},
+   {0x25, 0x00},
+   {0x45, 0x00},
+   {0x07, 0x00},
+   {0x27, 0x00},
+   {0x47, 0x00},
+   {0x0f, 0x00},
+   {0x2f, 0x00},
+   {0x4f, 0x00},
+   {0x17, 0x00},
+   {0x37, 0x00},
+   {0x57, 0x00},
+   {0x1f, 0x00},
+   {0x3f, 0x00},
+   {0x5f, 0x00},
+   {0x1f, 0x01},
+   {0x3f, 0x01},
+   {0x5f, 0x01},
+   {0x1f, 0x02},
+   {0x3f, 0x02},
+   {0x5f, 0x02},
+   {0x1f, 0x03},
+   {0x3f, 0x03},
+   {0x5f, 0x03},
+   {0x1f, 0x04},
+   {0x3f, 0x04},
+   {0x5f, 0x04},
+   {0x1f, 0x0c},
+   {0x3f, 0x0c},
+   {0x5f, 0x0c},
+   {0x1f, 0x14},
+   {0x3f, 0x14},
+   {0x5f, 0x14},
+   {0x1f, 0x1c},
+   {0x3f, 0x1c},
+   {0x5f, 0x1c},
+   {0x1f, 0x24},
+   {0x3f, 0x24},
+   

Re: [PATCH 1/3] e4000: convert DVB tuner to I2C driver model

2014-01-26 Thread Devin Heitmueller
On Sun, Jan 26, 2014 at 7:16 PM, Antti Palosaari cr...@iki.fi wrote:
 Driver conversion from proprietary DVB tuner model to more
 general I2C driver model.

Mike should definitely weigh in on this.  Eliminating the existing
model of using dvb_attach() for tuners is something that needs to be
considered carefully, and this course of action should be agreed on by
the subsystem maintainers before we start converting drivers.  This
could be particularly relevant for hybrid tuners where the driver
instance is instantiated via tuner-core using dvb_attach() for the
analog side.

In the meantime, this change makes this driver work differently than
every other tuner in the tree.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
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 1/3] e4000: convert DVB tuner to I2C driver model

2014-01-26 Thread Antti Palosaari

On 27.01.2014 02:28, Devin Heitmueller wrote:

On Sun, Jan 26, 2014 at 7:16 PM, Antti Palosaari cr...@iki.fi wrote:

Driver conversion from proprietary DVB tuner model to more
general I2C driver model.


Mike should definitely weigh in on this.  Eliminating the existing
model of using dvb_attach() for tuners is something that needs to be
considered carefully, and this course of action should be agreed on by
the subsystem maintainers before we start converting drivers.  This
could be particularly relevant for hybrid tuners where the driver
instance is instantiated via tuner-core using dvb_attach() for the
analog side.

In the meantime, this change makes this driver work differently than
every other tuner in the tree.


Heh, it is quite stupid to do things otherwise than rest of the kernel 
and also I think it is against i2c documentation. For more we refuse to 
use kernel standard practices the more there will be problems in a long ran.


There is things that are build top of these standard models and if you 
are using some proprietary method, then you are without these services. 
I think it was regmap which I was looking once, but dropped it as it 
requires i2c client.


Also, I already implemented one tuner driver using standard I2C model. 
If there will be problems then those are surely fixable.


regards
Antti

--
http://palosaari.fi/
--
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: Conexant PCI-8604PW 4 channel BNC Video capture card (bttv)

2014-01-26 Thread Daniel Glöckner
On Sun, Jan 26, 2014 at 04:23:06PM +, Robert Longbottom wrote:
 000 00D7 DSTATUS
 114 32734000 RISC_STRT_ADD
 120 32734000 RISC_COUNT

Video is present and locked but the RISC counter is stuck at the start
address. My best guess is that the CPLD is not forwarding the REQ signal
to the PCI bridge, so the BT878A can't fetch the RISC instructions.
But then there is also this persistent ADC overflow...

As for the CPLD, there is not much we can do. I count 23 GPIOs going
to that chip. And we don't know if some of these are outputs of the
CPLD, making it a bit risky to just randomly drive values on those
pins.

If we had the original software, we could analyze what it is doing.
There is someone on ebay.com selling two of those cards and a cd
labled Rescue Disk Version 1.14 for Linux DVR.

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


cron job: media_tree daily build: WARNINGS

2014-01-26 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:   Mon Jan 27 04:00:35 CET 2014
git branch: test
git hash:   587d1b06e07b4a079453c74ba9edf17d21931049
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.12-6.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: WARNINGS
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: 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.31.14-i686: WARNINGS
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12-i686: OK
linux-3.13-i686: OK
linux-2.6.31.14-x86_64: WARNINGS
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12-x86_64: OK
linux-3.13-x86_64: OK
apps: OK
spec-git: OK
sparse version: 0.4.5-rc1
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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


[PATCH 2/2] rtl2832_sdr: expose R820 gain controls to user space

2014-01-26 Thread Antti Palosaari
Provide R820 gain controls to userspace via V4L2 API. LNA, Mixer
and IF gain controls are offered, each one both manual and automode.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 41 
 1 file changed, 41 insertions(+)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index ee72233..69fc996 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -26,6 +26,7 @@
 #include rtl2832_sdr.h
 #include dvb_usb.h
 #include e4000.h
+#include r820t.h
 
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
@@ -947,6 +948,30 @@ err:
return ret;
 };
 
+static int rtl2832_sdr_set_gain_r820t(struct rtl2832_sdr_state *s)
+{
+   int ret;
+   struct dvb_frontend *fe = s-fe;
+   struct r820t_ctrl ctrl;
+   dev_dbg(s-udev-dev, %s: lna=%d mixer=%d if=%d\n, __func__,
+   s-lna_gain-val, s-mixer_gain-val, s-if_gain-val);
+
+   ctrl.lna_gain = s-lna_gain_auto-val ? INT_MIN : s-lna_gain-val;
+   ctrl.mixer_gain = s-mixer_gain_auto-val ? INT_MIN : 
s-mixer_gain-val;
+   ctrl.if_gain = s-if_gain_auto-val ? INT_MIN : s-if_gain-val;
+
+   if (fe-ops.tuner_ops.set_config) {
+   ret = fe-ops.tuner_ops.set_config(fe, ctrl);
+   if (ret)
+   goto err;
+   }
+
+   return 0;
+err:
+   dev_dbg(s-udev-dev, %s: failed %d\n, __func__, ret);
+   return ret;
+};
+
 static int rtl2832_sdr_set_gain(struct rtl2832_sdr_state *s)
 {
int ret;
@@ -955,6 +980,9 @@ static int rtl2832_sdr_set_gain(struct rtl2832_sdr_state *s)
case RTL2832_TUNER_E4000:
ret = rtl2832_sdr_set_gain_e4000(s);
break;
+   case RTL2832_TUNER_R820T:
+   ret = rtl2832_sdr_set_gain_r820t(s);
+   break;
default:
ret = 0;
}
@@ -1442,6 +1470,19 @@ struct dvb_frontend *rtl2832_sdr_attach(struct 
dvb_frontend *fe,
s-if_gain = v4l2_ctrl_new_std(s-hdl, ops, V4L2_CID_IF_GAIN, 
0, 54, 1, 0);
v4l2_ctrl_auto_cluster(2, s-if_gain_auto, 0, false);
break;
+   case RTL2832_TUNER_R820T:
+   v4l2_ctrl_handler_init(s-hdl, 7);
+   s-lna_gain_auto = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_LNA_GAIN_AUTO, 0, 1, 1, 1);
+   s-lna_gain = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_LNA_GAIN, 0, 15, 1, 6);
+   v4l2_ctrl_auto_cluster(2, s-lna_gain_auto, 0, false);
+   s-mixer_gain_auto = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_MIXER_GAIN_AUTO, 0, 1, 1, 1);
+   s-mixer_gain = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_MIXER_GAIN, 0, 15, 1, 5);
+   v4l2_ctrl_auto_cluster(2, s-mixer_gain_auto, 0, false);
+   s-if_gain_auto = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_IF_GAIN_AUTO, 0, 1, 1, 1);
+   s-if_gain = v4l2_ctrl_new_std(s-hdl, ops, V4L2_CID_IF_GAIN, 
0, 15, 1, 4);
+   v4l2_ctrl_auto_cluster(2, s-if_gain_auto, 0, false);
+   s-ctrl_tuner_bw = v4l2_ctrl_new_custom(s-hdl, 
ctrl_tuner_bw, NULL);
+   break;
default:
v4l2_ctrl_handler_init(s-hdl, 1);
s-ctrl_tuner_bw = v4l2_ctrl_new_custom(s-hdl, 
ctrl_tuner_bw, NULL);
-- 
1.8.5.3

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


[PATCH 1/2] r820t: add manual gain controls

2014-01-26 Thread Antti Palosaari
Add gain control for LNA, Mixer and IF. Expose controls via DVB
frontend .set_config callback.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/r820t.c | 38 ++
 drivers/media/tuners/r820t.h |  7 +++
 2 files changed, 45 insertions(+)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index d9ee43f..5a926a3 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1251,6 +1251,43 @@ static int r820t_set_gain_mode(struct r820t_priv *priv,
 }
 #endif
 
+static int r820t_set_config(struct dvb_frontend *fe, void *priv_cfg)
+{
+   struct r820t_priv *priv = fe-tuner_priv;
+   struct r820t_ctrl *ctrl = priv_cfg;
+   int rc;
+
+   if (fe-ops.i2c_gate_ctrl)
+   fe-ops.i2c_gate_ctrl(fe, 1);
+
+   if (ctrl-lna_gain == INT_MIN)
+   rc = r820t_write_reg_mask(priv, 0x05, 0x00, 0x10);
+   else
+   rc = r820t_write_reg_mask(priv, 0x05,
+   0x10 | ctrl-lna_gain, 0x1f);
+   if (rc  0)
+   goto err;
+
+   if (ctrl-mixer_gain == INT_MIN)
+   rc = r820t_write_reg_mask(priv, 0x07, 0x10, 0x10);
+   else
+   rc = r820t_write_reg_mask(priv, 0x07,
+   0x00 | ctrl-mixer_gain, 0x1f);
+   if (rc  0)
+   goto err;
+
+   if (ctrl-if_gain == INT_MIN)
+   rc = r820t_write_reg_mask(priv, 0x0c, 0x10, 0x10);
+   else
+   rc = r820t_write_reg_mask(priv, 0x0c,
+   0x00 | ctrl-if_gain, 0x1f);
+err:
+   if (fe-ops.i2c_gate_ctrl)
+   fe-ops.i2c_gate_ctrl(fe, 0);
+
+   return rc;
+}
+
 static int generic_set_freq(struct dvb_frontend *fe,
u32 freq /* in HZ */,
unsigned bw,
@@ -2275,6 +2312,7 @@ static const struct dvb_tuner_ops r820t_tuner_ops = {
.release = r820t_release,
.sleep = r820t_sleep,
.set_params = r820t_set_params,
+   .set_config = r820t_set_config,
.set_analog_params = r820t_set_analog_freq,
.get_if_frequency = r820t_get_if_frequency,
.get_rf_strength = r820t_signal,
diff --git a/drivers/media/tuners/r820t.h b/drivers/media/tuners/r820t.h
index 48af354..42c0d8e 100644
--- a/drivers/media/tuners/r820t.h
+++ b/drivers/media/tuners/r820t.h
@@ -42,6 +42,13 @@ struct r820t_config {
bool use_predetect;
 };
 
+/* set INT_MIN for automode */
+struct r820t_ctrl {
+   int lna_gain;
+   int mixer_gain;
+   int if_gain;
+};
+
 #if IS_ENABLED(CONFIG_MEDIA_TUNER_R820T)
 struct dvb_frontend *r820t_attach(struct dvb_frontend *fe,
  struct i2c_adapter *i2c,
-- 
1.8.5.3

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