dvb-usb-friio: decompose friio and merge with gl861
Subsystems (2)
v3 cover dvb-usb-friio: decompose friio and merge with gl861
From: Akihiro Tsukada <[email protected]>
This series decomposes dvb-usb-friio into sub drivers and merge the bridge driver with dvb-usb-gl861.
As to the demod & tuner drivers, existing drivers are re-used.
Changes since v2
- used the new i2c binding helpers instead of my own one
- extends dvb-pll instead of creating a new tuner driver
- merged gl861-friio.c with gl861.c
- improved module counting
- made i2c communications on USB robust (regarding DMA)
Replaces:
patch #27927, dvb: tua6034: add a new driver for Infineon tua6034 tuner patch #27928, dvb-usb-friio: split and merge into dvb-usbv2-gl861
Akihiro Tsukada (5):
dvb-frontends/dvb-pll: add i2c driver support dvb-frontends/dvb-pll: add tua6034 ISDB-T tuner used in Friio dvb-usb/friio, dvb-usb-v2/gl861: decompose friio and merge with gl861 dvb-usb-v2/gl861: use usleep_range() for short delay dvb-usb-v2/gl861: ensure USB message buffers DMA'able
drivers/media/dvb-frontends/dvb-pll.c | 67 +++++ drivers/media/dvb-frontends/dvb-pll.h | 7 + drivers/media/usb/dvb-usb-v2/Kconfig | 5 +- drivers/media/usb/dvb-usb-v2/gl861.c | 488 ++++++++++++++++++++++++++++++- drivers/media/usb/dvb-usb-v2/gl861.h | 1 + drivers/media/usb/dvb-usb/Kconfig | 6 - drivers/media/usb/dvb-usb/Makefile | 3 - drivers/media/usb/dvb-usb/friio-fe.c | 441 ---------------------------- drivers/media/usb/dvb-usb/friio.c | 522 ---------------------------------- drivers/media/usb/dvb-usb/friio.h | 99 ------- 10 files changed, 556 insertions(+), 1083 deletions(-) delete mode 100644 drivers/media/usb/dvb-usb/friio-fe.c delete mode 100644 drivers/media/usb/dvb-usb/friio.c delete mode 100644 drivers/media/usb/dvb-usb/friio.h
Signature · 1 line
2.16.2
PATCH v3 1/5 dvb-frontends/dvb-pll: add i2c driver support
From: Akihiro Tsukada <[email protected]>
registers the module as an i2c driver,
but keeps dvb_pll_attach() untouched for compatibility.
--- drivers/media/dvb-frontends/dvb-pll.c | 49 +++++++++++++++++++++++++++++++++++ drivers/media/dvb-frontends/dvb-pll.h | 6 +++++ 2 files changed, 55 insertions(+)
drivers/media/dvb-frontends/dvb-pll.c +49 -0
@@ -827,6 +827,55 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, }EXPORT_SYMBOL (dvb_pll_attach); + +static int +dvb_pll_probe (struct i2c_client *client,const struct i2c_device_id *id) +{ +struct dvb_pll_config *cfg; +struct dvb_frontend *fe; +unsigned int desc_id; + + cfg = client->dev.platform_data; + fe = cfg->fe; +i2c_set_clientdata (client, fe); + desc_id = cfg->desc_id; + +if (!dvb_pll_attach (fe, client->addr, client->adapter, desc_id)) +return -ENOMEM ; + +dev_info (&client->dev,"DVB Simple Tuner attached.\n" ); +return 0 ; +} + +static int dvb_pll_remove (struct i2c_client *client) +{ +struct dvb_frontend *fe; + + fe =i2c_get_clientdata (client); +dvb_pll_release (fe); +return 0 ; +} + + +static const struct i2c_device_id dvb_pll_id[] = { + {"dvb_pll" ,0 }, + {} +}; + + +MODULE_DEVICE_TABLE (i2c, dvb_pll_id); + +static struct i2c_driver dvb_pll_driver = { + .driver = { + .name ="dvb_pll" , + }, + .probe = dvb_pll_probe, + .remove = dvb_pll_remove, + .id_table = dvb_pll_id, +}; + +module_i2c_driver (dvb_pll_driver); +MODULE_DESCRIPTION ("dvb pll library" );MODULE_AUTHOR ("Gerd Knorr" );MODULE_LICENSE ("GPL" );
drivers/media/dvb-frontends/dvb-pll.h +6 -0
@@ -30,6 +30,12 @@#define DVB_PLL_TDEE4 18#define DVB_PLL_THOMSON_DTT7520X 19 +struct dvb_pll_config { +struct dvb_frontend *fe; + +unsigned int desc_id; +}; +#if IS_REACHABLE (CONFIG_DVB_PLL )/** * Attach a dvb-pll to the supplied frontend structure.
Signature · 1 line
2.16.2
Re: [PATCH v3 1/5] dvb-frontends/dvb-pll: add i2c driver support
Quoted 79 lines · On 03/26/2018 09:06 PM, [email protected] wrote:
From: Akihiro Tsukada <[email protected]>
registers the module as an i2c driver,
but keepsdvb_pll_attach()untouched for compatibility.Signed-off-by Akihiro Tsukada <[email protected]>--- drivers/media/dvb-frontends/dvb-pll.c | 49 +++++++++++++++++++++++++++++++++++ drivers/media/dvb-frontends/dvb-pll.h | 6 +++++ 2 files changed, 55 insertions(+)drivers/media/dvb-frontends/dvb-pll.c +49
-0@@ -827,6 +827,55 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, }EXPORT_SYMBOL (dvb_pll_attach); + +static int +dvb_pll_probe (struct i2c_client *client,const struct i2c_device_id *id) +{ +struct dvb_pll_config *cfg; +struct dvb_frontend *fe; +unsigned int desc_id; + + cfg = client->dev.platform_data; + fe = cfg->fe; +i2c_set_clientdata (client, fe); + desc_id = cfg->desc_id; + +if (!dvb_pll_attach (fe, client->addr, client->adapter, desc_id)) +return -ENOMEM ; + +dev_info (&client->dev,"DVB Simple Tuner attached.\n" ); +return 0 ; +} + +static int dvb_pll_remove (struct i2c_client *client) +{ +struct dvb_frontend *fe; + + fe =i2c_get_clientdata (client); +dvb_pll_release (fe); +return 0 ; +} + + +static const struct i2c_device_id dvb_pll_id[] = { + {"dvb_pll" ,0 }, + {} +}; + + +MODULE_DEVICE_TABLE (i2c, dvb_pll_id); + +static struct i2c_driver dvb_pll_driver = { + .driver = { + .name ="dvb_pll" , + }, + .probe = dvb_pll_probe, + .remove = dvb_pll_remove, + .id_table = dvb_pll_id, +}; + +module_i2c_driver (dvb_pll_driver); +MODULE_DESCRIPTION ("dvb pll library" );MODULE_AUTHOR ("Gerd Knorr" );MODULE_LICENSE ("GPL" );drivers/media/dvb-frontends/dvb-pll.h +0
-0@@ -30,6 +30,12 @@#define DVB_PLL_TDEE4 18#define DVB_PLL_THOMSON_DTT7520X 19
drivers/media/dvb-frontends/dvb-pll.h line 41
Quoted 10 lines
drivers/media/dvb-frontends/dvb-pll.h +6
-0+struct dvb_pll_config { +struct dvb_frontend *fe; + +unsigned int desc_id; +}; +#if IS_REACHABLE (CONFIG_DVB_PLL )/** * Attach a dvb-pll to the supplied frontend structure.
Hello
Idea is correct, but I would use pll chip names for passing correct pll type for driver - that field is just for that.
Like that:
static const struct i2c_device_id dvb_pll_id[] = {
{"PLL-NAME1", 0},
{"PLL-NAME2", 1},
{"PLL-NAME3", 2},
{}
};See si2157 for example.
regards
Antti
Signature · 1 line
http://palosaari.fi/
PATCH v3 2/5 dvb-frontends/dvb-pll: add tua6034 ISDB-T tuner used in Friio
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
This driver already contains tua6034-based device settings, but they are not for ISDB-T and have different parameters.
---
Changes since v2:
(patch #27927 dvb: tua6034: add a new driver for Infineon tua6034 tuner)
- extends dvb-pll instead of creating a new driver
drivers/media/dvb-frontends/dvb-pll.c | 18 ++++++++++++++++++ drivers/media/dvb-frontends/dvb-pll.h | 1 + 2 files changed, 19 insertions(+)
drivers/media/dvb-frontends/dvb-pll.c +18 -0
@@ -533,6 +533,23 @@ static const struct dvb_pll_desc dvb_pll_alps_tdee4 = { } }; +/* Infineon TUA6034 ISDB-T, used in Friio */ +/* CP cur. 50uA, AGC takeover: 103dBuV, PORT3 on */ +static const struct dvb_pll_desc dvb_pll_tua6034_friio = { + .name ="Infineon TUA6034 ISDB-T (Friio)" , + .min =90000000 , + .max =770000000 , + .iffreq =57000000 , + .initdata = (u8 []){4 ,0x9a ,0x50 ,0xb2 ,0x08 }, + .sleepdata = (u8 []){4 ,0x9a ,0x70 ,0xb3 ,0x0b }, + .count =3 , + .entries = { + {170000000 ,142857 ,0xba ,0x09 }, + {470000000 ,142857 ,0xba ,0x0a }, + {770000000 ,142857 ,0xb2 ,0x08 }, + } +}; +/* ----------------------------------------------------------- */ static const struct dvb_pll_desc *pll_list[] = {
@@ -556,6 +573,7 @@ static const struct dvb_pll_desc *pll_list[] = { [DVB_PLL_SAMSUNG_TDTC9251DH0] = &dvb_pll_samsung_tdtc9251dh0, [DVB_PLL_SAMSUNG_TBDU18132] = &dvb_pll_samsung_tbdu18132, [DVB_PLL_SAMSUNG_TBMU24112] = &dvb_pll_samsung_tbmu24112, + [DVB_PLL_TUA6034_FRIIO] = &dvb_pll_tua6034_friio, };/* ----------------------------------------------------------- */
drivers/media/dvb-frontends/dvb-pll.h +1 -0
@@ -29,6 +29,7 @@#define DVB_PLL_SAMSUNG_TBMU24112 17#define DVB_PLL_TDEE4 18#define DVB_PLL_THOMSON_DTT7520X 19 +#define DVB_PLL_TUA6034_FRIIO 20struct dvb_pll_config {struct dvb_frontend *fe;
Signature · 1 line
2.16.2
PATCH v3 3/5 dvb-usb/friio, dvb-usb-v2/gl861: decompose friio
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
Friio device contains "gl861" bridge and "tc90522" demod, for which the separate drivers are already in the kernel. But friio driver was monolithic and did not use them, practically copying those features.
This patch decomposes friio driver into sub drivers and re-uses existing ones, thus reduces some code.
It adds some features to gl861,
to support the friio-specific init/config of the devices and implement i2c communications to the tuner via demod with USB vendor requests.
---
Changes since v2:
(patch #27928, dvb-usb-friio: split and merge into dvb-usbv2-gl861)
- used the new i2c binding helpers instead of my own one
- merged gl861-friio.c with gl861.c
drivers/media/usb/dvb-usb-v2/Kconfig | 5 +- drivers/media/usb/dvb-usb-v2/gl861.c | 468 ++++++++++++++++++++++++++++++- drivers/media/usb/dvb-usb-v2/gl861.h | 1 + drivers/media/usb/dvb-usb/Kconfig | 6 - drivers/media/usb/dvb-usb/Makefile | 3 - drivers/media/usb/dvb-usb/friio-fe.c | 441 ----------------------------- drivers/media/usb/dvb-usb/friio.c | 522 ----------------------------------- drivers/media/usb/dvb-usb/friio.h | 99 ------- 8 files changed, 465 insertions(+), 1080 deletions(-) delete mode 100644 drivers/media/usb/dvb-usb/friio-fe.c delete mode 100644 drivers/media/usb/dvb-usb/friio.c delete mode 100644 drivers/media/usb/dvb-usb/friio.h
drivers/media/usb/dvb-usb-v2/Kconfig +4 -1
@@ -95,10 +95,13 @@ config DVB_USB_GL861 tristate "Genesys Logic GL861 USB2.0 support" depends on DVB_USB_V2 select DVB_ZL10353 if MEDIA_SUBDRV_AUTOSELECT + select DVB_TC90522 if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT + select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT help Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0 - receiver with USB ID 0db0:5581. + receiver with USB ID 0db0:5581, Friio White ISDB-T receiver + with USB ID 0x7a69:0001. config DVB_USB_LME2510 tristate "LME DM04/QQBOX DVB-S USB2.0 support"
drivers/media/usb/dvb-usb-v2/gl861.c +460 -8
505 lines not on this page · raw message
drivers/media/usb/dvb-usb-v2/gl861.h +1 -0
@@ -9,5 +9,6 @@#define GL861_REQ_I2C_WRITE 0x01#define GL861_REQ_I2C_READ 0x02 +#define GL861_REQ_I2C_RAW 0x03#endif
drivers/media/usb/dvb-usb/Kconfig +0 -6
@@ -312,12 +312,6 @@ config DVB_USB_DTV5100 help Say Y here to support the AME DTV-5100 USB2.0 DVB-T receiver. -config DVB_USB_FRIIO - tristate "Friio ISDB-T USB2.0 Receiver support" - depends on DVB_USB - help - Say Y here to support the Japanese DTV receiver Friio. - config DVB_USB_AZ6027 tristate "Azurewave DVB-S/S2 USB2.0 AZ6027 support" depends on DVB_USB
drivers/media/usb/dvb-usb/Makefile +0 -3
@@ -71,9 +71,6 @@ obj-$(CONFIG_DVB_USB_DTV5100) += dvb-usb-dtv5100.o dvb-usb-cinergyT2-objs := cinergyT2-core.o cinergyT2-fe.o obj-$(CONFIG_DVB_USB_CINERGY_T2) += dvb-usb-cinergyT2.o -dvb-usb-friio-objs := friio.o friio-fe.o -obj-$(CONFIG_DVB_USB_FRIIO) += dvb-usb-friio.o - dvb-usb-az6027-objs := az6027.o obj-$(CONFIG_DVB_USB_AZ6027) += dvb-usb-az6027.o
drivers/media/usb/dvb-usb/friio-fe.c deleted +0 -441
441 lines not on this page · raw message
drivers/media/usb/dvb-usb/friio.c deleted +0 -522
522 lines not on this page · raw message
drivers/media/usb/dvb-usb/friio.h deleted +0 -99
99 lines not on this page · raw message
Signature · 1 line
2.16.2
kbuild test robot
build botRe: [PATCH v3 3/5] dvb-usb/friio, dvb-usb-v2/gl861: decompose friio
Thank you for the patch! Perhaps something to improve:
Hi Akihiro,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.16-rc7 next-20180327]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/tskd08-gmail-com/dvb-frontends-dvb-pll-add-i2c-driver-support/20180327-194533 base: git://linuxtv.org/media_tree.git master reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/media/usb/dvb-usb-v2/gl861.c:575:34: sparse: symbol 'friio_props' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build bot[RFC PATCH] dvb-usb/friio, dvb-usb-v2/gl861: friio_props can be static
In reply to [email protected]Fixes: 7d9f3a71c6fc ("dvb-usb/friio, dvb-usb-v2/gl861: decompose friio")
--- gl861.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/gl861.c +1 -1
@@ -572,7 +572,7 @@ static struct dvb_usb_device_properties gl861_props = { } }; -struct dvb_usb_device_properties friio_props = { +static struct dvb_usb_device_properties friio_props = { .driver_name =KBUILD_MODNAME , .owner =THIS_MODULE , .adapter_nr = adapter_nr,
PATCH v3 4/5 dvb-usb-v2/gl861: use usleep_range() for short delay
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
As the kernel doc "timers-howto.txt" reads,
short delay with msleep() can take much longer.
In a case of raspbery-pi platform where CONFIG_HZ_100 was set, it actually affected the init of Friio devices
since it issues lots of i2c transactions with short delay.
--- drivers/media/usb/dvb-usb-v2/gl861.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/gl861.c +1 -1
@@ -45,7 +45,7 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr,return -EINVAL ; } -msleep (1 );/* avoid I2C errors */ +usleep_range (1000 ,2000 );/* avoid I2C errors */ return usb_control_msg (d->udev,usb_rcvctrlpipe (d->udev,0 ), req, type, value, index, rbuf, rlen,2000 );
Signature · 1 line
2.16.2
PATCH v3 5/5 dvb-usb-v2/gl861: ensure USB message buffers DMA'able
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
i2c message buf might be on stack.
--- drivers/media/usb/dvb-usb-v2/gl861.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/media/usb/dvb-usb-v2/gl861.c +17 -3
@@ -22,6 +22,8 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr,u16 value = addr << (8 +1 );int wo = (rbuf ==NULL || rlen ==0 );/* write-only */ u8 req, type; +u8 *buf; +int ret;if (wo) { req =GL861_REQ_I2C_WRITE ;
@@ -44,11 +46,23 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, KBUILD_MODNAME, wlen);return -EINVAL ; } - + buf =NULL ; +if (rlen >0 ) { + buf =kmalloc (rlen,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + }usleep_range (1000 ,2000 );/* avoid I2C errors */ -return usb_control_msg (d->udev,usb_rcvctrlpipe (d->udev,0 ), req, type, - value, index, rbuf, rlen,2000 ); + ret =usb_control_msg (d->udev,usb_rcvctrlpipe (d->udev,0 ), req, type, + value, index, buf, rlen,2000 ); +if (rlen >0 ) { +if (ret >0 ) +memcpy (rbuf, buf, rlen); +kfree (buf); + } + +return ret; }/* Friio specific I2C read/write */
Signature · 1 line
2.16.2