static int anysee_read_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { u8 buf[] = {CMD_REG_READ, reg >> 8, reg & 0xff, 0x01}; int ret; ret = anysee_ctrl_msg(d, buf, sizeof(buf), val, 1); deb_info("%s: reg:%04x val:%02x\n", __func__, reg, *val); return ret; }
static int ec168_probe(struct usb_interface *intf, const struct usb_device_id *id) { int ret; deb_info("%s: interface:%d\n", __func__, intf->cur_altsetting->desc.bInterfaceNumber); ret = dvb_usb_device_init(intf, &ec168_properties, THIS_MODULE, NULL, adapter_nr); if (ret) goto error; return ret; error: deb_info("%s: failed:%d\n", __func__, ret); return ret; }
static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { struct dvb_usb_device *d = adap->dev; deb_info("%s: %s", __func__, onoff ? "enable" : "disable"); return az6007_write(d, 0xbc, onoff, 0, NULL, 0); }
/* Sleep adapter */ static int mtvhd_fe_sleep(struct dvb_frontend *fe) { struct mtvhd_fe_state *st = fe->demodulator_priv; deb_info("FE sleep\n"); return mtvhd_asie560x_power_ctrl(st->adap, 0); }
static int ec168_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { struct ec168_req req = {STREAMING_CTRL, 0x7f01, 0x0202, 0, NULL}; deb_info("%s: onoff:%d\n", __func__, onoff); if (onoff) req.index = 0x0102; return ec168_ctrl_msg(adap->dev, &req); }
static int lme2510_download_firmware(struct dvb_usb_device *d, const struct firmware *fw) { int ret = 0; u8 *data; u16 j, wlen, len_in, start, end; u8 packet_size, dlen, i; u8 *fw_data; packet_size = 0x31; len_in = 1; data = kzalloc(128, GFP_KERNEL); if (!data) { info("FRM Could not start Firmware Download"\ "(Buffer allocation failed)"); return -ENOMEM; } info("FRM Starting Firmware Download"); for (i = 1; i < 3; i++) { start = (i == 1) ? 0 : 512; end = (i == 1) ? 512 : fw->size; for (j = start; j < end; j += (packet_size+1)) { fw_data = (u8 *)(fw->data + j); if ((end - j) > packet_size) { data[0] = i; dlen = packet_size; } else { data[0] = i | 0x80; dlen = (u8)(end - j)-1; } data[1] = dlen; memcpy(&data[2], fw_data, dlen+1); wlen = (u8) dlen + 4; data[wlen-1] = check_sum(fw_data, dlen+1); deb_info(1, "Data S=%02x:E=%02x CS= %02x", data[3], data[dlen+2], data[dlen+3]); lme2510_usb_talk(d, data, wlen, data, len_in); ret |= (data[0] == 0x88) ? 0 : -1; } } data[0] = 0x8a; len_in = 1; msleep(2000); lme2510_usb_talk(d, data, len_in, data, len_in); msleep(400); if (ret < 0) info("FRM Firmware Download Failed (%04x)" , ret); else info("FRM Firmware Download Completed - Resetting Device"); kfree(data); return RECONNECTS_USB; }
static int lme2510_download_firmware(struct usb_device *dev, const struct firmware *fw) { int ret = 0; u8 data[512] = {0}; u16 j, wlen, len_in, start, end; u8 packet_size, dlen, i; u8 *fw_data; packet_size = 0x31; len_in = 1; info("FRM Starting Firmware Download"); for (i = 1; i < 3; i++) { start = (i == 1) ? 0 : 512; end = (i == 1) ? 512 : fw->size; for (j = start; j < end; j += (packet_size+1)) { fw_data = (u8 *)(fw->data + j); if ((end - j) > packet_size) { data[0] = i; dlen = packet_size; } else { data[0] = i | 0x80; dlen = (u8)(end - j)-1; } data[1] = dlen; memcpy(&data[2], fw_data, dlen+1); wlen = (u8) dlen + 4; data[wlen-1] = check_sum(fw_data, dlen+1); deb_info(1, "Data S=%02x:E=%02x CS= %02x", data[3], data[dlen+2], data[dlen+3]); ret |= lme2510_bulk_write(dev, data, wlen, 1); ret |= lme2510_bulk_read(dev, data, len_in , 1); ret |= (data[0] == 0x88) ? 0 : -1; } } usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x06, 0x80, 0x0200, 0x00, data, 0x0109, 1000); data[0] = 0x8a; len_in = 1; msleep(2000); ret |= lme2510_bulk_write(dev, data , len_in, 1); /*Resetting*/ ret |= lme2510_bulk_read(dev, data, len_in, 1); msleep(400); if (ret < 0) info("FRM Firmware Download Failed (%04x)" , ret); else info("FRM Firmware Download Completed - Resetting Device"); return (ret < 0) ? -ENODEV : 0; }
int get_rtl2832_ioctrl_8bit_demodbytes( struct dvb_frontend *fe, unsigned char page, unsigned char reg_addr, unsigned char* data, unsigned short bytelength) { int ret = -1; int i=0; struct rtl2832_state* p_state = fe->demodulator_priv; unsigned char data_temp[128]; DVBT_NIM_MODULE *pNim; DVBT_DEMOD_MODULE *pDemod; deb_info("+%s: page= %d reg_addr=0x%x bytelength=%d \n", __FUNCTION__,page, reg_addr,bytelength); if (bytelength > 128 ) { deb_info("ERROR::bytelength > 128\n"); return -1; } if (p_state->demod_type != RTL2832) { deb_info("ERROR::demod type not rtl2832u...\n"); return -1; } pNim = p_state->pNim; if (pNim == NULL) { return -1; } if( mutex_lock_interruptible(&p_state->i2c_repeater_mutex) ) { return -1; } pDemod=pNim->pDemod; if(pDemod->SetRegPage(pDemod, page) != FUNCTION_SUCCESS) { ret=-1; goto error; } if(pDemod->GetRegBytes(pDemod, reg_addr, data_temp, bytelength) != FUNCTION_SUCCESS) { ret=-1; goto error; } deb_info("->%s: data[%d,%x]= \n", __FUNCTION__,page, reg_addr); for (i=0; i<bytelength; i++) { data[i]=data_temp[i]; deb_info("%x(%x),",data[i],data_temp[i]); } deb_info("\n"); ret=0; error: mutex_unlock(&p_state->i2c_repeater_mutex); deb_info("-%s: page=%d reg_addr=0x%x bytelength=%d \n", __FUNCTION__,page, reg_addr,bytelength); return ret; }
static int friio_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { int ret; deb_info("%s called.(%d)\n", __func__, onoff); /* set the LED color and saturation (and LNB on) */ if (onoff) ret = friio_ext_ctl(adap, 0x6400ff64, 1); else ret = friio_ext_ctl(adap, 0x96ff00ff, 1); if (ret != 1) { deb_info("%s failed to send cmdx. ret==%d\n", __func__, ret); return -EREMOTEIO; } return 0; }
static int lme2510_frontend_attach(struct dvb_usb_adapter *adap) { // struct dvb_usb_device *d = i2c_get_adapdata(adap); u8 obuf[0x40] = { 0x06, 0x00, 0xcf, 0xba, 0xd0 }; u8 ibuf[] = { 0 }; // u8 obuf[0x40], ibuf[0x40]; // int actlen, ret; if (lme2510_generic_rw(adap->dev, obuf, 5, ibuf, 1, 0) < 0) { err("command transfer failed."); } obuf[0] = 0x04; obuf[1] = 0x03; obuf[2] = 0x1c; obuf[3] = 0x00; obuf[4] = 0x11; if (lme2510_generic_rw(adap->dev, obuf, 0x40, ibuf, 1, 0) < 0) err("frontend transfer failed."); obuf[0] = 0x04; obuf[1] = 0x0c; obuf[2] = 0xc0; obuf[3] = 0x00; obuf[4] = 0x01; obuf[5] = 0x26; obuf[6] = 0x08; obuf[7] = 0x9a; obuf[8] = 0xf8; obuf[9] = 0x0e; obuf[10] = 0x83; obuf[11] = 0x80; obuf[12] = 0x1a; obuf[13] = 0xd4; obuf[14] = 0xff; if (lme2510_generic_rw(adap->dev, obuf, 0x40, ibuf, 1, 0) < 0) err("tuner transfer failed."); obuf[0] = 0x04; obuf[1] = 0x03; obuf[2] = 0x1c; obuf[3] = 0x00; obuf[4] = 0x01; if (lme2510_generic_rw(adap->dev, obuf, 0x40, ibuf, 1, 0) < 0) err("frontend transfer failed."); if ((adap->fe = dvb_attach(tda10086_attach, &tda10086_config, &adap->dev->i2c_adap)) == NULL) { deb_info("TDA10086 attach failed\n"); return -ENODEV; } return 0; }
static int mtvhd_fe_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { deb_info("FE read signal strength: "); *strength = 0; /* FIXME: tentatively return S/N */ return mtvhd_fe_read_snr(fe, strength); }
/* Initialize ASIE560x */ static int mtvhd_asie560x_init(struct dvb_usb_adapter *adap) { struct mtvhd_adapter_state *st = adap->priv; int ret; u8 reg, crypto_mode; /* ASIE560x Power On */ ret = mtvhd_asie560x_power_ctrl(adap, 1); if (ret != 0) { err("ASIE560x power on failed: %d", ret); return ret; } deb_info("ASIE560x[%d] init\n", adap->id); /* Probe ASIE560x and set crypto mode */ crypto_mode = 0; ret = mtvhd_asie560x_probe(adap, 0x09); if (ret < 0) { err("ASIE560x probe failed: %d", ret); return ret; } switch (ret & 0x07) { case 0x04: crypto_mode = MTVHD_CRYPTO_XOR; break; case 0x06: crypto_mode = MTVHD_CRYPTO_DES; break; default: err("Unknown crypto mode - ASIE560x reg 9: %02x", ret); } ret = mtvhd_crypto_init(st, crypto_mode); if (ret != 0) { err("Failed to initialize crypto library (%02x): %d", crypto_mode, ret); /* continue without decryption */ } ret = mtvhd_asie560x_reg_write(adap, 0x05, crypto_mode); if (ret != 0) { err("ASIE560x crypto mode setting failed: %d", ret); return ret; } /* Set crypto key on ASIE5606 (all 0) */ for (reg = 0x10; reg < 0x20; reg++) { ret = mtvhd_asie560x_reg_write(adap, reg, 0x00); if (ret != 0) { err("ASIE560x crypto key setting failed: %d", ret); return ret; } } return ret; }
static int mxl111sf_adap_fe_init(struct dvb_frontend *fe) { struct dvb_usb_device *d = fe_to_d(fe); struct mxl111sf_state *state = fe_to_priv(fe); struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id]; int err; /* exit if we didnt initialize the driver yet */ if (!state->chip_id) { mxl_debug("driver not yet initialized, exit."); goto fail; } deb_info("%s()\n", __func__); mutex_lock(&state->fe_lock); state->alt_mode = adap_state->alt_mode; if (usb_set_interface(d->udev, 0, state->alt_mode) < 0) err("set interface failed"); err = mxl1x1sf_soft_reset(state); mxl_fail(err); err = mxl111sf_init_tuner_demod(state); mxl_fail(err); err = mxl1x1sf_set_device_mode(state, adap_state->device_mode); mxl_fail(err); mxl111sf_enable_usb_output(state); mxl_fail(err); mxl1x1sf_top_master_ctrl(state, 1); mxl_fail(err); if ((MXL111SF_GPIO_MOD_DVBT != adap_state->gpio_mode) && (state->chip_rev > MXL111SF_V6)) { mxl111sf_config_pin_mux_modes(state, PIN_MUX_TS_SPI_IN_MODE_1); mxl_fail(err); } err = mxl111sf_init_port_expander(state); if (!mxl_fail(err)) { state->gpio_mode = adap_state->gpio_mode; err = mxl111sf_gpio_mode_switch(state, state->gpio_mode); mxl_fail(err); #if 0 err = fe->ops.init(fe); #endif msleep(100); /* add short delay after enabling * the demod before touching it */ } return (adap_state->fe_init) ? adap_state->fe_init(fe) : 0; fail: return -ENODEV; }
static int ttusb2_frontend_tda10023_attach(struct dvb_usb_adapter *adap) { if (usb_set_interface(adap->dev->udev, 0, 3) < 0) err("set interface to alts=3 failed"); if ((adap->fe = dvb_attach(tda10023_attach, &tda10023_config, &adap->dev->i2c_adap, 0x48)) == NULL) { deb_info("TDA10023 attach failed\n"); return -ENODEV; } return 0; }
static void mtvhd_fe_release(struct dvb_frontend* fe) { struct mtvhd_fe_state *st = fe->demodulator_priv; deb_info("FE release\n"); mtvhd_crypto_release(st->adap->priv); kfree(fe->demodulator_priv); fe->demodulator_priv = NULL; }
static int mtvhd_fe_get_property(struct dvb_frontend* fe, struct dtv_property *tvp) { deb_info("FE get property (cmd = %x)\n", tvp->cmd); /* for recovery from DTV_CLEAR */ fe->dtv_property_cache.delivery_system = SYS_ISDBT; return 0; }
/* module stuff */ static int __init ec168_module_init(void) { int ret; deb_info("%s:\n", __func__); ret = usb_register(&ec168_driver); if (ret) err("module init failed:%d", ret); return ret; }
static int ec168_ec100_frontend_attach(struct dvb_usb_adapter *adap) { deb_info("%s:\n", __func__); adap->fe_adap[0].fe = dvb_attach(ec100_attach, &ec168_ec100_config, &adap->dev->i2c_adap); if (adap->fe_adap[0].fe == NULL) return -ENODEV; return 0; }
static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) { int ret; struct rtl28xxu_priv *priv = adap->dev->priv; struct dvb_frontend *fe; deb_info("%s:\n", __func__); switch (priv->tuner) { case TUNER_RTL2832_FC0012: fe = dvb_attach(fc0012_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); /* since fc0012 includs reading the signal strength delegate * that to the tuner driver */ adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0]. fe->ops.tuner_ops.get_rf_strength; return 0; break; case TUNER_RTL2832_FC0013: fe = dvb_attach(fc0013_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); /* fc0013 also supports signal strength reading */ adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0] .fe->ops.tuner_ops.get_rf_strength; return 0; default: fe = NULL; err("unknown tuner=%d", priv->tuner); } if (fe == NULL) { ret = -ENODEV; goto err; } return 0; err: deb_info("%s: failed=%d\n", __func__, ret); return ret; }
static int flexcop_dma_remap(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, int onoff) { flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c; flexcop_ibi_value v = fc->read_ibi_reg(fc,r); deb_info("%s\n",__func__); v.dma_0xc.remap_enable = onoff; fc->write_ibi_reg(fc,r,v); return 0; }
static int lme2510_remote_keypress(struct dvb_usb_adapter *adap, u32 keypress) { struct dvb_usb_device *d = adap->dev; deb_info(1, "INT Key Keypress =%04x", keypress); if (keypress > 0) rc_keydown(d->rc_dev, keypress, 0); return 0; }
static int rtl28xxu_probe(struct usb_interface *intf, const struct usb_device_id *id) { int ret, i; int properties_count = ARRAY_SIZE(rtl28xxu_properties); struct dvb_usb_device *d; deb_info("%s: interface=%d\n", __func__, intf->cur_altsetting->desc.bInterfaceNumber); if (intf->cur_altsetting->desc.bInterfaceNumber != 0) return 0; for (i = 0; i < properties_count; i++) { ret = dvb_usb_device_init(intf, &rtl28xxu_properties[i], THIS_MODULE, &d, adapter_nr); if (ret == 0 || ret != -ENODEV) break; } if (ret) goto err; ret = rtl2831_wr_reg(d, USB_SYSCTL_0, 0x09); if (ret) goto err; ret = rtl2831_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); if (ret) goto err; ret = rtl2831_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); if (ret) goto err; return ret; err: deb_info("%s: failed=%d\n", __func__, ret); return ret; }
static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap) { int ret; struct rtl28xxu_priv *priv = adap->dev->priv; struct i2c_adapter *rtl2830_tuner_i2c; struct dvb_frontend *fe; deb_info("%s:\n", __func__); /* use rtl2830 driver I2C adapter, for more info see rtl2830 driver */ rtl2830_tuner_i2c = rtl2830_get_tuner_i2c_adapter(adap->fe_adap[0].fe); switch (priv->tuner) { case TUNER_RTL2830_QT1010: fe = dvb_attach(qt1010_attach, adap->fe_adap[0].fe, rtl2830_tuner_i2c, &rtl28xxu_qt1010_config); break; case TUNER_RTL2830_MT2060: fe = dvb_attach(mt2060_attach, adap->fe_adap[0].fe, rtl2830_tuner_i2c, &rtl28xxu_mt2060_config, 1220); break; case TUNER_RTL2830_MXL5005S: fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config); break; default: fe = NULL; err("unknown tuner=%d", priv->tuner); } if (fe == NULL) { ret = -ENODEV; goto err; } return 0; err: deb_info("%s: failed=%d\n", __func__, ret); return ret; }
static int mxl111sf_streaming_ctrl_mercury_mh(struct dvb_frontend *fe, int onoff) { deb_info("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); if (fe->id == 0) return mxl111sf_ep4_streaming_ctrl(fe, onoff); else if (fe->id == 1 && dvb_usb_mxl111sf_spi) return mxl111sf_ep5_streaming_ctrl(fe, onoff); else if (fe->id == 1 && !dvb_usb_mxl111sf_spi) return mxl111sf_ep6_streaming_ctrl(fe, onoff); return 0; }
/* mh lg2160 * bulk EP5/BULK/5/8192/RAW * isoc EP5/ISOC/5/96/200/RAW */ static int mxl111sf_get_stream_config_mh(struct dvb_frontend *fe, u8 *ts_type, struct usb_data_stream_properties *stream) { deb_info("%s: fe=%d\n", __func__, fe->id); *ts_type = DVB_USB_FE_TS_TYPE_RAW; if (dvb_usb_mxl111sf_isoc) mxl111sf_stream_config_isoc(stream, 5, 96, 200); else mxl111sf_stream_config_bulk(stream, 5); return 0; }
static void mxl111sf_stream_config_isoc(struct usb_data_stream_properties *stream, u8 endpoint, int framesperurb, int framesize) { deb_info("%s: endpoint=%d size=%d\n", __func__, endpoint, framesperurb * framesize); stream->type = USB_ISOC; stream->count = 5; stream->endpoint = endpoint; stream->u.isoc.framesperurb = framesperurb; stream->u.isoc.framesize = framesize; stream->u.isoc.interval = 1; }
static int af9015_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) { int ret; deb_info("%s: onoff:%d\n", __func__, onoff); if (onoff) ret = af9015_set_reg_bit(adap->dev, 0xd503, 0); else ret = af9015_clear_reg_bit(adap->dev, 0xd503, 0); return ret; }
/* module stuff */ static int __init rtl28xxu_module_init(void) { int ret; deb_info("%s:\n", __func__); ret = usb_register(&rtl28xxu_driver); if (ret) err("usb_register failed=%d", ret); return ret; }
int dibusb_urb_kill(struct usb_dibusb *dib) { int i; deb_info("trying to kill urbs\n"); if (dib->init_state & DIBUSB_STATE_URB_SUBMIT) { for (i = 0; i < dib->dibdev->dev_cl->urb_count; i++) { deb_info("killing URB no. %d.\n",i); /* stop the URB */ usb_kill_urb(dib->urb_list[i]); } } else deb_info(" URBs not killed.\n"); dib->init_state &= ~DIBUSB_STATE_URB_SUBMIT; return 0; }
static int __init rtl2832u_usb_module_init(void) { int result =0 ; deb_info("+info debug open_%s\n", __FUNCTION__); if ((result = usb_register(&rtl2832u_usb_driver))) { err("usb_register failed. (%d)",result); return result; } return 0; }