[PATCH] Drop owner assignment from i2c_driver (and platform left-overs)

2015-07-10 Thread Krzysztof Kozlowski
Hi,


The i2c drivers also do not have to set 'owner' field because
i2c_register_driver() will do it instead.

'owner' is removed from i2c drivers, which I was able to compile
with allyesconfig (arm, arm64, i386, x86_64, ppc64).
Only compile-tested.

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html


Best regards,
Krzysztof

Krzysztof Kozlowski (7):
  [media] dvb-frontends: Drop owner assignment from i2c_driver
  [media] dvb-frontends: Drop owner assignment from platform_driver
  [media] i2c: Drop owner assignment from i2c_driver
  [media] platform: Drop owner assignment from i2c_driver
  [media] radio: Drop owner assignment from i2c_driver
  [media] tuners: Drop owner assignment from i2c_driver
  [media] Drop owner assignment from i2c_driver

 drivers/media/dvb-frontends/a8293.c  | 1 -
 drivers/media/dvb-frontends/af9033.c | 1 -
 drivers/media/dvb-frontends/au8522_decoder.c | 1 -
 drivers/media/dvb-frontends/m88ds3103.c  | 1 -
 drivers/media/dvb-frontends/rtl2830.c| 1 -
 drivers/media/dvb-frontends/rtl2832.c| 1 -
 drivers/media/dvb-frontends/rtl2832_sdr.c| 1 -
 drivers/media/dvb-frontends/si2168.c | 1 -
 drivers/media/dvb-frontends/sp2.c| 1 -
 drivers/media/dvb-frontends/tda10071.c   | 1 -
 drivers/media/dvb-frontends/ts2020.c | 1 -
 drivers/media/i2c/adv7170.c  | 1 -
 drivers/media/i2c/adv7175.c  | 1 -
 drivers/media/i2c/adv7180.c  | 1 -
 drivers/media/i2c/adv7343.c  | 1 -
 drivers/media/i2c/adv7511.c  | 1 -
 drivers/media/i2c/adv7604.c  | 1 -
 drivers/media/i2c/adv7842.c  | 1 -
 drivers/media/i2c/bt819.c| 1 -
 drivers/media/i2c/bt856.c| 1 -
 drivers/media/i2c/bt866.c| 1 -
 drivers/media/i2c/cs5345.c   | 1 -
 drivers/media/i2c/cs53l32a.c | 1 -
 drivers/media/i2c/cx25840/cx25840-core.c | 1 -
 drivers/media/i2c/ks0127.c   | 1 -
 drivers/media/i2c/m52790.c   | 1 -
 drivers/media/i2c/msp3400-driver.c   | 1 -
 drivers/media/i2c/mt9v011.c  | 1 -
 drivers/media/i2c/ov7640.c   | 1 -
 drivers/media/i2c/ov7670.c   | 1 -
 drivers/media/i2c/saa6588.c  | 1 -
 drivers/media/i2c/saa6752hs.c| 1 -
 drivers/media/i2c/saa7110.c  | 1 -
 drivers/media/i2c/saa7115.c  | 1 -
 drivers/media/i2c/saa7127.c  | 1 -
 drivers/media/i2c/saa717x.c  | 1 -
 drivers/media/i2c/saa7185.c  | 1 -
 drivers/media/i2c/sony-btf-mpx.c | 1 -
 drivers/media/i2c/tda7432.c  | 1 -
 drivers/media/i2c/tda9840.c  | 1 -
 drivers/media/i2c/tea6415c.c | 1 -
 drivers/media/i2c/tea6420.c  | 1 -
 drivers/media/i2c/ths7303.c  | 1 -
 drivers/media/i2c/tvaudio.c  | 1 -
 drivers/media/i2c/tvp5150.c  | 1 -
 drivers/media/i2c/tw9903.c   | 1 -
 drivers/media/i2c/tw9906.c   | 1 -
 drivers/media/i2c/upd64031a.c| 1 -
 drivers/media/i2c/upd64083.c | 1 -
 drivers/media/i2c/vp27smpx.c | 1 -
 drivers/media/i2c/vpx3220.c  | 1 -
 drivers/media/i2c/wm8739.c   | 1 -
 drivers/media/i2c/wm8775.c   | 1 -
 drivers/media/platform/s5p-tv/hdmiphy_drv.c  | 1 -
 drivers/media/platform/s5p-tv/sii9234_drv.c  | 1 -
 drivers/media/radio/radio-tea5764.c  | 1 -
 drivers/media/radio/saa7706h.c   | 1 -
 drivers/media/radio/tef6862.c| 1 -
 drivers/media/tuners/e4000.c | 1 -
 drivers/media/tuners/fc2580.c| 1 -
 drivers/media/tuners/it913x.c| 1 -
 drivers/media/tuners/m88rs6000t.c| 1 -
 drivers/media/tuners/si2157.c| 1 -
 drivers/media/tuners/tda18212.c  | 1 -
 drivers/media/tuners/tua9001.c   | 1 -
 drivers/media/usb/go7007/s2250-board.c   | 1 -
 drivers/media/v4l2-core/tuner-core.c | 1 -
 67 files changed, 67 deletions(-)

-- 
1.9.1

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


