Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c003ab1b authored by David Härdeman's avatar David Härdeman Committed by Mauro Carvalho Chehab
Browse files

[media] rc-core: add separate defines for protocol bitmaps and numbers



The RC_TYPE_* defines are currently used both where a single protocol is
expected and where a bitmap of protocols is expected.

Functions like rc_keydown() and functions which add/remove entries to the
keytable want a single protocol. Future userspace APIs would also
benefit from numeric protocols (rather than bitmap ones). Keytables are
smaller if they can use a small(ish) integer rather than a bitmap.

Other functions or struct members (e.g. allowed_protos,
enabled_protocols, etc) accept multiple protocols and need a bitmap.

Using different types reduces the risk of programmer error. Using a
protocol enum whereever possible also makes for a more future-proof
user-space API as we don't need to worry about a sufficient number of
bits being available (e.g. in structs used for ioctl() calls).

The use of both a number and a corresponding bit is dalso one in e.g.
the input subsystem as well (see all the references to set/clear bit when
changing keytables for example).

This patch separate the different usages in preparation for
upcoming patches.

Where a single protocol is expected, enum rc_type is used; where one or more
protocol(s) are expected, something like u64 is used.

The patch has been rewritten so that the format of the sysfs "protocols"
file is no longer altered (at the loss of some detail). The file itself
should probably be deprecated in the future though.

Signed-off-by: default avatarDavid Härdeman <david@hardeman.nu>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Mike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 304ce75d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -88,7 +88,7 @@ int sms_ir_init(struct smscore_device_t *coredev)


	dev->priv = coredev;
	dev->priv = coredev;
	dev->driver_type = RC_DRIVER_IR_RAW;
	dev->driver_type = RC_DRIVER_IR_RAW;
	dev->allowed_protos = RC_TYPE_ALL;
	dev->allowed_protos = RC_BIT_ALL;
	dev->map_name = sms_get_board(board_id)->rc_codes;
	dev->map_name = sms_get_board(board_id)->rc_codes;
	dev->driver_name = MODULE_NAME;
	dev->driver_name = MODULE_NAME;


+7 −7
Original line number Original line Diff line number Diff line
@@ -284,7 +284,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
{
	char *ir_codes = NULL;
	char *ir_codes = NULL;
	const char *name = NULL;
	const char *name = NULL;
	u64 rc_type = RC_TYPE_UNKNOWN;
	u64 rc_type = RC_BIT_UNKNOWN;
	struct IR_i2c *ir;
	struct IR_i2c *ir;
	struct rc_dev *rc = NULL;
	struct rc_dev *rc = NULL;
	struct i2c_adapter *adap = client->adapter;
	struct i2c_adapter *adap = client->adapter;
@@ -303,7 +303,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
	case 0x64:
	case 0x64:
		name        = "Pixelview";
		name        = "Pixelview";
		ir->get_key = get_key_pixelview;
		ir->get_key = get_key_pixelview;
		rc_type     = RC_TYPE_OTHER;
		rc_type     = RC_BIT_OTHER;
		ir_codes    = RC_MAP_EMPTY;
		ir_codes    = RC_MAP_EMPTY;
		break;
		break;
	case 0x18:
	case 0x18:
@@ -311,31 +311,31 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
	case 0x1a:
	case 0x1a:
		name        = "Hauppauge";
		name        = "Hauppauge";
		ir->get_key = get_key_haup;
		ir->get_key = get_key_haup;
		rc_type     = RC_TYPE_RC5;
		rc_type     = RC_BIT_RC5;
		ir_codes    = RC_MAP_HAUPPAUGE;
		ir_codes    = RC_MAP_HAUPPAUGE;
		break;
		break;
	case 0x30:
	case 0x30:
		name        = "KNC One";
		name        = "KNC One";
		ir->get_key = get_key_knc1;
		ir->get_key = get_key_knc1;
		rc_type     = RC_TYPE_OTHER;
		rc_type     = RC_BIT_OTHER;
		ir_codes    = RC_MAP_EMPTY;
		ir_codes    = RC_MAP_EMPTY;
		break;
		break;
	case 0x6b:
	case 0x6b:
		name        = "FusionHDTV";
		name        = "FusionHDTV";
		ir->get_key = get_key_fusionhdtv;
		ir->get_key = get_key_fusionhdtv;
		rc_type     = RC_TYPE_RC5;
		rc_type     = RC_BIT_RC5;
		ir_codes    = RC_MAP_FUSIONHDTV_MCE;
		ir_codes    = RC_MAP_FUSIONHDTV_MCE;
		break;
		break;
	case 0x40:
	case 0x40:
		name        = "AVerMedia Cardbus remote";
		name        = "AVerMedia Cardbus remote";
		ir->get_key = get_key_avermedia_cardbus;
		ir->get_key = get_key_avermedia_cardbus;
		rc_type     = RC_TYPE_OTHER;
		rc_type     = RC_BIT_OTHER;
		ir_codes    = RC_MAP_AVERMEDIA_CARDBUS;
		ir_codes    = RC_MAP_AVERMEDIA_CARDBUS;
		break;
		break;
	case 0x71:
	case 0x71:
		name        = "Hauppauge/Zilog Z8";
		name        = "Hauppauge/Zilog Z8";
		ir->get_key = get_key_haup_xvr;
		ir->get_key = get_key_haup_xvr;
		rc_type     = RC_TYPE_RC5;
		rc_type     = RC_BIT_RC5;
		ir_codes    = RC_MAP_HAUPPAUGE;
		ir_codes    = RC_MAP_HAUPPAUGE;
		break;
		break;
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -98,7 +98,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
	case CX18_HW_Z8F0811_IR_RX_HAUP:
	case CX18_HW_Z8F0811_IR_RX_HAUP:
		init_data->ir_codes = RC_MAP_HAUPPAUGE;
		init_data->ir_codes = RC_MAP_HAUPPAUGE;
		init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
		init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
		init_data->type = RC_TYPE_RC5;
		init_data->type = RC_BIT_RC5;
		init_data->name = cx->card_name;
		init_data->name = cx->card_name;
		info.platform_data = init_data;
		info.platform_data = init_data;
		break;
		break;
+3 −3
Original line number Original line Diff line number Diff line
@@ -270,21 +270,21 @@ int cx23885_input_init(struct cx23885_dev *dev)
	case CX23885_BOARD_HAUPPAUGE_HVR1250:
	case CX23885_BOARD_HAUPPAUGE_HVR1250:
		/* Integrated CX2388[58] IR controller */
		/* Integrated CX2388[58] IR controller */
		driver_type = RC_DRIVER_IR_RAW;
		driver_type = RC_DRIVER_IR_RAW;
		allowed_protos = RC_TYPE_ALL;
		allowed_protos = RC_BIT_ALL;
		/* The grey Hauppauge RC-5 remote */
		/* The grey Hauppauge RC-5 remote */
		rc_map = RC_MAP_HAUPPAUGE;
		rc_map = RC_MAP_HAUPPAUGE;
		break;
		break;
	case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
	case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
		/* Integrated CX23885 IR controller */
		/* Integrated CX23885 IR controller */
		driver_type = RC_DRIVER_IR_RAW;
		driver_type = RC_DRIVER_IR_RAW;
		allowed_protos = RC_TYPE_NEC;
		allowed_protos = RC_BIT_NEC;
		/* The grey Terratec remote with orange buttons */
		/* The grey Terratec remote with orange buttons */
		rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
		rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
		break;
		break;
	case CX23885_BOARD_TEVII_S470:
	case CX23885_BOARD_TEVII_S470:
		/* Integrated CX23885 IR controller */
		/* Integrated CX23885 IR controller */
		driver_type = RC_DRIVER_IR_RAW;
		driver_type = RC_DRIVER_IR_RAW;
		allowed_protos = RC_TYPE_ALL;
		allowed_protos = RC_BIT_ALL;
		/* A guess at the remote */
		/* A guess at the remote */
		rc_map = RC_MAP_TEVII_NEC;
		rc_map = RC_MAP_TEVII_NEC;
		break;
		break;
+4 −4
Original line number Original line Diff line number Diff line
@@ -248,7 +248,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
	struct cx88_IR *ir;
	struct cx88_IR *ir;
	struct rc_dev *dev;
	struct rc_dev *dev;
	char *ir_codes = NULL;
	char *ir_codes = NULL;
	u64 rc_type = RC_TYPE_OTHER;
	u64 rc_type = RC_BIT_OTHER;
	int err = -ENOMEM;
	int err = -ENOMEM;
	u32 hardware_mask = 0;	/* For devices with a hardware mask, when
	u32 hardware_mask = 0;	/* For devices with a hardware mask, when
				 * used with a full-code IR table
				 * used with a full-code IR table
@@ -416,7 +416,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
		break;
		break;
	case CX88_BOARD_TWINHAN_VP1027_DVBS:
	case CX88_BOARD_TWINHAN_VP1027_DVBS:
		ir_codes         = RC_MAP_TWINHAN_VP1027_DVBS;
		ir_codes         = RC_MAP_TWINHAN_VP1027_DVBS;
		rc_type          = RC_TYPE_NEC;
		rc_type          = RC_BIT_NEC;
		ir->sampling     = 0xff00; /* address */
		ir->sampling     = 0xff00; /* address */
		break;
		break;
	}
	}
@@ -592,7 +592,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
	case CX88_BOARD_LEADTEK_PVR2000:
	case CX88_BOARD_LEADTEK_PVR2000:
		addr_list = pvr2000_addr_list;
		addr_list = pvr2000_addr_list;
		core->init_data.name = "cx88 Leadtek PVR 2000 remote";
		core->init_data.name = "cx88 Leadtek PVR 2000 remote";
		core->init_data.type = RC_TYPE_UNKNOWN;
		core->init_data.type = RC_BIT_UNKNOWN;
		core->init_data.get_key = get_key_pvr2000;
		core->init_data.get_key = get_key_pvr2000;
		core->init_data.ir_codes = RC_MAP_EMPTY;
		core->init_data.ir_codes = RC_MAP_EMPTY;
		break;
		break;
@@ -613,7 +613,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
			/* Hauppauge XVR */
			/* Hauppauge XVR */
			core->init_data.name = "cx88 Hauppauge XVR remote";
			core->init_data.name = "cx88 Hauppauge XVR remote";
			core->init_data.ir_codes = RC_MAP_HAUPPAUGE;
			core->init_data.ir_codes = RC_MAP_HAUPPAUGE;
			core->init_data.type = RC_TYPE_RC5;
			core->init_data.type = RC_BIT_RC5;
			core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
			core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;


			info.platform_data = &core->init_data;
			info.platform_data = &core->init_data;
Loading