1139749Simp/*-
2113584Ssimokawa * Copyright (c) 2003 Hidetoshi Shimokawa
3113584Ssimokawa * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
4103285Sikob * All rights reserved.
5103285Sikob *
6103285Sikob * Redistribution and use in source and binary forms, with or without
7103285Sikob * modification, are permitted provided that the following conditions
8103285Sikob * are met:
9103285Sikob * 1. Redistributions of source code must retain the above copyright
10103285Sikob *    notice, this list of conditions and the following disclaimer.
11103285Sikob * 2. Redistributions in binary form must reproduce the above copyright
12103285Sikob *    notice, this list of conditions and the following disclaimer in the
13103285Sikob *    documentation and/or other materials provided with the distribution.
14103285Sikob * 3. All advertising materials mentioning features or use of this software
15103285Sikob *    must display the acknowledgement as bellow:
16103285Sikob *
17103285Sikob *    This product includes software developed by K. Kobayashi and H. Shimokawa
18103285Sikob *
19103285Sikob * 4. The name of the author may not be used to endorse or promote products
20103285Sikob *    derived from this software without specific prior written permission.
21103285Sikob *
22103285Sikob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23103285Sikob * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24103285Sikob * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25103285Sikob * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26103285Sikob * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27103285Sikob * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28103285Sikob * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29103285Sikob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30103285Sikob * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31103285Sikob * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32103285Sikob * POSSIBILITY OF SUCH DAMAGE.
33103285Sikob *
34103285Sikob * $FreeBSD$
35103285Sikob *
36103285Sikob */
37114215Ssimokawa
38114215Ssimokawa#define		DV_BROADCAST_ON (1<<30)
39114215Ssimokawa#define		oMPR		0x900
40114215Ssimokawa#define		oPCR		0x904
41114215Ssimokawa#define		iMPR		0x980
42114215Ssimokawa#define		iPCR		0x984
43114215Ssimokawa
44103285Sikobstruct ciphdr {
45113584Ssimokawa#if BYTE_ORDER == BIG_ENDIAN
46129585Sdfr	uint8_t eoh0:1,		/* 0 */
47129585Sdfr		form0:1,	/* 0 */
48129585Sdfr		src:6;
49113584Ssimokawa#else
50129585Sdfr	uint8_t src:6,
51129585Sdfr		form0:1,	/* 0 */
52129585Sdfr		eoh0:1;		/* 0 */
53113584Ssimokawa#endif
54129585Sdfr	uint8_t len;
55113584Ssimokawa#if BYTE_ORDER == BIG_ENDIAN
56129585Sdfr	uint8_t fn:2,
57129585Sdfr		qpc:3,
58129585Sdfr		sph:1,
59129585Sdfr		:2;
60113584Ssimokawa#else
61129585Sdfr	uint8_t :2,
62129585Sdfr		sph:1,
63129585Sdfr		qpc:3,
64129585Sdfr		fn:2;
65113584Ssimokawa#endif
66129585Sdfr	uint8_t dbc;
67113584Ssimokawa#if BYTE_ORDER == BIG_ENDIAN
68129585Sdfr	uint8_t eoh1:1,		/* 1 */
69129585Sdfr		form1:1,	/* 0 */
70129585Sdfr		fmt:6;
71113584Ssimokawa#else
72129585Sdfr	uint8_t fmt:6,
73129585Sdfr		form1:1,	/* 0 */
74129585Sdfr		eoh1:1;		/* 1 */
75113584Ssimokawa#endif
76109178Ssimokawa#define CIP_FMT_DVCR	0
77109178Ssimokawa#define CIP_FMT_MPEG	(1<<5)
78109178Ssimokawa	union {
79109178Ssimokawa		struct {
80113584Ssimokawa#if BYTE_ORDER == BIG_ENDIAN
81129585Sdfr			uint8_t fs:1,		/* 50/60 field system
82113584Ssimokawa								NTSC/PAL */
83129585Sdfr				stype:5,
84129585Sdfr				:2;
85113584Ssimokawa#else
86129585Sdfr			uint8_t :2,
87129585Sdfr				stype:5,
88129585Sdfr		  		fs:1;		/* 50/60 field system
89113584Ssimokawa								NTSC/PAL */
90113584Ssimokawa#endif
91109178Ssimokawa#define	CIP_STYPE_SD	0
92109178Ssimokawa#define	CIP_STYPE_SDL	1
93109178Ssimokawa#define	CIP_STYPE_HD	2
94129585Sdfr	  		uint16_t cyc:16;	/* take care of byte order! */
95109178Ssimokawa		} __attribute__ ((packed)) dv;
96129585Sdfr		uint8_t bytes[3];
97109178Ssimokawa	} fdf;
98109178Ssimokawa
99103285Sikob};
100103285Sikobstruct dvdbc{
101113584Ssimokawa#if BYTE_ORDER == BIG_ENDIAN
102129585Sdfr	uint8_t sct:3,		/* Section type */
103129585Sdfr		:1,		/* Reserved */
104129585Sdfr		arb:4;		/* Arbitrary bit */
105113584Ssimokawa#else
106129585Sdfr	uint8_t arb:4,		/* Arbitrary bit */
107129585Sdfr		:1,		/* Reserved */
108129585Sdfr		sct:3;		/* Section type */
109113584Ssimokawa#endif
110109178Ssimokawa#define	DV_SCT_HEADER	0
111109178Ssimokawa#define	DV_SCT_SUBCODE	1
112109178Ssimokawa#define	DV_SCT_VAUX	2
113109178Ssimokawa#define	DV_SCT_AUDIO	3
114109178Ssimokawa#define	DV_SCT_VIDEO	4
115113584Ssimokawa#if BYTE_ORDER == BIG_ENDIAN
116129585Sdfr	uint8_t dseq:4,		/* DIF sequence number */
117129585Sdfr		fsc:1,		/* ID of a DIF block in each channel */
118129585Sdfr		:3;
119113584Ssimokawa#else
120129585Sdfr	uint8_t :3,
121129585Sdfr		fsc:1,		/* ID of a DIF block in each channel */
122129585Sdfr		dseq:4;		/* DIF sequence number */
123113584Ssimokawa#endif
124129585Sdfr	uint8_t dbn;		/* DIF block number */
125129585Sdfr	uint8_t payload[77];
126109178Ssimokawa#define	DV_DSF_12	0x80	/* PAL: payload[0] in Header DIF */
127103285Sikob};
128