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 <stdlib.h>
9 #include <string.h>
10 #include <stdio.h>
11 #include <stdarg.h>
12 
13 #ifdef USING_V4L2
14 // HACK. Broken kernel headers < 2.6.25 fail compile in videodev2.h when
15 // compiling with -std=c99. We could remove this in the .pro file,
16 // but that would disable it for all .c files.
17 #undef __STRICT_ANSI__
18 #ifdef USING_V4L1
19 #include <linux/videodev.h>
20 #endif // USING_V4L1
21 #include <linux/videodev2.h>
22 #endif // USING_V4L2
23 
24 // vbitext headers
25 #include "vt.h"
26 #include "vbi.h"
27 #include "hamm.h"
28 
29 #define FAC (1<<16) // factor for fix-point arithmetic
30 
31 static unsigned char *rawbuf; // one common buffer for raw vbi data.
32 #ifdef USING_V4L2
33 static int rawbuf_size; // its current size
34 #endif // USING_V4L2
35 
36 /***** bttv api *****/
37 #define BTTV_VBISIZE _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
38 
39 
40 static void
41 error(const char *str, ...)
42 {
43  va_list ap;
44 
45  va_start(ap, str);
46  vfprintf(stderr, str, ap);
47  fprintf(stderr, "\n");
48  va_end(ap);
49 }
50 
51 static void
53 {
54  int i;
55 
56  // discard all in progress pages
57  for (i = 0; i < 8; ++i)
58  vbi->rpage[i].page->flags &= ~PG_ACTIVE;
59 }
60 
61 
62 // send an event to all clients
63 
64 static void
65 vbi_send(struct vbi *vbi, int type, int i1, int i2, int i3, void *p1)
66 {
67  struct vt_event ev[1];
68  struct vbi_client *cl, *cln;
69 
70  ev->resource = vbi;
71  ev->type = type;
72  ev->i1 = i1;
73  ev->i2 = i2;
74  ev->i3 = i3;
75  ev->p1 = p1;
76 
77  for (cl = (void*)vbi->clients->first; (cln = (void*)cl->node->next);
78  (cl = cln))
79  cl->handler(cl->data, ev);
80 }
81 
82 static void
83 vbi_send_page(struct vbi *vbi, struct raw_page *rvtp, int page)
84 {
85  if (rvtp->page->flags & PG_ACTIVE)
86  {
87  if (rvtp->page->pgno % 256 != page)
88  {
89  struct vt_page *cvtp = 0;
90  rvtp->page->flags &= ~PG_ACTIVE;
91  enhance(rvtp->enh, rvtp->page);
92 // if (vbi->cache)
93 // cvtp = vbi->cache->op->put(vbi->cache, rvtp->page);
94  vbi_send(vbi, EV_PAGE, 0, 0, 0, cvtp ?: rvtp->page);
95  }
96  }
97 }
98 
99 // fine tune pll
100 // this routines tries to adjust the sampling point of the decoder.
101 // it collects parity and hamming errors and moves the sampling point
102 // a 10th of a bitlength left or right.
103 
104 #define PLL_SAMPLES 4 // number of err vals to collect
105 #define PLL_ERROR 4 // if this err val is crossed, readjust
106 //#define PLL_ADJUST 4 // max/min adjust (10th of bitlength)
107 
108 static void
109 pll_add(struct vbi *vbi, int n, int err)
110 {
111  if (vbi->pll_fixed)
112  return;
113 
114  if (err > PLL_ERROR*2/3) // limit burst errors
115  err = PLL_ERROR*2/3;
116 
117  vbi->pll_err += err;
118  vbi->pll_cnt += n;
119  if (vbi->pll_cnt < PLL_SAMPLES)
120  return;
121 
122  if (vbi->pll_err > PLL_ERROR)
123  {
124  if (vbi->pll_err > vbi->pll_lerr)
125  vbi->pll_dir = -vbi->pll_dir;
126  vbi->pll_lerr = vbi->pll_err;
127 
128  vbi->pll_adj += vbi->pll_dir;
129  if (vbi->pll_adj < -PLL_ADJUST || vbi->pll_adj > PLL_ADJUST)
130  {
131  vbi->pll_adj = 0;
132  vbi->pll_dir = -1;
133  vbi->pll_lerr = 0;
134  }
135 
136 #ifdef DEBUG
137  printf("pll_adj = %2d\n", vbi->pll_adj);
138 #endif
139  }
140  vbi->pll_cnt = 0;
141  vbi->pll_err = 0;
142 }
143 
144 void
145 vbi_pll_reset(struct vbi *vbi, int fine_tune)
146 {
147  vbi->pll_fixed = fine_tune >= -PLL_ADJUST && fine_tune <= PLL_ADJUST;
148 
149  vbi->pll_err = 0;
150  vbi->pll_lerr = 0;
151  vbi->pll_cnt = 0;
152  vbi->pll_dir = -1;
153  vbi->pll_adj = 0;
154  if (vbi->pll_fixed)
155  vbi->pll_adj = fine_tune;
156 #ifdef DEBUG
157  if (vbi->pll_fixed)
158  printf("pll_reset (fixed@%d)\n", vbi->pll_adj);
159  else
160  printf("pll_reset (auto)\n");
161 #endif
162 }
163 
164 // process one videotext packet
165 
166 static int
167 vt_line(struct vbi *vbi, unsigned char *p)
168 {
169  struct vt_page *cvtp;
170  struct raw_page *rvtp;
171  int hdr, mag, mag8, pkt, i;
172  int err = 0;
173 
174  hdr = hamm16(p, &err);
175  if (err & 0xf000)
176  return -4;
177 
178  mag = hdr & 7;
179  mag8 = mag?: 8;
180  pkt = (hdr >> 3) & 0x1f;
181  p += 2;
182 
183  rvtp = vbi->rpage + mag;
184  cvtp = rvtp->page;
185 
186  switch (pkt)
187  {
188  case 0:
189  {
190  int b1, b2, b3, b4;
191 
192  b1 = hamm16(p, &err); // page number
193  b2 = hamm16(p+2, &err); // subpage number + flags
194  b3 = hamm16(p+4, &err); // subpage number + flags
195  b4 = hamm16(p+6, &err); // language code + more flags
196 
197  if (vbi->ppage->page->flags & PG_MAGSERIAL)
198  vbi_send_page(vbi, vbi->ppage, b1);
199  vbi_send_page(vbi, rvtp, b1);
200 
201  if (err & 0xf000)
202  return 4;
203 
204  cvtp->errors = (err >> 8) + chk_parity(p + 8, 32);;
205  cvtp->pgno = mag8 * 256 + b1;
206  cvtp->subno = (b2 + b3 * 256) & 0x3f7f;
207  cvtp->lang = "\0\4\2\6\1\5\3\7"[b4 >> 5] + (latin1 ? 0 : 8);
208  cvtp->flags = b4 & 0x1f;
209  cvtp->flags |= b3 & 0xc0;
210  cvtp->flags |= (b2 & 0x80) >> 2;
211  cvtp->lines = 1;
212  cvtp->flof = 0;
213  vbi->ppage = rvtp;
214 
215  pll_add(vbi, 1, cvtp->errors);
216 
217  conv2latin(p + 8, 32, cvtp->lang);
218  vbi_send(vbi, EV_HEADER, cvtp->pgno, cvtp->subno, cvtp->flags, p);
219 
220  if (b1 == 0xff)
221  return 0;
222 
223  cvtp->flags |= PG_ACTIVE;
224  init_enhance(rvtp->enh);
225  memcpy(cvtp->data[0]+0, p, 40);
226  memset(cvtp->data[0]+40, ' ', sizeof(cvtp->data)-40);
227  return 0;
228  }
229 
230  case 1 ... 24:
231  {
232  pll_add(vbi, 1, err = chk_parity(p, 40));
233 
234  if (~cvtp->flags & PG_ACTIVE)
235  return 0;
236 
237  cvtp->errors += err;
238  cvtp->lines |= 1 << pkt;
239  conv2latin(p, 40, cvtp->lang);
240  memcpy(cvtp->data[pkt], p, 40);
241  return 0;
242  }
243  case 26:
244  {
245  int d, t[13];
246 
247  if (~cvtp->flags & PG_ACTIVE)
248  return 0;
249 
250 
251  d = hamm8(p, &err);
252  if (err & 0xf000)
253  return 4;
254 
255  for (i = 0; i < 13; ++i)
256  t[i] = hamm24(p + 1 + 3*i, &err);
257  if (err & 0xf000)
258  return 4;
259 
260  //printf("enhance on %x/%x\n", cvtp->pgno, cvtp->subno);
261  add_enhance(rvtp->enh, d, (unsigned int *)t);
262  return 0;
263  }
264  case 27:
265  {
266  // FLOF data (FastText)
267  int b1,b2;
268 
269  if (~cvtp->flags & PG_ACTIVE)
270  return 0; // -1 flushes all pages. we may never resync again :(
271 
272  b1 = hamm8(p, &err);
273  b2 = hamm8(p + 37, &err);
274  if (err & 0xf000)
275  return 4;
276  if (b1 != 0 || !(b2 & 8))
277  return 0;
278 
279  for (i = 0; i < 6; ++i)
280  {
281  err = 0;
282  b1 = hamm16(p+1+6*i, &err);
283  b2 = hamm16(p+3+6*i, &err);
284  int b3 = hamm16(p+5+6*i, &err);
285  if (err & 0xf000)
286  return 1;
287  int x = (b2 >> 7) | ((b3 >> 5) & 0x06);
288  cvtp->link[i].pgno = ((mag ^ x) ?: 8) * 256 + b1;
289  cvtp->link[i].subno = (b2 + b3 * 256) & 0x3f7f;
290  }
291  cvtp->flof = 1;
292  return 0;
293  }
294  case 30:
295  {
296  if (mag8 != 8)
297  return 0;
298 
299  p[0] = hamm8(p, &err); // designation code
300  p[1] = hamm16(p+1, &err); // initial page
301  p[3] = hamm16(p+3, &err); // initial subpage + mag
302  p[5] = hamm16(p+5, &err); // initial subpage + mag
303  if (err & 0xf000)
304  return 4;
305 
306  err += chk_parity(p+20, 20);
307  conv2latin(p+20, 20, 0);
308 
309  vbi_send(vbi, EV_XPACKET, mag8, pkt, err, p);
310  return 0;
311  }
312  default:
313  // unused at the moment...
314  //vbi_send(vbi, EV_XPACKET, mag8, pkt, err, p);
315  return 0;
316  }
317  return 0;
318 }
319 
320 
321 
322 // process one raw vbi line
323 
324 static int
325 vbi_line(struct vbi *vbi, unsigned char *p)
326 {
327  unsigned char data[43], min, max;
328  int dt[256], hi[6], lo[6];
329  int i, n, sync, thr;
330  int bpb = vbi->bpb;
331 
332  /* remove DC. edge-detector */
333  for (i = vbi->soc; i < vbi->eoc; ++i)
334  dt[i] = p[i+bpb/FAC] - p[i]; // amplifies the edges best.
335 
336  /* set barrier */
337  for (i = vbi->eoc; i < vbi->eoc+16; i += 2)
338  dt[i] = 100, dt[i+1] = -100;
339 
340  /* find 6 rising and falling edges */
341  for (i = vbi->soc, n = 0; n < 6; ++n)
342  {
343  while (dt[i] < 32)
344  i++;
345  hi[n] = i;
346  while (dt[i] > -32)
347  i++;
348  lo[n] = i;
349  }
350  if (i >= vbi->eoc)
351  return -1; // not enough periods found
352 
353  i = hi[5] - hi[1]; // length of 4 periods (8 bits)
354  if (i < vbi->bp8bl || i > vbi->bp8bh)
355  return -1; // bad frequency
356 
357  /* AGC and sync-reference */
358  min = 255, max = 0, sync = 0;
359  for (i = hi[4]; i < hi[5]; ++i)
360  if (p[i] > max)
361  max = p[i], sync = i;
362  for (i = lo[4]; i < lo[5]; ++i)
363  if (p[i] < min)
364  min = p[i];
365  thr = (min + max) / 2;
366 
367  p += sync;
368 
369  /* search start-byte 11100100 */
370  for (i = 4*bpb + vbi->pll_adj*bpb/10; i < 16*bpb; i += bpb)
371  if (p[i/FAC] > thr && p[(i+bpb)/FAC] > thr) // two ones is enough...
372  {
373  /* got it... */
374  memset(data, 0, sizeof(data));
375 
376  for (n = 0; n < 43*8; ++n, i += bpb)
377  if (p[i/FAC] > thr)
378  data[n/8] |= 1 << (n%8);
379 
380  if (data[0] != 0x27) // really 11100100? (rev order!)
381  return -1;
382 
383  if ((i = vt_line(vbi, data+1)))
384  {
385  if (i < 0)
386  pll_add(vbi, 2, -i);
387  else
388  pll_add(vbi, 1, i);
389  }
390  return 0;
391  }
392  return -1;
393 }
394 
395 
396 
397 // called when new vbi data is waiting
398 
399 void
400 vbi_handler(struct vbi *vbi, int fd)
401 {
402  int n;
403  unsigned int seq;
404 
405  (void)fd;
406 
407  n = read(vbi->fd, rawbuf, vbi->bufsize);
408 
409  if (dl_empty(vbi->clients))
410  return;
411 
412  if (n != vbi->bufsize)
413  return;
414 
415  seq = *(unsigned int *)&rawbuf[n - 4];
416  if (vbi->seq+1 != seq)
417  {
418  out_of_sync(vbi);
419  if (seq < 3 && vbi->seq >= 3)
420  vbi_reset(vbi);
421  }
422  vbi->seq = seq;
423 
424  if (seq > 1) // the first may contain data from prev channel
425  {
426 #if 1
427  for (int i = 0; i+vbi->bpl <= n; i += vbi->bpl)
428  vbi_line(vbi, rawbuf + i);
429 #else
430  /* work-around for old saa7134 driver versions (prior 0.2.6) */
431  for (int i = 16 * vbi->bpl; i + vbi->bpl <= n; i += vbi->bpl)
432  vbi_line(vbi, rawbuf + i);
433 
434  for (int i = 0; i + vbi->bpl <= 16 * vbi->bpl; i += vbi->bpl)
435  vbi_line(vbi, rawbuf + i);
436 #endif
437  }
438 }
439 
440 
441 
442 int
443 vbi_add_handler(struct vbi *vbi, void *handler, void *data)
444 {
445  struct vbi_client *cl;
446 
447  if (!(cl = malloc(sizeof(*cl))))
448  return -1;
449  cl->handler = handler;
450  cl->data = data;
451  // cl is not leaking, the first struct element has the same address
452  // as the struct
454  // cppcheck-suppress memleak
455  return 0;
456 }
457 
458 
459 
460 void
461 vbi_del_handler(struct vbi *vbi, void *handler, void *data)
462 {
463  struct vbi_client *cl;
464 
465  for (cl = (void*) vbi->clients->first; cl->node->next; cl = (void*) cl->node->next)
466  if (cl->handler == handler && cl->data == data)
467  {
468  dl_remove(cl->node);
469  break;
470  }
471  return;
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 = bpb * FAC + 0.5;
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_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_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:167
#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:37
#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:41
struct dl_node * first
Definition: dllist.h:16
static void pll_add(struct vbi *vbi, int n, int err)
Definition: vbi.c:109
int eoc
Definition: vbi.h:42
unsigned int lines
Definition: vt.h:42
int hamm16(unsigned char *p, int *err)
Definition: hamm.c:207
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
struct vbi * vbi_open(const char *vbi_name, struct cache *ca, int fine_tune, int big_buf)
Definition: vbi.c:607
void add_enhance(struct enhance *eh, int dcode, unsigned int *t)
Definition: lang.c:131
unsigned int seq
Definition: vbi.h:29
int bp8bh
Definition: vbi.h:41
void * data
Definition: vbi.h:49
#define FAC
Definition: vbi.c:29
def read(device=None, features=[])
Definition: disc.py:35
void enhance(struct enhance *eh, struct vt_page *vtp)
Definition: lang.c:143
static unsigned char * rawbuf
Definition: vbi.c:31
Definition: vt.h:36
#define PLL_SAMPLES
Definition: vbi.c:104
static int vbi_line(struct vbi *vbi, unsigned char *p)
Definition: vbi.c:325
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:340
static void vbi_send_page(struct vbi *vbi, struct raw_page *rvtp, int page)
Definition: vbi.c:83
int hamm24(unsigned char *p, int *err)
Definition: hamm.c:217
struct vt_page page[1]
Definition: vbi.h:17
static void out_of_sync(struct vbi *vbi)
Definition: vbi.c:52
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:145
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:400
static int rawbuf_size
Definition: vbi.c:33
#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 hamm8(unsigned char *p, int *err)
Definition: hamm.c:199
int flof
Definition: vt.h:44
#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:65
int vbi_add_handler(struct vbi *vbi, void *handler, void *data)
Definition: vbi.c:443
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
int bp8bl
Definition: vbi.h:41
#define PLL_ERROR
Definition: vbi.c:105
void vbi_del_handler(struct vbi *vbi, void *handler, void *data)
Definition: vbi.c:461
struct raw_page * ppage
Definition: vbi.h:32
void * p1
Definition: vt.h:13
void vbi_close(struct vbi *vbi)
Definition: vbi.c:658
static guint32 * p1
Definition: goom_core.c:35
void * resource
Definition: vt.h:11