RE: [PATCH 0/6] davinci vpbe: V4L2 Display driver for DM644X

2010-11-19 Thread Hadli, Manjunath
Hans,
 Thank you for the review comments. I will include a section 
on customizing for additions and changes to different boards.

Thanks again,
-Manju

On Sat, Nov 13, 2010 at 18:22:19, Hans Verkuil wrote:
 Hi Manju,
 
 I've reviewed the other patches as well. The only one for which I had 
 comments was patch 2/6.
 
 However, what I think would be useful here is to have an overview document, 
 either as part of a source or header, or as a separate text document. It is 
 not easy to get a good overview of how everything fits together, and a 
 document that describes the various parts and how they fit together would be 
 very benificial.
 
 I am thinking in particular of vendors building a new board based on this
 device: how and where do you define new i2c display devices, how are they 
 initialized, etc.
 
 Regards,
 
   Hans
 
 On Monday, November 08, 2010 15:54:05 Manjunath Hadli wrote:
  This driver is written for Texas Instruments's DM644X VPBE IP.
  This SoC supports 2 video planes and 2 OSD planes as part of its OSD 
  (On Screen Display) block. The OSD lanes predminantly support RGB 
  space and the Video planes support YUV data. Out of these 4, the 2 
  video planes are supported as part of the V4L2 driver. These would be 
  enumerated as video2 and video3 dev nodes.
  The blending and video timing generator unit (VENC- for Video Encoder) 
  is the unit which combines/blends the output of these 4 planes into a 
  single stream and this output is given to Video input devices like TV 
  and other digital LCDs. The software for VENC is designed as a 
  subdevice with support for SD(NTSC and PAL) modes and 2 outputs.
  This SoC forms the iniial implementation of its later additions like 
  DM355 and DM365.
  
  Muralidharan Karicheri (6):
davinci vpbe: V4L2 display driver for DM644X SoC
davinci vpbe: VPBE display driver
davinci vpbe: OSD(On Screen Display ) block
davinci vpbe: VENC( Video Encoder) implementation
davinci vpbe: platform specific additions
davinci vpbe: Build infrastructure for VPBE driver
  
   arch/arm/mach-davinci/board-dm644x-evm.c |   85 +-
   arch/arm/mach-davinci/dm644x.c   |  181 ++-
   arch/arm/mach-davinci/include/mach/dm644x.h  |4 +
   drivers/media/video/davinci/Kconfig  |   22 +
   drivers/media/video/davinci/Makefile |2 +
   drivers/media/video/davinci/vpbe.c   |  861 ++
   drivers/media/video/davinci/vpbe_display.c   | 2283 
  ++
   drivers/media/video/davinci/vpbe_osd.c   | 1208 ++
   drivers/media/video/davinci/vpbe_osd_regs.h  |  389 +
   drivers/media/video/davinci/vpbe_venc.c  |  617 +++
   drivers/media/video/davinci/vpbe_venc_regs.h |  189 +++
   include/media/davinci/vpbe.h |  187 +++
   include/media/davinci/vpbe_display.h |  144 ++
   include/media/davinci/vpbe_osd.h |  397 +
   include/media/davinci/vpbe_types.h   |  170 ++
   include/media/davinci/vpbe_venc.h|   70 +
   16 files changed, 6790 insertions(+), 19 deletions(-)  create mode 
  100644 drivers/media/video/davinci/vpbe.c
   create mode 100644 drivers/media/video/davinci/vpbe_display.c
   create mode 100644 drivers/media/video/davinci/vpbe_osd.c
   create mode 100644 drivers/media/video/davinci/vpbe_osd_regs.h
   create mode 100644 drivers/media/video/davinci/vpbe_venc.c
   create mode 100644 drivers/media/video/davinci/vpbe_venc_regs.h
   create mode 100644 include/media/davinci/vpbe.h  create mode 100644 
  include/media/davinci/vpbe_display.h
   create mode 100644 include/media/davinci/vpbe_osd.h  create mode 
  100644 include/media/davinci/vpbe_types.h
   create mode 100644 include/media/davinci/vpbe_venc.h
  
  --
  To unsubscribe from this list: send the line unsubscribe linux-media 
  in the body of a message to majord...@vger.kernel.org More majordomo 
  info at  http://vger.kernel.org/majordomo-info.html
  
  
 
 --
 Hans Verkuil - video4linux developer - sponsored by Cisco
 

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [omap3isp][PATCH v2 8/9] omap3isp: ccp2: Make SYSCONFIG fields consistent

2010-11-19 Thread David Cohen
Hi Sergio,

I've few comments below.

On Mon, Nov 15, 2010 at 03:30:00PM +0100, ext Sergio Aguirre wrote:
 Signed-off-by: Sergio Aguirre saagui...@ti.com
 ---
  drivers/media/video/isp/ispccp2.c |3 +--
  drivers/media/video/isp/ispreg.h  |   14 --
  2 files changed, 9 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/media/video/isp/ispccp2.c 
 b/drivers/media/video/isp/ispccp2.c
 index fa23394..3127a74 100644
 --- a/drivers/media/video/isp/ispccp2.c
 +++ b/drivers/media/video/isp/ispccp2.c
 @@ -419,8 +419,7 @@ static void ispccp2_mem_configure(struct isp_ccp2_device 
 *ccp2,
   config-src_ofst = 0;
   }
  
 - isp_reg_writel(isp, (ISPCSI1_MIDLEMODE_SMARTSTANDBY 
 -ISPCSI1_MIDLEMODE_SHIFT),
 + isp_reg_writel(isp, ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SMART,
  OMAP3_ISP_IOMEM_CCP2, ISPCCP2_SYSCONFIG);

To make your cleanup even better, you could change isp_reg_clr_set() instead.
If CCP2 MSTANDY_MODE is set to NOSTANDY, the result is going to be an
invalid 0x3 value. Despite it cannot happen with the current code, it's
still better to avoid such situations for future versions. :)

  
   /* Hsize, Skip */
 diff --git a/drivers/media/video/isp/ispreg.h 
 b/drivers/media/video/isp/ispreg.h
 index d885541..9b0d3ad 100644
 --- a/drivers/media/video/isp/ispreg.h
 +++ b/drivers/media/video/isp/ispreg.h
 @@ -141,6 +141,14 @@
  #define ISPCCP2_REVISION (0x000)
  #define ISPCCP2_SYSCONFIG(0x004)
  #define ISPCCP2_SYSCONFIG_SOFT_RESET (1  1)
 +#define ISPCCP2_SYSCONFIG_AUTO_IDLE  0x1
 +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT12
 +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_FORCE\
 + (0x0  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
 +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_NO   \
 + (0x1  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
 +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SMART\
 + (0x2  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)

You can add some ISPCCP2_SYSCONFIG_MSTANDY_MODE_MASK, as 2 bits must be
always set together.

Regards,

David Cohen

  #define ISPCCP2_SYSSTATUS(0x008)
  #define ISPCCP2_SYSSTATUS_RESET_DONE (1  0)
  #define ISPCCP2_LC01_IRQENABLE   (0x00C)
 @@ -1309,12 +1317,6 @@
  #define ISPMMU_SIDLEMODE_SMARTIDLE   2
  #define ISPMMU_SIDLEMODE_SHIFT   3
  
 -#define ISPCSI1_AUTOIDLE 0x1
 -#define ISPCSI1_MIDLEMODE_SHIFT  12
 -#define ISPCSI1_MIDLEMODE_FORCESTANDBY   0x0
 -#define ISPCSI1_MIDLEMODE_NOSTANDBY  0x1
 -#define ISPCSI1_MIDLEMODE_SMARTSTANDBY   0x2
 -
  /* 
 -
   * CSI2 receiver registers (ES2.0)
   */
 -- 
 1.7.0.4
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [omap3isp][PATCH v2 7/9] omap3isp: Cleanup isp_power_settings

2010-11-19 Thread David Cohen
Hi Sergio,

Thanks for the patch.

On Mon, Nov 15, 2010 at 03:29:59PM +0100, ext Sergio Aguirre wrote:
 1. Get rid of CSI2 / CCP2 power settings, as they are controlled
in the receivers code anyways.

CCP2 is not correctly handling this. It's setting SMART STANDBY mode one
when reading from memory. You should fix it before remove such code from
ISP core driver.

 2. Avoid code duplication.

Agree. But only after considering the comment above.

Regards,

David

 
 Signed-off-by: Sergio Aguirre saagui...@ti.com
 ---
  drivers/media/video/isp/isp.c |   49 
 ++---
  1 files changed, 7 insertions(+), 42 deletions(-)
 
 diff --git a/drivers/media/video/isp/isp.c b/drivers/media/video/isp/isp.c
 index de9352b..30bdc48 100644
 --- a/drivers/media/video/isp/isp.c
 +++ b/drivers/media/video/isp/isp.c
 @@ -254,48 +254,13 @@ EXPORT_SYMBOL(isp_set_xclk);
   */
  static void isp_power_settings(struct isp_device *isp, int idle)
  {
 - if (idle) {
 - isp_reg_writel(isp,
 -(ISP_SYSCONFIG_MIDLEMODE_SMARTSTANDBY 
 - ISP_SYSCONFIG_MIDLEMODE_SHIFT),
 -OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
 - if (omap_rev() == OMAP3430_REV_ES1_0) {
 - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
 -(ISPCSI1_MIDLEMODE_SMARTSTANDBY 
 - ISPCSI1_MIDLEMODE_SHIFT),
 -OMAP3_ISP_IOMEM_CSI2A_REGS1,
 -ISPCSI2_SYSCONFIG);
 - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
 -(ISPCSI1_MIDLEMODE_SMARTSTANDBY 
 - ISPCSI1_MIDLEMODE_SHIFT),
 -OMAP3_ISP_IOMEM_CCP2,
 -ISPCCP2_SYSCONFIG);
 - }
 - isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE, OMAP3_ISP_IOMEM_MAIN,
 -ISP_CTRL);
 -
 - } else {
 - isp_reg_writel(isp,
 -(ISP_SYSCONFIG_MIDLEMODE_FORCESTANDBY 
 - ISP_SYSCONFIG_MIDLEMODE_SHIFT),
 -OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
 - if (omap_rev() == OMAP3430_REV_ES1_0) {
 - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
 -(ISPCSI1_MIDLEMODE_FORCESTANDBY 
 - ISPCSI1_MIDLEMODE_SHIFT),
 -OMAP3_ISP_IOMEM_CSI2A_REGS1,
 -ISPCSI2_SYSCONFIG);
 -
 - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
 -(ISPCSI1_MIDLEMODE_FORCESTANDBY 
 - ISPCSI1_MIDLEMODE_SHIFT),
 -OMAP3_ISP_IOMEM_CCP2,
 -ISPCCP2_SYSCONFIG);
 - }
 -
 - isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE, OMAP3_ISP_IOMEM_MAIN,
 -ISP_CTRL);
 - }
 + isp_reg_writel(isp,
 +((idle ? ISP_SYSCONFIG_MIDLEMODE_SMARTSTANDBY :
 + ISP_SYSCONFIG_MIDLEMODE_FORCESTANDBY) 
 + ISP_SYSCONFIG_MIDLEMODE_SHIFT),
 +OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
 + isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE, OMAP3_ISP_IOMEM_MAIN,
 +ISP_CTRL);
  }
  
  /*
 -- 
 1.7.0.4
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [omap3isp][PATCH v2 5/9] omap3isp: Remove unused CBUFF register access

2010-11-19 Thread David Cohen
Hi Sergio,

I have one comment below.

On Mon, Nov 15, 2010 at 03:29:57PM +0100, ext Sergio Aguirre wrote:
 Signed-off-by: Sergio Aguirre saagui...@ti.com
 ---
  drivers/media/video/isp/isp.c|2 --
  drivers/media/video/isp/isp.h|1 -
  drivers/media/video/isp/ispreg.h |   25 -
  3 files changed, 0 insertions(+), 28 deletions(-)
 
 diff --git a/drivers/media/video/isp/isp.c b/drivers/media/video/isp/isp.c
 index a5c02ba..f266e7c 100644
 --- a/drivers/media/video/isp/isp.c
 +++ b/drivers/media/video/isp/isp.c
 @@ -86,7 +86,6 @@ static const struct isp_res_mapping isp_res_maps[] = {
   {
   .isp_rev = ISP_REVISION_2_0,
   .map = 1  OMAP3_ISP_IOMEM_MAIN |
 -1  OMAP3_ISP_IOMEM_CBUFF |
  1  OMAP3_ISP_IOMEM_CCP2 |
  1  OMAP3_ISP_IOMEM_CCDC |
  1  OMAP3_ISP_IOMEM_HIST |
 @@ -100,7 +99,6 @@ static const struct isp_res_mapping isp_res_maps[] = {
   {
   .isp_rev = ISP_REVISION_15_0,
   .map = 1  OMAP3_ISP_IOMEM_MAIN |
 -1  OMAP3_ISP_IOMEM_CBUFF |
  1  OMAP3_ISP_IOMEM_CCP2 |
  1  OMAP3_ISP_IOMEM_CCDC |
  1  OMAP3_ISP_IOMEM_HIST |
 diff --git a/drivers/media/video/isp/isp.h b/drivers/media/video/isp/isp.h
 index edc029c..b8f63e2 100644
 --- a/drivers/media/video/isp/isp.h
 +++ b/drivers/media/video/isp/isp.h
 @@ -56,7 +56,6 @@
  
  enum isp_mem_resources {
   OMAP3_ISP_IOMEM_MAIN,
 - OMAP3_ISP_IOMEM_CBUFF,
   OMAP3_ISP_IOMEM_CCP2,
   OMAP3_ISP_IOMEM_CCDC,
   OMAP3_ISP_IOMEM_HIST,
 diff --git a/drivers/media/video/isp/ispreg.h 
 b/drivers/media/video/isp/ispreg.h
 index 8e4324f..c080980 100644
 --- a/drivers/media/video/isp/ispreg.h
 +++ b/drivers/media/video/isp/ispreg.h
 @@ -37,11 +37,6 @@
  #define OMAP3ISP_REG_BASEOMAP3430_ISP_BASE
  #define OMAP3ISP_REG(offset) (OMAP3ISP_REG_BASE + (offset))
  
 -#define OMAP3ISP_CBUFF_REG_OFFSET0x0100
 -#define OMAP3ISP_CBUFF_REG_BASE  (OMAP3ISP_REG_BASE +
 \
 -  OMAP3ISP_CBUFF_REG_OFFSET)
 -#define OMAP3ISP_CBUFF_REG(offset)   (OMAP3ISP_CBUFF_REG_BASE + (offset))
 -
  #define OMAP3ISP_CCP2_REG_OFFSET 0x0400
  #define OMAP3ISP_CCP2_REG_BASE   (OMAP3ISP_REG_BASE +
 \
OMAP3ISP_CCP2_REG_OFFSET)
 @@ -244,26 +239,6 @@
  #define ISP_CSIB_SYSCONFIG   ISPCCP2_SYSCONFIG
  #define ISP_CSIA_SYSCONFIG   ISPCSI2_SYSCONFIG
  
 -/* ISP_CBUFF Registers */
 -
 -#define ISP_CBUFF_SYSCONFIG  (0x010)
 -#define ISP_CBUFF_IRQENABLE  (0x01C)
 -
 -#define ISP_CBUFF0_CTRL  (0x020)
 -#define ISP_CBUFF1_CTRL  (0x024)
 -
 -#define ISP_CBUFF0_START (0x040)
 -#define ISP_CBUFF1_START (0x044)
 -
 -#define ISP_CBUFF0_END   (0x050)
 -#define ISP_CBUFF1_END   (0x054)
 -
 -#define ISP_CBUFF0_WINDOWSIZE(0x060)
 -#define ISP_CBUFF1_WINDOWSIZE(0x064)
 -
 -#define ISP_CBUFF0_THRESHOLD (0x070)
 -#define ISP_CBUFF1_THRESHOLD (0x074)
 -

No need to remove the registers from header file. We're not using them
on current version, but it doesn't mean we won't use ever. :)

Br,

David Cohen

  /* CCDC module register offset */
  
  #define ISPCCDC_PID  (0x000)
 -- 
 1.7.0.4
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [omap3isp][PATCH v2 5/9] omap3isp: Remove unused CBUFF register access

2010-11-19 Thread Laurent Pinchart
Hi David,

On Friday 19 November 2010 11:19:44 David Cohen wrote:
 On Mon, Nov 15, 2010 at 03:29:57PM +0100, ext Sergio Aguirre wrote:

[snip]

  @@ -244,26 +239,6 @@
  
   #define ISP_CSIB_SYSCONFIG ISPCCP2_SYSCONFIG
   #define ISP_CSIA_SYSCONFIG ISPCSI2_SYSCONFIG
  
  -/* ISP_CBUFF Registers */
  -
  -#define ISP_CBUFF_SYSCONFIG(0x010)
  -#define ISP_CBUFF_IRQENABLE(0x01C)
  -
  -#define ISP_CBUFF0_CTRL(0x020)
  -#define ISP_CBUFF1_CTRL(0x024)
  -
  -#define ISP_CBUFF0_START   (0x040)
  -#define ISP_CBUFF1_START   (0x044)
  -
  -#define ISP_CBUFF0_END (0x050)
  -#define ISP_CBUFF1_END (0x054)
  -
  -#define ISP_CBUFF0_WINDOWSIZE  (0x060)
  -#define ISP_CBUFF1_WINDOWSIZE  (0x064)
  -
  -#define ISP_CBUFF0_THRESHOLD   (0x070)
  -#define ISP_CBUFF1_THRESHOLD   (0x074)
  -
 
 No need to remove the registers from header file. We're not using them
 on current version, but it doesn't mean we won't use ever. :)

I would have made the same comment for other registers, but we're not using 
the CBUFF module at all here, with no plans to use it in the future. It might 
not be worth it keeping the register definitions. I have no strong feeling 
about it, I'm fine with both choices.

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[omap3isp][PATCH] omap3isp: does not allow pipeline with multiple video outputs yet

2010-11-19 Thread David Cohen
OMAP3 ISP driver does not support pipeline with multiple video outputs yet.
Driver must return -EBUSY in this case.

Signed-off-by: David Cohen david.co...@nokia.com
---
 drivers/media/video/isp/ispccdc.c|   26 --
 drivers/media/video/isp/ispcsi2.c|   19 +++
 drivers/media/video/isp/isppreview.c |   19 +++
 3 files changed, 50 insertions(+), 14 deletions(-)

