xref: /linux/drivers/media/common/b2c2/flexcop-misc.c (revision 3785bc170f79ef04129731582b468c28e1326d6d)
1*3785bc17SMauro Carvalho Chehab /*
2*3785bc17SMauro Carvalho Chehab  * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3*3785bc17SMauro Carvalho Chehab  * flexcop-misc.c - miscellaneous functions
4*3785bc17SMauro Carvalho Chehab  * see flexcop.c for copyright information
5*3785bc17SMauro Carvalho Chehab  */
6*3785bc17SMauro Carvalho Chehab #include "flexcop.h"
7*3785bc17SMauro Carvalho Chehab 
8*3785bc17SMauro Carvalho Chehab void flexcop_determine_revision(struct flexcop_device *fc)
9*3785bc17SMauro Carvalho Chehab {
10*3785bc17SMauro Carvalho Chehab 	flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204);
11*3785bc17SMauro Carvalho Chehab 
12*3785bc17SMauro Carvalho Chehab 	switch (v.misc_204.Rev_N_sig_revision_hi) {
13*3785bc17SMauro Carvalho Chehab 	case 0x2:
14*3785bc17SMauro Carvalho Chehab 		deb_info("found a FlexCopII.\n");
15*3785bc17SMauro Carvalho Chehab 		fc->rev = FLEXCOP_II;
16*3785bc17SMauro Carvalho Chehab 		break;
17*3785bc17SMauro Carvalho Chehab 	case 0x3:
18*3785bc17SMauro Carvalho Chehab 		deb_info("found a FlexCopIIb.\n");
19*3785bc17SMauro Carvalho Chehab 		fc->rev = FLEXCOP_IIB;
20*3785bc17SMauro Carvalho Chehab 		break;
21*3785bc17SMauro Carvalho Chehab 	case 0x0:
22*3785bc17SMauro Carvalho Chehab 		deb_info("found a FlexCopIII.\n");
23*3785bc17SMauro Carvalho Chehab 		fc->rev = FLEXCOP_III;
24*3785bc17SMauro Carvalho Chehab 		break;
25*3785bc17SMauro Carvalho Chehab 	default:
26*3785bc17SMauro Carvalho Chehab 		err("unknown FlexCop Revision: %x. Please report this to "
27*3785bc17SMauro Carvalho Chehab 				"linux-dvb@linuxtv.org.",
28*3785bc17SMauro Carvalho Chehab 				v.misc_204.Rev_N_sig_revision_hi);
29*3785bc17SMauro Carvalho Chehab 		break;
30*3785bc17SMauro Carvalho Chehab 	}
31*3785bc17SMauro Carvalho Chehab 
32*3785bc17SMauro Carvalho Chehab 	if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps))
33*3785bc17SMauro Carvalho Chehab 		deb_info("this FlexCop has "
34*3785bc17SMauro Carvalho Chehab 				"the additional 32 hardware pid filter.\n");
35*3785bc17SMauro Carvalho Chehab 	else
36*3785bc17SMauro Carvalho Chehab 		deb_info("this FlexCop has "
37*3785bc17SMauro Carvalho Chehab 				"the 6 basic main hardware pid filter.\n");
38*3785bc17SMauro Carvalho Chehab 	/* bus parts have to decide if hw pid filtering is used or not. */
39*3785bc17SMauro Carvalho Chehab }
40*3785bc17SMauro Carvalho Chehab 
41*3785bc17SMauro Carvalho Chehab static const char *flexcop_revision_names[] = {
42*3785bc17SMauro Carvalho Chehab 	"Unknown chip",
43*3785bc17SMauro Carvalho Chehab 	"FlexCopII",
44*3785bc17SMauro Carvalho Chehab 	"FlexCopIIb",
45*3785bc17SMauro Carvalho Chehab 	"FlexCopIII",
46*3785bc17SMauro Carvalho Chehab };
47*3785bc17SMauro Carvalho Chehab 
48*3785bc17SMauro Carvalho Chehab static const char *flexcop_device_names[] = {
49*3785bc17SMauro Carvalho Chehab 	[FC_UNK]	= "Unknown device",
50*3785bc17SMauro Carvalho Chehab 	[FC_CABLE]	= "Cable2PC/CableStar 2 DVB-C",
51*3785bc17SMauro Carvalho Chehab 	[FC_AIR_DVBT]	= "Air2PC/AirStar 2 DVB-T",
52*3785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC1]	= "Air2PC/AirStar 2 ATSC 1st generation",
53*3785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC2]	= "Air2PC/AirStar 2 ATSC 2nd generation",
54*3785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC3]	= "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)",
55*3785bc17SMauro Carvalho Chehab 	[FC_SKY_REV23]	= "Sky2PC/SkyStar 2 DVB-S rev 2.3 (old version)",
56*3785bc17SMauro Carvalho Chehab 	[FC_SKY_REV26]	= "Sky2PC/SkyStar 2 DVB-S rev 2.6",
57*3785bc17SMauro Carvalho Chehab 	[FC_SKY_REV27]	= "Sky2PC/SkyStar 2 DVB-S rev 2.7a/u",
58*3785bc17SMauro Carvalho Chehab 	[FC_SKY_REV28]	= "Sky2PC/SkyStar 2 DVB-S rev 2.8",
59*3785bc17SMauro Carvalho Chehab };
60*3785bc17SMauro Carvalho Chehab 
61*3785bc17SMauro Carvalho Chehab static const char *flexcop_bus_names[] = {
62*3785bc17SMauro Carvalho Chehab 	"USB",
63*3785bc17SMauro Carvalho Chehab 	"PCI",
64*3785bc17SMauro Carvalho Chehab };
65*3785bc17SMauro Carvalho Chehab 
66*3785bc17SMauro Carvalho Chehab void flexcop_device_name(struct flexcop_device *fc,
67*3785bc17SMauro Carvalho Chehab 		const char *prefix, const char *suffix)
68*3785bc17SMauro Carvalho Chehab {
69*3785bc17SMauro Carvalho Chehab 	info("%s '%s' at the '%s' bus controlled by a '%s' %s",
70*3785bc17SMauro Carvalho Chehab 			prefix,	flexcop_device_names[fc->dev_type],
71*3785bc17SMauro Carvalho Chehab 			flexcop_bus_names[fc->bus_type],
72*3785bc17SMauro Carvalho Chehab 			flexcop_revision_names[fc->rev], suffix);
73*3785bc17SMauro Carvalho Chehab }
74*3785bc17SMauro Carvalho Chehab 
75*3785bc17SMauro Carvalho Chehab void flexcop_dump_reg(struct flexcop_device *fc,
76*3785bc17SMauro Carvalho Chehab 		flexcop_ibi_register reg, int num)
77*3785bc17SMauro Carvalho Chehab {
78*3785bc17SMauro Carvalho Chehab 	flexcop_ibi_value v;
79*3785bc17SMauro Carvalho Chehab 	int i;
80*3785bc17SMauro Carvalho Chehab 	for (i = 0; i < num; i++) {
81*3785bc17SMauro Carvalho Chehab 		v = fc->read_ibi_reg(fc, reg+4*i);
82*3785bc17SMauro Carvalho Chehab 		deb_rdump("0x%03x: %08x, ", reg+4*i, v.raw);
83*3785bc17SMauro Carvalho Chehab 	}
84*3785bc17SMauro Carvalho Chehab 	deb_rdump("\n");
85*3785bc17SMauro Carvalho Chehab }
86*3785bc17SMauro Carvalho Chehab EXPORT_SYMBOL(flexcop_dump_reg);
87