1 // SPDX-License-Identifier: GPL-2.0-or-later
5 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
9 #include <linux/signal.h>
10 #include <linux/sched.h>
11 #include <linux/interrupt.h>
13 #include <media/dmxdev.h>
14 #include <media/dvbdev.h>
15 #include <media/dvb_demux.h>
16 #include <media/dvb_frontend.h>
17 #include <media/dvb_net.h>
20 #include "mantis_common.h"
21 #include "mantis_ioc.h"
22 #include "mantis_dvb.h"
23 #include "mantis_vp1033.h"
24 #include "mantis_reg.h"
26 static u8 lgtdqcs001f_inittab
[] = {
71 #define MANTIS_MODEL_NAME "VP-1033"
72 #define MANTIS_DEV_TYPE "DVB-S/DSS"
74 static int lgtdqcs001f_tuner_set(struct dvb_frontend
*fe
)
76 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
77 struct mantis_pci
*mantis
= fe
->dvb
->priv
;
78 struct i2c_adapter
*adapter
= &mantis
->adapter
;
84 struct i2c_msg msg
= {.addr
= 0x61, .flags
= 0, .buf
= buf
, .len
= sizeof(buf
)};
86 div
= p
->frequency
/ 250;
88 buf
[0] = (div
>> 8) & 0x7f;
93 if (p
->frequency
< 1531000)
97 if (i2c_transfer(adapter
, &msg
, 1) < 0) {
98 dprintk(MANTIS_ERROR
, 1, "Write: I2C Transfer failed");
101 msleep_interruptible(100);
106 static int lgtdqcs001f_set_symbol_rate(struct dvb_frontend
*fe
,
107 u32 srate
, u32 ratio
)
112 if (srate
< 1500000) {
115 } else if (srate
< 3000000) {
118 } else if (srate
< 7000000) {
121 } else if (srate
< 14000000) {
124 } else if (srate
< 30000000) {
127 } else if (srate
< 45000000) {
131 stv0299_writereg(fe
, 0x13, aclk
);
132 stv0299_writereg(fe
, 0x14, bclk
);
134 stv0299_writereg(fe
, 0x1f, (ratio
>> 16) & 0xff);
135 stv0299_writereg(fe
, 0x20, (ratio
>> 8) & 0xff);
136 stv0299_writereg(fe
, 0x21, ratio
& 0xf0);
141 static struct stv0299_config lgtdqcs001f_config
= {
142 .demod_address
= 0x68,
143 .inittab
= lgtdqcs001f_inittab
,
147 .volt13_op0_op1
= STV0299_VOLT13_OP0
,
149 .set_symbol_rate
= lgtdqcs001f_set_symbol_rate
,
152 static int vp1033_frontend_init(struct mantis_pci
*mantis
, struct dvb_frontend
*fe
)
154 struct i2c_adapter
*adapter
= &mantis
->adapter
;
158 err
= mantis_frontend_power(mantis
, POWER_ON
);
160 mantis_frontend_soft_reset(mantis
);
163 dprintk(MANTIS_ERROR
, 1, "Probing for STV0299 (DVB-S)");
164 fe
= dvb_attach(stv0299_attach
, &lgtdqcs001f_config
, adapter
);
167 fe
->ops
.tuner_ops
.set_params
= lgtdqcs001f_tuner_set
;
168 dprintk(MANTIS_ERROR
, 1, "found STV0299 DVB-S frontend @ 0x%02x",
169 lgtdqcs001f_config
.demod_address
);
171 dprintk(MANTIS_ERROR
, 1, "Mantis DVB-S STV0299 frontend attach success");
176 dprintk(MANTIS_ERROR
, 1, "Frontend on <%s> POWER ON failed! <%d>",
183 dprintk(MANTIS_ERROR
, 1, "Done!");
188 struct mantis_hwconfig vp1033_config
= {
189 .model_name
= MANTIS_MODEL_NAME
,
190 .dev_type
= MANTIS_DEV_TYPE
,
191 .ts_size
= MANTIS_TS_204
,
193 .baud_rate
= MANTIS_BAUD_9600
,
194 .parity
= MANTIS_PARITY_NONE
,
197 .frontend_init
= vp1033_frontend_init
,