MythTV  master
vbi.c
Go to the documentation of this file.
1 // POSIX headers
2 #include <unistd.h>
3 #include <fcntl.h>
4 
5 #include <sys/ioctl.h>
6 
7 // ANSI C headers
8 #include <math.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <stdio.h>
12 #include <stdarg.h>
13 
14 #ifdef USING_V4L2
15 // HACK. Broken kernel headers < 2.6.25 fail compile in videodev2.h when
16 // compiling with -std=c99. We could remove this in the .pro file,
17 // but that would disable it for all .c files.
18 #undef __STRICT_ANSI__
19 #ifdef USING_V4L1
20 #include <linux/videodev.h>
21 #endif // USING_V4L1
22 #include <linux/videodev2.h>
23 #endif // USING_V4L2
24 
25 // vbitext headers
26 #include "vt.h"
27 #include "vbi.h"
28 #include "hamm.h"
29 
30 #define FAC (1<<16) // factor for fix-point arithmetic
31 
32 static unsigned char *rawbuf; // one common buffer for raw vbi data.
33 #ifdef USING_V4L2
34 static int rawbuf_size; // its current size
35 #endif // USING_V4L2
36 
37 /***** bttv api *****/
38 #define BTTV_VBISIZE _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
39 
40 
41 static void
42 error(const char *str, ...)
43 {
44  va_list ap;
45 
46  va_start(ap, str);
47  vfprintf(stderr, str, ap);
48  fprintf(stderr, "\n");
49  va_end(ap);
50 }
51 
52 static void
54 {
55  int i;
56 
57  // discard all in progress pages
58  for (i = 0; i < 8; ++i)
59  vbi->rpage[i].page->flags &= ~PG_ACTIVE;
60 }
61 
62 
63 // send an event to all clients
64 
65 static void
66 vbi_send(struct vbi *vbi, int type, int i1, int i2, int i3, void *p1)
67 {
68  struct vt_event ev[1];
69  struct vbi_client *cl, *cln;
70 
71  ev->resource = vbi;
72  ev->type = type;
73  ev->i1 = i1;
74  ev->i2 = i2;
75  ev->i3 = i3;
76  ev->p1 = p1;
77 
78  for (cl = (void*)vbi->clients->first; (cln = (void*)cl->node->next);
79  (cl = cln))
80  cl->handler(cl->data, ev);
81 }
82 
83 static void
84 vbi_send_page(struct vbi *vbi, struct raw_page *rvtp, int page)
85 {
86  if (rvtp->page->flags & PG_ACTIVE)
87  {
88  if (rvtp->page->pgno % 256 != page)
89  {
90  struct vt_page *cvtp = 0;
91  rvtp->page->flags &= ~PG_ACTIVE;
92  do_enhancements(rvtp->enh, rvtp->page);
93 // if (vbi->cache)
94 // cvtp = vbi->cache->op->put(vbi->cache, rvtp->page);
95  vbi_send(vbi, EV_PAGE, 0, 0, 0, cvtp ?: rvtp->page);
96  }
97  }
98 }
99 
100 // fine tune pll
101 // this routines tries to adjust the sampling point of the decoder.
102 // it collects parity and hamming errors and moves the sampling point
103 // a 10th of a bitlength left or right.
104 
105 #define PLL_SAMPLES 4 // number of err vals to collect
106 #define PLL_ERROR 4 // if this err val is crossed, readjust
107 //#define PLL_ADJUST 4 // max/min adjust (10th of bitlength)
108 
109 static void
110 pll_add(struct vbi *vbi, int n, int err)
111 {
112  if (vbi->pll_fixed)
113  return;
114 
115  if (err > PLL_ERROR*2/3) // limit burst errors
116  err = PLL_ERROR*2/3;
117 
118  vbi->pll_err += err;
119  vbi->pll_cnt += n;
120  if (vbi->pll_cnt < PLL_SAMPLES)
121  return;
122 
123  if (vbi->pll_err > PLL_ERROR)
124  {
125  if (vbi->pll_err > vbi->pll_lerr)
126  vbi->pll_dir = -vbi->pll_dir;
127  vbi->pll_lerr = vbi->pll_err;
128 
129  vbi->pll_adj += vbi->pll_dir;
130  if (vbi->pll_adj < -PLL_ADJUST || vbi->pll_adj > PLL_ADJUST)
131  {
132  vbi->pll_adj = 0;
133  vbi->pll_dir = -1;
134  vbi->pll_lerr = 0;
135  }
136 
137 #ifdef DEBUG
138  printf("pll_adj = %2d\n", vbi->pll_adj);
139 #endif
140  }
141  vbi->pll_cnt = 0;
142  vbi->pll_err = 0;
143 }
144 
145 void
146 vbi_pll_reset(struct vbi *vbi, int fine_tune)
147 {
148  vbi->pll_fixed = fine_tune >= -PLL_ADJUST && fine_tune <= PLL_ADJUST;
149 
150  vbi->pll_err = 0;
151  vbi->pll_lerr = 0;
152  vbi->pll_cnt = 0;
153  vbi->pll_dir = -1;
154  vbi->pll_adj = 0;
155  if (vbi->pll_fixed)
156  vbi->pll_adj = fine_tune;
157 #ifdef DEBUG
158  if (vbi->pll_fixed)
159  printf("pll_reset (fixed@%d)\n", vbi->pll_adj);
160  else
161  printf("pll_reset (auto)\n");
162 #endif
163 }
164 
165 // process one videotext packet
166 
167 static int
168 vt_line(struct vbi *vbi, unsigned char *p)
169 {
170  struct vt_page *cvtp;
171  struct raw_page *rvtp;
172  int hdr, mag, mag8, pkt, i;
173  int err = 0;
174 
175  hdr = hamm16(p, &err);
176  if (err & 0xf000)
177  return -4;
178 
179  mag = hdr & 7;
180  mag8 = mag?: 8;
181  pkt = (hdr >> 3) & 0x1f;
182  p += 2;
183 
184  rvtp = vbi->rpage + mag;
185  cvtp = rvtp->page;
186 
187  switch (pkt)
188  {
189  case 0:
190  {
191  int b1, b2, b3, b4;
192 
193  b1 = hamm16(p, &err); // page number
194  b2 = hamm16(p+2, &err); // subpage number + flags
195  b3 = hamm16(p+4, &err); // subpage number + flags
196  b4 = hamm16(p+6, &err); // language code + more flags
197 
198  if (vbi->ppage->page->flags & PG_MAGSERIAL)
199  vbi_send_page(vbi, vbi->ppage, b1);
200  vbi_send_page(vbi, rvtp, b1);
201 
202  if (err & 0xf000)
203  return 4;
204 
205  cvtp->errors = (err >> 8) + chk_parity(p + 8, 32);;
206  cvtp->pgno = mag8 * 256 + b1;
207  cvtp->subno = (b2 + b3 * 256) & 0x3f7f;
208  cvtp->lang = "\0\4\2\6\1\5\3\7"[b4 >> 5] + (latin1 ? 0 : 8);
209  cvtp->flags = b4 & 0x1f;
210  cvtp->flags |= b3 & 0xc0;
211  cvtp->flags |= (b2 & 0x80) >> 2;
212  cvtp->lines = 1;
213  cvtp->flof = 0;
214  vbi->ppage = rvtp;
215 
216  pll_add(vbi, 1, cvtp->errors);
217 
218  conv2latin(p + 8, 32, cvtp->lang);
219  vbi_send(vbi, EV_HEADER, cvtp->pgno, cvtp->subno, cvtp->flags, p);
220 
221  if (b1 == 0xff)
222  return 0;
223 
224  cvtp->flags |= PG_ACTIVE;
225  init_enhance(rvtp->enh);
226  memcpy(cvtp->data[0]+0, p, 40);
227  memset(cvtp->data[0]+40, ' ', sizeof(cvtp->data)-40);
228  return 0;
229  }
230 
231  case 1 ... 24:
232  {
233  pll_add(vbi, 1, err = chk_parity(p, 40));
234 
235  if (~cvtp->flags & PG_ACTIVE)
236  return 0;
237 
238  cvtp->errors += err;
239  cvtp->lines |= 1 << pkt;
240  conv2latin(p, 40, cvtp->lang);
241  memcpy(cvtp->data[pkt], p, 40);
242  return 0;
243  }
244  case 26:
245  {
246  int d, t[13];
247 
248  if (~cvtp->flags & PG_ACTIVE)
249  return 0;
250 
251 
252  d = hamm8(p, &err);
253  if (err & 0xf000)
254  return 4;
255 
256  for (i = 0; i < 13; ++i)
257  t[i] = hamm24(p + 1 + 3*i, &err);
258  if (err & 0xf000)
259  return 4;
260 
261  //printf("enhance on %x/%x\n", cvtp->pgno, cvtp->subno);
262  add_enhance(rvtp->enh, d, (unsigned int *)t);
263  return 0;
264  }
265  case 27:
266  {
267  // FLOF data (FastText)
268  int b1,b2;
269 
270  if (~cvtp->flags & PG_ACTIVE)
271  return 0; // -1 flushes all pages. we may never resync again :(
272 
273  b1 = hamm8(p, &err);
274  b2 = hamm8(p + 37, &err);
275  if (err & 0xf000)
276  return 4;
277  if (b1 != 0 || !(b2 & 8))
278  return 0;
279 
280  for (i = 0; i < 6; ++i)
281  {
282  err = 0;
283  b1 = hamm16(p+1+6*i, &err);
284  b2 = hamm16(p+3+6*i, &err);
285  int b3 = hamm16(p+5+6*i, &err);
286  if (err & 0xf000)
287  return 1;
288  int x = (b2 >> 7) | ((b3 >> 5) & 0x06);
289  cvtp->link[i].pgno = ((mag ^ x) ?: 8) * 256 + b1;
290  cvtp->link[i].subno = (b2 + b3 * 256) & 0x3f7f;
291  }
292  cvtp->flof = 1;
293  return 0;
294  }
295  case 30:
296  {
297  if (mag8 != 8)
298  return 0;
299 
300  p[0] = hamm8(p, &err); // designation code
301  p[1] = hamm16(p+1, &err); // initial page
302  p[3] = hamm16(p+3, &err); // initial subpage + mag
303  p[5] = hamm16(p+5, &err); // initial subpage + mag
304  if (err & 0xf000)
305  return 4;
306 
307  err += chk_parity(p+20, 20);
308  conv2latin(p+20, 20, 0);
309 
310  vbi_send(vbi, EV_XPACKET, mag8, pkt, err, p);
311  return 0;
312  }
313  default:
314  // unused at the moment...
315  //vbi_send(vbi, EV_XPACKET, mag8, pkt, err, p);
316  return 0;
317  }
318  return 0;
319 }
320 
321 
322 
323 // process one raw vbi line
324 
325 static int
326 vbi_line(struct vbi *vbi, const unsigned char *p)
327 {
328  unsigned char data[43], min, max;
329  int dt[256], hi[6], lo[6];
330  int i, n, sync, thr;
331  int bpb = vbi->bpb;
332 
333  /* remove DC. edge-detector */
334  for (i = vbi->soc; i < vbi->eoc; ++i)
335  dt[i] = p[i+bpb/FAC] - p[i]; // amplifies the edges best.
336 
337  /* set barrier */
338  for (i = vbi->eoc; i < vbi->eoc+16; i += 2)
339  dt[i] = 100, dt[i+1] = -100;
340 
341  /* find 6 rising and falling edges */
342  for (i = vbi->soc, n = 0; n < 6; ++n)
343  {
344  while (dt[i] < 32)
345  i++;
346  hi[n] = i;
347  while (dt[i] > -32)
348  i++;
349  lo[n] = i;
350  }
351  if (i >= vbi->eoc)
352  return -1; // not enough periods found
353 
354  i = hi[5] - hi[1]; // length of 4 periods (8 bits)
355  if (i < vbi->bp8bl || i > vbi->bp8bh)
356  return -1; // bad frequency
357 
358  /* AGC and sync-reference */
359  min = 255, max = 0, sync = 0;
360  for (i = hi[4]; i < hi[5]; ++i)
361  if (p[i] > max)
362  max = p[i], sync = i;
363  for (i = lo[4]; i < lo[5]; ++i)
364  if (p[i] < min)
365  min = p[i];
366  thr = (min + max) / 2;
367 
368  p += sync;
369 
370  /* search start-byte 11100100 */
371  for (i = 4*bpb + vbi->pll_adj*bpb/10; i < 16*bpb; i += bpb)
372  if (p[i/FAC] > thr && p[(i+bpb)/FAC] > thr) // two ones is enough...
373  {
374  /* got it... */
375  memset(data, 0, sizeof(data));
376 
377  for (n = 0; n < 43*8; ++n, i += bpb)
378  if (p[i/FAC] > thr)
379  data[n/8] |= 1 << (n%8);
380 
381  if (data[0] != 0x27) // really 11100100? (rev order!)
382  return -1;
383 
384  if ((i = vt_line(vbi, data+1)))
385  {
386  if (i < 0)
387  pll_add(vbi, 2, -i);
388  else
389  pll_add(vbi, 1, i);
390  }
391  return 0;
392  }
393  return -1;
394 }
395 
396 
397 
398 // called when new vbi data is waiting
399 
400 void
401 vbi_handler(struct vbi *vbi, int fd)
402 {
403  int n;
404  unsigned int seq;
405 
406  (void)fd;
407 
408  n = read(vbi->fd, rawbuf, vbi->bufsize);
409 
410  if (dl_empty(vbi->clients))
411  return;
412 
413  if (n != vbi->bufsize)
414  return;
415 
416  seq = *(unsigned int *)&rawbuf[n - 4];
417  if (vbi->seq+1 != seq)
418  {
419  out_of_sync(vbi);
420  if (seq < 3 && vbi->seq >= 3)
421  vbi_reset(vbi);
422  }
423  vbi->seq = seq;
424 
425  if (seq > 1) // the first may contain data from prev channel
426  {
427 #if 1
428  for (int i = 0; i+vbi->bpl <= n; i += vbi->bpl)
429  vbi_line(vbi, rawbuf + i);
430 #else
431  /* work-around for old saa7134 driver versions (prior 0.2.6) */
432  for (int i = 16 * vbi->bpl; i + vbi->bpl <= n; i += vbi->bpl)
433  vbi_line(vbi, rawbuf + i);
434 
435  for (int i = 0; i + vbi->bpl <= 16 * vbi->bpl; i += vbi->bpl)
436  vbi_line(vbi, rawbuf + i);
437 #endif
438  }
439 }
440 
441 
442 
443 int
444 vbi_add_handler(struct vbi *vbi, void *handler, void *data)
445 {
446  struct vbi_client *cl;
447 
448  if (!(cl = malloc(sizeof(*cl))))
449  return -1;
450  cl->handler = handler;
451  cl->data = data;
452  // cl is not leaking, the first struct element has the same address
453  // as the struct
455  // cppcheck-suppress memleak
456  return 0;
457 }
458 
459 
460 
461 void
462 vbi_del_handler(struct vbi *vbi, void *handler, void *data)
463 {
464  struct vbi_client *cl;
465 
466  for (cl = (void*) vbi->clients->first; cl->node->next; cl = (void*) cl->node->next)
467  if (cl->handler == handler && cl->data == data)
468  {
469  dl_remove(cl->node);
470  break;
471  }
472 }
473 
474 #ifdef USING_V4L2
475 static int
476 set_decode_parms(struct vbi *vbi, struct v4l2_vbi_format *p)
477 {
478  double fs; // sampling rate
479  double bpb; // bytes per bit
480  int soc, eoc; // start/end of clock run-in
481  int bpl; // bytes per line
482 
483  if (p->sample_format != V4L2_PIX_FMT_GREY)
484  {
485  fprintf(stderr, "got pix fmt %x\n", p->sample_format);
486  error("v4l2: unsupported vbi data format");
487  return -1;
488  }
489 
490  // some constants from the standard:
491  // horizontal frequency fh = 15625Hz
492  // teletext bitrate ft = 444*fh = 6937500Hz
493  // teletext identification sequence 10101010 10101010 11100100
494  // 13th bit of seq rel to falling hsync 12us -1us +0.4us
495  // I search for the clock run-in (10101010 10101010) from 12us-1us-12.5/ft
496  // (earliest first bit) to 12us+0.4us+3.5/ft (latest last bit)
497  // earlist first bit tf = 12us-1us-12.5/ft = 9.2us
498  // latest last bit tl = 12us+0.4us+3.5/ft = 12.9us
499  // total number of used bits n = (2+1+2+40)*8 = 360
500 
501  bpl = p->samples_per_line;
502  fs = p->sampling_rate;
503  bpb = fs/6937500.0;
504  soc = (int)(9.2e-6*fs) - (int)p->offset;
505  eoc = (int)(12.9e-6*fs) - (int)p->offset;
506  if (soc < 0)
507  soc = 0;
508  if (eoc > bpl - (int)(43*8*bpb))
509  eoc = bpl - (int)(43*8*bpb);
510  if (eoc - soc < (int)(16*bpb))
511  {
512  // line too short or offset too large or wrong sample_rate
513  error("v4l2: broken vbi format specification");
514  return -1;
515  }
516  if (eoc > 240)
517  {
518  // the vbi_line routine can hold max 240 values in its work buffer
519  error("v4l2: unable to handle these sampling parameters");
520  return -1;
521  }
522 
523  vbi->bpb = lround(bpb * FAC);
524  vbi->soc = soc;
525  vbi->eoc = eoc;
526  vbi->bp8bl = 0.97 * 8*bpb; // -3% tolerance
527  vbi->bp8bh = 1.03 * 8*bpb; // +3% tolerance
528 
529  vbi->bpl = bpl;
530  vbi->bufsize = bpl * (p->count[0] + p->count[1]);
531 
532  return 0;
533 }
534 #endif // USING_V4L2
535 
536 static int
537 setup_dev(struct vbi *vbi)
538 {
539 #ifdef USING_V4L2
540  struct v4l2_format v4l2_format;
541  struct v4l2_vbi_format *vbifmt = &v4l2_format.fmt.vbi;
542 
543  memset(&v4l2_format, 0, sizeof(v4l2_format));
544  v4l2_format.type = V4L2_BUF_TYPE_VBI_CAPTURE;
545  if (ioctl(vbi->fd, VIDIOC_G_FMT, &v4l2_format) == -1)
546  {
547 #ifdef USING_V4L1
548  // not a v4l2 device. assume bttv and create a standard fmt-struct.
549  int size;
550  perror("ioctl VIDIOC_G_FMT");
551 
552  vbifmt->sample_format = V4L2_PIX_FMT_GREY;
553  vbifmt->sampling_rate = 35468950;
554  vbifmt->samples_per_line = 2048;
555  vbifmt->offset = 244;
556  if ((size = ioctl(vbi->fd, BTTV_VBISIZE, 0)) == -1)
557  {
558  // BSD or older bttv driver.
559  vbifmt->count[0] = 16;
560  vbifmt->count[1] = 16;
561  }
562  else if (size % 2048)
563  {
564  error("broken bttv driver (bad buffer size)");
565  return -1;
566  }
567  else
568  {
569  size /= 2048;
570  vbifmt->count[0] = size/2;
571  vbifmt->count[1] = size - size/2;
572  }
573 #else
574  error("Video 4 Linux version 1 support is not enabled.");
575  return -1;
576 #endif
577  }
578 
579  if (set_decode_parms(vbi, vbifmt) == -1)
580  return -1;
581 
582  if (vbi->bpl < 1 || vbi->bufsize < vbi->bpl || vbi->bufsize % vbi->bpl != 0)
583  {
584  error("strange size of vbi buffer (%d/%d)", vbi->bufsize, vbi->bpl);
585  return -1;
586  }
587 
588  // grow buffer if necessary
589  if (rawbuf_size < vbi->bufsize)
590  {
591  if (rawbuf)
592  free(rawbuf);
593  if (!(rawbuf = malloc(rawbuf_size = vbi->bufsize)))
594  error("malloc refused in setup_dev()\n");
595  }
596 
597  return 0;
598 #else
599  (void)vbi;
600  return -1;
601 #endif // USING_V4L2
602 }
603 
604 
605 
606 struct vbi *
607 vbi_open(const char *vbi_dev_name, struct cache *ca, int fine_tune, int big_buf)
608 {
609  static int inited = 0;
610  struct vbi *vbi = 0;
611 
612  (void)ca;
613 
614  if (! inited)
615  lang_init();
616  inited = 1;
617 
618  if (!(vbi = malloc(sizeof(*vbi))))
619  {
620  error("out of memory");
621  goto fail1;
622  }
623 
624  if ((vbi->fd = open(vbi_dev_name, O_RDONLY)) == -1)
625  {
626  error("cannot open vbi device");
627  goto fail2;
628  }
629 
630  if (big_buf != -1)
631  error("-oldbttv/-newbttv is obsolete. option ignored.");
632 
633  if (setup_dev(vbi) == -1)
634  goto fail3;
635 
636 // vbi->cache = ca;
637 
638  dl_init(vbi->clients);
639  vbi->seq = 0;
640  out_of_sync(vbi);
641  vbi->ppage = vbi->rpage;
642 
643  vbi_pll_reset(vbi, fine_tune);
644 // ECA removed fdset_add_fd(fds, vbi->fd, vbi_handler, vbi);
645  return vbi;
646 
647 fail3:
648  close(vbi->fd);
649 fail2:
650  free(vbi);
651 fail1:
652  return 0;
653 }
654 
655 
656 
657 void
658 vbi_close(struct vbi *vbi)
659 {
660 // fdset_del_fd(fds, vbi->fd);
661 // if (vbi->cache)
662 // vbi->cache->op->close(vbi->cache);
663  close(vbi->fd);
664  free(vbi);
665 }
666 
667 
668 struct vt_page *
669 vbi_query_page(struct vbi *vbi, int pgno, int subno)
670 {
671 #ifdef IMPLEMENTED
672  struct vt_page *vtp = 0;
673 
674  (void)pgno;
675  (void)subno;
676 
677  if (vbi->cache)
678  vtp = vbi->cache->op->get(vbi->cache, pgno, subno);
679  if (vtp == 0)
680  {
681  // EV_PAGE will come later...
682  return 0;
683  }
684 
685  vbi_send(vbi, EV_PAGE, 1, 0, 0, vtp);
686  return vtp;
687 #else
688  (void)vbi;
689  (void)pgno;
690  (void)subno;
691  return NULL;
692 #endif
693 }
694 
695 void
696 vbi_reset(struct vbi *vbi)
697 {
698 // if (vbi->cache)
699 // vbi->cache->op->reset(vbi->cache);
700  vbi_send(vbi, EV_RESET, 0, 0, 0, 0);
701 }
702 
int pll_err
Definition: vbi.h:38
struct vt_page::@72 link[6]
static int vt_line(struct vbi *vbi, unsigned char *p)
Definition: vbi.c:168
#define PG_ACTIVE
Definition: vt.h:60
int pll_dir
Definition: vbi.h:36
void lang_init(void)
Definition: lang.c:93
stderr
Definition: ttvdb.py:1426
int pgno
Definition: vt.h:38
int latin1
Definition: lang.c:5
int errors
Definition: vt.h:41
int pll_lerr
Definition: vbi.h:38
#define EV_PAGE
Definition: vt.h:20
struct dl_head clients[1]
Definition: vbi.h:25
#define BTTV_VBISIZE
Definition: vbi.c:38
#define NULL
Definition: H264Parser.h:62
void init_enhance(struct enhance *eh)
Definition: lang.c:125
static void error(const char *str,...)
Definition: vbi.c:42
struct dl_node * first
Definition: dllist.h:16
int hamm8(const unsigned char *p, int *err)
Definition: hamm.c:199
void add_enhance(struct enhance *eh, int dcode, unsigned int *data)
Definition: lang.c:131
static void pll_add(struct vbi *vbi, int n, int err)
Definition: vbi.c:110
int eoc
Definition: vbi.h:42
unsigned int lines
Definition: vt.h:42
void vbi_reset(struct vbi *vbi)
Definition: vbi.c:696
struct cache * cache
Definition: vbi.h:24
#define PLL_ADJUST
Definition: vbi.h:13
#define EV_HEADER
Definition: vt.h:21
int chk_parity(unsigned char *p, int n)
Definition: hamm.c:227
unsigned int seq
Definition: vbi.h:29
int bp8bh
Definition: vbi.h:41
void * data
Definition: vbi.h:49
#define FAC
Definition: vbi.c:30
def read(device=None, features=[])
Definition: disc.py:35
static unsigned char * rawbuf
Definition: vbi.c:32
Definition: vt.h:36
#define PLL_SAMPLES
Definition: vbi.c:105
struct dl_node node[1]
Definition: vbi.h:47
static struct dl_node * dl_remove(struct dl_node *n)
Definition: dllist.h:35
int bufsize
Definition: vbi.h:27
int i1
Definition: vt.h:12
#define close
Definition: compat.h:16
int flags
Definition: vt.h:40
int bpl
Definition: vbi.h:28
static const uint16_t * d
#define PG_MAGSERIAL
Definition: vt.h:55
int bpb
Definition: vbi.h:40
int pll_fixed
Definition: vbi.h:34
unsigned char t
Definition: ParseText.cpp:329
static void vbi_send_page(struct vbi *vbi, struct raw_page *rvtp, int page)
Definition: vbi.c:84
struct vt_page page[1]
Definition: vbi.h:17
static void out_of_sync(struct vbi *vbi)
Definition: vbi.c:53
int pll_adj
Definition: vbi.h:35
Definition: vbi.h:45
void(* handler)(void *data, struct vt_event *ev)
Definition: vbi.h:48
#define EV_RESET
Definition: vt.h:23
void vbi_pll_reset(struct vbi *vbi, int fine_tune)
Definition: vbi.c:146
Definition: vt.h:8
unsigned char data[VT_HEIGHT][VT_WIDTH]
Definition: vt.h:43
static struct dl_head * dl_init(struct dl_head *h)
Definition: dllist.h:22
int i3
Definition: vt.h:12
int soc
Definition: vbi.h:42
Definition: vbi.h:15
void vbi_handler(struct vbi *vbi, int fd)
Definition: vbi.c:401
static int rawbuf_size
Definition: vbi.c:34
void do_enhancements(struct enhance *eh, struct vt_page *vtp)
Definition: lang.c:143
#define dl_empty(h)
Definition: dllist.h:52
int pll_cnt
Definition: vbi.h:37
#define EV_XPACKET
Definition: vt.h:22
int i2
Definition: vt.h:12
struct vt_page * vbi_query_page(struct vbi *vbi, int pgno, int subno)
Definition: vbi.c:669
int flof
Definition: vt.h:44
int hamm16(const unsigned char *p, int *err)
Definition: hamm.c:207
#define dl_insert_last(h, n)
Definition: dllist.h:56
struct raw_page rpage[8]
Definition: vbi.h:31
Definition: vbi.h:21
struct dl_node * next
Definition: dllist.h:10
static int set_decode_parms(struct vbi *vbi, struct v4l2_vbi_format *p)
Definition: vbi.c:476
int subno
Definition: vt.h:38
static void vbi_send(struct vbi *vbi, int type, int i1, int i2, int i3, void *p1)
Definition: vbi.c:66
int vbi_add_handler(struct vbi *vbi, void *handler, void *data)
Definition: vbi.c:444
int type
Definition: vt.h:10
struct enhance enh[1]
Definition: vbi.h:18
static int setup_dev(struct vbi *vbi)
Definition: vbi.c:537
int lang
Definition: vt.h:39
int fd
Definition: vbi.h:23
void conv2latin(unsigned char *p, int n, int lang)
Definition: lang.c:104
static int vbi_line(struct vbi *vbi, const unsigned char *p)
Definition: vbi.c:326
int bp8bl
Definition: vbi.h:41
#define PLL_ERROR
Definition: vbi.c:106
void vbi_del_handler(struct vbi *vbi, void *handler, void *data)
Definition: vbi.c:462
struct raw_page * ppage
Definition: vbi.h:32
void * p1
Definition: vt.h:13
void vbi_close(struct vbi *vbi)
Definition: vbi.c:658
struct vbi * vbi_open(const char *vbi_dev_name, struct cache *ca, int fine_tune, int big_buf)
Definition: vbi.c:607
int hamm24(const unsigned char *p, int *err)
Definition: hamm.c:217
static guint32 * p1
Definition: goom_core.c:35
void * resource
Definition: vt.h:11