[RFC][PATCH] [media] atmel-isc: add the isc pipeline function

2016-12-02 Thread Songjun Wu
Image Sensor Controller has an internal image processor.
It can convert raw format to the other formats, like
RGB565, YUV420P. A module parameter 'sensor_preferred'
is used to enable or disable the pipeline function.
Some v4l2 controls are added to tuning the image when
the pipeline function is enabled.

Signed-off-by: Songjun Wu 
---

 drivers/media/platform/atmel/atmel-isc-regs.h |  77 -
 drivers/media/platform/atmel/atmel-isc.c  | 460 +-
 2 files changed, 449 insertions(+), 88 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isc-regs.h 
b/drivers/media/platform/atmel/atmel-isc-regs.h
index 00c4497..7d83342 100644
--- a/drivers/media/platform/atmel/atmel-isc-regs.h
+++ b/drivers/media/platform/atmel/atmel-isc-regs.h
@@ -72,30 +72,98 @@
 /* ISC White Balance Configuration Register */
 #define ISC_WB_CFG  0x005c
 
+/* ISC White Balance Offset for R, GR Register */
+#define ISC_WB_O_RGR   0x0060
+
+/* ISC White Balance Offset for B, GB Register */
+#define ISC_WB_O_BGR   0x0064
+
+/* ISC White Balance Gain for R, GR Register */
+#define ISC_WB_G_RGR   0x0068
+
+/* ISC White Balance Gain for B, GB Register */
+#define ISC_WB_G_BGR   0x006c
+
 /* ISC Color Filter Array Control Register */
 #define ISC_CFA_CTRL0x0070
 
 /* ISC Color Filter Array Configuration Register */
 #define ISC_CFA_CFG 0x0074
+#define ISC_CFA_CFG_EITPOL BIT(4)
 
 #define ISC_BAY_CFG_GRGR   0x0
 #define ISC_BAY_CFG_RGRG   0x1
 #define ISC_BAY_CFG_GBGB   0x2
 #define ISC_BAY_CFG_BGBG   0x3
-#define ISC_BAY_CFG_MASK   GENMASK(1, 0)
 
 /* ISC Color Correction Control Register */
 #define ISC_CC_CTRL 0x0078
 
+/* ISC Color Correction RR RG Register */
+#define ISC_CC_RR_RG   0x007c
+
+/* ISC Color Correction RB OR Register */
+#define ISC_CC_RB_OR   0x0080
+
+/* ISC Color Correction GR GG Register */
+#define ISC_CC_GR_GG   0x0084
+
+/* ISC Color Correction GB OG Register */
+#define ISC_CC_GB_OG   0x0088
+
+/* ISC Color Correction BR BG Register */
+#define ISC_CC_BR_BG   0x008c
+
+/* ISC Color Correction BB OB Register */
+#define ISC_CC_BB_OB   0x0090
+
 /* ISC Gamma Correction Control Register */
 #define ISC_GAM_CTRL0x0094
 
+/* ISC_Gamma Correction Blue Entry Register */
+#define ISC_GAM_BENTRY 0x0098
+
+/* ISC_Gamma Correction Green Entry Register */
+#define ISC_GAM_GENTRY 0x0198
+
+/* ISC_Gamma Correction Green Entry Register */
+#define ISC_GAM_RENTRY 0x0298
+
 /* Color Space Conversion Control Register */
 #define ISC_CSC_CTRL0x0398
 
+/* Color Space Conversion YR YG Register */
+#define ISC_CSC_YR_YG  0x039c
+
+/* Color Space Conversion YB OY Register */
+#define ISC_CSC_YB_OY  0x03a0
+
+/* Color Space Conversion CBR CBG Register */
+#define ISC_CSC_CBR_CBG0x03a4
+
+/* Color Space Conversion CBB OCB Register */
+#define ISC_CSC_CBB_OCB0x03a8
+
+/* Color Space Conversion CRR CRG Register */
+#define ISC_CSC_CRR_CRG0x03ac
+
+/* Color Space Conversion CRB OCR Register */
+#define ISC_CSC_CRB_OCR0x03b0
+
 /* Contrast And Brightness Control Register */
 #define ISC_CBC_CTRL0x03b4
 
+/* Contrast And Brightness Configuration Register */
+#define ISC_CBC_CFG0x03b8
+
+/* Brightness Register */
+#define ISC_CBC_BRIGHT 0x03bc
+#define ISC_CBC_BRIGHT_MASKGENMASK(10, 0)
+
+/* Contrast Register */
+#define ISC_CBC_CONTRAST   0x03c0
+#define ISC_CBC_CONTRAST_MASK  GENMASK(11, 0)
+
 /* Subsampling 4:4:4 to 4:2:2 Control Register */
 #define ISC_SUB422_CTRL 0x03c4
 
@@ -159,7 +227,10 @@
 /* DMA Address 0 Register */
 #define ISC_DAD00x03ec
 
-/* DMA Stride 0 Register */
-#define ISC_DST00x03f0
+/* DMA Address 1 Register */
+#define ISC_DAD10x03f4
+
+/* DMA Address 2 Register */
+#define ISC_DAD20x03fc
 
 #endif