[PATCH 3/3] staging: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c 
b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
index 0f524bb7b41d..1f9ba8beb061 100644
--- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
+++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
@@ -1126,7 +1126,6 @@ MODULE_DEVICE_TABLE(i2c, synaptics_rmi4_id_table);
 static struct i2c_driver synaptics_rmi4_driver = {
.driver = {
.name   =   DRIVER_NAME,
-   .owner  =   THIS_MODULE,
.pm =   synaptics_rmi4_dev_pm_ops,
},
.probe  =   synaptics_rmi4_probe,
-- 
1.9.1

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


[PATCH] Drop owner assignment from i2c_driver (and platform left-overs)

2015-07-10 Thread Krzysztof Kozlowski
Hi,


The i2c drivers also do not have to set 'owner' field because
i2c_register_driver() will do it instead.

'owner' is removed from i2c drivers, which I was able to compile
with allyesconfig (arm, arm64, i386, x86_64, ppc64).
Only compile-tested.

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html


Best regards,
Krzysztof


Krzysztof Kozlowski (3):
  staging: iio: Drop owner assignment from i2c_driver
  staging: media: Drop owner assignment from i2c_driver
  staging: Drop owner assignment from i2c_driver

 drivers/staging/iio/addac/adt7316-i2c.c   | 1 -
 drivers/staging/iio/light/isl29018.c  | 1 -
 drivers/staging/iio/light/isl29028.c  | 1 -
 drivers/staging/media/lirc/lirc_zilog.c   | 1 -
 drivers/staging/media/mn88472/mn88472.c   | 1 -
 drivers/staging/media/mn88473/mn88473.c   | 1 -
 drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 1 -
 7 files changed, 7 deletions(-)

-- 
1.9.1

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


[PATCH 4/7] [media] platform: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/media/platform/s5p-tv/hdmiphy_drv.c | 1 -
 drivers/media/platform/s5p-tv/sii9234_drv.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/hdmiphy_drv.c 
b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
index c2f2e35642f2..aae652351aa8 100644
--- a/drivers/media/platform/s5p-tv/hdmiphy_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
@@ -315,7 +315,6 @@ MODULE_DEVICE_TABLE(i2c, hdmiphy_id);
 static struct i2c_driver hdmiphy_driver = {
.driver = {
.name   = s5p-hdmiphy,
-   .owner  = THIS_MODULE,
},
.probe  = hdmiphy_probe,
.remove = hdmiphy_remove,
diff --git a/drivers/media/platform/s5p-tv/sii9234_drv.c 
b/drivers/media/platform/s5p-tv/sii9234_drv.c
index db8c17bb4aaa..8d171310af8f 100644
--- a/drivers/media/platform/s5p-tv/sii9234_drv.c
+++ b/drivers/media/platform/s5p-tv/sii9234_drv.c
@@ -397,7 +397,6 @@ MODULE_DEVICE_TABLE(i2c, sii9234_id);
 static struct i2c_driver sii9234_driver = {
.driver = {
.name   = sii9234,
-   .owner  = THIS_MODULE,
.pm = sii9234_pm_ops,
},
.probe  = sii9234_probe,
-- 
1.9.1

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


[PATCH 2/7] [media] dvb-frontends: Drop owner assignment from platform_driver

2015-07-10 Thread Krzysztof Kozlowski
platform_driver does not need to set an owner because
platform_driver_register() will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/media/dvb-frontends/rtl2832_sdr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c 
b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 7edb885ae9c8..d5b994f17612 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -1538,7 +1538,6 @@ static int rtl2832_sdr_remove(struct platform_device 
*pdev)
 static struct platform_driver rtl2832_sdr_driver = {
.driver = {
.name   = rtl2832_sdr,
-   .owner  = THIS_MODULE,
},
.probe  = rtl2832_sdr_probe,
.remove = rtl2832_sdr_remove,
-- 
1.9.1

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


[PATCH 1/7] [media] dvb-frontends: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/media/dvb-frontends/a8293.c  | 1 -
 drivers/media/dvb-frontends/af9033.c | 1 -
 drivers/media/dvb-frontends/au8522_decoder.c | 1 -
 drivers/media/dvb-frontends/m88ds3103.c  | 1 -
 drivers/media/dvb-frontends/rtl2830.c| 1 -
 drivers/media/dvb-frontends/rtl2832.c| 1 -
 drivers/media/dvb-frontends/si2168.c | 1 -
 drivers/media/dvb-frontends/sp2.c| 1 -
 drivers/media/dvb-frontends/tda10071.c   | 1 -
 drivers/media/dvb-frontends/ts2020.c | 1 -
 10 files changed, 10 deletions(-)

diff --git a/drivers/media/dvb-frontends/a8293.c 
b/drivers/media/dvb-frontends/a8293.c
index 97ecbe01034c..df3c9758a903 100644
--- a/drivers/media/dvb-frontends/a8293.c
+++ b/drivers/media/dvb-frontends/a8293.c
@@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(i2c, a8293_id_table);
 
 static struct i2c_driver a8293_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = a8293,
.suppress_bind_attrs = true,
},
diff --git a/drivers/media/dvb-frontends/af9033.c 
b/drivers/media/dvb-frontends/af9033.c
index 59018afaa95f..bc35206a0821 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -1387,7 +1387,6 @@ MODULE_DEVICE_TABLE(i2c, af9033_id_table);
 
 static struct i2c_driver af9033_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = af9033,
},
.probe  = af9033_probe,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c 
b/drivers/media/dvb-frontends/au8522_decoder.c
index 33aa9410b624..28d7dc2fee34 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -820,7 +820,6 @@ MODULE_DEVICE_TABLE(i2c, au8522_id);
 
 static struct i2c_driver au8522_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = au8522,
},
.probe  = au8522_probe,
diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index e9b2d2b69b1d..ff31e7a01ca9 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -1495,7 +1495,6 @@ MODULE_DEVICE_TABLE(i2c, m88ds3103_id_table);
 
 static struct i2c_driver m88ds3103_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = m88ds3103,
.suppress_bind_attrs = true,
},
diff --git a/drivers/media/dvb-frontends/rtl2830.c 
b/drivers/media/dvb-frontends/rtl2830.c
index 3d01f4f22aca..b792f305cf15 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -915,7 +915,6 @@ MODULE_DEVICE_TABLE(i2c, rtl2830_id_table);
 
 static struct i2c_driver rtl2830_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = rtl2830,
},
.probe  = rtl2830_probe,
diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index 822ea4b7a7ff..78b87b260d74 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -1319,7 +1319,6 @@ MODULE_DEVICE_TABLE(i2c, rtl2832_id_table);
 
 static struct i2c_driver rtl2832_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = rtl2832,
},
.probe  = rtl2832_probe,
diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 25e238c370e5..81788c5a44d8 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -757,7 +757,6 @@ MODULE_DEVICE_TABLE(i2c, si2168_id_table);
 
 static struct i2c_driver si2168_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = si2168,
},
.probe  = si2168_probe,
diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
index 8fd42767e263..43d47dfcc7b8 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -426,7 +426,6 @@ MODULE_DEVICE_TABLE(i2c, sp2_id);
 
 static struct i2c_driver sp2_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = sp2,
},
.probe  = sp2_probe,
diff --git a/drivers/media/dvb-frontends/tda10071.c 
b/drivers/media/dvb-frontends/tda10071.c
index f6dc6307d35a..2b7d6ca69945 100644
--- a/drivers/media/dvb-frontends/tda10071.c
+++ b/drivers/media/dvb-frontends/tda10071.c
@@ -1409,7 +1409,6 @@ MODULE_DEVICE_TABLE(i2c, tda10071_id_table);
 
 static struct i2c_driver tda10071_driver = {
.driver = {
-   

[PATCH 6/7] [media] tuners: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/media/tuners/e4000.c  | 1 -
 drivers/media/tuners/fc2580.c | 1 -
 drivers/media/tuners/it913x.c | 1 -
 drivers/media/tuners/m88rs6000t.c | 1 -
 drivers/media/tuners/si2157.c | 1 -
 drivers/media/tuners/tda18212.c   | 1 -
 drivers/media/tuners/tua9001.c| 1 -
 7 files changed, 7 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 03538f88f488..564a000f503e 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -752,7 +752,6 @@ MODULE_DEVICE_TABLE(i2c, e4000_id_table);
 
 static struct i2c_driver e4000_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = e4000,
.suppress_bind_attrs = true,
},
diff --git a/drivers/media/tuners/fc2580.c b/drivers/media/tuners/fc2580.c
index 12f916e53150..f4d4665de168 100644
--- a/drivers/media/tuners/fc2580.c
+++ b/drivers/media/tuners/fc2580.c
@@ -632,7 +632,6 @@ MODULE_DEVICE_TABLE(i2c, fc2580_id_table);
 
 static struct i2c_driver fc2580_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = fc2580,
.suppress_bind_attrs = true,
},
diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c
index a076c87eda7a..5c96da693289 100644
--- a/drivers/media/tuners/it913x.c
+++ b/drivers/media/tuners/it913x.c
@@ -463,7 +463,6 @@ MODULE_DEVICE_TABLE(i2c, it913x_id_table);
 
 static struct i2c_driver it913x_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = it913x,
},
.probe  = it913x_probe,
diff --git a/drivers/media/tuners/m88rs6000t.c 
b/drivers/media/tuners/m88rs6000t.c
index d4c13fe6e7b3..504bfbc4027a 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -729,7 +729,6 @@ MODULE_DEVICE_TABLE(i2c, m88rs6000t_id);
 
 static struct i2c_driver m88rs6000t_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = m88rs6000t,
},
.probe  = m88rs6000t_probe,
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index a6245ef379c4..507382160e5e 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -469,7 +469,6 @@ MODULE_DEVICE_TABLE(i2c, si2157_id_table);
 
 static struct i2c_driver si2157_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = si2157,
},
.probe  = si2157_probe,
diff --git a/drivers/media/tuners/tda18212.c b/drivers/media/tuners/tda18212.c
index d93e0667b46b..7b8068354fea 100644
--- a/drivers/media/tuners/tda18212.c
+++ b/drivers/media/tuners/tda18212.c
@@ -277,7 +277,6 @@ MODULE_DEVICE_TABLE(i2c, tda18212_id);
 
 static struct i2c_driver tda18212_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = tda18212,
},
.probe  = tda18212_probe,
diff --git a/drivers/media/tuners/tua9001.c b/drivers/media/tuners/tua9001.c
index d4f6ca0c4d92..9d70378fe2d3 100644
--- a/drivers/media/tuners/tua9001.c
+++ b/drivers/media/tuners/tua9001.c
@@ -267,7 +267,6 @@ MODULE_DEVICE_TABLE(i2c, tua9001_id_table);
 
 static struct i2c_driver tua9001_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = tua9001,
.suppress_bind_attrs = true,
},
-- 
1.9.1

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


