xref: /linux/drivers/media/common/b2c2/flexcop-misc.c (revision 5afc9a25be8d4e627cf07aa8a7500eafe3664b94)
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:
263785bc17SMauro Carvalho Chehab 		err("unknown FlexCop Revision: %x. Please report this to "
273785bc17SMauro Carvalho Chehab 				"linux-dvb@linuxtv.org.",
283785bc17SMauro Carvalho Chehab 				v.misc_204.Rev_N_sig_revision_hi);
293785bc17SMauro Carvalho Chehab 		break;
303785bc17SMauro Carvalho Chehab 	}
313785bc17SMauro Carvalho Chehab 
323785bc17SMauro Carvalho Chehab 	if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps))
333785bc17SMauro Carvalho Chehab 		deb_info("this FlexCop has "
343785bc17SMauro Carvalho Chehab 				"the additional 32 hardware pid filter.\n");
353785bc17SMauro Carvalho Chehab 	else
363785bc17SMauro Carvalho Chehab 		deb_info("this FlexCop has "
373785bc17SMauro Carvalho Chehab 				"the 6 basic main hardware pid filter.\n");
383785bc17SMauro Carvalho Chehab 	/* bus parts have to decide if hw pid filtering is used or not. */
393785bc17SMauro Carvalho Chehab }
403785bc17SMauro Carvalho Chehab 
413785bc17SMauro Carvalho Chehab static const char *flexcop_revision_names[] = {
423785bc17SMauro Carvalho Chehab 	"Unknown chip",
433785bc17SMauro Carvalho Chehab 	"FlexCopII",
443785bc17SMauro Carvalho Chehab 	"FlexCopIIb",
453785bc17SMauro Carvalho Chehab 	"FlexCopIII",
463785bc17SMauro Carvalho Chehab };
473785bc17SMauro Carvalho Chehab 
483785bc17SMauro Carvalho Chehab static const char *flexcop_device_names[] = {
493785bc17SMauro Carvalho Chehab 	[FC_UNK]	= "Unknown device",
503785bc17SMauro Carvalho Chehab 	[FC_CABLE]	= "Cable2PC/CableStar 2 DVB-C",
513785bc17SMauro Carvalho Chehab 	[FC_AIR_DVBT]	= "Air2PC/AirStar 2 DVB-T",
523785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC1]	= "Air2PC/AirStar 2 ATSC 1st generation",
533785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC2]	= "Air2PC/AirStar 2 ATSC 2nd generation",
543785bc17SMauro Carvalho Chehab 	[FC_AIR_ATSC3]	= "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)",
553785bc17SMauro Carvalho Chehab 	[FC_SKY_REV23]	= "Sky2PC/SkyStar 2 DVB-S rev 2.3 (old version)",
563785bc17SMauro Carvalho Chehab 	[FC_SKY_REV26]	= "Sky2PC/SkyStar 2 DVB-S rev 2.6",
573785bc17SMauro Carvalho Chehab 	[FC_SKY_REV27]	= "Sky2PC/SkyStar 2 DVB-S rev 2.7a/u",
583785bc17SMauro Carvalho Chehab 	[FC_SKY_REV28]	= "Sky2PC/SkyStar 2 DVB-S rev 2.8",
59*5afc9a25SJemma Denson 	[FC_SKYS2_REV33] = "Sky2PC/SkyStar S2 DVB-S/S2 rev 3.3",
603785bc17SMauro Carvalho Chehab };
613785bc17SMauro Carvalho Chehab 
623785bc17SMauro Carvalho Chehab static const char *flexcop_bus_names[] = {
633785bc17SMauro Carvalho Chehab 	"USB",
643785bc17SMauro Carvalho Chehab 	"PCI",
653785bc17SMauro Carvalho Chehab };
663785bc17SMauro Carvalho Chehab 
673785bc17SMauro Carvalho Chehab void flexcop_device_name(struct flexcop_device *fc,
683785bc17SMauro Carvalho Chehab 		const char *prefix, const char *suffix)
693785bc17SMauro Carvalho Chehab {
703785bc17SMauro Carvalho Chehab 	info("%s '%s' at the '%s' bus controlled by a '%s' %s",
713785bc17SMauro Carvalho Chehab 			prefix,	flexcop_device_names[fc->dev_type],
723785bc17SMauro Carvalho Chehab 			flexcop_bus_names[fc->bus_type],
733785bc17SMauro Carvalho Chehab 			flexcop_revision_names[fc->rev], suffix);
743785bc17SMauro Carvalho Chehab }
753785bc17SMauro Carvalho Chehab 
763785bc17SMauro Carvalho Chehab void flexcop_dump_reg(struct flexcop_device *fc,
773785bc17SMauro Carvalho Chehab 		flexcop_ibi_register reg, int num)
783785bc17SMauro Carvalho Chehab {
793785bc17SMauro Carvalho Chehab 	flexcop_ibi_value v;
803785bc17SMauro Carvalho Chehab 	int i;
813785bc17SMauro Carvalho Chehab 	for (i = 0; i < num; i++) {
823785bc17SMauro Carvalho Chehab 		v = fc->read_ibi_reg(fc, reg+4*i);
833785bc17SMauro Carvalho Chehab 		deb_rdump("0x%03x: %08x, ", reg+4*i, v.raw);
843785bc17SMauro Carvalho Chehab 	}
853785bc17SMauro Carvalho Chehab 	deb_rdump("\n");
863785bc17SMauro Carvalho Chehab }
873785bc17SMauro Carvalho Chehab EXPORT_SYMBOL(flexcop_dump_reg);
88