diff --git a/drivers/media/platform/atmel/atmel-isc.c 
b/drivers/media/platform/atmel/atmel-isc.c
index fa68fe9..b06cbf6 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -36,7 +36,9 @@
 #include 
 #include 
 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -89,10 +91,12 @@ struct isc_subdev_entity {
  * struct isc_format - ISC media bus format information
  * @fourcc:Fourcc code for this format
  * @mbus_code: V4L2 media bus format code.
- * @bpp:   Bytes per pixel (when stored in memory)
+ * @bpp:   Bits per pixel (when stored in memory)
  * @reg_bps:   reg value for bits per sample
  * (when transferred over a bus)
- * @support:   Indicates format supported by subdev
+ * @pipeline:  pipeline switch
+ * @sd_support:Subdev supports this format
+ * @isc_support:   ISC can convert raw format to this format
  */
 struct isc_format {
u32 fourcc;
@@ 

Re: [PATCH] bdisp: Clean up file handle in open() error path.

2016-12-02 Thread Fabien DESSENNE
Hi Shailendra,
Thank you for the patch, it's good for me.


On 12/02/2016 05:48 AM, Shailendra Verma wrote:
> The File handle is not yet added in the vdev list.So no need to call
> v4l2_fh_del(&ctx->fh)if it fails to create control.
>
> Signed-off-by: Shailendra Verma 

Reviewed-by: Fabien Dessenne 

> ---
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
> b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index 45f82b5..fbf302f 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -632,8 +632,8 @@ static int bdisp_open(struct file *file)
>   
>   error_ctrls:
>   bdisp_ctrls_delete(ctx);
> -error_fh:
>   v4l2_fh_del(&ctx->fh);
> +error_fh:
>   v4l2_fh_exit(&ctx->fh);
>   bdisp_hw_free_nodes(ctx);
>   mem_ctx:
--
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 v2 3/3] uvcvideo: add a metadata device node

2016-12-02 Thread Guennadi Liakhovetski
Some UVC video cameras contain metadata in their payload headers. This
patch extracts that data, skipping the standard part of the header, on
both bulk and isochronous endpoints and makes it available to the user
space on a separate video node, using the V4L2_CAP_META_CAPTURE
capability and the V4L2_BUF_TYPE_META_CAPTURE buffer queue type. Even
though different cameras will have different metadata formats, we use
the same V4L2_META_FMT_UVC pixel format for all of them. Users have to
parse data, based on the specific camera model information.

Signed-off-by: Guennadi Liakhovetski 
---

v2:
- updated to the current media/master
- removed superfluous META capability from capture nodes
- now the complete UVC payload header is copied to buffers, including 
  standard fields

Still open for discussion: is this really OK to always create an 
additional metadata node for each UVC camera or UVC video interface.

IIUC, Laurent's metadata node patch 
https://patchwork.linuxtv.org/patch/36810/ has been acked by Hans and the 
only thing, that's preventing it from being merged it the lack of 
documentation. While waiting for documentation, I'd appreciate some 
discussion of this patch to beat it into shape soon enough and have it 
ready for merge soon after Laurent's patches are pulled in.

Thanks
Guennadi

 drivers/media/usb/uvc/Makefile   |   2 +-
 drivers/media/usb/uvc/uvc_driver.c   |  10 ++
 drivers/media/usb/uvc/uvc_isight.c   |   2 +-
 drivers/media/usb/uvc/uvc_metadata.c | 228 +++
 drivers/media/usb/uvc/uvc_video.c|  47 ++--
 drivers/media/usb/uvc/uvcvideo.h |  12 +-
 drivers/media/v4l2-core/v4l2-ioctl.c |   1 +
 include/uapi/linux/uvcvideo.h|  10 ++
 include/uapi/linux/videodev2.h   |   3 +
 9 files changed, 304 insertions(+), 11 deletions(-)
 create mode 100644 drivers/media/usb/uvc/uvc_metadata.c

diff --git a/drivers/media/usb/uvc/Makefile b/drivers/media/usb/uvc/Makefile
index c26d12f..06c7cd3 100644
--- a/drivers/media/usb/uvc/Makefile
+++ b/drivers/media/usb/uvc/Makefile
@@ -1,5 +1,5 @@
 uvcvideo-objs  := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \
- uvc_status.o uvc_isight.o uvc_debugfs.o
+ uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o
 ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
 uvcvideo-objs  += uvc_entity.o
 endif
diff --git a/drivers/media/usb/uvc/uvc_driver.c 
b/drivers/media/usb/uvc/uvc_driver.c
index 04bf350..edb67ac 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1866,6 +1866,9 @@ static void uvc_unregister_video(struct uvc_device *dev)
 
video_unregister_device(&stream->vdev);
 
+   if (video_is_registered(&stream->meta.vdev))
+   video_unregister_device(&stream->meta.vdev);
+
uvc_debugfs_cleanup_stream(stream);
}
 
@@ -1926,6 +1929,13 @@ static int uvc_register_video(struct uvc_device *dev,
return ret;
}
 
+   /*
+* Register a metadata node. TODO: shall this only be enabled for some
+* cameras?
+*/
+   if (!(dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT))
+   uvc_meta_register(stream);
+
if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE;
else
diff --git a/drivers/media/usb/uvc/uvc_isight.c 
b/drivers/media/usb/uvc/uvc_isight.c
index 8510e725..fb940cf 100644
--- a/drivers/media/usb/uvc/uvc_isight.c
+++ b/drivers/media/usb/uvc/uvc_isight.c
@@ -100,7 +100,7 @@ static int isight_decode(struct uvc_video_queue *queue, 
struct uvc_buffer *buf,
 }
 
 void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
