dvb: Add support for PT3 ISDB-S/T card
Subsystems (5)
[email protected]
maintainerv2 cover dvb: Add support for PT3 ISDB-S/T card
From: Akihiro Tsukada <[email protected]>
This patch series adds support for "PT3" ISDB-S/T receiver cards. It contains a PCI bridge driver, a dvb-frontend driver and two tuner drivers.
I know "Bud R" had already posted ones to this mailing list, (as in [email protected] ), but it seems that he stopped updating his patch and does not agree on splitting the single large patch into smaller, separate ones. This series is another version written independently by me.
Changes in v2:
- added a new tuner ops (get_signal_strength_dbm()) for DVBv5
- improved kthread handling on remove,suspend,resume
- added support for suspend/resume
- moved static const tables out of function scope
- renamed badly named variables
- changed symbol_rate calculation
- other small fixes pointed out in the last review by mauro
Akihiro Tsukada (5):
dvb-core: add a new tuner ops to dvb_frontend for APIv5
mxl301rf: add driver for MaxLinear MxL301RF OFDM tuner
qm1d1c0042: add driver for Sharp QM1D1C0042 ISDB-S tuner
tc90522: add driver for Toshiba TC90522 quad demodulator
pt3: add support for Earthsoft PT3 ISDB-S/T receiver card
drivers/media/dvb-core/dvb_frontend.h | 2 + drivers/media/dvb-frontends/Kconfig | 8 + drivers/media/dvb-frontends/Makefile | 1 + drivers/media/dvb-frontends/tc90522.c | 857 ++++++++++++++++++++++++++++++++++ drivers/media/dvb-frontends/tc90522.h | 63 +++ drivers/media/pci/Kconfig | 1 + drivers/media/pci/Makefile | 1 + drivers/media/pci/pt3/Kconfig | 10 + drivers/media/pci/pt3/Makefile | 8 + drivers/media/pci/pt3/pt3.c | 817 ++++++++++++++++++++++++++++++++ drivers/media/pci/pt3/pt3.h | 179 +++++++ drivers/media/pci/pt3/pt3_dma.c | 225 +++++++++ drivers/media/pci/pt3/pt3_i2c.c | 239 ++++++++++ drivers/media/tuners/Kconfig | 14 + drivers/media/tuners/Makefile | 2 + drivers/media/tuners/mxl301rf.c | 334 +++++++++++++ drivers/media/tuners/mxl301rf.h | 40 ++ drivers/media/tuners/qm1d1c0042.c | 422 +++++++++++++++++ drivers/media/tuners/qm1d1c0042.h | 50 ++ 19 files changed, 3273 insertions(+) create mode 100644 drivers/media/dvb-frontends/tc90522.c create mode 100644 drivers/media/dvb-frontends/tc90522.h create mode 100644 drivers/media/pci/pt3/Kconfig create mode 100644 drivers/media/pci/pt3/Makefile create mode 100644 drivers/media/pci/pt3/pt3.c create mode 100644 drivers/media/pci/pt3/pt3.h create mode 100644 drivers/media/pci/pt3/pt3_dma.c create mode 100644 drivers/media/pci/pt3/pt3_i2c.c create mode 100644 drivers/media/tuners/mxl301rf.c create mode 100644 drivers/media/tuners/mxl301rf.h create mode 100644 drivers/media/tuners/qm1d1c0042.c create mode 100644 drivers/media/tuners/qm1d1c0042.h
Signature · 1 line
2.1.0
[email protected]
maintainerPATCH v2 1/5 dvb-core: add a new tuner ops to dvb_frontend for APIv5
From: Akihiro Tsukada <[email protected]>
fe->ops.tuner_ops.get_rf_strength() reports its result in u16, while in DVB APIv5 it should be reported in s64 and by 0.001dBm.
--- drivers/media/dvb-core/dvb_frontend.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/dvb-core/dvb_frontend.h +2 -0
@@ -222,6 +222,8 @@ struct dvb_tuner_ops {#define TUNER_STATUS_STEREO 2int (*get_status)(struct dvb_frontend *fe,u32 *status);int (*get_rf_strength)(struct dvb_frontend *fe,u16 *strength); +/** get signal strengh in 0.001dBm, in accordance with APIv5 */ +int (*get_rf_strength_dbm)(struct dvb_frontend *fe,s64 *strength);int (*get_afc)(struct dvb_frontend *fe,s32 *afc);/** These are provided separately from set_params in order to facilitate silicon
Signature · 1 line
2.1.0
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Moikka
I have feeling DVBv5 API is aimed to transfer data via property cached. I haven't done much driver for DVBv5 statistics, but recently I implemented CNR (DVBv5 stats) to Si2168 driver and it just writes all the values directly to property cache. I expect RF strength (RSSI) is just similar.
Antti
Quoted 24 lines · On 08/27/2014 06:29 PM, [email protected] wrote:
From: Akihiro Tsukada <[email protected]>
fe->ops.tuner_ops.get_rf_strength()reports its result in u16, while in DVB APIv5 it should be reported in s64 and by 0.001dBm.Signed-off-by Akihiro Tsukada <[email protected]>--- drivers/media/dvb-core/dvb_frontend.h | 2 ++ 1 file changed, 2 insertions(+)drivers/media/dvb-core/dvb_frontend.h +2
-0@@ -222,6 +222,8 @@ struct dvb_tuner_ops {#define TUNER_STATUS_STEREO 2int (*get_status)(struct dvb_frontend *fe,u32 *status);int (*get_rf_strength)(struct dvb_frontend *fe,u16 *strength); +/** get signal strengh in 0.001dBm, in accordance with APIv5 */ +int (*get_rf_strength_dbm)(struct dvb_frontend *fe,s64 *strength);int (*get_afc)(struct dvb_frontend *fe,s32 *afc);/** These are provided separately from set_params in order to facilitate silicon
Signature · 1 line
http://palosaari.fi/
Akihiro TSUKADA
maintainerRe: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
moikka,
thanks for the comment.
Quoted 5 lines
I have feeling DVBv5 API is aimed to transfer data via property cached. I haven't done much driver for DVBv5 statistics, but recently I implemented CNR (DVBv5 stats) to Si2168 driver and it just writes all the values directly to property cache. I expect RF strength (RSSI) is just similar.
Currently, the demod of PT3 card (tc90522) gets RSSI data from the connected tuner (mxl301rf) via tuner_ops.get_signal_strength_dbm() and sets property cache in fe->ops.get_frontend() (which is called before returning property cache value by dvb_frontend_ioctl_properties()). If the tuner driver should set property cache directly,
when is the right timing to do so?
In fe->ops.tuner_ops.get_status() ?
or in the old fe->ops.tuner_ops.get_signal_strength()?
or Should I change get_signal_strength_dbm(fe, s64 *) to update_signal_strength(fe) and let the tuner driver set property cache there?
--
akihiro
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
moikka!
Quoted 9 lines · Akihiro TSUKADA
moikka,
thanks for the comment.Quoted 5 lines
I have feeling DVBv5 API is aimed to transfer data via property cached. I haven't done much driver for DVBv5 statistics, but recently I implemented CNR (DVBv5 stats) to Si2168 driver and it just writes all the values directly to property cache. I expect RF strength (RSSI) is just similar.
Quoted 10 lines
Currently, the demod of PT3 card (tc90522) gets RSSI data from the connected tuner (mxl301rf) via
tuner_ops.get_signal_strength_dbm()and sets property cache infe->ops.get_frontend()(which is called before returning property cache value bydvb_frontend_ioctl_properties()). If the tuner driver should set property cache directly,
when is the right timing to do so?
Infe->ops.tuner_ops.get_status()?
or in the oldfe->ops.tuner_ops.get_signal_strength()?
or Should I changeget_signal_strength_dbm(fe, s64 *)toupdate_signal_strength(fe)and let the tuner driver set property cache there?
I think tuner driver should set c->strength as own. Look drivers/media/dvb-core/dvb_frontend.c
/* Fill quality measures */ case DTV_STAT_SIGNAL_STRENGTH: tvp->u.st = c->strength; break;
So user-space just get info what is set to struct dtv_frontend_properties. That is similarly than CNR and all the other statistics.
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Akihiro TSUKADA
maintainerRe: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
moikka,
Quoted 4 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct
dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.
I understand that RSSI property should be set directly in the tuner driver, but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.
Would you give me an advice? >> Mauro
regards,
akihiro
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Moro!
Quoted 7 lines · Akihiro TSUKADA
moikka,
Quoted 4 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct
dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.
Quoted 5 lines
I understand that RSSI property should be set directly in the tuner driver, but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.
Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/
af9033: implement DVBv5 statistic for CNR
https://patchwork.linuxtv.org/patch/25744/
af9033: implement DVBv5 stat block counters
https://patchwork.linuxtv.org/patch/25749/
af9033: implement DVBv5 post-Viterbi BER
https://patchwork.linuxtv.org/patch/25750/
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:
Quoted 21 lines
Moro!
Quoted 7 lines · Akihiro TSUKADA
moikka,
Quoted 4 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct
dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.Quoted 5 lines
I understand that RSSI property should be set directly in the tuner driver, but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.
Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic at ops.read_status().
Quoted 1 line
From the last time I reviewed the code, the PT3 driver seems to be using
this approach already at the demod.
Getting this value at the tuner makes it a little more trickier, as you need to use some tuner callback to update the demod cache. The .get_rf_strength ops is meant to get the signal strength from the tuner, but it doesn't allow the tuner to return a value in dBm.
It shouldn't be the demod's task to convert a raw value on a tuner client into dBm.
After reading this thread and its comments, I think that the best would be to not add a new callback.
Instead, change the implementation at the .get_rf_strength callback in a way that it will return an integer from 0 to 65535 that would represent a "percentage" level, where 100% means the maximum signal that the device can measure.
Inside the tuner driver (mxl301rf), a call to .get_rf_strength will directly update the FE stats cache to reflect the signal measurements in dBm.
So, from the bridge driver, it will just call .get_rf_strength() without using the returned results. If, latter, we use this tuner on some other configuration (for example, on an hybrid analog/digital or SDR/digital board), the V4L2 part will use the "percentage" level, as the V4L2 API doesn't support returning values in dBm.
Regards,
Mauro
Quoted 12 lines
af9033: implement DVBv5 statistic for CNR
https://patchwork.linuxtv.org/patch/25744/af9033: implement DVBv5 stat block counters
https://patchwork.linuxtv.org/patch/25749/af9033: implement DVBv5 post-Viterbi BER
https://patchwork.linuxtv.org/patch/25750/regards
Antti
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Em Fri, 5 Sep 2014 23:51:05 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 29 lines
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 21 lines
Moro!
Quoted 7 lines · Akihiro TSUKADA
moikka,
Quoted 4 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct
dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.Quoted 5 lines
I understand that RSSI property should be set directly in the tuner driver, but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.
Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/
Quoted 6 lines
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().
In time: not implementing its own thread has one drawback: the driver needs to check if the minimal time needed to get a new stats were already archived.
Please see the mt86a20s driver and check for some examples on how to properly do that.
There, we do things like:
static int mb86a20s_read_signal_strength(struct dvb_frontend *fe)
{
struct mb86a20s_state *state = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int rc;
unsigned rf_max, rf_min, rf;
if (state->get_strength_time &&
(!time_after(jiffies, state->get_strength_time)))
return c->strength.stat[0].uvalue;To prevent the stats to be called too fast.
Regards,
Mauro
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Quoted 58 lines · Mauro Carvalho Chehab
Em Fri, 5 Sep 2014 23:51:05 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:Quoted 29 lines
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 21 lines
Moro!
Quoted 7 lines · Akihiro TSUKADA
moikka,
Quoted 4 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct
dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.Quoted 5 lines
I understand that RSSI property should be set directly in the tuner driver, but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.
Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/Quoted 6 lines
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().In time: not implementing its own thread has one drawback: the driver needs to check if the minimal time needed to get a new stats were already archived.
Please see the mt86a20s driver and check for some examples on how to properly do that.
There, we do things like:
static int
mb86a20s_read_signal_strength(struct dvb_frontend *fe){ struct mb86a20s_state *state = fe->demodulator_priv; struct dtv_frontend_properties *c = &fe->dtv_property_cache; int rc; unsigned rf_max, rf_min, rf; if (state->get_strength_time && (!time_after(jiffies, state->get_strength_time))) return c->strength.stat[0].uvalue;
Quoted 1 line
To prevent the stats to be called too fast.
... I simply don't understand why you want hook that RF strength call via demod? The frontend cache is shared between demod and tuner. We use it for tuner driver as well demod driver. Let the tuner driver make RSSI calculation independently without any unneeded relation to demod driver.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Em Sat, 06 Sep 2014 06:10:01 +0300
Antti Palosaari <[email protected]> escreveu:
Quoted 61 lines · Mauro Carvalho Chehab
Quoted 58 lines
Em Fri, 5 Sep 2014 23:51:05 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:Quoted 29 lines
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 21 lines
Moro!
Quoted 7 lines · Akihiro TSUKADA
moikka,
Quoted 4 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct
dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.Quoted 5 lines
I understand that RSSI property should be set directly in the tuner driver, but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.
Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/Quoted 6 lines
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().In time: not implementing its own thread has one drawback: the driver needs to check if the minimal time needed to get a new stats were already archived.
Please see the mt86a20s driver and check for some examples on how to properly do that.
There, we do things like:
static int
mb86a20s_read_signal_strength(struct dvb_frontend *fe){ struct mb86a20s_state *state = fe->demodulator_priv; struct dtv_frontend_properties *c = &fe->dtv_property_cache; int rc; unsigned rf_max, rf_min, rf; if (state->get_strength_time && (!time_after(jiffies, state->get_strength_time))) return c->strength.stat[0].uvalue;
Quoted 6 lines
Quoted 1 line
To prevent the stats to be called too fast.
... I simply don't understand why you want hook that RF strength call via demod? The frontend cache is shared between demod and tuner. We use it for tuner driver as well demod driver. Let the tuner driver make RSSI calculation independently without any unneeded relation to demod driver.
Well, adding kthreads has a cost, with is a way higher than just calling a callback function.
Also, it makes a way more complicated to implement several tasks.
For example, devices with kthreads need to stop them during suspend, and restart them at resume time, or otherwise suspend and/or resume may not work.
Also, the power consumption increases with kthread, as the CPU need to be periodically waken.
I'm not saying we shouldn't use kthreads at driver level, but the best is to avoid when there are some other simpler ways of doing it.
Regards,
Mauro
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Quoted 17 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 06:10:01 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 4 lines
... I simply don't understand why you want hook that RF strength call via demod? The frontend cache is shared between demod and tuner. We use it for tuner driver as well demod driver. Let the tuner driver make RSSI calculation independently without any unneeded relation to demod driver.
Well, adding kthreads has a cost, with is a way higher than just calling a callback function.
Also, it makes a way more complicated to implement several tasks.
For example, devices with kthreads need to stop them during suspend, and restart them at resume time, or otherwise suspend and/or resume may not work.
Quoted 5 lines
Also, the power consumption increases with kthread, as the CPU need to be periodically waken.
I'm not saying we shouldn't use kthreads at driver level, but the best is to avoid when there are some other simpler ways of doing it.
And small reality check, how much you think one kthreads, that polls once per 2 second or so causes, in a case when you are *already streaming* 20-80 Mbit/sec data stream :) I think CPU does not need wake up to execute one thread as there is a lot of other interrupts happening in that use case anyway.
We have a remote controller which is polled often as 100ms and it happens even when device is "sleeping".
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Em Sat, 06 Sep 2014 06:34:33 +0300
Antti Palosaari <[email protected]> escreveu:
Quoted 21 lines · Mauro Carvalho Chehab
Quoted 20 lines
Em Sat, 06 Sep 2014 06:10:01 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 4 lines
... I simply don't understand why you want hook that RF strength call via demod? The frontend cache is shared between demod and tuner. We use it for tuner driver as well demod driver. Let the tuner driver make RSSI calculation independently without any unneeded relation to demod driver.
Well, adding kthreads has a cost, with is a way higher than just calling a callback function.
Also, it makes a way more complicated to implement several tasks.
For example, devices with kthreads need to stop them during suspend, and restart them at resume time, or otherwise suspend and/or resume may not work.
Also, the power consumption increases with kthread, as the CPU need to be periodically waken.
Quoted 8 lines
Quoted 2 lines
I'm not saying we shouldn't use kthreads at driver level, but the best is to avoid when there are some other simpler ways of doing it.
And small reality check, how much you think one kthreads, that polls once per 2 second or so causes, in a case when you are *already streaming* 20-80 Mbit/sec data stream :) I think CPU does not need wake up to execute one thread as there is a lot of other interrupts happening in that use case anyway.
You can't assume that all streams received by a tuner uses 20-80Mbps.
It could be a sound broadcasting stream, for example, with uses a much lower bandwidth.
Quoted 2 lines
We have a remote controller which is polled often as 100ms and it happens even when device is "sleeping".
And lots of drivers have a modprobe parameter to disable it, because it causes too much power consumption.
Regards,
Mauro
Akihiro TSUKADA
maintainerRe: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
In reply to Mauro Carvalho ChehabMoikka!,
thanks for the comments and advices.
I had been updating my code and during that, I also found that updating property cache in tuner_ops.get_signal_strength() was simple and (seemed to me) better than using a kthread, so the current implementation (under testing) is just like what Mauro proposed, but,
Quoted 2 lines
In time: not implementing its own thread has one drawback: the driver needs to check if the minimal time needed to get a new stats were already archived.
since I don't know the minimal time and
whether there's a limit in the first place,
I'd like to let users take the responsibility.
Quoted 4 lines
Quoted 4 lines
... I simply don't understand why you want hook that RF strength call via demod? The frontend cache is shared between demod and tuner. We use it for tuner drivr as well demod driver. Let the tuner driver make RSSI calculation independently without any unneeded relation to demod driver.
I think the main reason for the hook is because the dvb-core calls ops.get_frontend() everytime before reading of any property cache, so it is already a nice place to trigger property updates, and reading any property involves demod (FE as a whole) anyway.
regards,
akihiro
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Quoted 9 lines · Akihiro TSUKADA
Moikka!,
thanks for the comments and advices.I had been updating my code and during that, I also found that updating property cache in
tuner_ops.get_signal_strength()was simple and (seemed to me) better than using a kthread, so the current implementation (under testing) is just like what Mauro proposed, but,
Quoted 6 lines
Quoted 2 lines
In time: not implementing its own thread has one drawback: the driver needs to check if the minimal time needed to get a new stats were already archived.
since I don't know the minimal time and
whether there's a limit in the first place,
I'd like to let users take the responsibility.
You could add some simple jiffie (some kind of kernel global time) which limits calls to some reasonable level.
if (jiffies > jiffies_previous + 1 sec)
return 0;
else
jiffies_previous = jiffies;
... continue
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
... I simply don't understand why you want hook that RF strength call via demod? The frontend cache is shared between demod and tuner. We use it for tuner drivr as well demod driver. Let the tuner driver make RSSI calculation independently without any unneeded relation to demod driver.
I think the main reason for the hook is because the dvb-core calls
ops.get_frontend()everytime before reading of any property cache, so it is already a nice place to trigger property updates, and reading any property involves demod (FE as a whole) anyway.
That must be changed 'resently'. IIRC originally get_frontend() was called by dvb-core only once, just after demod lock was gained. Also userspace could call it using some IOCTL (GET_FRONTEND?).
But if it is not called periodically by dvb-core, you could not use it for bit error measurements, as you will usually need to start measurement, then wait complete, read values and return.
Signal strength and SNR are typically provided by chip without any waiting.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Em Sat, 06 Sep 2014 13:36:14 +0300
Antti Palosaari <[email protected]> escreveu:
Quoted 10 lines · Akihiro TSUKADA
Quoted 9 lines
Moikka!,
thanks for the comments and advices.I had been updating my code and during that, I also found that updating property cache in
tuner_ops.get_signal_strength()was simple and (seemed to me) better than using a kthread, so the current implementation (under testing) is just like what Mauro proposed, but,
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
In time: not implementing its own thread has one drawback: the driver needs to check if the minimal time needed to get a new stats were already archived.
since I don't know the minimal time and
whether there's a limit in the first place,
I'd like to let users take the responsibility.
For RSSI measurements, in general there's no minimal time, but for measures like BER, PER, UCB, you'll need to wait for a while before the stats to be updated. So, you'll need to at least track those.
Quoted 7 lines
You could add some simple jiffie (some kind of kernel global time) which limits calls to some reasonable level.
if (jiffies >
jiffies_previous+ 1 sec)
return 0;
else
jiffies_previous= jiffies;
Don't use jiffies like that. jiffies can be overflowed and the update will never occur. The right way is to use the macros time_after() and time_before(), or, alternatively, time_is_after_jiffies() and time_is_before_jiffies().
Quoted 8 lines
... continue
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
... I simply don't understand why you want hook that RF strength call via demod? The frontend cache is shared between demod and tuner. We use it for tuner drivr as well demod driver. Let the tuner driver make RSSI calculation independently without any unneeded relation to demod driver.
Quoted 8 lines
Quoted 4 lines
I think the main reason for the hook is because the dvb-core calls
ops.get_frontend()everytime before reading of any property cache, so it is already a nice place to trigger property updates, and reading any property involves demod (FE as a whole) anyway.That must be changed 'resently'. IIRC originally
get_frontend()was called by dvb-core only once, just after demod lock was gained. Also userspace could call it using some IOCTL (GET_FRONTEND?).
No, get_frontend() is not automatically called by the dvb kthread after lock has gained. Just double-checked.
Quoted 3 lines
But if it is not called periodically by dvb-core, you could not use it for bit error measurements, as you will usually need to start measurement, then wait complete, read values and return.
Probably, the application you're using for tests are calling it periodically.
What the core calls periodically for sure is read_status(). That's why most drivers that provide DVBv5 stats hook the cache update there.
Quoted 5 lines
Signal strength and SNR are typically provided by chip without any waiting.
regards
Antti
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
In reply to Mauro Carvalho ChehabQuoted 29 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 21 lines
Moro!
Quoted 7 lines · Akihiro TSUKADA
moikka,
Quoted 4 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI and writes value to struct
dtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he designed that functionality.Quoted 5 lines
I understand that RSSI property should be set directly in the tuner driver, but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.
Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/
Quoted 7 lines
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().
Hmm, fepriv->delay missed that one, 3 seconds is far too long for lmedm04.
It would be good to hook stats on to this thread.
Regards
Malcolm
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Quoted 41 lines · Malcolm Priestley
Quoted 32 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 24 lines
Moro!
Quoted 9 lines · Akihiro TSUKADA
moikka,
Quoted 6 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI
and writes value to structdtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he
designed that functionality.Quoted 6 lines
I understand that RSSI property should be set directly in the tuner driver,
but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/Quoted 7 lines
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().
Quoted 3 lines
Hmm,
fepriv->delaymissed that one, 3 seconds is far too long for lmedm04.It would be good to hook stats on to this thread.
optional that is.
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
In reply to Malcolm PriestleyQuoted 41 lines · Malcolm Priestley
Quoted 32 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 24 lines
Moro!
Quoted 9 lines · Akihiro TSUKADA
moikka,
Quoted 6 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI
and writes value to structdtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he
designed that functionality.Quoted 6 lines
I understand that RSSI property should be set directly in the tuner driver,
but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/Quoted 7 lines
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().
Quoted 1 line
Hmm,
fepriv->delaymissed that one, 3 seconds is far too long for lmedm04.
The only way change this is by using algo DVBFE_ALGO_HW using the frontend ops tune.
As most frontends are using dvb_frontend_swzigzag it could be implemented by patching the frontend ops tune code at the lock return in this function or in dvb_frontend_swzigzag_update_delay.
Regards
Malcolm
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Em Sat, 06 Sep 2014 22:37:21 +0100
Malcolm Priestley <[email protected]> escreveu:
Quoted 42 lines · Malcolm Priestley
Quoted 41 lines · Mauro Carvalho Chehab
Quoted 39 lines
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 24 lines
Moro!
Quoted 9 lines · Akihiro TSUKADA
moikka,
Quoted 6 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI
and writes value to structdtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he
designed that functionality.Quoted 6 lines
I understand that RSSI property should be set directly in the tuner driver,
but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().
Quoted 8 lines
Quoted 1 line
Hmm,
fepriv->delaymissed that one, 3 seconds is far too long for lmedm04.The only way change this is by using algo
DVBFE_ALGO_HWusing the frontend ops tune.As most frontends are using
dvb_frontend_swzigzagit could be implemented by patching the frontend ops tune code at the lock return in this function or indvb_frontend_swzigzag_update_delay.
Well, if a different value is needed, it shouldn't be hard to add a way to customize it, letting the demod to specify it, in the same way as fe->ops.info.frequency_stepsize (and other similar demot properties) are passed through the core.
Regards,
Mauro
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Quoted 50 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 22:37:21 +0100
Malcolm Priestley <[email protected]> escreveu:Quoted 47 lines · Malcolm Priestley
Quoted 41 lines · Mauro Carvalho Chehab
Quoted 32 lines
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 24 lines
Moro!
Quoted 9 lines · Akihiro TSUKADA
moikka,
Quoted 6 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI
and writes value to structdtv_frontend_properties. That it is, in my understanding. Same for all those DVBv5 stats. Mauro knows better as he
designed that functionality.Quoted 6 lines
I understand that RSSI property should be set directly in the tuner driver,
but I'm afraid that creating a kthread just for updating RSSI would be overkill and complicate matters.Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength is reported by demod, not tuner, because there is some logic in firmware to calculate it.
Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/Quoted 7 lines
Actually, you don't need to add a separate kthread to collect the stats. The DVB frontend core already has a thread that calls the frontend status on every 3 seconds (the time can actually be different, depending on the value for
fepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic atops.read_status().Quoted 1 line
Hmm,
fepriv->delaymissed that one, 3 seconds is far too long for lmedm04.The only way change this is by using algo
DVBFE_ALGO_HWusing the frontend ops tune.
Quoted 8 lines
Quoted 3 lines
As most frontends are using
dvb_frontend_swzigzagit could be implemented by patching the frontend ops tune code at the lock return in this function or indvb_frontend_swzigzag_update_delay.Well, if a different value is needed, it shouldn't be hard to add a way to customize it, letting the demod to specify it, in the same way as
fe->ops.info.frequency_stepsize(and other similar demot properties) are passed through the core.
DVBFE_ALGO_SW, which is used normally, polls read_status rather rapidly. For statics problem is that it is too rapid, not that it is too slow. If you want re-use that as a timer for statistics, you could simply make own ratelimit very easily using kernel jiffies.
Not going to implement details, but here is skeleton, which is almost as many lines of code as actual implementation:
if (jiffies < jiffies_prev + 2 sec)
return 0; // limit on
else
jiffies_prev = jiffies;
... statistics polling code here.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: [PATCH v2 1/5] dvb-core: add a new tuner ops to dvb_frontend for APIv5
Quoted 70 lines · Antti Palosaari
Quoted 58 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 22:37:21 +0100
Malcolm Priestley <[email protected]> escreveu:Quoted 55 lines · Malcolm Priestley
Quoted 48 lines · Mauro Carvalho Chehab
Quoted 36 lines
Em Sat, 06 Sep 2014 05:09:55 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 28 lines
Moro!
Quoted 10 lines · Akihiro TSUKADA
moikka,
Quoted 7 lines
Start polling thread, which polls once per 2 sec or so, which reads RSSI
and writes value to structdtv_frontend_properties. That it is, in my
understanding. Same for all those DVBv5 stats. Mauro knows better as he
designed that functionality.Quoted 7 lines
I understand that RSSI property should be set directly in the tuner driver,
but I'm afraid that creating a kthread just for updating RSSI would be
overkill and complicate matters.Would you give me an advice? >> Mauro
Now I know that as I implement it. I added kthread and it works correctly, just I though it is aimed to work. In my case signal strength
is reported by demod, not tuner, because there is some logic in firmware
to calculate it.Quoted 4 lines
Here is patches you would like to look as a example:
af9033: implement DVBv5 statistic for signal strength
https://patchwork.linuxtv.org/patch/25748/Quoted 10 lines
Actually, you don't need to add a separate kthread to collect the stats.
The DVB frontend core already has a thread that calls the frontend status
on every 3 seconds (the time can actually be different, depending on the value forfepriv->delay. So, if the device doesn't have any issues on getting stats on this period, it could just hook the DVBv5 stats logic
atops.read_status().Quoted 2 lines
Hmm,
fepriv->delaymissed that one, 3 seconds is far too long for lmedm04.The only way change this is by using algo
DVBFE_ALGO_HWusing the frontend ops tune.Quoted 8 lines
Quoted 3 lines
As most frontends are using
dvb_frontend_swzigzagit could be implemented by patching the frontend ops tune code at the lock return in this function or indvb_frontend_swzigzag_update_delay.Well, if a different value is needed, it shouldn't be hard to add a way to customize it, letting the demod to specify it, in the same way as
fe->ops.info.frequency_stepsize(and other similar demot properties) are passed through the core.
Quoted 4 lines
DVBFE_ALGO_SW, which is used normally, pollsread_statusrather rapidly. For statics problem is that it is too rapid, not that it is too slow. If you want re-use that as a timer for statistics, you could simply make own ratelimit very easily using kernel jiffies.
The default starts off at 50msec and gradually rises to around 950msec.
There is another way to set fepriv->delay that is in ops->get_tune_settings dvb_frontend_tune_settings->min_delay_ms.
The delay increases by around 900msec on top of the value set there.
In the case of lmedm04/m88rs2000 that why I am seeing 3 sec.
Regards
Malcolm
[email protected]
maintainerPATCH v2 2/5 mxl301rf: add driver for MaxLinear MxL301RF OFDM tuner
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
This patch adds driver for mxl301rf OFDM tuner chips. It is used as an ISDB-T tuner in earthsoft pt3 cards.
Note that this driver does not initilize the chip,
because the initilization sequence / register setting is not disclosed. Thus, the driver assumes that the chips are initilized externally by its parent board driver before tuner_ops->init() are called, like in PT3 driver where the bridge chip contains the init sequence in its private memory and provides a command to trigger the sequence.
---
Changes in v2:
- use new tuner ops for get_signal_strengh() for DVBv5 API
- removed automatic frequency adjustment
- moved static const tables out of function scope
- extend max acceptable frequency to accept ISDB-Tb
drivers/media/tuners/Kconfig | 7 + drivers/media/tuners/Makefile | 1 + drivers/media/tuners/mxl301rf.c | 334 ++++++++++++++++++++++++++++++++++++++++ drivers/media/tuners/mxl301rf.h | 40 +++++ 4 files changed, 382 insertions(+)
drivers/media/tuners/Kconfig +7 -0
@@ -257,4 +257,11 @@ config MEDIA_TUNER_R820T default m if !MEDIA_SUBDRV_AUTOSELECT help Rafael Micro R820T silicon tuner driver. + +config MEDIA_TUNER_MXL301RF + tristate "MaxLinear MxL301RF tuner" + depends on MEDIA_SUPPORT && I2C + default m if !MEDIA_SUBDRV_AUTOSELECT + help + MaxLinear MxL301RF OFDM tuner driver. endmenu
drivers/media/tuners/Makefile +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_MEDIA_TUNER_FC0012) += fc0012.o obj-$(CONFIG_MEDIA_TUNER_FC0013) += fc0013.o obj-$(CONFIG_MEDIA_TUNER_IT913X) += tuner_it913x.o obj-$(CONFIG_MEDIA_TUNER_R820T) += r820t.o +obj-$(CONFIG_MEDIA_TUNER_MXL301RF) += mxl301rf.o ccflags-y += -I$(srctree)/drivers/media/dvb-core ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
drivers/media/tuners/mxl301rf.c new file +334 -0
334 lines not on this page · raw message
drivers/media/tuners/mxl301rf.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* MaxLinear MxL301RF OFDM tuner driver +* +* Copyright (C) 2014 Akihiro Tsukada <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef MXL301RF_H +#define MXL301RF_H + +#include <linux/kconfig.h> +#include "dvb_frontend.h" + +struct mxl301rf_config { +u8 addr; +u32 init_freq; +}; + +#if IS_ENABLED (CONFIG_MEDIA_TUNER_MXL301RF ) +extern struct dvb_frontend *mxl301rf_attach (struct dvb_frontend *fe, +struct i2c_adapter *i2c,const struct mxl301rf_config *cfg); +#else +static inline struct dvb_frontend *mxl301rf_attach (struct dvb_frontend *fe, +struct i2c_adapter *i2c,const struct mxl301rf_config *cfg) +{ +printk (KERN_WARNING "%s: driver disabled by Kconfig\n" , __func__); +return NULL ; +} +#endif + +#endif /* MXL301RF_H */
Signature · 1 line
2.1.0
[email protected]
maintainerPATCH v2 3/5 qm1d1c0042: add driver for Sharp QM1D1C0042 ISDB-S tuner
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
This patch adds driver for qm1d1c0042 tuner chips. It is used as an ISDB-S tuner in earthsoft pt3 cards.
---
Changes in v2:
- moved a static const table out of function scope
- removed an unused config parameter
- improvement in _init() to support suspend/resume
drivers/media/tuners/Kconfig | 7 + drivers/media/tuners/Makefile | 1 + drivers/media/tuners/qm1d1c0042.c | 422 ++++++++++++++++++++++++++++++++++++++ drivers/media/tuners/qm1d1c0042.h | 50 +++++ 4 files changed, 480 insertions(+)
drivers/media/tuners/Kconfig +7 -0
@@ -264,4 +264,11 @@ config MEDIA_TUNER_MXL301RF default m if !MEDIA_SUBDRV_AUTOSELECT help MaxLinear MxL301RF OFDM tuner driver. + +config MEDIA_TUNER_QM1D1C0042 + tristate "Sharp QM1D1C0042 tuner" + depends on MEDIA_SUPPORT && I2C + default m if !MEDIA_SUBDRV_AUTOSELECT + help + Sharp QM1D1C0042 trellis coded 8PSK tuner driver. endmenu
drivers/media/tuners/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_MEDIA_TUNER_FC0013) += fc0013.o obj-$(CONFIG_MEDIA_TUNER_IT913X) += tuner_it913x.o obj-$(CONFIG_MEDIA_TUNER_R820T) += r820t.o obj-$(CONFIG_MEDIA_TUNER_MXL301RF) += mxl301rf.o +obj-$(CONFIG_MEDIA_TUNER_QM1D1C0042) += qm1d1c0042.o ccflags-y += -I$(srctree)/drivers/media/dvb-core ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
drivers/media/tuners/qm1d1c0042.c new file +422 -0
422 lines not on this page · raw message
drivers/media/tuners/qm1d1c0042.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.1.0
[email protected]
maintainerPATCH v2 4/5 tc90522: add driver for Toshiba TC90522 quad demodulator
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
This patch adds driver for tc90522 demodulator chips.
The chip contains 4 demod modules that run in parallel and are independently controllable via separate I2C addresses.
Two of the modules are for ISDB-T and the rest for ISDB-S.
It is used in earthsoft pt3 cards.
Note that this driver does not init the chip,
because the initilization sequence / register setting is not disclosed. Thus, the driver assumes that the chips are initilized externally by its parent board driver before fe->ops->init() are called. Earthsoft PT3 PCIe card, for example, contains the init sequence in its private memory and provides a command to trigger the sequence.
---
Changes in v2:
- renamed badly named variables
- moved static const tables out of function scope
- calculate symbol rate per output TS
- improve in _init() to support suspend/resume
drivers/media/dvb-frontends/Kconfig | 8 + drivers/media/dvb-frontends/Makefile | 1 + drivers/media/dvb-frontends/tc90522.c | 857 ++++++++++++++++++++++++++++++++++ drivers/media/dvb-frontends/tc90522.h | 63 +++ 4 files changed, 929 insertions(+)
drivers/media/dvb-frontends/Kconfig +8 -0
@@ -648,6 +648,14 @@ config DVB_MB86A20S A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator. Say Y when you want to support this frontend. +config DVB_TC90522 + tristate "Toshiba TC90522" + depends on DVB_CORE && I2C + default m if !MEDIA_SUBDRV_AUTOSELECT + help + A Toshiba TC90522 2xISDB-T + 2xISDB-S demodulator. + Say Y when you want to support this frontend. + comment "Digital terrestrial only tuners/PLL" depends on DVB_CORE
drivers/media/dvb-frontends/Makefile +1 -0
@@ -114,3 +114,4 @@ obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o obj-$(CONFIG_DVB_AF9033) += af9033.o obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o +obj-$(CONFIG_DVB_TC90522) += tc90522.o
drivers/media/dvb-frontends/tc90522.c new file +857 -0
857 lines not on this page · raw message
drivers/media/dvb-frontends/tc90522.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
Quoted 2 lines · On 27.08.2014 17:29, [email protected] wrote:
From: Akihiro Tsukada <[email protected]>
Hi Akihiro,
Quoted 106 lines
This patch adds driver for tc90522 demodulator chips.
The chip contains 4 demod modules that run in parallel and are independently controllable via separate I2C addresses.
Two of the modules are for ISDB-T and the rest for ISDB-S.
It is used in earthsoft pt3 cards.Note that this driver does not init the chip,
because the initilization sequence / register setting is not disclosed. Thus, the driver assumes that the chips are initilized externally by its parent board driver beforefe->ops->init()are called. Earthsoft PT3 PCIe card, for example, contains the init sequence in its private memory and provides a command to trigger the sequence.Signed-off-by Akihiro Tsukada <[email protected]>drivers/media/dvb-frontends/tc90522.c new file +49
-0+ +struct dvb_frontend * +tc90522_attach (const struct tc90522_config *cfg,struct i2c_adapter *i2c) +{ +struct tc90522_state *state; +const struct dvb_frontend_ops *ops; +struct i2c_adapter *adap; +int ret; + + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return NULL ; + +memcpy (&state->cfg, cfg,sizeof (*cfg)); + state->i2c = i2c; + ops =TC90522_IS_ISDBS (cfg->addr) ? &tc90522_ops_sat : &tc90522_ops_ter; +memcpy (&state->dvb_fe.ops, ops,sizeof (*ops)); + state->dvb_fe.demodulator_priv = state; + + adap = &state->tuner_i2c; + adap->owner = i2c->owner; + adap->algo = &tc90522_tuner_i2c_algo; + adap->dev.parent = i2c->dev.parent; +strlcpy (adap->name,"tc90522 tuner" ,sizeof (adap->name)); +i2c_set_adapdata (adap, state); + ret =i2c_add_adapter (adap); +if (ret <0 ) { +kfree (state); +return NULL ; + } +dev_info (&i2c->dev,"Toshiba TC90522 attached.\n" ); +return &state->dvb_fe; +} +EXPORT_SYMBOL (tc90522_attach); + + +struct i2c_adapter *tc90522_get_tuner_i2c (struct dvb_frontend *fe) +{ +struct tc90522_state *state; + + state = fe->demodulator_priv; +return &state->tuner_i2c; +} +EXPORT_SYMBOL (tc90522_get_tuner_i2c); + + +MODULE_DESCRIPTION ("Toshiba TC90522 frontend" ); +MODULE_AUTHOR ("Akihiro TSUKADA" ); +MODULE_LICENSE ("GPL" );drivers/media/dvb-frontends/tc90522.h new file +36
-0@@ -0,0 +1,63 @@ +/* +* Toshiba TC90522 Demodulator +* +* Copyright (C) 2014 Akihiro Tsukada <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +/* +* The demod has 4 input (2xISDB-T and 2xISDB-S), +* and provides independent sub modules for each input. +* As the sub modules work in parallel and have the separate i2c addr's, +* this driver treats each sub module as one demod device. +*/ + +#ifndef TC90522_H +#define TC90522_H + +#include <linux/i2c.h> +#include <linux/kconfig.h> +#include "dvb_frontend.h" + +#define TC90522_IS_ISDBS (addr) (addr & 1) + +#define TC90522T_CMD_SET_LNA 1 +#define TC90522S_CMD_SET_LNB 1 + +struct tc90522_config {
drivers/media/dvb-frontends/tc90522.h line 46
Quoted 10 lines
drivers/media/dvb-frontends/tc90522.h new file +10
-0+u8 addr; +}; + +#if IS_ENABLED (CONFIG_DVB_TC90522 ) + +extern struct dvb_frontend *tc90522_attach (const struct tc90522_config *cfg, +struct i2c_adapter *i2c); + +extern struct i2c_adapter *tc90522_get_tuner_i2c (struct dvb_frontend *fe); +
it sounds wrong to export a second function besides tc90522_attach. This way there is a hard dependency of the bridge driver to the demod driver.
In this case it is the only possible demod, but in general it violates the design of demod drivers and their connection to bridge drivers.
si2168_probe at least has a solution for this:
Write the pointer to the new i2c adapter into location stored in "struct i2c_adapter **" in the config structure.
Regards
Matthias
Akihiro TSUKADA
maintainerRe: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
Hi Matthias,
thanks for the comment.
Quoted 5 lines
it sounds wrong to export a second function besides
tc90522_attach. This way there is a hard dependency of the bridge driver to the demod driver.
In this case it is the only possible demod, but in general it violates the design of demod drivers and their connection to bridge drivers.
I agree. I missed that point.
Quoted 4 lines
si2168_probeat least has a solution for this:
Write the pointer to the new i2c adapter into location stored in "structi2c_adapter**" in the config structure.
I'll look into the si2168 code and update tc90522 in v3.
regards,
akihiro
Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
Quoted 9 lines · Akihiro TSUKADA
Hi Matthias,
thanks for the comment.Quoted 5 lines
it sounds wrong to export a second function besides
tc90522_attach. This way there is a hard dependency of the bridge driver to the demod driver.
In this case it is the only possible demod, but in general it violates the design of demod drivers and their connection to bridge drivers.
Quoted 8 lines
I agree. I missed that point.
Quoted 4 lines
si2168_probeat least has a solution for this:
Write the pointer to the new i2c adapter into location stored in "structi2c_adapter**" in the config structure.I'll look into the si2168 code and update tc90522 in v3.
Also, I would like to see all new drivers (demod and tuner) implemented as a standard kernel I2C drivers (or any other bus). I have converted already quite many drivers, si2168, si2157, m88ds3103, m88ts2022, it913x, tda18212, ... When drivers are using proper kernel driver models, it allows using kernel services. For example dev_ / pr_ logging (it does not work properly without), RegMap API, I2C client, I2C multiplex, and so...
Here is few recent examples:
https://patchwork.linuxtv.org/patch/25495/
https://patchwork.linuxtv.org/patch/25152/
https://patchwork.linuxtv.org/patch/25146/
regards
Antti
Signature · 1 line
http://palosaari.fi/
Akihiro TSUKADA
maintainerRe: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
Hi,
Quoted 4 lines
Also, I would like to see all new drivers (demod and tuner) implemented as a standard kernel I2C drivers (or any other bus). I have converted already quite many drivers, si2168, si2157, m88ds3103, m88ts2022, it913x, tda18212, ...
I wrote the code in the old style using dvb_attach() because (I felt) it is simpler than using i2c_new_device() by introducing new i2c-related data structures, registering to both dvb and i2c, without any new practical features that i2c client provides.
But if the use of dvb_attach() is (almost) deprecated and i2c client driver is the standard/prefered way, I'll convert my code.
regards,
akihiro
Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
Quoted 7 lines · Akihiro TSUKADA
Hi,
Quoted 4 lines
Also, I would like to see all new drivers (demod and tuner) implemented as a standard kernel I2C drivers (or any other bus). I have converted already quite many drivers, si2168, si2157, m88ds3103, m88ts2022, it913x, tda18212, ...
Quoted 5 lines
I wrote the code in the old style using
dvb_attach()because (I felt) it is simpler than usingi2c_new_device()by introducing new i2c-related data structures, registering to both dvb and i2c, without any new practical features that i2c client provides.
Of course it is simpler to do old style as you could copy & paste older drivers and so. However, for a long term we must get rid of all DVB specific hacks and use common kernel solutions. The gap between common kernel solutions and DVB proprietary is already too big, without any good reason - just a laziness of developers to find out proper solutions as adding hacks is easier.
I mentioned quite many reasons earlier and If you look that driver you will see you use dev_foo() logging, that does not even work properly unless you convert driver to some kernel binding model (I2C on that case) (as I explained earlier).
There is also review issues. For more people do own tricks and hacks the harder code is review and also maintain as you don't never know what breaks when you do small change, which due to some trick used causes some other error.
Here is one example I fixed recently:
https://patchwork.linuxtv.org/patch/25776/
Lets mention that I am not even now fully happy to solution, even it somehow now works. Proper solution is implement clock source and clock client. Then register client to that source. And when client needs a clock (or power) it makes call to enable clock.
Quoted 3 lines
But if the use of
dvb_attach()is (almost) deprecated and i2c client driver is the standard/prefered way, I'll convert my code.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
Em Sat, 06 Sep 2014 05:02:15 +0300
Antti Palosaari <[email protected]> escreveu:
Quoted 26 lines · Akihiro TSUKADA
Quoted 7 lines
Hi,
Quoted 4 lines
Also, I would like to see all new drivers (demod and tuner) implemented as a standard kernel I2C drivers (or any other bus). I have converted already quite many drivers, si2168, si2157, m88ds3103, m88ts2022, it913x, tda18212, ...
Quoted 5 lines
I wrote the code in the old style using
dvb_attach()because (I felt) it is simpler than usingi2c_new_device()by introducing new i2c-related data structures, registering to both dvb and i2c, without any new practical features that i2c client provides.Of course it is simpler to do old style as you could copy & paste older drivers and so. However, for a long term we must get rid of all DVB specific hacks and use common kernel solutions. The gap between common kernel solutions and DVB proprietary is already too big, without any good reason - just a laziness of developers to find out proper solutions as adding hacks is easier.
I mentioned quite many reasons earlier and If you look that driver you will see you use
dev_foo()logging, that does not even work properly unless you convert driver to some kernel binding model (I2C on that case) (as I explained earlier).
Quoted 7 lines
There is also review issues. For more people do own tricks and hacks the harder code is review and also maintain as you don't never know what breaks when you do small change, which due to some trick used causes some other error.
Here is one example I fixed recently:
https://patchwork.linuxtv.org/patch/25776/
Yes, using the I2C binding way provides a better decoupling than using the legacy way. The current dvb_attach() macros are hacks that were created by the time where the I2C standard bind didn't work with DVB.
We need to move on.
Quoted 5 lines
Lets mention that I am not even now fully happy to solution, even it somehow now works. Proper solution is implement clock source and clock client. Then register client to that source. And when client needs a clock (or power) it makes call to enable clock.
Well, we need to discuss more about that, because you need to convince me first about that ;)
We had already some discussions about that related to V4L2 I2C devices. The consensus we've reached is that it makes sense to use the clock framework only for the cases where the bridge driver doesn't know anything about the clock to be used by a given device, e. g. in the case where this data comes from the Device Tree (embedded systems).
In the case where the bridge is the ownership of the information that will be used by a given device model (clock, serial/parallel mode, etc), then a series of data information should be passed by a call from the bridge driver to the device at setup time, and doing it in an atomic way is the best way to go.
Anyway, such discussions don't belong to this thread. For the PT3 and tc90522 to be merged, the only pending stuff to be done is to use the I2C binding.
Akihiro-san,
Please change the driver to use the I2C model as pointed by Antti.
Thank you!
Mauro
Quoted 7 lines
Quoted 3 lines
But if the use of
dvb_attach()is (almost) deprecated and i2c client driver is the standard/prefered way, I'll convert my code.regards
Antti
DVB clock source (Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator)
Quoted 17 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 05:02:15 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 4 lines
Lets mention that I am not even now fully happy to solution, even it somehow now works. Proper solution is implement clock source and clock client. Then register client to that source. And when client needs a clock (or power) it makes call to enable clock.
Well, we need to discuss more about that, because you need to convince me first about that ;)
We had already some discussions about that related to V4L2 I2C devices. The consensus we've reached is that it makes sense to use the clock framework only for the cases where the bridge driver doesn't know anything about the clock to be used by a given device, e. g. in the case where this data comes from the Device Tree (embedded systems).
Quoted 5 lines
In the case where the bridge is the ownership of the information that will be used by a given device model (clock, serial/parallel mode, etc), then a series of data information should be passed by a call from the bridge driver to the device at setup time, and doing it in an atomic way is the best way to go.
For AF9033/IT9133 demod + tuner I resolved it like that:
https://patchwork.linuxtv.org/patch/25772/
https://patchwork.linuxtv.org/patch/25774/
It is demod which provides clock for tuner. It is very common situation nowadays, one or more clocks are shared. And clock sharing is routed via chips so that there is clock gates you have enable/disable for power management reasons.
Currently we just enable clocks always. Clock output is put on when driver is attached and it is never disabled after that, leaving power management partly broken.
Lets take a example, dual tuner case:
tuner#0 gets clock from Xtal
tuner#1 gets clock from #tuner0
All possible use cases are:
1) #tuner0 off & #tuner1 off
2) #tuner0 on & #tuner1 off
3) #tuner1 off & #tuner1 on
4) #tuner1 on & #tuner1 on
you will need, as per aforementioned use case:
1) #tuner0 clock out off & #tuner1 clock out off
2) #tuner0 clock out off & #tuner1 clock out off
3) #tuner0 clock out on & #tuner1 clock out off
4) #tuner0 clock out on & #tuner1 clock out off
Implementing that currently is simply impossible. But if you use clock framework (or what ever its name is) I think it is possible to implement that properly. When tuner#1 driver needs a clock, it calls "get clock" and that call is routed to #tuner0 which enables clock.
And that was not even the most complicated case, as many times clock is routed to demod and USB bridge too.
Quite same situation is for power on/off gpios (which should likely implemented as a regulator). Also there is many times reset gpio (for PM chip is powered off by switching power totally off *or* chip is put to reset using GPIO)
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: DVB clock source (Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator)
Em Sat, 06 Sep 2014 06:00:28 +0300
Antti Palosaari <[email protected]> escreveu:
Quoted 58 lines · Mauro Carvalho Chehab
Quoted 17 lines
Em Sat, 06 Sep 2014 05:02:15 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 4 lines
Lets mention that I am not even now fully happy to solution, even it somehow now works. Proper solution is implement clock source and clock client. Then register client to that source. And when client needs a clock (or power) it makes call to enable clock.
Well, we need to discuss more about that, because you need to convince me first about that ;)
We had already some discussions about that related to V4L2 I2C devices. The consensus we've reached is that it makes sense to use the clock framework only for the cases where the bridge driver doesn't know anything about the clock to be used by a given device, e. g. in the case where this data comes from the Device Tree (embedded systems).
Quoted 5 lines
In the case where the bridge is the ownership of the information that will be used by a given device model (clock, serial/parallel mode, etc), then a series of data information should be passed by a call from the bridge driver to the device at setup time, and doing it in an atomic way is the best way to go.
For AF9033/IT9133 demod + tuner I resolved it like that:
https://patchwork.linuxtv.org/patch/25772/
https://patchwork.linuxtv.org/patch/25774/It is demod which provides clock for tuner. It is very common situation nowadays, one or more clocks are shared. And clock sharing is routed via chips so that there is clock gates you have enable/disable for power management reasons.
Currently we just enable clocks always. Clock output is put on when driver is attached and it is never disabled after that, leaving power management partly broken.
Lets take a example, dual tuner case:
tuner#0 gets clock from Xtal
tuner#1 gets clock from #tuner0All possible use cases are:
1) #tuner0 off & #tuner1 off
2) #tuner0 on & #tuner1 off
3) #tuner1 off & #tuner1 on
4) #tuner1 on & #tuner1 onyou will need, as per aforementioned use case:
1) #tuner0 clock out off & #tuner1 clock out off
2) #tuner0 clock out off & #tuner1 clock out off
3) #tuner0 clock out on & #tuner1 clock out off
4) #tuner0 clock out on & #tuner1 clock out offImplementing that currently is simply impossible. But if you use clock framework (or what ever its name is) I think it is possible to implement that properly. When tuner#1 driver needs a clock, it calls "get clock" and that call is routed to #tuner0 which enables clock.
Quoted 7 lines
And that was not even the most complicated case, as many times clock is routed to demod and USB bridge too.
Quite same situation is for power on/off gpios (which should likely implemented as a regulator). Also there is many times reset gpio (for PM chip is powered off by switching power totally off *or* chip is put to reset using GPIO)
Ok, in the above scenario, I agree that using the clock framework makes sense, but, on devices where the clock is independent (e. g. each chip has its on XTAL), I'm yet to see a scenario where using the clock framework will simplify the code or bring some extra benefit.
Regards,
Mauro
Re: DVB clock source (Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator)
Quoted 69 lines · Mauro Carvalho Chehab
Em Sat, 06 Sep 2014 06:00:28 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 58 lines · Mauro Carvalho Chehab
Quoted 17 lines
Em Sat, 06 Sep 2014 05:02:15 +0300
Antti Palosaari <[email protected]> escreveu:Quoted 4 lines
Lets mention that I am not even now fully happy to solution, even it somehow now works. Proper solution is implement clock source and clock client. Then register client to that source. And when client needs a clock (or power) it makes call to enable clock.
Well, we need to discuss more about that, because you need to convince me first about that ;)
We had already some discussions about that related to V4L2 I2C devices. The consensus we've reached is that it makes sense to use the clock framework only for the cases where the bridge driver doesn't know anything about the clock to be used by a given device, e. g. in the case where this data comes from the Device Tree (embedded systems).
Quoted 5 lines
In the case where the bridge is the ownership of the information that will be used by a given device model (clock, serial/parallel mode, etc), then a series of data information should be passed by a call from the bridge driver to the device at setup time, and doing it in an atomic way is the best way to go.
For AF9033/IT9133 demod + tuner I resolved it like that:
https://patchwork.linuxtv.org/patch/25772/
https://patchwork.linuxtv.org/patch/25774/It is demod which provides clock for tuner. It is very common situation nowadays, one or more clocks are shared. And clock sharing is routed via chips so that there is clock gates you have enable/disable for power management reasons.
Currently we just enable clocks always. Clock output is put on when driver is attached and it is never disabled after that, leaving power management partly broken.
Lets take a example, dual tuner case:
tuner#0 gets clock from Xtal
tuner#1 gets clock from #tuner0All possible use cases are:
1) #tuner0 off & #tuner1 off
2) #tuner0 on & #tuner1 off
3) #tuner1 off & #tuner1 on
4) #tuner1 on & #tuner1 onyou will need, as per aforementioned use case:
1) #tuner0 clock out off & #tuner1 clock out off
2) #tuner0 clock out off & #tuner1 clock out off
3) #tuner0 clock out on & #tuner1 clock out off
4) #tuner0 clock out on & #tuner1 clock out offImplementing that currently is simply impossible. But if you use clock framework (or what ever its name is) I think it is possible to implement that properly. When tuner#1 driver needs a clock, it calls "get clock" and that call is routed to #tuner0 which enables clock.
Quoted 7 lines
And that was not even the most complicated case, as many times clock is routed to demod and USB bridge too.
Quite same situation is for power on/off gpios (which should likely implemented as a regulator). Also there is many times reset gpio (for PM chip is powered off by switching power totally off *or* chip is put to reset using GPIO)
Quoted 5 lines
Ok, in the above scenario, I agree that using the clock framework makes sense, but, on devices where the clock is independent (e. g. each chip has its on XTAL), I'm yet to see a scenario where using the clock framework will simplify the code or bring some extra benefit.
And I resolved it like that for IT9135:
https://patchwork.linuxtv.org/patch/25763/
1) defined tuner role config parameter (master feeds a clock, slave does not)
2) master is then never put 100% deep sleep
Comment on code explains that:
/*
* Writing '0x00' to master tuner register '0x80ec08' causes slave tuner
* communication lost. Due to that, we cannot put master full sleep. */
but it will be much more elegant solution to use clock framework which allows implementing correct power management.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Akihiro TSUKADA
maintainerRe: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
In reply to Mauro Carvalho ChehabMoi!
Quoted 3 lines
Yes, using the I2C binding way provides a better decoupling than using the legacy way. The current
dvb_attach()macros are hacks that were created by the time where the I2C standard bind didn't work with DVB.
I understand. I converted my code to use i2c binding model, but I'm uncertain about a few things.
1. How to load the modules of i2c driver? Currently I use request_module()/module_put() like an example (ddbrige-core.c) from Antti does, but I'd prefer implicit module loading/ref-counting like in dvb_attach() if it exists.
2. Is there a standard way to pass around dvb_frontend*, i2c_client*, regmap* between bridge(dvb_adapter) and demod/tuner drivers? Currently I use config structure for the purpose, which is set to dev.platform_data (via i2c_board_info/i2c_new_device()) or dev.driver_data (via i2c_{get,set}_clientdata()),
but using config as both IN/OUT looks a bit hacky.
3. Should I also use RegMap API for register access?
I tried using it but gave up,
because it does not fit well to one of my use-case,
where (only) reads must be done via 0xfb register, like
READ(reg, buf, len) -> [addr/w, 0xfb, reg], [addr/r, buf[0]...], WRITE(reg, buf, len) -> [addr/w, reg, buf[0]...],
and regmap looked to me overkill for 8bit-reg, 8bit-val cases and did not simplify the code.
so I'd like to go without RegMap if possible,
since I'm already puzzled enough by I2C binding, regmap, clock source, as well as dvb-core, PCI ;)
regards,
Akihiro
Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
moikka!
Quoted 6 lines · Akihiro TSUKADA
Moi!
Quoted 3 lines
Yes, using the I2C binding way provides a better decoupling than using the legacy way. The current
dvb_attach()macros are hacks that were created by the time where the I2C standard bind didn't work with DVB.
Quoted 8 lines
I understand. I converted my code to use i2c binding model, but I'm uncertain about a few things.
1. How to load the modules of i2c driver? Currently I use request_module()/module_put() like an example (
ddbrige-core.c) from Antti does, but I'd prefer implicit module loading/ref-counting like indvb_attach()if it exists.
Maybe I haven't found the best way yet, but that was implementation I made for AF9035 driver:
https://patchwork.linuxtv.org/patch/25764/
Basically it is 2 functions, af9035_add_i2c_dev() and af9035_del_i2c_dev()
Quoted 6 lines
2. Is there a standard way to pass around dvb_frontend*, i2c_client*, regmap* between
bridge(dvb_adapter)and demod/tuner drivers? Currently I use config structure for the purpose, which is set to dev.platform_data (via i2c_board_info/i2c_new_device()) or dev.driver_data (via i2c_{get,set}_clientdata()),
but using config as both IN/OUT looks a bit hacky.
In my understanding, platform_data is place to pass environment specific config to driver. get/set client_data() is aimed to carry pointer for device specific instance "state" inside a driver. Is it possible to set I2C client data before calling i2c_new_device() and pass pointer to driver?
There is also IOCTL style command for I2C, but it is legacy and should not be used.
Documentation/i2c/busses/i2c-ocores
Yet, using config to OUT seems to be bit hacky for my eyes too. I though replacing all OUT with ops when converted af9033 driver. Currently caller fills struct af9033_ops and then af9033 I2C probe populates ops. See that patch:
https://patchwork.linuxtv.org/patch/25746/
Does this kind of ops sounds any better?
EXPORT_SYMBOL() is easiest way to offer outputs, like EXPORT_SYMBOL(get_frontend), EXPORT_SYMBOL(get_i2c_adapter). But we want avoid those exported symbols.
Quoted 11 lines
3. Should I also use RegMap API for register access? I tried using it but gave up,
because it does not fit well to one of my use-case, where (only) reads must be done via0xfbregister, likeREAD(reg, buf, len) -> [addr/w, 0xfb, reg], [addr/r, buf[0]...], WRITE(reg, buf, len) -> [addr/w, reg, buf[0]...],and regmap looked to me overkill for 8bit-reg, 8bit-val cases and did not simplify the code.
so I'd like to go without RegMap if possible,
since I'm already puzzled enough by I2C binding, regmap, clock source, as well as dvb-core, PCI ;)
I prefer RegMap API, but I am only one who has started using it yet. And I haven't converted any demod driver having I2C bus/gate/repeater for tuner to that API. It is because of I2C locking with I2C mux adapter, you need use unlocked version of i2c_transfer() for I2C mux as I2C bus lock is already taken. RegMap API does not support that, but I think it should be possible if you implement own xfer callback for regmap. For RF tuners RegMap API should be trivial and it will reduce ~100 LOC from driver.
But if you decide avoid RegMap API, I ask you add least implementing those I2C read / write function parameters similarly than RegMap API does. Defining all kind of weird register write / read functions makes life harder. I converted recently IT913x driver to RegMap API and biggest pain was there very different register read / write routines. So I need to do a lot of work in order convert functions first some common style and then it was trivial to change RegMap API.
https://patchwork.linuxtv.org/patch/25766/
https://patchwork.linuxtv.org/patch/25757/
I quickly overlooked that demod driver and one which looked crazy was LNA stuff. You implement set_lna callback in demod, but it is then passed back to PCI driver using frontend callback. Is there some reason you hooked it via demod? You could implement set_lna in PCI driver too.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Akihiro TSUKADA
maintainerRe: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
moikka!,
Quoted 1 line
Basically it is 2 functions,
af9035_add_i2c_dev()andaf9035_del_i2c_dev()
I used request_module()/try_module_get()/module_put() just like the above example (and bridge-core.c).
It works, but when I unload bridge driver(earth_pt3), its demod and tuner modules stay loaded, with the refcount of 0. Is it ok that the auto loaded modules remain with 0 ref count?
Quoted 7 lines
Yet, using config to OUT seems to be bit hacky for my eyes too. I though replacing all OUT with ops when converted af9033 driver. Currently caller fills struct
af9033_opsand then af9033 I2C probe populates ops. See that patch:
https://patchwork.linuxtv.org/patch/25746/Does this kind of ops sounds any better?
Do you mean using ops in struct config?
if so, I don't find much difference with the current situation where demod/tuner probe() sets dvb_frontend* to config->fe.
Quoted 4 lines
I quickly overlooked that demod driver and one which looked crazy was LNA stuff. You implement
set_lnacallback in demod, but it is then passed back to PCI driver using frontend callback. Is there some reason you hooked it via demod? You could implementset_lnain PCI driver too.
Stupidly I forgot that FE's ops can be set from the PCI driver. I will remove those callbacks and set the corresponding ops instead.
regards,
akihiro
Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
Quoted 9 lines · Akihiro TSUKADA
moikka!,
Quoted 1 line
Basically it is 2 functions,
af9035_add_i2c_dev()andaf9035_del_i2c_dev()I used request_module()/try_module_get()/module_put() just like the above example (and
bridge-core.c).
It works, but when I unload bridgedriver(earth_pt3), its demod and tuner modules stay loaded, with the refcount of 0. Is it ok that the auto loaded modules remain with 0 ref count?
So there is no other problem than those modules were left loaded? If you could unload those using rmmod it is OK then. Ref counting is here to prevent unloading demod and tuner driver while those are used by some other module. So when bridge is loaded, you should not be able to unload demod or tuner. But when bridge is unloaded, you should be able to unload demod and tuner.
And your question, I think there is no way to unload modules automatically or at least no need.
Quoted 11 lines
Quoted 7 lines
Yet, using config to OUT seems to be bit hacky for my eyes too. I though replacing all OUT with ops when converted af9033 driver. Currently caller fills struct
af9033_opsand then af9033 I2C probe populates ops. See that patch:
https://patchwork.linuxtv.org/patch/25746/Does this kind of ops sounds any better?
Do you mean using ops in struct config?
if so, I don't find much difference with the current situation where demod/tunerprobe()sets dvb_frontend* toconfig->fe.
Alloc driver specific ops in bridge driver, then put pointer to that ops to config struct. Driver fills ops during probe. Maybe that patch clears the idea:
af9033: Don't export functions for the hardware filter
https://patchwork.linuxtv.org/patch/23087/
Functionality is not much different than passing pointer to frontend pointer from bridge to I2C demod driver via platform_data...
Somehow you will need to transfer data during driver loading and there is not many alternatives:
* platform data pointer
* driver data pointer
* export function
* i2c_clients_command (legacy)
* device ID string (not very suitable)
* + the rest from i2c client, not related at all
regards
Antti
Signature · 1 line
http://palosaari.fi/
Re: [PATCH v2 4/5] tc90522: add driver for Toshiba TC90522 quad demodulator
In reply to Akihiro TSUKADAQuoted 11 lines · Akihiro TSUKADA
3. Should I also use RegMap API for register access? I tried using it but gave up,
because it does not fit well to one of my use-case, where (only) reads must be done via0xfbregister, likeREAD(reg, buf, len) -> [addr/w, 0xfb, reg], [addr/r, buf[0]...], WRITE(reg, buf, len) -> [addr/w, reg, buf[0]...],and regmap looked to me overkill for 8bit-reg, 8bit-val cases and did not simplify the code.
so I'd like to go without RegMap if possible,
since I'm already puzzled enough by I2C binding, regmap, clock source, as well as dvb-core, PCI ;)
That is MaxLinear MxL301RF tuner I2C. Problem is there that it uses write + STOP + write, so you should not even do that as a one I2C i2c_transfer. All I2C messages send using i2c_transfer are send so called REPEATED START condition.
I ran that same problem ears ago in a case of, surprise, MxL5007 tuner.
https://patchwork.linuxtv.org/patch/17847/
I think you could just write wanted register to command register 0xfb. And after that all the reads are coming from that active register until you change it.
RegMap API cannot handle I2C command format like that, it relies repeated start for reads.
Si2157 / Si2168 are using I2C access with STOP condition - but it is otherwise bad example as there is firmware API, not register API. Look still as a example.
regards
Antti
Signature · 1 line
http://palosaari.fi/
[email protected]
maintainerPATCH v2 5/5 pt3: add support for Earthsoft PT3 ISDB-S/T receiver card
In reply to [email protected]From: Akihiro Tsukada <[email protected]>
This patch adds support for PT3 PCIe cards.
PT3 has an FPGA PCIe bridge chip, a TC90522 demod chip and
a VA4M6JC2103 tuner module which contains two QM1D1C0042 chips for ISDB-S and two MxL301RF's for ISDB-T.
It can receive and deliver 4 (2x ISDB-S, 2x ISDB-T) streams simultaneously, and a kthread is used per stream to poll incoming data,
because PT3 does not have interrupts.
As an antenna input for each delivery system is split in the tuner module and shared between the corresponding two tuner chips,
LNB/LNA controls that the FPGA chip provides are (naturally) shared as well. The tuner chips also share the power line in the tuner module, which is controlled on/off by a GPIO pin of the demod chip.
As with the demod chip and the ISDB-T tuner chip,
the init sequences/register settings for those chips are not disclosed and stored in a private memory of the FPGA,
PT3 driver executes the init of those chips on behalf of their drivers.
---
Changes in v2:
- improved handling of kthread, including support of suspend/resume
- added support of suspend/resume
- improved init sequence to support live (streaming) suspend/resume
- moved static const tables out of function scop
drivers/media/pci/Kconfig | 1 + drivers/media/pci/Makefile | 1 + drivers/media/pci/pt3/Kconfig | 10 + drivers/media/pci/pt3/Makefile | 8 + drivers/media/pci/pt3/pt3.c | 817 ++++++++++++++++++++++++++++++++++++++++ drivers/media/pci/pt3/pt3.h | 179 +++++++++ drivers/media/pci/pt3/pt3_dma.c | 225 +++++++++++ drivers/media/pci/pt3/pt3_i2c.c | 239 ++++++++++++ 8 files changed, 1480 insertions(+)
drivers/media/pci/Kconfig +1 -0
@@ -41,6 +41,7 @@ source "drivers/media/pci/b2c2/Kconfig" source "drivers/media/pci/pluto2/Kconfig" source "drivers/media/pci/dm1105/Kconfig" source "drivers/media/pci/pt1/Kconfig" +source "drivers/media/pci/pt3/Kconfig" source "drivers/media/pci/mantis/Kconfig" source "drivers/media/pci/ngene/Kconfig" source "drivers/media/pci/ddbridge/Kconfig"
drivers/media/pci/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-y += ttpci/ \ pluto2/ \ dm1105/ \ pt1/ \ + pt3/ \ mantis/ \ ngene/ \ ddbridge/ \
drivers/media/pci/pt3/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +config DVB_PT3 + tristate "Earthsoft PT3 cards" + depends on DVB_CORE && PCI && I2C + select DVB_TC90522 if MEDIA_SUBDRV_AUTOSELECT + select MEDIA_TUNER_QM1D1C0042 if MEDIA_SUBDRV_AUTOSELECT + select MEDIA_TUNER_MXL301RF if MEDIA_SUBDRV_AUTOSELECT + help + Support for Earthsoft PT3 PCIe cards. + + Say Y or M if you own such a device and want to use it.
drivers/media/pci/pt3/Makefile new file +8 -0
@@ -0,0 +1,8 @@ + +earth-pt3-objs += pt3.o pt3_i2c.o pt3_dma.o + +obj-$(CONFIG_DVB_PT3) += earth-pt3.o + +ccflags-y += -Idrivers/media/dvb-core +ccflags-y += -Idrivers/media/dvb-frontends +ccflags-y += -Idrivers/media/tuners
drivers/media/pci/pt3/pt3.c new file +817 -0
817 lines not on this page · raw message
drivers/media/pci/pt3/pt3.h new file +179 -0
179 lines not on this page · raw message
drivers/media/pci/pt3/pt3_dma.c new file +225 -0
225 lines not on this page · raw message
drivers/media/pci/pt3/pt3_i2c.c new file +239 -0
239 lines not on this page · raw message
Signature · 1 line
2.1.0