All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] af9035: add remote control support
@ 2012-04-21 22:23 Hans-Frieder Vogt
  2012-05-07 18:46 ` Antti Palosaari
  0 siblings, 1 reply; 2+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-21 22:23 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab
  Cc: linux-media, Michael Büsch, Gianluca Gennari

af9035: support remote controls, version 2 of patch (Currently, no key maps are loaded).

This version of the patch addresses comments from Antti and Mauro. Thank very much for your comments!
Compared to the first version of the patch, the remote control is only activated after the EEPROM has been read
and confirmed that the remote is not working in the HID mode.
In addition, config variables are no longer needed and unnecessary checks have been removed.

Signed-off-by: Hans-Frieder Vogt <hfvogt@gmx.net>

 af9035.c |   65 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 af9035.h |    1 
 2 files changed, 66 insertions(+)

diff -Nupr a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-usb/af9035.c
--- a/drivers/media/dvb/dvb-usb/af9035.c	2012-04-10 05:45:26.000000000 +0200
+++ b/drivers/media/dvb/dvb-usb/af9035.c	2012-04-22 00:11:29.288907184 +0200
@@ -314,6 +314,37 @@ static struct i2c_algorithm af9035_i2c_a
 	.functionality = af9035_i2c_functionality,
 };
 
+#define AF9035_POLL 250
+static int af9035_rc_query(struct dvb_usb_device *d)
+{
+	unsigned int key;
+	unsigned char b[4];
+	int ret;
+	struct usb_req req = { CMD_IR_GET, 0, 0, NULL, 4, b };
+
+	ret = af9035_ctrl_msg(d->udev, &req);
+	if (ret < 0)
+		goto err;
+
+	if ((b[2] + b[3]) == 0xff) {
+		if ((b[0] + b[1]) == 0xff) {
+			/* NEC */
+			key = b[0] << 8 | b[2];
+		} else {
+			/* ext. NEC */
+			key = b[0] << 16 | b[1] << 8 | b[2];
+		}
+	} else {
+		key = b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
+	}
+
+	rc_keydown(d->rc_dev, key, 0);
+
+err:
+	/* ignore errors */
+	return 0;
+}
+
 static int af9035_init(struct dvb_usb_device *d)
 {
 	int ret, i;
@@ -628,6 +659,32 @@ static int af9035_read_mac_address(struc
 	for (i = 0; i < af9035_properties[0].num_adapters; i++)
 		af9035_af9033_config[i].clock = clock_lut[tmp];
 
+	ret = af9035_rd_reg(d, EEPROM_IR_MODE, &tmp);
+	if (ret < 0)
+		goto err;
+	pr_debug("%s: ir_mode=%02x\n", __func__, tmp);
+
+	/* don't activate rc if in HID mode or if not available */
+	if (tmp == 5) {
+		ret = af9035_rd_reg(d, EEPROM_IR_TYPE, &tmp);
+		if (ret < 0)
+			goto err;
+		pr_debug("%s: ir_type=%02x\n", __func__, tmp);
+
+		switch (tmp) {
+		case 0: /* NEC */
+		default:
+			d->props.rc.core.protocol = RC_TYPE_NEC;
+			d->props.rc.core.allowed_protos = RC_TYPE_NEC;
+			break;
+		case 1: /* RC6 */
+			d->props.rc.core.protocol = RC_TYPE_RC6;
+			d->props.rc.core.allowed_protos = RC_TYPE_RC6;
+			break;
+		}
+		d->props.rc.core.rc_query = af9035_rc_query;
+	}
+
 	return 0;
 
 err:
@@ -1004,6 +1061,14 @@ static struct dvb_usb_device_properties
 
 		.i2c_algo = &af9035_i2c_algo,
 
+		.rc.core = {
+			.protocol       = RC_TYPE_UNKNOWN,
+			.module_name    = "af9035",
+			.rc_query       = NULL,
+			.rc_interval    = AF9035_POLL,
+			.allowed_protos = RC_TYPE_UNKNOWN,
+			.rc_codes       = RC_MAP_EMPTY,
+		},
 		.num_device_descs = 5,
 		.devices = {
 			{
diff -Nupr a/drivers/media/dvb/dvb-usb/af9035.h b/drivers/media/dvb/dvb-usb/af9035.h
--- a/drivers/media/dvb/dvb-usb/af9035.h	2012-04-10 05:45:26.000000000 +0200
+++ b/drivers/media/dvb/dvb-usb/af9035.h	2012-04-21 17:07:49.201161565 +0200
@@ -110,6 +110,7 @@ u32 clock_lut_it9135[] = {
 #define CMD_MEM_WR                  0x01
 #define CMD_I2C_RD                  0x02
 #define CMD_I2C_WR                  0x03
+#define CMD_IR_GET                  0x18
 #define CMD_FW_DL                   0x21
 #define CMD_FW_QUERYINFO            0x22
 #define CMD_FW_BOOT                 0x23

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] af9035: add remote control support
  2012-04-21 22:23 [PATCH v2] af9035: add remote control support Hans-Frieder Vogt
@ 2012-05-07 18:46 ` Antti Palosaari
  0 siblings, 0 replies; 2+ messages in thread
From: Antti Palosaari @ 2012-05-07 18:46 UTC (permalink / raw)
  To: Hans-Frieder Vogt
  Cc: Mauro Carvalho Chehab, linux-media, Michael Büsch, Gianluca Gennari

On 22.04.2012 01:23, Hans-Frieder Vogt wrote:
> af9035: support remote controls, version 2 of patch (Currently, no key maps are loaded).
>
> This version of the patch addresses comments from Antti and Mauro. Thank very much for your comments!
> Compared to the first version of the patch, the remote control is only activated after the EEPROM has been read
> and confirmed that the remote is not working in the HID mode.
> In addition, config variables are no longer needed and unnecessary checks have been removed.
>
> Signed-off-by: Hans-Frieder Vogt<hfvogt@gmx.net>

I applied that and already PULL requested via my tree. Thanks!


regards
Antti

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-07 18:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-21 22:23 [PATCH v2] af9035: add remote control support Hans-Frieder Vogt
2012-05-07 18:46 ` Antti Palosaari

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.