[PATCH 2/2] USB: ehci-s5p: add function for burst

2012-02-29 Thread Sangwook Lee
Add platform specific function for EHCI burst function

Signed-off-by: Sangwook Lee 
---
 drivers/usb/host/ehci-s5p.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 293f741..c5eb0ce 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -134,6 +134,9 @@ static int __devinit s5p_ehci_probe(struct platform_device 
*pdev)
/* cache this readonly data; minimize chip reads */
ehci->hcs_params = readl(&ehci->caps->hcs_params);
 
+   if (pdata->burst_enable)
+   pdata->burst_enable(pdev, hcd->regs);
+
ehci_reset(ehci);
 
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 0/2] add ehci-s5p AHB burst function

2012-02-29 Thread Sangwook Lee
Enable burst transfer from AHB for EHCI.
This fixes data transfer issue of USB Ethernet with EHCI.
Without this patch, ping works and network utilities such as scp hardly works.

It was tested on Origen board with the following configs.
root@linaro-alip:~# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=exynos-ohci/3p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=s5p-ehci/3p, 480M
   |__ Port 1: Dev 2, If 0, Class=vend., Driver=MOSCHIP usb-ethernet driver, 
480M


Sangwook Lee (2):
  ARM: EXYNOS: Add EHCI AHB burst function
  USB: ehci-s5p: add function for burst

 arch/arm/mach-exynos/setup-usb-phy.c  |6 ++
 arch/arm/plat-samsung/devs.c  |2 ++
 arch/arm/plat-samsung/include/plat/ehci.h |   19 +++
 drivers/usb/host/ehci-s5p.c   |3 +++
 4 files changed, 30 insertions(+), 0 deletions(-)

-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 1/2] ARM: EXYNOS: Add EHCI AHB burst function

2012-02-29 Thread Sangwook Lee
Enable burst transfer from AHB for EHCI.
This fixes data transfer of USB Ethernet with EHCI.
Without this patch, scp hardly works.

Signed-off-by: Sangwook Lee 
---
 arch/arm/mach-exynos/setup-usb-phy.c  |6 ++
 arch/arm/plat-samsung/devs.c  |2 ++
 arch/arm/plat-samsung/include/plat/ehci.h |   19 +++
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index 41743d2..5a20460 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static atomic_t host_usage;
 
@@ -149,3 +150,8 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int type)
 
return -EINVAL;
 }
+
+void s5p_ehci_burst_enable(struct platform_device *pdev, void __iomem *base)
+{
+   writel(EHCI_INSNREG00_ENABLE_BURST, base + EHCI_INSNREG00);
+}
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index f10768e..8fd1bd3 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -1402,6 +1402,8 @@ void __init s5p_ehci_set_platdata(struct 
s5p_ehci_platdata *pd)
npd->phy_init = s5p_usb_phy_init;
if (!npd->phy_exit)
npd->phy_exit = s5p_usb_phy_exit;
+   if (!npd->burst_enable)
+   npd->burst_enable = s5p_ehci_burst_enable;
 }
 #endif /* CONFIG_S5P_DEV_USB_EHCI */
 
diff --git a/arch/arm/plat-samsung/include/plat/ehci.h 
b/arch/arm/plat-samsung/include/plat/ehci.h
index 5f28cae..9c866b7 100644
--- a/arch/arm/plat-samsung/include/plat/ehci.h
+++ b/arch/arm/plat-samsung/include/plat/ehci.h
@@ -14,8 +14,27 @@
 struct s5p_ehci_platdata {
int (*phy_init)(struct platform_device *pdev, int type);
int (*phy_exit)(struct platform_device *pdev, int type);
+   void (*burst_enable)(struct platform_device *pdev, void __iomem *base);
 };
 
 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
+extern void s5p_ehci_burst_enable(struct platform_device *pdev,
+   void __iomem *base);
+
+/* EHCI EXYNOS specific register */
+#define EHCI_INSNREG00 0x90
+
+/*
+ * EHCI INSNREG00 Specific fields
+ * Enable AHB master to use burst transfer from 4 to 16
+ */
+#define EHCI_INSNREG00_ENABLE_INCR16   (1 << 25)
+#define EHCI_INSNREG00_ENABLE_INCR8(1 << 24)
+#define EHCI_INSNREG00_ENABLE_INCR4(1 << 23)
+/* Force AHB master to start burst transfer only for 4,8,16 alignment */
+#define EHCI_INSNREG00_ENABLE_INCRX_ALIGN (1 << 22)
+#define EHCI_INSNREG00_ENABLE_BURST\
+   (EHCI_INSNREG00_ENABLE_INCR16 | EHCI_INSNREG00_ENABLE_INCR8 |   \
+   EHCI_INSNREG00_ENABLE_INCR4 | EHCI_INSNREG00_ENABLE_INCRX_ALIGN)
 
 #endif /* __PLAT_SAMSUNG_EHCI_H */
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 1/2] ARM: EXYNOS: Add EHCI AHB burst function

2012-02-29 Thread Sangwook Lee

Hi Jingoo

On 29/02/12 13:23, Jingoo Han wrote:

Hi, Sangwook.

I know what you want to add.
I'll send new patch which can enable EHCI burst mode.


Great !

Thanks
Sangwook


This new patch will not use platform data callback and different machine 
directory
file to include EHCI INSNREG00 definitions.
Also, comment will be modified properly.


Thank you.

Best regards,
Jingoo Han.


-Original Message-
From: Sangwook Lee [mailto:sangwook@linaro.org]
Sent: Wednesday, February 29, 2012 9:41 PM
To: linux-samsung-...@vger.kernel.org; linux-...@vger.kernel.org; 
linux-arm-ker...@lists.infradead.org
Cc: ben-li...@fluff.org; gre...@suse.de; kgene@samsung.com; 
st...@rowland.harvard.edu;
jg1@samsung.com; jy0922.s...@samsung.com; patc...@linaro.org; 
linaro-dev@lists.linaro.org;
li...@arm.linux.org.uk; Sangwook Lee
Subject: [PATCH 1/2] ARM: EXYNOS: Add EHCI AHB burst function

Enable burst transfer from AHB for EHCI.
This fixes data transfer of USB Ethernet with EHCI.
Without this patch, scp hardly works.

Signed-off-by: Sangwook Lee
---
  arch/arm/mach-exynos/setup-usb-phy.c  |6 ++
  arch/arm/plat-samsung/devs.c  |2 ++
  arch/arm/plat-samsung/include/plat/ehci.h |   19 +++
  3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index 41743d2..5a20460 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -18,6 +18,7 @@
  #include
  #include
  #include
+#include

  static atomic_t host_usage;

@@ -149,3 +150,8 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int type)

return -EINVAL;
  }
+
+void s5p_ehci_burst_enable(struct platform_device *pdev, void __iomem *base)
+{
+   writel(EHCI_INSNREG00_ENABLE_BURST, base + EHCI_INSNREG00);
+}
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index f10768e..8fd1bd3 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -1402,6 +1402,8 @@ void __init s5p_ehci_set_platdata(struct 
s5p_ehci_platdata *pd)
npd->phy_init = s5p_usb_phy_init;
if (!npd->phy_exit)
npd->phy_exit = s5p_usb_phy_exit;
+   if (!npd->burst_enable)
+   npd->burst_enable = s5p_ehci_burst_enable;
  }
  #endif /* CONFIG_S5P_DEV_USB_EHCI */

diff --git a/arch/arm/plat-samsung/include/plat/ehci.h 
b/arch/arm/plat-samsung/include/plat/ehci.h
index 5f28cae..9c866b7 100644
--- a/arch/arm/plat-samsung/include/plat/ehci.h
+++ b/arch/arm/plat-samsung/include/plat/ehci.h
@@ -14,8 +14,27 @@
  struct s5p_ehci_platdata {
int (*phy_init)(struct platform_device *pdev, int type);
int (*phy_exit)(struct platform_device *pdev, int type);
+   void (*burst_enable)(struct platform_device *pdev, void __iomem *base);
  };

  extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
+extern void s5p_ehci_burst_enable(struct platform_device *pdev,
+   void __iomem *base);
+
+/* EHCI EXYNOS specific register */
+#define EHCI_INSNREG00 0x90
+
+/*
+ * EHCI INSNREG00 Specific fields
+ * Enable AHB master to use burst transfer from 4 to 16
+ */
+#define EHCI_INSNREG00_ENABLE_INCR16   (1<<  25)
+#define EHCI_INSNREG00_ENABLE_INCR8(1<<  24)
+#define EHCI_INSNREG00_ENABLE_INCR4(1<<  23)
+/* Force AHB master to start burst transfer only for 4,8,16 alignment */
+#define EHCI_INSNREG00_ENABLE_INCRX_ALIGN (1<<  22)
+#define EHCI_INSNREG00_ENABLE_BURST\
+   (EHCI_INSNREG00_ENABLE_INCR16 | EHCI_INSNREG00_ENABLE_INCR8 |   \
+   EHCI_INSNREG00_ENABLE_INCR4 | EHCI_INSNREG00_ENABLE_INCRX_ALIGN)

  #endif /* __PLAT_SAMSUNG_EHCI_H */
--
1.7.4.1




___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 1/2] ARM: EXYNOS: Add EHCI AHB burst function

2012-02-29 Thread Sangwook Lee



On 29/02/12 13:01, Thomas Abraham wrote:

Hi Sangwook,

On 29 February 2012 18:11, Sangwook Lee  wrote:

Enable burst transfer from AHB for EHCI.
This fixes data transfer of USB Ethernet with EHCI.
Without this patch, scp hardly works.

Signed-off-by: Sangwook Lee
---
  arch/arm/mach-exynos/setup-usb-phy.c  |6 ++
  arch/arm/plat-samsung/devs.c  |2 ++
  arch/arm/plat-samsung/include/plat/ehci.h |   19 +++
  3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index 41743d2..5a20460 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -18,6 +18,7 @@
  #include
  #include
  #include
+#include

  static atomic_t host_usage;

@@ -149,3 +150,8 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int type)

return -EINVAL;
  }
+
+void s5p_ehci_burst_enable(struct platform_device *pdev, void __iomem *base)
+{
+   writel(EHCI_INSNREG00_ENABLE_BURST, base + EHCI_INSNREG00);
+}


This functionality can be added in ehci-s5p itself and avoid adding a
new platform callback in platform data. If this is specific to exynos,
driver data could be added in ehci-s5p to indicate platforms that need
this to be enabled.


it makes sense.



Thanks,
Thomas.

[...]


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 1/2] ARM: EXYNOS: Add EHCI AHB burst function

2012-03-01 Thread Sangwook Lee
On 1 March 2012 03:24, Tushar Behera  wrote:

> On 02/29/2012 06:31 PM, Thomas Abraham wrote:
> > Hi Sangwook,
> >
> > On 29 February 2012 18:11, Sangwook Lee  wrote:
> >> Enable burst transfer from AHB for EHCI.
> >> This fixes data transfer of USB Ethernet with EHCI.
> >> Without this patch, scp hardly works.
> >>
> >> Signed-off-by: Sangwook Lee 
> >> ---
> >>  arch/arm/mach-exynos/setup-usb-phy.c  |6 ++
> >>  arch/arm/plat-samsung/devs.c  |2 ++
> >>  arch/arm/plat-samsung/include/plat/ehci.h |   19 +++
> >>  3 files changed, 27 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/arch/arm/mach-exynos/setup-usb-phy.c
> b/arch/arm/mach-exynos/setup-usb-phy.c
> >> index 41743d2..5a20460 100644
> >> --- a/arch/arm/mach-exynos/setup-usb-phy.c
> >> +++ b/arch/arm/mach-exynos/setup-usb-phy.c
> >> @@ -18,6 +18,7 @@
> >>  #include 
> >>  #include 
> >>  #include 
> >> +#include 
> >>
> >>  static atomic_t host_usage;
> >>
> >> @@ -149,3 +150,8 @@ int s5p_usb_phy_exit(struct platform_device *pdev,
> int type)
> >>
> >>return -EINVAL;
> >>  }
> >> +
> >> +void s5p_ehci_burst_enable(struct platform_device *pdev, void __iomem
> *base)
> >> +{
> >> +   writel(EHCI_INSNREG00_ENABLE_BURST, base + EHCI_INSNREG00);
> >> +}
> >
> > This functionality can be added in ehci-s5p itself and avoid adding a
> > new platform callback in platform data. If this is specific to exynos,
> > driver data could be added in ehci-s5p to indicate platforms that need
> > this to be enabled.
> >
> Am I right in assuming that ehci-s5p driver can also be used for
> mach-s5pv210?
>
> The related bit-fields are reserved in S5PV210. So, won't it cause any
> side-effects?
>
>
do we use ehci-s5p.c in CPU 64xx series ?

>
> > Thanks,
> > Thomas.
> >
> > [...]
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> linux-samsung-soc" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> --
> Tushar Behera
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH v2 1/2] ARM: EXYNOS: Add USB HOST register definitions

2012-03-01 Thread Sangwook Lee
On 1 March 2012 15:24, Heiko Stübner  wrote:

> Am Donnerstag, 1. März 2012, 06:38:20 schrieb Jingoo Han:
> > This patch adds USB HOST register definitions. The definition for
> > EHCI INSNREG00 regiser and corresponding bit field definitions are
> > added.
> >
> > Signed-off-by: Sangwook Lee 
> > Signed-off-by: Jingoo Han 
> > ---
> > v2: change the definition name from EHCI_ENA_xxx to
> EHCI_INSNREG00_ENA_xxx.
> >
> > arch/arm/mach-exynos/include/mach/regs-usb-host.h |   24
> > + 1 files changed, 24 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/arm/mach-exynos/include/mach/regs-usb-host.h
> Isn't the general idea to depopulate the mach directories and make drivers
> buildable across architectures?
>
> The definitions are only used in drivers/usb/host/ehci-s5p.c [in the second
> patch], so there should be no need to add another arch-header and they
> could
> simply be included in the driver itself or if necessary a
> drivers/usb/host/ehci-s5p.h .
>

 I found out some code related to this burst function.

 the snip from ehci-s5pv210.c, 2.6.35 kernel

/* Mark hardware accessible again as we are out of D3 state by now
*/
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
#if defined(CONFIG_ARCH_S5PV210) || defined(CONFIG_ARCH_S5P6450)
ehci_writel(ehci, 0x000F, (void __iomem *)ehci->caps + 0x90);
#endif

#if defined(CONFIG_ARCH_S5PV310)
ehci_writel(ehci, 0x03C0, (void __iomem *)ehci->caps + 0x90);
#endif
if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) {

>From this code, this burst function seems to be depending on CPUs,
The driver by itself is not good idea because echi-s5p.c will have defined.

Which is the better place to pus this CPU specific definition either
drivers/usb/host/ehci-s5p.h is
or mach/xx.h or  include/linux/usb/xxx.h ?  I am not clear about this.


Heiko
>
> > diff --git a/arch/arm/mach-exynos/include/mach/regs-usb-host.h
> > b/arch/arm/mach-exynos/include/mach/regs-usb-host.h new file mode 100644
> > index 000..572b7d4
> > --- /dev/null
> > +++ b/arch/arm/mach-exynos/include/mach/regs-usb-host.h
> > @@ -0,0 +1,24 @@
> > +/*
> > + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> > + *   http://www.samsung.com
> > + *
> > + * EXYNOS - USB HOST register definitions
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#ifndef __REGS_USB_HOST_H
> > +#define __REGS_USB_HOST_H __FILE__
> > +
> > +#define EHCI_INSNREG00(base) (base + 0x90)
> > +#define EHCI_INSNREG00_ENA_INCR16(0x1 << 25)
> > +#define EHCI_INSNREG00_ENA_INCR8 (0x1 << 24)
> > +#define EHCI_INSNREG00_ENA_INCR4 (0x1 << 23)
> > +#define EHCI_INSNREG00_ENA_INCRX_ALIGN   (0x1 << 22)
> > +#define EHCI_INSNREG00_ENABLE_DMA_BURST  \
> > + (EHCI_INSNREG00_ENA_INCR16 | EHCI_INSNREG00_ENA_INCR8 | \
> > +  EHCI_INSNREG00_ENA_INCR4 | EHCI_INSNREG00_ENA_INCRX_ALIGN)
> > +
> > +#endif /* __REGS_USB_HOST_H */
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-samsung-soc" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: Slow/broken USB and Ethernet on Snowballs/Origen boards?

2012-03-16 Thread Sangwook Lee
On 16 March 2012 04:14, Sachin Kamat  wrote:

> Hi,
>
> On 15/03/2012, Mans Rullgard  wrote:
> > On 14 March 2012 20:04, Jannis Pohlmann  >
> > wrote:
> >> Hi,
> >>
> >> I am currently playing with a couple of the development boards for which
> >> there are Linaro hwpacks and LEBs. Since what I am trying to do requires
> >> a lot of disk and network I/O, I've been paying special attention to the
> >> data transfer rates I can get out of these boards.
> >>
> >> Below is a brief summary of my findings.
> >>
> >> 3) Origen
> >>
> >>  * the internal USB hub runs at Full Speed (12 MBit/s), resulting in a
> >>maximum USB disk I/O of 1.5 MByte/s
> >>
> >>  * since the board does not feature Ethernet itself, I tried to attach
> >>a USB Ethernet controller to it, but of course the transfer rate
> >>through that is by the I/O upper limit of the USB hub
> >>
> >>  * I did not test wireless but it is not feasible for what I am trying
> >>to do anyway
> >
> > Which kernel version are you using on the Origen?  I noticed the same
> > problem
> > a while back, but it appears to have been fixed in the Samsung landing
> team
> > tree.  There is still another bug present in the Origen kernel preventing
> > USB-ethernet working with EHCI.  Some patches have been posted, but they
> > have
> > not made it into the trees yet.
>
> These patches have been added to Samsung LT tree [1].
>
> [1] git://git.linaro.org/landing-teams/working/samsung/kernel.git
> (branch: tracking)
>
>
For http access,
http://git.linaro.org/gitweb?p=landing-teams/working/samsung/kernel.git;a=summary



