--- drivers/media/dvb-frontends/mxl58x.c.orig 2019-11-14 00:29:52.807837237 +1300 +++ drivers/media/dvb-frontends/mxl58x.c 2019-11-14 00:54:23.754013840 +1300 @@ -63,6 +63,11 @@ module_param(rfsource, int, 0644); MODULE_PARM_DESC(rfsource, "RF source selection for direct connection mode (default:0 - auto)"); +#define MAX_INPUTS 4 +static short inputs[MAX_INPUTS] = {0, 1, 2, 3}; +module_param_array(inputs, short, NULL, 0444); +MODULE_PARM_DESC(inputs, "Input number (0-3) for each of the 4 tuner pairs. Default is 0,1,2,3. Only used if mode=1."); + LIST_HEAD(mxllist); struct mxl_base { @@ -1473,20 +1478,35 @@ state->rf_in = 0; if(mode) { - if((demod==0)||(demod==1)) - state->rf_in = 3; - if((demod==2)||(demod==3)) - state->rf_in = 2; - if((demod ==4)||(demod ==5)) - state->rf_in = 1; - if((demod ==6)||(demod ==7)) - state->rf_in = 0; - - if (rfsource > 0 && rfsource < 5) - state->rf_in = 4 - rfsource; - + { + /* Protect against invalid inputs[] values. */ + short inputs_index; + for (inputs_index = 0; inputs_index < MAX_INPUTS; ++inputs_index) { + if (inputs[inputs_index] < 0 || inputs[inputs_index] >= MAX_INPUTS) { + pr_err( + "mxl5xx: Invalid inputs[%d] option value (%d), set to %d\n", + inputs_index, + inputs[inputs_index], + inputs_index + ); + inputs[inputs_index] = inputs_index; + } + } + } + pr_info("mxl5xx: mode=1, inputs=%d,%d,%d,%d", inputs[0], inputs[1], inputs[2], inputs[3]); + if ((demod == 0) || (demod == 1)) { + state->rf_in = (MAX_INPUTS-1) - inputs[3]; + } else if ((demod == 2) || (demod == 3)) { + state->rf_in = (MAX_INPUTS-1) - inputs[2]; + } else if ((demod == 4)||(demod == 5)) { + state->rf_in = (MAX_INPUTS-1) - inputs[1]; + } else if ((demod == 6)||(demod == 7)) { + state->rf_in = (MAX_INPUTS-1) - inputs[0]; + } if (mode==2) state->rf_in = 0; + } else { + pr_info("mxl5xx: mode=%d", mode); } state->fe.ops = mxl_ops; state->fe.demodulator_priv = state;