1 /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
2 /*
3  * ca.h
4  *
5  * Copyright (C) 2000 Ralph  Metzler <ralph@convergence.de>
6  *                  & Marcus Metzler <marcus@convergence.de>
7  *                    for convergence integrated media GmbH
8  */
9 
10 #ifndef _DVBCA_H_
11 #define _DVBCA_H_
12 
13 /**
14  * struct ca_slot_info - CA slot interface types and info.
15  *
16  * @num:	slot number.
17  * @type:	slot type.
18  * @flags:	flags applicable to the slot.
19  *
20  * This struct stores the CA slot information.
21  *
22  * @type can be:
23  *
24  *	- %CA_CI - CI high level interface;
25  *	- %CA_CI_LINK - CI link layer level interface;
26  *	- %CA_CI_PHYS - CI physical layer level interface;
27  *	- %CA_DESCR - built-in descrambler;
28  *	- %CA_SC -simple smart card interface.
29  *
30  * @flags can be:
31  *
32  *	- %CA_CI_MODULE_PRESENT - module (or card) inserted;
33  *	- %CA_CI_MODULE_READY - module is ready for usage.
34  */
35 
36 struct ca_slot_info {
37 	int num;
38 	int type;
39 #define CA_CI            1
40 #define CA_CI_LINK       2
41 #define CA_CI_PHYS       4
42 #define CA_DESCR         8
43 #define CA_SC          128
44 
45 	unsigned int flags;
46 #define CA_CI_MODULE_PRESENT 1
47 #define CA_CI_MODULE_READY   2
48 };
49 
50 
51 /**
52  * struct ca_descr_info - descrambler types and info.
53  *
54  * @num:	number of available descramblers (keys).
55  * @type:	type of supported scrambling system.
56  *
57  * Identifies the number of descramblers and their type.
58  *
59  * @type can be:
60  *
61  *	- %CA_ECD - European Common Descrambler (ECD) hardware;
62  *	- %CA_NDS - Videoguard (NDS) hardware;
63  *	- %CA_DSS - Distributed Sample Scrambling (DSS) hardware.
64  */
65 struct ca_descr_info {
66 	unsigned int num;
67 	unsigned int type;
68 #define CA_ECD           1
69 #define CA_NDS           2
70 #define CA_DSS           4
71 };
72 
73 /**
74  * struct ca_caps - CA slot interface capabilities.
75  *
76  * @slot_num:	total number of CA card and module slots.
77  * @slot_type:	bitmap with all supported types as defined at
78  *		&struct ca_slot_info (e. g. %CA_CI, %CA_CI_LINK, etc).
79  * @descr_num:	total number of descrambler slots (keys)
80  * @descr_type:	bitmap with all supported types as defined at
81  *		&struct ca_descr_info (e. g. %CA_ECD, %CA_NDS, etc).
82  */
83 struct ca_caps {
84 	unsigned int slot_num;
85 	unsigned int slot_type;
86 	unsigned int descr_num;
87 	unsigned int descr_type;
88 };
89 
90 /**
91  * struct ca_msg - a message to/from a CI-CAM
92  *
93  * @index:	unused
94  * @type:	unused
95  * @length:	length of the message
96  * @msg:	message
97  *
98  * This struct carries a message to be send/received from a CI CA module.
99  */
100 struct ca_msg {
101 	unsigned int index;
102 	unsigned int type;
103 	unsigned int length;
104 	unsigned char msg[256];
105 };
106 
107 /**
108  * struct ca_descr - CA descrambler control words info
109  *
110  * @index: CA Descrambler slot
111  * @parity: control words parity, where 0 means even and 1 means odd
112  * @cw: CA Descrambler control words
113  */
114 struct ca_descr {
115 	unsigned int index;
116 	unsigned int parity;
117 	unsigned char cw[8];
118 };
119 
120 #define CA_RESET          _IO('o', 128)
121 #define CA_GET_CAP        _IOR('o', 129, struct ca_caps)
122 #define CA_GET_SLOT_INFO  _IOR('o', 130, struct ca_slot_info)
123 #define CA_GET_DESCR_INFO _IOR('o', 131, struct ca_descr_info)
124 #define CA_GET_MSG        _IOR('o', 132, struct ca_msg)
125 #define CA_SEND_MSG       _IOW('o', 133, struct ca_msg)
126 #define CA_SET_DESCR      _IOW('o', 134, struct ca_descr)
127 
128 #if !defined(__KERNEL__)
129 
130 /* This is needed for legacy userspace support */
131 typedef struct ca_slot_info ca_slot_info_t;
132 typedef struct ca_descr_info  ca_descr_info_t;
133 typedef struct ca_caps  ca_caps_t;
134 typedef struct ca_msg ca_msg_t;
135 typedef struct ca_descr ca_descr_t;
136 
137 #endif
138 
139 
140 #endif
141