> Search the mailing lists for s5p usb burst
> > to find them.
> >
> > --
> > Mans Rullgard / mru
> >
> > ___
> > linaro-dev mailing list
> > linaro-dev@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/linaro-dev
> >
>
>
> --
> With warm regards,
> Sachin
>
> ___
> linaro-dev mailing list
> linaro-dev@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-dev
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: Slow/broken USB and Ethernet on Snowballs/Origen boards?

2012-03-16 Thread Sangwook Lee
Hi Mans

On 16 March 2012 11:50, Mans Rullgard  wrote:

> On 16 March 2012 04:14, Sachin Kamat  wrote:
> > Hi,
> >
> > On 15/03/2012, Mans Rullgard  wrote:
> >> On 14 March 2012 20:04, Jannis Pohlmann <
> jannis.pohlm...@codethink.co.uk>
> >> wrote:
> >>> Hi,
> >>>
> >>> I am currently playing with a couple of the development boards for
> which
> >>> there are Linaro hwpacks and LEBs. Since what I am trying to do
> requires
> >>> a lot of disk and network I/O, I've been paying special attention to
> the
> >>> data transfer rates I can get out of these boards.
> >>>
> >>> Below is a brief summary of my findings.
> >>>
> >>> 3) Origen
> >>>
> >>>  * the internal USB hub runs at Full Speed (12 MBit/s), resulting in a
> >>>maximum USB disk I/O of 1.5 MByte/s
> >>>
> >>>  * since the board does not feature Ethernet itself, I tried to attach
> >>>a USB Ethernet controller to it, but of course the transfer rate
> >>>through that is by the I/O upper limit of the USB hub
> >>>
> >>>  * I did not test wireless but it is not feasible for what I am trying
> >>>to do anyway
> >>
> >> Which kernel version are you using on the Origen?  I noticed the same
> >> problem
> >> a while back, but it appears to have been fixed in the Samsung landing
> team
> >> tree.  There is still another bug present in the Origen kernel
> preventing
> >> USB-ethernet working with EHCI.  Some patches have been posted, but they
> >> have not made it into the trees yet.
> >
> > These patches have been added to Samsung LT tree [1].
> >
> > [1] git://git.linaro.org/landing-teams/working/samsung/kernel.git
> > (branch: tracking)
>
> That branch still needs one more patch (attached).
>
> Thanks for looking at this git.

Initially I submitted patches with the call-back function
http://www.spinics.net/lists/linux-usb/msg59212.html

But maintainers  don't like to use call-back function, and it was rejected.
So Now LT doesn't to use this call-back function


> but it was
>
--
> Mans Rullgard / mru
>
> ___
> linaro-dev mailing list
> linaro-dev@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-dev
>
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH] usb: gadget: s3c-hsotg: fix kernel panic

2012-03-16 Thread Sangwook Lee
Fix kernel panic from s3c_hsotg_udc_stop.
if udc_is_newstyle is true, s3c_hsotg_udc_stop should not
call disconnect, unbind.

As running rmmod g_mass_storage, kernel panic happens.

(composite_unbind+0x14/0x164 [g_mass_storage])
from [] (s3c_hsotg_udc_stop)

This patch is based on Lukasz Majewski's patches:
[PATCH 0/9] USB: s3c-hsotg: USB S3C-HSOTG driver fixes and code cleanu

in order to test g_mass_storage in Origen board:

Signed-off-by: Sangwook Lee 
---
 drivers/usb/gadget/s3c-hsotg.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 4262df8..9925661 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -2883,16 +2883,12 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
for (ep = 0; ep < hsotg->num_of_eps; ep++)
s3c_hsotg_ep_disable(&hsotg->eps[ep].ep);
 
-   call_gadget(hsotg, disconnect);
-
-   driver->unbind(&hsotg->gadget);
s3c_hsotg_phy_disable(hsotg);
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
 
hsotg->driver = NULL;
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
-
-   device_del(&hsotg->gadget.dev);
+   hsotg->gadget.dev.driver = NULL;
 
dev_info(hsotg->dev, "unregistered gadget driver '%s'\n",
 driver->driver.name);
@@ -3526,7 +3522,10 @@ static int __devexit s3c_hsotg_remove(struct 
platform_device *pdev)
 
s3c_hsotg_delete_debug(hsotg);
 
-   usb_gadget_unregister_driver(hsotg->driver);
+   if (hsotg->driver) {
+   /* should have been done already by driver model core */
+   usb_gadget_unregister_driver(hsotg->driver);
+   }
 
free_irq(hsotg->irq, hsotg);
iounmap(hsotg->regs);
@@ -3540,6 +3539,7 @@ static int __devexit s3c_hsotg_remove(struct 
platform_device *pdev)
clk_disable(hsotg->clk);
clk_put(hsotg->clk);
 
+   device_unregister(&hsotg->gadget.dev);
kfree(hsotg);
return 0;
 }
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: Slow/broken USB and Ethernet on Snowballs/Origen boards?

2012-03-16 Thread Sangwook Lee
On 16 March 2012 14:55, Mans Rullgard  wrote:

> On 16 March 2012 12:36, Sangwook Lee  wrote:
> > Hi Mans
> >
> > On 16 March 2012 11:50, Mans Rullgard  wrote:
> >>
> >> On 16 March 2012 04:14, Sachin Kamat  wrote:
> >> > Hi,
> >> >
> >> > On 15/03/2012, Mans Rullgard  wrote:
> >> >> On 14 March 2012 20:04, Jannis Pohlmann
> >> >> 
> >> >> wrote:
> >> >>> Hi,
> >> >>>
> >> >>> I am currently playing with a couple of the development boards for
> >> >>> which
> >> >>> there are Linaro hwpacks and LEBs. Since what I am trying to do
> >> >>> requires
> >> >>> a lot of disk and network I/O, I've been paying special attention to
> >> >>> the
> >> >>> data transfer rates I can get out of these boards.
> >> >>>
> >> >>> Below is a brief summary of my findings.
> >> >>>
> >> >>> 3) Origen
> >> >>>
> >> >>>  * the internal USB hub runs at Full Speed (12 MBit/s), resulting
> in a
> >> >>>maximum USB disk I/O of 1.5 MByte/s
> >> >>>
> >> >>>  * since the board does not feature Ethernet itself, I tried to
> attach
> >> >>>a USB Ethernet controller to it, but of course the transfer rate
> >> >>>through that is by the I/O upper limit of the USB hub
> >> >>>
> >> >>>  * I did not test wireless but it is not feasible for what I am
> trying
> >> >>>to do anyway
> >> >>
> >> >> Which kernel version are you using on the Origen?  I noticed the same
> >> >> problem
> >> >> a while back, but it appears to have been fixed in the Samsung
> landing
> >> >> team
> >> >> tree.  There is still another bug present in the Origen kernel
> >> >> preventing
> >> >> USB-ethernet working with EHCI.  Some patches have been posted, but
> >> >> they
> >> >> have not made it into the trees yet.
> >> >
> >> > These patches have been added to Samsung LT tree [1].
> >> >
> >> > [1] git://git.linaro.org/landing-teams/working/samsung/kernel.git
> >> > (branch: tracking)
> >>
> >> That branch still needs one more patch (attached).
> >>
> > Thanks for looking at this git.
> >
> > Initially I submitted patches with the call-back function
> > http://www.spinics.net/lists/linux-usb/msg59212.html
> >
> > But maintainers  don't like to use call-back function, and it was
> rejected.
> > So Now LT doesn't to use this call-back function
>
> Yes, I saw that, but the tracking branch in git still has the incomplete
> callback version.
>
>
You're right.

@Tushar, we need to apply Mans's patch as well.

Thanks Mans!






> --
> Mans Rullgard / mru
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: Linaro 12.04 3.4-rc1 based androidization branch is available

2012-04-13 Thread Sangwook Lee

Hi John

On 11/04/12 20:19, John Stultz wrote:

On 04/09/2012 03:18 PM, John Stultz wrote:

I went ahead and forward ported the AOSP-3.3 tree to 3.4-rc1.

You can grab it here:
git://git.linaro.org/people/jstultz/android.git
linaro-android-3.4-jstultz-rebase


Sigh. Looks like the Google devs are following close behind and released
their own 3.4-rc2 based tree.

Don't get me wrong: Its great to see them keeping up with mainline, but
I've clearly duplicated their work this cycle.

I've gone ahead and mirrored the AOSP 3.4 tree here:
git://git.linaro.org/people/jstultz/android.git linaro-android-3.4


Are you going to add "merge_config.sh" into this branch?



Andrey: Probably you're call on this. If you've already merged in my
rebase tree it should be fine for 12.04, but if not you might want to
jump over to the AOSP 3.4 tree.

thanks
-john


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: Linaro 12.04 3.4-rc1 based androidization branch is available

2012-04-13 Thread Sangwook Lee
On 13 April 2012 12:01, Tushar Behera  wrote:

> On 04/13/2012 04:19 PM, Tushar Behera wrote:
> > On 04/13/2012 02:48 PM, Sangwook Lee wrote:
> >> Hi John
> >>
> >> On 11/04/12 20:19, John Stultz wrote:
> >>> On 04/09/2012 03:18 PM, John Stultz wrote:
> >>>> I went ahead and forward ported the AOSP-3.3 tree to 3.4-rc1.
> >>>>
> >>>> You can grab it here:
> >>>> git://git.linaro.org/people/jstultz/android.git
> >>>> linaro-android-3.4-jstultz-rebase
> >>>
> >>> Sigh. Looks like the Google devs are following close behind and
> released
> >>> their own 3.4-rc2 based tree.
> >>>
> >>> Don't get me wrong: Its great to see them keeping up with mainline, but
> >>> I've clearly duplicated their work this cycle.
> >>>
> >>> I've gone ahead and mirrored the AOSP 3.4 tree here:
> >>> git://git.linaro.org/people/jstultz/android.git linaro-android-3.4
> >>
> >> Are you going to add "merge_config.sh" into this branch?
> >>
> > merge_config.sh is in linaro-configs-3.4 on John's tree. The related
> > patches have also been part of topic/base.
> >
>
> I mean topic/base in Samsung's Landing team kernel.
>
>
Thanks for info.


> >>>
> >>> Andrey: Probably you're call on this. If you've already merged in my
> >>> rebase tree it should be fine for 12.04, but if not you might want to
> >>> jump over to the AOSP 3.4 tree.
> >>>
> >>> thanks
> >>> -john
> >>>
> >>>
> >>> ___
> >>> linaro-dev mailing list
> >>> linaro-dev@lists.linaro.org
> >>> http://lists.linaro.org/mailman/listinfo/linaro-dev
> >>
> >> ___
> >> linaro-dev mailing list
> >> linaro-dev@lists.linaro.org
> >> http://lists.linaro.org/mailman/listinfo/linaro-dev
> >
> >
>
>
> --
> Tushar Behera
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH] ARM: EXYNOS: PD: Fix duplicate variable

2012-05-09 Thread Sangwook Lee
struct generic_pm_domain already has a field for name. Use that field
instead of creating another field in struct exynos_pm_domain

Signed-off-by: Sangwook Lee 
---
 arch/arm/mach-exynos/pm_domains.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-exynos/pm_domains.c 
b/arch/arm/mach-exynos/pm_domains.c
index 13b3068..4d2563c 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -28,7 +28,6 @@
  */
 struct exynos_pm_domain {
void __iomem *base;
-   char const *name;
bool is_off;
struct generic_pm_domain pd;
 };
@@ -75,10 +74,10 @@ static int exynos_pd_power_off(struct generic_pm_domain 
*domain)
 #define EXYNOS_GPD(PD, BASE, NAME) \
 static struct exynos_pm_domain PD = {  \
.base = (void __iomem *)BASE,   \
-   .name = NAME,   \
.pd = { \
.power_off = exynos_pd_power_off,   \
.power_on = exynos_pd_power_on, \
+   .name = NAME,   \
},  \
 }
 
@@ -99,7 +98,7 @@ static __init int exynos_pm_dt_parse_domains(void)
 
if (of_get_property(np, "samsung,exynos4210-pd-off", NULL))
pd->is_off = true;
-   pd->name = np->name;
+   pd->pd.name = (char *)np->name;
pd->base = of_iomap(np, 0);
pd->pd.power_off = exynos_pd_power_off;
pd->pd.power_on = exynos_pd_power_on;
@@ -122,7 +121,7 @@ static __init void exynos_pm_add_dev_to_genpd(struct 
platform_device *pdev,
if (pm_genpd_add_device(&pd->pd, &pdev->dev))
pr_info("%s: error in adding %s device to %s power"
"domain\n", __func__, dev_name(&pdev->dev),
-   pd->name);
+   pd->pd.name);
}
 }
 
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: New Gator version ready for Linaro kernels / Mali

2012-05-17 Thread Sangwook Lee
On 17 May 2012 08:37, Jon Medhurst (Tixy)  wrote:

> On Thu, 2012-05-17 at 07:42 +0800, Andy Green wrote:
> > Just curious... how many LTs have Mali stuff?  If it's more than one, we
> > should perhaps be talking about moving it to linux-linaro-core-tracking.
>
> We have two teams with three different versions of the driver ;-) with,
> I suspect, custom modifications (different memory management
> components?).
>
> From my bystanders point of view, the interaction with closed source
> binary blobs seems to cause people enough nightmares without also trying
>

I am fully agree with this. Is there any plan to push ARM driver into the
mainline ?


> to converge code-lines between teams. Especially when engineering
> resources are spread so thin.
>
> Fortunately (?), the two teams have the drivers under different paths
> with different module and Kconfig option naming, so they could coexist
> in the same tree.
>
> --
> Tixy
>
>
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: How can I contribute to android-ucm project?

2012-06-28 Thread Sangwook Lee
+Usman, Tushar who are in charge of Origen project


On 28 June 2012 10:29, Claude Youn  wrote:

> Dear Mr Kurt Taylor,
>
> Hello, I'm Claude Youn, work for InSignal, she made Origen board. I'm so
> interest your project 'android-ucm', because I have a role on sound of
> Origen board. And also Mr Bernard Park, who is in Linaro, asked me to
> support audio and origen board works for linaro. :) After that, I asked
> to Mr Mark brown, ASoC maintainer, about his tinyhal project status, and
> he answered me to contect to you.
>
> For now, I worked audioHAL of Origen board from alsa HAL, which was
> ported by windriver guys, with some modifications. And also I ported
> tinyhal, from Mr Mark Brown's git. :) But it's not enought to be a
> official one, I think.
>
> See below links,
> - alsa legacy porting based hal
>
> http://git.insignal.co.kr/?p=insignal-android/vendor/insignal/hal/alsahw_legacy.git;a=summary
>
> - tinyhal based audio hal
>
> http://git.insignal.co.kr/?p=insignal-android/vendor/insignal/hal/tinyhal.git;a=summary
>
> So, how can I contribute to your project? Can you share your plan to me?
>
>
> with best regards,
>claude
>
> ___
> linaro-dev mailing list
> linaro-dev@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-dev
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-07-17 Thread Sangwook Lee
The following 2 patches add driver for S5K4ECGX sensor with embedded ISP SoC,
and minor v4l2 control API enhancement. S5K4ECGX is 5M CMOS Image sensor from 
Samsung.

Currenlty ony preview mode is supported. (no capture mode/face detection)

Sangwook Lee (2):
  v4l: Add factory register values form S5K4ECGX sensor
  v4l: Add v4l2 subdev driver for S5K4ECGX sensor

 drivers/media/video/Kconfig |7 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/s5k4ecgx.c  |  871 ++
 drivers/media/video/s5k4ecgx_regs.h | 3121 +++
 include/media/s5k4ecgx.h|   29 +
 5 files changed, 4029 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 drivers/media/video/s5k4ecgx_regs.h
 create mode 100644 include/media/s5k4ecgx.h

-- 
1.7.9.5


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-07-17 Thread Sangwook Lee
This dirver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.

Following controls are supported:
contrast/saturation/birghtness/sharpness

Signed-off-by: Sangwook Lee 
---
 drivers/media/video/Kconfig|7 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/s5k4ecgx.c |  871 
 include/media/s5k4ecgx.h   |   29 ++
 4 files changed, 908 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 99937c9..45d7f99 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -559,6 +559,13 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/video/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index d209de0..605bf35 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -79,6 +79,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)+= s5k4ecgx.o
 obj-$(CONFIG_VIDEO_SMIAPP) += smiapp/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
