media: dvb-frontends/tbs_priv: dos2unix

This commit is contained in:
CrazyCat
2023-09-24 17:40:20 +03:00
parent 17944a4eb0
commit 283a4a7961
2 changed files with 256 additions and 256 deletions

View File

@@ -1,219 +1,219 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/i2c-mux.h> #include <linux/i2c-mux.h>
#include <media/dvb_frontend.h> #include <media/dvb_frontend.h>
#include "tbs_priv.h" #include "tbs_priv.h"
struct tbs_dev{ struct tbs_dev{
struct dvb_frontend fe; struct dvb_frontend fe;
u32 adr; u32 adr;
u8 flag; u8 flag;
u8 rf; u8 rf;
struct i2c_adapter *i2c; struct i2c_adapter *i2c;
void (*TS_switch)(struct i2c_adapter * i2c,u8 flag); void (*TS_switch)(struct i2c_adapter * i2c,u8 flag);
void (*LED_switch)(struct i2c_adapter * i2c,u8 flag); void (*LED_switch)(struct i2c_adapter * i2c,u8 flag);
void (*write_properties) (struct i2c_adapter *i2c,u8 reg, u32 buf); void (*write_properties) (struct i2c_adapter *i2c,u8 reg, u32 buf);
void (*read_properties) (struct i2c_adapter *i2c,u8 reg, u32 *buf); void (*read_properties) (struct i2c_adapter *i2c,u8 reg, u32 *buf);
}; };
static int tbs_read_status(struct dvb_frontend *fe,enum fe_status*status) static int tbs_read_status(struct dvb_frontend *fe,enum fe_status*status)
{ {
struct tbs_dev*state =fe->demodulator_priv; struct tbs_dev*state =fe->demodulator_priv;
*status = FE_HAS_LOCK; *status = FE_HAS_LOCK;
return 0; return 0;
} }
static int tbs_read_ber(struct dvb_frontend*fe,u32*ber) static int tbs_read_ber(struct dvb_frontend*fe,u32*ber)
{ {
*ber = 10; *ber = 10;
return 0; return 0;
} }
static int tbs_read_snr(struct dvb_frontend*fe,u16*snr) static int tbs_read_snr(struct dvb_frontend*fe,u16*snr)
{ {
struct tbs_dev*state = fe->demodulator_priv; struct tbs_dev*state = fe->demodulator_priv;
struct dtv_frontend_properties *p = &fe->dtv_property_cache; struct dtv_frontend_properties *p = &fe->dtv_property_cache;
p->cnr.len = 1; p->cnr.len = 1;
p->cnr.stat[0].scale = FE_SCALE_DECIBEL; p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
p->cnr.stat[0].svalue = 40; p->cnr.stat[0].svalue = 40;
*snr = 0xf288; *snr = 0xf288;
return 0; return 0;
} }
static int tbs_read_signal_strength(struct dvb_frontend*fe, u16*strength) static int tbs_read_signal_strength(struct dvb_frontend*fe, u16*strength)
{ {
struct tbs_dev*state = fe->demodulator_priv; struct tbs_dev*state = fe->demodulator_priv;
struct dtv_frontend_properties *p = &fe->dtv_property_cache; struct dtv_frontend_properties *p = &fe->dtv_property_cache;
p->strength.len = 1; p->strength.len = 1;
p->strength.stat[0].scale = FE_SCALE_DECIBEL; p->strength.stat[0].scale = FE_SCALE_DECIBEL;
p->strength.stat[0].svalue = 40; p->strength.stat[0].svalue = 40;
*strength = 0xf188; *strength = 0xf188;
return 0; return 0;
} }
static int tbs_sleep(struct dvb_frontend *fe) static int tbs_sleep(struct dvb_frontend *fe)
{ {
return 0; return 0;
} }
static int tbs_init(struct dvb_frontend *fe) static int tbs_init(struct dvb_frontend *fe)
{ {
return 0; return 0;
} }
static void tbs_spi_read(struct dvb_frontend *fe, struct ecp3_info *ecp3inf) static void tbs_spi_read(struct dvb_frontend *fe, struct ecp3_info *ecp3inf)
{ {
struct tbs_dev *priv = fe->demodulator_priv; struct tbs_dev *priv = fe->demodulator_priv;
struct i2c_adapter *adapter = priv->i2c; struct i2c_adapter *adapter = priv->i2c;
if (priv->read_properties) if (priv->read_properties)
priv->read_properties(adapter,ecp3inf->reg, &(ecp3inf->data)); priv->read_properties(adapter,ecp3inf->reg, &(ecp3inf->data));
return; return;
} }
static void tbs_spi_write(struct dvb_frontend *fe,struct ecp3_info *ecp3inf) static void tbs_spi_write(struct dvb_frontend *fe,struct ecp3_info *ecp3inf)
{ {
struct tbs_dev *priv = fe->demodulator_priv; struct tbs_dev *priv = fe->demodulator_priv;
struct i2c_adapter *adapter = priv->i2c; struct i2c_adapter *adapter = priv->i2c;
if (priv->write_properties) if (priv->write_properties)
priv->write_properties(adapter,ecp3inf->reg, ecp3inf->data); priv->write_properties(adapter,ecp3inf->reg, ecp3inf->data);
return ; return ;
} }
static int tbs_set_tone(struct dvb_frontend *fe, static int tbs_set_tone(struct dvb_frontend *fe,
enum fe_sec_tone_mode tone) enum fe_sec_tone_mode tone)
{ {
return 0; return 0;
} }
static int tbs_set_voltage(struct dvb_frontend *fe, static int tbs_set_voltage(struct dvb_frontend *fe,
enum fe_sec_voltage voltage) enum fe_sec_voltage voltage)
{ {
return 0; return 0;
} }
static int tbs_set_frontend(struct dvb_frontend *fe) static int tbs_set_frontend(struct dvb_frontend *fe)
{ {
struct tbs_dev*state = fe->demodulator_priv; struct tbs_dev*state = fe->demodulator_priv;
if(state->TS_switch) if(state->TS_switch)
state->TS_switch(state->i2c,0); state->TS_switch(state->i2c,0);
if(state->LED_switch) if(state->LED_switch)
state->LED_switch(state->i2c,8); state->LED_switch(state->i2c,8);
return 0; return 0;
} }
static int tbs_tune(struct dvb_frontend *fe,bool re_tune, static int tbs_tune(struct dvb_frontend *fe,bool re_tune,
unsigned int mode_flags, unsigned int mode_flags,
unsigned int* delay,enum fe_status*status) unsigned int* delay,enum fe_status*status)
{ {
struct tbs_dev*state = fe->demodulator_priv; struct tbs_dev*state = fe->demodulator_priv;
int r; int r;
if(re_tune){ if(re_tune){
r = tbs_set_frontend(fe); r = tbs_set_frontend(fe);
if(r) if(r)
return r; return r;
} }
r = tbs_read_status(fe, status); r = tbs_read_status(fe, status);
if(*status&FE_HAS_LOCK) if(*status&FE_HAS_LOCK)
return 0; return 0;
return 0; return 0;
} }
static void tbs_release(struct dvb_frontend *fe) static void tbs_release(struct dvb_frontend *fe)
{ {
struct tbs_dev*state = fe->demodulator_priv; struct tbs_dev*state = fe->demodulator_priv;
kfree(state); kfree(state);
} }
static struct dvb_frontend_ops tbs_ops = { static struct dvb_frontend_ops tbs_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2 }, .delsys = { SYS_DVBS, SYS_DVBS2 },
.info = { .info = {
.name = "TBS virtual frontend", .name = "TBS virtual frontend",
.frequency_min_hz = 950 * MHz, .frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz, .frequency_max_hz = 2150 * MHz,
.symbol_rate_min = 1000000, .symbol_rate_min = 1000000,
.symbol_rate_max = 45000000, .symbol_rate_max = 45000000,
.caps = FE_CAN_INVERSION_AUTO | .caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_2G_MODULATION | FE_CAN_2G_MODULATION |
FE_CAN_QPSK | FE_CAN_RECOVER FE_CAN_QPSK | FE_CAN_RECOVER
}, },
.release = tbs_release, .release = tbs_release,
.init = tbs_init, .init = tbs_init,
.sleep = tbs_sleep, .sleep = tbs_sleep,
.read_status = tbs_read_status, .read_status = tbs_read_status,
.read_ber = tbs_read_ber, .read_ber = tbs_read_ber,
.read_signal_strength = tbs_read_signal_strength, .read_signal_strength = tbs_read_signal_strength,
.read_snr = tbs_read_snr, .read_snr = tbs_read_snr,
.tune = tbs_tune, .tune = tbs_tune,
.set_frontend = tbs_set_frontend, .set_frontend = tbs_set_frontend,
.set_tone = tbs_set_tone, .set_tone = tbs_set_tone,
.set_voltage = tbs_set_voltage, .set_voltage = tbs_set_voltage,
.spi_read = tbs_spi_read, .spi_read = tbs_spi_read,
.spi_write = tbs_spi_write, .spi_write = tbs_spi_write,
}; };
struct dvb_frontend *tbs_attach(struct i2c_adapter*i2c, struct dvb_frontend *tbs_attach(struct i2c_adapter*i2c,
struct tbs_cfg*cfg, struct tbs_cfg*cfg,
u32 demod) u32 demod)
{ {
struct tbs_dev*state = NULL; struct tbs_dev*state = NULL;
printk( " Attaching frontend\n"); printk( " Attaching frontend\n");
state = kzalloc(sizeof(struct tbs_dev),GFP_KERNEL); state = kzalloc(sizeof(struct tbs_dev),GFP_KERNEL);
if(!state) if(!state)
return NULL; return NULL;
state->adr = cfg->adr; state->adr = cfg->adr;
state->flag = cfg->flag; state->flag = cfg->flag;
state->rf = cfg->rf; state->rf = cfg->rf;
state->LED_switch =cfg->LED_switch; state->LED_switch =cfg->LED_switch;
state->TS_switch = cfg->TS_switch; state->TS_switch = cfg->TS_switch;
state->read_properties =cfg->read_properties; state->read_properties =cfg->read_properties;
state->write_properties = cfg->write_properties; state->write_properties = cfg->write_properties;
state->i2c = i2c; state->i2c = i2c;
memcpy(&state->fe.ops, &tbs_ops, memcpy(&state->fe.ops, &tbs_ops,
sizeof(struct dvb_frontend_ops)); sizeof(struct dvb_frontend_ops));
state->fe.demodulator_priv = state; state->fe.demodulator_priv = state;
printk( "tbs priv attach finish.\n"); printk( "tbs priv attach finish.\n");
return &state->fe; return &state->fe;
} }
MODULE_DESCRIPTION("TBS private virtual demodulator driver"); MODULE_DESCRIPTION("TBS private virtual demodulator driver");
MODULE_AUTHOR("Davin zhang(Davin@tbsdtv.com)"); MODULE_AUTHOR("Davin zhang(Davin@tbsdtv.com)");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
EXPORT_SYMBOL(tbs_attach); EXPORT_SYMBOL(tbs_attach);

