// SPDX-License-Identifier: GPL-2.0-or-later
/*
Mantis VP-1033 driver
Copyright (C) Manu Abraham (abraham.manu@gmail.com)
*/
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <media/dmxdev.h>
#include <media/dvbdev.h>
#include <media/dvb_demux.h>
#include <media/dvb_frontend.h>
#include <media/dvb_net.h>
#include "stv0299.h"
#include "mantis_common.h"
#include "mantis_ioc.h"
#include "mantis_dvb.h"
#include "mantis_vp1033.h"
#include "mantis_reg.h"
static u8 lgtdqcs001f_inittab[] = {
0 x01, 0 x15,
0 x02, 0 x30,
0 x03, 0 x00,
0 x04, 0 x2a,
0 x05, 0 x85,
0 x06, 0 x02,
0 x07, 0 x00,
0 x08, 0 x00,
0 x0c, 0 x01,
0 x0d, 0 x81,
0 x0e, 0 x44,
0 x0f, 0 x94,
0 x10, 0 x3c,
0 x11, 0 x84,
0 x12, 0 xb9,
0 x13, 0 xb5,
0 x14, 0 x4f,
0 x15, 0 xc9,
0 x16, 0 x80,
0 x17, 0 x36,
0 x18, 0 xfb,
0 x19, 0 xcf,
0 x1a, 0 xbc,
0 x1c, 0 x2b,
0 x1d, 0 x27,
0 x1e, 0 x00,
0 x1f, 0 x0b,
0 x20, 0 xa1,
0 x21, 0 x60,
0 x22, 0 x00,
0 x23, 0 x00,
0 x28, 0 x00,
0 x29, 0 x28,
0 x2a, 0 x14,
0 x2b, 0 x0f,
0 x2c, 0 x09,
0 x2d, 0 x05,
0 x31, 0 x1f,
0 x32, 0 x19,
0 x33, 0 xfc,
0 x34, 0 x13,
0 xff, 0 xff,
};
#define MANTIS_MODEL_NAME "VP-1033"
#define MANTIS_DEV_TYPE "DVB-S/DSS"
static int lgtdqcs001f_tuner_set(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct mantis_pci *mantis = fe->dvb->priv;
struct i2c_adapter *adapter = &mantis->adapter;
u8 buf[4 ];
u32 div;
struct i2c_msg msg = {.addr = 0 x61, .flags = 0 , .buf = buf, .len = sizeof (buf)};
div = p->frequency / 250 ;
buf[0 ] = (div >> 8 ) & 0 x7f;
buf[1 ] = div & 0 xff;
buf[2 ] = 0 x83;
buf[3 ] = 0 xc0;
if (p->frequency < 1531000 )
buf[3 ] |= 0 x04;
else
buf[3 ] &= ~0 x04;
if (i2c_transfer(adapter, &msg, 1 ) < 0 ) {
dprintk(MANTIS_ERROR, 1 , "Write: I2C Transfer failed" );
return -EIO;
}
msleep_interruptible(100 );
return 0 ;
}
static int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe,
u32 srate, u32 ratio)
{
u8 aclk = 0 ;
u8 bclk = 0 ;
if (srate < 1500000 ) {
aclk = 0 xb7;
bclk = 0 x47;
} else if (srate < 3000000 ) {
aclk = 0 xb7;
bclk = 0 x4b;
} else if (srate < 7000000 ) {
aclk = 0 xb7;
bclk = 0 x4f;
} else if (srate < 14000000 ) {
aclk = 0 xb7;
bclk = 0 x53;
} else if (srate < 30000000 ) {
aclk = 0 xb6;
bclk = 0 x53;
} else if (srate < 45000000 ) {
aclk = 0 xb4;
bclk = 0 x51;
}
stv0299_writereg(fe, 0 x13, aclk);
stv0299_writereg(fe, 0 x14, bclk);
stv0299_writereg(fe, 0 x1f, (ratio >> 16 ) & 0 xff);
stv0299_writereg(fe, 0 x20, (ratio >> 8 ) & 0 xff);
stv0299_writereg(fe, 0 x21, ratio & 0 xf0);
return 0 ;
}
static struct stv0299_config lgtdqcs001f_config = {
.demod_address = 0 x68,
.inittab = lgtdqcs001f_inittab,
.mclk = 88000000 UL,
.invert = 0 ,
.skip_reinit = 0 ,
.volt13_op0_op1 = STV0299_VOLT13_OP0,
.min_delay_ms = 100 ,
.set_symbol_rate = lgtdqcs001f_set_symbol_rate,
};
static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
{
struct i2c_adapter *adapter = &mantis->adapter;
int err = 0 ;
err = mantis_frontend_power(mantis, POWER_ON);
if (err == 0 ) {
mantis_frontend_soft_reset(mantis);
msleep(250 );
dprintk(MANTIS_ERROR, 1 , "Probing for STV0299 (DVB-S)" );
fe = dvb_attach(stv0299_attach, &lgtdqcs001f_config, adapter);
if (fe) {
fe->ops.tuner_ops.set_params = lgtdqcs001f_tuner_set;
dprintk(MANTIS_ERROR, 1 , "found STV0299 DVB-S frontend @ 0x%02x" ,
lgtdqcs001f_config.demod_address);
dprintk(MANTIS_ERROR, 1 , "Mantis DVB-S STV0299 frontend attach success" );
} else {
return -1 ;
}
} else {
dprintk(MANTIS_ERROR, 1 , "Frontend on <%s> POWER ON failed! <%d>" ,
adapter->name,
err);
return -EIO;
}
mantis->fe = fe;
dprintk(MANTIS_ERROR, 1 , "Done!" );
return 0 ;
}
struct mantis_hwconfig vp1033_config = {
.model_name = MANTIS_MODEL_NAME,
.dev_type = MANTIS_DEV_TYPE,
.ts_size = MANTIS_TS_204,
.baud_rate = MANTIS_BAUD_9600,
.parity = MANTIS_PARITY_NONE,
.bytes = 0 ,
.frontend_init = vp1033_frontend_init,
.power = GPIF_A12,
.reset = GPIF_A13,
};
Messung V0.5 in Prozent C=95 H=100 G=97
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland