By Date: <-- -->
By Thread: <-- -->

Pinnacle PCTV 50i grey remote control



On 3/6/06, Sylvain Pasche <sylvain.pasche (at) gmail.com> wrote:
> Here's an updated patch taking your proposal from irc into account.
> It's not very visible in the patch, but I have refactored the two
> get_key_pinnacle_(coloured|grey) functions into one
> (get_key_pinnacle).
> [...]

New version, which drops codes generated when a key is held down a
long time (it was making "unknown key" kernel messages). Sorry for
missing this :-/
diff -r f81d0494716e linux/drivers/media/video/ir-kbd-i2c.c
--- a/linux/drivers/media/video/ir-kbd-i2c.c	Fri Mar  3 12:05:48 2006
+++ b/linux/drivers/media/video/ir-kbd-i2c.c	Mon Mar  6 23:17:48 2006
 (at)  (at)  -152,12 +152,11  (at)  (at) 
 	return 1;
 }
 
-/* The new pinnacle PCTV remote (with the colored buttons)
- *
- * Ricardo Cerqueira <v4l (at) cerqueira.org>
+/* Common (grey or coloured) pinnacle PCTV remote handling
+ *
  */
-
-int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, 
+			    int parity_offset, int marker, int code_modulo)
 {
 	unsigned char b[4];
 	unsigned int start = 0,parity = 0,code = 0;
 (at)  (at)  -169,9 +168,9  (at)  (at) 
 	}
 
 	for (start = 0; start<4; start++) {
-		if (b[start] == 0x80) {
-			code=b[(start+3)%4];
-			parity=b[(start+2)%4];
+		if (b[start] == marker) {
+			code=b[(start+parity_offset+1)%4];
+			parity=b[(start+parity_offset)%4];
 		}
 	}
 
 (at)  (at)  -183,26 +182,57  (at)  (at) 
 	if (ir->old == parity)
 		return 0;
 
-
 	ir->old = parity;
 
-	/* Reduce code value to fit inside IR_KEYTAB_SIZE
+	/* drop special codes when a key is held down a long time for the grey controller
+	   In this case, the second bit of the code is asserted */
+	if (marker == 0xfe && (code & 0x40))
+		return 0;
+
+	code %= code_modulo;
+
+	*ir_raw = code;
+	*ir_key = code;
+
+	dprintk(1,"Pinnacle PCTV key %02x\n", code);
+
+	return 1;
+}
+
+/* The grey pinnacle PCTV remote
+ * 
+ *  There are one issue with this remote:
+ *   - I2c packet does not change when the same key is pressed quickly. The workaround
+ *     is to hold down each key for about half a second, so that another code is generated 
+ *     in the i2c packet, and the function can distinguish key presses.
+ *
+ * Sylvain Pasche <sylvain.pasche (at) gmail.com>
+ */
+int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+
+	return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff);
+}
+
+EXPORT_SYMBOL_GPL(get_key_pinnacle_grey);
+
+
+/* The new pinnacle PCTV remote (with the colored buttons)
+ *
+ * Ricardo Cerqueira <v4l (at) cerqueira.org>
+ */
+int get_key_pinnacle_coloured(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+	/* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
 	 *
 	 * this is the only value that results in 42 unique
 	 * codes < 128
 	 */
 
-	code %= 0x88;
-
-	*ir_raw = code;
-	*ir_key = code;
-
-	dprintk(1,"Pinnacle PCTV key %02x\n", code);
-
-	return 1;
-}
-
-EXPORT_SYMBOL_GPL(get_key_pinnacle);
+	return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
+}
+
+EXPORT_SYMBOL_GPL(get_key_pinnacle_coloured);
 
 /* ----------------------------------------------------------------------- */
 
diff -r f81d0494716e linux/drivers/media/video/saa7134/saa7134-input.c
--- a/linux/drivers/media/video/saa7134/saa7134-input.c	Fri Mar  3 12:05:48 2006
+++ b/linux/drivers/media/video/saa7134/saa7134-input.c	Mon Mar  6 23:17:48 2006
 (at)  (at)  -38,6 +38,10  (at)  (at) 
 static unsigned int ir_debug = 0;
 module_param(ir_debug, int, 0644);
 MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
+
+static int pinnacle_remote = 0;
+module_param(pinnacle_remote, int, 0644);    /* Choose Pinnacle PCTV remote */
+MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
 
 #define dprintk(fmt, arg...)	if (ir_debug) \
 	printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
 (at)  (at)  -324,8 +328,14  (at)  (at) 
 	switch (dev->board) {
 	case SAA7134_BOARD_PINNACLE_PCTV_110i:
 		snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV");
-		ir->get_key   = get_key_pinnacle;
-		ir->ir_codes  = ir_codes_pinnacle;
+		if (pinnacle_remote == 0) {
+			ir->get_key   = get_key_pinnacle_coloured;
+			ir->ir_codes = ir_codes_pinnacle;
+		} else {
+			ir->get_key   = get_key_pinnacle_grey;
+			// FIXME: ir code variable should be renamed as it is not only used by usb now
+			ir->ir_codes = ir_codes_em_pinnacle_usb;
+		}
 		break;
 	case SAA7134_BOARD_UPMOST_PURPLE_TV:
 		snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV");
diff -r f81d0494716e linux/include/media/ir-kbd-i2c.h
--- a/linux/include/media/ir-kbd-i2c.h	Fri Mar  3 12:05:48 2006
+++ b/linux/include/media/ir-kbd-i2c.h	Mon Mar  6 23:17:48 2006
 (at)  (at)  -20,5 +20,6  (at)  (at) 
 	int                    (*get_key)(struct IR_i2c*, u32*, u32*);
 };
 
-int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
+int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
+int get_key_pinnacle_coloured(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
 #endif
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request (at) redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list