Re: [GIT PULL FOR v4.5] Renesas VSP1 improvements and fixes

2016-01-06 Thread Laurent Pinchart
Hi Mauro,

I think this one slipped through the cracks, or possibly got buried under the 
winter holidays snowstorm :-) Could you tell me what your plans are ?

On Wednesday 16 December 2015 10:41:16 Laurent Pinchart wrote:
> Hi Mauro,
> 
> The following changes since commit 52d60eb7e6d6429a766ea1b8f67e01c3b2dcd3c5:
> 
>   Revert "[media] UVC: Add support for ds4 depth camera" (2015-12-12
> 08:10:40 -0200)
> 
> are available in the git repository at:
> 
>   git://linuxtv.org/pinchartl/media.git vsp1/next
> 
> for you to fetch changes up to 41db244b5b484f3f2afc1834552d6771f05c2ebe:
> 
>   v4l: vsp1: Add display list support (2015-12-16 10:37:47 +0200)
> 
> 
> Laurent Pinchart (31):
>   v4l: vsp1: Change the type of the rwpf field in struct vsp1_video
>   v4l: vsp1: Store the memory format in struct vsp1_rwpf
>   v4l: vsp1: Move video operations to vsp1_rwpf
>   v4l: vsp1: Rename vsp1_video_buffer to vsp1_vb2_buffer
>   v4l: vsp1: Move video device out of struct vsp1_rwpf
>   v4l: vsp1: Make rwpf operations independent of video device
>   v4l: vsp1: Support VSP1 instances without any UDS
>   v4l: vsp1: Move vsp1_video pointer from vsp1_entity to vsp1_rwpf
>   v4l: vsp1: Remove struct vsp1_pipeline num_video field
>   v4l: vsp1: Decouple pipeline end of frame processing from vsp1_video
>   v4l: vsp1: Split pipeline management code from vsp1_video.c
>   v4l: vsp1: Rename video pipeline functions to use vsp1_video prefix
>   v4l: vsp1: Extract pipeline initialization code into a function
>   v4l: vsp1: Reuse local variable instead of recomputing it
>   v4l: vsp1: Extract link creation to separate function
>   v4l: vsp1: Document the vsp1_pipeline structure
>   v4l: vsp1: Fix typo in VI6_DISP_IRQ_STA_DST register bit name
>   v4l: vsp1: Set the SRU CTRL0 register when starting the stream
>   v4l: vsp1: Remove unused module read functions
>   v4l: vsp1: Move entity route setup function to vsp1_entity.c
>   v4l: vsp1: Make number of BRU inputs configurable
>   v4l: vsp1: Make the BRU optional
>   v4l: vsp1: Move format info to vsp1_pipe.c
>   v4l: vsp1: Make the userspace API optional
>   v4l: vsp1: Make pipeline inputs array index by RPF index
>   v4l: vsp1: Set the alpha value manually in RPF and WPF s_stream
> handlers v4l: vsp1: Don't validate links when the userspace API is disabled
> v4l: vsp1: Add VSP+DU support
>   v4l: vsp1: Disconnect unused RPFs from the DRM pipeline
>   v4l: vsp1: Implement atomic update for the DRM driver
>   v4l: vsp1: Add support for the R-Car Gen3 VSP2
> 
> Takashi Saito (1):
>   v4l: vsp1: Add display list support
> 
>  .../devicetree/bindings/media/renesas,vsp1.txt  |  21 +-
>  drivers/media/platform/vsp1/Makefile|   3 +-
>  drivers/media/platform/vsp1/vsp1.h  |  24 +
>  drivers/media/platform/vsp1/vsp1_bru.c  |  33 +-
>  drivers/media/platform/vsp1/vsp1_bru.h  |   3 +-
>  drivers/media/platform/vsp1/vsp1_dl.c   | 304 
>  drivers/media/platform/vsp1/vsp1_dl.h   |  42 ++
>  drivers/media/platform/vsp1/vsp1_drm.c  | 597 +
>  drivers/media/platform/vsp1/vsp1_drm.h  |  38 ++
>  drivers/media/platform/vsp1/vsp1_drv.c  | 254 --
>  drivers/media/platform/vsp1/vsp1_entity.c   |  31 +-
>  drivers/media/platform/vsp1/vsp1_entity.h   |  14 +-
>  drivers/media/platform/vsp1/vsp1_hsit.c |   2 +-
>  drivers/media/platform/vsp1/vsp1_lif.c  |  11 +-
>  drivers/media/platform/vsp1/vsp1_lut.c  |   7 +-
>  drivers/media/platform/vsp1/vsp1_pipe.c | 405 +
>  drivers/media/platform/vsp1/vsp1_pipe.h | 134 ++
>  drivers/media/platform/vsp1/vsp1_regs.h |  32 +-
>  drivers/media/platform/vsp1/vsp1_rpf.c  |  77 ++-
>  drivers/media/platform/vsp1/vsp1_rwpf.h |  24 +-
>  drivers/media/platform/vsp1/vsp1_sru.c  |   9 +-
>  drivers/media/platform/vsp1/vsp1_uds.c  |   8 +-
>  drivers/media/platform/vsp1/vsp1_video.c| 516 ++--
>  drivers/media/platform/vsp1/vsp1_video.h| 111 +
>  drivers/media/platform/vsp1/vsp1_wpf.c  |  88 ++--
>  include/media/vsp1.h|  33 ++
>  26 files changed, 2071 insertions(+), 750 deletions(-)
>  create mode 100644 drivers/media/platform/vsp1/vsp1_dl.c
>  create mode 100644 drivers/media/platform/vsp1/vsp1_dl.h
>  create mode 100644 drivers/media/platform/vsp1/vsp1_drm.c
>  create mode 100644 drivers/media/platform/vsp1/vsp1_drm.h
>  create mode 100644 drivers/media/platform/vsp1/vsp1_pipe.c
>  create mode 100644 

Re: [PATCH 08/10] [media] tvp5150: Add OF match table

2016-01-06 Thread Laurent Pinchart
Hi Javier,

Thank you for the patch.

On Monday 04 January 2016 09:25:30 Javier Martinez Canillas wrote:
> From: Eduard Gavin 
> 
> The Documentation/devicetree/bindings/media/i2c/tvp5150.txt DT binding doc
> lists "ti,tvp5150" as the device compatible string but the driver does not
> have an OF match table. Add the table to the driver so the I2C core can do
> an OF style match.
> 
> Signed-off-by: Eduard Gavin 
> Signed-off-by: Javier Martinez Canillas 

Reviewed-by: Laurent Pinchart 

> ---
> 
>  drivers/media/i2c/tvp5150.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index 105bd1c6b17f..caac96a577f8 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -1295,8 +1295,17 @@ static const struct i2c_device_id tvp5150_id[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, tvp5150_id);
> 
> +#if IS_ENABLED(CONFIG_OF)
> +static const struct of_device_id tvp5150_of_match[] = {
> + { .compatible = "ti,tvp5150", },
> + { /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(of, tvp5150_of_match);
> +#endif
> +
>  static struct i2c_driver tvp5150_driver = {
>   .driver = {
> + .of_match_table = of_match_ptr(tvp5150_of_match),
>   .name   = "tvp5150",
>   },
>   .probe  = tvp5150_probe,

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH 09/10] [media] tvp5150: Initialize the chip on probe

2016-01-06 Thread Javier Martinez Canillas
Hello Laurent,

On 01/06/2016 07:59 AM, Laurent Pinchart wrote:
> Hi Javier,
> 
> Thankk you for the patch.
>

Thanks a lot for your feedback.
 
> On Monday 04 January 2016 09:25:31 Javier Martinez Canillas wrote:
>> After power-up, the tvp5150 decoder is in a unknown state until the
>> RESETB pin is driven LOW which reset all the registers and restarts
>> the chip's internal state machine.
>>
>> The init sequence has some timing constraints and the RESETB signal
>> can only be used if the PDN (Power-down) pin is first released.
>>
>> So, the initialization sequence is as follows:
>>
>> 1- PDN (active-low) is driven HIGH so the chip is power-up
>> 2- A 20 ms delay is needed before sending a RESETB (active-low) signal.
>> 3- The RESETB pulse duration is 500 ns.
>> 4- A 200 us delay is needed for the I2C client to be active after reset.
>>
>> This patch used as a reference the logic in the IGEPv2 board file from
>> the ISEE 2.6.37 vendor tree.
>>
>> Signed-off-by: Javier Martinez Canillas 
>> ---
>>
>>  drivers/media/i2c/tvp5150.c | 35 +++
>>  1 file changed, 35 insertions(+)
>>
>> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
>> index caac96a577f8..fed89a811ab7 100644
>> --- a/drivers/media/i2c/tvp5150.c
>> +++ b/drivers/media/i2c/tvp5150.c
>> @@ -5,6 +5,7 @@
>>   * This code is placed under the terms of the GNU General Public License v2
>> */
>>
>> +#include 
> 
> Let's keep the headers sorted alphabetically if you don't mind :-)
>

Right, sorry about that.
 
>>  #include 
>>  #include 
>>  #include 
>> @@ -1197,6 +1198,36 @@ static int tvp5150_detect_version(struct tvp5150
>> *core) return 0;
>>  }
>>
>> +static inline int tvp5150_init(struct i2c_client *c)
>> +{
>> +struct gpio_desc *pdn_gpio;
>> +struct gpio_desc *reset_gpio;
>> +
>> +pdn_gpio = devm_gpiod_get_optional(>dev, "powerdown", 
>> GPIOD_OUT_HIGH);
>> +if (IS_ERR(pdn_gpio))
>> +return PTR_ERR(pdn_gpio);
>> +
>> +if (pdn_gpio) {
>> +gpiod_set_value_cansleep(pdn_gpio, 0);
>> +/* Delay time between power supplies active and reset */
>> +msleep(20);
> 
> How about usleep_range() instead ?
>

Documentation/timers/timers-howto.txt says that usleep_range() should be
used for 1ms - 20ms and msleep() for 20ms+ so since this was a boundary
value, I chose for msleep() but I can use usleep_range() if you want.

I've no strong opinion on this.

>> +}
>> +
>> +reset_gpio = devm_gpiod_get_optional(>dev, "reset", GPIOD_OUT_HIGH);
>> +if (IS_ERR(reset_gpio))
>> +return PTR_ERR(reset_gpio);
>> +
>> +if (reset_gpio) {
>> +/* RESETB pulse duration */
>> +ndelay(500);
> 
> Is the timing so sensitive that we need a delay, or could we use 
> usleep_range() ?
>

According to my tests, it is a minimum value but I chose to do a delay since
the time is very short and also Documentation/timers/timers-howto.txt says
that using usleep for very short periods may not be worth it due the overhead
of setting up the hrtimers for usleep.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
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 10/10] [media] tvp5150: Configure data interface via pdata or DT

2016-01-06 Thread Laurent Pinchart
Hi Javier,

Thank you for the patch.

On Monday 04 January 2016 09:25:32 Javier Martinez Canillas wrote:
> The video decoder supports either 8-bit 4:2:2 YUV with discrete syncs
> or 8-bit ITU-R BT.656 with embedded syncs output format but currently
> BT.656 it's always reported. Allow to configure the format to use via
> either platform data or a device tree definition.
> 
> Signed-off-by: Javier Martinez Canillas 
> ---
>  drivers/media/i2c/tvp5150.c | 61 --
>  include/media/i2c/tvp5150.h |  5 
>  2 files changed, 64 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index fed89a811ab7..8bce45a6e264 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -6,6 +6,7 @@
>   */
> 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -15,6 +16,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include "tvp5150_reg.h"
> 
> @@ -39,6 +41,7 @@ struct tvp5150 {
>   struct media_pad pad;
>   struct v4l2_ctrl_handler hdl;
>   struct v4l2_rect rect;
> + struct tvp5150_platform_data *pdata;

How about embedding tvp5150_platform_data instead of pointing to it ? It would 
save an allocation and you could get rid of the pdata != NULL checks.

>   v4l2_std_id norm;   /* Current set standard */
>   u32 input;
> @@ -757,6 +760,7 @@ static int tvp5150_s_std(struct v4l2_subdev *sd,
> v4l2_std_id std) static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
>  {
>   struct tvp5150 *decoder = to_tvp5150(sd);
> + struct tvp5150_platform_data *pdata = decoder->pdata;
> 
>   /* Initializes TVP5150 to its default values */
>   tvp5150_write_inittab(sd, tvp5150_init_default);
> @@ -774,6 +778,10 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32
> val) v4l2_ctrl_handler_setup(>hdl);
> 
>   tvp5150_set_std(sd, decoder->norm);
> +
> + if (pdata && pdata->bus_type == V4L2_MBUS_PARALLEL)
> + tvp5150_write(sd, TVP5150_DATA_RATE_SEL, 0x40);
> +
>   return 0;
>  };
> 
> @@ -940,6 +948,16 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd,
> struct v4l2_cropcap *a) static int tvp5150_g_mbus_config(struct v4l2_subdev
> *sd,
>struct v4l2_mbus_config *cfg)
>  {
> + struct tvp5150_platform_data *pdata = to_tvp5150(sd)->pdata;
> +
> + if (pdata) {
> + cfg->type = pdata->bus_type;
> + cfg->flags = pdata->parallel_flags;

The clock and sync signals polarity don't seem configurable, shouldn't they 
just be hardcoded as currently done ?

> + return 0;
> + }
> +
> + /* Default values if no platform data was provided */
>   cfg->type = V4L2_MBUS_BT656;
>   cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
> 
>  | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
> 
> @@ -986,13 +1004,20 @@ static int tvp5150_enum_frame_size(struct v4l2_subdev
> *sd,
> 
>  static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
>  {
> + struct tvp5150_platform_data *pdata = to_tvp5150(sd)->pdata;
> + /* Output format: 8-bit ITU-R BT.656 with embedded syncs */
> + int val = 0x09;
> +
> + /* Output format: 8-bit 4:2:2 YUV with discrete sync */
> + if (pdata && pdata->bus_type == V4L2_MBUS_PARALLEL)
> + val = 0x0d;
> +
>   /* Initializes TVP5150 to its default values */
>   /* # set PCLK (27MHz) */
>   tvp5150_write(sd, TVP5150_CONF_SHARED_PIN, 0x00);
> 
> - /* Output format: 8-bit ITU-R BT.656 with embedded syncs */
>   if (enable)
> - tvp5150_write(sd, TVP5150_MISC_CTL, 0x09);
> + tvp5150_write(sd, TVP5150_MISC_CTL, val);
>   else
>   tvp5150_write(sd, TVP5150_MISC_CTL, 0x00);
> 
> @@ -1228,11 +1253,42 @@ static inline int tvp5150_init(struct i2c_client *c)
> return 0;
>  }
> 
> +static struct tvp5150_platform_data *tvp5150_get_pdata(struct device *dev)
> +{
> + struct tvp5150_platform_data *pdata = dev_get_platdata(dev);
> + struct v4l2_of_endpoint bus_cfg;
> + struct device_node *ep;
> +
> + if (pdata)
> + return pdata;

Nobody uses platform data today, I wonder whether we shouldn't postpone adding 
support for it until we have a use case. Embedded systems (at least the ARM-
based ones) should use DT.

> + if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return NULL;
> +
> + ep = of_graph_get_next_endpoint(dev->of_node, NULL);
> + if (!ep)
> + return NULL;
> +
> + v4l2_of_parse_endpoint(ep, _cfg);

Shouldn't you check the return value of the function ?

> +
> + pdata->bus_type = bus_cfg.bus_type;
> + pdata->parallel_flags = bus_cfg.bus.parallel.flags;

The 

Re: [PATCH 07/10] [media] tvp5150: Add device tree binding document

2016-01-06 Thread Laurent Pinchart
On Wednesday 06 January 2016 07:46:35 Javier Martinez Canillas wrote:
> On 01/06/2016 07:39 AM, Laurent Pinchart wrote:
> > Hi Javier,
> > 
> > Thank you for the patch.
> 
> Thanks a lot for your feedback.
> 
> [snip]
> 
> >> +
> >> +Optional Properties:
> >> +- powerdown-gpios: phandle for the GPIO connected to the PDN pin, if
> >> any.
> > 
> > The signal is called PDN in the datasheet, so it might make sense to call
> > this pdn-gpios. I have no strong opinion on this, I'll let you decide
> > what you think is best.
> 
> Yes, I wondered if the convention was to use a descriptive name or the one
> used in the datasheet but Documentation/devicetree/bindings/gpio/gpio.txt
> says nothing about it.

The device tree maintainers might want to comment on that :-)

> I'll change it to pdn-gpios since it could be easier to match with the doc.

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH 09/10] [media] tvp5150: Initialize the chip on probe

2016-01-06 Thread Laurent Pinchart
Hi Javier,

Thankk you for the patch.

On Monday 04 January 2016 09:25:31 Javier Martinez Canillas wrote:
> After power-up, the tvp5150 decoder is in a unknown state until the
> RESETB pin is driven LOW which reset all the registers and restarts
> the chip's internal state machine.
> 
> The init sequence has some timing constraints and the RESETB signal
> can only be used if the PDN (Power-down) pin is first released.
> 
> So, the initialization sequence is as follows:
> 
> 1- PDN (active-low) is driven HIGH so the chip is power-up
> 2- A 20 ms delay is needed before sending a RESETB (active-low) signal.
> 3- The RESETB pulse duration is 500 ns.
> 4- A 200 us delay is needed for the I2C client to be active after reset.
> 
> This patch used as a reference the logic in the IGEPv2 board file from
> the ISEE 2.6.37 vendor tree.
> 
> Signed-off-by: Javier Martinez Canillas 
> ---
> 
>  drivers/media/i2c/tvp5150.c | 35 +++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index caac96a577f8..fed89a811ab7 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -5,6 +5,7 @@
>   * This code is placed under the terms of the GNU General Public License v2
> */
> 
> +#include 

Let's keep the headers sorted alphabetically if you don't mind :-)

>  #include 
>  #include 
>  #include 
> @@ -1197,6 +1198,36 @@ static int tvp5150_detect_version(struct tvp5150
> *core) return 0;
>  }
> 
> +static inline int tvp5150_init(struct i2c_client *c)
> +{
> + struct gpio_desc *pdn_gpio;
> + struct gpio_desc *reset_gpio;
> +
> + pdn_gpio = devm_gpiod_get_optional(>dev, "powerdown", 
> GPIOD_OUT_HIGH);
> + if (IS_ERR(pdn_gpio))
> + return PTR_ERR(pdn_gpio);
> +
> + if (pdn_gpio) {
> + gpiod_set_value_cansleep(pdn_gpio, 0);
> + /* Delay time between power supplies active and reset */
> + msleep(20);

How about usleep_range() instead ?

> + }
> +
> + reset_gpio = devm_gpiod_get_optional(>dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(reset_gpio))
> + return PTR_ERR(reset_gpio);
> +
> + if (reset_gpio) {
> + /* RESETB pulse duration */
> + ndelay(500);

Is the timing so sensitive that we need a delay, or could we use 
usleep_range() ?

> + gpiod_set_value_cansleep(reset_gpio, 0);
> + /* Delay time between end of reset to I2C active */
> + usleep_range(200, 250);
> + }
> +
> + return 0;
> +}
> +
>  static int tvp5150_probe(struct i2c_client *c,
>const struct i2c_device_id *id)
>  {
> @@ -1209,6 +1240,10 @@ static int tvp5150_probe(struct i2c_client *c,
>I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
>   return -EIO;
> 
> + res = tvp5150_init(c);
> + if (res)
> + return res;
> +
>   core = devm_kzalloc(>dev, sizeof(*core), GFP_KERNEL);
>   if (!core)
>   return -ENOMEM;

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


[patch] [media] vpx3220: signedness bug in vpx3220_fp_read()

2016-01-06 Thread Dan Carpenter
The intent was to return -1 on error and that's what the callers expect
but the current code returns USHRT_MAX instead.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c
index 4b564f1..90b693f 100644
--- a/drivers/media/i2c/vpx3220.c
+++ b/drivers/media/i2c/vpx3220.c
@@ -124,7 +124,7 @@ static int vpx3220_fp_write(struct v4l2_subdev *sd, u8 
fpaddr, u16 data)
return 0;
 }
 
-static u16 vpx3220_fp_read(struct v4l2_subdev *sd, u16 fpaddr)
+static int vpx3220_fp_read(struct v4l2_subdev *sd, u16 fpaddr)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
s16 data;
--
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 10/10] [media] tvp5150: Configure data interface via pdata or DT