diff --git a/drivers/media/video/isp/ispccdc.c 
b/drivers/media/video/isp/ispccdc.c
index a4c6444..a19795c 100644
--- a/drivers/media/video/isp/ispccdc.c
+++ b/drivers/media/video/isp/ispccdc.c
@@ -2016,30 +2016,44 @@ static int ccdc_link_setup(struct media_entity *entity,
 
break;
 
+   /*
+* This driver currently does not support pipeline with multiples
+* video outputs. It must return -EBUSY while it's not implemented.
+*/
+
case CCDC_PAD_SOURCE_VP | (MEDIA_ENTITY_TYPE_SUBDEV  16):
/* Write to preview engine, histogram and H3A. When none of
 * those links are active, the video port can be disabled.
 */
-   if (flags  MEDIA_LINK_FLAG_ACTIVE)
+   if (flags  MEDIA_LINK_FLAG_ACTIVE) {
+   if (ccdc-output  ~CCDC_OUTPUT_PREVIEW)
+   return -EBUSY;
ccdc-output |= CCDC_OUTPUT_PREVIEW;
-   else
+   } else {
ccdc-output = ~CCDC_OUTPUT_PREVIEW;
+   }
break;
 
case CCDC_PAD_SOURCE_OF | (MEDIA_ENTITY_TYPE_NODE  16):
/* Write to memory */
-   if (flags  MEDIA_LINK_FLAG_ACTIVE)
+   if (flags  MEDIA_LINK_FLAG_ACTIVE) {
+   if (ccdc-output  ~CCDC_OUTPUT_MEMORY)
+   return -EBUSY;
ccdc-output |= CCDC_OUTPUT_MEMORY;
-   else
+   } else {
ccdc-output = ~CCDC_OUTPUT_MEMORY;
+   }
break;
 
case CCDC_PAD_SOURCE_OF | (MEDIA_ENTITY_TYPE_SUBDEV  16):
/* Write to resizer */
-   if (flags  MEDIA_LINK_FLAG_ACTIVE)
+   if (flags  MEDIA_LINK_FLAG_ACTIVE) {
+   if (ccdc-output  ~CCDC_OUTPUT_RESIZER)
+   return -EBUSY;
ccdc-output |= CCDC_OUTPUT_RESIZER;
-   else
+   } else {
ccdc-output = ~CCDC_OUTPUT_RESIZER;
+   }
break;
 
default:
diff --git a/drivers/media/video/isp/ispcsi2.c 
b/drivers/media/video/isp/ispcsi2.c
index 65c777a..8052b38 100644
--- a/drivers/media/video/isp/ispcsi2.c
+++ b/drivers/media/video/isp/ispcsi2.c
@@ -1088,19 +1088,30 @@ static int csi2_link_setup(struct media_entity *entity,
struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
struct isp_csi2_ctrl_cfg *ctrl = csi2-ctrl;
 
+   /*
+* This driver currently does not support pipeline with multiples
+* video outputs. It must return -EBUSY while it's not implemented.
+*/
+
switch (local-index | (remote-entity-type  16)) {
case CSI2_PAD_SOURCE | (MEDIA_ENTITY_TYPE_NODE  16):
-   if (flags  MEDIA_LINK_FLAG_ACTIVE)
+   if (flags  MEDIA_LINK_FLAG_ACTIVE) {
+   if (csi2-output  ~CSI2_OUTPUT_MEMORY)
+   return -EBUSY;
csi2-output |= CSI2_OUTPUT_MEMORY;
-   else
+   } else {
csi2-output = ~CSI2_OUTPUT_MEMORY;
+   }
break;
 
case CSI2_PAD_SOURCE | (MEDIA_ENTITY_TYPE_SUBDEV  16):
-   if (flags  MEDIA_LINK_FLAG_ACTIVE)
+   if (flags  MEDIA_LINK_FLAG_ACTIVE) {
+   if (csi2-output  ~CSI2_OUTPUT_MEMORY)
+   return -EBUSY;
csi2-output |= CSI2_OUTPUT_CCDC;
-   else
+   } else {
csi2-output = ~CSI2_OUTPUT_CCDC;
+   }
break;
 
default:
diff --git a/drivers/media/video/isp/isppreview.c 
b/drivers/media/video/isp/isppreview.c
index 6274b44..39d4da4 100644
--- a/drivers/media/video/isp/isppreview.c
+++ b/drivers/media/video/isp/isppreview.c
@@ -2026,20 +2026,31 @@ static int preview_link_setup(struct media_entity 
*entity,
}
break;
 
+   /*
+* This driver currently does not support pipeline with multiples
+* video outputs. It must return -EBUSY while it's not implemented.
+*/
+
case PREV_PAD_SOURCE | (MEDIA_ENTITY_TYPE_NODE  16):
/* write to memory */
-   if (flags  MEDIA_LINK_FLAG_ACTIVE)
+   if (flags  MEDIA_LINK_FLAG_ACTIVE) {
+   if (prev-output  

[PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Laurent Pinchart
Some buggy sensors generate corrupt frames when the stream is started.
This new operation returns the number of corrupt frames to skip when
starting the stream.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/media/v4l2-subdev.h |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 04878e1..b196966 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -291,9 +291,13 @@ struct v4l2_subdev_pad_ops {
  *   This is needed for some sensors, which always corrupt
  *   several top lines of the output image, or which send their
  *   metadata in them.
+ * @g_skip_frames: number of frames to skip at stream start. This is needed for
+ *buggy sensors that generate faulty frames when they are
+ *turned on.
  */
 struct v4l2_subdev_sensor_ops {
int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
+   int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
 };
 
 struct v4l2_subdev_ops {
-- 
1.7.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Translation faults with OMAP ISP

2010-11-19 Thread David Cohen
Hi Lane,

On Thu, Nov 18, 2010 at 12:17:21AM +0100, ext Lane Brooks wrote:
 On 11/17/2010 04:09 PM, Laurent Pinchart wrote:
  Hi Lane,
 
  On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:
  Laurent,
 
  I am getting iommu translation errors when I try to use the CCDC output
  after using the Resizer output.
 
  If I use the CCDC output to stream some video, then close it down,
  switch to the Resizer output and open it up and try to stream, I get the
  following errors spewing out:
 
  omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00 translation
  fault
  omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00 pgd:ce664034
  *pgd:
 
  and the select times out.
 
From a fresh boot, I can stream just fine from the Resizer and then
  switch to the CCDC output just fine. It is only when I go from the CCDC
  to the Resizer that I get this problem. Furthermore, when it gets into
  this state, then anything dev node I try to use has the translation
  errors and the only way to recover is to reboot.
 
  Any ideas on the problem?
  Ouch. First of all, could you please make sure you run the latest code ? 
  Many
  bugs have been fixed in the last few months
 
 I had a pretty good idea that this would be your response, but I was 
 hoping otherwise as merging has become more and more difficult to keep 
 up with. Anyway, until I have a chance to merge in everything, I just 
 found a work around for our usage needs, and that is to always use the 
 resizer output and just change the resizer format between full 
 resolution and preview resolution. This has turned out to be much more 
 stable than switching between the CCDC and RESIZER dev nodes.

I'm not sure if it's your case, but OMAP3 ISP driver does not support
pipeline with multiples outputs yet. We have to return error from the
driver in this case. If you configured CCDC to write to memory and then
to write to preview/resizer afterwards without deactivating the link to
write to memory, you may face a similar problem you described.

Can you please try a patch I've sent to you (CC'ing linux-media) with subject:
[omap3isp][PATCH] omap3isp: does not allow pipeline with multiple video
outputs yet?

Regards,

David


 
 Thanks again for your feedback.
 
 Lane
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [omap3isp][PATCH] omap3isp: does not allow pipeline with multiple video outputs yet

2010-11-19 Thread David Cohen
On Fri, Nov 19, 2010 at 02:23:54PM +0100, Cohen David (Nokia-MS/Helsinki) wrote:
 OMAP3 ISP driver does not support pipeline with multiple video outputs yet.
 Driver must return -EBUSY in this case.
 
 Signed-off-by: David Cohen david.co...@nokia.com
 ---
  drivers/media/video/isp/ispccdc.c|   26 --
  drivers/media/video/isp/ispcsi2.c|   19 +++
  drivers/media/video/isp/isppreview.c |   19 +++
  3 files changed, 50 insertions(+), 14 deletions(-)
 

[snip]

 diff --git a/drivers/media/video/isp/ispcsi2.c 
 b/drivers/media/video/isp/ispcsi2.c
 index 65c777a..8052b38 100644
 --- a/drivers/media/video/isp/ispcsi2.c
 +++ b/drivers/media/video/isp/ispcsi2.c
 @@ -1088,19 +1088,30 @@ static int csi2_link_setup(struct media_entity 
 *entity,
   struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
   struct isp_csi2_ctrl_cfg *ctrl = csi2-ctrl;
  
 + /*
 +  * This driver currently does not support pipeline with multiples
 +  * video outputs. It must return -EBUSY while it's not implemented.
 +  */
 +
   switch (local-index | (remote-entity-type  16)) {
   case CSI2_PAD_SOURCE | (MEDIA_ENTITY_TYPE_NODE  16):
 - if (flags  MEDIA_LINK_FLAG_ACTIVE)
 + if (flags  MEDIA_LINK_FLAG_ACTIVE) {
 + if (csi2-output  ~CSI2_OUTPUT_MEMORY)
 + return -EBUSY;
   csi2-output |= CSI2_OUTPUT_MEMORY;
 - else
 + } else {
   csi2-output = ~CSI2_OUTPUT_MEMORY;
 + }
   break;
  
   case CSI2_PAD_SOURCE | (MEDIA_ENTITY_TYPE_SUBDEV  16):
 - if (flags  MEDIA_LINK_FLAG_ACTIVE)
 + if (flags  MEDIA_LINK_FLAG_ACTIVE) {
 + if (csi2-output  ~CSI2_OUTPUT_MEMORY)

There is a typo here. Please, change ~CSI2_OUTPUT_MEMORY to ~CSI2_OUTPUT_CCDC
here before test it. I'll send a new version after get comments.

Br,

David Cohen

 + return -EBUSY;
   csi2-output |= CSI2_OUTPUT_CCDC;
 - else
 + } else {
   csi2-output = ~CSI2_OUTPUT_CCDC;
 + }
   break;
  
   default:
 diff --git a/drivers/media/video/isp/isppreview.c 
 b/drivers/media/video/isp/isppreview.c
 index 6274b44..39d4da4 100644
 --- a/drivers/media/video/isp/isppreview.c
 +++ b/drivers/media/video/isp/isppreview.c
 @@ -2026,20 +2026,31 @@ static int preview_link_setup(struct media_entity 
 *entity,
   }
   break;
  
 + /*
 +  * This driver currently does not support pipeline with multiples
 +  * video outputs. It must return -EBUSY while it's not implemented.
 +  */
 +
   case PREV_PAD_SOURCE | (MEDIA_ENTITY_TYPE_NODE  16):
   /* write to memory */
 - if (flags  MEDIA_LINK_FLAG_ACTIVE)
 + if (flags  MEDIA_LINK_FLAG_ACTIVE) {
 + if (prev-output  ~PREVIEW_OUTPUT_MEMORY)
 + return -EBUSY;
   prev-output |= PREVIEW_OUTPUT_MEMORY;
 - else
 + } else {
   prev-output = ~PREVIEW_OUTPUT_MEMORY;
 + }
   break;
  
   case PREV_PAD_SOURCE | (MEDIA_ENTITY_TYPE_SUBDEV  16):
   /* write to resizer */
 - if (flags  MEDIA_LINK_FLAG_ACTIVE)
 + if (flags  MEDIA_LINK_FLAG_ACTIVE) {
 + if (prev-output  ~PREVIEW_OUTPUT_RESIZER)
 + return -EBUSY;
   prev-output |= PREVIEW_OUTPUT_RESIZER;
 - else
 + } else {
   prev-output = ~PREVIEW_OUTPUT_RESIZER;
 + }
   break;
  
   default:
 -- 
 1.7.2.3
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Hans Verkuil
On Friday 19 November 2010 14:26:42 Laurent Pinchart wrote:
 Some buggy sensors generate corrupt frames when the stream is started.
 This new operation returns the number of corrupt frames to skip when
 starting the stream.

Looks OK, but perhaps the two should be combined to one function?

I also have my doubts about the sensor_ops in general. I expected originally
to see a lot of ops here, but apparently there is little or no need for it.

Do we expect to see this grow, or would it make more sense to move the ops
to video_ops? I'd be interested to hear what sensor specialists think.

Regards.

Hans

 
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  include/media/v4l2-subdev.h |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 
 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
 index 04878e1..b196966 100644
 --- a/include/media/v4l2-subdev.h
 +++ b/include/media/v4l2-subdev.h
 @@ -291,9 +291,13 @@ struct v4l2_subdev_pad_ops {
   * This is needed for some sensors, which always corrupt
   * several top lines of the output image, or which send their
   * metadata in them.
 + * @g_skip_frames: number of frames to skip at stream start. This is needed 
 for
 + *  buggy sensors that generate faulty frames when they are
 + *  turned on.
   */
  struct v4l2_subdev_sensor_ops {
   int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
 + int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
  };
  
  struct v4l2_subdev_ops {
 

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Guennadi Liakhovetski
On Fri, 19 Nov 2010, Laurent Pinchart wrote:

 Some buggy sensors generate corrupt frames when the stream is started.
 This new operation returns the number of corrupt frames to skip when
 starting the stream.
 
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  include/media/v4l2-subdev.h |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 
 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
 index 04878e1..b196966 100644
 --- a/include/media/v4l2-subdev.h
 +++ b/include/media/v4l2-subdev.h
 @@ -291,9 +291,13 @@ struct v4l2_subdev_pad_ops {
   * This is needed for some sensors, which always corrupt
   * several top lines of the output image, or which send their
   * metadata in them.
 + * @g_skip_frames: number of frames to skip at stream start. This is needed 
 for
 + *  buggy sensors that generate faulty frames when they are
 + *  turned on.
   */
  struct v4l2_subdev_sensor_ops {
   int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
 + int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);

Well, yes, this would be useful, but, I think, it is a part of a larger 
problem - general video quality from sensors. Like, I think, there are 
other situations, when the sensor driver knows, that the next few frames 
will be of poor quality. E.g., when changing some parameters, which will 
make the sensor re-adjust auto-exposure, auto-gain or something similar. 
So, we can either just handle this one specific case, or try to design a 
more generic approach, or leave frame quality analysis completely to the 
user-space. Like - for a normal generic mplayer, just streaming video to 
an output device - you don't really care in most cases. If recording video 
- you edit it afterwords, if building an industrial quality 
purpose-designed application - it will, probably, take care of these 
things itself. And yes, there is also out-of-band data, that can carry 
such quality-related information. So, this is just one bit of a bigger 
problem, no idea though, wheather it's worth trying to tackle all those 
issues at once or better just fix this one small specific problem.

  };
  
  struct v4l2_subdev_ops {
 -- 
 1.7.2.2

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Laurent Pinchart
Hi Hans,

On Friday 19 November 2010 14:42:31 Hans Verkuil wrote:
 On Friday 19 November 2010 14:26:42 Laurent Pinchart wrote:
  Some buggy sensors generate corrupt frames when the stream is started.
  This new operation returns the number of corrupt frames to skip when
  starting the stream.
 
 Looks OK, but perhaps the two should be combined to one function?

I'm fine with both. Guennadi, any opinion ?

 I also have my doubts about the sensor_ops in general. I expected
 originally to see a lot of ops here, but apparently there is little or no
 need for it.
 
 Do we expect to see this grow, or would it make more sense to move the ops
 to video_ops? I'd be interested to hear what sensor specialists think.

Good question. It won't remove the need for the g_skip_frames operation, but 
it's certainly worth asking. Standards are emerging for sensors in specific 
markets (SMIA comes to mind - I'm not sure if the spec is public, but some 
information can be found online) and there will probably be a need to provide 
more sensor information to both bridge drivers and userspace applications in 
the future.

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Guennadi Liakhovetski
On Fri, 19 Nov 2010, Hans Verkuil wrote:

 On Friday 19 November 2010 14:26:42 Laurent Pinchart wrote:
  Some buggy sensors generate corrupt frames when the stream is started.
  This new operation returns the number of corrupt frames to skip when
  starting the stream.
 
 Looks OK, but perhaps the two should be combined to one function?
 
 I also have my doubts about the sensor_ops in general. I expected originally
 to see a lot of ops here, but apparently there is little or no need for it.
 
 Do we expect to see this grow, or would it make more sense to move the ops
 to video_ops? I'd be interested to hear what sensor specialists think.

I would keep the struct.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Laurent Pinchart
Hi Guennadi,

On Friday 19 November 2010 14:49:44 Guennadi Liakhovetski wrote:
 On Fri, 19 Nov 2010, Laurent Pinchart wrote:
  Some buggy sensors generate corrupt frames when the stream is started.
  This new operation returns the number of corrupt frames to skip when
  starting the stream.
  
  Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
  ---
  
   include/media/v4l2-subdev.h |4 
   1 files changed, 4 insertions(+), 0 deletions(-)
  
  diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
  index 04878e1..b196966 100644
  --- a/include/media/v4l2-subdev.h
  +++ b/include/media/v4l2-subdev.h
  @@ -291,9 +291,13 @@ struct v4l2_subdev_pad_ops {
  
*   This is needed for some sensors, which always corrupt
*   several top lines of the output image, or which send their
*   metadata in them.
  
  + * @g_skip_frames: number of frames to skip at stream start. This is
  needed for + * buggy sensors that generate faulty frames 
  when they
  are + *turned on.
  
*/
   
   struct v4l2_subdev_sensor_ops {
   
  int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
  
  +   int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
 
 Well, yes, this would be useful, but, I think, it is a part of a larger
 problem - general video quality from sensors. Like, I think, there are
 other situations, when the sensor driver knows, that the next few frames
 will be of poor quality. E.g., when changing some parameters, which will
 make the sensor re-adjust auto-exposure, auto-gain or something similar.
 So, we can either just handle this one specific case, or try to design a
 more generic approach, or leave frame quality analysis completely to the
 user-space. Like - for a normal generic mplayer, just streaming video to
 an output device - you don't really care in most cases. If recording video
 - you edit it afterwords, if building an industrial quality
 purpose-designed application - it will, probably, take care of these
 things itself. And yes, there is also out-of-band data, that can carry
 such quality-related information. So, this is just one bit of a bigger
 problem, no idea though, wheather it's worth trying to tackle all those
 issues at once or better just fix this one small specific problem.

Lots of different issues there. Quality handling should be implemented in 
userspace, but drivers need to provide enough information to 
applications/libraries. Metadata could be bundled with frame using the recent 
multiplane formats support infrastructure.

The purpose of this operation is to skip frames that are know to be real bad. 
Think of a buggy sensor that outputs a frame of complete garbage when you 
start the stream. Not just bad quality data, but real garbage (either random 
or a flat color).

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Translation faults with OMAP ISP

2010-11-19 Thread Lane Brooks

On 11/19/2010 06:29 AM, David Cohen wrote:

On Thu, Nov 18, 2010 at 12:17:21AM +0100, ext Lane Brooks wrote:

On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:

Laurent,

I am getting iommu translation errors when I try to use the CCDC output
after using the Resizer output.

If I use the CCDC output to stream some video, then close it down,
switch to the Resizer output and open it up and try to stream, I get the
following errors spewing out:

omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00 translation
fault
omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00 pgd:ce664034
*pgd:

and the select times out.

   From a fresh boot, I can stream just fine from the Resizer and then
switch to the CCDC output just fine. It is only when I go from the CCDC
to the Resizer that I get this problem. Furthermore, when it gets into
this state, then anything dev node I try to use has the translation
errors and the only way to recover is to reboot.

Any ideas on the problem?

I'm not sure if it's your case, but OMAP3 ISP driver does not support
pipeline with multiples outputs yet. We have to return error from the
driver in this case. If you configured CCDC to write to memory and then
to write to preview/resizer afterwards without deactivating the link to
write to memory, you may face a similar problem you described.

Can you please try a patch I've sent to you (CC'ing linux-media) with subject:
[omap3isp][PATCH] omap3isp: does not allow pipeline with multiple video
outputs yet?

Regards,

David

David,

I am not trying to use multiple outputs simultaneously. I get the 
translation error with the following sequence:


- Open resizer output and setup media links.
- Stream some images.
- Close resizer.
- Reset all media links.
- Open CCDC and setup media links.
- Try to stream some images but get translation faults.

Is your patch going to help with this problem?

Lane
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Translation faults with OMAP ISP

2010-11-19 Thread Laurent Pinchart
Hi Lane,

On Friday 19 November 2010 15:08:38 Lane Brooks wrote:
 On 11/19/2010 06:29 AM, David Cohen wrote:
  On Thu, Nov 18, 2010 at 12:17:21AM +0100, ext Lane Brooks wrote:
  On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:
  Laurent,
  
  I am getting iommu translation errors when I try to use the CCDC
  output after using the Resizer output.
  
  If I use the CCDC output to stream some video, then close it down,
  switch to the Resizer output and open it up and try to stream, I get
  the following errors spewing out:
  
  omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00
  translation fault
  omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00 pgd:ce664034
  *pgd:
  
  and the select times out.
  
 From a fresh boot, I can stream just fine from the Resizer and then
  
  switch to the CCDC output just fine. It is only when I go from the
  CCDC to the Resizer that I get this problem. Furthermore, when it
  gets into this state, then anything dev node I try to use has the
  translation errors and the only way to recover is to reboot.
  
  Any ideas on the problem?
  
  I'm not sure if it's your case, but OMAP3 ISP driver does not support
  pipeline with multiples outputs yet. We have to return error from the
  driver in this case. If you configured CCDC to write to memory and then
  to write to preview/resizer afterwards without deactivating the link to
  write to memory, you may face a similar problem you described.
  
  Can you please try a patch I've sent to you (CC'ing linux-media) with
  subject: [omap3isp][PATCH] omap3isp: does not allow pipeline with
  multiple video outputs yet?
  
  Regards,
  
  David
 
 David,
 
 I am not trying to use multiple outputs simultaneously. I get the
 translation error with the following sequence:
 
 - Open resizer output and setup media links.
 - Stream some images.
 - Close resizer.
 - Reset all media links.
 - Open CCDC and setup media links.
 - Try to stream some images but get translation faults.
 
 Is your patch going to help with this problem?

If you reset all links before setting them up for the CCDC output, probably 
not (unless you have a bug in your CCDC links setup, but I doubt that).

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Guennadi Liakhovetski
On Fri, 19 Nov 2010, Laurent Pinchart wrote:

 Hi Hans,
 
 On Friday 19 November 2010 14:42:31 Hans Verkuil wrote:
  On Friday 19 November 2010 14:26:42 Laurent Pinchart wrote:
   Some buggy sensors generate corrupt frames when the stream is started.
   This new operation returns the number of corrupt frames to skip when
   starting the stream.
  
  Looks OK, but perhaps the two should be combined to one function?
 
 I'm fine with both. Guennadi, any opinion ?

Same as before;) I think, there can be many more such micro parameters, 
that we'll want to collect from the sensor. So, if we had a good idea - 
what those parameters are like, we could implement just one API call to 
get them all, or even just pass one object with this information - if it 
is constant. If we don't have a good idea yet, what to expect there, it 
might be best to wait and first collect a more complete understanding of 
this kind of information. In any case I wouldn't convert these two calls 
to one like

int (*get_bad_things)(struct v4l2_subdev *sd, u32 *lines, u32 *frames)

;)

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Translation faults with OMAP ISP

2010-11-19 Thread Lane Brooks

On 11/19/2010 07:13 AM, Laurent Pinchart wrote:

On Friday 19 November 2010 15:08:38 Lane Brooks wrote:

On 11/19/2010 06:29 AM, David Cohen wrote:

On Thu, Nov 18, 2010 at 12:17:21AM +0100, ext Lane Brooks wrote:

On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:

Laurent,

I am getting iommu translation errors when I try to use the CCDC
output after using the Resizer output.

If I use the CCDC output to stream some video, then close it down,
switch to the Resizer output and open it up and try to stream, I get
the following errors spewing out:

omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00
translation fault
omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00 pgd:ce664034
*pgd:

and the select times out.

From a fresh boot, I can stream just fine from the Resizer and then

switch to the CCDC output just fine. It is only when I go from the
CCDC to the Resizer that I get this problem. Furthermore, when it
gets into this state, then anything dev node I try to use has the
translation errors and the only way to recover is to reboot.

Any ideas on the problem?

I'm not sure if it's your case, but OMAP3 ISP driver does not support
pipeline with multiples outputs yet. We have to return error from the
driver in this case. If you configured CCDC to write to memory and then
to write to preview/resizer afterwards without deactivating the link to
write to memory, you may face a similar problem you described.

Can you please try a patch I've sent to you (CC'ing linux-media) with
subject: [omap3isp][PATCH] omap3isp: does not allow pipeline with
multiple video outputs yet?

Regards,

David

David,

I am not trying to use multiple outputs simultaneously. I get the
translation error with the following sequence:

- Open resizer output and setup media links.
- Stream some images.
- Close resizer.
- Reset all media links.
- Open CCDC and setup media links.
- Try to stream some images but get translation faults.

Is your patch going to help with this problem?

If you reset all links before setting them up for the CCDC output, probably
not (unless you have a bug in your CCDC links setup, but I doubt that).
I can stream just fine from the CCDC output if I do not use the resizer 
prior, so I am pretty sure I am setting up the CCDC links correctly.


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Hans Verkuil
On Friday 19 November 2010 15:15:11 Guennadi Liakhovetski wrote:
 On Fri, 19 Nov 2010, Laurent Pinchart wrote:
 
  Hi Hans,
  
  On Friday 19 November 2010 14:42:31 Hans Verkuil wrote:
   On Friday 19 November 2010 14:26:42 Laurent Pinchart wrote:
Some buggy sensors generate corrupt frames when the stream is started.
This new operation returns the number of corrupt frames to skip when
starting the stream.
   
   Looks OK, but perhaps the two should be combined to one function?
  
  I'm fine with both. Guennadi, any opinion ?
 
 Same as before;) I think, there can be many more such micro parameters, 
 that we'll want to collect from the sensor. So, if we had a good idea - 
 what those parameters are like, we could implement just one API call to 
 get them all, or even just pass one object with this information - if it 
 is constant. If we don't have a good idea yet, what to expect there, it 
 might be best to wait and first collect a more complete understanding of 
 this kind of information. In any case I wouldn't convert these two calls 
 to one like
 
 int (*get_bad_things)(struct v4l2_subdev *sd, u32 *lines, u32 *frames)
 
 ;)

OK, let's go with Laurent's proposal. But I do think this should be reviewed
at some point in time.

Regards,

Hans

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC] v4l: Add subdev sensor g_skip_frames operation

2010-11-19 Thread Laurent Pinchart
Hi Guennadi,

On Friday 19 November 2010 15:15:11 Guennadi Liakhovetski wrote:
 On Fri, 19 Nov 2010, Laurent Pinchart wrote:
  On Friday 19 November 2010 14:42:31 Hans Verkuil wrote:
   On Friday 19 November 2010 14:26:42 Laurent Pinchart wrote:
Some buggy sensors generate corrupt frames when the stream is
started. This new operation returns the number of corrupt frames to
skip when starting the stream.
   
   Looks OK, but perhaps the two should be combined to one function?
  
  I'm fine with both. Guennadi, any opinion ?
 
 Same as before;) I think, there can be many more such micro parameters,
 that we'll want to collect from the sensor. So, if we had a good idea -
 what those parameters are like, we could implement just one API call to
 get them all, or even just pass one object with this information - if it
 is constant. If we don't have a good idea yet, what to expect there, it
 might be best to wait and first collect a more complete understanding of
 this kind of information.

I agree.

 In any case I wouldn't convert these two calls
 to one like
 
 int (*get_bad_things)(struct v4l2_subdev *sd, u32 *lines, u32 *frames)
 
 ;)

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] v4l: Include linux/videodev2.h in media/v4l2-ctrls.h

2010-11-19 Thread Laurent Pinchart
The later makes extensive use of structures defined in the former.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/media/v4l2-ctrls.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 9b7bea9..3b133b7 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -23,6 +23,7 @@
 
 #include linux/list.h
 #include linux/device.h
+#include linux/videodev2.h
 
 /* forward references */
 struct v4l2_ctrl_handler;
-- 
1.7.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Translation faults with OMAP ISP

2010-11-19 Thread David Cohen
On Fri, Nov 19, 2010 at 03:16:41PM +0100, ext Lane Brooks wrote:
 On 11/19/2010 07:13 AM, Laurent Pinchart wrote:
  On Friday 19 November 2010 15:08:38 Lane Brooks wrote:
  On 11/19/2010 06:29 AM, David Cohen wrote:
  On Thu, Nov 18, 2010 at 12:17:21AM +0100, ext Lane Brooks wrote:
  On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:
  Laurent,
 
  I am getting iommu translation errors when I try to use the CCDC
  output after using the Resizer output.
 
  If I use the CCDC output to stream some video, then close it down,
  switch to the Resizer output and open it up and try to stream, I get
  the following errors spewing out:
 
  omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00
  translation fault
  omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00 pgd:ce664034
  *pgd:
 
  and the select times out.
 
  From a fresh boot, I can stream just fine from the Resizer and then
 
  switch to the CCDC output just fine. It is only when I go from the
  CCDC to the Resizer that I get this problem. Furthermore, when it
  gets into this state, then anything dev node I try to use has the
  translation errors and the only way to recover is to reboot.
 
  Any ideas on the problem?
  I'm not sure if it's your case, but OMAP3 ISP driver does not support
  pipeline with multiples outputs yet. We have to return error from the
  driver in this case. If you configured CCDC to write to memory and then
  to write to preview/resizer afterwards without deactivating the link to
  write to memory, you may face a similar problem you described.
 
  Can you please try a patch I've sent to you (CC'ing linux-media) with
  subject: [omap3isp][PATCH] omap3isp: does not allow pipeline with
  multiple video outputs yet?
 
  Regards,
 
  David
  David,
 
  I am not trying to use multiple outputs simultaneously. I get the
  translation error with the following sequence:
 
  - Open resizer output and setup media links.
  - Stream some images.
  - Close resizer.
  - Reset all media links.
  - Open CCDC and setup media links.
  - Try to stream some images but get translation faults.

You're describing some different steps from your previous e-mail, as
here the iommu faults come while CCDC outputting to memory and in your
comment above it was happening while Resizer outputting to memory.

Which one should I consider as the correct? :)

It would be nice if you could print the values of CCDC_SDR_ADDR and
RSZ_SDR_OUTADD just before the bug.

Are you also enabling CCDC's LSC?

 
  Is your patch going to help with this problem?
  If you reset all links before setting them up for the CCDC output, probably
  not (unless you have a bug in your CCDC links setup, but I doubt that).

As Laurent said, probably not. But if you want to go ahead to test this
patch, that's fine. It's very unlikely we have a bug on CCDC or Resizer
link setup, but not completely impossible. :)
A new version of this patch fixing the typo I mentioned there is going to be
locally applied anyway.

 I can stream just fine from the CCDC output if I do not use the resizer 
 prior, so I am pretty sure I am setting up the CCDC links correctly.

Well, iommu faults mean bug on kernel side. If you're still doing
something wrong, the driver must be able to return and error to
userland.

Regards,

David

 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Translation faults with OMAP ISP

2010-11-19 Thread Laurent Pinchart
Hi David,

On Friday 19 November 2010 16:06:21 David Cohen wrote:
 On Fri, Nov 19, 2010 at 03:16:41PM +0100, ext Lane Brooks wrote:
  On 11/19/2010 07:13 AM, Laurent Pinchart wrote:
   On Friday 19 November 2010 15:08:38 Lane Brooks wrote:
   On 11/19/2010 06:29 AM, David Cohen wrote:
   On Thu, Nov 18, 2010 at 12:17:21AM +0100, ext Lane Brooks wrote:
   On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:
   Laurent,
   
   I am getting iommu translation errors when I try to use the CCDC
   output after using the Resizer output.
   
   If I use the CCDC output to stream some video, then close it down,
   switch to the Resizer output and open it up and try to stream, I
   get the following errors spewing out:
   
   omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00
   translation fault
   omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00
   pgd:ce664034 *pgd:
   
   and the select times out.
   
   From a fresh boot, I can stream just fine from the Resizer and
   then
   
   switch to the CCDC output just fine. It is only when I go from the
   CCDC to the Resizer that I get this problem. Furthermore, when it
   gets into this state, then anything dev node I try to use has the
   translation errors and the only way to recover is to reboot.
   
   Any ideas on the problem?
   
   I'm not sure if it's your case, but OMAP3 ISP driver does not support
   pipeline with multiples outputs yet. We have to return error from the
   driver in this case. If you configured CCDC to write to memory and
   then to write to preview/resizer afterwards without deactivating the
   link to write to memory, you may face a similar problem you
   described.
   
   Can you please try a patch I've sent to you (CC'ing linux-media) with
   subject: [omap3isp][PATCH] omap3isp: does not allow pipeline with
   multiple video outputs yet?
   
   Regards,
   
   David
   
   David,
   
   I am not trying to use multiple outputs simultaneously. I get the
   translation error with the following sequence:
   
   - Open resizer output and setup media links.
   - Stream some images.
   - Close resizer.
   - Reset all media links.
   - Open CCDC and setup media links.
   - Try to stream some images but get translation faults.
 
 You're describing some different steps from your previous e-mail, as
 here the iommu faults come while CCDC outputting to memory and in your
 comment above it was happening while Resizer outputting to memory.
 
 Which one should I consider as the correct? :)
 
 It would be nice if you could print the values of CCDC_SDR_ADDR and
 RSZ_SDR_OUTADD just before the bug.
 
 Are you also enabling CCDC's LSC?
 
   Is your patch going to help with this problem?
   
   If you reset all links before setting them up for the CCDC output,
   probably not (unless you have a bug in your CCDC links setup, but I
   doubt that).
 
 As Laurent said, probably not. But if you want to go ahead to test this
 patch, that's fine. It's very unlikely we have a bug on CCDC or Resizer
 link setup, but not completely impossible. :)
 A new version of this patch fixing the typo I mentioned there is going to
 be locally applied anyway.
 
  I can stream just fine from the CCDC output if I do not use the resizer
  prior, so I am pretty sure I am setting up the CCDC links correctly.
 
 Well, iommu faults mean bug on kernel side. If you're still doing
 something wrong, the driver must be able to return and error to
 userland.

Don't forget that Lane is using an older version of the OMAP3 ISP driver. The 
bug might have been fixed in the latest code.

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Translation faults with OMAP ISP

2010-11-19 Thread David Cohen
On Fri, Nov 19, 2010 at 04:07:27PM +0100, ext Laurent Pinchart wrote:
 Hi David,
 
 On Friday 19 November 2010 16:06:21 David Cohen wrote:
  On Fri, Nov 19, 2010 at 03:16:41PM +0100, ext Lane Brooks wrote:
   On 11/19/2010 07:13 AM, Laurent Pinchart wrote:
On Friday 19 November 2010 15:08:38 Lane Brooks wrote:
On 11/19/2010 06:29 AM, David Cohen wrote:
On Thu, Nov 18, 2010 at 12:17:21AM +0100, ext Lane Brooks wrote:
On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:
Laurent,

I am getting iommu translation errors when I try to use the CCDC
output after using the Resizer output.

If I use the CCDC output to stream some video, then close it down,
switch to the Resizer output and open it up and try to stream, I
get the following errors spewing out:

omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00
translation fault
omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00
pgd:ce664034 *pgd:

and the select times out.

From a fresh boot, I can stream just fine from the Resizer and
then

switch to the CCDC output just fine. It is only when I go from the
CCDC to the Resizer that I get this problem. Furthermore, when it
gets into this state, then anything dev node I try to use has the
translation errors and the only way to recover is to reboot.

Any ideas on the problem?

I'm not sure if it's your case, but OMAP3 ISP driver does not support
pipeline with multiples outputs yet. We have to return error from the
driver in this case. If you configured CCDC to write to memory and
then to write to preview/resizer afterwards without deactivating the
link to write to memory, you may face a similar problem you
described.

Can you please try a patch I've sent to you (CC'ing linux-media) with
subject: [omap3isp][PATCH] omap3isp: does not allow pipeline with
multiple video outputs yet?

Regards,

David

David,

I am not trying to use multiple outputs simultaneously. I get the
translation error with the following sequence:

- Open resizer output and setup media links.
- Stream some images.
- Close resizer.
- Reset all media links.
- Open CCDC and setup media links.
- Try to stream some images but get translation faults.
  
  You're describing some different steps from your previous e-mail, as
  here the iommu faults come while CCDC outputting to memory and in your
  comment above it was happening while Resizer outputting to memory.
  
  Which one should I consider as the correct? :)
  
  It would be nice if you could print the values of CCDC_SDR_ADDR and
  RSZ_SDR_OUTADD just before the bug.
  
  Are you also enabling CCDC's LSC?
  
Is your patch going to help with this problem?

If you reset all links before setting them up for the CCDC output,
probably not (unless you have a bug in your CCDC links setup, but I
doubt that).
  
  As Laurent said, probably not. But if you want to go ahead to test this
  patch, that's fine. It's very unlikely we have a bug on CCDC or Resizer
  link setup, but not completely impossible. :)
  A new version of this patch fixing the typo I mentioned there is going to
  be locally applied anyway.
  
   I can stream just fine from the CCDC output if I do not use the resizer
   prior, so I am pretty sure I am setting up the CCDC links correctly.
  
  Well, iommu faults mean bug on kernel side. If you're still doing
  something wrong, the driver must be able to return and error to
  userland.
 
 Don't forget that Lane is using an older version of the OMAP3 ISP driver. The 
 bug might have been fixed in the latest code.

Hm. We did fix some iommu faults.
Maybe it's better to test a newer version instead.
If you still see that bug using an up-to-date version, please report it
and I can try to help you. :)

Regards,

David

 
 -- 
 Regards,
 
 Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [omap3isp][PATCH v2 8/9] omap3isp: ccp2: Make SYSCONFIG fields consistent

2010-11-19 Thread Aguirre, Sergio

 -Original Message-
 From: David Cohen [mailto:david.co...@nokia.com]
 Sent: Friday, November 19, 2010 4:06 AM
 To: Aguirre, Sergio
 Cc: Laurent Pinchart; linux-media@vger.kernel.org
 Subject: Re: [omap3isp][PATCH v2 8/9] omap3isp: ccp2: Make SYSCONFIG
 fields consistent
 
 Hi Sergio,

Hi David,

Thanks for the review.

 
 I've few comments below.
 
 On Mon, Nov 15, 2010 at 03:30:00PM +0100, ext Sergio Aguirre wrote:
  Signed-off-by: Sergio Aguirre saagui...@ti.com
  ---
   drivers/media/video/isp/ispccp2.c |3 +--
   drivers/media/video/isp/ispreg.h  |   14 --
   2 files changed, 9 insertions(+), 8 deletions(-)
 
  diff --git a/drivers/media/video/isp/ispccp2.c
 b/drivers/media/video/isp/ispccp2.c
  index fa23394..3127a74 100644
  --- a/drivers/media/video/isp/ispccp2.c
  +++ b/drivers/media/video/isp/ispccp2.c
  @@ -419,8 +419,7 @@ static void ispccp2_mem_configure(struct
 isp_ccp2_device *ccp2,
  config-src_ofst = 0;
  }
 
  -   isp_reg_writel(isp, (ISPCSI1_MIDLEMODE_SMARTSTANDBY 
  -  ISPCSI1_MIDLEMODE_SHIFT),
  +   isp_reg_writel(isp, ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SMART,
 OMAP3_ISP_IOMEM_CCP2, ISPCCP2_SYSCONFIG);
 
 To make your cleanup even better, you could change isp_reg_clr_set()
 instead.
 If CCP2 MSTANDY_MODE is set to NOSTANDY, the result is going to be an
 invalid 0x3 value. Despite it cannot happen with the current code, it's
 still better to avoid such situations for future versions. :)

Hmm you're right, I guess I didn't do any real functional changes, just defines 
renaming.

I can repost an updated patch with this suggestion. No problem.

 
 
  /* Hsize, Skip */
  diff --git a/drivers/media/video/isp/ispreg.h
 b/drivers/media/video/isp/ispreg.h
  index d885541..9b0d3ad 100644
  --- a/drivers/media/video/isp/ispreg.h
  +++ b/drivers/media/video/isp/ispreg.h
  @@ -141,6 +141,14 @@
   #define ISPCCP2_REVISION   (0x000)
   #define ISPCCP2_SYSCONFIG  (0x004)
   #define ISPCCP2_SYSCONFIG_SOFT_RESET   (1  1)
  +#define ISPCCP2_SYSCONFIG_AUTO_IDLE0x1
  +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT  12
  +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_FORCE  \
  +   (0x0  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
  +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_NO \
  +   (0x1  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
  +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SMART  \
  +   (0x2  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
 
 You can add some ISPCCP2_SYSCONFIG_MSTANDY_MODE_MASK, as 2 bits must be
 always set together.

Sure, will do.

Thanks and Regards,
Sergio

 
 Regards,
 
 David Cohen
 
   #define ISPCCP2_SYSSTATUS  (0x008)
   #define ISPCCP2_SYSSTATUS_RESET_DONE   (1  0)
   #define ISPCCP2_LC01_IRQENABLE (0x00C)
  @@ -1309,12 +1317,6 @@
   #define ISPMMU_SIDLEMODE_SMARTIDLE 2
   #define ISPMMU_SIDLEMODE_SHIFT 3
 
  -#define ISPCSI1_AUTOIDLE   0x1
  -#define ISPCSI1_MIDLEMODE_SHIFT12
  -#define ISPCSI1_MIDLEMODE_FORCESTANDBY 0x0
  -#define ISPCSI1_MIDLEMODE_NOSTANDBY0x1
  -#define ISPCSI1_MIDLEMODE_SMARTSTANDBY 0x2
  -
   /* 
 -
* CSI2 receiver registers (ES2.0)
*/
  --
  1.7.0.4
 
  --
  To unsubscribe from this list: send the line unsubscribe linux-media
 in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [omap3isp][PATCH v2 7/9] omap3isp: Cleanup isp_power_settings

2010-11-19 Thread Aguirre, Sergio


 -Original Message-
 From: David Cohen [mailto:david.co...@nokia.com]
 Sent: Friday, November 19, 2010 4:18 AM
 To: Aguirre, Sergio
 Cc: Laurent Pinchart; linux-media@vger.kernel.org
 Subject: Re: [omap3isp][PATCH v2 7/9] omap3isp: Cleanup isp_power_settings
 
 Hi Sergio,
 
 Thanks for the patch.

Hi David,

Thanks for the comments.

 
 On Mon, Nov 15, 2010 at 03:29:59PM +0100, ext Sergio Aguirre wrote:
  1. Get rid of CSI2 / CCP2 power settings, as they are controlled
 in the receivers code anyways.
 
 CCP2 is not correctly handling this. It's setting SMART STANDBY mode one
 when reading from memory. You should fix it before remove such code from
 ISP core driver.

Ok, agreed.

I'll generate a new patch before this to compensate that. Not a problem.

 
  2. Avoid code duplication.
 
 Agree. But only after considering the comment above.

Ok.

Thanks and Regards,
Sergio

 
 Regards,
 
 David
 
 
  Signed-off-by: Sergio Aguirre saagui...@ti.com
  ---
   drivers/media/video/isp/isp.c |   49 ++
 ---
   1 files changed, 7 insertions(+), 42 deletions(-)
 
  diff --git a/drivers/media/video/isp/isp.c
 b/drivers/media/video/isp/isp.c
  index de9352b..30bdc48 100644
  --- a/drivers/media/video/isp/isp.c
  +++ b/drivers/media/video/isp/isp.c
  @@ -254,48 +254,13 @@ EXPORT_SYMBOL(isp_set_xclk);
*/
   static void isp_power_settings(struct isp_device *isp, int idle)
   {
  -   if (idle) {
  -   isp_reg_writel(isp,
  -  (ISP_SYSCONFIG_MIDLEMODE_SMARTSTANDBY 
  -   ISP_SYSCONFIG_MIDLEMODE_SHIFT),
  -  OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
  -   if (omap_rev() == OMAP3430_REV_ES1_0) {
  -   isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
  -  (ISPCSI1_MIDLEMODE_SMARTSTANDBY 
  -   ISPCSI1_MIDLEMODE_SHIFT),
  -  OMAP3_ISP_IOMEM_CSI2A_REGS1,
  -  ISPCSI2_SYSCONFIG);
  -   isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
  -  (ISPCSI1_MIDLEMODE_SMARTSTANDBY 
  -   ISPCSI1_MIDLEMODE_SHIFT),
  -  OMAP3_ISP_IOMEM_CCP2,
  -  ISPCCP2_SYSCONFIG);
  -   }
  -   isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE,
 OMAP3_ISP_IOMEM_MAIN,
  -  ISP_CTRL);
  -
  -   } else {
  -   isp_reg_writel(isp,
  -  (ISP_SYSCONFIG_MIDLEMODE_FORCESTANDBY 
  -   ISP_SYSCONFIG_MIDLEMODE_SHIFT),
  -  OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
  -   if (omap_rev() == OMAP3430_REV_ES1_0) {
  -   isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
  -  (ISPCSI1_MIDLEMODE_FORCESTANDBY 
  -   ISPCSI1_MIDLEMODE_SHIFT),
  -  OMAP3_ISP_IOMEM_CSI2A_REGS1,
  -  ISPCSI2_SYSCONFIG);
  -
  -   isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
  -  (ISPCSI1_MIDLEMODE_FORCESTANDBY 
  -   ISPCSI1_MIDLEMODE_SHIFT),
  -  OMAP3_ISP_IOMEM_CCP2,
  -  ISPCCP2_SYSCONFIG);
  -   }
  -
  -   isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE,
 OMAP3_ISP_IOMEM_MAIN,
  -  ISP_CTRL);
  -   }
  +   isp_reg_writel(isp,
  +  ((idle ? ISP_SYSCONFIG_MIDLEMODE_SMARTSTANDBY :
  +   ISP_SYSCONFIG_MIDLEMODE_FORCESTANDBY) 
  +   ISP_SYSCONFIG_MIDLEMODE_SHIFT),
  +  OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
  +   isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE, OMAP3_ISP_IOMEM_MAIN,
  +  ISP_CTRL);
   }
 
   /*
  --
  1.7.0.4
 
  --
  To unsubscribe from this list: send the line unsubscribe linux-media
 in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [omap3isp][PATCH v2 5/9] omap3isp: Remove unused CBUFF register access

2010-11-19 Thread Aguirre, Sergio
Hi Laurent and David,

 -Original Message-
 From: Laurent Pinchart [mailto:laurent.pinch...@ideasonboard.com]
 Sent: Friday, November 19, 2010 4:33 AM
 To: David Cohen
 Cc: Aguirre, Sergio; linux-media@vger.kernel.org
 Subject: Re: [omap3isp][PATCH v2 5/9] omap3isp: Remove unused CBUFF
 register access
 
 Hi David,
 
 On Friday 19 November 2010 11:19:44 David Cohen wrote:
  On Mon, Nov 15, 2010 at 03:29:57PM +0100, ext Sergio Aguirre wrote:
 
 [snip]
 
   @@ -244,26 +239,6 @@
  
#define ISP_CSIB_SYSCONFIG   ISPCCP2_SYSCONFIG
#define ISP_CSIA_SYSCONFIG   ISPCSI2_SYSCONFIG
  
   -/* ISP_CBUFF Registers */
   -
   -#define ISP_CBUFF_SYSCONFIG  (0x010)
   -#define ISP_CBUFF_IRQENABLE  (0x01C)
   -
   -#define ISP_CBUFF0_CTRL  (0x020)
   -#define ISP_CBUFF1_CTRL  (0x024)
   -
   -#define ISP_CBUFF0_START (0x040)
   -#define ISP_CBUFF1_START (0x044)
   -
   -#define ISP_CBUFF0_END   (0x050)
   -#define ISP_CBUFF1_END   (0x054)
   -
   -#define ISP_CBUFF0_WINDOWSIZE(0x060)
   -#define ISP_CBUFF1_WINDOWSIZE(0x064)
   -
   -#define ISP_CBUFF0_THRESHOLD (0x070)
   -#define ISP_CBUFF1_THRESHOLD (0x074)
   -
 
  No need to remove the registers from header file. We're not using them
  on current version, but it doesn't mean we won't use ever. :)
 
 I would have made the same comment for other registers, but we're not
 using
 the CBUFF module at all here, with no plans to use it in the future. It
 might
 not be worth it keeping the register definitions. I have no strong feeling
 about it, I'm fine with both choices.

