^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * dvb_ca.h: generic DVB functions for EN50221 CA interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2004 Andrew de Quincey
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * modify it under the terms of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * as published by the Free Software Foundation; either version 2.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifndef _DVB_CA_EN50221_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define _DVB_CA_EN50221_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/dvb/ca.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <media/dvbdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define DVB_CA_EN50221_POLL_CAM_PRESENT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define DVB_CA_EN50221_POLL_CAM_CHANGED 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define DVB_CA_EN50221_POLL_CAM_READY 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define DVB_CA_EN50221_FLAG_IRQ_FR 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define DVB_CA_EN50221_FLAG_IRQ_DA 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define DVB_CA_EN50221_CAMCHANGE_REMOVED 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define DVB_CA_EN50221_CAMCHANGE_INSERTED 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * struct dvb_ca_en50221- Structure describing a CA interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * @owner: the module owning this structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * @read_attribute_mem: function for reading attribute memory on the CAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * @write_attribute_mem: function for writing attribute memory on the CAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * @read_cam_control: function for reading the control interface on the CAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * @write_cam_control: function for reading the control interface on the CAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @read_data: function for reading data (block mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * @write_data: function for writing data (block mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @slot_reset: function to reset the CAM slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @slot_shutdown: function to shutdown a CAM slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @slot_ts_enable: function to enable the Transport Stream on a CAM slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @poll_slot_status: function to poll slot status. Only necessary if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * DVB_CA_FLAG_EN50221_IRQ_CAMCHANGE is not set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @data: private data, used by caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @private: Opaque data used by the dvb_ca core. Do not modify!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * NOTE: the read_*, write_* and poll_slot_status functions will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * called for different slots concurrently and need to use locks where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * and if appropriate. There will be no concurrent access to one slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct dvb_ca_en50221 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct module *owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int (*read_attribute_mem)(struct dvb_ca_en50221 *ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int slot, int address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int (*write_attribute_mem)(struct dvb_ca_en50221 *ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int slot, int address, u8 value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int (*read_cam_control)(struct dvb_ca_en50221 *ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int slot, u8 address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int (*write_cam_control)(struct dvb_ca_en50221 *ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int slot, u8 address, u8 value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int (*read_data)(struct dvb_ca_en50221 *ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int slot, u8 *ebuf, int ecount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) int (*write_data)(struct dvb_ca_en50221 *ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int slot, u8 *ebuf, int ecount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int (*slot_reset)(struct dvb_ca_en50221 *ca, int slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int (*slot_shutdown)(struct dvb_ca_en50221 *ca, int slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) int (*slot_ts_enable)(struct dvb_ca_en50221 *ca, int slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) int (*poll_slot_status)(struct dvb_ca_en50221 *ca, int slot, int open);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) void *private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * Functions for reporting IRQ events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * dvb_ca_en50221_camchange_irq - A CAMCHANGE IRQ has occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @pubca: CA instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * @slot: Slot concerned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * @change_type: One of the DVB_CA_CAMCHANGE_* values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) int change_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * dvb_ca_en50221_camready_irq - A CAMREADY IRQ has occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * @pubca: CA instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * @slot: Slot concerned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * dvb_ca_en50221_frda_irq - An FR or a DA IRQ has occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * @ca: CA instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * @slot: Slot concerned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *ca, int slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * Initialisation/shutdown functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * dvb_ca_en50221_init - Initialise a new DVB CA device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * @dvb_adapter: DVB adapter to attach the new CA device to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * @ca: The dvb_ca instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * @flags: Flags describing the CA device (DVB_CA_EN50221_FLAG_*).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * @slot_count: Number of slots supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * @return 0 on success, nonzero on failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct dvb_ca_en50221 *ca, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int slot_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * dvb_ca_en50221_release - Release a DVB CA device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * @ca: The associated dvb_ca instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) void dvb_ca_en50221_release(struct dvb_ca_en50221 *ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #endif