blob: dffa59e95ebbf2f4642720e67f01417c4aa95e9c [file] [log] [blame]
Greg Kroah-Hartmane2be04c2017-11-01 15:09:13 +01001/* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Lesser Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 */
24
25#ifndef _DVBCA_H_
26#define _DVBCA_H_
27
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040028/**
29 * struct ca_slot_info - CA slot interface types and info.
30 *
31 * @num: slot number.
32 * @type: slot type.
33 * @flags: flags applicable to the slot.
34 *
35 * This struct stores the CA slot information.
36 *
37 * @type can be:
38 *
39 * - %CA_CI - CI high level interface;
40 * - %CA_CI_LINK - CI link layer level interface;
41 * - %CA_CI_PHYS - CI physical layer level interface;
42 * - %CA_DESCR - built-in descrambler;
43 * - %CA_SC -simple smart card interface.
44 *
45 * @flags can be:
46 *
47 * - %CA_CI_MODULE_PRESENT - module (or card) inserted;
48 * - %CA_CI_MODULE_READY - module is ready for usage.
49 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040051struct ca_slot_info {
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040052 int num;
53 int type;
54#define CA_CI 1
55#define CA_CI_LINK 2
56#define CA_CI_PHYS 4
57#define CA_DESCR 8
58#define CA_SC 128
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080060 unsigned int flags;
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040061#define CA_CI_MODULE_PRESENT 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#define CA_CI_MODULE_READY 2
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040063};
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040066/**
67 * struct ca_descr_info - descrambler types and info.
68 *
69 * @num: number of available descramblers (keys).
70 * @type: type of supported scrambling system.
71 *
72 * Identifies the number of descramblers and their type.
73 *
74 * @type can be:
75 *
76 * - %CA_ECD - European Common Descrambler (ECD) hardware;
77 * - %CA_NDS - Videoguard (NDS) hardware;
78 * - %CA_DSS - Distributed Sample Scrambling (DSS) hardware.
79 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040080struct ca_descr_info {
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040081 unsigned int num;
82 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#define CA_ECD 1
84#define CA_NDS 2
85#define CA_DSS 4
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040086};
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040088/**
89 * struct ca_caps - CA slot interface capabilities.
90 *
91 * @slot_num: total number of CA card and module slots.
92 * @slot_type: bitmap with all supported types as defined at
93 * &struct ca_slot_info (e. g. %CA_CI, %CA_CI_LINK, etc).
94 * @descr_num: total number of descrambler slots (keys)
95 * @descr_type: bitmap with all supported types as defined at
96 * &struct ca_descr_info (e. g. %CA_ECD, %CA_NDS, etc).
97 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -040098struct ca_caps {
Mauro Carvalho Chehabfed7c4f2017-09-01 07:48:02 -040099 unsigned int slot_num;
100 unsigned int slot_type;
101 unsigned int descr_num;
102 unsigned int descr_type;
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400103};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Mauro Carvalho Chehab7e6854a2017-09-04 08:03:40 -0400105/**
106 * struct ca_msg - a message to/from a CI-CAM
107 *
108 * @index: unused
109 * @type: unused
110 * @length: length of the message
111 * @msg: message
112 *
113 * This struct carries a message to be send/received from a CI CA module.
114 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400115struct ca_msg {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800116 unsigned int index;
117 unsigned int type;
118 unsigned int length;
119 unsigned char msg[256];
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400120};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Mauro Carvalho Chehabbd9049e2017-09-03 20:50:17 -0400122/**
123 * struct ca_descr - CA descrambler control words info
124 *
125 * @index: CA Descrambler slot
126 * @parity: control words parity, where 0 means even and 1 means odd
127 * @cw: CA Descrambler control words
128 */
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400129struct ca_descr {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800130 unsigned int index;
Mauro Carvalho Chehabbd9049e2017-09-03 20:50:17 -0400131 unsigned int parity;
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800132 unsigned char cw[8];
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400133};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#define CA_RESET _IO('o', 128)
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400136#define CA_GET_CAP _IOR('o', 129, struct ca_caps)
137#define CA_GET_SLOT_INFO _IOR('o', 130, struct ca_slot_info)
138#define CA_GET_DESCR_INFO _IOR('o', 131, struct ca_descr_info)
139#define CA_GET_MSG _IOR('o', 132, struct ca_msg)
140#define CA_SEND_MSG _IOW('o', 133, struct ca_msg)
141#define CA_SET_DESCR _IOW('o', 134, struct ca_descr)
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400142
Mauro Carvalho Chehabe4faa092017-09-05 07:02:44 -0400143#if !defined(__KERNEL__)
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400144
145/* This is needed for legacy userspace support */
146typedef struct ca_slot_info ca_slot_info_t;
147typedef struct ca_descr_info ca_descr_info_t;
148typedef struct ca_caps ca_caps_t;
149typedef struct ca_msg ca_msg_t;
150typedef struct ca_descr ca_descr_t;
Mauro Carvalho Chehabc93022a2017-09-01 05:43:39 -0400151
152#endif
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155#endif