Re: [PATCH 3/5] tw2804: video decoder subdev conversion
On Friday 12 February 2010 01:33:12 Pete Eberlein wrote: From: Pete Eberlein p...@sensoray.com This is a subdev conversion of wis-tw2804 video decoder from the staging go7007 directory. This obsoletes the wis-tw2804 driver. Review below... Priority: normal Signed-off-by: Pete Eberlein p...@sensoray.com diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/Kconfig --- a/linux/drivers/media/video/Kconfig Wed Feb 10 15:06:05 2010 -0800 +++ b/linux/drivers/media/video/Kconfig Thu Feb 11 14:34:39 2010 -0800 @@ -368,6 +368,12 @@ To compile this driver as a module, choose M here: the module will be called saa7191. +config VIDEO_TW2804 + tristate Techwell 2804 video decoder + depends on VIDEO_V4L2 I2C + ---help--- + Support for the Techwell 2804 video decoder. + config VIDEO_TVP514X tristate Texas Instruments TVP514x video decoder depends on VIDEO_V4L2 I2C diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/Makefile --- a/linux/drivers/media/video/Makefile Wed Feb 10 15:06:05 2010 -0800 +++ b/linux/drivers/media/video/Makefile Thu Feb 11 14:34:39 2010 -0800 @@ -71,6 +71,7 @@ obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o +obj-$(CONFIG_VIDEO_TW2804) += tw2804.o obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o obj-$(CONFIG_SOC_CAMERA_MT9M111) += mt9m111.o diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/tw2804.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/linux/drivers/media/video/tw2804.c Thu Feb 11 14:34:39 2010 -0800 @@ -0,0 +1,398 @@ +/* + * Copyright (C) 2005-2006 Micronas USA Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (Version 2) as + * published by the Free Software Foundation. + * + * 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/module.h +#include linux/init.h +#include linux/i2c.h +#include linux/videodev2.h +#include linux/ioctl.h +#include media/v4l2-device.h +#include media/v4l2-i2c-drv.h + +MODULE_DESCRIPTION(TW2804 I2C subdev driver); +MODULE_LICENSE(GPL v2); + +struct tw2804 { + struct v4l2_subdev sd; + int channel; + v4l2_std_id norm; + int brightness; + int contrast; + int saturation; + int hue; +}; + +static inline struct tw2804 *to_state(struct v4l2_subdev *sd) +{ + return container_of(sd, struct tw2804, sd); +} + +static u8 global_registers[] = const +{ + 0x39, 0x00, + 0x3a, 0xff, + 0x3b, 0x84, + 0x3c, 0x80, + 0x3d, 0x80, + 0x3e, 0x82, + 0x3f, 0x82, + 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ +}; + +static u8 channel_registers[] = const +{ + 0x01, 0xc4, + 0x02, 0xa5, + 0x03, 0x20, + 0x04, 0xd0, + 0x05, 0x20, + 0x06, 0xd0, + 0x07, 0x88, + 0x08, 0x20, + 0x09, 0x07, + 0x0a, 0xf0, + 0x0b, 0x07, + 0x0c, 0xf0, + 0x0d, 0x40, + 0x0e, 0xd2, + 0x0f, 0x80, + 0x10, 0x80, + 0x11, 0x80, + 0x12, 0x80, + 0x13, 0x1f, + 0x14, 0x00, + 0x15, 0x00, + 0x16, 0x00, + 0x17, 0x00, + 0x18, 0xff, + 0x19, 0xff, + 0x1a, 0xff, + 0x1b, 0xff, + 0x1c, 0xff, + 0x1d, 0xff, + 0x1e, 0xff, + 0x1f, 0xff, + 0x20, 0x07, + 0x21, 0x07, + 0x22, 0x00, + 0x23, 0x91, + 0x24, 0x51, + 0x25, 0x03, + 0x26, 0x00, + 0x27, 0x00, + 0x28, 0x00, + 0x29, 0x00, + 0x2a, 0x00, + 0x2b, 0x00, + 0x2c, 0x00, + 0x2d, 0x00, + 0x2e, 0x00, + 0x2f, 0x00, + 0x30, 0x00, + 0x31, 0x00, + 0x32, 0x00, + 0x33, 0x00, + 0x34, 0x00, + 0x35, 0x00, + 0x36, 0x00, + 0x37, 0x00, + 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ +}; + +static int write_reg(struct v4l2_subdev *sd, u8 reg, u8 value, int channel) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + return i2c_smbus_write_byte_data(client, reg | (channel 6), value); +} + +static int write_regs(struct v4l2_subdev *sd, u8 *regs, int channel) +{ + int i; + + for (i = 0; regs[i] != 0xff; i += 2) + if (write_reg(sd, regs[i], regs[i + 1], channel) 0) + return -1; + return 0; +} + +static int tw2804_s_config(struct v4l2_subdev *sd, +
[PATCH 3/5] tw2804: video decoder subdev conversion
From: Pete Eberlein p...@sensoray.com This is a subdev conversion of wis-tw2804 video decoder from the staging go7007 directory. This obsoletes the wis-tw2804 driver. Priority: normal Signed-off-by: Pete Eberlein p...@sensoray.com diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/Kconfig --- a/linux/drivers/media/video/Kconfig Wed Feb 10 15:06:05 2010 -0800 +++ b/linux/drivers/media/video/Kconfig Thu Feb 11 14:34:39 2010 -0800 @@ -368,6 +368,12 @@ To compile this driver as a module, choose M here: the module will be called saa7191. +config VIDEO_TW2804 + tristate Techwell 2804 video decoder + depends on VIDEO_V4L2 I2C + ---help--- + Support for the Techwell 2804 video decoder. + config VIDEO_TVP514X tristate Texas Instruments TVP514x video decoder depends on VIDEO_V4L2 I2C diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/Makefile --- a/linux/drivers/media/video/MakefileWed Feb 10 15:06:05 2010 -0800 +++ b/linux/drivers/media/video/MakefileThu Feb 11 14:34:39 2010 -0800 @@ -71,6 +71,7 @@ obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o +obj-$(CONFIG_VIDEO_TW2804) += tw2804.o obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o obj-$(CONFIG_SOC_CAMERA_MT9M111) += mt9m111.o diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/tw2804.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/linux/drivers/media/video/tw2804.cThu Feb 11 14:34:39 2010 -0800 @@ -0,0 +1,398 @@ +/* + * Copyright (C) 2005-2006 Micronas USA Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (Version 2) as + * published by the Free Software Foundation. + * + * 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/module.h +#include linux/init.h +#include linux/i2c.h +#include linux/videodev2.h +#include linux/ioctl.h +#include media/v4l2-device.h +#include media/v4l2-i2c-drv.h + +MODULE_DESCRIPTION(TW2804 I2C subdev driver); +MODULE_LICENSE(GPL v2); + +struct tw2804 { + struct v4l2_subdev sd; + int channel; + v4l2_std_id norm; + int brightness; + int contrast; + int saturation; + int hue; +}; + +static inline struct tw2804 *to_state(struct v4l2_subdev *sd) +{ + return container_of(sd, struct tw2804, sd); +} + +static u8 global_registers[] = +{ + 0x39, 0x00, + 0x3a, 0xff, + 0x3b, 0x84, + 0x3c, 0x80, + 0x3d, 0x80, + 0x3e, 0x82, + 0x3f, 0x82, + 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ +}; + +static u8 channel_registers[] = +{ + 0x01, 0xc4, + 0x02, 0xa5, + 0x03, 0x20, + 0x04, 0xd0, + 0x05, 0x20, + 0x06, 0xd0, + 0x07, 0x88, + 0x08, 0x20, + 0x09, 0x07, + 0x0a, 0xf0, + 0x0b, 0x07, + 0x0c, 0xf0, + 0x0d, 0x40, + 0x0e, 0xd2, + 0x0f, 0x80, + 0x10, 0x80, + 0x11, 0x80, + 0x12, 0x80, + 0x13, 0x1f, + 0x14, 0x00, + 0x15, 0x00, + 0x16, 0x00, + 0x17, 0x00, + 0x18, 0xff, + 0x19, 0xff, + 0x1a, 0xff, + 0x1b, 0xff, + 0x1c, 0xff, + 0x1d, 0xff, + 0x1e, 0xff, + 0x1f, 0xff, + 0x20, 0x07, + 0x21, 0x07, + 0x22, 0x00, + 0x23, 0x91, + 0x24, 0x51, + 0x25, 0x03, + 0x26, 0x00, + 0x27, 0x00, + 0x28, 0x00, + 0x29, 0x00, + 0x2a, 0x00, + 0x2b, 0x00, + 0x2c, 0x00, + 0x2d, 0x00, + 0x2e, 0x00, + 0x2f, 0x00, + 0x30, 0x00, + 0x31, 0x00, + 0x32, 0x00, + 0x33, 0x00, + 0x34, 0x00, + 0x35, 0x00, + 0x36, 0x00, + 0x37, 0x00, + 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ +}; + +static int write_reg(struct v4l2_subdev *sd, u8 reg, u8 value, int channel) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + return i2c_smbus_write_byte_data(client, reg | (channel 6), value); +} + +static int write_regs(struct v4l2_subdev *sd, u8 *regs, int channel) +{ + int i; + + for (i = 0; regs[i] != 0xff; i += 2) + if (write_reg(sd, regs[i], regs[i + 1], channel) 0) + return -1; + return 0; +} + +static int tw2804_s_config(struct v4l2_subdev *sd, + const struct v4l2_priv_tun_config *config) +{ + struct tw2804 *dec =