Re: [PATCH 2/4 v2][FOR 3.1] v4l2: add adv7183 decoder driver
Hi Scott! Sorry for the late review, but real-life interfered with my usual v4l review duties in the past few weeks. On Monday, September 19, 2011 22:59:39 Scott Jiang wrote: > this driver is a v4l2 subdevice driver to support > Analog Devices ADV7183 SDTV video decoder Since we already have an adv7180.c driver I was wondering if there are many differences between the two chips or if it might be possible to support both through the same driver? > Signed-off-by: Scott Jiang > --- > drivers/media/video/Kconfig| 10 + > drivers/media/video/Makefile |1 + > drivers/media/video/adv7183.c | 686 > > drivers/media/video/adv7183_regs.h | 107 ++ > include/media/adv7183.h| 47 +++ > include/media/v4l2-chip-ident.h|3 + > 6 files changed, 854 insertions(+), 0 deletions(-) > create mode 100644 drivers/media/video/adv7183.c > create mode 100644 drivers/media/video/adv7183_regs.h > create mode 100644 include/media/adv7183.h > > diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig > index f574dc0..af8ed6b 100644 > --- a/drivers/media/video/Kconfig > +++ b/drivers/media/video/Kconfig > @@ -273,6 +273,16 @@ config VIDEO_ADV7180 > To compile this driver as a module, choose M here: the > module will be called adv7180. > > +config VIDEO_ADV7183 > + tristate "Analog Devices ADV7183 decoder" > + depends on VIDEO_V4L2 && I2C > + ---help--- > + V4l2 subdevice driver for the Analog Devices > + ADV7183 video decoder. > + > + To compile this driver as a module, choose M here: the > + module will be called adv7183. > + > config VIDEO_BT819 > tristate "BT819A VideoStream decoder" > depends on VIDEO_V4L2 && I2C > diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile > index 2723900..b0329ae 100644 > --- a/drivers/media/video/Makefile > +++ b/drivers/media/video/Makefile > @@ -40,6 +40,7 @@ obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o > obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o > obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o > obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o > +obj-$(CONFIG_VIDEO_ADV7183) += adv7183.o > obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o > obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o > obj-$(CONFIG_VIDEO_BT819) += bt819.o > diff --git a/drivers/media/video/adv7183.c b/drivers/media/video/adv7183.c > new file mode 100644 > index 000..65d682c > --- /dev/null > +++ b/drivers/media/video/adv7183.c > @@ -0,0 +1,686 @@ > +/* > + * adv7183.c Analog Devices ADV7183 video decoder driver > + * > + * Copyright (c) 2011 Analog Devices 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., 675 Mass Ave, Cambridge, MA 02139, USA. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > + > +#include "adv7183_regs.h" > + > +struct adv7183 { > + struct v4l2_subdev sd; > + struct v4l2_ctrl_handler hdl; > + > + v4l2_std_id std; /* Current set standard */ > + u32 input; > + u32 output; > + unsigned reset_pin; > + unsigned oe_pin; > + struct v4l2_mbus_framefmt fmt; > +}; > + > +/* EXAMPLES USING 27 MHz CLOCK > + * Mode 1 CVBS Input (Composite Video on AIN5) > + * All standards are supported through autodetect, 8-bit, 4:2:2, ITU-R > BT.656 output on P15 to P8. > + */ > +static const unsigned char adv7183_init_regs[] = { > + ADV7183_IN_CTRL, 0x04, /* CVBS input on AIN5 */ > + ADV7183_DIGI_CLAMP_CTRL_1, 0x00, /* Slow down digital clamps */ > + ADV7183_SHAP_FILT_CTRL, 0x41,/* Set CSFM to SH1 */ > + ADV7183_ADC_CTRL, 0x16, /* Power down ADC 1 and ADC 2 */ > + ADV7183_CTI_DNR_CTRL_4, 0x04,/* Set DNR threshold to 4 for flat > response */ > + /* ADI recommended programming sequence */ > + ADV7183_ADI_CTRL, 0x80, > + ADV7183_CTI_DNR_CTRL_4, 0x20, > + 0x52, 0x18, > + 0x58, 0xED, > + 0x77, 0xC5, > + 0x7C, 0x93, > + 0x7D, 0x00, > + 0xD0, 0x48, > + 0xD5, 0xA0, > + 0xD7, 0xEA, > + ADV7183_SD_SATURATION_CR, 0x3E, > + ADV7183_PAL_V_END, 0x3E, > + ADV7183_PAL_F_TOGGLE, 0x0F, > + ADV7183_ADI_CTRL, 0x00, > +}; > + > +static inline struct adv7183 *to_adv7183(struct v4l2_subdev *sd) > +{ > + return container_of(sd, struct
[PATCH 2/4 v2][FOR 3.1] v4l2: add adv7183 decoder driver
this driver is a v4l2 subdevice driver to support Analog Devices ADV7183 SDTV video decoder Signed-off-by: Scott Jiang --- drivers/media/video/Kconfig| 10 + drivers/media/video/Makefile |1 + drivers/media/video/adv7183.c | 686 drivers/media/video/adv7183_regs.h | 107 ++ include/media/adv7183.h| 47 +++ include/media/v4l2-chip-ident.h|3 + 6 files changed, 854 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/adv7183.c create mode 100644 drivers/media/video/adv7183_regs.h create mode 100644 include/media/adv7183.h diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f574dc0..af8ed6b 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -273,6 +273,16 @@ config VIDEO_ADV7180 To compile this driver as a module, choose M here: the module will be called adv7180. +config VIDEO_ADV7183 + tristate "Analog Devices ADV7183 decoder" + depends on VIDEO_V4L2 && I2C + ---help--- + V4l2 subdevice driver for the Analog Devices + ADV7183 video decoder. + + To compile this driver as a module, choose M here: the + module will be called adv7183. + config VIDEO_BT819 tristate "BT819A VideoStream decoder" depends on VIDEO_V4L2 && I2C diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 2723900..b0329ae 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o +obj-$(CONFIG_VIDEO_ADV7183) += adv7183.o obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o obj-$(CONFIG_VIDEO_BT819) += bt819.o diff --git a/drivers/media/video/adv7183.c b/drivers/media/video/adv7183.c new file mode 100644 index 000..65d682c --- /dev/null +++ b/drivers/media/video/adv7183.c @@ -0,0 +1,686 @@ +/* + * adv7183.c Analog Devices ADV7183 video decoder driver + * + * Copyright (c) 2011 Analog Devices 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "adv7183_regs.h" + +struct adv7183 { + struct v4l2_subdev sd; + struct v4l2_ctrl_handler hdl; + + v4l2_std_id std; /* Current set standard */ + u32 input; + u32 output; + unsigned reset_pin; + unsigned oe_pin; + struct v4l2_mbus_framefmt fmt; +}; + +/* EXAMPLES USING 27 MHz CLOCK + * Mode 1 CVBS Input (Composite Video on AIN5) + * All standards are supported through autodetect, 8-bit, 4:2:2, ITU-R BT.656 output on P15 to P8. + */ +static const unsigned char adv7183_init_regs[] = { + ADV7183_IN_CTRL, 0x04, /* CVBS input on AIN5 */ + ADV7183_DIGI_CLAMP_CTRL_1, 0x00, /* Slow down digital clamps */ + ADV7183_SHAP_FILT_CTRL, 0x41,/* Set CSFM to SH1 */ + ADV7183_ADC_CTRL, 0x16, /* Power down ADC 1 and ADC 2 */ + ADV7183_CTI_DNR_CTRL_4, 0x04,/* Set DNR threshold to 4 for flat response */ + /* ADI recommended programming sequence */ + ADV7183_ADI_CTRL, 0x80, + ADV7183_CTI_DNR_CTRL_4, 0x20, + 0x52, 0x18, + 0x58, 0xED, + 0x77, 0xC5, + 0x7C, 0x93, + 0x7D, 0x00, + 0xD0, 0x48, + 0xD5, 0xA0, + 0xD7, 0xEA, + ADV7183_SD_SATURATION_CR, 0x3E, + ADV7183_PAL_V_END, 0x3E, + ADV7183_PAL_F_TOGGLE, 0x0F, + ADV7183_ADI_CTRL, 0x00, +}; + +static inline struct adv7183 *to_adv7183(struct v4l2_subdev *sd) +{ + return container_of(sd, struct adv7183, sd); +} +static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) +{ + return &container_of(ctrl->handler, struct adv7183, hdl)->sd; +} + +static inline int adv7183_read(struct v4l2_subdev *sd, unsigned char reg) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + return i2c_smbus_read_byte_data(client, reg); +} + +static inline int adv7183_write(struct v4l2_subdev *sd, unsigned char reg, + unsigned char value) +{ + struct i2c_client *client = v4l2_get_subdevdata