All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] [media] Remove staging/lirc/lirc_i2c driver
       [not found] <cover.1293709356.git.mchehab@redhat.com>
@ 2010-12-30 11:45 ` Mauro Carvalho Chehab
  2010-12-30 11:45 ` [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 11:45 UTC (permalink / raw)
  Cc: Linux Media Mailing List

This driver duplicates the same functionality found at ir-kbd-i2c.
There were a few missing key parsers that were added by the previous
patches. The only thing left on lirc_i2c driver is the IR parsing
for Asus TV-Box and Creative/VisionTek BreakOut-Box.
Those devices use pcf8574 chip for IR.

They are old video adapters with TV tuners. Their code were never
merged upstream, and they are not chipped anymore. So, it is very
unlikely that someone would have interests on porting them to the
Linux Kernel.

Due to that, let's remove lirc_i2c, as all the remaining functionality
are already mapped via ir-kbd-i2c.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

 delete mode 100644 drivers/staging/lirc/lirc_i2c.c

diff --git a/drivers/staging/lirc/Kconfig b/drivers/staging/lirc/Kconfig
index be97f7b..cdaff59 100644
--- a/drivers/staging/lirc/Kconfig
+++ b/drivers/staging/lirc/Kconfig
@@ -18,13 +18,6 @@ config LIRC_BT829
 	help
 	  Driver for the IR interface on BT829-based hardware
 
-config LIRC_I2C
-	tristate "I2C Based IR Receivers"
-	depends on LIRC && I2C
-	help
-	  Driver for I2C-based IR receivers, such as those commonly
-	  found onboard Hauppauge PVR-150/250/350 video capture cards
-
 config LIRC_IGORPLUGUSB
 	tristate "Igor Cesko's USB IR Receiver"
 	depends on LIRC && USB
diff --git a/drivers/staging/lirc/Makefile b/drivers/staging/lirc/Makefile
index 4da1f33..94af218 100644
--- a/drivers/staging/lirc/Makefile
+++ b/drivers/staging/lirc/Makefile
@@ -4,7 +4,6 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_LIRC_BT829)	+= lirc_bt829.o
-obj-$(CONFIG_LIRC_I2C)		+= lirc_i2c.o
 obj-$(CONFIG_LIRC_IGORPLUGUSB)	+= lirc_igorplugusb.o
 obj-$(CONFIG_LIRC_IMON)		+= lirc_imon.o
 obj-$(CONFIG_LIRC_IT87)		+= lirc_it87.o