-   struct uvc_buffer *buf)
+   struct uvc_buffer *buf, struct uvc_buffer *meta_buf)
 {
int ret, i;
 
diff --git a/drivers/media/usb/uvc/uvc_metadata.c 
b/drivers/media/usb/uvc/uvc_metadata.c
new file mode 100644
index 000..ddf77d9
--- /dev/null
+++ b/drivers/media/usb/uvc/uvc_metadata.c
@@ -0,0 +1,228 @@
+/*
+ *  uvc_metadata.c  --  USB Video Class driver - Metadata handling
+ *
+ *  Copyright (C) 2016
+ *  Guennadi Liakhovetski (guennadi.liakhovet...@intel.com)
+ *
+ *  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 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "uvcvideo.h"
+
+static inline struct uvc_buffer *to_uvc_buffer(struct vb2_v4l2_buffer *vbuf)
+{
+   return container_of(vbuf, struct uvc_buffer, buf);
+}
+
+/* 
-
+ * videobuf2 Queue Operations
+ */
+
+static int meta_queue_setup(struct vb2_queu

Re: [PATCH v3 3/4] stk1160: Add module param for setting the record gain.

2016-12-02 Thread Mauro Carvalho Chehab
Em Sun, 27 Nov 2016 12:11:48 +0100
Marcel Hasler  escreveu:

> Allow setting a custom record gain for the internal AC97 codec (if 
> available). This can be
> a value between 0 and 15, 8 is the default and should be suitable for most 
> users. The Windows
> driver also sets this to 8 without any possibility for changing it.

The problem of removing the mixer is that you need this kind of
crap to setup the volumes on a non-standard way.

NACK.

Instead, keep the alsa mixer. The way other drivers do (for example, 
em28xx) is that they configure the mixer when an input is selected,
increasing the volume of the active audio channel to 100% and muting
the other audio channels. Yet, as the alsa mixer is exported, users 
can change the mixer settings in runtime using some alsa (or pa)
mixer application.

> 
> Signed-off-by: Marcel Hasler 
> ---
>  drivers/media/usb/stk1160/stk1160-ac97.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c 
> b/drivers/media/usb/stk1160/stk1160-ac97.c
> index 95648ac..60327af 100644
> --- a/drivers/media/usb/stk1160/stk1160-ac97.c
> +++ b/drivers/media/usb/stk1160/stk1160-ac97.c
> @@ -28,6 +28,11 @@
>  #include "stk1160.h"
>  #include "stk1160-reg.h"
>  
> +static u8 gain = 8;
> +
> +module_param(gain, byte, 0444);
> +MODULE_PARM_DESC(gain, "Set capture gain level if AC97 codec is available 
> (0-15, default: 8)");
> +
>  static void stk1160_write_ac97(struct stk1160 *dev, u16 reg, u16 value)
>  {
>   /* Set codec register address */
> @@ -136,7 +141,10 @@ void stk1160_ac97_setup(struct stk1160 *dev)
>   stk1160_write_ac97(dev, 0x16, 0x0808); /* Aux volume */
>   stk1160_write_ac97(dev, 0x1a, 0x0404); /* Record select */
>   stk1160_write_ac97(dev, 0x02, 0x); /* Master volume */
> - stk1160_write_ac97(dev, 0x1c, 0x0808); /* Record gain */
> +
> + /* Record gain */
> + gain = (gain > 15) ? 15 : gain;
> + stk1160_write_ac97(dev, 0x1c, (gain<<8) | gain);
>  
>  #ifdef DEBUG
>   stk1160_ac97_dump_regs(dev);



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: [PATCH v3 4/4] stk1160: Give the chip some time to retrieve data from AC97 codec.

2016-12-02 Thread Mauro Carvalho Chehab
Em Sun, 27 Nov 2016 12:12:36 +0100
Marcel Hasler  escreveu:

> The STK1160 needs some time to transfer data from the AC97 registers into its 
> own. On some
> systems reading the chip's own registers to soon will return wrong values. 
> The "proper" way to
> handle this would be to poll STK1160_AC97CTL_0 after every read or write 
> command until the
> command bit has been cleared, but this may not be worth the hassle.
> 
> Signed-off-by: Marcel Hasler 
> ---
>  drivers/media/usb/stk1160/stk1160-ac97.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c 
> b/drivers/media/usb/stk1160/stk1160-ac97.c
> index 60327af..b39f51b 100644
> --- a/drivers/media/usb/stk1160/stk1160-ac97.c
> +++ b/drivers/media/usb/stk1160/stk1160-ac97.c
> @@ -23,6 +23,7 @@
>   *
>   */
>  
> +#include 
>  #include 
>  
>  #include "stk1160.h"
> @@ -64,6 +65,14 @@ static u16 stk1160_read_ac97(struct stk1160 *dev, u16 reg)
>*/
>   stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8b);
>  
> + /*
> +  * Give the chip some time to transfer the data.
> +  * The proper way would be to poll STK1160_AC97CTL_0
> +  * until the command bit has been cleared, but this
> +  * may not be worth the hassle.

Why not? Relying on a fixed amount time is not nice.

Take a look at em28xx_is_ac97_ready() function, at
drivers/media/usb/em28xx/em28xx-core.c to see how this could be
implemented instead.


> +  */
> + usleep_range(20, 40);
> +

>   /* Retrieve register value */
>   stk1160_read_reg(dev, STK1160_AC97_CMD, &vall);
>   stk1160_read_reg(dev, STK1160_AC97_CMD + 1, &valh);



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: [RFC v4 19/21] omap3isp: Allocate the media device dynamically

2016-12-02 Thread Sakari Ailus
Hi Hans,

On Tue, Nov 22, 2016 at 11:05:49AM +0100, Hans Verkuil wrote:
...
> >@@ -2183,7 +2185,7 @@ static int isp_subdev_notifier_complete(struct 
> >v4l2_async_notifier *async)
> > if (ret < 0)
> > return ret;
> >
> >-return media_device_register(&isp->media_dev);
> >+return media_device_register(isp->media_dev);
> 
> I wonder if this is correct. Usually if the register fails, then the
> release/delete function
> has to be called explicitly. That doesn't happen here.

This patch is really about making the media_dev a pointer in struct
omap3isp_device. Currently the cleanup takes place when the device is
unbound. That's perhaps not ideal but on the other hand optimising error
handling is often just not worth it.

Improvements could be done how the async framework handles errors but that
shouldn't be in the scope of this patchset.

> 
> E.g. from adv7604.c:
> 
> static int adv76xx_registered(struct v4l2_subdev *sd)
> {
> struct adv76xx_state *state = to_state(sd);
> int err;
> 
> err = cec_register_adapter(state->cec_adap);
> if (err)
> cec_delete_adapter(state->cec_adap);
> return err;
> }

-- 
Kind regards,

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


[PATCH 5/8] [media] serial_ir: generate timeout

2016-12-02 Thread Sean Young
No timeout is generated by serial_ir since the port only generates
interrupts on edges. Some IR protocols like rc6 and rc5 need a trailing
space or timeout so they know there are no more bits coming.

Without it, the current key will only be reported once some more IR
occurs.

Signed-off-by: Sean Young 
---
 drivers/media/rc/serial_ir.c | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
index 436bd58..2cb6471 100644
--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -137,6 +137,7 @@ struct serial_ir {
ktime_t lastkt;
struct rc_dev *rcdev;
struct platform_device *pdev;
+   struct timer_list timeout_timer;
 
unsigned int freq;
unsigned int duty_cycle;
@@ -395,9 +396,14 @@ static irqreturn_t serial_ir_irq_handler(int i, void *blah)
frbwrite(data, !(dcd ^ sense));
serial_ir.lastkt = kt;
last_dcd = dcd;
-   ir_raw_event_handle(serial_ir.rcdev);
}
} while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */
+
+   mod_timer(&serial_ir.timeout_timer,
+ jiffies + nsecs_to_jiffies(serial_ir.rcdev->timeout));
+
+   ir_raw_event_handle(serial_ir.rcdev);
+
return IRQ_HANDLED;
 }
 
@@ -471,6 +477,16 @@ static int hardware_init_port(void)
return 0;
 }
 
+static void serial_ir_timeout(unsigned long arg)
+{
+   DEFINE_IR_RAW_EVENT(ev);
+
+   ev.timeout = true;
+   ev.duration = serial_ir.rcdev->timeout;
+   ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
+   ir_raw_event_handle(serial_ir.rcdev);
+}
+
 static int serial_ir_probe(struct platform_device *dev)
 {
int i, nlow, nhigh, result;
@@ -500,6 +516,9 @@ static int serial_ir_probe(struct platform_device *dev)
return -EBUSY;
}
 
+   setup_timer(&serial_ir.timeout_timer, serial_ir_timeout,
+   (unsigned long)&serial_ir);
+
result = hardware_init_port();
if (result < 0)
return result;
@@ -781,7 +800,9 @@ static int __init serial_ir_init_module(void)
rcdev->allowed_protocols = RC_BIT_ALL;
rcdev->driver_name = KBUILD_MODNAME;
rcdev->map_name = RC_MAP_RC6_MCE;
+   rcdev->min_timeout = 1;
rcdev->timeout = IR_DEFAULT_TIMEOUT;
+   rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
rcdev->rx_resolution = 25;
 
serial_ir.rcdev = rcdev;
@@ -797,6 +818,7 @@ static int __init serial_ir_init_module(void)
 
 static void __exit serial_ir_exit_module(void)
 {
+   del_timer_sync(&serial_ir.timeout_timer);
rc_unregister_device(serial_ir.rcdev);
serial_ir_exit();
 }
-- 
2.9.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/8] [media] mceusb: LIRC_SET_SEND_CARRIER returns 0 on success

