xref: /linux/drivers/media/common/b2c2/flexcop-misc.c (revision d9942ad0228a7e1a46a24f7962cb790443042da3)
13785bc17SMauro Carvalho Chehab /*
23785bc17SMauro Carvalho Chehab  * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
33785bc17SMauro Carvalho Chehab  * flexcop-misc.c - miscellaneous functions
43785bc17SMauro Carvalho Chehab  * see flexcop.c for copyright information
53785bc17SMauro Carvalho Chehab  */
63785bc17SMauro Carvalho Chehab #include "flexcop.h"
73785bc17SMauro Carvalho Chehab 
83785bc17SMauro Carvalho Chehab void flexcop_determine_revision(struct flexcop_device *fc)
93785bc17SMauro Carvalho Chehab {
103785bc17SMauro Carvalho Chehab 	flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204);
113785bc17SMauro Carvalho Chehab 
123785bc17SMauro Carvalho Chehab 	switch (v.misc_204.Rev_N_sig_revision_hi) {
133785bc17SMauro Carvalho Chehab 	case 0x2:
143785bc17SMauro Carvalho Chehab 		deb_info("found a FlexCopII.\n");
153785bc17SMauro Carvalho Chehab 		fc->rev = FLEXCOP_II;
163785bc17SMauro Carvalho Chehab 		break;
173785bc17SMauro Carvalho Chehab 	case 0x3:
183785bc17SMauro Carvalho Chehab 		deb_info("found a FlexCopIIb.\n");
193785bc17SMauro Carvalho Chehab 		fc->rev = FLEXCOP_IIB;
203785bc17SMauro Carvalho Chehab 		break;
213785bc17SMauro Carvalho Chehab 	case 0x0:
223785bc17SMauro Carvalho Chehab 		deb_info("found a FlexCopIII.\n");
233785bc17SMauro Carvalho Chehab 		fc->rev = FLEXCOP_III;
243785bc17SMauro Carvalho Chehab 		break;
253785bc17SMauro Carvalho Chehab 	default:
26*d9942ad0SMauro Carvalho Chehab 		err("unknown FlexCop Revision: %x. Please report this to linux-dvb@linuxtv.org.",
273785bc17SMauro Carvalho Chehab 				v.misc_204.Rev_N_sig_revision_hi);
283785bc17SMauro Carvalho Chehab 		break;
293785bc17SMauro Carvalho Chehab 	}
303785bc17SMauro Carvalho Chehab 
313785bc17SMauro Carvalho Chehab 	if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps))
32*d9942ad0SMauro Carvalho Chehab 		deb_info("this FlexCop has the additional 32 hardware pid filter.\n");
333785bc17SMauro Carvalho Chehab 	else
34*d9942ad0SMauro Carvalho Chehab 		deb_info("this FlexCop has the 6 basic main hardware pid filter.\n");
353785bc17SMauro Carvalho Chehab 	/* bus parts have to decide if hw pid filtering is used or not. */
363785bc17SMauro Carvalho Chehab }
373785bc17SMauro Carvalho Chehab 
383785bc17SMauro Carvalho Chehab static const char *flexcop_revision_names[] = {
393785bc17SMauro Carvalho Chehab 	"Unknown chip",
403785bc17SMauro Carvalho Chehab 	"FlexCopII",
413785bc17SMauro Carvalho Chehab 	"FlexCopIIb",
423785bc17SMauro Carvalho Chehab 	"FlexCopIII",
433785bc17SMauro Carvalho Chehab };
443785bc17SMauro Carvalho Chehab 
453785bc17SMauro Carvalho Chehab static const char *flexcop_device_names[] = {
463785bc17SMauro Carvalho Chehab 	[FC_UNK]	= "Unknown device",
473785bc17SMauro Carvalho Chehab 	[FC_CABLE]	= "Cable2PC/CableStar 2 DVB-C",
483785bc17SMauro Carvalho Chehab 	[FC_AIR_DVBT]	= "Air2PC/AirStar 2 DVB-T",
493785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC1]	= "Air2PC/AirStar 2 ATSC 1st generation",
503785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC2]	= "Air2PC/AirStar 2 ATSC 2nd generation",
513785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC3]	= "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)",
523785bc17SMauro Carvalho Chehab 	[FC_SKY_REV23]	= "Sky2PC/SkyStar 2 DVB-S rev 2.3 (old version)",
533785bc17SMauro Carvalho Chehab 	[FC_SKY_REV26]	= "Sky2PC/SkyStar 2 DVB-S rev 2.6",
543785bc17SMauro Carvalho Chehab 	[FC_SKY_REV27]	= "Sky2PC/SkyStar 2 DVB-S rev 2.7a/u",
553785bc17SMauro Carvalho Chehab 	[FC_SKY_REV28]	= "Sky2PC/SkyStar 2 DVB-S rev 2.8",
565afc9a25SJemma Denson 	[FC_SKYS2_REV33] = "Sky2PC/SkyStar S2 DVB-S/S2 rev 3.3",
573785bc17SMauro Carvalho Chehab };
583785bc17SMauro Carvalho Chehab 
593785bc17SMauro Carvalho Chehab static const char *flexcop_bus_names[] = {
603785bc17SMauro Carvalho Chehab 	"USB",
613785bc17SMauro Carvalho Chehab 	"PCI",
623785bc17SMauro Carvalho Chehab };
633785bc17SMauro Carvalho Chehab 
643785bc17SMauro Carvalho Chehab void flexcop_device_name(struct flexcop_device *fc,
653785bc17SMauro Carvalho Chehab 		const char *prefix, const char *suffix)
663785bc17SMauro Carvalho Chehab {
673785bc17SMauro Carvalho Chehab 	info("%s '%s' at the '%s' bus controlled by a '%s' %s",
683785bc17SMauro Carvalho Chehab 			prefix,	flexcop_device_names[fc->dev_type],
693785bc17SMauro Carvalho Chehab 			flexcop_bus_names[fc->bus_type],
703785bc17SMauro Carvalho Chehab 			flexcop_revision_names[fc->rev], suffix);
713785bc17SMauro Carvalho Chehab }
723785bc17SMauro Carvalho Chehab 
733785bc17SMauro Carvalho Chehab void flexcop_dump_reg(struct flexcop_device *fc,
743785bc17SMauro Carvalho Chehab 		flexcop_ibi_register reg, int num)
753785bc17SMauro Carvalho Chehab {
763785bc17SMauro Carvalho Chehab 	flexcop_ibi_value v;
773785bc17SMauro Carvalho Chehab 	int i;
783785bc17SMauro Carvalho Chehab 	for (i = 0; i < num; i++) {
793785bc17SMauro Carvalho Chehab 		v = fc->read_ibi_reg(fc, reg+4*i);
803785bc17SMauro Carvalho Chehab 		deb_rdump("0x%03x: %08x, ", reg+4*i, v.raw);
813785bc17SMauro Carvalho Chehab 	}
823785bc17SMauro Carvalho Chehab 	deb_rdump("\n");
833785bc17SMauro Carvalho Chehab }
843785bc17SMauro Carvalho Chehab EXPORT_SYMBOL(flexcop_dump_reg);
85