diff --git a/drivers/staging/lirc/lirc_i2c.c b/drivers/staging/lirc/lirc_i2c.c
deleted file mode 100644
index 6df2c0e..0000000
--- a/drivers/staging/lirc/lirc_i2c.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * lirc_i2c.c
- *
- * i2c IR driver for the onboard IR port on many TV tuner cards, including:
- *  -Flavors of the Hauppauge PVR-150/250/350
- *  -Hauppauge HVR-1300
- *  -PixelView (BT878P+W/FM)
- *  -KNC ONE TV Station/Anubis Typhoon TView Tuner
- *  -Asus TV-Box and Creative/VisionTek BreakOut-Box
- *  -Leadtek Winfast PVR2000
- *
- * Copyright (c) 2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
- * modified for PixelView (BT878P+W/FM) by
- *      Michal Kochanowicz <mkochano@pld.org.pl>
- *      Christoph Bartelmus <lirc@bartelmus.de>
- * modified for KNC ONE TV Station/Anubis Typhoon TView Tuner by
- *      Ulrich Mueller <ulrich.mueller42@web.de>
- * modified for Asus TV-Box and Creative/VisionTek BreakOut-Box by
- *      Stefan Jahn <stefan@lkcc.org>
- * modified for inclusion into kernel sources by
- *      Jerome Brock <jbrock@users.sourceforge.net>
- * modified for Leadtek Winfast PVR2000 by
- *      Thomas Reitmayr (treitmayr@yahoo.com)
- * modified for Hauppauge HVR-1300 by
- *      Jan Frey (jfrey@gmx.de)
- *
- * parts are cut&pasted from the old lirc_haup.c driver
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/kmod.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/i2c-algo-bit.h>
-
-#include <media/lirc_dev.h>
-
-struct IR {
-	struct lirc_driver l;
-	struct i2c_client  c;
-	int nextkey;
-	unsigned char b[3];
-	unsigned char bits;
-	unsigned char flag;
-};
-
-#define DEVICE_NAME "lirc_i2c"
-
-/* module parameters */
-static int debug;	/* debug output */
-static int minor = -1;	/* minor number */
-
-#define dprintk(fmt, args...)						\
-	do {								\
-		if (debug)						\
-			printk(KERN_DEBUG DEVICE_NAME ": " fmt,		\
-			       ## args);				\
-	} while (0)
-
-static int reverse(int data, int bits)
-{
-	int i;
-	int c;
-
-	for (c = 0, i = 0; i < bits; i++)
-		c |= ((data & (1<<i)) ? 1 : 0) << (bits-1-i);
-
-	return c;
-}
-
-static int add_to_buf_adap(void *data, struct lirc_buffer *buf)
-{
-	struct IR *ir = data;
-	unsigned char keybuf[4];
-
-	keybuf[0] = 0x00;
-	i2c_master_send(&ir->c, keybuf, 1);
-	/* poll IR chip */
-	if (i2c_master_recv(&ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
-		dprintk("read error\n");
-		return -EIO;
-	}
-
-	dprintk("key (0x%02x%02x%02x%02x)\n",
-		keybuf[0], keybuf[1], keybuf[2], keybuf[3]);
-
-	/* key pressed ? */
-	if (keybuf[2] == 0xff)
-		return -ENODATA;
-
-	/* remove repeat bit */
-	keybuf[2] &= 0x7f;
-	keybuf[3] |= 0x80;
-
-	lirc_buffer_write(buf, keybuf);
-	return 0;
-}
-
-static int add_to_buf_pcf8574(void *data, struct lirc_buffer *buf)
-{
-	struct IR *ir = data;
-	int rc;
-	unsigned char all, mask;
-	unsigned char key;
-
-	/* compute all valid bits (key code + pressed/release flag) */
-	all = ir->bits | ir->flag;
-
-	/* save IR writable mask bits */
-	mask = i2c_smbus_read_byte(&ir->c) & ~all;
-
-	/* send bit mask */
-	rc = i2c_smbus_write_byte(&ir->c, (0xff & all) | mask);
-
-	/* receive scan code */
-	rc = i2c_smbus_read_byte(&ir->c);
-
-	if (rc == -1) {
-		dprintk("%s read error\n", ir->c.name);
-		return -EIO;
-	}
-
-	/* drop duplicate polls */
-	if (ir->b[0] == (rc & all))
-		return -ENODATA;
-
-	ir->b[0] = rc & all;
-
-	dprintk("%s key 0x%02X %s\n", ir->c.name, rc & ir->bits,
-		(rc & ir->flag) ? "released" : "pressed");
-
-	/* ignore released buttons */
-	if (rc & ir->flag)
-		return -ENODATA;
-
-	/* set valid key code */
-	key  = rc & ir->bits;
-	lirc_buffer_write(buf, &key);
-	return 0;
-}
-
-/* common for Hauppauge IR receivers */
-static int add_to_buf_haup_common(void *data, struct lirc_buffer *buf,
-		unsigned char *keybuf, int size, int offset)
-{
-	struct IR *ir = data;
-	__u16 code;
-	unsigned char codes[2];
-	int ret;
-
-	/* poll IR chip */
-	ret = i2c_master_recv(&ir->c, keybuf, size);
-	if (ret == size) {
-		ir->b[0] = keybuf[offset];
-		ir->b[1] = keybuf[offset+1];
-		ir->b[2] = keybuf[offset+2];
-		if (ir->b[0] != 0x00 && ir->b[1] != 0x00)
-			dprintk("key (0x%02x/0x%02x)\n", ir->b[0], ir->b[1]);
-	} else {
-		dprintk("read error (ret=%d)\n", ret);
-		/* keep last successful read buffer */
-	}
-
-	/* key pressed ? */
-	if ((ir->b[0] & 0x80) == 0)
-		return -ENODATA;
-
-	/* look what we have */
-	code = (((__u16)ir->b[0]&0x7f)<<6) | (ir->b[1]>>2);
-
-	codes[0] = (code >> 8) & 0xff;
-	codes[1] = code & 0xff;
-
-	/* return it */
-	dprintk("sending code 0x%02x%02x to lirc\n", codes[0], codes[1]);
-	lirc_buffer_write(buf, codes);
-	return 0;
-}
-
-/* specific for the Hauppauge PVR150 IR receiver */
-static int add_to_buf_haup_pvr150(void *data, struct lirc_buffer *buf)
-{
-	unsigned char keybuf[6];
-	/* fetch 6 bytes, first relevant is at offset 3 */
-	return add_to_buf_haup_common(data, buf, keybuf, 6, 3);
-}
-
-/* used for all Hauppauge IR receivers but the PVR150 */
-static int add_to_buf_haup(void *data, struct lirc_buffer *buf)
-{
-	unsigned char keybuf[3];
-	/* fetch 3 bytes, first relevant is at offset 0 */
-	return add_to_buf_haup_common(data, buf, keybuf, 3, 0);
-}
-
-
-static int add_to_buf_pvr2000(void *data, struct lirc_buffer *buf)
-{
-	struct IR *ir = data;
-	unsigned char key;
-	s32 flags;
-	s32 code;
-
-	/* poll IR chip */
-	flags = i2c_smbus_read_byte_data(&ir->c, 0x10);
-	if (-1 == flags) {
-		dprintk("read error\n");
-		return -ENODATA;
-	}
-	/* key pressed ? */
-	if (0 == (flags & 0x80))
-		return -ENODATA;
-
-	/* read actual key code */
-	code = i2c_smbus_read_byte_data(&ir->c, 0x00);
-	if (-1 == code) {
-		dprintk("read error\n");
-		return -ENODATA;
-	}
-
-	key = code & 0xFF;
-
-	dprintk("IR Key/Flags: (0x%02x/0x%02x)\n", key, flags & 0xFF);
-
-	/* return it */
-	lirc_buffer_write(buf, &key);
-	return 0;
-}
-
-static int add_to_buf_pixelview(void *data, struct lirc_buffer *buf)
-{
-	struct IR *ir = data;
-	unsigned char key;
-
-	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c, &key, 1)) {
-		dprintk("read error\n");
-		return -1;
-	}
-	dprintk("key %02x\n", key);
-
-	/* return it */
-	lirc_buffer_write(buf, &key);
-	return 0;
-}
-
-static int add_to_buf_pv951(void *data, struct lirc_buffer *buf)
-{
-	struct IR *ir = data;
-	unsigned char key;
-	unsigned char codes[4];
-
-	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c, &key, 1)) {
-		dprintk("read error\n");
-		return -ENODATA;
-	}
-	/* ignore 0xaa */
-	if (key == 0xaa)
-		return -ENODATA;
-	dprintk("key %02x\n", key);
-
-	codes[0] = 0x61;
-	codes[1] = 0xD6;
-	codes[2] = reverse(key, 8);
-	codes[3] = (~codes[2])&0xff;
-
-	lirc_buffer_write(buf, codes);
-	return 0;
-}
-
-static int add_to_buf_knc1(void *data, struct lirc_buffer *buf)
-{
-	static unsigned char last_key = 0xFF;
-	struct IR *ir = data;
-	unsigned char key;
-
-	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c, &key, 1)) {
-		dprintk("read error\n");
-		return -ENODATA;
-	}
-
-	/*
-	 * it seems that 0xFE indicates that a button is still held
-	 * down, while 0xFF indicates that no button is held
-	 * down. 0xFE sequences are sometimes interrupted by 0xFF
-	 */
-
-	dprintk("key %02x\n", key);
-
-	if (key == 0xFF)
-		return -ENODATA;
-
-	if (key == 0xFE)
-		key = last_key;
-
-	last_key = key;
-	lirc_buffer_write(buf, &key);
-
-	return 0;
-}
-
-static int set_use_inc(void *data)
-{
-	struct IR *ir = data;
-
-	dprintk("%s called\n", __func__);
-
-	/* lock bttv in memory while /dev/lirc is in use  */
-	i2c_use_client(&ir->c);
-
-	return 0;
-}
-
-static void set_use_dec(void *data)
-{
-	struct IR *ir = data;
-
-	dprintk("%s called\n", __func__);
-
-	i2c_release_client(&ir->c);
-}
-
-static struct lirc_driver lirc_template = {
-	.name		= "lirc_i2c",
-	.set_use_inc	= set_use_inc,
-	.set_use_dec	= set_use_dec,
-	.dev		= NULL,
-	.owner		= THIS_MODULE,
-};
-
-static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id);
-static int ir_remove(struct i2c_client *client);
-static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg);
-
-static const struct i2c_device_id ir_receiver_id[] = {
-	/* Generic entry for any IR receiver */
-	{ "ir_video", 0 },
-	/* IR device specific entries could be added here */
-	{ }
-};
-
-static struct i2c_driver driver = {
-	.driver = {
-		.owner	= THIS_MODULE,
-		.name	= "i2c ir driver",
-	},
-	.probe		= ir_probe,
-	.remove		= ir_remove,
-	.id_table	= ir_receiver_id,
-	.command	= ir_command,
-};
-
-static void pcf_probe(struct i2c_client *client, struct IR *ir)
-{
-	int ret1, ret2, ret3, ret4;
-
-	ret1 = i2c_smbus_write_byte(client, 0xff);
-	ret2 = i2c_smbus_read_byte(client);
-	ret3 = i2c_smbus_write_byte(client, 0x00);
-	ret4 = i2c_smbus_read_byte(client);
-
-	/* in the Asus TV-Box: bit 1-0 */
-	if (((ret2 & 0x03) == 0x03) && ((ret4 & 0x03) == 0x00)) {
-		ir->bits = (unsigned char) ~0x07;
-		ir->flag = 0x04;
-	/* in the Creative/VisionTek BreakOut-Box: bit 7-6 */
-	} else if (((ret2 & 0xc0) == 0xc0) && ((ret4 & 0xc0) == 0x00)) {
-		ir->bits = (unsigned char) ~0xe0;
-		ir->flag = 0x20;
-	}
-
-	return;
-}
-
-static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
-{
-	struct IR *ir;
-	struct i2c_adapter *adap = client->adapter;
-	unsigned short addr = client->addr;
-	int retval;
-
-	ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
-	if (!ir)
-		return -ENOMEM;
-	memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver));
-	memcpy(&ir->c, client, sizeof(struct i2c_client));
-
-	i2c_set_clientdata(client, ir);
-	ir->l.data    = ir;
-	ir->l.minor   = minor;
-	ir->l.sample_rate = 10;
-	ir->l.dev     = &ir->c.dev;
-	ir->nextkey   = -1;
-
-	switch (addr) {
-	case 0x64:
-		strlcpy(ir->c.name, "Pixelview IR", I2C_NAME_SIZE);
-		ir->l.code_length = 8;
-		ir->l.add_to_buf = add_to_buf_pixelview;
-		break;
-	case 0x4b:
-		strlcpy(ir->c.name, "PV951 IR", I2C_NAME_SIZE);
-		ir->l.code_length = 32;
-		ir->l.add_to_buf = add_to_buf_pv951;
-		break;
-	case 0x71:
-		if (adap->id == I2C_HW_B_CX2388x)
-			strlcpy(ir->c.name, "Hauppauge HVR1300", I2C_NAME_SIZE);
-		else /* bt8xx or cx2341x */
-			/*
-			 * The PVR150 IR receiver uses the same protocol as
-			 * other Hauppauge cards, but the data flow is
-			 * different, so we need to deal with it by its own.
-			 */
-			strlcpy(ir->c.name, "Hauppauge PVR150", I2C_NAME_SIZE);
-		ir->l.code_length = 13;
-		ir->l.add_to_buf = add_to_buf_haup_pvr150;
-		break;
-	case 0x6b:
-		strlcpy(ir->c.name, "Adaptec IR", I2C_NAME_SIZE);
-		ir->l.code_length = 32;
-		ir->l.add_to_buf = add_to_buf_adap;
-		break;
-	case 0x18:
-	case 0x1a:
-		if (adap->id == I2C_HW_B_CX2388x) {
-			strlcpy(ir->c.name, "Leadtek IR", I2C_NAME_SIZE);
-			ir->l.code_length = 8;
-			ir->l.add_to_buf = add_to_buf_pvr2000;
-		} else { /* bt8xx or cx2341x */
-			strlcpy(ir->c.name, "Hauppauge IR", I2C_NAME_SIZE);
-			ir->l.code_length = 13;
-			ir->l.add_to_buf = add_to_buf_haup;
-		}
-		break;
-	case 0x30:
-		strlcpy(ir->c.name, "KNC ONE IR", I2C_NAME_SIZE);
-		ir->l.code_length = 8;
-		ir->l.add_to_buf = add_to_buf_knc1;
-		break;
-	case 0x21:
-	case 0x23:
-		pcf_probe(client, ir);
-		strlcpy(ir->c.name, "TV-Box IR", I2C_NAME_SIZE);
-		ir->l.code_length = 8;
-		ir->l.add_to_buf = add_to_buf_pcf8574;
-		break;
-	default:
-		/* shouldn't happen */
-		printk("lirc_i2c: Huh? unknown i2c address (0x%02x)?\n", addr);
-		kfree(ir);
-		return -EINVAL;
-	}
-	printk(KERN_INFO "lirc_i2c: chip 0x%x found @ 0x%02x (%s)\n",
-	       adap->id, addr, ir->c.name);
-
-	retval = lirc_register_driver(&ir->l);
-
-	if (retval < 0) {
-		printk(KERN_ERR "lirc_i2c: failed to register driver!\n");
-		kfree(ir);
-		return retval;
-	}
-
-	ir->l.minor = retval;
-
-	return 0;
-}
-
-static int ir_remove(struct i2c_client *client)
-{
-	struct IR *ir = i2c_get_clientdata(client);
-
-	/* unregister device */
-	lirc_unregister_driver(ir->l.minor);
-
-	/* free memory */
-	kfree(ir);
-	return 0;
-}
-
-static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg)
-{
-	/* nothing */
-	return 0;
-}
-
-static int __init lirc_i2c_init(void)
-{
-	i2c_add_driver(&driver);
-	return 0;
-}
-
-static void __exit lirc_i2c_exit(void)
-{
-	i2c_del_driver(&driver);
-}
-
-MODULE_DESCRIPTION("Infrared receiver driver for Hauppauge and "
-		   "Pixelview cards (i2c stack)");
-MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, "
-	      "Ulrich Mueller, Stefan Jahn, Jerome Brock");
-MODULE_LICENSE("GPL");
-
-module_param(minor, int, S_IRUGO);
-MODULE_PARM_DESC(minor, "Preferred minor device number");
-
-module_param(debug, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(debug, "Enable debugging messages");
-
-module_init(lirc_i2c_init);
-module_exit(lirc_i2c_exit);
-- 
1.7.3.4


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

* [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
       [not found] <cover.1293709356.git.mchehab@redhat.com>
  2010-12-30 11:45 ` [PATCH 4/4] [media] Remove staging/lirc/lirc_i2c driver Mauro Carvalho Chehab
@ 2010-12-30 11:45 ` Mauro Carvalho Chehab
  2010-12-30 11:56   ` Hans Verkuil
                     ` (3 more replies)
  2010-12-30 11:45 ` [PATCH 2/4] [media] cx88: Add RC logic for Leadtek PVR 2000 Mauro Carvalho Chehab
  2010-12-30 11:45 ` [PATCH 1/4] [media] bttv-input: Add a note about PV951 RC Mauro Carvalho Chehab
  3 siblings, 4 replies; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 11:45 UTC (permalink / raw)
  Cc: Linux Media Mailing List

lirc-i2c implements a get key logic for the Adaptec Remote
Controller, at address 0x6b. The only driver that seems to have
an Adaptec device is ivtv:

$ git grep -i adaptec drivers/media
drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */

There are two Adaptec cards defined there, but only one has tuner.
I never found any device without tuners, but with a remote controllers, so
the logic at lirc_i2c seems to be for Adaptec AVC-2410.

As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
use it for AVC2410.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 6817092..8d1b016 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -94,6 +94,7 @@
 #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
 #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
 #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
+#define IVTV_ADAPTEC_IR			0x6b
 
 /* This array should match the IVTV_HW_ defines */
 static const u8 hw_addrs[] = {
@@ -118,6 +119,7 @@ static const u8 hw_addrs[] = {
 	IVTV_HAUP_INT_IR_RX_I2C_ADDR,	/* IVTV_HW_I2C_IR_RX_HAUP_INT */
 	IVTV_Z8F0811_IR_TX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
 	IVTV_Z8F0811_IR_RX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
+	IVTV_ADAPTEC_IR,
 };
 
 /* This array should match the IVTV_HW_ defines */
@@ -145,6 +147,31 @@ static const char * const hw_devicenames[] = {
 	"ir_rx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
 };
 
+static int get_key_adaptec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+	unsigned char keybuf[4];
+
+	keybuf[0] = 0x00;
+	i2c_master_send(ir->c, keybuf, 1);
+	/* poll IR chip */
+	if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
+		return 0;
+	}
+
+	/* key pressed ? */
+	if (keybuf[2] == 0xff)
+		return 0;
+
+	/* remove repeat bit */
+	keybuf[2] &= 0x7f;
+	keybuf[3] |= 0x80;
+
+	*ir_key = (u32) keybuf;
+	*ir_raw = (u32) keybuf;
+
+	return 1;
+}
+
 static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 {
 	struct i2c_board_info info;
@@ -190,6 +217,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 		init_data->type = RC_TYPE_RC5;
 		init_data->name = itv->card_name;
 		break;
+	case IVTV_CARD_AVC2410:
+		init_data->ir_codes = RC_MAP_EMPTY;
+		init_data->get_key = get_key_adaptec;
+		init_data->type = RC_TYPE_UNKNOWN;
+		init_data->name = itv->card_name;
+		break;
 	}
 
 	memset(&info, 0, sizeof(struct i2c_board_info));
@@ -219,7 +252,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 		0x1a,	/* Hauppauge IR external - collides with WM8739 */
 		0x18,	/* Hauppauge IR internal */
 		0x71,	/* Hauppauge IR (PVR150) */
-		0x6b,	/* Adaptec IR */
 		I2C_CLIENT_END
 	};
 
