dvb_demux.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * dvb_demux.h: DVB kernel demux API
  3. *
  4. * Copyright (C) 2000-2001 Marcus Metzler & Ralph Metzler
  5. * for convergence integrated media GmbH
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 2.1
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #ifndef _DVB_DEMUX_H_
  19. #define _DVB_DEMUX_H_
  20. #include <linux/time.h>
  21. #include <linux/timer.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/mutex.h>
  24. #include "demux.h"
  25. #define DMX_TYPE_TS 0
  26. #define DMX_TYPE_SEC 1
  27. #define DMX_TYPE_PES 2
  28. #define DMX_STATE_FREE 0
  29. #define DMX_STATE_ALLOCATED 1
  30. #define DMX_STATE_SET 2
  31. #define DMX_STATE_READY 3
  32. #define DMX_STATE_GO 4
  33. #define DVB_DEMUX_MASK_MAX 18
  34. #define MAX_PID 0x1fff
  35. #define SPEED_PKTS_INTERVAL 50000
  36. struct dvb_demux_filter {
  37. struct dmx_section_filter filter;
  38. u8 maskandmode[DMX_MAX_FILTER_SIZE];
  39. u8 maskandnotmode[DMX_MAX_FILTER_SIZE];
  40. int doneq;
  41. struct dvb_demux_filter *next;
  42. struct dvb_demux_feed *feed;
  43. int index;
  44. int state;
  45. int type;
  46. u16 hw_handle;
  47. struct timer_list timer;
  48. };
  49. #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head)
  50. struct dvb_demux_feed {
  51. union {
  52. struct dmx_ts_feed ts;
  53. struct dmx_section_feed sec;
  54. } feed;
  55. union {
  56. dmx_ts_cb ts;
  57. dmx_section_cb sec;
  58. } cb;
  59. struct dvb_demux *demux;
  60. void *priv;
  61. int type;
  62. int state;
  63. u16 pid;
  64. ktime_t timeout;
  65. struct dvb_demux_filter *filter;
  66. int ts_type;
  67. enum dmx_ts_pes pes_type;
  68. int cc;
  69. int pusi_seen; /* prevents feeding of garbage from previous section */
  70. u16 peslen;
  71. struct list_head list_head;
  72. unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */
  73. };
  74. struct dvb_demux {
  75. struct dmx_demux dmx;
  76. void *priv;
  77. int filternum;
  78. int feednum;
  79. int (*start_feed)(struct dvb_demux_feed *feed);
  80. int (*stop_feed)(struct dvb_demux_feed *feed);
  81. int (*write_to_decoder)(struct dvb_demux_feed *feed,
  82. const u8 *buf, size_t len);
  83. u32 (*check_crc32)(struct dvb_demux_feed *feed,
  84. const u8 *buf, size_t len);
  85. void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst,
  86. const u8 *src, size_t len);
  87. int users;
  88. #define MAX_DVB_DEMUX_USERS 10
  89. struct dvb_demux_filter *filter;
  90. struct dvb_demux_feed *feed;
  91. struct list_head frontend_list;
  92. struct dvb_demux_feed *pesfilter[DMX_PES_OTHER];
  93. u16 pids[DMX_PES_OTHER];
  94. int playing;
  95. int recording;
  96. #define DMX_MAX_PID 0x2000
  97. struct list_head feed_list;
  98. u8 tsbuf[204];
  99. int tsbufp;
  100. struct mutex mutex;
  101. spinlock_t lock;
  102. uint8_t *cnt_storage; /* for TS continuity check */
  103. ktime_t speed_last_time; /* for TS speed check */
  104. uint32_t speed_pkts_cnt; /* for TS speed check */
  105. };
  106. int dvb_dmx_init(struct dvb_demux *dvbdemux);
  107. void dvb_dmx_release(struct dvb_demux *dvbdemux);
  108. void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf,
  109. size_t count);
  110. void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count);
  111. void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf,
  112. size_t count);
  113. void dvb_dmx_swfilter_raw(struct dvb_demux *demux, const u8 *buf,
  114. size_t count);
  115. #endif /* _DVB_DEMUX_H_ */