David,

IMO, we should not introduce dead code/unusued defines in the first omap3isp
upstream version. I think it's already quite hard to review for somebody
outside the omap3isp development team.

Having all this just in case will most probably end up in bulk, as we
might never implement the CBUFF HW block, as Laurent mentions.

I'll be more biased on all this being re-added if we end up implementing a 
ispcbuff submodule.

Regards,
Sergio


 
 --
 Regards,
 
 Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] v4l: videobuf2: add generic memory handling routines

2010-11-19 Thread Marek Szyprowski
From: Pawel Osciak p.osc...@samsung.com

Add generic memory handling routines for userspace pointer handling,
contiguous memory verification and mapping.

Signed-off-by: Pawel Osciak p.osc...@samsung.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
CC: Pawel Osciak pa...@osciak.com
---
 drivers/media/video/Kconfig|3 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/videobuf2-memops.c |  199 
 include/media/videobuf2-memops.h   |   31 +
 4 files changed, 234 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-memops.c
 create mode 100644 include/media/videobuf2-memops.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index fef6a14..83ce858 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -52,6 +52,9 @@ config V4L2_MEM2MEM_DEV
 config VIDEOBUF2_CORE
tristate
 
+config VIDEOBUF2_MEMOPS
+   tristate
+
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 77c4f85..a97a2a0 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_VIDEOBUF_DVB) += videobuf-dvb.o
 obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 
 obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
+obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-memops.c 
b/drivers/media/video/videobuf2-memops.c
new file mode 100644
index 000..67ebdff
--- /dev/null
+++ b/drivers/media/video/videobuf2-memops.c
@@ -0,0 +1,199 @@
+/*
+ * videobuf2-memops.c - generic memory handling routines for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak p.osc...@samsung.com
+ *Marek Szyprowski m.szyprow...@samsung.com
+ *
+ * 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.
+ */
+
+#include linux/slab.h
+#include linux/module.h
+#include linux/dma-mapping.h
+#include linux/vmalloc.h
+#include linux/cma.h
+#include linux/mm.h
+#include linux/sched.h
+#include linux/file.h
+
+#include media/videobuf2-core.h
+
+/**
+ * vb2_contig_verify_userptr() - verify contiguity of a userspace-mapped memory
+ * @vma:   virtual memory region which maps the physical memory
+ * to be verified
+ * @vaddr: starting virtual address of the area to be verified
+ * @size:  size of the area to be verified
+ * @paddr: will return physical address for the given vaddr
+ *
+ * This function will go through memory area of size size mapped at vaddr and
+ * verify that the underlying physical pages are contiguous.
+ *
+ * Returns 0 on success and a physical address to the memory pointed
+ * to by vaddr in paddr.
+ */
+int vb2_contig_verify_userptr(struct vm_area_struct *vma,
+   unsigned long vaddr, unsigned long size,
+   unsigned long *paddr)
+{
+   struct mm_struct *mm = current-mm;
+   unsigned long offset;
+   unsigned long vma_size;
+   unsigned long curr_pfn, prev_pfn;
+   unsigned long num_pages;
+   int ret = -EINVAL;
+   unsigned int i;
+
+   offset = vaddr  ~PAGE_MASK;
+
+   down_read(mm-mmap_sem);
+
+   vma = find_vma(mm, vaddr);
+   if (!vma) {
+   printk(KERN_ERR Invalid userspace address\n);
+   goto done;
+   }
+
+   vma_size = vma-vm_end - vma-vm_start;
+
+   if (size  vma_size - offset) {
+   printk(KERN_ERR Region too small\n);
+   goto done;
+   }
+   num_pages = (size + offset)  PAGE_SHIFT;
+
+   ret = follow_pfn(vma, vaddr, curr_pfn);
+   if (ret) {
+   printk(KERN_ERR Invalid userspace address\n);
+   goto done;
+   }
+
+   *paddr = (curr_pfn  PAGE_SHIFT) + offset;
+
+   for (i = 1; i  num_pages; ++i) {
+   prev_pfn = curr_pfn;
+   vaddr += PAGE_SIZE;
+
+   ret = follow_pfn(vma, vaddr, curr_pfn);
+   if (ret || curr_pfn != prev_pfn + 1) {
+   printk(KERN_ERR Invalid userspace address\n);
+   ret = -EINVAL;
+   break;
+   }
+   }
+
+done:
+   up_read(mm-mmap_sem);
+   return ret;
+}
+
+/**
+ * vb2_mmap_pfn_range() - map physical pages to userspace
+ * @vma:   virtual memory region for the mapping
+ * @paddr: starting physical address of the memory to be mapped
+ * @size:  size of the memory to be mapped
+ * @vm_ops:vm operations to be assigned to the created area
+ * @priv:  private data to be associated with the area
+ *
+ * Returns 0 on success.
+ */
+int 

[PATCH 3/7] v4l: videobuf2: add vmalloc allocator

2010-11-19 Thread Marek Szyprowski
From: Pawel Osciak p.osc...@samsung.com

Add an implementation of contiguous virtual memory allocator and handling
routines for videobuf2, implemented on top of vmalloc()/vfree() calls.

Signed-off-by: Pawel Osciak p.osc...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
CC: Pawel Osciak pa...@osciak.com
---
 drivers/media/video/Kconfig |5 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/videobuf2-vmalloc.c |  177 +++
 include/media/videobuf2-vmalloc.h   |   21 
 4 files changed, 204 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-vmalloc.c
 create mode 100644 include/media/videobuf2-vmalloc.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 83ce858..9351423 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -55,6 +55,11 @@ config VIDEOBUF2_CORE
 config VIDEOBUF2_MEMOPS
tristate
 
+config VIDEOBUF2_VMALLOC
+   select VIDEOBUF2_CORE
+   select VIDEOBUF2_MEMOPS
+   tristate
+
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index a97a2a0..538bee9 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -116,6 +116,7 @@ obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 
 obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
 obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
