dvb-core: add common dvb adapter [1/2]

PD#SWPL-100942

Problem:
should separate adapter from dvb-extern

Solution:
add adapter in dvb-core module

Verify:
verified by T + ohm

Change-Id: I305329f8d97d1a6429f2bb6600b2129ac149d90d
Signed-off-by: min.yang <min.yang@amlogic.com>
This commit is contained in:
min.yang
2022-11-11 14:11:30 +08:00
committed by Dongjin Kim
parent c4ec13c1f4
commit 40cddef24b
2 changed files with 47 additions and 0 deletions

View File

@@ -234,6 +234,42 @@ static enum dvbv3_emulation_type dvbv3_type(u32 delivery_system)
}
}
#ifdef CONFIG_AMLOGIC_DVB_COMPAT
static struct dvb_adapter frontend_adapter;
static int ref_count;
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
struct dvb_adapter *aml_dvb_get_adapter(struct device *dev)
{
mutex_lock(&frontend_mutex);
if (!ref_count) {
pr_err("%s need register adapter first.\n", __func__);
dvb_register_adapter(&frontend_adapter, "amlogic-dvb", THIS_MODULE,
dev, adapter_nr);
}
ref_count++;
mutex_unlock(&frontend_mutex);
return &frontend_adapter;
}
EXPORT_SYMBOL(aml_dvb_get_adapter);
int aml_dvb_put_adapter(struct dvb_adapter *adapter)
{
mutex_lock(&frontend_mutex);
if (ref_count > 0)
ref_count--;
if (!ref_count && adapter == &frontend_adapter) {
pr_err("%s dvb unregister adapter.\n", __func__);
dvb_unregister_adapter(&frontend_adapter);
}
mutex_unlock(&frontend_mutex);
return 0;
}
EXPORT_SYMBOL(aml_dvb_put_adapter);
#endif
#ifdef CONFIG_AMLOGIC_DVB_COMPAT
void dvb_frontend_add_event(struct dvb_frontend *fe,
enum fe_status status)

View File

@@ -844,5 +844,16 @@ void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
* dvb_frontend_add_event() - add event for the dvb frontend
*/
void dvb_frontend_add_event(struct dvb_frontend *fe, enum fe_status status);
/**
* aml_dvb_get_adapter() - offer a common dvb adapter for demod, demux and CI
*/
struct dvb_adapter *aml_dvb_get_adapter(struct device *dev);
/**
* aml_dvb_put_adapter() - when call this function, ref count will -1,
* if ref count is 0, adapter would be unregistered.
*/
int aml_dvb_put_adapter(struct dvb_adapter *adapter);
#endif
#endif