[PATCH 3/7] [media] i2c: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/media/i2c/adv7170.c  | 1 -
 drivers/media/i2c/adv7175.c  | 1 -
 drivers/media/i2c/adv7180.c  | 1 -
 drivers/media/i2c/adv7343.c  | 1 -
 drivers/media/i2c/adv7511.c  | 1 -
 drivers/media/i2c/adv7604.c  | 1 -
 drivers/media/i2c/adv7842.c  | 1 -
 drivers/media/i2c/bt819.c| 1 -
 drivers/media/i2c/bt856.c| 1 -
 drivers/media/i2c/bt866.c| 1 -
 drivers/media/i2c/cs5345.c   | 1 -
 drivers/media/i2c/cs53l32a.c | 1 -
 drivers/media/i2c/cx25840/cx25840-core.c | 1 -
 drivers/media/i2c/ks0127.c   | 1 -
 drivers/media/i2c/m52790.c   | 1 -
 drivers/media/i2c/msp3400-driver.c   | 1 -
 drivers/media/i2c/mt9v011.c  | 1 -
 drivers/media/i2c/ov7640.c   | 1 -
 drivers/media/i2c/ov7670.c   | 1 -
 drivers/media/i2c/saa6588.c  | 1 -
 drivers/media/i2c/saa6752hs.c| 1 -
 drivers/media/i2c/saa7110.c  | 1 -
 drivers/media/i2c/saa7115.c  | 1 -
 drivers/media/i2c/saa7127.c  | 1 -
 drivers/media/i2c/saa717x.c  | 1 -
 drivers/media/i2c/saa7185.c  | 1 -
 drivers/media/i2c/sony-btf-mpx.c | 1 -
 drivers/media/i2c/tda7432.c  | 1 -
 drivers/media/i2c/tda9840.c  | 1 -
 drivers/media/i2c/tea6415c.c | 1 -
 drivers/media/i2c/tea6420.c  | 1 -
 drivers/media/i2c/ths7303.c  | 1 -
 drivers/media/i2c/tvaudio.c  | 1 -
 drivers/media/i2c/tvp5150.c  | 1 -
 drivers/media/i2c/tw9903.c   | 1 -
 drivers/media/i2c/tw9906.c   | 1 -
 drivers/media/i2c/upd64031a.c| 1 -
 drivers/media/i2c/upd64083.c | 1 -
 drivers/media/i2c/vp27smpx.c | 1 -
 drivers/media/i2c/vpx3220.c  | 1 -
 drivers/media/i2c/wm8739.c   | 1 -
 drivers/media/i2c/wm8775.c   | 1 -
 42 files changed, 42 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index f0d3f5a2da46..05f1dc6c72af 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -401,7 +401,6 @@ MODULE_DEVICE_TABLE(i2c, adv7170_id);
 
 static struct i2c_driver adv7170_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = adv7170,
},
.probe  = adv7170_probe,
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index 321834ba8f57..f554809a51e7 100644
--- a/drivers/media/i2c/adv7175.c
+++ b/drivers/media/i2c/adv7175.c
@@ -455,7 +455,6 @@ MODULE_DEVICE_TABLE(i2c, adv7175_id);
 
 static struct i2c_driver adv7175_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = adv7175,
},
.probe  = adv7175_probe,
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index a493c0b0b5fe..db4a09ac1cea 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1326,7 +1326,6 @@ static SIMPLE_DEV_PM_OPS(adv7180_pm_ops, adv7180_suspend, 
adv7180_resume);
 
 static struct i2c_driver adv7180_driver = {
.driver = {
-  .owner = THIS_MODULE,
   .name = KBUILD_MODNAME,
   .pm = ADV7180_PM_OPS,
   },
diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index 7c50833e7d17..5f7a3bfcb905 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -529,7 +529,6 @@ MODULE_DEVICE_TABLE(of, adv7343_of_match);
 static struct i2c_driver adv7343_driver = {
.driver = {
.of_match_table = of_match_ptr(adv7343_of_match),
-   .owner  = THIS_MODULE,
.name   = adv7343,
},
.probe  = adv7343_probe,
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 95bcd4026451..ef198cee8969 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -1576,7 +1576,6 @@ MODULE_DEVICE_TABLE(i2c, adv7511_id);
 
 static struct i2c_driver adv7511_driver = {
.driver = {
-   .owner = THIS_MODULE,
.name = adv7511,
},
.probe = adv7511_probe,
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 808360fd6539..ee59f41d9951 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2985,7 +2985,6 @@ static int adv76xx_remove(struct i2c_client *client)
 
 static struct i2c_driver adv76xx_driver = {
.driver = {
-   .owner = THIS_MODULE,
.name = adv7604,

[PATCH 7/7] [media] Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/media/usb/go7007/s2250-board.c | 1 -
 drivers/media/v4l2-core/tuner-core.c   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/media/usb/go7007/s2250-board.c 
b/drivers/media/usb/go7007/s2250-board.c
index 5c2a49534d2b..1466db150d82 100644
--- a/drivers/media/usb/go7007/s2250-board.c
+++ b/drivers/media/usb/go7007/s2250-board.c
@@ -629,7 +629,6 @@ MODULE_DEVICE_TABLE(i2c, s2250_id);
 
 static struct i2c_driver s2250_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = s2250,
},
.probe  = s2250_probe,
diff --git a/drivers/media/v4l2-core/tuner-core.c 
b/drivers/media/v4l2-core/tuner-core.c
index abdcffabcb59..581e21ad6801 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -1366,7 +1366,6 @@ MODULE_DEVICE_TABLE(i2c, tuner_id);
 
 static struct i2c_driver tuner_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = tuner,
.pm = tuner_pm_ops,
},
-- 
1.9.1

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


[PATCH 5/7] [media] radio: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/media/radio/radio-tea5764.c | 1 -
 drivers/media/radio/saa7706h.c  | 1 -
 drivers/media/radio/tef6862.c   | 1 -
 3 files changed, 3 deletions(-)

diff --git a/drivers/media/radio/radio-tea5764.c 
b/drivers/media/radio/radio-tea5764.c
index cc3990111411..a1930b300c06 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -526,7 +526,6 @@ MODULE_DEVICE_TABLE(i2c, tea5764_id);
 static struct i2c_driver tea5764_i2c_driver = {
.driver = {
.name = radio-tea5764,
-   .owner = THIS_MODULE,
},
.probe = tea5764_i2c_probe,
.remove = tea5764_i2c_remove,
diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c
index ec805b09c608..53a5de1af9b4 100644
--- a/drivers/media/radio/saa7706h.c
+++ b/drivers/media/radio/saa7706h.c
@@ -429,7 +429,6 @@ MODULE_DEVICE_TABLE(i2c, saa7706h_id);
 
 static struct i2c_driver saa7706h_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = DRIVER_NAME,
},
.probe  = saa7706h_probe,
diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c
index a9319a24c7ef..9f879f0ec0ef 100644
--- a/drivers/media/radio/tef6862.c
+++ b/drivers/media/radio/tef6862.c
@@ -195,7 +195,6 @@ MODULE_DEVICE_TABLE(i2c, tef6862_id);
 
 static struct i2c_driver tef6862_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = DRIVER_NAME,
},
.probe  = tef6862_probe,
-- 
1.9.1

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


[PATCH 1/3] staging: iio: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/staging/iio/addac/adt7316-i2c.c | 1 -
 drivers/staging/iio/light/isl29018.c| 1 -
 drivers/staging/iio/light/isl29028.c| 1 -
 3 files changed, 3 deletions(-)

diff --git a/drivers/staging/iio/addac/adt7316-i2c.c 
b/drivers/staging/iio/addac/adt7316-i2c.c
index 75ddd4f801a3..78fe0b557280 100644
--- a/drivers/staging/iio/addac/adt7316-i2c.c
+++ b/drivers/staging/iio/addac/adt7316-i2c.c
@@ -124,7 +124,6 @@ static struct i2c_driver adt7316_driver = {
.driver = {
.name = adt7316,
.pm = ADT7316_PM_OPS,
-   .owner  = THIS_MODULE,
},
.probe = adt7316_i2c_probe,
.id_table = adt7316_i2c_id,
diff --git a/drivers/staging/iio/light/isl29018.c 
b/drivers/staging/iio/light/isl29018.c
index e646c5d24004..019ba5245c23 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -838,7 +838,6 @@ static struct i2c_driver isl29018_driver = {
.name = isl29018,
.acpi_match_table = ACPI_PTR(isl29018_acpi_match),
.pm = ISL29018_PM_OPS,
-   .owner = THIS_MODULE,
.of_match_table = isl29018_of_match,
},
.probe   = isl29018_probe,
diff --git a/drivers/staging/iio/light/isl29028.c 
b/drivers/staging/iio/light/isl29028.c
index e5b2fdc2334b..cd6f2727aa58 100644
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -547,7 +547,6 @@ static struct i2c_driver isl29028_driver = {
.class  = I2C_CLASS_HWMON,
.driver  = {
.name = isl29028,
-   .owner = THIS_MODULE,
.of_match_table = isl29028_of_match,
},
.probe   = isl29028_probe,
-- 
1.9.1

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


[PATCH 2/3] staging: media: Drop owner assignment from i2c_driver

2015-07-10 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/staging/media/lirc/lirc_zilog.c | 1 -
 drivers/staging/media/mn88472/mn88472.c | 1 -
 drivers/staging/media/mn88473/mn88473.c | 1 -
 3 files changed, 3 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index 261e27d6b054..d032745081ee 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1367,7 +1367,6 @@ static const struct i2c_device_id ir_transceiver_id[] = {
 
 static struct i2c_driver driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = Zilog/Hauppauge i2c IR,
},
.probe  = ir_probe,
diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index a8d45f44765c..cf2e96bcf395 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -561,7 +561,6 @@ MODULE_DEVICE_TABLE(i2c, mn88472_id_table);
 
 static struct i2c_driver mn88472_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = mn88472,
},
.probe  = mn88472_probe,
diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index f9146a146d07..a222e99935d2 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -507,7 +507,6 @@ MODULE_DEVICE_TABLE(i2c, mn88473_id_table);
 
 static struct i2c_driver mn88473_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = mn88473,
},
.probe  = mn88473_probe,
-- 
1.9.1

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


[PATCH 1/2] [media] bdisp: composing support

2015-07-10 Thread Fabien Dessenne
Support the composing (at VIDEO_CAPTURE) with the _selection API.
v4l2-compliance successfully run (test Composing: OK)

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/bdisp-hw.c   |  8 +--
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 76 ++-
 2 files changed, 55 insertions(+), 29 deletions(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
b/drivers/media/platform/sti/bdisp/bdisp-hw.c
index 465828e..c83f9c2 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
@@ -336,8 +336,8 @@ static int bdisp_hw_get_hv_inc(struct bdisp_ctx *ctx, u16 
*h_inc, u16 *v_inc)
 
src_w = ctx-src.crop.width;
src_h = ctx-src.crop.height;
-   dst_w = ctx-dst.width;
-   dst_h = ctx-dst.height;
+   dst_w = ctx-dst.crop.width;
+   dst_h = ctx-dst.crop.height;
 
if (bdisp_hw_get_inc(src_w, dst_w, h_inc) ||
bdisp_hw_get_inc(src_h, dst_h, v_inc)) {
@@ -483,9 +483,9 @@ static void bdisp_hw_build_node(struct bdisp_ctx *ctx,
src_rect.width -= src_x_offset;
src_rect.width = min_t(__s32, MAX_SRC_WIDTH, src_rect.width);
 
-   dst_x_offset = (src_x_offset * dst-width) / ctx-src.crop.width;
+   dst_x_offset = (src_x_offset * dst_width) / ctx-src.crop.width;
dst_rect.left += dst_x_offset;
-   dst_rect.width = (src_rect.width * dst-width) / ctx-src.crop.width;
+   dst_rect.width = (src_rect.width * dst_width) / ctx-src.crop.width;
 
/* General */
src_fmt = src-fmt-pixelformat;
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index 9e782eb..df61355 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -851,33 +851,56 @@ static int bdisp_g_selection(struct file *file, void *fh,
struct bdisp_frame *frame;
struct bdisp_ctx *ctx = fh_to_ctx(fh);
 
-   if (s-type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-   /* Composing  / capture is not supported */
-   dev_dbg(ctx-bdisp_dev-dev, Not supported for capture\n);
-   return -EINVAL;
-   }
-
frame = ctx_get_frame(ctx, s-type);
if (IS_ERR(frame)) {
dev_err(ctx-bdisp_dev-dev, Invalid frame (%p)\n, frame);
return PTR_ERR(frame);
}
 
-   switch (s-target) {
-   case V4L2_SEL_TGT_CROP:
-   /* cropped frame */
-   s-r = frame-crop;
+   switch (s-type) {
+   case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+   switch (s-target) {
+   case V4L2_SEL_TGT_CROP:
+   /* cropped frame */
+   s-r = frame-crop;
+   break;
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   /* complete frame */
+   s-r.left = 0;
+   s-r.top = 0;
+   s-r.width = frame-width;
+   s-r.height = frame-height;
+   break;
+   default:
+   dev_err(ctx-bdisp_dev-dev, Invalid target\n);
+   return -EINVAL;
+   }
break;
-   case V4L2_SEL_TGT_CROP_DEFAULT:
-   case V4L2_SEL_TGT_CROP_BOUNDS:
-   /* complete frame */
-   s-r.left = 0;
-   s-r.top = 0;
-   s-r.width = frame-width;
-   s-r.height = frame-height;
+
+   case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+   switch (s-target) {
+   case V4L2_SEL_TGT_COMPOSE:
+   case V4L2_SEL_TGT_COMPOSE_PADDED:
+   /* composed (cropped) frame */
+   s-r = frame-crop;
+   break;
+   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+   /* complete frame */
+   s-r.left = 0;
+   s-r.top = 0;
+   s-r.width = frame-width;
+   s-r.height = frame-height;
+   break;
+   default:
+   dev_err(ctx-bdisp_dev-dev, Invalid target\n);
+   return -EINVAL;
+   }
break;
+
default:
-   dev_dbg(ctx-bdisp_dev-dev, Invalid target\n);
+   dev_err(ctx-bdisp_dev-dev, Invalid type\n);
return -EINVAL;
}
 
@@ -906,15 +929,18 @@ static int bdisp_s_selection(struct file *file, void *fh,
struct bdisp_frame *frame;
struct bdisp_ctx *ctx = fh_to_ctx(fh);
struct v4l2_rect *in, out;
+   bool valid = false;
 
-   if (s-type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-   /* Composing  / capture is not supported */
-   

[PATCH 2/2] [media] bdisp: add debug info for RGB24 format

2015-07-10 Thread Fabien Dessenne
Add this missing debug information

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/bdisp-debug.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c 
b/drivers/media/platform/sti/bdisp/bdisp-debug.c
index 18282a0..79c5635 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
@@ -116,6 +116,9 @@ static void bdisp_dbg_dump_tty(struct seq_file *s, u32 val)
case BDISP_RGB565:
seq_puts(s, RGB565 - );
break;
+   case BDISP_RGB888:
+   seq_puts(s, RGB888 - );
+   break;
case BDISP_XRGB:
seq_puts(s, xRGB888 - );
break;
@@ -185,6 +188,9 @@ static void bdisp_dbg_dump_sty(struct seq_file *s,
case BDISP_RGB565:
seq_puts(s, RGB565 - );
break;
+   case BDISP_RGB888:
+   seq_puts(s, RGB888 - );
+   break;
case BDISP_XRGB:
seq_puts(s, xRGB888 - );
break;
@@ -420,6 +426,8 @@ static const char *bdisp_fmt_to_str(struct bdisp_frame 
frame)
return NV12;
case V4L2_PIX_FMT_RGB565:
return RGB16;
+   case V4L2_PIX_FMT_RGB24:
+   return RGB24;
case V4L2_PIX_FMT_XBGR32:
return XRGB;
case V4L2_PIX_FMT_ABGR32:
-- 
1.9.1

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


[PATCH v2 1/2] genalloc: add name arg to gen_pool_get() and devm_gen_pool_create()

2015-07-10 Thread Vladimir Zapolskiy
This change modifies gen_pool_get() and devm_gen_pool_create() client
interfaces adding one more argument name of a gen_pool object.

Due to implementation gen_pool_get() is capable to retrieve only one
gen_pool associated with a device even if multiple gen_pools are created,
fortunately right at the moment it is sufficient for the clients, hence
provide NULL as a valid argument on both producer devm_gen_pool_create()
and consumer gen_pool_get() sides.

Because only one created gen_pool per device is addressable, explicitly
add a restriction to devm_gen_pool_create() to create only one gen_pool
per device, this implies two possible error codes returned by the
function, account it on client side (only misc/sram).  This completes
client side changes related to genalloc updates.

Signed-off-by: Vladimir Zapolskiy vladimir_zapols...@mentor.com
Cc: Philipp Zabel p.za...@pengutronix.de
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Russell King li...@arm.linux.org.uk
Cc: Nicolas Ferre nicolas.fe...@atmel.com
Cc: Alexandre Belloni alexandre.bell...@free-electrons.com
Cc: Jean-Christophe Plagniol-Villard plagn...@jcrosoft.com
Cc: Shawn Guo shawn...@kernel.org
Cc: Sascha Hauer ker...@pengutronix.de
Cc: Mauro Carvalho Chehab mche...@osg.samsung.com
Cc: Arnd Bergmann a...@arndb.de
Cc: Dinh Nguyen dingu...@opensource.altera.com
---

Changes from v1 to v2:
* Added the same change in gen_pool_get() argument list
  to account a recently added client in arm/mach-socfpga/pm.c

 arch/arm/mach-at91/pm.c   |  2 +-
 arch/arm/mach-imx/pm-imx5.c   |  2 +-
 arch/arm/mach-imx/pm-imx6.c   |  2 +-
 arch/arm/mach-socfpga/pm.c|  2 +-
 drivers/media/platform/coda/coda-common.c |  2 +-
 drivers/misc/sram.c   |  8 ++---
 include/linux/genalloc.h  |  4 +--
 lib/genalloc.c| 49 ++-
 8 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index e24df77..e65e9db 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -369,7 +369,7 @@ static void __init at91_pm_sram_init(void)
return;
}
 
-   sram_pool = gen_pool_get(pdev-dev);
+   sram_pool = gen_pool_get(pdev-dev, NULL);
if (!sram_pool) {
pr_warn(%s: sram pool unavailable!\n, __func__);
return;
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index 1885676..532d4b0 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -297,7 +297,7 @@ static int __init imx_suspend_alloc_ocram(
goto put_node;
}
 
-   ocram_pool = gen_pool_get(pdev-dev);
+   ocram_pool = gen_pool_get(pdev-dev, NULL);
if (!ocram_pool) {
pr_warn(%s: ocram pool unavailable!\n, __func__);
ret = -ENODEV;
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
index 93ecf55..8ff8fc0 100644
--- a/arch/arm/mach-imx/pm-imx6.c
+++ b/arch/arm/mach-imx/pm-imx6.c
@@ -451,7 +451,7 @@ static int __init imx6q_suspend_init(const struct 
imx6_pm_socdata *socdata)
goto put_node;
}
 
-   ocram_pool = gen_pool_get(pdev-dev);
+   ocram_pool = gen_pool_get(pdev-dev, NULL);
if (!ocram_pool) {
pr_warn(%s: ocram pool unavailable!\n, __func__);
ret = -ENODEV;
diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c
index 6a4199f..c378ab0 100644
--- a/arch/arm/mach-socfpga/pm.c
+++ b/arch/arm/mach-socfpga/pm.c
@@ -56,7 +56,7 @@ static int socfpga_setup_ocram_self_refresh(void)
goto put_node;
}
 
-   ocram_pool = gen_pool_get(pdev-dev);
+   ocram_pool = gen_pool_get(pdev-dev, NULL);
if (!ocram_pool) {
pr_warn(%s: ocram pool unavailable!\n, __func__);
ret = -ENODEV;
diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 58f6548..284ac4c 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2157,7 +2157,7 @@ static int coda_probe(struct platform_device *pdev)
/* Get IRAM pool from device tree or platform data */
pool = of_gen_pool_get(np, iram, 0);
if (!pool  pdata)
-   pool = gen_pool_get(pdata-iram_dev);
+   pool = gen_pool_get(pdata-iram_dev, NULL);
if (!pool) {
dev_err(pdev-dev, iram pool not available\n);
return -ENOMEM;
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index 15c33cc..431e1dd 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -186,10 +186,10 @@ static int sram_probe(struct platform_device *pdev)
if (IS_ERR(sram-virt_base))
return PTR_ERR(sram-virt_base);
 
-   sram-pool = devm_gen_pool_create(sram-dev,
-   

[PATCH v3 0/2] RFC: Secure Memory Allocation Framework

2015-07-10 Thread Benjamin Gaignard
version 3 changes:
 - Remove ioctl for allocator selection instead provide the name of
   the targeted allocator with allocation request.
   Selecting allocator from userland isn't the prefered way of working
   but is needed when the first user of the buffer is a software component.
 - Fix issues in case of error while creating smaf handle.
 - Fix module license.
 - Update libsmaf and tests to care of the SMAF API evolution
   https://git.linaro.org/people/benjamin.gaignard/libsmaf.git

version 2 changes:
 - Add one ioctl to allow allocator selection from userspace.
   This is required for the uses case where the first user of
   the buffer is a software IP which can't perform dma_buf attachement.
 - Add name and ranking to allocator structure to be able to sort them.
 - Create a tiny library to test SMAF:
   https://git.linaro.org/people/benjamin.gaignard/libsmaf.git
 - Fix one issue when try to secure buffer without secure module registered

The outcome of the previous RFC about how do secure data path was the need
of a secure memory allocator (https://lkml.org/lkml/2015/5/5/551)

SMAF goal is to provide a framework that allow allocating and securing
memory by using dma_buf. Each platform have it own way to perform those two
features so SMAF design allow to register helper modules to perform them.

To be sure to select the best allocation method for devices SMAF implement
deferred allocation mechanism: memory allocation is only done when the first
device effectively required it.
Allocator modules have to implement a match() to let SMAF know if they are
compatibles with devices needs.
This patch set provide an example of allocator module which use
dma_{alloc/free/mmap}_attrs() and check if at least one device have
coherent_dma_mask set to DMA_BIT_MASK(32) in match function. 
I have named smaf-cma.c like it is done for drm_gem_cma_helper.c even if 
a better name could be found for this file.

Secure modules are responsibles of granting and revoking devices access rights
on the memory. Secure module is also called to check if CPU map memory into
kernel and user address spaces.
An example of secure module implementation can be found here:
http://git.linaro.org/people/benjamin.gaignard/optee-sdp.git
This code isn't yet part of the patch set because it depends on generic TEE
which is still under discussion (https://lwn.net/Articles/644646/)

For allocation part of SMAF code I get inspirated by Sumit Semwal work about
constraint aware allocator.

Benjamin Gaignard (2):
  create SMAF module
  SMAF: add CMA allocator

 drivers/Kconfig|   2 +
 drivers/Makefile   |   1 +
 drivers/smaf/Kconfig   |  11 +
 drivers/smaf/Makefile  |   2 +
 drivers/smaf/smaf-cma.c| 200 +++
 drivers/smaf/smaf-core.c   | 735 +
 include/linux/smaf-allocator.h |  54 +++
 include/linux/smaf-secure.h|  62 
 include/uapi/linux/smaf.h  |  52 +++
 9 files changed, 1119 insertions(+)
 create mode 100644 drivers/smaf/Kconfig
 create mode 100644 drivers/smaf/Makefile
 create mode 100644 drivers/smaf/smaf-cma.c
 create mode 100644 drivers/smaf/smaf-core.c
 create mode 100644 include/linux/smaf-allocator.h
 create mode 100644 include/linux/smaf-secure.h
 create mode 100644 include/uapi/linux/smaf.h

-- 
1.9.1

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


[PATCH v3 1/2] create SMAF module

2015-07-10 Thread Benjamin Gaignard
Secure Memory Allocation Framework goal is to be able
to allocate memory that can be securing.
There is so much ways to allocate and securing memory that SMAF
doesn't do it by itself but need help of additional modules.
To be sure to use the correct allocation method SMAF implement
deferred allocation (i.e. allocate memory when only really needed)

Allocation modules (smaf-alloctor.h):
SMAF could manage with multiple allocation modules at same time.
To select the good one SMAF call match() to be sure that a module
can allocate memory for a given list of devices. It is to the module
to check if the devices are compatible or not with it allocation
method.

Securing module (smaf-secure.h):
The way of how securing memory it is done is platform specific.
Secure module is responsible of grant/revoke memory access.

Signed-off-by: Benjamin Gaignard benjamin.gaign...@linaro.org
---
 drivers/Kconfig|   2 +
 drivers/Makefile   |   1 +
 drivers/smaf/Kconfig   |   5 +
 drivers/smaf/Makefile  |   1 +
 drivers/smaf/smaf-core.c   | 735 +
 include/linux/smaf-allocator.h |  54 +++
 include/linux/smaf-secure.h|  62 
 include/uapi/linux/smaf.h  |  52 +++
 8 files changed, 912 insertions(+)
 create mode 100644 drivers/smaf/Kconfig
 create mode 100644 drivers/smaf/Makefile
 create mode 100644 drivers/smaf/smaf-core.c
 create mode 100644 include/linux/smaf-allocator.h
 create mode 100644 include/linux/smaf-secure.h
 create mode 100644 include/uapi/linux/smaf.h

diff --git a/drivers/Kconfig b/drivers/Kconfig
index c0cc96b..2421fcb 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -182,4 +182,6 @@ source drivers/thunderbolt/Kconfig
 
 source drivers/android/Kconfig
 
+source drivers/smaf/Kconfig
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 46d2554..0cca66e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -165,3 +165,4 @@ obj-$(CONFIG_RAS)   += ras/
 obj-$(CONFIG_THUNDERBOLT)  += thunderbolt/
 obj-$(CONFIG_CORESIGHT)+= hwtracing/coresight/
 obj-$(CONFIG_ANDROID)  += android/
+obj-$(CONFIG_SMAF) += smaf/
diff --git a/drivers/smaf/Kconfig b/drivers/smaf/Kconfig
new file mode 100644
index 000..d36651a
--- /dev/null
+++ b/drivers/smaf/Kconfig
@@ -0,0 +1,5 @@
+config SMAF
+   tristate Secure Memory Allocation Framework
+   depends on DMA_SHARED_BUFFER
+   help
+ Choose this option to enable Secure Memory Allocation Framework
diff --git a/drivers/smaf/Makefile b/drivers/smaf/Makefile
new file mode 100644
index 000..40cd882
--- /dev/null
+++ b/drivers/smaf/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_SMAF) += smaf-core.o
diff --git a/drivers/smaf/smaf-core.c b/drivers/smaf/smaf-core.c
new file mode 100644
index 000..90a7a97
--- /dev/null
+++ b/drivers/smaf/smaf-core.c
@@ -0,0 +1,735 @@
+/*
+ * smaf.c
+ *
+ * Copyright (C) Linaro SA 2015
+ * Author: Benjamin Gaignard benjamin.gaign...@linaro.org for Linaro.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include linux/device.h
+#include linux/dma-buf.h
+#include linux/dma-mapping.h
+#include linux/fs.h
+#include linux/ioctl.h
+#include linux/list_sort.h
+#include linux/miscdevice.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/smaf.h
+#include linux/smaf-allocator.h
+#include linux/smaf-secure.h
+#include linux/uaccess.h
+
+struct smaf_handle {
+   struct dma_buf *dmabuf;
+   struct smaf_allocator *allocator;
+   struct dma_buf *db_alloc;
+   size_t length;
+   unsigned int flags;
+   int fd;
+   bool is_secure;
+   void *secure_ctx;
+};
+
+/**
+ * struct smaf_device - smaf device node private data
+ * @misc_dev:  the misc device
+ * @head:  list of allocator
+ * @lock:  list and secure pointer mutex
+ * @secure:pointer to secure functions helpers
+ */
+struct smaf_device {
+   struct miscdevice misc_dev;
+   struct list_head head;
+   /* list and secure pointer lock*/
+   struct mutex lock;
+   struct smaf_secure *secure;
+};
+
+static struct smaf_device smaf_dev;
+
+/**
+ * smaf_allow_cpu_access return true if CPU can access to memory
+ * if their is no secure module associated to SMAF assume that CPU can get
+ * access to the memory.
+ */
+static bool smaf_allow_cpu_access(struct smaf_handle *handle,
+ unsigned long flags)
+{
+   if (!handle-is_secure)
+   return true;
+
+   if (!smaf_dev.secure)
+   return true;
+
+   if (!smaf_dev.secure-allow_cpu_access)
+   return true;
+
+   return smaf_dev.secure-allow_cpu_access(handle-secure_ctx, flags);
+}
+
+static int smaf_grant_access(struct smaf_handle *handle, struct device *dev,
+dma_addr_t addr, size_t size,
+enum dma_data_direction dir)
+{
+   if (!handle-is_secure)
+   return 

[PATCH v3 2/2] SMAF: add CMA allocator

2015-07-10 Thread Benjamin Gaignard
SMAF CMA allocator implement helpers functions to allow SMAF
to allocate contiguous memory.

match() each if at least one of the attached devices have coherent_dma_mask
set to DMA_BIT_MASK(32).

For allocation it use dma_alloc_attrs() with DMA_ATTR_WRITE_COMBINE and not
dma_alloc_writecombine to be compatible with ARM 64bits architecture

Signed-off-by: Benjamin Gaignard benjamin.gaign...@linaro.org
---
 drivers/smaf/Kconfig|   6 ++
 drivers/smaf/Makefile   |   1 +
 drivers/smaf/smaf-cma.c | 200 
 3 files changed, 207 insertions(+)
 create mode 100644 drivers/smaf/smaf-cma.c

diff --git a/drivers/smaf/Kconfig b/drivers/smaf/Kconfig
index d36651a..058ec4c 100644
--- a/drivers/smaf/Kconfig
+++ b/drivers/smaf/Kconfig
@@ -3,3 +3,9 @@ config SMAF
depends on DMA_SHARED_BUFFER
help
  Choose this option to enable Secure Memory Allocation Framework
+
+config SMAF_CMA
+   tristate SMAF CMA allocator
+   depends on SMAF  HAVE_DMA_ATTRS
+   help
+ Choose this option to enable CMA allocation within SMAF
diff --git a/drivers/smaf/Makefile b/drivers/smaf/Makefile
index 40cd882..05bab01 100644
--- a/drivers/smaf/Makefile
+++ b/drivers/smaf/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_SMAF) += smaf-core.o
+obj-$(CONFIG_SMAF_CMA) += smaf-cma.o
diff --git a/drivers/smaf/smaf-cma.c b/drivers/smaf/smaf-cma.c
new file mode 100644
index 000..ab38717
--- /dev/null
+++ b/drivers/smaf/smaf-cma.c
@@ -0,0 +1,200 @@
+/*
+ * smaf-cma.c
+ *
+ * Copyright (C) Linaro SA 2015
+ * Author: Benjamin Gaignard benjamin.gaign...@linaro.org for Linaro.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include linux/dma-mapping.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/smaf-allocator.h
+
+struct smaf_cma_buffer_info {
+   struct device *dev;
+   size_t size;
+   void *vaddr;
+   dma_addr_t paddr;
+};
+
+/**
+ * find_matching_device - iterate over the attached devices to find one
+ * with coherent_dma_mask correctly set to DMA_BIT_MASK(32).
+ * Matching device (if any) will be used to aim CMA area.
+ */
+static struct device *find_matching_device(struct dma_buf *dmabuf)
+{
+   struct dma_buf_attachment *attach_obj;
+
+   list_for_each_entry(attach_obj, dmabuf-attachments, node) {
+   if (attach_obj-dev-coherent_dma_mask == DMA_BIT_MASK(32))
+   return attach_obj-dev;
+   }
+
+   return NULL;
+}
+
+/**
+ * smaf_cma_match - return true if at least one device has been found
+ */
+static bool smaf_cma_match(struct dma_buf *dmabuf)
+{
+   return !!find_matching_device(dmabuf);
+}
+
+static void smaf_cma_release(struct dma_buf *dmabuf)
+{
+   struct smaf_cma_buffer_info *info = dmabuf-priv;
+   DEFINE_DMA_ATTRS(attrs);
+
+   dma_set_attr(DMA_ATTR_WRITE_COMBINE, attrs);
+
+   dma_free_attrs(info-dev, info-size, info-vaddr, info-paddr, attrs);
+
+   kfree(info);
+}
+
+static struct sg_table *smaf_cma_map(struct dma_buf_attachment *attachment,
+enum dma_data_direction direction)
+{
+   struct smaf_cma_buffer_info *info = attachment-dmabuf-priv;
+   struct sg_table *sgt;
+   int ret;
+
+   sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
+   if (!sgt)
+   return NULL;
+
+   ret = dma_get_sgtable(info-dev, sgt, info-vaddr,
+ info-paddr, info-size);
+   if (ret  0)
+   goto out;
+
+   sg_dma_address(sgt-sgl) = info-paddr;
+   return sgt;
+
+out:
+   kfree(sgt);
+   return NULL;
+}
+
+static void smaf_cma_unmap(struct dma_buf_attachment *attachment,
+  struct sg_table *sgt,
+  enum dma_data_direction direction)
+{
+   /* do nothing */
+}
+
+static int smaf_cma_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
+{
+   struct smaf_cma_buffer_info *info = dmabuf-priv;
+   int ret;
+   DEFINE_DMA_ATTRS(attrs);
+
+   dma_set_attr(DMA_ATTR_WRITE_COMBINE, attrs);
+
+   if (info-size  vma-vm_end - vma-vm_start)
+   return -EINVAL;
+
+   vma-vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
+   ret = dma_mmap_attrs(info-dev, vma, info-vaddr, info-paddr,
+info-size, attrs);
+
+   return ret;
+}
+
+static void *smaf_cma_vmap(struct dma_buf *dmabuf)
+{
+   struct smaf_cma_buffer_info *info = dmabuf-priv;
+
+   return info-vaddr;
+}
+
+static void *smaf_kmap_atomic(struct dma_buf *dmabuf, unsigned long offset)
+{
+   struct smaf_cma_buffer_info *info = dmabuf-priv;
+
+   return (void *)info-paddr + offset;
+}
+
+static struct dma_buf_ops smaf_cma_ops = {
+   .map_dma_buf = smaf_cma_map,
+   .unmap_dma_buf = smaf_cma_unmap,
+   .mmap = smaf_cma_mmap,
+   .release = smaf_cma_release,
+   .kmap_atomic = smaf_kmap_atomic,
+   .kmap = smaf_kmap_atomic,
+   

[PATCH 5/5] [media] tc358743: allow event subscription

2015-07-10 Thread Philipp Zabel
This is useful to subscribe to HDMI hotplug events via the
V4L2_CID_DV_RX_POWER_PRESENT control.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/i2c/tc358743.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 4a889d4..91fffa8 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -40,6 +40,7 @@
 #include media/v4l2-dv-timings.h
 #include media/v4l2-device.h
 #include media/v4l2-ctrls.h
+#include media/v4l2-event.h
 #include media/v4l2-of.h
 #include media/tc358743.h
 
@@ -1604,6 +1605,8 @@ static const struct v4l2_subdev_core_ops 
tc358743_core_ops = {
.s_register = tc358743_s_register,
 #endif
.interrupt_service_routine = tc358743_isr,
+   .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+   .unsubscribe_event = v4l2_event_subdev_unsubscribe,
 };
 
 static const struct v4l2_subdev_video_ops tc358743_video_ops = {
-- 
2.1.4

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


[PATCH 3/5] [media] tc358743: support probe from device tree

2015-07-10 Thread Philipp Zabel
Add support for probing the TC358743 subdevice from device tree.
The reference clock must be supplied using the common clock bindings.
MIPI CSI-2 specific properties are parsed from the OF graph endpoint
node and support for a non-continuous MIPI CSI-2 clock is added.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 .../devicetree/bindings/media/i2c/tc358743.txt |  48 +++
 drivers/media/i2c/tc358743.c   | 153 -
 2 files changed, 195 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/tc358743.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/tc358743.txt 
b/Documentation/devicetree/bindings/media/i2c/tc358743.txt
new file mode 100644
index 000..5218921
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/tc358743.txt
@@ -0,0 +1,48 @@
+* Toshiba TC358743 HDMI-RX to MIPI CSI2-TX Bridge
+
+The Toshiba TC358743 HDMI-RX to MIPI CSI2-TX (H2C) is a bridge that converts
+a HDMI stream to MIPI CSI-2 TX. It is programmable through I2C.
+
+Required Properties:
+
+- compatible: value should be toshiba,tc358743
+- clocks, clock-names: should contain a phandle link to the reference clock
+  source, the clock input is named refclk.
+
+Optional Properties:
+
+- reset-gpios: gpio phandle GPIO connected to the reset pin
+- interrupts, interrupt-parent: GPIO connected to the interrupt pin
+- data-lanes: should be 1 2 3 4 for four-lane operation,
+ or 1 2 for two-lane operation
+- clock-lanes: should be 0
+- clock-noncontinuous: Presence of this boolean property decides whether the
+  MIPI CSI-2 clock is continuous or non-continuous.
+- link-frequencies: List of allowed link frequencies in Hz. Each frequency is
+   expressed as a 64-bit big-endian integer. The frequency
+   is half of the bps per lane due to DDR transmission.
+
+For further information on the MIPI CSI-2 endpoint node properties, see
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+
+   tc358743@0f {
+   compatible = toshiba,tc358743;
+   reg = 0x0f;
+   clocks = hdmi_osc;
+   clock-names = refclk;
+   reset-gpios = gpio6 9 GPIO_ACTIVE_LOW;
+   interrupt-parent = gpio2;
+   interrupts = 5 IRQ_TYPE_LEVEL_HIGH;
+
+   port {
+   tc358743_out: endpoint {
+   remote-endpoint = mipi_csi2_in;
+   data-lanes = 1 2 3 4;
+   clock-lanes = 0;
+   clock-noncontinuous;
+   link-frequencies = /bits/ 64 29700;
+   };
+   };
+   };
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 0be6d9f..02c60b3 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -29,7 +29,9 @@
 #include linux/module.h
 #include linux/slab.h
 #include linux/i2c.h
+#include linux/clk.h
 #include linux/delay.h
+#include linux/gpio/consumer.h
 #include linux/videodev2.h
 #include linux/workqueue.h
 #include linux/v4l2-dv-timings.h
@@ -37,6 +39,7 @@
 #include media/v4l2-dv-timings.h
 #include media/v4l2-device.h
 #include media/v4l2-ctrls.h
+#include media/v4l2-of.h
 #include media/tc358743.h
 
 #include tc358743_regs.h
@@ -69,6 +72,7 @@ static const struct v4l2_dv_timings_cap tc358743_timings_cap 
= {
 
 struct tc358743_state {
struct tc358743_platform_data pdata;
+   struct v4l2_of_bus_mipi_csi2 bus;
struct v4l2_subdev sd;
struct media_pad pad;
struct v4l2_ctrl_handler hdl;
@@ -90,6 +94,8 @@ struct tc358743_state {
 
struct v4l2_dv_timings timings;
u32 mbus_fmt_code;
+
+   struct gpio_desc *reset_gpio;
 };
 
 static void tc358743_enable_interrupts(struct v4l2_subdev *sd,
@@ -700,7 +706,8 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
((lanes  2) ? MASK_D2M_HSTXVREGEN : 0x0) |
((lanes  3) ? MASK_D3M_HSTXVREGEN : 0x0));
 
-   i2c_wr32(sd, TXOPTIONCNTRL, MASK_CONTCLKMODE);
+   i2c_wr32(sd, TXOPTIONCNTRL, (state-bus.flags 
+V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
i2c_wr32(sd, STARTCNTRL, MASK_START);
i2c_wr32(sd, CSI_START, MASK_STRT);
 
@@ -1638,6 +1645,135 @@ static const struct v4l2_ctrl_config 
tc358743_ctrl_audio_present = {
 
 /* --- PROBE / REMOVE --- */
 
+#if CONFIG_OF
+static void tc358743_gpio_reset(struct tc358743_state *state)
+{
+   gpiod_set_value(state-reset_gpio, 0);
+   usleep_range(5000, 1);
+   gpiod_set_value(state-reset_gpio, 1);
+   usleep_range(1000, 2000);
+   gpiod_set_value(state-reset_gpio, 0);
+   msleep(20);
+}
+
+static int tc358743_probe_of(struct tc358743_state *state)
+{
+  

[PATCH 4/5] [media] tc358743: add direct interrupt handling

2015-07-10 Thread Philipp Zabel
When probed from device tree, the i2c client driver can handle the interrupt
on its own.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/i2c/tc358743.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 02c60b3..4a889d4 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -32,6 +32,7 @@
 #include linux/clk.h
 #include linux/delay.h
 #include linux/gpio/consumer.h
+#include linux/interrupt.h
 #include linux/videodev2.h
 #include linux/workqueue.h
 #include linux/v4l2-dv-timings.h
@@ -1306,6 +1307,16 @@ static int tc358743_isr(struct v4l2_subdev *sd, u32 
status, bool *handled)
return 0;
 }
 
+static irqreturn_t tc358743_irq_handler(int irq, void *dev_id)
+{
+   struct tc358743_state *state = dev_id;
+   bool handled;
+
+   tc358743_isr(state-sd, 0, handled);
+
+   return handled ? IRQ_HANDLED : IRQ_NONE;
+}
+
 /* --- VIDEO OPS --- */
 
 static int tc358743_g_input_status(struct v4l2_subdev *sd, u32 *status)
@@ -1874,6 +1885,17 @@ static int tc358743_probe(struct i2c_client *client,
tc358743_set_csi_color_space(sd);
 
tc358743_init_interrupts(sd);
+
+   if (state-i2c_client-irq) {
+   err = devm_request_threaded_irq(client-dev,
+   state-i2c_client-irq,
+   NULL, tc358743_irq_handler,
+   IRQF_TRIGGER_HIGH | 
IRQF_ONESHOT,
+   tc358743, state);
+   if (err)
+   goto err_work_queues;
+   }
+
tc358743_enable_interrupts(sd, tx_5v_power_present(sd));
i2c_wr16(sd, INTMASK, ~(MASK_HDMI_MSK | MASK_CSI_MSK)  0x);
 
-- 
2.1.4

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


[PATCH 2/5] [media] tc358743: enable v4l2 subdevice devnode

2015-07-10 Thread Philipp Zabel
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/i2c/tc358743.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 48d1575..0be6d9f 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1668,7 +1668,7 @@ static int tc358743_probe(struct i2c_client *client,
state-i2c_client = client;
sd = state-sd;
v4l2_i2c_subdev_init(sd, client, tc358743_ops);
-   sd-flags |= V4L2_SUBDEV_FL_HAS_EVENTS;
+   sd-flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
 
/* i2c access */
if ((i2c_rd16(sd, CHIPID)  MASK_CHIPID) != 0) {
-- 
2.1.4

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


[PATCH 1/5] [media] tc358743: register v4l2 asynchronous subdevice

2015-07-10 Thread Philipp Zabel
Add support for registering the sensor subdevice using the v4l2-async API.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/i2c/tc358743.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 34d4f32..48d1575 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1710,6 +1710,16 @@ static int tc358743_probe(struct i2c_client *client,
goto err_hdl;
}
 
+   state-pad.flags = MEDIA_PAD_FL_SOURCE;
+   err = media_entity_init(sd-entity, 1, state-pad, 0);
+   if (err  0)
+   goto err_hdl;
+
+   sd-dev = client-dev;
+   err = v4l2_async_register_subdev(sd);
+   if (err  0)
+   goto err_hdl;
+
mutex_init(state-confctl_mutex);
 
INIT_DELAYED_WORK(state-delayed_work_enable_hotplug,
@@ -1740,6 +1750,7 @@ err_work_queues:
destroy_workqueue(state-work_queues);
mutex_destroy(state-confctl_mutex);
 err_hdl:
+   media_entity_cleanup(sd-entity);
v4l2_ctrl_handler_free(state-hdl);
return err;
 }
@@ -1751,6 +1762,7 @@ static int tc358743_remove(struct i2c_client *client)
 
cancel_delayed_work(state-delayed_work_enable_hotplug);
destroy_workqueue(state-work_queues);
+   v4l2_async_unregister_subdev(sd);
v4l2_device_unregister_subdev(sd);
mutex_destroy(state-confctl_mutex);
v4l2_ctrl_handler_free(state-hdl);
-- 
2.1.4

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


Re: [RFC v04] Driver for Toshiba TC358743

2015-07-10 Thread Philipp Zabel
Hi Mats,

thanks for the update! With a few changes on top
Tested-by: Philipp Zabel p.za...@pengutronix.de

Am Donnerstag, den 09.07.2015, 10:45 +0200 schrieb matra...@cisco.com:
 From: Mats Randgaard matra...@cisco.com
 
 Improvements based on feedback from Hans Verkuil:
 - Use functions in linux/hdmi.h to print AVI info frames
 - Replace private format change event with V4L2_EVENT_SOURCE_CHANGE
 - Rewrite set_fmt/get_fmt
 - Remove V4L2_SUBDEV_FL_HAS_DEVNODE

I had to add that back again together with initializing the media entity
to make it configurable with media-ctl --set-dv.

regards
Philipp

--
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] Doc: z8530book: Fix typo in API-z8530-sync-txdma-open.html

2015-07-10 Thread Masanari Iida
This patch fix a spelling typo found in API-z8530-sync-txdma-open.html.
It is because this file was generated from comment in source,
I have to fix comment in source.

Signed-off-by: Masanari Iida standby2...@gmail.com
---
 drivers/net/wan/z85230.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
index feacc3b..2f0bd69 100644
--- a/drivers/net/wan/z85230.c
+++ b/drivers/net/wan/z85230.c
@@ -1044,7 +1044,7 @@ EXPORT_SYMBOL(z8530_sync_dma_close);
  * @dev: The network device to attach
  * @c: The Z8530 channel to configure in sync DMA mode.
  *
- * Set up a Z85x30 device for synchronous DMA tranmission. One
+ * Set up a Z85x30 device for synchronous DMA transmission. One
  * ISA DMA channel must be available for this to work. The receive
  * side is run in PIO mode, but then it has the bigger FIFO.
  */
-- 
2.5.0.rc1

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


[PATCH] [media] coda: reset CODA960 hardware after sequence end

2015-07-10 Thread Philipp Zabel
On i.MX6, sometimes after decoding a stream, encoding will produce macroblock
errors caused by missing 8-byte sequences in the output stream. Until the cause
for this is found, reset the hardware after sequence end, which seems to help.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-bit.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 25910cc..bcb9911 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1347,6 +1347,14 @@ static void coda_seq_end_work(struct work_struct *work)
 CODA_COMMAND_SEQ_END failed\n);
}
 
+   /*
+* FIXME: Sometimes h.264 encoding fails with 8-byte sequences missing
+* from the output stream after the h.264 decoder has run. Resetting the
+* hardware after the decoder has finished seems to help.
+*/
+   if (dev-devtype-product == CODA_960)
+   coda_hw_reset(ctx);
+
kfifo_init(ctx-bitstream_fifo,
ctx-bitstream.vaddr, ctx-bitstream.size);
 
-- 
2.1.4

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


[PATCH] [media] coda: implement VBV delay and buffer size controls

2015-07-10 Thread Philipp Zabel
The encoder allows to specify the VBV model reference decoder's initial
delay and buffer size. Export the corresponding V4L2 controls.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-bit.c|  5 -
 drivers/media/platform/coda/coda-common.c | 14 ++
 drivers/media/platform/coda/coda.h|  2 ++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index bcb9911..b14affc 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -922,6 +922,9 @@ static int coda_start_encoding(struct coda_ctx *ctx)
value = (ctx-params.bitrate  CODA_RATECONTROL_BITRATE_MASK)
 CODA_RATECONTROL_BITRATE_OFFSET;
value |=  1  CODA_RATECONTROL_ENABLE_MASK;
+   value |= (ctx-params.vbv_delay 
+ CODA_RATECONTROL_INITIALDELAY_MASK)
+ CODA_RATECONTROL_INITIALDELAY_OFFSET;
if (dev-devtype-product == CODA_960)
value |= BIT(31); /* disable autoskip */
} else {
@@ -929,7 +932,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)
}
coda_write(dev, value, CODA_CMD_ENC_SEQ_RC_PARA);
 
-   coda_write(dev, 0, CODA_CMD_ENC_SEQ_RC_BUF_SIZE);
+   coda_write(dev, ctx-params.vbv_size, CODA_CMD_ENC_SEQ_RC_BUF_SIZE);
coda_write(dev, ctx-params.intra_refresh,
   CODA_CMD_ENC_SEQ_INTRA_REFRESH);
 
diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 351b4124..913dba9 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1502,6 +1502,12 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_JPEG_RESTART_INTERVAL:
ctx-params.jpeg_restart_interval = ctrl-val;
break;
+   case V4L2_CID_MPEG_VIDEO_VBV_DELAY:
+   ctx-params.vbv_delay = ctrl-val;
+   break;
+   case V4L2_CID_MPEG_VIDEO_VBV_SIZE:
+   ctx-params.vbv_size = min(ctrl-val * 8192, 0x7fff);
+   break;
default:
v4l2_dbg(1, coda_debug, ctx-dev-v4l2_dev,
Invalid control, id=%d, val=%d\n,
@@ -1561,6 +1567,14 @@ static void coda_encode_ctrls(struct coda_ctx *ctx)
v4l2_ctrl_new_std(ctx-ctrls, coda_ctrl_ops,
V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB, 0,
1920 * 1088 / 256, 1, 0);
+   v4l2_ctrl_new_std(ctx-ctrls, coda_ctrl_ops,
+   V4L2_CID_MPEG_VIDEO_VBV_DELAY, 0, 0x7fff, 1, 0);
+   /*
+* The maximum VBV size value is 0x7fff bits,
+* one bit less than 262144 KiB
+*/
+   v4l2_ctrl_new_std(ctx-ctrls, coda_ctrl_ops,
+   V4L2_CID_MPEG_VIDEO_VBV_SIZE, 0, 262144, 1, 0);
 }
 
 static void coda_jpeg_encode_ctrls(struct coda_ctx *ctx)
diff --git a/drivers/media/platform/coda/coda.h 
b/drivers/media/platform/coda/coda.h
index a3d70cc..26c9c4b 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -128,6 +128,8 @@ struct coda_params {
enum v4l2_mpeg_video_multi_slice_mode slice_mode;
u32 framerate;
u16 bitrate;
+   u16 vbv_delay;
+   u32 vbv_size;
u32 slice_max_bits;
u32 slice_max_mb;
 };
-- 
2.1.4

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


Re: [PATCH 01/53] [media] coda: Use S_PARM to set nominal framerate for h.264 encoder

2015-07-10 Thread Philipp Zabel
Am Freitag, den 10.07.2015, 15:35 +0200 schrieb Philipp Zabel:
 The encoder needs to know the nominal framerate for the constant bitrate
 control mechanism to work. Currently the only way to set the framerate is
 by using VIDIOC_S_PARM on the output queue.
 
 Signed-off-by: Philipp Zabel p.za...@pengutronix.de

Sorry, please ignore this one. I forgot to add -1 to the git send-email
prompt.

regards
Philipp

--
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 v3 1/3] [media] v4l2-dev: use event class to deduplicate v4l2 trace events

2015-07-10 Thread Philipp Zabel
Trace events with exactly the same parameters and trace output, such as
v4l2_qbuf and v4l2_dqbuf, are supposed to use the DECLARE_EVENT_CLASS and
DEFINE_EVENT macros instead of duplicated TRACE_EVENT macro calls.

Suggested-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 include/trace/events/v4l2.h | 160 +---
 1 file changed, 78 insertions(+), 82 deletions(-)

diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index 89d0497..4c88a32 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -93,90 +93,86 @@ SHOW_FIELD
{ V4L2_TC_USERBITS_USERDEFINED, USERBITS_USERDEFINED }, \
{ V4L2_TC_USERBITS_8BITCHARS,   USERBITS_8BITCHARS })
 
-#define V4L2_TRACE_EVENT(event_name)   \
-   TRACE_EVENT(event_name, \
-   TP_PROTO(int minor, struct v4l2_buffer *buf),   \
-   \
-   TP_ARGS(minor, buf),\
-   \
-   TP_STRUCT__entry(   \
-   __field(int, minor) \
-   __field(u32, index) \
-   __field(u32, type)  \
-   __field(u32, bytesused) \
-   __field(u32, flags) \
-   __field(u32, field) \
-   __field(s64, timestamp) \
-   __field(u32, timecode_type) \
-   __field(u32, timecode_flags)\
-   __field(u8, timecode_frames)\
-   __field(u8, timecode_seconds)   \
-   __field(u8, timecode_minutes)   \
-   __field(u8, timecode_hours) \
-   __field(u8, timecode_userbits0) \
-   __field(u8, timecode_userbits1) \
-   __field(u8, timecode_userbits2) \
-   __field(u8, timecode_userbits3) \
-   __field(u32, sequence)  \
-   ),  \
-   \
-   TP_fast_assign( \
-   __entry-minor = minor; \
-   __entry-index = buf-index;\
-   __entry-type = buf-type;  \
-   __entry-bytesused = buf-bytesused;\
-   __entry-flags = buf-flags;\
-   __entry-field = buf-field;\
-   __entry-timestamp =\
-   timeval_to_ns(buf-timestamp); \
-   __entry-timecode_type = buf-timecode.type;\
-   __entry-timecode_flags = buf-timecode.flags;  \
-   __entry-timecode_frames =  \
-   buf-timecode.frames;   \
-   __entry-timecode_seconds = \
-   buf-timecode.seconds;  \
-   __entry-timecode_minutes = \
-   buf-timecode.minutes;  \
-   __entry-timecode_hours = buf-timecode.hours;  \
-   __entry-timecode_userbits0 =   \
-   buf-timecode.userbits[0];  \
-   __entry-timecode_userbits1 =   \
-   buf-timecode.userbits[1];  \
-   __entry-timecode_userbits2 =   \
-   buf-timecode.userbits[2];  \
-   __entry-timecode_userbits3 =   \
-   buf-timecode.userbits[3];  \
-   __entry-sequence = buf-sequence;  \
-   ),  \
-   \
-   TP_printk(minor = %d, index = %u, type = %s,  \
- 

[PATCH v3 3/3] [media] videobuf2: add trace events

2015-07-10 Thread Philipp Zabel
Add videobuf2 specific vb2_qbuf and vb2_dqbuf trace events that mirror the
v4l2_qbuf and v4l2_dqbuf trace events, only they include additional
information about queue fill state and are emitted right before the buffer
is enqueued in the driver or userspace is woken up. This allows to make
sense of the timeline of trace events in combination with others that might
be triggered by __enqueue_in_driver.

Also two new trace events vb2_buf_queue and vb2_buf_done are added,
allowing to trace the handover between videobuf2 framework and driver.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
Changes since v2:
 - Use vb2-v4l2_planes[0].bytesused instead of vb-v4l2_buf.bytesused, which
   is always zero.
---
 drivers/media/v4l2-core/videobuf2-core.c | 11 
 include/trace/events/v4l2.h  | 97 
 2 files changed, 108 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 93b3154..b866a6b 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -30,6 +30,8 @@
 #include media/v4l2-common.h
 #include media/videobuf2-core.h
 
+#include trace/events/v4l2.h
+
 static int debug;
 module_param(debug, int, 0644);
 
@@ -1207,6 +1209,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum 
vb2_buffer_state state)
atomic_dec(q-owned_by_drv_count);
spin_unlock_irqrestore(q-done_lock, flags);
 
+   trace_vb2_buf_done(q, vb);
+
if (state == VB2_BUF_STATE_QUEUED) {
if (q-start_streaming_called)
__enqueue_in_driver(vb);
@@ -1629,6 +1633,8 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
vb-state = VB2_BUF_STATE_ACTIVE;
atomic_inc(q-owned_by_drv_count);
 
+   trace_vb2_buf_queue(q, vb);
+
/* sync buffers */
for (plane = 0; plane  vb-num_planes; ++plane)
call_void_memop(vb, prepare, vb-planes[plane].mem_priv);
@@ -1878,6 +1884,8 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct 
v4l2_buffer *b)
vb-v4l2_buf.timecode = b-timecode;
}
 
+   trace_vb2_qbuf(q, vb);
+
/*
 * If already streaming, give the buffer to driver for processing.
 * If not, the buffer will be given to driver on next streamon.
@@ -2123,6 +2131,9 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct 
v4l2_buffer *b, bool n
/* Remove from videobuf queue */
list_del(vb-queued_entry);
q-queued_count--;
+
+   trace_vb2_dqbuf(q, vb);
+
if (!V4L2_TYPE_IS_OUTPUT(q-type) 
vb-v4l2_buf.flags  V4L2_BUF_FLAG_LAST)
q-last_buffer_dequeued = true;
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index 4c88a32..dbf017b 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -174,6 +174,103 @@ DEFINE_EVENT(v4l2_event_class, v4l2_qbuf,
TP_ARGS(minor, buf)
 );
 
+DECLARE_EVENT_CLASS(vb2_event_class,
+   TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
+   TP_ARGS(q, vb),
+
+   TP_STRUCT__entry(
+   __field(int, minor)
+   __field(u32, queued_count)
+   __field(int, owned_by_drv_count)
+   __field(u32, index)
+   __field(u32, type)
+   __field(u32, bytesused)
+   __field(u32, flags)
+   __field(u32, field)
+   __field(s64, timestamp)
+   __field(u32, timecode_type)
+   __field(u32, timecode_flags)
+   __field(u8, timecode_frames)
+   __field(u8, timecode_seconds)
+   __field(u8, timecode_minutes)
+   __field(u8, timecode_hours)
+   __field(u8, timecode_userbits0)
+   __field(u8, timecode_userbits1)
+   __field(u8, timecode_userbits2)
+   __field(u8, timecode_userbits3)
+   __field(u32, sequence)
+   ),
+
+   TP_fast_assign(
+   __entry-minor = q-owner ? q-owner-vdev-minor : -1;
+   __entry-queued_count = q-queued_count;
+   __entry-owned_by_drv_count =
+   atomic_read(q-owned_by_drv_count);
+   __entry-index = vb-v4l2_buf.index;
+   __entry-type = vb-v4l2_buf.type;
+   __entry-bytesused = vb-v4l2_planes[0].bytesused;
+   __entry-flags = vb-v4l2_buf.flags;
+   __entry-field = vb-v4l2_buf.field;
+   __entry-timestamp = timeval_to_ns(vb-v4l2_buf.timestamp);
+   __entry-timecode_type = vb-v4l2_buf.timecode.type;
+   __entry-timecode_flags = vb-v4l2_buf.timecode.flags;
+   __entry-timecode_frames = vb-v4l2_buf.timecode.frames;
+   __entry-timecode_seconds = vb-v4l2_buf.timecode.seconds;
+   __entry-timecode_minutes = vb-v4l2_buf.timecode.minutes;
+   

[PATCH v3 2/3] [media] v4l2-mem2mem: set the queue owner field just as vb2_ioctl_reqbufs does

2015-07-10 Thread Philipp Zabel
The queue owner will be used by videobuf2 trace events to determine and
record the device minor number. It is set in v4l2_m2m_reqbufs instead of
v4l2_m2m_ioctl_reqbufs because several drivers implement their own
vidioc_reqbufs handlers that still call v4l2_m2m_reqbufs directly.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c 
b/drivers/media/v4l2-core/v4l2-mem2mem.c
index dc853e5..af8d6b4 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -357,9 +357,16 @@ int v4l2_m2m_reqbufs(struct file *file, struct 
v4l2_m2m_ctx *m2m_ctx,
 struct v4l2_requestbuffers *reqbufs)
 {
struct vb2_queue *vq;
+   int ret;
 
vq = v4l2_m2m_get_vq(m2m_ctx, reqbufs-type);
-   return vb2_reqbufs(vq, reqbufs);
+   ret = vb2_reqbufs(vq, reqbufs);
+   /* If count == 0, then the owner has released all buffers and he
+  is no longer owner of the queue. Otherwise we have an owner. */
+   if (ret == 0)
+   vq-owner = reqbufs-count ? file-private_data : NULL;
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_reqbufs);
 
-- 
2.1.4

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


[PATCH 01/53] [media] coda: Use S_PARM to set nominal framerate for h.264 encoder

2015-07-10 Thread Philipp Zabel
The encoder needs to know the nominal framerate for the constant bitrate
control mechanism to work. Currently the only way to set the framerate is
by using VIDIOC_S_PARM on the output queue.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-common.c | 102 ++
 drivers/media/platform/coda/coda_regs.h   |   4 ++
 2 files changed, 106 insertions(+)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 367b6ba..351b4124 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -15,6 +15,7 @@
 #include linux/debugfs.h
 #include linux/delay.h
 #include linux/firmware.h
+#include linux/gcd.h
 #include linux/genalloc.h
 #include linux/interrupt.h
 #include linux/io.h
@@ -770,6 +771,104 @@ static int coda_decoder_cmd(struct file *file, void *fh,
return 0;
 }
 
+static int coda_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+{
+   struct coda_ctx *ctx = fh_to_ctx(fh);
+   struct v4l2_fract *tpf;
+
+   if (a-type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL,
+
+   a-parm.output.capability = V4L2_CAP_TIMEPERFRAME;
+   tpf = a-parm.output.timeperframe;
+   tpf-denominator = ctx-params.framerate  CODA_FRATE_RES_MASK;
+   tpf-numerator = 1 + (ctx-params.framerate 
+ CODA_FRATE_DIV_OFFSET);
+
+   return 0;
+}
+
+/*
+ * Approximate timeperframe v4l2_fract with values that can be written
+ * into the 16-bit CODA_FRATE_DIV and CODA_FRATE_RES fields.
+ */
+static void coda_approximate_timeperframe(struct v4l2_fract *timeperframe)
+{
+   struct v4l2_fract s = *timeperframe;
+   struct v4l2_fract f0;
+   struct v4l2_fract f1 = { 1, 0 };
+   struct v4l2_fract f2 = { 0, 1 };
+   unsigned int i, div, s_denominator;
+
+   /* Lower bound is 1/65535 */
+   if (s.numerator == 0 || s.denominator / s.numerator  65535) {
+   timeperframe-numerator = 1;
+   timeperframe-denominator = 65535;
+   return;
+   }
+
+   /* Upper bound is 65536/1, map everything above to infinity */
+   if (s.denominator == 0 || s.numerator / s.denominator  65536) {
+   timeperframe-numerator = 1;
+   timeperframe-denominator = 0;
+   return;
+   }
+
+   /* Reduce fraction to lowest terms */
+   div = gcd(s.numerator, s.denominator);
+   if (div  1) {
+   s.numerator /= div;
+   s.denominator /= div;
+   }
+
+   if (s.numerator = 65536  s.denominator  65536) {
+   *timeperframe = s;
+   return;
+   }
+
+   /* Find successive convergents from continued fraction expansion */
+   while (f2.numerator = 65536  f2.denominator  65536) {
+   f0 = f1;
+   f1 = f2;
+
+   /* Stop when f2 exactly equals timeperframe */
+   if (s.numerator == 0)
+   break;
+
+   i = s.denominator / s.numerator;
+
+   f2.numerator = f0.numerator + i * f1.numerator;
+   f2.denominator = f0.denominator + i * f2.denominator;
+
+   s_denominator = s.numerator;
+   s.numerator = s.denominator % s.numerator;
+   s.denominator = s_denominator;
+   }
+
+   *timeperframe = f1;
+}
+
+static uint32_t coda_timeperframe_to_frate(struct v4l2_fract *timeperframe)
+{
+   return ((timeperframe-numerator - 1)  CODA_FRATE_DIV_OFFSET) |
+   timeperframe-denominator;
+}
+
+static int coda_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+{
+   struct coda_ctx *ctx = fh_to_ctx(fh);
+   struct v4l2_fract *tpf;
+
+   if (a-type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   tpf = a-parm.output.timeperframe;
+   coda_approximate_timeperframe(tpf);
+   ctx-params.framerate = coda_timeperframe_to_frate(tpf);
+
+   return 0;
+}
+
 static int coda_subscribe_event(struct v4l2_fh *fh,
const struct v4l2_event_subscription *sub)
 {
@@ -810,6 +909,9 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
.vidioc_try_decoder_cmd = coda_try_decoder_cmd,
.vidioc_decoder_cmd = coda_decoder_cmd,
 
+   .vidioc_g_parm  = coda_g_parm,
+   .vidioc_s_parm  = coda_s_parm,
+
.vidioc_subscribe_event = coda_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
diff --git a/drivers/media/platform/coda/coda_regs.h 
b/drivers/media/platform/coda/coda_regs.h
index 7d02624..00e4f51 100644
--- a/drivers/media/platform/coda/coda_regs.h
+++ b/drivers/media/platform/coda/coda_regs.h
@@ -263,6 +263,10 @@
 #defineCODADX6_PICHEIGHT_MASK  0x3ff
 #defineCODA7_PICHEIGHT_MASK0x