2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Driver for Dummy Frontend
|
|
|
|
*
|
|
|
|
* Written by Emard <emard@softhome.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
*
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
2005-10-30 23:03:48 +00:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-12-28 18:03:51 +00:00
|
|
|
#include <media/dvb_frontend.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "dvb_dummy_fe.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct dvb_dummy_fe_state {
|
|
|
|
struct dvb_frontend frontend;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-06-07 17:53:52 +00:00
|
|
|
static int dvb_dummy_fe_read_status(struct dvb_frontend *fe,
|
|
|
|
enum fe_status *status)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
*status = FE_HAS_SIGNAL
|
|
|
|
| FE_HAS_CARRIER
|
|
|
|
| FE_HAS_VITERBI
|
|
|
|
| FE_HAS_SYNC
|
|
|
|
| FE_HAS_LOCK;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
|
|
|
|
{
|
|
|
|
*ber = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
|
|
|
|
{
|
|
|
|
*strength = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
|
|
|
|
{
|
|
|
|
*snr = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
|
|
|
|
{
|
|
|
|
*ucblocks = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[media] dvb: don't require a parameter for get_frontend
Just like set_frontend, use the dvb cache properties for get_frontend.
This is more consistent, as both functions are now symetric. Also,
at the places get_frontend is called, it makes sense to update the
cache.
Most of this patch were generated by this small perl script:
while (<>) { $file .= $_; }
if ($file =~ m/\.get_frontend\s*=\s*([\d\w_]+)/) {
my $get = $1;
$file =~ s/($get)(\s*\([^\,\)]+)\,\s*struct\s+dtv_frontend_properties\s*\*\s*([_\d\w]+)\)\s*\{/\1\2)\n{\n\tstruct dtv_frontend_properties *\3 = &fe->dtv_property_cache;/g;
}
print $file;
Of course, the changes at dvb_frontend.[ch] were made by hand,
as well as the changes on a few other places, where get_frontend()
is called internally inside the driver.
On some places, get_frontend() were just a void function. Those
occurrences were removed, as the DVB core handles such cases.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-12-30 14:30:21 +00:00
|
|
|
/*
|
2016-02-04 14:58:30 +00:00
|
|
|
* 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.
|
[media] dvb: don't require a parameter for get_frontend
Just like set_frontend, use the dvb cache properties for get_frontend.
This is more consistent, as both functions are now symetric. Also,
at the places get_frontend is called, it makes sense to update the
cache.
Most of this patch were generated by this small perl script:
while (<>) { $file .= $_; }
if ($file =~ m/\.get_frontend\s*=\s*([\d\w_]+)/) {
my $get = $1;
$file =~ s/($get)(\s*\([^\,\)]+)\,\s*struct\s+dtv_frontend_properties\s*\*\s*([_\d\w]+)\)\s*\{/\1\2)\n{\n\tstruct dtv_frontend_properties *\3 = &fe->dtv_property_cache;/g;
}
print $file;
Of course, the changes at dvb_frontend.[ch] were made by hand,
as well as the changes on a few other places, where get_frontend()
is called internally inside the driver.
On some places, get_frontend() were just a void function. Those
occurrences were removed, as the DVB core handles such cases.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-12-30 14:30:21 +00:00
|
|
|
*/
|
2016-02-04 14:58:30 +00:00
|
|
|
static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe,
|
|
|
|
struct dtv_frontend_properties *p)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-26 13:10:42 +00:00
|
|
|
static int dvb_dummy_fe_set_frontend(struct dvb_frontend *fe)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-08-30 15:15:54 +00:00
|
|
|
if (fe->ops.tuner_ops.set_params) {
|
2011-12-24 15:24:33 +00:00
|
|
|
fe->ops.tuner_ops.set_params(fe);
|
2008-08-30 15:15:54 +00:00
|
|
|
if (fe->ops.i2c_gate_ctrl)
|
|
|
|
fe->ops.i2c_gate_ctrl(fe, 0);
|
2006-04-18 20:47:10 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dvb_dummy_fe_init(struct dvb_frontend* fe)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-07 17:53:52 +00:00
|
|
|
static int dvb_dummy_fe_set_tone(struct dvb_frontend *fe,
|
|
|
|
enum fe_sec_tone_mode tone)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-07 17:53:52 +00:00
|
|
|
static int dvb_dummy_fe_set_voltage(struct dvb_frontend *fe,
|
|
|
|
enum fe_sec_voltage voltage)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dvb_dummy_fe_release(struct dvb_frontend* fe)
|
|
|
|
{
|
2005-05-17 04:54:31 +00:00
|
|
|
struct dvb_dummy_fe_state* state = fe->demodulator_priv;
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree(state);
|
|
|
|
}
|
|
|
|
|
2016-08-09 21:32:21 +00:00
|
|
|
static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
|
|
|
|
{
|
|
|
|
struct dvb_dummy_fe_state* state = NULL;
|
|
|
|
|
|
|
|
/* allocate memory for the internal state */
|
2009-08-11 01:51:01 +00:00
|
|
|
state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
|
2012-09-12 11:56:04 +00:00
|
|
|
if (!state)
|
|
|
|
return NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* create dvb_frontend */
|
2006-05-14 08:01:31 +00:00
|
|
|
memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
|
2005-04-16 22:20:36 +00:00
|
|
|
state->frontend.demodulator_priv = state;
|
|
|
|
return &state->frontend;
|
|
|
|
}
|
|
|
|
|
2016-08-09 21:32:21 +00:00
|
|
|
static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-09-04 06:33:43 +00:00
|
|
|
struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct dvb_dummy_fe_state* state = NULL;
|
|
|
|
|
|
|
|
/* allocate memory for the internal state */
|
2009-08-11 01:51:01 +00:00
|
|
|
state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
|
2012-09-12 11:56:04 +00:00
|
|
|
if (!state)
|
|
|
|
return NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* create dvb_frontend */
|
2006-05-14 08:01:31 +00:00
|
|
|
memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
|
2005-04-16 22:20:36 +00:00
|
|
|
state->frontend.demodulator_priv = state;
|
|
|
|
return &state->frontend;
|
|
|
|
}
|
|
|
|
|
2016-08-09 21:32:21 +00:00
|
|
|
static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-09-04 06:33:43 +00:00
|
|
|
struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct dvb_dummy_fe_state* state = NULL;
|
|
|
|
|
|
|
|
/* allocate memory for the internal state */
|
2009-08-11 01:51:01 +00:00
|
|
|
state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
|
2012-09-12 11:56:04 +00:00
|
|
|
if (!state)
|
|
|
|
return NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* create dvb_frontend */
|
2006-05-14 08:01:31 +00:00
|
|
|
memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
|
2005-04-16 22:20:36 +00:00
|
|
|
state->frontend.demodulator_priv = state;
|
|
|
|
return &state->frontend;
|
|
|
|
}
|
|
|
|
|
2016-08-09 21:32:21 +00:00
|
|
|
static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
|
2011-12-26 13:10:42 +00:00
|
|
|
.delsys = { SYS_DVBT },
|
2005-04-16 22:20:36 +00:00
|
|
|
.info = {
|
|
|
|
.name = "Dummy DVB-T",
|
2018-07-05 22:59:36 +00:00
|
|
|
.frequency_min_hz = 0,
|
|
|
|
.frequency_max_hz = 863250 * kHz,
|
|
|
|
.frequency_stepsize_hz = 62500,
|
2005-04-16 22:20:36 +00:00
|
|
|
.caps = 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_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
|
|
|
|
FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
|
|
|
|
FE_CAN_TRANSMISSION_MODE_AUTO |
|
|
|
|
FE_CAN_GUARD_INTERVAL_AUTO |
|
|
|
|
FE_CAN_HIERARCHY_AUTO,
|
|
|
|
},
|
|
|
|
|
|
|
|
.release = dvb_dummy_fe_release,
|
|
|
|
|
|
|
|
.init = dvb_dummy_fe_init,
|
|
|
|
.sleep = dvb_dummy_fe_sleep,
|
|
|
|
|
2011-12-26 13:10:42 +00:00
|
|
|
.set_frontend = dvb_dummy_fe_set_frontend,
|
|
|
|
.get_frontend = dvb_dummy_fe_get_frontend,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
.read_status = dvb_dummy_fe_read_status,
|
|
|
|
.read_ber = dvb_dummy_fe_read_ber,
|
|
|
|
.read_signal_strength = dvb_dummy_fe_read_signal_strength,
|
|
|
|
.read_snr = dvb_dummy_fe_read_snr,
|
|
|
|
.read_ucblocks = dvb_dummy_fe_read_ucblocks,
|
|
|
|
};
|
|
|
|
|
2016-08-09 21:32:21 +00:00
|
|
|
static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
|
2011-12-26 13:10:42 +00:00
|
|
|
.delsys = { SYS_DVBC_ANNEX_A },
|
2005-04-16 22:20:36 +00:00
|
|
|
.info = {
|
|
|
|
.name = "Dummy DVB-C",
|
2018-07-05 22:59:36 +00:00
|
|
|
.frequency_min_hz = 51 * MHz,
|
|
|
|
.frequency_max_hz = 858 * MHz,
|
|
|
|
.frequency_stepsize_hz = 62500,
|
|
|
|
.symbol_rate_min = (57840000 / 2) / 64, /* SACLK/64 == (XIN/2)/64 */
|
|
|
|
.symbol_rate_max = (57840000 / 2) / 4, /* SACLK/4 */
|
2005-04-16 22:20:36 +00:00
|
|
|
.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
|
|
|
|
},
|
|
|
|
|
|
|
|
.release = dvb_dummy_fe_release,
|
|
|
|
|
|
|
|
.init = dvb_dummy_fe_init,
|
|
|
|
.sleep = dvb_dummy_fe_sleep,
|
|
|
|
|
2011-12-26 13:10:42 +00:00
|
|
|
.set_frontend = dvb_dummy_fe_set_frontend,
|
|
|
|
.get_frontend = dvb_dummy_fe_get_frontend,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
.read_status = dvb_dummy_fe_read_status,
|
|
|
|
.read_ber = dvb_dummy_fe_read_ber,
|
|
|
|
.read_signal_strength = dvb_dummy_fe_read_signal_strength,
|
|
|
|
.read_snr = dvb_dummy_fe_read_snr,
|
|
|
|
.read_ucblocks = dvb_dummy_fe_read_ucblocks,
|
|
|
|
};
|
|
|
|
|
2016-08-09 21:32:21 +00:00
|
|
|
static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
|
2011-12-26 13:10:42 +00:00
|
|
|
.delsys = { SYS_DVBS },
|
2005-04-16 22:20:36 +00:00
|
|
|
.info = {
|
|
|
|
.name = "Dummy DVB-S",
|
2018-07-05 22:59:36 +00:00
|
|
|
.frequency_min_hz = 950 * MHz,
|
|
|
|
.frequency_max_hz = 2150 * MHz,
|
|
|
|
.frequency_stepsize_hz = 250 * kHz,
|
|
|
|
.frequency_tolerance_hz = 29500 * kHz,
|
2005-04-16 22:20:36 +00:00
|
|
|
.symbol_rate_min = 1000000,
|
|
|
|
.symbol_rate_max = 45000000,
|
|
|
|
.caps = FE_CAN_INVERSION_AUTO |
|
|
|
|
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
|
|
|
|
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
|
|
|
|
FE_CAN_QPSK
|
|
|
|
},
|
|
|
|
|
|
|
|
.release = dvb_dummy_fe_release,
|
|
|
|
|
|
|
|
.init = dvb_dummy_fe_init,
|
|
|
|
.sleep = dvb_dummy_fe_sleep,
|
|
|
|
|
2011-12-26 13:10:42 +00:00
|
|
|
.set_frontend = dvb_dummy_fe_set_frontend,
|
|
|
|
.get_frontend = dvb_dummy_fe_get_frontend,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
.read_status = dvb_dummy_fe_read_status,
|
|
|
|
.read_ber = dvb_dummy_fe_read_ber,
|
|
|
|
.read_signal_strength = dvb_dummy_fe_read_signal_strength,
|
|
|
|
.read_snr = dvb_dummy_fe_read_snr,
|
|
|
|
.read_ucblocks = dvb_dummy_fe_read_ucblocks,
|
|
|
|
|
|
|
|
.set_voltage = dvb_dummy_fe_set_voltage,
|
|
|
|
.set_tone = dvb_dummy_fe_set_tone,
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("DVB DUMMY Frontend");
|
|
|
|
MODULE_AUTHOR("Emard");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
|
|
|
|
EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
|
|
|
|
EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);
|