+obj-$(CONFIG_VIDEOBUF2_VMALLOC)+= videobuf2-vmalloc.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-vmalloc.c 
b/drivers/media/video/videobuf2-vmalloc.c
new file mode 100644
index 000..3310900
--- /dev/null
+++ b/drivers/media/video/videobuf2-vmalloc.c
@@ -0,0 +1,177 @@
+/*
+ * videobuf2-vmalloc.c - vmalloc memory allocator for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak p.osc...@samsung.com
+ *
+ * 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.
+ */
+
+#include linux/module.h
+#include linux/mm.h
+#include linux/slab.h
+#include linux/vmalloc.h
+
+#include media/videobuf2-core.h
+#include media/videobuf2-memops.h
+
+struct vb2_vmalloc_conf {
+   struct vb2_alloc_ctxalloc_ctx;
+};
+
+struct vb2_vmalloc_buf {
+   void*vaddr;
+   unsigned long   size;
+   unsigned intrefcount;
+};
+
+static void *vb2_vmalloc_alloc(const struct vb2_alloc_ctx *alloc_ctx,
+   unsigned long size)
+{
+   struct vb2_vmalloc_buf *buf;
+
+   buf = kzalloc(sizeof *buf, GFP_KERNEL);
+   if (!buf)
+   return NULL;
+
+   buf-size = size;
+   buf-vaddr = vmalloc_user(buf-size);
+   if (!buf-vaddr) {
+   printk(KERN_ERR vmalloc of size %ld failed\n, buf-size);
+   kfree(buf);
+   return NULL;
+   }
+
+   buf-refcount++;
+   printk(KERN_DEBUG Allocated vmalloc buffer of size %ld at vaddr=%p\n,
+   buf-size, buf-vaddr);
+
+   return buf;
+}
+
+static void vb2_vmalloc_put(void *buf_priv)
+{
+   struct vb2_vmalloc_buf *buf = buf_priv;
+
+   buf-refcount--;
+
+   if (0 == buf-refcount) {
+   printk(KERN_DEBUG %s: Freeing vmalloc mem at vaddr=%p\n,
+   __func__, buf-vaddr);
+   vfree(buf-vaddr);
+   kfree(buf);
+   }
+}
+
+static void *vb2_vmalloc_vaddr(void *buf_priv)
+{
+   struct vb2_vmalloc_buf *buf = buf_priv;
+
+   BUG_ON(!buf);
+
+   if (!buf-vaddr) {
+   printk(KERN_ERR Address of an unallocated 
+   plane requested\n);
+   return NULL;
+   }
+
+   return buf-vaddr;
+}
+
+static unsigned int vb2_vmalloc_num_users(void *buf_priv)
+{
+   struct vb2_vmalloc_buf *buf = buf_priv;
+
+   return buf-refcount;
+}
+
+/* TODO generalize and extract to core as much as possible */
+static void vb2_vmalloc_vm_open(struct vm_area_struct *vma)
+{
+   struct vb2_vmalloc_buf *buf = vma-vm_private_data;
+
+   printk(KERN_DEBUG %s vmalloc_priv: %p, refcount: %d, 
+   vma: %08lx-%08lx\n, __func__, buf, buf-refcount,
+   vma-vm_start, vma-vm_end);
+
+   buf-refcount++;
+}
+
+static void vb2_vmalloc_vm_close(struct vm_area_struct *vma)
+{
+   struct vb2_vmalloc_buf *buf = vma-vm_private_data;
+
+   printk(KERN_DEBUG %s vmalloc_priv: %p, refcount: %d, 
+   vma: %08lx-%08lx\n, __func__, buf, buf-refcount,
+   vma-vm_start, vma-vm_end);
+
+   vb2_vmalloc_put(buf);
+}
+
+static const struct vm_operations_struct vb2_vmalloc_vm_ops = {
+   .open = 

[PATCH 1/7] v4l: add videobuf2 Video for Linux 2 driver framework

2010-11-19 Thread Marek Szyprowski
From: Pawel Osciak p.osc...@samsung.com

Videobuf2 is a Video for Linux 2 API-compatible driver framework for
multimedia devices. It acts as an intermediate layer between userspace
applications and device drivers. It also provides low-level, modular
memory management functions for drivers.

Videobuf2 eases driver development, reduces drivers' code size and aids in
proper and consistent implementation of V4L2 API in drivers.

Videobuf2 memory management backend is fully modular. This allows custom
memory management routines for devices and platforms with non-standard
memory management requirements to be plugged in, without changing the
high-level buffer management functions and API.

The framework provides:
- implementations of streaming I/O V4L2 ioctls and file operations
- high-level video buffer, video queue and state management functions
- video buffer memory allocation and management

Signed-off-by: Pawel Osciak p.osc...@samsung.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
CC: Pawel Osciak pa...@osciak.com
---
 drivers/media/video/Kconfig  |3 +
 drivers/media/video/Makefile |2 +
 drivers/media/video/videobuf2-core.c | 1435 ++
 include/media/videobuf2-core.h   |  376 +
 4 files changed, 1816 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-core.c
 create mode 100644 include/media/videobuf2-core.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index ac16e81..fef6a14 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -49,6 +49,9 @@ config V4L2_MEM2MEM_DEV
tristate
depends on VIDEOBUF_GEN
 
+config VIDEOBUF2_CORE
+   tristate
+
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index af79d47..77c4f85 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -114,6 +114,8 @@ obj-$(CONFIG_VIDEOBUF_VMALLOC) += videobuf-vmalloc.o
 obj-$(CONFIG_VIDEOBUF_DVB) += videobuf-dvb.o
 obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 
+obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
+
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
 obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
diff --git a/drivers/media/video/videobuf2-core.c 
b/drivers/media/video/videobuf2-core.c
new file mode 100644
index 000..828803f
--- /dev/null
+++ b/drivers/media/video/videobuf2-core.c
@@ -0,0 +1,1435 @@
+/*
+ * videobuf2-core.c - V4L2 driver helper framework
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak p.osc...@samsung.com
+ *Marek Szyprowski m.szyprow...@samsung.com
+ *
+ * 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.
+ */
+
+#include linux/kernel.h
+#include linux/mm.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/sched.h
+#include linux/err.h
+#include linux/poll.h
+
+#include media/videobuf2-core.h
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define dprintk(level, fmt, arg...)\
+   do {\
+   if (debug = level) \
+   printk(KERN_DEBUG vb2:  fmt, ## arg); \
+   } while (0)
+
+#define mem_ops(q, plane) ((q)-alloc_ctx[plane]-mem_ops)
+
+#define call_memop(q, plane, op, args...)  \
+   ((mem_ops(q, plane)-op) ?  \
+   (mem_ops(q, plane)-op(args)) : 0)
+
+#define call_qop(q, op, args...)   \
+   (((q)-ops-op) ? ((q)-ops-op(args)) : 0)
+
+/**
+ * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
+ */
+static int __vb2_buf_mem_alloc(struct vb2_buffer *vb,
+   unsigned long *plane_sizes)
+{
+   struct vb2_queue *q = vb-vb2_queue;
+   void *mem_priv;
+   int plane;
+
+   /* Allocate memory for all planes in this buffer */
+   for (plane = 0; plane  vb-num_planes; ++plane) {
+   mem_priv = call_memop(q, plane, alloc, q-alloc_ctx[plane],
+   plane_sizes[plane]);
+   if (!mem_priv)
+   goto free;
+
+   /* Associate allocator private data with this plane */
+   vb-planes[plane].mem_priv = mem_priv;
+   vb-v4l2_planes[plane].length = plane_sizes[plane];
+   }
+
+   return 0;
+free:
+   /* Free already allocated memory if one of the allocations failed */
+   for (; plane  0; --plane)
+   call_memop(q, plane, put, vb-planes[plane - 1].mem_priv);
+
+   return -ENOMEM;
+}
+
+/**
+ * __vb2_buf_mem_free() - free memory of 

[PATCH 7/7] v4l: videobuf2: add CMA allocator

2010-11-19 Thread Marek Szyprowski
From: Pawel Osciak p.osc...@samsung.com

Add support for the CMA contiguous memory allocator to videobuf2.

Signed-off-by: Pawel Osciak p.osc...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
CC: Pawel Osciak pa...@osciak.com
---
 drivers/media/video/Kconfig |5 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/videobuf2-cma.c |  250 +++
 include/media/videobuf2-cma.h   |   31 +
 4 files changed, 287 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-cma.c
 create mode 100644 include/media/videobuf2-cma.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9315c0a..eec6c3f 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -65,6 +65,11 @@ config VIDEOBUF2_VMALLOC
select VIDEOBUF2_MEMOPS
tristate
 
+config VIDEOBUF2_CMA
+   depends on CMA
+   select VIDEOBUF2_CORE
+   select VIDEOBUF2_MEMOPS
+   tristate
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index ede588d..82635fc 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -118,6 +118,7 @@ obj-$(CONFIG_VIDEOBUF2_CORE)+= 
videobuf2-core.o
 obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
 obj-$(CONFIG_VIDEOBUF2_VMALLOC)+= videobuf2-vmalloc.o
 obj-$(CONFIG_VIDEOBUF2_DMA_COHERENT)   += videobuf2-dma-coherent.o
+obj-$(CONFIG_VIDEOBUF2_CMA)+= videobuf2-cma.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-cma.c 
b/drivers/media/video/videobuf2-cma.c
new file mode 100644
index 000..157d7ac
--- /dev/null
+++ b/drivers/media/video/videobuf2-cma.c
@@ -0,0 +1,250 @@
+/*
+ * videobuf2-cma.c - CMA memory allocator for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak p.osc...@samsung.com
+ *
+ * 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.
+ */
+
+#include linux/module.h
+#include linux/slab.h
+#include linux/cma.h
+#include linux/mm.h
+#include linux/sched.h
+#include linux/file.h
+
+#include media/videobuf2-core.h
+#include media/videobuf2-memops.h
+
+struct vb2_cma_conf {
+   struct vb2_alloc_ctxalloc_ctx;
+   struct device   *dev;
+   const char  *type;
+   unsigned long   alignment;
+};
+
+struct vb2_cma_buf {
+   struct vb2_cma_conf *conf;
+   dma_addr_t  paddr;
+   unsigned long   size;
+   unsigned intrefcount;
+   struct vm_area_struct   *vma;
+};
+
+static void *vb2_cma_alloc(const struct vb2_alloc_ctx *alloc_ctx,
+   unsigned long size)
+{
+   struct vb2_cma_conf *conf =
+   container_of(alloc_ctx, struct vb2_cma_conf, alloc_ctx);
+   struct vb2_cma_buf *buf;
+
+   buf = kzalloc(sizeof *buf, GFP_KERNEL);
+   if (!buf)
+   return ERR_PTR(-ENOMEM);
+
+   buf-paddr = cma_alloc(conf-dev, conf-type, size, conf-alignment);
+   if (IS_ERR((void *)buf-paddr)) {
+   printk(KERN_ERR cma_alloc of size %ld failed\n, size);
+   kfree(buf);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   buf-conf = conf;
+   buf-size = size;
+   buf-refcount++;
+
+   printk(KERN_DEBUG Allocated cma mem of size %ld at paddr=0x%08x\n,
+   buf-size, buf-paddr);
+
+   return buf;
+}
+
+static void vb2_cma_put(void *buf_priv)
+{
+   struct vb2_cma_buf *buf = buf_priv;
+
+   buf-refcount--;
+
+   if (0 == buf-refcount) {
+   cma_free(buf-paddr);
+   kfree(buf);
+   }
+}
+
+static unsigned long vb2_cma_cookie(void *buf_priv)
+{
+   struct vb2_cma_buf *buf = buf_priv;
+
+   return buf-paddr;
+}
+
+static unsigned int vb2_cma_num_users(void *buf_priv)
+{
+   struct vb2_cma_buf *buf = buf_priv;
+
+   return buf-refcount;
+}
+
+static void vb2_cma_vm_open(struct vm_area_struct *vma)
+{
+   struct vb2_cma_buf *buf = vma-vm_private_data;
+
+   printk(KERN_DEBUG %s cma_priv: %p, refcount: %d, 
+   vma: %08lx-%08lx\n, __func__, buf, buf-refcount,
+   vma-vm_start, vma-vm_end);
+
+   buf-refcount++;
+}
+
+static void vb2_cma_vm_close(struct vm_area_struct *vma)
+{
+   struct vb2_cma_buf *buf = vma-vm_private_data;
+
+   printk(KERN_DEBUG %s cma_priv: %p, refcount: %d, 
+   vma: %08lx-%08lx\n, __func__, buf, buf-refcount,
+   vma-vm_start, vma-vm_end);
+
+   vb2_cma_put(buf);
+}
+
+static const struct vm_operations_struct vb2_cma_vm_ops = {
+   .open = vb2_cma_vm_open,

[PATCH 4/7] v4l: videobuf2: add DMA coherent allocator

2010-11-19 Thread Marek Szyprowski
From: Pawel Osciak p.osc...@samsung.com

Add an implementation of DMA coherent memory allocator and handling
routines for videobuf2, implemented on top of dma_alloc_coherent() call.

Signed-off-by: Pawel Osciak p.osc...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
CC: Pawel Osciak pa...@osciak.com
---
 drivers/media/video/Kconfig  |5 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/videobuf2-dma-coherent.c |  211 ++
 include/media/videobuf2-dma-coherent.h   |   27 
 4 files changed, 244 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-dma-coherent.c
 create mode 100644 include/media/videobuf2-dma-coherent.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9351423..e7752ee1 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -55,6 +55,11 @@ config VIDEOBUF2_CORE
 config VIDEOBUF2_MEMOPS
tristate
 
+config VIDEOBUF2_DMA_COHERENT
+   select VIDEOBUF2_CORE
+   select VIDEOBUF2_MEMOPS
+   tristate
+
 config VIDEOBUF2_VMALLOC
select VIDEOBUF2_CORE
select VIDEOBUF2_MEMOPS
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 538bee9..ede588d 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -117,6 +117,7 @@ obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
 obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
 obj-$(CONFIG_VIDEOBUF2_VMALLOC)+= videobuf2-vmalloc.o
+obj-$(CONFIG_VIDEOBUF2_DMA_COHERENT)   += videobuf2-dma-coherent.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-dma-coherent.c 
b/drivers/media/video/videobuf2-dma-coherent.c
new file mode 100644
index 000..965a80a
--- /dev/null
+++ b/drivers/media/video/videobuf2-dma-coherent.c
@@ -0,0 +1,211 @@
+/*
+ * videobuf2-dma-coherent.c - DMA coherent memory allocator for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak p.osc...@samsung.com
+ *
+ * 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.
+ */
+
+#include linux/module.h
+#include linux/slab.h
+#include linux/dma-mapping.h
+
+#include media/videobuf2-core.h
+#include media/videobuf2-memops.h
+
+struct vb2_dc_conf {
+   struct vb2_alloc_ctxalloc_ctx;
+   struct device   *dev;
+};
+
+struct vb2_dc_buf {
+   struct vb2_dc_conf  *conf;
+   void*vaddr;
+   dma_addr_t  paddr;
+   unsigned long   size;
+   unsigned intrefcount;
+   struct vm_area_struct   *vma;
+};
+
+static void *vb2_dma_coherent_alloc(const struct vb2_alloc_ctx *alloc_ctx,
+   unsigned long size)
+{
+   struct vb2_dc_conf *conf =
+   container_of(alloc_ctx, struct vb2_dc_conf, alloc_ctx);
+   struct vb2_dc_buf *buf;
+
+   buf = kzalloc(sizeof *buf, GFP_KERNEL);
+   if (!buf)
+   return ERR_PTR(-ENOMEM);
+
+   buf-vaddr = dma_alloc_coherent(conf-dev, size, buf-paddr,
+   GFP_KERNEL);
+   if (!buf-vaddr) {
+   dev_err(conf-dev, dma_alloc_coherent of size %ld failed\n,
+   buf-size);
+   kfree(buf);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   buf-conf = conf;
+   buf-size = size;
+
+   return buf;
+}
+
+static void vb2_dma_coherent_put(void *buf_priv)
+{
+   struct vb2_dc_buf *buf = buf_priv;
+
+   buf-refcount--;
+
+   if (0 == buf-refcount) {
+   dma_free_coherent(buf-conf-dev, buf-size, buf-vaddr,
+   buf-paddr);
+   kfree(buf);
+   }
+}
+
+static void *vb2_dma_coherent_cookie(void *buf_priv)
+{
+   struct vb2_dc_buf *buf = buf_priv;
+
+   return (void *)buf-paddr;
+}
+
+static unsigned int vb2_dma_coherent_num_users(void *buf_priv)
+{
+   struct vb2_dc_buf *buf = buf_priv;
+
+   return buf-refcount;
+}
+
+static void vb2_dma_coherent_vm_open(struct vm_area_struct *vma)
+{
+   struct vb2_dc_buf *buf = vma-vm_private_data;
+
+   printk(KERN_DEBUG %s cma_priv: %p, refcount: %d, 
+   vma: %08lx-%08lx\n, __func__, buf, buf-refcount,
+   vma-vm_start, vma-vm_end);
+
+   buf-refcount++;
+}
+
+static void vb2_dma_coherent_vm_close(struct vm_area_struct *vma)
+{
+   struct vb2_dc_buf *buf = vma-vm_private_data;
+
+   printk(KERN_DEBUG %s cma_priv: %p, refcount: %d, 
+   vma: %08lx-%08lx\n, __func__, buf, buf-refcount,
+   vma-vm_start, vma-vm_end);
+
+   

[PATCH 5/7] v4l: videobuf2: add read() and write() emulator

2010-11-19 Thread Marek Szyprowski
Add a generic file io (read and write) emulator for videobuf2. It uses
MMAP memory type buffers and generic vb2 calls: req_bufs, qbuf and
dqbuf. Video date is being copied from mmap buffers to userspace with
standard copy_to_user() function. To add support for file io the driver
needs to provide an additional callback - read_setup or write_setup. It
should provide the default number of buffers used by emulator and flags.

With these flags one can detemine the style of read() or write()
emulation. By default 'streaming' style is used. With
VB2_FILEIO_READ_ONCE flag one can select 'one shot' mode for read()
emulator. With VB2_FILEIO_WRITE_IMMEDIATE flag one can select immediate
conversion of write calls to qbuf for write() emulator, so the vb2 will
not wait until each buffer is filled completely before queueing it to
the driver.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
CC: Pawel Osciak pa...@osciak.com
---
 drivers/media/video/videobuf2-core.c |  396 +-
 include/media/videobuf2-core.h   |   31 +++
 2 files changed, 426 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/videobuf2-core.c 
b/drivers/media/video/videobuf2-core.c
index 828803f..bc497e3 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -500,6 +500,11 @@ int vb2_reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
unsigned int num_buffers, num_planes;
int ret = 0;
 
+   if (q-fileio) {
+   dprintk(1, reqbufs: file io in progress\n);
+   return -EBUSY;
+   }
+
if (req-memory != V4L2_MEMORY_MMAP
 req-memory != V4L2_MEMORY_USERPTR) {
dprintk(1, reqbufs: unsupported memory type\n);
@@ -846,6 +851,10 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
struct vb2_buffer *vb;
int ret = 0;
 
+   if (q-fileio) {
+   dprintk(1, qbuf: file io in progress\n);
+   return -EBUSY;
+   }
 
if (b-type != q-type) {
dprintk(1, qbuf: invalid buffer type\n);
@@ -1019,6 +1028,10 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer 
*b, bool nonblocking)
struct vb2_buffer *vb = NULL;
int ret;
 
+   if (q-fileio) {
+   dprintk(1, dqbuf: file io in progress\n);
+   return -EBUSY;
+   }
 
if (b-type != q-type) {
dprintk(1, dqbuf: invalid buffer type\n);
@@ -1083,6 +1096,10 @@ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type 
type)
struct vb2_buffer *vb;
int ret = 0;
 
+   if (q-fileio) {
+   dprintk(1, streamon: file io in progress\n);
+   return -EBUSY;
+   }
 
if (type != q-type) {
dprintk(1, streamon: invalid stream type\n);
@@ -1181,6 +1198,10 @@ int vb2_streamoff(struct vb2_queue *q, enum 
v4l2_buf_type type)
 {
int ret = 0;
 
+   if (q-fileio) {
+   dprintk(1, streamoff: file io in progress\n);
+   return -EBUSY;
+   }
 
if (type != q-type) {
dprintk(1, streamoff: invalid stream type\n);
@@ -1319,6 +1340,9 @@ bool vb2_has_consumers(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(vb2_has_consumers);
 
+static int __vb2_init_fileio(struct vb2_queue *q, int read);
+static int __vb2_cleanup_fileio(struct vb2_queue *q);
+
 /**
  * vb2_poll() - implements poll userspace operation
  * @q: videobuf2 queue
@@ -1341,6 +1365,21 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
*file, poll_table *wait)
unsigned int ret = 0;
struct vb2_buffer *vb = NULL;
 
+   /*
+* Start file io emulator if streaming api has not been used yet.
+*/
+   if (q-num_buffers == 0  q-fileio == NULL) {
+   if (!V4L2_TYPE_IS_OUTPUT(q-type)  q-ops-read_setup) {
+   ret = __vb2_init_fileio(q, 1);
+   if (ret)
+   return ret;
+   }
+   if (V4L2_TYPE_IS_OUTPUT(q-type)  q-ops-write_setup) {
+   ret = __vb2_init_fileio(q, 0);
+   if (ret == 0)
+   return POLLOUT | POLLWRNORM;
+   }
+   }
 
/*
 * There is nothing to wait for if no buffers have already been queued.
@@ -1425,11 +1464,366 @@ EXPORT_SYMBOL_GPL(vb2_queue_init);
  */
 void vb2_queue_release(struct vb2_queue *q)
 {
+   __vb2_cleanup_fileio(q);
__vb2_queue_cancel(q);
__vb2_queue_free(q);
 }
 EXPORT_SYMBOL_GPL(vb2_queue_release);
 
+/**
+ * struct vb2_fileio_buf - buffer context used by file io emulator
+ *
+ * vb2 provides a compatibility layer and emulator of file io (read and
+ * write) calls on top of streaming API. This structure is used for
+ * tracking context related to the buffers.
+ */
+struct vb2_fileio_buf {

[PATCH/RFC v5 0/7] Videobuf2 framework

2010-11-19 Thread Marek Szyprowski
Hello,

This is a quick update of the patch series posted a few days ago. I've
fixed coding style issues pointed by Hans, added the correct version of
dma coherent allocator (looks that outdated patch have been included in
all previous series) and fixed an ugly bug in __queue_cancel function
(the state of the buffers was not updated what caused problems if one
paused streaming with stream off/on).

Since v4 the vb2 contains a complete file IO emulator. It provides 2
modes for both read and write. By default both read and write are
implemented in 'streaming' style (like old videobuf_read_stream() call).
By setting VB2_FILEIO_READ_ONCE one can request 'one shot' mode (like
videobuf_read_one() from the original videobuf). For write emulator one
can set VB2_FILEIO_WRITE_IMMEDIATE flag, what will make each write()
call to transform directly into a q_buf() with aproperiate bytesused
entry set, without waiting until the buffer is filled completely.

Best regards
--
Marek Szyprowski
Samsung Poland RD Center


Changes since V4:
=
- fixed coding style issues reported by Hans Verkuil
- fixed __queue_cancel function to reinitialize all buffers
- included proper version of dma_coherent allocator (previous series
  contained only an outdated version)
- updated comment here and there

Changes since V3:
=
- rebased onto 2.6.37-rc2
- new locking policy: vb2 has no internal/hidden locks, the driver takes
  all the responsibility to ensure proper locking: removed vb2_lock and
  introduced new entries in qops: lock and unlock
- added buf_alloc and buf_free callback, it was very hard to add driver
  dependent custom data to buffers without them (and erlier version of VIVI
  driver silently trashed memory with its vivi_buffer structures - now fixed)
- added a new macro 'call_qop' to the core, simplified code
- fixed bytesused entry handling in core (it is now always stored in planes[0])
- changed the paddr callback into a cookie (required for the new upcoming dma
  sg and iommu memory allocators), see include/media/videobuf2-dma-coherent.h
  for more details
- added generic write() support!

Changes since V2:
=
- added read() emulator (see patch #5/7)
- fixed lack of parentheses in macro definitions (caused side effects
  in some places)
- added a separate check for VM_READ or VM_WRITE in vb2_mmap()
- added vb2_is_streaming(), vb2_lock and vb2_unlock inlines
- updated vivi driver with the new read() emulator 

Changes since V1:
=
- removed drv_lock, added start_streaming and stop_streaming callbacks


Here is the original Videobuf2 introduction prepared by Pawel:
===

These patches add a new driver framework for Video for Linux 2 driver
- Videobuf2.

Videobuf2 is intended as a replacement for videobuf, the current driver
framework, which will be referred to as videobuf1 for the remainder
of this document.


What is videobuf2?

Videobuf2 is a Video for Linux 2 API-compatible driver framework for
multimedia devices. It acts as an intermediate layer between userspace
applications and device drivers. It also provides low-level, modular
memory management functions for drivers.

Videobuf2 eases driver development, reduces drivers' code size and aids in
proper and consistent implementation of V4L2 API in drivers.

Videobuf2 memory management backend is fully modular. This allows custom
memory management routines for devices and platforms with non-standard
memory management requirements to be plugged in, without changing the
high-level buffer management functions and API.

The framework provides:
- implementations of streaming I/O V4L2 ioctls and file operations
- high-level video buffer, video queue and state management functions
- video buffer memory allocation and management


Why a new framework?

There have been many discussions in the V4L2 community about the feasibility
of writing a new framework, as opposed to fixing the existing one. It has been
agreed though that:
- videobuf1 has major flaws and an attempt to fix it would end up in rewriting
most of the code
- many drivers depend on videobuf1 and since the changes would be major,
an effort to adapt and test them all would not be realistically possible

Due to the problems with videobuf most new drivers cannot use it. This leads
to code replication and overcomplicated drivers.


What is wrong with videobuf1?

There are many problems with the current videobuf implementation. During a V4L2
mini-summit in Helsinki in June 2010, two presentations were delivered
on this topic:
- Laurent Pinchart videobuf - the good, the bad and the ugly
http://linuxtv.org/downloads/presentations/summit_jun_2010/20100614-v4l2_summit-videobuf.pdf
- Pawel Osciak Future of the 

[PATCH 6/7] v4l: vivi: port to videobuf2

2010-11-19 Thread Marek Szyprowski
Make vivi use videobuf2 in place of videobuf.

Signed-off-by: Pawel Osciak p.osc...@samsung.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
CC: Pawel Osciak pa...@osciak.com
---
 drivers/media/video/Kconfig |2 +-
 drivers/media/video/vivi.c  |  390 ---
 2 files changed, 221 insertions(+), 171 deletions(-)

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index e7752ee1..9315c0a 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -557,7 +557,7 @@ config VIDEO_VIVI
depends on VIDEO_DEV  VIDEO_V4L2  !SPARC32  !SPARC64
depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
select FONT_8x16
-   select VIDEOBUF_VMALLOC
+   select VIDEOBUF2_VMALLOC
default n
---help---
  Enables a virtual video driver. This device shows a color bar
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 9797e5a..baaacf3 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -7,6 +7,9 @@
  *  John Sokol sokol--a.t--videotechnology.com
  *  http://v4l.videotechnology.com/
  *
+ *  Conversion to videobuf2 by Pawel Osciak  Marek Szyprowski
+ *  Copyright (c) 2010 Samsung Electronics
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the BSD Licence, GNU General Public License
  * as published by the Free Software Foundation; either version 2 of the
@@ -23,10 +26,8 @@
 #include linux/mutex.h
 #include linux/videodev2.h
 #include linux/kthread.h
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2, 6, 20)
 #include linux/freezer.h
-#endif
-#include media/videobuf-vmalloc.h
+#include media/videobuf2-vmalloc.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-common.h
@@ -42,7 +43,7 @@
 #define MAX_HEIGHT 1200
 
 #define VIVI_MAJOR_VERSION 0
-#define VIVI_MINOR_VERSION 7
+#define VIVI_MINOR_VERSION 8
 #define VIVI_RELEASE 0
 #define VIVI_VERSION \
KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
@@ -70,6 +71,9 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in 
megabytes);
 /* Global font descriptor */
 static const u8 *font8x16;
 
+/* Videobuf2 allocator/memory handler context */
+static struct vb2_alloc_ctx *alloc_ctx;
+
 #define dprintk(dev, level, fmt, arg...) \
v4l2_dbg(level, debug, dev-v4l2_dev, fmt, ## arg)
 
@@ -133,16 +137,11 @@ static struct vivi_fmt *get_format(struct v4l2_format *f)
return formats[k];
 }
 
-struct sg_to_addr {
-   int pos;
-   struct scatterlist *sg;
-};
-
 /* buffer for one video frame */
 struct vivi_buffer {
/* common v4l buffer stuff -- must be first */
-   struct videobuf_buffer vb;
-
+   struct vb2_buffer   vb;
+   struct list_headlist;
struct vivi_fmt*fmt;
 };
 
@@ -190,9 +189,11 @@ struct vivi_dev {
/* video capture */
struct vivi_fmt*fmt;
unsigned int   width, height;
-   struct videobuf_queue  vb_vidq;
+   struct vb2_queue   vb_vidq;
+   enum v4l2_fieldfield;
+   unsigned int   field_count;
 
-   unsigned long  generating;
+   unsigned int   open_count;
u8 bars[9][3];
u8 line[MAX_WIDTH * 4];
 };
@@ -443,10 +444,10 @@ static void gen_text(struct vivi_dev *dev, char *basep,
 
 static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
 {
-   int hmax = buf-vb.height;
-   int wmax = buf-vb.width;
+   int wmax = dev-width;
+   int hmax = dev-height;
struct timeval ts;
-   void *vbuf = videobuf_to_vmalloc(buf-vb);
+   void *vbuf = vb2_plane_vaddr(buf-vb, 0);
unsigned ms;
char str[100];
int h, line = 1;
@@ -483,11 +484,11 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct 
vivi_buffer *buf)
 
dev-mv_count += 2;
 
-   /* Advice that buffer was filled */
-   buf-vb.field_count++;
+   buf-vb.v4l2_buf.field = dev-field;
+   dev-field_count++;
+   buf-vb.v4l2_buf.sequence = dev-field_count  1;
do_gettimeofday(ts);
-   buf-vb.ts = ts;
-   buf-vb.state = VIDEOBUF_DONE;
+   buf-vb.v4l2_buf.timestamp = ts;
 }
 
 static void vivi_thread_tick(struct vivi_dev *dev)
@@ -504,23 +505,21 @@ static void vivi_thread_tick(struct vivi_dev *dev)
goto unlock;
}
 
-   buf = list_entry(dma_q-active.next,
-struct vivi_buffer, vb.queue);
-
-   /* Nobody is waiting on this buffer, return */
-   if (!waitqueue_active(buf-vb.done))
+   /* If nobody is waiting for a buffer, return */
+   if (!vb2_has_consumers(dev-vb_vidq))
goto unlock;
 
-   list_del(buf-vb.queue);
+   buf = 

[RFCv6 01/13] lib: rbtree: rb_root_init() function added

2010-11-19 Thread Michal Nazarewicz
Added a rb_root_init() function which initialises a rb_root
structure as a red-black tree with at most one element.  The
rationale is that using rb_root_init(root, node) is more
straightforward and cleaner then first initialising and
empty tree followed by an insert operation.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/rbtree.h |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 7066acb..5b6dc66 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -130,6 +130,17 @@ static inline void rb_set_color(struct rb_node *rb, int 
color)
 }
 
 #define RB_ROOT(struct rb_root) { NULL, }
+
+static inline void rb_root_init(struct rb_root *root, struct rb_node *node)
+{
+   root-rb_node = node;
+   if (node) {
+   node-rb_parent_color = RB_BLACK; /* black, no parent */
+   node-rb_left  = NULL;
+   node-rb_right = NULL;
+   }
+}
+
 #definerb_entry(ptr, type, member) container_of(ptr, type, member)
 
 #define RB_EMPTY_ROOT(root)((root)-rb_node == NULL)
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv6 02/13] lib: bitmap: Added alignment offset for bitmap_find_next_zero_area()

2010-11-19 Thread Michal Nazarewicz
This commit adds a bitmap_find_next_zero_area_off() function which
works like bitmap_find_next_zero_area() function expect it allows an
offset to be specified when alignment is checked.  This lets caller
request a bit such that its number plus the offset is aligned
according to the mask.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/bitmap.h |   24 +++-
 lib/bitmap.c   |   22 --
 2 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index daf8c48..c0528d1 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -45,6 +45,7 @@
  * bitmap_set(dst, pos, nbits) Set specified bit area
  * bitmap_clear(dst, pos, nbits)   Clear specified bit area
  * bitmap_find_next_zero_area(buf, len, pos, n, mask)  Find bit free area
+ * bitmap_find_next_zero_area_off(buf, len, pos, n, mask)  as above
  * bitmap_shift_right(dst, src, n, nbits)  *dst = *src  n
  * bitmap_shift_left(dst, src, n, nbits)   *dst = *src  n
  * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
@@ -113,11 +114,24 @@ extern int __bitmap_weight(const unsigned long *bitmap, 
int bits);
 
 extern void bitmap_set(unsigned long *map, int i, int len);
 extern void bitmap_clear(unsigned long *map, int start, int nr);
-extern unsigned long bitmap_find_next_zero_area(unsigned long *map,
-unsigned long size,
-unsigned long start,
-unsigned int nr,
-unsigned long align_mask);
+
+extern unsigned long bitmap_find_next_zero_area_off(unsigned long *map,
+   unsigned long size,
+   unsigned long start,
+   unsigned int nr,
+   unsigned long align_mask,
+   unsigned long align_offset);
+
+static inline unsigned long
+bitmap_find_next_zero_area(unsigned long *map,
+  unsigned long size,
+  unsigned long start,
+  unsigned int nr,
+  unsigned long align_mask)
+{
+   return bitmap_find_next_zero_area_off(map, size, start, nr,
+ align_mask, 0);
+}
 
 extern int bitmap_scnprintf(char *buf, unsigned int len,
const unsigned long *src, int nbits);
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 741fae9..8e75a6f 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -315,30 +315,32 @@ void bitmap_clear(unsigned long *map, int start, int nr)
 }
 EXPORT_SYMBOL(bitmap_clear);
 
-/*
+/**
  * bitmap_find_next_zero_area - find a contiguous aligned zero area
  * @map: The address to base the search on
  * @size: The bitmap size in bits
  * @start: The bitnumber to start searching at
  * @nr: The number of zeroed bits we're looking for
  * @align_mask: Alignment mask for zero area
+ * @align_offset: Alignment offset for zero area.
  *
  * The @align_mask should be one less than a power of 2; the effect is that
- * the bit offset of all zero areas this function finds is multiples of that
- * power of 2. A @align_mask of 0 means no alignment is required.
+ * the bit offset of all zero areas this function finds plus @align_offset
+ * is multiple of that power of 2.
  */
-unsigned long bitmap_find_next_zero_area(unsigned long *map,
-unsigned long size,
-unsigned long start,
-unsigned int nr,
-unsigned long align_mask)
+unsigned long bitmap_find_next_zero_area_off(unsigned long *map,
+unsigned long size,
+unsigned long start,
+unsigned int nr,
+unsigned long align_mask,
+unsigned long align_offset)
 {
unsigned long index, end, i;
 again:
index = find_next_zero_bit(map, size, start);
 
/* Align allocation */
-   index = __ALIGN_MASK(index, align_mask);
+   index = __ALIGN_MASK(index + align_offset, align_mask) - align_offset;
 
end = index + nr;
if (end  size)
@@ -350,7 +352,7 @@ again:
}
return index;
 }
-EXPORT_SYMBOL(bitmap_find_next_zero_area);
+EXPORT_SYMBOL(bitmap_find_next_zero_area_off);
 
 /*
  * Bitmap printing  parsing functions: first version by Bill Irwin,
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe 

[RFCv6 05/13] mm: cma: debugfs support added

2010-11-19 Thread Michal Nazarewicz
The debugfs development interface lets one change the map attribute
at run time as well as observe what regions have been reserved.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/contiguous-memory.txt |4 +
 include/linux/cma.h |   11 +
 mm/Kconfig  |   25 ++-
 mm/cma.c|  501 ++-
 4 files changed, 537 insertions(+), 4 deletions(-)

diff --git a/Documentation/contiguous-memory.txt 
b/Documentation/contiguous-memory.txt
index f1715ba..ec09d8e 100644
--- a/Documentation/contiguous-memory.txt
+++ b/Documentation/contiguous-memory.txt
@@ -258,6 +258,10 @@
  iff it matched in previous pattern.  If the second part is
  omitted it will mach any type of memory requested by device.
 
+ If debugfs support is enabled, this attribute is accessible via
+ debugfs and can be changed at run-time by writing to
+ contiguous/map.
+
  Some examples (whitespace added for better readability):
 
  cma_map = foo/quaz = r1;
diff --git a/include/linux/cma.h b/include/linux/cma.h
index a6031a7..8437104 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -24,6 +24,7 @@
 
 struct device;
 struct cma_info;
+struct dentry;
 
 /**
  * struct cma - an allocated contiguous chunk of memory.
@@ -276,6 +277,11 @@ struct cma_region {
unsigned users;
struct list_head list;
 
+#if defined CONFIG_CMA_DEBUGFS
+   const char *to_alloc_link, *from_alloc_link;
+   struct dentry *dir, *to_alloc, *from_alloc;
+#endif
+
unsigned used:1;
unsigned registered:1;
unsigned reserved:1;
@@ -382,6 +388,11 @@ struct cma_allocator {
void (*unpin)(struct cma *chunk);
 
struct list_head list;
+
+#if defined CONFIG_CMA_DEBUGFS
+   const char *dir_name;
+   struct dentry *regs_dir;
+#endif
 };
 
 /**
diff --git a/mm/Kconfig b/mm/Kconfig
index c7eb1bc..a5480ea 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -351,16 +351,35 @@ config CMA
  For more information see Documentation/contiguous-memory.txt.
  If unsure, say n.
 
-config CMA_DEBUG
-   bool CMA debug messages (DEVELOPEMENT)
+config CMA_DEVELOPEMENT
+   bool Include CMA developement features
depends on CMA
help
+ This lets you enable some developement features of the CMA
+ framework.  It does not add any code to the kernel.
+
+ Those options are mostly usable during development and testing.
+ If unsure, say n.
+
+config CMA_DEBUG
+   bool CMA debug messages
+   depends on CMA_DEVELOPEMENT
+   help
  Turns on debug messages in CMA.  This produces KERN_DEBUG
  messages for every CMA call as well as various messages while
  processing calls such as cma_alloc().  This option does not
  affect warning and error messages.
 
- This is mostly used during development.  If unsure, say n.
+config CMA_DEBUGFS
+   bool CMA debugfs interface support
+   depends on CMA_DEVELOPEMENT  DEBUG_FS
+   help
+ Enable support for debugfs interface.  It is available under the
+ contiguous directory in the debugfs root directory.  Each
+ region and allocator is represented there.
+
+ For more information consult
+ Documentation/contiguous-memory.txt.
 
 config CMA_GENERIC_ALLOCATOR
bool CMA generic allocator
diff --git a/mm/cma.c b/mm/cma.c
index 17276b3..dfdeeb7 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -34,11 +34,16 @@
 #include linux/slab.h/* kmalloc() */
 #include linux/string.h  /* str*() */
 #include linux/genalloc.h/* gen_pool_*() */
+#include linux/debugfs.h /* debugfs stuff */
+#include linux/uaccess.h /* copy_{to,from}_user */
 
 #include linux/cma.h
 
 
-/* Protects cma_regions, cma_allocators, cma_map and cma_map_length. */
+/*
+ * Protects cma_regions, cma_allocators, cma_map, cma_map_length,
+ * cma_dfs_regions and cma_dfs_allocators.
+ */
 static DEFINE_MUTEX(cma_mutex);
 
 
@@ -139,7 +144,13 @@ int __init __must_check cma_early_region_register(struct 
cma_region *reg)
 
 /* Regions  Allocators */
 
+static void __cma_dfs_region_add(struct cma_region *reg);
+static void __cma_dfs_region_alloc_update(struct cma_region *reg);
+static void __cma_dfs_allocator_add(struct cma_allocator *alloc);
+
 static int __cma_region_attach_alloc(struct cma_region *reg);
+static void __maybe_unused __cma_region_detach_alloc(struct cma_region *reg);
+
 
 /* List of all regions.  Named regions are kept before unnamed. */
 static LIST_HEAD(cma_regions);
@@ -222,6 +233,8 @@ int __must_check cma_region_register(struct cma_region *reg)
else
list_add_tail(reg-list, cma_regions);
 
+   __cma_dfs_region_add(reg);
+
 done:
mutex_unlock(cma_mutex);
 
@@ -298,6 +311,8 @@ int 

[RFCv6 13/13] ARM: cma: Added CMA to Aquila, Goni and c210 universal boards

2010-11-19 Thread Michal Nazarewicz
This commit adds CMA memory reservation code to Aquila, Goni and c210
universal boards.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 arch/arm/mach-s5pv210/mach-aquila.c |   26 ++
 arch/arm/mach-s5pv210/mach-goni.c   |   26 ++
 arch/arm/mach-s5pv310/mach-universal_c210.c |   17 +
 3 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s5pv210/mach-aquila.c 
b/arch/arm/mach-s5pv210/mach-aquila.c
index 28677ca..f1feb73 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -21,6 +21,7 @@
 #include linux/gpio_keys.h
 #include linux/input.h
 #include linux/gpio.h
+#include linux/cma.h
 
 #include asm/mach/arch.h
 #include asm/mach/map.h
@@ -650,6 +651,30 @@ static void __init aquila_sound_init(void)
__raw_writel(__raw_readl(S5P_OTHERS) | (0x3  8), S5P_OTHERS);
 }
 
+#ifdef CONFIG_CMA
+
+static void __init aquila_reserve(void)
+{
+   static struct cma_region regions[] = {
+   CMA_REGION(fw,  1  20, 128  10, 0x3200),
+   CMA_REGION(b1, 32  20, 0, 0x3300),
+   CMA_REGION(b2, 16  20, 0, 0x4400),
+   { }
+   };
+
+   static const char map[] __initconst =
+   s5p-mfc5/f=fw;s5p-mfc5/a=b1;s5p-mfc5/b=b2;*=b1,b2;
+
+   cma_set_defaults(regions, map);
+   cma_early_regions_reserve(NULL);
+}
+
+#else
+
+#define aquila_reserve NULL
+
+#endif
+
 static void __init aquila_map_io(void)
 {
s5p_init_io(NULL, 0, S5P_VA_CHIPID);
@@ -690,4 +715,5 @@ MACHINE_START(AQUILA, Aquila)
.map_io = aquila_map_io,
.init_machine   = aquila_machine_init,
.timer  = s3c24xx_timer,
+   .reserve= aquila_reserve,
 MACHINE_END
diff --git a/arch/arm/mach-s5pv210/mach-goni.c 
b/arch/arm/mach-s5pv210/mach-goni.c
index b1dcf96..0bda14f 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -25,6 +25,7 @@
 #include linux/gpio_keys.h
 #include linux/input.h
 #include linux/gpio.h
+#include linux/cma.h
 
 #include asm/mach/arch.h
 #include asm/mach/map.h
@@ -809,6 +810,30 @@ static void __init goni_sound_init(void)
__raw_writel(__raw_readl(S5P_OTHERS) | (0x3  8), S5P_OTHERS);
 }
 
+#ifdef CONFIG_CMA
+
+static void __init goni_reserve(void)
+{
+   static struct cma_region regions[] = {
+   CMA_REGION(fw,  1  20, 128  10, 0x3200),
+   CMA_REGION(b1, 32  20, 0, 0x3300),
+   CMA_REGION(b2, 16  20, 0, 0x4400),
+   { }
+   };
+
+   static const char map[] __initconst =
+   s5p-mfc5/f=fw;s5p-mfc5/a=b1;s5p-mfc5/b=b2;*=b1,b2;
+
+   cma_set_defaults(regions, map);
+   cma_early_regions_reserve(NULL);
+}
+
+#else
+
+#define goni_reserve NULL
+
+#endif
+
 static void __init goni_map_io(void)
 {
s5p_init_io(NULL, 0, S5P_VA_CHIPID);
@@ -865,4 +890,5 @@ MACHINE_START(GONI, GONI)
.map_io = goni_map_io,
.init_machine   = goni_machine_init,
.timer  = s3c24xx_timer,
+   .reserve= goni_reserve,
 MACHINE_END
diff --git a/arch/arm/mach-s5pv310/mach-universal_c210.c 
b/arch/arm/mach-s5pv310/mach-universal_c210.c
index 16d8fc0..90a2296 100644
--- a/arch/arm/mach-s5pv310/mach-universal_c210.c
+++ b/arch/arm/mach-s5pv310/mach-universal_c210.c
@@ -13,6 +13,7 @@
 #include linux/i2c.h
 #include linux/gpio_keys.h
 #include linux/gpio.h
+#include linux/cma.h
 
 #include asm/mach/arch.h
 #include asm/mach-types.h
@@ -138,6 +139,21 @@ static void __init universal_map_io(void)
s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs));
 }
 
+static void __init universal_reserve(void)
+{
+   static struct cma_region regions[] = {
+   CMA_REGION(r , 64  20, 0, 0),
+   CMA_REGION(fw,  1  20, 128  10),
+   { }
+   };
+
+   static const char map[] __initconst =
+   s3c-mfc5/f=fw;*=r;
+
+   cma_set_defaults(regions, map);
+   cma_early_regions_reserve(NULL);
+}
+
 static void __init universal_machine_init(void)
 {
i2c_register_board_info(0, i2c0_devs, ARRAY_SIZE(i2c0_devs));
@@ -152,6 +168,7 @@ MACHINE_START(UNIVERSAL_C210, UNIVERSAL_C210)
.boot_params= S5P_PA_SDRAM + 0x100,
.init_irq   = s5pv310_init_irq,
.map_io = universal_map_io,
+   .reserve= universal_reserve,
.init_machine   = universal_machine_init,
.timer  = s5pv310_timer,
 MACHINE_END
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv6 07/13] mm: cma: Test device and application added

2010-11-19 Thread Michal Nazarewicz
This patch adds a cma misc device which lets user space use the
CMA API.  This device is meant for testing.  A testing application
is also provided.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/misc/Kconfig   |8 +
 drivers/misc/Makefile  |1 +
 drivers/misc/cma-dev.c |  263 +++
 include/linux/cma.h|   40 +
 tools/cma/cma-test.c   |  459 
 5 files changed, 771 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/cma-dev.c
 create mode 100644 tools/cma/cma-test.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 1e1a4be..519a291 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -458,4 +458,12 @@ source drivers/misc/cb710/Kconfig
 source drivers/misc/iwmc3200top/Kconfig
 source drivers/misc/ti-st/Kconfig
 
+config CMA_DEVICE
+   tristate CMA misc device (DEVELOPEMENT)
+   depends on CMA_DEVELOPEMENT
+   help
+ The CMA misc device allows allocating contiguous memory areas
+ from user space.  This is mostly for testing of the CMA
+ framework.
+
 endif # MISC_DEVICES
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 98009cc..f8eadd4 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -42,3 +42,4 @@ obj-$(CONFIG_ARM_CHARLCD) += arm-charlcd.o
 obj-$(CONFIG_PCH_PHUB) += pch_phub.o
 obj-y  += ti-st/
 obj-$(CONFIG_AB8500_PWM)   += ab8500-pwm.o
+obj-$(CONFIG_CMA_DEVICE)   += cma-dev.o
diff --git a/drivers/misc/cma-dev.c b/drivers/misc/cma-dev.c
new file mode 100644
index 000..dce418a
--- /dev/null
+++ b/drivers/misc/cma-dev.c
@@ -0,0 +1,263 @@
+/*
+ * Contiguous Memory Allocator userspace driver
+ * Copyright (c) 2010 by Samsung Electronics.
+ * Written by Michal Nazarewicz (m.nazarew...@samsung.com)
+ *
+ * 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 optional) any later version of the license.
+ */
+
+#define pr_fmt(fmt) cma:  fmt
+
+#ifdef CONFIG_CMA_DEBUG
+#  define DEBUG
+#endif
+
+#include linux/errno.h   /* Error numbers */
+#include linux/err.h /* IS_ERR_VALUE() */
+#include linux/fs.h  /* struct file */
+#include linux/mm.h  /* Memory stuff */
+#include linux/mman.h
+#include linux/slab.h
+#include linux/module.h  /* Standard module stuff */
+#include linux/device.h  /* struct device, dev_dbg() */
+#include linux/types.h   /* Just to be safe ;) */
+#include linux/uaccess.h /* __copy_{to,from}_user */
+#include linux/miscdevice.h  /* misc_register() and company */
+
+#include linux/cma.h
+
+static int  cma_file_open(struct inode *inode, struct file *file);
+static int  cma_file_release(struct inode *inode, struct file *file);
+static long cma_file_ioctl(struct file *file, unsigned cmd, unsigned long arg);
+static int  cma_file_mmap(struct file *file, struct vm_area_struct *vma);
+
+static struct miscdevice cma_miscdev = {
+   .minor = MISC_DYNAMIC_MINOR,
+   .name  = cma,
+   .fops  = (const struct file_operations) {
+   .owner  = THIS_MODULE,
+   .open   = cma_file_open,
+   .release= cma_file_release,
+   .unlocked_ioctl = cma_file_ioctl,
+   .mmap   = cma_file_mmap,
+   },
+};
+#define cma_dev (cma_miscdev.this_device)
+
+static int  cma_file_open(struct inode *inode, struct file *file)
+{
+   dev_dbg(cma_dev, %s(%p)\n, __func__, (void *)file);
+
+   file-private_data = NULL;
+
+   return 0;
+}
+
+static int  cma_file_release(struct inode *inode, struct file *file)
+{
+   dev_dbg(cma_dev, %s(%p)\n, __func__, (void *)file);
+
+   if (file-private_data) {
+   cma_unpin(file-private_data);
+   cma_free(file-private_data);
+   }
+
+   return 0;
+}
+
+static long cma_file_ioctl_req(struct file *file, unsigned long arg)
+{
+   struct cma_alloc_request req;
+   const struct cma *chunk;
+
+   dev_dbg(cma_dev, %s(%p)\n, __func__, (void *)file);
+
+   if (!arg)
+   return -EINVAL;
+
+   if (file-private_data) /* Already allocated */
+   return -EBADFD;
+
+   if (copy_from_user(req, (void *)arg, sizeof req))
+   return -EFAULT;
+
+   if (req.magic != CMA_MAGIC)
+   return -ENOTTY;
+
+   if (req.type != CMA_REQ_DEV_KIND  req.type != CMA_REQ_FROM_REG)
+   return -EINVAL;
+
+   /* May happen on 32 bit system. */
+   if (req.size  ~(typeof(req.size))0 ||
+   req.alignment  ~(typeof(req.alignment))0)
+   return -EINVAL;
+
+   if (strnlen(req.spec, sizeof req.spec) = sizeof req.spec)
+   return 

[RFCv6 00/13] The Contiguous Memory Allocator framework

2010-11-19 Thread Michal Nazarewicz
Hello everyone,

A few people asked about CMA at the LPC, so even though the I have not
yet finished working on the new CMA here it is so that all
interested parties can take a look and decide if it can be used for
their use case.

In particular, this version adds not yet completed support for memory
migration and cma_pin()/cma_unpin() calls.


For those who have not yet stumbled across CMA an excerpt from
documentation:
 
   The Contiguous Memory Allocator (CMA) is a framework, which allows
   setting up a machine-specific configuration for physically-contiguous
   memory management. Memory for devices is then allocated according
   to that configuration.
 
   The main role of the framework is not to allocate memory, but to
   parse and manage memory configurations, as well as to act as an
   in-between between device drivers and pluggable allocators. It is
   thus not tied to any memory allocation method or strategy.
 
For more information please refer to the fourth patch from the
patchset which contains the documentation. 


Links to the previous versions of the patch set:
v5: (intentionally left out as CMA v5 was identical to CMA v4)
v4: http://article.gmane.org/gmane.linux.kernel.mm/52010/
v3: http://article.gmane.org/gmane.linux.kernel.mm/51573/
v2: http://article.gmane.org/gmane.linux.kernel.mm/50986/
v1: http://article.gmane.org/gmane.linux.kernel.mm/50669/


Changelog:

v6: 1. Most importantly, v6 introduces support for memory migration.
   The implementation is not yet complete though.

   Migration support means that when CMA is not using memory
   reserved for it, page allocator can allocate pages from it.
   When CMA wants to use the memory, the pages have to be moved
   and/or evicted as to make room for CMA.

   To make it possible it must be guaranteed that only movable and
   reclaimable pages are allocated in CMA controlled regions.
   This is done by introducing a MIGRATE_CMA migrate type that
   guarantees exactly that.

   Some of the migration code is borrowed from Kamezawa
   Hiroyuki's alloc_contig_pages() implementation.  The main
   difference is that thanks to MIGRATE_CMA migrate type CMA
   assumes that memory controlled by CMA are is always movable or
   reclaimable so that it makes allocation decisions regardless of
   the whether some pages are actually allocated and migrates them
   if needed.

   The most interesting patches from the patchset that implement
   the functionality are:

 09/13: mm: alloc_contig_free_pages() added
 10/13: mm: MIGRATE_CMA migration type added
 11/13: mm: MIGRATE_CMA isolation functions added
 12/13: mm: cma: Migration support added [wip]

   Currently, kernel panics in some situations which I am trying
   to investigate.

2. cma_pin() and cma_unpin() functions has been added (after
   a conversation with Johan Mossberg).  The idea is that whenever
   hardware does not use the memory (no transaction is on) the
   chunk can be moved around.  This would allow defragmentation to
   be implemented if desired.  No defragmentation algorithm is
   provided at this time.

3. Sysfs support has been replaced with debugfs.  I always felt
   unsure about the sysfs interface and when Greg KH pointed it
   out I finally got to rewrite it to debugfs.


v5: (intentionally left out as CMA v5 was identical to CMA v4)


v4: 1. The asterisk flag has been removed in favour of requiring
   that platform will provide a *=regions rule in the map
   attribute.
 
2. The terminology has been changed slightly renaming kind to
   type of memory.  In the previous revisions, the documentation
   indicated that device drivers define memory kinds and now,
 
v3: 1. The command line parameters have been removed (and moved to
   a separate patch, the fourth one).  As a consequence, the
   cma_set_defaults() function has been changed -- it no longer
   accepts a string with list of regions but an array of regions.
 
2. The asterisk attribute has been removed.  Now, each region
   has an asterisk flag which lets one specify whether this
   region should by considered asterisk region.
 
3. SysFS support has been moved to a separate patch (the third one
   in the series) and now also includes list of regions.
 
v2: 1. The cma_map command line have been removed.  In exchange,
   a SysFS entry has been created under kernel/mm/contiguous.
 
   The intended way of specifying the attributes is
   a cma_set_defaults() function called by platform initialisation
   code.  regions attribute (the string specified by cma
   command line parameter) can be overwritten with command line
   parameter; the other attributes can be changed during run-time
   using the SysFS entries.
 
2. The behaviour of the map attribute has been modified
   slightly.  Currently, if 

[RFCv6 10/13] mm: MIGRATE_CMA migration type added

2010-11-19 Thread Michal Nazarewicz
The MIGRATE_CMA migration type has two main characteristics:
(i) only movable and reclaimable pages can be allocated from
MIGRATE_CMA page blocks and (ii) page allocator will never
change migration type of MIGRATE_CMA page blocks.

This guarantees that page in a MIGRATE_CMA page block can
always be freed (by reclaiming it or moving somewhere else).

It is designed to be used with Contiguous Memory Allocator
(CMA) for allocating big chunks (eg. 10MiB) of physically
contiguous memory.  Once driver requests contiguous memory,
CMA will migrate or reclaim pages from MIGRATE_CMA page block.

To minimise number of migrations, MIGRATE_CMA migration type
is the last type tried when page allocator falls back to other
migration types then requested.

To use this new migration type one can use
__free_pageblock_cma() function which moves frees a whole page
block to a buddy allocator marking it (and thus all pages in
it) as MIGRATE_CMA.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/mmzone.h |   30 +
 mm/Kconfig |9 +
 mm/compaction.c|   10 ++
 mm/internal.h  |3 ++
 mm/page_alloc.c|   83 +++-
 5 files changed, 113 insertions(+), 22 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 39c24eb..317da6b 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -35,13 +35,24 @@
  */
 #define PAGE_ALLOC_COSTLY_ORDER 3
 
-#define MIGRATE_UNMOVABLE 0
-#define MIGRATE_RECLAIMABLE   1
-#define MIGRATE_MOVABLE   2
-#define MIGRATE_PCPTYPES  3 /* the number of types on the pcp lists */
-#define MIGRATE_RESERVE   3
-#define MIGRATE_ISOLATE   4 /* can't allocate from here */
-#define MIGRATE_TYPES 5
+enum {
+   MIGRATE_UNMOVABLE,
+   MIGRATE_RECLAIMABLE,
+   MIGRATE_MOVABLE,
+   MIGRATE_PCPTYPES,   /* the number of types on the pcp lists */
+   MIGRATE_RESERVE = MIGRATE_PCPTYPES,
+   MIGRATE_ISOLATE,/* can't allocate from here */
+#ifdef CONFIG_MIGRATE_CMA
+   MIGRATE_CMA,/* only movable  reclaimable */
+#endif
+   MIGRATE_TYPES
+};
+
+#ifdef CONFIG_MIGRATE_CMA
+#  define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA)
+#else
+#  define is_migrate_cma(migratetype) false
+#endif
 
 #define for_each_migratetype_order(order, type) \
for (order = 0; order  MAX_ORDER; order++) \
@@ -54,6 +65,11 @@ static inline int get_pageblock_migratetype(struct page 
*page)
return get_pageblock_flags_group(page, PB_migrate, PB_migrate_end);
 }
 
+static inline bool is_pageblock_cma(struct page *page)
+{
+   return is_migrate_cma(get_pageblock_migratetype(page));
+}
+
 struct free_area {
struct list_headfree_list[MIGRATE_TYPES];
unsigned long   nr_free;
diff --git a/mm/Kconfig b/mm/Kconfig
index 5ad2471..4aee3c5 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -1,3 +1,12 @@
+config MIGRATE_CMA
+   bool
+   help
+ This option should be selected by code that requires MIGRATE_CMA
+ migration type to be present.  Once a page block has this
+ migration type, only movable and reclaimable pages can be
+ allocated from it and the page block never changes it's
+ migration type.
+
 config SELECT_MEMORY_MODEL
def_bool y
depends on EXPERIMENTAL || ARCH_SELECT_MEMORY_MODEL
diff --git a/mm/compaction.c b/mm/compaction.c
index 4d709ee..c5e404b 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -113,6 +113,16 @@ static bool suitable_migration_target(struct page *page)
if (migratetype == MIGRATE_ISOLATE || migratetype == MIGRATE_RESERVE)
return false;
 
+   /* Keep MIGRATE_CMA alone as well. */
+   /*
+* XXX Revisit.  We currently cannot let compaction touch CMA
+* pages since compaction insists on changing their migration
+* type to MIGRATE_MOVABLE (see split_free_page() called from
+* isolate_freepages_block() above).
+*/
+   if (is_migrate_cma(migratetype))
+   return false;
+
/* If the page is a large free page, then allow migration */
if (PageBuddy(page)  page_order(page) = pageblock_order)
return true;
diff --git a/mm/internal.h b/mm/internal.h
index dedb0af..cc24e74 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -49,6 +49,9 @@ extern void putback_lru_page(struct page *page);
  * in mm/page_alloc.c
  */
 extern void __free_pages_bootmem(struct page *page, unsigned int order);
+#ifdef CONFIG_MIGRATE_CMA
+extern void __free_pageblock_cma(struct page *page);
+#endif
 extern void prep_compound_page(struct page *page, unsigned long order);
 #ifdef CONFIG_MEMORY_FAILURE
 extern bool is_free_buddy_page(struct page *page);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6dd2854..91daf22 100644
--- 

[RFCv6 09/13] mm: alloc_contig_free_pages() added

2010-11-19 Thread Michal Nazarewicz
From: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com

This commit introduces alloc_contig_free_pages() function
which allocates (ie. removes from buddy system) free pages
in range.  Caller has to guarantee that all pages in range
are in buddy system.

Along with alloc_contig_free_pages(), a free_contig_pages()
function is provided which frees (or a subset of) pages
allocated with alloc_contig_free_pages().

I, Michal Nazarewicz, have modified the
alloc_contig_free_pages() function slightly from the original
version, mostly to make it easier to allocate note MAX_ORDER
aligned pages.  This is done by making the function return
a pfn of a page one past the one allocated which may be
further then caller requested.

Signed-off-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/page-isolation.h |3 ++
 mm/page_alloc.c|   42 
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 58cdbac..f1417ed 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -32,6 +32,9 @@ test_pages_isolated(unsigned long start_pfn, unsigned long 
end_pfn);
  */
 extern int set_migratetype_isolate(struct page *page);
 extern void unset_migratetype_isolate(struct page *page);
+extern unsigned long alloc_contig_freed_pages(unsigned long start,
+ unsigned long end, gfp_t flag);
+extern void free_contig_pages(struct page *page, int nr_pages);
 
 /*
  * For migration.
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 07a6544..6dd2854 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5424,6 +5424,48 @@ out:
spin_unlock_irqrestore(zone-lock, flags);
 }
 
+unsigned long alloc_contig_freed_pages(unsigned long start,
+  unsigned long end, gfp_t flag)
+{
+   unsigned long pfn = start, count;
+   struct page *page;
+   struct zone *zone;
+   int order;
+
+   VM_BUG_ON(!pfn_valid(pfn));
+   page = pfn_to_page(pfn);
+
+   zone = page_zone(page);
+   spin_lock_irq(zone-lock);
+   for (;;) {
+   VM_BUG_ON(page_count(page) || !PageBuddy(page));
+   list_del(page-lru);
+   order = page_order(page);
+   zone-free_area[order].nr_free--;
+   rmv_page_order(page);
+   __mod_zone_page_state(zone, NR_FREE_PAGES, -(1UL  order));
+   pfn  += 1  order;
+   if (pfn = end)
+   break;
+   VM_BUG_ON(!pfn_valid(pfn));
+   page += 1  order;
+   }
+   spin_unlock_irq(zone-lock);
+
+   /* After this, pages in the range can be freed one be one */
+   page = pfn_to_page(start);
+   for (count = pfn - start; count; --count, ++page)
+   prep_new_page(page, 0, flag);
+
+   return pfn;
+}
+
+void free_contig_pages(struct page *page, int nr_pages)
+{
+   for (; nr_pages; --nr_pages, ++page)
+   __free_page(page);
+}
+
 #ifdef CONFIG_MEMORY_HOTREMOVE
 /*
  * All pages in the range must be isolated before calling this.
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv6 11/13] mm: MIGRATE_CMA isolation functions added

2010-11-19 Thread Michal Nazarewicz
This commit changes various functions that change pages and
pageblocks migrate type between MIGRATE_ISOLATE and
MIGRATE_MOVABLE in such a way as to allow to work with
MIGRATE_CMA migrate type.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/page-isolation.h |   39 ++-
 mm/page_alloc.c|6 +++---
 mm/page_isolation.c|   15 ---
 3 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index f1417ed..56f0e13 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -3,35 +3,49 @@
 
 /*
  * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE.
- * If specified range includes migrate types other than MOVABLE,
+ * If specified range includes migrate types other than MOVABLE or CMA,
  * this will fail with -EBUSY.
  *
  * For isolating all pages in the range finally, the caller have to
  * free all pages in the range. test_page_isolated() can be used for
  * test it.
  */
-extern int
-start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn);
+int __start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
+  unsigned migratetype);
+
+static inline int
+start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn)
+{
+   return __start_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
+}
+
+int __undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
+ unsigned migratetype);
 
 /*
  * Changes MIGRATE_ISOLATE to MIGRATE_MOVABLE.
  * target range is [start_pfn, end_pfn)
  */
