• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/media/dvb/ttusb-budget/

Lines Matching defs:ttusb

80  *  since we're casting (struct ttusb*) <-> (struct dvb_demux*) around
83 struct ttusb {
137 static int ttusb_cmd(struct ttusb *ttusb,
151 if (mutex_lock_interruptible(&ttusb->semusb) < 0)
154 err = usb_bulk_msg(ttusb->dev, ttusb->bulk_out_pipe,
159 mutex_unlock(&ttusb->semusb);
165 mutex_unlock(&ttusb->semusb);
169 err = usb_bulk_msg(ttusb->dev, ttusb->bulk_in_pipe,
170 ttusb->last_result, 32, &actual_len, 1000);
175 mutex_unlock(&ttusb->semusb);
179 actual_len = ttusb->last_result[3] + 4;
182 printk(" %02x", ttusb->last_result[i]);
186 mutex_unlock(&ttusb->semusb);
190 static int ttusb_result(struct ttusb *ttusb, u8 * data, int len)
192 memcpy(data, ttusb->last_result, len);
193 mutex_unlock(&ttusb->semusb);
197 static int ttusb_i2c_msg(struct ttusb *ttusb,
202 u8 id = ++ttusb->c;
219 err = ttusb_cmd(ttusb, b, snd_len + 7, 1);
224 err = ttusb_result(ttusb, b, 0x20);
247 struct ttusb *ttusb = i2c_get_adapdata(adapter);
251 if (mutex_lock_interruptible(&ttusb->semi2c) < 0)
274 err = ttusb_i2c_msg(ttusb, addr,
285 mutex_unlock(&ttusb->semi2c);
289 static int ttusb_boot_dsp(struct ttusb *ttusb)
295 err = request_firmware(&fw, "ttusb-budget/dspbootcode.bin",
296 &ttusb->dev->dev);
298 printk(KERN_ERR "ttusb-budget: failed to request firmware\n");
312 b[1] = ++ttusb->c;
314 err = ttusb_cmd(ttusb, b, 32, 0);
320 b[1] = ++ttusb->c;
324 err = ttusb_cmd(ttusb, b, 4, 0);
329 b[1] = ++ttusb->c;
333 err = ttusb_cmd(ttusb, b, 4, 0);
344 static int ttusb_set_channel(struct ttusb *ttusb, int chan_id, int filter_type,
349 u8 b[] = { 0xaa, ++ttusb->c, 0x22, 4, chan_id, filter_type,
353 err = ttusb_cmd(ttusb, b, sizeof(b), 0);
357 static int ttusb_del_channel(struct ttusb *ttusb, int channel_id)
361 u8 b[] = { 0xaa, ++ttusb->c, 0x23, 1, channel_id };
363 err = ttusb_cmd(ttusb, b, sizeof(b), 0);
368 static int ttusb_set_filter(struct ttusb *ttusb, int filter_id,
382 err = ttusb_cmd(ttusb, b, sizeof(b), 0);
386 static int ttusb_del_filter(struct ttusb *ttusb, int filter_id)
390 u8 b[] = { 0xaa, ++ttusb->c, 0x25, 1, filter_id };
392 err = ttusb_cmd(ttusb, b, sizeof(b), 0);
397 static int ttusb_init_controller(struct ttusb *ttusb)
399 u8 b0[] = { 0xaa, ++ttusb->c, 0x15, 1, 0 };
400 u8 b1[] = { 0xaa, ++ttusb->c, 0x15, 1, 1 };
401 u8 b2[] = { 0xaa, ++ttusb->c, 0x32, 1, 0 };
404 { 0xaa, ++ttusb->c, 0x31, 5, 0x10, 0x02, 0x01, 0x00, 0x1e };
406 { 0x55, ttusb->c, 0x31, 4, 0x10, 0x02, 0x01, 0x00, 0x1e };
408 u8 get_version[] = { 0xaa, ++ttusb->c, 0x17, 5, 0, 0, 0, 0, 0 };
410 { 0xaa, ++ttusb->c, 0x26, 28, 0, 0, 0, 0, 0 };
414 if ((err = ttusb_cmd(ttusb, b0, sizeof(b0), 0)))
418 if ((err = ttusb_cmd(ttusb, b1, sizeof(b1), 0)))
421 ttusb_boot_dsp(ttusb);
424 if ((err = ttusb_cmd(ttusb, b2, sizeof(b2), 0)))
427 if ((err = ttusb_cmd(ttusb, b3, sizeof(b3), 1)))
430 err = ttusb_result(ttusb, b4, sizeof(b4));
432 if ((err = ttusb_cmd(ttusb, get_version, sizeof(get_version), 1)))
435 if ((err = ttusb_result(ttusb, get_version, sizeof(get_version))))
452 ttusb->revision = ((get_version[6] - '0') << 4) |
456 ttusb_cmd(ttusb, get_dsp_version, sizeof(get_dsp_version), 1);
461 ttusb_result(ttusb, get_dsp_version, sizeof(get_dsp_version));
473 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
474 u8 b[12] = { 0xaa, ++ttusb->c, 0x18 };
485 if ((err = ttusb_cmd(ttusb, b, 4 + b[3], 0))) {
494 static int ttusb_update_lnb(struct ttusb *ttusb)
496 u8 b[] = { 0xaa, ++ttusb->c, 0x16, 5, /*power: */ 1,
497 ttusb->voltage == SEC_VOLTAGE_18 ? 0 : 1,
498 ttusb->tone == SEC_TONE_ON ? 1 : 0, 1, 1
503 if ((err = ttusb_cmd(ttusb, b, sizeof(b), 0))) {
513 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
515 ttusb->voltage = voltage;
516 return ttusb_update_lnb(ttusb);
522 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
524 ttusb->tone = tone;
525 return ttusb_update_lnb(ttusb);
543 static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
559 if ((cc != ttusb->cc) && (ttusb->cc != -1))
561 __func__, (cc - ttusb->cc) & 0x7FFF);
562 ttusb->cc = (cc + 1) & 0x7FFF;
574 ttusb_handle_sec_data(ttusb->channel + channel, data,
578 if ((!!(ttusb->muxpack[0] & 0x20)) ^
579 !!(ttusb->muxpack[1] & 1))
591 if (ttusb->channel[channel].active
592 && (pid == ttusb->channel[channel].pid))
593 ttusb_handle_ts_data(ttusb->channel +
598 dvb_dmx_swfilter_packets(&ttusb->dvb_demux, muxpack, 1);
606 static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len)
615 switch (ttusb->mux_state) {
621 ++ttusb->mux_state;
623 ttusb->mux_state = 0;
625 if (ttusb->insync)
628 if (ttusb->insync) {
631 ttusb->insync = 0;
637 ttusb->insync = 1;
639 ttusb->mux_npacks = *data++;
640 ++ttusb->mux_state;
641 ttusb->muxpack_ptr = 0;
643 ttusb->muxpack_len = 2;
650 (ttusb->muxpack_len -
651 ttusb->muxpack_ptr))
653 ttusb->muxpack_len -
654 ttusb->muxpack_ptr;
655 memcpy(ttusb->muxpack + ttusb->muxpack_ptr,
657 ttusb->muxpack_ptr += avail;
658 BUG_ON(ttusb->muxpack_ptr > 264);
662 if (ttusb->muxpack_ptr == 2) {
663 if (ttusb->muxpack[0] & 0x80) {
664 ttusb->muxpack_len =
665 ttusb->muxpack[1] + 2;
666 if (ttusb->
668 ttusb->
671 (ttusb->
673 !!(ttusb->
675 ttusb->
677 ttusb->muxpack_len += 4;
678 } else if (ttusb->muxpack[0] ==
680 ttusb->muxpack_len =
682 else if (ttusb->muxpack[0] == 0x00)
683 ttusb->muxpack_len =
684 ttusb->muxpack[1] + 2 +
690 ttusb->muxpack[0]);
691 ttusb->mux_state = 0;
699 if ((ttusb->muxpack_ptr >= 2) &&
700 (ttusb->muxpack_ptr ==
701 ttusb->muxpack_len)) {
702 ttusb_process_muxpack(ttusb,
703 ttusb->
705 ttusb->
707 ttusb->muxpack_ptr = 0;
709 ttusb->muxpack_len = 2;
715 if (!ttusb->mux_npacks--) {
716 ttusb->mux_state = 0;
731 struct ttusb *ttusb = urb->context;
733 if (!ttusb->iso_streaming)
762 ttusb_process_frame(ttusb, data, len);
768 static void ttusb_free_iso_urbs(struct ttusb *ttusb)
773 if (ttusb->iso_urb[i])
774 usb_free_urb(ttusb->iso_urb[i]);
778 ISO_BUF_COUNT, ttusb->iso_buffer,
779 ttusb->iso_dma_handle);
782 static int ttusb_alloc_iso_urbs(struct ttusb *ttusb)
786 ttusb->iso_buffer = pci_alloc_consistent(NULL,
790 &ttusb->iso_dma_handle);
792 if (!ttusb->iso_buffer) {
798 memset(ttusb->iso_buffer, 0,
807 ttusb_free_iso_urbs(ttusb);
811 ttusb->iso_urb[i] = urb;
817 static void ttusb_stop_iso_xfer(struct ttusb *ttusb)
822 usb_kill_urb(ttusb->iso_urb[i]);
824 ttusb->iso_streaming = 0;
827 static int ttusb_start_iso_xfer(struct ttusb *ttusb)
831 if (ttusb->iso_streaming) {
836 ttusb->cc = -1;
837 ttusb->insync = 0;
838 ttusb->mux_state = 0;
842 struct urb *urb = ttusb->iso_urb[i];
844 urb->dev = ttusb->dev;
845 urb->context = ttusb;
847 urb->pipe = ttusb->isoc_in_pipe;
853 urb->transfer_buffer = ttusb->iso_buffer + buffer_offset;
864 if ((err = usb_submit_urb(ttusb->iso_urb[i], GFP_ATOMIC))) {
865 ttusb_stop_iso_xfer(ttusb);
873 ttusb->iso_streaming = 1;
896 struct ttusb *ttusb = (struct ttusb *) dvbdmxfeed->demux;
932 ttusb_set_channel(ttusb, dvbdmxfeed->index, feed_type, dvbdmxfeed->pid);
934 if (0 == ttusb->running_feed_count++)
935 ttusb_start_iso_xfer(ttusb);
942 struct ttusb *ttusb = (struct ttusb *) dvbdmxfeed->demux;
944 ttusb_del_channel(ttusb, dvbdmxfeed->index);
946 if (--ttusb->running_feed_count == 0)
947 ttusb_stop_iso_xfer(ttusb);
952 static int ttusb_setup_interfaces(struct ttusb *ttusb)
954 usb_set_interface(ttusb->dev, 1, 1);
956 ttusb->bulk_out_pipe = usb_sndbulkpipe(ttusb->dev, 1);
957 ttusb->bulk_in_pipe = usb_rcvbulkpipe(ttusb->dev, 1);
958 ttusb->isoc_in_pipe = usb_rcvisocpipe(ttusb->dev, 2);
973 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
987 if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) return -EIO;
1001 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1009 if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) return -EIO;
1018 if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
1019 i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1);
1027 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1087 if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1)
1096 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1098 return request_firmware(fw, name, &ttusb->dev->dev);
1229 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1247 if (ttusb->revision == TTUSB_REV_2_2)
1252 if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1)
1272 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1286 if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1)
1299 struct ttusb* ttusb = fe->dvb->priv;
1313 if (i2c_transfer (&ttusb->i2c_adap, &msg, 1) != 1)
1327 static u8 read_pwm(struct ttusb* ttusb)
1334 if ((i2c_transfer(&ttusb->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
1343 struct ttusb *ttusb = (struct ttusb *) fe->dvb->priv;
1382 if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
1383 printk("dvb-ttusb-budget: dvbc_philips_tdm1316l_pll_set Error 1\n");
1391 if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
1392 printk("dvb-ttusb-budget: dvbc_philips_tdm1316l_pll_set Error 2\n");
1509 static void frontend_init(struct ttusb* ttusb)
1511 switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) {
1514 ttusb->fe = dvb_attach(stv0299_attach, &alps_stv0299_config, &ttusb->i2c_adap);
1515 if (ttusb->fe != NULL) {
1516 ttusb->fe->ops.tuner_ops.set_params = philips_tsa5059_tuner_set_params;
1518 if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1
1520 dvb_attach(lnbp21_attach, ttusb->fe, &ttusb->i2c_adap, 0, 0);
1522 ttusb->fe->ops.set_voltage = ttusb_set_voltage;
1528 ttusb->fe = dvb_attach(tda8083_attach, &ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap);
1529 if (ttusb->fe != NULL) {
1530 ttusb->fe->ops.tuner_ops.set_params = ttusb_novas_grundig_29504_491_tuner_set_params;
1531 ttusb->fe->ops.set_voltage = ttusb_set_voltage;
1537 ttusb->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb));
1538 if (ttusb->fe != NULL) {
1539 ttusb->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
1543 ttusb->fe = dvb_attach(stv0297_attach, &dvbc_philips_tdm1316l_config, &ttusb->i2c_adap);
1544 if (ttusb->fe != NULL) {
1545 ttusb->fe->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
1552 ttusb->fe = dvb_attach(cx22700_attach, &alps_tdmb7_config, &ttusb->i2c_adap);
1553 if (ttusb->fe != NULL) {
1554 ttusb->fe->ops.tuner_ops.set_params = alps_tdmb7_tuner_set_params;
1559 ttusb->fe = dvb_attach(tda10046_attach, &philips_tdm1316l_config, &ttusb->i2c_adap);
1560 if (ttusb->fe != NULL) {
1561 ttusb->fe->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
1562 ttusb->fe->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
1568 if (ttusb->fe == NULL) {
1569 printk("dvb-ttusb-budget: A frontend driver was not found for device [%04x:%04x]\n",
1570 le16_to_cpu(ttusb->dev->descriptor.idVendor),
1571 le16_to_cpu(ttusb->dev->descriptor.idProduct));
1573 if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) {
1574 printk("dvb-ttusb-budget: Frontend registration failed!\n");
1575 dvb_frontend_detach(ttusb->fe);
1576 ttusb->fe = NULL;
1591 struct ttusb *ttusb;
1600 if (!(ttusb = kzalloc(sizeof(struct ttusb), GFP_KERNEL)))
1603 ttusb->dev = udev;
1604 ttusb->c = 0;
1605 ttusb->mux_state = 0;
1606 mutex_init(&ttusb->semi2c);
1608 mutex_lock(&ttusb->semi2c);
1610 mutex_init(&ttusb->semusb);
1612 ttusb_setup_interfaces(ttusb);
1614 result = ttusb_alloc_iso_urbs(ttusb);
1617 mutex_unlock(&ttusb->semi2c);
1618 kfree(ttusb);
1622 if (ttusb_init_controller(ttusb))
1625 mutex_unlock(&ttusb->semi2c);
1627 result = dvb_register_adapter(&ttusb->adapter,
1631 ttusb_free_iso_urbs(ttusb);
1632 kfree(ttusb);
1635 ttusb->adapter.priv = ttusb;
1638 memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter));
1639 strcpy(ttusb->i2c_adap.name, "TTUSB DEC");
1641 i2c_set_adapdata(&ttusb->i2c_adap, ttusb);
1643 ttusb->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
1644 ttusb->i2c_adap.algo = &ttusb_dec_algo;
1645 ttusb->i2c_adap.algo_data = NULL;
1646 ttusb->i2c_adap.dev.parent = &udev->dev;
1648 result = i2c_add_adapter(&ttusb->i2c_adap);
1650 dvb_unregister_adapter (&ttusb->adapter);
1654 memset(&ttusb->dvb_demux, 0, sizeof(ttusb->dvb_demux));
1656 ttusb->dvb_demux.dmx.capabilities =
1658 ttusb->dvb_demux.priv = NULL;
1660 ttusb->dvb_demux.filternum = TTUSB_MAXFILTER;
1662 ttusb->dvb_demux.filternum = 32;
1664 ttusb->dvb_demux.feednum = TTUSB_MAXCHANNEL;
1665 ttusb->dvb_demux.start_feed = ttusb_start_feed;
1666 ttusb->dvb_demux.stop_feed = ttusb_stop_feed;
1667 ttusb->dvb_demux.write_to_decoder = NULL;
1669 if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) {
1671 i2c_del_adapter(&ttusb->i2c_adap);
1672 dvb_unregister_adapter (&ttusb->adapter);
1675 ttusb->dmxdev.filternum = ttusb->dvb_demux.filternum;
1676 ttusb->dmxdev.demux = &ttusb->dvb_demux.dmx;
1677 ttusb->dmxdev.capabilities = 0;
1679 if ((result = dvb_dmxdev_init(&ttusb->dmxdev, &ttusb->adapter)) < 0) {
1682 dvb_dmx_release(&ttusb->dvb_demux);
1683 i2c_del_adapter(&ttusb->i2c_adap);
1684 dvb_unregister_adapter (&ttusb->adapter);
1688 if (dvb_net_init(&ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
1690 dvb_dmxdev_release(&ttusb->dmxdev);
1691 dvb_dmx_release(&ttusb->dvb_demux);
1692 i2c_del_adapter(&ttusb->i2c_adap);
1693 dvb_unregister_adapter (&ttusb->adapter);
1697 usb_set_intfdata(intf, (void *) ttusb);
1699 frontend_init(ttusb);
1706 struct ttusb *ttusb = usb_get_intfdata(intf);
1710 ttusb->disconnecting = 1;
1712 ttusb_stop_iso_xfer(ttusb);
1714 ttusb->dvb_demux.dmx.close(&ttusb->dvb_demux.dmx);
1715 dvb_net_release(&ttusb->dvbnet);
1716 dvb_dmxdev_release(&ttusb->dmxdev);
1717 dvb_dmx_release(&ttusb->dvb_demux);
1718 if (ttusb->fe != NULL) {
1719 dvb_unregister_frontend(ttusb->fe);
1720 dvb_frontend_detach(ttusb->fe);
1722 i2c_del_adapter(&ttusb->i2c_adap);
1723 dvb_unregister_adapter(&ttusb->adapter);
1725 ttusb_free_iso_urbs(ttusb);
1727 kfree(ttusb);
1742 .name = "ttusb",
1772 MODULE_FIRMWARE("ttusb-budget/dspbootcode.bin");