firesat_iso.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * FireSAT DVB driver
  3. *
  4. * Copyright (c) 2008 Henrik Kurelid <henrik@kurelid.se>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. */
  11. #include "firesat.h"
  12. static void rawiso_activity_cb(struct hpsb_iso *iso);
  13. void tear_down_iso_channel(struct firesat *firesat)
  14. {
  15. if (firesat->iso_handle != NULL) {
  16. hpsb_iso_stop(firesat->iso_handle);
  17. hpsb_iso_shutdown(firesat->iso_handle);
  18. }
  19. firesat->iso_handle = NULL;
  20. }
  21. int setup_iso_channel(struct firesat *firesat)
  22. {
  23. int result;
  24. firesat->iso_handle =
  25. hpsb_iso_recv_init(firesat->host,
  26. 256 * 200, //data_buf_size,
  27. 256, //buf_packets,
  28. firesat->isochannel,
  29. HPSB_ISO_DMA_DEFAULT, //dma_mode,
  30. -1, //stat.config.irq_interval,
  31. rawiso_activity_cb);
  32. if (firesat->iso_handle == NULL) {
  33. printk(KERN_ERR "Cannot initialize iso receive.\n");
  34. return -EINVAL;
  35. }
  36. result = hpsb_iso_recv_start(firesat->iso_handle, -1, -1, 0);
  37. if (result != 0) {
  38. printk(KERN_ERR "Cannot start iso receive.\n");
  39. return -EINVAL;
  40. }
  41. return 0;
  42. }
  43. static void rawiso_activity_cb(struct hpsb_iso *iso)
  44. {
  45. unsigned int num;
  46. unsigned int i;
  47. /* unsigned int j; */
  48. unsigned int packet;
  49. unsigned long flags;
  50. struct firesat *firesat = NULL;
  51. struct firesat *firesat_iterator;
  52. spin_lock_irqsave(&firesat_list_lock, flags);
  53. list_for_each_entry(firesat_iterator, &firesat_list, list) {
  54. if(firesat_iterator->iso_handle == iso) {
  55. firesat = firesat_iterator;
  56. break;
  57. }
  58. }
  59. spin_unlock_irqrestore(&firesat_list_lock, flags);
  60. if (firesat) {
  61. packet = iso->first_packet;
  62. num = hpsb_iso_n_ready(iso);
  63. for (i = 0; i < num; i++,
  64. packet = (packet + 1) % iso->buf_packets) {
  65. unsigned char *buf =
  66. dma_region_i(&iso->data_buf, unsigned char,
  67. iso->infos[packet].offset +
  68. sizeof(struct CIPHeader));
  69. int count = (iso->infos[packet].len -
  70. sizeof(struct CIPHeader)) /
  71. (188 + sizeof(struct firewireheader));
  72. if (iso->infos[packet].len <= sizeof(struct CIPHeader))
  73. continue; // ignore empty packet
  74. /* printk("%s: Handling packets (%d): ", __func__, */
  75. /* iso->infos[packet].len); */
  76. /* for (j = 0; j < iso->infos[packet].len - */
  77. /* sizeof(struct CIPHeader); j++) */
  78. /* printk("%02X,", buf[j]); */
  79. /* printk("\n"); */
  80. while (count --) {
  81. if (buf[sizeof(struct firewireheader)] == 0x47)
  82. dvb_dmx_swfilter_packets(&firesat->demux,
  83. &buf[sizeof(struct firewireheader)], 1);
  84. else
  85. printk("%s: invalid packet, skipping\n", __func__);
  86. buf += 188 + sizeof(struct firewireheader);
  87. }
  88. }
  89. hpsb_iso_recv_release_packets(iso, num);
  90. }
  91. else {
  92. printk("%s: packets for unknown iso channel, skipping\n",
  93. __func__);
  94. hpsb_iso_recv_release_packets(iso, hpsb_iso_n_ready(iso));
  95. }
  96. }