* pll_desc and pll_init_buf of struct dvb_usb_device).
* @stream: configuration of the USB streaming
*/
-struct dvb_usb_adapter_fe_properties {
- int size_of_priv;
-};
#define MAX_NO_OF_FE_PER_ADAP 3
struct dvb_usb_adapter_properties {
unsigned int, void *, unsigned int);
int num_frontends;
- struct dvb_usb_adapter_fe_properties fe[MAX_NO_OF_FE_PER_ADAP];
struct usb_data_stream_properties 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 {
#define DVB_USB_ADAP_STATE_INIT 0x000
#define DVB_USB_ADAP_STATE_DVB 0x001
struct dvb_demux demux;
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 num_frontends_initialized;
/* resolve TS configuration */
if (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);
if (ret < 0)
return ret;
/* resolve USB stream configuration */
if (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);
if (ret < 0)
return ret;
dvb_usb_set_active_fe(fe, 1);
- if (adap->fe_adap[fe->id].fe_init)
- adap->fe_adap[fe->id].fe_init(fe);
+ if (adap->fe_init[fe->id])
+ adap->fe_init[fe->id](fe);
return 0;
}
{
struct dvb_usb_adapter *adap = fe->dvb->priv;
- if (adap->fe_adap[fe->id].fe_sleep)
- adap->fe_adap[fe->id].fe_sleep(fe);
+ if (adap->fe_sleep[fe->id])
+ adap->fe_sleep[fe->id](fe);
dvb_usb_set_active_fe(fe, 0);
{
int ret, i;
- /* register all given adapter frontends */
- for (i = 0; i < adap->props.num_frontends; i++) {
+ memset(adap->fe, 0, sizeof(adap->fe));
- if (adap->props.frontend_attach == NULL) {
- err("strange: '%s' #%d,%d " \
- "doesn't want to attach a frontend.",
- adap->dev->name, adap->id, i);
+ adap->active_fe = 0;
- 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);
- if (ret || adap->fe_adap[i].fe == NULL) {
- /* only print error when there is no FE at all */
- if (i == 0)
- err("no frontend was attached by '%s'",
- adap->dev->name);
+ /* attach all given adapter frontends */
+ ret = adap->props.frontend_attach(adap);
+ if (ret < 0)
+ goto err;
- 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 */
- adap->fe_adap[i].fe_init = adap->fe_adap[i].fe->ops.init;
- adap->fe_adap[i].fe->ops.init = dvb_usb_fe_wakeup;
- adap->fe_adap[i].fe_sleep = adap->fe_adap[i].fe->ops.sleep;
- adap->fe_adap[i].fe->ops.sleep = dvb_usb_fe_sleep;
+ adap->fe_init[i] = adap->fe[i]->ops.init;
+ adap->fe[i]->ops.init = dvb_usb_fe_wakeup;
+ adap->fe_sleep[i] = adap->fe[i]->ops.sleep;
+ adap->fe[i]->ops.sleep = dvb_usb_fe_sleep;
- if (dvb_register_frontend(&adap->dvb_adap,
- adap->fe_adap[i].fe)) {
+ ret = dvb_register_frontend(&adap->dvb_adap, adap->fe[i]);
+ if (ret < 0) {
err("Frontend %d registration failed.", i);
- dvb_frontend_detach(adap->fe_adap[i].fe);
- adap->fe_adap[i].fe = NULL;
+ dvb_frontend_detach(adap->fe[i]);
+ adap->fe[i] = NULL;
/* In error case, do not try register more FEs,
* still leaving already registered FEs alive. */
if (i == 0)
- return -ENODEV;
+ goto err;
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++;
}
+ /* 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;
+err:
+ pr_debug("%s: failed=%d\n", __func__, ret);
+ return ret;
}
int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap)
/* unregister all given adapter frontends */
for (; i >= 0; i--) {
- if (adap->fe_adap[i].fe != NULL) {
- dvb_unregister_frontend(adap->fe_adap[i].fe);
- dvb_frontend_detach(adap->fe_adap[i].fe);
+ if (adap->fe[i] != NULL) {
+ dvb_unregister_frontend(adap->fe[i]);
+ dvb_frontend_detach(adap->fe[i]);
}
}
adap->num_frontends_initialized = 0;