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

Commit 1cd72781 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab
Browse files

[media] af9015: move remote controllers to new RC core



Use new RC core instead of old legacy RC implementation.

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3cbf5072
Loading
Loading
Loading
Loading
+120 −107
Original line number Diff line number Diff line
@@ -701,80 +701,80 @@ static int af9015_download_firmware(struct usb_device *udev,
	return ret;
}

struct af9015_setup {
struct af9015_rc_setup {
	unsigned int id;
	struct ir_scancode *rc_key_map;
	unsigned int rc_key_map_size;
	char *rc_codes;
};

static const struct af9015_setup *af9015_setup_match(unsigned int id,
		const struct af9015_setup *table)
static char *af9015_rc_setup_match(unsigned int id,
	const struct af9015_rc_setup *table)
{
	for (; table->rc_key_map; table++)
	for (; table->rc_codes; table++)
		if (table->id == id)
			return table;
			return table->rc_codes;
	return NULL;
}

static const struct af9015_setup af9015_setup_modparam[] = {
	{ AF9015_REMOTE_A_LINK_DTU_M, af9015_rc_a_link,
		ARRAY_SIZE(af9015_rc_a_link) },
	{ AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, af9015_rc_msi,
		ARRAY_SIZE(af9015_rc_msi) },
	{ AF9015_REMOTE_MYGICTV_U718, af9015_rc_mygictv,
		ARRAY_SIZE(af9015_rc_mygictv) },
	{ AF9015_REMOTE_DIGITTRADE_DVB_T, af9015_rc_digittrade,
		ARRAY_SIZE(af9015_rc_digittrade) },
	{ AF9015_REMOTE_AVERMEDIA_KS, af9015_rc_avermedia_ks,
		ARRAY_SIZE(af9015_rc_avermedia_ks) },
static const struct af9015_rc_setup af9015_rc_setup_modparam[] = {
	{ AF9015_REMOTE_A_LINK_DTU_M, RC_MAP_ALINK_DTU_M },
	{ AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, RC_MAP_MSI_DIGIVOX_II },
	{ AF9015_REMOTE_MYGICTV_U718, RC_MAP_TOTAL_MEDIA_IN_HAND },
	{ AF9015_REMOTE_DIGITTRADE_DVB_T, RC_MAP_DIGITTRADE },
	{ AF9015_REMOTE_AVERMEDIA_KS, RC_MAP_AVERMEDIA_RM_KS },
	{ }
};

/* don't add new entries here anymore, use hashes instead */
static const struct af9015_setup af9015_setup_usbids[] = {
	{ USB_VID_LEADTEK, af9015_rc_leadtek,
		ARRAY_SIZE(af9015_rc_leadtek) },
	{ USB_VID_VISIONPLUS, af9015_rc_twinhan,
		ARRAY_SIZE(af9015_rc_twinhan) },
	{ USB_VID_KWORLD_2, af9015_rc_kworld,
		ARRAY_SIZE(af9015_rc_kworld) },
	{ USB_VID_AVERMEDIA, af9015_rc_avermedia,
		ARRAY_SIZE(af9015_rc_avermedia) },
	{ USB_VID_MSI_2, af9015_rc_msi_digivox_iii,
		ARRAY_SIZE(af9015_rc_msi_digivox_iii) },
	{ USB_VID_TERRATEC, af9015_rc_terratec,
		ARRAY_SIZE(af9015_rc_terratec) },
static const struct af9015_rc_setup af9015_rc_setup_hashes[] = {
	{ 0xb8feb708, RC_MAP_MSI_DIGIVOX_II },
	{ 0xa3703d00, RC_MAP_ALINK_DTU_M },
	{ 0x9b7dc64e, RC_MAP_TOTAL_MEDIA_IN_HAND }, /* MYGICTV U718 */
	{ }
};

static const struct af9015_setup af9015_setup_hashes[] = {
	{ 0xb8feb708, af9015_rc_msi, ARRAY_SIZE(af9015_rc_msi) },
	{ 0xa3703d00, af9015_rc_a_link, ARRAY_SIZE(af9015_rc_a_link) },
	{ 0x9b7dc64e, af9015_rc_mygictv, ARRAY_SIZE(af9015_rc_mygictv) },
static const struct af9015_rc_setup af9015_rc_setup_usbids[] = {
	{ (USB_VID_TERRATEC << 16) + USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC,
		RC_MAP_TERRATEC_SLIM },
	{ (USB_VID_VISIONPLUS << 16) + USB_PID_AZUREWAVE_AD_TU700,
		RC_MAP_AZUREWAVE_AD_TU700 },
	{ (USB_VID_VISIONPLUS << 16) + USB_PID_TINYTWIN,
		RC_MAP_AZUREWAVE_AD_TU700 },
	{ (USB_VID_MSI_2 << 16) + USB_PID_MSI_DIGI_VOX_MINI_III,
		RC_MAP_MSI_DIGIVOX_III },
	{ (USB_VID_LEADTEK << 16) + USB_PID_WINFAST_DTV_DONGLE_GOLD,
		RC_MAP_LEADTEK_Y04G0051 },
	{ (USB_VID_AVERMEDIA << 16) + USB_PID_AVERMEDIA_VOLAR_X,
		RC_MAP_AVERMEDIA_M135A },
	{ (USB_VID_AFATECH << 16) + USB_PID_TREKSTOR_DVBT,
		RC_MAP_TREKSTOR },
	{ }
};

static void af9015_set_remote_config(struct usb_device *udev,
		struct dvb_usb_device_properties *props)
{
	const struct af9015_setup *table = NULL;
	u16 vid = le16_to_cpu(udev->descriptor.idVendor);
	u16 pid = le16_to_cpu(udev->descriptor.idProduct);

	if (dvb_usb_af9015_remote) {
		/* load remote defined as module param */
		table = af9015_setup_match(dvb_usb_af9015_remote,
				af9015_setup_modparam);
	} else {
		u16 vendor = le16_to_cpu(udev->descriptor.idVendor);
	/* try to load remote based module param */
	props->rc.core.rc_codes = af9015_rc_setup_match(
		dvb_usb_af9015_remote, af9015_rc_setup_modparam);

	/* try to load remote based eeprom hash */
	if (!props->rc.core.rc_codes)
		props->rc.core.rc_codes = af9015_rc_setup_match(
			af9015_config.eeprom_sum, af9015_rc_setup_hashes);

		table = af9015_setup_match(af9015_config.eeprom_sum,
				af9015_setup_hashes);
	/* try to load remote based USB ID */
	if (!props->rc.core.rc_codes)
		props->rc.core.rc_codes = af9015_rc_setup_match(
			(vid << 16) + pid, af9015_rc_setup_usbids);

		if (!table && vendor == USB_VID_AFATECH) {
	/* try to load remote based USB iManufacturer string */
	if (!props->rc.core.rc_codes && vid == USB_VID_AFATECH) {
		/* Check USB manufacturer and product strings and try
		   to determine correct remote in case of chip vendor
		   reference IDs are used.
			   DO NOT ADD ANYTHING NEW HERE. Use hashes instead.
			 */
		   DO NOT ADD ANYTHING NEW HERE. Use hashes instead. */
		char manufacturer[10];
		memset(manufacturer, 0, sizeof(manufacturer));
		usb_string(udev, udev->descriptor.iManufacturer,
@@ -782,25 +782,16 @@ static void af9015_set_remote_config(struct usb_device *udev,
		if (!strcmp("MSI", manufacturer)) {
			/* iManufacturer 1 MSI
			   iProduct      2 MSI K-VOX */
				table = af9015_setup_match(
			props->rc.core.rc_codes = af9015_rc_setup_match(
				AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
					af9015_setup_modparam);
			} else if (udev->descriptor.idProduct ==
				cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
				table = &(const struct af9015_setup){ 0,
					af9015_rc_trekstor,
					ARRAY_SIZE(af9015_rc_trekstor) };
				af9015_rc_setup_modparam);
		}
		} else if (!table)
			table = af9015_setup_match(vendor, af9015_setup_usbids);
	}

	if (table) {
		props->rc.legacy.rc_key_map = table->rc_key_map;
		props->rc.legacy.rc_key_map_size = table->rc_key_map_size;
	}
	return;
}

static int af9015_rc_query(struct dvb_usb_device *d);

static int af9015_read_config(struct usb_device *udev)
{
	int ret;
@@ -825,11 +816,12 @@ static int af9015_read_config(struct usb_device *udev)
	deb_info("%s: IR mode:%d\n", __func__, val);
	for (i = 0; i < af9015_properties_count; i++) {
		if (val == AF9015_IR_MODE_DISABLED) {
			af9015_properties[i].rc.legacy.rc_key_map = NULL;
			af9015_properties[i].rc.legacy.rc_key_map_size  = 0;
		} else
			af9015_properties[i].rc.core.rc_query = NULL;
		} else {
			af9015_properties[i].rc.core.rc_query = af9015_rc_query;
			af9015_set_remote_config(udev, &af9015_properties[i]);
		}
	}

	/* TS mode - one or two receivers */
	req.addr = AF9015_EEPROM_TS_MODE;
@@ -1009,34 +1001,41 @@ static int af9015_identify_state(struct usb_device *udev,
	return ret;
}

static int af9015_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
static int af9015_rc_query(struct dvb_usb_device *d)
{
	struct af9015_state *priv = d->priv;
	int ret;
	u8 ircode[5], repeat;
	u8 repeat, keycode[4];

	/* read registers needed to detect remote controller code */
	/* TODO: Implement read multiple registers to reduce idle USB traffic.
	   Currently three reads are needed for one idle rc polling. */
	ret = af9015_read_reg(d, 0x98df, &repeat);
	if (ret)
		goto error;

	ret = af9015_read_reg(d, 0x98e7, &ircode[3]);
	ret = af9015_read_reg(d, 0x98e7, &keycode[2]);
	if (ret)
		goto error;

	ret = af9015_read_reg(d, 0x98e8, &ircode[4]);
	ret = af9015_read_reg(d, 0x98e8, &keycode[3]);
	if (ret)
		goto error;

	if (ircode[3] || ircode[4]) {
		deb_rc("%s: key pressed\n", __func__);
		ircode[0] = 1; /* DVB_USB_RC_NEC_KEY_PRESSED */

	if (keycode[2] || keycode[3]) {
		/* read 1st address byte */
		ret = af9015_read_reg(d, 0x98e5, &ircode[1]);
		ret = af9015_read_reg(d, 0x98e5, &keycode[0]);
		if (ret)
			goto error;

		/* read 2nd address byte */
		ret = af9015_read_reg(d, 0x98e6, &keycode[1]);
		if (ret)
			goto error;

		deb_rc("%s: key pressed ", __func__);
		debug_dump(keycode, sizeof(keycode), deb_rc);

		/* clean data bytes from mem */
		ret = af9015_write_reg(d, 0x98e7, 0);
		if (ret)
@@ -1046,26 +1045,28 @@ static int af9015_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
		if (ret)
			goto error;

		/* FIXME: Hack to pass checksum on the custom field for the
		   remote controllers using NEC extended address.
		   That must done since dvb_usb_nec_rc_key_to_event()
		   does not support NEC extended address format. */
		ircode[2] = ~ircode[1];
		if (keycode[2] == (u8) ~keycode[3]) {
			if (keycode[0] == (u8) ~keycode[1]) {
				/* NEC */
				priv->rc_keycode = keycode[0] << 8 | keycode[2];
			} else {
				/* NEC extended*/
				priv->rc_keycode = keycode[0] << 16 |
					keycode[1] << 8 | keycode[2];
			}
			ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
		} else {
			priv->rc_keycode = 0; /* clear just for sure */
		}
	} else if (priv->rc_repeat != repeat) {
		deb_rc("%s: key repeated\n", __func__);
		ircode[0] = 2; /* DVB_USB_RC_NEC_KEY_REPEATED */
		ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
	} else {
		deb_rc("%s: no key press\n", __func__);
		ircode[0] = 0; /* DVB_USB_RC_NEC_EMPTY */
	}

	priv->rc_repeat = repeat;

	deb_rc("%s: ", __func__);
	debug_dump(ircode, sizeof(ircode), deb_rc);

	dvb_usb_nec_rc_key_to_event(d, ircode, event, state);

error:
	if (ret)
		err("%s: failed:%d", __func__, ret);
@@ -1359,9 +1360,13 @@ static struct dvb_usb_device_properties af9015_properties[] = {

		.identify_state = af9015_identify_state,

		.rc.legacy = {
			.rc_query         = af9015_rc_query,
		.rc.core = {
			.protocol         = IR_TYPE_NEC,
			.module_name      = "af9015",
			.rc_interval      = AF9015_RC_INTERVAL,
			.rc_props = {
				.allowed_protos = IR_TYPE_NEC,
			},
		},

		.i2c_algo = &af9015_i2c_algo,
@@ -1483,9 +1488,13 @@ static struct dvb_usb_device_properties af9015_properties[] = {

		.identify_state = af9015_identify_state,

		.rc.legacy = {
			.rc_query         = af9015_rc_query,
		.rc.core = {
			.protocol         = IR_TYPE_NEC,
			.module_name      = "af9015",
			.rc_interval      = AF9015_RC_INTERVAL,
			.rc_props = {
				.allowed_protos = IR_TYPE_NEC,
			},
		},

		.i2c_algo = &af9015_i2c_algo,
@@ -1592,9 +1601,13 @@ static struct dvb_usb_device_properties af9015_properties[] = {

		.identify_state = af9015_identify_state,

		.rc.legacy = {
			.rc_query         = af9015_rc_query,
		.rc.core = {
			.protocol         = IR_TYPE_NEC,
			.module_name      = "af9015",
			.rc_interval      = AF9015_RC_INTERVAL,
			.rc_props = {
				.allowed_protos = IR_TYPE_NEC,
			},
		},

		.i2c_algo = &af9015_i2c_algo,
+1 −417
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ enum af9015_ir_mode {
struct af9015_state {
	struct i2c_adapter i2c_adap; /* I2C adapter for 2nd FE */
	u8 rc_repeat;
	u32 rc_keycode;
};

struct af9015_config {
@@ -120,421 +121,4 @@ enum af9015_remote {
/* 5 */	AF9015_REMOTE_AVERMEDIA_KS,
};

/* LeadTek - Y04G0051 */
/* Leadtek WinFast DTV Dongle Gold */
static struct ir_scancode af9015_rc_leadtek[] = {
	{ 0x0300, KEY_POWER2 },
	{ 0x0303, KEY_SCREEN },
	{ 0x0304, KEY_RIGHT },
	{ 0x0305, KEY_1 },
	{ 0x0306, KEY_2 },
	{ 0x0307, KEY_3 },
	{ 0x0308, KEY_LEFT },
	{ 0x0309, KEY_4 },
	{ 0x030a, KEY_5 },
	{ 0x030b, KEY_6 },
	{ 0x030c, KEY_UP },
	{ 0x030d, KEY_7 },
	{ 0x030e, KEY_8 },
	{ 0x030f, KEY_9 },
	{ 0x0310, KEY_DOWN },
	{ 0x0311, KEY_AGAIN },
	{ 0x0312, KEY_0 },
	{ 0x0313, KEY_OK },              /* 1st ok */
	{ 0x0314, KEY_MUTE },
	{ 0x0316, KEY_OK },              /* 2nd ok */
	{ 0x031e, KEY_VIDEO },           /* 2nd video */
	{ 0x031b, KEY_AUDIO },
	{ 0x031f, KEY_TEXT },
	{ 0x0340, KEY_SLEEP },
	{ 0x0341, KEY_DOT },
	{ 0x0342, KEY_REWIND },
	{ 0x0343, KEY_PLAY },
	{ 0x0344, KEY_FASTFORWARD },
	{ 0x0345, KEY_TIME },
	{ 0x0346, KEY_STOP },            /* 2nd stop */
	{ 0x0347, KEY_RECORD },
	{ 0x0348, KEY_CAMERA },
	{ 0x0349, KEY_ESC },
	{ 0x034a, KEY_NEW },
	{ 0x034b, KEY_RED },
	{ 0x034c, KEY_GREEN },
	{ 0x034d, KEY_YELLOW },
	{ 0x034e, KEY_BLUE },
	{ 0x034f, KEY_MENU },
	{ 0x0350, KEY_STOP },            /* 1st stop */
	{ 0x0351, KEY_CHANNEL },
	{ 0x0352, KEY_VIDEO },           /* 1st video */
	{ 0x0353, KEY_EPG },
	{ 0x0354, KEY_PREVIOUS },
	{ 0x0355, KEY_NEXT },
	{ 0x0356, KEY_TV },
	{ 0x035a, KEY_VOLUMEDOWN },
	{ 0x035b, KEY_CHANNELUP },
	{ 0x035e, KEY_VOLUMEUP },
	{ 0x035f, KEY_CHANNELDOWN },
};

/* TwinHan AzureWave AD-TU700(704J) */
static struct ir_scancode af9015_rc_twinhan[] = {
	{ 0x0000, KEY_TAB },             /* Tab */
	{ 0x0001, KEY_2 },
	{ 0x0002, KEY_CHANNELDOWN },
	{ 0x0003, KEY_1 },
	{ 0x0004, KEY_LIST },            /* Record List */
	{ 0x0005, KEY_CHANNELUP },
	{ 0x0006, KEY_3 },
	{ 0x0007, KEY_SLEEP },           /* Hibernate */
	{ 0x0008, KEY_SWITCHVIDEOMODE }, /* A/V */
	{ 0x0009, KEY_4 },
	{ 0x000a, KEY_VOLUMEDOWN },
	{ 0x000c, KEY_CANCEL },          /* Cancel */
	{ 0x000d, KEY_7 },
	{ 0x000e, KEY_AGAIN },           /* Recall */
	{ 0x000f, KEY_TEXT },            /* Teletext */
	{ 0x0010, KEY_MUTE },
	{ 0x0011, KEY_RECORD },
	{ 0x0012, KEY_FASTFORWARD },     /* FF >> */
	{ 0x0013, KEY_BACK },            /* Back */
	{ 0x0014, KEY_PLAY },
	{ 0x0015, KEY_0 },
	{ 0x0016, KEY_POWER },
	{ 0x0017, KEY_FAVORITES },       /* Favorite List */
	{ 0x0018, KEY_RED },
	{ 0x0019, KEY_8 },
	{ 0x001a, KEY_STOP },
	{ 0x001b, KEY_9 },
	{ 0x001c, KEY_EPG },             /* Info/EPG */
	{ 0x001d, KEY_5 },
	{ 0x001e, KEY_VOLUMEUP },
	{ 0x001f, KEY_6 },
	{ 0x0040, KEY_REWIND },          /* FR << */
	{ 0x0041, KEY_PREVIOUS },        /* Replay */
	{ 0x0042, KEY_NEXT },            /* Skip */
	{ 0x0043, KEY_SUBTITLE },        /* Subtitle / CC */
	{ 0x0045, KEY_KPPLUS },          /* Zoom+ */
	{ 0x0046, KEY_KPMINUS },         /* Zoom- */
	{ 0x0047, KEY_TV2 },             /* PIP */
	{ 0x0048, KEY_INFO },            /* Preview */
	{ 0x0049, KEY_AUDIO },           /* L/R */ /* TODO better event */
	{ 0x004a, KEY_CLEAR },           /* Clear */
	{ 0x004b, KEY_UP },              /* up arrow */
	{ 0x004c, KEY_PAUSE },
	{ 0x004d, KEY_ZOOM },            /* Full Screen */
	{ 0x004e, KEY_LEFT },            /* left arrow */
	{ 0x004f, KEY_ENTER },           /* Enter / ok */
	{ 0x0050, KEY_LANGUAGE },        /* SAP */
	{ 0x0051, KEY_DOWN },            /* down arrow */
	{ 0x0052, KEY_RIGHT },           /* right arrow */
	{ 0x0053, KEY_GREEN },
	{ 0x0054, KEY_CAMERA },          /* Capture */
	{ 0x005e, KEY_YELLOW },
	{ 0x005f, KEY_BLUE },
};

/* A-Link DTU(m) - 3x6 slim remote */
static struct ir_scancode af9015_rc_a_link[] = {
	{ 0x0800, KEY_VOLUMEUP },
	{ 0x0801, KEY_1 },
	{ 0x0802, KEY_3 },
	{ 0x0803, KEY_7 },
	{ 0x0804, KEY_9 },
	{ 0x0805, KEY_ZOOM },
	{ 0x0806, KEY_0 },
	{ 0x0807, KEY_GOTO },            /* jump */
	{ 0x080d, KEY_5 },
	{ 0x080f, KEY_2 },
	{ 0x0812, KEY_POWER },
	{ 0x0814, KEY_CHANNELUP },
	{ 0x0816, KEY_VOLUMEDOWN },
	{ 0x0818, KEY_6 },
	{ 0x081a, KEY_MUTE },
	{ 0x081b, KEY_8 },
	{ 0x081c, KEY_4 },
	{ 0x081d, KEY_CHANNELDOWN },
};

/* MSI DIGIVOX mini II V3.0 */
static struct ir_scancode af9015_rc_msi[] = {
	{ 0x0002, KEY_2 },
	{ 0x0003, KEY_UP },              /* up */
	{ 0x0004, KEY_3 },
	{ 0x0005, KEY_CHANNELDOWN },
	{ 0x0008, KEY_5 },
	{ 0x0009, KEY_0 },
	{ 0x000b, KEY_8 },
	{ 0x000d, KEY_DOWN },            /* down */
	{ 0x0010, KEY_9 },
	{ 0x0011, KEY_7 },
	{ 0x0014, KEY_VOLUMEUP },
	{ 0x0015, KEY_CHANNELUP },
	{ 0x0016, KEY_ENTER },
	{ 0x0017, KEY_POWER },
	{ 0x001a, KEY_1 },
	{ 0x001c, KEY_4 },
	{ 0x001d, KEY_6 },
	{ 0x001f, KEY_VOLUMEDOWN },
};

/* MYGICTV U718 */
/* Uses NEC extended 0x02bd. Extended byte removed for compatibility... */
static struct ir_scancode af9015_rc_mygictv[] = {
	{ 0x0200, KEY_1 },
	{ 0x0201, KEY_2 },
	{ 0x0202, KEY_3 },
	{ 0x0203, KEY_4 },
	{ 0x0204, KEY_5 },
	{ 0x0205, KEY_6 },
	{ 0x0206, KEY_7 },
	{ 0x0207, KEY_8 },
	{ 0x0208, KEY_9 },
	{ 0x0209, KEY_0 },
	{ 0x020a, KEY_MUTE },
	{ 0x020b, KEY_CYCLEWINDOWS },    /* yellow, min / max */
	{ 0x020c, KEY_SWITCHVIDEOMODE }, /* TV / AV */
	{ 0x020e, KEY_VOLUMEDOWN },
	{ 0x020f, KEY_TIME },            /* TimeShift */
	{ 0x0210, KEY_RIGHT },           /* right arrow */
	{ 0x0211, KEY_LEFT },            /* left arrow */
	{ 0x0212, KEY_UP },              /* up arrow */
	{ 0x0213, KEY_DOWN },            /* down arrow */
	{ 0x0214, KEY_POWER },
	{ 0x0215, KEY_ENTER },           /* ok */
	{ 0x0216, KEY_STOP },
	{ 0x0217, KEY_CAMERA },          /* Snapshot */
	{ 0x0218, KEY_CHANNELUP },
	{ 0x0219, KEY_RECORD },
	{ 0x021a, KEY_CHANNELDOWN },
	{ 0x021c, KEY_ESC },             /* Esc */
	{ 0x021e, KEY_PLAY },
	{ 0x021f, KEY_VOLUMEUP },
	{ 0x0240, KEY_PAUSE },
	{ 0x0241, KEY_FASTFORWARD },     /* FF >> */
	{ 0x0242, KEY_REWIND },          /* FR << */
	{ 0x0243, KEY_ZOOM },            /* 'select' (?) */
	{ 0x0244, KEY_SHUFFLE },         /* Shuffle */
	{ 0x0245, KEY_POWER },
};

/* KWorld PlusTV Dual DVB-T Stick (DVB-T 399U) */
/* FIXME: This mapping is totally incomplete and probably even wrong... */
/* Uses NEC extended 0x866b. Extended byte removed for compatibility... */
static struct ir_scancode af9015_rc_kworld[] = {
	{ 0x8600, KEY_1 },
	{ 0x8601, KEY_2 },
	{ 0x8602, KEY_3 },
	{ 0x8603, KEY_4 },
	{ 0x8604, KEY_5 },
	{ 0x8605, KEY_6 },
	{ 0x8606, KEY_7 },
	{ 0x8607, KEY_8 },
	{ 0x8608, KEY_9 },
	{ 0x860a, KEY_0 },
};

/* AverMedia Volar X */
static struct ir_scancode af9015_rc_avermedia[] = {
	{ 0x0200, KEY_POWER },           /* POWER */
	{ 0x0201, KEY_PROG1 },           /* SOURCE */
	{ 0x0203, KEY_TEXT },            /* TELETEXT */
	{ 0x0204, KEY_EPG },             /* EPG */
	{ 0x0205, KEY_1 },               /* 1 */
	{ 0x0206, KEY_2 },               /* 2 */
	{ 0x0207, KEY_3 },               /* 3 */
	{ 0x0208, KEY_AUDIO },           /* AUDIO */
	{ 0x0209, KEY_4 },               /* 4 */
	{ 0x020a, KEY_5 },               /* 5 */
	{ 0x020b, KEY_6 },               /* 6 */
	{ 0x020c, KEY_ZOOM },            /* FULL SCREEN */
	{ 0x020d, KEY_7 },               /* 7 */
	{ 0x020e, KEY_8 },               /* 8 */
	{ 0x020f, KEY_9 },               /* 9 */
	{ 0x0210, KEY_PROG3 },           /* 16-CH PREV */
	{ 0x0211, KEY_0 },               /* 0 */
	{ 0x0212, KEY_LEFT },            /* L / DISPLAY */
	{ 0x0213, KEY_RIGHT },           /* R / CH RTN */
	{ 0x0214, KEY_MUTE },            /* MUTE */
	{ 0x0215, KEY_MENU },            /* MENU */
	{ 0x0217, KEY_PROG2 },           /* SNAP SHOT */
	{ 0x0218, KEY_PLAY },            /* PLAY */
	{ 0x0219, KEY_RECORD },          /* RECORD */
	{ 0x021a, KEY_PLAYPAUSE },       /* TIMESHIFT / PAUSE */
	{ 0x021b, KEY_STOP },            /* STOP */
	{ 0x021c, KEY_FORWARD },         /* >> / YELLOW */
	{ 0x021d, KEY_BACK },            /* << / RED */
	{ 0x021e, KEY_VOLUMEDOWN },      /* VOL DOWN */
	{ 0x021f, KEY_VOLUMEUP },        /* VOL UP */

	{ 0x0300, KEY_LAST },            /* >>| / BLUE */
	{ 0x0301, KEY_FIRST },           /* |<< / GREEN */
	{ 0x0302, KEY_CHANNELDOWN },     /* CH DOWN */
	{ 0x0303, KEY_CHANNELUP },       /* CH UP */
};

/* AverMedia KS */
/* FIXME: mappings are not 100% correct? */
static struct ir_scancode af9015_rc_avermedia_ks[] = {
	{ 0x0501, KEY_POWER },
	{ 0x0502, KEY_CHANNELUP },
	{ 0x0503, KEY_CHANNELDOWN },
	{ 0x0504, KEY_VOLUMEUP },
	{ 0x0505, KEY_VOLUMEDOWN },
	{ 0x0506, KEY_MUTE },
	{ 0x0507, KEY_RIGHT },
	{ 0x0508, KEY_PROG1 },
	{ 0x0509, KEY_1 },
	{ 0x050a, KEY_2 },
	{ 0x050b, KEY_3 },
	{ 0x050c, KEY_4 },
	{ 0x050d, KEY_5 },
	{ 0x050e, KEY_6 },
	{ 0x050f, KEY_7 },
	{ 0x0510, KEY_8 },
	{ 0x0511, KEY_9 },
	{ 0x0512, KEY_0 },
	{ 0x0513, KEY_AUDIO },
	{ 0x0515, KEY_EPG },
	{ 0x0516, KEY_PLAY },
	{ 0x0517, KEY_RECORD },
	{ 0x0518, KEY_STOP },
	{ 0x051c, KEY_BACK },
	{ 0x051d, KEY_FORWARD },
	{ 0x054d, KEY_LEFT },
	{ 0x0556, KEY_ZOOM },
};

/* Digittrade DVB-T USB Stick */
static struct ir_scancode af9015_rc_digittrade[] = {
	{ 0x0000, KEY_9 },
	{ 0x0001, KEY_EPG },             /* EPG */
	{ 0x0002, KEY_VOLUMEDOWN },      /* Vol Dn */
	{ 0x0003, KEY_TEXT },            /* TELETEXT */
	{ 0x0004, KEY_8 },
	{ 0x0005, KEY_MUTE },            /* MUTE */
	{ 0x0006, KEY_POWER },           /* POWER */
	{ 0x0009, KEY_ZOOM },            /* FULLSCREEN */
	{ 0x000a, KEY_RECORD },          /* RECORD */
	{ 0x000d, KEY_SUBTITLE },        /* SUBTITLE */
	{ 0x000e, KEY_STOP },            /* STOP */
	{ 0x0010, KEY_LAST },            /* RETURN */
	{ 0x0011, KEY_2 },
	{ 0x0012, KEY_4 },
	{ 0x0015, KEY_3 },
	{ 0x0016, KEY_5 },
	{ 0x0017, KEY_CHANNELDOWN },     /* Ch Dn */
	{ 0x0019, KEY_CHANNELUP },       /* CH Up */
	{ 0x001a, KEY_PAUSE },           /* PAUSE */
	{ 0x001b, KEY_1 },
	{ 0x001d, KEY_AUDIO },           /* DUAL SOUND */
	{ 0x001e, KEY_PLAY },            /* PLAY */
	{ 0x001f, KEY_PRINT },           /* SNAPSHOT */
	{ 0x0040, KEY_VOLUMEUP },        /* Vol Up */
	{ 0x0048, KEY_7 },
	{ 0x004c, KEY_6 },
	{ 0x004d, KEY_PLAYPAUSE },       /* TIMESHIFT */
	{ 0x0054, KEY_0 },
};

/* TREKSTOR DVB-T USB Stick */
static struct ir_scancode af9015_rc_trekstor[] = {
	{ 0x0084, KEY_0 },
	{ 0x0085, KEY_MUTE },            /* Mute */
	{ 0x0086, KEY_AGAIN },           /* Home */
	{ 0x0087, KEY_UP },              /* Up */
	{ 0x0088, KEY_ENTER },           /* OK */
	{ 0x0089, KEY_RIGHT },           /* Right */
	{ 0x008a, KEY_FASTFORWARD },     /* Fast forward */
	{ 0x008b, KEY_VOLUMEUP },        /* Volume + */
	{ 0x008c, KEY_DOWN },            /* Down */
	{ 0x008d, KEY_PLAY },            /* Play/Pause */
	{ 0x008e, KEY_STOP },            /* Stop */
	{ 0x008f, KEY_EPG },             /* Info/EPG */
	{ 0x0090, KEY_7 },
	{ 0x0091, KEY_4 },
	{ 0x0092, KEY_1 },
	{ 0x0093, KEY_CHANNELDOWN },     /* Channel - */
	{ 0x0094, KEY_8 },
	{ 0x0095, KEY_5 },
	{ 0x0096, KEY_2 },
	{ 0x0097, KEY_CHANNELUP },       /* Channel + */
	{ 0x0098, KEY_9 },
	{ 0x0099, KEY_6 },
	{ 0x009a, KEY_3 },
	{ 0x009b, KEY_VOLUMEDOWN },      /* Volume - */
	{ 0x009c, KEY_ZOOM },            /* TV */
	{ 0x009d, KEY_RECORD },          /* Record */
	{ 0x009e, KEY_REWIND },          /* Rewind */
	{ 0x009f, KEY_LEFT },            /* Left */
};

/* MSI DIGIVOX mini III */
/* Uses NEC extended 0x61d6. Extended byte removed for compatibility... */
static struct ir_scancode af9015_rc_msi_digivox_iii[] = {
	{ 0x6101, KEY_VIDEO },           /* Source */
	{ 0x6102, KEY_3 },
	{ 0x6103, KEY_POWER2 },          /* ShutDown */
	{ 0x6104, KEY_1 },
	{ 0x6105, KEY_5 },
	{ 0x6106, KEY_6 },
	{ 0x6107, KEY_CHANNELDOWN },     /* CH- */
	{ 0x6108, KEY_2 },
	{ 0x6109, KEY_CHANNELUP },       /* CH+ */
	{ 0x610a, KEY_9 },
	{ 0x610b, KEY_ZOOM },            /* Zoom */
	{ 0x610c, KEY_7 },
	{ 0x610d, KEY_8 },
	{ 0x610e, KEY_VOLUMEUP },        /* Vol+ */
	{ 0x610f, KEY_4 },
	{ 0x6110, KEY_ESC },             /* [back up arrow] */
	{ 0x6111, KEY_0 },
	{ 0x6112, KEY_OK },              /* [enter arrow] */
	{ 0x6113, KEY_VOLUMEDOWN },      /* Vol- */
	{ 0x6114, KEY_RECORD },          /* Rec */
	{ 0x6115, KEY_STOP },            /* Stop */
	{ 0x6116, KEY_PLAY },            /* Play */
	{ 0x6117, KEY_MUTE },            /* Mute */
	{ 0x6118, KEY_UP },
	{ 0x6119, KEY_DOWN },
	{ 0x611a, KEY_LEFT },
	{ 0x611b, KEY_RIGHT },
	{ 0x611c, KEY_RED },
	{ 0x611d, KEY_GREEN },
	{ 0x611e, KEY_YELLOW },
	{ 0x611f, KEY_BLUE },
	{ 0x6143, KEY_POWER },           /* [red power button] */
};

/* TerraTec - 4x7 slim remote */
/* Uses NEC extended 0x02bd. Extended byte removed for compatibility... */
static struct ir_scancode af9015_rc_terratec[] = {
	{ 0x0200, KEY_1 },
	{ 0x0201, KEY_2 },
	{ 0x0202, KEY_3 },
	{ 0x0203, KEY_4 },
	{ 0x0204, KEY_5 },
	{ 0x0205, KEY_6 },
	{ 0x0206, KEY_7 },
	{ 0x0207, KEY_8 },
	{ 0x0208, KEY_9 },
	{ 0x0209, KEY_0 },
	{ 0x020a, KEY_MUTE },
	{ 0x020b, KEY_ZOOM },            /* symbol: PIP or zoom ? */
	{ 0x020e, KEY_VOLUMEDOWN },
	{ 0x020f, KEY_PLAYPAUSE },
	{ 0x0210, KEY_RIGHT },
	{ 0x0211, KEY_LEFT },
	{ 0x0212, KEY_UP },
	{ 0x0213, KEY_DOWN },
	{ 0x0215, KEY_OK },
	{ 0x0216, KEY_STOP },
	{ 0x0217, KEY_CAMERA },          /* snapshot */
	{ 0x0218, KEY_CHANNELUP },
	{ 0x0219, KEY_RECORD },
	{ 0x021a, KEY_CHANNELDOWN },
	{ 0x021c, KEY_ESC },
	{ 0x021f, KEY_VOLUMEUP },
	{ 0x0244, KEY_EPG },
	{ 0x0245, KEY_POWER2 },          /* [red power button] */
};

#endif