RE: [PATCH 2/2] AM3517: Add VPFE Capture driver support to board file

2010-06-02 Thread Karicheri, Muralidharan
Vaibhav,

See below my comments...

Murali Karicheri
Software Design Engineer
Texas Instruments Inc.
Germantown, MD 20874
phone: 301-407-9583
email: m-kariche...@ti.com

-Original Message-
From: Hiremath, Vaibhav
Sent: Thursday, May 27, 2010 9:11 AM
To: linux-media@vger.kernel.org
Cc: mche...@redhat.com; Karicheri, Muralidharan; linux-
o...@vger.kernel.org; Hiremath, Vaibhav
Subject: [PATCH 2/2] AM3517: Add VPFE Capture driver support to board file

From: Vaibhav Hiremath hvaib...@ti.com

Also created vpfe master/slave clock aliases, since naming
convention is different in both Davinci and AM3517 devices.

Signed-off-by: Vaibhav Hiremath hvaib...@ti.com
---
 arch/arm/mach-omap2/board-am3517evm.c |  161
+
 1 files changed, 161 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-
omap2/board-am3517evm.c
index c1c4389..edcb6db 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -30,15 +30,168 @@

 #include plat/board.h
 #include plat/common.h
+#include plat/control.h
 #include plat/usb.h
 #include plat/display.h

+#include media/tvp514x.h
+#include media/davinci/vpfe_capture.h
+
 #include mux.h

 #define LCD_PANEL_PWR 176
 #define LCD_PANEL_BKLIGHT_PWR 182
 #define LCD_PANEL_PWM 181

+/*
+ * VPFE - Video Decoder interface
+ */
+#define TVP514X_STD_ALL   (V4L2_STD_NTSC | V4L2_STD_PAL)
+
+/* Inputs available at the TVP5146 */
+static struct v4l2_input tvp5146_inputs[] = {
+  {
+  .index  = 0,
+  .name   = Composite,
+  .type   = V4L2_INPUT_TYPE_CAMERA,
+  .std= TVP514X_STD_ALL,
+  },
+  {
+  .index  = 1,
+  .name   = S-Video,
+  .type   = V4L2_INPUT_TYPE_CAMERA,
+  .std= TVP514X_STD_ALL,
+  },
+};
+
+static struct tvp514x_platform_data tvp5146_pdata = {
+  .clk_polarity   = 0,
+  .hs_polarity= 1,
+  .vs_polarity= 1
+};
+
+static struct vpfe_route tvp5146_routes[] = {
+  {
+  .input  = INPUT_CVBS_VI1A,
+  .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
+  },
+  {
+  .input  = INPUT_SVIDEO_VI2C_VI1C,
+  .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
+  },
+};
+
+static struct vpfe_subdev_info vpfe_sub_devs[] = {
+  {
+  .name   = tvp5146,
+  .grp_id = 0,
+  .num_inputs = ARRAY_SIZE(tvp5146_inputs),
+  .inputs = tvp5146_inputs,
+  .routes = tvp5146_routes,
+  .can_route  = 1,
+  .ccdc_if_params = {
+  .if_type = VPFE_BT656,
+  .hdpol  = VPFE_PINPOL_POSITIVE,
+  .vdpol  = VPFE_PINPOL_POSITIVE,
+  },
+  .board_info = {
+  I2C_BOARD_INFO(tvp5146, 0x5C),
+  .platform_data = tvp5146_pdata,
+  },
+  },
+};
+
+static void am3517_evm_clear_vpfe_intr(int vdint)
+{
+  unsigned int vpfe_int_clr;
+
+  vpfe_int_clr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+
+  switch (vdint) {
+  /* VD0 interrrupt */
+  case INT_35XX_CCDC_VD0_IRQ:
+  vpfe_int_clr = ~AM35XX_VPFE_CCDC_VD0_INT_CLR;
+  vpfe_int_clr |= AM35XX_VPFE_CCDC_VD0_INT_CLR;
+  break;
+  /* VD1 interrrupt */
+  case INT_35XX_CCDC_VD1_IRQ:
+  vpfe_int_clr = ~AM35XX_VPFE_CCDC_VD1_INT_CLR;
+  vpfe_int_clr |= AM35XX_VPFE_CCDC_VD1_INT_CLR;
+  break;
+  /* VD2 interrrupt */
+  case INT_35XX_CCDC_VD2_IRQ:
+  vpfe_int_clr = ~AM35XX_VPFE_CCDC_VD2_INT_CLR;
+  vpfe_int_clr |= AM35XX_VPFE_CCDC_VD2_INT_CLR;
+  break;
+  /* Clear all interrrupts */
+  default:
+  vpfe_int_clr = ~(AM35XX_VPFE_CCDC_VD0_INT_CLR |
+  AM35XX_VPFE_CCDC_VD1_INT_CLR |
+  AM35XX_VPFE_CCDC_VD2_INT_CLR);
+  vpfe_int_clr |= (AM35XX_VPFE_CCDC_VD0_INT_CLR |
+  AM35XX_VPFE_CCDC_VD1_INT_CLR |
+  AM35XX_VPFE_CCDC_VD2_INT_CLR);
+  break;
+  }
+  omap_ctrl_writel(vpfe_int_clr, AM35XX_CONTROL_LVL_INTR_CLEAR);
+  vpfe_int_clr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+}
+
+static struct vpfe_config vpfe_cfg = {
+  .num_subdevs= ARRAY_SIZE(vpfe_sub_devs),
+  .i2c_adapter_id = 3,
+  .sub_devs   = vpfe_sub_devs,
+  .clr_intr   = am3517_evm_clear_vpfe_intr,
+  .card_name  = DM6446 EVM,

[MK] You might want to change the card name to match with what you are using.
This is what user will see in querycap and should reflect the correct name IMO.

+  .ccdc   = DM6446 CCDC,
+};
+
+static struct resource vpfe_resources[] = {
+  {
+  

RE: [PATCH 2/2] AM3517: Add VPFE Capture driver support to board file

2010-06-02 Thread Hiremath, Vaibhav


From: Karicheri, Muralidharan
Sent: Wednesday, June 02, 2010 7:31 PM
To: Hiremath, Vaibhav; linux-media@vger.kernel.org
Cc: mche...@redhat.com; linux-o...@vger.kernel.org
Subject: RE: [PATCH 2/2] AM3517: Add VPFE Capture driver support to board file

Vaibhav,

See below my comments...

Murali Karicheri
Software Design Engineer
Texas Instruments Inc.
Germantown, MD 20874
phone: 301-407-9583
email: m-kariche...@ti.com

-Original Message-
From: Hiremath, Vaibhav
Sent: Thursday, May 27, 2010 9:11 AM
To: linux-media@vger.kernel.org
Cc: mche...@redhat.com; Karicheri, Muralidharan; linux-
o...@vger.kernel.org; Hiremath, Vaibhav
Subject: [PATCH 2/2] AM3517: Add VPFE Capture driver support to board file

From: Vaibhav Hiremath hvaib...@ti.com

Also created vpfe master/slave clock aliases, since naming
convention is different in both Davinci and AM3517 devices.

Signed-off-by: Vaibhav Hiremath hvaib...@ti.com
---
 arch/arm/mach-omap2/board-am3517evm.c |  161
+
 1 files changed, 161 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-
omap2/board-am3517evm.c
index c1c4389..edcb6db 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -30,15 +30,168 @@

 #include plat/board.h
 #include plat/common.h
+#include plat/control.h
 #include plat/usb.h
 #include plat/display.h

+#include media/tvp514x.h
+#include media/davinci/vpfe_capture.h
+
 #include mux.h

 #define LCD_PANEL_PWR 176
 #define LCD_PANEL_BKLIGHT_PWR 182
 #define LCD_PANEL_PWM 181

+/*
+ * VPFE - Video Decoder interface
+ */
+#define TVP514X_STD_ALL   (V4L2_STD_NTSC | V4L2_STD_PAL)
+
+/* Inputs available at the TVP5146 */
+static struct v4l2_input tvp5146_inputs[] = {
+  {
+  .index  = 0,
+  .name   = Composite,
+  .type   = V4L2_INPUT_TYPE_CAMERA,
+  .std= TVP514X_STD_ALL,
+  },
+  {
+  .index  = 1,
+  .name   = S-Video,
+  .type   = V4L2_INPUT_TYPE_CAMERA,
+  .std= TVP514X_STD_ALL,
+  },
+};
+
+static struct tvp514x_platform_data tvp5146_pdata = {
+  .clk_polarity   = 0,
+  .hs_polarity= 1,
+  .vs_polarity= 1
+};
+
+static struct vpfe_route tvp5146_routes[] = {
+  {
+  .input  = INPUT_CVBS_VI1A,
+  .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
+  },
+  {
+  .input  = INPUT_SVIDEO_VI2C_VI1C,
+  .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
+  },
+};
+
+static struct vpfe_subdev_info vpfe_sub_devs[] = {
+  {
+  .name   = tvp5146,
+  .grp_id = 0,
+  .num_inputs = ARRAY_SIZE(tvp5146_inputs),
+  .inputs = tvp5146_inputs,
+  .routes = tvp5146_routes,
+  .can_route  = 1,
+  .ccdc_if_params = {
+  .if_type = VPFE_BT656,
+  .hdpol  = VPFE_PINPOL_POSITIVE,
+  .vdpol  = VPFE_PINPOL_POSITIVE,
+  },
+  .board_info = {
+  I2C_BOARD_INFO(tvp5146, 0x5C),
+  .platform_data = tvp5146_pdata,
+  },
+  },
+};
+
+static void am3517_evm_clear_vpfe_intr(int vdint)
+{
+  unsigned int vpfe_int_clr;
+
+  vpfe_int_clr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+
+  switch (vdint) {
+  /* VD0 interrrupt */
+  case INT_35XX_CCDC_VD0_IRQ:
+  vpfe_int_clr = ~AM35XX_VPFE_CCDC_VD0_INT_CLR;
+  vpfe_int_clr |= AM35XX_VPFE_CCDC_VD0_INT_CLR;
+  break;
+  /* VD1 interrrupt */
+  case INT_35XX_CCDC_VD1_IRQ:
+  vpfe_int_clr = ~AM35XX_VPFE_CCDC_VD1_INT_CLR;
+  vpfe_int_clr |= AM35XX_VPFE_CCDC_VD1_INT_CLR;
+  break;
+  /* VD2 interrrupt */
+  case INT_35XX_CCDC_VD2_IRQ:
+  vpfe_int_clr = ~AM35XX_VPFE_CCDC_VD2_INT_CLR;
+  vpfe_int_clr |= AM35XX_VPFE_CCDC_VD2_INT_CLR;
+  break;
+  /* Clear all interrrupts */
+  default:
+  vpfe_int_clr = ~(AM35XX_VPFE_CCDC_VD0_INT_CLR |
+  AM35XX_VPFE_CCDC_VD1_INT_CLR |
+  AM35XX_VPFE_CCDC_VD2_INT_CLR);
+  vpfe_int_clr |= (AM35XX_VPFE_CCDC_VD0_INT_CLR |
+  AM35XX_VPFE_CCDC_VD1_INT_CLR |
+  AM35XX_VPFE_CCDC_VD2_INT_CLR);
+  break;
+  }
+  omap_ctrl_writel(vpfe_int_clr, AM35XX_CONTROL_LVL_INTR_CLEAR);
+  vpfe_int_clr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+}
+
+static struct vpfe_config vpfe_cfg = {
+  .num_subdevs= ARRAY_SIZE(vpfe_sub_devs),
+  .i2c_adapter_id = 3,
+  .sub_devs   = vpfe_sub_devs,
+  .clr_intr   = am3517_evm_clear_vpfe_intr,
+  .card_name