diff mbox

[04/10] rtl28xxu: swap frontend order for slave demods

Message ID 1426460275-3766-4-git-send-email-benjamin@southpole.se (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Larsson March 15, 2015, 10:57 p.m. UTC
Some devices have 2 demodulators, when this is the case
make the slave demod be listed first. Enumerating the slave
first will help legacy applications to use the hardware.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Benjamin Larsson March 16, 2015, 8:44 p.m. UTC | #1
On 03/15/2015 11:57 PM, Benjamin Larsson wrote:
> Some devices have 2 demodulators, when this is the case
> make the slave demod be listed first. Enumerating the slave
> first will help legacy applications to use the hardware.
>

Ignore this patch for now. Stuff gets broken if applied.

/Benjamin

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Antti Palosaari March 16, 2015, 9:04 p.m. UTC | #2
On 03/16/2015 10:44 PM, Benjamin Larsson wrote:
> On 03/15/2015 11:57 PM, Benjamin Larsson wrote:
>> Some devices have 2 demodulators, when this is the case
>> make the slave demod be listed first. Enumerating the slave
>> first will help legacy applications to use the hardware.
>>
>
> Ignore this patch for now. Stuff gets broken if applied.

I will not apply it even you fix it. I don't like idea adding such hack 
to kernel in order to workaround buggy applications. There is many older 
devices having similar situation, having 2 demods - one for DVB-T and 
one for DVB-C. So there has been surely enough time for app developers 
to add support for multiple frontends... laziness.

Quite same happened for DVB-T2 support. I added initially hack for 
CXD2820R driver in order to support DVB-T2 even applications are not 
supporting it. That was implemented using trick driver did DVB-T2 tune 
when DVB-T tune fails. After many years I did another DVB-T2 driver 
Si2168 and didn't add such hack anymore. And what was result; almost all 
applications were still lacking proper DVB-T2 support, after many many 
years...

So I will never ever add any hacks to driver to workaround application 
support as application developers are so lazy to add support or new 
things if there is some workaround available.

regards
Antti
Benjamin Larsson March 16, 2015, 9:22 p.m. UTC | #3
On 03/16/2015 10:04 PM, Antti Palosaari wrote:
> On 03/16/2015 10:44 PM, Benjamin Larsson wrote:
>> On 03/15/2015 11:57 PM, Benjamin Larsson wrote:
>>> Some devices have 2 demodulators, when this is the case
>>> make the slave demod be listed first. Enumerating the slave
>>> first will help legacy applications to use the hardware.
>>>
>>
>> Ignore this patch for now. Stuff gets broken if applied.
>
> I will not apply it even you fix it. I don't like idea adding such hack
> to kernel in order to workaround buggy applications. There is many older
> devices having similar situation, having 2 demods - one for DVB-T and
> one for DVB-C. So there has been surely enough time for app developers
> to add support for multiple frontends... laziness.
>
> Quite same happened for DVB-T2 support. I added initially hack for
> CXD2820R driver in order to support DVB-T2 even applications are not
> supporting it. That was implemented using trick driver did DVB-T2 tune
> when DVB-T tune fails. After many years I did another DVB-T2 driver
> Si2168 and didn't add such hack anymore. And what was result; almost all
> applications were still lacking proper DVB-T2 support, after many many
> years...
>
> So I will never ever add any hacks to driver to workaround application
> support as application developers are so lazy to add support or new
> things if there is some workaround available.
>
> regards
> Antti
>

While I agree with your reasoning, the point with this patch is just to 
register one demod before another. If that is a hack or not I don't 
know. I have used it locally for test purposes and it is not needed for 
actual use so consider the patch withdrawn.

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

Patch

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index ea75b3a..bb5003d 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -853,6 +853,7 @@  static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 
 	if (dev->slave_demod) {
 		struct i2c_board_info info = {};
+		struct dvb_frontend *tmp_fe;
 
 		/*
 		 * We continue on reduced mode, without DVB-T2/C, using master
@@ -907,6 +908,11 @@  static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 
 			dev->i2c_client_slave_demod = client;
 		}
+
+		/* Swap frontend order */
+		tmp_fe = adap->fe[0];
+		adap->fe[0] = adap->fe[1];
+		adap->fe[1] = tmp_fe;
 	}
 
 	return 0;
@@ -1134,12 +1140,6 @@  static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 				adap->fe[0]->ops.tuner_ops.get_rf_strength;
 		break;
 	case TUNER_RTL2832_R828D:
-		fe = dvb_attach(r820t_attach, adap->fe[0],
-				dev->demod_i2c_adapter,
-				&rtl2832u_r828d_config);
-		adap->fe[0]->ops.read_signal_strength =
-				adap->fe[0]->ops.tuner_ops.get_rf_strength;
-
 		if (adap->fe[1]) {
 			fe = dvb_attach(r820t_attach, adap->fe[1],
 					dev->demod_i2c_adapter,
@@ -1147,6 +1147,12 @@  static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 			adap->fe[1]->ops.read_signal_strength =
 					adap->fe[1]->ops.tuner_ops.get_rf_strength;
 		}
+
+		fe = dvb_attach(r820t_attach, adap->fe[0],
+			dev->demod_i2c_adapter,
+			&rtl2832u_r828d_config);
+		adap->fe[0]->ops.read_signal_strength =
+			adap->fe[0]->ops.tuner_ops.get_rf_strength;
 		break;
 	default:
 		dev_err(&d->intf->dev, "unknown tuner %d\n", dev->tuner);