-extern int
-undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn);
+static inline int
+undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn)
+{
+   return __undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
+}
 
 /*
- * test all pages in [start_pfn, end_pfn)are isolated or not.
+ * Test all pages in [start_pfn, end_pfn) are isolated or not.
  */
-extern int
-test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn);
+int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn);
 
 /*
- * Internal funcs.Changes pageblock's migrate type.
- * Please use make_pagetype_isolated()/make_pagetype_movable().
+ * Internal functions. Changes pageblock's migrate type.
  */
-extern int set_migratetype_isolate(struct page *page);
-extern void unset_migratetype_isolate(struct page *page);
+int set_migratetype_isolate(struct page *page);
+void __unset_migratetype_isolate(struct page *page, unsigned migratetype);
+static inline void unset_migratetype_isolate(struct page *page)
+{
+   __unset_migratetype_isolate(page, MIGRATE_MOVABLE);
+}
 extern unsigned long alloc_contig_freed_pages(unsigned long start,
  unsigned long end, gfp_t flag);
 extern void free_contig_pages(struct page *page, int nr_pages);
@@ -39,7 +53,6 @@ extern void free_contig_pages(struct page *page, int 
nr_pages);
 /*
  * For migration.
  */
-
 int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn);
 unsigned long scan_lru_pages(unsigned long start, unsigned long end);
 int do_migrate_range(unsigned long start_pfn, unsigned long end_pfn);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 91daf22..a24193e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5463,7 +5463,7 @@ out:
return ret;
 }
 
-void unset_migratetype_isolate(struct page *page)
+void __unset_migratetype_isolate(struct page *page, unsigned migratetype)
 {
struct zone *zone;
unsigned long flags;
@@ -5471,8 +5471,8 @@ void unset_migratetype_isolate(struct page *page)
spin_lock_irqsave(zone-lock, flags);
if (get_pageblock_migratetype(page) != MIGRATE_ISOLATE)
goto out;
-   set_pageblock_migratetype(page, MIGRATE_MOVABLE);
-   move_freepages_block(zone, page, MIGRATE_MOVABLE);
+   set_pageblock_migratetype(page, migratetype);
+   move_freepages_block(zone, page, migratetype);
 out:
spin_unlock_irqrestore(zone-lock, flags);
 }
diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 077cf19..ea9781e 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -23,10 +23,11 @@ __first_valid_page(unsigned long pfn, unsigned long 
nr_pages)
 }
 
 /*
- * start_isolate_page_range() -- make page-allocation-type of range of pages
+ * __start_isolate_page_range() -- make page-allocation-type of range of pages
  * to be MIGRATE_ISOLATE.
  * @start_pfn: The lower PFN of the range to be isolated.
  * @end_pfn: The upper PFN of the range to be isolated.
+ * @migratetype: migrate type to set in error recovery.
  *
  * Making page-allocation-type to be MIGRATE_ISOLATE means free pages in
  * the range will never be allocated. 

[RFCv6 08/13] mm: move some functions to page_isolation.c

2010-11-19 Thread Michal Nazarewicz
From: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com

Memory hotplug is a logic for making pages unused in the specified range
of pfn. So, some of core logics can be used for other purpose as
allocating a very large contigous memory block.

This patch moves some functions from mm/memory_hotplug.c to
mm/page_isolation.c. This helps adding a function for large-alloc in
page_isolation.c with memory-unplug technique.

Changelog: 2010/10/26
 - adjusted to mmotm-1024 + Bob's 3 clean ups.
Changelog: 2010/10/21
 - adjusted to mmotm-1020

Signed-off-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/page-isolation.h |7 +++
 mm/memory_hotplug.c|  108 --
 mm/page_isolation.c|  111 
 3 files changed, 118 insertions(+), 108 deletions(-)

diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 051c1b1..58cdbac 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -33,5 +33,12 @@ test_pages_isolated(unsigned long start_pfn, unsigned long 
end_pfn);
 extern int set_migratetype_isolate(struct page *page);
 extern void unset_migratetype_isolate(struct page *page);
 
+/*
+ * For migration.
+ */
+
+int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn);
+unsigned long scan_lru_pages(unsigned long start, unsigned long end);
+int do_migrate_range(unsigned long start_pfn, unsigned long end_pfn);
 
 #endif
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 9260314..23f4e36 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -617,114 +617,6 @@ int is_mem_section_removable(unsigned long start_pfn, 
unsigned long nr_pages)
 }
 
 /*
- * Confirm all pages in a range [start, end) is belongs to the same zone.
- */
-static int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn)
-{
-   unsigned long pfn;
-   struct zone *zone = NULL;
-   struct page *page;
-   int i;
-   for (pfn = start_pfn;
-pfn  end_pfn;
-pfn += MAX_ORDER_NR_PAGES) {
-   i = 0;
-   /* This is just a CONFIG_HOLES_IN_ZONE check.*/
-   while ((i  MAX_ORDER_NR_PAGES)  !pfn_valid_within(pfn + i))
-   i++;
-   if (i == MAX_ORDER_NR_PAGES)
-   continue;
-   page = pfn_to_page(pfn + i);
-   if (zone  page_zone(page) != zone)
-   return 0;
-   zone = page_zone(page);
-   }
-   return 1;
-}
-
-/*
- * Scanning pfn is much easier than scanning lru list.
- * Scan pfn from start to end and Find LRU page.
- */
-static unsigned long scan_lru_pages(unsigned long start, unsigned long end)
-{
-   unsigned long pfn;
-   struct page *page;
-   for (pfn = start; pfn  end; pfn++) {
-   if (pfn_valid(pfn)) {
-   page = pfn_to_page(pfn);
-   if (PageLRU(page))
-   return pfn;
-   }
-   }
-   return 0;
-}
-
-static struct page *
-hotremove_migrate_alloc(struct page *page, unsigned long private, int **x)
-{
-   /* This should be improved!! */
-   return alloc_page(GFP_HIGHUSER_MOVABLE);
-}
-
-#define NR_OFFLINE_AT_ONCE_PAGES   (256)
-static int
-do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
-{
-   unsigned long pfn;
-   struct page *page;
-   int move_pages = NR_OFFLINE_AT_ONCE_PAGES;
-   int not_managed = 0;
-   int ret = 0;
-   LIST_HEAD(source);
-
-   for (pfn = start_pfn; pfn  end_pfn  move_pages  0; pfn++) {
-   if (!pfn_valid(pfn))
-   continue;
-   page = pfn_to_page(pfn);
-   if (!page_count(page))
-   continue;
-   /*
-* We can skip free pages. And we can only deal with pages on
-* LRU.
-*/
-   ret = isolate_lru_page(page);
-   if (!ret) { /* Success */
-   list_add_tail(page-lru, source);
-   move_pages--;
-   inc_zone_page_state(page, NR_ISOLATED_ANON +
-   page_is_file_cache(page));
-
-   } else {
-#ifdef CONFIG_DEBUG_VM
-   printk(KERN_ALERT removing pfn %lx from LRU failed\n,
-  pfn);
-   dump_page(page);
-#endif
-   /* Becasue we don't have big zone-lock. we should
-  check this again here. */
-   if (page_count(page)) {
-   not_managed++;
-   ret = -EBUSY;
-   break;
-   

[RFCv6 06/13] mm: cma: Best-fit algorithm added

2010-11-19 Thread Michal Nazarewicz
This commits adds a best-fit algorithm to the set of
algorithms supported by the CMA.

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 mm/Kconfig|   16 ++-
 mm/Makefile   |1 +
 mm/cma-best-fit.c |  372 +
 3 files changed, 388 insertions(+), 1 deletions(-)
 create mode 100644 mm/cma-best-fit.c

diff --git a/mm/Kconfig b/mm/Kconfig
index a5480ea..5ad2471 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -332,10 +332,13 @@ config CLEANCACHE
 
  If unsure, say Y to enable cleancache
 
+config CMA_HAS_ALLOCATOR
+   bool
+
 config CMA
bool Contiguous Memory Allocator framework
# Currently there is only one allocator so force it on
-   select CMA_GENERIC_ALLOCATOR
+   select CMA_GENERIC_ALLOCATOR if !CMA_HAS_ALLOCATOR
help
  This enables the Contiguous Memory Allocator framework which
  allows drivers to allocate big physically-contiguous blocks of
@@ -391,3 +394,14 @@ config CMA_GENERIC_ALLOCATOR
  implementations: the first-fit, bitmap-based algorithm or
  a best-fit, red-black tree-based algorithm.  The algorithm can
  be changed under Library routines.
+
+config CMA_BEST_FIT
+   bool CMA best-fit allocator
+   depends on CMA
+   select CMA_HAS_ALLOCATOR
+   help
+ This is a best-fit algorithm running in O(n log n) time where
+ n is the number of existing holes (which is never greater then
+ the number of allocated regions and usually much smaller).  It
+ allocates area from the smallest hole that is big enough for
+ allocation in question.
diff --git a/mm/Makefile b/mm/Makefile
index c6a84f1..2cb2569 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -44,3 +44,4 @@ obj-$(CONFIG_DEBUG_KMEMLEAK) += kmemleak.o
 obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak-test.o
 obj-$(CONFIG_CLEANCACHE) += cleancache.o
 obj-$(CONFIG_CMA) += cma.o
+obj-$(CONFIG_CMA_BEST_FIT) += cma-best-fit.o
diff --git a/mm/cma-best-fit.c b/mm/cma-best-fit.c
new file mode 100644
index 000..5ed1168
--- /dev/null
+++ b/mm/cma-best-fit.c
@@ -0,0 +1,372 @@
+/*
+ * Contiguous Memory Allocator framework: Best Fit allocator
+ * Copyright (c) 2010 by Samsung Electronics.
+ * Written by Michal Nazarewicz (m.nazarew...@samsung.com)
+ *
+ * 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 optional) any later version of the license.
+ */
+
+#define pr_fmt(fmt) cma: bf:  fmt
+
+#ifdef CONFIG_CMA_DEBUG
+#  define DEBUG
+#endif
+
+#include linux/errno.h   /* Error numbers */
+#include linux/slab.h/* kmalloc() */
+
+#include linux/cma.h /* CMA structures */
+
+
+/* Data Types */
+
+struct cma_bf_node {
+   unsigned long v;
+   struct rb_node n;
+};
+
+union cma_bf_item {
+   struct cma chunk;
+   struct {
+   struct cma_bf_node start, size;
+   };
+};
+
+struct cma_bf_private {
+   struct rb_root by_start_root;
+   struct rb_root by_size_root;
+   bool warned;
+};
+
+
+/* Basic Tree Manipulation */
+
+static int  cma_bf_node_add(struct cma_bf_node *node, struct rb_root *root,
+   bool unique)
+{
+   struct rb_node **link = root-rb_node, *parent = NULL;
+   const unsigned long v = node-v;
+
+   while (*link) {
+   struct cma_bf_node *n;
+   parent = *link;
+   n = rb_entry(parent, struct cma_bf_node, n);
+
+   if (unlikely(unique  v == n-v))
+   return -EBUSY;
+
+   link = v = n-v ? parent-rb_left : parent-rb_right;
+   }
+
+   rb_link_node(node-n, parent, link);
+   rb_insert_color(node-n, root);
+
+   return 0;
+}
+
+static void cma_bf_node_del(struct cma_bf_node *node, struct rb_root *root)
+{
+   rb_erase(node-n, root);
+}
+
+static int  cma_bf_item_add_by_start(union cma_bf_item *item,
+struct cma_bf_private *prv)
+{
+   int ret = cma_bf_node_add(item-start, prv-by_start_root, true);
+   if (WARN_ON(ret  !prv-warned))
+   prv-warned = true;
+   return ret;
+}
+
+static void cma_bf_item_del_by_start(union cma_bf_item *item,
+struct cma_bf_private *prv)
+{
+   cma_bf_node_del(item-start, prv-by_start_root);
+}
+
+static void cma_bf_item_add_by_size(union cma_bf_item *item,
+   struct cma_bf_private *prv)
+{
+   cma_bf_node_add(item-size, prv-by_size_root, false);
+}
+
+static void cma_bf_item_del_by_size(union cma_bf_item *item,
+   struct cma_bf_private *prv)
+{

[RFCv6 03/13] lib: genalloc: Generic allocator improvements

2010-11-19 Thread Michal Nazarewicz
This commit adds a gen_pool_alloc_aligned() function to the
generic allocator API.  It allows specifying alignment for the
allocated block.  This feature uses
the bitmap_find_next_zero_area_off() function.

It also fixes possible issue with bitmap's last element being
not fully allocated (ie. space allocated for chunk-bits is
not a multiple of sizeof(long)).

It also makes some other smaller changes:
- moves structure definitions out of the header file,
- adds __must_check to functions returning value,
- makes gen_pool_add() return -ENOMEM rater than -1 on error,
- changes list_for_each to list_for_each_entry, and
- makes use of bitmap_clear().

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/genalloc.h |   46 ++--
 lib/genalloc.c   |  182 ++---
 2 files changed, 129 insertions(+), 99 deletions(-)

diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index 9869ef3..8ac7337 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -8,29 +8,31 @@
  * Version 2.  See the file COPYING for more details.
  */
 
+struct gen_pool;
 
-/*
- *  General purpose special memory pool descriptor.
- */
-struct gen_pool {
-   rwlock_t lock;
-   struct list_head chunks;/* list of chunks in this pool */
-   int min_alloc_order;/* minimum allocation order */
-};
+struct gen_pool *__must_check gen_pool_create(unsigned order, int nid);
 
-/*
- *  General purpose special memory pool chunk descriptor.
+int __must_check gen_pool_add(struct gen_pool *pool, unsigned long addr,
+ size_t size, int nid);
+
+void gen_pool_destroy(struct gen_pool *pool);
+
+unsigned long __must_check
+gen_pool_alloc_aligned(struct gen_pool *pool, size_t size,
+  unsigned alignment_order);
+
+/**
+ * gen_pool_alloc() - allocate special memory from the pool
+ * @pool:  Pool to allocate from.
+ * @size:  Number of bytes to allocate from the pool.
+ *
+ * Allocate the requested number of bytes from the specified pool.
+ * Uses a first-fit algorithm.
  */
-struct gen_pool_chunk {
-   spinlock_t lock;
-   struct list_head next_chunk;/* next chunk in pool */
-   unsigned long start_addr;   /* starting address of memory chunk */
-   unsigned long end_addr; /* ending address of memory chunk */
-   unsigned long bits[0];  /* bitmap for allocating memory chunk */
-};
+static inline unsigned long __must_check
+gen_pool_alloc(struct gen_pool *pool, size_t size)
+{
+   return gen_pool_alloc_aligned(pool, size, 0);
+}
 
-extern struct gen_pool *gen_pool_create(int, int);
-extern int gen_pool_add(struct gen_pool *, unsigned long, size_t, int);
-extern void gen_pool_destroy(struct gen_pool *);
-extern unsigned long gen_pool_alloc(struct gen_pool *, size_t);
-extern void gen_pool_free(struct gen_pool *, unsigned long, size_t);
+void gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size);
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 1923f14..dc6d833 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -15,54 +15,81 @@
 #include linux/bitmap.h
 #include linux/genalloc.h
 
+/* General purpose special memory pool descriptor. */
+struct gen_pool {
+   rwlock_t lock;  /* protects chunks list */
+   struct list_head chunks;/* list of chunks in this pool */
+   unsigned order; /* minimum allocation order */
+};
+
+/* General purpose special memory pool chunk descriptor. */
+struct gen_pool_chunk {
+   spinlock_t lock;/* protects bits */
+   struct list_head next_chunk;/* next chunk in pool */
+   unsigned long start;/* start of memory chunk */
+   unsigned long size; /* number of bits */
+   unsigned long bits[0];  /* bitmap for allocating memory chunk */
+};
 
 /**
- * gen_pool_create - create a new special memory pool
- * @min_alloc_order: log base 2 of number of bytes each bitmap bit represents
- * @nid: node id of the node the pool structure should be allocated on, or -1
+ * gen_pool_create() - create a new special memory pool
+ * @order: Log base 2 of number of bytes each bitmap bit
+ * represents.
+ * @nid:   Node id of the node the pool structure should be allocated
+ * on, or -1.
  *
  * Create a new special memory pool that can be used to manage special purpose
  * memory not managed by the regular kmalloc/kfree interface.
  */
-struct gen_pool *gen_pool_create(int min_alloc_order, int nid)
+struct gen_pool *__must_check gen_pool_create(unsigned order, int nid)
 {
struct gen_pool *pool;
 
-   pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid);
-   if (pool != NULL) {
+   if (WARN_ON(order = BITS_PER_LONG))
+   return NULL;
+
+   pool = kmalloc_node(sizeof 

[RFCv6 12/13] mm: cma: Migration support added [wip]

2010-11-19 Thread Michal Nazarewicz
This commits adds cma_early_grab_pageblocks() function as well
as makes cma_early_region_reserve() function use the former if
some conditions are met.

Grabbed pageblocks are later given back to page allocator with
migration type set to MIGRATE_CMA.  This guarantees that only
movable and reclaimable pages are allocated from those page
blocks.

* * * THIS COMMIT IS NOT YET FINISHED * * *

Signed-off-by: Michal Nazarewicz m.nazarew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/cma.h |   38 +++-
 mm/Kconfig  |   15 +++
 mm/cma-best-fit.c   |   12 +++-
 mm/cma.c|  239 +++
 4 files changed, 299 insertions(+), 5 deletions(-)

diff --git a/include/linux/cma.h b/include/linux/cma.h
index 56ed021..6a56e2a 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -310,10 +310,6 @@ struct cma_region {
const char *alloc_name;
void *private_data;
 
-#ifdef CONFIG_CMA_USE_MIGRATE_CMA
-   unsigned short *isolation_map;
-#endif
-
unsigned users;
struct list_head list;
 
@@ -327,7 +323,9 @@ struct cma_region {
unsigned reserved:1;
unsigned copy_name:1;
unsigned free_alloc_name:1;
+#ifdef CONFIG_CMA_USE_MIGRATE_CMA
unsigned use_isolate:1;
+#endif
 };
 
 /**
@@ -449,6 +447,38 @@ struct cma_allocator {
  */
 int cma_allocator_register(struct cma_allocator *alloc);
 
+/**
+ * __cma_grab() - migrates all pages from range and reserves them for CMA
+ * @reg:   Region this call is made in context of.  If the region is
+ * not marked needing grabbing the function does nothing.
+ * @start: Address in bytes of the first byte to free.
+ * @size:  Size of the region to free.
+ *
+ * This function should be used when allocator wants to allocate some
+ * physical memory to make sure that it is not used for any movable or
+ * reclaimable pages (eg. page cache).
+ *
+ * In essence, this function migrates all movable and reclaimable
+ * pages from the range and then removes them from buddy system so
+ * page allocator won't consider them when allocating space.
+ *
+ * The allocator may assume that it is unlikely for this function to fail so
+ * if it fails allocator should just recover and return error.
+ */
+int __cma_grab(struct cma_region *reg, phys_addr_t start, size_t size);
+
+/**
+ * cma_ungrab_range() - frees pages from range back to buddy system.
+ * @reg:   Region this call is made in context of.  If the region is
+ * not marked needing grabbing the function does nothing.
+ * @start: Address in bytes of the first byte to free.
+ * @size:  Size of the region to free.
+ *
+ * This is reverse of cma_grab_range().  Allocator should use it when
+ * physical memory is no longer used.
+ */
+void __cma_ungrab(struct cma_region *reg, phys_addr_t start, size_t size);
+
 
 / Initialisation API /
 
diff --git a/mm/Kconfig b/mm/Kconfig
index 4aee3c5..80fd6bd 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -363,6 +363,21 @@ config CMA
  For more information see Documentation/contiguous-memory.txt.
  If unsure, say n.
 
+config CMA_USE_MIGRATE_CMA
+   bool Use MIGRATE_CMA
+   depends on CMA
+   default y
+   select MIGRATION
+   select MIGRATE_CMA
+   help
+ This makes CMA use MIGRATE_CMA migration type for regions
+ maintained by CMA.  This makes it possible for standard page
+ allocator to use pages from such regions.  This in turn may
+ make the whole system run faster as there will be more space
+ for page caches, etc.
+
+ If unsure, say y.
+
 config CMA_DEVELOPEMENT
bool Include CMA developement features
depends on CMA
diff --git a/mm/cma-best-fit.c b/mm/cma-best-fit.c
index 5ed1168..15f4206 100644
--- a/mm/cma-best-fit.c
+++ b/mm/cma-best-fit.c
@@ -145,6 +145,8 @@ static void cma_bf_cleanup(struct cma_region *reg)
kfree(prv);
 }
 
+static void __cma_bf_free(struct cma_region *reg, union cma_bf_item *chunk);
+
 struct cma *cma_bf_alloc(struct cma_region *reg,
 size_t size, unsigned long alignment)
 {
@@ -281,10 +283,17 @@ case_2:
 
item-chunk.phys = start;
item-chunk.size = size;
+
+   ret = __cma_grab(reg, start, size);
+   if (ret) {
+   __cma_bf_free(reg, item);
+   return ERR_PTR(ret);
+   }
+
return item-chunk;
 }
 
-static void cma_bf_free(struct cma_chunk *chunk)
+static void __cma_bf_free(struct cma_region *reg, union cma_bf_item *item)
 {
struct cma_bf_private *prv = reg-private_data;
union cma_bf_item *prev;
@@ -350,6 +359,7 @@ next:
}
 }
 
+static void cma_bf_free(struct cma *chunk)
 {
__cma_ungrab(chunk-reg, chunk-phys, chunk-size);
__cma_bf_free(chunk-reg, 
diff --git a/mm/cma.c b/mm/cma.c
index dfdeeb7..510181a 

[omap3isp] Prefered patch base for latest code? (was: RE: Translation faults with OMAP ISP)

2010-11-19 Thread Aguirre, Sergio
Hi David and Laurent,

snip

 
  Don't forget that Lane is using an older version of the OMAP3 ISP
 driver. The
  bug might have been fixed in the latest code.
 
 Hm. We did fix some iommu faults.
 Maybe it's better to test a newer version instead.
 If you still see that bug using an up-to-date version, please report it
 and I can try to help you. :)

How close is this tree from the latest internal version you guys work with?

http://meego.gitorious.com/maemo-multimedia/omap3isp-rx51/commits/devel

I have been basing my patches on top of this tree:

http://git.linuxtv.org/pinchartl/media.git?h=refs/heads/media-0004-omap3isp

Would it be better to be based on the gitorious tree instead?

What do you think?

Regards,
Sergio

 
 Regards,
 
 David
 
 
  --
  Regards,
 
  Laurent Pinchart
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [omap3isp] Prefered patch base for latest code? (was: RE: Translation faults with OMAP ISP)

2010-11-19 Thread Laurent Pinchart
Hi Sergio,

On Friday 19 November 2010 17:07:09 Aguirre, Sergio wrote:
 Hi David and Laurent,
 
 snip
 
   Don't forget that Lane is using an older version of the OMAP3 ISP
   driver. The bug might have been fixed in the latest code.
  
  Hm. We did fix some iommu faults.
  Maybe it's better to test a newer version instead.
  If you still see that bug using an up-to-date version, please report it
  and I can try to help you. :)
 
 How close is this tree from the latest internal version you guys work with?
 
 http://meego.gitorious.com/maemo-multimedia/omap3isp-rx51/commits/devel

There's less differences between gitorious and our internal tree than between 
linuxtv and our internal tree.

 I have been basing my patches on top of this tree:
 
 http://git.linuxtv.org/pinchartl/media.git?h=refs/heads/media-0004-omap3isp
 
 Would it be better to be based on the gitorious tree instead?
 
 What do you think?

I will push a big patch that ports all the changes made to the MC and V4L2 
core, as well as omap3-isp driver, during public review to our internal tree 
early next week (should be on Monday). The trees will then get in sync. The 
gitorious tree will be updated as well.

Unless you want your patches to be applied before Monday, which won't happen 
anyway, please base them on the linuxtv tree :-)

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [omap3isp] Prefered patch base for latest code? (was: RE: Translation faults with OMAP ISP)

2010-11-19 Thread Aguirre, Sergio
Hi Laurent,

 -Original Message-
 From: Laurent Pinchart [mailto:laurent.pinch...@ideasonboard.com]
 Sent: Friday, November 19, 2010 10:16 AM
 To: Aguirre, Sergio
 Cc: David Cohen; ext Lane Brooks; linux-media@vger.kernel.org
 Subject: Re: [omap3isp] Prefered patch base for latest code? (was: RE:
 Translation faults with OMAP ISP)
 
 Hi Sergio,
 
 On Friday 19 November 2010 17:07:09 Aguirre, Sergio wrote:
  Hi David and Laurent,
 
  snip
 
Don't forget that Lane is using an older version of the OMAP3 ISP
driver. The bug might have been fixed in the latest code.
  
   Hm. We did fix some iommu faults.
   Maybe it's better to test a newer version instead.
   If you still see that bug using an up-to-date version, please report
 it
   and I can try to help you. :)
 
  How close is this tree from the latest internal version you guys work
 with?
 
  http://meego.gitorious.com/maemo-multimedia/omap3isp-rx51/commits/devel
 
 There's less differences between gitorious and our internal tree than
 between
 linuxtv and our internal tree.

Ok, I guess I can treat above tree as an omap3isp-next tree then, to have
a sneak preview of what's coming ;)

 
  I have been basing my patches on top of this tree:
 
  http://git.linuxtv.org/pinchartl/media.git?h=refs/heads/media-0004-
 omap3isp
 
  Would it be better to be based on the gitorious tree instead?
 
  What do you think?
 
 I will push a big patch that ports all the changes made to the MC and V4L2
 core, as well as omap3-isp driver, during public review to our internal
 tree
 early next week (should be on Monday). The trees will then get in sync.
 The
 gitorious tree will be updated as well.
 
 Unless you want your patches to be applied before Monday, which won't
 happen
 anyway, please base them on the linuxtv tree :-)

Ok, sure. It's better for me, since the gitorious devel tree includes rx51
support which I don't even have a device to try it out :P

I'll continue to be based on media-0004-omap3isp branch then, and just watch
devel branch to know if I'm not doing something conflicting.

Regards,
Sergio
 
 --
 Regards,
 
 Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [omap3isp] Prefered patch base for latest code? (was: RE: Translation faults with OMAP ISP)

2010-11-19 Thread Laurent Pinchart
Hi Sergio,

On Friday 19 November 2010 17:23:45 Aguirre, Sergio wrote:
 On Friday, November 19, 2010 10:16 AM Aguirre, Sergio wrote:
  On Friday 19 November 2010 17:07:09 Aguirre, Sergio wrote:

[snip]

   How close is this tree from the latest internal version you guys work
   with?
  
   http://meego.gitorious.com/maemo-multimedia/omap3isp-rx51/commits/devel
  
  There's less differences between gitorious and our internal tree than
  between linuxtv and our internal tree.
 
 Ok, I guess I can treat above tree as an omap3isp-next tree then, to have
 a sneak preview of what's coming ;)

I haven't expressed myself clearly enough. The gitorious tree is currently 
more in sync with our internal tree that the linuxtv is for a simple reason: 
both our internal tree and the gitorious tree are missing modifications made 
during the public review process.

Patches published from our internal tree are always pushed to linuxtv and 
gitorious at the same time (or mostly). Please don't use the gitorious tree 
for anything else than trying the driver on the N900.

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [omap3isp] Prefered patch base for latest code? (was: RE: Translation faults with OMAP ISP)

2010-11-19 Thread Aguirre, Sergio
Hi Laurent,

 -Original Message-
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Laurent Pinchart
 Sent: Friday, November 19, 2010 10:32 AM
 To: Aguirre, Sergio
 Cc: David Cohen; ext Lane Brooks; linux-media@vger.kernel.org
 Subject: Re: [omap3isp] Prefered patch base for latest code? (was: RE:
 Translation faults with OMAP ISP)
 
 Hi Sergio,
 
 On Friday 19 November 2010 17:23:45 Aguirre, Sergio wrote:
  On Friday, November 19, 2010 10:16 AM Aguirre, Sergio wrote:
   On Friday 19 November 2010 17:07:09 Aguirre, Sergio wrote:
 
 [snip]
 
How close is this tree from the latest internal version you guys
 work
with?
   
http://meego.gitorious.com/maemo-multimedia/omap3isp-
 rx51/commits/devel
  
   There's less differences between gitorious and our internal tree than
   between linuxtv and our internal tree.
 
  Ok, I guess I can treat above tree as an omap3isp-next tree then, to
 have
  a sneak preview of what's coming ;)
 
 I haven't expressed myself clearly enough. The gitorious tree is currently
 more in sync with our internal tree that the linuxtv is for a simple
 reason:
 both our internal tree and the gitorious tree are missing modifications
 made
 during the public review process.

Ok. Sorry, I think I didn't quite understood that.

 
 Patches published from our internal tree are always pushed to linuxtv and
 gitorious at the same time (or mostly). Please don't use the gitorious
 tree
 for anything else than trying the driver on the N900.

I see. So I probably won't worry about this tree at all, since I don't have an 
N900.

I'm trying this in my Zoom board w/OMAP3630, and I have a Beagleboard xM handy 
aswell (OMAP3730), so In my tree I'll try to keep support for both of
These.

Also, I'm working on trying to bring this in a very different chip, but that's 
a secret ;) That's why I'm working in doing cleanups.

Regards,
Sergio

 
 --
 Regards,
 
 Laurent Pinchart
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


tvp5150 extension to tvp5151

2010-11-19 Thread Raffaele Recalcati
I need to support fully tvp5151.
So I'm trying to understand your driver, that is ready for VBI and not
for video acquisition.
I also take sometimes a look at tvp514x.c, for instance trying to add
VIDIOC_ENUM_FMT and other ioctls.
I think we can move from tvp5150.c to tvp515x.c, maybe...
I don't think is good to have tvp51xx.c because tvp514x.c family is
more complex (more inputs...).
By now I'm using tvp5150.c with some modifications and video acquisition works.
I need to complete the support in order to have gstreamer fully running.
I'm working on 2.6.32, but I have planned to port it to mainline.
Do you have any suggestion for my work?

Thx,
Raffaele
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[cron job] v4l-dvb daily build: WARNINGS

2010-11-19 Thread Hans Verkuil
This message is generated daily by a cron job that builds v4l-dvb for
the kernels and architectures in the list below.

Results of the daily build of v4l-dvb:

date:Fri Nov 19 19:00:22 CET 2010
git master:   59365d136d205cc20fe666ca7f89b1c5001b0d5a
git media-master: gcc version:  i686-linux-gcc (GCC) 4.5.1
host hardware:x86_64
host os:  2.6.32.5

linux-git-armv5: WARNINGS
linux-git-armv5-davinci: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-armv5-omap2: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: WARNINGS
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.tar.bz2

The V4L-DVB specification from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: video: pvrusb2: fix memory leak

2010-11-19 Thread Vasiliy Kulikov
Use put_device() instead of kfree() because of device name leak.

Signed-off-by: Vasiliy Kulikov seg...@openwall.com
---
 Compile tested only.

 drivers/media/video/pvrusb2/pvrusb2-sysfs.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c 
b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 3d7e5aa..281806b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -647,7 +647,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
if (ret) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
   device_register failed);
