blob: cb150029fdffab2ece722f7a888ab286a0c310fd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ca.h
3 *
4 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
5 * & Marcus Metzler <marcus@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Lesser Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBCA_H_
25#define _DVBCA_H_
26
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040027/**
28 * struct ca_slot_info - CA slot interface types and info.
29 *
30 * @num: slot number.
31 * @type: slot type.
32 * @flags: flags applicable to the slot.
33 *
34 * This struct stores the CA slot information.
35 *
36 * @type can be:
37 *
38 * - %CA_CI - CI high level interface;
39 * - %CA_CI_LINK - CI link layer level interface;
40 * - %CA_CI_PHYS - CI physical layer level interface;
41 * - %CA_DESCR - built-in descrambler;
42 * - %CA_SC -simple smart card interface.
43 *
44 * @flags can be:
45 *
46 * - %CA_CI_MODULE_PRESENT - module (or card) inserted;
47 * - %CA_CI_MODULE_READY - module is ready for usage.
48 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040050struct ca_slot_info {
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040051 int num;
52 int type;
53#define CA_CI 1
54#define CA_CI_LINK 2
55#define CA_CI_PHYS 4
56#define CA_DESCR 8
57#define CA_SC 128
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080059 unsigned int flags;
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040060#define CA_CI_MODULE_PRESENT 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#define CA_CI_MODULE_READY 2
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040062};
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040065/**
66 * struct ca_descr_info - descrambler types and info.
67 *
68 * @num: number of available descramblers (keys).
69 * @type: type of supported scrambling system.
70 *
71 * Identifies the number of descramblers and their type.
72 *
73 * @type can be:
74 *
75 * - %CA_ECD - European Common Descrambler (ECD) hardware;
76 * - %CA_NDS - Videoguard (NDS) hardware;
77 * - %CA_DSS - Distributed Sample Scrambling (DSS) hardware.
78 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040079struct ca_descr_info {
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040080 unsigned int num;
81 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#define CA_ECD 1
83#define CA_NDS 2
84#define CA_DSS 4
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040085};
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040087/**
88 * struct ca_caps - CA slot interface capabilities.
89 *
90 * @slot_num: total number of CA card and module slots.
91 * @slot_type: bitmap with all supported types as defined at
92 * &struct ca_slot_info (e. g. %CA_CI, %CA_CI_LINK, etc).
93 * @descr_num: total number of descrambler slots (keys)
94 * @descr_type: bitmap with all supported types as defined at
95 * &struct ca_descr_info (e. g. %CA_ECD, %CA_NDS, etc).
96 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040097struct ca_caps {
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040098 unsigned int slot_num;
99 unsigned int slot_type;
100 unsigned int descr_num;
101 unsigned int descr_type;
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400102};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Mauro Carvalho Chehab7e6854a2017-09-04 08:03:40 -0400104/**
105 * struct ca_msg - a message to/from a CI-CAM
106 *
107 * @index: unused
108 * @type: unused
109 * @length: length of the message
110 * @msg: message
111 *
112 * This struct carries a message to be send/received from a CI CA module.
113 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400114struct ca_msg {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800115 unsigned int index;
116 unsigned int type;
117 unsigned int length;
118 unsigned char msg[256];
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400119};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Mauro Carvalho Chehabbd9049e2017-09-03 20:50:17 -0400121/**
122 * struct ca_descr - CA descrambler control words info
123 *
124 * @index: CA Descrambler slot
125 * @parity: control words parity, where 0 means even and 1 means odd
126 * @cw: CA Descrambler control words
127 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400128struct ca_descr {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800129 unsigned int index;
Mauro Carvalho Chehabbd9049e2017-09-03 20:50:17 -0400130 unsigned int parity;
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800131 unsigned char cw[8];
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400132};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#define CA_RESET _IO('o', 128)
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400135#define CA_GET_CAP _IOR('o', 129, struct ca_caps)
136#define CA_GET_SLOT_INFO _IOR('o', 130, struct ca_slot_info)
137#define CA_GET_DESCR_INFO _IOR('o', 131, struct ca_descr_info)
138#define CA_GET_MSG _IOR('o', 132, struct ca_msg)
139#define CA_SEND_MSG _IOW('o', 133, struct ca_msg)
140#define CA_SET_DESCR _IOW('o', 134, struct ca_descr)
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400141
Mauro Carvalho Chehabe4faa092017-09-05 07:02:44 -0400142#if !defined(__KERNEL__)
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400143
144/* This is needed for legacy userspace support */
145typedef struct ca_slot_info ca_slot_info_t;
146typedef struct ca_descr_info ca_descr_info_t;
147typedef struct ca_caps ca_caps_t;
148typedef struct ca_msg ca_msg_t;
149typedef struct ca_descr ca_descr_t;
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400150
151#endif
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154#endif