2016-01-06 Thread Javier Martinez Canillas
Hello Laurent,

Thanks a lot for your feedback.

On 01/06/2016 07:56 AM, Laurent Pinchart wrote:
> Hi Javier,
> 
> Thank you for the patch.
> 
> On Monday 04 January 2016 09:25:32 Javier Martinez Canillas wrote:
>> The video decoder supports either 8-bit 4:2:2 YUV with discrete syncs
>> or 8-bit ITU-R BT.656 with embedded syncs output format but currently
>> BT.656 it's always reported. Allow to configure the format to use via
>> either platform data or a device tree definition.
>>
>> Signed-off-by: Javier Martinez Canillas 
>> ---
>>  drivers/media/i2c/tvp5150.c | 61 --
>>  include/media/i2c/tvp5150.h |  5 
>>  2 files changed, 64 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
>> index fed89a811ab7..8bce45a6e264 100644
>> --- a/drivers/media/i2c/tvp5150.c
>> +++ b/drivers/media/i2c/tvp5150.c
>> @@ -6,6 +6,7 @@
>>   */
>>
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -15,6 +16,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include "tvp5150_reg.h"
>>
>> @@ -39,6 +41,7 @@ struct tvp5150 {
>>  struct media_pad pad;
>>  struct v4l2_ctrl_handler hdl;
>>  struct v4l2_rect rect;
>> +struct tvp5150_platform_data *pdata;
> 
> How about embedding tvp5150_platform_data instead of pointing to it ? It 
> would 
> save an allocation and you could get rid of the pdata != NULL checks.
>

Agreed.
 
>>  v4l2_std_id norm;   /* Current set standard */
>>  u32 input;
>> @@ -757,6 +760,7 @@ static int tvp5150_s_std(struct v4l2_subdev *sd,
>> v4l2_std_id std) static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
>>  {
>>  struct tvp5150 *decoder = to_tvp5150(sd);
>> +struct tvp5150_platform_data *pdata = decoder->pdata;
>>
>>  /* Initializes TVP5150 to its default values */
>>  tvp5150_write_inittab(sd, tvp5150_init_default);
>> @@ -774,6 +778,10 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32
>> val) v4l2_ctrl_handler_setup(>hdl);
>>
>>  tvp5150_set_std(sd, decoder->norm);
>> +
>> +if (pdata && pdata->bus_type == V4L2_MBUS_PARALLEL)
>> +tvp5150_write(sd, TVP5150_DATA_RATE_SEL, 0x40);
>> +
>>  return 0;
>>  };
>>
>> @@ -940,6 +948,16 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd,
>> struct v4l2_cropcap *a) static int tvp5150_g_mbus_config(struct v4l2_subdev
>> *sd,
>>   struct v4l2_mbus_config *cfg)
>>  {
>> +struct tvp5150_platform_data *pdata = to_tvp5150(sd)->pdata;
>> +
>> +if (pdata) {
>> +cfg->type = pdata->bus_type;
>> +cfg->flags = pdata->parallel_flags;
> 
> The clock and sync signals polarity don't seem configurable, shouldn't they 
> just be hardcoded as currently done ?
>

That's a very good question, I added the flags because according to
Documentation/devicetree/bindings/media/video-interfaces.txt, the way
to define that the output format will be BT.656 is to avoid defining
{hsync,vsync,field-even}-active properties.

IOW, if parallel sync is used, then these properties have to be defined
and it felt strange to not use in the driver what is defined in the DT.

>> +return 0;
>> +}
>> +
>> +/* Default values if no platform data was provided */
>>  cfg->type = V4L2_MBUS_BT656;
>>  cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
>>
>> | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
>>
>> @@ -986,13 +1004,20 @@ static int tvp5150_enum_frame_size(struct v4l2_subdev
>> *sd,
>>
>>  static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
>>  {
>> +struct tvp5150_platform_data *pdata = to_tvp5150(sd)->pdata;
>> +/* Output format: 8-bit ITU-R BT.656 with embedded syncs */
>> +int val = 0x09;
>> +
>> +/* Output format: 8-bit 4:2:2 YUV with discrete sync */
>> +if (pdata && pdata->bus_type == V4L2_MBUS_PARALLEL)
>> +val = 0x0d;
>> +
>>  /* Initializes TVP5150 to its default values */
>>  /* # set PCLK (27MHz) */
>>  tvp5150_write(sd, TVP5150_CONF_SHARED_PIN, 0x00);
>>
>> -/* Output format: 8-bit ITU-R BT.656 with embedded syncs */
>>  if (enable)
>> -tvp5150_write(sd, TVP5150_MISC_CTL, 0x09);
>> +tvp5150_write(sd, TVP5150_MISC_CTL, val);
>>  else
>>  tvp5150_write(sd, TVP5150_MISC_CTL, 0x00);
>>
>> @@ -1228,11 +1253,42 @@ static inline int tvp5150_init(struct i2c_client *c)
>> return 0;
>>  }
>>
>> +static struct tvp5150_platform_data *tvp5150_get_pdata(struct device *dev)
>> +{
>> +struct tvp5150_platform_data *pdata = dev_get_platdata(dev);
>> +struct v4l2_of_endpoint bus_cfg;
>> +struct device_node *ep;
>> +
>> +if (pdata)
>> +return pdata;
> 
> Nobody uses platform data today, I wonder whether we shouldn't postpone 
> adding 
> support for it until we have a use case. Embedded systems (at least the ARM-
> based 

[REGRESSION/bisected] kernel oops in vb2_core_qbuf when tuning to DVB on the HVR-4400 caused by videobuf2: Refactor vb2_fileio_data and vb2_thread

2016-01-06 Thread Matthias Schwarzott
Hi!

When tuning the HVR-4400 to a DVB-C channel I get this kernel oops:

Jan  3 21:59:39 gauss kernel: BUG: unable to handle kernel NULL pointer
dereference at 01a0
Jan  3 21:59:39 gauss kernel: IP: []
vb2_core_qbuf+0x18/0x200 [videobuf2_core]
Jan  3 21:59:39 gauss kernel: PGD bbf99067 PUD b9dbf067 PMD 0
Jan  3 21:59:39 gauss kernel: Oops:  [#1] SMP
Jan  3 21:59:39 gauss kernel: Modules linked in: si2165(O) a8293(O)
tda10071(O) tea5767(O) tuner(O) cx23885(O) tda18271(O) videobuf2_dvb(O)
videobuf2_dma_sg(O) videobuf2_memops(O) frame_vector(PO)
videobuf2_v4l2(O) videobuf2_core(O) tveeprom(O) cx2341x(O)
v4l2_common(O) videodev(O) media(O) dvb_core(O) rc_core(O) regmap_i2c
bluetooth rtl8192cu rtl_usb rtl8192c_common uas rtlwifi usb_storage
snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic
snd_hda_intel snd_hda_codec x86_pkg_temp_thermal kvm_intel kvm snd_hwdep
snd_hda_core [last unloaded: si2165]
Jan  3 21:59:39 gauss kernel: CPU: 2 PID: 29081 Comm: vb2-cx23885[0]
Tainted: PW  O4.2.8-gentoo #1
Jan  3 21:59:39 gauss kernel: Hardware name: MEDION E2050
2391/H81H3-EM2, BIOS H81EM2W08.308 08/25/2014
Jan  3 21:59:39 gauss kernel: task: 880087533300 ti:
880101ca8000 task.ti: 880101ca8000
Jan  3 21:59:39 gauss kernel: RIP: 0010:[]
[] vb2_core_qbuf+0x18/0x200 [videobuf2_core]
Jan  3 21:59:39 gauss kernel: RSP: 0018:880101cabe28  EFLAGS: 00010246
Jan  3 21:59:39 gauss kernel: RAX: 880087533300 RBX:
8800a9c98000 RCX: 03a5
Jan  3 21:59:39 gauss kernel: RDX: 8800a9c98000 RSI:
5e00 RDI: 88011995e828
Jan  3 21:59:39 gauss kernel: RBP: 880101cabe48 R08:
0007 R09: 0001
Jan  3 21:59:39 gauss kernel: R10:  R11:
88011995e828 R12: 88011a457780
Jan  3 21:59:39 gauss kernel: R13:  R14:
8800a9c98000 R15: 88011995e828
Jan  3 21:59:39 gauss kernel: FS:  ()
GS:88011fb0() knlGS:
Jan  3 21:59:39 gauss kernel: CS:  0010 DS:  ES:  CR0:
80050033
Jan  3 21:59:39 gauss kernel: CR2: 01a0 CR3:
b9e63000 CR4: 001406e0
Jan  3 21:59:39 gauss kernel: Stack:
Jan  3 21:59:39 gauss kernel:  8800a9c98000 88011a457780
 
Jan  3 21:59:39 gauss kernel:  880101cabeb8 a019f83c
88004550bb58 880087533300
Jan  3 21:59:39 gauss kernel:  8800a9c9a400 00cac000
88011995e828 a019f610
Jan  3 21:59:39 gauss kernel: Call Trace:
Jan  3 21:59:39 gauss kernel:  []
vb2_thread+0x22c/0x3c0 [videobuf2_core]
Jan  3 21:59:39 gauss kernel:  [] ?
vb2_core_dqbuf+0x5a0/0x5a0 [videobuf2_core]
Jan  3 21:59:39 gauss kernel:  [] ?
vb2_core_dqbuf+0x5a0/0x5a0 [videobuf2_core]
Jan  3 21:59:39 gauss kernel:  [] kthread+0xc4/0xe0
Jan  3 21:59:39 gauss kernel:  [] ?
kthread_worker_fn+0x150/0x150
Jan  3 21:59:39 gauss kernel:  [] ret_from_fork+0x3f/0x70
Jan  3 21:59:39 gauss kernel:  [] ?
kthread_worker_fn+0x150/0x150
Jan  3 21:59:39 gauss kernel: Code: c7 a8 1d 1a a0 e8 12 67 6f e1 31 c0
e9 70 ff ff ff 66 90 55 89 f6 48 89 e5 41 56 41 55 41 54 53 49 89 d6 4c
8b ac f7 80 00 00 00 <41> 8b 95 a0 01 00 00 83 fa 01 0f 84 fb 00 00 00
49 89 fc 0f 82
Jan  3 21:59:39 gauss kernel: RIP  []
vb2_core_qbuf+0x18/0x200 [videobuf2_core]
Jan  3 21:59:39 gauss kernel:  RSP 
Jan  3 21:59:39 gauss kernel: CR2: 01a0
Jan  3 21:59:39 gauss kernel: ---[ end trace f45084629c26b0e2 ]---

It oopses in vb2_core_qbuf+0x18
addr2line shows this:
media_build/v4l/videobuf2-core.c:1377

>From decodecode:
  13:   55  push   %rbp
  14:   89 f6   mov%esi,%esi
  16:   48 89 e5mov%rsp,%rbp
  19:   41 56   push   %r14
  1b:   41 55   push   %r13
  1d:   41 54   push   %r12
  1f:   53  push   %rbx
  20:   49 89 d6mov%rdx,%r14
  23:   4c 8b ac f7 80 00 00mov0x80(%rdi,%rsi,8),%r13
  2a:   00
  2b:*  41 8b 95 a0 01 00 00mov0x1a0(%r13),%edx <--
trapping instruction
  32:   83 fa 01cmp$0x1,%edx
  35:   0f 84 fb 00 00 00   je 0x136
  3b:   49 89 fcmov%rdi,%r12

1375: vb = q->bufs[index];
1376:
1377: switch (vb->state) {

The value vb (r13) is equal to 0 here.

I bisected the oops to this commit:
70433a152f0058404afb5496a9329e4e26b127df is the first bad commit
commit 70433a152f0058404afb5496a9329e4e26b127df
Author: Junghak Sung 
Date:   Tue Nov 3 08:16:41 2015 -0200

[media] media: videobuf2: Refactor vb2_fileio_data and vb2_thread

Replace v4l2-stuffs with common things in struct vb2_fileio_data and
vb2_thread().

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 

Re: [PATCH 07/10] [media] tvp5150: Add device tree binding document

2016-01-06 Thread Javier Martinez Canillas
Hello Laurent,

On 01/06/2016 07:39 AM, Laurent Pinchart wrote:
> Hi Javier,
> 
> Thank you for the patch.
>

Thanks a lot for your feedback.

[snip]

>> +
>> +Optional Properties:
>> +- powerdown-gpios: phandle for the GPIO connected to the PDN pin, if any.
> 
> The signal is called PDN in the datasheet, so it might make sense to call 
> this 
> pdn-gpios. I have no strong opinion on this, I'll let you decide what you 
> think is best.
>

Yes, I wondered if the convention was to use a descriptive name or the one
used in the datasheet but Documentation/devicetree/bindings/gpio/gpio.txt
says nothing about it.

I'll change it to pdn-gpios since it could be easier to match with the doc.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
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 07/10] [media] tvp5150: Add device tree binding document

2016-01-06 Thread Laurent Pinchart
Hi Javier,

Thank you for the patch.

On Monday 04 January 2016 09:25:29 Javier Martinez Canillas wrote:
> Add a Device Tree binding document for the TVP5150 video decoder.
> 
> Signed-off-by: Javier Martinez Canillas 
> ---
> 
>  .../devicetree/bindings/media/i2c/tvp5150.txt  | 35 +++
>  1 file changed, 35 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp5150.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
> b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt new file mode
> 100644
> index ..bf0b3f3128ce
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
> @@ -0,0 +1,35 @@
> +* Texas Instruments TVP5150 and TVP5151 video decoders
> +
> +The TVP5150 and TVP5151 are video decoders that convert baseband NTSC and
> PAL
> +(and also SECAM in the TVP5151 case) video signals to either 8-bit 4:2:2
> YUV
> +with discrete syncs or 8-bit ITU-R BT.656 with embedded syncs output
> formats.
> +
> +Required Properties:
> +- compatible: value must be "ti,tvp5150"
> +- reg: I2C slave address
> +
> +Optional Properties:
> +- powerdown-gpios: phandle for the GPIO connected to the PDN pin, if any.

The signal is called PDN in the datasheet, so it might make sense to call this 
pdn-gpios. I have no strong opinion on this, I'll let you decide what you 
think is best.

Apart from that (and the indentation issue pointed out by Rob),

Reviewed-by: Laurent Pinchart 

> +- reset-gpios: phandle for the GPIO connected to the RESETB pin, if any.
> +
> +The device node must contain one 'port' child node for its digital output
> +video port, in accordance with the video interface bindings defined in
> +Documentation/devicetree/bindings/media/video-interfaces.txt.
> +
> +Example:
> +
> + {
> + ...
> + tvp5150@5c {
> + compatible = "ti,tvp5150";
> + reg = <0x5c>;
> + powerdown-gpios = < 30 GPIO_ACTIVE_LOW>;
> + reset-gpios = < 7 GPIO_ACTIVE_LOW>;
> +
> + port {
> + tvp5150_1: endpoint {
> + remote-endpoint = <_ep>;
> + };
> + };
> + };
> +};

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v2 0/8] i2c mux cleanup and locking update

2016-01-06 Thread Crt Mori
Hi Wolfram and Peter,
I will give my opinion about the path chosen although it should be
taken lightly.

I can see that hardware guys missed the software guys again on the
development path, but since this happens more often than not, I would
say it seems OK to have support for this as long as it does not make
more complex (longer) standard i2c transfers. I would support to have
additional mutex before mux as that will make less chance that someone
forgets to lock mutex before mux and proposed solution seems valid.

Regards,
Crt

On 5 January 2016 at 19:48, Wolfram Sang  wrote:
> Peter,
>
>> PS. needs a bunch of testing, I do not have access to all the involved hw
>
> First of all, thanks for diving into this topic and the huge effort you
> apparently have put into it.
>
> It is obviously a quite intrusive series, so it needs careful review.
> TBH, I can't really tell when I have the bandwidth to do that, so I hope
> other people will step up. And yes, it needs serious testing.
>
> To all: Although I appreciate any review support, I'd think the first
> thing to be done should be a very high level review - is this series
> worth the huge update? Is the path chosen proper? Stuff like this. I'd
> appreciate Acks or Revs for that. Stuff like fixing checkpatch warnings
> and other minor stuff should come later.
>
> Thanks,
>
>Wolfram
>
--
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 10/10] [media] tvp5150: Configure data interface via pdata or DT

2016-01-06 Thread Laurent Pinchart
Hi Javier,

On Wednesday 06 January 2016 08:27:26 Javier Martinez Canillas wrote:
> On 01/06/2016 07:56 AM, Laurent Pinchart wrote:
> > On Monday 04 January 2016 09:25:32 Javier Martinez Canillas wrote:
> >> The video decoder supports either 8-bit 4:2:2 YUV with discrete syncs
> >> or 8-bit ITU-R BT.656 with embedded syncs output format but currently
> >> BT.656 it's always reported. Allow to configure the format to use via
> >> either platform data or a device tree definition.
> >> 
> >> Signed-off-by: Javier Martinez Canillas 
> >> ---
> >> 
> >>  drivers/media/i2c/tvp5150.c | 61 +--
> >>  include/media/i2c/tvp5150.h |  5 
> >>  2 files changed, 64 insertions(+), 2 deletions(-)
> >> 
> >> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> >> index fed89a811ab7..8bce45a6e264 100644
> >> --- a/drivers/media/i2c/tvp5150.c
> >> +++ b/drivers/media/i2c/tvp5150.c

[snip]

> >> @@ -940,6 +948,16 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd,
> >> struct v4l2_cropcap *a)
> >>  static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
> >> struct v4l2_mbus_config *cfg)
> >>  {
> >> +  struct tvp5150_platform_data *pdata = to_tvp5150(sd)->pdata;
> >> +
> >> +  if (pdata) {
> >> +  cfg->type = pdata->bus_type;
> >> +  cfg->flags = pdata->parallel_flags;
> > 
> > The clock and sync signals polarity don't seem configurable, shouldn't
> > they just be hardcoded as currently done ?
> 
> That's a very good question, I added the flags because according to
> Documentation/devicetree/bindings/media/video-interfaces.txt, the way
> to define that the output format will be BT.656 is to avoid defining
> {hsync,vsync,field-even}-active properties.
> 
> IOW, if parallel sync is used, then these properties have to be defined
> and it felt strange to not use in the driver what is defined in the DT.

In that case we should restrict the values of the properties to what the 
hardware actually supports. I would hardcode the flags here, and check them 
when parsing the endpoint to make sure they're valid.

If you find a register I have missed in the documentation with which 
polarities could be configured then please also feel free to prove me wrong 
:-)

> >> +  return 0;
> >> +  }
> >> +
> >> +  /* Default values if no platform data was provided */
> >>cfg->type = V4L2_MBUS_BT656;
> >>cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
> >>   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;

[snip]

> >> @@ -1228,11 +1253,42 @@ static inline int tvp5150_init(struct i2c_client
> >> *c) return 0;
> >> 
> >>  }
> >> 
> >> +static struct tvp5150_platform_data *tvp5150_get_pdata(struct device
> >> *dev)
> >> +{
> >> +  struct tvp5150_platform_data *pdata = dev_get_platdata(dev);
> >> +  struct v4l2_of_endpoint bus_cfg;
> >> +  struct device_node *ep;
> >> +
> >> +  if (pdata)
> >> +  return pdata;
> > 
> > Nobody uses platform data today, I wonder whether we shouldn't postpone
> > adding support for it until we have a use case. Embedded systems (at
> > least the ARM- based ones) should use DT.
> 
> Yes, I just added it for completeness since in other subsystems I've been
> yelled in the past that not all the world is DT and that I needed a pdata :)
> 
> But I'll gladly remove it since it means less code which is always good.
> 
> >> +  if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
> >> +  pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> >> +  if (!pdata)
> >> +  return NULL;
> >> +
> >> +  ep = of_graph_get_next_endpoint(dev->of_node, NULL);
> >> +  if (!ep)
> >> +  return NULL;
> >> +
> >> +  v4l2_of_parse_endpoint(ep, _cfg);
> > 
> > Shouldn't you check the return value of the function ?
> 
> Right, the v4l2_of_parse_endpoint() kernel doc says "Return: 0." and most
> drivers are not checking the return value so I thought that it couldn't
> fail. But now looking at the implementation I see that's not true so I'll
> add a check in v2.
> 
> I'll also post patches to update v4l2_of_parse_endpoint() kernel-doc and
> the drivers that are not currently checking for this return value.

