* [PATCH 1/5] mb86a20s: remove unused debug modprobe parameter
2015-01-01 15:51 [RFC PATCH 0/5] mb96a20s:use DVB core I2C binding and add media controller support Mauro Carvalho Chehab
@ 2015-01-01 15:51 ` Mauro Carvalho Chehab
2015-01-01 15:51 ` [PATCH 2/5] mb86a20s: convert it to I2C binding model Mauro Carvalho Chehab
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-01 15:51 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil
The debug parameter is not used anymore, as this module was
converted already to use dev_dbg().
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index e6f165a5b90d..8f54c39ca63f 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -22,10 +22,6 @@
#define NUM_LAYERS 3
-static int debug = 1;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
-
enum mb86a20s_bandwidth {
MB86A20S_13SEG = 0,
MB86A20S_13SEG_PARTIAL = 1,
--
2.1.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/5] mb86a20s: convert it to I2C binding model
2015-01-01 15:51 [RFC PATCH 0/5] mb96a20s:use DVB core I2C binding and add media controller support Mauro Carvalho Chehab
2015-01-01 15:51 ` [PATCH 1/5] mb86a20s: remove unused debug modprobe parameter Mauro Carvalho Chehab
@ 2015-01-01 15:51 ` Mauro Carvalho Chehab
2015-01-01 15:51 ` [PATCH 3/5] mb86a20s: remove two uneeded macros Mauro Carvalho Chehab
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-01 15:51 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Olli Salonen,
Antti Palosaari, Nibble Max, James Harper, Matthias Schwarzott
Instead of using I2C raw API, use the standard I2C binding API,
with the DVB core support for it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index 8f54c39ca63f..8dd608be1edd 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -18,6 +18,7 @@
#include <asm/div64.h>
#include "dvb_frontend.h"
+#include "dvb_i2c.h"
#include "mb86a20s.h"
#define NUM_LAYERS 3
@@ -35,12 +36,10 @@ static u8 mb86a20s_subchannel[] = {
};
struct mb86a20s_state {
- struct i2c_adapter *i2c;
+ struct i2c_client *i2c;
const struct mb86a20s_config *config;
u32 last_frequency;
- struct dvb_frontend frontend;
-
u32 if_freq;
enum mb86a20s_bandwidth bw;
bool inversion;
@@ -234,7 +233,7 @@ static int mb86a20s_i2c_writereg(struct mb86a20s_state *state,
};
int rc;
- rc = i2c_transfer(state->i2c, &msg, 1);
+ rc = i2c_transfer(state->i2c->adapter, &msg, 1);
if (rc != 1) {
dev_err(&state->i2c->dev,
"%s: writereg error (rc == %i, reg == 0x%02x, data == 0x%02x)\n",
@@ -269,7 +268,7 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state *state,
{ .addr = i2c_addr, .flags = I2C_M_RD, .buf = &val, .len = 1 }
};
- rc = i2c_transfer(state->i2c, msg, 2);
+ rc = i2c_transfer(state->i2c->adapter, msg, 2);
if (rc != 2) {
dev_err(&state->i2c->dev, "%s: reg=0x%x (error=%d)\n",
@@ -281,11 +280,11 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state *state,
}
#define mb86a20s_readreg(state, reg) \
- mb86a20s_i2c_readreg(state, state->config->demod_address, reg)
+ mb86a20s_i2c_readreg(state, state->i2c->addr, reg)
#define mb86a20s_writereg(state, reg, val) \
- mb86a20s_i2c_writereg(state, state->config->demod_address, reg, val)
+ mb86a20s_i2c_writereg(state, state->i2c->addr, reg, val)
#define mb86a20s_writeregdata(state, regdata) \
- mb86a20s_i2c_writeregdata(state, state->config->demod_address, \
+ mb86a20s_i2c_writeregdata(state, state->i2c->addr, \
regdata, ARRAY_SIZE(regdata))
/*
@@ -2058,41 +2057,34 @@ static int mb86a20s_tune(struct dvb_frontend *fe,
return rc;
}
-static void mb86a20s_release(struct dvb_frontend *fe)
+static int mb86a20s_remove(struct i2c_client *i2c)
{
- struct mb86a20s_state *state = fe->demodulator_priv;
+ dev_dbg(&i2c->dev, "%s called.\n", __func__);
- dev_dbg(&state->i2c->dev, "%s called.\n", __func__);
-
- kfree(state);
+ return 0;
}
static struct dvb_frontend_ops mb86a20s_ops;
-struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
- struct i2c_adapter *i2c)
+static int mb86a20s_probe(struct i2c_client *i2c,
+ const struct i2c_device_id *id)
{
+ struct dvb_frontend *fe;
struct mb86a20s_state *state;
u8 rev;
dev_dbg(&i2c->dev, "%s called.\n", __func__);
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL);
- if (state == NULL) {
- dev_err(&i2c->dev,
- "%s: unable to allocate memory for state\n", __func__);
- goto error;
- }
+ fe = i2c_get_clientdata(i2c);
+ state = fe->demodulator_priv;
/* setup the state */
- state->config = config;
+ memcpy(&state->config, i2c->dev.platform_data, sizeof(state->config));
state->i2c = i2c;
/* create dvb_frontend */
- memcpy(&state->frontend.ops, &mb86a20s_ops,
+ memcpy(&fe->ops, &mb86a20s_ops,
sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
/* Check if it is a mb86a20s frontend */
rev = mb86a20s_readreg(state, 0);
@@ -2104,16 +2096,11 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
dev_dbg(&i2c->dev,
"Frontend revision %d is unknown - aborting.\n",
rev);
- goto error;
+ return -ENODEV;
}
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
+ return 0;
}
-EXPORT_SYMBOL(mb86a20s_attach);
static struct dvb_frontend_ops mb86a20s_ops = {
.delsys = { SYS_ISDBT },
@@ -2132,8 +2119,6 @@ static struct dvb_frontend_ops mb86a20s_ops = {
.frequency_stepsize = 62500,
},
- .release = mb86a20s_release,
-
.init = mb86a20s_initfe,
.set_frontend = mb86a20s_set_frontend,
.get_frontend = mb86a20s_get_frontend_dummy,
@@ -2142,6 +2127,21 @@ static struct dvb_frontend_ops mb86a20s_ops = {
.tune = mb86a20s_tune,
};
+static const struct i2c_device_id mb86a20s_id[] = {
+ { "mb86a20s", 0 },
+ {}
+};
+
+static const struct dvb_i2c_module_param mb86a20s_param = {
+ .ops.fe_ops = NULL,
+ .priv_probe = mb86a20s_probe,
+ .priv_remove = mb86a20s_remove,
+ .priv_size = sizeof(struct mb86a20s_state),
+ .is_tuner = false,
+};
+
+DEFINE_DVB_I2C_MODULE(mb86a20s, mb86a20s_id, mb86a20s_param);
+
MODULE_DESCRIPTION("DVB Frontend module for Fujitsu mb86A20s hardware");
MODULE_AUTHOR("Mauro Carvalho Chehab");
MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/mb86a20s.h b/drivers/media/dvb-frontends/mb86a20s.h
index cbeb941fba7c..18743c32209c 100644
--- a/drivers/media/dvb-frontends/mb86a20s.h
+++ b/drivers/media/dvb-frontends/mb86a20s.h
@@ -34,23 +34,4 @@ struct mb86a20s_config {
bool is_serial;
};
-#if IS_ENABLED(CONFIG_DVB_MB86A20S)
-extern struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
- struct i2c_adapter *i2c);
-extern struct i2c_adapter *mb86a20s_get_tuner_i2c_adapter(struct dvb_frontend *);
-#else
-static inline struct dvb_frontend *mb86a20s_attach(
- const struct mb86a20s_config *config, struct i2c_adapter *i2c)
-{
- printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
- return NULL;
-}
-static struct i2c_adapter *
- mb86a20s_get_tuner_i2c_adapter(struct dvb_frontend *fe)
-{
- printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
- return NULL;
-}
-#endif
-
#endif /* MB86A20S */
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index c47d18270cfc..fc23b7ad194f 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -26,6 +26,7 @@
#include "cx23885.h"
#include <media/v4l2-common.h>
+#include "dvb_i2c.h"
#include "dvb_ca_en50221.h"
#include "s5h1409.h"
#include "s5h1411.h"
@@ -542,7 +543,10 @@ static struct xc5000_config mygica_x8506_xc5000_config = {
};
static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
- .demod_address = 0x10,
+};
+
+static const struct i2c_board_info mb86a20s_board_info = {
+ I2C_BOARD_INFO("mb86a20s", 0x10)
};
static struct xc5000_config mygica_x8507_xc5000_config = {
@@ -1503,9 +1507,10 @@ static int dvb_register(struct cx23885_tsport *port)
case CX23885_BOARD_MYGICA_X8507:
i2c_bus = &dev->i2c_bus[0];
i2c_bus2 = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
- &mygica_x8507_mb86a20s_config,
- &i2c_bus->i2c_adap);
+ fe0->dvb.frontend = dvb_i2c_attach_fe(&i2c_bus->i2c_adap,
+ &mb86a20s_board_info,
+ &mygica_x8507_mb86a20s_config,
+ NULL);
if (fe0->dvb.frontend == NULL)
break;
diff --git a/drivers/media/pci/saa7134/saa7134-dvb.c b/drivers/media/pci/saa7134/saa7134-dvb.c
index 73ffbabf831c..74b5ce0de488 100644
--- a/drivers/media/pci/saa7134/saa7134-dvb.c
+++ b/drivers/media/pci/saa7134/saa7134-dvb.c
@@ -34,6 +34,7 @@
#include "dvb-pll.h"
#include <dvb_frontend.h>
+#include "dvb_i2c.h"
#include "mt352.h"
#include "mt352_priv.h" /* FIXME */
#include "tda1004x.h"
@@ -245,7 +246,10 @@ static struct tda18271_config kworld_tda18271_config = {
};
static const struct mb86a20s_config kworld_mb86a20s_config = {
- .demod_address = 0x10,
+};
+
+static const struct i2c_board_info mb86a20s_board_info = {
+ I2C_BOARD_INFO("mb86a20s", 0x10)
};
static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
@@ -1807,9 +1811,10 @@ static int dvb_init(struct saa7134_dev *dev)
/* Switch to digital mode */
saa7134_tuner_callback(dev, 0,
TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
- fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
- &kworld_mb86a20s_config,
- &dev->i2c_adap);
+ fe0->dvb.frontend = dvb_i2c_attach_fe(&dev->i2c_adap,
+ &mb86a20s_board_info,
+ &kworld_mb86a20s_config,
+ NULL);
if (fe0->dvb.frontend != NULL) {
dvb_attach(tda829x_attach, fe0->dvb.frontend,
&dev->i2c_adap, 0x4b,
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index dd600b994e69..27803a8cf5a4 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -26,6 +26,7 @@
#include <media/v4l2-common.h>
#include <media/videobuf-vmalloc.h>
+#include "dvb_i2c.h"
#include "xc5000.h"
#include "s5h1432.h"
#include "tda18271.h"
@@ -138,10 +139,13 @@ static struct tda18271_config hcw_tda18271_config = {
};
static const struct mb86a20s_config pv_mb86a20s_config = {
- .demod_address = 0x10,
.is_serial = true,
};
+static const struct i2c_board_info mb86a20s_board_info = {
+ I2C_BOARD_INFO("mb86a20s", 0x10)
+};
+
static struct tda18271_config pv_tda18271_config = {
.std_map = &mb86a20s_tda18271_config,
.gate = TDA18271_GATE_DIGITAL,
@@ -815,10 +819,10 @@ static int dvb_init(struct cx231xx *dev)
"%s: looking for demod on i2c bus: %d\n",
__func__, i2c_adapter_id(tuner_i2c));
- dev->dvb->frontend = dvb_attach(mb86a20s_attach,
- &pv_mb86a20s_config,
- demod_i2c);
-
+ dev->dvb->frontend = dvb_i2c_attach_fe(demod_i2c,
+ &mb86a20s_board_info,
+ &pv_mb86a20s_config,
+ NULL);
if (dev->dvb->frontend == NULL) {
dev_err(dev->dev,
"Failed to attach mb86a20s demod\n");
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index aee70d483264..6fa4eeed9f50 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -34,6 +34,7 @@
#include "tuner-simple.h"
#include <linux/gpio.h>
+#include "dvb_i2c.h"
#include "lgdt330x.h"
#include "lgdt3305.h"
#include "zl10353.h"
@@ -833,10 +834,13 @@ static struct qt1010_config em28xx_qt1010_config = {
};
static const struct mb86a20s_config c3tech_duo_mb86a20s_config = {
- .demod_address = 0x10,
.is_serial = true,
};
+static const struct i2c_board_info mb86a20s_board_info = {
+ I2C_BOARD_INFO("mb86a20s", 0x10)
+};
+
static struct tda18271_std_map mb86a20s_tda18271_config = {
.dvbt_6 = { .if_freq = 4000, .agc_mode = 3, .std = 4,
.if_lvl = 1, .rfagc_top = 0x37, },
@@ -1323,9 +1327,10 @@ static int em28xx_dvb_init(struct em28xx *dev)
break;
case EM2884_BOARD_C3TECH_DIGITAL_DUO:
- dvb->fe[0] = dvb_attach(mb86a20s_attach,
- &c3tech_duo_mb86a20s_config,
- &dev->i2c_adap[dev->def_i2c_bus]);
+ dvb->fe[0] = dvb_i2c_attach_fe(&dev->i2c_adap[dev->def_i2c_bus],
+ &mb86a20s_board_info,
+ &c3tech_duo_mb86a20s_config,
+ NULL);
if (dvb->fe[0] != NULL)
dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
&dev->i2c_adap[dev->def_i2c_bus],
--
2.1.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/5] mb86a20s: remove two uneeded macros
2015-01-01 15:51 [RFC PATCH 0/5] mb96a20s:use DVB core I2C binding and add media controller support Mauro Carvalho Chehab
2015-01-01 15:51 ` [PATCH 1/5] mb86a20s: remove unused debug modprobe parameter Mauro Carvalho Chehab
2015-01-01 15:51 ` [PATCH 2/5] mb86a20s: convert it to I2C binding model Mauro Carvalho Chehab
@ 2015-01-01 15:51 ` Mauro Carvalho Chehab
2015-01-01 15:51 ` [PATCH 4/5] dvb core: add media controller support for the demod Mauro Carvalho Chehab
2015-01-01 15:51 ` [PATCH 5/5] cx231xx: add media controller support for mb86a20s boards Mauro Carvalho Chehab
4 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-01 15:51 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil
There are two macros that are there just to simplify the parameter
passage. Remove them, as the i2c address is already inside the
i2c client structure.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index 8dd608be1edd..7d6a688f6f12 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -224,12 +224,12 @@ static struct regdata mb86a20s_per_ber_reset[] = {
* I2C read/write functions and macros
*/
-static int mb86a20s_i2c_writereg(struct mb86a20s_state *state,
- u8 i2c_addr, u8 reg, u8 data)
+static int mb86a20s_writereg(struct mb86a20s_state *state,
+ u8 reg, u8 data)
{
u8 buf[] = { reg, data };
struct i2c_msg msg = {
- .addr = i2c_addr, .flags = 0, .buf = buf, .len = 2
+ .addr = state->i2c->addr, .flags = 0, .buf = buf, .len = 2
};
int rc;
@@ -245,27 +245,25 @@ static int mb86a20s_i2c_writereg(struct mb86a20s_state *state,
}
static int mb86a20s_i2c_writeregdata(struct mb86a20s_state *state,
- u8 i2c_addr, struct regdata *rd, int size)
+ struct regdata *rd, int size)
{
int i, rc;
for (i = 0; i < size; i++) {
- rc = mb86a20s_i2c_writereg(state, i2c_addr, rd[i].reg,
- rd[i].data);
+ rc = mb86a20s_writereg(state, rd[i].reg, rd[i].data);
if (rc < 0)
return rc;
}
return 0;
}
-static int mb86a20s_i2c_readreg(struct mb86a20s_state *state,
- u8 i2c_addr, u8 reg)
+static int mb86a20s_readreg(struct mb86a20s_state *state, u8 reg)
{
u8 val;
int rc;
struct i2c_msg msg[] = {
- { .addr = i2c_addr, .flags = 0, .buf = ®, .len = 1 },
- { .addr = i2c_addr, .flags = I2C_M_RD, .buf = &val, .len = 1 }
+ { .addr = state->i2c->addr, .flags = 0, .buf = ®, .len = 1 },
+ { .addr = state->i2c->addr, .flags = I2C_M_RD, .buf = &val, .len = 1 }
};
rc = i2c_transfer(state->i2c->adapter, msg, 2);
@@ -279,12 +277,8 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state *state,
return val;
}
-#define mb86a20s_readreg(state, reg) \
- mb86a20s_i2c_readreg(state, state->i2c->addr, reg)
-#define mb86a20s_writereg(state, reg, val) \
- mb86a20s_i2c_writereg(state, state->i2c->addr, reg, val)
#define mb86a20s_writeregdata(state, regdata) \
- mb86a20s_i2c_writeregdata(state, state->i2c->addr, \
+ mb86a20s_i2c_writeregdata(state, \
regdata, ARRAY_SIZE(regdata))
/*
--
2.1.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 4/5] dvb core: add media controller support for the demod
2015-01-01 15:51 [RFC PATCH 0/5] mb96a20s:use DVB core I2C binding and add media controller support Mauro Carvalho Chehab
` (2 preceding siblings ...)
2015-01-01 15:51 ` [PATCH 3/5] mb86a20s: remove two uneeded macros Mauro Carvalho Chehab
@ 2015-01-01 15:51 ` Mauro Carvalho Chehab
2015-01-05 14:36 ` Akihiro TSUKADA
2015-01-01 15:51 ` [PATCH 5/5] cx231xx: add media controller support for mb86a20s boards Mauro Carvalho Chehab
4 siblings, 1 reply; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-01 15:51 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Shuah Khan, Akihiro Tsukada, Olli Salonen,
Antti Palosaari, Hans Verkuil, Nibble Max, James Harper,
Matthias Schwarzott, linux-api
Now that we have an I2C function to attach DVB sub-devices, add
support for media controller on it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
index 41aae1bf0103..65d002f19cc3 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -40,6 +40,8 @@
#include <linux/dvb/frontend.h>
+#include <media/media-device.h>
+
#include "dvbdev.h"
/*
@@ -416,6 +418,11 @@ struct dvb_frontend {
struct dvb_frontend_ops ops;
struct dvb_adapter *dvb;
struct i2c_client *fe_cl;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ struct media_device *mdev;
+ struct media_entity demod_entity;
+#endif
+
void *demodulator_priv;
void *tuner_priv;
void *frontend_priv;
diff --git a/drivers/media/dvb-core/dvb_i2c.c b/drivers/media/dvb-core/dvb_i2c.c
index 4ea4e5e59f14..df8b7718ca8a 100644
--- a/drivers/media/dvb-core/dvb_i2c.c
+++ b/drivers/media/dvb-core/dvb_i2c.c
@@ -39,11 +39,12 @@ dvb_i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info *info,
struct dvb_frontend *
dvb_i2c_attach_fe(struct i2c_adapter *adap, const struct i2c_board_info *info,
- const void *cfg, void **out)
+ const void *cfg, void **out, struct media_device *mdev)
{
struct i2c_client *cl;
struct i2c_board_info bi;
struct dvb_i2c_dev_config dcfg;
+ struct dvb_frontend *fe;
dcfg.priv_cfg = cfg;
dcfg.out = out;
@@ -53,7 +54,28 @@ dvb_i2c_attach_fe(struct i2c_adapter *adap, const struct i2c_board_info *info,
cl = dvb_i2c_new_device(adap, &bi, NULL);
if (!cl)
return NULL;
- return i2c_get_clientdata(cl);
+ fe = i2c_get_clientdata(cl);
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ /* Register the media controller entity. */
+ if (mdev) {
+ int ret;
+
+ if (!fe->mdev)
+ fe->mdev = mdev;
+
+ fe->demod_entity.type = MEDIA_ENT_T_DEVNODE_DVB;
+ fe->demod_entity.name = info->type;
+ fe->demod_entity.info.dvb = fe->id;
+ fe->demod_entity.flags = MEDIA_ENT_T_DVB_DEMOD;
+ ret = media_device_register_entity(fe->mdev, &fe->demod_entity);
+ if (ret < 0)
+ printk(KERN_WARNING
+ "%s: media_device_register_entity failed\n",
+ __func__);
+ }
+#endif
+ return fe;
}
EXPORT_SYMBOL(dvb_i2c_attach_fe);
@@ -193,6 +215,10 @@ static int remove_fe(struct i2c_client *client,
if (param->priv_remove)
param->priv_remove(client);
fe = i2c_get_clientdata(client);
+
+ if (fe->mdev)
+ media_device_unregister_entity(&fe->demod_entity);
+
kfree(fe->demodulator_priv);
kfree(fe);
module_put(this_module);
diff --git a/drivers/media/dvb-core/dvb_i2c.h b/drivers/media/dvb-core/dvb_i2c.h
index 2bf409d4bcaf..c2efed9c997e 100644
--- a/drivers/media/dvb-core/dvb_i2c.h
+++ b/drivers/media/dvb-core/dvb_i2c.h
@@ -33,7 +33,8 @@
struct dvb_frontend *dvb_i2c_attach_fe(struct i2c_adapter *adap,
const struct i2c_board_info *info,
- const void *cfg, void **out);
+ const void *cfg, void **out,
+ struct media_device *mdev);
struct i2c_client *dvb_i2c_attach_tuner(struct i2c_adapter *adap,
const struct i2c_board_info *info,
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index fc23b7ad194f..084526a29414 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1510,7 +1510,7 @@ static int dvb_register(struct cx23885_tsport *port)
fe0->dvb.frontend = dvb_i2c_attach_fe(&i2c_bus->i2c_adap,
&mb86a20s_board_info,
&mygica_x8507_mb86a20s_config,
- NULL);
+ NULL, NULL);
if (fe0->dvb.frontend == NULL)
break;
diff --git a/drivers/media/pci/saa7134/saa7134-dvb.c b/drivers/media/pci/saa7134/saa7134-dvb.c
index 74b5ce0de488..a47630be4583 100644
--- a/drivers/media/pci/saa7134/saa7134-dvb.c
+++ b/drivers/media/pci/saa7134/saa7134-dvb.c
@@ -1814,7 +1814,7 @@ static int dvb_init(struct saa7134_dev *dev)
fe0->dvb.frontend = dvb_i2c_attach_fe(&dev->i2c_adap,
&mb86a20s_board_info,
&kworld_mb86a20s_config,
- NULL);
+ NULL, NULL);
if (fe0->dvb.frontend != NULL) {
dvb_attach(tda829x_attach, fe0->dvb.frontend,
&dev->i2c_adap, 0x4b,
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 27803a8cf5a4..e6b6da44b1e5 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -822,7 +822,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_i2c_attach_fe(demod_i2c,
&mb86a20s_board_info,
&pv_mb86a20s_config,
- NULL);
+ NULL, NULL);
if (dev->dvb->frontend == NULL) {
dev_err(dev->dev,
"Failed to attach mb86a20s demod\n");
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 6fa4eeed9f50..c9bbc251c7c7 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1330,7 +1330,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
dvb->fe[0] = dvb_i2c_attach_fe(&dev->i2c_adap[dev->def_i2c_bus],
&mb86a20s_board_info,
&c3tech_duo_mb86a20s_config,
- NULL);
+ NULL, NULL);
if (dvb->fe[0] != NULL)
dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
&dev->i2c_adap[dev->def_i2c_bus],
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index d847c760e8f0..c002aed74e6b 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -27,7 +27,7 @@
#include <linux/types.h>
#include <linux/version.h>
-#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
+#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 1)
struct media_device_info {
char driver[16];
@@ -59,6 +59,8 @@ struct media_device_info {
/* A converter of analogue video to its digital representation. */
#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV + 4)
+#define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_V4L2_SUBDEV + 5)
+
#define MEDIA_ENT_FL_DEFAULT (1 << 0)
struct media_entity_desc {
--
2.1.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 4/5] dvb core: add media controller support for the demod
2015-01-01 15:51 ` [PATCH 4/5] dvb core: add media controller support for the demod Mauro Carvalho Chehab
@ 2015-01-05 14:36 ` Akihiro TSUKADA
2015-01-05 18:29 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 9+ messages in thread
From: Akihiro TSUKADA @ 2015-01-05 14:36 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab
On 2015年01月02日 00:51, Mauro Carvalho Chehab wrote:
> /*
> @@ -416,6 +418,11 @@ struct dvb_frontend {
> struct dvb_frontend_ops ops;
> struct dvb_adapter *dvb;
> struct i2c_client *fe_cl;
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> + struct media_device *mdev;
> + struct media_entity demod_entity;
> +#endif
> +
I understood that this patch was invalidated by the updated patch series:
"dvb core: add basic suuport for the media controller",
and now the demod_entity is registered in dvbdev.c::dvb_register_device()
via dvb_frontend_register(). Is that right?
And if so,
Shouldn't only the (tuner) subdevices be registered separately
in dvb_i2c_attach_tuner(), instead of dvb_i2c_attach_fe()?
(and it would be simpler if "mdev" can be accessed
like dvb_fe_get_mdev() {return fepriv->dvbdev->mdev;},
instead of having a cached value in dvb_frontend.)
sorry if I'm totally wrong,
I don't have an experience with media controller API.
regards,
akihiro
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 4/5] dvb core: add media controller support for the demod
2015-01-05 14:36 ` Akihiro TSUKADA
@ 2015-01-05 18:29 ` Mauro Carvalho Chehab
2015-01-06 12:32 ` Akihiro TSUKADA
0 siblings, 1 reply; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-05 18:29 UTC (permalink / raw)
To: Akihiro TSUKADA; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab
Em Mon, 05 Jan 2015 23:36:00 +0900
Akihiro TSUKADA <tskd08@gmail.com> escreveu:
> On 2015年01月02日 00:51, Mauro Carvalho Chehab wrote:
> > /*
> > @@ -416,6 +418,11 @@ struct dvb_frontend {
> > struct dvb_frontend_ops ops;
> > struct dvb_adapter *dvb;
> > struct i2c_client *fe_cl;
> > +#if defined(CONFIG_MEDIA_CONTROLLER)
> > + struct media_device *mdev;
> > + struct media_entity demod_entity;
> > +#endif
> > +
>
> I understood that this patch was invalidated by the updated patch series:
> "dvb core: add basic suuport for the media controller",
> and now the demod_entity is registered in dvbdev.c::dvb_register_device()
> via dvb_frontend_register(). Is that right?
Yes.
> And if so,
> Shouldn't only the (tuner) subdevices be registered separately
> in dvb_i2c_attach_tuner(), instead of dvb_i2c_attach_fe()?
No, it seems better to let dmxdev to register. That means that even
the non-converted I2C drivers, plus the non-I2C drivers may benefit
from the Media controller as well.
> (and it would be simpler if "mdev" can be accessed
> like dvb_fe_get_mdev() {return fepriv->dvbdev->mdev;},
> instead of having a cached value in dvb_frontend.)
Yeah, we could map this way, but that would require to add an extra
parameter to the fe register function, with has already too much
parameters. So, as it already uses an struct to pass parameters into
it, I decided to just re-use it.
> sorry if I'm totally wrong,
> I don't have an experience with media controller API.
>
> regards,
> akihiro
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 4/5] dvb core: add media controller support for the demod
2015-01-05 18:29 ` Mauro Carvalho Chehab
@ 2015-01-06 12:32 ` Akihiro TSUKADA
0 siblings, 0 replies; 9+ messages in thread
From: Akihiro TSUKADA @ 2015-01-06 12:32 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab
On 2015年01月06日 03:29, Mauro Carvalho Chehab wrote:
> Em Mon, 05 Jan 2015 23:36:00 +0900
>> And if so,
>> Shouldn't only the (tuner) subdevices be registered separately
>> in dvb_i2c_attach_tuner(), instead of dvb_i2c_attach_fe()?
>
> No, it seems better to let dmxdev to register. That means that even
> the non-converted I2C drivers, plus the non-I2C drivers may benefit
> from the Media controller as well.
I guess you meant dvbdev instead of dmxdev,
but still I'm afraid that media_entity for a tuner module is not
registered like FE(demod),dmxdev,net,ca, because dvb_frontend_register()
registers just a demod (or a whole FE module) for now.
Tuner subdevices don't have their own device nodes to be passed to
dvb_register_media_device() in the first place,
So I think we need to define MEDIA_ENT_T_DVB_SUBDEV{,_TUNER}
and register a media_entity of type:MEDIA_ENT_T_DVB_SUBDEV_TUNER,
if a separate tuner chip is used.
(with {major,minor} of the parent FE dev?)
If we can distinguish if a separate tuner subdev is used or not
by looking into "fe", then we might be able to register
the subdev from within dvb_register_[media_]device().
But if we cannot know from "fe",
dvb_i2c_attach_tuner() looks to be a good place.
Further, when a DTV board has multiple tuners and/or multiple demods
and the link between them can be dynamically configurable,
(via media controller API or a new DVB ioctl?),
then a tuner subdev can be unused and connected to no demod,
so we cannot identify all tuner subdevs from the demod ("fe") anyway.
> Yeah, we could map this way, but that would require to add an extra
> parameter to the fe register function, with has already too much
> parameters. So, as it already uses an struct to pass parameters into
> it, I decided to just re-use it.
if we add dvb_adapter.mdev and a user sets the pointer,
then we can retrieve mdev in all the registering functions
(dvb_register_frontend, dvb_{dmxdev,net,ca_en50221}_init),
as all of them take a dvb_adapter parameter.
or is it possible that the FE,demux,net,ca under one DVB adapter
belong to different mdev's and each of them must keep its parent mdev
separately?
regards,
akihiro
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/5] cx231xx: add media controller support for mb86a20s boards
2015-01-01 15:51 [RFC PATCH 0/5] mb96a20s:use DVB core I2C binding and add media controller support Mauro Carvalho Chehab
` (3 preceding siblings ...)
2015-01-01 15:51 ` [PATCH 4/5] dvb core: add media controller support for the demod Mauro Carvalho Chehab
@ 2015-01-01 15:51 ` Mauro Carvalho Chehab
4 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-01 15:51 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Matthias Schwarzott, Antti Palosaari,
Hans Verkuil
Add experimental support for the media controlers, on boards
that have mb86a20s (and use the new dvb core I2C binding).
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index e6b6da44b1e5..d772d386849f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -65,6 +65,10 @@ struct cx231xx_dvb {
struct dmx_frontend fe_mem;
struct dvb_net net;
struct i2c_client *i2c_client_tuner;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ struct media_device *media_dev;
+#endif
};
static struct s5h1432_config dvico_s5h1432_config = {
@@ -562,6 +566,7 @@ fail_adapter:
static void unregister_dvb(struct cx231xx_dvb *dvb)
{
struct i2c_client *client;
+
dvb_net_release(&dvb->net);
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
@@ -573,6 +578,13 @@ static void unregister_dvb(struct cx231xx_dvb *dvb)
module_put(client->dev.driver->owner);
i2c_unregister_device(client);
}
+#ifdef CONFIG_MEDIA_CONTROLLER
+ if (dvb->media_dev) {
+ media_device_unregister(dvb->media_dev);
+ kfree(dvb->media_dev);
+ dvb->media_dev = NULL;
+ }
+#endif
dvb_unregister_frontend(dvb->frontend);
dvb_frontend_detach(dvb->frontend);
dvb_unregister_adapter(&dvb->adapter);
@@ -813,16 +825,45 @@ static int dvb_init(struct cx231xx *dev)
}
case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID:
- case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID:
+ case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID: {
+#ifdef CONFIG_MEDIA_CONTROLLER
+ struct media_device *mdev;
+#endif
dev_info(dev->dev,
"%s: looking for demod on i2c bus: %d\n",
__func__, i2c_adapter_id(tuner_i2c));
+#ifdef CONFIG_MEDIA_CONTROLLER
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+ if (mdev) {
+ mdev->dev = dev->dev;
+ strlcpy(mdev->model, dev->board.name,
+ sizeof(mdev->model));
+ if (dev->udev->serial)
+ strlcpy(mdev->serial, dev->udev->serial,
+ sizeof(mdev->serial));
+ strcpy(mdev->bus_info, dev->udev->devpath);
+ mdev->hw_revision = le16_to_cpu(dev->udev->descriptor.bcdDevice);
+ mdev->driver_version = LINUX_VERSION_CODE;
+
+ result = media_device_register(mdev);
+ if (result) {
+ dev_err(dev->dev,
+ "Couln't create a media device. Error: %d\n",
+ result);
+ kfree(mdev);
+ mdev = NULL;
+ } else {
+ dvb->media_dev = mdev;
+ }
+ }
+#endif
+
dev->dvb->frontend = dvb_i2c_attach_fe(demod_i2c,
&mb86a20s_board_info,
&pv_mb86a20s_config,
- NULL, NULL);
+ NULL, mdev);
if (dev->dvb->frontend == NULL) {
dev_err(dev->dev,
"Failed to attach mb86a20s demod\n");
@@ -837,7 +878,7 @@ static int dvb_init(struct cx231xx *dev)
0x60, tuner_i2c,
&pv_tda18271_config);
break;
-
+ }
default:
dev_err(dev->dev,
"%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
@@ -866,6 +907,13 @@ ret:
return result;
out_free:
+#ifdef CONFIG_MEDIA_CONTROLLER
+ if (dvb->media_dev) {
+ media_device_unregister(dvb->media_dev);
+ kfree(dvb->media_dev);
+ dvb->media_dev = NULL;
+ }
+#endif
kfree(dvb);
dev->dvb = NULL;
goto ret;
--
2.1.0
^ permalink raw reply related [flat|nested] 9+ messages in thread