18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * dvb_ca.h: generic DVB functions for EN50221 CA interfaces
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2004 Andrew de Quincey
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
78c2ecf20Sopenharmony_ci * modify it under the terms of the GNU Lesser General Public License
88c2ecf20Sopenharmony_ci * as published by the Free Software Foundation; either version 2.1
98c2ecf20Sopenharmony_ci * of the License, or (at your option) any later version.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful,
128c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
138c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
148c2ecf20Sopenharmony_ci * GNU General Public License for more details.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifndef _DVB_CA_EN50221_H_
188c2ecf20Sopenharmony_ci#define _DVB_CA_EN50221_H_
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include <linux/list.h>
218c2ecf20Sopenharmony_ci#include <linux/dvb/ca.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <media/dvbdev.h>
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_POLL_CAM_PRESENT	1
268c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_POLL_CAM_CHANGED	2
278c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_POLL_CAM_READY		4
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE	1
308c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_FLAG_IRQ_FR		2
318c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_FLAG_IRQ_DA		4
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_CAMCHANGE_REMOVED		0
348c2ecf20Sopenharmony_ci#define DVB_CA_EN50221_CAMCHANGE_INSERTED		1
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/**
378c2ecf20Sopenharmony_ci * struct dvb_ca_en50221- Structure describing a CA interface
388c2ecf20Sopenharmony_ci *
398c2ecf20Sopenharmony_ci * @owner:		the module owning this structure
408c2ecf20Sopenharmony_ci * @read_attribute_mem:	function for reading attribute memory on the CAM
418c2ecf20Sopenharmony_ci * @write_attribute_mem: function for writing attribute memory on the CAM
428c2ecf20Sopenharmony_ci * @read_cam_control:	function for reading the control interface on the CAM
438c2ecf20Sopenharmony_ci * @write_cam_control:	function for reading the control interface on the CAM
448c2ecf20Sopenharmony_ci * @read_data:		function for reading data (block mode)
458c2ecf20Sopenharmony_ci * @write_data:		function for writing data (block mode)
468c2ecf20Sopenharmony_ci * @slot_reset:		function to reset the CAM slot
478c2ecf20Sopenharmony_ci * @slot_shutdown:	function to shutdown a CAM slot
488c2ecf20Sopenharmony_ci * @slot_ts_enable:	function to enable the Transport Stream on a CAM slot
498c2ecf20Sopenharmony_ci * @poll_slot_status:	function to poll slot status. Only necessary if
508c2ecf20Sopenharmony_ci *			DVB_CA_FLAG_EN50221_IRQ_CAMCHANGE is not set.
518c2ecf20Sopenharmony_ci * @data:		private data, used by caller.
528c2ecf20Sopenharmony_ci * @private:		Opaque data used by the dvb_ca core. Do not modify!
538c2ecf20Sopenharmony_ci *
548c2ecf20Sopenharmony_ci * NOTE: the read_*, write_* and poll_slot_status functions will be
558c2ecf20Sopenharmony_ci * called for different slots concurrently and need to use locks where
568c2ecf20Sopenharmony_ci * and if appropriate. There will be no concurrent access to one slot.
578c2ecf20Sopenharmony_ci */
588c2ecf20Sopenharmony_cistruct dvb_ca_en50221 {
598c2ecf20Sopenharmony_ci	struct module *owner;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	int (*read_attribute_mem)(struct dvb_ca_en50221 *ca,
628c2ecf20Sopenharmony_ci				  int slot, int address);
638c2ecf20Sopenharmony_ci	int (*write_attribute_mem)(struct dvb_ca_en50221 *ca,
648c2ecf20Sopenharmony_ci				   int slot, int address, u8 value);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	int (*read_cam_control)(struct dvb_ca_en50221 *ca,
678c2ecf20Sopenharmony_ci				int slot, u8 address);
688c2ecf20Sopenharmony_ci	int (*write_cam_control)(struct dvb_ca_en50221 *ca,
698c2ecf20Sopenharmony_ci				 int slot, u8 address, u8 value);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	int (*read_data)(struct dvb_ca_en50221 *ca,
728c2ecf20Sopenharmony_ci			 int slot, u8 *ebuf, int ecount);
738c2ecf20Sopenharmony_ci	int (*write_data)(struct dvb_ca_en50221 *ca,
748c2ecf20Sopenharmony_ci			  int slot, u8 *ebuf, int ecount);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	int (*slot_reset)(struct dvb_ca_en50221 *ca, int slot);
778c2ecf20Sopenharmony_ci	int (*slot_shutdown)(struct dvb_ca_en50221 *ca, int slot);
788c2ecf20Sopenharmony_ci	int (*slot_ts_enable)(struct dvb_ca_en50221 *ca, int slot);
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	int (*poll_slot_status)(struct dvb_ca_en50221 *ca, int slot, int open);
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	void *data;
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	void *private;
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/*
888c2ecf20Sopenharmony_ci * Functions for reporting IRQ events
898c2ecf20Sopenharmony_ci */
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci/**
928c2ecf20Sopenharmony_ci * dvb_ca_en50221_camchange_irq - A CAMCHANGE IRQ has occurred.
938c2ecf20Sopenharmony_ci *
948c2ecf20Sopenharmony_ci * @pubca: CA instance.
958c2ecf20Sopenharmony_ci * @slot: Slot concerned.
968c2ecf20Sopenharmony_ci * @change_type: One of the DVB_CA_CAMCHANGE_* values
978c2ecf20Sopenharmony_ci */
988c2ecf20Sopenharmony_civoid dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot,
998c2ecf20Sopenharmony_ci				  int change_type);
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/**
1028c2ecf20Sopenharmony_ci * dvb_ca_en50221_camready_irq - A CAMREADY IRQ has occurred.
1038c2ecf20Sopenharmony_ci *
1048c2ecf20Sopenharmony_ci * @pubca: CA instance.
1058c2ecf20Sopenharmony_ci * @slot: Slot concerned.
1068c2ecf20Sopenharmony_ci */
1078c2ecf20Sopenharmony_civoid dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci/**
1108c2ecf20Sopenharmony_ci * dvb_ca_en50221_frda_irq - An FR or a DA IRQ has occurred.
1118c2ecf20Sopenharmony_ci *
1128c2ecf20Sopenharmony_ci * @ca: CA instance.
1138c2ecf20Sopenharmony_ci * @slot: Slot concerned.
1148c2ecf20Sopenharmony_ci */
1158c2ecf20Sopenharmony_civoid dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *ca, int slot);
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci/*
1188c2ecf20Sopenharmony_ci * Initialisation/shutdown functions
1198c2ecf20Sopenharmony_ci */
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/**
1228c2ecf20Sopenharmony_ci * dvb_ca_en50221_init - Initialise a new DVB CA device.
1238c2ecf20Sopenharmony_ci *
1248c2ecf20Sopenharmony_ci * @dvb_adapter: DVB adapter to attach the new CA device to.
1258c2ecf20Sopenharmony_ci * @ca: The dvb_ca instance.
1268c2ecf20Sopenharmony_ci * @flags: Flags describing the CA device (DVB_CA_EN50221_FLAG_*).
1278c2ecf20Sopenharmony_ci * @slot_count: Number of slots supported.
1288c2ecf20Sopenharmony_ci *
1298c2ecf20Sopenharmony_ci * @return 0 on success, nonzero on failure
1308c2ecf20Sopenharmony_ci */
1318c2ecf20Sopenharmony_ciint dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1328c2ecf20Sopenharmony_ci			struct dvb_ca_en50221 *ca, int flags,
1338c2ecf20Sopenharmony_ci			       int slot_count);
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/**
1368c2ecf20Sopenharmony_ci * dvb_ca_en50221_release - Release a DVB CA device.
1378c2ecf20Sopenharmony_ci *
1388c2ecf20Sopenharmony_ci * @ca: The associated dvb_ca instance.
1398c2ecf20Sopenharmony_ci */
1408c2ecf20Sopenharmony_civoid dvb_ca_en50221_release(struct dvb_ca_en50221 *ca);
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#endif
143