Commit 20bb9cc4 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] dvb_usb_v2: get rid of (struct dvb_usb_adapter_fe_properties)

Get rid of (struct dvb_usb_adapter_fe_properties) as we no longer
need it. Frontends are now defined as a array of pointers inside
adapter struct.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent fec88df0
...@@ -113,9 +113,6 @@ struct usb_data_stream_properties { ...@@ -113,9 +113,6 @@ struct usb_data_stream_properties {
* pll_desc and pll_init_buf of struct dvb_usb_device). * pll_desc and pll_init_buf of struct dvb_usb_device).
* @stream: configuration of the USB streaming * @stream: configuration of the USB streaming
*/ */
struct dvb_usb_adapter_fe_properties {
int size_of_priv;
};
#define MAX_NO_OF_FE_PER_ADAP 3 #define MAX_NO_OF_FE_PER_ADAP 3
struct dvb_usb_adapter_properties { struct dvb_usb_adapter_properties {
...@@ -139,7 +136,6 @@ struct dvb_usb_adapter_properties { ...@@ -139,7 +136,6 @@ struct dvb_usb_adapter_properties {
unsigned int, void *, unsigned int); unsigned int, void *, unsigned int);
int num_frontends; int num_frontends;
struct dvb_usb_adapter_fe_properties fe[MAX_NO_OF_FE_PER_ADAP];
struct usb_data_stream_properties stream; struct usb_data_stream_properties stream;
}; };
...@@ -306,15 +302,6 @@ struct usb_data_stream { ...@@ -306,15 +302,6 @@ struct usb_data_stream {
* *
* @stream: the usb data stream. * @stream: the usb data stream.
*/ */
struct dvb_usb_fe_adapter {
struct dvb_frontend *fe;
int (*fe_init) (struct dvb_frontend *);
int (*fe_sleep) (struct dvb_frontend *);
void *priv;
};
struct dvb_usb_adapter { struct dvb_usb_adapter {
#define DVB_USB_ADAP_STATE_INIT 0x000 #define DVB_USB_ADAP_STATE_INIT 0x000
#define DVB_USB_ADAP_STATE_DVB 0x001 #define DVB_USB_ADAP_STATE_DVB 0x001
...@@ -334,7 +321,10 @@ struct dvb_usb_adapter { ...@@ -334,7 +321,10 @@ struct dvb_usb_adapter {
struct dvb_demux demux; struct dvb_demux demux;
struct dvb_net dvb_net; struct dvb_net dvb_net;
struct dvb_usb_fe_adapter fe_adap[MAX_NO_OF_FE_PER_ADAP]; struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
int active_fe; int active_fe;
int num_frontends_initialized; int num_frontends_initialized;
......
...@@ -115,7 +115,7 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -115,7 +115,7 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
/* resolve TS configuration */ /* resolve TS configuration */
if (adap->dev->props.get_ts_config) { if (adap->dev->props.get_ts_config) {
ret = adap->dev->props.get_ts_config( ret = adap->dev->props.get_ts_config(
adap->fe_adap[adap->active_fe].fe, adap->fe[adap->active_fe],
&ts_props); &ts_props);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -133,7 +133,7 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -133,7 +133,7 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
/* resolve USB stream configuration */ /* resolve USB stream configuration */
if (adap->dev->props.get_usb_stream_config) { if (adap->dev->props.get_usb_stream_config) {
ret = adap->dev->props.get_usb_stream_config( ret = adap->dev->props.get_usb_stream_config(
adap->fe_adap[adap->active_fe].fe, adap->fe[adap->active_fe],
&stream_props); &stream_props);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -292,8 +292,8 @@ static int dvb_usb_fe_wakeup(struct dvb_frontend *fe) ...@@ -292,8 +292,8 @@ static int dvb_usb_fe_wakeup(struct dvb_frontend *fe)
dvb_usb_set_active_fe(fe, 1); dvb_usb_set_active_fe(fe, 1);
if (adap->fe_adap[fe->id].fe_init) if (adap->fe_init[fe->id])
adap->fe_adap[fe->id].fe_init(fe); adap->fe_init[fe->id](fe);
return 0; return 0;
} }
...@@ -302,8 +302,8 @@ static int dvb_usb_fe_sleep(struct dvb_frontend *fe) ...@@ -302,8 +302,8 @@ static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
{ {
struct dvb_usb_adapter *adap = fe->dvb->priv; struct dvb_usb_adapter *adap = fe->dvb->priv;
if (adap->fe_adap[fe->id].fe_sleep) if (adap->fe_sleep[fe->id])
adap->fe_adap[fe->id].fe_sleep(fe); adap->fe_sleep[fe->id](fe);
dvb_usb_set_active_fe(fe, 0); dvb_usb_set_active_fe(fe, 0);
...@@ -314,56 +314,66 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) ...@@ -314,56 +314,66 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
{ {
int ret, i; int ret, i;
/* register all given adapter frontends */ memset(adap->fe, 0, sizeof(adap->fe));
for (i = 0; i < adap->props.num_frontends; i++) {
if (adap->props.frontend_attach == NULL) { adap->active_fe = 0;
err("strange: '%s' #%d,%d " \
"doesn't want to attach a frontend.",
adap->dev->name, adap->id, i);
return 0; if (adap->props.frontend_attach == NULL) {
} err("strange: '%s' doesn't want to attach a frontend.",
adap->dev->name);
ret = 0;
goto err;
}
ret = adap->props.frontend_attach(adap); /* attach all given adapter frontends */
if (ret || adap->fe_adap[i].fe == NULL) { ret = adap->props.frontend_attach(adap);
/* only print error when there is no FE at all */ if (ret < 0)
if (i == 0) goto err;
err("no frontend was attached by '%s'",
adap->dev->name);
return 0; if (adap->fe[0] == NULL) {
} err("no frontend was attached by '%s'", adap->dev->name);
goto err;
}
for (i = 0; i < MAX_NO_OF_FE_PER_ADAP; i++) {
if (adap->fe[i] == NULL)
break;
adap->fe_adap[i].fe->id = i; adap->fe[i]->id = i;
/* re-assign sleep and wakeup functions */ /* re-assign sleep and wakeup functions */
adap->fe_adap[i].fe_init = adap->fe_adap[i].fe->ops.init; adap->fe_init[i] = adap->fe[i]->ops.init;
adap->fe_adap[i].fe->ops.init = dvb_usb_fe_wakeup; adap->fe[i]->ops.init = dvb_usb_fe_wakeup;
adap->fe_adap[i].fe_sleep = adap->fe_adap[i].fe->ops.sleep; adap->fe_sleep[i] = adap->fe[i]->ops.sleep;
adap->fe_adap[i].fe->ops.sleep = dvb_usb_fe_sleep; adap->fe[i]->ops.sleep = dvb_usb_fe_sleep;
if (dvb_register_frontend(&adap->dvb_adap, ret = dvb_register_frontend(&adap->dvb_adap, adap->fe[i]);
adap->fe_adap[i].fe)) { if (ret < 0) {
err("Frontend %d registration failed.", i); err("Frontend %d registration failed.", i);
dvb_frontend_detach(adap->fe_adap[i].fe); dvb_frontend_detach(adap->fe[i]);
adap->fe_adap[i].fe = NULL; adap->fe[i] = NULL;
/* In error case, do not try register more FEs, /* In error case, do not try register more FEs,
* still leaving already registered FEs alive. */ * still leaving already registered FEs alive. */
if (i == 0) if (i == 0)
return -ENODEV; goto err;
else else
return 0; break;
} }
/* only attach the tuner if the demod is there */
if (adap->props.tuner_attach != NULL)
adap->props.tuner_attach(adap);
adap->num_frontends_initialized++; adap->num_frontends_initialized++;
} }
/* attach all given adapter tuners */
if (adap->props.tuner_attach) {
ret = adap->props.tuner_attach(adap);
if (ret < 0)
err("tuner attach failed - will continue");
}
return 0; return 0;
err:
pr_debug("%s: failed=%d\n", __func__, ret);
return ret;
} }
int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap) int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap)
...@@ -372,9 +382,9 @@ int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap) ...@@ -372,9 +382,9 @@ int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap)
/* unregister all given adapter frontends */ /* unregister all given adapter frontends */
for (; i >= 0; i--) { for (; i >= 0; i--) {
if (adap->fe_adap[i].fe != NULL) { if (adap->fe[i] != NULL) {
dvb_unregister_frontend(adap->fe_adap[i].fe); dvb_unregister_frontend(adap->fe[i]);
dvb_frontend_detach(adap->fe_adap[i].fe); dvb_frontend_detach(adap->fe[i]);
} }
} }
adap->num_frontends_initialized = 0; adap->num_frontends_initialized = 0;
......
...@@ -104,7 +104,7 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) ...@@ -104,7 +104,7 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d)
return ret; return ret;
/* use exclusive FE lock if there is multiple shared FEs */ /* use exclusive FE lock if there is multiple shared FEs */
if (adap->fe_adap[1].fe) if (adap->fe[1])
adap->dvb_adap.mfe_shared = 1; adap->dvb_adap.mfe_shared = 1;
d->num_adapters_initialized++; d->num_adapters_initialized++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment