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
34 #include "ddbridge-regs.h"
35 #include "ddbridge-io.h"
36 #include "ddbridge-mci.h"
38 #include "ddbridge-max.h"
48 static int fmode_sat = -1;
62 v = LNB_TONE & (dev->link[link].lnb.tone << (15 - lnb)); in lnb_command()
71 dev_info(dev->dev, "%s lnb = %08x cmd = %08x\n", in lnb_command()
79 struct ddb_input *input = fe->sec_priv; in max_send_master_cmd()
80 struct ddb_port *port = input->port; in max_send_master_cmd() local
81 struct ddb *dev = port->dev; in max_send_master_cmd()
82 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_send_master_cmd()
83 u32 tag = DDB_LINK_TAG(port->lnr); in max_send_master_cmd()
85 u32 fmode = dev->link[port->lnr].lnb.fmode; in max_send_master_cmd()
89 if (dvb->diseqc_send_master_cmd) in max_send_master_cmd()
90 dvb->diseqc_send_master_cmd(fe, cmd); in max_send_master_cmd()
92 mutex_lock(&dev->link[port->lnr].lnb.lock); in max_send_master_cmd()
93 ddbwritel(dev, 0, tag | LNB_BUF_LEVEL(dvb->input)); in max_send_master_cmd()
94 for (i = 0; i < cmd->msg_len; i++) in max_send_master_cmd()
95 ddbwritel(dev, cmd->msg[i], tag | LNB_BUF_WRITE(dvb->input)); in max_send_master_cmd()
96 lnb_command(dev, port->lnr, dvb->input, LNB_CMD_DISEQC); in max_send_master_cmd()
97 mutex_unlock(&dev->link[port->lnr].lnb.lock); in max_send_master_cmd()
108 for (i = 0; i < cmd->msg_len; i++) in lnb_send_diseqc()
109 ddbwritel(dev, cmd->msg[i], tag | LNB_BUF_WRITE(input)); in lnb_send_diseqc()
121 cmd.msg[3] = 0xf0 | (((sat << 2) & 0x0c) | (band ? 1 : 0) | in lnb_set_sat()
134 if (!(dev->link[link].lnb.tone & mask)) in lnb_set_tone()
136 dev->link[link].lnb.tone &= ~(1ULL << input); in lnb_set_tone()
139 if (dev->link[link].lnb.tone & mask) in lnb_set_tone()
141 dev->link[link].lnb.tone |= (1ULL << input); in lnb_set_tone()
144 s = -EINVAL; in lnb_set_tone()
157 if (dev->link[link].lnb.oldvoltage[input] == voltage) in lnb_set_voltage()
161 if (dev->link[link].lnb.voltage[input]) in lnb_set_voltage()
172 s = -EINVAL; in lnb_set_voltage()
175 dev->link[link].lnb.oldvoltage[input] = voltage; in lnb_set_voltage()
181 struct ddb_input *input = fe->sec_priv; in max_set_input_unlocked()
182 struct ddb_port *port = input->port; in max_set_input_unlocked() local
183 struct ddb *dev = port->dev; in max_set_input_unlocked()
184 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_set_input_unlocked()
187 if (in > 3) in max_set_input_unlocked()
188 return -EINVAL; in max_set_input_unlocked()
189 if (dvb->input != in) { in max_set_input_unlocked()
190 u32 bit = (1ULL << input->nr); in max_set_input_unlocked()
192 dev->link[port->lnr].lnb.voltage[dvb->input & 3] & bit; in max_set_input_unlocked()
194 dev->link[port->lnr].lnb.voltage[dvb->input & 3] &= ~bit; in max_set_input_unlocked()
195 dvb->input = in; in max_set_input_unlocked()
196 dev->link[port->lnr].lnb.voltage[dvb->input & 3] |= obit; in max_set_input_unlocked()
198 res = dvb->set_input(fe, in); in max_set_input_unlocked()
204 struct ddb_input *input = fe->sec_priv; in max_set_tone()
205 struct ddb_port *port = input->port; in max_set_tone() local
206 struct ddb *dev = port->dev; in max_set_tone()
207 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_set_tone()
210 u32 fmode = dev->link[port->lnr].lnb.fmode; in max_set_tone()
212 mutex_lock(&dev->link[port->lnr].lnb.lock); in max_set_tone()
213 dvb->tone = tone; in max_set_tone()
217 case 3: in max_set_tone()
218 res = lnb_set_tone(dev, port->lnr, dvb->input, tone); in max_set_tone()
223 if (dvb->tone == SEC_TONE_ON) in max_set_tone()
225 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_tone()
228 if (dvb->tone == SEC_TONE_ON) in max_set_tone()
230 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_tone()
236 mutex_unlock(&dev->link[port->lnr].lnb.lock); in max_set_tone()
242 struct ddb_input *input = fe->sec_priv; in max_set_voltage()
243 struct ddb_port *port = input->port; in max_set_voltage() local
244 struct ddb *dev = port->dev; in max_set_voltage()
245 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in max_set_voltage()
247 u32 nv, ov = dev->link[port->lnr].lnb.voltages; in max_set_voltage()
249 u32 fmode = dev->link[port->lnr].lnb.fmode; in max_set_voltage()
251 mutex_lock(&dev->link[port->lnr].lnb.lock); in max_set_voltage()
252 dvb->voltage = voltage; in max_set_voltage()
255 case 3: in max_set_voltage()
258 if (fmode == 3) in max_set_voltage()
261 dev->link[port->lnr].lnb.voltage[dvb->input] &= in max_set_voltage()
262 ~(1ULL << input->nr); in max_set_voltage()
264 dev->link[port->lnr].lnb.voltage[dvb->input] |= in max_set_voltage()
265 (1ULL << input->nr); in max_set_voltage()
267 res = lnb_set_voltage(dev, port->lnr, dvb->input, voltage); in max_set_voltage()
272 dev->link[port->lnr].lnb.voltages &= in max_set_voltage()
273 ~(1ULL << input->nr); in max_set_voltage()
275 dev->link[port->lnr].lnb.voltages |= in max_set_voltage()
276 (1ULL << input->nr); in max_set_voltage()
278 nv = dev->link[port->lnr].lnb.voltages; in max_set_voltage()
281 if (dvb->tone == SEC_TONE_ON) in max_set_voltage()
283 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_voltage()
286 if (dvb->tone == SEC_TONE_ON) in max_set_voltage()
288 if (dvb->voltage == SEC_VOLTAGE_18) in max_set_voltage()
296 dev, port->lnr, in max_set_voltage()
300 dev, port->lnr, in max_set_voltage()
304 dev, port->lnr, in max_set_voltage()
307 dev, port->lnr, in max_set_voltage()
311 dev, port->lnr, in max_set_voltage()
314 dev, port->lnr, in max_set_voltage()
318 dev, port->lnr, in max_set_voltage()
319 3, SEC_VOLTAGE_18); in max_set_voltage()
323 dev, port->lnr, in max_set_voltage()
327 dev, port->lnr, in max_set_voltage()
330 dev, port->lnr, in max_set_voltage()
333 dev, port->lnr, in max_set_voltage()
334 3, SEC_VOLTAGE_OFF); in max_set_voltage()
340 mutex_unlock(&dev->link[port->lnr].lnb.lock); in max_set_voltage()
357 struct ddb *dev = link->dev; in mxl_fw_read()
359 dev_info(dev->dev, "Read mxl_fw from link %u\n", link->nr); in mxl_fw_read()
361 return ddbridge_flashread(dev, link->nr, buf, 0xc0000, len); in mxl_fw_read()
366 u32 l = link->nr; in ddb_lnb_init_fmode()
368 if (link->lnb.fmode == fm) in ddb_lnb_init_fmode()
370 dev_info(dev->dev, "Set fmode link %u = %u\n", l, fm); in ddb_lnb_init_fmode()
371 mutex_lock(&link->lnb.lock); in ddb_lnb_init_fmode()
382 lnb_set_sat(dev, l, 3, fmode_sat, 1, 1); in ddb_lnb_init_fmode()
392 lnb_set_tone(dev, l, 3, SEC_TONE_ON); in ddb_lnb_init_fmode()
394 link->lnb.fmode = fm; in ddb_lnb_init_fmode()
395 mutex_unlock(&link->lnb.lock); in ddb_lnb_init_fmode()
410 struct ddb *dev = input->port->dev; in ddb_fe_attach_mxl5xx()
411 struct i2c_adapter *i2c = &input->port->i2c->adap; in ddb_fe_attach_mxl5xx()
412 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in ddb_fe_attach_mxl5xx()
413 struct ddb_port *port = input->port; in ddb_fe_attach_mxl5xx() local
414 struct ddb_link *link = &dev->link[port->lnr]; in ddb_fe_attach_mxl5xx()
420 dvb->set_input = NULL; in ddb_fe_attach_mxl5xx()
422 demod = input->nr; in ddb_fe_attach_mxl5xx()
423 tuner = demod & 3; in ddb_fe_attach_mxl5xx()
424 if (fmode == 3) in ddb_fe_attach_mxl5xx()
427 dvb->fe = dvb_attach(mxl5xx_attach, i2c, &cfg, in ddb_fe_attach_mxl5xx()
428 demod, tuner, &dvb->set_input); in ddb_fe_attach_mxl5xx()
430 if (!dvb->fe) { in ddb_fe_attach_mxl5xx()
431 dev_err(dev->dev, "No MXL5XX found!\n"); in ddb_fe_attach_mxl5xx()
432 return -ENODEV; in ddb_fe_attach_mxl5xx()
435 if (!dvb->set_input) { in ddb_fe_attach_mxl5xx()
436 dev_err(dev->dev, "No mxl5xx_set_input function pointer!\n"); in ddb_fe_attach_mxl5xx()
437 return -ENODEV; in ddb_fe_attach_mxl5xx()
440 if (input->nr < 4) { in ddb_fe_attach_mxl5xx()
441 lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT); in ddb_fe_attach_mxl5xx()
442 lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF); in ddb_fe_attach_mxl5xx()
446 dvb->fe->ops.set_voltage = max_set_voltage; in ddb_fe_attach_mxl5xx()
447 dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage; in ddb_fe_attach_mxl5xx()
448 dvb->fe->ops.set_tone = max_set_tone; in ddb_fe_attach_mxl5xx()
449 dvb->diseqc_send_master_cmd = dvb->fe->ops.diseqc_send_master_cmd; in ddb_fe_attach_mxl5xx()
450 dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd; in ddb_fe_attach_mxl5xx()
451 dvb->fe->ops.diseqc_send_burst = max_send_burst; in ddb_fe_attach_mxl5xx()
452 dvb->fe->sec_priv = input; in ddb_fe_attach_mxl5xx()
453 dvb->input = tuner; in ddb_fe_attach_mxl5xx()
462 struct ddb *dev = input->port->dev; in ddb_fe_attach_mci()
463 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in ddb_fe_attach_mci()
464 struct ddb_port *port = input->port; in ddb_fe_attach_mci() local
465 struct ddb_link *link = &dev->link[port->lnr]; in ddb_fe_attach_mci()
469 demod = input->nr; in ddb_fe_attach_mci()
470 tuner = demod & 3; in ddb_fe_attach_mci()
474 if (fmode == 3) in ddb_fe_attach_mci()
478 return -EINVAL; in ddb_fe_attach_mci()
480 dvb->fe = ddb_mci_attach(input, &cfg, demod, &dvb->set_input); in ddb_fe_attach_mci()
481 if (!dvb->fe) { in ddb_fe_attach_mci()
482 dev_err(dev->dev, "No MCI card found!\n"); in ddb_fe_attach_mci()
483 return -ENODEV; in ddb_fe_attach_mci()
485 if (!dvb->set_input) { in ddb_fe_attach_mci()
486 dev_err(dev->dev, "No MCI set_input function pointer!\n"); in ddb_fe_attach_mci()
487 return -ENODEV; in ddb_fe_attach_mci()
489 if (input->nr < 4) { in ddb_fe_attach_mci()
490 lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT); in ddb_fe_attach_mci()
491 lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF); in ddb_fe_attach_mci()
495 dvb->fe->ops.set_voltage = max_set_voltage; in ddb_fe_attach_mci()
496 dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage; in ddb_fe_attach_mci()
497 dvb->fe->ops.set_tone = max_set_tone; in ddb_fe_attach_mci()
498 dvb->diseqc_send_master_cmd = dvb->fe->ops.diseqc_send_master_cmd; in ddb_fe_attach_mci()
499 dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd; in ddb_fe_attach_mci()
500 dvb->fe->ops.diseqc_send_burst = max_send_burst; in ddb_fe_attach_mci()
501 dvb->fe->sec_priv = input; in ddb_fe_attach_mci()
502 dvb->input = tuner; in ddb_fe_attach_mci()