Thank you for that.

> >> +
> >> +  pdata->bus_type = bus_cfg.bus_type;
> >> +  pdata->parallel_flags = bus_cfg.bus.parallel.flags;
> > 
> > The V4L2_MBUS_DATA_ACTIVE_HIGH flags set returned by
> > tvp5150_g_mbus_config() when pdata is NULL is never set by
> > v4l2_of_parse_endpoint(), should you add it unconditionally ?
> 
> But v4l2_of_parse_endpoint() calls v4l2_of_parse_parallel_bus() which does
> it or did I read the code incorrectly?

No, you're right, I had overlooked the V4L2_MBUS_DATA_ACTIVE_HIGH flag when 
reading v4l2_of_parse_parallel_bus(), probably a typo when searching. Please 
ignore that comment.

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send 

Re: [PATCH v2 8/8] i2c-mux: relax locking of the top i2c adapter during i2c controlled muxing

2016-01-06 Thread Rob Herring
On Tue, Jan 05, 2016 at 04:57:18PM +0100, Peter Rosin wrote:
> From: Peter Rosin 
> 
> With a i2c topology like the following
> 
>GPIO ---|  -- BAT1
> |  v /
>I2C  -+--+ MUX
>  |   \
>EEPROM -- BAT2

Yuck. One would think you would just use an I2C controlled mux in this 
case...
 
> there is a locking problem with the GPIO controller since it is a client
> on the same i2c bus that it muxes. Transfers to the mux clients (e.g. BAT1)
> will lock the whole i2c bus prior to attempting to switch the mux to the
> correct i2c segment. In the above case, the GPIO device is an I/O expander
> with an i2c interface, and since the GPIO subsystem knows nothing (and
> rightfully so) about the lockless needs of the i2c mux code, this results
> in a deadlock when the GPIO driver issues i2c transfers to modify the
> mux.
> 
> So, observing that while it is needed to have the i2c bus locked during the
> actual MUX update in order to avoid random garbage on the slave side, it
> is not strictly a must to have it locked over the whole sequence of a full
> select-transfer-deselect mux client operation. The mux itself needs to be
> locked, so transfers to clients behind the mux are serialized, and the mux
> needs to be stable during all i2c traffic (otherwise individual mux slave
> segments might see garbage, or worse).
> 
> Add devive tree properties (bool named i2c-controlled) to i2c-mux-gpio and
> i2c-mux-pinctrl that asserts that the the gpio/pinctrl is controlled via
> the same i2c bus that it muxes.

Can't you determine this condition by checking the mux parent and gpio 
parent are the same i2c controller?

Alternatively, can't you just always do the locking like i2c-controlled 
is set when a mux is involved? What is the harm in doing that if the 
GPIO is controlled somewhere else?

I would prefer to see a solution not requiring DT updates to fix and 
this change seems like it is working around kernel issues.

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: [PATCH 10/10] [media] tvp5150: Configure data interface via pdata or DT

2016-01-06 Thread Javier Martinez Canillas
Hello Laurent,

On 01/06/2016 10:48 AM, Laurent Pinchart wrote:

[snip]

 @@ -940,6 +948,16 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd,
 struct v4l2_cropcap *a)
  static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
 struct v4l2_mbus_config *cfg)
  {
 +  struct tvp5150_platform_data *pdata = to_tvp5150(sd)->pdata;
 +
 +  if (pdata) {
 +  cfg->type = pdata->bus_type;
 +  cfg->flags = pdata->parallel_flags;
>>>
>>> The clock and sync signals polarity don't seem configurable, shouldn't
>>> they just be hardcoded as currently done ?
>>
>> That's a very good question, I added the flags because according to
>> Documentation/devicetree/bindings/media/video-interfaces.txt, the way
>> to define that the output format will be BT.656 is to avoid defining
>> {hsync,vsync,field-even}-active properties.
>>
>> IOW, if parallel sync is used, then these properties have to be defined
>> and it felt strange to not use in the driver what is defined in the DT.
> 
> In that case we should restrict the values of the properties to what the 
> hardware actually supports. I would hardcode the flags here, and check them 
> when parsing the endpoint to make sure they're valid.
>

That's a good idea, I'll also mention the supported values in the binding doc.
 
> If you find a register I have missed in the documentation with which 
> polarities could be configured then please also feel free to prove me wrong 
> :-)
>

I didn't find either when reading the datasheet to prepare this patch-set
so I think you are correct on that.

[snip]

 +
 +  pdata->bus_type = bus_cfg.bus_type;
 +  pdata->parallel_flags = bus_cfg.bus.parallel.flags;
>>>
>>> The V4L2_MBUS_DATA_ACTIVE_HIGH flags set returned by
>>> tvp5150_g_mbus_config() when pdata is NULL is never set by
>>> v4l2_of_parse_endpoint(), should you add it unconditionally ?
>>
>> But v4l2_of_parse_endpoint() calls v4l2_of_parse_parallel_bus() which does
>> it or did I read the code incorrectly?
> 
> No, you're right, I had overlooked the V4L2_MBUS_DATA_ACTIVE_HIGH flag when 
> reading v4l2_of_parse_parallel_bus(), probably a typo when searching. Please 
> ignore that comment.
> 

Ok, thanks for the clarification.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
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][davinci] ccdc_update_raw_params() frees the wrong thing

2016-01-06 Thread Al Viro
On Tue, Jan 05, 2016 at 05:37:06PM +, Lad, Prabhakar wrote:
> On Sun, Dec 13, 2015 at 12:32 AM, Al Viro  wrote:
> > Passing a physical address to free_pages() is a bad idea.
> > config_params->fault_pxl.fpc_table_addr is set to virt_to_phys()
> > of __get_free_pages() return value; what we should pass to free_pages()
> > is its phys_to_virt().  ccdc_close() does that properly, but
> > ccdc_update_raw_params() doesn't.
> >
> > Signed-off-by: Al Viro 
> >
> Acked-by: Lad, Prabhakar 
> 
> Regards,
> --Prabhakar Lad

Which tree should it go through?  I can certainly put that into
vfs.git#work.misc, but it looks like a better fit for linux-media tree, or
the davinci-specific one...
--
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] dvb-usb-dvbsky: add new product id for TT CT2-4650 CI

2016-01-06 Thread Torbjörn Jansson
Add a new product id to dvb-usb-dvbsky for new version of TechnoTrend CT2-4650 
CI

Signed-off-by: Torbjörn Jansson 
---
 drivers/media/dvb-core/dvb-usb-ids.h  | 1 +
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 1c1c298..a3761e9 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -247,6 +247,7 @@
 #define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
 #define USB_PID_TECHNOTREND_CONNECT_S2_4600 0x3011
 #define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI0x3012
+#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2  0x3015
 #define USB_PID_TECHNOTREND_TVSTICK_CT2_4400   0x3014
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY   0x005a
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 1dd9625..b4620b7 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -847,6 +847,10 @@ static const struct usb_device_id dvbsky_id_table[] = {
USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI,
_t680c_props, "TechnoTrend TT-connect CT2-4650 CI",
RC_MAP_TT_1500) },
+   { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
+   USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2,
+   _t680c_props, "TechnoTrend TT-connect CT2-4650 CI v1.1",
+   RC_MAP_TT_1500) },
{ DVB_USB_DEVICE(USB_VID_TERRATEC,
USB_PID_TERRATEC_H7_3,
_t680c_props, "Terratec H7 Rev.4",
-- 
2.4.3

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


Re: [PATCH][davinci] ccdc_update_raw_params() frees the wrong thing

2016-01-06 Thread Lad, Prabhakar
On Wed, Jan 6, 2016 at 4:34 PM, Al Viro  wrote:
> On Tue, Jan 05, 2016 at 05:37:06PM +, Lad, Prabhakar wrote:
>> On Sun, Dec 13, 2015 at 12:32 AM, Al Viro  wrote:
>> > Passing a physical address to free_pages() is a bad idea.
>> > config_params->fault_pxl.fpc_table_addr is set to virt_to_phys()
>> > of __get_free_pages() return value; what we should pass to free_pages()
>> > is its phys_to_virt().  ccdc_close() does that properly, but
>> > ccdc_update_raw_params() doesn't.
>> >
>> > Signed-off-by: Al Viro 
>> >
>> Acked-by: Lad, Prabhakar 
>>
>> Regards,
>> --Prabhakar Lad
>
> Which tree should it go through?  I can certainly put that into
> vfs.git#work.misc, but it looks like a better fit for linux-media tree, or
> the davinci-specific one...

It needs to go linux-media tree I'll issue a pull to mauro soon.

Cheers,
--Prabhakar Lad
--
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 v2 0/8] i2c mux cleanup and locking update

2016-01-06 Thread Antti Palosaari

On 01/05/2016 05:57 PM, Peter Rosin wrote:

From: Peter Rosin 

Hi!

I have a pair of boards with this i2c topology:

GPIO ---|  -- BAT1
 |  v /
I2C  -+--B---+ MUX
  |   \
EEPROM -- BAT2

(B denotes the boundary between the boards)


Handling of I2C muxes that close channel automatically, after the first 
I2C stop (P) is seen?


For example channel is selected to BAT1 => there is EEPROM write => mux 
closes channel BAT1 => access to BAT1 will fail. Is it possible to lock 
whole adapter, but allow only traffic to i2c mux client?


regards
Antti



The problem with this is that the GPIO controller sits on the same i2c bus
that it MUXes. For pca954x devices this is worked around by using unlocked
transfers when updating the MUX. I have no such luck as the GPIO is a general
purpose IO expander and the MUX is just a random bidirectional MUX, unaware
of the fact that it is muxing an i2c bus, and extending unlocked transfers
into the GPIO subsystem is too ugly to even think about. But the general hw
approach is sane in my opinion, with the number of connections between the
two boards minimized. To put is plainly, I need support for it.

So, I observe that while it is needed to have the i2c bus locked during the
actual MUX update in order to avoid random garbage on the slave side, it
is not strictly a must to have it locked over the whole sequence of a full
select-transfer-deselect operation. The MUX itself needs to be locked, so
transfers to clients behind the mux are serialized, and the MUX needs to be
stable during all i2c traffic (otherwise individual mux slave segments
might see garbage).

This series accomplishes this by adding a dt property to i2c-mux-gpio and
i2c-mux-pinctrl that can be used to state that the mux is updated by means
of the muxed master bus, and that the select-transfer-deselect operations
should be locked individually. When this holds, the i2c bus *is* locked
during muxing, since the muxing happens as part of i2c transfers. This
is true even if the MUX is updated with several transfers to the GPIO (at
least as long as *all* MUX changes are using the i2s master bus). A lock
is added to the mux so that transfers through the mux are serialized.

Concerns:
- The locking is perhaps too complex?
- I worry about the priority inheritance aspect of the adapter lock. When
   the transfers behind the mux are divided into select-transfer-deselect all
   locked individually, low priority transfers get more chances to interfere
   with high priority transfers.
- When doing an i2c_transfer() in_atomic() context of with irqs_disabled(),
   there is a higher possibility that the mux is not returned to its idle
   state after a failed (-EAGAIN) transfer due to trylock.

To summarize the series, there's some i2c-mux infrastructure cleanup work
first (I think that part stands by itself as desireable regardless), the
locking changes are in the last three patches of the series, with the real
meat in 8/8.

PS. needs a bunch of testing, I do not have access to all the involved hw

Changes since v1:
- Allocate mux core and (optional) priv in a combined allocation.
- Killed dev_err messages triggered by memory allocation failure.
- Fix the device specific i2c muxes that I had overlooked.
- Rebased on top of v4.4-rc8 (was based on v4.4-rc6 previously).

Cheers,
Peter

Peter Rosin (8):
   i2c-mux: add common core data for every mux instance
   i2c-mux: move select and deselect ops to i2c_mux_core
   i2c-mux: move the slave side adapter management to i2c_mux_core
   i2c-mux: remove the mux dev pointer from the mux per channel data
   i2c-mux: pinctrl: get rid of the driver private struct device pointer
   i2c: allow adapter drivers to override the adapter locking
   i2c: muxes always lock the parent adapter
   i2c-mux: relax locking of the top i2c adapter during i2c controlled
 muxing

  .../devicetree/bindings/i2c/i2c-mux-gpio.txt   |   2 +
  .../devicetree/bindings/i2c/i2c-mux-pinctrl.txt|   4 +
  drivers/i2c/i2c-core.c |  59 ++---
  drivers/i2c/i2c-mux.c  | 272 +
  drivers/i2c/muxes/i2c-arb-gpio-challenge.c |  46 ++--
  drivers/i2c/muxes/i2c-mux-gpio.c   |  58 ++---
  drivers/i2c/muxes/i2c-mux-pca9541.c|  58 +++--
  drivers/i2c/muxes/i2c-mux-pca954x.c|  66 ++---
  drivers/i2c/muxes/i2c-mux-pinctrl.c|  89 +++
  drivers/i2c/muxes/i2c-mux-reg.c|  63 ++---
  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c |  33 +--
  drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |   2 +-
  drivers/media/dvb-frontends/m88ds3103.c|  23 +-
  drivers/media/dvb-frontends/m88ds3103_priv.h   |   2 +-
  drivers/media/dvb-frontends/rtl2830.c  |  24 +-
  

Re: [PATCH] si2168: use i2c controlled mux interface

2016-01-06 Thread Antti Palosaari

Moikka!

On 01/06/2016 09:14 AM, Peter Rosin wrote:

Hi Antti,

On 2016-01-06 06:42, Antti Palosaari wrote:

Recent i2c mux locking update offers support for i2c controlled i2c
muxes. Use it and get the rid of homemade hackish i2c adapter
locking code.


That looks good on a first glance, and I'm sure it felt good to get rid
of the locking workaround :-)


And I forgot mutext to protect si2168_cmd_execute()...


However, is this safe? From looking at the short datasheet of the si2168,
it seems that the mux is used to open up the channel to the tuner? But
what happens is there are two parallel accesses, one to the tuner and one
to the si2168 chip? With your change, it could happen that the access to
the si2168 happens while the gate to the tuner is open. Can that break
anything?

I.e.
 thread one  thread two
 --  --
open gate
 access si2168
 access tuner
 close gate

If that is safe, then I don't understand why the gate isn't left open
at all times? The short datasheet is too short to answer my questions...


It is often called I2C Gate or repeater, and yes it is there to block 
noise traveling to tuner. I think that noise could be unnecessary I2C 
traffic as well some digital noise travelling via I2C wires. Tuners are 
usually build using pure digital logic + analog circuits (RF mixers, RF 
filters, RF amplifiers). Leaving gate open usually does not harm and 
there is even some designs it is connected directly to main bus (but 
almost all demodulators still has that kind of gate to connect tuner).


All in all, I don't see it very big issue if only few unwanted I2C 
messages are sent to bus tuner is connected.



Also, my series needs some Tested-by (and Reviewed-by for that matter),
and I assume that you have tested it? Is it ok to add something like
that from you? I understand that you may only be able to test your
corner of the series, but that would still be very helpful. Thanks!


Yes it worked, but I haven't examined it care enough yet.

However, I think I see one problem: i2c muxes that deselects channel 
automatically, usually after the first i2c stop (P) condition is seen.


regards
Antti



Cheers,
Peter


Cc: Peter Rosin 
Cc: Peter Rosin 
Signed-off-by: Antti Palosaari 
---
  drivers/media/dvb-frontends/si2168.c | 61 
  1 file changed, 6 insertions(+), 55 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index ae217b5..d2a5608 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -18,48 +18,15 @@

  static const struct dvb_frontend_ops si2168_ops;

-/* Own I2C adapter locking is needed because of I2C gate logic. */
-static int si2168_i2c_master_send_unlocked(const struct i2c_client *client,
-  const char *buf, int count)
-{
-   int ret;
-   struct i2c_msg msg = {
-   .addr = client->addr,
-   .flags = 0,
-   .len = count,
-   .buf = (char *)buf,
-   };
-
-   ret = __i2c_transfer(client->adapter, , 1);
-   return (ret == 1) ? count : ret;
-}
-
-static int si2168_i2c_master_recv_unlocked(const struct i2c_client *client,
-  char *buf, int count)
-{
-   int ret;
-   struct i2c_msg msg = {
-   .addr = client->addr,
-   .flags = I2C_M_RD,
-   .len = count,
-   .buf = buf,
-   };
-
-   ret = __i2c_transfer(client->adapter, , 1);
-   return (ret == 1) ? count : ret;
-}
-
  /* execute firmware command */
-static int si2168_cmd_execute_unlocked(struct i2c_client *client,
-  struct si2168_cmd *cmd)
+static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd 
*cmd)
  {
int ret;
unsigned long timeout;

if (cmd->wlen) {
/* write cmd and args for firmware */
-   ret = si2168_i2c_master_send_unlocked(client, cmd->args,
- cmd->wlen);
+   ret = i2c_master_send(client, cmd->args, cmd->wlen);
if (ret < 0) {
goto err;
} else if (ret != cmd->wlen) {
@@ -73,8 +40,7 @@ static int si2168_cmd_execute_unlocked(struct i2c_client 
*client,
#define TIMEOUT 70
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
while (!time_after(jiffies, timeout)) {
-   ret = si2168_i2c_master_recv_unlocked(client, cmd->args,
- cmd->rlen);
+   ret = i2c_master_recv(client, cmd->args, cmd->rlen);
if (ret < 0) {
 

[Patch v6 0/3] media: ti-vpe: Add CAL v4l2 camera capture driver

2016-01-06 Thread Benoit Parrot
The Camera Adaptation Layer (CAL) is a block which consists of a dual
port CSI2/MIPI camera capture engine.
This camera engine is currently found on DRA72xx family of devices.

Port #0 can handle CSI2 camera connected to up to 4 data lanes.
Port #1 can handle CSI2 camera connected to up to 2 data lanes.

The driver implements the required API/ioctls to be V4L2 compliant.
Driver supports the following:
- V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api
- Asynchronous sensor sub device registration
- DT support

Currently each port is designed to connect to a single sub-device.
In other words port aggregation is not currently supported.

Changes since v5:
- Added ti-vpe entry into the MAINTAINERS file.
- Per review comment corrected potential infinite loop.
- Fix checkpatch alignment and use safer strlcpy.
- Remove trace like debug statement.
- Modified register and bit field macro to use existing
  bitops support, cleaning up the header file and make
  the code a little easier to follow.

Changes since v4:
- Corrected dt bindings per review comment.
- Applied related dt bindings changes to driver code.
- Folded in coccinelle generated patches.
- Corrected checkpatch.pl --strict warnings.

Changes since v3:
- Nothing really I messed up the previous format-patch with the
  wrong commit-id. Sorry about the repeat.

Changes since v2:
- Rework Kconfig options and added COMPILE_TEST
- Merged in provided vb2 buffer rework
- Rebase on tip of lmm master and fixe vb2 split related changes

Changes since v1:
- Remove unnecessary format description
- Reworked how transient frame format is maintained
  in order to make it easier to use the fill helper functions
- Added a per port list of active frame format
- Reworked an added missing vb2 cleanup code
- Fix a module load/unload kernel oops
- Switch to use proper int64 get function for pixel rate control

=

Here is a sample output of the v4l2-compliance tool:

# ./v4l2-compliance -f -s -v -d /dev/video0 
Driver Info:
Driver name   : cal
Card type : cal
Bus info : platform:cal-000

Capabilities  : 0x8521
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x0521
Video Capture
Read/Write
Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

Control ioctls:
info: checking v4l2_queryctrl of control 'User Controls' 
(0x00980001)
info: checking v4l2_queryctrl of control 'Horizontal Flip' 
(0x00980914)
info: checking v4l2_queryctrl of control 'Vertical Flip' 
(0x00980915)
info: checking v4l2_queryctrl of control 'Image Processing 
Controls' (0x009f0001)
info: checking v4l2_queryctrl of control 'Pixel Rate' 
(0x009f0902)
info: checking v4l2_queryctrl of control 'Horizontal Flip' 
(0x00980914)
info: checking v4l2_queryctrl of control 'Vertical Flip' 
(0x00980915)
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
info: checking control 'User Controls' (0x00980001)
info: checking control 'Horizontal Flip' (0x00980914)
info: checking control 'Vertical Flip' (0x00980915)
info: checking control 'Image Processing Controls' (0x009f0001)
info: checking control 'Pixel Rate' (0x009f0902)
test VIDIOC_G/S_CTRL: OK
info: checking extended control 'User Controls' 

[Patch v6 1/3] media: ti-vpe: Document CAL driver

2016-01-06 Thread Benoit Parrot
Device Tree bindings for the Camera Adaptation Layer (CAL) driver

Signed-off-by: Benoit Parrot 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/media/ti-cal.txt | 72 ++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/ti-cal.txt

diff --git a/Documentation/devicetree/bindings/media/ti-cal.txt 
b/Documentation/devicetree/bindings/media/ti-cal.txt
new file mode 100644
index ..ae9b52f37576
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/ti-cal.txt
@@ -0,0 +1,72 @@
+Texas Instruments DRA72x CAMERA ADAPTATION LAYER (CAL)
+--
+
+The Camera Adaptation Layer (CAL) is a key component for image capture
+applications. The capture module provides the system interface and the
+processing capability to connect CSI2 image-sensor modules to the
+DRA72x device.
+
+Required properties:
+- compatible: must be "ti,dra72-cal"
+- reg: CAL Top level, Receiver Core #0, Receiver Core #1 and Camera RX
+   control address space
+- reg-names: cal_top, cal_rx_core0, cal_rx_core1, and camerrx_control
+registers
+- interrupts: should contain IRQ line for the CAL;
+
+CAL supports 2 camera port nodes on MIPI bus. Each CSI2 camera port nodes
+should contain a 'port' child node with child 'endpoint' node. Please
+refer to the bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+   cal: cal@4845b000 {
+   compatible = "ti,dra72-cal";
+   ti,hwmods = "cal";
+   reg = <0x4845B000 0x400>,
+ <0x4845B800 0x40>,
+ <0x4845B900 0x40>,
+ <0x4A002e94 0x4>;
+   reg-names = "cal_top",
+   "cal_rx_core0",
+   "cal_rx_core1",
+   "camerrx_control";
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   csi2_0: port@0 {
+   reg = <0>;
+   endpoint {
+   slave-mode;
+   remote-endpoint = <_1>;
+   };
+   };
+   csi2_1: port@1 {
+   reg = <1>;
+   };
+   };
+   };
+
+   i2c5: i2c@4807c000 {
+   ar0330@10 {
+   compatible = "ti,ar0330";
+   reg = <0x10>;
+
+   port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ar0330_1: endpoint {
+   reg = <0>;
+   clock-lanes = <1>;
+   data-lanes = <0 2 3 4>;
+   remote-endpoint = <_0>;
+   };
+   };
+   };
+   };
-- 
1.8.5.1

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


[Patch v6 3/3] media: ti-vpe: Add CAL v4l2 camera capture driver

2016-01-06 Thread Benoit Parrot
The Camera Adaptation Layer (CAL) is a block which consists of a dual
port CSI2/MIPI camera capture engine.
Port #0 can handle CSI2 camera connected to up to 4 data lanes.
Port #1 can handle CSI2 camera connected to up to 2 data lanes.
The driver implements the required API/ioctls to be V4L2 compliant.
Driver supports the following:
- V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api
- Asynchronous sensor sub device registration
- DT support

Signed-off-by: Benoit Parrot 
Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/Kconfig   |   12 +
 drivers/media/platform/Makefile  |2 +
 drivers/media/platform/ti-vpe/Makefile   |4 +
 drivers/media/platform/ti-vpe/cal.c  | 1970 ++
 drivers/media/platform/ti-vpe/cal_regs.h |  479 
 5 files changed, 2467 insertions(+)
 create mode 100644 drivers/media/platform/ti-vpe/cal.c
 create mode 100644 drivers/media/platform/ti-vpe/cal_regs.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 0c53805dff0e..db052f5a627a 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -120,6 +120,18 @@ source "drivers/media/platform/s5p-tv/Kconfig"
 source "drivers/media/platform/am437x/Kconfig"
 source "drivers/media/platform/xilinx/Kconfig"
 
+config VIDEO_TI_CAL
+   tristate "TI CAL (Camera Adaptation Layer) driver"
+   depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+   depends on SOC_DRA7XX || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   default n
+   ---help---
+ Support for the TI CAL (Camera Adaptation Layer) block
+ found on DRA72X SoC.
+ In TI Technical Reference Manual this module is referred as
+ Camera Interface Subsystem (CAMSS).
+
 endif # V4L_PLATFORM_DRIVERS
 
 menuconfig V4L_MEM2MEM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index efa0295af87b..028a7233096b 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -18,6 +18,8 @@ obj-$(CONFIG_VIDEO_VIM2M) += vim2m.o
 
 obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/
 
+obj-$(CONFIG_VIDEO_TI_CAL) += ti-vpe/
+
 obj-$(CONFIG_VIDEO_MX2_EMMAPRP)+= mx2_emmaprp.o
 obj-$(CONFIG_VIDEO_CODA)   += coda/
 
diff --git a/drivers/media/platform/ti-vpe/Makefile 
b/drivers/media/platform/ti-vpe/Makefile
index be680f839e77..e236059a60ad 100644
--- a/drivers/media/platform/ti-vpe/Makefile
+++ b/drivers/media/platform/ti-vpe/Makefile
@@ -3,3 +3,7 @@ obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
 ti-vpe-y := vpe.o sc.o csc.o vpdma.o
 
 ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
+
+obj-$(CONFIG_VIDEO_TI_CAL) += ti-cal.o
+
+ti-cal-y := cal.o
diff --git a/drivers/media/platform/ti-vpe/cal.c 
b/drivers/media/platform/ti-vpe/cal.c
new file mode 100644
index ..69ec79ba49ee
--- /dev/null
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -0,0 +1,1970 @@
+/*
+ * TI CAL camera interface driver
+ *
+ * Copyright (c) 2015 Texas Instruments Inc.
+ * Benoit Parrot, 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "cal_regs.h"
+
+#define CAL_MODULE_NAME "cal"
+
+#define MAX_WIDTH 1920
+#define MAX_HEIGHT 1200
+
+#define CAL_VERSION "0.1.0"
+
+MODULE_DESCRIPTION("TI CAL driver");
+MODULE_AUTHOR("Benoit Parrot, ");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(CAL_VERSION);
+
+static unsigned video_nr = -1;
+module_param(video_nr, uint, 0644);
+MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
+
+static unsigned debug;
+module_param(debug, uint, 0644);
+MODULE_PARM_DESC(debug, "activates debug info");
+
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+   tpf_default = {.numerator = 1001,   .denominator = 3};
+
+#define cal_dbg(level, caldev, fmt, arg...)\
+   v4l2_dbg(level, debug, >v4l2_dev, fmt, ##arg)
+#define cal_info(caldev, fmt, arg...)  \
+   v4l2_info(>v4l2_dev, fmt, ##arg)
+#define cal_err(caldev, fmt, arg...)   \
+   v4l2_err(>v4l2_dev, fmt, ##arg)
+
+#define ctx_dbg(level, ctx, fmt, arg...)   \
+   v4l2_dbg(level, debug, >v4l2_dev, fmt, ##arg)
+#define ctx_info(ctx, fmt, arg...) \
+   v4l2_info(>v4l2_dev, fmt, ##arg)
+#define ctx_err(ctx, fmt, arg...)  \
+   v4l2_err(>v4l2_dev, fmt, ##arg)
+
+#define CAL_NUM_INPUT 1
+#define CAL_NUM_CONTEXT 2
+
+#define 

[Patch v6 2/3] MAINTAINERS: Add ti-vpe maintainer entry

2016-01-06 Thread Benoit Parrot
Signed-off-by: Benoit Parrot 
---
 MAINTAINERS | 8 
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4635e1d14612..ebbdb410c0f0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10631,6 +10631,14 @@ L: linux-o...@vger.kernel.org
 S: Maintained
 F: drivers/thermal/ti-soc-thermal/
 
+TI VPE/CAL DRIVERS
+M: Benoit Parrot 
+L: linux-media@vger.kernel.org
+W: http://linuxtv.org/
+Q: http://patchwork.linuxtv.org/project/linux-media/list/
+S: Maintained
+F: drivers/media/platform/ti-vpe/
+
 TI CDCE706 CLOCK DRIVER
 M: Max Filippov 
 S: Maintained
-- 
1.8.5.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


cron job: media_tree daily build: OK

2016-01-06 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:   Thu Jan  7 04:00:17 CET 2016
git branch: test
git hash:   768acf46e1320d6c41ed1b7c4952bab41c1cde79
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-51-ga53cea2
smatch version: v0.5.0-3228-g5cf65ab
host hardware:  x86_64
host os:4.3.0-164

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

Detailed results are available here:

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

Full logs are available here:

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


Getting my Ion Video 2 PC to work

2016-01-06 Thread Alexandre-Xavier Labonté-Lamoureux
Hi everyone,

I have tried to get my Ion Video 2 PC to work on my Linux computer, but 
I was unsuccessful. I'm using Debian with the kernel version 
3.16.0-4-amd64. When I connect the device, I can see that it detects a 
new audio input as "ION Audio USB 2861 Device: Audio (hw:1,0)", but I 
cannot capture audio from it. In Audacity it's completely silent and in 
VLC, if I open hw:1,0 without selecting any video source (because none 
is detected), then VLC displays tones of error messages saying...

core input error: open of 'v4l2://' failed
v4l2: demux error: cannot open device '/dev/radio0': no such file or 
directory
v4l2: access error: cannot open device '/dev/video0': no such file or 
directory

To try to fix the problem, I used:
sudo modprobe em28xx
sudo modprobe em28xx card=29
sudo modprobe em28xx card=9

It didn't work. I don't know the good card to use. I know my Ion Video 2 
PC uses an Empia chip, the 2861. It is shown in the Windows device 
manager and this number comes back when I run the dmesg command.

I have a lot of other recording devices, one of which is a StarTech 
device using this same Empia chip (but it's said to be an 2860 in the 
instruction manual, though the drivers and the device manager on Windows 
recognizes it as a 2861 chip). Once I know how to get each of them to be 
recognized by Linux, I'll write a kernel patch.

Thanks in advance for any help.
--Alexandre-Xavier



Here's some info that you may need to help me with the Ion Video 2 PC:

dmesg
=
[  120.844089] usb 1-3: new high-speed USB device number 2 using ehci-pci
[  120.983509] usb 1-3: New USB device found, idVendor=eb1a, idProduct=5051
[  120.983526] usb 1-3: New USB device strings: Mfr=3, Product=1, 
SerialNumber=2
[  120.983534] usb 1-3: Product: ION Audio USB 2861 Device
[  120.983541] usb 1-3: Manufacturer: ION Audio
[  120.983547] usb 1-3: SerialNumber: 0
[  121.182288] usbcore: registered new interface driver snd-usb-audio

lsusb
===
Bus 001 Device 002: ID eb1a:5051 eMPIA Technology, Inc.


lsusb -v
=
Bus 001 Device 002: ID eb1a:5051 eMPIA Technology, Inc.
Couldn't open device, some information will be missing
Device Descriptor:
   bLength18
   bDescriptorType 1
   bcdUSB   2.00
   bDeviceClass0 (Defined at Interface level)
   bDeviceSubClass 0
   bDeviceProtocol 0
   bMaxPacketSize064
   idVendor   0xeb1a eMPIA Technology, Inc.
   idProduct  0x5051
   bcdDevice1.00
   iManufacturer   3
   iProduct1
   iSerial 2
   bNumConfigurations  1
   Configuration Descriptor:
 bLength 9
 bDescriptorType 2
 wTotalLength  555
 bNumInterfaces  3
 bConfigurationValue 1
 iConfiguration  0
 bmAttributes 0x80
   (Bus Powered)
 MaxPower  500mA
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber0
   bAlternateSetting   0
   bNumEndpoints   3
   bInterfaceClass   255 Vendor Specific Class
   bInterfaceSubClass  0
   bInterfaceProtocol255
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x81  EP 1 IN
 bmAttributes3
   Transfer TypeInterrupt
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0001  1x 1 bytes
 bInterval  11
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x82  EP 2 IN
 bmAttributes1
   Transfer TypeIsochronous
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x  1x 0 bytes
 bInterval   1
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x84  EP 4 IN
 bmAttributes1
   Transfer TypeIsochronous
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x  1x 0 bytes
 bInterval   1
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber0
   bAlternateSetting   1
   bNumEndpoints   3
   bInterfaceClass   255 Vendor Specific Class
   bInterfaceSubClass  0
   bInterfaceProtocol255
   iInterface  0
   Endpoint Descriptor:
 bLength 7

em28xx driver for StarTech SVID2USB2

2016-01-06 Thread Schubert, Matthew R. (LARC-D319)[TEAMS2]
Hello,

We are attempting to use a StarTech Video Capture cable (Part# SVID2USB2) with 
our CentOS 6.7 machine with no success. The em28xx driver seems to load but 
cannot properly ID the capture cable. Below are the outputs from "dmesg" and 
"lsusb -v" run after plugging in the device. Any advice is appreciated.

Thanks,

Matt R. Schubert
Programmer | Analyst
Analytical Mechanics Associates
NASA Langley Computational Vision Lab

==
dmesg

em28xx: New device USB 2821 Device @ 480 Mbps (eb1a:2821, interface 0, class 0)
em28xx #0: chip ID is em2820 (or em2710)
IR NEC protocol handler initialized
IR RC5(x) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
lirc_dev: IR Remote Control driver registered, major 245
IR LIRC bridge handler initialized
em28xx #0: i2c eeprom 00: 1a eb 67 95 1a eb 21 28 90 00 11 03 6a 22 00 00
em28xx #0: i2c eeprom 10: 00 00 04 57 06 21 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 20: 02 00 01 01 f0 10 00 00 00 00 00 00 5b 00 00 00
em28xx #0: i2c eeprom 30: 00 00 20 40 20 80 02 20 01 01 03 01 00 00 00 00
em28xx #0: i2c eeprom 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 60: 00 00 00 00 00 00 00 00 00 00 22 03 55 00 53 00
em28xx #0: i2c eeprom 70: 42 00 20 00 32 00 38 00 32 00 31 00 20 00 44 00
em28xx #0: i2c eeprom 80: 65 00 76 00 69 00 63 00 65 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: EEPROM ID= 0x9567eb1a, EEPROM hash = 0x26da7a8a
em28xx #0: EEPROM info:
em28xx #0:  AC97 audio (5 sample rates)
em28xx #0:  500mA max power
em28xx #0:  Table at 0x04, strings=0x226a, 0x, 0x
em28xx #0: found i2c device @ 0x4a [saa7113h]
em28xx #0: found i2c device @ 0xa0 [eeprom]
em28xx #0: Your board has no unique USB ID and thus need a hint to be detected.
em28xx #0: You may try to use card= insmod option to workaround that.
em28xx #0: Please send an email with this log to:
em28xx #0:  V4L Mailing List 
em28xx #0: Board eeprom hash is 0x26da7a8a
em28xx #0: Board i2c devicelist hash is 0x6ba50080
em28xx #0: Here is a list of valid choices for the card= insmod option:
em28xx #0: card=0 -> Unknown EM2800 video grabber
em28xx #0: card=1 -> Unknown EM2750/28xx video grabber
em28xx #0: card=2 -> Terratec Cinergy 250 USB
em28xx #0: card=3 -> Pinnacle PCTV USB 2
em28xx #0: card=4 -> Hauppauge WinTV USB 2
em28xx #0: card=5 -> MSI VOX USB 2.0
em28xx #0: card=6 -> Terratec Cinergy 200 USB
em28xx #0: card=7 -> Leadtek Winfast USB II
em28xx #0: card=8 -> Kworld USB2800
em28xx #0: card=9 -> Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video 
to DVD maker / Kworld DVD Maker 2
em28xx #0: card=10 -> Hauppauge WinTV HVR 900
em28xx #0: card=11 -> Terratec Hybrid XS
em28xx #0: card=12 -> Kworld PVR TV 2800 RF
em28xx #0: card=13 -> Terratec Prodigy XS
em28xx #0: card=14 -> SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0
em28xx #0: card=15 -> V-Gear PocketTV
em28xx #0: card=16 -> Hauppauge WinTV HVR 950
em28xx #0: card=17 -> Pinnacle PCTV HD Pro Stick
em28xx #0: card=18 -> Hauppauge WinTV HVR 900 (R2)
em28xx #0: card=19 -> EM2860/SAA711X Reference Design
em28xx #0: card=20 -> AMD ATI TV Wonder HD 600
em28xx #0: card=21 -> eMPIA Technology, Inc. GrabBeeX+ Video Encoder
em28xx #0: card=22 -> EM2710/EM2750/EM2751 webcam grabber
em28xx #0: card=23 -> Huaqi DLCW-130
em28xx #0: card=24 -> D-Link DUB-T210 TV Tuner
em28xx #0: card=25 -> Gadmei UTV310
em28xx #0: card=26 -> Hercules Smart TV USB 2.0
em28xx #0: card=27 -> Pinnacle PCTV USB 2 (Philips FM1216ME)
em28xx #0: card=28 -> Leadtek Winfast USB II Deluxe
em28xx #0: card=29 -> EM2860/TVP5150 Reference Design
em28xx #0: card=30 -> Videology 20K14XUSB USB2.0
em28xx #0: card=31 -> Usbgear VD204v9
em28xx #0: card=32 -> Supercomp USB 2.0 TV
em28xx #0: card=33 -> Elgato Video Capture
em28xx #0: card=34 -> Terratec Cinergy A Hybrid XS
em28xx #0: card=35 -> Typhoon DVD Maker
em28xx #0: card=36 -> NetGMBH Cam
em28xx #0: card=37 -> Gadmei UTV330
em28xx #0: card=38 -> Yakumo MovieMixer
em28xx #0: card=39 -> KWorld PVRTV 300U
em28xx #0: card=40 -> Plextor ConvertX PX-TV100U
em28xx #0: card=41 -> 

Re: em28xx driver for StarTech SVID2USB2

2016-01-06 Thread Devin Heitmueller
On Wed, Jan 6, 2016 at 1:27 PM, Schubert, Matthew R.
(LARC-D319)[TEAMS2]  wrote:
> Hello,
>
> We are attempting to use a StarTech Video Capture cable (Part# SVID2USB2) 
> with our CentOS 6.7 machine with no success. The em28xx driver seems to load 
> but cannot properly ID the capture cable. Below are the outputs from "dmesg" 
> and "lsusb -v" run after plugging in the device. Any advice is appreciated.

Try adding "card=9" to the modprobe option.  If that doesn't work than
try "card=29".  Most of those really cheap devices either have an
saa7113 or tvp5150 video decoder, and one of those two board profiles
should work.

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


[PATCH 00/31] Sharing media resources across ALSA and au0828 drivers

2016-01-06 Thread Shuah Khan
This patch series updates ALSA driver, and au0828 core
driver to use Managed Media controller API and Media
Controller API to share tuner.

Media Controller Next Generation API has been enhanced
to add two new interfaces to register and unregister
entity_notify hooks to allow drivers to take appropriate
actions when as new entities get added to the shared media
device.

Mauro and Takashi: I am hoping you can both coordinate
and decide on ALSA patches once the reviews are done
and the patches look good.

Design Highlights:
1. ALSA to check for resources and hold in snd_usb_hw_params(),
   and release from snd_usb_hw_free(). This change fixed the
   lockdep warnings seen when resources were held in
   TRIGGER_START and released from TRIGGER_STOP which could
   run in IRQ context. I acknowledge Clemens Ladisch for
   suggesting the correct places to hold/free resources to
   avoid IRQ path complications.
2. The Bridge driver (au0828) owns and drives the graph creation
   as well as enabling and disabling tuner. It also keeps state
   information to avoid graph walks in enable_source and
   disable_source handler. I acknowledge Hans Verkuil for his
   suggestions and ideas for this change.

Tested exclusion between digital, analog, and audio to ensure
when tuner has an active link to DVB FE, analog, and audio will
detect and honor the tuner busy conditions and vice versa.

Please find the graphs generated using mc_nextgen_test tool at
various points during testing at:
https://drive.google.com/folderview?id=0B0NIL0BQg-AlRndaaXViSXdPeTA=sharing

This patch series is a rebase and update to the latest Media
Controller Next Gen API of the Media Controller Next Generation
API port.

Rebase highlights:
1. Changes to videobuf2 framework required additional
   v4l2 helper function to enable the tuner from
   vb2_core_streamon(). Patch 9 has this work.
2. Media device initialization and registration steps
   are now split in the latest Media Controller Next Gen
   API. This required changes to au0828 and ALSA to coordinate
   initialization and registration of the Managed Media Device
   they share. Patch 19 shows au0828 changes. ALSA changes
   for this are folded into the main ALSA patch 26.
3. Media device unregistration does more cleanup now. As a
   result, au0828 and ALSA need to coordinate so media device
   is done only once. These changes are in patches: 29, 30,
   and 31.
4. In addition, media device resources cleanup gets done
   before snd_card_disconnect(). This work is in patch 30.

Media Controller Next Generation API port from Media Controller API:
The patch series below was a port of the Patch v3 - Media Controller API
to Next Gen API and Mixer patch update to address comments and bug fixes:
https://www.mail-archive.com/linux-media@vger.kernel.org/msg93086.html
https://www.mail-archive.com/linux-media@vger.kernel.org/msg93417.html

Patch v3 - Media Controller API:
https://www.mail-archive.com/linux-media@vger.kernel.org/msg92572.html

Mauro Carvalho Chehab (1):
  uapi/media.h: Declare interface types for ALSA

Shuah Khan (30):
  media: Add ALSA Media Controller function entities
  media: Media Controller register/unregister entity_notify API
  media: Media Controller enable/disable source handler API
  media: Media Controller fix to not let stream_count go negative
  media: Media Controller export non locking __media_entity_setup_link()
  media: Media Controller non-locking
__media_entity_pipeline_start/stop()
  media: v4l-core add v4l_enable/disable_media_tuner() helper functions
  media: v4l2-core add v4l_vb2q_enable_media_tuner() helper
  media: Move au8522_media_pads enum to au8522.h from au8522_priv.h
  media: au8522 change to create MC pad for ALSA Audio Out
  media: au0828 Use au8522_media_pads enum for pad defines
  media: au0828 fix au0828_create_media_graph() entity checks
  media: Change v4l-core to check for tuner availability
  media: dvb-frontend invoke enable/disable_source handlers
  media: au0828 video remove au0828_enable_analog_tuner()
  media: au0828 video change to use v4l_enable_media_tuner()
  media: au0828 change to use Managed Media Controller API
  media: au0828 handle media_init and media_register window
  media: au0828 change to register/unregister entity_notify hook
  media: au0828 create tuner to decoder link in deactivated state
  media: dvb-core create tuner to demod pad link in disabled state
  media: au0828 implement enable_source and disable_source handlers
  media: au0828 fix null pointer reference in
au0828_create_media_graph()
  media: au0828 fix to not call media_device_unregister_entity_notify()
  sound/usb: Update ALSA driver to use Managed Media Controller API
  sound/usb: Create media mixer function and control interface entities
  media: au0828 create link between ALSA Mixer and decoder
  media: track media device unregister in progress
  sound/usb: Check media device unregister progress state
  media: au0828 change to check media device unregister 

[PATCH 01/31] uapi/media.h: Declare interface types for ALSA

2016-01-06 Thread Shuah Khan
From: Mauro Carvalho Chehab 

Declare the interface types to be used on alsa for the new
G_TOPOLOGY ioctl.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-entity.c | 12 
 include/uapi/linux/media.h   |  8 
 2 files changed, 20 insertions(+)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index eb38bc3..6e02d19 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -65,6 +65,18 @@ static inline const char *intf_type(struct media_interface 
*intf)
return "v4l2-subdev";
case MEDIA_INTF_T_V4L_SWRADIO:
return "swradio";
+   case MEDIA_INTF_T_ALSA_PCM_CAPTURE:
+   return "pcm-capture";
+   case MEDIA_INTF_T_ALSA_PCM_PLAYBACK:
+   return "pcm-playback";
+   case MEDIA_INTF_T_ALSA_CONTROL:
+   return "alsa-control";
+   case MEDIA_INTF_T_ALSA_COMPRESS:
+   return "compress";
+   case MEDIA_INTF_T_ALSA_RAWMIDI:
+   return "rawmidi";
+   case MEDIA_INTF_T_ALSA_HWDEP:
+   return "hwdep";
default:
return "unknown-intf";
}
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index cacfceb..75cbe92 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -252,6 +252,7 @@ struct media_links_enum {
 
 #define MEDIA_INTF_T_DVB_BASE  0x0100
 #define MEDIA_INTF_T_V4L_BASE  0x0200
+#define MEDIA_INTF_T_ALSA_BASE 0x0300
 
 /* Interface types */
 
@@ -267,6 +268,13 @@ struct media_links_enum {
 #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
 #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
 
+#define MEDIA_INTF_T_ALSA_PCM_CAPTURE   (MEDIA_INTF_T_ALSA_BASE)
+#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK  (MEDIA_INTF_T_ALSA_BASE + 1)
+#define MEDIA_INTF_T_ALSA_CONTROL   (MEDIA_INTF_T_ALSA_BASE + 2)
+#define MEDIA_INTF_T_ALSA_COMPRESS  (MEDIA_INTF_T_ALSA_BASE + 3)
+#define MEDIA_INTF_T_ALSA_RAWMIDI   (MEDIA_INTF_T_ALSA_BASE + 4)
+#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
+
 /*
  * MC next gen API definitions
  *
-- 
2.5.0

--
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 03/31] media: Media Controller register/unregister entity_notify API

2016-01-06 Thread Shuah Khan
Add new interfaces to register and unregister entity_notify
hook to media device to allow drivers to take appropriate
actions when as new entities get added to the shared media
device.When a new entity is registered, all registered
entity_notify hooks are invoked to allow drivers or modules
that registered hook to take appropriate action. For example,
ALSA driver registers an entity_notify hook to parse the list
of registered entities to determine if decoder has been linked
to ALSA entity. au0828 bridge driver registers an entity_notify
hook to create media graph for the device.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-device.c | 61 
 include/media/media-device.h | 25 ++
 2 files changed, 86 insertions(+)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index b786b10..20c85a9 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -536,6 +536,7 @@ static void media_device_release(struct media_devnode *mdev)
 int __must_check media_device_register_entity(struct media_device *mdev,
  struct media_entity *entity)
 {
+   struct media_entity_notify *notify, *next;
unsigned int i;
int ret;
 
@@ -575,6 +576,11 @@ int __must_check media_device_register_entity(struct 
media_device *mdev,
media_gobj_create(mdev, MEDIA_GRAPH_PAD,
   >pads[i].graph_obj);
 
+   /* invoke entity_notify callbacks */
+   list_for_each_entry_safe(notify, next, >entity_notify, list) {
+   (notify)->notify(entity, notify->notify_data);
+   }
+
spin_unlock(>lock);
 
return 0;
@@ -608,6 +614,8 @@ static void __media_device_unregister_entity(struct 
media_entity *entity)
/* Remove the entity */
media_gobj_destroy(>graph_obj);
 
+   /* invoke entity_notify callbacks to handle entity removal?? */
+
entity->graph_obj.mdev = NULL;
 }
 
@@ -633,6 +641,7 @@ int __must_check media_device_init(struct media_device 
*mdev)
INIT_LIST_HEAD(>interfaces);
INIT_LIST_HEAD(>pads);
INIT_LIST_HEAD(>links);
+   INIT_LIST_HEAD(>entity_notify);
spin_lock_init(>lock);
mutex_init(>graph_mutex);
ida_init(>entity_internal_idx);
@@ -680,11 +689,59 @@ int __must_check __media_device_register(struct 
media_device *mdev,
 }
 EXPORT_SYMBOL_GPL(__media_device_register);
 
+/**
+ * media_device_register_entity_notify - Register a media entity notify
+ * callback with a media device. When a new entity is registered, all
+ * the registered media_entity_notify callbacks are invoked.
+ * @mdev:  The media device
+ * @nptr:  The media_entity_notify
+ */
+int __must_check media_device_register_entity_notify(struct media_device *mdev,
+   struct media_entity_notify *nptr)
+{
+   spin_lock(>lock);
+   list_add_tail(>list, >entity_notify);
+   spin_unlock(>lock);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(media_device_register_entity_notify);
+
+/**
+ * __media_device_unregister_entity_notify - Unregister a media entity notify
+ * callback with a media device. When a new entity is registered, all
+ * the registered media_entity_notify callbacks are invoked.
+ * @mdev:  The media device
+ * @nptr:  The media_entity_notify
+ * Non-locking version. Should be called with mdev->lock held.
+ */
+static void __media_device_unregister_entity_notify(struct media_device *mdev,
+   struct media_entity_notify *nptr)
+{
+   list_del(>list);
+}
+
+/**
+ * media_device_unregister_entity_notify - Unregister a media entity notify
+ * callback with a media device. When a new entity is registered, all
+ * the registered media_entity_notify callbacks are invoked.
+ * @mdev:  The media device
+ * @nptr:  The media_entity_notify
+ */
+void media_device_unregister_entity_notify(struct media_device *mdev,
+   struct media_entity_notify *nptr)
+{
+   spin_lock(>lock);
+   __media_device_unregister_entity_notify(mdev, nptr);
+   spin_unlock(>lock);
+}
+EXPORT_SYMBOL_GPL(media_device_unregister_entity_notify);
+
 void media_device_unregister(struct media_device *mdev)
 {
struct media_entity *entity;
struct media_entity *next;
struct media_interface *intf, *tmp_intf;
+   struct media_entity_notify *notify, *nextp;
 
if (mdev == NULL)
return;
@@ -701,6 +758,10 @@ void media_device_unregister(struct media_device *mdev)
list_for_each_entry_safe(entity, next, >entities, graph_obj.list)
__media_device_unregister_entity(entity);
 
+   /* Remove all entity_notify callbacks from the media device */
+   list_for_each_entry_safe(notify, nextp, >entity_notify, list)
+   

[PATCH 07/31] media: Media Controller non-locking __media_entity_pipeline_start/stop()

2016-01-06 Thread Shuah Khan
Add non-locking __media_entity_pipeline_start/stop() interfaces
to be called from code paths that hold the graph_mutex. For this
change, the media_entity_pipeline_start() routine is renamed to
__media_entity_pipeline_start() minus the graph_mutex lock and
unlock. media_entity_pipeline_start() now calls the non-locking
__media_entity_pipeline_start() holding the graph_lock. The stop
interface, media_entity_pipeline_stop() routine is renamed to
__media_entity_pipeline_stop() minus the graph_mutex lock and
unlock. media_entity_pipeline_stop() now calls the non-locking
__media_entity_pipeline_stop() holding the graph_lock.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-entity.c | 34 --
 include/media/media-entity.h | 12 
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index b8769aa..270ade2 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -361,8 +361,8 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
  * Pipeline management
  */
 
-__must_check int media_entity_pipeline_start(struct media_entity *entity,
-struct media_pipeline *pipe)
+__must_check int __media_entity_pipeline_start(struct media_entity *entity,
+  struct media_pipeline *pipe)
 {
struct media_device *mdev = entity->graph_obj.mdev;
struct media_entity_graph *graph = >graph;
@@ -370,8 +370,6 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
struct media_link *link;
int ret;
 
-   mutex_lock(>graph_mutex);
-
if (!pipe->streaming_count++) {
ret = media_entity_graph_walk_init(>graph, mdev);
if (ret)
@@ -452,8 +450,6 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
}
}
 
-   mutex_unlock(>graph_mutex);
-
return 0;
 
 error:
@@ -483,19 +479,28 @@ error_graph_walk_start:
if (!--pipe->streaming_count)
media_entity_graph_walk_cleanup(graph);
 
-   mutex_unlock(>graph_mutex);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(__media_entity_pipeline_start);
 
+__must_check int media_entity_pipeline_start(struct media_entity *entity,
+struct media_pipeline *pipe)
+{
+   struct media_device *mdev = entity->graph_obj.mdev;
+   int ret;
+
+   mutex_lock(>graph_mutex);
+   ret = __media_entity_pipeline_start(entity, pipe);
+   mutex_unlock(>graph_mutex);
return ret;
 }
 EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
 
-void media_entity_pipeline_stop(struct media_entity *entity)
+void __media_entity_pipeline_stop(struct media_entity *entity)
 {
-   struct media_device *mdev = entity->graph_obj.mdev;
struct media_entity_graph *graph = >pipe->graph;
struct media_pipeline *pipe = entity->pipe;
 
-   mutex_lock(>graph_mutex);
 
WARN_ON(!pipe->streaming_count);
media_entity_graph_walk_start(graph, entity);
@@ -512,6 +517,15 @@ void media_entity_pipeline_stop(struct media_entity 
*entity)
if (!--pipe->streaming_count)
media_entity_graph_walk_cleanup(graph);
 
+}
+EXPORT_SYMBOL_GPL(__media_entity_pipeline_stop);
+
+void media_entity_pipeline_stop(struct media_entity *entity)
+{
+   struct media_device *mdev = entity->graph_obj.mdev;
+
+   mutex_lock(>graph_mutex);
+   __media_entity_pipeline_stop(entity);
mutex_unlock(>graph_mutex);
 }
 EXPORT_SYMBOL_GPL(media_entity_pipeline_stop);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 79dd81f..3f4f577 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -781,6 +781,12 @@ media_entity_graph_walk_next(struct media_entity_graph 
*graph);
  */
 __must_check int media_entity_pipeline_start(struct media_entity *entity,
 struct media_pipeline *pipe);
+/**
+ * non-locking __media_entity_pipeline_start() can be called from
+ * code paths that hold the graph_mutex
+ */
+__must_check int __media_entity_pipeline_start(struct media_entity *entity,
+  struct media_pipeline *pipe);
 
 /**
  * media_entity_pipeline_stop - Mark a pipeline as not streaming
@@ -797,6 +803,12 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
 void media_entity_pipeline_stop(struct media_entity *entity);
 
 /**
+ * non-locking __media_entity_pipeline_stop() can be called from
+ * code paths that hold the graph_mutex
+ */
+void __media_entity_pipeline_stop(struct media_entity *entity);
+
+/**
  * media_devnode_create() - creates and initializes a device node interface
  *
  * @mdev:  pointer to struct _device
-- 
2.5.0

--
To unsubscribe from this list: send the line 

[PATCH 08/31] media: v4l-core add v4l_enable/disable_media_tuner() helper functions

2016-01-06 Thread Shuah Khan
Add a new interfaces to be used by v4l-core to invoke enable
source and disable_source handlers in the media_device. The
enable_source helper function invokes the enable_source handler
to find tuner entity connected to the decoder and check is it
is available or busy. If tuner is available, link is activated
and pipeline is started. The disable_source helper function
invokes the disable_source handler to deactivate and stop the
pipeline.

Signed-off-by: Shuah Khan 
---
 drivers/media/v4l2-core/v4l2-dev.c | 27 +++
 include/media/v4l2-dev.h   |  4 
 2 files changed, 31 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index d8e5994..f06da6e 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -233,6 +233,33 @@ struct video_device *video_devdata(struct file *file)
 }
 EXPORT_SYMBOL(video_devdata);
 
+int v4l_enable_media_tuner(struct video_device *vdev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_device *mdev = vdev->entity.graph_obj.mdev;
+   int ret;
+
+   if (!mdev || !mdev->enable_source)
+   return 0;
+   ret = mdev->enable_source(>entity, >pipe);
+   if (ret)
+   return -EBUSY;
+   return 0;
+#endif /* CONFIG_MEDIA_CONTROLLER */
+   return 0;
+}
+EXPORT_SYMBOL_GPL(v4l_enable_media_tuner);
+
+void v4l_disable_media_tuner(struct video_device *vdev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_device *mdev = vdev->entity.graph_obj.mdev;
+
+   if (mdev && mdev->disable_source)
+   mdev->disable_source(>entity);
+#endif /* CONFIG_MEDIA_CONTROLLER */
+}
+EXPORT_SYMBOL_GPL(v4l_disable_media_tuner);
 
 /* Priority handling */
 
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index eeabf20..68999a3 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -87,6 +87,7 @@ struct video_device
 #if defined(CONFIG_MEDIA_CONTROLLER)
struct media_entity entity;
struct media_intf_devnode *intf_devnode;
+   struct media_pipeline pipe;
 #endif
/* device ops */
const struct v4l2_file_operations *fops;
@@ -176,6 +177,9 @@ void video_unregister_device(struct video_device *vdev);
latter can also be used for video_device->release(). */
 struct video_device * __must_check video_device_alloc(void);
 
+int v4l_enable_media_tuner(struct video_device *vdev);
+void v4l_disable_media_tuner(struct video_device *vdev);
+
 /* this release function frees the vdev pointer */
 void video_device_release(struct video_device *vdev);
 
-- 
2.5.0

--
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 02/31] media: Add ALSA Media Controller function entities

2016-01-06 Thread Shuah Khan
Add ALSA Media Controller capture, playback, and mixer
function entity defines.

Signed-off-by: Shuah Khan 
---
 include/uapi/linux/media.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 75cbe92..53a96ae 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -89,6 +89,13 @@ struct media_device_info {
 #define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 33)
 
 /*
+ * ALSA entities MEDIA_ENT_F_AUDIO_IO is for Capture and Playback
+*/
+#define MEDIA_ENT_F_AUDIO_CAPTURE  (MEDIA_ENT_F_BASE + 200)
+#define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 201)
+#define MEDIA_ENT_F_AUDIO_MIXER(MEDIA_ENT_F_BASE + 202)
+
+/*
  * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
  * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
  * with the legacy v1 API.The number range is out of range by purpose:
@@ -130,7 +137,7 @@ struct media_device_info {
 #define MEDIA_ENT_T_DEVNODEMEDIA_ENT_F_OLD_BASE
 #define MEDIA_ENT_T_DEVNODE_V4LMEDIA_ENT_F_IO_V4L
 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
-#define MEDIA_ENT_T_DEVNODE_ALSA   (MEDIA_ENT_T_DEVNODE + 3)
+#define MEDIA_ENT_T_DEVNODE_ALSA   MEDIA_ENT_F_AUDIO_IO
 #define MEDIA_ENT_T_DEVNODE_DVB(MEDIA_ENT_T_DEVNODE + 4)
 
 #define MEDIA_ENT_T_UNKNOWNMEDIA_ENT_F_UNKNOWN
-- 
2.5.0

--
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 05/31] media: Media Controller fix to not let stream_count go negative

2016-01-06 Thread Shuah Khan
Add a range check to not let the stream_count become negative.
Wthout this check, calls to stop pipeline when there is no active
pipeline will result in stream_count < 0 condition and lock and
preventing link state (activate/deactivate) changes. This will
happen from error leg in start pipeline interface.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-entity.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 6e02d19..78486a9 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -464,9 +464,12 @@ error:
media_entity_graph_walk_start(graph, entity_err);
 
while ((entity_err = media_entity_graph_walk_next(graph))) {
-   entity_err->stream_count--;
-   if (entity_err->stream_count == 0)
-   entity_err->pipe = NULL;
+   /* don't let the stream_count go negative */
+   if (entity->stream_count > 0) {
+   entity_err->stream_count--;
+   if (entity_err->stream_count == 0)
+   entity_err->pipe = NULL;
+   }
 
/*
 * We haven't increased stream_count further than this
@@ -498,9 +501,12 @@ void media_entity_pipeline_stop(struct media_entity 
*entity)
media_entity_graph_walk_start(graph, entity);
 
while ((entity = media_entity_graph_walk_next(graph))) {
-   entity->stream_count--;
-   if (entity->stream_count == 0)
-   entity->pipe = NULL;
+   /* don't let the stream_count go negative */
+   if (entity->stream_count > 0) {
+   entity->stream_count--;
+   if (entity->stream_count == 0)
+   entity->pipe = NULL;
+   }
}
 
if (!--pipe->streaming_count)
-- 
2.5.0

--
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 20/31] media: au0828 change to register/unregister entity_notify hook

2016-01-06 Thread Shuah Khan
au0828 registers entity_notify hook to create media graph for
the device. This handler runs whenvere a new entity gets added
to the media device. It creates necessary links from video, vbi,
and ALSA entities to decoder and links tuner and decoder entities.
As this handler runs as entities get added, it has to maintain
state on the links it already created. New fields are added to
au0828_dev to keep this state information. entity_notify gets
unregistered before media_device unregister.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 104 +++--
 drivers/media/usb/au0828/au0828.h  |   6 ++
 2 files changed, 78 insertions(+), 32 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 6ef177c..a381660 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -137,6 +137,8 @@ static void au0828_unregister_media_device(struct 
au0828_dev *dev)
 #ifdef CONFIG_MEDIA_CONTROLLER
if (dev->media_dev &&
media_devnode_is_registered(>media_dev->devnode)) {
+   media_device_unregister_entity_notify(dev->media_dev,
+ >entity_notify);
media_device_unregister(dev->media_dev);
media_device_cleanup(dev->media_dev);
dev->media_dev = NULL;
@@ -263,11 +265,16 @@ static int au0828_create_media_graph(struct au0828_dev 
*dev)
struct media_device *mdev = dev->media_dev;
struct media_entity *entity;
struct media_entity *tuner = NULL, *decoder = NULL;
+   struct media_entity *audio_capture = NULL;
int i, ret;
 
if (!mdev)
return 0;
 
+   if (dev->tuner_linked && dev->vdev_linked && dev->vbi_linked &&
+   dev->audio_capture_linked)
+   return 0;
+
media_device_for_each_entity(entity, mdev) {
switch (entity->function) {
case MEDIA_ENT_F_TUNER:
@@ -276,6 +283,9 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
case MEDIA_ENT_F_ATV_DECODER:
decoder = entity;
break;
+   case MEDIA_ENT_F_AUDIO_CAPTURE:
+   audio_capture = entity;
+   break;
}
}
 
@@ -285,60 +295,77 @@ static int au0828_create_media_graph(struct au0828_dev 
*dev)
if (!decoder)
return -EINVAL;
 
-   if (tuner) {
+   if (tuner  && !dev->tuner_linked) {
+   dev->tuner = tuner;
ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
decoder, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
+   dev->tuner_linked = 1;
}
-   if (dev->vdev.entity.graph_obj.mdev) {
+   if (dev->vdev.entity.graph_obj.mdev && !dev->vdev_linked) {
ret = media_create_pad_link(decoder, AU8522_PAD_VID_OUT,
>vdev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
+   dev->vdev_linked = 1;
}
-   if (dev->vbi_dev.entity.graph_obj.mdev) {
+   if (dev->vbi_dev.entity.graph_obj.mdev && !dev->vbi_linked) {
ret = media_create_pad_link(decoder, AU8522_PAD_VBI_OUT,
>vbi_dev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
-   }
-
-   for (i = 0; i < AU0828_MAX_INPUT; i++) {
-   struct media_entity *ent = >input_ent[i];
+   dev->vbi_linked = 1;
 
-   if (!ent->graph_obj.mdev)
-   continue;
+   /*
+* Input entities are registered before vbi entity,
+* create graph nodes for them after vbi is created
+   */
+   for (i = 0; i < AU0828_MAX_INPUT; i++) {
+   struct media_entity *ent = >input_ent[i];
 
-   if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
-   break;
+   if (!ent->graph_obj.mdev)
+   continue;
 
-   switch (AUVI_INPUT(i).type) {
-   case AU0828_VMUX_CABLE:
-   case AU0828_VMUX_TELEVISION:
-   case AU0828_VMUX_DVB:
-   if (!tuner)
+   if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
break;
 
-   ret = media_create_pad_link(ent, 0, tuner,
-   TUNER_PAD_RF_INPUT,
-   

[PATCH 13/31] media: au0828 fix au0828_create_media_graph() entity checks

2016-01-06 Thread Shuah Khan
au0828_create_media_graph() doesn't do any checks to determine,
if vbi_dev, vdev, and input entities have been registered prior
to creating pad links. Checking graph_obj.mdev field works as
the graph_obj.mdev field gets initialized in the entity register
interface. Fix it to check graph_obj.mdev field before creating
pad links.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index f46fb43..8ef7c71 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -291,20 +291,27 @@ static int au0828_create_media_graph(struct au0828_dev 
*dev)
if (ret)
return ret;
}
-   ret = media_create_pad_link(decoder, AU8522_PAD_VID_OUT,
-   >vdev.entity, 0,
-   MEDIA_LNK_FL_ENABLED);
-   if (ret)
-   return ret;
-   ret = media_create_pad_link(decoder, AU8522_PAD_VBI_OUT,
-   >vbi_dev.entity, 0,
-   MEDIA_LNK_FL_ENABLED);
-   if (ret)
-   return ret;
+   if (dev->vdev.entity.graph_obj.mdev) {
+   ret = media_create_pad_link(decoder, AU8522_PAD_VID_OUT,
+   >vdev.entity, 0,
+   MEDIA_LNK_FL_ENABLED);
+   if (ret)
+   return ret;
+   }
+   if (dev->vbi_dev.entity.graph_obj.mdev) {
+   ret = media_create_pad_link(decoder, AU8522_PAD_VBI_OUT,
+   >vbi_dev.entity, 0,
+   MEDIA_LNK_FL_ENABLED);
+   if (ret)
+   return ret;
+   }
 
for (i = 0; i < AU0828_MAX_INPUT; i++) {
struct media_entity *ent = >input_ent[i];
 
+   if (!ent->graph_obj.mdev)
+   continue;
+
if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
break;
 
-- 
2.5.0

--
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 16/31] media: au0828 video remove au0828_enable_analog_tuner()

2016-01-06 Thread Shuah Khan
au0828_enable_analog_tuner() is no longer needed with
v4l2-core and au0828-video invoking enable_source and
disable_source handlers. In addition, it is unnecessary
to check for tuner availability in queue_setup() as
v4l2-core handles the tuner availability checks.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-video.c | 61 -
 1 file changed, 61 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 3ea9d4f..32bcc56 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -638,64 +638,6 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, 
struct urb *urb)
return rc;
 }
 
-static int au0828_enable_analog_tuner(struct au0828_dev *dev)
-{
-#ifdef CONFIG_MEDIA_CONTROLLER
-   struct media_device *mdev = dev->media_dev;
-   struct media_entity *source;
-   struct media_link *link, *found_link = NULL;
-   int ret, active_links = 0;
-
-   if (!mdev || !dev->decoder)
-   return 0;
-
-   /*
-* This will find the tuner that is connected into the decoder.
-* Technically, this is not 100% correct, as the device may be
-* using an analog input instead of the tuner. However, as we can't
-* do DVB streaming while the DMA engine is being used for V4L2,
-* this should be enough for the actual needs.
-*/
-   list_for_each_entry(link, >decoder->links, list) {
-   if (link->sink->entity == dev->decoder) {
-   found_link = link;
-   if (link->flags & MEDIA_LNK_FL_ENABLED)
-   active_links++;
-   break;
-   }
-   }
-
-   if (active_links == 1 || !found_link)
-   return 0;
-
-   source = found_link->source->entity;
-   list_for_each_entry(link, >links, list) {
-   struct media_entity *sink;
-   int flags = 0;
-
-   sink = link->sink->entity;
-
-   if (sink == dev->decoder)
-   flags = MEDIA_LNK_FL_ENABLED;
-
-   ret = media_entity_setup_link(link, flags);
-   if (ret) {
-   pr_err(
-   "Couldn't change link %s->%s to %s. Error %d\n",
-   source->name, sink->name,
-   flags ? "enabled" : "disabled",
-   ret);
-   return ret;
-   } else
-   au0828_isocdbg(
-   "link %s->%s was %s\n",
-   source->name, sink->name,
-   flags ? "ENABLED" : "disabled");
-   }
-#endif
-   return 0;
-}
-
 static int queue_setup(struct vb2_queue *vq, const void *parg,
   unsigned int *nbuffers, unsigned int *nplanes,
   unsigned int sizes[], void *alloc_ctxs[])
@@ -711,9 +653,6 @@ static int queue_setup(struct vb2_queue *vq, const void 
*parg,
 
*nplanes = 1;
sizes[0] = size;
-
-   au0828_enable_analog_tuner(dev);
-
return 0;
 }
 
-- 
2.5.0

--
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 19/31] media: au0828 handle media_init and media_register window

2016-01-06 Thread Shuah Khan
Media device initialization and registration is split
and there is a window between media device init and
media device register during usb probe. au0828 bridge
driver has to coordinate managed media device init and
register with snd-usb-audio. Checking if the device is
registered during media device init could result in the
two drivers stepping on each other for media init. Change
the media device init in au0828 to check if media device
dev is set as this happens at the end of media device
init in au0828 and snd-usb-audio. Change register step
in au0828 to check if media device in registered.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 1f97fc0..6ef177c 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -229,7 +229,8 @@ static int au0828_media_device_init(struct au0828_dev *dev,
if (!mdev)
return -ENOMEM;
 
-   if (!media_devnode_is_registered(>devnode)) {
+   /* check if media device is already initialized */
+   if (!mdev->dev) {
mdev->dev = >dev;
 
if (udev->product)
@@ -342,6 +343,27 @@ static int au0828_create_media_graph(struct au0828_dev 
*dev)
return 0;
 }
 
+static int au0828_media_device_register(struct au0828_dev *dev,
+   struct usb_device *udev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   int ret;
+
+   if (dev->media_dev &&
+   !media_devnode_is_registered(>media_dev->devnode)) {
+
+   /* register media device */
+   ret = media_device_register(dev->media_dev);
+   if (ret) {
+   dev_err(>dev,
+   "Media Device Register Error: %d\n", ret);
+   return ret;
+   }
+   }
+#endif
+   return 0;
+}
+
 static int au0828_usb_probe(struct usb_interface *interface,
const struct usb_device_id *id)
 {
@@ -469,7 +491,7 @@ static int au0828_usb_probe(struct usb_interface *interface,
}
 
 #ifdef CONFIG_MEDIA_CONTROLLER
-   retval = media_device_register(dev->media_dev);
+   retval = au0828_media_device_register(dev, usbdev);
 #endif
 
 done:
-- 
2.5.0

--
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 24/31] media: au0828 fix null pointer reference in au0828_create_media_graph()

2016-01-06 Thread Shuah Khan
Add a new wrapper function to au0828_create_media_graph()
to be called as an entity_notify function to fix null
pointer dereference. A rebasing mistake resulted in
registering au0828_create_media_graph() without the
correct parameters which lead to the following
null pointer dereference:

[   69.006164] Call Trace:
[   69.006169]  [] dump_stack+0x44/0x64
[   69.006175]  [] print_trailer+0xf9/0x150
[   69.006180]  [] object_err+0x34/0x40
[   69.006185]  [] ? ___slab_alloc+0x4c4/0x4e0
[   69.006190]  [] kasan_report_error+0x212/0x520
[   69.006196]  [] ? ___slab_alloc+0x4c4/0x4e0
[   69.006201]  [] __asan_report_load1_noabort+0x43/0x50
[   69.006208]  [] ? au0828_create_media_graph+0x641/0x730 
[au0828]
[   69.006215]  [] au0828_create_media_graph+0x641/0x730 
[au0828]
[   69.006221]  [] media_device_register_entity+0x33d/0x4f0
[   69.006234]  [] media_stream_init+0x2ac/0x610 
[snd_usb_audio]
[   69.006247]  [] snd_usb_pcm_open+0xcd0/0x1280 
[snd_usb_audio]

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index f8d2db3..9497ad1 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -370,6 +370,20 @@ static int au0828_create_media_graph(struct au0828_dev 
*dev)
return 0;
 }
 
+void au0828_create_media_graph_notify(struct media_entity *new,
+ void *notify_data)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct au0828_dev *dev = (struct au0828_dev *) notify_data;
+   int ret;
+
+   ret = au0828_create_media_graph(dev);
+   if (ret)
+   pr_err("%s() media graph create failed for new entity %s\n",
+  __func__, new->name);
+#endif
+}
+
 static int au0828_enable_source(struct media_entity *entity,
struct media_pipeline *pipe)
 {
@@ -535,7 +549,7 @@ static int au0828_media_device_register(struct au0828_dev 
*dev,
}
/* register entity_notify callback */
dev->entity_notify.notify_data = (void *) dev;
-   dev->entity_notify.notify = (void *) au0828_create_media_graph;
+   dev->entity_notify.notify = au0828_create_media_graph_notify;
ret = media_device_register_entity_notify(dev->media_dev,
  >entity_notify);
if (ret) {
-- 
2.5.0

--
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 09/31] media: v4l2-core add v4l_vb2q_enable_media_tuner() helper

2016-01-06 Thread Shuah Khan
Add a new v4l_vb2q_enable_media_tuner() wrapper function
to be called from v4l2-core to enable the media tuner with
videobuf2 queue, when the calling frunction has the videobuf2
queue and doesn't have the struct video_device associated with
the queue handy as in the case of vb2_core_streamon(). This
function simply calls v4l_enable_media_tuner() passing in the
pointer to struct video_device.

Signed-off-by: Shuah Khan 
---
 drivers/media/v4l2-core/v4l2-dev.c | 21 +
 include/media/v4l2-dev.h   |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index f06da6e..9ef675a 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define VIDEO_NUM_DEVICES  256
 #define VIDEO_NAME  "video4linux"
@@ -261,6 +262,26 @@ void v4l_disable_media_tuner(struct video_device *vdev)
 }
 EXPORT_SYMBOL_GPL(v4l_disable_media_tuner);
 
+/**
+ * v4l_vb2q_enable_media_tuner - Wrapper for v4l_enable_media_tuner()
+ * @q: videobuf2 queue
+ *
+ * This function is intended to be called from v4l2-core
+ * to enable the media tuner with videobuf2 queue, when
+ * the calling frunction has the videobuf2 queue and doesn't
+ * have the struct video_device associated with the
+ * queue handy as in the case of vb2_core_streamon(). This
+ * function simply calls v4l_enable_media_tuner() passing
+ * in the pointer to struct video_device.
+ */
+int v4l_vb2q_enable_media_tuner(struct vb2_queue *q)
+{
+   struct v4l2_fh *fh = q->owner;
+
+   return v4l_enable_media_tuner(fh->vdev);
+}
+EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_tuner);
+
 /* Priority handling */
 
 static inline bool prio_is_valid(enum v4l2_priority prio)
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 68999a3..1948097 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -179,6 +179,7 @@ struct video_device * __must_check video_device_alloc(void);
 
 int v4l_enable_media_tuner(struct video_device *vdev);
 void v4l_disable_media_tuner(struct video_device *vdev);
+int v4l_vb2q_enable_media_tuner(struct vb2_queue *q);
 
 /* this release function frees the vdev pointer */
 void video_device_release(struct video_device *vdev);
-- 
2.5.0

--
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 12/31] media: au0828 Use au8522_media_pads enum for pad defines

2016-01-06 Thread Shuah Khan
Change au0828-core to use au8522_media_pads enum defines
instead of hard-coding the pad values when it creates
media graph linking decode pads to other entities.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 101d329..f46fb43 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -20,6 +20,7 @@
  */
 
 #include "au0828.h"
+#include "au8522.h"
 
 #include 
 #include 
@@ -290,11 +291,13 @@ static int au0828_create_media_graph(struct au0828_dev 
*dev)
if (ret)
return ret;
}
-   ret = media_create_pad_link(decoder, 1, >vdev.entity, 0,
+   ret = media_create_pad_link(decoder, AU8522_PAD_VID_OUT,
+   >vdev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
-   ret = media_create_pad_link(decoder, 2, >vbi_dev.entity, 0,
+   ret = media_create_pad_link(decoder, AU8522_PAD_VBI_OUT,
+   >vbi_dev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
-- 
2.5.0

--
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 17/31] media: au0828 video change to use v4l_enable_media_tuner()

2016-01-06 Thread Shuah Khan
au0828 is changed to use v4l_enable_media_tuner() to check for
tuner availability from vidioc_g_tuner(), and au0828_v4l2_close(),
before changing tuner settings. If tuner isn't free, return busy
condition from vidioc_g_tuner() and in au0828_v4l2_close() tuner
is left untouched without powering down to save energy.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-video.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 32bcc56..ed3ba05 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1010,8 +1010,12 @@ static int au0828_v4l2_close(struct file *filp)
goto end;
 
if (dev->users == 1) {
-   /* Save some power by putting tuner to sleep */
-   v4l2_device_call_all(>v4l2_dev, 0, core, s_power, 0);
+   /* Save some power by putting tuner to sleep, if it is free */
+   /* What happens when radio is using tuner?? */
+   ret = v4l_enable_media_tuner(vdev);
+   if (ret == 0)
+   v4l2_device_call_all(>v4l2_dev, 0, core,
+s_power, 0);
dev->std_set_in_tuner_core = 0;
 
/* When close the device, set the usb intf0 into alt0 to free
@@ -1412,10 +1416,16 @@ static int vidioc_s_audio(struct file *file, void 
*priv, const struct v4l2_audio
 static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
 {
struct au0828_dev *dev = video_drvdata(file);
+   struct video_device *vfd = video_devdata(file);
+   int ret;
 
if (t->index != 0)
return -EINVAL;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
+
dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
dev->std_set_in_tuner_core, dev->dev_state);
 
-- 
2.5.0

--
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 10/31] media: Move au8522_media_pads enum to au8522.h from au8522_priv.h

2016-01-06 Thread Shuah Khan
Move the au8522_media_pads enum to au8522.h from au8522_priv.h.
This will allow au0828-core to use these defines instead of
hard-coding the pad values when it creates media graph linking
decode pads to other entities.

Signed-off-by: Shuah Khan 
---
 drivers/media/dvb-frontends/au8522.h  | 7 +++
 drivers/media/dvb-frontends/au8522_priv.h | 8 
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/au8522.h 
b/drivers/media/dvb-frontends/au8522.h
index dde6158..3c72f40 100644
--- a/drivers/media/dvb-frontends/au8522.h
+++ b/drivers/media/dvb-frontends/au8522.h
@@ -90,4 +90,11 @@ enum au8522_audio_input {
AU8522_AUDIO_SIF,
 };
 
+enum au8522_media_pads {
+   AU8522_PAD_INPUT,
+   AU8522_PAD_VID_OUT,
+   AU8522_PAD_VBI_OUT,
+
+   AU8522_NUM_PADS
+};
 #endif /* __AU8522_H__ */
diff --git a/drivers/media/dvb-frontends/au8522_priv.h 
b/drivers/media/dvb-frontends/au8522_priv.h
index d6209d9..4c2a6ed 100644
--- a/drivers/media/dvb-frontends/au8522_priv.h
+++ b/drivers/media/dvb-frontends/au8522_priv.h
@@ -39,14 +39,6 @@
 #define AU8522_DIGITAL_MODE 1
 #define AU8522_SUSPEND_MODE 2
 
-enum au8522_media_pads {
-   AU8522_PAD_INPUT,
-   AU8522_PAD_VID_OUT,
-   AU8522_PAD_VBI_OUT,
-
-   AU8522_NUM_PADS
-};
-
 struct au8522_state {
struct i2c_client *c;
struct i2c_adapter *i2c;
-- 
2.5.0

--
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 21/31] media: au0828 create tuner to decoder link in deactivated state

2016-01-06 Thread Shuah Khan
Create tuner to demod pad link in disabled state to help
avoid disable step when tuner resource is requested by dvb.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index a381660..a15a61a 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -297,9 +297,9 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 
if (tuner  && !dev->tuner_linked) {
dev->tuner = tuner;
+   /* create tuner to decoder link in deactivated state */
ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
-   decoder, 0,
-   MEDIA_LNK_FL_ENABLED);
+   decoder, 0, 0);
if (ret)
return ret;
dev->tuner_linked = 1;
-- 
2.5.0

--
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 15/31] media: dvb-frontend invoke enable/disable_source handlers

2016-01-06 Thread Shuah Khan
Checking for tuner availability from frontend thread start
disrupts video stream. Change to check for tuner and start
pipeline from frontend open instead and stop pipeline from
frontend release. In addition, make a change to invoke
enable_source and disable_source handlers to check for
tuner availability. The enable_source handler finds tuner
entity connected to the decoder and check is it is available
or busy. If tuner is available, link is activated and pipeline
is started. The disable_source handler to deactivate and stop
the pipeline. dvb_enable_media_tuner() is removed as it is no
longer necessary with dvb invoking enable_source and
disable_source handlers. pipe_start_entity field is removed
and pipe field is moved to dvb_frontend from dvb_frontend_private.

Signed-off-by: Shuah Khan 
---
 drivers/media/dvb-core/dvb_frontend.c | 139 +-
 drivers/media/dvb-core/dvb_frontend.h |   3 +
 2 files changed, 24 insertions(+), 118 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index 4008064..c15f3d8 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -131,11 +131,6 @@ struct dvb_frontend_private {
int quality;
unsigned int check_wrapped;
enum dvbfe_search algo_status;
-
-#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
-   struct media_pipeline pipe;
-   struct media_entity *pipe_start_entity;
-#endif
 };
 
 static void dvb_frontend_wakeup(struct dvb_frontend *fe);
@@ -596,104 +591,12 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
wake_up_interruptible(>wait_queue);
 }
 
-/**
- * dvb_enable_media_tuner() - tries to enable the DVB tuner
- *
- * @fe:struct dvb_frontend pointer
- *
- * This function ensures that just one media tuner is enabled for a given
- * frontend. It has two different behaviors:
- * - For trivial devices with just one tuner:
- *   it just enables the existing tuner->fe link
- * - For devices with more than one tuner:
- *   It is up to the driver to implement the logic that will enable one tuner
- *   and disable the other ones. However, if more than one tuner is enabled for
- *   the same frontend, it will print an error message and return -EINVAL.
- *
- * At return, it will return the error code returned by 
media_entity_setup_link,
- * or 0 if everything is OK, if no tuner is linked to the frontend or if the
- * mdev is NULL.
- */
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
-static int dvb_enable_media_tuner(struct dvb_frontend *fe)
-{
-   struct dvb_frontend_private *fepriv = fe->frontend_priv;
-   struct dvb_adapter *adapter = fe->dvb;
-   struct media_device *mdev = adapter->mdev;
-   struct media_entity  *entity, *source;
-   struct media_link *link, *found_link = NULL;
-   int ret, n_links = 0, active_links = 0;
-
-   fepriv->pipe_start_entity = NULL;
-
-   if (!mdev)
-   return 0;
-
-   entity = fepriv->dvbdev->entity;
-   fepriv->pipe_start_entity = entity;
-
-   list_for_each_entry(link, >links, list) {
-   if (link->sink->entity == entity) {
-   found_link = link;
-   n_links++;
-   if (link->flags & MEDIA_LNK_FL_ENABLED)
-   active_links++;
-   }
-   }
-
-   if (!n_links || active_links == 1 || !found_link)
-   return 0;
-
-   /*
-* If a frontend has more than one tuner linked, it is up to the driver
-* to select with one will be the active one, as the frontend core can't
-* guess. If the driver doesn't do that, it is a bug.
-*/
-   if (n_links > 1 && active_links != 1) {
-   dev_err(fe->dvb->device,
-   "WARNING: there are %d active links among %d tuners. 
This is a driver's bug!\n",
-   active_links, n_links);
-   return -EINVAL;
-   }
-
-   source = found_link->source->entity;
-   fepriv->pipe_start_entity = source;
-   list_for_each_entry(link, >links, list) {
-   struct media_entity *sink;
-   int flags = 0;
-
-   sink = link->sink->entity;
-   if (sink == entity)
-   flags = MEDIA_LNK_FL_ENABLED;
-
-   ret = media_entity_setup_link(link, flags);
-   if (ret) {
-   dev_err(fe->dvb->device,
-   "Couldn't change link %s->%s to %s. Error %d\n",
-   source->name, sink->name,
-   flags ? "enabled" : "disabled",
-   ret);
-   return ret;
-   } else
-   dev_dbg(fe->dvb->device,
-   "link %s->%s was %s\n",
-   source->name, sink->name,
-

[PATCH 23/31] media: au0828 implement enable_source and disable_source handlers

2016-01-06 Thread Shuah Khan
Implements enable_source and disable_source handlers for other
drivers (v4l2-core, dvb-core, and ALSA) to use to check for
tuner connected to the decoder and activate the link if tuner
is free, and deactivate and free the tuner when it is no longer
needed.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 148 +
 drivers/media/usb/au0828/au0828.h  |   2 +
 2 files changed, 150 insertions(+)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index a15a61a..f8d2db3 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -370,6 +370,150 @@ static int au0828_create_media_graph(struct au0828_dev 
*dev)
return 0;
 }
 
+static int au0828_enable_source(struct media_entity *entity,
+   struct media_pipeline *pipe)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_entity  *source;
+   struct media_entity *sink;
+   struct media_link *link, *found_link = NULL;
+   int ret = 0;
+   struct media_device *mdev = entity->graph_obj.mdev;
+   struct au0828_dev *dev;
+
+   if (!mdev)
+   return -ENODEV;
+
+   /* for Audio and Video entities, source is the decoder */
+   mutex_lock(>graph_mutex);
+
+   dev = mdev->source_priv;
+   if (!dev->tuner || !dev->decoder) {
+   ret = -ENODEV;
+   goto end;
+   }
+
+   /*
+* For Audio and V4L2 entity, find the link to which decoder
+* is the sink. Look for an active link between decoder and
+* tuner, if one exists, nothing to do. If not, look for any
+* active links between tuner and any other entity. If one
+* exists, tuner is busy. If tuner is free, setup link and
+* start pipeline from source (tuner).
+* For DVB FE entity, the source for the link is the tuner.
+* Check if tuner is available and setup link and start
+* pipeline.
+   */
+   if (entity->function != MEDIA_ENT_F_DTV_DEMOD)
+   sink = dev->decoder;
+   else
+   sink = entity;
+
+   /* Is an active link between sink and tuner */
+   if (dev->active_link) {
+   if (dev->active_link->sink->entity == sink &&
+   dev->active_link->source->entity == dev->tuner) {
+   ret = 0;
+   goto end;
+   } else {
+   ret = -EBUSY;
+   goto end;
+   }
+   }
+
+   list_for_each_entry(link, >links, list) {
+   /* Check sink, and source */
+   if (link->sink->entity == sink &&
+   link->source->entity == dev->tuner) {
+   found_link = link;
+   break;
+   }
+   }
+
+   if (!found_link) {
+   ret = -ENODEV;
+   goto end;
+   }
+
+   /* activate link between source and sink and start pipeline */
+   source = found_link->source->entity;
+   ret = __media_entity_setup_link(found_link, MEDIA_LNK_FL_ENABLED);
+   if (ret) {
+   pr_err(
+   "Activate tuner link %s->%s. Error %d\n",
+   source->name, sink->name, ret);
+   goto end;
+   }
+
+   ret = __media_entity_pipeline_start(entity, pipe);
+   if (ret) {
+   pr_err("Start Pipeline: %s->%s Error %d\n",
+   source->name, entity->name, ret);
+   ret = __media_entity_setup_link(found_link, 0);
+   pr_err("Deactive link Error %d\n", ret);
+   goto end;
+   }
+   /*
+* save active link and active link owner to avoid audio
+* deactivating video owned link from disable_source and
+* vice versa
+   */
+   dev->active_link = found_link;
+   dev->active_link_owner = entity;
+end:
+   mutex_unlock(>graph_mutex);
+   pr_debug("au0828_enable_source() end %s %d %d\n",
+   entity->name, entity->function, ret);
+   return ret;
+#endif
+   return 0;
+}
+
+static void au0828_disable_source(struct media_entity *entity)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_entity *sink;
+   int ret = 0;
+   struct media_device *mdev = entity->graph_obj.mdev;
+   struct au0828_dev *dev;
+
+   if (!mdev)
+   return;
+
+   mutex_lock(>graph_mutex);
+   dev = mdev->source_priv;
+   if (!dev->tuner || !dev->decoder || !dev->active_link) {
+   ret = -ENODEV;
+   goto end;
+   }
+
+   if (entity->function != MEDIA_ENT_F_DTV_DEMOD)
+   sink = dev->decoder;
+   else
+   sink = entity;
+
+   /* link is active - stop pipeline from source (tuner) */
+   if (dev->active_link && dev->active_link->sink->entity == sink &&
+

[PATCH 22/31] media: dvb-core create tuner to demod pad link in disabled state

2016-01-06 Thread Shuah Khan
Create tuner to demod pad link in disabled state to help avoid
disable step when tuner resource is requested by video or audio.

Signed-off-by: Shuah Khan 
---
 drivers/media/dvb-core/dvbdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index b56e008..1d10fa6 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -593,8 +593,9 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
}
 
if (tuner && demod) {
+   /* create tuner to demod link deactivated */
ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
-   demod, 0, MEDIA_LNK_FL_ENABLED);
+   demod, 0, 0);
if (ret)
return ret;
}
-- 
2.5.0

--
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 06/31] media: Media Controller export non locking __media_entity_setup_link()

2016-01-06 Thread Shuah Khan
Export __media_entity_setup_link() to be used from code paths that hold
the graph_mutex.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-entity.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 78486a9..b8769aa 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -736,6 +736,7 @@ int __media_entity_setup_link(struct media_link *link, u32 
flags)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(__media_entity_setup_link);
 
 int media_entity_setup_link(struct media_link *link, u32 flags)
 {
-- 
2.5.0

--
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 18/31] media: au0828 change to use Managed Media Controller API

2016-01-06 Thread Shuah Khan
Change au0828 to use Managed Media Controller API to coordinate
creating/deleting media device on parent usb device it shares
with the snd-usb-audio driver. With this change, au0828 uses
media_device_get_devres() to allocate a new media device devres
or return an existing one, if it finds one.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 44 +-
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 8ef7c71..1f97fc0 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -135,10 +135,10 @@ static void au0828_unregister_media_device(struct 
au0828_dev *dev)
 {
 
 #ifdef CONFIG_MEDIA_CONTROLLER
-   if (dev->media_dev) {
+   if (dev->media_dev &&
+   media_devnode_is_registered(>media_dev->devnode)) {
media_device_unregister(dev->media_dev);
media_device_cleanup(dev->media_dev);
-   kfree(dev->media_dev);
dev->media_dev = NULL;
}
 #endif
@@ -225,29 +225,29 @@ static int au0828_media_device_init(struct au0828_dev 
*dev,
struct media_device *mdev;
int ret;
 
-   mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+   mdev = media_device_get_devres(>dev);
if (!mdev)
return -ENOMEM;
 
-   mdev->dev = >dev;
-
-   if (!dev->board.name)
-   strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model));
-   else
-   strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
-   if (udev->serial)
-   strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
-   strcpy(mdev->bus_info, udev->devpath);
-   mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-   mdev->driver_version = LINUX_VERSION_CODE;
-
-   ret = media_device_init(mdev);
-   if (ret) {
-   pr_err(
-   "Couldn't create a media device. Error: %d\n",
-   ret);
-   kfree(mdev);
-   return ret;
+   if (!media_devnode_is_registered(>devnode)) {
+   mdev->dev = >dev;
+
+   if (udev->product)
+   strlcpy(mdev->model, udev->product,
+   sizeof(mdev->model));
+   if (udev->serial)
+   strlcpy(mdev->serial, udev->serial,
+   sizeof(mdev->serial));
+   strcpy(mdev->bus_info, udev->devpath);
+   mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
+
+   ret = media_device_init(mdev);
+   if (ret) {
+   dev_err(>dev,
+   "Couldn't create a media device. Error: %d\n",
+   ret);
+   return ret;
+   }
}
 
dev->media_dev = mdev;
-- 
2.5.0

--
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 14/31] media: Change v4l-core to check for tuner availability

2016-01-06 Thread Shuah Khan
Change s_input, s_fmt, s_tuner, s_frequency, querystd,
s_hw_freq_seek, and vb2_core_streamon interfaces that
alter the tuner configuration to check for tuner availability
by calling v4l_enable_media_tuner(). If tuner isn't free,
return -EBUSY. v4l_disable_media_tuner() is called from
v4l2_fh_exit() to release the tuner. vb2_core_streamon()
uses v4l_vb2q_enable_media_tuner().

Signed-off-by: Shuah Khan 
---
 drivers/media/v4l2-core/v4l2-fh.c|  1 +
 drivers/media/v4l2-core/v4l2-ioctl.c | 29 +
 drivers/media/v4l2-core/videobuf2-core.c |  4 
 3 files changed, 34 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fh.c 
b/drivers/media/v4l2-core/v4l2-fh.c
index c97067a..538db62 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -92,6 +92,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh)
 {
if (fh->vdev == NULL)
return;
+   v4l_disable_media_tuner(fh->vdev);
v4l2_event_unsubscribe_all(fh);
fh->vdev = NULL;
 }
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 8a018c6..ed7f600 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1041,6 +1041,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 static int v4l_s_input(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
+   struct video_device *vfd = video_devdata(file);
+   int ret;
+
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
return ops->vidioc_s_input(file, fh, *(unsigned int *)arg);
 }
 
@@ -1448,6 +1454,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
v4l_sanitize_format(p);
 
switch (p->type) {
@@ -1637,7 +1646,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops,
 {
struct video_device *vfd = video_devdata(file);
struct v4l2_tuner *p = arg;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
return ops->vidioc_s_tuner(file, fh, p);
@@ -1691,7 +1704,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops 
*ops,
struct video_device *vfd = video_devdata(file);
const struct v4l2_frequency *p = arg;
enum v4l2_tuner_type type;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
if (vfd->vfl_type == VFL_TYPE_SDR) {
if (p->type != V4L2_TUNER_SDR && p->type != V4L2_TUNER_RF)
return -EINVAL;
@@ -1746,7 +1763,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops,
 {
struct video_device *vfd = video_devdata(file);
v4l2_std_id id = *(v4l2_std_id *)arg, norm;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
norm = id & vfd->tvnorms;
if (vfd->tvnorms && !norm)  /* Check if std is supported */
return -EINVAL;
@@ -1760,7 +1781,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops,
 {
struct video_device *vfd = video_devdata(file);
v4l2_std_id *p = arg;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
/*
 * If no signal is detected, then the driver should return
 * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with
@@ -1779,7 +1804,11 @@ static int v4l_s_hw_freq_seek(const struct 
v4l2_ioctl_ops *ops,
struct video_device *vfd = video_devdata(file);
struct v4l2_hw_freq_seek *p = arg;
enum v4l2_tuner_type type;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
/* s_hw_freq_seek is not supported for SDR for now */
if (vfd->vfl_type == VFL_TYPE_SDR)
return -EINVAL;
diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 33bdd81..c9bbb87 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -25,6 +25,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -1742,6 +1743,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int 
type)
 * are available.
 */
if (q->queued_count >= q->min_buffers_needed) {
+   ret = v4l_vb2q_enable_media_tuner(q);
+   if (ret)
+   return ret;
ret = vb2_start_streaming(q);
if (ret) {
__vb2_queue_cancel(q);
-- 
2.5.0

--

[PATCH 04/31] media: Media Controller enable/disable source handler API

2016-01-06 Thread Shuah Khan
Add new fields to struct media_device to add enable_source, and
disable_source handlers, and source_priv to stash driver private
data that is need to run these handlers. The enable_source handler
finds source entity for the passed in entity and check if it is
available, and activate the link using __media_entity_setup_link()
interface. Bridge driver is expected to implement and set these
handlers and private data when media_device is registered or when
bridge driver finds the media_device during probe. This is to enable
the use-case to find tuner entity connected to the decoder entity and
check if it is available, and activate it and start pipeline between
the source and the entity. The disable_source handler deactivates the
link and stops the pipeline. This handler can be invoked from the
media core (v4l-core, dvb-core) as well as other drivers such as ALSA
that control the media device.

Signed-off-by: Shuah Khan 
---
 include/media/media-device.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/include/media/media-device.h b/include/media/media-device.h
index 6520d1c..04b6c2e 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -333,6 +333,25 @@ struct media_device {
/* Serializes graph operations. */
struct mutex graph_mutex;
 
+   /* Handlers to find source entity for the sink entity and
+* check if it is available, and activate the link using
+* media_entity_setup_link() interface and start pipeline
+* from the source to the entity.
+* Bridge driver is expected to implement and set the
+* handler when media_device is registered or when
+* bridge driver finds the media_device during probe.
+* Bridge driver sets source_priv with information
+* necessary to run enable/disable source handlers.
+*
+* Use-case: find tuner entity connected to the decoder
+* entity and check if it is available, and activate the
+* using media_entity_setup_link() if it is available.
+   */
+   void *source_priv;
+   int (*enable_source)(struct media_entity *entity,
+struct media_pipeline *pipe);
+   void (*disable_source)(struct media_entity *entity);
+
int (*link_notify)(struct media_link *link, u32 flags,
   unsigned int notification);
 };
-- 
2.5.0

--
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 11/31] media: au8522 change to create MC pad for ALSA Audio Out

2016-01-06 Thread Shuah Khan
Add new pad for ALSA Audio Out to au8522_media_pads.

Signed-off-by: Shuah Khan 
---
 drivers/media/dvb-frontends/au8522.h | 1 +
 drivers/media/dvb-frontends/au8522_decoder.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/dvb-frontends/au8522.h 
b/drivers/media/dvb-frontends/au8522.h
index 3c72f40..d7a997f 100644
--- a/drivers/media/dvb-frontends/au8522.h
+++ b/drivers/media/dvb-frontends/au8522.h
@@ -94,6 +94,7 @@ enum au8522_media_pads {
AU8522_PAD_INPUT,
AU8522_PAD_VID_OUT,
AU8522_PAD_VBI_OUT,
+   AU8522_PAD_AUDIO_OUT,
 
AU8522_NUM_PADS
 };
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c 
b/drivers/media/dvb-frontends/au8522_decoder.c
index 9674cef..2c53b61 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,6 +775,7 @@ static int au8522_probe(struct i2c_client *client,
state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
+   state->pads[AU8522_PAD_AUDIO_OUT].flags = MEDIA_PAD_FL_SOURCE;
sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
ret = media_entity_pads_init(>entity, ARRAY_SIZE(state->pads),
-- 
2.5.0

--
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 26/31] sound/usb: Update ALSA driver to use Managed Media Controller API

2016-01-06 Thread Shuah Khan
Change ALSA driver to use Managed Media Managed Controller
API to share tuner with DVB and V4L2 drivers that control
AU0828 media device.  Media device is created based on a
newly added field value in the struct snd_usb_audio_quirk.
Using this approach, the media controller API usage can be
added for a specific device. In this patch, Media Controller
API is enabled for AU0828 hw. snd_usb_create_quirk() will
check this new field, if set will create a media device using
media_device_get_devres() interface.

media_device_get_devres() will allocate a new media device
devres or return an existing one, if it finds one.

During probe, media usb driver could have created the media
device devres. It will then initialze (if necessary) and
register the media device if it isn't already initialized
and registered. Media device unregister is done from
usb_audio_disconnect().

During probe, media usb driver could have created the
media device devres. It will then register the media
device if it isn't already registered. Media device
unregister is done from usb_audio_disconnect().

New structure media_ctl is added to group the new
fields to support media entity and links. This new
structure is added to struct snd_usb_substream.

A new entity_notify hook and a new ALSA capture media
entity are registered from snd_usb_pcm_open() after
setting up hardware information for the PCM device.

When a new entity is registered, Media Controller API
interface media_device_register_entity() invokes all
registered entity_notify hooks for the media device.
ALSA entity_notify hook parses all the entity list to
find a link from decoder it ALSA entity. This indicates
that the bridge driver created a link from decoder to
ALSA capture entity.

ALSA will attempt to enable the tuner to link the tuner
to the decoder calling enable_source handler if one is
provided by the bridge driver prior to starting Media
pipeline from snd_usb_hw_params(). If enable_source returns
with tuner busy condition, then snd_usb_hw_params() will fail
with -EBUSY. Media pipeline is stopped from snd_usb_hw_free().

Signed-off-by: Shuah Khan 
---
 sound/usb/Makefile   |  15 +++-
 sound/usb/card.c |   7 ++
 sound/usb/card.h |   1 +
 sound/usb/media.c| 214 +++
 sound/usb/media.h|  54 
 sound/usb/pcm.c  |  26 --
 sound/usb/quirks-table.h |   1 +
 sound/usb/quirks.c   |   9 +-
 sound/usb/stream.c   |   2 +
 sound/usb/usbaudio.h |   1 +
 10 files changed, 323 insertions(+), 7 deletions(-)
 create mode 100644 sound/usb/media.c
 create mode 100644 sound/usb/media.h

diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index 2d2d122..665fdd9 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -2,6 +2,18 @@
 # Makefile for ALSA
 #
 
+# Media Controller
+ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
+  ifeq ($(CONFIG_MEDIA_SUPPORT),y)
+KBUILD_CFLAGS += -DUSE_MEDIA_CONTROLLER
+  endif
+  ifeq ($(CONFIG_MEDIA_SUPPORT_MODULE),y)
+ifeq ($(MODULE),y)
+  KBUILD_CFLAGS += -DUSE_MEDIA_CONTROLLER
+endif
+  endif
+endif
+
 snd-usb-audio-objs :=  card.o \
clock.o \
endpoint.o \
@@ -13,7 +25,8 @@ snd-usb-audio-objs := card.o \
pcm.o \
proc.o \
quirks.o \
-   stream.o
+   stream.o \
+   media.o
 
 snd-usbmidi-lib-objs := midi.o
 
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 18f5664..1a63851 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -66,6 +66,7 @@
 #include "format.h"
 #include "power.h"
 #include "stream.h"
+#include "media.h"
 
 MODULE_AUTHOR("Takashi Iwai ");
 MODULE_DESCRIPTION("USB Audio");
@@ -621,6 +622,12 @@ static void usb_audio_disconnect(struct usb_interface 
*intf)
list_for_each_entry(mixer, >mixer_list, list) {
snd_usb_mixer_disconnect(mixer);
}
+   /*
+* Nice to check quirk && quirk->media_device
+* need some special handlings. Doesn't look like
+* we have access to quirk here
+   */
+   media_device_delete(intf);
}
 
chip->num_interfaces--;
diff --git a/sound/usb/card.h b/sound/usb/card.h
index 71778ca..c15a03c 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -156,6 +156,7 @@ struct snd_usb_substream {
} dsd_dop;
 
bool trigger_tstamp_pending_update; /* trigger timestamp being updated 
from initial estimate */
+   void *media_ctl;
 };
 
 struct snd_usb_stream {
diff --git a/sound/usb/media.c b/sound/usb/media.c
new file mode 100644
index 000..747a66a
--- /dev/null
+++ b/sound/usb/media.c
@@ -0,0 +1,214 @@
+/*
+ * media.c - Media Controller specific ALSA driver code
+ *
+ * Copyright (c) 2015 Shuah Khan 

[PATCH 29/31] media: track media device unregister in progress

2016-01-06 Thread Shuah Khan
Add support to track media device unregister in progress
state to prevent more than one driver entering unregister.
This enables fixing the general protection faults while
snd-usb-audio was cleaning up media resources for pcm
streams and mixers. In this patch a new interface is added
to return the unregister in progress state. Subsequent
patches to snd-usb-audio and au0828-core use this interface
to avoid entering unregister and attempting to unregister
entities and remove devnodes while unregister is in progress.
Media device unregister removes entities and interface nodes.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-device.c |  5 -
 include/media/media-device.h | 17 +
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 20c85a9..1bb9a5f 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -749,10 +749,13 @@ void media_device_unregister(struct media_device *mdev)
spin_lock(>lock);
 
/* Check if mdev was ever registered at all */
-   if (!media_devnode_is_registered(>devnode)) {
+   /* check if unregister is in progress */
+   if (!media_devnode_is_registered(>devnode) ||
+   mdev->unregister_in_progress) {
spin_unlock(>lock);
return;
}
+   mdev->unregister_in_progress = true;
 
/* Remove all entities from the media device */
list_for_each_entry_safe(entity, next, >entities, graph_obj.list)
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 04b6c2e..0807292 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -332,6 +332,10 @@ struct media_device {
spinlock_t lock;
/* Serializes graph operations. */
struct mutex graph_mutex;
+   /* Tracks unregister in progress state to prevent
+* more than one driver entering unregister
+   */
+   bool unregister_in_progress;
 
/* Handlers to find source entity for the sink entity and
 * check if it is available, and activate the link using
@@ -365,6 +369,7 @@ struct media_device {
 /* media_devnode to media_device */
 #define to_media_device(node) container_of(node, struct media_device, devnode)
 
+
 /**
  * media_entity_enum_init - Initialise an entity enumeration
  *
@@ -553,6 +558,12 @@ struct media_device *media_device_get_devres(struct device 
*dev);
  * @dev: pointer to struct 
  */
 struct media_device *media_device_find_devres(struct device *dev);
+/* return unregister in progress state */
+static inline bool media_device_is_unregister_in_progress(
+   struct media_device *mdev)
+{
+   return mdev->unregister_in_progress;
+}
 
 /* Iterate over all entities. */
 #define media_device_for_each_entity(entity, mdev) \
@@ -569,6 +580,7 @@ struct media_device *media_device_find_devres(struct device 
*dev);
 /* Iterate over all links. */
 #define media_device_for_each_link(link, mdev) \
list_for_each_entry(link, &(mdev)->links, graph_obj.list)
+
 #else
 static inline int media_device_register(struct media_device *mdev)
 {
@@ -604,5 +616,10 @@ static inline struct media_device 
*media_device_find_devres(struct device *dev)
 {
return NULL;
 }
+static inline bool media_device_is_unregister_in_progress(
+   struct media_device *mdev)
+{
+   return false;
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
 #endif
-- 
2.5.0

--
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 30/31] sound/usb: Check media device unregister progress state

2016-01-06 Thread Shuah Khan
Change to release media resources for pcm streams
and mixer before snd_card_disconnect() is done from
usb_audio_disconnect(). The stream and mixer resource
release interfaces access managed media resources
(device resources) created on the usb device parent.
These interfaces should be called before the last
put_device() which releases all the device resources.
In addition, changed the stream and mixer resource
release interfaces to check if media device unregister
is in progress and avoid calling Media Controller API
to unregister entities and remove devnodes. Media device
unregister takes care of all of this. This fixes the
the general protection faults while snd-usb-audio was
cleaning up media resources for pcm streams and mixers.

Signed-off-by: Shuah Khan 
---
 sound/usb/card.c   |  8 ++--
 sound/usb/media.c  | 41 +++--
 sound/usb/media.h  |  4 ++--
 sound/usb/stream.c |  1 -
 4 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index e965982..8959ccb 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -608,6 +608,12 @@ static void usb_audio_disconnect(struct usb_interface 
*intf)
 */
wait_event(chip->shutdown_wait,
   !atomic_read(>usage_count));
+
+   /* release media pcm stream resources */
+   media_stream_delete(chip);
+   /* delete mixer media resources */
+   media_mixer_delete(chip);
+
snd_card_disconnect(card);
/* release the pcm resources */
list_for_each_entry(as, >pcm_list, list) {
@@ -621,8 +627,6 @@ static void usb_audio_disconnect(struct usb_interface *intf)
list_for_each(p, >midi_list) {
snd_usbmidi_disconnect(p);
}
-   /* delete mixer media resources */
-   media_mixer_delete(chip);
/* release mixer resources */
list_for_each_entry(mixer, >mixer_list, list) {
snd_usb_mixer_disconnect(mixer);
diff --git a/sound/usb/media.c b/sound/usb/media.c
index 4f99086..9d29e1d 100644
--- a/sound/usb/media.c
+++ b/sound/usb/media.c
@@ -98,8 +98,11 @@ void media_device_delete(struct usb_interface *iface)
struct usb_device *usbdev = interface_to_usbdev(iface);
 
mdev = media_device_find_devres(>dev);
-   if (mdev && media_devnode_is_registered(>devnode))
-   media_device_unregister(mdev);
+   if (mdev) {
+   if (media_devnode_is_registered(>devnode) &&
+   !media_device_is_unregister_in_progress(mdev))
+   media_device_unregister(mdev);
+   }
 }
 
 static int media_enable_source(struct media_ctl *mctl)
@@ -177,7 +180,7 @@ int media_stream_init(struct snd_usb_substream *subs, 
struct snd_pcm *pcm,
return 0;
 }
 
-void media_stream_delete(struct snd_usb_substream *subs)
+static void __media_stream_delete(struct snd_usb_substream *subs)
 {
struct media_ctl *mctl = (struct media_ctl *) subs->media_ctl;
 
@@ -185,7 +188,7 @@ void media_stream_delete(struct snd_usb_substream *subs)
struct media_device *mdev;
 
mdev = media_device_find_devres(>dev->dev);
-   if (mdev) {
+   if (mdev && !media_device_is_unregister_in_progress(mdev)) {
media_devnode_remove(mctl->intf_devnode);
media_device_unregister_entity(>media_entity);
media_entity_cleanup(>media_entity);
@@ -195,6 +198,21 @@ void media_stream_delete(struct snd_usb_substream *subs)
}
 }
 
+void media_stream_delete(struct snd_usb_audio *chip)
+{
+   struct snd_usb_stream *as;
+
+   list_for_each_entry(as, >pcm_list, list) {
+   struct snd_usb_substream *subs;
+   int idx;
+
+   for (idx = 0; idx < 2; idx++) {
+   subs = >substream[idx];
+   __media_stream_delete(subs);
+   }
+   }
+}
+
 int media_start_pipeline(struct snd_usb_substream *subs)
 {
struct media_ctl *mctl = (struct media_ctl *) subs->media_ctl;
@@ -283,22 +301,25 @@ void media_mixer_delete(struct snd_usb_audio *chip)
struct media_device *mdev;
 
mdev = media_device_find_devres(>dev->dev);
-   if (!mdev)
-   return;
 
+   if (chip->ctl_intf_media_devnode) {
+   if (mdev && !media_device_is_unregister_in_progress(mdev))
+   media_devnode_remove(chip->ctl_intf_media_devnode);
+   chip->ctl_intf_media_devnode = NULL;
+   }
list_for_each_entry(mixer, >mixer_list, list) {
struct media_mixer_ctl *mctl;
 
mctl = (struct media_mixer_ctl *) mixer->media_mixer_ctl;
if (!mixer->media_mixer_ctl)
continue;
-

[PATCH 31/31] media: au0828 change to check media device unregister progress state

2016-01-06 Thread Shuah Khan
Change au0828_unregister_media_device() to check media
device media device unregister is in progress and avoid
calling media_device_unregister() and other cleanup done
in au0828_unregister_media_device().

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 886fb28..de357a2 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -136,7 +136,9 @@ static void au0828_unregister_media_device(struct 
au0828_dev *dev)
 
 #ifdef CONFIG_MEDIA_CONTROLLER
if (dev->media_dev &&
-   media_devnode_is_registered(>media_dev->devnode)) {
+   media_devnode_is_registered(>media_dev->devnode) &&
+   !media_device_is_unregister_in_progress(dev->media_dev)) {
+
media_device_unregister(dev->media_dev);
media_device_cleanup(dev->media_dev);
dev->media_dev = NULL;
-- 
2.5.0

--
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 25/31] media: au0828 fix to not call media_device_unregister_entity_notify()

2016-01-06 Thread Shuah Khan
entity_notify handlers are removed from media_device_unregister().
There is no need to call media_device_unregister_entity_notify()
to do that right before calling media_device_unregister().

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 9497ad1..722e073 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -137,8 +137,6 @@ static void au0828_unregister_media_device(struct 
au0828_dev *dev)
 #ifdef CONFIG_MEDIA_CONTROLLER
if (dev->media_dev &&
media_devnode_is_registered(>media_dev->devnode)) {
-   media_device_unregister_entity_notify(dev->media_dev,
- >entity_notify);
media_device_unregister(dev->media_dev);
media_device_cleanup(dev->media_dev);
dev->media_dev = NULL;
-- 
2.5.0

--
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 27/31] sound/usb: Create media mixer function and control interface entities

2016-01-06 Thread Shuah Khan
Add support for creating MEDIA_ENT_F_AUDIO_MIXER entity for
each mixer and a MEDIA_INTF_T_ALSA_CONTROL control interface
entity that links to mixer entities. MEDIA_INTF_T_ALSA_CONTROL
entity corresponds to the control device for the card.

Signed-off-by: Shuah Khan 
---
 sound/usb/card.c |  5 +++
 sound/usb/media.c| 90 
 sound/usb/media.h| 21 
 sound/usb/mixer.h|  1 +
 sound/usb/usbaudio.h |  1 +
 5 files changed, 118 insertions(+)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1a63851..e965982 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -562,6 +562,9 @@ static int usb_audio_probe(struct usb_interface *intf,
if (err < 0)
goto __error;
 
+   /* Create media entities for mixer and control dev */
+   media_mixer_init(chip);
+
usb_chip[chip->index] = chip;
chip->num_interfaces++;
usb_set_intfdata(intf, chip);
@@ -618,6 +621,8 @@ static void usb_audio_disconnect(struct usb_interface *intf)
list_for_each(p, >midi_list) {
snd_usbmidi_disconnect(p);
}
+   /* delete mixer media resources */
+   media_mixer_delete(chip);
/* release mixer resources */
list_for_each_entry(mixer, >mixer_list, list) {
snd_usb_mixer_disconnect(mixer);
diff --git a/sound/usb/media.c b/sound/usb/media.c
index 747a66a..4f99086 100644
--- a/sound/usb/media.c
+++ b/sound/usb/media.c
@@ -211,4 +211,94 @@ void media_stop_pipeline(struct snd_usb_substream *subs)
if (mctl)
media_disable_source(mctl);
 }
+
+int media_mixer_init(struct snd_usb_audio *chip)
+{
+   struct device *ctl_dev = >card->ctl_dev;
+   struct media_intf_devnode *ctl_intf;
+   struct usb_mixer_interface *mixer;
+   struct media_device *mdev;
+   struct media_mixer_ctl *mctl;
+   u32 intf_type = MEDIA_INTF_T_ALSA_CONTROL;
+   int ret;
+
+   mdev = media_device_find_devres(>dev->dev);
+   if (!mdev)
+   return -ENODEV;
+
+   ctl_intf = chip->ctl_intf_media_devnode;
+   if (!ctl_intf) {
+   ctl_intf = (void *) media_devnode_create(mdev,
+intf_type, 0,
+MAJOR(ctl_dev->devt),
+MINOR(ctl_dev->devt));
+   if (!ctl_intf)
+   return -ENOMEM;
+   chip->ctl_intf_media_devnode = ctl_intf;
+   }
+
+   list_for_each_entry(mixer, >mixer_list, list) {
+
+   if (mixer->media_mixer_ctl)
+   continue;
+
+   /* allocate media_mixer_ctl */
+   mctl = kzalloc(sizeof(*mctl), GFP_KERNEL);
+   if (!mctl)
+   return -ENOMEM;
+
+   mctl->media_dev = mdev;
+   mctl->media_entity.function = MEDIA_ENT_F_AUDIO_MIXER;
+   mctl->media_entity.name = chip->card->mixername;
+   mctl->media_pad[0].flags = MEDIA_PAD_FL_SINK;
+   mctl->media_pad[1].flags = MEDIA_PAD_FL_SOURCE;
+   mctl->media_pad[2].flags = MEDIA_PAD_FL_SOURCE;
+   media_entity_pads_init(>media_entity, MEDIA_MIXER_PAD_MAX,
+ mctl->media_pad);
+   ret =  media_device_register_entity(mctl->media_dev,
+   >media_entity);
+   if (ret) {
+   kfree(mctl);
+   return ret;
+   }
+
+   mctl->intf_link = media_create_intf_link(>media_entity,
+_intf->intf,
+MEDIA_LNK_FL_ENABLED);
+   if (!mctl->intf_link) {
+   media_device_unregister_entity(>media_entity);
+   media_entity_cleanup(>media_entity);
+   kfree(mctl);
+   return -ENOMEM;
+   }
+   mctl->intf_devnode = ctl_intf;
+   mixer->media_mixer_ctl = (void *) mctl;
+   }
+   return 0;
+}
+
+void media_mixer_delete(struct snd_usb_audio *chip)
+{
+   struct usb_mixer_interface *mixer;
+   struct media_device *mdev;
+
+   mdev = media_device_find_devres(>dev->dev);
+   if (!mdev)
+   return;
+
+   list_for_each_entry(mixer, >mixer_list, list) {
+   struct media_mixer_ctl *mctl;
+
+   mctl = (struct media_mixer_ctl *) mixer->media_mixer_ctl;
+   if (!mixer->media_mixer_ctl)
+   continue;
+
+   media_device_unregister_entity(>media_entity);
+   media_entity_cleanup(>media_entity);
+   

Re: em28xx driver for StarTech SVID2USB2

2016-01-06 Thread Alexandre-Xavier Labonté-Lamoureux
Hello, 

I had the exact same problem. 
Here's a question I asked on the Ubuntu but got no answer: 
http://askubuntu.com/questions/686779/video-recording-device-detected-but-cant-use-it

Now I bought another device, an Ion Video 2 PC MKII, it uses the same chip and 
it won't work with Linux. 

Here's a video were a guy compiles his own kernel and makes it work (the Ion 
Video 2 PC, not the StarTech Device)
https://www.youtube.com/watch?v=30e-N5z51vU

I tried the same thing (recompiling a new kernel) following his instructions 
without success. The sound didn't work and the only thing I got was a still 
image on VLC. Programs like guvcview and cheese didn't detect the  StarTech 
SVID2USB2. I firmly believe they use the same chip because they both use 
eb1a:5051 to identify themselves. 

Many thanks if you guys can fix it. 
Alexandre-Xavier 



From: linux-media-ow...@vger.kernel.org  on 
behalf of Devin Heitmueller 
Sent: January 6, 2016 2:21 PM
To: Schubert, Matthew R. (LARC-D319)[TEAMS2]
Cc: linux-media@vger.kernel.org
Subject: Re: em28xx driver for StarTech SVID2USB2

On Wed, Jan 6, 2016 at 1:27 PM, Schubert, Matthew R.
(LARC-D319)[TEAMS2]  wrote:
> Hello,
>
> We are attempting to use a StarTech Video Capture cable (Part# SVID2USB2) 
> with our CentOS 6.7 machine with no success. The em28xx driver seems to load 
> but cannot properly ID the capture cable. Below are the outputs from "dmesg" 
> and "lsusb -v" run after plugging in the device. Any advice is appreciated.

Try adding "card=9" to the modprobe option.  If that doesn't work than
try "card=29".  Most of those really cheap devices either have an
saa7113 or tvp5150 video decoder, and one of those two board profiles
should work.

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
--
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: mc_nextgen_test renable ALSA interfaces

2016-01-06 Thread Shuah Khan
ALSA interfaces were disable with #if 0. Renable
them.

Signed-off-by: Shuah Khan 
---
 contrib/test/mc_nextgen_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/contrib/test/mc_nextgen_test.c b/contrib/test/mc_nextgen_test.c
index 14a0917..7d0344b 100644
--- a/contrib/test/mc_nextgen_test.c
+++ b/contrib/test/mc_nextgen_test.c
@@ -184,7 +184,6 @@ static inline const char *intf_type(uint32_t intf_type)
return "v4l2-subdev";
case MEDIA_INTF_T_V4L_SWRADIO:
return "swradio";
-#if 0
case MEDIA_INTF_T_ALSA_PCM_CAPTURE:
return "pcm-capture";
case MEDIA_INTF_T_ALSA_PCM_PLAYBACK:
@@ -197,7 +196,6 @@ static inline const char *intf_type(uint32_t intf_type)
return "rawmidi";
case MEDIA_INTF_T_ALSA_HWDEP:
return "hwdep";
-#endif
default:
return "unknown_intf";
}
-- 
2.5.0

--
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 RESEND] v4l-utils: mc_nextgen_test add ALSA capture, playback, and mixer

2016-01-06 Thread Shuah Khan
Add support for ALSA capture, playback, and mixer entity functions.

Signed-off-by: Shuah Khan 
---
 contrib/test/mc_nextgen_test.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/contrib/test/mc_nextgen_test.c b/contrib/test/mc_nextgen_test.c
index e287096..e0d0ad2 100644
--- a/contrib/test/mc_nextgen_test.c
+++ b/contrib/test/mc_nextgen_test.c
@@ -227,6 +227,12 @@ static inline const char *ent_function(uint32_t function)
return "ATV decoder";
case MEDIA_ENT_F_TUNER:
return "tuner";
+   case MEDIA_ENT_F_AUDIO_CAPTURE:
+   return "Audio Capture";
+   case MEDIA_ENT_F_AUDIO_PLAYBACK:
+   return "Audio Playback";
+   case MEDIA_ENT_F_AUDIO_MIXER:
+   return "Audio Mixer";
case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
default:
return "unknown entity type";
-- 
2.1.4

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