-   kfree(class_dev);
+   put_device(class_dev);
return;
}
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] drivers/media: nuvoton: fix chip id probe

2010-11-19 Thread Jarod Wilson
On Wed, Nov 17, 2010 at 11:35:25AM +0100, Nicolas Kaiser wrote:
 Make sure we have a matching chip id high and one or the other
 of the chip id low values.
 Print the values if the probe fails.
 
 Signed-off-by: Nicolas Kaiser ni...@nikai.net
 ---
 Like this?
 Supersedes patch drivers/media: nuvoton: always true expression.
 
  drivers/media/IR/nuvoton-cir.c |7 +--
  1 files changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/IR/nuvoton-cir.c b/drivers/media/IR/nuvoton-cir.c
 index 301be53..92d32c8 100644
 --- a/drivers/media/IR/nuvoton-cir.c
 +++ b/drivers/media/IR/nuvoton-cir.c
 @@ -249,9 +249,12 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
   chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO);
   nvt_dbg(%s: chip id: 0x%02x 0x%02x, chip_id, chip_major, chip_minor);
  
 - if (chip_major != CHIP_ID_HIGH 
 - (chip_minor != CHIP_ID_LOW || chip_minor != CHIP_ID_LOW2))
 + if (chip_major != CHIP_ID_HIGH ||
 + (chip_minor != CHIP_ID_LOW  chip_minor != CHIP_ID_LOW2)) {
 + nvt_pr(KERN_ERR, %s: chip id mismatch: 0x%02x 0x%02x,

I'd probably go with unsupported chip, id:  instead, since it makes the
message a bit clearer, but generally speaking, yeah, something along
those lines should be fine.

-- 
Jarod Wilson
ja...@redhat.com

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/media: nuvoton: fix chip id probe v2

2010-11-19 Thread Nicolas Kaiser
Make sure we have a matching chip id high and one or the other
of the chip id low values.
Print the values if the probe fails.

Signed-off-by: Nicolas Kaiser ni...@nikai.net
---
 drivers/media/IR/nuvoton-cir.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/IR/nuvoton-cir.c b/drivers/media/IR/nuvoton-cir.c
index 301be53..e3274ef 100644
--- a/drivers/media/IR/nuvoton-cir.c
+++ b/drivers/media/IR/nuvoton-cir.c
@@ -249,9 +249,12 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO);
nvt_dbg(%s: chip id: 0x%02x 0x%02x, chip_id, chip_major, chip_minor);
 
-   if (chip_major != CHIP_ID_HIGH 
-   (chip_minor != CHIP_ID_LOW || chip_minor != CHIP_ID_LOW2))
+   if (chip_major != CHIP_ID_HIGH ||
+   (chip_minor != CHIP_ID_LOW  chip_minor != CHIP_ID_LOW2)) {
+   nvt_pr(KERN_ERR, %s: unsupported chip, id: 0x%02x 0x%02x,
+  chip_id, chip_major, chip_minor);
ret = -ENODEV;
+   }
 
nvt_efm_disable(nvt);
 
-- 
1.7.2.2
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PATCHES FOR 2.6.37]

2010-11-19 Thread Hans Verkuil
Hi Mauro,

Here is the pull request for the patch series that:

1) Converts 29 drivers to unlocked_ioctl
2) Improves the v4l core by using mutex_lock_interruptible and fixes
   incorrect return codes for poll, write and read.
3) Improves the BKL-replacement code so that VIDIOC_DQBUF is no longer
   using the core locks (either the static lock or the new per-v4l2_device
   lock).

Three drivers may develop problems by not locking DQBUF: uvc (this must be
converted for 2.6.37 to unlocked_ioctl due to its popularity), stk-webcam.c
and usbvision. The stk-webcam driver has no locking whatsoever. I will see if
I can prepare a patch converting it to core-assisted locking.

usbvision has some sort of locking already and is likely to be OK, or at least
as likely as that driver ever was since it has many problems already.

Regarding point 2: poll didn't return POLLERR in case of an error, and read
and write returned -EIO for unregistered (i.e. disconnected) device nodes
whereas elsewhere in the kernel -ENODEV is used for that. That makes more sense
as well.

I have two possible trees for you to pull from. The first uses
mutex_lock_interruptible for mmap:

The following changes since commit e53beacd23d9cb47590da6a7a7f6d417b941a994:
  Linus Torvalds (1):
Linux 2.6.37-rc2

are available in the git repository at:

  ssh://linuxtv.org/git/hverkuil/media_tree.git bkl-lock-int

Hans Verkuil (14):
  BKL: trivial BKL removal from V4L2 radio drivers
  cadet: use unlocked_ioctl
  tea5764: convert to unlocked_ioctl
  si4713: convert to unlocked_ioctl
  typhoon: convert to unlocked_ioctl.
  BKL: trivial ioctl - unlocked_ioctl video driver conversions
  sn9c102: convert to unlocked_ioctl.
  et61x251_core: trivial conversion to unlocked_ioctl.
  cafe_ccic: replace ioctl by unlocked_ioctl.
  sh_vou: convert to unlocked_ioctl.
  radio-timb: convert to unlocked_ioctl.
  cx18: convert to unlocked_ioctl.
  v4l2-dev: use mutex_lock_interruptible instead of plain mutex_lock
  V4L: improve the BKL replacement heuristic

 drivers/media/radio/radio-aimslab.c  |   16 +++---
 drivers/media/radio/radio-aztech.c   |6 +-
 drivers/media/radio/radio-cadet.c|   12 +++-
 drivers/media/radio/radio-gemtek-pci.c   |6 +-
 drivers/media/radio/radio-gemtek.c   |   14 ++--
 drivers/media/radio/radio-maestro.c  |   14 ++---
 drivers/media/radio/radio-maxiradio.c|2 +-
 drivers/media/radio/radio-miropcm20.c|6 +-
 drivers/media/radio/radio-rtrack2.c  |   10 ++--
 drivers/media/radio/radio-sf16fmi.c  |7 +-
 drivers/media/radio/radio-sf16fmr2.c |   11 ++--
 drivers/media/radio/radio-si4713.c   |3 +-
 drivers/media/radio/radio-tea5764.c  |   49 +++
 drivers/media/radio/radio-terratec.c |8 +-
 drivers/media/radio/radio-timb.c |5 +-
 drivers/media/radio/radio-trust.c|   18 +++---
 drivers/media/radio/radio-typhoon.c  |   16 +++---
 drivers/media/radio/radio-zoltrix.c  |   30 +-
 drivers/media/video/arv.c|2 +-
 drivers/media/video/bw-qcam.c|2 +-
 drivers/media/video/c-qcam.c |2 +-
 drivers/media/video/cafe_ccic.c  |2 +-
 drivers/media/video/cx18/cx18-alsa-pcm.c |8 ++-
 drivers/media/video/cx18/cx18-streams.c  |2 +-
 drivers/media/video/et61x251/et61x251_core.c |2 +-
 drivers/media/video/meye.c   |   14 ++--
 drivers/media/video/pms.c|2 +-
 drivers/media/video/sh_vou.c |   13 +++--
 drivers/media/video/sn9c102/sn9c102_core.c   |2 +-
 drivers/media/video/v4l2-dev.c   |   85 --
 drivers/media/video/v4l2-device.c|1 +
 drivers/media/video/w9966.c  |2 +-
 include/media/v4l2-device.h  |2 +
 33 files changed, 207 insertions(+), 167 deletions(-)

And the second uses mutex_lock for mmap():

The following changes since commit e53beacd23d9cb47590da6a7a7f6d417b941a994:
  Linus Torvalds (1):
Linux 2.6.37-rc2

are available in the git repository at:

  ssh://linuxtv.org/git/hverkuil/media_tree.git bkl-lock

Hans Verkuil (14):
  BKL: trivial BKL removal from V4L2 radio drivers
  cadet: use unlocked_ioctl
  tea5764: convert to unlocked_ioctl
  si4713: convert to unlocked_ioctl
  typhoon: convert to unlocked_ioctl.
  BKL: trivial ioctl - unlocked_ioctl video driver conversions
  sn9c102: convert to unlocked_ioctl.
  et61x251_core: trivial conversion to unlocked_ioctl.
  cafe_ccic: replace ioctl by unlocked_ioctl.
  sh_vou: convert to unlocked_ioctl.
  radio-timb: convert to unlocked_ioctl.
  cx18: convert to unlocked_ioctl.
  v4l2-dev: use mutex_lock_interruptible instead of plain mutex_lock
  V4L: improve the 

Re: [omap3isp][PATCH v2 5/9] omap3isp: Remove unused CBUFF register access

2010-11-19 Thread David Cohen
On Fri, Nov 19, 2010 at 04:54:01PM +0100, ext Aguirre, Sergio wrote:
 Hi Laurent and David,

Hi Sergio,

 
  -Original Message-
  From: Laurent Pinchart [mailto:laurent.pinch...@ideasonboard.com]
  Sent: Friday, November 19, 2010 4:33 AM
  To: David Cohen
  Cc: Aguirre, Sergio; linux-media@vger.kernel.org
  Subject: Re: [omap3isp][PATCH v2 5/9] omap3isp: Remove unused CBUFF
  register access
  
  Hi David,
  
  On Friday 19 November 2010 11:19:44 David Cohen wrote:
   On Mon, Nov 15, 2010 at 03:29:57PM +0100, ext Sergio Aguirre wrote:
  
  [snip]
  
@@ -244,26 +239,6 @@
   
 #define ISP_CSIB_SYSCONFIG ISPCCP2_SYSCONFIG
 #define ISP_CSIA_SYSCONFIG ISPCSI2_SYSCONFIG
   
-/* ISP_CBUFF Registers */
-
-#define ISP_CBUFF_SYSCONFIG(0x010)
-#define ISP_CBUFF_IRQENABLE(0x01C)
-
-#define ISP_CBUFF0_CTRL(0x020)
-#define ISP_CBUFF1_CTRL(0x024)
-
-#define ISP_CBUFF0_START   (0x040)
-#define ISP_CBUFF1_START   (0x044)
-
-#define ISP_CBUFF0_END (0x050)
-#define ISP_CBUFF1_END (0x054)
-
-#define ISP_CBUFF0_WINDOWSIZE  (0x060)
-#define ISP_CBUFF1_WINDOWSIZE  (0x064)
-
-#define ISP_CBUFF0_THRESHOLD   (0x070)
-#define ISP_CBUFF1_THRESHOLD   (0x074)
-
  
   No need to remove the registers from header file. We're not using them
   on current version, but it doesn't mean we won't use ever. :)
  
  I would have made the same comment for other registers, but we're not
  using
  the CBUFF module at all here, with no plans to use it in the future. It
  might
  not be worth it keeping the register definitions. I have no strong feeling
  about it, I'm fine with both choices.
 
 David,
 
 IMO, we should not introduce dead code/unusued defines in the first omap3isp
 upstream version. I think it's already quite hard to review for somebody
 outside the omap3isp development team.
 
 Having all this just in case will most probably end up in bulk, as we
 might never implement the CBUFF HW block, as Laurent mentions.

That's a good point. I see no problem in removing it in that case.

Br,

David

 
 I'll be more biased on all this being re-added if we end up implementing a 
 ispcbuff submodule.
 
 Regards,
 Sergio
 
 
  
  --
  Regards,
  
  Laurent Pinchart
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] drivers/media: nuvoton: fix chip id probe v2

2010-11-19 Thread Jarod Wilson
On Fri, Nov 19, 2010 at 09:42:40PM +0100, Nicolas Kaiser wrote:
 Make sure we have a matching chip id high and one or the other
 of the chip id low values.
 Print the values if the probe fails.
 
 Signed-off-by: Nicolas Kaiser ni...@nikai.net

That works for me, thanks much.

Acked-by: Jarod Wilson ja...@redhat.com

-- 
Jarod Wilson
ja...@redhat.com

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [omap3isp][PATCH v2 7/9] omap3isp: Cleanup isp_power_settings

2010-11-19 Thread Aguirre, Sergio


 -Original Message-
 From: Aguirre, Sergio
 Sent: Friday, November 19, 2010 9:46 AM
 To: 'David Cohen'
 Cc: Laurent Pinchart; linux-media@vger.kernel.org
 Subject: RE: [omap3isp][PATCH v2 7/9] omap3isp: Cleanup isp_power_settings
  -Original Message-
  From: David Cohen [mailto:david.co...@nokia.com]
  Sent: Friday, November 19, 2010 4:18 AM
  To: Aguirre, Sergio
  Cc: Laurent Pinchart; linux-media@vger.kernel.org
  Subject: Re: [omap3isp][PATCH v2 7/9] omap3isp: Cleanup
 isp_power_settings
 
  Hi Sergio,
 
  Thanks for the patch.
 
 Hi David,
 
 Thanks for the comments.
 
 
  On Mon, Nov 15, 2010 at 03:29:59PM +0100, ext Sergio Aguirre wrote:
   1. Get rid of CSI2 / CCP2 power settings, as they are controlled
  in the receivers code anyways.
 
  CCP2 is not correctly handling this. It's setting SMART STANDBY mode one
  when reading from memory. You should fix it before remove such code from
  ISP core driver.
 
 Ok, agreed.
 
 I'll generate a new patch before this to compensate that. Not a problem.

Is N900 seeing any functional difference w/ this patch?

Actually, I reanalyzed the patch, and this code should be unexecuted, since
it is conditioned to 3430 ES1.0 chip (omap_rev() == OMAP3430_REV_ES1_0),
which I don't think much people has access. And not definitely any
production quality device.

Even the N900 is using ES3.1 or something like that AFAIK.

So, It should not make any functional difference, unless you have an ES1.0.

Regards,
Sergio

 
 
   2. Avoid code duplication.
 
  Agree. But only after considering the comment above.
 
 Ok.
 
 Thanks and Regards,
 Sergio
 
 
  Regards,
 
  David
 
  
   Signed-off-by: Sergio Aguirre saagui...@ti.com
   ---
drivers/media/video/isp/isp.c |   49 ++--
 --
  ---
1 files changed, 7 insertions(+), 42 deletions(-)
  
   diff --git a/drivers/media/video/isp/isp.c
  b/drivers/media/video/isp/isp.c
   index de9352b..30bdc48 100644
   --- a/drivers/media/video/isp/isp.c
   +++ b/drivers/media/video/isp/isp.c
   @@ -254,48 +254,13 @@ EXPORT_SYMBOL(isp_set_xclk);
 */
static void isp_power_settings(struct isp_device *isp, int idle)
{
   - if (idle) {
   - isp_reg_writel(isp,
   -(ISP_SYSCONFIG_MIDLEMODE_SMARTSTANDBY 
   - ISP_SYSCONFIG_MIDLEMODE_SHIFT),
   -OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
   - if (omap_rev() == OMAP3430_REV_ES1_0) {
   - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
   -(ISPCSI1_MIDLEMODE_SMARTSTANDBY 
   - ISPCSI1_MIDLEMODE_SHIFT),
   -OMAP3_ISP_IOMEM_CSI2A_REGS1,
   -ISPCSI2_SYSCONFIG);
   - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
   -(ISPCSI1_MIDLEMODE_SMARTSTANDBY 
   - ISPCSI1_MIDLEMODE_SHIFT),
   -OMAP3_ISP_IOMEM_CCP2,
   -ISPCCP2_SYSCONFIG);
   - }
   - isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE,
  OMAP3_ISP_IOMEM_MAIN,
   -ISP_CTRL);
   -
   - } else {
   - isp_reg_writel(isp,
   -(ISP_SYSCONFIG_MIDLEMODE_FORCESTANDBY 
   - ISP_SYSCONFIG_MIDLEMODE_SHIFT),
   -OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
   - if (omap_rev() == OMAP3430_REV_ES1_0) {
   - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
   -(ISPCSI1_MIDLEMODE_FORCESTANDBY 
   - ISPCSI1_MIDLEMODE_SHIFT),
   -OMAP3_ISP_IOMEM_CSI2A_REGS1,
   -ISPCSI2_SYSCONFIG);
   -
   - isp_reg_writel(isp, ISPCSI1_AUTOIDLE |
   -(ISPCSI1_MIDLEMODE_FORCESTANDBY 
   - ISPCSI1_MIDLEMODE_SHIFT),
   -OMAP3_ISP_IOMEM_CCP2,
   -ISPCCP2_SYSCONFIG);
   - }
   -
   - isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE,
  OMAP3_ISP_IOMEM_MAIN,
   -ISP_CTRL);
   - }
   + isp_reg_writel(isp,
   +((idle ? ISP_SYSCONFIG_MIDLEMODE_SMARTSTANDBY :
   + ISP_SYSCONFIG_MIDLEMODE_FORCESTANDBY) 
   + ISP_SYSCONFIG_MIDLEMODE_SHIFT),
   +OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
   + isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE, OMAP3_ISP_IOMEM_MAIN,
   +ISP_CTRL);
}
  
/*
   --
   1.7.0.4
  
   --
   To unsubscribe from this list: send the line unsubscribe linux-media
  in
   the body of a message to majord...@vger.kernel.org
   More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body 

RE: [omap3isp][PATCH v2 8/9] omap3isp: ccp2: Make SYSCONFIG fields consistent

2010-11-19 Thread Aguirre, Sergio


 -Original Message-
 From: Aguirre, Sergio
 Sent: Friday, November 19, 2010 9:44 AM
 To: 'David Cohen'
 Cc: Laurent Pinchart; linux-media@vger.kernel.org
 Subject: RE: [omap3isp][PATCH v2 8/9] omap3isp: ccp2: Make SYSCONFIG
 fields consistent
 
 
  -Original Message-
  From: David Cohen [mailto:david.co...@nokia.com]
  Sent: Friday, November 19, 2010 4:06 AM
  To: Aguirre, Sergio
  Cc: Laurent Pinchart; linux-media@vger.kernel.org
  Subject: Re: [omap3isp][PATCH v2 8/9] omap3isp: ccp2: Make SYSCONFIG
  fields consistent
 
  Hi Sergio,
 
 Hi David,
 
 Thanks for the review.
 
 
  I've few comments below.
 
  On Mon, Nov 15, 2010 at 03:30:00PM +0100, ext Sergio Aguirre wrote:
   Signed-off-by: Sergio Aguirre saagui...@ti.com
   ---
drivers/media/video/isp/ispccp2.c |3 +--
drivers/media/video/isp/ispreg.h  |   14 --
2 files changed, 9 insertions(+), 8 deletions(-)
  
   diff --git a/drivers/media/video/isp/ispccp2.c
  b/drivers/media/video/isp/ispccp2.c
   index fa23394..3127a74 100644
   --- a/drivers/media/video/isp/ispccp2.c
   +++ b/drivers/media/video/isp/ispccp2.c
   @@ -419,8 +419,7 @@ static void ispccp2_mem_configure(struct
  isp_ccp2_device *ccp2,
 config-src_ofst = 0;
 }
  
   - isp_reg_writel(isp, (ISPCSI1_MIDLEMODE_SMARTSTANDBY 
   -ISPCSI1_MIDLEMODE_SHIFT),
   + isp_reg_writel(isp, ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SMART,
OMAP3_ISP_IOMEM_CCP2, ISPCCP2_SYSCONFIG);
 
  To make your cleanup even better, you could change isp_reg_clr_set()
  instead.
  If CCP2 MSTANDY_MODE is set to NOSTANDY, the result is going to be an
  invalid 0x3 value. Despite it cannot happen with the current code, it's
  still better to avoid such situations for future versions. :)
 
 Hmm you're right, I guess I didn't do any real functional changes, just
 defines renaming.
 
 I can repost an updated patch with this suggestion. No problem.

David,

Geez I guess I wasn't paying much attention to this either. Sorry.

The case you mention about it potentially become 0x3 is not possible, because, 
I'm basically overwriting the whole register with (0x2  12)
Notice the isp_reg_write, there's no OR operation...

Now, this means that we have been implicitly setting other fields as Zeroes 
(SOFT_RESET = 0, and AUTO_IDLE = 0) aswell.

Has AUTOIDLE in CCP2 been tried in N900? I don't have a CCP2 sensor to test
with :(.

Regards,
Sergio

 
 
  
 /* Hsize, Skip */
   diff --git a/drivers/media/video/isp/ispreg.h
  b/drivers/media/video/isp/ispreg.h
   index d885541..9b0d3ad 100644
   --- a/drivers/media/video/isp/ispreg.h
   +++ b/drivers/media/video/isp/ispreg.h
   @@ -141,6 +141,14 @@
#define ISPCCP2_REVISION (0x000)
#define ISPCCP2_SYSCONFIG(0x004)
#define ISPCCP2_SYSCONFIG_SOFT_RESET (1  1)
   +#define ISPCCP2_SYSCONFIG_AUTO_IDLE  0x1
   +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT12
   +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_FORCE\
   + (0x0  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
   +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_NO   \
   + (0x1  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
   +#define ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SMART\
   + (0x2  ISPCCP2_SYSCONFIG_MSTANDBY_MODE_SHIFT)
 
  You can add some ISPCCP2_SYSCONFIG_MSTANDY_MODE_MASK, as 2 bits must be
  always set together.
 
 Sure, will do.
 
 Thanks and Regards,
 Sergio
 
 
  Regards,
 
  David Cohen
 
#define ISPCCP2_SYSSTATUS(0x008)
#define ISPCCP2_SYSSTATUS_RESET_DONE (1  0)
#define ISPCCP2_LC01_IRQENABLE   (0x00C)
   @@ -1309,12 +1317,6 @@
#define ISPMMU_SIDLEMODE_SMARTIDLE   2
#define ISPMMU_SIDLEMODE_SHIFT   3
  
   -#define ISPCSI1_AUTOIDLE 0x1
   -#define ISPCSI1_MIDLEMODE_SHIFT  12
   -#define ISPCSI1_MIDLEMODE_FORCESTANDBY   0x0
   -#define ISPCSI1_MIDLEMODE_NOSTANDBY  0x1
   -#define ISPCSI1_MIDLEMODE_SMARTSTANDBY   0x2
   -
/* --
 --
  -
 * CSI2 receiver registers (ES2.0)
 */
   --
   1.7.0.4
  
   --
   To unsubscribe from this list: send the line unsubscribe linux-media
  in
   the body of a message to majord...@vger.kernel.org
   More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Zooming with V4L2

2010-11-19 Thread Shuzhen Wang
Hello, 

I am working on a SOC V4L2 video driver, and need to implement zoom
functionality. 

From application, there are 2 ways to do zooming. The 1st way is to use
cropping and scaling as described in section 1.11.1. The application calls
VIDIOC_S_CROP to achieve zoom. The 2nd way is to use V4L2_CID_ZOOM_ABSOLUTE
and V4L2_CID_ZOOM_RELATIVE as described by Laurent in
http://video4linux-list.1448896.n2.nabble.com/RFC-Zoom-controls-in-V4L2-td14
51987.html.

Our camera hardware supports digital zoom. However, it acts LIKE optical
zoom because it doesn't do upscaling, so no video quality is sacrificed. As
a driver writter, is it okay to support only V4L2_CID_ZOOM_ABSOLUTE and
V4L2_CID_ZOOM_RELATIVE? 

I guess it also depends on how zooming is done for most of the V4L2 user
application out there. 

Your comments are appreciated.
-Shuzhen


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[omap3isp RFC][PATCH 4/4] omap3isp: csi2: Don't dump ISP main registers

2010-11-19 Thread Sergio Aguirre
This keeps the driver focused only on accessing CSI2 registers
only.

if the same info is needed, isp_print_status should be called instead.

Signed-off-by: Sergio Aguirre saagui...@ti.com
---
 drivers/media/video/isp/ispcsi2.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/media/video/isp/ispcsi2.c 
b/drivers/media/video/isp/ispcsi2.c
index 35e3629..13e7e22 100644
--- a/drivers/media/video/isp/ispcsi2.c
+++ b/drivers/media/video/isp/ispcsi2.c
@@ -611,13 +611,6 @@ void isp_csi2_regdump(struct isp_csi2_device *csi2)
 
dev_dbg(isp-dev, -CSI2 Register dump-\n);
 
-   dev_dbg(isp-dev, ###ISP_CTRL=0x%x\n,
-   isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL));
-   dev_dbg(isp-dev, ###ISP_IRQ0ENABLE=0x%x\n,
-   isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0ENABLE));
-   dev_dbg(isp-dev, ###ISP_IRQ0STATUS=0x%x\n,
-   isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS));
-
CSI2_PRINT_REGISTER(isp, csi2-regs1, SYSCONFIG);
CSI2_PRINT_REGISTER(isp, csi2-regs1, SYSSTATUS);
CSI2_PRINT_REGISTER(isp, csi2-regs1, IRQENABLE);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[omap3isp RFC][PATCH 2/4] omap3isp: Move CCDC LSC prefetch wait to main isp code