-- 
1.7.3.4



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

* [PATCH 2/4] [media] cx88: Add RC logic for Leadtek PVR 2000
       [not found] <cover.1293709356.git.mchehab@redhat.com>
  2010-12-30 11:45 ` [PATCH 4/4] [media] Remove staging/lirc/lirc_i2c driver Mauro Carvalho Chehab
  2010-12-30 11:45 ` [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller Mauro Carvalho Chehab
@ 2010-12-30 11:45 ` Mauro Carvalho Chehab
  2010-12-30 11:45 ` [PATCH 1/4] [media] bttv-input: Add a note about PV951 RC Mauro Carvalho Chehab
  3 siblings, 0 replies; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 11:45 UTC (permalink / raw)
  Cc: Linux Media Mailing List

Currently, lirc-i2c has a decoding logic for Leadtek Remote
Control. Move it to cx88, as we intend to remove lirc-i2c.

For now, initialize LIRC remote keytable with RC_MAP_EMPTY, as
we don't know its keymap yet. It would be nice to later check
if is there any file on LIRC userspace with that keytable.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 4a3bf54..06f7d1d 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -68,6 +68,9 @@ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
 #define ir_dprintk(fmt, arg...)	if (ir_debug) \
 	printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg)
 
+#define dprintk(fmt, arg...)	if (ir_debug) \
+	printk(KERN_DEBUG "cx88 IR: " fmt , ##arg)
+
 /* ---------------------------------------------------------------------- */
 
 static void cx88_ir_handle_key(struct cx88_IR *ir)
@@ -527,13 +530,47 @@ void cx88_ir_irq(struct cx88_core *core)
 	ir_raw_event_handle(ir->dev);
 }
 
