drivers/media/firewire/firedtv-avc.c

Source file repositories/reference/linux-study-clean/drivers/media/firewire/firedtv-avc.c

File Facts

System
Linux kernel
Corpus path
drivers/media/firewire/firedtv-avc.c
Extension
.c
Size
41201 bytes
Lines
1476
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct avc_command_frame {
	u8 ctype;
	u8 subunit;
	u8 opcode;
	u8 operand[509];
};

struct avc_response_frame {
	u8 response;
	u8 subunit;
	u8 opcode;
	u8 operand[509];
};

#define LAST_OPERAND (509 - 1)

static inline void clear_operands(struct avc_command_frame *c, int from, int to)
{
	memset(&c->operand[from], 0, to - from + 1);
}

static void pad_operands(struct avc_command_frame *c, int from)
{
	int to = ALIGN(from, 4);

	if (from <= to && to <= LAST_OPERAND)
		clear_operands(c, from, to);
}

#define AVC_DEBUG_READ_DESCRIPTOR              0x0001
#define AVC_DEBUG_DSIT                         0x0002
#define AVC_DEBUG_DSD                          0x0004
#define AVC_DEBUG_REGISTER_REMOTE_CONTROL      0x0008
#define AVC_DEBUG_LNB_CONTROL                  0x0010
#define AVC_DEBUG_TUNE_QPSK                    0x0020
#define AVC_DEBUG_TUNE_QPSK2                   0x0040
#define AVC_DEBUG_HOST2CA                      0x0080
#define AVC_DEBUG_CA2HOST                      0x0100
#define AVC_DEBUG_APPLICATION_PMT              0x4000
#define AVC_DEBUG_FCP_PAYLOADS                 0x8000

static int avc_debug;
module_param_named(debug, avc_debug, int, 0644);
MODULE_PARM_DESC(debug, "Verbose logging (none = 0"
	", FCP subactions"
	": READ DESCRIPTOR = "		__stringify(AVC_DEBUG_READ_DESCRIPTOR)
	", DSIT = "			__stringify(AVC_DEBUG_DSIT)
	", REGISTER_REMOTE_CONTROL = "	__stringify(AVC_DEBUG_REGISTER_REMOTE_CONTROL)
	", LNB CONTROL = "		__stringify(AVC_DEBUG_LNB_CONTROL)
	", TUNE QPSK = "		__stringify(AVC_DEBUG_TUNE_QPSK)
	", TUNE QPSK2 = "		__stringify(AVC_DEBUG_TUNE_QPSK2)
	", HOST2CA = "			__stringify(AVC_DEBUG_HOST2CA)
	", CA2HOST = "			__stringify(AVC_DEBUG_CA2HOST)
	"; Application sent PMT = "	__stringify(AVC_DEBUG_APPLICATION_PMT)
	", FCP payloads = "		__stringify(AVC_DEBUG_FCP_PAYLOADS)
	", or a combination, or all = -1)");

/*
 * This is a workaround since there is no vendor specific command to retrieve
 * ca_info using AVC. If this parameter is not used, ca_system_id will be
 * filled with application_manufacturer from ca_app_info.
 * Digital Everywhere have said that adding ca_info is on their TODO list.
 */
static unsigned int num_fake_ca_system_ids;
static int fake_ca_system_ids[4] = { -1, -1, -1, -1 };
module_param_array(fake_ca_system_ids, int, &num_fake_ca_system_ids, 0644);
MODULE_PARM_DESC(fake_ca_system_ids, "If your CAM application manufacturer "
		 "does not have the same ca_system_id as your CAS, you can "
		 "override what ca_system_ids are presented to the "
		 "application by setting this field to an array of ids.");

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",		[0xf] = "INTERIM",
	};
	const char *ret = ctype < ARRAY_SIZE(ctypes) ? ctypes[ctype] : NULL;

	return ret ? ret : "?";
}

static const char *debug_fcp_opcode(unsigned int opcode,
				    const u8 *data, int length)
{
	switch (opcode) {

Annotation

Implementation Notes