2010-11-19 Thread Sergio Aguirre
Since this sequence strictly touches ISP global registers, it's
not really part of the same register address space than the CCDC.

Do this check in main isp code instead.

Signed-off-by: Sergio Aguirre saagui...@ti.com
---
 drivers/media/video/isp/isp.c |   24 
 drivers/media/video/isp/isp.h |2 ++
 drivers/media/video/isp/ispccdc.c |   26 +-
 3 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/drivers/media/video/isp/isp.c b/drivers/media/video/isp/isp.c
index 2e5030f..ee45eb6 100644
--- a/drivers/media/video/isp/isp.c
+++ b/drivers/media/video/isp/isp.c
@@ -339,6 +339,30 @@ void isphist_dma_done(struct isp_device *isp)
}
 }
 
+int ispccdc_lsc_wait_prefetch(struct isp_device *isp)
+{
+   unsigned int wait;
+
+   isp_reg_writel(isp, IRQ0STATUS_CCDC_LSC_PREF_COMP_IRQ,
+  OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
+
+   /* timeout 1 ms */
+   for (wait = 0; wait  1000; wait++) {
+   if (isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS) 
+ IRQ0STATUS_CCDC_LSC_PREF_COMP_IRQ) {
+   isp_reg_writel(isp, IRQ0STATUS_CCDC_LSC_PREF_COMP_IRQ,
+  OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
+   return 0;
+   }
+
+   rmb();
+   udelay(1);
+   }
+
+   return -ETIMEDOUT;
+}
+
+
 static inline void isp_isr_dbg(struct isp_device *isp, u32 irqstatus)
 {
static const char *name[] = {
diff --git a/drivers/media/video/isp/isp.h b/drivers/media/video/isp/isp.h
index 1260e9f..d0b7b0f 100644
--- a/drivers/media/video/isp/isp.h
+++ b/drivers/media/video/isp/isp.h
@@ -280,6 +280,8 @@ struct isp_device {
 
 void isphist_dma_done(struct isp_device *isp);
 
+int ispccdc_lsc_wait_prefetch(struct isp_device *isp);
+
 void isp_flush(struct isp_device *isp);
 
 int isp_pipeline_set_stream(struct isp_pipeline *pipe,
diff --git a/drivers/media/video/isp/ispccdc.c 
b/drivers/media/video/isp/ispccdc.c
index 4244edf..b039bce 100644
--- a/drivers/media/video/isp/ispccdc.c
+++ b/drivers/media/video/isp/ispccdc.c
@@ -223,30 +223,6 @@ static void ispccdc_lsc_setup_regs(struct isp_ccdc_device 
*ccdc,
   ISPCCDC_LSC_INITIAL);
 }
 
-static int ispccdc_lsc_wait_prefetch(struct isp_ccdc_device *ccdc)
-{
-   struct isp_device *isp = to_isp_device(ccdc);
-   unsigned int wait;
-
-   isp_reg_writel(isp, IRQ0STATUS_CCDC_LSC_PREF_COMP_IRQ,
-  OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
-
-   /* timeout 1 ms */
-   for (wait = 0; wait  1000; wait++) {
-   if (isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS) 
- IRQ0STATUS_CCDC_LSC_PREF_COMP_IRQ) {
-   isp_reg_writel(isp, IRQ0STATUS_CCDC_LSC_PREF_COMP_IRQ,
-  OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
-   return 0;
-   }
-
-   rmb();
-   udelay(1);
-   }
-
-   return -ETIMEDOUT;
-}
-
 /*
  * __ispccdc_lsc_enable - Enables/Disables the Lens Shading Compensation 
module.
  * @ccdc: Pointer to ISP CCDC device.
@@ -272,7 +248,7 @@ static int __ispccdc_lsc_enable(struct isp_ccdc_device 
*ccdc, int enable)
ISPCCDC_LSC_ENABLE, enable ? ISPCCDC_LSC_ENABLE : 0);
 
if (enable) {
-   if (ispccdc_lsc_wait_prefetch(ccdc)  0) {
+   if (ispccdc_lsc_wait_prefetch(isp)  0) {
isp_reg_clr(isp, OMAP3_ISP_IOMEM_CCDC,
ISPCCDC_LSC_CONFIG, ISPCCDC_LSC_ENABLE);
ccdc-lsc.state = LSC_STATE_STOPPED;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[omap3isp RFC][PATCH 0/4] Improve inter subdev interaction

2010-11-19 Thread Sergio Aguirre
Hi,

These are some patches to make these operations more generic:
- Clock control is being controlled in a very crude manner by
  subdevices, it should be centralized in isp.c.
- LSC prefetch wait check is reading a main ISP register, so move
  it to isp.c
- Abstract SBL busy check: we don't want a submodule thinkering
  with main ISP registers. That should be done in the main isp.c

Also, remove main ISP register dump from CSI2 specific dump. We
should be using isp_print_status if we'll like to know main ISP
regdump.

Comments are welcome. More cleanups for better subdevice isolation
are on the way.

Regards,
Sergio

Sergio Aguirre (4):
  omap3isp: Abstract isp subdevs clock control
  omap3isp: Move CCDC LSC prefetch wait to main isp code
  omap3isp: sbl: Abstract SBL busy check
  omap3isp: csi2: Don't dump ISP main registers

 drivers/media/video/isp/isp.c|   95 ++
 drivers/media/video/isp/isp.h|   16 ++
 drivers/media/video/isp/ispccdc.c|   42 ++-
 drivers/media/video/isp/ispcsi2.c|7 ---
 drivers/media/video/isp/isppreview.c |6 +--
 drivers/media/video/isp/ispresizer.c |6 +--
 6 files changed, 119 insertions(+), 53 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[omap3isp RFC][PATCH 1/4] omap3isp: Abstract isp subdevs clock control

2010-11-19 Thread Sergio Aguirre
Submodules shouldn't be aware of global register bit structure,
specially if the submodules are shared in the future with
other TI architectures (Davinci, future OMAPs, etc)

Signed-off-by: Sergio Aguirre saagui...@ti.com
---
 drivers/media/video/isp/isp.c|   54 ++
 drivers/media/video/isp/isp.h|   12 +++
 drivers/media/video/isp/ispccdc.c|6 +--
 drivers/media/video/isp/isppreview.c |6 +--
 drivers/media/video/isp/ispresizer.c |6 +--
 5 files changed, 72 insertions(+), 12 deletions(-)

diff --git a/drivers/media/video/isp/isp.c b/drivers/media/video/isp/isp.c
index 30bdc48..2e5030f 100644
--- a/drivers/media/video/isp/isp.c
+++ b/drivers/media/video/isp/isp.c
@@ -991,6 +991,60 @@ void isp_sbl_disable(struct isp_device *isp, enum 
isp_sbl_resource res)
  * Clock management
  */
 
+void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource res)
+{
+   u32 clk = 0;
+
+   isp-subclk_resources |= res;
+
+   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_H3A)
+   clk |= ISPCTRL_H3A_CLK_EN;
+
+   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_HIST)
+   clk |= ISPCTRL_HIST_CLK_EN;
+
+   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_RESIZER)
+   clk |= ISPCTRL_RSZ_CLK_EN;
+
+   /* NOTE: For CCDC  Preview submodules, we need to affect internal
+*   RAM aswell.
+*/
+   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_CCDC)
+   clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN;
+
+   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_PREVIEW)
+   clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN;
+
+   isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, clk);
+}
+
+void isp_subclk_disable(struct isp_device *isp, enum isp_subclk_resource res)
+{
+   u32 clk = 0;
+
+   isp-subclk_resources = ~res;
+
+   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_H3A))
+   clk |= ISPCTRL_H3A_CLK_EN;
+
+   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_HIST))
+   clk |= ISPCTRL_HIST_CLK_EN;
+
+   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_RESIZER))
+   clk |= ISPCTRL_RSZ_CLK_EN;
+
+   /* NOTE: For CCDC  Preview submodules, we need to affect internal
+*   RAM aswell.
+*/
+   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_CCDC))
+   clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN;
+
+   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_PREVIEW))
+   clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN;
+
+   isp_reg_clr(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, clk);
+}
+
 /*
  * isp_enable_clocks - Enable ISP clocks
  * @isp: OMAP3 ISP device
diff --git a/drivers/media/video/isp/isp.h b/drivers/media/video/isp/isp.h
index b8f63e2..1260e9f 100644
--- a/drivers/media/video/isp/isp.h
+++ b/drivers/media/video/isp/isp.h
@@ -85,6 +85,14 @@ enum isp_sbl_resource {
OMAP3_ISP_SBL_RESIZER_WRITE = 0x200,
 };
 
+enum isp_subclk_resource {
+   OMAP3_ISP_SUBCLK_CCDC   = 0x1,
+   OMAP3_ISP_SUBCLK_H3A= 0x2,
+   OMAP3_ISP_SUBCLK_HIST   = 0x4,
+   OMAP3_ISP_SUBCLK_PREVIEW= 0x8,
+   OMAP3_ISP_SUBCLK_RESIZER= 0x10,
+};
+
 enum isp_interface_type {
ISP_INTERFACE_PARALLEL,
ISP_INTERFACE_CSI2A_PHY2,
@@ -262,6 +270,7 @@ struct isp_device {
struct isp_csiphy isp_csiphy2;
 
unsigned int sbl_resources;
+   unsigned int subclk_resources;
 
struct iommu *iommu;
 };
@@ -294,6 +303,9 @@ void isp_print_status(struct isp_device *isp);
 void isp_sbl_enable(struct isp_device *isp, enum isp_sbl_resource res);
 void isp_sbl_disable(struct isp_device *isp, enum isp_sbl_resource res);
 
+void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource res);
+void isp_subclk_disable(struct isp_device *isp, enum isp_subclk_resource res);
+
 int omap3isp_register_entities(struct platform_device *pdev,
   struct v4l2_device *v4l2_dev);
 void omap3isp_unregister_entities(struct platform_device *pdev);
diff --git a/drivers/media/video/isp/ispccdc.c 
b/drivers/media/video/isp/ispccdc.c
index c3d1d7a..4244edf 100644
--- a/drivers/media/video/isp/ispccdc.c
+++ b/drivers/media/video/isp/ispccdc.c
@@ -1687,8 +1687,7 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int 
enable)
if (enable == ISP_PIPELINE_STREAM_STOPPED)
return 0;
 
-   isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL,
-   ISPCTRL_CCDC_RAM_EN | ISPCTRL_CCDC_CLK_EN);
+   isp_subclk_enable(isp, OMAP3_ISP_SUBCLK_CCDC);
isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_CFG,
ISPCCDC_CFG_VDLC);
 
@@ -1725,8 +1724,7 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int 
enable)
ret = ispccdc_disable(ccdc);
if (ccdc-output  CCDC_OUTPUT_MEMORY)

[omap3isp RFC][PATCH 3/4] omap3isp: sbl: Abstract SBL busy check

2010-11-19 Thread Sergio Aguirre
Make a nicer interface that can be used by anyone accessing the isp.

Signed-off-by: Sergio Aguirre saagui...@ti.com
---
 drivers/media/video/isp/isp.c |   17 +
 drivers/media/video/isp/isp.h |2 ++
 drivers/media/video/isp/ispccdc.c |   10 +-
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/media/video/isp/isp.c b/drivers/media/video/isp/isp.c
index ee45eb6..9db2145 100644
--- a/drivers/media/video/isp/isp.c
+++ b/drivers/media/video/isp/isp.c
@@ -362,6 +362,23 @@ int ispccdc_lsc_wait_prefetch(struct isp_device *isp)
return -ETIMEDOUT;
 }
 
+int isp_sbl_busy(struct isp_device *isp, enum isp_sbl_resource res)
+{
+   int ret = 0;
+
+   if (res  OMAP3_ISP_SBL_CCDC_WRITE) {
+   ret |= (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, 
ISPSBL_CCDC_WR_0) 
+   ISPSBL_CCDC_WR_0_DATA_READY)
+| (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, 
ISPSBL_CCDC_WR_1) 
+   ISPSBL_CCDC_WR_0_DATA_READY)
+| (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, 
ISPSBL_CCDC_WR_2) 
+   ISPSBL_CCDC_WR_0_DATA_READY)
+| (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, 
ISPSBL_CCDC_WR_3) 
+   ISPSBL_CCDC_WR_0_DATA_READY);
+   }
+
+   return ret;
+}
 
 static inline void isp_isr_dbg(struct isp_device *isp, u32 irqstatus)
 {
diff --git a/drivers/media/video/isp/isp.h b/drivers/media/video/isp/isp.h
index d0b7b0f..1948e23 100644
--- a/drivers/media/video/isp/isp.h
+++ b/drivers/media/video/isp/isp.h
@@ -282,6 +282,8 @@ void isphist_dma_done(struct isp_device *isp);
 
 int ispccdc_lsc_wait_prefetch(struct isp_device *isp);
 
+int isp_sbl_busy(struct isp_device *isp, enum isp_sbl_resource res);
+
 void isp_flush(struct isp_device *isp);
 
 int isp_pipeline_set_stream(struct isp_pipeline *pipe,
diff --git a/drivers/media/video/isp/ispccdc.c 
b/drivers/media/video/isp/ispccdc.c
index b039bce..9220d09 100644
--- a/drivers/media/video/isp/ispccdc.c
+++ b/drivers/media/video/isp/ispccdc.c
@@ -1217,15 +1217,7 @@ static int ispccdc_sbl_busy(struct isp_ccdc_device *ccdc)
 {
struct isp_device *isp = to_isp_device(ccdc);
 
-   return ispccdc_busy(ccdc)
-   | (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, ISPSBL_CCDC_WR_0) 
-  ISPSBL_CCDC_WR_0_DATA_READY)
-   | (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, ISPSBL_CCDC_WR_1) 
-  ISPSBL_CCDC_WR_0_DATA_READY)
-   | (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, ISPSBL_CCDC_WR_2) 
-  ISPSBL_CCDC_WR_0_DATA_READY)
-   | (isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, ISPSBL_CCDC_WR_3) 
-  ISPSBL_CCDC_WR_0_DATA_READY);
+   return ispccdc_busy(ccdc) | isp_sbl_busy(isp, OMAP3_ISP_SBL_CCDC_WRITE);
 }
 
 /*
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [omap3isp RFC][PATCH 1/4] omap3isp: Abstract isp subdevs clock control

2010-11-19 Thread Aguirre, Sergio


 -Original Message-
 From: Aguirre, Sergio
 Sent: Friday, November 19, 2010 5:24 PM
 To: Laurent Pinchart
 Cc: linux-media@vger.kernel.org; Aguirre, Sergio
 Subject: [omap3isp RFC][PATCH 1/4] omap3isp: Abstract isp subdevs clock
 control
 
 Submodules shouldn't be aware of global register bit structure,
 specially if the submodules are shared in the future with
 other TI architectures (Davinci, future OMAPs, etc)

Oops, I just noticed a bug in this patch in clock disabling...
Will resend the updated version.

Regards,
Sergio

 
 Signed-off-by: Sergio Aguirre saagui...@ti.com
 ---
  drivers/media/video/isp/isp.c|   54
 ++
  drivers/media/video/isp/isp.h|   12 +++
  drivers/media/video/isp/ispccdc.c|6 +--
  drivers/media/video/isp/isppreview.c |6 +--
  drivers/media/video/isp/ispresizer.c |6 +--
  5 files changed, 72 insertions(+), 12 deletions(-)
 
 diff --git a/drivers/media/video/isp/isp.c b/drivers/media/video/isp/isp.c
 index 30bdc48..2e5030f 100644
 --- a/drivers/media/video/isp/isp.c
 +++ b/drivers/media/video/isp/isp.c
 @@ -991,6 +991,60 @@ void isp_sbl_disable(struct isp_device *isp, enum
 isp_sbl_resource res)
   * Clock management
   */
 
 +void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource
 res)
 +{
 + u32 clk = 0;
 +
 + isp-subclk_resources |= res;
 +
 + if (isp-subclk_resources  OMAP3_ISP_SUBCLK_H3A)
 + clk |= ISPCTRL_H3A_CLK_EN;
 +
 + if (isp-subclk_resources  OMAP3_ISP_SUBCLK_HIST)
 + clk |= ISPCTRL_HIST_CLK_EN;
 +
 + if (isp-subclk_resources  OMAP3_ISP_SUBCLK_RESIZER)
 + clk |= ISPCTRL_RSZ_CLK_EN;
 +
 + /* NOTE: For CCDC  Preview submodules, we need to affect internal
 +  *   RAM aswell.
 +  */
 + if (isp-subclk_resources  OMAP3_ISP_SUBCLK_CCDC)
 + clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN;
 +
 + if (isp-subclk_resources  OMAP3_ISP_SUBCLK_PREVIEW)
 + clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN;
 +
 + isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, clk);
 +}
 +
 +void isp_subclk_disable(struct isp_device *isp, enum isp_subclk_resource
 res)
 +{
 + u32 clk = 0;
 +
 + isp-subclk_resources = ~res;
 +
 + if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_H3A))
 + clk |= ISPCTRL_H3A_CLK_EN;
 +
 + if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_HIST))
 + clk |= ISPCTRL_HIST_CLK_EN;
 +
 + if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_RESIZER))
 + clk |= ISPCTRL_RSZ_CLK_EN;
 +
 + /* NOTE: For CCDC  Preview submodules, we need to affect internal
 +  *   RAM aswell.
 +  */
 + if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_CCDC))
 + clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN;
 +
 + if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_PREVIEW))
 + clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN;
 +
 + isp_reg_clr(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, clk);
 +}
 +
  /*
   * isp_enable_clocks - Enable ISP clocks
   * @isp: OMAP3 ISP device
 diff --git a/drivers/media/video/isp/isp.h b/drivers/media/video/isp/isp.h
 index b8f63e2..1260e9f 100644
 --- a/drivers/media/video/isp/isp.h
 +++ b/drivers/media/video/isp/isp.h
 @@ -85,6 +85,14 @@ enum isp_sbl_resource {
   OMAP3_ISP_SBL_RESIZER_WRITE = 0x200,
  };
 
 +enum isp_subclk_resource {
 + OMAP3_ISP_SUBCLK_CCDC   = 0x1,
 + OMAP3_ISP_SUBCLK_H3A= 0x2,
 + OMAP3_ISP_SUBCLK_HIST   = 0x4,
 + OMAP3_ISP_SUBCLK_PREVIEW= 0x8,
 + OMAP3_ISP_SUBCLK_RESIZER= 0x10,
 +};
 +
  enum isp_interface_type {
   ISP_INTERFACE_PARALLEL,
   ISP_INTERFACE_CSI2A_PHY2,
 @@ -262,6 +270,7 @@ struct isp_device {
   struct isp_csiphy isp_csiphy2;
 
   unsigned int sbl_resources;
 + unsigned int subclk_resources;
 
   struct iommu *iommu;
  };
 @@ -294,6 +303,9 @@ void isp_print_status(struct isp_device *isp);
  void isp_sbl_enable(struct isp_device *isp, enum isp_sbl_resource res);
  void isp_sbl_disable(struct isp_device *isp, enum isp_sbl_resource res);
 
 +void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource
 res);
 +void isp_subclk_disable(struct isp_device *isp, enum isp_subclk_resource
 res);
 +
  int omap3isp_register_entities(struct platform_device *pdev,
  struct v4l2_device *v4l2_dev);
  void omap3isp_unregister_entities(struct platform_device *pdev);
 diff --git a/drivers/media/video/isp/ispccdc.c
 b/drivers/media/video/isp/ispccdc.c
 index c3d1d7a..4244edf 100644
 --- a/drivers/media/video/isp/ispccdc.c
 +++ b/drivers/media/video/isp/ispccdc.c
 @@ -1687,8 +1687,7 @@ static int ccdc_set_stream(struct v4l2_subdev *sd,
 int enable)
   if (enable == ISP_PIPELINE_STREAM_STOPPED)
   return 0;
 
 - isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL,
 - ISPCTRL_CCDC_RAM_EN 

RE: [omap3isp RFC][PATCH 1/4] omap3isp: Abstract isp subdevs clock control

2010-11-19 Thread Aguirre, Sergio


 -Original Message-
 From: Aguirre, Sergio
 Sent: Friday, November 19, 2010 5:27 PM
 To: Aguirre, Sergio; Laurent Pinchart
 Cc: linux-media@vger.kernel.org
 Subject: RE: [omap3isp RFC][PATCH 1/4] omap3isp: Abstract isp subdevs
 clock control
 
 
 
  -Original Message-
  From: Aguirre, Sergio
  Sent: Friday, November 19, 2010 5:24 PM
  To: Laurent Pinchart
  Cc: linux-media@vger.kernel.org; Aguirre, Sergio
  Subject: [omap3isp RFC][PATCH 1/4] omap3isp: Abstract isp subdevs clock
  control
 
  Submodules shouldn't be aware of global register bit structure,
  specially if the submodules are shared in the future with
  other TI architectures (Davinci, future OMAPs, etc)
 
 Oops, I just noticed a bug in this patch in clock disabling...
 Will resend the updated version.

Geez, I'm apologize again. The patch was indeed correct..

Too much coffee. ;P

Regards,
Sergio

 
 Regards,
 Sergio
 
 
  Signed-off-by: Sergio Aguirre saagui...@ti.com
  ---
   drivers/media/video/isp/isp.c|   54
  ++
   drivers/media/video/isp/isp.h|   12 +++
   drivers/media/video/isp/ispccdc.c|6 +--
   drivers/media/video/isp/isppreview.c |6 +--
   drivers/media/video/isp/ispresizer.c |6 +--
   5 files changed, 72 insertions(+), 12 deletions(-)
 
  diff --git a/drivers/media/video/isp/isp.c
 b/drivers/media/video/isp/isp.c
  index 30bdc48..2e5030f 100644
  --- a/drivers/media/video/isp/isp.c
  +++ b/drivers/media/video/isp/isp.c
  @@ -991,6 +991,60 @@ void isp_sbl_disable(struct isp_device *isp, enum
  isp_sbl_resource res)
* Clock management
*/
 
  +void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource
  res)
  +{
  +   u32 clk = 0;
  +
  +   isp-subclk_resources |= res;
  +
  +   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_H3A)
  +   clk |= ISPCTRL_H3A_CLK_EN;
  +
  +   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_HIST)
  +   clk |= ISPCTRL_HIST_CLK_EN;
  +
  +   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_RESIZER)
  +   clk |= ISPCTRL_RSZ_CLK_EN;
  +
  +   /* NOTE: For CCDC  Preview submodules, we need to affect internal
  +*   RAM aswell.
  +*/
  +   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_CCDC)
  +   clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN;
  +
  +   if (isp-subclk_resources  OMAP3_ISP_SUBCLK_PREVIEW)
  +   clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN;
  +
  +   isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, clk);
  +}
  +
  +void isp_subclk_disable(struct isp_device *isp, enum
 isp_subclk_resource
  res)
  +{
  +   u32 clk = 0;
  +
  +   isp-subclk_resources = ~res;
  +
  +   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_H3A))
  +   clk |= ISPCTRL_H3A_CLK_EN;
  +
  +   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_HIST))
  +   clk |= ISPCTRL_HIST_CLK_EN;
  +
  +   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_RESIZER))
  +   clk |= ISPCTRL_RSZ_CLK_EN;
  +
  +   /* NOTE: For CCDC  Preview submodules, we need to affect internal
  +*   RAM aswell.
  +*/
  +   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_CCDC))
  +   clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN;
  +
  +   if (!(isp-subclk_resources  OMAP3_ISP_SUBCLK_PREVIEW))
  +   clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN;
  +
  +   isp_reg_clr(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, clk);
  +}
  +
   /*
* isp_enable_clocks - Enable ISP clocks
* @isp: OMAP3 ISP device
  diff --git a/drivers/media/video/isp/isp.h
 b/drivers/media/video/isp/isp.h
  index b8f63e2..1260e9f 100644
  --- a/drivers/media/video/isp/isp.h
  +++ b/drivers/media/video/isp/isp.h
  @@ -85,6 +85,14 @@ enum isp_sbl_resource {
  OMAP3_ISP_SBL_RESIZER_WRITE = 0x200,
   };
 
  +enum isp_subclk_resource {
  +   OMAP3_ISP_SUBCLK_CCDC   = 0x1,
  +   OMAP3_ISP_SUBCLK_H3A= 0x2,
  +   OMAP3_ISP_SUBCLK_HIST   = 0x4,
  +   OMAP3_ISP_SUBCLK_PREVIEW= 0x8,
  +   OMAP3_ISP_SUBCLK_RESIZER= 0x10,
  +};
  +
   enum isp_interface_type {
  ISP_INTERFACE_PARALLEL,
  ISP_INTERFACE_CSI2A_PHY2,
  @@ -262,6 +270,7 @@ struct isp_device {
  struct isp_csiphy isp_csiphy2;
 
  unsigned int sbl_resources;
  +   unsigned int subclk_resources;
 
  struct iommu *iommu;
   };
  @@ -294,6 +303,9 @@ void isp_print_status(struct isp_device *isp);
   void isp_sbl_enable(struct isp_device *isp, enum isp_sbl_resource res);
   void isp_sbl_disable(struct isp_device *isp, enum isp_sbl_resource
 res);
 
  +void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource
  res);
  +void isp_subclk_disable(struct isp_device *isp, enum
 isp_subclk_resource
  res);
  +
   int omap3isp_register_entities(struct platform_device *pdev,
 struct v4l2_device *v4l2_dev);
   void omap3isp_unregister_entities(struct platform_device *pdev);
  diff --git a/drivers/media/video/isp/ispccdc.c
  b/drivers/media/video/isp/ispccdc.c
  

[PATCH 00/10] rc-core: various cleanups

2010-11-19 Thread David Härdeman
Here's a set of smaller patches which performs various cleanups, mostly to
the saa7134 and bttv driver. They are based on the media_tree.git repo
(2.6.38 branch) on top of Mauro's recent renaming patches.

---

David Härdeman (10):
  saa7134: remove unused module parameter
  saa7134: use full keycode for BeholdTV
  saa7134: some minor cleanups
  saa7134: merge saa7134_card_ir-timer and saa7134_card_ir-timer_end
  saa7134: protect the ir user count
  saa7134: make module parameters boolean
  bttv: rename struct card_ir to bttv_ir
  bttv: merge ir decoding timers
  mceusb: int to bool conversion
  rc-core: fix some leftovers from the renaming patches


 drivers/media/rc/ir-raw.c   |2 
 drivers/media/rc/keymaps/rc-behold.c|   70 +++---
 drivers/media/rc/mceusb.c   |   62 +
 drivers/media/rc/rc-core-priv.h |6 +
 drivers/media/rc/rc-main.c  |2 
 drivers/media/video/bt8xx/bttv-input.c  |   31 +++---
 drivers/media/video/bt8xx/bttvp.h   |   32 ++
 drivers/media/video/saa7134/saa7134-input.c |  133 +++
 drivers/media/video/saa7134/saa7134.h   |6 +
 include/media/rc-core.h |   12 +-
 10 files changed, 154 insertions(+), 202 deletions(-)

-- 
David Härdeman
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/10] saa7134: remove unused module parameter

2010-11-19 Thread David Härdeman
ir_rc5_remote_gap is a leftover from ir-common, remove it.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/video/saa7134/saa7134-input.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index f3f4aff..4fdc165 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -41,9 +41,6 @@ static int pinnacle_remote;
 module_param(pinnacle_remote, int, 0644);/* Choose Pinnacle PCTV remote */
 MODULE_PARM_DESC(pinnacle_remote, Specify Pinnacle PCTV remote: 0=coloured, 
1=grey (defaults to 0));
 
-static int ir_rc5_remote_gap = 885;
-module_param(ir_rc5_remote_gap, int, 0644);
-
 static unsigned int disable_other_ir;
 module_param(disable_other_ir, int, 0644);
 MODULE_PARM_DESC(disable_other_ir, disable full codes of 

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/10] saa7134: use full keycode for BeholdTV

2010-11-19 Thread David Härdeman
Using the full keycode for BeholdTV hardware makes another module
parameter unnecessary.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/rc/keymaps/rc-behold.c|   70 ++-
 drivers/media/video/saa7134/saa7134-input.c |   19 +--
 2 files changed, 37 insertions(+), 52 deletions(-)

diff --git a/drivers/media/rc/keymaps/rc-behold.c 
b/drivers/media/rc/keymaps/rc-behold.c
index ae4d235..c64c356 100644
--- a/drivers/media/rc/keymaps/rc-behold.c
+++ b/drivers/media/rc/keymaps/rc-behold.c
@@ -29,8 +29,8 @@ static struct rc_map_table behold[] = {
/*  0x1c0x12  *
 *  TV/FM  POWER  *
 **/
-   { 0x1c, KEY_TUNER },/* XXX KEY_TV / KEY_RADIO */
-   { 0x12, KEY_POWER },
+   { 0x6b861c, KEY_TUNER },/* XXX KEY_TV / KEY_RADIO */
+   { 0x6b8612, KEY_POWER },
 
/*  0x010x020x03  *
 *   1   2   3*
@@ -41,28 +41,28 @@ static struct rc_map_table behold[] = {
 *  0x070x080x09  *
 *   7   8   9*
 **/
-   { 0x01, KEY_1 },
-   { 0x02, KEY_2 },
-   { 0x03, KEY_3 },
-   { 0x04, KEY_4 },
-   { 0x05, KEY_5 },
-   { 0x06, KEY_6 },
-   { 0x07, KEY_7 },
-   { 0x08, KEY_8 },
-   { 0x09, KEY_9 },
+   { 0x6b8601, KEY_1 },
+   { 0x6b8602, KEY_2 },
+   { 0x6b8603, KEY_3 },
+   { 0x6b8604, KEY_4 },
+   { 0x6b8605, KEY_5 },
+   { 0x6b8606, KEY_6 },
+   { 0x6b8607, KEY_7 },
+   { 0x6b8608, KEY_8 },
+   { 0x6b8609, KEY_9 },
 
/*  0x0a0x000x17  *
 * RECALL0  MODE  *
 **/
-   { 0x0a, KEY_AGAIN },
-   { 0x00, KEY_0 },
-   { 0x17, KEY_MODE },
+   { 0x6b860a, KEY_AGAIN },
+   { 0x6b8600, KEY_0 },
+   { 0x6b8617, KEY_MODE },
 
/*  0x14  0x10*
 * ASPECT  FULLSCREEN *
 **/
-   { 0x14, KEY_SCREEN },
-   { 0x10, KEY_ZOOM },
+   { 0x6b8614, KEY_SCREEN },
+   { 0x6b8610, KEY_ZOOM },
 
/*  0x0b  *
 *   Up   *
@@ -73,17 +73,17 @@ static struct rc_map_table behold[] = {
 * 0x015  *
 * Down   *
 **/
-   { 0x0b, KEY_CHANNELUP },
-   { 0x18, KEY_VOLUMEDOWN },
-   { 0x16, KEY_OK },   /* XXX KEY_ENTER */
-   { 0x0c, KEY_VOLUMEUP },
-   { 0x15, KEY_CHANNELDOWN },
+   { 0x6b860b, KEY_CHANNELUP },
+   { 0x6b8618, KEY_VOLUMEDOWN },
+   { 0x6b8616, KEY_OK },   /* XXX KEY_ENTER */
+   { 0x6b860c, KEY_VOLUMEUP },
+   { 0x6b8615, KEY_CHANNELDOWN },
 
/*  0x110x0d  *
 *  MUTEINFO  *
 **/
-   { 0x11, KEY_MUTE },
-   { 0x0d, KEY_INFO },
+   { 0x6b8611, KEY_MUTE },
+   { 0x6b860d, KEY_INFO },
 
/*  0x0f0x1b0x1a  *
 * RECORD PLAY/PAUSE STOP *
@@ -92,26 +92,26 @@ static struct rc_map_table behold[] = {
 *TELETEXT  AUDIO  SOURCE *
 *   RED   YELLOW *
 **/
-   { 0x0f, KEY_RECORD },
-   { 0x1b, KEY_PLAYPAUSE },
-   { 0x1a, KEY_STOP },
-   { 0x0e, KEY_TEXT },
-   { 0x1f, KEY_RED },  /*XXX KEY_AUDIO */
-   { 0x1e, KEY_YELLOW },   /*XXX KEY_SOURCE*/
+   { 0x6b860f, KEY_RECORD },
+   { 0x6b861b, KEY_PLAYPAUSE },
+   { 0x6b861a, KEY_STOP },
+   { 0x6b860e, KEY_TEXT },
+   { 0x6b861f, KEY_RED },  /*XXX KEY_AUDIO */
+   { 0x6b861e, KEY_YELLOW },   /*XXX KEY_SOURCE*/
 
/*  0x1d   0x13 0x19  *
 * SLEEP  PREVIEW   DVB   *
 * GREENBLUE  *
 **/
-   { 0x1d, KEY_SLEEP },
-   { 0x13, KEY_GREEN },
-   { 0x19, KEY_BLUE }, /* XXX KEY_SAT  */
+   { 0x6b861d, KEY_SLEEP },
+   { 0x6b8613, KEY_GREEN },
+   { 0x6b8619, KEY_BLUE }, /* XXX KEY_SAT  */
 
/*  0x58   0x5c   *
 * FREEZESNAPSHOT *
 **/
-   { 0x58, KEY_SLOW },
-   { 0x5c, KEY_CAMERA },
+   { 0x6b8658, KEY_SLOW },
+   { 0x6b865c, KEY_CAMERA },
 
 };
 
