2020-03-26 15:06:02 +01:00
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Dummy Frontend
*
* Written by Emard < emard @ softhome . net >
*/
# include <linux/module.h>
# include <linux/init.h>
# include <linux/string.h>
# include <linux/slab.h>
# include <media/dvb_frontend.h>
2020-03-26 15:08:59 +01:00
# include "ddbridge-dummy-fe.h"
2020-03-26 15:06:02 +01:00
2020-03-26 15:08:59 +01:00
struct ddbridge_dummy_fe_state {
2020-03-26 15:06:02 +01:00
struct dvb_frontend frontend ;
} ;
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_read_status ( struct dvb_frontend * fe ,
2020-03-26 15:06:02 +01:00
enum fe_status * status )
{
* status = FE_HAS_SIGNAL
| FE_HAS_CARRIER
| FE_HAS_VITERBI
| FE_HAS_SYNC
| FE_HAS_LOCK ;
return 0 ;
}
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_read_ber ( struct dvb_frontend * fe , u32 * ber )
2020-03-26 15:06:02 +01:00
{
* ber = 0 ;
return 0 ;
}
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_read_signal_strength ( struct dvb_frontend * fe ,
2020-03-26 15:06:02 +01:00
u16 * strength )
{
* strength = 0 ;
return 0 ;
}
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_read_snr ( struct dvb_frontend * fe , u16 * snr )
2020-03-26 15:06:02 +01:00
{
* snr = 0 ;
return 0 ;
}
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_read_ucblocks ( struct dvb_frontend * fe , u32 * ucblocks )
2020-03-26 15:06:02 +01:00
{
* ucblocks = 0 ;
return 0 ;
}
/*
* Should only be implemented if it actually reads something from the hardware .
* Also , it should check for the locks , in order to avoid report wrong data
* to userspace .
*/
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_get_frontend ( struct dvb_frontend * fe ,
2020-03-26 15:06:02 +01:00
struct dtv_frontend_properties * p )
{
return 0 ;
}
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_set_frontend ( struct dvb_frontend * fe )
2020-03-26 15:06:02 +01:00
{
if ( fe - > ops . tuner_ops . set_params ) {
fe - > ops . tuner_ops . set_params ( fe ) ;
if ( fe - > ops . i2c_gate_ctrl )
fe - > ops . i2c_gate_ctrl ( fe , 0 ) ;
}
return 0 ;
}
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_sleep ( struct dvb_frontend * fe )
2020-03-26 15:06:02 +01:00
{
return 0 ;
}
2020-03-26 15:08:59 +01:00
static int ddbridge_dummy_fe_init ( struct dvb_frontend * fe )
2020-03-26 15:06:02 +01:00
{
return 0 ;
}
2020-03-26 15:08:59 +01:00
static void ddbridge_dummy_fe_release ( struct dvb_frontend * fe )
2020-03-26 15:06:02 +01:00
{
2020-03-26 15:08:59 +01:00
struct ddbridge_dummy_fe_state * state = fe - > demodulator_priv ;
2020-03-26 15:06:02 +01:00
kfree ( state ) ;
}
2020-03-26 15:08:59 +01:00
static const struct dvb_frontend_ops ddbridge_dummy_fe_qam_ops ;
2020-03-26 15:06:02 +01:00
2020-03-26 15:08:59 +01:00
struct dvb_frontend * ddbridge_dummy_fe_qam_attach ( void )
2020-03-26 15:06:02 +01:00
{
2020-03-26 15:08:59 +01:00
struct ddbridge_dummy_fe_state * state = NULL ;
2020-03-26 15:06:02 +01:00
/* allocate memory for the internal state */
2020-03-26 15:08:59 +01:00
state = kzalloc ( sizeof ( struct ddbridge_dummy_fe_state ) , GFP_KERNEL ) ;
2020-03-26 15:06:02 +01:00
if ( ! state )
return NULL ;
/* create dvb_frontend */
memcpy ( & state - > frontend . ops ,
2020-03-26 15:08:59 +01:00
& ddbridge_dummy_fe_qam_ops ,
2020-03-26 15:06:02 +01:00
sizeof ( struct dvb_frontend_ops ) ) ;
state - > frontend . demodulator_priv = state ;
return & state - > frontend ;
}
2023-09-08 10:20:36 +01:00
EXPORT_SYMBOL_GPL ( ddbridge_dummy_fe_qam_attach ) ;
2020-03-26 15:06:02 +01:00
2020-03-26 15:08:59 +01:00
static const struct dvb_frontend_ops ddbridge_dummy_fe_qam_ops = {
2020-03-26 15:06:02 +01:00
. delsys = { SYS_DVBC_ANNEX_A } ,
. info = {
2020-03-26 15:08:59 +01:00
. name = " ddbridge dummy DVB-C " ,
2020-03-26 15:06:02 +01:00
. frequency_min_hz = 51 * MHz ,
. frequency_max_hz = 858 * MHz ,
. frequency_stepsize_hz = 62500 ,
/* symbol_rate_min: SACLK/64 == (XIN/2)/64 */
. symbol_rate_min = ( 57840000 / 2 ) / 64 ,
. symbol_rate_max = ( 57840000 / 2 ) / 4 , /* SACLK/4 */
. caps = FE_CAN_QAM_16 |
FE_CAN_QAM_32 |
FE_CAN_QAM_64 |
FE_CAN_QAM_128 |
FE_CAN_QAM_256 |
FE_CAN_FEC_AUTO |
FE_CAN_INVERSION_AUTO
} ,
2020-03-26 15:08:59 +01:00
. release = ddbridge_dummy_fe_release ,
2020-03-26 15:06:02 +01:00
2020-03-26 15:08:59 +01:00
. init = ddbridge_dummy_fe_init ,
. sleep = ddbridge_dummy_fe_sleep ,
2020-03-26 15:06:02 +01:00
2020-03-26 15:08:59 +01:00
. set_frontend = ddbridge_dummy_fe_set_frontend ,
. get_frontend = ddbridge_dummy_fe_get_frontend ,
2020-03-26 15:06:02 +01:00
2020-03-26 15:08:59 +01:00
. read_status = ddbridge_dummy_fe_read_status ,
. read_ber = ddbridge_dummy_fe_read_ber ,
. read_signal_strength = ddbridge_dummy_fe_read_signal_strength ,
. read_snr = ddbridge_dummy_fe_read_snr ,
. read_ucblocks = ddbridge_dummy_fe_read_ucblocks ,
2020-03-26 15:06:02 +01:00
} ;
2020-03-26 15:08:59 +01:00
MODULE_DESCRIPTION ( " ddbridge dummy Frontend " ) ;
2020-03-26 15:06:02 +01:00
MODULE_AUTHOR ( " Emard " ) ;
MODULE_LICENSE ( " GPL " ) ;