示例#1
0
static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
{
	int ret;

	if (adap->id == 1) {
		/* copy firmware to 2nd demodulator */
		if (af9015_config.dual_mode) {
			ret = af9015_copy_firmware(adap->dev);
			if (ret) {
				err("firmware copy to 2nd frontend " \
					"failed, will disable it");
				af9015_config.dual_mode = 0;
				return -ENODEV;
			}
		} else {
			return -ENODEV;
		}
	}

	/* attach demodulator */
	adap->fe[0] = dvb_attach(af9013_attach, &af9015_af9013_config[adap->id],
		&adap->dev->i2c_adap);

	return adap->fe[0] == NULL ? -ENODEV : 0;
}
示例#2
0
static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
{
	int ret;
	struct af9015_state *state = adap->dev->priv;

	if (adap->id == 1) {
		/* copy firmware to 2nd demodulator */
		if (af9015_config.dual_mode) {
			ret = af9015_copy_firmware(adap->dev);
			if (ret) {
				err("firmware copy to 2nd frontend " \
					"failed, will disable it");
				af9015_config.dual_mode = 0;
				return -ENODEV;
			}
		} else {
			return -ENODEV;
		}
	}

	/* attach demodulator */
	adap->fe_adap[0].fe = dvb_attach(af9013_attach,
		&af9015_af9013_config[adap->id], &adap->dev->i2c_adap);

	/*
	 * AF9015 firmware does not like if it gets interrupted by I2C adapter
	 * request on some critical phases. During normal operation I2C adapter
	 * is used only 2nd demodulator and tuner on dual tuner devices.
	 * Override demodulator callbacks and use mutex for limit access to
	 * those "critical" paths to keep AF9015 happy.
	 * Note: we abuse unused usb_mutex here.
	 */
	if (adap->fe_adap[0].fe) {
		state->set_frontend[adap->id] =
			adap->fe_adap[0].fe->ops.set_frontend;
		adap->fe_adap[0].fe->ops.set_frontend =
			af9015_af9013_set_frontend;

		state->read_status[adap->id] =
			adap->fe_adap[0].fe->ops.read_status;
		adap->fe_adap[0].fe->ops.read_status =
			af9015_af9013_read_status;

		state->init[adap->id] = adap->fe_adap[0].fe->ops.init;
		adap->fe_adap[0].fe->ops.init = af9015_af9013_init;

		state->sleep[adap->id] = adap->fe_adap[0].fe->ops.sleep;
		adap->fe_adap[0].fe->ops.sleep = af9015_af9013_sleep;
	}

	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
}
示例#3
0
文件: af9015.c 项目: ChineseDr/linux
static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
{
    int ret;
    struct af9015_state *state = adap_to_priv(adap);

    if (adap->id == 0) {
        state->af9013_config[0].ts_mode = AF9013_TS_USB;
        memcpy(state->af9013_config[0].api_version, "\x0\x1\x9\x0", 4);
        state->af9013_config[0].gpio[0] = AF9013_GPIO_HI;
        state->af9013_config[0].gpio[3] = AF9013_GPIO_TUNER_ON;
    } else if (adap->id == 1) {
        state->af9013_config[1].ts_mode = AF9013_TS_SERIAL;
        memcpy(state->af9013_config[1].api_version, "\x0\x1\x9\x0", 4);
        state->af9013_config[1].gpio[0] = AF9013_GPIO_TUNER_ON;
        state->af9013_config[1].gpio[1] = AF9013_GPIO_LO;

        /* copy firmware to 2nd demodulator */
        if (state->dual_mode) {
            ret = af9015_copy_firmware(adap_to_d(adap));
            if (ret) {
                dev_err(&adap_to_d(adap)->udev->dev,
                        "%s: firmware copy to 2nd " \
                        "frontend failed, will " \
                        "disable it\n", KBUILD_MODNAME);
                state->dual_mode = 0;
                return -ENODEV;
            }
        } else {
            return -ENODEV;
        }
    }

    /* attach demodulator */
    adap->fe[0] = dvb_attach(af9013_attach,
                             &state->af9013_config[adap->id], &adap_to_d(adap)->i2c_adap);

    /*
     * AF9015 firmware does not like if it gets interrupted by I2C adapter
     * request on some critical phases. During normal operation I2C adapter
     * is used only 2nd demodulator and tuner on dual tuner devices.
     * Override demodulator callbacks and use mutex for limit access to
     * those "critical" paths to keep AF9015 happy.
     */
    if (adap->fe[0]) {
        state->set_frontend[adap->id] =
            adap->fe[0]->ops.set_frontend;
        adap->fe[0]->ops.set_frontend =
            af9015_af9013_set_frontend;

        state->read_status[adap->id] =
            adap->fe[0]->ops.read_status;
        adap->fe[0]->ops.read_status =
            af9015_af9013_read_status;

        state->init[adap->id] = adap->fe[0]->ops.init;
        adap->fe[0]->ops.init = af9015_af9013_init;

        state->sleep[adap->id] = adap->fe[0]->ops.sleep;
        adap->fe[0]->ops.sleep = af9015_af9013_sleep;
    }

    return adap->fe[0] == NULL ? -ENODEV : 0;
}