+static int get_key_pvr2000(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+	int flags, code;
+
+	/* poll IR chip */
+	flags = i2c_smbus_read_byte_data(ir->c, 0x10);
+	if (flags < 0) {
+		dprintk("read error\n");
+		return 0;
+	}
+	/* key pressed ? */
+	if (0 == (flags & 0x80))
+		return 0;
+
+	/* read actual key code */
+	code = i2c_smbus_read_byte_data(ir->c, 0x00);
+	if (code < 0) {
+		dprintk("read error\n");
+		return 0;
+	}
+
+	dprintk("IR Key/Flags: (0x%02x/0x%02x)\n",
+		   code & 0xff, flags & 0xff);
+
+	*ir_key = code & 0xff;
+	*ir_raw = code;
+	return 1;
+}
+
 void cx88_i2c_init_ir(struct cx88_core *core)
 {
 	struct i2c_board_info info;
-	const unsigned short addr_list[] = {
+	const unsigned short default_addr_list[] = {
 		0x18, 0x6b, 0x71,
 		I2C_CLIENT_END
 	};
+	const unsigned short pvr2000_addr_list[] = {
+		0x18, 0x1a,
+		I2C_CLIENT_END
+	};
+	const unsigned short *addr_list = default_addr_list;
 	const unsigned short *addrp;
 	/* Instantiate the IR receiver device, if present */
 	if (0 != core->i2c_rc)
@@ -542,6 +579,16 @@ void cx88_i2c_init_ir(struct cx88_core *core)
 	memset(&info, 0, sizeof(struct i2c_board_info));
 	strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
 
+	switch (core->boardnr) {
+	case CX88_BOARD_LEADTEK_PVR2000:
+		addr_list = pvr2000_addr_list;
+		core->init_data.name = "cx88 Leadtek PVR 2000 remote";
+		core->init_data.type = RC_TYPE_UNKNOWN;
+		core->init_data.get_key = get_key_pvr2000;
+		core->init_data.ir_codes = RC_MAP_EMPTY;
+		break;
+	}
+
 	/*
 	 * We can't call i2c_new_probed_device() because it uses
 	 * quick writes for probing and at least some RC receiver
-- 
1.7.3.4



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

* [PATCH 1/4] [media] bttv-input: Add a note about PV951 RC
       [not found] <cover.1293709356.git.mchehab@redhat.com>
                   ` (2 preceding siblings ...)
  2010-12-30 11:45 ` [PATCH 2/4] [media] cx88: Add RC logic for Leadtek PVR 2000 Mauro Carvalho Chehab
@ 2010-12-30 11:45 ` Mauro Carvalho Chehab
  3 siblings, 0 replies; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 11:45 UTC (permalink / raw)
  Cc: Linux Media Mailing List

When comparing lirc-i2c and ir-kbd-i2c/bttv-input logic, a difference
was noticed. As lirc-i2c will be removed soon, store the difference on
a comment inside ir-kbd-i2c, in order to preserve the knowledge we
have about that remote controller.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index 7f48306..97793b9 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -354,6 +354,18 @@ static int get_key_pv951(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
 		return 0;
 	dprintk(KERN_INFO DEVNAME ": key %02x\n", b);
 
+	/*
+	 * NOTE:
+	 * lirc_i2c maps the pv951 code as:
+	 *	addr = 0x61D6
+	 * 	cmd = bit_reverse (b)
+	 * So, it seems that this device uses NEC extended
+	 * I decided to not fix the table, due to two reasons:
+	 * 	1) Without the actual device, this is only a guess;
+	 * 	2) As the addr is not reported via I2C, nor can be changed,
+	 * 	   the device is bound to the vendor-provided RC.
+	 */
+
 	*ir_key = b;
 	*ir_raw = b;
 	return 1;
-- 
1.7.3.4



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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 11:45 ` [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller Mauro Carvalho Chehab
@ 2010-12-30 11:56   ` Hans Verkuil
  2010-12-30 12:09     ` Mauro Carvalho Chehab
  2010-12-30 12:36   ` Andy Walls
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ messages in thread
From: Hans Verkuil @ 2010-12-30 11:56 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List

On Thursday, December 30, 2010 12:45:09 Mauro Carvalho Chehab wrote:
> lirc-i2c implements a get key logic for the Adaptec Remote
> Controller, at address 0x6b. The only driver that seems to have
> an Adaptec device is ivtv:
> 
> $ git grep -i adaptec drivers/media
> drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
> drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
> drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
> drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
> 
> There are two Adaptec cards defined there, but only one has tuner.
> I never found any device without tuners, but with a remote controllers, so
> the logic at lirc_i2c seems to be for Adaptec AVC-2410.

That's correct. The AVC-2010 does not come with a remote.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco

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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 11:56   ` Hans Verkuil
@ 2010-12-30 12:09     ` Mauro Carvalho Chehab
  2010-12-30 12:34       ` Hans Verkuil
  0 siblings, 1 reply; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 12:09 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List

Em 30-12-2010 09:56, Hans Verkuil escreveu:
> On Thursday, December 30, 2010 12:45:09 Mauro Carvalho Chehab wrote:
>> lirc-i2c implements a get key logic for the Adaptec Remote
>> Controller, at address 0x6b. The only driver that seems to have
>> an Adaptec device is ivtv:
>>
>> $ git grep -i adaptec drivers/media
>> drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
>> drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
>> drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
>> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
>> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
>> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
>> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
>> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
>> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
>> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
>> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
>> drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
>>
>> There are two Adaptec cards defined there, but only one has tuner.
>> I never found any device without tuners, but with a remote controllers, so
>> the logic at lirc_i2c seems to be for Adaptec AVC-2410.
> 
> That's correct. The AVC-2010 does not come with a remote.

Thanks for double checking. I've replaced the comments to:

    [media] ivtv: Add Adaptec Remote Controller
    
    lirc-i2c implements a get key logic for the Adaptec Remote
    Controller, at address 0x6b. The only driver that seems to have
    an Adaptec device is ivtv:
    
    $ git grep -i adaptec drivers/media
    drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
    drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
    drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
    drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
    drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
    drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
    drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
    drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
    drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
    drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
    drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
    drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
    drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
    drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
    drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
    
    There are two Adaptec cards defined there, but AVC-2010 doesn't have a
    remote controller. So, the logic at lirc_i2c seems to be for Adaptec AVC-2410.
    
    As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
    use it for AVC-2410.

I have no means to test the IR with AVC-2410, but I think it is safe to apply
this patch, if none of us have this device, as the patch is trivial, and this
allows us to remove i2c_adapter.id obsolete field and lirc_i2c, after applying
this series, and the tree patches for lirc_zilog that Andy made.

Cheers,
Mauro

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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 12:09     ` Mauro Carvalho Chehab
@ 2010-12-30 12:34       ` Hans Verkuil
  2010-12-30 13:32         ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 16+ messages in thread
From: Hans Verkuil @ 2010-12-30 12:34 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

On Thursday, December 30, 2010 13:09:52 Mauro Carvalho Chehab wrote:
> Em 30-12-2010 09:56, Hans Verkuil escreveu:
> > On Thursday, December 30, 2010 12:45:09 Mauro Carvalho Chehab wrote:
> >> lirc-i2c implements a get key logic for the Adaptec Remote
> >> Controller, at address 0x6b. The only driver that seems to have
> >> an Adaptec device is ivtv:
> >>
> >> $ git grep -i adaptec drivers/media
> >> drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
> >> drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
> >> drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
> >> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
> >> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
> >> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
> >> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
> >> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
> >> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
> >> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
> >> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
> >> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
> >> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
> >> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
> >> drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
> >>
> >> There are two Adaptec cards defined there, but only one has tuner.
> >> I never found any device without tuners, but with a remote controllers, so
> >> the logic at lirc_i2c seems to be for Adaptec AVC-2410.
> > 
> > That's correct. The AVC-2010 does not come with a remote.
> 
> Thanks for double checking. I've replaced the comments to:
> 
>     [media] ivtv: Add Adaptec Remote Controller
>     
>     lirc-i2c implements a get key logic for the Adaptec Remote
>     Controller, at address 0x6b. The only driver that seems to have
>     an Adaptec device is ivtv:
>     
>     $ git grep -i adaptec drivers/media
>     drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
>     drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
>     drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
>     drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
>     drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
>     drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
>     drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
>     drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
>     drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
>     drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
>     drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
>     drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
>     drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
>     drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
>     drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
>     
>     There are two Adaptec cards defined there, but AVC-2010 doesn't have a
>     remote controller. So, the logic at lirc_i2c seems to be for Adaptec AVC-2410.
>     
>     As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
>     use it for AVC-2410.
> 
> I have no means to test the IR with AVC-2410, but I think it is safe to apply
> this patch, if none of us have this device, as the patch is trivial, and this
> allows us to remove i2c_adapter.id obsolete field and lirc_i2c, after applying
> this series, and the tree patches for lirc_zilog that Andy made.

I think I have the AVC-2410 but I think you have the remote for it. It's one of
the remotes I gave you in San Franscisco.

So that's going to be hard to test :-)

BTW, pending unforseen circumstances I'll be at the ELC in San Francisco again
this year.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco

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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 11:45 ` [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller Mauro Carvalho Chehab
  2010-12-30 11:56   ` Hans Verkuil
@ 2010-12-30 12:36   ` Andy Walls
  2010-12-30 13:30     ` Mauro Carvalho Chehab
  2010-12-30 12:46   ` Andy Walls
  2010-12-30 13:05   ` [PATCH v2] " Mauro Carvalho Chehab
  3 siblings, 1 reply; 16+ messages in thread
From: Andy Walls @ 2010-12-30 12:36 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

On Thu, 2010-12-30 at 09:45 -0200, Mauro Carvalho Chehab wrote:
> lirc-i2c implements a get key logic for the Adaptec Remote
> Controller, at address 0x6b. The only driver that seems to have
> an Adaptec device is ivtv:
> 
> $ git grep -i adaptec drivers/media
> drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
> drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
> drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
> drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
> 
> There are two Adaptec cards defined there, but only one has tuner.
> I never found any device without tuners, but with a remote controllers, so
> the logic at lirc_i2c seems to be for Adaptec AVC-2410.
> 
> As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
> use it for AVC2410.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Mauro,

This patch is missing a few things, so it won't work.
The required - and some desired - changes are in the comments below.


> diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
> index 6817092..8d1b016 100644
> --- a/drivers/media/video/ivtv/ivtv-i2c.c
> +++ b/drivers/media/video/ivtv/ivtv-i2c.c
> @@ -94,6 +94,7 @@
>  #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
>  #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
>  #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
> +#define IVTV_ADAPTEC_IR			0x6b

For consistency with the other defines for I2C addresses, please rename
this to "IVTV_ADAPTEC_IR_I2C_ADDR"


>  /* This array should match the IVTV_HW_ defines */
>  static const u8 hw_addrs[] = {
> @@ -118,6 +119,7 @@ static const u8 hw_addrs[] = {
>  	IVTV_HAUP_INT_IR_RX_I2C_ADDR,	/* IVTV_HW_I2C_IR_RX_HAUP_INT */
>  	IVTV_Z8F0811_IR_TX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
>  	IVTV_Z8F0811_IR_RX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
> +	IVTV_ADAPTEC_IR,
>  };

Please add this comment to the right of the new entry: /* IVTV_HW_I2C_IR_RX_ADAPTEC */


You will need to add in ivtv-cards.h:

#define IVTV_HW_I2C_IR_RX_ADAPTEC         (1 << 21)

and modify this define in ivtv-cards.h

#define IVTV_HW_IR_RX_ANY (IVTV_HW_I2C_IR_RX_AVER | \
                           IVTV_HW_I2C_IR_RX_HAUP_EXT | \
                           IVTV_HW_I2C_IR_RX_HAUP_INT | \
                           IVTV_HW_Z8F0811_IR_RX_HAUP | \
			   IVTV_HW_I2C_IR_RX_ADAPTEC)

In ivtv-cards.c, for the "ivtv_card_avc2410" entry, you must modify the
".hw_all" to be:

        .hw_all = IVTV_HW_MSP34XX | IVTV_HW_CS53L32A |
                  IVTV_HW_SAA7115 | IVTV_HW_TUNER |
		  IVTV_HW_I2C_IR_RX_ADAPTEC,


>  /* This array should match the IVTV_HW_ defines */
> @@ -145,6 +147,31 @@ static const char * const hw_devicenames[] = {
>  	"ir_rx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
>  };

To avoid walking off the end of "hw_devicenames[]", you will need to add
a new entry to the end of "hw_devicenames[]":

	"ir_video",	/* IVTV_HW_I2C_IR_RX_ADAPTEC */

> +static int get_key_adaptec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
> +{
> +	unsigned char keybuf[4];
> +
> +	keybuf[0] = 0x00;
> +	i2c_master_send(ir->c, keybuf, 1);
> +	/* poll IR chip */
> +	if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
> +		return 0;
> +	}
> +
> +	/* key pressed ? */
> +	if (keybuf[2] == 0xff)
> +		return 0;
> +
> +	/* remove repeat bit */
> +	keybuf[2] &= 0x7f;
> +	keybuf[3] |= 0x80;
> +
> +	*ir_key = (u32) keybuf;
> +	*ir_raw = (u32) keybuf;
> +
> +	return 1;
> +}
> +
>  static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
>  {
>  	struct i2c_board_info info;
> @@ -190,6 +217,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
>  		init_data->type = RC_TYPE_RC5;
>  		init_data->name = itv->card_name;
>  		break;
> +	case IVTV_CARD_AVC2410:

You are switching on a value from a different set.  Instead use:

	case IVTV_HW_I2C_IR_RX_ADAPTEC:


> +		init_data->ir_codes = RC_MAP_EMPTY;
> +		init_data->get_key = get_key_adaptec;
> +		init_data->type = RC_TYPE_UNKNOWN;
> +		init_data->name = itv->card_name;
> +		break;

Please add a /*FIXME */ comment here, so that I will remember to figure
out the default keymap and RC protocol type. 

Regards,
Andy

>  	}
>  
>  	memset(&info, 0, sizeof(struct i2c_board_info));
> @@ -219,7 +252,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
>  		0x1a,	/* Hauppauge IR external - collides with WM8739 */
>  		0x18,	/* Hauppauge IR internal */
>  		0x71,	/* Hauppauge IR (PVR150) */
> -		0x6b,	/* Adaptec IR */
>  		I2C_CLIENT_END
>  	};
>  
> -- 
> 1.7.3.4



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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 11:45 ` [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller Mauro Carvalho Chehab
  2010-12-30 11:56   ` Hans Verkuil
  2010-12-30 12:36   ` Andy Walls
@ 2010-12-30 12:46   ` Andy Walls
  2010-12-30 13:29     ` Mauro Carvalho Chehab
  2010-12-30 13:05   ` [PATCH v2] " Mauro Carvalho Chehab
  3 siblings, 1 reply; 16+ messages in thread
From: Andy Walls @ 2010-12-30 12:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

On Thu, 2010-12-30 at 09:45 -0200, Mauro Carvalho Chehab wrote:



> As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
> use it for AVC2410.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> 
> diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
> index 6817092..8d1b016 100644
> --- a/drivers/media/video/ivtv/ivtv-i2c.c
> +++ b/drivers/media/video/ivtv/ivtv-i2c.c
> @@ -94,6 +94,7 @@
>  #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
>  #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
>  #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
[snip]

> @@ -219,7 +252,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
>  		0x1a,	/* Hauppauge IR external - collides with WM8739 */
>  		0x18,	/* Hauppauge IR internal */
>  		0x71,	/* Hauppauge IR (PVR150) */
                  ^^^^
BTW, since

a. all ivtv cards that have an IR Rx chip at address 0x71 should be
accounted for in ivtv-cards.c
b. lirc_i2c is going away
c. lirc_zilog should not be probing devices labeled "ir_video"
d. ir-kbd-i2c doesn't have defaults for address 0x71

Can you remove the 0x71 case here while you are making changes?

Thanks,
Andy



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

* [PATCH v2] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 11:45 ` [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller Mauro Carvalho Chehab
                     ` (2 preceding siblings ...)
  2010-12-30 12:46   ` Andy Walls
@ 2010-12-30 13:05   ` Mauro Carvalho Chehab
  2010-12-30 13:35     ` Andy Walls
  3 siblings, 1 reply; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 13:05 UTC (permalink / raw)
  To: Linux Media Mailing List

>From f4b19dd8ac2d15666975f262cc1bdf461d48e687 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab@redhat.com>
Date: Thu, 30 Dec 2010 09:31:10 -0200
Subject: [PATCH] [media] ivtv: Add Adaptec Remote Controller

lirc-i2c implements a get key logic for the Adaptec Remote
Controller, at address 0x6b. The only driver that seems to have
an Adaptec device is ivtv:

$ git grep -i adaptec drivers/media
drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */

There are two Adaptec cards defined there, but AVC-2010 doesn't have a
remote controller. So, the logic at lirc_i2c seems to be for Adaptec AVC-2410.

As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
use it for AVC-2410.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

---

v2: Update comment and add a new entry at hw_devicenames table


diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 6817092..71912ec 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -94,6 +94,7 @@
 #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
 #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
 #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
+#define IVTV_ADAPTEC_IR			0x6b
 
 /* This array should match the IVTV_HW_ defines */
 static const u8 hw_addrs[] = {
@@ -118,6 +119,7 @@ static const u8 hw_addrs[] = {
 	IVTV_HAUP_INT_IR_RX_I2C_ADDR,	/* IVTV_HW_I2C_IR_RX_HAUP_INT */
 	IVTV_Z8F0811_IR_TX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
 	IVTV_Z8F0811_IR_RX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
+	IVTV_ADAPTEC_IR,
 };
 
 /* This array should match the IVTV_HW_ defines */
@@ -143,8 +145,34 @@ static const char * const hw_devicenames[] = {
 	"ir_video",		/* IVTV_HW_I2C_IR_RX_HAUP_INT */
 	"ir_tx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
 	"ir_rx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
+	"ir_adaptec",
 };
 
+static int get_key_adaptec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+	unsigned char keybuf[4];
+
+	keybuf[0] = 0x00;
+	i2c_master_send(ir->c, keybuf, 1);
+	/* poll IR chip */
+	if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
+		return 0;
+	}
+
+	/* key pressed ? */
+	if (keybuf[2] == 0xff)
+		return 0;
+
+	/* remove repeat bit */
+	keybuf[2] &= 0x7f;
+	keybuf[3] |= 0x80;
+
+	*ir_key = (u32) keybuf;
+	*ir_raw = (u32) keybuf;
+
+	return 1;
+}
+
 static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 {
 	struct i2c_board_info info;
@@ -190,6 +218,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 		init_data->type = RC_TYPE_RC5;
 		init_data->name = itv->card_name;
 		break;
+	case IVTV_CARD_AVC2410:
+		init_data->ir_codes = RC_MAP_EMPTY;
+		init_data->get_key = get_key_adaptec;
+		init_data->type = RC_TYPE_UNKNOWN;
+		init_data->name = itv->card_name;
+		break;
 	}
 
 	memset(&info, 0, sizeof(struct i2c_board_info));
@@ -219,7 +253,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 		0x1a,	/* Hauppauge IR external - collides with WM8739 */
 		0x18,	/* Hauppauge IR internal */
 		0x71,	/* Hauppauge IR (PVR150) */
-		0x6b,	/* Adaptec IR */
 		I2C_CLIENT_END
 	};
 


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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 12:46   ` Andy Walls
@ 2010-12-30 13:29     ` Mauro Carvalho Chehab
  2010-12-30 13:46       ` Andy Walls
  0 siblings, 1 reply; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 13:29 UTC (permalink / raw)
  To: Andy Walls; +Cc: Linux Media Mailing List

Em 30-12-2010 10:46, Andy Walls escreveu:
> On Thu, 2010-12-30 at 09:45 -0200, Mauro Carvalho Chehab wrote:
> 
> 
> 
>> As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
>> use it for AVC2410.
>>
>> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
>>
>> diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
>> index 6817092..8d1b016 100644
>> --- a/drivers/media/video/ivtv/ivtv-i2c.c
>> +++ b/drivers/media/video/ivtv/ivtv-i2c.c
>> @@ -94,6 +94,7 @@
>>  #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
>>  #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
>>  #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
> [snip]
> 
>> @@ -219,7 +252,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
>>  		0x1a,	/* Hauppauge IR external - collides with WM8739 */
>>  		0x18,	/* Hauppauge IR internal */
>>  		0x71,	/* Hauppauge IR (PVR150) */
>                   ^^^^
> BTW, since
> 
> a. all ivtv cards that have an IR Rx chip at address 0x71 should be
> accounted for in ivtv-cards.c
> b. lirc_i2c is going away
> c. lirc_zilog should not be probing devices labeled "ir_video"
> d. ir-kbd-i2c doesn't have defaults for address 0x71
> 
> Can you remove the 0x71 case here while you are making changes?

Sure. Patch enclosed.

Btw, I think we should remove ivtv_i2c_new_ir_legacy, or rename it.
The only remaining case there is the standard non-Z8 Hauppauge IR
I2C decoder.

Thanks,
Mauro

-

commit 615a80d8f744677bc79b33811c5f671fa7fe1976
Author: Mauro Carvalho Chehab <mchehab@redhat.com>
Date:   Thu Dec 30 11:25:12 2010 -0200

    ivtv-i2c: Don't use IR legacy mode for Zilog IR
    
    The Zilog IR entries are already handled by IR new code. So,
    remove its usage from the legacy IR support.
    
    Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index fb0ac68..d121389 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -253,7 +253,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 	const unsigned short addr_list[] = {
 		0x1a,	/* Hauppauge IR external - collides with WM8739 */
 		0x18,	/* Hauppauge IR internal */
-		0x71,	/* Hauppauge IR (PVR150) */
 		I2C_CLIENT_END
 	};
 

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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 12:36   ` Andy Walls
@ 2010-12-30 13:30     ` Mauro Carvalho Chehab
  2010-12-30 13:53       ` Andy Walls
  0 siblings, 1 reply; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 13:30 UTC (permalink / raw)
  To: Andy Walls; +Cc: Linux Media Mailing List

Em 30-12-2010 10:36, Andy Walls escreveu:
> On Thu, 2010-12-30 at 09:45 -0200, Mauro Carvalho Chehab wrote:
>> lirc-i2c implements a get key logic for the Adaptec Remote
>> Controller, at address 0x6b. The only driver that seems to have
>> an Adaptec device is ivtv:
>>
>> $ git grep -i adaptec drivers/media
>> drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
>> drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
>> drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
>> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
>> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
>> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
>> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
>> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
>> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
>> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
>> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
>> drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
>>
>> There are two Adaptec cards defined there, but only one has tuner.
>> I never found any device without tuners, but with a remote controllers, so
>> the logic at lirc_i2c seems to be for Adaptec AVC-2410.
>>
>> As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
>> use it for AVC2410.
>>
>> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> 
> Mauro,
> 
> This patch is missing a few things, so it won't work.
> The required - and some desired - changes are in the comments below.
> 
> 
>> diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
>> index 6817092..8d1b016 100644
>> --- a/drivers/media/video/ivtv/ivtv-i2c.c
>> +++ b/drivers/media/video/ivtv/ivtv-i2c.c
>> @@ -94,6 +94,7 @@
>>  #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
>>  #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
>>  #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
>> +#define IVTV_ADAPTEC_IR			0x6b
> 
> For consistency with the other defines for I2C addresses, please rename
> this to "IVTV_ADAPTEC_IR_I2C_ADDR"
> 
> 
>>  /* This array should match the IVTV_HW_ defines */
>>  static const u8 hw_addrs[] = {
>> @@ -118,6 +119,7 @@ static const u8 hw_addrs[] = {
>>  	IVTV_HAUP_INT_IR_RX_I2C_ADDR,	/* IVTV_HW_I2C_IR_RX_HAUP_INT */
>>  	IVTV_Z8F0811_IR_TX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
>>  	IVTV_Z8F0811_IR_RX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
>> +	IVTV_ADAPTEC_IR,
>>  };
> 
> Please add this comment to the right of the new entry: /* IVTV_HW_I2C_IR_RX_ADAPTEC */
> 
> 
> You will need to add in ivtv-cards.h:
> 
> #define IVTV_HW_I2C_IR_RX_ADAPTEC         (1 << 21)
> 
> and modify this define in ivtv-cards.h
> 
> #define IVTV_HW_IR_RX_ANY (IVTV_HW_I2C_IR_RX_AVER | \
>                            IVTV_HW_I2C_IR_RX_HAUP_EXT | \
>                            IVTV_HW_I2C_IR_RX_HAUP_INT | \
>                            IVTV_HW_Z8F0811_IR_RX_HAUP | \
> 			   IVTV_HW_I2C_IR_RX_ADAPTEC)
> 
> In ivtv-cards.c, for the "ivtv_card_avc2410" entry, you must modify the
> ".hw_all" to be:
> 
>         .hw_all = IVTV_HW_MSP34XX | IVTV_HW_CS53L32A |
>                   IVTV_HW_SAA7115 | IVTV_HW_TUNER |
> 		  IVTV_HW_I2C_IR_RX_ADAPTEC,
> 
> 
>>  /* This array should match the IVTV_HW_ defines */
>> @@ -145,6 +147,31 @@ static const char * const hw_devicenames[] = {
>>  	"ir_rx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
>>  };
> 
> To avoid walking off the end of "hw_devicenames[]", you will need to add
> a new entry to the end of "hw_devicenames[]":
> 
> 	"ir_video",	/* IVTV_HW_I2C_IR_RX_ADAPTEC */
> 
>> +static int get_key_adaptec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
>> +{
>> +	unsigned char keybuf[4];
>> +
>> +	keybuf[0] = 0x00;
>> +	i2c_master_send(ir->c, keybuf, 1);
>> +	/* poll IR chip */
>> +	if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
>> +		return 0;
>> +	}
>> +
>> +	/* key pressed ? */
>> +	if (keybuf[2] == 0xff)
>> +		return 0;
>> +
>> +	/* remove repeat bit */
>> +	keybuf[2] &= 0x7f;
>> +	keybuf[3] |= 0x80;
>> +
>> +	*ir_key = (u32) keybuf;
>> +	*ir_raw = (u32) keybuf;
>> +
>> +	return 1;
>> +}
>> +
>>  static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
>>  {
>>  	struct i2c_board_info info;
>> @@ -190,6 +217,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
>>  		init_data->type = RC_TYPE_RC5;
>>  		init_data->name = itv->card_name;
>>  		break;
>> +	case IVTV_CARD_AVC2410:
> 
> You are switching on a value from a different set.  Instead use:
> 
> 	case IVTV_HW_I2C_IR_RX_ADAPTEC:
> 
> 
>> +		init_data->ir_codes = RC_MAP_EMPTY;
>> +		init_data->get_key = get_key_adaptec;
>> +		init_data->type = RC_TYPE_UNKNOWN;
>> +		init_data->name = itv->card_name;
>> +		break;
> 
> Please add a /*FIXME */ comment here, so that I will remember to figure
> out the default keymap and RC protocol type. 
> 
> Regards,
> Andy

Thanks for the review. Version 3 of the patch enclosed.

commit 8576bd14361ec75c91ddfb49cc2df389143cf06a
Author: Mauro Carvalho Chehab <mchehab@redhat.com>
Date:   Thu Dec 30 09:31:10 2010 -0200

    [media] ivtv: Add Adaptec Remote Controller
    
    lirc-i2c implements a get key logic for the Adaptec Remote
    Controller, at address 0x6b. The only driver that seems to have
    an Adaptec device is ivtv:
    
    $ git grep -i adaptec drivers/media
    drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
    drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
    drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
    drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
    drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
    drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
    drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
    drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
    drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
    drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
    drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
    drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
    drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
    drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
    drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
    
    There are two Adaptec cards defined there, but AVC-2010 doesn't have a
    remote controller. So, the logic at lirc_i2c seems to be for Adaptec AVC-2410.
    
    As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
    use it for AVC-2410.
    
    Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/ivtv/ivtv-cards.c b/drivers/media/video/ivtv/ivtv-cards.c
index b6f2a2b..145e474 100644
--- a/drivers/media/video/ivtv/ivtv-cards.c
+++ b/drivers/media/video/ivtv/ivtv-cards.c
@@ -405,7 +405,8 @@ static const struct ivtv_card ivtv_card_avc2410 = {
 	.hw_audio_ctrl = IVTV_HW_MSP34XX,
 	.hw_muxer = IVTV_HW_CS53L32A,
 	.hw_all = IVTV_HW_MSP34XX | IVTV_HW_CS53L32A |
-		  IVTV_HW_SAA7115 | IVTV_HW_TUNER,
+		  IVTV_HW_SAA7115 | IVTV_HW_TUNER |
+		  IVTV_HW_I2C_IR_RX_ADAPTEC,
 	.video_inputs = {
 		{ IVTV_CARD_INPUT_VID_TUNER,  0, IVTV_SAA71XX_COMPOSITE4 },
 		{ IVTV_CARD_INPUT_SVIDEO1,    1, IVTV_SAA71XX_SVIDEO0    },
diff --git a/drivers/media/video/ivtv/ivtv-cards.h b/drivers/media/video/ivtv/ivtv-cards.h
index 78eca99..e6f5c02 100644
--- a/drivers/media/video/ivtv/ivtv-cards.h
+++ b/drivers/media/video/ivtv/ivtv-cards.h
@@ -111,6 +111,7 @@
 #define IVTV_HW_I2C_IR_RX_HAUP_INT	(1 << 18)
 #define IVTV_HW_Z8F0811_IR_TX_HAUP	(1 << 19)
 #define IVTV_HW_Z8F0811_IR_RX_HAUP	(1 << 20)
+#define IVTV_HW_I2C_IR_RX_ADAPTEC	(1 << 21)
 
 #define IVTV_HW_Z8F0811_IR_HAUP	(IVTV_HW_Z8F0811_IR_RX_HAUP | \
 				 IVTV_HW_Z8F0811_IR_TX_HAUP)
@@ -120,7 +121,8 @@
 #define IVTV_HW_IR_RX_ANY (IVTV_HW_I2C_IR_RX_AVER | \
 			   IVTV_HW_I2C_IR_RX_HAUP_EXT | \
 			   IVTV_HW_I2C_IR_RX_HAUP_INT | \
-			   IVTV_HW_Z8F0811_IR_RX_HAUP)
+			   IVTV_HW_Z8F0811_IR_RX_HAUP | \
+			   IVTV_HW_I2C_IR_RX_ADAPTEC)
 
 #define IVTV_HW_IR_TX_ANY (IVTV_HW_Z8F0811_IR_TX_HAUP)
 
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 6817092..fb0ac68 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -94,6 +94,7 @@
 #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
 #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
 #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
+#define IVTV_ADAPTEC_IR_ADDR		0x6b
 
 /* This array should match the IVTV_HW_ defines */
 static const u8 hw_addrs[] = {
@@ -118,6 +119,7 @@ static const u8 hw_addrs[] = {
 	IVTV_HAUP_INT_IR_RX_I2C_ADDR,	/* IVTV_HW_I2C_IR_RX_HAUP_INT */
 	IVTV_Z8F0811_IR_TX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
 	IVTV_Z8F0811_IR_RX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
+	IVTV_ADAPTEC_IR_ADDR,		/* IVTV_HW_I2C_IR_RX_ADAPTEC */
 };
 
 /* This array should match the IVTV_HW_ defines */
@@ -143,8 +145,34 @@ static const char * const hw_devicenames[] = {
 	"ir_video",		/* IVTV_HW_I2C_IR_RX_HAUP_INT */
 	"ir_tx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
 	"ir_rx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
+	"ir_adaptec",		/* IVTV_HW_I2C_IR_RX_ADAPTEC */
 };
 
+static int get_key_adaptec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+	unsigned char keybuf[4];
+
+	keybuf[0] = 0x00;
+	i2c_master_send(ir->c, keybuf, 1);
+	/* poll IR chip */
+	if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
+		return 0;
+	}
+
+	/* key pressed ? */
+	if (keybuf[2] == 0xff)
+		return 0;
+
+	/* remove repeat bit */
+	keybuf[2] &= 0x7f;
+	keybuf[3] |= 0x80;
+
+	*ir_key = (u32) keybuf;
+	*ir_raw = (u32) keybuf;
+
+	return 1;
+}
+
 static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 {
 	struct i2c_board_info info;
@@ -190,6 +218,13 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 		init_data->type = RC_TYPE_RC5;
 		init_data->name = itv->card_name;
 		break;
+	case IVTV_HW_I2C_IR_RX_ADAPTEC:
+		init_data->get_key = get_key_adaptec;
+		init_data->name = itv->card_name;
+		/* FIXME: The protocol and RC_MAP needs to be corrected */
+		init_data->ir_codes = RC_MAP_EMPTY;
+		init_data->type = RC_TYPE_UNKNOWN;
+		break;
 	}
 
 	memset(&info, 0, sizeof(struct i2c_board_info));
@@ -219,7 +254,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 		0x1a,	/* Hauppauge IR external - collides with WM8739 */
 		0x18,	/* Hauppauge IR internal */
 		0x71,	/* Hauppauge IR (PVR150) */
-		0x6b,	/* Adaptec IR */
 		I2C_CLIENT_END
 	};
 

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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 12:34       ` Hans Verkuil
@ 2010-12-30 13:32         ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-30 13:32 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List

Em 30-12-2010 10:34, Hans Verkuil escreveu:
> On Thursday, December 30, 2010 13:09:52 Mauro Carvalho Chehab wrote:
>> Em 30-12-2010 09:56, Hans Verkuil escreveu:
>>> On Thursday, December 30, 2010 12:45:09 Mauro Carvalho Chehab wrote:
>>>> lirc-i2c implements a get key logic for the Adaptec Remote
>>>> Controller, at address 0x6b. The only driver that seems to have
>>>> an Adaptec device is ivtv:
>>>>
>>>> $ git grep -i adaptec drivers/media
>>>> drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
>>>> drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
>>>> drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
>>>> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
>>>> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
>>>> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
>>>> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
>>>> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
>>>> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
>>>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
>>>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
>>>> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
>>>> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
>>>> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
>>>> drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
>>>>
>>>> There are two Adaptec cards defined there, but only one has tuner.
>>>> I never found any device without tuners, but with a remote controllers, so
>>>> the logic at lirc_i2c seems to be for Adaptec AVC-2410.
>>>
>>> That's correct. The AVC-2010 does not come with a remote.
>>
>> Thanks for double checking. I've replaced the comments to:
>>
>>     [media] ivtv: Add Adaptec Remote Controller
>>     
>>     lirc-i2c implements a get key logic for the Adaptec Remote
>>     Controller, at address 0x6b. The only driver that seems to have
>>     an Adaptec device is ivtv:
>>     
>>     $ git grep -i adaptec drivers/media
>>     drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
>>     drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
>>     drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
>>     drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
>>     drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
>>     drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
>>     drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
>>     drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
>>     drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
>>     drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
>>     drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
>>     drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
>>     drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
>>     drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
>>     drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
>>     
>>     There are two Adaptec cards defined there, but AVC-2010 doesn't have a
>>     remote controller. So, the logic at lirc_i2c seems to be for Adaptec AVC-2410.
>>     
>>     As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
>>     use it for AVC-2410.
>>
>> I have no means to test the IR with AVC-2410, but I think it is safe to apply
>> this patch, if none of us have this device, as the patch is trivial, and this
>> allows us to remove i2c_adapter.id obsolete field and lirc_i2c, after applying
>> this series, and the tree patches for lirc_zilog that Andy made.
> 
> I think I have the AVC-2410 but I think you have the remote for it. It's one of
> the remotes I gave you in San Franscisco.
> 
> So that's going to be hard to test :-)

I'll see if I can identify the AVC RC protocol and its keymap table in Jan.

> BTW, pending unforseen circumstances I'll be at the ELC in San Francisco again
> this year.

It is a little early to say, but I probably won't be there in 2011.

Cheers,
Mauro

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

* Re: [PATCH v2] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 13:05   ` [PATCH v2] " Mauro Carvalho Chehab
@ 2010-12-30 13:35     ` Andy Walls
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Walls @ 2010-12-30 13:35 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

On Thu, 2010-12-30 at 11:05 -0200, Mauro Carvalho Chehab wrote:
> >From f4b19dd8ac2d15666975f262cc1bdf461d48e687 Mon Sep 17 00:00:00 2001
> From: Mauro Carvalho Chehab <mchehab@redhat.com>
> Date: Thu, 30 Dec 2010 09:31:10 -0200
> Subject: [PATCH] [media] ivtv: Add Adaptec Remote Controller
> 
> lirc-i2c implements a get key logic for the Adaptec Remote
> Controller, at address 0x6b. The only driver that seems to have
> an Adaptec device is ivtv:
> 
> $ git grep -i adaptec drivers/media
> drivers/media/video/cs53l32a.c: * cs53l32a (Adaptec AVC-2010 and AVC-2410) i2c ivtv driver.
> drivers/media/video/cs53l32a.c: * Audio source switching for Adaptec AVC-2410 added by Trev Jackson
> drivers/media/video/cs53l32a.c:   /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2410 card */
> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0093 },
> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2410",
> drivers/media/video/ivtv/ivtv-cards.c:/* Adaptec VideOh! AVC-2010 card */
> drivers/media/video/ivtv/ivtv-cards.c:    { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_ADAPTEC, 0x0092 },
> drivers/media/video/ivtv/ivtv-cards.c:    .name = "Adaptec VideOh! AVC-2010",
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2410         7 /* Adaptec AVC-2410 */
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_CARD_AVC2010         8 /* Adaptec AVD-2010 (No Tuner) */
> drivers/media/video/ivtv/ivtv-cards.h:#define IVTV_PCI_ID_ADAPTEC                 0x9005
> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 8 = Adaptec AVC-2410\n"
> drivers/media/video/ivtv/ivtv-driver.c:            "\t\t\t 9 = Adaptec AVC-2010\n"
> drivers/media/video/ivtv/ivtv-i2c.c:              0x6b,   /* Adaptec IR */
> 
> There are two Adaptec cards defined there, but AVC-2010 doesn't have a
> remote controller. So, the logic at lirc_i2c seems to be for Adaptec AVC-2410.
> 
> As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
> use it for AVC-2410.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Nak!

See below...

> ---
> 
> v2: Update comment and add a new entry at hw_devicenames table
> 
> 
> diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
> index 6817092..71912ec 100644
> --- a/drivers/media/video/ivtv/ivtv-i2c.c
> +++ b/drivers/media/video/ivtv/ivtv-i2c.c
> @@ -94,6 +94,7 @@
>  #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
>  #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
>  #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
> +#define IVTV_ADAPTEC_IR			0x6b
>  
>  /* This array should match the IVTV_HW_ defines */
>  static const u8 hw_addrs[] = {
> @@ -118,6 +119,7 @@ static const u8 hw_addrs[] = {
>  	IVTV_HAUP_INT_IR_RX_I2C_ADDR,	/* IVTV_HW_I2C_IR_RX_HAUP_INT */
>  	IVTV_Z8F0811_IR_TX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
>  	IVTV_Z8F0811_IR_RX_I2C_ADDR,	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
> +	IVTV_ADAPTEC_IR,
>  };
>  
>  /* This array should match the IVTV_HW_ defines */
> @@ -143,8 +145,34 @@ static const char * const hw_devicenames[] = {
>  	"ir_video",		/* IVTV_HW_I2C_IR_RX_HAUP_INT */
>  	"ir_tx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
>  	"ir_rx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
> +	"ir_adaptec",
>  };

That won't work.  ir-kbd-i2c.c is only looking to bind with devices
labeled "ir_video" or "ir_rx_z8f0811_haup".


> +static int get_key_adaptec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
> +{
> +	unsigned char keybuf[4];
> +
> +	keybuf[0] = 0x00;
> +	i2c_master_send(ir->c, keybuf, 1);
> +	/* poll IR chip */
> +	if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
> +		return 0;
> +	}
> +
> +	/* key pressed ? */
> +	if (keybuf[2] == 0xff)
> +		return 0;
> +
> +	/* remove repeat bit */
> +	keybuf[2] &= 0x7f;
> +	keybuf[3] |= 0x80;
> +
> +	*ir_key = (u32) keybuf;
> +	*ir_raw = (u32) keybuf;
> +
> +	return 1;
> +}
> +
>  static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
>  {
>  	struct i2c_board_info info;
> @@ -190,6 +218,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
>  		init_data->type = RC_TYPE_RC5;
>  		init_data->name = itv->card_name;
>  		break;
> +	case IVTV_CARD_AVC2410:

As I mentioned before, that won't work.  Following the function call
chain:

	ivtv-driver.c:ivtv_probe()
		ivtv-driver.c:ivtv_load_and_init_modules()
			ivtv-i2c.c:ivtv_i2c_register(..., idx = i)
				ivtv-i2c.c:ivtv_i2c_new_ir(..., hw = 1 << idx, ...) /* Known card IR configurations */
			ivtv-i2c.c:ivtv_i2c_new_ir_legacy()			    /* Legacy probing for IR chips */
			
The switch on "hw" in ivtv_i2c_new_ir() is switching on these defines at ivtv-cards.h:

        #define IVTV_HW_I2C_IR_RX_AVER          (1 << 16)
        #define IVTV_HW_I2C_IR_RX_HAUP_EXT      (1 << 17) /* External before internal */
        #define IVTV_HW_I2C_IR_RX_HAUP_INT      (1 << 18)
        #define IVTV_HW_Z8F0811_IR_TX_HAUP      (1 << 19)
        #define IVTV_HW_Z8F0811_IR_RX_HAUP      (1 << 20)

You need to add a new one in ivtv-cards.h and fix the Adaptec card entry
in ivtv-cards.c or no probe attempt will even be made for the IR unit on
the Adaptec card.

The switch statement must operate on a bit flag that corresponds to an
I2C device, not "IVTV_CARD_AVC2410", which is en enumerated value for a
card model.

Regards,
Andy
> +		init_data->ir_codes = RC_MAP_EMPTY;
> +		init_data->get_key = get_key_adaptec;
> +		init_data->type = RC_TYPE_UNKNOWN;
> +		init_data->name = itv->card_name;
> +		break;
>  	}
>  
>  	memset(&info, 0, sizeof(struct i2c_board_info));
> @@ -219,7 +253,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
>  		0x1a,	/* Hauppauge IR external - collides with WM8739 */
>  		0x18,	/* Hauppauge IR internal */
>  		0x71,	/* Hauppauge IR (PVR150) */
> -		0x6b,	/* Adaptec IR */
>  		I2C_CLIENT_END
>  	};
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 13:29     ` Mauro Carvalho Chehab
@ 2010-12-30 13:46       ` Andy Walls
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Walls @ 2010-12-30 13:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

On Thu, 2010-12-30 at 11:29 -0200, Mauro Carvalho Chehab wrote:
> Em 30-12-2010 10:46, Andy Walls escreveu:
> > On Thu, 2010-12-30 at 09:45 -0200, Mauro Carvalho Chehab wrote:
> > 
> > 
> > 
> >> As we'll remove lirc_i2c from kernel, move the getkey code to ivtv driver, and
> >> use it for AVC2410.
> >>
> >> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> >>
> >> diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
> >> index 6817092..8d1b016 100644
> >> --- a/drivers/media/video/ivtv/ivtv-i2c.c
> >> +++ b/drivers/media/video/ivtv/ivtv-i2c.c
> >> @@ -94,6 +94,7 @@
> >>  #define IVTV_HAUP_INT_IR_RX_I2C_ADDR 	0x18
> >>  #define IVTV_Z8F0811_IR_TX_I2C_ADDR	0x70
> >>  #define IVTV_Z8F0811_IR_RX_I2C_ADDR	0x71
> > [snip]
> > 
> >> @@ -219,7 +252,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
> >>  		0x1a,	/* Hauppauge IR external - collides with WM8739 */
> >>  		0x18,	/* Hauppauge IR internal */
> >>  		0x71,	/* Hauppauge IR (PVR150) */
> >                   ^^^^
> > BTW, since
> > 
> > a. all ivtv cards that have an IR Rx chip at address 0x71 should be
> > accounted for in ivtv-cards.c
> > b. lirc_i2c is going away
> > c. lirc_zilog should not be probing devices labeled "ir_video"
> > d. ir-kbd-i2c doesn't have defaults for address 0x71
> > 
> > Can you remove the 0x71 case here while you are making changes?
> 
> Sure. Patch enclosed.
> 
> Btw, I think we should remove ivtv_i2c_new_ir_legacy, or rename it.
> The only remaining case there is the standard non-Z8 Hauppauge IR
> I2C decoder.

The "i2c_new_ir" portion of the name means "register a new I2C connected
IR controller".
 
The "_legacy" portion of the name means "probe for an IR device that
might exist".

The ivtv driver only does it for ivtv-cards.c entries that don't mention
any IR device.

I can't remove it, since some deployed cards models still might need it.

For a rename maybe "ivtv_i2c_probe_unlisted_ir()"?

> Thanks,
> Mauro
> 
> -
> 
> commit 615a80d8f744677bc79b33811c5f671fa7fe1976
> Author: Mauro Carvalho Chehab <mchehab@redhat.com>
> Date:   Thu Dec 30 11:25:12 2010 -0200
> 
>     ivtv-i2c: Don't use IR legacy mode for Zilog IR
>     
>     The Zilog IR entries are already handled by IR new code. So,
>     remove its usage from the legacy IR support.
>     
>     Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Looks good.

Acked-by: Andy Walls <awalls@md.metrocast.net>

Regards,
Andy

> diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
> index fb0ac68..d121389 100644
> --- a/drivers/media/video/ivtv/ivtv-i2c.c
> +++ b/drivers/media/video/ivtv/ivtv-i2c.c
> @@ -253,7 +253,6 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
>  	const unsigned short addr_list[] = {
>  		0x1a,	/* Hauppauge IR external - collides with WM8739 */
>  		0x18,	/* Hauppauge IR internal */
> -		0x71,	/* Hauppauge IR (PVR150) */
>  		I2C_CLIENT_END
>  	};
>  



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

* Re: [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller
  2010-12-30 13:30     ` Mauro Carvalho Chehab
