linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] cxd2099 series fixup
@ 2018-03-06 16:39 Daniel Scheller
  2018-03-06 16:39 ` [PATCH 1/4] [media] ddbridge: adapt cxd2099 attach to new i2c_client way Daniel Scheller
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Daniel Scheller @ 2018-03-06 16:39 UTC (permalink / raw)
  To: linux-media, mchehab, mchehab; +Cc: jasmin

From: Daniel Scheller <d.scheller@gmx.net>

These are the missing bits from the cxd2099 that went MIA during the
merge of the series.

Please pull - ngene driver requires the ngene patch for all I2C clients
to work (including the tda18212 that's now used since the merge of the
other ngene series) and ddbridge can't make use of the cxd2099 driver
at all right now.

Daniel Scheller (3):
  [media] ddbridge: adapt cxd2099 attach to new i2c_client way
  [media] ngene: add I2C_FUNC_I2C to the I2C interface functionality
  [media] dvb-frontends/cxd2099: remove remainders from old attach way

Jasmin Jessich (1):
  [media] MAINTAINERS: add entry for cxd2099

 MAINTAINERS                              |  8 +++++
 drivers/media/dvb-frontends/cxd2099.h    | 10 ------
 drivers/media/pci/ddbridge/ddbridge-ci.c | 62 +++++++++++++++++++++++++++++---
 drivers/media/pci/ddbridge/ddbridge.h    |  1 +
 drivers/media/pci/ngene/ngene-i2c.c      |  2 +-
 5 files changed, 67 insertions(+), 16 deletions(-)

-- 
2.16.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] [media] ddbridge: adapt cxd2099 attach to new i2c_client way
  2018-03-06 16:39 [PATCH 0/4] cxd2099 series fixup Daniel Scheller
@ 2018-03-06 16:39 ` Daniel Scheller
  2018-03-06 16:39 ` [PATCH 2/4] [media] ngene: add I2C_FUNC_I2C to the I2C interface functionality Daniel Scheller
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Scheller @ 2018-03-06 16:39 UTC (permalink / raw)
  To: linux-media, mchehab, mchehab; +Cc: jasmin

From: Daniel Scheller <d.scheller@gmx.net>

Change the way the cxd2099 hardware is being attached to the new I2C
client interface way.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/pci/ddbridge/ddbridge-ci.c | 62 +++++++++++++++++++++++++++++---
 drivers/media/pci/ddbridge/ddbridge.h    |  1 +
 2 files changed, 58 insertions(+), 5 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c b/drivers/media/pci/ddbridge/ddbridge-ci.c
index ed19890710d6..6585ef54ac22 100644
--- a/drivers/media/pci/ddbridge/ddbridge-ci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.c
@@ -172,6 +172,7 @@ static void ci_attach(struct ddb_port *port)
 	memcpy(&ci->en, &en_templ, sizeof(en_templ));
 	ci->en.data = ci;
 	port->en = &ci->en;
+	port->en_freedata = 1;
 	ci->port = port;
 	ci->nr = port->nr - 2;
 }
@@ -304,6 +305,7 @@ static void ci_xo2_attach(struct ddb_port *port)
 	memcpy(&ci->en, &en_xo2_templ, sizeof(en_xo2_templ));
 	ci->en.data = ci;
 	port->en = &ci->en;
+	port->en_freedata = 1;
 	ci->port = port;
 	ci->nr = port->nr - 2;
 	ci->port->creg = 0;
@@ -311,20 +313,58 @@ static void ci_xo2_attach(struct ddb_port *port)
 	write_creg(ci, 0x08, 0x08);
 }
 
-static struct cxd2099_cfg cxd_cfg = {
+static const struct cxd2099_cfg cxd_cfgtmpl = {
 	.bitrate =  72000,
-	.adr     =  0x40,
 	.polarity = 1,
 	.clock_mode = 1,
 	.max_i2c = 512,
 };
 
+static int ci_cxd2099_attach(struct ddb_port *port, u32 bitrate)
+{
+	struct cxd2099_cfg cxd_cfg = cxd_cfgtmpl;
+	struct i2c_client *client;
+	struct i2c_board_info board_info = {
+		.type = "cxd2099",
+		.addr = 0x40,
+		.platform_data = &cxd_cfg,
+	};
+
+	cxd_cfg.bitrate = bitrate;
+	cxd_cfg.en = &port->en;
+
+	request_module(board_info.type);
+
+	client = i2c_new_device(&port->i2c->adap, &board_info);
+	if (!client || !client->dev.driver)
+		goto err_ret;
+
+	if (!try_module_get(client->dev.driver->owner))
+		goto err_i2c;
+
+	if (!port->en)
+		goto err_i2c;
+
+	port->dvb[0].i2c_client[0] = client;
+	port->en_freedata = 0;
+	return 0;
+
+err_i2c:
+	i2c_unregister_device(client);
+err_ret:
+	dev_err(port->dev->dev, "CXD2099AR attach failed\n");
+	return -ENODEV;
+}
+
 int ddb_ci_attach(struct ddb_port *port, u32 bitrate)
 {
+	int ret;
+
 	switch (port->type) {
 	case DDB_CI_EXTERNAL_SONY:
-		cxd_cfg.bitrate = bitrate;
-		port->en = cxd2099_attach(&cxd_cfg, port, &port->i2c->adap);
+		ret = ci_cxd2099_attach(port, bitrate);
+		if (ret)
+			return -ENODEV;
 		break;
 	case DDB_CI_EXTERNAL_XO2:
 	case DDB_CI_EXTERNAL_XO2_B:
@@ -345,11 +385,23 @@ int ddb_ci_attach(struct ddb_port *port, u32 bitrate)
 
 void ddb_ci_detach(struct ddb_port *port)
 {
+	struct i2c_client *client;
+
 	if (port->dvb[0].dev)
 		dvb_unregister_device(port->dvb[0].dev);
 	if (port->en) {
 		dvb_ca_en50221_release(port->en);
-		kfree(port->en->data);
+
+		client = port->dvb[0].i2c_client[0];
+		if (client) {
+			module_put(client->dev.driver->owner);
+			i2c_unregister_device(client);
+		}
+
+		/* free alloc'ed memory if needed */
+		if (port->en_freedata)
+			kfree(port->en->data);
+
 		port->en = NULL;
 	}
 }
diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h
index 095457737bc1..f223dc6c9963 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -276,6 +276,7 @@ struct ddb_port {
 	struct ddb_input      *input[2];
 	struct ddb_output     *output;
 	struct dvb_ca_en50221 *en;
+	u8                     en_freedata;
 	struct ddb_dvb         dvb[2];
 	u32                    gap;
 	u32                    obr;
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] [media] ngene: add I2C_FUNC_I2C to the I2C interface functionality
  2018-03-06 16:39 [PATCH 0/4] cxd2099 series fixup Daniel Scheller
  2018-03-06 16:39 ` [PATCH 1/4] [media] ddbridge: adapt cxd2099 attach to new i2c_client way Daniel Scheller