2016-12-02 Thread Sean Young
LIRC_SET_SEND_CARRIER ioctl should not return the carrier used, it
should return 0.

Signed-off-by: Sean Young 
---
 drivers/media/rc/mceusb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 9bf6917..96b0ade 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -890,7 +890,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 
carrier)
cmdbuf[3] = MCE_IRDATA_TRAILER;
dev_dbg(ir->dev, "disabling carrier modulation");
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
-   return carrier;
+   return 0;
}
 
for (prescaler = 0; prescaler < 4; ++prescaler) {
@@ -904,7 +904,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 
carrier)
 
/* Transmit new carrier to mce device */
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
-   return carrier;
+   return 0;
}
}
 
-- 
2.9.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 8/8] [media] rc5x: document that this is the 20 bit variant

2016-12-02 Thread Sean Young
There are many variants of extended rc5. This implements the 20 bit
version.

Signed-off-by: Sean Young 
Cc: David Härdeman 
---
 drivers/media/rc/ir-rc5-decoder.c | 6 +++---
 drivers/media/rc/rc-main.c| 2 +-
 include/media/rc-map.h| 8 
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/rc/ir-rc5-decoder.c 
b/drivers/media/rc/ir-rc5-decoder.c
index a95477c..484185e 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -124,7 +124,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
if (data->is_rc5x && data->count == RC5X_NBITS) {
/* RC5X */
u8 xdata, command, system;
-   if (!(dev->enabled_protocols & RC_BIT_RC5X)) {
+   if (!(dev->enabled_protocols & RC_BIT_RC5X_20)) {
data->state = STATE_INACTIVE;
return 0;
}
@@ -134,7 +134,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
toggle   = (data->bits & 0x2) ? 1 : 0;
command += (data->bits & 0x4) ? 0 : 0x40;
scancode = system << 16 | command << 8 | xdata;
-   protocol = RC_TYPE_RC5X;
+   protocol = RC_TYPE_RC5X_20;
 
} else if (!data->is_rc5x && data->count == RC5_NBITS) {
/* RC5 */
@@ -182,7 +182,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
 }
 
 static struct ir_raw_handler rc5_handler = {
-   .protocols  = RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ,
+   .protocols  = RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ,
.decode = ir_rc5_decode,
 };
 
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index dedaf38..75bdc49 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -796,7 +796,7 @@ static const struct {
{ RC_BIT_OTHER, "other",NULL},
{ RC_BIT_UNKNOWN,   "unknown",  NULL},
{ RC_BIT_RC5 |
- RC_BIT_RC5X,  "rc-5", "ir-rc5-decoder"},
+ RC_BIT_RC5X_20,   "rc-5", "ir-rc5-decoder"},
{ RC_BIT_NEC |
  RC_BIT_NECX |
  RC_BIT_NEC32, "nec",  "ir-nec-decoder"},
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index e1cc14c..39c00ef 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -17,7 +17,7 @@
  * @RC_TYPE_UNKNOWN: Protocol not known
  * @RC_TYPE_OTHER: Protocol known but proprietary
  * @RC_TYPE_RC5: Philips RC5 protocol
- * @RC_TYPE_RC5X: Philips RC5x protocol
+ * @RC_TYPE_RC5X_20: Philips RC5x 20 bit protocol
  * @RC_TYPE_RC5_SZ: StreamZap variant of RC5
  * @RC_TYPE_JVC: JVC protocol
  * @RC_TYPE_SONY12: Sony 12 bit protocol
@@ -41,7 +41,7 @@ enum rc_type {
RC_TYPE_UNKNOWN = 0,
RC_TYPE_OTHER   = 1,
RC_TYPE_RC5 = 2,
-   RC_TYPE_RC5X= 3,
+   RC_TYPE_RC5X_20 = 3,
RC_TYPE_RC5_SZ  = 4,
RC_TYPE_JVC = 5,
RC_TYPE_SONY12  = 6,
@@ -66,7 +66,7 @@ enum rc_type {
 #define RC_BIT_UNKNOWN (1ULL << RC_TYPE_UNKNOWN)
 #define RC_BIT_OTHER   (1ULL << RC_TYPE_OTHER)
 #define RC_BIT_RC5 (1ULL << RC_TYPE_RC5)
-#define RC_BIT_RC5X(1ULL << RC_TYPE_RC5X)
+#define RC_BIT_RC5X_20 (1ULL << RC_TYPE_RC5X_20)
 #define RC_BIT_RC5_SZ  (1ULL << RC_TYPE_RC5_SZ)
 #define RC_BIT_JVC (1ULL << RC_TYPE_JVC)
 #define RC_BIT_SONY12  (1ULL << RC_TYPE_SONY12)
@@ -87,7 +87,7 @@ enum rc_type {
 #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 | \
+RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ | \
 RC_BIT_JVC | \
 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \
-- 
2.9.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 4/8] [media] em28xx: IR protocol not reported correctly

2016-12-02 Thread Sean Young
Report the correct NEC variant.

Signed-off-by: Sean Young 
---
 drivers/media/usb/em28xx/em28xx-input.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-input.c 
b/drivers/media/usb/em28xx/em28xx-input.c
index a1904e2..a9a7f16 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -259,18 +259,21 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
break;
 
case RC_BIT_NEC:
-   poll_result->protocol = RC_TYPE_RC5;
poll_result->scancode = msg[1] << 8 | msg[2];
-   if ((msg[3] ^ msg[4]) != 0xff)  /* 32 bits NEC */
+   if ((msg[3] ^ msg[4]) != 0xff) {/* 32 bits NEC */
+   poll_result->protocol = RC_TYPE_NEC32;
poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 
24) |
  (msg[2] << 
16) |
  (msg[3] << 8) 
 |
  (msg[4]));
-   else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */
+   } else if ((msg[1] ^ msg[2]) != 0xff) { /* 24 bits NEC */
+   poll_result->protocol = RC_TYPE_NECX;
poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 |
 msg[2], 
msg[3]);
-   else/* Normal NEC */
+   } else {/* Normal NEC */
+   poll_result->protocol = RC_TYPE_NEC;
poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]);
+   }
break;
 
case RC_BIT_RC6_0:
@@ -775,7 +778,7 @@ static int em28xx_ir_init(struct em28xx *dev)
case CHIP_ID_EM28178:
ir->get_key = em2874_polling_getkey;
rc->allowed_protocols = RC_BIT_RC5 | RC_BIT_NEC |
-RC_BIT_RC6_0;
+   RC_BIT_NECX | RC_BIT_NEC32 | RC_BIT_RC6_0;
break;
default:
err = -ENODEV;
-- 
2.9.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 2/8] [media] lirc_dev: LIRC_{G,S}ET_REC_MODE do not work

2016-12-02 Thread Sean Young
Since "273b902 [media] lirc_dev: use LIRC_CAN_REC() define" these
ioctls no longer work.

Signed-off-by: Sean Young 
Cc: Andi Shyti 
Cc:  # v4.8+
---
 drivers/media/rc/lirc_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 3854809..7f5d109 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -582,7 +582,7 @@ long lirc_dev_fop_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
result = put_user(ir->d.features, (__u32 __user *)arg);
break;
case LIRC_GET_REC_MODE:
-   if (LIRC_CAN_REC(ir->d.features)) {
+   if (!LIRC_CAN_REC(ir->d.features)) {
result = -ENOTTY;
break;
}
@@ -592,7 +592,7 @@ long lirc_dev_fop_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
  (__u32 __user *)arg);
break;
case LIRC_SET_REC_MODE:
-   if (LIRC_CAN_REC(ir->d.features)) {
+   if (!LIRC_CAN_REC(ir->d.features)) {
result = -ENOTTY;
break;
}
-- 
2.9.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 3/8] [media] lirc: LIRC_{G,S}ET_SEND_MODE fail if device cannot transmit

2016-12-02 Thread Sean Young
These ioctls should not succeed if the device cannot send. Also make it
clear that these ioctls should return the lirc mode, although the actual
value does not change.

Signed-off-by: Sean Young 
---
 drivers/media/rc/ir-lirc-codec.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index c327730..9e41305 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -204,11 +204,17 @@ static long ir_lirc_ioctl(struct file *filep, unsigned 
int cmd,
 
/* legacy support */
case LIRC_GET_SEND_MODE:
-   val = LIRC_CAN_SEND_PULSE & LIRC_CAN_SEND_MASK;
+   if (!dev->tx_ir)
+   return -ENOTTY;
+
+   val = LIRC_MODE_PULSE;
break;
 
case LIRC_SET_SEND_MODE:
-   if (val != (LIRC_MODE_PULSE & LIRC_CAN_SEND_MASK))
+   if (!dev->tx_ir)
+   return -ENOTTY;
+
+   if (val != LIRC_MODE_PULSE)
return -EINVAL;
return 0;
 
-- 
2.9.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 6/8] [media] rc: allow software timeout to be set

2016-12-02 Thread Sean Young
Both the iguanair and the technotrend usb ir do not do any timeout
handling in hardware, so timeout is entirely done in
ir_raw_event_store_with_filter(). Any sensible timeout value will
do, so allow it to be set using LIRC_SET_REC_TIMEOUT.

