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