@ 2018-03-06 16:39 ` Daniel Scheller
  2018-03-06 16:39 ` [PATCH 3/4] [media] dvb-frontends/cxd2099: remove remainders from old attach way Daniel Scheller
  2018-03-06 16:39 ` [PATCH 4/4] [media] MAINTAINERS: add entry for cxd2099 Daniel Scheller
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Scheller @ 2018-03-06 16:39 UTC (permalink / raw)
  To: linux-media, mchehab, mchehab; +Cc: jasmin

From: Daniel Scheller <d.scheller@gmx.net>

Report I2C_FUNC_I2C in .functionality() aswell. The I2C interface can
handle this fine and even is required for all I2C client drivers that
utilise the regmap API which are used from within the ngene driver.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/pci/ngene/ngene-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ngene/ngene-i2c.c b/drivers/media/pci/ngene/ngene-i2c.c
index 3004947f300b..092d46c2a3a9 100644
--- a/drivers/media/pci/ngene/ngene-i2c.c
+++ b/drivers/media/pci/ngene/ngene-i2c.c
@@ -147,7 +147,7 @@ static int ngene_i2c_master_xfer(struct i2c_adapter *adapter,
 
 static u32 ngene_i2c_functionality(struct i2c_adapter *adap)
 {
-	return I2C_FUNC_SMBUS_EMUL;
+	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
 static const struct i2c_algorithm ngene_i2c_algo = {
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] [media] dvb-frontends/cxd2099: remove remainders from old attach way
  2018-03-06 16:39 [PATCH 0/4] cxd2099 series fixup Daniel Scheller
  2018-03-06 16:39 ` [PATCH 1/4] [media] ddbridge: adapt cxd2099 attach to new i2c_client way Daniel Scheller
  2018-03-06 16:39 ` [PATCH 2/4] [media] ngene: add I2C_FUNC_I2C to the I2C interface functionality Daniel Scheller
@ 2018-03-06 16:39 ` Daniel Scheller
  2018-03-06 16:39 ` [PATCH 4/4] [media] MAINTAINERS: add entry for cxd2099 Daniel Scheller
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Scheller @ 2018-03-06 16:39 UTC (permalink / raw)
  To: linux-media, mchehab, mchehab; +Cc: jasmin

From: Daniel Scheller <d.scheller@gmx.net>

As all drivers using the cxd2099 are converted to handle attach/detach
the generic I2C client way, the static inline cxd2099_attach isn't
required anymore. Thus cleanup cxd2099.h from the remainders, the adr
struct member isn't used anymore aswell.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-frontends/cxd2099.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/media/dvb-frontends/cxd2099.h b/drivers/media/dvb-frontends/cxd2099.h
index 679e87512799..8fa45a4c615a 100644
--- a/drivers/media/dvb-frontends/cxd2099.h
+++ b/drivers/media/dvb-frontends/cxd2099.h
@@ -20,7 +20,6 @@
 
 struct cxd2099_cfg {
 	u32 bitrate;
-	u8  adr;
 	u8  polarity;
 	u8  clock_mode;
 
@@ -30,13 +29,4 @@ struct cxd2099_cfg {
 	struct dvb_ca_en50221 **en;
 };
 
-/* TODO: remove when done */
-static inline struct
-dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, void *priv,
-			       struct i2c_adapter *i2c)
-{
-	dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__);
-	return NULL;
-}
-
 #endif
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] [media] MAINTAINERS: add entry for cxd2099
  2018-03-06 16:39 [PATCH 0/4] cxd2099 series fixup Daniel Scheller
                   ` (2 preceding siblings ...)
  2018-03-06 16:39 ` [PATCH 3/4] [media] dvb-frontends/cxd2099: remove remainders from old attach way Daniel Scheller
@ 2018-03-06 16:39 ` Daniel Scheller
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Scheller @ 2018-03-06 16:39 UTC (permalink / raw)
  To: linux-media, mchehab, mchehab; +Cc: jasmin

