| 1 |
/* |
| 2 |
* Raw VBI to sliced VBI parser. |
| 3 |
* |
| 4 |
* The slicing code was copied from libzvbi. The original copyright notice is: |
| 5 |
* |
| 6 |
* Copyright (C) 2000-2004 Michael H. Schimek |
| 7 |
* |
| 8 |
* The vbi_prepare/vbi_parse functions are: |
| 9 |
* |
| 10 |
* Copyright (C) 2012 Hans Verkuil <[email protected]> |
| 11 |
* |
| 12 |
* This library is free software; you can redistribute it and/or |
| 13 |
* modify it under the terms of the GNU Library General Public |
| 14 |
* License as published by the Free Software Foundation; either |
| 15 |
* version 2 of the License, or (at your option) any later version. |
| 16 |
* |
| 17 |
* This library is distributed in the hope that it will be useful, |
| 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 |
* Library General Public License for more details. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU Library General Public |
| 23 |
* License along with this library; if not, write to the |
| 24 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 25 |
* Boston, MA 02110-1301 USA. |
| 26 |
*/ |
| 27 |
|
| 28 |
#ifndef _RAW2SLICED_H |
| 29 |
#define _RAW2SLICED_H |
| 30 |
|
| 31 |
#include <linux/videodev2.h> |
| 32 |
|
| 33 |
#define VBI_MAX_SERVICES (3) |
| 34 |
|
| 35 |
// Bit slicer internal struct |
| 36 |
struct vbi_bit_slicer { |
| 37 |
unsigned int service; |
| 38 |
unsigned int cri; |
| 39 |
unsigned int cri_mask; |
| 40 |
unsigned int thresh; |
| 41 |
unsigned int thresh_frac; |
| 42 |
unsigned int cri_samples; |
| 43 |
unsigned int cri_rate; |
| 44 |
unsigned int oversampling_rate; |
| 45 |
unsigned int phase_shift; |
| 46 |
unsigned int step; |
| 47 |
unsigned int frc; |
| 48 |
unsigned int frc_bits; |
| 49 |
unsigned int payload; |
| 50 |
unsigned int endian; |
| 51 |
}; |
| 52 |
|
| 53 |
struct vbi_handle { |
| 54 |
unsigned services; |
| 55 |
unsigned start_of_field_2; |
| 56 |
unsigned stride; |
| 57 |
bool interlaced; |
| 58 |
int start[2]; |
| 59 |
int count[2]; |
| 60 |
struct vbi_bit_slicer slicers[VBI_MAX_SERVICES]; |
| 61 |
}; |
| 62 |
|
| 63 |
// Fills in vbi_handle based on the standard and VBI format |
| 64 |
// Returns true if one or more services are valid for the fmt/std combination. |
| 65 |
bool vbi_prepare(struct vbi_handle *vh, |
| 66 |
const struct v4l2_vbi_format *fmt, v4l2_std_id std); |
| 67 |
|
| 68 |
// Parses the raw buffer and fills in sliced_vbi_format and _data. |
| 69 |
// data must be an array of count[0] + count[1] v4l2_sliced_vbi_data structs. |
| 70 |
void vbi_parse(struct vbi_handle *vh, const unsigned char *buf, |
| 71 |
struct v4l2_sliced_vbi_format *vbi, |
| 72 |
struct v4l2_sliced_vbi_data *data); |
| 73 |
|
| 74 |
#endif |