@ 2010-12-30 13:53       ` Andy Walls
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Walls @ 2010-12-30 13:53 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

On Thu, 2010-12-30 at 11:30 -0200, Mauro Carvalho Chehab wrote:
> Em 30-12-2010 10:36, Andy Walls escreveu:


> Thanks for the review. Version 3 of the patch enclosed.

Still one little mistake that matters, otherwise it looks good.
See below...

> commit 8576bd14361ec75c91ddfb49cc2df389143cf06a
> Author: Mauro Carvalho Chehab <mchehab@redhat.com>
> Date:   Thu Dec 30 09:31:10 2010 -0200
> 
>     [media] ivtv: Add Adaptec Remote Controller
>     

>  
>  /* This array should match the IVTV_HW_ defines */
> @@ -143,8 +145,34 @@ static const char * const hw_devicenames[] = {
>  	"ir_video",		/* IVTV_HW_I2C_IR_RX_HAUP_INT */
>  	"ir_tx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_TX_HAUP */
>  	"ir_rx_z8f0811_haup",	/* IVTV_HW_Z8F0811_IR_RX_HAUP */
> +	"ir_adaptec",		/* IVTV_HW_I2C_IR_RX_ADAPTEC */
>  };
 
This either needs to be "ir_video", or you need to add "ir_adaptec" to
the i2c_device_id[] array in ir-kbd-i2c.c.  Otherwise ir-kbd-i2c.c won't
claim the device and use it.

Upon fixing that

Reviewed-by: Andy Walls <awalls@md.metrocast.net>
Acked-by: Andy Walls <awalls@md.metrocast.net>


Regards,
Andy


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

end of thread, other threads:[~2010-12-30 13:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1293709356.git.mchehab@redhat.com>
2010-12-30 11:45 ` [PATCH 4/4] [media] Remove staging/lirc/lirc_i2c driver Mauro Carvalho Chehab
2010-12-30 11:45 ` [PATCH 3/4] [media] ivtv: Add Adaptec Remote Controller Mauro Carvalho Chehab
2010-12-30 11:56   ` Hans Verkuil
2010-12-30 12:09     ` Mauro Carvalho Chehab
2010-12-30 12:34       ` Hans Verkuil
2010-12-30 13:32         ` Mauro Carvalho Chehab
2010-12-30 12:36   ` Andy Walls
2010-12-30 13:30     ` Mauro Carvalho Chehab
2010-12-30 13:53       ` Andy Walls
2010-12-30 12:46   ` Andy Walls
2010-12-30 13:29     ` Mauro Carvalho Chehab
2010-12-30 13:46       ` Andy Walls
2010-12-30 13:05   ` [PATCH v2] " Mauro Carvalho Chehab
2010-12-30 13:35     ` Andy Walls
2010-12-30 11:45 ` [PATCH 2/4] [media] cx88: Add RC logic for Leadtek PVR 2000 Mauro Carvalho Chehab
2010-12-30 11:45 ` [PATCH 1/4] [media] bttv-input: Add a note about PV951 RC Mauro Carvalho Chehab

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.