/*
* FireDTV driver (formerly known as FireSAT)
*
* Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
* Copyright (C) 2008 Ben Backx <ben@bbackx.com>
* Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include <linux/bug.h>
#include <linux/crc32.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <linux/string.h>
#include <linux/stringify.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
#include "firedtv.h"
#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL
#define AVC_CTYPE_CONTROL 0x0
#define AVC_CTYPE_STATUS 0x1
#define AVC_CTYPE_NOTIFY 0x3
#define AVC_RESPONSE_ACCEPTED 0x9
#define AVC_RESPONSE_STABLE 0xc
#define AVC_RESPONSE_CHANGED 0xd
#define AVC_RESPONSE_INTERIM 0xf
#define AVC_SUBUNIT_TYPE_TUNER (0x05 << 3)
#define AVC_SUBUNIT_TYPE_UNIT (0x1f << 3)
#define AVC_OPCODE_VENDOR 0x00
#define AVC_OPCODE_READ_DESCRIPTOR 0x09
#define AVC_OPCODE_DSIT 0xc8
#define AVC_OPCODE_DSD 0xcb
#define DESCRIPTOR_TUNER_STATUS 0x80
#define DESCRIPTOR_SUBUNIT_IDENTIFIER 0x00
#define SFE_VENDOR_DE_COMPANYID_0 0x00 /* OUI of Digital Everywhere */
#define SFE_VENDOR_DE_COMPANYID_1 0x12
#define SFE_VENDOR_DE_COMPANYID_2 0x87
#define SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL 0x0a
#define SFE_VENDOR_OPCODE_LNB_CONTROL 0x52
#define SFE_VENDOR_OPCODE_TUNE_QPSK 0x58 /* for DVB-S */
#define SFE_VENDOR_OPCODE_GET_FIRMWARE_VERSION 0x00
#define SFE_VENDOR_OPCODE_HOST2CA 0x56
#define SFE_VENDOR_OPCODE_CA2HOST 0x57
#define SFE_VENDOR_OPCODE_CISTATUS 0x59
#define SFE_VENDOR_OPCODE_TUNE_QPSK2 0x60 /* for DVB-S2 */
#define SFE_VENDOR_TAG_CA_RESET 0x00
#define SFE_VENDOR_TAG_CA_APPLICATION_INFO 0x01
#define SFE_VENDOR_TAG_CA_PMT 0x02
#define SFE_VENDOR_TAG_CA_DATE_TIME 0x04
#define SFE_VENDOR_TAG_CA_MMI 0x05
#define SFE_VENDOR_TAG_CA_ENTER_MENU 0x07
#define EN50221_LIST_MANAGEMENT_ONLY 0x03
#define EN50221_TAG_APP_INFO 0x9f8021
#define EN50221_TAG_CA_INFO 0x9f8031
struct avc_command_frame {
int length;
u8 ctype;
u8 subunit;
u8 opcode;
u8 operand[509];
};
struct avc_response_frame {
int length;
u8 response;
u8 subunit;
u8 opcode;
u8 operand[509];
};
#define AVC_DEBUG_FCP_SUBACTIONS 1
#define AVC_DEBUG_FCP_PAYLOADS 2
static int avc_debug;
module_param_named(debug, avc_debug, int, 0644);
MODULE_PARM_DESC(debug, "Verbose logging (default = 0"
", FCP subactions = " __stringify(AVC_DEBUG_FCP_SUBACTIONS)
", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS)
", or all = -1)");
static const char *debug_fcp_ctype(unsigned int ctype)
{
static const char *ctypes[] = {
[0x0] = "CONTROL", [0x1] = "STATUS",
[0x2] = "SPECIFIC INQUIRY", [0x3] = "NOTIFY",
[0x4] = "GENERAL INQUIRY", [0x8] = "NOT IMPLEMENTED",
[0x9] = "ACCEPTED", [0xa] = "REJECTED",
[0xb] = "IN TRANSITION", [0xc] = "IMPLEMENTED/STABLE",
[0xd] = "CHANGED&quo