130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/*
230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ca.h
330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright (C) 2000 Ralph  Metzler <ralph@convergence.de>
530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *                  & Marcus Metzler <marcus@convergence.de>
630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *                    for convergence integrated media GmbH
730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * This program is free software; you can redistribute it and/or
930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * modify it under the terms of the GNU General Lesser Public License
1030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * as published by the Free Software Foundation; either version 2.1
1130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * of the License, or (at your option) any later version.
1230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * This program is distributed in the hope that it will be useful,
1430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * but WITHOUT ANY WARRANTY; without even the implied warranty of
1530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * GNU General Public License for more details.
1730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * You should have received a copy of the GNU Lesser General Public License
1930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * along with this program; if not, write to the Free Software
2030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
2130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
2230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */
2330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#ifndef _DVBCA_H_
2530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define _DVBCA_H_
2630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* slot interface types and info */
2830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2930692c65c4174412c90e79489e98ab85c1a7412fBen Chengtypedef struct ca_slot_info {
3030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	int num;               /* slot number */
3130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
3230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	int type;              /* CA interface this slot supports */
3330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_CI            1     /* CI high level interface */
3430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_CI_LINK       2     /* CI link layer level interface */
3530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_CI_PHYS       4     /* CI physical layer level interface */
3630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_DESCR         8     /* built-in descrambler */
3730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_SC          128     /* simple smart card interface */
3830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
3930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int flags;
4030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
4130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_CI_MODULE_READY   2
4230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} ca_slot_info_t;
4330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
4430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
4530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* descrambler types and info */
4630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
4730692c65c4174412c90e79489e98ab85c1a7412fBen Chengtypedef struct ca_descr_info {
4830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int num;          /* number of available descramblers (keys) */
4930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int type;         /* type of supported scrambling system */
5030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_ECD           1
5130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_NDS           2
5230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_DSS           4
5330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} ca_descr_info_t;
5430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
5530692c65c4174412c90e79489e98ab85c1a7412fBen Chengtypedef struct ca_caps {
5630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int slot_num;     /* total number of CA card and module slots */
5730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int slot_type;    /* OR of all supported types */
5830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int descr_num;    /* total number of descrambler slots (keys) */
5930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int descr_type;   /* OR of all supported types */
6030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} ca_caps_t;
6130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
6230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* a message to/from a CI-CAM */
6330692c65c4174412c90e79489e98ab85c1a7412fBen Chengtypedef struct ca_msg {
6430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int index;
6530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int type;
6630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int length;
6730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned char msg[256];
6830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} ca_msg_t;
6930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
7030692c65c4174412c90e79489e98ab85c1a7412fBen Chengtypedef struct ca_descr {
7130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int index;
7230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int parity;	/* 0 == even, 1 == odd */
7330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned char cw[8];
7430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} ca_descr_t;
7530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
7630692c65c4174412c90e79489e98ab85c1a7412fBen Chengtypedef struct ca_pid {
7730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned int pid;
7830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	int index;		/* -1 == disable*/
7930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} ca_pid_t;
8030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
8130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_RESET          _IO('o', 128)
8230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_GET_CAP        _IOR('o', 129, ca_caps_t)
8330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_GET_SLOT_INFO  _IOR('o', 130, ca_slot_info_t)
8430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t)
8530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_GET_MSG        _IOR('o', 132, ca_msg_t)
8630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_SEND_MSG       _IOW('o', 133, ca_msg_t)
8730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_SET_DESCR      _IOW('o', 134, ca_descr_t)
8830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CA_SET_PID        _IOW('o', 135, ca_pid_t)
8930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
9030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#endif
91