@@ -119,7 +119,7 @@ static struct rc_map_list behold_map = {
.map = {
.scan= behold,
.size= ARRAY_SIZE(behold),
-   .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
+   .ir_type = IR_TYPE_NEC,
.name= RC_MAP_BEHOLD,
}
 };
diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index 4fdc165..10dc9ad 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -41,11 +41,6 @@ static int pinnacle_remote;
 

[PATCH 03/10] saa7134: some minor cleanups

2010-11-19 Thread David Härdeman
Mostly using appropriate data types and constants (e.g. int - bool).

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/video/saa7134/saa7134-input.c |   49 ++-
 drivers/media/video/saa7134/saa7134.h   |4 +-
 2 files changed, 21 insertions(+), 32 deletions(-)

diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index 10dc9ad..d75c307 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -407,17 +407,16 @@ static int __saa7134_ir_start(void *priv)
struct saa7134_dev *dev = priv;
struct saa7134_card_ir *ir;
 
-   if (!dev)
+   if (!dev || !dev-remote)
return -EINVAL;
 
ir  = dev-remote;
-   if (!ir)
-   return -EINVAL;
-
if (ir-running)
return 0;
 
ir-running = true;
+   ir-active = false;
+
if (ir-polling) {
setup_timer(ir-timer, saa7134_input_timer,
(unsigned long)dev);
@@ -425,10 +424,8 @@ static int __saa7134_ir_start(void *priv)
add_timer(ir-timer);
} else if (ir-raw_decode) {
/* set timer_end for code completion */
-   init_timer(ir-timer_end);
-   ir-timer_end.function = ir_raw_decode_timer_end;
-   ir-timer_end.data = (unsigned long)dev;
-   ir-active = false;
+   setup_timer(ir-timer_end, ir_raw_decode_timer_end,
+   (unsigned long)dev);
}
 
return 0;
@@ -439,22 +436,19 @@ static void __saa7134_ir_stop(void *priv)
struct saa7134_dev *dev = priv;
struct saa7134_card_ir *ir;
 
-   if (!dev)
+   if (!dev || !dev-remote)
return;
 
ir  = dev-remote;
-   if (!ir)
-   return;
-
if (!ir-running)
return;
-   if (dev-remote-polling)
-   del_timer_sync(dev-remote-timer);
-   else if (ir-raw_decode) {
+
+   if (ir-polling)
+   del_timer_sync(ir-timer);
+   else if (ir-raw_decode)
del_timer_sync(ir-timer_end);
-   ir-active = false;
-   }
 
+   ir-active = false;
ir-running = false;
 
return;
@@ -499,8 +493,8 @@ int saa7134_input_init1(struct saa7134_dev *dev)
u32 mask_keycode = 0;
u32 mask_keydown = 0;
u32 mask_keyup   = 0;
-   int polling  = 0;
-   int raw_decode   = 0;
+   unsigned polling = 0;
+   bool raw_decode  = false;
int err;
 
if (dev-has_remote != SAA7134_REMOTE_GPIO)
@@ -565,14 +559,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
mask_keydown = 0x004;   /* Enable GPIO18 line on both 
edges */
mask_keyup   = 0x004;
mask_keycode = 0x;
-   raw_decode   = 1;
+   raw_decode   = true;
break;
case SAA7134_BOARD_AVERMEDIA_M733A:
ir_codes = RC_MAP_AVERMEDIA_M733A_RM_K6;
mask_keydown = 0x004;
mask_keyup   = 0x004;
mask_keycode = 0x;
-   raw_decode   = 1;
+   raw_decode   = true;
break;
case SAA7134_BOARD_AVERMEDIA_777:
case SAA7134_BOARD_AVERMEDIA_A16AR:
@@ -679,7 +673,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
mask_keydown = 0x004;   /* Enable GPIO18 line on both 
edges */
mask_keyup   = 0x004;
mask_keycode = 0x;
-   raw_decode   = 1;
+   raw_decode   = true;
break;
case SAA7134_BOARD_ENCORE_ENLTV:
case SAA7134_BOARD_ENCORE_ENLTV_FM:
@@ -693,7 +687,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
mask_keydown = 0x004;   /* Enable GPIO18 line on both 
edges */
mask_keyup   = 0x004;
mask_keycode = 0x;
-   raw_decode   = 1;
+   raw_decode   = true;
break;
case SAA7134_BOARD_10MOONSTVMASTER3:
ir_codes = RC_MAP_ENCORE_ENLTV;
@@ -746,8 +740,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
ir-dev = rc;
dev-remote = ir;
 
-   ir-running = false;
-
/* init hardware-specific stuff */
ir-mask_keycode = mask_keycode;
ir-mask_keydown = mask_keydown;
@@ -809,14 +801,12 @@ void saa7134_input_fini(struct saa7134_dev *dev)
 void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
 {
struct i2c_board_info info;
-
struct i2c_msg msg_msi = {
.addr = 0x50,
.flags = I2C_M_RD,
.len = 0,
.buf = NULL,
};
-
int rc;
 
if (disable_ir) {
@@ -916,8 +906,8 @@ void saa7134_probe_i2c_ir(struct saa7134_dev 

[PATCH 04/10] saa7134: merge saa7134_card_ir-timer and saa7134_card_ir-timer_end

2010-11-19 Thread David Härdeman
Both timers are used for a similar purpose. Merging them allows for some
minor simplifications.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/video/saa7134/saa7134-input.c |   10 --
 drivers/media/video/saa7134/saa7134.h   |1 -
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index d75c307..98678d9 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -420,11 +420,11 @@ static int __saa7134_ir_start(void *priv)
if (ir-polling) {
setup_timer(ir-timer, saa7134_input_timer,
(unsigned long)dev);
-   ir-timer.expires  = jiffies + HZ;
+   ir-timer.expires = jiffies + HZ;
add_timer(ir-timer);
} else if (ir-raw_decode) {
/* set timer_end for code completion */
-   setup_timer(ir-timer_end, ir_raw_decode_timer_end,
+   setup_timer(ir-timer, ir_raw_decode_timer_end,
(unsigned long)dev);
}
 
@@ -443,10 +443,8 @@ static void __saa7134_ir_stop(void *priv)
if (!ir-running)
return;
 
-   if (ir-polling)
+   if (ir-polling || ir-raw_decode)
del_timer_sync(ir-timer);
-   else if (ir-raw_decode)
-   del_timer_sync(ir-timer_end);
 
ir-active = false;
ir-running = false;
@@ -923,7 +921,7 @@ static int saa7134_raw_decode_irq(struct saa7134_dev *dev)
 */
if (!ir-active) {
timeout = jiffies + jiffies_to_msecs(15);
-   mod_timer(ir-timer_end, timeout);
+   mod_timer(ir-timer, timeout);
ir-active = true;
}
 
diff --git a/drivers/media/video/saa7134/saa7134.h 
b/drivers/media/video/saa7134/saa7134.h
index f93951a..babfbe7 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -134,7 +134,6 @@ struct saa7134_card_ir {
boolactive;
 
struct timer_list   timer;
-   struct timer_list   timer_end;/* timer_end for code completion 
*/
 
/* IR core raw decoding */
u32 raw_decode;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/10] mceusb: int to bool conversion

2010-11-19 Thread David Härdeman
Convert boolean variables to use the corresponding data type.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/rc/mceusb.c |   62 +++--
 1 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index ef9bddc..bb6e2dc 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -103,9 +103,9 @@
 
 /* module parameters */
 #ifdef CONFIG_USB_DEBUG
-static int debug = 1;
+static bool debug = true;
 #else
-static int debug;
+static bool debug;
 #endif
 
 /* general constants */
@@ -151,12 +151,12 @@ enum mceusb_model_type {
 };
 
 struct mceusb_model {
-   u32 mce_gen1:1;
-   u32 mce_gen2:1;
-   u32 mce_gen3:1;
-   u32 tx_mask_inverted:1;
-   u32 is_polaris:1;
-   u32 no_tx:1;
+   bool mce_gen1:1;
+   bool mce_gen2:1;
+   bool mce_gen3:1;
+   bool tx_mask_inverted:1;
+   bool is_polaris:1;
+   bool no_tx:1;
 
const char *rc_map; /* Allow specify a per-board map */
const char *name;   /* per-board name */
@@ -164,22 +164,22 @@ struct mceusb_model {
 
 static const struct mceusb_model mceusb_model[] = {
[MCE_GEN1] = {
-   .mce_gen1 = 1,
-   .tx_mask_inverted = 1,
+   .mce_gen1 = true,
+   .tx_mask_inverted = true,
},
[MCE_GEN2] = {
-   .mce_gen2 = 1,
+   .mce_gen2 = true,
},
[MCE_GEN2_TX_INV] = {
-   .mce_gen2 = 1,
-   .tx_mask_inverted = 1,
+   .mce_gen2 = true,
+   .tx_mask_inverted = true,
},
[MCE_GEN3] = {
-   .mce_gen3 = 1,
-   .tx_mask_inverted = 1,
+   .mce_gen3 = true,
+   .tx_mask_inverted = true,
},
[POLARIS_EVK] = {
-   .is_polaris = 1,
+   .is_polaris = true,
/*
 * In fact, the EVK is shipped without
 * remotes, but we should have something handy,
@@ -189,8 +189,8 @@ static const struct mceusb_model mceusb_model[] = {
.name = Conexant Hybrid TV (cx231xx) MCE IR,
},
[CX_HYBRID_TV] = {
-   .is_polaris = 1,
-   .no_tx = 1, /* tx isn't wired up at all */
+   .is_polaris = true,
+   .no_tx = true, /* tx isn't wired up at all */
.name = Conexant Hybrid TV (cx231xx) MCE IR,
},
 };
@@ -344,10 +344,10 @@ struct mceusb_dev {
u8 cmd, rem;/* Remaining IR data bytes in packet */
 
struct {
-   u32 connected:1;
-   u32 tx_mask_inverted:1;
-   u32 microsoft_gen1:1;
-   u32 no_tx:1;
+   bool connected:1;
+   bool tx_mask_inverted:1;
+   bool microsoft_gen1:1;
+   bool no_tx:1;
} flags;
 
/* transmit support */
@@ -1090,21 +1090,11 @@ static int __devinit mceusb_dev_probe(struct 
usb_interface *intf,
int pipe, maxp, i;
char buf[63], name[128] = ;
enum mceusb_model_type model = id-driver_info;
-   bool is_gen3;
-   bool is_microsoft_gen1;
-   bool tx_mask_inverted;
-   bool is_polaris;
 
dev_dbg(intf-dev, %s called\n, __func__);
-
idesc  = intf-cur_altsetting;
 
-   is_gen3 = mceusb_model[model].mce_gen3;
-   is_microsoft_gen1 = mceusb_model[model].mce_gen1;
-   tx_mask_inverted = mceusb_model[model].tx_mask_inverted;
-   is_polaris = mceusb_model[model].is_polaris;
-
-   if (is_polaris) {
+   if (mceusb_model[model].is_polaris) {
/* Interface 0 is IR */
if (idesc-desc.bInterfaceNumber)
return -ENODEV;
@@ -1167,8 +1157,8 @@ static int __devinit mceusb_dev_probe(struct 
usb_interface *intf,
ir-usbdev = dev;
ir-dev = intf-dev;
ir-len_in = maxp;
-   ir-flags.microsoft_gen1 = is_microsoft_gen1;
-   ir-flags.tx_mask_inverted = tx_mask_inverted;
+   ir-flags.microsoft_gen1 = mceusb_model[model].mce_gen1;
+   ir-flags.tx_mask_inverted = mceusb_model[model].tx_mask_inverted;
ir-flags.no_tx = mceusb_model[model].no_tx;
ir-model = model;
 
@@ -1203,7 +1193,7 @@ static int __devinit mceusb_dev_probe(struct 
usb_interface *intf,
/* initialize device */
if (ir-flags.microsoft_gen1)
mceusb_gen1_init(ir);
-   else if (!is_gen3)
+   else if (!mceusb_model[model].mce_gen3)
mceusb_gen2_init(ir);
 
mceusb_get_parameters(ir);

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/10] saa7134: protect the ir user count

2010-11-19 Thread David Härdeman
The use of the saa7134_card_ir-users seems racy, so protect the count with
a spinlock. Also use proper data types as arguments to __saa7134_ir_start()
and __saa7134_ir_stop() to remove some unnecessary casts.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/video/saa7134/saa7134-input.c |   54 ---
 drivers/media/video/saa7134/saa7134.h   |1 +
 2 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index 98678d9..8b80efb 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -402,17 +402,12 @@ static void ir_raw_decode_timer_end(unsigned long data)
ir-active = false;
 }
 
-static int __saa7134_ir_start(void *priv)
+static void __saa7134_ir_start(struct saa7134_dev *dev)
 {
-   struct saa7134_dev *dev = priv;
-   struct saa7134_card_ir *ir;
-
-   if (!dev || !dev-remote)
-   return -EINVAL;
+   struct saa7134_card_ir *ir = dev-remote;
 
-   ir  = dev-remote;
if (ir-running)
-   return 0;
+   return;
 
ir-running = true;
ir-active = false;
@@ -427,19 +422,12 @@ static int __saa7134_ir_start(void *priv)
setup_timer(ir-timer, ir_raw_decode_timer_end,
(unsigned long)dev);
}
-
-   return 0;
 }
 
-static void __saa7134_ir_stop(void *priv)
+static void __saa7134_ir_stop(struct saa7134_dev *dev)
 {
-   struct saa7134_dev *dev = priv;
-   struct saa7134_card_ir *ir;
-
-   if (!dev || !dev-remote)
-   return;
+   struct saa7134_card_ir *ir = dev-remote;
 
-   ir  = dev-remote;
if (!ir-running)
return;
 
@@ -448,39 +436,60 @@ static void __saa7134_ir_stop(void *priv)
 
ir-active = false;
ir-running = false;
-
-   return;
 }
 
 int saa7134_ir_start(struct saa7134_dev *dev)
 {
+   if (!dev || !dev-remote)
+   return -EINVAL;
+
+   spin_lock(dev-remote-lock);
if (dev-remote-users)
-   return __saa7134_ir_start(dev);
+   __saa7134_ir_start(dev);
+   spin_unlock(dev-remote-lock);
 
return 0;
 }
 
 void saa7134_ir_stop(struct saa7134_dev *dev)
 {
+   if (!dev || !dev-remote)
+   return;
+
+   spin_lock(dev-remote-lock);
if (dev-remote-users)
__saa7134_ir_stop(dev);
+   spin_unlock(dev-remote-lock);
 }
 
 static int saa7134_ir_open(struct rc_dev *rc)
 {
struct saa7134_dev *dev = rc-priv;
 
+   if (!dev || !dev-remote)
+   return -EINVAL;
+
+   spin_lock(dev-remote-lock);
+   if (dev-remote-users == 0)
+   __saa7134_ir_start(dev);
dev-remote-users++;
-   return __saa7134_ir_start(dev);
+   spin_unlock(dev-remote-lock);
+
+   return 0;
 }
 
 static void saa7134_ir_close(struct rc_dev *rc)
 {
struct saa7134_dev *dev = rc-priv;
 
+   if (!dev || !dev-remote)
+   return;
+
+   spin_lock(dev-remote-lock);
dev-remote-users--;
-   if (!dev-remote-users)
+   if (dev-remote-users == 0)
__saa7134_ir_stop(dev);
+   spin_unlock(dev-remote-lock);
 }
 
 int saa7134_input_init1(struct saa7134_dev *dev)
@@ -744,6 +753,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
ir-mask_keyup   = mask_keyup;
ir-polling  = polling;
ir-raw_decode   = raw_decode;
+   spin_lock_init(ir-lock);
 
/* init input device */
snprintf(ir-name, sizeof(ir-name), saa7134 IR (%s),
diff --git a/drivers/media/video/saa7134/saa7134.h 
b/drivers/media/video/saa7134/saa7134.h
index babfbe7..7c836c3 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -125,6 +125,7 @@ struct saa7134_card_ir {
charname[32];
charphys[32];
unsignedusers;
+   spinlock_t  lock;
 
u32 polling;
 u32last_gpio;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/10] rc-core: fix some leftovers from the renaming patches

2010-11-19 Thread David Härdeman
Fix some minor comments etc which are leftover from the old naming scheme.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/rc/ir-raw.c   |2 +-
 drivers/media/rc/rc-core-priv.h |6 +++---
 drivers/media/rc/rc-main.c  |2 +-
 include/media/rc-core.h |   12 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 165412f..185badd 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -1,4 +1,4 @@
-/* ir-raw-event.c - handle IR Pulse/Space event
+/* ir-raw.c - handle IR pulse/space events
  *
  * Copyright (C) 2010 by Mauro Carvalho Chehab mche...@redhat.com
  *
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 48065b7..873b387 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -13,8 +13,8 @@
  *  GNU General Public License for more details.
  */
 
-#ifndef _IR_RAW_EVENT
-#define _IR_RAW_EVENT
+#ifndef _RC_CORE_PRIV
+#define _RC_CORE_PRIV
 
 #include linux/slab.h
 #include linux/spinlock.h
@@ -190,4 +190,4 @@ void ir_raw_init(void);
 #endif
 
 
-#endif /* _IR_RAW_EVENT */
+#endif /* _RC_CORE_PRIV */
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 0b0524c..6bdd0d3 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1,4 +1,4 @@
-/* rc-core.c - handle IR scancode-keycode tables
+/* rc-main.c - Remote Controller core module
  *
  * Copyright (C) 2009-2010 by Mauro Carvalho Chehab mche...@redhat.com
  *
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index affb93f..a23c1fc 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -206,12 +206,12 @@ static inline u32 ir_extract_bits(u32 data, u32 mask)
u32 vbit = 1, value = 0;
 
do {
-   if (mask  1) {
-   if (data  1)
-   value |= vbit;
-   vbit = 1;
-   }
-   data = 1;
+   if (mask  1) {
+   if (data  1)
+   value |= vbit;
+   vbit = 1;
+   }
+   data = 1;
} while (mask = 1);
 
return value;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/10] saa7134: make module parameters boolean

2010-11-19 Thread David Härdeman
int to bool conversion for module parameters which are truely boolean.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/video/saa7134/saa7134-input.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index 8b80efb..aea74e2 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -29,12 +29,12 @@
 
 #define MODULE_NAME saa7134
 
-static unsigned int disable_ir;
-module_param(disable_ir, int, 0444);
+static bool disable_ir;
+module_param(disable_ir, bool, 0444);
 MODULE_PARM_DESC(disable_ir,disable infrared remote support);
 
-static unsigned int ir_debug;
-module_param(ir_debug, int, 0644);
+static bool ir_debug;
+module_param(ir_debug, bool, 0644);
 MODULE_PARM_DESC(ir_debug,enable debug messages [IR]);
 
 static int pinnacle_remote;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/10] bttv: rename struct card_ir to bttv_ir

2010-11-19 Thread David Härdeman
bttv_ir is more consistent with all other structs used in the same driver.
Also, clean up the struct to remove commented out members and the work_struct
which is unused.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/video/bt8xx/bttv-input.c |   27 +--
 drivers/media/video/bt8xx/bttvp.h  |   31 +--
 2 files changed, 22 insertions(+), 36 deletions(-)

diff --git a/drivers/media/video/bt8xx/bttv-input.c 
b/drivers/media/video/bt8xx/bttv-input.c
index 773ee6a..c8bf423 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -49,7 +49,7 @@ module_param(ir_rc5_remote_gap, int, 0644);
 
 static void ir_handle_key(struct bttv *btv)
 {
-   struct card_ir *ir = btv-remote;
+   struct bttv_ir *ir = btv-remote;
u32 gpio,data;
 
/* read gpio value */
@@ -83,7 +83,7 @@ static void ir_handle_key(struct bttv *btv)
 
 static void ir_enltv_handle_key(struct bttv *btv)
 {
-   struct card_ir *ir = btv-remote;
+   struct bttv_ir *ir = btv-remote;
u32 gpio, data, keyup;
 
/* read gpio value */
@@ -122,7 +122,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
 
 void bttv_input_irq(struct bttv *btv)
 {
-   struct card_ir *ir = btv-remote;
+   struct bttv_ir *ir = btv-remote;
 
if (!ir-polling)
ir_handle_key(btv);
@@ -131,7 +131,7 @@ void bttv_input_irq(struct bttv *btv)
 static void bttv_input_timer(unsigned long data)
 {
struct bttv *btv = (struct bttv*)data;
-   struct card_ir *ir = btv-remote;
+   struct bttv_ir *ir = btv-remote;
 
if (btv-c.type == BTTV_BOARD_ENLTV_FM_2)
ir_enltv_handle_key(btv);
@@ -185,9 +185,9 @@ static u32 bttv_rc5_decode(unsigned int code)
return rc5;
 }
 
-void bttv_rc5_timer_end(unsigned long data)
+static void bttv_rc5_timer_end(unsigned long data)
 {
-   struct card_ir *ir = (struct card_ir *)data;
+   struct bttv_ir *ir = (struct card_ir *)data;
struct timeval tv;
unsigned long current_jiffies;
u32 gap;
@@ -206,7 +206,7 @@ void bttv_rc5_timer_end(unsigned long data)
}
 
/* signal we're ready to start a new code */
-   ir-active = 0;
+   ir-active = false;
 
/* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */
if (gap  28000) {
@@ -242,7 +242,7 @@ void bttv_rc5_timer_end(unsigned long data)
 
 static int bttv_rc5_irq(struct bttv *btv)
 {
-   struct card_ir *ir = btv-remote;
+   struct bttv_ir *ir = btv-remote;
struct timeval tv;
u32 gpio;
u32 gap;
@@ -278,7 +278,7 @@ static int bttv_rc5_irq(struct bttv *btv)
}
/* starting new code */
} else {
-   ir-active = 1;
+   ir-active = true;
ir-code = 0;
ir-base_time = tv;
ir-last_bit = 0;
@@ -295,7 +295,7 @@ static int bttv_rc5_irq(struct bttv *btv)
 
 /* -- */
 
-static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)
+static void bttv_ir_start(struct bttv *btv, struct bttv_ir *ir)
 {
if (ir-polling) {
setup_timer(ir-timer, bttv_input_timer, (unsigned long)btv);
@@ -303,9 +303,8 @@ static void bttv_ir_start(struct bttv *btv, struct card_ir 
*ir)
add_timer(ir-timer);
} else if (ir-rc5_gpio) {
/* set timer_end for code completion */
-   init_timer(ir-timer_end);
-   ir-timer_end.function = bttv_rc5_timer_end;
-   ir-timer_end.data = (unsigned long)ir;
+   setup_timer(ir-timer_end, bttv_rc5_timer_end,
+   (unsigned long)ir);
ir-shift_by = 1;
ir-start = 3;
ir-addr = 0x0;
@@ -409,7 +408,7 @@ int __devexit fini_bttv_i2c(struct bttv *btv)
 
 int bttv_input_init(struct bttv *btv)
 {
-   struct card_ir *ir;
+   struct bttv_ir *ir;
char *ir_codes = NULL;
struct rc_dev *rc;
int err = -ENOMEM;
diff --git a/drivers/media/video/bt8xx/bttvp.h 
b/drivers/media/video/bt8xx/bttvp.h
index b71d04d..3d5b2bc 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -120,15 +120,12 @@ struct bttv_format {
int  hshift,vshift;   /* for planar modes   */
 };
 
-struct card_ir {
+struct bttv_ir {
struct rc_dev   *dev;
 
charname[32];
charphys[32];
-#if 0
-   int users;
-   u32 running:1;
-#endif
+
/* Usual gpio signalling */
u32 mask_keycode;
u32 mask_keydown;
@@ -139,25 +136,15 @@ struct card_ir {
int start; // What should RC5_START() be
int addr; 

Re: [RFC PATCH 0/2] Apple remote support

2010-11-19 Thread David Härdeman
On Thu, Nov 18, 2010 at 06:59:43PM -0200, Mauro Carvalho Chehab wrote:
Em 18-11-2010 18:49, Jarod Wilson escreveu:
 On Thu, Nov 18, 2010 at 09:43:19PM +0100, David Härdeman wrote:
 On Thu, Nov 18, 2010 at 11:33:04AM -0500, Jarod Wilson wrote:
 Mauro's suggestion, iirc, was that max scancode size should be a
 property of the keytable uploaded, and something set at load time (and
 probably exposed as a sysfs node, similar to protocols).

 I think that would be a step in the wrong direction. It would make the
 keytables less flexible while providing no real advantages.

We can't simply just change NEC to 32 bits, as we'll break userspace ABI 
(as current NEC keycode tables use only 16 bits). So, an old table will not
worky anymore, if we do such change.

The idea was to do the conversion from whatever to 32 bits in
get/setkeycode.


-- 
David Härdeman
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [linux-dvb] DVB Driver for DiBcom's DiB7000M does not support the remote control for the kaiserbass TVStick

2010-11-19 Thread David Wilson
This is my first attempt at working on a linux driver and I need some
assistance.

I have purchased the  kaiserbass TVStick product ID 'KBA01007-KB DVD-T
USB TUNER WITH 2 GB MEMORY'. The Linux-DVB Driver for DiBcom's DiB7000M
driver works very well for video, but the software driver does not
support the slim 28 key remote control provided by  kaiserbass.

The driver has support coded for several ir remote devices but not for
the unbranded slim 28 key one supplied with my tuner.

The  driver reports unrecognised remote key sequences it receives, for
example, the volume up key results in the system error message:

2010-11-14 13:07:26Capuletkernel[10464.828505] dib0700:
Unknown remote controller key:  2b d4

I tried adding a new set of key codes to the DiB7000M-devices.c file i.e.

{ 0x2bd4, KEY_VOLUMEUP },

and compiled and tested it but this did not work, the driver still
reports the keys as unrecognised. Perhaps I have used the wrong
conversion or format for the key values.

I have looked at the MS Windows driver configuration that came with the
tuner - modrc.infl, it defines the volume up key as:

HKR,,ReportMappingTable,0x0001,\
   \;0x01,SystemMSB,SystemLSB,Data, Flags, ...

 0x01,0x00,0x00,0x2C, 0x0B, 0x04,0x00,0x42,  \ ; AC volume up
..

I can not see the relationship between controller reported in the system
log - key:  2b d4 and MS defined - 0x01,0x00,0x00,0x2C, 0x0B,
0x04,0x00,0x42

So there seems to de some some code conversion going on or incorrect
reporting of the key input.

Can anyone  assist me with this ?

regards

David Wilson

On 14/11/10 16:19, David Wilson wrote:

 I have purchased the  kaiserbass TVStick product ID 'KBA01007-KB DVD-T
 USB TUNER WITH 2 GB MEMORY'. The Linux-DVB Driver for DiBcom's
 DiB7000M driver works very well for video, but the software driver
 does not support the slim 28 key remote control provided by  kaiserbass.

 The evidence is the error codes in the system log. For example
 pressing any key causes a system log error, the volume up key results
 in the system error message:

 2010-11-14 13:07:26Capuletkernel[10464.828505] dib0700:
 Unknown remote controller key:  2b d4


 I tried adding a new set of key codes to the DiB7000M-devices.c file i.e.

 { 0x2bd4, KEY_VOLUMEUP },

 but this did not work, perhaps I have used the wrong conversion or
 format for the key values.
 Here are the key values from the system error messages

 KEY_MUTE0AF5   
 KEY_SOURCE  38C7
 KEY_SCREEN  0FF0
 KEY_POWER   0CF3
 KEY_1   01FE
 KEY_2   02FD
 KEY_3   03FC
 KEY_4   04FB
 KEY_5   05FA
 KEY_6   06F9
 KEY_7   07F8
 KEY_8   08F7
 KEY_9   09F6
 KEY_0   00FF
 KEY_UP  20DF
 KEY_ESC 29D6
 KEY_FASTFORWARD 1EE1
 KEY_LEFT11EE
 KEY_OK  0DF2
 KEY_RIGHT   10EF
 KEY_VOLUMEUP2BD4
 KEY_CHANNELUP   12ED
 KEY_DOWN21DE
 KEY_STOP0BF4
 KEY_CHANNELDOWN 13EC
 KEY_VOLUMEDOWN  2CD3
 KEY_SCREEN_COPY 0EF1
 KEY_RECORD  1FEO

 regards

 David Wilson


 ___
 linux-dvb users mailing list
 For V4L/DVB development, please use instead linux-media@vger.kernel.org
 linux-...@linuxtv.org
 http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/10] saa7134: make module parameters boolean

2010-11-19 Thread hermann pitton

Am Samstag, den 20.11.2010, 00:43 +0100 schrieb David Härdeman:
 int to bool conversion for module parameters which are truely boolean.
 
 Signed-off-by: David Härdeman da...@hardeman.nu
 ---
  drivers/media/video/saa7134/saa7134-input.c |8 
  1 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/media/video/saa7134/saa7134-input.c 
 b/drivers/media/video/saa7134/saa7134-input.c
 index 8b80efb..aea74e2 100644
 --- a/drivers/media/video/saa7134/saa7134-input.c
 +++ b/drivers/media/video/saa7134/saa7134-input.c
 @@ -29,12 +29,12 @@
  
  #define MODULE_NAME saa7134
  
 -static unsigned int disable_ir;
 -module_param(disable_ir, int, 0444);
 +static bool disable_ir;
 +module_param(disable_ir, bool, 0444);
  MODULE_PARM_DESC(disable_ir,disable infrared remote support);
  
 -static unsigned int ir_debug;
 -module_param(ir_debug, int, 0644);
 +static bool ir_debug;
 +module_param(ir_debug, bool, 0644);
  MODULE_PARM_DESC(ir_debug,enable debug messages [IR]);
  
  static int pinnacle_remote;
 

Hi,

not exactly that one, but given all the previous changes,

I wonder if there will ever be some tested-by: from someone ...

Cheers,
Hermann


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html