Signed-off-by: Sean Young 
---
 drivers/media/rc/iguanair.c | 4 +++-
 drivers/media/rc/ttusbir.c  | 5 -
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 5f63454..139a09c 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -504,7 +504,9 @@ static int iguanair_probe(struct usb_interface *intf,
rc->tx_ir = iguanair_tx;
rc->driver_name = DRIVER_NAME;
rc->map_name = RC_MAP_RC6_MCE;
-   rc->timeout = MS_TO_NS(100);
+   rc->min_timeout = 1;
+   rc->timeout = IR_DEFAULT_TIMEOUT;
+   rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
rc->rx_resolution = RX_RESOLUTION;
 
iguanair_set_tx_carrier(rc, 38000);
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index bc214e2..8393014 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -322,7 +322,10 @@ static int ttusbir_probe(struct usb_interface *intf,
rc->priv = tt;
rc->driver_name = DRIVER_NAME;
rc->map_name = RC_MAP_TT_1500;
-   rc->timeout = MS_TO_NS(100);
+   rc->min_timeout = 1;
+   rc->timeout = IR_DEFAULT_TIMEOUT;
+   rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
+
/*
 * The precision is NS_PER_BIT, but since every 8th bit can be
 * overwritten with garbage the accuracy is at best 2 * NS_PER_BIT.
-- 
2.9.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 7/8] [media] rc5x: 6th command bit is S2 bit

2016-12-02 Thread Sean Young
The 2nd stop bit in rc5 is reused as an inverted 6th command bit in
20 bits rc5x. Currently the rc5x decoder sets the 6th command bit as
an inverted duplicate of the lowest system bit; as a result we do
not have all the command bits.

Note that there are no rc5x keymaps present.

Signed-off-by: Sean Young 
Cc: David Härdeman 
---
 drivers/media/rc/ir-rc5-decoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/ir-rc5-decoder.c 
b/drivers/media/rc/ir-rc5-decoder.c
index a0fd4e6..a95477c 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -132,7 +132,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
command  = (data->bits & 0x00FC0) >> 6;
system   = (data->bits & 0x1F000) >> 12;
toggle   = (data->bits & 0x2) ? 1 : 0;
-   command += (data->bits & 0x01000) ? 0 : 0x40;
+   command += (data->bits & 0x4) ? 0 : 0x40;
scancode = system << 16 | command << 8 | xdata;
protocol = RC_TYPE_RC5X;
 
-- 
2.9.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 v4l-utils 2/6] ir-ctl: fix rc5x encoding

2016-12-02 Thread Sean Young
6th command bit was missing.

Signed-off-by: Sean Young 
---
 utils/ir-ctl/ir-encode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/ir-ctl/ir-encode.c b/utils/ir-ctl/ir-encode.c
index 1bf0ac6..704ce95 100644
--- a/utils/ir-ctl/ir-encode.c
+++ b/utils/ir-ctl/ir-encode.c
@@ -261,7 +261,7 @@ static int rc5_encode(enum rc_proto proto, unsigned 
scancode, unsigned *buf)
add_bits(scancode, 6);
break;
case RC_PROTO_RC5X:
-   add_bits(!!(scancode & 0x4000), 1);
+   add_bits(!(scancode & 0x4000), 1);
add_bits(0, 1);
add_bits(scancode >> 16, 5);
advance_space(NS_TO_US(rc5_unit * 4));
@@ -350,7 +350,7 @@ static const struct {
int (*encode)(enum rc_proto proto, unsigned scancode, unsigned *buf);
 } encoders[RC_PROTO_COUNT] = {
[RC_PROTO_RC5] = { "rc5", 0x1f3f, 24, 36000, rc5_encode },
-   [RC_PROTO_RC5X] = { "rc5x", 0x1f3f3f, 40, 36000, rc5_encode },
+   [RC_PROTO_RC5X] = { "rc5x", 0x1f7f3f, 40, 36000, rc5_encode },
[RC_PROTO_RC5_SZ] = { "rc5_sz", 0x2fff, 26, 36000, rc5_encode },
[RC_PROTO_SONY12] = { "sony12", 0x1f007f, 25, 4, sony_encode },
[RC_PROTO_SONY15] = { "sony15", 0xff007f, 31, 4, sony_encode },
-- 
2.9.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 v4l-utils 1/6] ir-ctl: uninitialised memory used

2016-12-02 Thread Sean Young
We might end up with a corrupt rc6.

Signed-off-by: Sean Young 
---
 utils/ir-ctl/ir-encode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/utils/ir-ctl/ir-encode.c b/utils/ir-ctl/ir-encode.c
index a0d2f4c..1bf0ac6 100644
--- a/utils/ir-ctl/ir-encode.c
+++ b/utils/ir-ctl/ir-encode.c
@@ -310,6 +310,7 @@ static int rc6_encode(enum rc_proto proto, unsigned 
scancode, unsigned *buf)
 
buf[n++] = NS_TO_US(rc6_unit * 6);
buf[n++] = NS_TO_US(rc6_unit * 2);
+   buf[n] = 0;
 
switch (proto) {
default:
-- 
2.9.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 v4l-utils 3/6] ir-ctl: 0 is valid scancode

2016-12-02 Thread Sean Young
Same for 0x.

Signed-off-by: Sean Young 
---
 utils/ir-ctl/ir-ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index f19bd05..768daad 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -146,7 +146,7 @@ static bool strtoscancode(const char *p, unsigned *ret)
if (end == NULL || end[0] != 0)
return false;
 
-   if (arg <= 0 || arg >= 0x)
+   if (arg < 0 || arg > 0x)
return false;
 
*ret = arg;
-- 
2.9.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 v4l-utils 6/6] ir-ctl: rename rc5x to rc5x_20

2016-12-02 Thread Sean Young
There are many extended rc5 protocols and we can only generate the 20
bit variant.

Signed-off-by: Sean Young 
---
 utils/ir-ctl/ir-ctl.1.in | 7 ---
 utils/ir-ctl/ir-encode.c | 4 ++--
 utils/ir-ctl/ir-encode.h | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/utils/ir-ctl/ir-ctl.1.in b/utils/ir-ctl/ir-ctl.1.in
index a1d5aeb..c2e0094 100644
--- a/utils/ir-ctl/ir-ctl.1.in
+++ b/utils/ir-ctl/ir-ctl.1.in
@@ -177,9 +177,10 @@ there are limits to what lirc devices can send in one go.
 .SS Supported Protocols
 A scancode with protocol can be specified on the command line or in the
 pulse and space file. The following protocols are supported:
-\fBrc5\fR, \fBrc5x\fR, \fBrc5_sz\fR, \fBjvc\fR, \fBsony12\fR, \fBsony\fB15\fR,
-\fBsony20\fR, \fBnec\fR, \fBnecx\fR, \fBnec32\fR, \fBsanyo\fR, \fBrc6_0\fR,
-\fBrc6_6a_20\fR, \fBrc6_6a_24\fR, \fBrc6_6a_32\fR, \fBrc6_mce\fR, \fBsharp\fR.
+\fBrc5\fR, \fBrc5x_20\fR, \fBrc5_sz\fR, \fBjvc\fR, \fBsony12\fR,
+\fBsony\fB15\fR, \fBsony20\fR, \fBnec\fR, \fBnecx\fR, \fBnec32\fR,
+\fBsanyo\fR, \fBrc6_0\fR, \fBrc6_6a_20\fR, \fBrc6_6a_24\fR, \fBrc6_6a_32\fR,
+\fBrc6_mce\fR, \fBsharp\fR.
 If the scancode starts with 0x it will be interpreted as a
 hexidecimal number, and if it starts with 0 it will be interpreted as an
 octal number.
diff --git a/utils/ir-ctl/ir-encode.c b/utils/ir-ctl/ir-encode.c
index d3ee035..9cc8c5d 100644
--- a/utils/ir-ctl/ir-encode.c
+++ b/utils/ir-ctl/ir-encode.c
@@ -260,7 +260,7 @@ static int rc5_encode(enum rc_proto proto, unsigned 
scancode, unsigned *buf)
add_bits(scancode >> 6, 6);
add_bits(scancode, 6);
break;
-   case RC_PROTO_RC5X:
+   case RC_PROTO_RC5X_20:
add_bits(!(scancode & 0x4000), 1);
add_bits(0, 1);
add_bits(scancode >> 16, 5);
@@ -350,7 +350,7 @@ static const struct {
int (*encode)(enum rc_proto proto, unsigned scancode, unsigned *buf);
 } encoders[RC_PROTO_COUNT] = {
[RC_PROTO_RC5] = { "rc5", 0x1f3f, 24, 36000, rc5_encode },
-   [RC_PROTO_RC5X] = { "rc5x", 0x1f7f3f, 40, 36000, rc5_encode },
+   [RC_PROTO_RC5X_20] = { "rc5x_20", 0x1f7f3f, 40, 36000, rc5_encode },
[RC_PROTO_RC5_SZ] = { "rc5_sz", 0x2fff, 26, 36000, rc5_encode },
[RC_PROTO_SONY12] = { "sony12", 0x1f007f, 25, 4, sony_encode },
[RC_PROTO_SONY15] = { "sony15", 0xff007f, 31, 4, sony_encode },
diff --git a/utils/ir-ctl/ir-encode.h b/utils/ir-ctl/ir-encode.h
index 4a51f1c..31d81aa 100644
--- a/utils/ir-ctl/ir-encode.h
+++ b/utils/ir-ctl/ir-encode.h
@@ -4,7 +4,7 @@
 
 enum rc_proto {
RC_PROTO_RC5,
-   RC_PROTO_RC5X,
+   RC_PROTO_RC5X_20,
RC_PROTO_RC5_SZ,
RC_PROTO_JVC,
RC_PROTO_SONY12,
-- 
2.9.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 v4l-utils 5/6] ir-keytable: "-p all" or "-p mce-kdb" does not work

2016-12-02 Thread Sean Young
When writing to the sysfs protocols file, use the underscore variant.
The kernel does not accept "mce-kdb" and it never did.

Signed-off-by: Sean Young 
---
 utils/keytable/keytable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index 202610a..a6ecc9e 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -131,8 +131,8 @@ const struct protocol_map_entry protocol_map[] = {
{ "sony20", NULL,   SYSFS_INVALID   },
{ "nec","/nec_decoder", SYSFS_NEC   },
{ "sanyo",  NULL,   SYSFS_SANYO },
-   { "mce-kbd",NULL,   SYSFS_MCE_KBD   },
{ "mce_kbd",NULL,   SYSFS_MCE_KBD   },
+   { "mce-kbd",NULL,   SYSFS_MCE_KBD   },
{ "rc-6",   "/rc6_decoder", SYSFS_RC6   },
{ "rc6",NULL,   SYSFS_RC6   },
{ "rc-6-0", NULL,   SYSFS_INVALID   },
-- 
2.9.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 v4l-utils 4/6] ir-ctl: improve scancode validation

2016-12-02 Thread Sean Young
Ensure rc6 mce is that just that and that nec32 is not necx or nec.

Signed-off-by: Sean Young 
---
 utils/ir-ctl/ir-ctl.c|  4 ++--
 utils/ir-ctl/ir-encode.c | 18 ++
 utils/ir-ctl/ir-encode.h |  1 +
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index 768daad..53ff8ca 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -242,7 +242,7 @@ static struct file *read_file(const char *fname)
return NULL;
}
 
-   if (scancode & ~protocol_scancode_mask(proto)) {
+   if (!protocol_scancode_valid(proto, scancode)) {
fprintf(stderr, _("error: %s:%d: invalid 
scancode '%s' for protocol '%s'\n"), fname, lineno, scancodestr, 
protocol_name(proto));
return NULL;
}
@@ -354,7 +354,7 @@ static struct file *read_scancode(const char *name)
return NULL;
}
 
-   if (scancode & ~protocol_scancode_mask(proto)) {
+   if (!protocol_scancode_valid(proto, scancode)) {
fprintf(stderr, _("error: invalid scancode '%s' for protocol 
'%s'\n"), p + 1, protocol_name(proto));
return NULL;
}
diff --git a/utils/ir-ctl/ir-encode.c b/utils/ir-ctl/ir-encode.c
index 704ce95..d3ee035 100644
--- a/utils/ir-ctl/ir-encode.c
+++ b/utils/ir-ctl/ir-encode.c
@@ -417,6 +417,24 @@ unsigned protocol_scancode_mask(enum rc_proto proto)
return encoders[proto].scancode_mask;
 }
 
+bool protocol_scancode_valid(enum rc_proto p, unsigned s)
+{
+   if (s & ~encoders[p].scancode_mask)
+   return false;
+
+   if (p == RC_PROTO_NECX) {
+   return (((s >> 16) ^ ~(s >> 8)) & 0xff) != 0;
+   } else if (p == RC_PROTO_NEC32) {
+   return (((s >> 24) ^ ~(s >> 16)) & 0xff) != 0;
+   } else if (p == RC_PROTO_RC6_MCE) {
+   return (s & 0x) == 0x800f;
+   } else if (p == RC_PROTO_RC6_6A_32) {
+   return (s & 0x) != 0x800f;
+   }
+
+   return true;
+}
+
 unsigned protocol_encode(enum rc_proto proto, unsigned scancode, unsigned *buf)
 {
return encoders[proto].encode(proto, scancode, buf);
diff --git a/utils/ir-ctl/ir-encode.h b/utils/ir-ctl/ir-encode.h
index b2542ec..4a51f1c 100644
--- a/utils/ir-ctl/ir-encode.h
+++ b/utils/ir-ctl/ir-encode.h
@@ -28,6 +28,7 @@ enum rc_proto {
 bool protocol_match(const char *name, enum rc_proto *proto);
 unsigned protocol_carrier(enum rc_proto proto);
 unsigned protocol_max_size(enum rc_proto proto);
+bool protocol_scancode_valid(enum rc_proto proto, unsigned scancode);
 unsigned protocol_scancode_mask(enum rc_proto proto);
 unsigned protocol_encode(enum rc_proto proto, unsigned scancode, unsigned 
*buf);
 const char *protocol_name(enum rc_proto proto);
-- 
2.9.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


Re: [PATCH v4 9/9] media: venus: enable building of Venus video driver

2016-12-02 Thread kbuild test robot
Hi Stanimir,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on next-20161202]
[cannot apply to v4.9-rc7]
[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/Stanimir-Varbanov/Qualcomm-video-decoder-encoder-driver/20161203-054705
base:   git://linuxtv.org/media_tree.git master
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/media/platform/qcom/venus/hfi_venus.c: In function 
'venus_tzbsp_set_video_state':
>> drivers/media/platform/qcom/venus/hfi_venus.c:455:9: error: implicit 
>> declaration of function 'qcom_scm_video_set_state' 
>> [-Werror=implicit-function-declaration]
 return qcom_scm_video_set_state(state, 0);
^~~~
   cc1: some warnings being treated as errors

vim +/qcom_scm_video_set_state +455 
drivers/media/platform/qcom/venus/hfi_venus.c

93fa34d2 Stanimir Varbanov 2016-12-01  439  
93fa34d2 Stanimir Varbanov 2016-12-01  440  pkt = (struct 
hfi_sys_set_resource_pkt *) packet;
93fa34d2 Stanimir Varbanov 2016-12-01  441  
93fa34d2 Stanimir Varbanov 2016-12-01  442  ret = pkt_sys_set_resource(pkt, 
id, size, addr, cookie);
93fa34d2 Stanimir Varbanov 2016-12-01  443  if (ret)
93fa34d2 Stanimir Varbanov 2016-12-01  444  return ret;
93fa34d2 Stanimir Varbanov 2016-12-01  445  
93fa34d2 Stanimir Varbanov 2016-12-01  446  ret = 
venus_iface_cmdq_write(hdev, pkt);
93fa34d2 Stanimir Varbanov 2016-12-01  447  if (ret)
93fa34d2 Stanimir Varbanov 2016-12-01  448  return ret;
93fa34d2 Stanimir Varbanov 2016-12-01  449  
93fa34d2 Stanimir Varbanov 2016-12-01  450  return 0;
93fa34d2 Stanimir Varbanov 2016-12-01  451  }
93fa34d2 Stanimir Varbanov 2016-12-01  452  
93fa34d2 Stanimir Varbanov 2016-12-01  453  static int 
venus_tzbsp_set_video_state(enum tzbsp_video_state state)
93fa34d2 Stanimir Varbanov 2016-12-01  454  {
93fa34d2 Stanimir Varbanov 2016-12-01 @455  return 
qcom_scm_video_set_state(state, 0);
93fa34d2 Stanimir Varbanov 2016-12-01  456  }
93fa34d2 Stanimir Varbanov 2016-12-01  457  
93fa34d2 Stanimir Varbanov 2016-12-01  458  static int venus_boot_core(struct 
venus_hfi_device *hdev)
93fa34d2 Stanimir Varbanov 2016-12-01  459  {
93fa34d2 Stanimir Varbanov 2016-12-01  460  struct device *dev = 
hdev->core->dev;
93fa34d2 Stanimir Varbanov 2016-12-01  461  static const unsigned int 
max_tries = 100;
93fa34d2 Stanimir Varbanov 2016-12-01  462  u32 ctrl_status = 0;
93fa34d2 Stanimir Varbanov 2016-12-01  463  unsigned int count = 0;

:: The code at line 455 was first introduced by commit
:: 93fa34d264d32979ec1634d8fc366d7cf6ff453d media: venus: hfi: add Venus 
HFI files

:: TO: Stanimir Varbanov 
:: CC: 0day robot 

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


.config.gz
Description: application/gzip


Re: [PATCH v4 1/9] media: v4l2-mem2mem: extend m2m APIs for more accurate buffer management

2016-12-02 Thread kbuild test robot
Hi Stanimir,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.9-rc7 next-20161202]
[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/Stanimir-Varbanov/Qualcomm-video-decoder-encoder-driver/20161203-054705
base:   git://linuxtv.org/media_tree.git master
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
   include/linux/init.h:1: warning: no structured comments found
   include/linux/workqueue.h:392: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:392: warning: Excess function parameter 'args' 
description in 'alloc_workqueue'
   include/linux/workqueue.h:413: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:413: warning: Excess function parameter 'args' 
description in 'alloc_ordered_workqueue'
   include/linux/kthread.h:26: warning: No description found for parameter '...'
   kernel/sys.c:1: warning: no structured comments found
   drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
   include/linux/fence-array.h:61: warning: No description found for parameter 
'fence'
   include/sound/core.h:324: warning: No description found for parameter '...'
   include/sound/core.h:335: warning: No description found for parameter '...'
   include/sound/core.h:388: warning: No description found for parameter '...'
   drivers/media/dvb-core/dvb_frontend.h:677: warning: No description found for 
parameter 'refcount'
   include/media/media-entity.h:1054: warning: No description found for 
parameter '...'
>> include/media/v4l2-mem2mem.h:446: warning: No description found for 
>> parameter 'b'
   include/media/v4l2-mem2mem.h:454: warning: No description found for 
parameter 'b'
   include/media/v4l2-mem2mem.h:463: warning: No description found for 
parameter 'b'
>> include/media/v4l2-mem2mem.h:463: warning: No description found for 
>> parameter 'n'
   include/media/v4l2-mem2mem.h:472: warning: No description found for 
parameter 'b'
   include/media/v4l2-mem2mem.h:472: warning: No description found for 
parameter 'n'
>> include/media/v4l2-mem2mem.h:533: warning: No description found for 
>> parameter 'vbuf'
   include/media/v4l2-mem2mem.h:543: warning: No description found for 
parameter 'vbuf'
   include/media/v4l2-mem2mem.h:555: warning: No description found for 
parameter 'vbuf'
   include/net/mac80211.h:3207: ERROR: Unexpected indentation.
   include/net/mac80211.h:3210: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:3212: ERROR: Unexpected indentation.
   include/net/mac80211.h:3213: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:1772: ERROR: Unexpected indentation.
   include/net/mac80211.h:1776: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/sched/fair.c:7259: WARNING: Inline emphasis start-string without 
end-string.
   kernel/time/timer.c:1240: ERROR: Unexpected indentation.
   kernel/time/timer.c:1242: ERROR: Unexpected indentation.
   kernel/time/timer.c:1243: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:121: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:124: ERROR: Unexpected indentation.
   include/linux/wait.h:126: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/signal.c:317: WARNING: Inline literal start-string without end-string.
   drivers/base/firmware_class.c:1348: WARNING: Bullet list ends without a 
blank line; unexpected unindent.
   drivers/message/fusion/mptbase.c:5054: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   drivers/tty/serial/serial_core.c:1893: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
   WARNING: dvipng command 'dvipng' cannot be run (needed for math display), 
check the imgmath_dvipng setting

vim +/b +446 include/media/v4l2-mem2mem.h

   440   * v4l2_m2m_for_each_dst_buf() - iterate over a list of destination 
ready
   441   * buffers
   442   *
   443   * @m2m_ctx: m2m context assigned to the instance given by struct 
&v4l2_m2m_ctx
   444   */
   445  #define v4l2_m2m_for_each_dst_buf(m2m_ctx, b)   \
 > 446  list_for_each_entry(b, &m2m_ctx->cap_q_ctx.rdy_queue, list)
   447  
   448  /**
   449 

cron job: media_tree daily build: ERRORS

2016-12-02 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:   Sat Dec  3 05:00:19 CET 2016
media-tree git hash:365fe4e0ce218dc5ad10df17b150a366b6015499
media_build git hash:   1606032398b1d79149c1507be2029e1a00d8dff0
v4l-utils git hash: 063d1f5d5e60783002d781e8a23911acbda65e99
gcc version:i686-linux-gcc (GCC) 6.2.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.8.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: 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: 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: WARNINGS
linux-3.3.8-i686: WARNINGS
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: WARNINGS
linux-3.11.1-i686: OK
linux-3.12.67-i686: OK
linux-3.13.11-i686: WARNINGS
linux-3.14.9-i686: WARNINGS
linux-3.15.2-i686: WARNINGS
linux-3.16.7-i686: WARNINGS
linux-3.17.8-i686: WARNINGS
linux-3.18.7-i686: WARNINGS
linux-3.19-i686: WARNINGS
linux-4.0.9-i686: WARNINGS
linux-4.1.33-i686: WARNINGS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: OK
linux-4.9-rc5-i686: OK
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: WARNINGS
linux-3.3.8-x86_64: WARNINGS
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: WARNINGS
linux-3.11.1-x86_64: OK
linux-3.12.67-x86_64: OK
linux-3.13.11-x86_64: WARNINGS
linux-3.14.9-x86_64: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16.7-x86_64: WARNINGS
linux-3.17.8-x86_64: WARNINGS
linux-3.18.7-x86_64: WARNINGS
linux-3.19-x86_64: WARNINGS
linux-4.0.9-x86_64: WARNINGS
linux-4.1.33-x86_64: WARNINGS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: OK
linux-4.9-rc5-x86_64: OK
apps: WARNINGS
spec-git: OK
smatch: ERRORS
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.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] staging: Replaced BUG_ON with warnings

2016-12-02 Thread Shilpa Puttegowda
From: Shilpa P 

Don't crash the Kernel for driver errors

Signed-off-by: Shilpa P 
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 4d9bd02..05f5918 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -1538,7 +1538,11 @@ static int bcm2048_parse_rt_match_c(struct 
bcm2048_device *bdev, int i,
if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
return 0;
 
-   BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
+   if ((index + 2) >= BCM2048_MAX_RDS_RT) {
+   dev_err(&bdev->client->dev,
+   "Incorrect index = %d\n", index);
+   return 0;
+   }
 
if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
BCM2048_RDS_BLOCK_C) {
@@ -1561,7 +1565,11 @@ static void bcm2048_parse_rt_match_d(struct 
bcm2048_device *bdev, int i,
if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
return;
 
-   BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
+   if ((index + 4) >= BCM2048_MAX_RDS_RT) {
+   dev_err(&bdev->client->dev,
+   "Incorrect index = %d\n", index);
+   return;
+   }
 
if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
BCM2048_RDS_BLOCK_D)
-- 
1.9.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] staging: Replaced BUG_ON with warnings

2016-12-02 Thread Allen
On Sat, Dec 3, 2016 at 12:32 PM, Shilpa Puttegowda  wrote:
> From: Shilpa P 
>
> Don't crash the Kernel for driver errors
>
> Signed-off-by: Shilpa P 
> ---
>  drivers/staging/media/bcm2048/radio-bcm2048.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>

Acked-by: Allen Pais 
--
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