diff --git a/drivers/media/video/s5k4ecgx.c b/drivers/media/video/s5k4ecgx.c
new file mode 100644
index 000..68a1977
--- /dev/null
+++ b/drivers/media/video/s5k4ecgx.c
@@ -0,0 +1,871 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from SAMSUNG
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor, as reffering to s5k6aa.c
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ * Copyright (C) 2011, SAMSUNG ELECTRONICS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "s5k4ecgx_regs.h"
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+
+/* Basic windows sizes */
+#define S5K4ECGX_OUT_WIDTH_DEF 640
+#define S5K4ECGX_OUT_HEIGHT_DEF480
+#define S5K4ECGX_WIN_WIDTH_MAX 1024
+#define S5K4ECGX_WIN_HEIGHT_MAX600
+#define S5K4ECGX_WIN_WIDTH_MIN 176
+#define S5K4ECGX_WIN_HEIGHT_MIN144
+
+/* Firmware revision information */
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4EC0
+#define REG_FW_VERSION 0x71A4
+#define REG_FW_REVISION0x71A6
+
+/* For now we use only one user configuration register set */
+#define S5K4ECGX_MAX_PRESETS   1
+
+/* Review this depending on system */
+#define S5K4ECGX_POLL_TIME 1 /* ms */
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722C /* Brigthness */
+#define REG_USER_CONTRAST  0x722E /* Contrast */
+#define REG_USER_SATURATION0x7230 /* Saturation */
+
+/* FIXME: No information availble about these register from the datasheet */
+#define REG_USER_SHARP10x7A28
+#define REG_USER_SHARP20x7ADE
+#define REG_USER_SHARP30x7B94
+#define REG_USER_SHARP40x7C4A
+#define REG_USER_SHARP50x7D00
+
+#define LSB(X) (((X) & 0xFF))
+#define MSB(Y) (((Y) >> 8) & 0xFF)
+
+/*
+ * Preview size lists supported by sensor
+ */
+struct regval_list *pview_size[] = {
+   s5k4ecgx_176_preview,
+   s5k4ecgx_352_preview,
+   s5k4ecgx_640_preview,
+   s5k4ecgx_720_preview,
+};
+
+struct s5k4ecgx_framesize {
+   u32 idx; /* Should indicate index of pview_size */
+   u32 width;
+   u32 height;
+};
+
+/*
+ * TODO: currently only preview is supported and snapshopt(capture)
+ * is not implemented yet
+ */
+static struct s5k4ecgx_framesize p_sets[] = {
+   {0, 176, 144},
+   {1, 352, 288},
+   {2, 640, 480},
+   {3, 720, 4

Re: [PATCH 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-07-18 Thread Sangwook Lee
Hi David

Thanks for the review!

On 17 July 2012 22:45, David Cohen  wrote:

> Hi Sangwook,
>
> I've few comments, some just nitpicking. Feel free to disagree. :)
>
>
> On 07/17/2012 07:17 PM, Sangwook Lee wrote:
>
>> This dirver implements preview mode of the S5K4ECGX sensor.
>> capture (snapshot) operation, face detection are missing now.
>>
>> Following controls are supported:
>> contrast/saturation/**birghtness/sharpness
>>
>> Signed-off-by: Sangwook Lee 
>> ---
>>   drivers/media/video/Kconfig|7 +
>>   drivers/media/video/Makefile   |1 +
>>   drivers/media/video/s5k4ecgx.c |  871 ++**
>> ++
>>   include/media/s5k4ecgx.h   |   29 ++
>>   4 files changed, 908 insertions(+)
>>   create mode 100644 drivers/media/video/s5k4ecgx.c
>>   create mode 100644 include/media/s5k4ecgx.h
>>
>>
> [snip]
>
>
>  +/*
>> + * V4L2 subdev controls
>> + */
>> +static int s5k4ecgx_s_ctrl(struct v4l2_ctrl *ctrl)
>> +{
>> +
>> +   struct v4l2_subdev *sd = &container_of(ctrl->handler, struct
>> s5k4ecgx,
>> +   handler)->sd;
>> +   struct s5k4ecgx *priv = to_s5k4ecgx(sd);
>> +   int err = 0;
>> +
>> +   v4l2_dbg(1, debug, sd, "ctrl: 0x%x, value: %d\n", ctrl->id,
>> ctrl->val);
>> +   mutex_lock(&priv->lock);
>> +
>> +   switch (ctrl->id) {
>> +   case V4L2_CID_CONTRAST:
>> +   err = s5k4ecgx_write_ctrl(sd, REG_USER_CONTRAST,
>> ctrl->val);
>> +   break;
>> +
>> +   case V4L2_CID_SATURATION:
>> +   err = s5k4ecgx_write_ctrl(sd, REG_USER_SATURATION,
>> ctrl->val);
>> +   break;
>> +
>> +   case V4L2_CID_SHARPNESS:
>> +   err |= s5k4ecgx_write_ctrl(sd, REG_USER_SHARP1,
>> ctrl->val);
>> +   err |= s5k4ecgx_write_ctrl(sd, REG_USER_SHARP2,
>> ctrl->val);
>> +   err |= s5k4ecgx_write_ctrl(sd, REG_USER_SHARP3,
>> ctrl->val);
>> +   err |= s5k4ecgx_write_ctrl(sd, REG_USER_SHARP4,
>> ctrl->val);
>> +   err |= s5k4ecgx_write_ctrl(sd, REG_USER_SHARP5,
>> ctrl->val);
>> +   break;
>> +
>> +   case V4L2_CID_BRIGHTNESS:
>> +   err = s5k4ecgx_write_ctrl(sd, REG_USER_BRIGHTNESS,
>> ctrl->val);
>> +   break;
>> +   default:
>> +   v4l2_dbg(1, debug, sd, "unknown set ctrl id 0x%x\n",
>> ctrl->id);
>> +   err = -ENOIOCTLCMD;
>> +   break;
>> +   }
>> +
>> +   /* Review this */
>> +   priv->reg_type = TOK_TERM;
>> +
>> +   if (err < 0)
>> +   v4l2_err(sd, "Failed to write videoc_s_ctrl err %d\n",
>> err);
>>
>
> I like to hold locks only when strictly necessary. You could write
> this error message after it's released.
>
>
Good point, I will change it.


>
>  +   mutex_unlock(&priv->lock);
>> +
>> +   return err;
>> +}
>> +
>> +static const struct v4l2_ctrl_ops s5k4ecgx_ctrl_ops = {
>> +   .s_ctrl = s5k4ecgx_s_ctrl,
>> +};
>> +
>> +/*
>> + * Reading s5k4ecgx version information
>> + */
>> +static int s5k4ecgx_registered(struct v4l2_subdev *sd)
>> +{
>> +   struct s5k4ecgx *priv = to_s5k4ecgx(sd);
>> +   int ret;
>> +
>> +   if (!priv->set_power) {
>> +   v4l2_err(sd, "Failed to call power-up function!\n");
>>
>
> Maybe it's more accurate to say function isn't set.
>
>
It makes more sense. I will change comments.


>  +   return -EIO;
>> +   }
>> +
>> +   mutex_lock(&priv->lock);
>> +   priv->set_power(true);
>> +   /* Time to stablize sensor */
>> +   mdelay(priv->mdelay);
>> +   ret = s5k4ecgx_read_fw_ver(sd);
>> +   priv->set_power(false);
>> +   mutex_unlock(&priv->lock);
>> +
>> +   return ret;
>> +}
>> +
>> +/*
>> + *  V4L2 subdev internal operations
>> + */
>> +static int s5k4ecgx_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh
>> *fh)
>> +{
>> +
>> +   struct v4l2_mbus_framefmt *format =
>> v4l2_subdev_get_try_format(fh, 0);
>> +   struct v4l2_rect *crop = v4l2_subdev_get_try_crop(

[PATCH v2 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-07-19 Thread Sangwook Lee
This dirver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.

Following controls are supported:
contrast/saturation/birghtness/sharpness

Signed-off-by: Sangwook Lee 
---
 drivers/media/video/Kconfig|7 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/s5k4ecgx.c |  881 
 include/media/s5k4ecgx.h   |   29 ++
 4 files changed, 918 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 99937c9..45d7f99 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -559,6 +559,13 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/video/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index d209de0..605bf35 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -79,6 +79,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)+= s5k4ecgx.o
 obj-$(CONFIG_VIDEO_SMIAPP) += smiapp/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
diff --git a/drivers/media/video/s5k4ecgx.c b/drivers/media/video/s5k4ecgx.c
new file mode 100644
index 000..e277d71
--- /dev/null
+++ b/drivers/media/video/s5k4ecgx.c
@@ -0,0 +1,881 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from SAMSUNG
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor, as reffering to s5k6aa.c
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ * Copyright (C) 2011, SAMSUNG ELECTRONICS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "s5k4ecgx_regs.h"
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+
+/* Basic windows sizes */
+#define S5K4ECGX_OUT_WIDTH_DEF 640
+#define S5K4ECGX_OUT_HEIGHT_DEF480
+#define S5K4ECGX_WIN_WIDTH_MAX 1024
+#define S5K4ECGX_WIN_HEIGHT_MAX600
+#define S5K4ECGX_WIN_WIDTH_MIN 176
+#define S5K4ECGX_WIN_HEIGHT_MIN144
+
+/* Firmware revision information */
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4EC0
+#define REG_FW_VERSION 0x71A4
+#define REG_FW_REVISION0x71A6
+
+/* For now we use only one user configuration register set */
+#define S5K4ECGX_MAX_PRESETS   1
+
+/* Review this depending on system */
+#define S5K4ECGX_POLL_TIME 1 /* ms */
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722C /* Brigthness */
+#define REG_USER_CONTRAST  0x722E /* Contrast */
+#define REG_USER_SATURATION0x7230 /* Saturation */
+
+/* FIXME: No information availble about these register from the datasheet */
+#define REG_USER_SHARP10x7A28
+#define REG_USER_SHARP20x7ADE
+#define REG_USER_SHARP30x7B94
+#define REG_USER_SHARP40x7C4A
+#define REG_USER_SHARP50x7D00
+
+#define LSB(X) (((X) & 0xFF))
+#define MSB(Y) (((Y) >> 8) & 0xFF)
+
+/*
+ * Preview size lists supported by sensor
+ */
+struct regval_list *pview_size[] = {
+   s5k4ecgx_176_preview,
+   s5k4ecgx_352_preview,
+   s5k4ecgx_640_preview,
+   s5k4ecgx_720_preview,
+};
+
+struct s5k4ecgx_framesize {
+   u32 idx; /* Should indicate index of pview_size */
+   u32 width;
+   u32 height;
+};
+
+/*
+ * TODO: currently only preview is supported and snapshopt(capture)
+ * is not implemented yet
+ */
+static struct s5k4ecgx_framesize p_sets[] = {
+   {0, 176, 144},
+   {1, 352, 288},
+   {2, 640, 480},
+   {3, 720, 4

[PATCH v2 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-07-19 Thread Sangwook Lee
The following 2 patches add driver for S5K4ECGX sensor with embedded ISP SoC,
and minor v4l2 control API enhancement. S5K4ECGX is 5M CMOS Image sensor from 
Samsung.

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else 

Sangwook Lee (2):
  v4l: Add factory register values form S5K4ECGX sensor
  v4l: Add v4l2 subdev driver for S5K4ECGX sensor

 drivers/media/video/Kconfig |7 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/s5k4ecgx.c  |  881 ++
 drivers/media/video/s5k4ecgx_regs.h | 3121 +++
 include/media/s5k4ecgx.h|   29 +
 5 files changed, 4039 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 drivers/media/video/s5k4ecgx_regs.h
 create mode 100644 include/media/s5k4ecgx.h

-- 
1.7.9.5


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH v2 1/2] v4l: Add factory register values form S5K4ECGX sensor

2012-07-20 Thread Sangwook Lee
Hi Sylwester

Thank for the review.

On 19 July 2012 20:40, Sylwester Nawrocki wrote:

> Hi Sangwook,
>
> On 07/19/2012 02:14 PM, Sangwook Lee wrote:
> > Add factory default settings for S5K4ECGX sensor registers.
> > I copied them from the reference code of Samsung S.LSI.
>
> I'm pretty sure we can do better than that. I've started S5K6AAFX sensor
> driver development with similar set of write-only register address/value
> arrays, that stored mainly register default values after the device reset,
> or were configuring presets that were never used.
>
> If you lok at the s5k6aa driver, you'll find only one relatively small
> array of register values for the analog processing block settings.
> It's true that I had to reverse engineer a couple of things, but I also
>
had a relatively good datasheet for the sensor.
>
>
Yes, I already saw analog settings in s5k6aa. Compared to s5k6aa,
I couldn't also understand why the sensor has lots of initial values.
Is it because s5k4ecgx is slightly more complicated than s5k6aa ?

> According to comments from the reference code, they do not
> > recommend any changes of these settings.
>
> Yes, but it doesn't mean cannot convert, at least part of, those ugly
> tables into function calls.
>

Yes, the biggest table seems to be one time for boot-up, at least I need to
remove one more macro (token)


> Have you tried to contact Samsung S.LSI for a datasheet that would
> contain better registers' description ?
>

As you might know, there is a limitation for me to get those information.
:-)
Instead, if I look into the source code of Google Nexus S which uses
s5k4ecgx,

  https://android.googlesource.com/kernel/samsung.git

I can discover that both Google and Samsung are using the same huge table
just for initial settings from the sensor booting-up. I added the original
author
of this sensor driver. Hopes he might add some comments :-)



Thanks
Sangwook


> --
>
> Thanks,
> Sylwester
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH v2 1/2] v4l: Add factory register values form S5K4ECGX sensor

2012-07-20 Thread Sangwook Lee
Opps, the previous email has a HTML part, so resending.




Hi Sylwester

Thank for the review.

On 19 July 2012 20:40, Sylwester Nawrocki  wrote:
>
> Hi Sangwook,
>
> On 07/19/2012 02:14 PM, Sangwook Lee wrote:
> > Add factory default settings for S5K4ECGX sensor registers.
> > I copied them from the reference code of Samsung S.LSI.
>
> I'm pretty sure we can do better than that. I've started S5K6AAFX sensor
> driver development with similar set of write-only register address/value
> arrays, that stored mainly register default values after the device reset,
> or were configuring presets that were never used.
>
> If you lok at the s5k6aa driver, you'll find only one relatively small
> array of register values for the analog processing block settings.
> It's true that I had to reverse engineer a couple of things, but I also
>
> had a relatively good datasheet for the sensor.
>

Yes, I already saw analog settings in s5k6aa. Compared to s5k6aa,
I couldn't also understand why the sensor has lots of initial values.
Is it because s5k4ecgx is slightly more complicated than s5k6aa ?

> > According to comments from the reference code, they do not
> > recommend any changes of these settings.
>
> Yes, but it doesn't mean cannot convert, at least part of, those ugly
> tables into function calls.


Yes, the biggest table seems to be one time for boot-up, at least I need to
remove one more macro (token)

>
> Have you tried to contact Samsung S.LSI for a datasheet that would
> contain better registers' description ?


As you might know, there is a limitation for me to get those information. :-)
Instead, if I look into the source code of Google Nexus S which uses s5k4ecgx,

  https://android.googlesource.com/kernel/samsung.git

I can discover that both Google and Samsung are using the same huge table
just for initial settings from the sensor booting-up. I added the
original author
of this sensor driver. Hopes he might add some comments :-)



Thanks
Sangwook

>
> --
>
> Thanks,
> Sylwester

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH v2 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-07-20 Thread Sangwook Lee
Hi Sylwester

Thank you for the great review!

On 19 July 2012 22:40, Sylwester Nawrocki  wrote:
>
> Hi Sangwook,
>
> A few review comments for you below...
>
> On 07/19/2012 02:14 PM, Sangwook Lee wrote:
> > This dirver implements preview mode of the S5K4ECGX sensor.
>
> dirver -> driver

OK, I will fix this.

> > capture (snapshot) operation, face detection are missing now.
> >
> > Following controls are supported:
> > contrast/saturation/birghtness/sharpness
>
> birghtness -> brightness
>

ditto

> > Signed-off-by: Sangwook Lee
> > ---
> > + * Driver for s5k4ecgx (5MP Camera) from SAMSUNG
> > + * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
> > + * CMOS image sensor, as reffering to s5k6aa.c
>
> I think this should be mentioned after your own copyright notice,
> e.g. in form of:
>
> Based on s5k6aa driver,
> Copyright (C) 2011, Samsung Electronics Co., Ltd.

ditto

> > + *
> > + * Copyright (C) 2012, Linaro, Sangwook Lee
> > + * Copyright (C) 2012, Insignal Co,. Ltd,  Homin
> > Lee
> > + * Copyright (C) 2011, SAMSUNG ELECTRONICS
>
> No need to shout, "Samsung Electronics Co., Ltd." would be just enough.

ditto

>

> > +#include
> > +#include
> > +#include
> > +#include
> > +#include
> > +#include
>
> Can we, please, have these sorted alphabetically ?

OK, I will fix this.

>
> > +#include "s5k4ecgx_regs.h"
> > +
> > +static int debug;
> > +module_param(debug, int, 0644);
> > +
[snip]
> > +/* General purpose parameters */
> > +#define REG_USER_BRIGHTNESS  0x722C /* Brigthness */
>
> availble -> available

ditto

>
> > +#define REG_USER_SHARP1  0x7A28
> > +#define REG_USER_SHARP2  0x7ADE
> > +#define REG_USER_SHARP3  0x7B94
> > +#define REG_USER_SHARP4  0x7C4A
> > +#define REG_USER_SHARP5  0x7D00
> > +
> > +#define LSB(X) (((X)&  0xFF))
> > +#define MSB(Y) (((Y)>>  8)&  0xFF)
>
> Lower case for hex numbers is preferred.
>

ditto

> > +
> > +/*
> > + * Preview size lists supported by sensor
> > + */
> > +struct regval_list *pview_size[] = {
> > + s5k4ecgx_176_preview,
> > + s5k4ecgx_352_preview,
> > + s5k4ecgx_640_preview,
> > + s5k4ecgx_720_preview,
> > +};
> > +
> > +struct s5k4ecgx_framesize {
> > + u32 idx; /* Should indicate index of pview_size */
> > + u32 width;
> > + u32 height;
> > +};
> > +
> > +/*
> > + * TODO: currently only preview is supported and snapshopt(capture)
> > + * is not implemented yet
> > + */
> > +static struct s5k4ecgx_framesize p_sets[] = {
>
> p_sets -> s5k4ecgx_framesizes ?

Hmm, the structure name needs to be changed properly.

>
> > + {0, 176, 144},
> > + {1, 352, 288},
> > + {2, 640, 480},
> > + {3, 720, 480},
>
> I believe we can do without presets for just the preview operation mode.

This (p_sets[]) is only used to configure preview size dynamically
when _s_fmt is called and then s_stream become on.

> Then, the number of registers to configure when device is powered on
> should then decrease significantly.
> Those presets are meant to speed up switching the device context, e.g.
> from preview to capture, but they just slow down initialization, because
> you have to configure all presets beforehand.
>
> > +};
> > +
> > +#define S5K4ECGX_NUM_PREV ARRAY_SIZE(p_sets)
> > +struct s5k4ecgx_pixfmt {
> > + enum v4l2_mbus_pixelcode code;
> > + u32 colorspace;
> > +};
> > +
> > +/* By defaut value, output from sensor will be YUV422 0-255 */
> > +static const struct s5k4ecgx_pixfmt s5k4ecgx_formats[] = {
> > + { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
>
> Nit: missing whitespace before }.

Thanks, I will fix this.

>
> > +};
> > +
> > +struct s5k4ecgx_preset {
> > + /* output pixel format and resolution */
> > + struct v4l2_mbus_framefmt mbus_fmt;
> > + u8 clk_id;
> > + u8 index;
> > +};
> > +
> > +struct s5k4ecgx {
> > + struct v4l2_subdev sd;
> > + struct media_pad pad;
> > + struct v4l2_ctrl_handler handler;
> > +
> > + struct s5k4ecgx_platform_data *pdata;
> > + struct s5k4ecgx_preset presets[S5K4ECGX_MAX_PRESETS];
> > + struct s5k4ecgx_preset *preset;
> > + struct s5k4ecgx_frames

[PATH v3 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-02 Thread Sangwook Lee
The following 2 patches add driver for S5K4ECGX sensor with embedded ISP SoC,
and minor v4l2 control API enhancement. S5K4ECGX is 5M CMOS Image sensor from 
Samsung

Changes since v2:
- added GPIO (reset/stby) and regulators
- updated I2C read/write, based on s5k6aa datasheet
- fixed set_fmt errors
- reduced register tables a bit
- removed vmalloc

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else 

Sangwook Lee (2):
  v4l: Add factory register values form S5K4ECGX sensor
  v4l: Add v4l2 subdev driver for S5K4ECGX sensor

 drivers/media/video/Kconfig |8 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/s5k4ecgx.c  |  839 ++
 drivers/media/video/s5k4ecgx_regs.h | 3105 +++
 include/media/s5k4ecgx.h|   39 +
 5 files changed, 3992 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 drivers/media/video/s5k4ecgx_regs.h
 create mode 100644 include/media/s5k4ecgx.h

-- 
1.7.9.5


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATH v3 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-08-02 Thread Sangwook Lee
This driver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.

Following controls are supported:
contrast/saturation/brightness/sharpness

Signed-off-by: Sangwook Lee 
---
 drivers/media/video/Kconfig|8 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/s5k4ecgx.c |  839 
 include/media/s5k4ecgx.h   |   39 ++
 4 files changed, 887 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index c128fac..2c3f434 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -580,6 +580,14 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+   depends on MEDIA_CAMERA_SUPPORT
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/video/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index b7da9fa..ec39c47 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)+= s5k4ecgx.o
 obj-$(CONFIG_VIDEO_SMIAPP) += smiapp/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
diff --git a/drivers/media/video/s5k4ecgx.c b/drivers/media/video/s5k4ecgx.c
new file mode 100644
index 000..cfc90b8
--- /dev/null
+++ b/drivers/media/video/s5k4ecgx.c
@@ -0,0 +1,839 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from Samsung
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor.
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ *
+ * Based on s5k6aa, noon010pc30 driver
+ * Copyright (C) 2011, Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "s5k4ecgx_regs.h"
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+
+/* Firmware revision information */
+#define REG_FW_REVISION0x71a6
+#define REG_FW_VERSION 0x71a4
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4ec0
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722c /* Brigthness */
+#define REG_USER_CONTRAST  0x722e /* Contrast */
+#define REG_USER_SATURATION0x7230 /* Saturation */
+
+#define REG_USER_SHARP10x7a28
+#define REG_USER_SHARP20x7ade
+#define REG_USER_SHARP30x7b94
+#define REG_USER_SHARP40x7c4a
+#define REG_USER_SHARP50x7d00
+
+/* Reduce sharpness range for user space API */
+#define SHARPNESS_DIV  8208
+
+#define TOK_TERM   0x
+
+/*
+ * FIMXE: This is copied from s5k6aa, because of no information
+ * in s5k4ecgx's datasheet
+ * H/W register Interface (0xd000 - 0xdfff)
+ */
+#define AHB_MSB_ADDR_PTR   0xfcfc
+#define GEN_REG_OFFSH  0xd000
+#define REG_CMDWR_ADDRH0x0028
+#define REG_CMDWR_ADDRL0x002a
+#define REG_CMDRD_ADDRH0x002c
+#define REG_CMDRD_ADDRL0x002e
+#define REG_CMDBUF0_ADDR   0x0f12
+
+/*
+ * Preview size lists supported by sensor
+ */
+static const struct regval_list *prev_regs[] = {
+   s5k4ecgx_176_preview,
+   s5k4ecgx_352_preview,
+   s5k4ecgx_640_preview,
+   s5k4ecgx_720_preview,
+};
+
+struct s5k4ecgx_frmsize {
+   u32 idx; /* Should indicate index of prev_regs */
+   u32 width;
+   u32 height;
+};
+
+/*
+ * TODO: currently only preview is supported and snapshopt(capture)
+ * is not implemented yet
+ */
+static const struct s5k4ecgx_f

[PATH v3 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-02 Thread Sangwook Lee
The following 2 patches add driver for S5K4ECGX sensor with embedded ISP SoC,
and minor v4l2 control API enhancement. S5K4ECGX is 5M CMOS Image sensor from 
Samsung

Changes since v2:
- added GPIO (reset/stby) and regulators
- updated I2C read/write, based on s5k6aa datasheet
- fixed set_fmt errors
- reduced register tables a bit
- removed vmalloc

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else 

Sangwook Lee (2):
  v4l: Add factory register values form S5K4ECGX sensor
  v4l: Add v4l2 subdev driver for S5K4ECGX sensor

 drivers/media/video/Kconfig |8 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/s5k4ecgx.c  |  839 ++
 drivers/media/video/s5k4ecgx_regs.h | 3105 +++
 include/media/s5k4ecgx.h|   39 +
 5 files changed, 3992 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 drivers/media/video/s5k4ecgx_regs.h
 create mode 100644 include/media/s5k4ecgx.h

-- 
1.7.9.5


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATH v3 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-08-02 Thread Sangwook Lee
This driver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.

Following controls are supported:
contrast/saturation/brightness/sharpness

Signed-off-by: Sangwook Lee 
---
 drivers/media/video/Kconfig|8 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/s5k4ecgx.c |  839 
 include/media/s5k4ecgx.h   |   39 ++
 4 files changed, 887 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index c128fac..2c3f434 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -580,6 +580,14 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+   depends on MEDIA_CAMERA_SUPPORT
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/video/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index b7da9fa..ec39c47 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)+= s5k4ecgx.o
 obj-$(CONFIG_VIDEO_SMIAPP) += smiapp/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
diff --git a/drivers/media/video/s5k4ecgx.c b/drivers/media/video/s5k4ecgx.c
new file mode 100644
index 000..cfc90b8
--- /dev/null
+++ b/drivers/media/video/s5k4ecgx.c
@@ -0,0 +1,839 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from Samsung
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor.
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ *
+ * Based on s5k6aa, noon010pc30 driver
+ * Copyright (C) 2011, Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "s5k4ecgx_regs.h"
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+
+/* Firmware revision information */
+#define REG_FW_REVISION0x71a6
+#define REG_FW_VERSION 0x71a4
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4ec0
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722c /* Brigthness */
+#define REG_USER_CONTRAST  0x722e /* Contrast */
+#define REG_USER_SATURATION0x7230 /* Saturation */
+
+#define REG_USER_SHARP10x7a28
+#define REG_USER_SHARP20x7ade
+#define REG_USER_SHARP30x7b94
+#define REG_USER_SHARP40x7c4a
+#define REG_USER_SHARP50x7d00
+
+/* Reduce sharpness range for user space API */
+#define SHARPNESS_DIV  8208
+
+#define TOK_TERM   0x
+
+/*
+ * FIMXE: This is copied from s5k6aa, because of no information
+ * in s5k4ecgx's datasheet
+ * H/W register Interface (0xd000 - 0xdfff)
+ */
+#define AHB_MSB_ADDR_PTR   0xfcfc
+#define GEN_REG_OFFSH  0xd000
+#define REG_CMDWR_ADDRH0x0028
+#define REG_CMDWR_ADDRL0x002a
+#define REG_CMDRD_ADDRH0x002c
+#define REG_CMDRD_ADDRL0x002e
+#define REG_CMDBUF0_ADDR   0x0f12
+
+/*
+ * Preview size lists supported by sensor
+ */
+static const struct regval_list *prev_regs[] = {
+   s5k4ecgx_176_preview,
+   s5k4ecgx_352_preview,
+   s5k4ecgx_640_preview,
+   s5k4ecgx_720_preview,
+};
+
+struct s5k4ecgx_frmsize {
+   u32 idx; /* Should indicate index of prev_regs */
+   u32 width;
+   u32 height;
+};
+
+/*
+ * TODO: currently only preview is supported and snapshopt(capture)
+ * is not implemented yet
+ */
+static const struct s5k4ecgx_f

Re: [PATH v3 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-03 Thread Sangwook Lee
Hi  Sylwester

Thank you for the review.

On 2 August 2012 21:11, Sylwester Nawrocki  wrote:
>
> Hi Sangwook,
>
> On 08/02/2012 03:42 PM, Sangwook Lee wrote:
> > The following 2 patches add driver for S5K4ECGX sensor with embedded ISP 
> > SoC,
> > and minor v4l2 control API enhancement. S5K4ECGX is 5M CMOS Image sensor 
> > from Samsung
> >
> > Changes since v2:
> > - added GPIO (reset/stby) and regulators
> > - updated I2C read/write, based on s5k6aa datasheet
> > - fixed set_fmt errors
> > - reduced register tables a bit
> > - removed vmalloc
>
> It looks like a great improvement, well done! Thanks!
>
> In the S5K4CAGX sensor datasheet, that can be found on the internet,
> there is 0x...0x002E registers description, which look very much
> same as in S5K6AAFX case and likely is also valid for S5K4CAGX.


[snip]

>
>
> What do you think about converting s5k4ecgx_img_regs arrays (it has
> over 2700 entries) to a firmware file and adding some simple parser
> to the driver ? Then we would have the problem solved in most part.
>

Thanks, fair enough. let me try this.


>
> Regarding various preview resolution set up, the difference in all
> those s5k4ecgx_*_preview[] arrays is rather small, only register
> values differ, e.g. for 640x480 and 720x480 there is only 8 different
> entries:
>

Ok, let me reduce table size again.

>
> $ diff -a s5k4ec_640.txt s5k4ec_720.txt
> 1c1
> < static const struct regval_list s5k4ecgx_640_preview[] = {
> ---
> > static const struct regval_list s5k4ecgx_720_preview[] = {
> 3c3
> <   { 0x7252, 0x0780 },
> ---
> >   { 0x7252, 0x06a8 },
> 5c5



[snip]

>
> <   { 0x7256, 0x000c },
> >   { 0x72a6, 0x02d

[snip]
>
> Could you please try to implement a function that replaces those tables,
> based s5k6aa_set_prev_config() and s5k6aa_set_output_framefmt() ?
>
I was thinking about this, but this seems to be is a bit time-consuming because
I have to do this just due to lack of s5k4ecgx hardware information.
let me try it later once
this patch is accepted.

Thanks
Sangwook

> Regards,
> Sylwester

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATH v3 1/2] v4l: Add factory register values form S5K4ECGX sensor

2012-08-03 Thread Sangwook Lee
Hi Sylwester

On 2 August 2012 21:50, Sylwester Nawrocki  wrote:
> On 08/02/2012 03:42 PM, Sangwook Lee wrote:
>> Add factory default settings for S5K4ECGX sensor registers,
>> which was copied from the reference code of Samsung S.LSI.
>>
>> Signed-off-by: Sangwook Lee
>> ---
>>   drivers/media/video/s5k4ecgx_regs.h | 3105 
>> +++
>>   1 file changed, 3105 insertions(+)
>>   create mode 100644 drivers/media/video/s5k4ecgx_regs.h
>>
>> diff --git a/drivers/media/video/s5k4ecgx_regs.h 
>> b/drivers/media/video/s5k4ecgx_regs.h
>> new file mode 100644
>> index 000..ef87c09
>> --- /dev/null
>> +++ b/drivers/media/video/s5k4ecgx_regs.h
>> @@ -0,0 +1,3105 @@
>> +/*
>> + * Samsung S5K4ECGX register tables for default values
>> + *
>> + * Copyright (C) 2012 Linaro
>> + * Copyright (C) 2012 Insignal Co,. Ltd
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#ifndef __DRIVERS_MEDIA_VIDEO_S5K4ECGX_H__
>> +#define __DRIVERS_MEDIA_VIDEO_S5K4ECGX_H__
>> +
>> +struct regval_list {
>> + u32 addr;
>> + u16 val;
>> +};
>> +
>> +/*
>> + * FIXME:
>> + * The tables are default values of a S5K4ECGX sensor EVT1.1
>> + * from Samsung LSI. currently there is no information available
>> + * to the public in order to reduce these tables size.
>> + */
>> +static const struct regval_list s5k4ecgx_apb_regs[] = {
>
> 
>
>> +/* configure 30 fps */
>> +static const struct regval_list s5k4ecgx_fps_30[] = {
>
> It really depends on sensor master clock frequency (as specified
> in FIMC driver platform data) and PLL setting what the resulting
> frame rate will be.
>
>> + { 0x72b4, 0x0052 },
>
> Looks surprising! Are we really just disabling horizontal/vertical
> image mirror here ?

I believe, this setting values are used still in Galaxy Nexus.
It might be some reasons  to set this values in the product, but I am not
sure of this.


>
>> + { 0x72d2, 0x },
>
> REG_0TC_PCFG_uCaptureMirror
>
>> + { 0x7266, 0x },
>
> REG_TC_GP_ActivePrevConfig
>
>> + { 0x726a, 0x0001 },
>
> REG_TC_GP_PrevOpenAfterChange
>
>> + { 0x724e, 0x0001 },
>
> REG_TC_GP_NewConfigSync
>
>> + { 0x7268, 0x0001 },
>
> REG_TC_GP_PrevConfigChanged
>
>
> Please have a look how it is handled in s5k6aa driver, it all looks
> pretty similar.
>
>> + { 0x, 0x },
>> +};
>> +
>> +static const struct regval_list s5k4ecgx_effect_normal[] = {
>> + { 0x723c, 0x },
>
> Just one register, why do we need an array for it ? And of course
> 0x is default value after reset, so it seems sort of pointless
> doing this I2C write to set the default image effect value (disabled).
>
> These are possible values as found in the datasheet:
>
> 0x723C REG_TC_GP_SpecialEffects 0x 2 RW Special effect
>
> 0 : Normal
> 1 : MONOCHROME (BW)
> 2 : Negative Mono
> 3 : Negative Color
> 4 : Sepia
> 5 : AQUA
> 6 : Reddish
> 7 : Bluish
> 8 : Greenish
> 9 : Sketch
> 10 : Emboss color
> 11 : Emboss Mono
>
>> + { 0x, 0x },
>> +};
>> +
>> +static const struct regval_list s5k4ecgx_wb_auto[] = {
>> + { 0x74e6, 0x077f },
>
> Ditto - register REG_TC_DBG_AutoAlgEnBits. And 0x077f is the default
> value after reset...
>
>> + { 0x, 0x },
>> +};
>> +
>> +static const struct regval_list s5k4ecgx_iso_auto[] = {
>> + { 0x7938, 0x },
>> + { 0x7f2a, 0x0001 },
>> + { 0x74e6, 0x077f },
>> + { 0x74d0, 0x },
>> + { 0x74d2, 0x },
>> + { 0x74d4, 0x0001 },
>> + { 0x76c2, 0x0200 },
>> + { 0x, 0x },
>> +};
>> +
>> +static const struct regval_list s5k4ecgx_contrast_default[] = {
>> + { 0x7232, 0x },
>
> No need for an array, it's REG_TC_UserContrast.
>
>> + { 0x, 0x },
>> +};
>> +
>
[snip]
>> + { 0x, 0x },
>> +};
>
> You already use a sequence of i2c writes in s5k4ecgx_s_ctrl() function
> for V4L2_CID_SHARPNESS control. So why not just create e.g.
> s5k4ecgx_set_saturation() and send this array to /dev/null ?
> Also, invoking v4l2_ctrl_handler_setup() will cause a call to 
> s5k4ecgx_s_ctrl()
> with default sharpness value (as specified during the control's creation).
>
> So I would say this array is redundant in two ways... :)

Thanks, let me change this.


>
> --
>
> Regards,
> Sylwester

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATH v3 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-08-06 Thread Sangwook Lee
Hi Sylwester

On 2 August 2012 22:18, Sylwester Nawrocki wrote:

> On 08/02/2012 03:42 PM, Sangwook Lee wrote:
> > This driver implements preview mode of the S5K4ECGX sensor.
> > capture (snapshot) operation, face detection are missing now.
> >
> > Following controls are supported:
> > contrast/saturation/brightness/sharpness
> >
> > Signed-off-by: Sangwook Lee<
> sangwook.lee-qsej5fyqhm4dnm+yrof...@public.gmane.org>
> > ---
> ...
> > +static const char * const s5k4ecgx_supply_names[] = {
> > + /*
> > +  * vdd_2.8v is for Analog power supply 2.8V(vdda)
> > +  * and Digital IO(vddio, vddd_core)
> > +  */
> > + "vdd_2.8v",
>
> Might be better to avoid voltage value in regulator supply names. Can you
> just make it on of: vdda, vddio, vddcore ? On some systems all 3 power pads
> might be used and all 3 voltage supply names might be needed. I guess it
> can
> be changed if there is a need for it. Also we could specify all 3 entries
> as
> above and add such regulator supply names at a corresponding regulator.
>
>
Ok, I will change this.


> > + /* vdd_1.8v is for regulator input */
> > + "vdd_1.8v",
>
> I would suggest just using "vddreg".
>
> > +static int s5k4ecgx_write(struct i2c_client *client, u32 addr, u16 val)
> > +{
> > + int ret = 0;
>
> Unneeded initialization.
>
>
ditto


> > + u16 high = addr>>  16, low =  addr&  0x;
> > +
> > + ret = s5k4ecgx_i2c_write(client, REG_CMDWR_ADDRH, high);
> > + ret |= s5k4ecgx_i2c_write(client, REG_CMDWR_ADDRL, low);
> > + ret |= s5k4ecgx_i2c_write(client, REG_CMDBUF0_ADDR, val);
> > + if (ret)
> > + return -ENODEV;
> > +
> > + return 0;
> > +}
> > +
> > +static int s5k4ecgx_read(struct i2c_client *client, u32 addr, u16 *val)
> > +{
> > + int ret = 0;
>
> Ditto.
>
> > + u16 high = addr>>  16, low =  addr&  0x;
> > +
> > + ret  = s5k4ecgx_i2c_write(client, REG_CMDRD_ADDRH, high);
> > + ret  |= s5k4ecgx_i2c_write(client, REG_CMDRD_ADDRL, low);
> > + ret  |= s5k4ecgx_i2c_read(client, REG_CMDBUF0_ADDR, val);
> > + if (ret) {
> > + dev_err(&client->dev, "Failed to execute read command\n");
> > + return -ENODEV;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static int s5k4ecgx_set_ahb_address(struct v4l2_subdev *sd)
> > +{
> > + int ret;
> > + struct i2c_client *client = v4l2_get_subdevdata(sd);
> > +
> > + /* Set APB peripherals start address */
> > + ret = s5k4ecgx_i2c_write(client, AHB_MSB_ADDR_PTR, GEN_REG_OFFSH);
> > + if (ret)
> > + return ret;
> > + /*
> > +  * FIMXE: This is copied from s5k6aa, because of no information
> > +  * in s5k4ecgx's datasheet.
> > +  * sw_reset is activated to put device into idle status
> > +  */
> > + ret = s5k4ecgx_i2c_write(client, 0x0010, 0x0001);
> > + if (ret)
> > + return ret;
> > +
> > + /* FIXME: no information avaialbe about this register */
>
> avaialbe -> available
>
> Oops!, I will change this.


> > + ret = s5k4ecgx_i2c_write(client, 0x1030, 0x);
> > + if (ret)
> > + return ret;
> > + /* Halt ARM CPU */
> > + ret = s5k4ecgx_i2c_write(client, 0x0014, 0x0001);
> > +
> > + return ret;
>
> return s5k4ecgx_i2c_write(...); ?
> > +}
> > +
> > +static int s5k4ecgx_write_array(struct v4l2_subdev *sd,
> > + const struct regval_list *reg)
> > +{
> > + struct i2c_client *client = v4l2_get_subdevdata(sd);
> > + u16 addr_incr = 0;
> > + int ret = 0;
>
> Unneeded initialization.
>
>
ditto


> > +
> > + while (reg->addr != TOK_TERM) {
> > + if (addr_incr != 2)
> > + ret = s5k4ecgx_write(client, reg->addr, reg->val);
> > + else
> > + ret = s5k4ecgx_i2c_write(client, REG_CMDBUF0_ADDR,
> > + reg->val);
> > + if (ret)
> > + break;
> > + /* Assume that msg->addr is always less than 0xfffc */
> > + addr_incr = (reg + 1)->addr - reg->addr;
> > + reg++;
> > + }
> > +
> > + return ret;
> > +}
&g

[PATCH v4 1/2] v4l: Add factory register values form S5K4ECGX sensor

2012-08-10 Thread Sangwook Lee
Add preview default settings for S5K4ECGX sensor registers,
which was copied from the reference code of Samsung S.LSI.

Signed-off-by: Sangwook Lee 
---
 drivers/media/video/s5k4ecgx_regs.h |  138 +++
 1 file changed, 138 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx_regs.h

diff --git a/drivers/media/video/s5k4ecgx_regs.h 
b/drivers/media/video/s5k4ecgx_regs.h
new file mode 100644
index 000..e99b0e6
--- /dev/null
+++ b/drivers/media/video/s5k4ecgx_regs.h
@@ -0,0 +1,138 @@
+/*
+ * Samsung S5K4ECGX register tables for default values
+ *
+ * Copyright (C) 2012 Linaro
+ * Copyright (C) 2012 Insignal Co,. Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __DRIVERS_MEDIA_VIDEO_S5K4ECGX_H__
+#define __DRIVERS_MEDIA_VIDEO_S5K4ECGX_H__
+
+struct regval_list {
+   u32 addr;
+   u16 val;
+};
+
+/* Configure 720x480 preview size */
+static const struct regval_list s5k4ecgx_720_prev[] = {
+   { 0x7250, 0x0a00 },
+   { 0x7252, 0x06a8 },
+   { 0x7254, 0x0010 },
+   { 0x7256, 0x0078 },
+   { 0x7258, 0x0a00 },
+   { 0x725a, 0x06a8 },
+   { 0x725c, 0x0010 },
+   { 0x725e, 0x0078 },
+   { 0x7494, 0x0a00 },
+
+   /*
+* FIXME: according to the datasheet,
+* 0x7496~ 0x749c seems to be only for capture mode,
+* but without these value, it doesn't work with preview mode.
+*/
+   { 0x7496, 0x06a8 },
+   { 0x7498, 0x },
+   { 0x749a, 0x },
+   { 0x749c, 0x0a00 },
+
+   { 0x749e, 0x06a8 },
+   { 0x72a6, 0x02d0 },
+   { 0x72a8, 0x01e0 },
+   { 0x, 0x }, /* End token */
+};
+
+/* Configure 640x480 preview size */
+static const struct regval_list s5k4ecgx_640_prev[] = {
+   { 0x7250, 0x0a00 },
+   { 0x7252, 0x0780 },
+   { 0x7254, 0x0010 },
+   { 0x7256, 0x000c },
+   { 0x7258, 0x0a00 },
+   { 0x725a, 0x0780 },
+   { 0x725c, 0x0010 },
+   { 0x725e, 0x000c },
+   { 0x7494, 0x0a00 },
+   { 0x7496, 0x0780 },
+   { 0x7498, 0x },
+   { 0x749a, 0x },
+   { 0x749c, 0x0a00 },
+   { 0x749e, 0x0780 },
+   { 0x72a6, 0x0280 },
+   { 0x72a8, 0x01e0 },
+   { 0x, 0x }, /* End token */
+};
+
+/* Configure 352x288 preview size */
+static const struct regval_list s5k4ecgx_352_prev[] = {
+   { 0x7250, 0x0928 },
+   { 0x7252, 0x0780 },
+   { 0x7254, 0x007c },
+   { 0x7256, 0x000c },
+   { 0x7258, 0x0928 },
+   { 0x725a, 0x0780 },
+   { 0x725c, 0x007c },
+   { 0x725e, 0x000c },
+   { 0x7494, 0x0928 },
+   { 0x7496, 0x0780 },
+   { 0x7498, 0x },
+   { 0x749a, 0x },
+   { 0x749c, 0x0928 },
+   { 0x749e, 0x0780 },
+   { 0x72a6, 0x0160 },
+   { 0x72a8, 0x0120 },
+   { 0x, 0x }, /* End token */
+};
+
+/* Configure 176x144 preview size */
+static const struct regval_list s5k4ecgx_176_prev[] = {
+   { 0x7250, 0x0928 },
+   { 0x7252, 0x0780 },
+   { 0x7254, 0x007c },
+   { 0x7256, 0x000c },
+   { 0x7258, 0x0928 },
+   { 0x725a, 0x0780 },
+   { 0x725c, 0x007c },
+   { 0x725e, 0x000c },
+   { 0x7494, 0x0928 },
+   { 0x7496, 0x0780 },
+   { 0x7498, 0x },
+   { 0x749a, 0x },
+   { 0x749c, 0x0928 },
+   { 0x749e, 0x0780 },
+   { 0x72a6, 0x00b0 },
+   { 0x72a8, 0x0090 },
+   { 0x, 0x }, /* End token */
+};
+
+/* Common setting 1 for preview */
+static const struct regval_list s5k4ecgx_com1_prev[] = {
+   { 0x74a0, 0x },
+   { 0x74a2, 0x },
+   { 0x7262, 0x0001 },
+   { 0x7a1e, 0x0028 },
+   { 0x7ad4, 0x003c },
+   { 0x, 0x }, /* End token */
+};
+
+/* Common setting 2 for preview */
+static const struct regval_list s5k4ecgx_com2_prev[] = {
+   { 0x72aa, 0x0005 },
+   { 0x72b4, 0x0052 },
+   { 0x72be, 0x },
+   { 0x72c0, 0x0001 },
+   { 0x72c2, 0x029a },
+   { 0x72c4, 0x014d },
+   { 0x72d0, 0x },
+   { 0x72d2, 0x },
+   { 0x7266, 0x },
+   { 0x726a, 0x0001 },
+   { 0x724e, 0x0001 },
+   { 0x7268, 0x0001 },
+   { 0x, 0x }, /* End token */
+};
+
+#endif /* __DRIVERS_MEDIA_VIDEO_S5K4ECGX_H__ */
-- 
1.7.9.5


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH v4 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-10 Thread Sangwook Lee
The following 2 patches add driver for S5K4ECGX sensor with embedded ISP SoC,
and minor v4l2 control API enhancement. S5K4ECGX is 5M CMOS Image sensor from 
Samsung

Changes since v3:
- used request_firmware to configure initial settings
- added parsing functions to read initial settings
- updated regulator API
- reduced preview setting tables by experiment 

Changes since v2:
- added GPIO (reset/stby) and regulators
- updated I2C read/write, based on s5k6aa datasheet
- fixed set_fmt errors
- reduced register tables a bit
- removed vmalloc

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else

Sangwook Lee (2):
  v4l: Add factory register values form S5K4ECGX sensor
  v4l: Add v4l2 subdev driver for S5K4ECGX sensor

 drivers/media/video/Kconfig |8 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/s5k4ecgx.c  |  941 +++
 drivers/media/video/s5k4ecgx_regs.h |  138 +
 include/media/s5k4ecgx.h|   37 ++
 5 files changed, 1125 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 drivers/media/video/s5k4ecgx_regs.h
 create mode 100644 include/media/s5k4ecgx.h

-- 
1.7.9.5


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH v4 2/2] v4l: Add v4l2 subdev driver for S5K4ECGX sensor

2012-08-10 Thread Sangwook Lee
This driver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.

Following controls are supported:
contrast/saturation/brightness/sharpness

Signed-off-by: Sangwook Lee 
---
 drivers/media/video/Kconfig|8 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/s5k4ecgx.c |  941 
 include/media/s5k4ecgx.h   |   37 ++
 4 files changed, 987 insertions(+)
 create mode 100644 drivers/media/video/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index c128fac..d405cb1 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -580,6 +580,14 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+   tristate "Samsung S5K4ECGX sensor support"
+   depends on MEDIA_CAMERA_SUPPORT
+   depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+   ---help---
+ This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+ camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/video/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index b7da9fa..ec39c47 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)+= s5k4ecgx.o
 obj-$(CONFIG_VIDEO_SMIAPP) += smiapp/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
diff --git a/drivers/media/video/s5k4ecgx.c b/drivers/media/video/s5k4ecgx.c
new file mode 100644
index 000..4e57738
--- /dev/null
+++ b/drivers/media/video/s5k4ecgx.c
@@ -0,0 +1,941 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from Samsung
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor.
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ *
+ * Based on s5k6aa, noon010pc30 driver
+ * Copyright (C) 2011, Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "s5k4ecgx_regs.h"
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+
+#define S5K4ECGX_FIRMWARE  "s5k4ecgx.fw"
+/* Firmware parsing token */
+#define FW_START_TOKEN '{'
+#define FW_END_TOKEN   '}'
+
+/* Firmware revision information */
+#define REG_FW_REVISION0x71a6
+#define REG_FW_VERSION 0x71a4
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4ec0
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722c /* Brigthness */
+#define REG_USER_CONTRAST  0x722e /* Contrast */
+#define REG_USER_SATURATION0x7230 /* Saturation */
+
+#define REG_USER_SHARP10x7a28
+#define REG_USER_SHARP20x7ade
+#define REG_USER_SHARP30x7b94
+#define REG_USER_SHARP40x7c4a
+#define REG_USER_SHARP50x7d00
+
+/* Reduce sharpness range for user space API */
+#define SHARPNESS_DIV  8208
+#define TOK_TERM   0x
+
+/*
+ * FIMXE: This is copied from s5k6aa, because of no information
+ * in s5k4ecgx's datasheet
+ * H/W register Interface (0xd000 - 0xdfff)
+ */
+#define AHB_MSB_ADDR_PTR   0xfcfc
+#define GEN_REG_OFFSH  0xd000
+#define REG_CMDWR_ADDRH0x0028
+#define REG_CMDWR_ADDRL0x002a
+#define REG_CMDRD_ADDRH0x002c
+#define REG_CMDRD_ADDRL0x002e
+#define REG_CMDBUF0_ADDR   0x0f12
+
+/*
+ * Preview size lists supported by sensor
+ */
+static const struct regval_list *prev_regs[] = {
+   s5k4ecgx_176_prev,
+   s5k4ecgx_352_prev,
+   s5k4ecgx_640_prev,
+   s5k4ecgx_720_prev,
+};
+
+struct s5k4ecgx_frmsize {
+   u32 idx; /* Should ind

Re: [PATCH v4 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-10 Thread Sangwook Lee
Ccing Sylwester.


On 10 August 2012 15:14, Sangwook Lee  wrote:

> The following 2 patches add driver for S5K4ECGX sensor with embedded ISP
> SoC,
> and minor v4l2 control API enhancement. S5K4ECGX is 5M CMOS Image sensor
> from Samsung
>
> Changes since v3:
> - used request_firmware to configure initial settings
> - added parsing functions to read initial settings
> - updated regulator API
> - reduced preview setting tables by experiment
>
> Changes since v2:
> - added GPIO (reset/stby) and regulators
> - updated I2C read/write, based on s5k6aa datasheet
> - fixed set_fmt errors
> - reduced register tables a bit
> - removed vmalloc
>
> Changes since v1:
> - fixed s_stream(0) when it called twice
> - changed mutex_X position to be used when strictly necessary
> - add additional s_power(0) in case that error happens
> - update more accurate debugging statements
> - remove dummy else
>
> Sangwook Lee (2):
>   v4l: Add factory register values form S5K4ECGX sensor
>   v4l: Add v4l2 subdev driver for S5K4ECGX sensor
>
>  drivers/media/video/Kconfig |8 +
>  drivers/media/video/Makefile|1 +
>  drivers/media/video/s5k4ecgx.c  |  941
> +++
>  drivers/media/video/s5k4ecgx_regs.h |  138 +
>  include/media/s5k4ecgx.h|   37 ++
>  5 files changed, 1125 insertions(+)
>  create mode 100644 drivers/media/video/s5k4ecgx.c
>  create mode 100644 drivers/media/video/s5k4ecgx_regs.h
>  create mode 100644 include/media/s5k4ecgx.h
>
> --
> 1.7.9.5
>
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATH v3 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-20 Thread Sangwook Lee
Hi Sylwester

On 19 August 2012 22:29, Sylwester Nawrocki
 wrote:
> Hi Sangwook,
>
> On 08/03/2012 04:24 PM, Sangwook Lee wrote:
>> I was thinking about this, but this seems to be is a bit time-consuming 
>> because
>> I have to do this just due to lack of s5k4ecgx hardware information.
>> let me try it later once
>> this patch is accepted.
>
> I've converted this driver to use function calls instead of the register
> arrays. It can be pulled, along with a couple of minor fixes/improvements,
> from following git tree:
>
> git://linuxtv.org/snawrocki/media.git s5k4ecgx
> (gitweb: http://git.linuxtv.org/snawrocki/media.git/s5k4ecgx)
>
> I don't own any Origen board thus it's untested. Could you give it a try ?

Wow! Great,  let me download from this git and then test.


> The register write sequence should be identical as in the case of using
> the arrays.
>
> You won't find much regarding the face detection features in V4L2,
> unfortunately. _Maybe_ I'll try to address this as well on some day, for
> now private controls might be your only solution. Unless you feel like
> adding face detection features support to V4L2.. ;)
>
> BTW, are your requirements to support both EVT1.0 and EVT1.1 S5K4ECGX
> revisions ?

I have only EVT 1.1. So I have no chance to run EVT 1.0 version.

Thanks
Sangwook

>
> --
>
> Regards,
> Sylwester

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATH v3 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-20 Thread Sangwook Lee
Hi Sylwester

On 20 August 2012 09:12, Sangwook Lee  wrote:
> Hi Sylwester
>
> On 19 August 2012 22:29, Sylwester Nawrocki
>  wrote:
>> Hi Sangwook,
>>
>> On 08/03/2012 04:24 PM, Sangwook Lee wrote:
>>> I was thinking about this, but this seems to be is a bit time-consuming 
>>> because
>>> I have to do this just due to lack of s5k4ecgx hardware information.
>>> let me try it later once
>>> this patch is accepted.
>>
>> I've converted this driver to use function calls instead of the register
>> arrays. It can be pulled, along with a couple of minor fixes/improvements,
>> from following git tree:
>>
>> git://linuxtv.org/snawrocki/media.git s5k4ecgx
>> (gitweb: http://git.linuxtv.org/snawrocki/media.git/s5k4ecgx)
>>
>> I don't own any Origen board thus it's untested. Could you give it a try ?

Sorry, It doesn't work. I will send pictures to you by another mail thread.
Previously, I tested preview array and found out that
+   /*
+* FIXME: according to the datasheet,
+* 0x7496~ 0x749c seems to be only for capture mode,
+* but without these value, it doesn't work with preview mode.
+*/

Do we need to set those values ?


Thanks
Sangwook


>
> Wow! Great,  let me download from this git and then test.
>


Thanks



>

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATH v3 0/2] Add v4l2 subdev driver for S5K4ECGX sensor with embedded SoC ISP

2012-08-20 Thread Sangwook Lee
Hi Sylwester


On 20 August 2012 12:33, Sylwester Nawrocki  wrote:

> Hi Sangwook,
>

[snip]


>
> registers definitions. Attached patch should correct this, sorry about
> this oversight. Let me know if there are still any issues.
> To make sure the I2C write sequences are correct it might be useful to
> log all calls to s5k4ecgx_write() and compare the logs with original
> tables.
>
>
Yes, it is. I still need to compare both two revision after applying the
new patch.
let me compare logs in detail.


Thanks
Sangwook



> --
>
> Regards,
> Sylwester
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[RFC PATCH v5] media: add v4l2 subdev driver for S5K4ECGX sensor

2012-09-05 Thread Sangwook Lee
This patch adds driver for S5K4ECGX sensor with embedded ISP SoC,
S5K4ECGX, which is a 5M CMOS Image sensor from Samsung
The driver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.
Following controls are supported:
contrast/saturation/brightness/sharpness

Signed-off-by: Sangwook Lee 
Cc: Sylwester Nawrocki 
Cc: Scott Bambrough 
---
Changes since v4:
- replaced register tables with the function from Sylwester
- updated firmware parsing function with CRC32 check
  firmware generator from user space:
  git://git.linaro.org/people/sangwook/fimc-v4l2-app.git

Changes since v3:
- used request_firmware to configure initial settings
- added parsing functions to read initial settings
- updated regulator API
- reduced preview setting tables by experiment 

Changes since v2:
- added GPIO (reset/stby) and regulators
- updated I2C read/write, based on s5k6aa datasheet
- fixed set_fmt errors
- reduced register tables a bit
- removed vmalloc

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else

 drivers/media/i2c/Kconfig|7 +
 drivers/media/i2c/Makefile   |1 +
 drivers/media/i2c/s5k4ecgx.c | 1019 ++
 include/media/s5k4ecgx.h |   37 ++
 4 files changed, 1064 insertions(+)
 create mode 100644 drivers/media/i2c/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 9a5a059..55b3bbb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -484,6 +484,13 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/i2c/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 088a460..a720812 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_VIDEO_MT9V032) += mt9v032.o
 obj-$(CONFIG_VIDEO_SR030PC30)  += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
 obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
new file mode 100644
index 000..0f12d46
--- /dev/null
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -0,0 +1,1019 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from Samsung
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor.
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ *
+ * Based on s5k6aa, noon010pc30 driver
+ * Copyright (C) 2011, Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+#define S5K4ECGX_FIRMWARE  "s5k4ecgx.bin"
+
+/* Firmware revision information */
+#define REG_FW_REVISION0x71a6
+#define REG_FW_VERSION 0x71a4
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4ec0
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722c
+#define REG_USER_CONTRAST  0x722e
+#define REG_USER_SATURATION0x7230
+
+#define REG_G_NEW_CFG_SYNC 0x724a
+#define REG_G_PREV_IN_WIDTH0x7250
+#define REG_G_PREV_IN_HEIGHT   0x7252
+#define REG_G_PREV_IN_XOFFS0x7254
+#define REG_G_PREV_IN_YOFFS0x7256
+#define REG_G_CAP_IN_WIDTH 0x7258
+#define REG_G_CAP_IN_HEIGHT0x725a
+#define REG_G_CAP_IN_XOFFS 0x725c
+#define REG_G_CAP_IN_YOFFS 0x725e
+#define REG_G_INPUTS_CHANGE_REQ   

Re: [RFC PATCH v5] media: add v4l2 subdev driver for S5K4ECGX sensor

2012-09-06 Thread Sangwook Lee
Hi Sylwester

Thank you for the review again.

On 5 September 2012 22:56, Sylwester Nawrocki
 wrote:
> Hi Sangwook,
>
> On 09/05/2012 02:28 PM, Sangwook Lee wrote:
[snip]
>> +#include
>
> What do we need this header for ?

Ok, let me delete this.

>
>> +
>> +#include
>> +#include
>> +#include
>> +#include
>> +#include
>> +#include
> ...
>> +
>> +static int s5k4ecgx_set_ahb_address(struct v4l2_subdev *sd)
>> +{
>> + int ret;
>> + struct i2c_client *client = v4l2_get_subdevdata(sd);
>> +
>> + /* Set APB peripherals start address */
>> + ret = s5k4ecgx_i2c_write(client, AHB_MSB_ADDR_PTR, GEN_REG_OFFSH);
>> + if (ret)
>> + return ret;
>> + /*
>> +  * FIXME: This is copied from s5k6aa, because of no information
>> +  * in s5k4ecgx's datasheet.
>> +  * sw_reset is activated to put device into idle status
>> +  */
>> + ret = s5k4ecgx_i2c_write(client, 0x0010, 0x0001);
>> + if (ret)
>> + return ret;
>> +
>> + /* FIXME: no information available about this register */
>
> Let's drop that comment, we will fix all magic numbers once proper
> documentation is available.

Ok.

>
>> + ret = s5k4ecgx_i2c_write(client, 0x1030, 0x);
>> + if (ret)
>> + return ret;
>> + /* Halt ARM CPU */
>> + ret = s5k4ecgx_i2c_write(client, 0x0014, 0x0001);
>> +
>> + return ret;
>
> Just do
>
> return s5k4ecgx_i2c_write(client, 0x0014, 0x0001);

OK, I will fix this.

>> +}
>> +
>> +#define FW_HEAD 6
>> +/* Register address, value are 4, 2 bytes */
>> +#define FW_REG_SIZE 6
>
> FW_REG_SIZE is a bit confusing, maybe we could name this FW_RECORD_SIZE
> or something similar ?

Fair enough

>
>> +/*
>> + * Firmware has the following format:
>> + *,<  record 0>,
>> + *<  record N - 1>,<  CRC32-CCITT (4-bytes)>
>> + * where "record" is a 4-byte register address followed by 2-byte
>> + * register value (little endian)
>> + */
>> +static int s5k4ecgx_load_firmware(struct v4l2_subdev *sd)
>> +{
>> + const struct firmware *fw;
>> + int err, i, regs_num;
>> + struct i2c_client *client = v4l2_get_subdevdata(sd);
>> + u16 val;
>> + u32 addr, crc, crc_file, addr_inc = 0;
>> + u8 *fwbuf;
>> +
>> + err = request_firmware(&fw, S5K4ECGX_FIRMWARE, sd->v4l2_dev->dev);
>> + if (err) {
>> + v4l2_err(sd, "Failed to read firmware %s\n", 
>> S5K4ECGX_FIRMWARE);
>> + goto fw_out1;
>
> return err;

OK, I will fix this.

>
> ?
>> + }
>> + fwbuf = kmemdup(fw->data, fw->size, GFP_KERNEL);
>
> Why do we need this kmemdup ? Couldn't we just use fw->data ?

OK,  Iet me reconsider this.

>
>> + if (!fwbuf) {
>> + err = -ENOMEM;
>> + goto fw_out2;
>> + }
>> + crc_file = *(u32 *)(fwbuf + regs_num * FW_REG_SIZE);
>
> regs_num is uninitialized ?
>
>> + crc = crc32_le(~0, fwbuf, regs_num * FW_REG_SIZE);
>> + if (crc != crc_file) {
>> + v4l2_err(sd, "FW: invalid crc (%#x:%#x)\n", crc, crc_file);
>> + err = -EINVAL;
>> + goto fw_out3;
>> + }
>> + regs_num = *(u32 *)(fwbuf);
>
> I guess this needs to be moved up. I would make it
>
> regs_num = le32_to_cpu(*(u32 *)fw->data);
>
> And perhaps we need a check like:
>
> if (fw->size < regs_num * FW_REG_SIZE)
> return -EINVAL;
> ?
>> + v4l2_dbg(3, debug, sd, "FW: %s size %d register sets %d\n",
>> +  S5K4ECGX_FIRMWARE, fw->size, regs_num);
>> + regs_num++; /* Add header */
>> + for (i = 1; i<  regs_num; i++) {
>> + addr = *(u32 *)(fwbuf + i * FW_REG_SIZE);
>> + val = *(u16 *)(fwbuf + i * FW_REG_SIZE + 4);
>
> I think you need to access addr and val through le32_to_cpu() as well,
> even though your ARM system might be little-endian by default, this
> driver could possibly be used on machines with different endianness.
>
> Something like this could be more optimal:
>
> const u8 *ptr = fw->data + FW_REG_SIZE;
>
> for (i = 1; i < regs_num; i++) {
> addr = le32_to_cpu(*(u32 *)ptr);
> ptr += 4;
> val = le16_to_cpu(*(u16 *)ptr);
> ptr += FW_REG_SIZE;
>

Thanks for your adv

[RFC PATCH v6] media: add v4l2 subdev driver for S5K4ECGX sensor

2012-09-06 Thread Sangwook Lee
This patch adds driver for S5K4ECGX sensor with embedded ISP SoC,
S5K4ECGX, which is a 5M CMOS Image sensor from Samsung
The driver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.
Following controls are supported:
contrast/saturation/brightness/sharpness

Signed-off-by: Sangwook Lee 
Reviewed-by: Sylwester Nawrocki 
---
Changes since v5:
- deleted dummy lines
- fixed pointer errors in handling firmware
- updated comments
- added le32_to_cpu,le16_to_cpu

Changes since v4:
- replaced register tables with the function from Sylwester
- updated firmware parsing function with CRC32 check
  firmware generator from user space:
  git://git.linaro.org/people/sangwook/fimc-v4l2-app.git

Changes since v3:
- used request_firmware to configure initial settings
- added parsing functions to read initial settings
- updated regulator API
- reduced preview setting tables by experiment

Changes since v2:
- added GPIO (reset/stby) and regulators
- updated I2C read/write, based on s5k6aa datasheet
- fixed set_fmt errors
- reduced register tables a bit
- removed vmalloc

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else

 drivers/media/i2c/Kconfig|7 +
 drivers/media/i2c/Makefile   |1 +
 drivers/media/i2c/s5k4ecgx.c | 1011 ++
 include/media/s5k4ecgx.h |   37 ++
 4 files changed, 1056 insertions(+)
 create mode 100644 drivers/media/i2c/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 9a5a059..55b3bbb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -484,6 +484,13 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/i2c/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 088a460..a720812 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_VIDEO_MT9V032) += mt9v032.o
 obj-$(CONFIG_VIDEO_SR030PC30)  += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
 obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
new file mode 100644
index 000..66107c8
--- /dev/null
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -0,0 +1,1011 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from Samsung
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor.
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ *
+ * Based on s5k6aa, noon010pc30 driver
+ * Copyright (C) 2011, Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+#define S5K4ECGX_FIRMWARE  "s5k4ecgx.bin"
+
+/* Firmware revision information */
+#define REG_FW_REVISION0x71a6
+#define REG_FW_VERSION 0x71a4
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4ec0
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722c
+#define REG_USER_CONTRAST  0x722e
+#define REG_USER_SATURATION0x7230
+
+#define REG_G_NEW_CFG_SYNC 0x724a
+#define REG_G_PREV_IN_WIDTH0x7250
+#define REG_G_PREV_IN_HEIGHT   0x7252
+#define REG_G_PREV_IN_XOFFS0x7254
+#define REG_G_PREV_IN_YOFFS0x7256
+#define REG_G_CAP_IN_WIDTH 0x7258
+#define REG_G_CAP_IN_HEIGHT0x725a
+#define REG_G_CAP_IN_XOFFS

[PATCH] Samsung ARM:EXYNOS4: DMA Cleanup

2011-06-27 Thread Sangwook Lee
Function declaration differs between file:s3c-pl330.c and file:dma.h
and SPARSE (Documentation/sparse.txt) gives error messages

Signed-off-by: Sangwook Lee 
---
 arch/arm/plat-samsung/include/plat/dma.h |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/plat-samsung/include/plat/dma.h 
b/arch/arm/plat-samsung/include/plat/dma.h
index 2e8f8c6..7365f46 100644
--- a/arch/arm/plat-samsung/include/plat/dma.h
+++ b/arch/arm/plat-samsung/include/plat/dma.h
@@ -62,7 +62,7 @@ typedef int  (*s3c2410_dma_opfn_t)(struct s3c2410_dma_chan *,
  * request a dma channel exclusivley
 */
 
-extern int s3c2410_dma_request(unsigned int channel,
+extern int s3c2410_dma_request(enum dma_ch id,
   struct s3c2410_dma_client *, void *dev);
 
 
@@ -71,14 +71,14 @@ extern int s3c2410_dma_request(unsigned int channel,
  * change the state of the dma channel
 */
 
-extern int s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op);
+extern int s3c2410_dma_ctrl(enum dma_ch id, enum s3c2410_chan_op op);
 
 /* s3c2410_dma_setflags
  *
  * set the channel's flags to a given state
 */
 
-extern int s3c2410_dma_setflags(unsigned int channel,
+extern int s3c2410_dma_setflags(enum dma_ch id,
unsigned int flags);
 
 /* s3c2410_dma_free
@@ -86,7 +86,7 @@ extern int s3c2410_dma_setflags(unsigned int channel,
  * free the dma channel (will also abort any outstanding operations)
 */
 
-extern int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *);
+extern int s3c2410_dma_free(enum dma_ch id, struct s3c2410_dma_client *);
 
 /* s3c2410_dma_enqueue
  *
@@ -95,7 +95,7 @@ extern int s3c2410_dma_free(unsigned int channel, struct 
s3c2410_dma_client *);
  * drained before the buffer is given to the DMA system.
 */
 
-extern int s3c2410_dma_enqueue(unsigned int channel, void *id,
+extern int s3c2410_dma_enqueue(enum dma_ch idx, void *id,
   dma_addr_t data, int size);
 
 /* s3c2410_dma_config
@@ -103,14 +103,14 @@ extern int s3c2410_dma_enqueue(unsigned int channel, void 
*id,
  * configure the dma channel
 */
 
-extern int s3c2410_dma_config(unsigned int channel, int xferunit);
+extern int s3c2410_dma_config(enum dma_ch id, int xferunit);
 
 /* s3c2410_dma_devconfig
  *
  * configure the device we're talking to
 */
 
-extern int s3c2410_dma_devconfig(unsigned int channel,
+extern int s3c2410_dma_devconfig(enum dma_ch id,
enum s3c2410_dmasrc source, unsigned long devaddr);
 
 /* s3c2410_dma_getposition
@@ -118,7 +118,7 @@ extern int s3c2410_dma_devconfig(unsigned int channel,
  * get the position that the dma transfer is currently at
 */
 
-extern int s3c2410_dma_getposition(unsigned int channel,
+extern int s3c2410_dma_getposition(enum dma_ch id,
   dma_addr_t *src, dma_addr_t *dest);
 
 extern int s3c2410_dma_set_opfn(unsigned int, s3c2410_dma_opfn_t rtn);
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH] ARM:SAMSUNG: DMA Cleanup as per sparse

2011-07-08 Thread Sangwook Lee
Function declaration differs between file: dma.c and file:dma.h
and SPARSE (Documentation/sparse.txt) gives error messages

All dma channels are members of 'enum dma_ch' and not 'unsigned int'
Please have a look at channel definitions in:
arch/arm/mach-s3c64xx/include/mach/dma.h
arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h
arch/arm/mach-s3c2410/include/mach/dma.h
So all arguments should be of type 'enum dma_ch'

Signed-off-by: Sangwook Lee 
---
 arch/arm/mach-s3c64xx/dma.c  |   14 +++---
 arch/arm/plat-s3c24xx/dma.c  |   12 ++--
 arch/arm/plat-samsung/dma.c  |6 +++---
 arch/arm/plat-samsung/include/plat/dma.h |   21 +++--
 4 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/dma.c b/arch/arm/mach-s3c64xx/dma.c
index b197171..204bfaf 100644
--- a/arch/arm/mach-s3c64xx/dma.c
+++ b/arch/arm/mach-s3c64xx/dma.c
@@ -113,7 +113,7 @@ found:
return chan;
 }
 
-int s3c2410_dma_config(unsigned int channel, int xferunit)
+int s3c2410_dma_config(enum dma_ch channel, int xferunit)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
 
@@ -297,7 +297,7 @@ static int s3c64xx_dma_flush(struct s3c2410_dma_chan *chan)
return 0;
 }
 
-int s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op)
+int s3c2410_dma_ctrl(enum dma_ch channel, enum s3c2410_chan_op op)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
 
@@ -331,7 +331,7 @@ EXPORT_SYMBOL(s3c2410_dma_ctrl);
  *
  */
 
-int s3c2410_dma_enqueue(unsigned int channel, void *id,
+int s3c2410_dma_enqueue(enum dma_ch channel, void *id,
dma_addr_t data, int size)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
@@ -415,7 +415,7 @@ err_buff:
 EXPORT_SYMBOL(s3c2410_dma_enqueue);
 
 
-int s3c2410_dma_devconfig(unsigned int channel,
+int s3c2410_dma_devconfig(enum dma_ch channel,
  enum s3c2410_dmasrc source,
  unsigned long devaddr)
 {
@@ -463,7 +463,7 @@ int s3c2410_dma_devconfig(unsigned int channel,
 EXPORT_SYMBOL(s3c2410_dma_devconfig);
 
 
-int s3c2410_dma_getposition(unsigned int channel,
+int s3c2410_dma_getposition(enum dma_ch channel,
dma_addr_t *src, dma_addr_t *dst)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
@@ -487,7 +487,7 @@ EXPORT_SYMBOL(s3c2410_dma_getposition);
  * get control of an dma channel
 */
 
-int s3c2410_dma_request(unsigned int channel,
+int s3c2410_dma_request(enum dma_ch channel,
struct s3c2410_dma_client *client,
void *dev)
 {
@@ -533,7 +533,7 @@ EXPORT_SYMBOL(s3c2410_dma_request);
  * allowed to go through.
 */
 
-int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client)
+int s3c2410_dma_free(enum dma_ch channel, struct s3c2410_dma_client *client)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
unsigned long flags;
diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c
index 2abf966..623fba5 100644
--- a/arch/arm/plat-s3c24xx/dma.c
+++ b/arch/arm/plat-s3c24xx/dma.c
@@ -712,7 +712,7 @@ static struct s3c2410_dma_chan *s3c2410_dma_map_channel(int 
channel);
  * get control of an dma channel
 */
 
-int s3c2410_dma_request(unsigned int channel,
+int s3c2410_dma_request(enum dma_ch channel,
struct s3c2410_dma_client *client,
void *dev)
 {
@@ -783,7 +783,7 @@ EXPORT_SYMBOL(s3c2410_dma_request);
  * allowed to go through.
 */
 
-int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client)
+int s3c2410_dma_free(enum dma_ch channel, struct s3c2410_dma_client *client)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
unsigned long flags;
@@ -974,7 +974,7 @@ static int s3c2410_dma_started(struct s3c2410_dma_chan 
*chan)
 }
 
 int
-s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op)
+s3c2410_dma_ctrl(enum dma_ch channel, enum s3c2410_chan_op op)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
 
@@ -1021,7 +1021,7 @@ EXPORT_SYMBOL(s3c2410_dma_ctrl);
  * xfersize: size of unit in bytes (1,2,4)
 */
 
-int s3c2410_dma_config(unsigned int channel,
+int s3c2410_dma_config(enum dma_ch channel,
   int xferunit)
 {
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
@@ -1104,7 +1104,7 @@ EXPORT_SYMBOL(s3c2410_dma_config);
  * devaddr:   physical address of the source
 */
 
-int s3c2410_dma_devconfig(unsigned int channel,
+int s3c2410_dma_devconfig(enum dma_ch channel,
  enum s3c2410_dmasrc source,
  unsigned long devaddr)
 {
@@ -1177,7 +1177,7 @@ EXPORT_SYMBOL(s3c2410_dma_devconfig);
  * returns the current transfer points for the dma sou

Re: [Samsung] Origen touchscreen problem

2011-09-19 Thread Sangwook Lee
Thanks Angus!

I updated your advice into the following:

https://wiki.linaro.org/Boards/Origen/Setup

Regards
Sangwook


On 19 September 2011 00:35, Angus Ainslie  wrote:

> Hi,
>
> For the last few days I've been fighting what I thought was a
> touchscreen software problem with the Origen.
>
> I finally went back to a known good version and it didn't work either.
> I've figured out what happened to my board I'm just not sure why as
> there has been no mechanical stress on that connection. One of the
> connectors has become de-laminated so the signals aren't getting
> through.
>
>  I've attached a picture with the area of the fault indicated.
> Applying pressure to the indicted area re-establishes the connection.
>
> Angus
>
> --
> Angus Ainslie 
> Team Lead, Samsung Landing Team
>
> ___
> Samsung mailing list
> sams...@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/samsung
>
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH] ARM: EXYNOS4: Enable Bluetooth on ORIGEN

2011-10-26 Thread Sangwook Lee
This patch enables Bluetooth support on ORIGEN board.

Signed-off-by: Sangwook 
---
 arch/arm/mach-exynos4/mach-origen.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-exynos4/mach-origen.c 
b/arch/arm/mach-exynos4/mach-origen.c
index f80b563..f8c50d7 100644
--- a/arch/arm/mach-exynos4/mach-origen.c
+++ b/arch/arm/mach-exynos4/mach-origen.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -232,6 +233,7 @@ static struct regulator_init_data __initdata 
max8997_ldo9_data = {
.min_uV = 280,
.max_uV = 280,
.apply_uV   = 1,
+   .always_on  = 1,
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
.state_mem  = {
.disabled   = 1,
@@ -275,6 +277,7 @@ static struct regulator_init_data __initdata 
max8997_ldo14_data = {
.min_uV = 180,
.max_uV = 180,
.apply_uV   = 1,
+   .always_on  = 1,
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
.state_mem  = {
.disabled   = 1,
@@ -290,6 +293,7 @@ static struct regulator_init_data __initdata 
max8997_ldo17_data = {
.min_uV = 330,
.max_uV = 330,
.apply_uV   = 1,
+   .always_on  = 1,
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
.state_mem  = {
.disabled   = 1,
@@ -588,6 +592,21 @@ static struct s3c_fb_platdata origen_lcd_pdata __initdata 
= {
.setup_gpio = exynos4_fimd0_gpio_setup_24bpp,
 };
 
+/* Bluetooth rfkill gpio platform data */
+struct rfkill_gpio_platform_data origen_bt_pdata = {
+   .reset_gpio = EXYNOS4_GPX2(2),
+   .shutdown_gpio = -1,
+   .type = RFKILL_TYPE_BLUETOOTH,
+   .name = "origen-bt",
+};
+
+/* Bluetooth Platform device */
+static struct platform_device origen_device_bluetooth = {
+   .name = "rfkill_gpio",
+   .id = -1,
+   .dev.platform_data = &origen_bt_pdata,
+};
+
 static struct platform_device *origen_devices[] __initdata = {
&s3c_device_hsmmc2,
&s3c_device_hsmmc0,
@@ -615,6 +634,7 @@ static struct platform_device *origen_devices[] __initdata 
= {
&exynos4_device_pd[PD_MFC],
&origen_device_gpiokeys,
&origen_lcd_hv070wsa,
+   &origen_device_bluetooth,
 };
 
 /* LCD Backlight data */
@@ -628,6 +648,16 @@ static struct platform_pwm_backlight_data origen_bl_data = 
{
.pwm_period_ns  = 1000,
 };
 
+static void __init origen_bt_setup(void)
+{
+   gpio_request(EXYNOS4_GPA0(0), "GPIO BT_UART");
+   /* 4 UART Pins configuration */
+   s3c_gpio_cfgrange_nopull(EXYNOS4_GPA0(0), 4, S3C_GPIO_SFN(2));
+   /* Setup BT Reset, this gpio will be requesed by rfkill-gpio */
+   s3c_gpio_cfgpin(EXYNOS4_GPX2(2), S3C_GPIO_OUTPUT);
+   s3c_gpio_setpull(EXYNOS4_GPX2(2), S3C_GPIO_PULL_NONE);
+}
+
 static void s5p_tv_setup(void)
 {
/* Direct HPD to HDMI chip */
@@ -687,6 +717,8 @@ static void __init origen_machine_init(void)
s5p_device_mfc.dev.parent = &exynos4_device_pd[PD_MFC].dev;
 
samsung_bl_set(&origen_bl_gpio_info, &origen_bl_data);
+
+   origen_bt_setup();
 }
 
 MACHINE_START(ORIGEN, "ORIGEN")
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 1/2] ARM: SAMSUNG: Add pm_caps into platform data

2011-11-07 Thread Sangwook Lee
Add pm_caps into platform_data. This is power management, usually
for SDIO device such as SDIO WLAN.

Signed-off-by: Sangwook Lee 
---
 arch/arm/plat-samsung/dev-hsmmc3.c |2 ++
 arch/arm/plat-samsung/include/plat/sdhci.h |2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-samsung/dev-hsmmc3.c 
b/arch/arm/plat-samsung/dev-hsmmc3.c
index ede776f..8f467f2 100644
--- a/arch/arm/plat-samsung/dev-hsmmc3.c
+++ b/arch/arm/plat-samsung/dev-hsmmc3.c
@@ -78,6 +78,8 @@ void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd)
set->cfg_card = pd->cfg_card;
if (pd->host_caps)
set->host_caps |= pd->host_caps;
+   if (pd->pm_caps)
+   set->pm_caps |= pd->pm_caps;
if (pd->clk_type)
set->clk_type = pd->clk_type;
 }
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h 
b/arch/arm/plat-samsung/include/plat/sdhci.h
index 058e096..35646de 100644
--- a/arch/arm/plat-samsung/include/plat/sdhci.h
+++ b/arch/arm/plat-samsung/include/plat/sdhci.h
@@ -40,6 +40,7 @@ enum clk_types {
  * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
  * @max_width: The maximum number of data bits supported.
  * @host_caps: Standard MMC host capabilities bit field.
+ * @pm_caps: SDIO host PM capabilities bit field.
  * @cd_type: Type of Card Detection method (see cd_types enum above)
  * @clk_type: Type of clock divider method (see clk_types enum above)
  * @ext_cd_init: Initialize external card detect subsystem. Called on
@@ -67,6 +68,7 @@ enum clk_types {
 struct s3c_sdhci_platdata {
unsigned intmax_width;
unsigned inthost_caps;
+   unsigned intpm_caps;
enum cd_types   cd_type;
enum clk_types  clk_type;
 
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 0/2] ARM: SAMSUNG: Add pm_caps

2011-11-07 Thread Sangwook Lee
Add pm_caps into platform data and update it in SD/MMC driver
This field can be used with SDIO device such as SDIO WLAN.

Sangwook Lee (2):
  ARM: SAMSUNG: Add pm_caps into platform data
  mmc: sdhci-s3c: Add pm_caps into SD/MMC host

 arch/arm/plat-samsung/dev-hsmmc3.c |2 ++
 arch/arm/plat-samsung/include/plat/sdhci.h |2 ++
 drivers/mmc/host/sdhci-s3c.c   |3 +++
 3 files changed, 7 insertions(+), 0 deletions(-)

-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 2/2] mmc: sdhci-s3c: Add pm_caps into SD/MMC host

2011-11-07 Thread Sangwook Lee
sdhci-s3c updates pm_caps from platform data for SDIO PM.

Signed-off-by: Sangwook Lee 
---
 drivers/mmc/host/sdhci-s3c.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index fe886d6..f10dd52 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -518,6 +518,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device 
*pdev)
if (pdata->host_caps)
host->mmc->caps |= pdata->host_caps;
 
+   if (pdata->pm_caps)
+   host->mmc->pm_caps |= pdata->pm_caps;
+
host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR |
 SDHCI_QUIRK_32BIT_DMA_SIZE);
 
-- 
1.7.4.1


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 1/2] ARM: SAMSUNG: Add pm_caps into platform data

2011-11-15 Thread Sangwook Lee
Hi

On 15 November 2011 09:53, Kukjin Kim  wrote:

> Sangwook Lee wrote:
> >
> > Add pm_caps into platform_data. This is power management, usually
> > for SDIO device such as SDIO WLAN.
> >
> > Signed-off-by: Sangwook Lee 
> > ---
> >  arch/arm/plat-samsung/dev-hsmmc3.c |2 ++
> >  arch/arm/plat-samsung/include/plat/sdhci.h |2 ++
> >  2 files changed, 4 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/plat-samsung/dev-hsmmc3.c
> b/arch/arm/plat-samsung/dev-
> > hsmmc3.c
> > index ede776f..8f467f2 100644
> > --- a/arch/arm/plat-samsung/dev-hsmmc3.c
> > +++ b/arch/arm/plat-samsung/dev-hsmmc3.c
> > @@ -78,6 +78,8 @@ void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata
> *pd)
> >   set->cfg_card = pd->cfg_card;
> >   if (pd->host_caps)
> >   set->host_caps |= pd->host_caps;
> > + if (pd->pm_caps)
> > + set->pm_caps |= pd->pm_caps;
> >   if (pd->clk_type)
> >   set->clk_type = pd->clk_type;
> >  }
> > diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-
> > samsung/include/plat/sdhci.h
> > index 058e096..35646de 100644
> > --- a/arch/arm/plat-samsung/include/plat/sdhci.h
> > +++ b/arch/arm/plat-samsung/include/plat/sdhci.h
> > @@ -40,6 +40,7 @@ enum clk_types {
> >   * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
> >   * @max_width: The maximum number of data bits supported.
> >   * @host_caps: Standard MMC host capabilities bit field.
> > + * @pm_caps: SDIO host PM capabilities bit field.
> >   * @cd_type: Type of Card Detection method (see cd_types enum above)
> >   * @clk_type: Type of clock divider method (see clk_types enum above)
> >   * @ext_cd_init: Initialize external card detect subsystem. Called on
> > @@ -67,6 +68,7 @@ enum clk_types {
> >  struct s3c_sdhci_platdata {
> >   unsigned intmax_width;
> >   unsigned inthost_caps;
> > + unsigned intpm_caps;
> >   enum cd_types   cd_type;
> >   enum clk_types  clk_type;
> >
> > --
> > 1.7.4.1
>
> Hi Sangwook,
>
> I think you need to re-work based on latest my for-next.
>
>
Ok, I will rebase and then it again



> Thanks.
>
> Best regards,
> Kgene.
> --
> Kukjin Kim , Senior Engineer,
> SW Solution Development Team, Samsung Electronics Co., Ltd.
>
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [RFC PATCH v6] media: add v4l2 subdev driver for S5K4ECGX sensor

2012-09-11 Thread Sangwook Lee
Hi  Francesco

Thanks for your advice.

@ Sylwester
Thanks for your nice patch, and I will squash  and then send it again.


Thanks
Sangwook


On 10 September 2012 21:29, Sylwester Nawrocki
 wrote:
> On 09/10/2012 08:52 PM, Francesco Lavra wrote:
>> On 09/10/2012 05:04 PM, Sylwester Nawrocki wrote:
>>> On 09/09/2012 06:01 PM, Francesco Lavra wrote:
> +static int s5k4ecgx_load_firmware(struct v4l2_subdev *sd)
> +{
> +  const struct firmware *fw;
> +  int err, i, regs_num;
> +  struct i2c_client *client = v4l2_get_subdevdata(sd);
> +  u16 val;
> +  u32 addr, crc, crc_file, addr_inc = 0;
> +
> +  err = request_firmware(&fw, S5K4ECGX_FIRMWARE, sd->v4l2_dev->dev);
> +  if (err) {
> +  v4l2_err(sd, "Failed to read firmware %s\n", 
> S5K4ECGX_FIRMWARE);
> +  return err;
> +  }
> +  regs_num = *(u32 *)(fw->data);
> +  v4l2_dbg(3, debug, sd, "FW: %s size %d register sets %d\n",
> +   S5K4ECGX_FIRMWARE, fw->size, regs_num);
> +  regs_num++; /* Add header */
> +  if (fw->size != regs_num * FW_RECORD_SIZE + FW_CRC_SIZE) {
> +  err = -EINVAL;
> +  goto fw_out;
> +  }
> +  crc_file = *(u32 *)(fw->data + regs_num * FW_RECORD_SIZE);

 Depending on the value of regs_num, this may result in unaligned access
>>>
>>> Thanks for the catch. I think it is not the only place where unaligned
>>> issues are possible. Since the data records are 4-byte address + 2-byte
>>> value there is also an issue with reading the address entries. Assuming
>>> fw->data is aligned to at least 2-bytes (not quite sure if we can assume
>>> that) there should be no problem with reading 2-byte register values.
>>
>> I'm not sure 2-byte alignment can be safely assumed, either.
>>
>>> We could change the data types of the register values from u16 to u32,
>>> wasting some memory (there is approximately 3 000 records), so there is
>>> no other data types in the file structure than u32. Or use a patch as
>>> below. Not sure what's better.
>>
>> I prefer the approach of your patch below, but I would use get_unaligned
>> to get the 2-byte values, too. Also there are another couple of
>> glitches, see below.
>
> OK, thanks for the feedback. It was also my preference. The performance
> impact seems insignificant, given a write of each record takes time of
> 1 ms order.
>
>>> 8<-
>>>  From a970480b99bdb74e2bf48e1a321724231e6516a0 Mon Sep 17 00:00:00 2001
>>> From: Sylwester Nawrocki
>>> Date: Sun, 9 Sep 2012 19:56:31 +0200
>>> Subject: [PATCH] s5k4ecgx: Fix unaligned access issues
>>>
>>> Signed-off-by: Sylwester Nawrocki
>>> ---
>>>   drivers/media/i2c/s5k4ecgx.c |   16 
>>>   1 files changed, 12 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
>>> index 0ef0b7d..4c6439a 100644
>>> --- a/drivers/media/i2c/s5k4ecgx.c
>>> +++ b/drivers/media/i2c/s5k4ecgx.c
>>> @@ -24,6 +24,7 @@
>>>   #include
>>>   #include
>>>   #include
>>> +#include
>>>
>>>   #include
>>>   #include
>>> @@ -331,6 +332,7 @@ static int s5k4ecgx_load_firmware(struct v4l2_subdev 
>>> *sd)
>>>  const struct firmware *fw;
>>>  int err, i, regs_num;
>>>  u32 addr, crc, crc_file, addr_inc = 0;
>>> +const u8 *ptr;
>>>  u16 val;
>>>
>>>  err = request_firmware(&fw, S5K4ECGX_FIRMWARE, sd->v4l2_dev->dev);
>>> @@ -338,7 +340,7 @@ static int s5k4ecgx_load_firmware(struct v4l2_subdev 
>>> *sd)
>>>  v4l2_err(sd, "Failed to read firmware %s\n", 
>>> S5K4ECGX_FIRMWARE);
>>>  return err;
>>>  }
>>> -regs_num = le32_to_cpu(*(u32 *)fw->data);
>>> +regs_num = le32_to_cpu(get_unaligned((__le32 *)fw->data));
>>>
>>>  v4l2_dbg(3, debug, sd, "FW: %s size %d register sets %d\n",
>>>   S5K4ECGX_FIRMWARE, fw->size, regs_num);
>>> @@ -349,7 +351,8 @@ static int s5k4ecgx_load_firmware(struct v4l2_subdev 
>>> *sd)
>>>  goto fw_out;
>>>  }
>>>
>>> -crc_file = *(u32 *)(fw->data + regs_num * FW_RECORD_SIZE);
>>> +memcpy(&crc_file, fw->data + regs_num * FW_RECORD_SIZE, sizeof(u32));
>>
>> crc_file should be converted from little endian to native endian.
>
> Right, I should have verified that crc32_le() return value is in native
> endianness.
>
>>> +
>>>  crc = crc32_le(~0, fw->data, regs_num * FW_RECORD_SIZE);
>>>  if (crc != crc_file) {
>>>  v4l2_err(sd, "FW: invalid crc (%#x:%#x)\n", crc, crc_file);
>>> @@ -357,9 +360,14 @@ static int s5k4ecgx_load_firmware(struct v4l2_subdev 
>>> *sd)
>>>  goto fw_out;
>>>  }
>>>
>>> +ptr = fw->data + FW_RECORD_SIZE;
>>> +
>>>  for (i = 1; i<  regs_num; i++) {
>>> -addr = le32_to_cpu(*(u32 *)(fw->data + i * FW_RECORD_SIZE));
>>> -val = le16_to_cpu(*(u16 *)(fw->data + i * FW_RECORD_SIZE + 4));
>>> +addr = le32_to_cpu(get_unaligned((__le

[RFC PATCH v7] media: add v4l2 subdev driver for S5K4ECGX sensor

2012-09-12 Thread Sangwook Lee
This patch adds driver for S5K4ECGX sensor with embedded ISP SoC,
S5K4ECGX, which is a 5M CMOS Image sensor from Samsung
The driver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.
Following controls are supported:
contrast/saturation/brightness/sharpness

Signed-off-by: Sangwook Lee 
Reviewed-by: Sylwester Nawrocki 
Cc: Francesco Lavra 
CC: Scott Bambrough 
Cc: Homin Lee 
---
Changes since v6:
- fix alignment issue from Francesco, Sylwester

Changes since v5:
- deleted dummy lines
- fixed pointer errors in handling firmware
- updated comments
- added le32_to_cpu,le16_to_cpu

Changes since v4:
- replaced register tables with the function from Sylwester
- updated firmware parsing function with CRC32 check
  firmware generator from user space:
  git://git.linaro.org/people/sangwook/fimc-v4l2-app.git

Changes since v3:
- used request_firmware to configure initial settings
- added parsing functions to read initial settings
- updated regulator API
- reduced preview setting tables by experiment

Changes since v2:
- added GPIO (reset/stby) and regulators
- updated I2C read/write, based on s5k6aa datasheet
- fixed set_fmt errors
- reduced register tables a bit
- removed vmalloc

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else
 drivers/media/i2c/Kconfig|7 +
 drivers/media/i2c/Makefile   |1 +
 drivers/media/i2c/s5k4ecgx.c | 1016 ++
 include/media/s5k4ecgx.h |   37 ++
 4 files changed, 1061 insertions(+)
 create mode 100644 drivers/media/i2c/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 9a5a059..55b3bbb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -484,6 +484,13 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/i2c/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 088a460..a720812 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_VIDEO_MT9V032) += mt9v032.o
 obj-$(CONFIG_VIDEO_SR030PC30)  += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
 obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
new file mode 100644
index 000..dd2f68d
--- /dev/null
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -0,0 +1,1016 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from Samsung
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor.
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ *
+ * Based on s5k6aa, noon010pc30 driver
+ * Copyright (C) 2011, Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+#define S5K4ECGX_FIRMWARE  "s5k4ecgx.bin"
+
+/* Firmware revision information */
+#define REG_FW_REVISION0x71a6
+#define REG_FW_VERSION 0x71a4
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4ec0
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722c
+#define REG_USER_CONTRAST  0x722e
+#define REG_USER_SATURATION0x7230
+
+#define REG_G_NEW_CFG_SYNC 0x724a
+#define REG_G_PREV_IN_WIDTH0x7250
+#define REG_G_PREV_IN_HEIGHT   0x7252
+#define REG_G_PREV_IN_XOFFS0x7254
+#define REG_G_PREV_IN_YOFFS0x70

Re: [RFC PATCH v7] media: add v4l2 subdev driver for S5K4ECGX sensor

2012-09-13 Thread Sangwook Lee
Hi Francesco

On 12 September 2012 19:07, Francesco Lavra  wrote:
> Hi Sangwook,
> two remarks from my review on September 9th haven't been addressed.

Thanks for the review.
I missed those, please let me correct them and send patch again.

Regards
Sangwook


> I believe those remarks are correct, but please let me know if I'm
> missing something.
> See below.
>
> On 09/12/2012 01:26 PM, Sangwook Lee wrote:
>> +static int s5k4ecgx_s_power(struct v4l2_subdev *sd, int on)
>> +{
>> + struct s5k4ecgx *priv = to_s5k4ecgx(sd);
>> + int ret;
>> +
>> + v4l2_dbg(1, debug, sd, "Switching %s\n", on ? "on" : "off");
>> +
>> + if (on) {
>> + ret = __s5k4ecgx_power_on(priv);
>> + if (ret < 0)
>> + return ret;
>> + /* Time to stabilize sensor */
>> + msleep(100);
>> + ret = s5k4ecgx_init_sensor(sd);
>> + if (ret < 0)
>> + __s5k4ecgx_power_off(priv);
>> + else
>> + priv->set_params = 1;
>> + } else {
>> + ret = __s5k4ecgx_power_off(priv);
>> + }
>> +
>> + return 0;
>
> return ret;
>
>> +static int s5k4ecgx_probe(struct i2c_client *client,
>> +   const struct i2c_device_id *id)
>> +{
>> + int ret, i;
>> + struct v4l2_subdev *sd;
>> + struct s5k4ecgx *priv;
>> + struct s5k4ecgx_platform_data *pdata = client->dev.platform_data;
>> +
>> + if (pdata == NULL) {
>> + dev_err(&client->dev, "platform data is missing!\n");
>> + return -EINVAL;
>> + }
>> + priv = devm_kzalloc(&client->dev, sizeof(struct s5k4ecgx), GFP_KERNEL);
>> + if (!priv)
>> + return -ENOMEM;
>> +
>> + mutex_init(&priv->lock);
>> + priv->streaming = 0;
>> +
>> + sd = &priv->sd;
>> + /* Registering subdev */
>> + v4l2_i2c_subdev_init(sd, client, &s5k4ecgx_ops);
>> + strlcpy(sd->name, S5K4ECGX_DRIVER_NAME, sizeof(sd->name));
>> +
>> + sd->internal_ops = &s5k4ecgx_subdev_internal_ops;
>> + /* Support v4l2 sub-device user space API */
>> + sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>> +
>> + priv->pad.flags = MEDIA_PAD_FL_SOURCE;
>> + sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>> + ret = media_entity_init(&sd->entity, 1, &priv->pad, 0);
>> + if (ret)
>> + return ret;
>> +
>> + ret = s5k4ecgx_config_gpios(priv, pdata);
>> + if (ret) {
>> + dev_err(&client->dev, "Failed to set gpios\n");
>> + goto out_err1;
>> + }
>> + for (i = 0; i < S5K4ECGX_NUM_SUPPLIES; i++)
>> + priv->supplies[i].supply = s5k4ecgx_supply_names[i];
>> +
>> + ret = devm_regulator_bulk_get(&client->dev, S5K4ECGX_NUM_SUPPLIES,
>> +  priv->supplies);
>> + if (ret) {
>> + dev_err(&client->dev, "Failed to get regulators\n");
>> + goto out_err2;
>> + }
>> + ret = s5k4ecgx_init_v4l2_ctrls(priv);
>> + if (ret)
>> + goto out_err2;
>> +
>> + priv->curr_pixfmt = &s5k4ecgx_formats[0];
>> + priv->curr_frmsize = &s5k4ecgx_prev_sizes[0];
>> +
>> + return 0;
>> +
>> +out_err2:
>> + s5k4ecgx_free_gpios(priv);
>> +out_err1:
>> + media_entity_cleanup(&priv->sd.entity);
>> +
>> + return ret;
>> +}
>> +
>> +static int s5k4ecgx_remove(struct i2c_client *client)
>> +{
>> + struct v4l2_subdev *sd = i2c_get_clientdata(client);
>> + struct s5k4ecgx *priv = to_s5k4ecgx(sd);
>> +
>> + mutex_destroy(&priv->lock);
>> + v4l2_device_unregister_subdev(sd);
>> + v4l2_ctrl_handler_free(&priv->handler);
>> + media_entity_cleanup(&sd->entity);
>> +
>> + return 0;
>
> s5k4ecgx_free_gpios() should be called to release the GPIOs
>
> Thanks,
> Francesco

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[RFC PATCH v8] media: add v4l2 subdev driver for S5K4ECGX sensor

2012-09-13 Thread Sangwook Lee
This patch adds driver for S5K4ECGX sensor with embedded ISP SoC,
S5K4ECGX, which is a 5M CMOS Image sensor from Samsung
The driver implements preview mode of the S5K4ECGX sensor.
capture (snapshot) operation, face detection are missing now.
Following controls are supported:
contrast/saturation/brightness/sharpness

Signed-off-by: Sangwook Lee 
Reviewed-by: Sylwester Nawrocki 
Cc: Francesco Lavra 
Cc: Scott Bambrough 
Cc: Homin Lee 
---
Changes since v7:
- added gpio free function
- fixed return value of power function

Changes since v6:
- fixed alignment issue from Francesco, Sylwester

Changes since v5:
- deleted dummy lines
- fixed pointer errors in handling firmware
- updated comments
- added le32_to_cpu,le16_to_cpu

Changes since v4:
- replaced register tables with the function from Sylwester
- updated firmware parsing function with CRC32 check
  firmware generator from user space:
  git://git.linaro.org/people/sangwook/fimc-v4l2-app.git

Changes since v3:
- used request_firmware to configure initial settings
- added parsing functions to read initial settings
- updated regulator API
- reduced preview setting tables by experiment

Changes since v2:
- added GPIO (reset/stby) and regulators
- updated I2C read/write, based on s5k6aa datasheet
- fixed set_fmt errors
- reduced register tables a bit
- removed vmalloc

Changes since v1:
- fixed s_stream(0) when it called twice
- changed mutex_X position to be used when strictly necessary
- add additional s_power(0) in case that error happens
- update more accurate debugging statements
- remove dummy else

 drivers/media/i2c/Kconfig|7 +
 drivers/media/i2c/Makefile   |1 +
 drivers/media/i2c/s5k4ecgx.c | 1017 ++
 include/media/s5k4ecgx.h |   37 ++
 4 files changed, 1062 insertions(+)
 create mode 100644 drivers/media/i2c/s5k4ecgx.c
 create mode 100644 include/media/s5k4ecgx.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 9a5a059..55b3bbb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -484,6 +484,13 @@ config VIDEO_S5K6AA
  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K4ECGX
+tristate "Samsung S5K4ECGX sensor support"
+depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+---help---
+  This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M
+  camera sensor with an embedded SoC image signal processor.
+
 source "drivers/media/i2c/smiapp/Kconfig"
 
 comment "Flash devices"
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 088a460..a720812 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_VIDEO_MT9V032) += mt9v032.o
 obj-$(CONFIG_VIDEO_SR030PC30)  += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
+obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
 obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
new file mode 100644
index 000..7b455e1
--- /dev/null
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -0,0 +1,1017 @@
+/*
+ * Driver for s5k4ecgx (5MP Camera) from Samsung
+ * a quarter-inch optical format 1.4 micron 5 megapixel (Mp)
+ * CMOS image sensor.
+ *
+ * Copyright (C) 2012, Linaro, Sangwook Lee 
+ * Copyright (C) 2012, Insignal Co,. Ltd,  Homin Lee 
+ *
+ * Based on s5k6aa, noon010pc30 driver
+ * Copyright (C) 2011, Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define S5K4ECGX_DRIVER_NAME   "s5k4ecgx"
+#define S5K4ECGX_FIRMWARE  "s5k4ecgx.bin"
+
+/* Firmware revision information */
+#define REG_FW_REVISION0x71a6
+#define REG_FW_VERSION 0x71a4
+#define S5K4ECGX_REVISION_1_1  0x11
+#define S5K4ECGX_FW_VERSION0x4ec0
+
+/* General purpose parameters */
+#define REG_USER_BRIGHTNESS0x722c
+#define REG_USER_CONTRAST  0x722e
+#define REG_USER_SATURATION0x7230
+
+#define REG_G_NEW_CFG_SYNC 0x724a
+#define REG_G_PREV_IN_WIDTH0x7250
+#define REG_G_PREV_IN_HEIGHT   0x7252
+#define REG_

Re: Linaro Website Contact

2012-09-19 Thread Sangwook Lee
Hi JunrongYe,

[snip]

>
>
>
> I have installed the pre-built image of ubuntu 12.08 on my OrigenBoard. At
> the first I download the firmware-linux and copy the folder
> /ath6k/AR6003/hw2.1.1 to the folder /etc/firmware/ on my board.Then the
> wifi can work well.But now the wifi does not work.And it can not find any
> wireless router.At the same time the blueetooth can not work. I want the


Could you try to run as followings ?

$ iwlist wlan0 scan

It should show APs. If not, it seems to be related to kernel drivers &
board.

Thanks
Sangwook



> wifi can be used for my board. Can you help me to solve the problem. Thank
> you for your




https://wiki.linaro.org/Resources/HowTo/SamsungLT
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev