Re: [PATCH 0/6] radio: Utilize the module_isa_driver macro

2016-07-20 Thread William Breathitt Gray
On Wed, Jul 20, 2016 at 12:37:31PM +0200, Hans Verkuil wrote:
>On 07/18/2016 04:45 PM, William Breathitt Gray wrote:
>> The module_isa_driver macro is a helper macro for ISA drivers which do
>> not do anything special in module init/exit. This patchset eliminates a
>> lot of ISA driver registration boilerplate code by utilizing
>> module_isa_driver, which replaces module_init and module_exit.
>> 
>> William Breathitt Gray (6):
>>   radio: terratec: Utilize the module_isa_driver macro
>>   radio: rtrack2: Utilize the module_isa_driver macro
>>   radio: trust: Utilize the module_isa_driver macro
>>   radio: zoltrix: Utilize the module_isa_driver macro
>>   radio: aztech: Utilize the module_isa_driver macro
>>   radio: aimslab: Utilize the module_isa_driver macro
>
>Good idea, but it doesn't compile:
>
>module_isa_driver(terratec_driver.driver, 1);
>
>expands to:
>
>static int __init terratec_driver.driver_init(void)
>{
>return isa_register_driver(&(terratec_driver.driver), 1);
>}
>
>So now the function name contains a '.' and it won't compile.
>
>Regards,
>
>   Hans

Oops, looks like I was a bit on autopilot there. I'll have to rethink
this patchset at a later point to overcome the symbol naming issue.

Thank you,

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


[PATCH 4/6] radio: zoltrix: Utilize the module_isa_driver macro

2016-07-18 Thread William Breathitt Gray
This driver does not do anything special in module init/exit. This patch
eliminates the module init/exit boilerplate code by utilizing the
module_isa_driver macro.

Signed-off-by: William Breathitt Gray <vilhelm.g...@gmail.com>
---
 drivers/media/radio/radio-zoltrix.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/media/radio/radio-zoltrix.c 
b/drivers/media/radio/radio-zoltrix.c
index 026e88e..597da26 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -233,16 +233,4 @@ static struct radio_isa_driver zoltrix_driver = {
.max_volume = 15,
 };
 
-static int __init zoltrix_init(void)
-{
-   return isa_register_driver(_driver.driver, ZOLTRIX_MAX);
-}
-
-static void __exit zoltrix_exit(void)
-{
-   isa_unregister_driver(_driver.driver);
-}
-
-module_init(zoltrix_init);
-module_exit(zoltrix_exit);
-
+module_isa_driver(zoltrix_driver.driver, ZOLTRIX_MAX);
-- 
2.7.3

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


[PATCH 3/6] radio: trust: Utilize the module_isa_driver macro

2016-07-18 Thread William Breathitt Gray
This driver does not do anything special in module init/exit. This patch
eliminates the module init/exit boilerplate code by utilizing the
module_isa_driver macro.

Signed-off-by: William Breathitt Gray <vilhelm.g...@gmail.com>
---
 drivers/media/radio/radio-trust.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/media/radio/radio-trust.c 
b/drivers/media/radio/radio-trust.c
index 26a8c60..e4bec5e 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -229,15 +229,4 @@ static struct radio_isa_driver trust_driver = {
.max_volume = 31,
 };
 
-static int __init trust_init(void)
-{
-   return isa_register_driver(_driver.driver, TRUST_MAX);
-}
-
-static void __exit trust_exit(void)
-{
-   isa_unregister_driver(_driver.driver);
-}
-
-module_init(trust_init);
-module_exit(trust_exit);
+module_isa_driver(trust_driver.driver, TRUST_MAX);
-- 
2.7.3

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


[PATCH 6/6] radio: aimslab: Utilize the module_isa_driver macro

2016-07-18 Thread William Breathitt Gray
This driver does not do anything special in module init/exit. This patch
eliminates the module init/exit boilerplate code by utilizing the
module_isa_driver macro.

Cc: Hans Verkuil <hverk...@xs4all.nl>
Signed-off-by: William Breathitt Gray <vilhelm.g...@gmail.com>
---
 drivers/media/radio/radio-aimslab.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/media/radio/radio-aimslab.c 
b/drivers/media/radio/radio-aimslab.c
index ea930879..d1566a3 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -180,15 +180,4 @@ static struct radio_isa_driver rtrack_driver = {
.max_volume = 0xff,
 };
 
-static int __init rtrack_init(void)
-{
-   return isa_register_driver(_driver.driver, RTRACK_MAX);
-}
-
-static void __exit rtrack_exit(void)
-{
-   isa_unregister_driver(_driver.driver);
-}
-
-module_init(rtrack_init);
-module_exit(rtrack_exit);
+module_isa_driver(rtrack_driver.driver, RTRACK_MAX);
-- 
2.7.3

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


[PATCH 5/6] radio: aztech: Utilize the module_isa_driver macro

2016-07-18 Thread William Breathitt Gray
This driver does not do anything special in module init/exit. This patch
eliminates the module init/exit boilerplate code by utilizing the
module_isa_driver macro.

Cc: Hans Verkuil <hverk...@xs4all.nl>
Signed-off-by: William Breathitt Gray <vilhelm.g...@gmail.com>
---
 drivers/media/radio/radio-aztech.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/media/radio/radio-aztech.c 
b/drivers/media/radio/radio-aztech.c
index 705dd6f..7b39655 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -147,15 +147,4 @@ static struct radio_isa_driver aztech_driver = {
.max_volume = 3,
 };
 
-static int __init aztech_init(void)
-{
-   return isa_register_driver(_driver.driver, AZTECH_MAX);
-}
-
-static void __exit aztech_exit(void)
-{
-   isa_unregister_driver(_driver.driver);
-}
-
-module_init(aztech_init);
-module_exit(aztech_exit);
+module_isa_driver(aztech_driver.driver, AZTECH_MAX);
-- 
2.7.3

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


[PATCH 2/6] radio: rtrack2: Utilize the module_isa_driver macro

2016-07-18 Thread William Breathitt Gray
This driver does not do anything special in module init/exit. This patch
eliminates the module init/exit boilerplate code by utilizing the
module_isa_driver macro.

Signed-off-by: William Breathitt Gray <vilhelm.g...@gmail.com>
---
 drivers/media/radio/radio-rtrack2.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/media/radio/radio-rtrack2.c 
b/drivers/media/radio/radio-rtrack2.c
index 09cfbc3..82b8794 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -127,15 +127,4 @@ static struct radio_isa_driver rtrack2_driver = {
.has_stereo = true,
 };
 
-static int __init rtrack2_init(void)
-{
-   return isa_register_driver(_driver.driver, RTRACK2_MAX);
-}
-
-static void __exit rtrack2_exit(void)
-{
-   isa_unregister_driver(_driver.driver);
-}
-
-module_init(rtrack2_init);
-module_exit(rtrack2_exit);
+module_isa_driver(rtrack2_driver.driver, RTRACK2_MAX);
-- 
2.7.3

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


[PATCH 1/6] radio: terratec: Utilize the module_isa_driver macro

2016-07-18 Thread William Breathitt Gray
This driver does not do anything special in module init/exit. This patch
eliminates the module init/exit boilerplate code by utilizing the
module_isa_driver macro.

Signed-off-by: William Breathitt Gray <vilhelm.g...@gmail.com>
---
 drivers/media/radio/radio-terratec.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/media/radio/radio-terratec.c 
b/drivers/media/radio/radio-terratec.c
index be10a80..621bbb2 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -155,16 +155,4 @@ static struct radio_isa_driver terratec_driver = {
.max_volume = 10,
 };
 
-static int __init terratec_init(void)
-{
-   return isa_register_driver(_driver.driver, 1);
-}
-
-static void __exit terratec_exit(void)
-{
-   isa_unregister_driver(_driver.driver);
-}
-
-module_init(terratec_init);
-module_exit(terratec_exit);
-
+module_isa_driver(terratec_driver.driver, 1);
-- 
2.7.3

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


[PATCH 0/6] radio: Utilize the module_isa_driver macro

2016-07-18 Thread William Breathitt Gray
The module_isa_driver macro is a helper macro for ISA drivers which do
not do anything special in module init/exit. This patchset eliminates a
lot of ISA driver registration boilerplate code by utilizing
module_isa_driver, which replaces module_init and module_exit.

William Breathitt Gray (6):
  radio: terratec: Utilize the module_isa_driver macro
  radio: rtrack2: Utilize the module_isa_driver macro
  radio: trust: Utilize the module_isa_driver macro
  radio: zoltrix: Utilize the module_isa_driver macro
  radio: aztech: Utilize the module_isa_driver macro
  radio: aimslab: Utilize the module_isa_driver macro

 drivers/media/radio/radio-aimslab.c  | 13 +
 drivers/media/radio/radio-aztech.c   | 13 +
 drivers/media/radio/radio-rtrack2.c  | 13 +
 drivers/media/radio/radio-terratec.c | 14 +-
 drivers/media/radio/radio-trust.c| 13 +
 drivers/media/radio/radio-zoltrix.c  | 14 +-
 6 files changed, 6 insertions(+), 74 deletions(-)

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


Hello Dear One

2016-04-28 Thread martin william
My name is Barr. Martin William and i am writing to you about the death of
my late client whom I believe to be one of your relatives and some
fund($US9,500,000,00)he left behind before his death. And I want you to
stand as his next of kin since you have the same surname with him and claim
this money before the bank confiscates it.

Contact me for more information (barr.martinwill...@outlook.com)

Barrister Martin William Esq.
--
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


Hello Dear One

2016-04-28 Thread martin william
My name is Barr. Martin William and i am writing to you about the death of
my late client whom I believe to be one of your relatives and some
fund($US9,500,000,00)he left behind before his death. And I want you to
stand as his next of kin since you have the same surname with him and claim
this money before the bank confiscates it.

Contact me for more information (barr.martinwill...@outlook.com)

Barrister Martin William Esq.
--
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: [Linux-kernel] Renesas Lager: Device Tree entries for VIN HDMI input, version 2

2015-09-22 Thread William Towle

Hi Simon,


On Thu, 13 Aug 2015, William Towle wrote:
>  (Obsoletes corresponding parts of "HDMI and Composite capture on
> Lager...", published previously)



> To follow:
>[PATCH 1/3] ARM: shmobile: lager dts: Add entries for VIN HDMI input
>[PATCH 2/3] media: adv7604: automatic "default-input" selection
>[PATCH 3/3] ARM: shmobile: lager dts: specify default-input for



I am wondering about the status of patch 2 of the series,
is it queued-up anywhere?


  All of these are effectively new, although the first and third
debuted in another thread. The patchwork link for the latter (at
https://patchwork.linuxtv.org/patch/30707/) contains the discussion
that led to the above being separated out.



I am also wondering about the relationship between patch 2 and 3.
Does 3 work without 2? Does 2 make 3 unnecessary?


  The device tree change in patch 3 is from Ian Molton's original
submissions, and works regardless of whether patch 2 is alongside it
or not.

  As far as the automatic port selection goes, patch 2 is related to
the argument made in commit 7111cdd ("[media] media: adv7604: reduce
support to first (digital) input") that since cable detect doesn't
work for port B, the .max_port property for boards using an ADV7612
should be ADV76XX_PAD_HDMI_PORT_A and we can use this to configure
port A as the default where there is not also an entry to specify it
in the device tree.
  If support for port B were available [in future], no action would
be taken where an ADV7612 is present and one would need to arrange
for applications in userland to actively make a choice where the
device tree does not have an appropriate value. In our particular case
we don't differentiate between hardware with ADV7611/7612 in the test
suite, and this necessitates having port selection available in the
device tree.

  Laurent may wish to comment further; for earlier discussion, see
https://patchwork.linuxtv.org/patch/30707/

Cheers,
  Wills.
--
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


Charity Project Worth $1,000,000.00 Dollars

2015-09-06 Thread Bill William And Andrea Groner


My wife and I have awarded you with a donation of 1 million Dollars from 
part of our Jackpot Lottery of 50 Million Dollars, respond with your details 
for claims.

http://www.huffingtonpost.ca/2014/07/22/50-million-edmonton-lotto_n_5610890.html

We await your earliest response and God Bless you.

Best of luck.

Bill And Andrea Groner
--
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


Charity Project Worth $1,000,000.00 Dollars

2015-09-06 Thread Bill William And Andrea Groner


My wife and I have awarded you with a donation of 1 million Dollars from 
part of our Jackpot Lottery of 50 Million Dollars, respond with your details 
for claims.

http://www.huffingtonpost.ca/2014/07/22/50-million-edmonton-lotto_n_5610890.html

We await your earliest response and God Bless you.

Best of luck.

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


[PATCH 2/3] media: adv7604: automatic default-input selection

2015-08-13 Thread William Towle
Add logic such that the default-input property becomes unnecessary
for chips that only have one suitable input (ADV7611 by design, and
ADV7612 due to commit 7111cddd [media] media: adv7604: reduce support
to first (digital) input).

Additionally, Ian's documentation in commit bf9c8227 ([media] media:
adv7604: ability to read default input port from DT) states that the
default-input property should reside directly in the node for
adv7612. Hence, also adjust the parsing to make the implementation
consistent with this.

Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |   25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 5631ec0..5bd81bd 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2799,7 +2799,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
struct device_node *endpoint;
struct device_node *np;
unsigned int flags;
-   u32 v;
+   u32 v= -1;
 
np = state-i2c_clients[ADV76XX_PAGE_IO]-dev.of_node;
 
@@ -2809,14 +2809,25 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
return -EINVAL;
 
v4l2_of_parse_endpoint(endpoint, bus_cfg);
-
-   if (!of_property_read_u32(endpoint, default-input, v))
-   state-pdata.default_input = v;
-   else
-   state-pdata.default_input = -1;
-
of_node_put(endpoint);
 
+   if (of_property_read_u32(np, default-input, v)) {
+   /* not specified ... can we choose automatically? */
+   switch (state-info-type) {
+   case ADV7611:
+   v = 0;
+   break;
+   case ADV7612:
+   if (state-info-max_port
+   == ADV76XX_PAD_HDMI_PORT_A)
+   v = 0;
+   /* else is unhobbled, leave unspecified */
+   default:
+   break;
+   }
+   }
+   state-pdata.default_input = v;
+
flags = bus_cfg.bus.parallel.flags;
 
if (flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH)
-- 
1.7.10.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


[PATCH 1/3] ARM: shmobile: lager dts: Add entries for VIN HDMI input support

2015-08-13 Thread William Towle
Add DT entries for vin0, vin0_pins, and adv7612.

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |   37 ++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index e02b523..31854bc 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -378,7 +378,12 @@
renesas,function = usb2;
};
 
-   vin1_pins: vin {
+   vin0_pins: vin0 {
+   renesas,groups = vin0_data24, vin0_sync, vin0_clkenb, 
vin0_clk;
+   renesas,function = vin0;
+   };
+
+   vin1_pins: vin1 {
renesas,groups = vin1_data8, vin1_clk;
renesas,function = vin1;
};
@@ -539,6 +544,17 @@
reg = 0x12;
};
 
+   hdmi-in@4c {
+   compatible = adi,adv7612;
+   reg = 0x4c;
+
+   port {
+   hdmi_in_ep: endpoint {
+   remote-endpoint = vin0ep0;
+   };
+   };
+   };
+
composite-in@20 {
compatible = adi,adv7180;
reg = 0x20;
@@ -654,6 +670,25 @@
status = okay;
 };
 
+/* HDMI video input */
+vin0 {
+   pinctrl-0 = vin0_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   vin0ep0: endpoint {
+   remote-endpoint = hdmi_in_ep;
+   bus-width = 24;
+   hsync-active = 0;
+   vsync-active = 0;
+   pclk-sample = 1;
+   data-active = 1;
+   };
+   };
+};
+
 /* composite video input */
 vin1 {
pinctrl-0 = vin1_pins;
-- 
1.7.10.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


[PATCH 3/3] ARM: shmobile: lager dts: specify default-input for ADV7612

2015-08-13 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

Set the 'default-input' property for ADV7612, enabling image and video
capture without the need to have userspace specifying routing.

(This version places the property in the adv7612 node, in line with
Ian's documentation)

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Signed-off-by: William Towle william.to...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 31854bc..12e1cfa 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -547,6 +547,7 @@
hdmi-in@4c {
compatible = adi,adv7612;
reg = 0x4c;
+   default-input = 0;
 
port {
hdmi_in_ep: endpoint {
-- 
1.7.10.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


Renesas Lager: Device Tree entries for VIN HDMI input, version 2

2015-08-13 Thread William Towle
  Version 2 ... removes some redundant configuration from device nodes,
and provides some supplementary logic for automatic initialisation of
state-pdata.default_input based on the hardware present.

  (Obsoletes corresponding parts of HDMI and Composite capture on
Lager..., published previously)

Cheers,
  Wills.

To follow:
[PATCH 1/3] ARM: shmobile: lager dts: Add entries for VIN HDMI input
[PATCH 2/3] media: adv7604: automatic default-input selection
[PATCH 3/3] ARM: shmobile: lager dts: specify default-input for
--
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: [GIT PULL FOR v4.3] Various fixes

2015-08-11 Thread William Towle

Hi Hans,

On Tue, 11 Aug 2015, Hans Verkuil wrote:

0015-v4l-subdev-Add-pad-config-allocator-and-init.patch
0016-media-soc_camera-rcar_vin-Add-BT.709-24-bit-RGB888-i.patch
0017-media-soc_camera-pad-aware-driver-initialisation.patch
0018-media-rcar_vin-Use-correct-pad-number-in-try_fmt.patch
0019-media-soc_camera-soc_scale_crop-Use-correct-pad-numb.patch
0020-media-rcar_vin-fill-in-bus_info-field.patch
0021-media-rcar_vin-Reject-videobufs-that-are-too-small-f.patch


William, can you take a look at this? Just let me know which patches
are independent to patch 0015.


  Of those, the patches that *do* call the allocator function directly
or are otherwise co-dependent are numbers 17-19 inclusive.


  The independent patches in that list are therefore:

[prerequisite work by Laurent Pinchart (1x)...]
0016-media-soc_camera-rcar_vin-Add-BT.709-24-bit-RGB888-i.patch
[general rcar_vin enhancements by Rob Taylor (2x)...]
0020-media-rcar_vin-fill-in-bus_info-field.patch
0021-media-rcar_vin-Reject-videobufs-that-are-too-small-f.patch

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


[PATCH 2/2] ARM: shmobile: lager dts: specify default-input for ADV7612

2015-07-28 Thread William Towle
Set 'default-input' property for ADV7612. Enables image/video capture
without the need to have userspace specifying routing.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Tested-by: William Towle william.to...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index aec7db6..e537052 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -552,6 +552,7 @@
port {
hdmi_in_ep: endpoint {
remote-endpoint = vin0ep0;
+   default-input = 0;
};
};
};
-- 
1.7.10.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


[PATCH 1/2] ARM: shmobile: lager dts: Add entries for VIN HDMI input support

2015-07-28 Thread William Towle
Add DT entries for vin0, vin0_pins, and adv7612

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |   41 ++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index e02b523..aec7db6 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -378,7 +378,12 @@
renesas,function = usb2;
};
 
-   vin1_pins: vin {
+   vin0_pins: vin0 {
+   renesas,groups = vin0_data24, vin0_sync, vin0_field, 
vin0_clkenb, vin0_clk;
+   renesas,function = vin0;
+   };
+
+   vin1_pins: vin1 {
renesas,groups = vin1_data8, vin1_clk;
renesas,function = vin1;
};
@@ -539,6 +544,18 @@
reg = 0x12;
};
 
+   hdmi-in@4c {
+   compatible = adi,adv7612;
+   reg = 0x4c;
+   remote = vin0;
+
+   port {
+   hdmi_in_ep: endpoint {
+   remote-endpoint = vin0ep0;
+   };
+   };
+   };
+
composite-in@20 {
compatible = adi,adv7180;
reg = 0x20;
@@ -654,6 +671,28 @@
status = okay;
 };
 
+/* HDMI video input */
+vin0 {
+   pinctrl-0 = vin0_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin0ep0: endpoint {
+   remote-endpoint = hdmi_in_ep;
+   bus-width = 24;
+   hsync-active = 0;
+   vsync-active = 0;
+   pclk-sample = 1;
+   data-active = 1;
+   };
+   };
+};
+
 /* composite video input */
 vin1 {
pinctrl-0 = vin1_pins;
-- 
1.7.10.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


Renesas Lager: Device Tree entries for VIN HDMI input

2015-07-28 Thread William Towle
  The patch series HDMI and Composite capture on Lager..., here
https://www.mail-archive.com/linux-media@vger.kernel.org/msg90650.html

  ...received a request for a re-post of its first two patches with an
additional Cc: to linux...@vger.kernel.org here:
https://www.mail-archive.com/linux-media@vger.kernel.org/msg90748.html

  That selection follows, with subject lines:
[PATCH 1/2] ARM: shmobile: lager dts: Add entries for VIN HDMI input
[PATCH 2/2] ARM: shmobile: lager dts: specify default-input for

Cheers,
  Wills.
--
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 03/13] media: adv7604: fix probe of ADV7611/7612

2015-07-27 Thread William Towle

On Fri, 24 Jul 2015, Hans Verkuil wrote:

-   val2 |= val;
+   val |= val2;



Oops. Added to my TODO list, I'll probably pick this up on Tuesday for a pull
request.


  And an oops from me: a keen-eyed local correspondent spotted that
I'd omitted the S-o-b :(

Wills.

...
Subject: [PATCH] media: adv7604: fix probe of ADV7611/7612

Prior to commit f862f57d ([media] media: i2c: ADV7604: Migrate to
regmap), the local variable 'val' contained the combined register
reads used in the chipset version ID test. Restore this expectation
so that the comparison works as it used to.

Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index bfb0b6a..0587d27 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3108,7 +3108,7 @@ static int adv76xx_probe(struct i2c_client *client,
v4l2_err(sd, Error %d reading IO Regmap\n, err);
return -ENODEV;
}
-   val2 |= val;
+   val |= val2;
if ((state-info-type == ADV7611  val != 0x2051) ||
(state-info-type == ADV7612  val != 0x2041)) {
v4l2_err(sd, not an adv761x on address 0x%x\n,
--
1.7.10.4

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


Re: [PATCH 07/13] media: soc_camera pad-aware driver initialisation

2015-07-27 Thread William Towle

On Fri, 24 Jul 2015, Hans Verkuil wrote:

Why would you want to init vdev-entity? soc-camera doesn't create a media 
controller
device, so there is no point in doing this.


  Thanks, I hadn't quite understood that about the code I was
transplanting to/from. Please find an update below.

Cheers,
  Wills.


...
Subject: [PATCH] media: soc_camera pad-aware driver initialisation

Add detection of source pad number for drivers aware of the media
controller API, so that the combination of soc_camera and rcar_vin
can create device nodes to support modern drivers such as adv7604.c
(for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/Kconfig  |1 +
 drivers/media/platform/soc_camera/rcar_vin.c   |1 +
 drivers/media/platform/soc_camera/soc_camera.c |   20 +++-
 include/media/soc_camera.h |1 +
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index f2776cd..5c45c83 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN
depends on VIDEO_DEV  SOC_CAMERA
depends on ARCH_SHMOBILE || COMPILE_TEST
depends on HAS_DMA
+   depends on MEDIA_CONTROLLER
select VIDEOBUF2_DMA_CONTIG
select SOC_CAMERA_SCALE_CROP
---help---
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 16352a8..00c1034 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
struct device *dev = icd-parent;
int shift;

+   fmt.pad = icd-src_pad_idx;
ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
if (ret  0)
return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index d708df4..82d3ebe 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1293,6 +1293,10 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = fmt.format;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad pad;
+   int pad_idx;
+#endif
int ret;

sd-grp_id = soc_camera_grp_id(icd);
@@ -1311,9 +1315,23 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
}

/* At this point client .probe() should have run already */
+   icd-src_pad_idx = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   for (pad_idx = 0; pad_idx  sd-entity.num_pads; pad_idx++)
+   if (sd-entity.pads[pad_idx].flags
+   == MEDIA_PAD_FL_SOURCE)
+   break;
+   if (pad_idx = sd-entity.num_pads)
+   goto eusrfmt;
+
+   icd-src_pad_idx = pad_idx;
+#endif
+
ret = soc_camera_init_user_formats(icd);
-   if (ret  0)
+   if (ret  0) {
+   icd-src_pad_idx = -1;
goto eusrfmt;
+   }

icd-field = V4L2_FIELD_ANY;

diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2f6261f..30193cf 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -42,6 +42,7 @@ struct soc_camera_device {
unsigned char devnum;   /* Device number per host */
struct soc_camera_sense *sense; /* See comment in struct definition */
struct video_device *vdev;
+   int src_pad_idx;/* For media-controller drivers */
struct v4l2_ctrl_handler ctrl_handler;
const struct soc_camera_format_xlate *current_fmt;
struct soc_camera_format_xlate *user_formats;
--
1.7.10.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


[PATCH 05/13] v4l: subdev: Add pad config allocator and init

2015-07-23 Thread William Towle
From: Laurent Pinchart laurent.pinch...@linaro.org

Add a new subdev operation to initialize a subdev pad config array, and
a helper function to allocate and initialize the array. This can be used
by bridge drivers to implement try format based on subdev pad
operations.

Signed-off-by: Laurent Pinchart laurent.pinch...@linaro.org
Acked-by: Vaibhav Hiremath vaibhav.hirem...@linaro.org
---
 drivers/media/v4l2-core/v4l2-subdev.c | 19 ++-
 include/media/v4l2-subdev.h   | 10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

Changes since v1:

- Added v4l2_subdev_free_pad_config
---
 drivers/media/v4l2-core/v4l2-subdev.c |   19 ++-
 include/media/v4l2-subdev.h   |   10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 83615b8..951a9cf 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -35,7 +35,7 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-   fh-pad = kzalloc(sizeof(*fh-pad) * sd-entity.num_pads, GFP_KERNEL);
+   fh-pad = v4l2_subdev_alloc_pad_config(sd);
if (fh-pad == NULL)
return -ENOMEM;
 #endif
@@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
sink, link, source_fmt, sink_fmt);
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd)
+{
+   struct v4l2_subdev_pad_config *cfg;
+
+   if (!sd-entity.num_pads)
+   return NULL;
+
+   cfg = kcalloc(sd-entity.num_pads, sizeof(*cfg), GFP_KERNEL);
+   if (!cfg)
+   return NULL;
+
+   v4l2_subdev_call(sd, pad, init_cfg, cfg);
+
+   return cfg;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops 
*ops)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 370fc38..a03b600 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -486,6 +486,8 @@ struct v4l2_subdev_pad_config {
  *  may be adjusted by the subdev driver to device 
capabilities.
  */
 struct v4l2_subdev_pad_ops {
+   void (*init_cfg)(struct v4l2_subdev *sd,
+struct v4l2_subdev_pad_config *cfg);
int (*enum_mbus_code)(struct v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_mbus_code_enum *code);
@@ -680,7 +682,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev 
*sd,
  struct v4l2_subdev_format *source_fmt,
  struct v4l2_subdev_format *sink_fmt);
 int v4l2_subdev_link_validate(struct media_link *link);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd);
+
+static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config 
*cfg)
+{
+   kfree(cfg);
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
+
 void v4l2_subdev_init(struct v4l2_subdev *sd,
  const struct v4l2_subdev_ops *ops);
 
-- 
1.7.10.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


[PATCH 04/13] media: adv7604: reduce support to first (digital) input

2015-07-23 Thread William Towle
Using adv7611_read_cable_det() for ADV7612 means that full
support for '.max_port = ADV7604_PAD_HDMI_PORT_B,' isn't available
due to the need for multiple port reads to determine cable detection,
and an agreed mechanism for communicating the separate statuses.

This patch replaces adv7611_read_cable_det() with a functionally
identical copy, commented appropriately.

Earlier submissions [leading to commit 8331d30b] also set .cp_csc,
which is used in a cp_read() call within adv76xx_log_status().

Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |   17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 0587d27..2524184 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -877,6 +877,16 @@ static unsigned int adv7611_read_cable_det(struct 
v4l2_subdev *sd)
return value  1;
 }
 
+static unsigned int adv7612_read_cable_det(struct v4l2_subdev *sd)
+{
+   /*  Reads CABLE_DET_A_RAW. For input B support, need to
+*  account for bit 7 [MSB] of 0x6a (ie. CABLE_DET_B_RAW)
+*/
+   u8 value = io_read(sd, 0x6f);
+
+   return value  1;
+}
+
 static int adv76xx_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd)
 {
struct adv76xx_state *state = to_state(sd);
@@ -2728,20 +2738,21 @@ static const struct adv76xx_chip_info 
adv76xx_chip_info[] = {
[ADV7612] = {
.type = ADV7612,
.has_afe = false,
-   .max_port = ADV7604_PAD_HDMI_PORT_B,
-   .num_dv_ports = 2,
+   .max_port = ADV76XX_PAD_HDMI_PORT_A,/* B not supported */
+   .num_dv_ports = 1,  /* normally 2 */
.edid_enable_reg = 0x74,
.edid_status_reg = 0x76,
.lcf_reg = 0xa3,
.tdms_lock_mask = 0x43,
.cable_det_mask = 0x01,
.fmt_change_digital_mask = 0x03,
+   .cp_csc = 0xf4,
.formats = adv7612_formats,
.nformats = ARRAY_SIZE(adv7612_formats),
.set_termination = adv7611_set_termination,
.setup_irqs = adv7612_setup_irqs,
.read_hdmi_pixelclock = adv7611_read_hdmi_pixelclock,
-   .read_cable_det = adv7611_read_cable_det,
+   .read_cable_det = adv7612_read_cable_det,
.recommended_settings = {
[1] = adv7612_recommended_settings_hdmi,
},
-- 
1.7.10.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


[PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support

2015-07-23 Thread William Towle
This adds V4L2_MBUS_FMT_RGB888_1X24 input format support
which is used by the ADV7612 chip.

Signed-off-by: Koji Matsuoka koji.matsuoka...@renesas.com
Signed-off-by: Simon Horman horms+rene...@verge.net.au
Signed-off-by: Yoshihiro Kaneko ykaneko0...@gmail.com

Modified to use MEDIA_BUS_FMT_* constants

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/soc_camera/rcar_vin.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index db7700b..16352a8 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -98,6 +98,7 @@
 #define VNMC_INF_YUV10_BT656   (2  16)
 #define VNMC_INF_YUV10_BT601   (3  16)
 #define VNMC_INF_YUV16 (5  16)
+#define VNMC_INF_RGB888(6  16)
 #define VNMC_VUP   (1  10)
 #define VNMC_IM_ODD(0  3)
 #define VNMC_IM_ODD_EVEN   (1  3)
@@ -589,7 +590,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
struct soc_camera_device *icd = priv-ici.icd;
struct rcar_vin_cam *cam = icd-host_priv;
u32 vnmc, dmr, interrupts;
-   bool progressive = false, output_is_yuv = false;
+   bool progressive = false, output_is_yuv = false, input_is_yuv = false;
 
switch (priv-field) {
case V4L2_FIELD_TOP:
@@ -623,16 +624,22 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
case MEDIA_BUS_FMT_YUYV8_1X16:
/* BT.601/BT.1358 16bit YCbCr422 */
vnmc |= VNMC_INF_YUV16;
+   input_is_yuv = true;
break;
case MEDIA_BUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
+   input_is_yuv = true;
+   break;
+   case MEDIA_BUS_FMT_RGB888_1X24:
+   vnmc |= VNMC_INF_RGB888;
break;
case MEDIA_BUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
+   input_is_yuv = true;
break;
default:
break;
@@ -676,7 +683,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
vnmc |= VNMC_VUP;
 
/* If input and output use the same colorspace, use bypass mode */
-   if (output_is_yuv)
+   if (input_is_yuv == output_is_yuv)
vnmc |= VNMC_BPS;
 
/* progressive or interlaced mode */
@@ -1423,6 +1430,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
case MEDIA_BUS_FMT_YUYV8_1X16:
case MEDIA_BUS_FMT_YUYV8_2X8:
case MEDIA_BUS_FMT_YUYV10_2X10:
+   case MEDIA_BUS_FMT_RGB888_1X24:
if (cam-extra_fmt)
break;
 
-- 
1.7.10.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


[PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt

2015-07-23 Thread William Towle
Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
the subdev set_fmt function - for the ADV7612, IDs should be non-zero.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 00c1034..dab729a 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1697,7 +1697,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
@@ -1706,6 +1706,10 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
int width, height;
int ret;
 
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+   if (pad_cfg == NULL)
+   return -ENOMEM;
+
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
xlate = icd-current_fmt;
@@ -1734,10 +1738,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
+   format.pad = icd-src_pad_idx;
ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
+pad, set_fmt, pad_cfg, format);
if (ret  0)
-   return ret;
+   goto cleanup;
 
/* Adjust only if VIN cannot scale */
if (pix-width  mf-width * 2)
@@ -1761,12 +1766,12 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-height = VIN_MAX_HEIGHT;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
client try_fmt() = %d\n, ret);
-   return ret;
+   goto cleanup;
}
}
/* We will scale exactly */
@@ -1776,6 +1781,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
pix-height = height;
}
 
+cleanup:
+   v4l2_subdev_free_pad_config(pad_cfg);
return ret;
 }
 
-- 
1.7.10.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


[PATCH 09/13] media: soc_camera: soc_scale_crop: Use correct pad number in try_fmt

2015-07-23 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Fix calls to subdev try_fmt function to use valid pad numbers, fixing
the case where subdevs (eg. ADV7612) have valid pad numbers that are
non-zero.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_scale_crop.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c 
b/drivers/media/platform/soc_camera/soc_scale_crop.c
index bda29bc..2772215 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -225,6 +225,7 @@ static int client_set_fmt(struct soc_camera_device *icd,
bool host_1to1;
int ret;
 
+   format-pad = icd-src_pad_idx;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd), pad,
 set_fmt, NULL, format);
-- 
1.7.10.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


[PATCH 02/13] ARM: shmobile: lager dts: specify default-input for ADV7612

2015-07-23 Thread William Towle
Set 'default-input' property for ADV7612. Enables image/video capture
without the need to have userspace specifying routing.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Tested-by: William Towle william.to...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index aec7db6..e537052 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -552,6 +552,7 @@
port {
hdmi_in_ep: endpoint {
remote-endpoint = vin0ep0;
+   default-input = 0;
};
};
};
-- 
1.7.10.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


HDMI and Composite capture on Lager, for kernel 4.1, version 5

2015-07-23 Thread William Towle
  Version 5. Some successful upstreaming and some further modification
means this obsoletes version 4, as seen at:

http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/92832

  This version of the patch series contains a fix for probing the
ADV7611/ADV7612 chips, a reduced (and renamed) chip info and formats
patch intended to pave the way for better ADV7612 support, and updates
to rcar_vin_try_fmt() in line with the latest feedback.

Cheers,
  Wills.

To follow:
[PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI
[PATCH 02/13] ARM: shmobile: lager dts: specify default-input for
[PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
[PATCH 04/13] media: adv7604: reduce support to first (digital)
[PATCH 05/13] v4l: subdev: Add pad config allocator and init
[PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
[PATCH 07/13] media: soc_camera pad-aware driver initialisation
[PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt
[PATCH 09/13] media: soc_camera: soc_scale_crop: Use correct pad
[PATCH 10/13] media: soc_camera: Fill std field in enum_input
[PATCH 11/13] media: soc_camera: Fix error reporting in expbuf
[PATCH 12/13] media: rcar_vin: fill in bus_info field
[PATCH 13/13] media: rcar_vin: Reject videobufs that are too small
--
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 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI input support

2015-07-23 Thread William Towle
Add DT entries for vin0, vin0_pins, and adv7612

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |   41 ++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index e02b523..aec7db6 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -378,7 +378,12 @@
renesas,function = usb2;
};
 
-   vin1_pins: vin {
+   vin0_pins: vin0 {
+   renesas,groups = vin0_data24, vin0_sync, vin0_field, 
vin0_clkenb, vin0_clk;
+   renesas,function = vin0;
+   };
+
+   vin1_pins: vin1 {
renesas,groups = vin1_data8, vin1_clk;
renesas,function = vin1;
};
@@ -539,6 +544,18 @@
reg = 0x12;
};
 
+   hdmi-in@4c {
+   compatible = adi,adv7612;
+   reg = 0x4c;
+   remote = vin0;
+
+   port {
+   hdmi_in_ep: endpoint {
+   remote-endpoint = vin0ep0;
+   };
+   };
+   };
+
composite-in@20 {
compatible = adi,adv7180;
reg = 0x20;
@@ -654,6 +671,28 @@
status = okay;
 };
 
+/* HDMI video input */
+vin0 {
+   pinctrl-0 = vin0_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin0ep0: endpoint {
+   remote-endpoint = hdmi_in_ep;
+   bus-width = 24;
+   hsync-active = 0;
+   vsync-active = 0;
+   pclk-sample = 1;
+   data-active = 1;
+   };
+   };
+};
+
 /* composite video input */
 vin1 {
pinctrl-0 = vin1_pins;
-- 
1.7.10.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


[PATCH 07/13] media: soc_camera pad-aware driver initialisation

2015-07-23 Thread William Towle
Add detection of source pad number for drivers aware of the media
controller API, so that the combination of soc_camera and rcar_vin
can create device nodes to support modern drivers such as adv7604.c
(for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/Kconfig  |1 +
 drivers/media/platform/soc_camera/rcar_vin.c   |1 +
 drivers/media/platform/soc_camera/soc_camera.c |   36 
 include/media/soc_camera.h |1 +
 4 files changed, 39 insertions(+)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index f2776cd..5c45c83 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN
depends on VIDEO_DEV  SOC_CAMERA
depends on ARCH_SHMOBILE || COMPILE_TEST
depends on HAS_DMA
+   depends on MEDIA_CONTROLLER
select VIDEOBUF2_DMA_CONTIG
select SOC_CAMERA_SCALE_CROP
---help---
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 16352a8..00c1034 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
struct device *dev = icd-parent;
int shift;
 
+   fmt.pad = icd-src_pad_idx;
ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
if (ret  0)
return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index d708df4..8d4d20c 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1293,6 +1293,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = fmt.format;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad pad;
+#endif
int ret;
 
sd-grp_id = soc_camera_grp_id(icd);
@@ -1310,8 +1313,33 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
return ret;
}
 
+   icd-src_pad_idx = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
/* At this point client .probe() should have run already */
+   ret = media_entity_init(icd-vdev-entity, 1, pad, 0);
+   if (ret  0) {
+   goto eusrfmt;
+   } else {
+   int pad_idx;
+
+   for (pad_idx = 0; pad_idx  sd-entity.num_pads; pad_idx++)
+   if (sd-entity.pads[pad_idx].flags
+   == MEDIA_PAD_FL_SOURCE)
+   break;
+   if (pad_idx = sd-entity.num_pads)
+   goto eusrfmt;
+
+   icd-src_pad_idx = pad_idx;
+   ret = soc_camera_init_user_formats(icd);
+   if (ret  0) {
+   icd-src_pad_idx = -1;
+   goto eusrfmt;
+   }
+   }
+#else
ret = soc_camera_init_user_formats(icd);
+#endif
+
if (ret  0)
goto eusrfmt;
 
@@ -1335,6 +1363,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
 evidstart:
soc_camera_free_user_formats(icd);
 eusrfmt:
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   media_entity_cleanup(icd-vdev-entity);
+#endif
soc_camera_remove_device(icd);
 
return ret;
@@ -1856,6 +1887,11 @@ static int soc_camera_remove(struct soc_camera_device 
*icd)
if (icd-num_user_formats)
soc_camera_free_user_formats(icd);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   if (icd-vdev-entity.num_pads)
+   media_entity_cleanup(icd-vdev-entity);
+#endif
+
if (icd-clk) {
/* For the synchronous case */
v4l2_clk_unregister(icd-clk);
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2f6261f..30193cf 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -42,6 +42,7 @@ struct soc_camera_device {
unsigned char devnum;   /* Device number per host */
struct soc_camera_sense *sense; /* See comment in struct definition */
struct video_device *vdev;
+   int src_pad_idx;/* For media-controller drivers */
struct v4l2_ctrl_handler ctrl_handler;
const struct soc_camera_format_xlate *current_fmt;
struct soc_camera_format_xlate *user_formats

[PATCH 13/13] media: rcar_vin: Reject videobufs that are too small for current format

2015-07-23 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

In videobuf_setup reject buffers that are too small for the configured
format. Fixes v4l2-compliance issue.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/soc_camera/rcar_vin.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 93e20d6..f4e611b 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -541,6 +541,9 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
unsigned int bytes_per_line;
int ret;
 
+   if (fmt-fmt.pix.sizeimage  icd-sizeimage)
+   return -EINVAL;
+
xlate = soc_camera_xlate_by_fourcc(icd,
   fmt-fmt.pix.pixelformat);
if (!xlate)
-- 
1.7.10.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


[PATCH 10/13] media: soc_camera: Fill std field in enum_input

2015-07-23 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Fill in the std field from the video_device tvnorms field in
enum_input.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 8d4d20c..7971388 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -309,11 +309,14 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, 
void *priv,
 static int soc_camera_enum_input(struct file *file, void *priv,
 struct v4l2_input *inp)
 {
+   struct soc_camera_device *icd = file-private_data;
+
if (inp-index != 0)
return -EINVAL;
 
/* default is camera */
inp-type = V4L2_INPUT_TYPE_CAMERA;
+   inp-std = icd-vdev-tvnorms;
strcpy(inp-name, Camera);
 
return 0;
-- 
1.7.10.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


[PATCH 11/13] media: soc_camera: Fix error reporting in expbuf

2015-07-23 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Remove unnecessary check and fix the error code for vb1 drivers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 7971388..bb181c1 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -470,14 +470,10 @@ static int soc_camera_expbuf(struct file *file, void 
*priv,
struct soc_camera_device *icd = file-private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
 
-   if (icd-streamer != file)
-   return -EBUSY;
-
/* videobuf2 only */
if (ici-ops-init_videobuf)
-   return -EINVAL;
-   else
-   return vb2_expbuf(icd-vb2_vidq, p);
+   return -ENOTTY;
+   return vb2_expbuf(icd-vb2_vidq, p);
 }
 
 /* Always entered with .host_lock held */
-- 
1.7.10.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


[PATCH 12/13] media: rcar_vin: fill in bus_info field

2015-07-23 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Adapt rcar_vin_querycap() so that cap-bus_info is populated with
something meaningful/unique.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index dab729a..93e20d6 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1799,6 +1799,7 @@ static int rcar_vin_querycap(struct soc_camera_host *ici,
strlcpy(cap-card, R_Car_VIN, sizeof(cap-card));
cap-device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
+   snprintf(cap-bus_info, sizeof(cap-bus_info), platform:%s%d, 
DRV_NAME, ici-nr);
 
return 0;
 }
-- 
1.7.10.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


[PATCH 03/13] media: adv7604: fix probe of ADV7611/7612

2015-07-23 Thread William Towle
Prior to commit f862f57d ([media] media: i2c: ADV7604: Migrate to
regmap), the local variable 'val' contained the combined register
reads used in the chipset version ID test. Restore this expectation
so that the comparison works as it used to.
---
 drivers/media/i2c/adv7604.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index bfb0b6a..0587d27 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3108,7 +3108,7 @@ static int adv76xx_probe(struct i2c_client *client,
v4l2_err(sd, Error %d reading IO Regmap\n, err);
return -ENODEV;
}
-   val2 |= val;
+   val |= val2;
if ((state-info-type == ADV7611  val != 0x2051) ||
(state-info-type == ADV7612  val != 0x2041)) {
v4l2_err(sd, not an adv761x on address 0x%x\n,
-- 
1.7.10.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


[PATCH 09/15] media: soc_camera pad-aware driver initialisation

2015-06-25 Thread William Towle
Add detection of source pad number for drivers aware of the media
controller API, so that the combination of soc_camera and rcar_vin
can create device nodes to support modern drivers such as adv7604.c
(for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/Kconfig  |1 +
 drivers/media/platform/soc_camera/rcar_vin.c   |1 +
 drivers/media/platform/soc_camera/soc_camera.c |   36 
 include/media/soc_camera.h |1 +
 4 files changed, 39 insertions(+)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index f2776cd..5c45c83 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN
depends on VIDEO_DEV  SOC_CAMERA
depends on ARCH_SHMOBILE || COMPILE_TEST
depends on HAS_DMA
+   depends on MEDIA_CONTROLLER
select VIDEOBUF2_DMA_CONTIG
select SOC_CAMERA_SCALE_CROP
---help---
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 16352a8..00c1034 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
struct device *dev = icd-parent;
int shift;
 
+   fmt.pad = icd-src_pad_idx;
ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
if (ret  0)
return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index d708df4..8d4d20c 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1293,6 +1293,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = fmt.format;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad pad;
+#endif
int ret;
 
sd-grp_id = soc_camera_grp_id(icd);
@@ -1310,8 +1313,33 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
return ret;
}
 
+   icd-src_pad_idx = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
/* At this point client .probe() should have run already */
+   ret = media_entity_init(icd-vdev-entity, 1, pad, 0);
+   if (ret  0) {
+   goto eusrfmt;
+   } else {
+   int pad_idx;
+
+   for (pad_idx = 0; pad_idx  sd-entity.num_pads; pad_idx++)
+   if (sd-entity.pads[pad_idx].flags
+   == MEDIA_PAD_FL_SOURCE)
+   break;
+   if (pad_idx = sd-entity.num_pads)
+   goto eusrfmt;
+
+   icd-src_pad_idx = pad_idx;
+   ret = soc_camera_init_user_formats(icd);
+   if (ret  0) {
+   icd-src_pad_idx = -1;
+   goto eusrfmt;
+   }
+   }
+#else
ret = soc_camera_init_user_formats(icd);
+#endif
+
if (ret  0)
goto eusrfmt;
 
@@ -1335,6 +1363,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
 evidstart:
soc_camera_free_user_formats(icd);
 eusrfmt:
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   media_entity_cleanup(icd-vdev-entity);
+#endif
soc_camera_remove_device(icd);
 
return ret;
@@ -1856,6 +1887,11 @@ static int soc_camera_remove(struct soc_camera_device 
*icd)
if (icd-num_user_formats)
soc_camera_free_user_formats(icd);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   if (icd-vdev-entity.num_pads)
+   media_entity_cleanup(icd-vdev-entity);
+#endif
+
if (icd-clk) {
/* For the synchronous case */
v4l2_clk_unregister(icd-clk);
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2f6261f..30193cf 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -42,6 +42,7 @@ struct soc_camera_device {
unsigned char devnum;   /* Device number per host */
struct soc_camera_sense *sense; /* See comment in struct definition */
struct video_device *vdev;
+   int src_pad_idx;/* For media-controller drivers */
struct v4l2_ctrl_handler ctrl_handler;
const struct soc_camera_format_xlate *current_fmt;
struct soc_camera_format_xlate *user_formats

[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-06-25 Thread William Towle
Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
the subdev set_fmt function - for the ADV7612, IDs should be non-zero.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 00c1034..1023c5b 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1697,14 +1697,18 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
struct v4l2_mbus_framefmt *mf = format.format;
__u32 pixfmt = pix-pixelformat;
int width, height;
-   int ret;
+   int ret= -ENOMEM;
+
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+   if (pad_cfg == NULL)
+   goto out;
 
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
@@ -1734,10 +1738,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
+   format.pad = icd-src_pad_idx;
ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
+pad, set_fmt, pad_cfg, format);
if (ret  0)
-   return ret;
+   goto cleanup;
 
/* Adjust only if VIN cannot scale */
if (pix-width  mf-width * 2)
@@ -1761,12 +1766,12 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-height = VIN_MAX_HEIGHT;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
client try_fmt() = %d\n, ret);
-   return ret;
+   goto cleanup;
}
}
/* We will scale exactly */
@@ -1776,6 +1781,9 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
pix-height = height;
}
 
+cleanup:
+   v4l2_subdev_free_pad_config(pad_cfg);
+out:
return ret;
 }
 
-- 
1.7.10.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


[PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support

2015-06-25 Thread William Towle
This adds V4L2_MBUS_FMT_RGB888_1X24 input format support
which is used by the ADV7612 chip.

Signed-off-by: Koji Matsuoka koji.matsuoka...@renesas.com
Signed-off-by: Simon Horman horms+rene...@verge.net.au
Signed-off-by: Yoshihiro Kaneko ykaneko0...@gmail.com

Modified to use MEDIA_BUS_FMT_* constants

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/soc_camera/rcar_vin.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index db7700b..16352a8 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -98,6 +98,7 @@
 #define VNMC_INF_YUV10_BT656   (2  16)
 #define VNMC_INF_YUV10_BT601   (3  16)
 #define VNMC_INF_YUV16 (5  16)
+#define VNMC_INF_RGB888(6  16)
 #define VNMC_VUP   (1  10)
 #define VNMC_IM_ODD(0  3)
 #define VNMC_IM_ODD_EVEN   (1  3)
@@ -589,7 +590,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
struct soc_camera_device *icd = priv-ici.icd;
struct rcar_vin_cam *cam = icd-host_priv;
u32 vnmc, dmr, interrupts;
-   bool progressive = false, output_is_yuv = false;
+   bool progressive = false, output_is_yuv = false, input_is_yuv = false;
 
switch (priv-field) {
case V4L2_FIELD_TOP:
@@ -623,16 +624,22 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
case MEDIA_BUS_FMT_YUYV8_1X16:
/* BT.601/BT.1358 16bit YCbCr422 */
vnmc |= VNMC_INF_YUV16;
+   input_is_yuv = true;
break;
case MEDIA_BUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
+   input_is_yuv = true;
+   break;
+   case MEDIA_BUS_FMT_RGB888_1X24:
+   vnmc |= VNMC_INF_RGB888;
break;
case MEDIA_BUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
+   input_is_yuv = true;
break;
default:
break;
@@ -676,7 +683,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
vnmc |= VNMC_VUP;
 
/* If input and output use the same colorspace, use bypass mode */
-   if (output_is_yuv)
+   if (input_is_yuv == output_is_yuv)
vnmc |= VNMC_BPS;
 
/* progressive or interlaced mode */
@@ -1423,6 +1430,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
case MEDIA_BUS_FMT_YUYV8_1X16:
case MEDIA_BUS_FMT_YUYV8_2X8:
case MEDIA_BUS_FMT_YUYV10_2X10:
+   case MEDIA_BUS_FMT_RGB888_1X24:
if (cam-extra_fmt)
break;
 
-- 
1.7.10.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


[PATCH 07/15] ARM: shmobile: lager dts: specify default-input for ADV7612

2015-06-25 Thread William Towle
Set 'default-input' property for ADV7612. Enables image/video capture
without the need to have userspace specifying routing.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Tested-by: William Towle william.to...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index d381e99..be3b3c6 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -552,6 +552,7 @@
port {
hdmi_in_ep: endpoint {
remote-endpoint = vin0ep0;
+   default-input = 0;
};
};
};
-- 
1.7.10.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


[PATCH 04/15] media: adv7604: chip info and formats for ADV7612

2015-06-25 Thread William Towle
Add support for the ADV7612 chip as implemented on Renesas' Lager
board to adv7604.c, including lists for formats/colourspace/timing
selection and an IRQ handler.

Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |  102 +--
 1 file changed, 98 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 808360f..ebeddd5 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -81,6 +81,7 @@ MODULE_LICENSE(GPL);
 enum adv76xx_type {
ADV7604,
ADV7611,
+   ADV7612,
 };
 
 struct adv76xx_reg_seq {
@@ -766,6 +767,23 @@ static const struct adv76xx_format_info adv7611_formats[] 
= {
  ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_12BIT },
 };
 
+static const struct adv76xx_format_info adv7612_formats[] = {
+   { MEDIA_BUS_FMT_RGB888_1X24, ADV76XX_OP_CH_SEL_RGB, true, false,
+ ADV76XX_OP_MODE_SEL_SDR_444 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YUYV8_2X8, ADV76XX_OP_CH_SEL_RGB, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YVYU8_2X8, ADV76XX_OP_CH_SEL_RGB, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_UYVY8_1X16, ADV76XX_OP_CH_SEL_RBG, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_VYUY8_1X16, ADV76XX_OP_CH_SEL_RBG, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YUYV8_1X16, ADV76XX_OP_CH_SEL_RGB, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YVYU8_1X16, ADV76XX_OP_CH_SEL_RGB, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+};
+
 static const struct adv76xx_format_info *
 adv76xx_format_info(struct adv76xx_state *state, u32 code)
 {
@@ -870,6 +888,16 @@ static unsigned int adv7611_read_cable_det(struct 
v4l2_subdev *sd)
return value  1;
 }
 
+static unsigned int adv7612_read_cable_det(struct v4l2_subdev *sd)
+{
+   /*  Reads CABLE_DET_A_RAW. For input B support, need to
+*  account for bit 7 [MSB] of 0x6a (ie. CABLE_DET_B_RAW)
+*/
+   u8 value = io_read(sd, 0x6f);
+
+   return value  1;
+}
+
 static int adv76xx_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd)
 {
struct adv76xx_state *state = to_state(sd);
@@ -2510,6 +2538,11 @@ static void adv7611_setup_irqs(struct v4l2_subdev *sd)
io_write(sd, 0x41, 0xd0); /* STDI irq for any change, disable INT2 */
 }
 
+static void adv7612_setup_irqs(struct v4l2_subdev *sd)
+{
+   io_write(sd, 0x41, 0xd0); /* disable INT2 */
+}
+
 static void adv76xx_unregister_clients(struct adv76xx_state *state)
 {
unsigned int i;
@@ -2597,6 +2630,19 @@ static const struct adv76xx_reg_seq 
adv7611_recommended_settings_hdmi[] = {
{ ADV76XX_REG_SEQ_TERM, 0 },
 };
 
+static const struct adv76xx_reg_seq adv7612_recommended_settings_hdmi[] = {
+   { ADV76XX_REG(ADV76XX_PAGE_CP, 0x6c), 0x00 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x9b), 0x03 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x6f), 0x08 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x85), 0x1f },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x87), 0x70 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x57), 0xda },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x58), 0x01 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x03), 0x98 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x4c), 0x44 },
+   { ADV76XX_REG_SEQ_TERM, 0 },
+};
+
 static const struct adv76xx_chip_info adv76xx_chip_info[] = {
[ADV7604] = {
.type = ADV7604,
@@ -2685,17 +2731,60 @@ static const struct adv76xx_chip_info 
adv76xx_chip_info[] = {
.field1_vsync_mask = 0x3fff,
.field1_vbackporch_mask = 0x3fff,
},
+   [ADV7612] = {
+   .type = ADV7612,
+   .has_afe = false,
+   .max_port = ADV76XX_PAD_HDMI_PORT_A,/* B not supported */
+   .num_dv_ports = 1,  /* normally 2 */
+   .edid_enable_reg = 0x74,
+   .edid_status_reg = 0x76,
+   .lcf_reg = 0xa3,
+   .tdms_lock_mask = 0x43,
+   .cable_det_mask = 0x01,
+   .fmt_change_digital_mask = 0x03,
+   .cp_csc = 0xf4,
+   .formats = adv7612_formats,
+   .nformats = ARRAY_SIZE(adv7612_formats),
+   .set_termination = adv7611_set_termination,
+   .setup_irqs = adv7612_setup_irqs,
+   .read_hdmi_pixelclock = adv7611_read_hdmi_pixelclock,
+   .read_cable_det = adv7612_read_cable_det,
+   .recommended_settings = {
+   [1] = adv7612_recommended_settings_hdmi

[PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI input support

2015-06-25 Thread William Towle
Add DT entries for vin0, vin0_pins, and adv7612

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |   41 ++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 10b3426..d381e99 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -378,7 +378,12 @@
renesas,function = usb2;
};
 
-   vin1_pins: vin {
+   vin0_pins: vin0 {
+   renesas,groups = vin0_data24, vin0_sync, vin0_field, 
vin0_clkenb, vin0_clk;
+   renesas,function = vin0;
+   };
+
+   vin1_pins: vin1 {
renesas,groups = vin1_data8, vin1_clk;
renesas,function = vin1;
};
@@ -539,6 +544,18 @@
reg = 0x12;
};
 
+   hdmi-in@4c {
+   compatible = adi,adv7612;
+   reg = 0x4c;
+   remote = vin0;
+
+   port {
+   hdmi_in_ep: endpoint {
+   remote-endpoint = vin0ep0;
+   };
+   };
+   };
+
composite-in@20 {
compatible = adi,adv7180;
reg = 0x20;
@@ -654,6 +671,28 @@
status = okay;
 };
 
+/* HDMI video input */
+vin0 {
+   pinctrl-0 = vin0_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin0ep0: endpoint {
+   remote-endpoint = hdmi_in_ep;
+   bus-width = 24;
+   hsync-active = 0;
+   vsync-active = 0;
+   pclk-sample = 1;
+   data-active = 1;
+   };
+   };
+};
+
 /* composite video input */
 vin1 {
pinctrl-0 = vin1_pins;
-- 
1.7.10.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


[PATCH 03/15] media: adv7180: add of match table

2015-06-25 Thread William Towle
From: Ben Dooks ben.do...@codethink.co.uk

Add a proper of match id for use when the device is being bound via
device tree, to avoid having to use the i2c old-style binding of the
device.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
Signed-off-by: William.Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/adv7180.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index a493c0b..09a96df 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -25,6 +25,7 @@
 #include linux/interrupt.h
 #include linux/i2c.h
 #include linux/slab.h
+#include linux/of.h
 #include media/v4l2-ioctl.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
@@ -1324,11 +1325,21 @@ static SIMPLE_DEV_PM_OPS(adv7180_pm_ops, 
adv7180_suspend, adv7180_resume);
 #define ADV7180_PM_OPS NULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id adv7180_of_id[] = {
+   { .compatible = adi,adv7180, },
+   { },
+};
+
+MODULE_DEVICE_TABLE(of, adv7180_of_id);
+#endif
+
 static struct i2c_driver adv7180_driver = {
.driver = {
   .owner = THIS_MODULE,
   .name = KBUILD_MODNAME,
   .pm = ADV7180_PM_OPS,
+  .of_match_table = of_match_ptr(adv7180_of_id),
   },
.probe = adv7180_probe,
.remove = adv7180_remove,
-- 
1.7.10.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


HDMI and Composite capture on Lager, for kernel 4.1, version 4

2015-06-25 Thread William Towle

  Version 4. Obsoletes version 3, as seen at:

http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/91931

  This version has the bus_info field set in rcar_vin.c, where the
value used can be constructed uniquely. Elsewhere a number of small
optimisations have been made, and some redundant initialisation code
has been removed.

To follow:
[PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI
[PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
[PATCH 03/15] media: adv7180: add of match table
[PATCH 04/15] media: adv7604: chip info and formats for ADV7612
[PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI
[PATCH 06/15] media: adv7604: ability to read default input port
[PATCH 07/15] ARM: shmobile: lager dts: specify default-input for
[PATCH 08/15] v4l: subdev: Add pad config allocator and init
[PATCH 09/15] media: soc_camera pad-aware driver initialisation
[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt
[PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad
[PATCH 12/15] media: soc_camera: Fill std field in enum_input
[PATCH 13/15] media: soc_camera: Fix error reporting in expbuf
[PATCH 14/15] media: rcar_vin: fill in bus_info field
[PATCH 15/15] media: rcar_vin: Reject videobufs that are too small

Cheers,
  Wills.
--
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 08/15] v4l: subdev: Add pad config allocator and init

2015-06-25 Thread William Towle
From: Laurent Pinchart laurent.pinch...@linaro.org

Add a new subdev operation to initialize a subdev pad config array, and
a helper function to allocate and initialize the array. This can be used
by bridge drivers to implement try format based on subdev pad
operations.

Signed-off-by: Laurent Pinchart laurent.pinch...@linaro.org
Acked-by: Vaibhav Hiremath vaibhav.hirem...@linaro.org
---
 drivers/media/v4l2-core/v4l2-subdev.c | 19 ++-
 include/media/v4l2-subdev.h   | 10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

Changes since v1:

- Added v4l2_subdev_free_pad_config
---
 drivers/media/v4l2-core/v4l2-subdev.c |   19 ++-
 include/media/v4l2-subdev.h   |   10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 6359606..d594fe5 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -35,7 +35,7 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-   fh-pad = kzalloc(sizeof(*fh-pad) * sd-entity.num_pads, GFP_KERNEL);
+   fh-pad = v4l2_subdev_alloc_pad_config(sd);
if (fh-pad == NULL)
return -ENOMEM;
 #endif
@@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
sink, link, source_fmt, sink_fmt);
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd)
+{
+   struct v4l2_subdev_pad_config *cfg;
+
+   if (!sd-entity.num_pads)
+   return NULL;
+
+   cfg = kcalloc(sd-entity.num_pads, sizeof(*cfg), GFP_KERNEL);
+   if (!cfg)
+   return NULL;
+
+   v4l2_subdev_call(sd, pad, init_cfg, cfg);
+
+   return cfg;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops 
*ops)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index dc20102..4a609f6 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -485,6 +485,8 @@ struct v4l2_subdev_pad_config {
  *  may be adjusted by the subdev driver to device 
capabilities.
  */
 struct v4l2_subdev_pad_ops {
+   void (*init_cfg)(struct v4l2_subdev *sd,
+struct v4l2_subdev_pad_config *cfg);
int (*enum_mbus_code)(struct v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_mbus_code_enum *code);
@@ -677,7 +679,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev 
*sd,
  struct v4l2_subdev_format *source_fmt,
  struct v4l2_subdev_format *sink_fmt);
 int v4l2_subdev_link_validate(struct media_link *link);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd);
+
+static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config 
*cfg)
+{
+   kfree(cfg);
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
+
 void v4l2_subdev_init(struct v4l2_subdev *sd,
  const struct v4l2_subdev_ops *ops);
 
-- 
1.7.10.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


[PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI input decoder

2015-06-25 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

This documentation accompanies the patch adding support for the ADV7612
dual HDMI decoder / repeater chip.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 .../devicetree/bindings/media/i2c/adv7604.txt|   18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index c27cede..7eafdbc 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -1,15 +1,17 @@
-* Analog Devices ADV7604/11 video decoder with HDMI receiver
+* Analog Devices ADV7604/11/12 video decoder with HDMI receiver
 
-The ADV7604 and ADV7611 are multiformat video decoders with an integrated HDMI
-receiver. The ADV7604 has four multiplexed HDMI inputs and one analog input,
-and the ADV7611 has one HDMI input and no analog input.
+The ADV7604 and ADV7611/12 are multiformat video decoders with an integrated
+HDMI receiver. The ADV7604 has four multiplexed HDMI inputs and one analog
+input, and the ADV7611 has one HDMI input and no analog input. The 7612 is
+similar to the 7611 but has 2 HDMI inputs.
 
-These device tree bindings support the ADV7611 only at the moment.
+These device tree bindings support the ADV7611/12 only at the moment.
 
 Required Properties:
 
   - compatible: Must contain one of the following
 - adi,adv7611 for the ADV7611
+- adi,adv7612 for the ADV7612
 
   - reg: I2C slave address
 
@@ -22,10 +24,10 @@ port, in accordance with the video interface bindings 
defined in
 Documentation/devicetree/bindings/media/video-interfaces.txt. The port nodes
 are numbered as follows.
 
-  Port ADV7611
+  Port ADV7611ADV7612
 
-  HDMI 0
-  Digital output   1
+  HDMI 0 0, 1
+  Digital output   12
 
 The digital output port node must contain at least one endpoint.
 
-- 
1.7.10.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


[PATCH 12/15] media: soc_camera: Fill std field in enum_input

2015-06-25 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Fill in the std field from the video_device tvnorms field in
enum_input.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 8d4d20c..7971388 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -309,11 +309,14 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, 
void *priv,
 static int soc_camera_enum_input(struct file *file, void *priv,
 struct v4l2_input *inp)
 {
+   struct soc_camera_device *icd = file-private_data;
+
if (inp-index != 0)
return -EINVAL;
 
/* default is camera */
inp-type = V4L2_INPUT_TYPE_CAMERA;
+   inp-std = icd-vdev-tvnorms;
strcpy(inp-name, Camera);
 
return 0;
-- 
1.7.10.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


[PATCH 13/15] media: soc_camera: Fix error reporting in expbuf

2015-06-25 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Remove unnecessary check and fix the error code for vb1 drivers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 7971388..bb181c1 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -470,14 +470,10 @@ static int soc_camera_expbuf(struct file *file, void 
*priv,
struct soc_camera_device *icd = file-private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
 
-   if (icd-streamer != file)
-   return -EBUSY;
-
/* videobuf2 only */
if (ici-ops-init_videobuf)
-   return -EINVAL;
-   else
-   return vb2_expbuf(icd-vb2_vidq, p);
+   return -ENOTTY;
+   return vb2_expbuf(icd-vb2_vidq, p);
 }
 
 /* Always entered with .host_lock held */
-- 
1.7.10.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


[PATCH 15/15] media: rcar_vin: Reject videobufs that are too small for current format

2015-06-25 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

In videobuf_setup reject buffers that are too small for the configured
format. Fixes v4l2-compliance issue.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/soc_camera/rcar_vin.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 20f690d..75f5ad0 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -541,6 +541,9 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
unsigned int bytes_per_line;
int ret;
 
+   if (fmt-fmt.pix.sizeimage  icd-sizeimage)
+   return -EINVAL;
+
xlate = soc_camera_xlate_by_fourcc(icd,
   fmt-fmt.pix.pixelformat);
if (!xlate)
-- 
1.7.10.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


[PATCH 14/15] media: rcar_vin: fill in bus_info field

2015-06-25 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Adapt rcar_vin_querycap() so that cap-bus_info is populated with
something meaningful/unique.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 1023c5b..20f690d 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1800,6 +1800,7 @@ static int rcar_vin_querycap(struct soc_camera_host *ici,
strlcpy(cap-card, R_Car_VIN, sizeof(cap-card));
cap-device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
+   snprintf(cap-bus_info, sizeof(cap-bus_info), platform:%s%d, 
DRV_NAME, ici-nr);
 
return 0;
 }
-- 
1.7.10.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


[PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad number in try_fmt

2015-06-25 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Fix calls to subdev try_fmt function to use valid pad numbers, fixing
the case where subdevs (eg. ADV7612) have valid pad numbers that are
non-zero.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_scale_crop.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c 
b/drivers/media/platform/soc_camera/soc_scale_crop.c
index bda29bc..2772215 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -225,6 +225,7 @@ static int client_set_fmt(struct soc_camera_device *icd,
bool host_1to1;
int ret;
 
+   format-pad = icd-src_pad_idx;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd), pad,
 set_fmt, NULL, format);
-- 
1.7.10.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


[PATCH 06/15] media: adv7604: ability to read default input port from DT

2015-06-25 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

Adds support to the adv7604 driver for specifying the default input
port in the Device tree. If no value is provided, the driver will be
unable to select an input without help from userspace.

Tested-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/devicetree/bindings/media/i2c/adv7604.txt |3 +++
 drivers/media/i2c/adv7604.c |8 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index 7eafdbc..8337f75 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -47,6 +47,7 @@ Optional Endpoint Properties:
   If none of hsync-active, vsync-active and pclk-sample is specified the
   endpoint will use embedded BT.656 synchronization.
 
+  - default-input: Select which input is selected after reset.
 
 Example:
 
@@ -60,6 +61,8 @@ Example:
#address-cells = 1;
#size-cells = 0;
 
+   default-input = 0;
+
port@0 {
reg = 0;
};
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index ebeddd5..2a89b91 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2795,6 +2795,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
struct device_node *endpoint;
struct device_node *np;
unsigned int flags;
+   u32 v;
 
np = state-i2c_clients[ADV76XX_PAGE_IO]-dev.of_node;
 
@@ -2804,6 +2805,12 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
return -EINVAL;
 
v4l2_of_parse_endpoint(endpoint, bus_cfg);
+
+   if (!of_property_read_u32(endpoint, default-input, v))
+   state-pdata.default_input = v;
+   else
+   state-pdata.default_input = -1;
+
of_node_put(endpoint);
 
flags = bus_cfg.bus.parallel.flags;
@@ -2842,7 +2849,6 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
/* Hardcode the remaining platform data fields. */
state-pdata.disable_pwrdnb = 0;
state-pdata.disable_cable_det_rst = 0;
-   state-pdata.default_input = -1;
state-pdata.blank_data = 1;
state-pdata.alt_data_sat = 1;
state-pdata.op_format_mode_sel = ADV7604_OP_FORMAT_MODE0;
-- 
1.7.10.4

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


Re: HDMI and Composite capture on Lager, for kernel 4.1, version 3

2015-06-22 Thread William Towle


Hi Hans,

I'm not sure if I've asked this before, but shouldn't soc-camera be extended
with support for the DV_TIMINGS ioctls in order to control the adv7604?

It's peculiar that that is not included in this patch series...


  Rob tells me he did some work on this, but we don't have it passing
muster with v4l2-compliance and since gstreamer tries a number of
resolutions of its own accord and subsequently produces images and
video without it we can make do without for our needs. I can include it
in or alongside the next submission if you'd to see it.


  Regarding your other comments, in particular the specification of the
following:
.tdms_lock_mask = 0x43,
.cable_det_mask = 0x01,
...when testing just the first input, these seem reasonable - in the
case of tdms_lock_mask the two least significant bits represent
V_LOCKED_RAW and DE_REGEN_LCK_RAW, and they are set in line with
the value of TDMSPLL_LCK_A_RAW when queried.

  While an implementation suitable for testing both of the ADV7612's
A and B inputs could just add TDMSPLL_LCK_B_RAW to tdms_lock mask,
the cable detect function isn't so trivial: it would need to query two
separate (and numerically non-adjacent) registers to do its job.

  For simplicity we would like to propose that our next iteration
supports just the first input (which is sufficient for our current
needs) and has commentary in appropriate places regarding its
shortcomings, although we're open to alternative suggestions if there
has already been discussion on the matter here.

Cheers,
  Wills.
--
To unsubscribe from this list: send the line unsubscribe linux-media in


[PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad number in try_fmt

2015-06-03 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Fix calls to subdev try_fmt to use correct pad. Fixes failures with
subdevs that care about having the right pad number set.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_scale_crop.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c 
b/drivers/media/platform/soc_camera/soc_scale_crop.c
index bda29bc..90e2769 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -225,6 +225,10 @@ static int client_set_fmt(struct soc_camera_device *icd,
bool host_1to1;
int ret;
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   format-pad = icd-src_pad_idx;
+#endif
+
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd), pad,
 set_fmt, NULL, format);
@@ -261,10 +265,16 @@ static int client_set_fmt(struct soc_camera_device *icd,
/* width = max_width  height = max_height - guaranteed by try_fmt */
while ((width  tmp_w || height  tmp_h) 
   tmp_w  max_width  tmp_h  max_height) {
+
tmp_w = min(2 * tmp_w, max_width);
tmp_h = min(2 * tmp_h, max_height);
mf-width = tmp_w;
mf-height = tmp_h;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   format-pad = icd-src_pad_idx;
+#endif
+
ret = v4l2_device_call_until_err(sd-v4l2_dev,
soc_camera_grp_id(icd), pad,
set_fmt, NULL, format);
-- 
1.7.10.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


[PATCH 09/15] media: soc_camera pad-aware driver initialisation

2015-06-03 Thread William Towle
Add detection of source pad number for drivers aware of the media
controller API, so that the combination of soc_camera and rcar_vin
can create device nodes to support modern drivers such as adv7604.c
(for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/Kconfig  |1 +
 drivers/media/platform/soc_camera/rcar_vin.c   |1 +
 drivers/media/platform/soc_camera/soc_camera.c |   46 
 include/media/soc_camera.h |1 +
 4 files changed, 49 insertions(+)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index f2776cd..5c45c83 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN
depends on VIDEO_DEV  SOC_CAMERA
depends on ARCH_SHMOBILE || COMPILE_TEST
depends on HAS_DMA
+   depends on MEDIA_CONTROLLER
select VIDEOBUF2_DMA_CONTIG
select SOC_CAMERA_SCALE_CROP
---help---
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 16352a8..00c1034 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
struct device *dev = icd-parent;
int shift;
 
+   fmt.pad = icd-src_pad_idx;
ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
if (ret  0)
return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index d708df4..c4952c8 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1293,6 +1293,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = fmt.format;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad pad;
+#endif
int ret;
 
sd-grp_id = soc_camera_grp_id(icd);
@@ -1310,8 +1313,40 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
return ret;
}
 
+   icd-src_pad_idx = -1;
+#if defined(CONFIG_MEDIA_CONTROLLER)
/* At this point client .probe() should have run already */
+   ret = media_entity_init(icd-vdev-entity, 1, pad, 0);
+   if (ret  0) {
+   goto eusrfmt;
+   } else {
+   int pad_idx;
+
+   for (pad_idx = 0; pad_idx  sd-entity.num_pads; pad_idx++)
+   if (sd-entity.pads[pad_idx].flags
+   == MEDIA_PAD_FL_SOURCE)
+   break;
+   if (pad_idx = sd-entity.num_pads)
+   goto eusrfmt;
+
+   ret = media_entity_create_link(icd-vdev-entity, 0,
+   sd-entity, pad_idx,
+   MEDIA_LNK_FL_IMMUTABLE |
+   MEDIA_LNK_FL_ENABLED);
+   if (ret  0)
+   goto eusrfmt;
+
+   icd-src_pad_idx = pad_idx;
+   ret = soc_camera_init_user_formats(icd);
+   if (ret  0) {
+   icd-src_pad_idx = -1;
+   goto eusrfmt;
+   }
+   }
+#else
ret = soc_camera_init_user_formats(icd);
+#endif
+
if (ret  0)
goto eusrfmt;
 
@@ -1322,6 +1357,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
goto evidstart;
 
/* Try to improve our guess of a reasonable window format */
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   fmt.pad = icd-src_pad_idx;
+#endif
if (!v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt)) {
icd-user_width = mf-width;
icd-user_height= mf-height;
@@ -1335,6 +1373,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
 evidstart:
soc_camera_free_user_formats(icd);
 eusrfmt:
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   media_entity_cleanup(icd-vdev-entity);
+#endif
soc_camera_remove_device(icd);
 
return ret;
@@ -1856,6 +1897,11 @@ static int soc_camera_remove(struct soc_camera_device 
*icd)
if (icd-num_user_formats)
soc_camera_free_user_formats(icd);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   if (icd-vdev-entity.num_pads

[PATCH 04/15] media: adv7604: chip info and formats for ADV7612

2015-06-03 Thread William Towle
Add support for the ADV7612 chip as implemented on Renesas' Lager
board to adv7604.c, including lists for formats/colourspace/timing
selection and an IRQ handler.

Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |   91 +--
 1 file changed, 87 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index aaa37b0..16646517 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -80,6 +80,7 @@ MODULE_LICENSE(GPL);
 enum adv76xx_type {
ADV7604,
ADV7611,
+   ADV7612,
 };
 
 struct adv76xx_reg_seq {
@@ -758,6 +759,23 @@ static const struct adv76xx_format_info adv7611_formats[] 
= {
  ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_12BIT },
 };
 
+static const struct adv76xx_format_info adv7612_formats[] = {
+   { MEDIA_BUS_FMT_RGB888_1X24, ADV76XX_OP_CH_SEL_RGB, true, false,
+ ADV76XX_OP_MODE_SEL_SDR_444 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YUYV8_2X8, ADV76XX_OP_CH_SEL_RGB, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YVYU8_2X8, ADV76XX_OP_CH_SEL_RGB, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_UYVY8_1X16, ADV76XX_OP_CH_SEL_RBG, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_VYUY8_1X16, ADV76XX_OP_CH_SEL_RBG, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YUYV8_1X16, ADV76XX_OP_CH_SEL_RGB, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YVYU8_1X16, ADV76XX_OP_CH_SEL_RGB, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+};
+
 static const struct adv76xx_format_info *
 adv76xx_format_info(struct adv76xx_state *state, u32 code)
 {
@@ -2471,6 +2489,11 @@ static void adv7611_setup_irqs(struct v4l2_subdev *sd)
io_write(sd, 0x41, 0xd0); /* STDI irq for any change, disable INT2 */
 }
 
+static void adv7612_setup_irqs(struct v4l2_subdev *sd)
+{
+   io_write(sd, 0x41, 0xd0); /* disable INT2 */
+}
+
 static void adv76xx_unregister_clients(struct adv76xx_state *state)
 {
unsigned int i;
@@ -2558,6 +2581,19 @@ static const struct adv76xx_reg_seq 
adv7611_recommended_settings_hdmi[] = {
{ ADV76XX_REG_SEQ_TERM, 0 },
 };
 
+static const struct adv76xx_reg_seq adv7612_recommended_settings_hdmi[] = {
+   { ADV76XX_REG(ADV76XX_PAGE_CP, 0x6c), 0x00 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x9b), 0x03 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x6f), 0x08 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x85), 0x1f },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x87), 0x70 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x57), 0xda },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x58), 0x01 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x03), 0x98 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x4c), 0x44 },
+   { ADV76XX_REG_SEQ_TERM, 0 },
+};
+
 static const struct adv76xx_chip_info adv76xx_chip_info[] = {
[ADV7604] = {
.type = ADV7604,
@@ -2646,17 +2682,59 @@ static const struct adv76xx_chip_info 
adv76xx_chip_info[] = {
.field1_vsync_mask = 0x3fff,
.field1_vbackporch_mask = 0x3fff,
},
+   [ADV7612] = {
+   .type = ADV7612,
+   .has_afe = false,
+   .max_port = ADV7604_PAD_HDMI_PORT_B,
+   .num_dv_ports = 2,
+   .edid_enable_reg = 0x74,
+   .edid_status_reg = 0x76,
+   .lcf_reg = 0xa3,
+   .tdms_lock_mask = 0x43,
+   .cable_det_mask = 0x01,
+   .fmt_change_digital_mask = 0x03,
+   .formats = adv7612_formats,
+   .nformats = ARRAY_SIZE(adv7612_formats),
+   .set_termination = adv7611_set_termination,
+   .setup_irqs = adv7612_setup_irqs,
+   .read_hdmi_pixelclock = adv7611_read_hdmi_pixelclock,
+   .read_cable_det = adv7611_read_cable_det,
+   .recommended_settings = {
+   [1] = adv7612_recommended_settings_hdmi,
+   },
+   .num_recommended_settings = {
+   [1] = ARRAY_SIZE(adv7612_recommended_settings_hdmi),
+   },
+   .page_mask = BIT(ADV76XX_PAGE_IO) | BIT(ADV76XX_PAGE_CEC) |
+   BIT(ADV76XX_PAGE_INFOFRAME) | BIT(ADV76XX_PAGE_AFE) |
+   BIT(ADV76XX_PAGE_REP) |  BIT(ADV76XX_PAGE_EDID) |
+   BIT(ADV76XX_PAGE_HDMI) | BIT(ADV76XX_PAGE_CP),
+   .linewidth_mask = 0x1fff,
+   .field0_height_mask = 0x1fff,
+   .field1_height_mask = 0x1fff,
+   .hfrontporch_mask = 0x1fff,
+   .hsync_mask

[PATCH 07/15] ARM: shmobile: lager dts: specify default-input for ADV7612

2015-06-03 Thread William Towle
Set 'default-input' property for ADV7612. Enables image/video capture
without the need to have userspace specifying routing.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Tested-by: William Towle william.to...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 90c4531..6946e9a 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -544,6 +544,7 @@
port {
hdmi_in_ep: endpoint {
remote-endpoint = vin0ep0;
+   default-input = 0;
};
};
};
-- 
1.7.10.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


[PATCH 03/15] media: adv7180: add of match table

2015-06-03 Thread William Towle
From: Ben Dooks ben.do...@codethink.co.uk

Add a proper of match id for use when the device is being bound via
device tree, to avoid having to use the i2c old-style binding of the
device.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
Signed-off-by: William.Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/i2c/adv7180.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index a493c0b..09a96df 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -25,6 +25,7 @@
 #include linux/interrupt.h
 #include linux/i2c.h
 #include linux/slab.h
+#include linux/of.h
 #include media/v4l2-ioctl.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
@@ -1324,11 +1325,21 @@ static SIMPLE_DEV_PM_OPS(adv7180_pm_ops, 
adv7180_suspend, adv7180_resume);
 #define ADV7180_PM_OPS NULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id adv7180_of_id[] = {
+   { .compatible = adi,adv7180, },
+   { },
+};
+
+MODULE_DEVICE_TABLE(of, adv7180_of_id);
+#endif
+
 static struct i2c_driver adv7180_driver = {
.driver = {
   .owner = THIS_MODULE,
   .name = KBUILD_MODNAME,
   .pm = ADV7180_PM_OPS,
+  .of_match_table = of_match_ptr(adv7180_of_id),
   },
.probe = adv7180_probe,
.remove = adv7180_remove,
-- 
1.7.10.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


[PATCH 14/15] media: soc_camera: fill in bus_info field

2015-06-03 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Adapt soc_camera_querycap() so that cap-bus_info is populated in
addition to cap-driver.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 4e59833..675cfc4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -954,6 +954,7 @@ static int soc_camera_querycap(struct file *file, void  
*priv,
WARN_ON(priv != file-private_data);
 
strlcpy(cap-driver, ici-drv_name, sizeof(cap-driver));
+   strlcpy(cap-bus_info, platform:soc_camera, sizeof(cap-bus_info));
return ici-ops-querycap(ici, cap);
 }
 
-- 
1.7.10.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


HDMI and Composite capture on Lager, for kernel 4.1, version 3

2015-06-03 Thread William Towle
  Version 3. Obsoletes version 2, as seen at:

http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/91668

  Key changes in this version: this has some reworking of the adv7604
driver probe and soc_camera initialisation functions. In addition,
we give rcar_vin.c a dependency on CONFIG_MEDIA_CONTROLLER in line with
the drivers used with it.

Cheers,
  Wills.

To follow:
[PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI
[PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
[PATCH 03/15] media: adv7180: add of match table
[PATCH 04/15] media: adv7604: chip info and formats for ADV7612
[PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI
[PATCH 06/15] media: adv7604: ability to read default input port
[PATCH 07/15] ARM: shmobile: lager dts: specify default-input for
[PATCH 08/15] v4l: subdev: Add pad config allocator and init
[PATCH 09/15] media: soc_camera pad-aware driver initialisation
[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt
[PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad
[PATCH 12/15] media: soc_camera: Fill std field in enum_input
[PATCH 13/15] media: soc_camera: Fix error reporting in expbuf
[PATCH 14/15] media: soc_camera: fill in bus_info field
[PATCH 15/15] media: rcar_vin: Reject videobufs that are too small
--
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/15] media: rcar_vin: Use correct pad number in try_fmt

2015-06-03 Thread William Towle
Fix rcar_vin_try_fmt to use the correct pad number when calling the
subdev set_fmt. Previously pad number 0 was always used, resulting in
EINVAL if the subdev cares about the pad number (e.g. ADV7612).

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 00c1034..cc993bc 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1697,7 +1697,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
@@ -1706,6 +1706,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
int width, height;
int ret;
 
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
xlate = icd-current_fmt;
@@ -1734,10 +1736,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
-   ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
-   if (ret  0)
+   format.pad = icd-src_pad_idx;
+   ret = v4l2_device_call_until_err(sd-v4l2_dev,
+   soc_camera_grp_id(icd), pad,
+   set_fmt, pad_cfg,
+   format);
+   if (ret  0) {
+   v4l2_subdev_free_pad_config(pad_cfg);
return ret;
+   }
 
/* Adjust only if VIN cannot scale */
if (pix-width  mf-width * 2)
@@ -1759,13 +1766,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
 */
mf-width = VIN_MAX_WIDTH;
mf-height = VIN_MAX_HEIGHT;
+   format.pad = icd-src_pad_idx;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
client try_fmt() = %d\n, ret);
+   v4l2_subdev_free_pad_config(pad_cfg);
return ret;
}
}
@@ -1776,6 +1785,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
pix-height = height;
}
 
+   v4l2_subdev_free_pad_config(pad_cfg);
return ret;
 }
 
-- 
1.7.10.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


[PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI input support

2015-06-03 Thread William Towle
Add DT entries for vin0, vin0_pins, and adv7612

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |   41 ++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index aaa4f25..90c4531 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -370,7 +370,12 @@
renesas,function = usb2;
};
 
-   vin1_pins: vin {
+   vin0_pins: vin0 {
+   renesas,groups = vin0_data24, vin0_sync, vin0_field, 
vin0_clkenb, vin0_clk;
+   renesas,function = vin0;
+   };
+
+   vin1_pins: vin1 {
renesas,groups = vin1_data8, vin1_clk;
renesas,function = vin1;
};
@@ -531,6 +536,18 @@
reg = 0x12;
};
 
+   hdmi-in@4c {
+   compatible = adi,adv7612;
+   reg = 0x4c;
+   remote = vin0;
+
+   port {
+   hdmi_in_ep: endpoint {
+   remote-endpoint = vin0ep0;
+   };
+   };
+   };
+
composite-in@20 {
compatible = adi,adv7180;
reg = 0x20;
@@ -646,6 +663,28 @@
status = okay;
 };
 
+/* HDMI video input */
+vin0 {
+   pinctrl-0 = vin0_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin0ep0: endpoint {
+   remote-endpoint = hdmi_in_ep;
+   bus-width = 24;
+   hsync-active = 0;
+   vsync-active = 0;
+   pclk-sample = 1;
+   data-active = 1;
+   };
+   };
+};
+
 /* composite video input */
 vin1 {
pinctrl-0 = vin1_pins;
-- 
1.7.10.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


[PATCH 15/15] media: rcar_vin: Reject videobufs that are too small for current format

2015-06-03 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

In videobuf_setup reject buffers that are too small for the configured
format. Fixes v4l2-complience issue.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index cc993bc..1531a76 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -541,6 +541,9 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
unsigned int bytes_per_line;
int ret;
 
+   if (fmt-fmt.pix.sizeimage  icd-sizeimage)
+   return -EINVAL;
+
xlate = soc_camera_xlate_by_fourcc(icd,
   fmt-fmt.pix.pixelformat);
if (!xlate)
-- 
1.7.10.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


[PATCH 06/15] media: adv7604: ability to read default input port from DT

2015-06-03 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

Adds support to the adv7604 driver for specifying the default input
port in the Device tree. If no value is provided, the driver will be
unable to select an input without help from userspace.

Tested-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
---
 Documentation/devicetree/bindings/media/i2c/adv7604.txt |3 +++
 drivers/media/i2c/adv7604.c |8 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index 7eafdbc..8337f75 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -47,6 +47,7 @@ Optional Endpoint Properties:
   If none of hsync-active, vsync-active and pclk-sample is specified the
   endpoint will use embedded BT.656 synchronization.
 
+  - default-input: Select which input is selected after reset.
 
 Example:
 
@@ -60,6 +61,8 @@ Example:
#address-cells = 1;
#size-cells = 0;
 
+   default-input = 0;
+
port@0 {
reg = 0;
};
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 16646517..5b6ac8e 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2745,6 +2745,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
struct device_node *endpoint;
struct device_node *np;
unsigned int flags;
+   u32 v;
 
np = state-i2c_clients[ADV76XX_PAGE_IO]-dev.of_node;
 
@@ -2754,6 +2755,12 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
return -EINVAL;
 
v4l2_of_parse_endpoint(endpoint, bus_cfg);
+
+   if (!of_property_read_u32(endpoint, default-input, v))
+   state-pdata.default_input = v;
+   else
+   state-pdata.default_input = -1;
+
of_node_put(endpoint);
 
flags = bus_cfg.bus.parallel.flags;
@@ -2792,7 +2799,6 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
/* Hardcode the remaining platform data fields. */
state-pdata.disable_pwrdnb = 0;
state-pdata.disable_cable_det_rst = 0;
-   state-pdata.default_input = -1;
state-pdata.blank_data = 1;
state-pdata.alt_data_sat = 1;
state-pdata.op_format_mode_sel = ADV7604_OP_FORMAT_MODE0;
-- 
1.7.10.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


[PATCH 12/15] media: soc_camera: Fill std field in enum_input

2015-06-03 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Fill in the std field from the video_device tvnorms field in
enum_input.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index c4952c8..51daeb1 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -309,11 +309,14 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, 
void *priv,
 static int soc_camera_enum_input(struct file *file, void *priv,
 struct v4l2_input *inp)
 {
+   struct soc_camera_device *icd = file-private_data;
+
if (inp-index != 0)
return -EINVAL;
 
/* default is camera */
inp-type = V4L2_INPUT_TYPE_CAMERA;
+   inp-std = icd-vdev-tvnorms;
strcpy(inp-name, Camera);
 
return 0;
-- 
1.7.10.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


[PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support

2015-06-03 Thread William Towle
This adds V4L2_MBUS_FMT_RGB888_1X24 input format support
which is used by the ADV7612 chip.

Signed-off-by: Koji Matsuoka koji.matsuoka...@renesas.com
Signed-off-by: Simon Horman horms+rene...@verge.net.au
Signed-off-by: Yoshihiro Kaneko ykaneko0...@gmail.com

Modified to use MEDIA_BUS_FMT_* constants

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index db7700b..16352a8 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -98,6 +98,7 @@
 #define VNMC_INF_YUV10_BT656   (2  16)
 #define VNMC_INF_YUV10_BT601   (3  16)
 #define VNMC_INF_YUV16 (5  16)
+#define VNMC_INF_RGB888(6  16)
 #define VNMC_VUP   (1  10)
 #define VNMC_IM_ODD(0  3)
 #define VNMC_IM_ODD_EVEN   (1  3)
@@ -589,7 +590,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
struct soc_camera_device *icd = priv-ici.icd;
struct rcar_vin_cam *cam = icd-host_priv;
u32 vnmc, dmr, interrupts;
-   bool progressive = false, output_is_yuv = false;
+   bool progressive = false, output_is_yuv = false, input_is_yuv = false;
 
switch (priv-field) {
case V4L2_FIELD_TOP:
@@ -623,16 +624,22 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
case MEDIA_BUS_FMT_YUYV8_1X16:
/* BT.601/BT.1358 16bit YCbCr422 */
vnmc |= VNMC_INF_YUV16;
+   input_is_yuv = true;
break;
case MEDIA_BUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
+   input_is_yuv = true;
+   break;
+   case MEDIA_BUS_FMT_RGB888_1X24:
+   vnmc |= VNMC_INF_RGB888;
break;
case MEDIA_BUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
+   input_is_yuv = true;
break;
default:
break;
@@ -676,7 +683,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
vnmc |= VNMC_VUP;
 
/* If input and output use the same colorspace, use bypass mode */
-   if (output_is_yuv)
+   if (input_is_yuv == output_is_yuv)
vnmc |= VNMC_BPS;
 
/* progressive or interlaced mode */
@@ -1423,6 +1430,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
case MEDIA_BUS_FMT_YUYV8_1X16:
case MEDIA_BUS_FMT_YUYV8_2X8:
case MEDIA_BUS_FMT_YUYV10_2X10:
+   case MEDIA_BUS_FMT_RGB888_1X24:
if (cam-extra_fmt)
break;
 
-- 
1.7.10.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


[PATCH 13/15] media: soc_camera: Fix error reporting in expbuf

2015-06-03 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Remove unnecessary check and fix the error code for vb1 drivers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 51daeb1..4e59833 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -470,14 +470,10 @@ static int soc_camera_expbuf(struct file *file, void 
*priv,
struct soc_camera_device *icd = file-private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
 
-   if (icd-streamer != file)
-   return -EBUSY;
-
/* videobuf2 only */
if (ici-ops-init_videobuf)
-   return -EINVAL;
-   else
-   return vb2_expbuf(icd-vb2_vidq, p);
+   return -ENOTTY;
+   return vb2_expbuf(icd-vb2_vidq, p);
 }
 
 /* Always entered with .host_lock held */
-- 
1.7.10.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


[PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI input decoder

2015-06-03 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

This documentation accompanies the patch adding support for the ADV7612
dual HDMI decoder / repeater chip.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 .../devicetree/bindings/media/i2c/adv7604.txt|   18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index c27cede..7eafdbc 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -1,15 +1,17 @@
-* Analog Devices ADV7604/11 video decoder with HDMI receiver
+* Analog Devices ADV7604/11/12 video decoder with HDMI receiver
 
-The ADV7604 and ADV7611 are multiformat video decoders with an integrated HDMI
-receiver. The ADV7604 has four multiplexed HDMI inputs and one analog input,
-and the ADV7611 has one HDMI input and no analog input.
+The ADV7604 and ADV7611/12 are multiformat video decoders with an integrated
+HDMI receiver. The ADV7604 has four multiplexed HDMI inputs and one analog
+input, and the ADV7611 has one HDMI input and no analog input. The 7612 is
+similar to the 7611 but has 2 HDMI inputs.
 
-These device tree bindings support the ADV7611 only at the moment.
+These device tree bindings support the ADV7611/12 only at the moment.
 
 Required Properties:
 
   - compatible: Must contain one of the following
 - adi,adv7611 for the ADV7611
+- adi,adv7612 for the ADV7612
 
   - reg: I2C slave address
 
@@ -22,10 +24,10 @@ port, in accordance with the video interface bindings 
defined in
 Documentation/devicetree/bindings/media/video-interfaces.txt. The port nodes
 are numbered as follows.
 
-  Port ADV7611
+  Port ADV7611ADV7612
 
-  HDMI 0
-  Digital output   1
+  HDMI 0 0, 1
+  Digital output   12
 
 The digital output port node must contain at least one endpoint.
 
-- 
1.7.10.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


[PATCH 08/15] v4l: subdev: Add pad config allocator and init

2015-06-03 Thread William Towle
From: Laurent Pinchart laurent.pinch...@linaro.org

Add a new subdev operation to initialize a subdev pad config array, and
a helper function to allocate and initialize the array. This can be used
by bridge drivers to implement try format based on subdev pad
operations.

Signed-off-by: Laurent Pinchart laurent.pinch...@linaro.org
Acked-by: Vaibhav Hiremath vaibhav.hirem...@linaro.org
---
 drivers/media/v4l2-core/v4l2-subdev.c | 19 ++-
 include/media/v4l2-subdev.h   | 10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

Changes since v1:

- Added v4l2_subdev_free_pad_config
---
 drivers/media/v4l2-core/v4l2-subdev.c |   19 ++-
 include/media/v4l2-subdev.h   |   10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 6359606..d594fe5 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -35,7 +35,7 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-   fh-pad = kzalloc(sizeof(*fh-pad) * sd-entity.num_pads, GFP_KERNEL);
+   fh-pad = v4l2_subdev_alloc_pad_config(sd);
if (fh-pad == NULL)
return -ENOMEM;
 #endif
@@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
sink, link, source_fmt, sink_fmt);
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd)
+{
+   struct v4l2_subdev_pad_config *cfg;
+
+   if (!sd-entity.num_pads)
+   return NULL;
+
+   cfg = kcalloc(sd-entity.num_pads, sizeof(*cfg), GFP_KERNEL);
+   if (!cfg)
+   return NULL;
+
+   v4l2_subdev_call(sd, pad, init_cfg, cfg);
+
+   return cfg;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops 
*ops)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index dc20102..4a609f6 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -485,6 +485,8 @@ struct v4l2_subdev_pad_config {
  *  may be adjusted by the subdev driver to device 
capabilities.
  */
 struct v4l2_subdev_pad_ops {
+   void (*init_cfg)(struct v4l2_subdev *sd,
+struct v4l2_subdev_pad_config *cfg);
int (*enum_mbus_code)(struct v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_mbus_code_enum *code);
@@ -677,7 +679,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev 
*sd,
  struct v4l2_subdev_format *source_fmt,
  struct v4l2_subdev_format *sink_fmt);
 int v4l2_subdev_link_validate(struct media_link *link);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd);
+
+static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config 
*cfg)
+{
+   kfree(cfg);
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
+
 void v4l2_subdev_init(struct v4l2_subdev *sd,
  const struct v4l2_subdev_ops *ops);
 
-- 
1.7.10.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


[PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad when calling subdev try_fmt

2015-05-27 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Fix calls to subdev try_fmt to use correct pad. Fixes failures with
subdevs that care about having the right pad number set.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_scale_crop.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c 
b/drivers/media/platform/soc_camera/soc_scale_crop.c
index bda29bc..d2b377f 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -224,6 +224,12 @@ static int client_set_fmt(struct soc_camera_device *icd,
struct v4l2_cropcap cap;
bool host_1to1;
int ret;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad *remote_pad;
+
+   remote_pad = media_entity_remote_pad(icd-vdev-entity.pads[0]);
+   format-pad = remote_pad-index;
+#endif
 
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd), pad,
@@ -261,10 +267,21 @@ static int client_set_fmt(struct soc_camera_device *icd,
/* width = max_width  height = max_height - guaranteed by try_fmt */
while ((width  tmp_w || height  tmp_h) 
   tmp_w  max_width  tmp_h  max_height) {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad *remote_pad;
+#endif
+
tmp_w = min(2 * tmp_w, max_width);
tmp_h = min(2 * tmp_h, max_height);
mf-width = tmp_w;
mf-height = tmp_h;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   remote_pad = media_entity_remote_pad(
+   icd-vdev-entity.pads[0]);
+   format-pad = remote_pad-index;
+#endif
+
ret = v4l2_device_call_until_err(sd-v4l2_dev,
soc_camera_grp_id(icd), pad,
set_fmt, NULL, format);
-- 
1.7.10.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


[PATCH 12/15] media: soc_camera: Fill std field in enum_input

2015-05-27 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Fill in the std field from the video_device tvnorms field in
enum_input.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index b054f46..f6c05c6 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -309,11 +309,14 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, 
void *priv,
 static int soc_camera_enum_input(struct file *file, void *priv,
 struct v4l2_input *inp)
 {
+   struct soc_camera_device *icd = file-private_data;
+
if (inp-index != 0)
return -EINVAL;
 
/* default is camera */
inp-type = V4L2_INPUT_TYPE_CAMERA;
+   inp-std = icd-vdev-tvnorms;
strcpy(inp-name, Camera);
 
return 0;
-- 
1.7.10.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


[PATCH 15/15] media: rcar_vin: Reject videobufs that are too small for current format

2015-05-27 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

In videobuf_setup reject buffers that are too small for the configured
format. Fixes v4l2-complience issue.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 5523d04..a226c02 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -541,6 +541,9 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
unsigned int bytes_per_line;
int ret;
 
+   if (fmt-fmt.pix.sizeimage  icd-sizeimage)
+   return -EINVAL;
+
xlate = soc_camera_xlate_by_fourcc(icd,
   fmt-fmt.pix.pixelformat);
if (!xlate)
-- 
1.7.10.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


[PATCH 03/15] media: adv7180: add of match table

2015-05-27 Thread William Towle
From: Ben Dooks ben.do...@codethink.co.uk

Add a proper of match id for use when the device is being bound via
device tree, to avoid having to use the i2c old-style binding of the
device.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
Signed-off-by: William.Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/i2c/adv7180.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index a493c0b..09a96df 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -25,6 +25,7 @@
 #include linux/interrupt.h
 #include linux/i2c.h
 #include linux/slab.h
+#include linux/of.h
 #include media/v4l2-ioctl.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
@@ -1324,11 +1325,21 @@ static SIMPLE_DEV_PM_OPS(adv7180_pm_ops, 
adv7180_suspend, adv7180_resume);
 #define ADV7180_PM_OPS NULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id adv7180_of_id[] = {
+   { .compatible = adi,adv7180, },
+   { },
+};
+
+MODULE_DEVICE_TABLE(of, adv7180_of_id);
+#endif
+
 static struct i2c_driver adv7180_driver = {
.driver = {
   .owner = THIS_MODULE,
   .name = KBUILD_MODNAME,
   .pm = ADV7180_PM_OPS,
+  .of_match_table = of_match_ptr(adv7180_of_id),
   },
.probe = adv7180_probe,
.remove = adv7180_remove,
-- 
1.7.10.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


[PATCH 13/15] media: soc_camera: Fix error reporting in expbuf

2015-05-27 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Remove unnecessary check and fix the error code for vb1 drivers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index f6c05c6..a80cde5 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -470,14 +470,10 @@ static int soc_camera_expbuf(struct file *file, void 
*priv,
struct soc_camera_device *icd = file-private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
 
-   if (icd-streamer != file)
-   return -EBUSY;
-
/* videobuf2 only */
if (ici-ops-init_videobuf)
-   return -EINVAL;
-   else
-   return vb2_expbuf(icd-vb2_vidq, p);
+   return -ENOTTY;
+   return vb2_expbuf(icd-vb2_vidq, p);
 }
 
 /* Always entered with .host_lock held */
-- 
1.7.10.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


HDMI and Composite capture on Lager, for kernel 4.1, version 2

2015-05-27 Thread William Towle
  Version 2 of the patchset sent last week, ie.

http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/91423

  In response to comments, this version has: fixes regarding use of
CONFIG_MEDIA_CONTROLLER defines; an additional line for the RGB888
support patch (required by parallel changes); removal of more vestigial
format handling; the set no longer has its debugging changes and now
incorporates the patch at https://patchwork.linuxtv.org/patch/29807/

Cheers,
  Wills.

To follow:
[PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI
[PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
[PATCH 03/15] media: adv7180: add of match table
[PATCH 04/15] media: adv7604: chip info and formats for ADV7612
[PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI
[PATCH 06/15] media: adv7604: ability to read default input port
[PATCH 07/15] ARM: shmobile: lager dts: specify default-input for
[PATCH 08/15] v4l: subdev: Add pad config allocator and init
[PATCH 09/15] media: soc_camera pad-aware driver initialisation
[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt
[PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad
[PATCH 12/15] media: soc_camera: Fill std field in enum_input
[PATCH 13/15] media: soc_camera: Fix error reporting in expbuf
[PATCH 14/15] media: soc_camera: v4l2-compliance fixes for querycap
[PATCH 15/15] media: rcar_vin: Reject videobufs that are too small
--
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/15] media: soc_camera pad-aware driver initialisation

2015-05-27 Thread William Towle
Add detection of source pad number for drivers aware of the media
controller API, so that soc_camera/rcar_vin can create device nodes
to support a driver such as adv7604.c (for HDMI on Lager) underneath.

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c   |6 +
 drivers/media/platform/soc_camera/soc_camera.c |   32 
 include/media/soc_camera.h |1 +
 3 files changed, 39 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 16352a8..0df3212 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1358,7 +1358,13 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
struct v4l2_rect rect;
struct device *dev = icd-parent;
int shift;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad *remote_pad;
 
+   remote_pad = media_entity_remote_pad(
+   icd-vdev-entity.pads[0]);
+   fmt.pad = remote_pad-index;
+#endif
ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
if (ret  0)
return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index d708df4..b054f46 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1293,6 +1293,7 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = fmt.format;
+   int src_pad_idx = -1;
int ret;
 
sd-grp_id = soc_camera_grp_id(icd);
@@ -1310,8 +1311,30 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
return ret;
}
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
/* At this point client .probe() should have run already */
+   ret = media_entity_init(icd-vdev-entity, 1, icd-pad, 0);
+   if (!ret) {
+   for (src_pad_idx = 0; src_pad_idx  sd-entity.num_pads;
+   src_pad_idx++)
+   if (sd-entity.pads[src_pad_idx].flags
+   == MEDIA_PAD_FL_SOURCE)
+   break;
+
+   if (src_pad_idx  sd-entity.num_pads) {
+   if (!media_entity_create_link(
+   icd-vdev-entity, 0,
+   sd-entity, src_pad_idx,
+   MEDIA_LNK_FL_IMMUTABLE |
+   MEDIA_LNK_FL_ENABLED)) {
+   ret = soc_camera_init_user_formats(icd);
+   }
+   }
+   }
+#else
ret = soc_camera_init_user_formats(icd);
+#endif
+
if (ret  0)
goto eusrfmt;
 
@@ -1322,6 +1345,7 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
goto evidstart;
 
/* Try to improve our guess of a reasonable window format */
+   fmt.pad = src_pad_idx;
if (!v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt)) {
icd-user_width = mf-width;
icd-user_height= mf-height;
@@ -1335,6 +1359,9 @@ static int soc_camera_probe_finish(struct 
soc_camera_device *icd)
 evidstart:
soc_camera_free_user_formats(icd);
 eusrfmt:
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   media_entity_cleanup(icd-vdev-entity);
+#endif
soc_camera_remove_device(icd);
 
return ret;
@@ -1856,6 +1883,11 @@ static int soc_camera_remove(struct soc_camera_device 
*icd)
if (icd-num_user_formats)
soc_camera_free_user_formats(icd);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   if (icd-vdev-entity.num_pads)
+   media_entity_cleanup(icd-vdev-entity);
+#endif
+
if (icd-clk) {
/* For the synchronous case */
v4l2_clk_unregister(icd-clk);
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2f6261f..f0c5238 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -42,6 +42,7 @@ struct soc_camera_device {
unsigned char devnum;   /* Device number per host */
struct soc_camera_sense *sense; /* See comment in struct definition */
struct video_device *vdev;
+   struct media_pad pad;
struct v4l2_ctrl_handler ctrl_handler;
const struct soc_camera_format_xlate *current_fmt;
struct soc_camera_format_xlate *user_formats;
-- 
1.7.10.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

[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-05-27 Thread William Towle
Fix rcar_vin_try_fmt to use the correct pad number when calling the
subdev set_fmt. Previously pad number 0 was always used, resulting in
EINVAL if the subdev cares about the pad number (e.g. ADV7612).

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   36 ++
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 0df3212..5523d04 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1702,7 +1702,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg = NULL;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
@@ -1710,6 +1710,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
__u32 pixfmt = pix-pixelformat;
int width, height;
int ret;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad *remote_pad;
+
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+#endif
 
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
@@ -1739,10 +1744,22 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
-   ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
-   if (ret  0)
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   remote_pad = media_entity_remote_pad(
+   icd-vdev-entity.pads[0]);
+   format.pad = remote_pad-index;
+#endif
+
+   ret = v4l2_device_call_until_err(sd-v4l2_dev,
+   soc_camera_grp_id(icd), pad,
+   set_fmt, pad_cfg,
+   format);
+   if (ret  0) {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   v4l2_subdev_free_pad_config(pad_cfg);
+#endif
return ret;
+   }
 
/* Adjust only if VIN cannot scale */
if (pix-width  mf-width * 2)
@@ -1764,13 +1781,19 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
 */
mf-width = VIN_MAX_WIDTH;
mf-height = VIN_MAX_HEIGHT;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   format.pad = remote_pad-index;
+#endif
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
client try_fmt() = %d\n, ret);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   v4l2_subdev_free_pad_config(pad_cfg);
+#endif
return ret;
}
}
@@ -1781,6 +1804,9 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
pix-height = height;
}
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   v4l2_subdev_free_pad_config(pad_cfg);
+#endif
return ret;
 }
 
-- 
1.7.10.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


[PATCH 14/15] media: soc_camera: v4l2-compliance fixes for querycap

2015-05-27 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Fill in bus_info field and zero reserved field - v4l2-compliance
complained it wasn't zero (v4l2-compliance.cpp:308 in v4l-utils v1.6.2)

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index a80cde5..7307924 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -954,6 +954,8 @@ static int soc_camera_querycap(struct file *file, void  
*priv,
WARN_ON(priv != file-private_data);
 
strlcpy(cap-driver, ici-drv_name, sizeof(cap-driver));
+   strlcpy(cap-bus_info, platform:soc_camera, sizeof(cap-bus_info));
+   memset(cap-reserved, 0, sizeof(cap-reserved));
return ici-ops-querycap(ici, cap);
 }
 
-- 
1.7.10.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


[PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI input decoder

2015-05-27 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

This documentation accompanies the patch adding support for the ADV7612
dual HDMI decoder / repeater chip.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 .../devicetree/bindings/media/i2c/adv7604.txt|   18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index c27cede..7eafdbc 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -1,15 +1,17 @@
-* Analog Devices ADV7604/11 video decoder with HDMI receiver
+* Analog Devices ADV7604/11/12 video decoder with HDMI receiver
 
-The ADV7604 and ADV7611 are multiformat video decoders with an integrated HDMI
-receiver. The ADV7604 has four multiplexed HDMI inputs and one analog input,
-and the ADV7611 has one HDMI input and no analog input.
+The ADV7604 and ADV7611/12 are multiformat video decoders with an integrated
+HDMI receiver. The ADV7604 has four multiplexed HDMI inputs and one analog
+input, and the ADV7611 has one HDMI input and no analog input. The 7612 is
+similar to the 7611 but has 2 HDMI inputs.
 
-These device tree bindings support the ADV7611 only at the moment.
+These device tree bindings support the ADV7611/12 only at the moment.
 
 Required Properties:
 
   - compatible: Must contain one of the following
 - adi,adv7611 for the ADV7611
+- adi,adv7612 for the ADV7612
 
   - reg: I2C slave address
 
@@ -22,10 +24,10 @@ port, in accordance with the video interface bindings 
defined in
 Documentation/devicetree/bindings/media/video-interfaces.txt. The port nodes
 are numbered as follows.
 
-  Port ADV7611
+  Port ADV7611ADV7612
 
-  HDMI 0
-  Digital output   1
+  HDMI 0 0, 1
+  Digital output   12
 
 The digital output port node must contain at least one endpoint.
 
-- 
1.7.10.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


[PATCH 07/15] ARM: shmobile: lager dts: specify default-input for ADV7612

2015-05-27 Thread William Towle
Set 'default-input' property for ADV7612. Enables image/video capture
without the need to have userspace specifying routing.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Tested-by: William Towle william.to...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 90c4531..6946e9a 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -544,6 +544,7 @@
port {
hdmi_in_ep: endpoint {
remote-endpoint = vin0ep0;
+   default-input = 0;
};
};
};
-- 
1.7.10.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


[PATCH 06/15] media: adv7604: ability to read default input port from DT

2015-05-27 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

Adds support to the adv7604 driver for specifying the default input
port in the Device tree. If no value is provided, the driver will be
unable to select an input without help from userspace.

Tested-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
---
 Documentation/devicetree/bindings/media/i2c/adv7604.txt |3 +++
 drivers/media/i2c/adv7604.c |8 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index 7eafdbc..8337f75 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -47,6 +47,7 @@ Optional Endpoint Properties:
   If none of hsync-active, vsync-active and pclk-sample is specified the
   endpoint will use embedded BT.656 synchronization.
 
+  - default-input: Select which input is selected after reset.
 
 Example:
 
@@ -60,6 +61,8 @@ Example:
#address-cells = 1;
#size-cells = 0;
 
+   default-input = 0;
+
port@0 {
reg = 0;
};
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index c5a1566..ec8161d 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2745,6 +2745,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
struct device_node *endpoint;
struct device_node *np;
unsigned int flags;
+   u32 v;
 
np = state-i2c_clients[ADV76XX_PAGE_IO]-dev.of_node;
 
@@ -2754,6 +2755,12 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
return -EINVAL;
 
v4l2_of_parse_endpoint(endpoint, bus_cfg);
+
+   if (!of_property_read_u32(endpoint, default-input, v))
+   state-pdata.default_input = v;
+   else
+   state-pdata.default_input = -1;
+
of_node_put(endpoint);
 
flags = bus_cfg.bus.parallel.flags;
@@ -2792,7 +2799,6 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
/* Hardcode the remaining platform data fields. */
state-pdata.disable_pwrdnb = 0;
state-pdata.disable_cable_det_rst = 0;
-   state-pdata.default_input = -1;
state-pdata.blank_data = 1;
state-pdata.alt_data_sat = 1;
state-pdata.op_format_mode_sel = ADV7604_OP_FORMAT_MODE0;
-- 
1.7.10.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


[PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support

2015-05-27 Thread William Towle
This adds V4L2_MBUS_FMT_RGB888_1X24 input format support
which is used by the ADV7612 chip.

Signed-off-by: Koji Matsuoka koji.matsuoka...@renesas.com
Signed-off-by: Simon Horman horms+rene...@verge.net.au
Signed-off-by: Yoshihiro Kaneko ykaneko0...@gmail.com

Modified to use MEDIA_BUS_FMT_* constants

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index db7700b..16352a8 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -98,6 +98,7 @@
 #define VNMC_INF_YUV10_BT656   (2  16)
 #define VNMC_INF_YUV10_BT601   (3  16)
 #define VNMC_INF_YUV16 (5  16)
+#define VNMC_INF_RGB888(6  16)
 #define VNMC_VUP   (1  10)
 #define VNMC_IM_ODD(0  3)
 #define VNMC_IM_ODD_EVEN   (1  3)
@@ -589,7 +590,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
struct soc_camera_device *icd = priv-ici.icd;
struct rcar_vin_cam *cam = icd-host_priv;
u32 vnmc, dmr, interrupts;
-   bool progressive = false, output_is_yuv = false;
+   bool progressive = false, output_is_yuv = false, input_is_yuv = false;
 
switch (priv-field) {
case V4L2_FIELD_TOP:
@@ -623,16 +624,22 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
case MEDIA_BUS_FMT_YUYV8_1X16:
/* BT.601/BT.1358 16bit YCbCr422 */
vnmc |= VNMC_INF_YUV16;
+   input_is_yuv = true;
break;
case MEDIA_BUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
+   input_is_yuv = true;
+   break;
+   case MEDIA_BUS_FMT_RGB888_1X24:
+   vnmc |= VNMC_INF_RGB888;
break;
case MEDIA_BUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
+   input_is_yuv = true;
break;
default:
break;
@@ -676,7 +683,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
vnmc |= VNMC_VUP;
 
/* If input and output use the same colorspace, use bypass mode */
-   if (output_is_yuv)
+   if (input_is_yuv == output_is_yuv)
vnmc |= VNMC_BPS;
 
/* progressive or interlaced mode */
@@ -1423,6 +1430,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
case MEDIA_BUS_FMT_YUYV8_1X16:
case MEDIA_BUS_FMT_YUYV8_2X8:
case MEDIA_BUS_FMT_YUYV10_2X10:
+   case MEDIA_BUS_FMT_RGB888_1X24:
if (cam-extra_fmt)
break;
 
-- 
1.7.10.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


[PATCH 08/15] v4l: subdev: Add pad config allocator and init

2015-05-27 Thread William Towle
From: Laurent Pinchart laurent.pinch...@linaro.org

Add a new subdev operation to initialize a subdev pad config array, and
a helper function to allocate and initialize the array. This can be used
by bridge drivers to implement try format based on subdev pad
operations.

Signed-off-by: Laurent Pinchart laurent.pinch...@linaro.org
Acked-by: Vaibhav Hiremath vaibhav.hirem...@linaro.org
---
 drivers/media/v4l2-core/v4l2-subdev.c | 19 ++-
 include/media/v4l2-subdev.h   | 10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

Changes since v1:

- Added v4l2_subdev_free_pad_config
---
 drivers/media/v4l2-core/v4l2-subdev.c |   19 ++-
 include/media/v4l2-subdev.h   |   10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 6359606..d594fe5 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -35,7 +35,7 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-   fh-pad = kzalloc(sizeof(*fh-pad) * sd-entity.num_pads, GFP_KERNEL);
+   fh-pad = v4l2_subdev_alloc_pad_config(sd);
if (fh-pad == NULL)
return -ENOMEM;
 #endif
@@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
sink, link, source_fmt, sink_fmt);
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd)
+{
+   struct v4l2_subdev_pad_config *cfg;
+
+   if (!sd-entity.num_pads)
+   return NULL;
+
+   cfg = kcalloc(sd-entity.num_pads, sizeof(*cfg), GFP_KERNEL);
+   if (!cfg)
+   return NULL;
+
+   v4l2_subdev_call(sd, pad, init_cfg, cfg);
+
+   return cfg;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops 
*ops)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index dc20102..4a609f6 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -485,6 +485,8 @@ struct v4l2_subdev_pad_config {
  *  may be adjusted by the subdev driver to device 
capabilities.
  */
 struct v4l2_subdev_pad_ops {
+   void (*init_cfg)(struct v4l2_subdev *sd,
+struct v4l2_subdev_pad_config *cfg);
int (*enum_mbus_code)(struct v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_mbus_code_enum *code);
@@ -677,7 +679,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev 
*sd,
  struct v4l2_subdev_format *source_fmt,
  struct v4l2_subdev_format *sink_fmt);
 int v4l2_subdev_link_validate(struct media_link *link);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd);
+
+static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config 
*cfg)
+{
+   kfree(cfg);
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
+
 void v4l2_subdev_init(struct v4l2_subdev *sd,
  const struct v4l2_subdev_ops *ops);
 
-- 
1.7.10.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


[PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI input support

2015-05-27 Thread William Towle
Add DT entries for vin0, vin0_pins, and adv7612

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |   41 ++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index aaa4f25..90c4531 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -370,7 +370,12 @@
renesas,function = usb2;
};
 
-   vin1_pins: vin {
+   vin0_pins: vin0 {
+   renesas,groups = vin0_data24, vin0_sync, vin0_field, 
vin0_clkenb, vin0_clk;
+   renesas,function = vin0;
+   };
+
+   vin1_pins: vin1 {
renesas,groups = vin1_data8, vin1_clk;
renesas,function = vin1;
};
@@ -531,6 +536,18 @@
reg = 0x12;
};
 
+   hdmi-in@4c {
+   compatible = adi,adv7612;
+   reg = 0x4c;
+   remote = vin0;
+
+   port {
+   hdmi_in_ep: endpoint {
+   remote-endpoint = vin0ep0;
+   };
+   };
+   };
+
composite-in@20 {
compatible = adi,adv7180;
reg = 0x20;
@@ -646,6 +663,28 @@
status = okay;
 };
 
+/* HDMI video input */
+vin0 {
+   pinctrl-0 = vin0_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin0ep0: endpoint {
+   remote-endpoint = hdmi_in_ep;
+   bus-width = 24;
+   hsync-active = 0;
+   vsync-active = 0;
+   pclk-sample = 1;
+   data-active = 1;
+   };
+   };
+};
+
 /* composite video input */
 vin1 {
pinctrl-0 = vin1_pins;
-- 
1.7.10.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


[PATCH 04/15] media: adv7604: chip info and formats for ADV7612

2015-05-27 Thread William Towle
Add support for the ADV7612 chip as implemented on Renesas' Lager
board to adv7604.c, including lists for formats/colourspace/timing
selection and an IRQ handler.

Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |   83 +--
 1 file changed, 81 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index aaa37b0..c5a1566 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -80,6 +80,7 @@ MODULE_LICENSE(GPL);
 enum adv76xx_type {
ADV7604,
ADV7611,
+   ADV7612,
 };
 
 struct adv76xx_reg_seq {
@@ -758,6 +759,23 @@ static const struct adv76xx_format_info adv7611_formats[] 
= {
  ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_12BIT },
 };
 
+static const struct adv76xx_format_info adv7612_formats[] = {
+   { MEDIA_BUS_FMT_RGB888_1X24, ADV76XX_OP_CH_SEL_RGB, true, false,
+ ADV76XX_OP_MODE_SEL_SDR_444 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YUYV8_2X8, ADV76XX_OP_CH_SEL_RGB, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YVYU8_2X8, ADV76XX_OP_CH_SEL_RGB, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422 | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_UYVY8_1X16, ADV76XX_OP_CH_SEL_RBG, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_VYUY8_1X16, ADV76XX_OP_CH_SEL_RBG, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YUYV8_1X16, ADV76XX_OP_CH_SEL_RGB, false, false,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+   { MEDIA_BUS_FMT_YVYU8_1X16, ADV76XX_OP_CH_SEL_RGB, false, true,
+ ADV76XX_OP_MODE_SEL_SDR_422_2X | ADV76XX_OP_FORMAT_SEL_8BIT },
+};
+
 static const struct adv76xx_format_info *
 adv76xx_format_info(struct adv76xx_state *state, u32 code)
 {
@@ -2471,6 +2489,11 @@ static void adv7611_setup_irqs(struct v4l2_subdev *sd)
io_write(sd, 0x41, 0xd0); /* STDI irq for any change, disable INT2 */
 }
 
+static void adv7612_setup_irqs(struct v4l2_subdev *sd)
+{
+   io_write(sd, 0x41, 0xd0); /* disable INT2 */
+}
+
 static void adv76xx_unregister_clients(struct adv76xx_state *state)
 {
unsigned int i;
@@ -2558,6 +2581,19 @@ static const struct adv76xx_reg_seq 
adv7611_recommended_settings_hdmi[] = {
{ ADV76XX_REG_SEQ_TERM, 0 },
 };
 
+static const struct adv76xx_reg_seq adv7612_recommended_settings_hdmi[] = {
+   { ADV76XX_REG(ADV76XX_PAGE_CP, 0x6c), 0x00 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x9b), 0x03 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x6f), 0x08 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x85), 0x1f },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x87), 0x70 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x57), 0xda },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x58), 0x01 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x03), 0x98 },
+   { ADV76XX_REG(ADV76XX_PAGE_HDMI, 0x4c), 0x44 },
+   { ADV76XX_REG_SEQ_TERM, 0 },
+};
+
 static const struct adv76xx_chip_info adv76xx_chip_info[] = {
[ADV7604] = {
.type = ADV7604,
@@ -2646,17 +2682,59 @@ static const struct adv76xx_chip_info 
adv76xx_chip_info[] = {
.field1_vsync_mask = 0x3fff,
.field1_vbackporch_mask = 0x3fff,
},
+   [ADV7612] = {
+   .type = ADV7612,
+   .has_afe = false,
+   .max_port = ADV7604_PAD_HDMI_PORT_B,
+   .num_dv_ports = 2,
+   .edid_enable_reg = 0x74,
+   .edid_status_reg = 0x76,
+   .lcf_reg = 0xa3,
+   .tdms_lock_mask = 0x43,
+   .cable_det_mask = 0x01,
+   .fmt_change_digital_mask = 0x03,
+   .formats = adv7612_formats,
+   .nformats = ARRAY_SIZE(adv7612_formats),
+   .set_termination = adv7611_set_termination,
+   .setup_irqs = adv7612_setup_irqs,
+   .read_hdmi_pixelclock = adv7611_read_hdmi_pixelclock,
+   .read_cable_det = adv7611_read_cable_det,
+   .recommended_settings = {
+   [1] = adv7612_recommended_settings_hdmi,
+   },
+   .num_recommended_settings = {
+   [1] = ARRAY_SIZE(adv7612_recommended_settings_hdmi),
+   },
+   .page_mask = BIT(ADV76XX_PAGE_IO) | BIT(ADV76XX_PAGE_CEC) |
+   BIT(ADV76XX_PAGE_INFOFRAME) | BIT(ADV76XX_PAGE_AFE) |
+   BIT(ADV76XX_PAGE_REP) |  BIT(ADV76XX_PAGE_EDID) |
+   BIT(ADV76XX_PAGE_HDMI) | BIT(ADV76XX_PAGE_CP),
+   .linewidth_mask = 0x1fff,
+   .field0_height_mask = 0x1fff,
+   .field1_height_mask = 0x1fff,
+   .hfrontporch_mask = 0x1fff,
+   .hsync_mask

Re: [PATCH 07/20] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support

2015-05-26 Thread William Towle

On Mon, 25 May 2015, Guennadi Liakhovetski wrote:

How about this version of this patch:

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

? I personally like that one better, it seems clearer to me. This one
first sets a bit to vnmp, then make another check and inverts it, whereas
that version clearly sets it just for equal colour-spaces. I just never
got with proper Sob and (maybe?) authorship.


Hi Guennadi,
  Thanks for noticing - we reverted this patch to the version
previously indicated in testing and it didn't get set back.

  We have a test branch for the next version, and I shall attend to
this and the other authorship comments you made immediately.

Thanks,
  Wills.
--
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/20] media: adv7180: add of match table

2015-05-21 Thread William Towle
From: Ben Dooks ben.do...@codethink.co.uk

Add a proper of match id for use when the device is being bound via
device tree, to avoid having to use the i2c old-style binding of the
device.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
Signed-off-by: William.Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/i2c/adv7180.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index a493c0b..09a96df 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -25,6 +25,7 @@
 #include linux/interrupt.h
 #include linux/i2c.h
 #include linux/slab.h
+#include linux/of.h
 #include media/v4l2-ioctl.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
@@ -1324,11 +1325,21 @@ static SIMPLE_DEV_PM_OPS(adv7180_pm_ops, 
adv7180_suspend, adv7180_resume);
 #define ADV7180_PM_OPS NULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id adv7180_of_id[] = {
+   { .compatible = adi,adv7180, },
+   { },
+};
+
+MODULE_DEVICE_TABLE(of, adv7180_of_id);
+#endif
+
 static struct i2c_driver adv7180_driver = {
.driver = {
   .owner = THIS_MODULE,
   .name = KBUILD_MODNAME,
   .pm = ADV7180_PM_OPS,
+  .of_match_table = of_match_ptr(adv7180_of_id),
   },
.probe = adv7180_probe,
.remove = adv7180_remove,
-- 
1.7.10.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


[PATCH 10/20] media: soc_camera: soc_scale_crop: Use correct pad when calling subdev try_fmt

2015-05-21 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Fix calls to subdev try_fmt to use correct pad. Fixes failures with
subdevs that care about having the right pad number set.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_scale_crop.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c 
b/drivers/media/platform/soc_camera/soc_scale_crop.c
index bda29bc..d8d32ea 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -224,6 +224,10 @@ static int client_set_fmt(struct soc_camera_device *icd,
struct v4l2_cropcap cap;
bool host_1to1;
int ret;
+   struct media_pad *remote_pad;
+
+   remote_pad = media_entity_remote_pad(icd-vdev-entity.pads[0]);
+   format-pad = remote_pad-index;
 
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd), pad,
@@ -261,10 +265,17 @@ static int client_set_fmt(struct soc_camera_device *icd,
/* width = max_width  height = max_height - guaranteed by try_fmt */
while ((width  tmp_w || height  tmp_h) 
   tmp_w  max_width  tmp_h  max_height) {
+   struct media_pad *remote_pad;
+
tmp_w = min(2 * tmp_w, max_width);
tmp_h = min(2 * tmp_h, max_height);
mf-width = tmp_w;
mf-height = tmp_h;
+
+   remote_pad = media_entity_remote_pad(
+   icd-vdev-entity.pads[0]);
+   format-pad = remote_pad-index;
+
ret = v4l2_device_call_until_err(sd-v4l2_dev,
soc_camera_grp_id(icd), pad,
set_fmt, NULL, format);
-- 
1.7.10.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


[PATCH 14/20] media: rcar_vin: Reject videobufs that are too small for current format

2015-05-21 Thread William Towle
In videobuf_setup reject buffers that are too small for the configured
format. Fixes v4l2-complience issue.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 571ab20..222002a 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -541,6 +541,9 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
unsigned int bytes_per_line;
int ret;
 
+   if (fmt-fmt.pix.sizeimage  icd-sizeimage)
+   return -EINVAL;
+
xlate = soc_camera_xlate_by_fourcc(icd,
   fmt-fmt.pix.pixelformat);
if (!xlate)
-- 
1.7.10.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


[PATCH 18/20] media: adv7604: Always query_dv_timings in adv76xx_fill_format

2015-05-21 Thread William Towle
Make sure we're always reporting the current format of the input.
Fixes start of day bugs.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Signed-off-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index d77ee1f..526fa4e 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1787,8 +1787,12 @@ static int adv76xx_enum_mbus_code(struct v4l2_subdev *sd,
 static void adv76xx_fill_format(struct adv76xx_state *state,
struct v4l2_mbus_framefmt *format)
 {
+   struct v4l2_subdev *sd = state-sd;
+
memset(format, 0, sizeof(*format));
 
+   v4l2_subdev_call(sd, video, query_dv_timings, state-timings);
+
format-width = state-timings.bt.width;
format-height = state-timings.bt.height;
 
-- 
1.7.10.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


[PATCH 06/20] ARM: shmobile: lager dts: specify default-input for ADV7612

2015-05-21 Thread William Towle
Set 'default-input' property for ADV7612. Enables image/video capture
without the need to have userspace specifying routing.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Tested-by: William Towle william.to...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 90c4531..6946e9a 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -544,6 +544,7 @@
port {
hdmi_in_ep: endpoint {
remote-endpoint = vin0ep0;
+   default-input = 0;
};
};
};
-- 
1.7.10.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


[PATCH 07/20] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support

2015-05-21 Thread William Towle
From: Koji Matsuoka koji.matsuoka...@renesas.com

Signed-off-by: Koji Matsuoka koji.matsuoka...@renesas.com
Signed-off-by: Simon Horman horms+rene...@verge.net.au
Signed-off-by: Yoshihiro Kaneko ykaneko0...@gmail.com

Modified to use MEDIA_BUS_FMT_* constants

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index db7700b..0f67646 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -98,6 +98,7 @@
 #define VNMC_INF_YUV10_BT656   (2  16)
 #define VNMC_INF_YUV10_BT601   (3  16)
 #define VNMC_INF_YUV16 (5  16)
+#define VNMC_INF_RGB888(6  16)
 #define VNMC_VUP   (1  10)
 #define VNMC_IM_ODD(0  3)
 #define VNMC_IM_ODD_EVEN   (1  3)
@@ -620,6 +621,10 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
 
/* input interface */
switch (icd-current_fmt-code) {
+   case MEDIA_BUS_FMT_RGB888_1X24:
+   /* BT.601/BT.709 24-bit RGB-888 */
+   vnmc |= VNMC_INF_RGB888;
+   break;
case MEDIA_BUS_FMT_YUYV8_1X16:
/* BT.601/BT.1358 16bit YCbCr422 */
vnmc |= VNMC_INF_YUV16;
@@ -679,6 +684,15 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
if (output_is_yuv)
vnmc |= VNMC_BPS;
 
+   /*
+* The above assumes YUV input, toggle BPS for RGB input.
+* RGB inputs can be detected by checking that the most-significant
+* two bits of INF are set. This corresponds to the bits
+* set in VNMC_INF_RGB888.
+*/
+   if ((vnmc  VNMC_INF_RGB888) == VNMC_INF_RGB888)
+   vnmc ^= VNMC_BPS;
+
/* progressive or interlaced mode */
interrupts = progressive ? VNIE_FIE : VNIE_EFE;
 
@@ -1423,6 +1437,7 @@ static int rcar_vin_get_formats(struct soc_camera_device 
*icd, unsigned int idx,
case MEDIA_BUS_FMT_YUYV8_1X16:
case MEDIA_BUS_FMT_YUYV8_2X8:
case MEDIA_BUS_FMT_YUYV10_2X10:
+   case MEDIA_BUS_FMT_RGB888_1X24:
if (cam-extra_fmt)
break;
 
-- 
1.7.10.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


[PATCH 17/20] media: adv7604: Support V4L_FIELD_INTERLACED

2015-05-21 Thread William Towle
When hardware reports interlaced input, correctly set field to
V4L_FIELD_INTERLACED ini adv76xx_fill_format.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/i2c/adv7604.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 4bde3e1..d77ee1f 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1791,7 +1791,12 @@ static void adv76xx_fill_format(struct adv76xx_state 
*state,
 
format-width = state-timings.bt.width;
format-height = state-timings.bt.height;
-   format-field = V4L2_FIELD_NONE;
+
+   if (state-timings.bt.interlaced)
+   format-field= V4L2_FIELD_INTERLACED;
+   else
+   format-field= V4L2_FIELD_NONE;
+
format-colorspace = V4L2_COLORSPACE_SRGB;
 
if (state-timings.bt.flags  V4L2_DV_FL_IS_CE_VIDEO)
-- 
1.7.10.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


[PATCH 11/20] media: soc_camera: Fill std field in enum_input

2015-05-21 Thread William Towle
From: Hans Verkuil hans.verk...@cisco.com

Fill in the std field from the video_device tvnorms field in
enum_input.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 126d645..5afbf65 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -309,11 +309,14 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, 
void *priv,
 static int soc_camera_enum_input(struct file *file, void *priv,
 struct v4l2_input *inp)
 {
+   struct soc_camera_device *icd = file-private_data;
+
if (inp-index != 0)
return -EINVAL;
 
/* default is camera */
inp-type = V4L2_INPUT_TYPE_CAMERA;
+   inp-std = icd-vdev-tvnorms;
strcpy(inp-name, Camera);
 
return 0;
-- 
1.7.10.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


[PATCH 20/20] media: soc_camera: Add debugging for get_formats

2015-05-21 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Some helpful debugging for get_formats use, useful for debugging
v4l2-compliance issues.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 583c5e6..503e9b6 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -522,7 +522,7 @@ static int soc_camera_init_user_formats(struct 
soc_camera_device *icd)
 
/* Second pass - actually fill data formats */
fmts = 0;
-   for (i = 0; i  raw_fmts; i++)
+   for (i = 0; i  raw_fmts; i++) {
if (!ici-ops-get_formats) {
code.index = i;
v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, code);
@@ -537,6 +537,8 @@ static int soc_camera_init_user_formats(struct 
soc_camera_device *icd)
goto egfmt;
fmts += ret;
}
+   dev_dbg(icd-pdev,  Format: %x %c%c%c%c, 
icd-user_formats[fmts-1].code, 
pixfmtstr(icd-user_formats[fmts-1].host_fmt-fourcc));
+   }
 
icd-num_user_formats = fmts;
icd-current_fmt = icd-user_formats[0];
@@ -732,6 +734,8 @@ static int soc_camera_open(struct file *file)
 * apart from someone else calling open() simultaneously, but
 * .host_lock is protecting us against it.
 */
+
+   dev_dbg(icd-pdev, %s:%d calling set_fmt with size %d x 
%d,__func__, __LINE__, f.fmt.pix.width, f.fmt.pix.height);
ret = soc_camera_set_fmt(icd, f);
if (ret  0)
goto esfmt;
@@ -2234,6 +2238,7 @@ static int soc_camera_pdrv_probe(struct platform_device 
*pdev)
icd-user_width = DEFAULT_WIDTH;
icd-user_height= DEFAULT_HEIGHT;
 
+   dev_dbg(icd-pdev, %s:%d setting default user size to %d x 
%d,__func__, __LINE__, icd-user_width, icd-user_height);
return soc_camera_device_register(icd);
 }
 
-- 
1.7.10.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


[PATCH 01/20] ARM: shmobile: lager dts: Add entries for VIN HDMI input support

2015-05-21 Thread William Towle
Adds DT entries for vin0_pins, adv7612 and vin0

Signed-off-by: William Towle william.to...@codethink.co.uk
Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts |   41 ++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index aaa4f25..90c4531 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -370,7 +370,12 @@
renesas,function = usb2;
};
 
-   vin1_pins: vin {
+   vin0_pins: vin0 {
+   renesas,groups = vin0_data24, vin0_sync, vin0_field, 
vin0_clkenb, vin0_clk;
+   renesas,function = vin0;
+   };
+
+   vin1_pins: vin1 {
renesas,groups = vin1_data8, vin1_clk;
renesas,function = vin1;
};
@@ -531,6 +536,18 @@
reg = 0x12;
};
 
+   hdmi-in@4c {
+   compatible = adi,adv7612;
+   reg = 0x4c;
+   remote = vin0;
+
+   port {
+   hdmi_in_ep: endpoint {
+   remote-endpoint = vin0ep0;
+   };
+   };
+   };
+
composite-in@20 {
compatible = adi,adv7180;
reg = 0x20;
@@ -646,6 +663,28 @@
status = okay;
 };
 
+/* HDMI video input */
+vin0 {
+   pinctrl-0 = vin0_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin0ep0: endpoint {
+   remote-endpoint = hdmi_in_ep;
+   bus-width = 24;
+   hsync-active = 0;
+   vsync-active = 0;
+   pclk-sample = 1;
+   data-active = 1;
+   };
+   };
+};
+
 /* composite video input */
 vin1 {
pinctrl-0 = vin1_pins;
-- 
1.7.10.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


[PATCH 04/20] media: adv7604: document support for ADV7612 dual HDMI input decoder

2015-05-21 Thread William Towle
From: Ian Molton ian.mol...@codethink.co.uk

This documentation accompanies the patch adding support for the ADV7612
dual HDMI decoder / repeater chip.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 .../devicetree/bindings/media/i2c/adv7604.txt|   18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index c27cede..7eafdbc 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -1,15 +1,17 @@
-* Analog Devices ADV7604/11 video decoder with HDMI receiver
+* Analog Devices ADV7604/11/12 video decoder with HDMI receiver
 
-The ADV7604 and ADV7611 are multiformat video decoders with an integrated HDMI
-receiver. The ADV7604 has four multiplexed HDMI inputs and one analog input,
-and the ADV7611 has one HDMI input and no analog input.
+The ADV7604 and ADV7611/12 are multiformat video decoders with an integrated
+HDMI receiver. The ADV7604 has four multiplexed HDMI inputs and one analog
+input, and the ADV7611 has one HDMI input and no analog input. The 7612 is
+similar to the 7611 but has 2 HDMI inputs.
 
-These device tree bindings support the ADV7611 only at the moment.
+These device tree bindings support the ADV7611/12 only at the moment.
 
 Required Properties:
 
   - compatible: Must contain one of the following
 - adi,adv7611 for the ADV7611
+- adi,adv7612 for the ADV7612
 
   - reg: I2C slave address
 
@@ -22,10 +24,10 @@ port, in accordance with the video interface bindings 
defined in
 Documentation/devicetree/bindings/media/video-interfaces.txt. The port nodes
 are numbered as follows.
 
-  Port ADV7611
+  Port ADV7611ADV7612
 
-  HDMI 0
-  Digital output   1
+  HDMI 0 0, 1
+  Digital output   12
 
 The digital output port node must contain at least one endpoint.
 
-- 
1.7.10.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


[PATCH 09/20] media: rcar_vin: Use correct pad number in try_fmt

2015-05-21 Thread William Towle
From: Rob Taylor rob.tay...@codethink.co.uk

Fix rcar_vin_try_fmt to use the correct pad number when calling the
subdev set_fmt. Previously pad number 0 was always used, resulting in
EINVAL if the subdev cares about the pad number (e.g. ADV7612).

Signed-off-by: William Towle  Taylor rob.tay...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   29 +-
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index b4e9b43..571ab20 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1707,12 +1707,13 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config pad_cfg[sd-entity.num_pads];
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
struct v4l2_mbus_framefmt *mf = format.format;
__u32 pixfmt = pix-pixelformat;
+   struct media_pad *remote_pad;
int width, height;
int ret;
 
@@ -1744,17 +1745,24 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
-   ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
+   remote_pad = media_entity_remote_pad(
+   icd-vdev-entity.pads[0]);
+   format.pad = remote_pad-index;
+
+   ret = v4l2_device_call_until_err(sd-v4l2_dev,
+   soc_camera_grp_id(icd), pad,
+   set_fmt, pad_cfg,
+   format);
if (ret  0)
return ret;
 
-   /* Adjust only if VIN cannot scale */
-   if (pix-width  mf-width * 2)
-   pix-width = mf-width * 2;
-   if (pix-height  mf-height * 3)
-   pix-height = mf-height * 3;
-
+   /*  In case the driver has adjusted 'fmt' to match the
+*  resolution of the live stream, 'pix' needs to pass this
+*  change out so that the buffer userland creates for the
+*  captured image/video has these dimensions
+*/
+   pix-width = mf-width;
+   pix-height = mf-height;
pix-field = mf-field;
pix-colorspace = mf-colorspace;
 
@@ -1769,9 +1777,10 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
 */
mf-width = VIN_MAX_WIDTH;
mf-height = VIN_MAX_HEIGHT;
+   format.pad = remote_pad-index;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
-- 
1.7.10.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


[PATCH 15/20] media: rcar_vin: Don't advertise support for USERPTR

2015-05-21 Thread William Towle
rcar_vin requires physically contiguous buffer, so shouldn't advertise
support for USERPTR.

Signed-off-by: Rob Taylor rob.tay...@codethink.co.uk
Reviewed-by: William Towle william.to...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 222002a..b530503 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1824,7 +1824,7 @@ static int rcar_vin_init_videobuf2(struct vb2_queue *vq,
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
 
vq-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-   vq-io_modes = VB2_MMAP | VB2_USERPTR;
+   vq-io_modes = VB2_MMAP;
vq-drv_priv = icd;
vq-ops = rcar_vin_vb2_ops;
vq-mem_ops = vb2_dma_contig_memops;
-- 
1.7.10.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


  1   2   >