View File

@@ -1,37 +1,37 @@
#ifndef TBS_PRIV_H_ #ifndef TBS_PRIV_H_
#define TBS_PRIV_H_ #define TBS_PRIV_H_
#include <linux/i2c.h> #include <linux/i2c.h>
#include <media/dvb_frontend.h> #include <media/dvb_frontend.h>
struct tbs_cfg{ struct tbs_cfg{
u8 adr; u8 adr;
u8 flag; u8 flag;
u8 rf; u8 rf;
void (*TS_switch)(struct i2c_adapter * i2c,u8 flag); void (*TS_switch)(struct i2c_adapter * i2c,u8 flag);
void (*LED_switch)(struct i2c_adapter * i2c,u8 flag); void (*LED_switch)(struct i2c_adapter * i2c,u8 flag);
void (*write_properties) (struct i2c_adapter *i2c,u8 reg, u32 buf); void (*write_properties) (struct i2c_adapter *i2c,u8 reg, u32 buf);
void (*read_properties) (struct i2c_adapter *i2c,u8 reg, u32 *buf); void (*read_properties) (struct i2c_adapter *i2c,u8 reg, u32 *buf);
}; };
#if IS_REACHABLE(CONFIG_DVB_TBSPRIV) #if IS_REACHABLE(CONFIG_DVB_TBSPRIV)
extern struct dvb_frontend *tbs_attach(struct i2c_adapter * i2c, extern struct dvb_frontend *tbs_attach(struct i2c_adapter * i2c,
struct tbs_cfg * cfg,u32 demod); struct tbs_cfg * cfg,u32 demod);
#else #else
static inline struct dvb_frontend *tbs_attach(struct i2c_adapter * i2c, static inline struct dvb_frontend *tbs_attach(struct i2c_adapter * i2c,
struct tbs_cfg * cfg,u32 demod) struct tbs_cfg * cfg,u32 demod)
{ {
dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__); dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__);
return NULL; return NULL;
} }
#endif #endif
#endif #endif