Lines Matching +full:3 +full:- +full:port
1 // SPDX-License-Identifier: GPL-2.0
3 * ddbridge-max.c: Digital Devices bridge MAX card support
5 * Copyright (C) 2010-2017 Digital Devices GmbH
25 #include "ddbridge-regs.h"
26 #include "ddbridge-io.h"
27 #include "ddbridge-mci.h"
29 #include "ddbridge-max.h"
39 static int fmode_sat = -1;
53 v = LNB_TONE & (dev->link[link].lnb.tone << (15 - lnb)); in lnb_command()
62 dev_info(dev->dev, "%s lnb = %08x cmd = %08x\n", in lnb_command()
70 struct ddb_input *input = fe->sec_priv; in max_send_master_cmd()
71 struct ddb_port *port = input->port; in max_send_master_cmd() local
72 struct ddb *dev = port->dev; in max_send_master_cmd()
73 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_send_master_cmd()
74 u32 tag = DDB_LINK_TAG(port->lnr); in max_send_master_cmd()
76 u32 fmode = dev->link[port->lnr].lnb.fmode; in max_send_master_cmd()
80 if (dvb->diseqc_send_master_cmd) in max_send_master_cmd()
81 dvb->diseqc_send_master_cmd(fe, cmd); in max_send_master_cmd()
83 mutex_lock(&dev->link[port->lnr].lnb.lock); in max_send_master_cmd()
84 ddbwritel(dev, 0, tag | LNB_BUF_LEVEL(dvb->input)); in max_send_master_cmd()
85 for (i = 0; i < cmd->msg_len; i++) in max_send_master_cmd()
86 ddbwritel(dev, cmd->msg[i], tag | LNB_BUF_WRITE(dvb->input)); in max_send_master_cmd()
87 lnb_command(dev, port->lnr, dvb->input, LNB_CMD_DISEQC); in max_send_master_cmd()
88 mutex_unlock(&dev->link[port->lnr].lnb.lock); in max_send_master_cmd()
99 for (i = 0; i < cmd->msg_len; i++) in lnb_send_diseqc()
100 ddbwritel(dev, cmd->msg[i], tag | LNB_BUF_WRITE(input)); in lnb_send_diseqc()
112 cmd.msg[3] = 0xf0 | (((sat << 2) & 0x0c) | (band ? 1 : 0) | in lnb_set_sat()
125 if (!(dev->link[link].lnb.tone & mask)) in lnb_set_tone()
127 dev->link[link].lnb.tone &= ~(1ULL << input); in lnb_set_tone()
130 if (dev->link[link].lnb.tone & mask) in lnb_set_tone()
132 dev->link[link].lnb.tone |= (1ULL << input); in lnb_set_tone()
135 s = -EINVAL; in lnb_set_tone()
148 if (dev->link[link].lnb.oldvoltage[input] == voltage) in lnb_set_voltage()
152 if (dev->link[link].lnb.voltage[input]) in lnb_set_voltage()
163 s = -EINVAL; in lnb_set_voltage()
166 dev->link[link].lnb.oldvoltage[input] = voltage; in lnb_set_voltage()
172 struct ddb_input *input = fe->sec_priv; in max_set_input_unlocked()
173 struct ddb_port *port = input->port; in max_set_input_unlocked() local
174 struct ddb *dev = port->dev; in max_set_input_unlocked()
175 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_set_input_unlocked()
178 if (in > 3) in max_set_input_unlocked()
179 return -EINVAL; in max_set_input_unlocked()
180 if (dvb->input != in) { in max_set_input_unlocked()
181 u32 bit = (1ULL << input->nr); in max_set_input_unlocked()
183 dev->link[port->lnr].lnb.voltage[dvb->input & 3] & bit; in max_set_input_unlocked()
185 dev->link[port->lnr].lnb.voltage[dvb->input & 3] &= ~bit; in max_set_input_unlocked()
186 dvb->input = in; in max_set_input_unlocked()
187 dev->link[port->lnr].lnb.voltage[dvb->input & 3] |= obit; in max_set_input_unlocked()
189 res = dvb->set_input(fe, in); in max_set_input_unlocked()
195 struct ddb_input *input = fe->sec_priv; in max_set_tone()
196 struct ddb_port *port = input->port; in max_set_tone() local
197 struct ddb *dev = port->dev; in max_set_tone()
198 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_set_tone()
201 u32 fmode = dev->link[port->lnr].lnb.fmode; in max_set_tone()
203 mutex_lock(&dev->link[port->lnr].lnb.lock); in max_set_tone()
204 dvb->tone = tone; in max_set_tone()
208 case 3: in max_set_tone()
209 res = lnb_set_tone(dev, port->lnr, dvb->input, tone); in max_set_tone()
214 if (dvb->tone == SEC_TONE_ON) in max_set_tone()
216 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_tone()
219 if (dvb->tone == SEC_TONE_ON) in max_set_tone()
221 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_tone()
227 mutex_unlock(&dev->link[port->lnr].lnb.lock); in max_set_tone()
233 struct ddb_input *input = fe->sec_priv; in max_set_voltage()
234 struct ddb_port *port = input->port; in max_set_voltage() local
235 struct ddb *dev = port->dev; in max_set_voltage()
236 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_set_voltage()
238 u32 nv, ov = dev->link[port->lnr].lnb.voltages; in max_set_voltage()
240 u32 fmode = dev->link[port->lnr].lnb.fmode; in max_set_voltage()
242 mutex_lock(&dev->link[port->lnr].lnb.lock); in max_set_voltage()
243 dvb->voltage = voltage; in max_set_voltage()
246 case 3: in max_set_voltage()
249 if (fmode == 3) in max_set_voltage()
252 dev->link[port->lnr].lnb.voltage[dvb->input] &= in max_set_voltage()
253 ~(1ULL << input->nr); in max_set_voltage()
255 dev->link[port->lnr].lnb.voltage[dvb->input] |= in max_set_voltage()
256 (1ULL << input->nr); in max_set_voltage()
258 res = lnb_set_voltage(dev, port->lnr, dvb->input, voltage); in max_set_voltage()
263 dev->link[port->lnr].lnb.voltages &= in max_set_voltage()
264 ~(1ULL << input->nr); in max_set_voltage()
266 dev->link[port->lnr].lnb.voltages |= in max_set_voltage()
267 (1ULL << input->nr); in max_set_voltage()
269 nv = dev->link[port->lnr].lnb.voltages; in max_set_voltage()
272 if (dvb->tone == SEC_TONE_ON) in max_set_voltage()
274 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_voltage()
277 if (dvb->tone == SEC_TONE_ON) in max_set_voltage()
279 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_voltage()
287 dev, port->lnr, in max_set_voltage()
291 dev, port->lnr, in max_set_voltage()
295 dev, port->lnr, in max_set_voltage()
298 dev, port->lnr, in max_set_voltage()
302 dev, port->lnr, in max_set_voltage()
305 dev, port->lnr, in max_set_voltage()
309 dev, port->lnr, in max_set_voltage()
310 3, SEC_VOLTAGE_18); in max_set_voltage()
314 dev, port->lnr, in max_set_voltage()
318 dev, port->lnr, in max_set_voltage()
321 dev, port->lnr, in max_set_voltage()
324 dev, port->lnr, in max_set_voltage()
325 3, SEC_VOLTAGE_OFF); in max_set_voltage()
331 mutex_unlock(&dev->link[port->lnr].lnb.lock); in max_set_voltage()
348 struct ddb *dev = link->dev; in mxl_fw_read()
350 dev_info(dev->dev, "Read mxl_fw from link %u\n", link->nr); in mxl_fw_read()
352 return ddbridge_flashread(dev, link->nr, buf, 0xc0000, len); in mxl_fw_read()
357 u32 l = link->nr; in ddb_lnb_init_fmode()
359 if (link->lnb.fmode == fm) in ddb_lnb_init_fmode()
361 dev_info(dev->dev, "Set fmode link %u = %u\n", l, fm); in ddb_lnb_init_fmode()
362 mutex_lock(&link->lnb.lock); in ddb_lnb_init_fmode()
373 lnb_set_sat(dev, l, 3, fmode_sat, 1, 1); in ddb_lnb_init_fmode()
383 lnb_set_tone(dev, l, 3, SEC_TONE_ON); in ddb_lnb_init_fmode()
385 link->lnb.fmode = fm; in ddb_lnb_init_fmode()
386 mutex_unlock(&link->lnb.lock); in ddb_lnb_init_fmode()
401 struct ddb *dev = input->port->dev; in ddb_fe_attach_mxl5xx()
402 struct i2c_adapter *i2c = &input->port->i2c->adap; in ddb_fe_attach_mxl5xx()
403 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in ddb_fe_attach_mxl5xx()
404 struct ddb_port *port = input->port; in ddb_fe_attach_mxl5xx() local
405 struct ddb_link *link = &dev->link[port->lnr]; in ddb_fe_attach_mxl5xx()
411 dvb->set_input = NULL; in ddb_fe_attach_mxl5xx()
413 demod = input->nr; in ddb_fe_attach_mxl5xx()
414 tuner = demod & 3; in ddb_fe_attach_mxl5xx()
415 if (fmode == 3) in ddb_fe_attach_mxl5xx()
418 dvb->fe = dvb_attach(mxl5xx_attach, i2c, &cfg, in ddb_fe_attach_mxl5xx()
419 demod, tuner, &dvb->set_input); in ddb_fe_attach_mxl5xx()
421 if (!dvb->fe) { in ddb_fe_attach_mxl5xx()
422 dev_err(dev->dev, "No MXL5XX found!\n"); in ddb_fe_attach_mxl5xx()
423 return -ENODEV; in ddb_fe_attach_mxl5xx()
426 if (!dvb->set_input) { in ddb_fe_attach_mxl5xx()
427 dev_err(dev->dev, "No mxl5xx_set_input function pointer!\n"); in ddb_fe_attach_mxl5xx()
428 return -ENODEV; in ddb_fe_attach_mxl5xx()
431 if (input->nr < 4) { in ddb_fe_attach_mxl5xx()
432 lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT); in ddb_fe_attach_mxl5xx()
433 lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF); in ddb_fe_attach_mxl5xx()
437 dvb->fe->ops.set_voltage = max_set_voltage; in ddb_fe_attach_mxl5xx()
438 dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage; in ddb_fe_attach_mxl5xx()
439 dvb->fe->ops.set_tone = max_set_tone; in ddb_fe_attach_mxl5xx()
440 dvb->diseqc_send_master_cmd = dvb->fe->ops.diseqc_send_master_cmd; in ddb_fe_attach_mxl5xx()
441 dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd; in ddb_fe_attach_mxl5xx()
442 dvb->fe->ops.diseqc_send_burst = max_send_burst; in ddb_fe_attach_mxl5xx()
443 dvb->fe->sec_priv = input; in ddb_fe_attach_mxl5xx()
444 dvb->input = tuner; in ddb_fe_attach_mxl5xx()
453 struct ddb *dev = input->port->dev; in ddb_fe_attach_mci()
454 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in ddb_fe_attach_mci()
455 struct ddb_port *port = input->port; in ddb_fe_attach_mci() local
456 struct ddb_link *link = &dev->link[port->lnr]; in ddb_fe_attach_mci()
460 demod = input->nr; in ddb_fe_attach_mci()
461 tuner = demod & 3; in ddb_fe_attach_mci()
465 if (fmode == 3) in ddb_fe_attach_mci()
469 return -EINVAL; in ddb_fe_attach_mci()
471 dvb->fe = ddb_mci_attach(input, &cfg, demod, &dvb->set_input); in ddb_fe_attach_mci()
472 if (!dvb->fe) { in ddb_fe_attach_mci()
473 dev_err(dev->dev, "No MCI card found!\n"); in ddb_fe_attach_mci()
474 return -ENODEV; in ddb_fe_attach_mci()
476 if (!dvb->set_input) { in ddb_fe_attach_mci()
477 dev_err(dev->dev, "No MCI set_input function pointer!\n"); in ddb_fe_attach_mci()
478 return -ENODEV; in ddb_fe_attach_mci()
480 if (input->nr < 4) { in ddb_fe_attach_mci()
481 lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT); in ddb_fe_attach_mci()
482 lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF); in ddb_fe_attach_mci()
486 dvb->fe->ops.set_voltage = max_set_voltage; in ddb_fe_attach_mci()
487 dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage; in ddb_fe_attach_mci()
488 dvb->fe->ops.set_tone = max_set_tone; in ddb_fe_attach_mci()
489 dvb->diseqc_send_master_cmd = dvb->fe->ops.diseqc_send_master_cmd; in ddb_fe_attach_mci()
490 dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd; in ddb_fe_attach_mci()
491 dvb->fe->ops.diseqc_send_burst = max_send_burst; in ddb_fe_attach_mci()
492 dvb->fe->sec_priv = input; in ddb_fe_attach_mci()
493 dvb->input = tuner; in ddb_fe_attach_mci()