From: Jasmin Jessich <jasmin@anw.at>

The cxd2099 driver is now maintained and being taken care of by

  * Jasmin Jessich <jasmin@anw.at>

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0eea2f0e9456..298f0b84a4ed 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8612,6 +8612,14 @@ T:	git git://linuxtv.org/media_tree.git
 S:	Supported
 F:	drivers/media/dvb-frontends/ascot2e*
 
+MEDIA DRIVERS FOR CXD2099AR CI CONTROLLERS
+M:	Jasmin Jessich <jasmin@anw.at>
+L:	linux-media@vger.kernel.org
+W:	https://linuxtv.org
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/dvb-frontends/cxd2099*
+
 MEDIA DRIVERS FOR CXD2841ER
 M:	Sergey Kozlov <serjk@netup.ru>
 M:	Abylay Ospan <aospan@netup.ru>
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-06 16:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06 16:39 [PATCH 0/4] cxd2099 series fixup Daniel Scheller
2018-03-06 16:39 ` [PATCH 1/4] [media] ddbridge: adapt cxd2099 attach to new i2c_client way Daniel Scheller
2018-03-06 16:39 ` [PATCH 2/4] [media] ngene: add I2C_FUNC_I2C to the I2C interface functionality Daniel Scheller
2018-03-06 16:39 ` [PATCH 3/4] [media] dvb-frontends/cxd2099: remove remainders from old attach way Daniel Scheller
2018-03-06 16:39 ` [PATCH 4/4] [media] MAINTAINERS: add entry for cxd2099 Daniel Scheller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).