RE: [PATCH 5/6 v3] Updated TVP7002 driver for DM365

2009-09-02 Thread Karicheri, Muralidharan
Santiago,

you are missing a tvp7002_init() that calls i2c_add_driver(). Similarly 
i2c_del_driver(). See tvp514x.c or adv7353.c for examples... Also read the
polarities from platform_data in probe(). I had mentioned the second comment 
during earlier review.

Murali Karicheri
Software Design Engineer
Texas Instruments Inc.
Germantown, MD 20874
new phone: 301-407-9583
Old Phone : 301-515-3736 (will be deprecated)
email: m-kariche...@ti.com

>-Original Message-
>From: santiago.nu...@ridgerun.com [mailto:santiago.nu...@ridgerun.com]
>Sent: Tuesday, September 01, 2009 6:55 PM
>To: Karicheri, Muralidharan
>Cc: davinci-linux-open-source@linux.davincidsp.com;
>todd.fisc...@ridgerun.com; diego.do...@ridgerun.com;
>clark.bec...@ridgerun.com; Narnakaje, Snehaprabha; Santiago Nunez-Corrales
>Subject: [PATCH 5/6 v3] Updated TVP7002 driver for DM365
>
>From: Santiago Nunez-Corrales 
>
>This patch provides the implementation of the TVP7002 decoder
>driver for DM365. Implemented revisions by Vaibhav Hiremath
>and Hans Verkuil. Removed most of controls, cleared up logic,
>cleaned up code.
>
>Signed-off-by: Santiago Nunez-Corrales 
>---
> drivers/media/video/tvp7002.c | 1493
>+
> 1 files changed, 1493 insertions(+), 0 deletions(-)
> create mode 100644 drivers/media/video/tvp7002.c
>
>diff --git a/drivers/media/video/tvp7002.c b/drivers/media/video/tvp7002.c
>new file mode 100644
>index 000..e8cd77e
>--- /dev/null
>+++ b/drivers/media/video/tvp7002.c
>@@ -0,0 +1,1493 @@
>+/* Texas Instruments Triple 8-/10-BIT 165-/110-MSPS Video and Graphics
>+ * Digitizer with Horizontal PLL registers
>+ *
>+ * Copyright (C) 2009 Texas Instruments Inc
>+ * Author: Santiago Nunez-Corrales 
>+ *
>+ * This code is partially based upon the TVP5150 driver
>+ * written by Mauro Carvalho Chehab (mche...@infradead.org)
>+ * and the TVP514x driver written by Vaibhav Hiremath 
>+ *
>+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
>+ */
>+
>+#include 
>+#include 
>+#include 
>+#include 
>+#include 
>+#include 
>+#include 
>+#include 
>+#include "tvp7002_reg.h"
>+
>+MODULE_DESCRIPTION("TI TVP7002 Video and Graphics Digitizer driver");
>+MODULE_AUTHOR("Santiago Nunez-Corrales ");
>+MODULE_LICENSE("GPL");
>+
>+/* I2C retry attempts */
>+#define I2C_RETRY_COUNT (5)
>+
>+/* Debugging information */
>+
>+static int debug;
>+module_param(debug, int, 0);
>+MODULE_PARM_DESC(debug, "Debug level (0-2)");
>+
>+/* Reference to tvp7002_platform_data */
>+extern struct tvp7002_platform_data tvp7002_pdata;
>+
>+/* Struct for handling resolutions and associate register values */
>+struct tvp7002_resol {
>+  v4l2_std_id id;
>+  int hres;
>+  int vres;
>+  int frate;
>+  int lrate;
>+  int prate;
>+  u8 reg01;
>+  u8 reg02;
>+  u8 reg03;
>+  u8 reg04;
>+};
>+
>+/* Struct for handling register values */
>+struct i2c_reg_value {
>+  u8 reg;
>+  u8 value;
>+};
>+
>+/* Register default values (according to tvp7002 datasheet) */
>+static const struct i2c_reg_value tvp7002_init_default[] = {
>+  /* 0x00: read only */
>+  { TVP7002_HPLL_FDBK_DIV_MSBS, 0x67 },
>+  { TVP7002_HPLL_FDBK_DIV_LSBS, 0x20 },
>+  { TVP7002_HPLL_CRTL, 0xa8 },
>+  { TVP7002_HPLL_PHASE_SEL, 0x80 },
>+  { TVP7002_CLAMP_START, 0x32 },
>+  { TVP7002_CLAMP_W, 0x20 },
>+  { TVP7002_HSYNC_OUT_W, 0x20 },
>+  { TVP7002_B_FINE_GAIN, 0x00 },
>+  { TVP7002_G_FINE_GAIN, 0x00 },
>+  { TVP7002_R_FINE_GAIN, 0x00 },
>+  { TVP7002_B_FINE_OFF_MSBS, 0x80 },
>+  { TVP7002_G_FINE_OFF_MSBS, 0x80 },
>+  { TVP7002_R_FINE_OFF_MSBS, 0x80 },
>+  { TVP7002_SYNC_CTL_1, 0x5b },
>+  { TVP7002_HPLL_AND_CLAMP_CTL, 0x2e },
>+  { TVP7002_SYNC_ON_G_THRS, 0x5d },
>+  { TVP7002_SYNC_SEPARATOR_THRS, 0x20 },
>+  { TVP7002_HPLL_PRE_COAST, 0x00 },
>+  { TVP7002_HP

Re: [PATCH 5/6 v3] Updated TVP7002 driver for DM365

2009-09-01 Thread Hans Verkuil
On Wednesday 02 September 2009 00:54:58 santiago.nu...@ridgerun.com wrote:
> From: Santiago Nunez-Corrales 
> 
> This patch provides the implementation of the TVP7002 decoder
> driver for DM365. Implemented revisions by Vaibhav Hiremath
> and Hans Verkuil. Removed most of controls, cleared up logic,
> cleaned up code.
> 
> Signed-off-by: Santiago Nunez-Corrales 
> ---
>  drivers/media/video/tvp7002.c | 1493 
> +
>  1 files changed, 1493 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/tvp7002.c
> 
> diff --git a/drivers/media/video/tvp7002.c b/drivers/media/video/tvp7002.c
> new file mode 100644
> index 000..e8cd77e
> --- /dev/null
> +++ b/drivers/media/video/tvp7002.c
> @@ -0,0 +1,1493 @@
> +/* Texas Instruments Triple 8-/10-BIT 165-/110-MSPS Video and Graphics
> + * Digitizer with Horizontal PLL registers
> + *
> + * Copyright (C) 2009 Texas Instruments Inc
> + * Author: Santiago Nunez-Corrales 
> + *
> + * This code is partially based upon the TVP5150 driver
> + * written by Mauro Carvalho Chehab (mche...@infradead.org)
> + * and the TVP514x driver written by Vaibhav Hiremath 
> + *
> + * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "tvp7002_reg.h"
> +
> +MODULE_DESCRIPTION("TI TVP7002 Video and Graphics Digitizer driver");
> +MODULE_AUTHOR("Santiago Nunez-Corrales ");
> +MODULE_LICENSE("GPL");
> +
> +/* I2C retry attempts */
> +#define I2C_RETRY_COUNT (5)
> +
> +/* Debugging information */
> +
> +static int debug;
> +module_param(debug, int, 0);
> +MODULE_PARM_DESC(debug, "Debug level (0-2)");
> +
> +/* Reference to tvp7002_platform_data */
> +extern struct tvp7002_platform_data tvp7002_pdata;

No, no, don't do this. This will fail if you have multiple tvp7002 devices in
one system. Just pass the platform data in through the board_info. I also
suggest renaming this struct to tvp7002_config or something like that.
platform_data suggests that this device is platform specific, but it can also
be used in PCI or USB boards.

> +
> +/* Struct for handling resolutions and associate register values */
> +struct tvp7002_resol {
> + v4l2_std_id id;
> + int hres;
> + int vres;
> + int frate;
> + int lrate;
> + int prate;
> + u8 reg01;
> + u8 reg02;
> + u8 reg03;
> + u8 reg04;
> +};
> +
> +/* Struct for handling register values */
> +struct i2c_reg_value {
> + u8 reg;
> + u8 value;
> +};
> +
> +/* Register default values (according to tvp7002 datasheet) */
> +static const struct i2c_reg_value tvp7002_init_default[] = {
> + /* 0x00: read only */
> + { TVP7002_HPLL_FDBK_DIV_MSBS, 0x67 },
> + { TVP7002_HPLL_FDBK_DIV_LSBS, 0x20 },
> + { TVP7002_HPLL_CRTL, 0xa8 },
> + { TVP7002_HPLL_PHASE_SEL, 0x80 },
> + { TVP7002_CLAMP_START, 0x32 },
> + { TVP7002_CLAMP_W, 0x20 },
> + { TVP7002_HSYNC_OUT_W, 0x20 },
> + { TVP7002_B_FINE_GAIN, 0x00 },
> + { TVP7002_G_FINE_GAIN, 0x00 },
> + { TVP7002_R_FINE_GAIN, 0x00 },
> + { TVP7002_B_FINE_OFF_MSBS, 0x80 },
> + { TVP7002_G_FINE_OFF_MSBS, 0x80 },
> + { TVP7002_R_FINE_OFF_MSBS, 0x80 },
> + { TVP7002_SYNC_CTL_1, 0x5b },
> + { TVP7002_HPLL_AND_CLAMP_CTL, 0x2e },
> + { TVP7002_SYNC_ON_G_THRS, 0x5d },
> + { TVP7002_SYNC_SEPARATOR_THRS, 0x20 },
> + { TVP7002_HPLL_PRE_COAST, 0x00 },
> + { TVP7002_HPLL_POST_COAST, 0x00 },
> + /* 0x14: read only */
> + { TVP7002_OUT_FORMATTER, 0x00 },
> + { TVP7002_MISC_CTL_1, 0x11 },
> + { TVP7002_MISC_CTL_2, 0x03 },
> + { TVP7002_MISC_CTL_3, 0x00 },
> + { TVP7002_IN_MUX_SEL_1, 0x00 },
> + { TVP7002_IN_MUX_SEL_2, 0xc2 },
> + { TVP7002_B_AND_G_COARSE_GAIN, 0x77 },
> + { TVP7002_R_COARSE_GAIN, 0x07 },
> + { TVP7002_COARSE_CLAMP_CTL, 0x00 },
> + { TVP7002_FINE_OFF_LSBS, 0x00 },
> + { TVP7002_B_COARSE_OFF, 0x10 },
> + { TVP7002_G_COARSE_OFF, 0x10 },
> + { TVP7002_R_COARSE_OFF, 0x10 },
> + { TVP7002_HSOUT_OUT_START, 0x0d },
> + { TVP7002_MISC_CTL_4, 0x0d },
> + /* 0x23: read only */
> + /* 0x24: read only */
> + /* 0x25: read only */
> + { TVP7002_AUTO_LVL_CTL_ENABLE, 0x80 },
> +

[PATCH 5/6 v3] Updated TVP7002 driver for DM365

2009-09-01 Thread santiago . nunez
From: Santiago Nunez-Corrales 

This patch provides the implementation of the TVP7002 decoder
driver for DM365. Implemented revisions by Vaibhav Hiremath
and Hans Verkuil. Removed most of controls, cleared up logic,
cleaned up code.

Signed-off-by: Santiago Nunez-Corrales 
---
 drivers/media/video/tvp7002.c | 1493 +
 1 files changed, 1493 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/tvp7002.c

diff --git a/drivers/media/video/tvp7002.c b/drivers/media/video/tvp7002.c
new file mode 100644
index 000..e8cd77e
--- /dev/null
+++ b/drivers/media/video/tvp7002.c
@@ -0,0 +1,1493 @@
+/* Texas Instruments Triple 8-/10-BIT 165-/110-MSPS Video and Graphics
+ * Digitizer with Horizontal PLL registers
+ *
+ * Copyright (C) 2009 Texas Instruments Inc
+ * Author: Santiago Nunez-Corrales 
+ *
+ * This code is partially based upon the TVP5150 driver
+ * written by Mauro Carvalho Chehab (mche...@infradead.org)
+ * and the TVP514x driver written by Vaibhav Hiremath 
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "tvp7002_reg.h"
+
+MODULE_DESCRIPTION("TI TVP7002 Video and Graphics Digitizer driver");
+MODULE_AUTHOR("Santiago Nunez-Corrales ");
+MODULE_LICENSE("GPL");
+
+/* I2C retry attempts */
+#define I2C_RETRY_COUNT (5)
+
+/* Debugging information */
+
+static int debug;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "Debug level (0-2)");
+
+/* Reference to tvp7002_platform_data */
+extern struct tvp7002_platform_data tvp7002_pdata;
+
+/* Struct for handling resolutions and associate register values */
+struct tvp7002_resol {
+   v4l2_std_id id;
+   int hres;
+   int vres;
+   int frate;
+   int lrate;
+   int prate;
+   u8 reg01;
+   u8 reg02;
+   u8 reg03;
+   u8 reg04;
+};
+
+/* Struct for handling register values */
+struct i2c_reg_value {
+   u8 reg;
+   u8 value;
+};
+
+/* Register default values (according to tvp7002 datasheet) */
+static const struct i2c_reg_value tvp7002_init_default[] = {
+   /* 0x00: read only */
+   { TVP7002_HPLL_FDBK_DIV_MSBS, 0x67 },
+   { TVP7002_HPLL_FDBK_DIV_LSBS, 0x20 },
+   { TVP7002_HPLL_CRTL, 0xa8 },
+   { TVP7002_HPLL_PHASE_SEL, 0x80 },
+   { TVP7002_CLAMP_START, 0x32 },
+   { TVP7002_CLAMP_W, 0x20 },
+   { TVP7002_HSYNC_OUT_W, 0x20 },
+   { TVP7002_B_FINE_GAIN, 0x00 },
+   { TVP7002_G_FINE_GAIN, 0x00 },
+   { TVP7002_R_FINE_GAIN, 0x00 },
+   { TVP7002_B_FINE_OFF_MSBS, 0x80 },
+   { TVP7002_G_FINE_OFF_MSBS, 0x80 },
+   { TVP7002_R_FINE_OFF_MSBS, 0x80 },
+   { TVP7002_SYNC_CTL_1, 0x5b },
+   { TVP7002_HPLL_AND_CLAMP_CTL, 0x2e },
+   { TVP7002_SYNC_ON_G_THRS, 0x5d },
+   { TVP7002_SYNC_SEPARATOR_THRS, 0x20 },
+   { TVP7002_HPLL_PRE_COAST, 0x00 },
+   { TVP7002_HPLL_POST_COAST, 0x00 },
+   /* 0x14: read only */
+   { TVP7002_OUT_FORMATTER, 0x00 },
+   { TVP7002_MISC_CTL_1, 0x11 },
+   { TVP7002_MISC_CTL_2, 0x03 },
+   { TVP7002_MISC_CTL_3, 0x00 },
+   { TVP7002_IN_MUX_SEL_1, 0x00 },
+   { TVP7002_IN_MUX_SEL_2, 0xc2 },
+   { TVP7002_B_AND_G_COARSE_GAIN, 0x77 },
+   { TVP7002_R_COARSE_GAIN, 0x07 },
+   { TVP7002_COARSE_CLAMP_CTL, 0x00 },
+   { TVP7002_FINE_OFF_LSBS, 0x00 },
+   { TVP7002_B_COARSE_OFF, 0x10 },
+   { TVP7002_G_COARSE_OFF, 0x10 },
+   { TVP7002_R_COARSE_OFF, 0x10 },
+   { TVP7002_HSOUT_OUT_START, 0x0d },
+   { TVP7002_MISC_CTL_4, 0x0d },
+   /* 0x23: read only */
+   /* 0x24: read only */
+   /* 0x25: read only */
+   { TVP7002_AUTO_LVL_CTL_ENABLE, 0x80 },
+   /* 0x27: read only */
+   { TVP7002_AUTO_LVL_CTL_FILTER, 0x53 },
+   { TVP7002_FINE_CLAMP_CTL, 0x07 },
+   { TVP7002_PWR_CTL, 0x00 },
+   { TVP7002_ADC_SETUP, 0x50 },
+   { TVP7002_COARSE_CLAMP_CTL, 0x00 },
+   { TVP7002_SOG_CLAMP, 0x80 },
+   { TVP7002_RGB_COARSE_CLAMP_CTL, 0x8c },
+   { TVP7002_SOG_COARSE_CLAMP_CTL, 0x04 },
+   { TVP7002_ALC_PLACEMENT, 0x5a },
+   { TVP7002_MVIS_STRIPPER_W, 0x03 },
+   { TVP7002_VSYNC_ALGN, 0x10 },
+   { TVP7002_SYNC_BYPASS, 0x00 },
+   /* 0x37: read only */
+   /* 0x38: re