Lines Matching refs:pt3

112 static inline void pt3_lnb_ctrl(struct pt3_board *pt3, bool on)  in pt3_lnb_ctrl()  argument
114 iowrite32((on ? 0x0f : 0x0c), pt3->regs[0] + REG_SYSTEM_W); in pt3_lnb_ctrl()
119 struct pt3_board *pt3; in pt3_find_adapter() local
123 pt3 = fe->dvb->priv; in pt3_find_adapter()
125 if (pt3->adaps[i]->fe == fe) in pt3_find_adapter()
126 return pt3->adaps[i]; in pt3_find_adapter()
137 pt3_set_tuner_power(struct pt3_board *pt3, bool tuner_on, bool amp_on) in pt3_set_tuner_power() argument
145 return pt3_demod_write(pt3->adaps[PT3_NUM_FE - 1], &rv, 1); in pt3_set_tuner_power()
151 struct pt3_board *pt3; in pt3_set_lna() local
162 pt3 = adap->dvb_adap.priv; in pt3_set_lna()
163 if (mutex_lock_interruptible(&pt3->lock)) in pt3_set_lna()
166 pt3->lna_on_cnt++; in pt3_set_lna()
168 pt3->lna_on_cnt--; in pt3_set_lna()
170 if (val && pt3->lna_on_cnt <= 1) { in pt3_set_lna()
171 pt3->lna_on_cnt = 1; in pt3_set_lna()
172 ret = pt3_set_tuner_power(pt3, true, true); in pt3_set_lna()
173 } else if (!val && pt3->lna_on_cnt <= 0) { in pt3_set_lna()
174 pt3->lna_on_cnt = 0; in pt3_set_lna()
175 ret = pt3_set_tuner_power(pt3, true, false); in pt3_set_lna()
178 mutex_unlock(&pt3->lock); in pt3_set_lna()
186 struct pt3_board *pt3; in pt3_set_voltage() local
196 pt3 = adap->dvb_adap.priv; in pt3_set_voltage()
197 if (mutex_lock_interruptible(&pt3->lock)) in pt3_set_voltage()
200 pt3->lnb_on_cnt++; in pt3_set_voltage()
202 pt3->lnb_on_cnt--; in pt3_set_voltage()
204 if (on && pt3->lnb_on_cnt <= 1) { in pt3_set_voltage()
205 pt3->lnb_on_cnt = 1; in pt3_set_voltage()
206 pt3_lnb_ctrl(pt3, true); in pt3_set_voltage()
207 } else if (!on && pt3->lnb_on_cnt <= 0) { in pt3_set_voltage()
208 pt3->lnb_on_cnt = 0; in pt3_set_voltage()
209 pt3_lnb_ctrl(pt3, false); in pt3_set_voltage()
211 mutex_unlock(&pt3->lock); in pt3_set_voltage()
242 static int pt3_fe_init(struct pt3_board *pt3) in pt3_fe_init() argument
247 pt3_i2c_reset(pt3); in pt3_fe_init()
248 ret = pt3_init_all_demods(pt3); in pt3_fe_init()
250 dev_warn(&pt3->pdev->dev, "Failed to init demod chips\n"); in pt3_fe_init()
256 fe = pt3->adaps[i]->fe; in pt3_fe_init()
259 ret = pt3_demod_write(pt3->adaps[i], in pt3_fe_init()
262 ret = pt3_demod_write(pt3->adaps[i], in pt3_fe_init()
265 dev_warn(&pt3->pdev->dev, in pt3_fe_init()
275 ret = pt3_set_tuner_power(pt3, true, false); in pt3_fe_init()
277 dev_warn(&pt3->pdev->dev, "Failed to control tuner module\n"); in pt3_fe_init()
283 fe = pt3->adaps[i]->fe; in pt3_fe_init()
285 ret = pt3_demod_write(pt3->adaps[i], in pt3_fe_init()
288 ret = pt3_demod_write(pt3->adaps[i], in pt3_fe_init()
291 dev_warn(&pt3->pdev->dev, in pt3_fe_init()
299 fe = pt3->adaps[i]->fe; in pt3_fe_init()
305 dev_warn(&pt3->pdev->dev, in pt3_fe_init()
310 ret = pt3_init_all_mxl301rf(pt3); in pt3_fe_init()
312 dev_warn(&pt3->pdev->dev, "Failed to init TERR-tuners\n"); in pt3_fe_init()
316 ret = pt3_set_tuner_power(pt3, true, true); in pt3_fe_init()
318 dev_warn(&pt3->pdev->dev, "Failed to control tuner module\n"); in pt3_fe_init()
327 fe = pt3->adaps[i]->fe; in pt3_fe_init()
338 dev_warn(&pt3->pdev->dev, in pt3_fe_init()
346 fe = pt3->adaps[i]->fe; in pt3_fe_init()
361 dev_warn(&pt3->pdev->dev, "FE[%d] failed to standby\n", i); in pt3_fe_init()
368 static int pt3_attach_fe(struct pt3_board *pt3, int i) in pt3_attach_fe() argument
381 cl = dvb_module_probe("tc90522", info->type, &pt3->i2c_adap, in pt3_attach_fe()
385 pt3->adaps[i]->i2c_demod = cl; in pt3_attach_fe()
407 pt3->adaps[i]->i2c_tuner = cl; in pt3_attach_fe()
409 dvb_adap = &pt3->adaps[one_adapter ? 0 : i]->dvb_adap; in pt3_attach_fe()
413 pt3->adaps[i]->fe = cfg.fe; in pt3_attach_fe()
417 dvb_module_release(pt3->adaps[i]->i2c_tuner); in pt3_attach_fe()
419 dvb_module_release(pt3->adaps[i]->i2c_demod); in pt3_attach_fe()
526 static int pt3_alloc_adapter(struct pt3_board *pt3, int index) in pt3_alloc_adapter() argument
536 pt3->adaps[index] = adap; in pt3_alloc_adapter()
541 THIS_MODULE, &pt3->pdev->dev, adapter_nr); in pt3_alloc_adapter()
543 dev_err(&pt3->pdev->dev, in pt3_alloc_adapter()
549 da = &pt3->adaps[0]->dvb_adap; in pt3_alloc_adapter()
551 adap->dvb_adap.priv = pt3; in pt3_alloc_adapter()
560 dev_err(&pt3->pdev->dev, "failed to init dmx dev\n"); in pt3_alloc_adapter()
568 dev_err(&pt3->pdev->dev, "failed to init dmxdev\n"); in pt3_alloc_adapter()
574 dev_err(&pt3->pdev->dev, "failed to alloc DMA buffers\n"); in pt3_alloc_adapter()
590 pt3->adaps[index] = NULL; in pt3_alloc_adapter()
594 static void pt3_cleanup_adapter(struct pt3_board *pt3, int index) in pt3_cleanup_adapter() argument
599 adap = pt3->adaps[index]; in pt3_cleanup_adapter()
622 pt3->adaps[index] = NULL; in pt3_cleanup_adapter()
629 struct pt3_board *pt3 = dev_get_drvdata(dev); in pt3_suspend() local
634 adap = pt3->adaps[i]; in pt3_suspend()
641 pt3_lnb_ctrl(pt3, false); in pt3_suspend()
642 pt3_set_tuner_power(pt3, false, false); in pt3_suspend()
648 struct pt3_board *pt3 = dev_get_drvdata(dev); in pt3_resume() local
652 ret = pt3_fe_init(pt3); in pt3_resume()
656 if (pt3->lna_on_cnt > 0) in pt3_resume()
657 pt3_set_tuner_power(pt3, true, true); in pt3_resume()
658 if (pt3->lnb_on_cnt > 0) in pt3_resume()
659 pt3_lnb_ctrl(pt3, true); in pt3_resume()
662 adap = pt3->adaps[i]; in pt3_resume()
666 dev_err(&pt3->pdev->dev, "failed to alloc DMA bufs\n"); in pt3_resume()
681 struct pt3_board *pt3; in pt3_remove() local
684 pt3 = pci_get_drvdata(pdev); in pt3_remove()
686 pt3_cleanup_adapter(pt3, i); in pt3_remove()
687 i2c_del_adapter(&pt3->i2c_adap); in pt3_remove()
695 struct pt3_board *pt3; in pt3_probe() local
724 pt3 = devm_kzalloc(&pdev->dev, sizeof(*pt3), GFP_KERNEL); in pt3_probe()
725 if (!pt3) in pt3_probe()
727 pci_set_drvdata(pdev, pt3); in pt3_probe()
728 pt3->pdev = pdev; in pt3_probe()
729 mutex_init(&pt3->lock); in pt3_probe()
730 pt3->regs[0] = pcim_iomap_table(pdev)[0]; in pt3_probe()
731 pt3->regs[1] = pcim_iomap_table(pdev)[2]; in pt3_probe()
733 ver = ioread32(pt3->regs[0] + REG_VERSION); in pt3_probe()
740 pt3->num_bufs = clamp_val(num_bufs, MIN_DATA_BUFS, MAX_DATA_BUFS); in pt3_probe()
742 pt3->i2c_buf = devm_kmalloc(&pdev->dev, sizeof(*pt3->i2c_buf), GFP_KERNEL); in pt3_probe()
743 if (!pt3->i2c_buf) in pt3_probe()
745 i2c = &pt3->i2c_adap; in pt3_probe()
751 i2c_set_adapdata(i2c, pt3); in pt3_probe()
757 ret = pt3_alloc_adapter(pt3, i); in pt3_probe()
761 ret = pt3_attach_fe(pt3, i); in pt3_probe()
770 ret = pt3_fe_init(pt3); in pt3_probe()
784 pt3_cleanup_adapter(pt3, i--); in pt3_probe()