[PATCHv2 1/7] media: video: append $(srctree) to -I parameters

2012-02-17 Thread Andy Shevchenko
Without this we have got the warnings like following if build with make W=1
O=/var/tmp:
   CHECK   drivers/media/video/videobuf-vmalloc.c
   CC [M]  drivers/media/video/videobuf-vmalloc.o
 +cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]
 +cc1: warning: drivers/media/dvb/frontends: No such file or directory [enabled 
by default]
 +cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]
 +cc1: warning: drivers/media/dvb/frontends: No such file or directory [enabled 
by default]
   LD  drivers/media/built-in.o

Some details could be found in [1] as well.

[1] http://comments.gmane.org/gmane.linux.kbuild.devel/7733

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/media/video/Makefile |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 3541388..3bf0aa8 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -199,6 +199,6 @@ obj-y   += davinci/
 
 obj-$(CONFIG_ARCH_OMAP)+= omap/
 
-ccflags-y += -Idrivers/media/dvb/dvb-core
-ccflags-y += -Idrivers/media/dvb/frontends
-ccflags-y += -Idrivers/media/common/tuners
+ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
+ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
+ccflags-y += -I$(srctree)/drivers/media/common/tuners
-- 
1.7.9

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


[PATCHv2 4/7] media: dvb: append $(srctree) to -I parameters

2012-02-17 Thread Andy Shevchenko
Without this we have got the warnings like following if build with make W=1
O=/var/tmp:
  cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/media/dvb/dvb-usb/Makefile   |7 ---
 drivers/media/dvb/frontends/Makefile |4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/Makefile 
b/drivers/media/dvb/dvb-usb/Makefile
index d9549cb..2e64f84 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -107,8 +107,9 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += dvb-usb-mxl111sf.o
 obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-demod.o
 obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o
 
-ccflags-y += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
+ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
+ccflags-y += -I$(srctree)/drivers/media/dvb/frontends/
 # due to tuner-xc3028
-ccflags-y += -Idrivers/media/common/tuners
-EXTRA_CFLAGS += -Idrivers/media/dvb/ttpci
+ccflags-y += -I$(srctree)/drivers/media/common/tuners
+ccflags-y += -I$(srctree)/drivers/media/dvb/ttpci
 
diff --git a/drivers/media/dvb/frontends/Makefile 
b/drivers/media/dvb/frontends/Makefile
index 00a2063..90320f1 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -2,8 +2,8 @@
 # Makefile for the kernel DVB frontend device drivers.
 #
 
-ccflags-y += -Idrivers/media/dvb/dvb-core/
-ccflags-y += -Idrivers/media/common/tuners/
+ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core/
+ccflags-y += -I$(srctree)/drivers/media/common/tuners/
 
 stb0899-objs = stb0899_drv.o stb0899_algo.o
 stv0900-objs = stv0900_core.o stv0900_sw.o
-- 
1.7.9

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


[PATCHv2 2/7] media: tuners: append $(srctree) to -I parameters

2012-02-17 Thread Andy Shevchenko
Without this we have got the warnings like following if build with make W=1
O=/var/tmp:
  cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/media/common/tuners/Makefile |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/common/tuners/Makefile 
b/drivers/media/common/tuners/Makefile
index 8295854..f80407e 100644
--- a/drivers/media/common/tuners/Makefile
+++ b/drivers/media/common/tuners/Makefile
@@ -29,5 +29,5 @@ obj-$(CONFIG_MEDIA_TUNER_MAX2165) += max2165.o
 obj-$(CONFIG_MEDIA_TUNER_TDA18218) += tda18218.o
 obj-$(CONFIG_MEDIA_TUNER_TDA18212) += tda18212.o
 
-ccflags-y += -Idrivers/media/dvb/dvb-core
-ccflags-y += -Idrivers/media/dvb/frontends
+ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
+ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
-- 
1.7.9

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


[PATCHv2 3/7] media: gspca: append $(srctree) to -I parameters

2012-02-17 Thread Andy Shevchenko
Without this we have got the warnings like following if build with make W=1
O=/var/tmp:
  cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/media/video/gspca/gl860/Makefile   |2 +-
 drivers/media/video/gspca/m5602/Makefile   |2 +-
 drivers/media/video/gspca/stv06xx/Makefile |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/gspca/gl860/Makefile 
b/drivers/media/video/gspca/gl860/Makefile
index f511ecc..773ea34 100644
--- a/drivers/media/video/gspca/gl860/Makefile
+++ b/drivers/media/video/gspca/gl860/Makefile
@@ -6,5 +6,5 @@ gspca_gl860-objs := gl860.o \
gl860-ov9655.o \
gl860-mi2020.o
 
-ccflags-y += -Idrivers/media/video/gspca
+ccflags-y += -I$(srctree)/drivers/media/video/gspca
 
diff --git a/drivers/media/video/gspca/m5602/Makefile 
b/drivers/media/video/gspca/m5602/Makefile
index 7f52961..575b75b 100644
--- a/drivers/media/video/gspca/m5602/Makefile
+++ b/drivers/media/video/gspca/m5602/Makefile
@@ -8,4 +8,4 @@ gspca_m5602-objs := m5602_core.o \
m5602_s5k83a.o \
m5602_s5k4aa.o
 
-ccflags-y += -Idrivers/media/video/gspca
+ccflags-y += -I$(srctree)/drivers/media/video/gspca
diff --git a/drivers/media/video/gspca/stv06xx/Makefile 
b/drivers/media/video/gspca/stv06xx/Makefile
index 5b318fa..38bc410 100644
--- a/drivers/media/video/gspca/stv06xx/Makefile
+++ b/drivers/media/video/gspca/stv06xx/Makefile
@@ -6,5 +6,5 @@ gspca_stv06xx-objs := stv06xx.o \
  stv06xx_pb0100.o \
  stv06xx_st6422.o
 
-ccflags-y += -Idrivers/media/video/gspca
+ccflags-y += -I$(srctree)/drivers/media/video/gspca
 
-- 
1.7.9

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


[PATCHv2 6/7] media: saa7164: append $(srctree) to -I parameters

2012-02-17 Thread Andy Shevchenko
Without this we have got the warnings like following if build with make W=1
O=/var/tmp:
  cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/media/video/saa7164/Makefile |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/saa7164/Makefile 
b/drivers/media/video/saa7164/Makefile
index ecd5811..068443a 100644
--- a/drivers/media/video/saa7164/Makefile
+++ b/drivers/media/video/saa7164/Makefile
@@ -4,9 +4,9 @@ saa7164-objs:= saa7164-cards.o saa7164-core.o saa7164-i2c.o 
saa7164-dvb.o \
 
 obj-$(CONFIG_VIDEO_SAA7164) += saa7164.o
 
-ccflags-y += -Idrivers/media/video
-ccflags-y += -Idrivers/media/common/tuners
-ccflags-y += -Idrivers/media/dvb/dvb-core
-ccflags-y += -Idrivers/media/dvb/frontends
+ccflags-y += -I$(srctree)/drivers/media/video
+ccflags-y += -I$(srctree)/drivers/media/common/tuners
+ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
+ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
 
 ccflags-y += $(extra-cflags-y) $(extra-cflags-m)
-- 
1.7.9

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


[PATCHv2 5/7] media: ivtv: append $(srctree) to -I parameters

2012-02-17 Thread Andy Shevchenko
Without this we have got the warnings like following if build with make W=1
O=/var/tmp:
  cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/media/video/ivtv/Makefile |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/ivtv/Makefile 
b/drivers/media/video/ivtv/Makefile
index 71ab76a..77de8a4 100644
--- a/drivers/media/video/ivtv/Makefile
+++ b/drivers/media/video/ivtv/Makefile
@@ -7,8 +7,8 @@ ivtv-objs   := ivtv-routing.o ivtv-cards.o ivtv-controls.o \
 obj-$(CONFIG_VIDEO_IVTV) += ivtv.o
 obj-$(CONFIG_VIDEO_FB_IVTV) += ivtvfb.o
 
-ccflags-y += -Idrivers/media/video
-ccflags-y += -Idrivers/media/common/tuners
-ccflags-y += -Idrivers/media/dvb/dvb-core
-ccflags-y += -Idrivers/media/dvb/frontends
+ccflags-y += -I$(srctree)/drivers/media/video
+ccflags-y += -I$(srctree)/drivers/media/common/tuners
+ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
+ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
 
-- 
1.7.9

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


[PATCHv2 7/7] media: saa7134: append $(srctree) to -I parameters

2012-02-17 Thread Andy Shevchenko
Without this we have got the warnings like following if build with make W=1
O=/var/tmp:
  cc1: warning: drivers/media/dvb/dvb-core: No such file or directory [enabled 
by default]

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/media/video/saa7134/Makefile |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/saa7134/Makefile 
b/drivers/media/video/saa7134/Makefile
index a646ccf..da38993 100644
--- a/drivers/media/video/saa7134/Makefile
+++ b/drivers/media/video/saa7134/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_VIDEO_SAA7134_ALSA) += saa7134-alsa.o
 
 obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
 
-ccflags-y += -Idrivers/media/video
-ccflags-y += -Idrivers/media/common/tuners
-ccflags-y += -Idrivers/media/dvb/dvb-core
-ccflags-y += -Idrivers/media/dvb/frontends
+ccflags-y += -I$(srctree)/drivers/media/video
+ccflags-y += -I$(srctree)/drivers/media/common/tuners
+ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
+ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
-- 
1.7.9

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


Re: [PATCH] media: video: mx2_camera: Remove ifdef's

2012-02-17 Thread Sascha Hauer
On Thu, Feb 16, 2012 at 04:25:39PM -0200, Fabio Estevam wrote:
 As we are able to build a same kernel that supports both mx27 and mx25, we 
 should remove
 the ifdef's for CONFIG_MACH_MX27 in the mx2_camera driver.

It's not that simple. Yes, we are able to build a kernel for both
i.MX25 and i.MX27 and this patch will work when both architectures
are compiled in, but it will break if we try to build it for only
i.MX25.

Sascha

 
 Signed-off-by: Fabio Estevam fabio.este...@freescale.com
 ---
  drivers/media/video/mx2_camera.c |   22 +++---
  1 files changed, 3 insertions(+), 19 deletions(-)
 
 diff --git a/drivers/media/video/mx2_camera.c 
 b/drivers/media/video/mx2_camera.c
 index 04aab0c..afb4619 100644
 --- a/drivers/media/video/mx2_camera.c
 +++ b/drivers/media/video/mx2_camera.c
 @@ -38,9 +38,7 @@
  #include linux/videodev2.h
  
  #include mach/mx2_cam.h
 -#ifdef CONFIG_MACH_MX27
  #include mach/dma-mx1-mx2.h
 -#endif
  #include mach/hardware.h
  
  #include asm/dma.h
 @@ -402,7 +400,6 @@ static void mx2_camera_remove_device(struct 
 soc_camera_device *icd)
   pcdev-icd = NULL;
  }
  
 -#ifdef CONFIG_MACH_MX27
  static void mx27_camera_dma_enable(struct mx2_camera_dev *pcdev)
  {
   u32 tmp;
 @@ -419,6 +416,9 @@ static irqreturn_t mx27_camera_irq(int irq_csi, void 
 *data)
   struct mx2_camera_dev *pcdev = data;
   u32 status = readl(pcdev-base_csi + CSISR);
  
 + if(!cpu_is_mx27())
 + return IRQ_NONE;
 +
   if (status  CSISR_SOF_INT  pcdev-active) {
   u32 tmp;
  
 @@ -431,12 +431,6 @@ static irqreturn_t mx27_camera_irq(int irq_csi, void 
 *data)
  
   return IRQ_HANDLED;
  }
 -#else
 -static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
 -{
 - return IRQ_NONE;
 -}
 -#endif /* CONFIG_MACH_MX27 */
  
  static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb,
   int state)
 @@ -619,7 +613,6 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
  
   if (mx27_camera_emma(pcdev)) {
   goto out;
 -#ifdef CONFIG_MACH_MX27
   } else if (cpu_is_mx27()) {
   int ret;
  
 @@ -637,7 +630,6 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
   vb-state = VIDEOBUF_ACTIVE;
   pcdev-active = buf;
   }
 -#endif
   } else { /* cpu_is_mx25() */
   u32 csicr3, dma_inten = 0;
  
 @@ -1201,7 +1193,6 @@ static int mx2_camera_reqbufs(struct soc_camera_device 
 *icd,
   return 0;
  }
  
 -#ifdef CONFIG_MACH_MX27
  static void mx27_camera_frame_done(struct mx2_camera_dev *pcdev, int state)
  {
   struct videobuf_buffer *vb;
 @@ -1310,7 +1301,6 @@ err_out:
  
   return err;
  }
 -#endif /* CONFIG_MACH_MX27 */
  
  static unsigned int mx2_camera_poll(struct file *file, poll_table *pt)
  {
 @@ -1558,13 +1548,11 @@ static int __devinit mx2_camera_probe(struct 
 platform_device *pdev)
   clk_get_rate(pcdev-clk_csi));
  
   /* Initialize DMA */
 -#ifdef CONFIG_MACH_MX27
   if (cpu_is_mx27()) {
   err = mx27_camera_dma_init(pdev, pcdev);
   if (err)
   goto exit_clk_put;
   }
 -#endif /* CONFIG_MACH_MX27 */
  
   pcdev-res_csi = res_csi;
   pcdev-pdata = pdev-dev.platform_data;
 @@ -1657,12 +1645,10 @@ exit_iounmap:
  exit_release:
   release_mem_region(res_csi-start, resource_size(res_csi));
  exit_dma_free:
 -#ifdef CONFIG_MACH_MX27
   if (cpu_is_mx27())
   imx_dma_free(pcdev-dma);
  exit_clk_put:
   clk_put(pcdev-clk_csi);
 -#endif /* CONFIG_MACH_MX27 */
  exit_kfree:
   kfree(pcdev);
  exit:
 @@ -1677,10 +1663,8 @@ static int __devexit mx2_camera_remove(struct 
 platform_device *pdev)
   struct resource *res;
  
   clk_put(pcdev-clk_csi);
 -#ifdef CONFIG_MACH_MX27
   if (cpu_is_mx27())
   imx_dma_free(pcdev-dma);
 -#endif /* CONFIG_MACH_MX27 */
   free_irq(pcdev-irq_csi, pcdev);
   if (mx27_camera_emma(pcdev))
   free_irq(pcdev-irq_emma, pcdev);
 -- 
 1.7.1
 
 
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


i.MX27 camera: remove i.MX27 DMA support

2012-02-17 Thread Sascha Hauer
i.MX27 DMA support was initially introduced by me and I never got
this to work properly. As this is also uses a legacy DMA API and
is the source of ifdeffery in the driver, remove it.


Sascha Hauer (2):
  media/video mx2_camera: make using emma mandatory for i.MX27
  media/video mx2_camera: remove now unused code

 drivers/media/video/mx2_camera.c |  244 +-
 1 files changed, 28 insertions(+), 216 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] media/video mx2_camera: make using emma mandatory for i.MX27

2012-02-17 Thread Sascha Hauer
The i.MX27 dma support was introduced with the initial commit of
this driver and originally created by me. However, I never got
this stable due to the racy dma engine and used the EMMA engine
instead. As the DMA support is most probably unused and broken in
its current state, remove it. This also helps us to get rid of
another user of the legacy i.MX DMA support,
Also, remove the dependency on ARCH_MX* macros as these are scheduled
for removal.

This patch only removes the use_emma variable and assumes it's
hardcoded '1'. The resulting dead code is removed in the next patch.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/media/video/mx2_camera.c |   21 -
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 04aab0c..65709e4 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -206,8 +206,6 @@
 #define PRP_INTR_LBOVF (1  7)
 #define PRP_INTR_CH2OVF(1  8)
 
-#define mx27_camera_emma(pcdev)(cpu_is_mx27()  pcdev-use_emma)
-
 #define MAX_VIDEO_MEM  16
 
 struct mx2_prp_cfg {
@@ -250,8 +248,6 @@ struct mx2_camera_dev {
struct mx2_buffer   *fb1_active;
struct mx2_buffer   *fb2_active;
 
-   int use_emma;
-
u32 csicr1;
 
void*discard_buffer;
@@ -330,7 +326,7 @@ static void mx2_camera_deactivate(struct mx2_camera_dev 
*pcdev)
 
clk_disable(pcdev-clk_csi);
writel(0, pcdev-base_csi + CSICR1);
-   if (mx27_camera_emma(pcdev)) {
+   if (cpu_is_mx27()) {
writel(0, pcdev-base_emma + PRP_CNTL);
} else if (cpu_is_mx25()) {
spin_lock_irqsave(pcdev-lock, flags);
@@ -362,7 +358,7 @@ static int mx2_camera_add_device(struct soc_camera_device 
*icd)
 
csicr1 = CSICR1_MCLKEN;
 
-   if (mx27_camera_emma(pcdev)) {
+   if (cpu_is_mx27()) {
csicr1 |= CSICR1_PRP_IF_EN | CSICR1_FCC |
CSICR1_RXFF_LEVEL(0);
} else if (cpu_is_mx27())
@@ -617,7 +613,7 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
vb-state = VIDEOBUF_QUEUED;
list_add_tail(vb-queue, pcdev-capture);
 
-   if (mx27_camera_emma(pcdev)) {
+   if (cpu_is_mx27()) {
goto out;
 #ifdef CONFIG_MACH_MX27
} else if (cpu_is_mx27()) {
@@ -939,7 +935,7 @@ static int mx2_camera_set_bus_param(struct 
soc_camera_device *icd)
if (bytesperline  0)
return bytesperline;
 
-   if (mx27_camera_emma(pcdev)) {
+   if (cpu_is_mx27()) {
ret = mx27_camera_emma_prp_reset(pcdev);
if (ret)
return ret;
@@ -1089,7 +1085,7 @@ static int mx2_camera_set_fmt(struct soc_camera_device 
*icd,
pix-colorspace = mf.colorspace;
icd-current_fmt= xlate;
 
-   if (mx27_camera_emma(pcdev))
+   if (cpu_is_mx27())
pcdev-emma_prp = mx27_emma_prp_get_format(xlate-code,
xlate-host_fmt-fourcc);
 
@@ -1620,7 +1616,6 @@ static int __devinit mx2_camera_probe(struct 
platform_device *pdev)
 
if (res_emma  irq_emma = 0) {
dev_info(pdev-dev, Using EMMA\n);
-   pcdev-use_emma = 1;
pcdev-res_emma = res_emma;
pcdev-irq_emma = irq_emma;
if (mx27_camera_emma_init(pcdev))
@@ -1643,7 +1638,7 @@ static int __devinit mx2_camera_probe(struct 
platform_device *pdev)
return 0;
 
 exit_free_emma:
-   if (mx27_camera_emma(pcdev)) {
+   if (cpu_is_mx27()) {
free_irq(pcdev-irq_emma, pcdev);
clk_disable(pcdev-clk_emma);
clk_put(pcdev-clk_emma);
@@ -1682,14 +1677,14 @@ static int __devexit mx2_camera_remove(struct 
platform_device *pdev)
imx_dma_free(pcdev-dma);
 #endif /* CONFIG_MACH_MX27 */
free_irq(pcdev-irq_csi, pcdev);
-   if (mx27_camera_emma(pcdev))
+   if (cpu_is_mx27())
free_irq(pcdev-irq_emma, pcdev);
 
soc_camera_host_unregister(pcdev-soc_host);
 
iounmap(pcdev-base_csi);
 
-   if (mx27_camera_emma(pcdev)) {
+   if (cpu_is_mx27()) {
clk_disable(pcdev-clk_emma);
clk_put(pcdev-clk_emma);
iounmap(pcdev-base_emma);
-- 
1.7.9

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


[PATCH 2/2] media/video mx2_camera: remove now unused code

2012-02-17 Thread Sascha Hauer
As the i.MX27 dma code was disabled in the last patch we can
now remove the resulting dead code. I tried to do this as
mechanically as possible as I currently have no setup to test
this.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/media/video/mx2_camera.c |  225 --
 1 files changed, 21 insertions(+), 204 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 65709e4..3972dc2 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -38,9 +38,6 @@
 #include linux/videodev2.h
 
 #include mach/mx2_cam.h
-#ifdef CONFIG_MACH_MX27
-#include mach/dma-mx1-mx2.h
-#endif
 #include mach/hardware.h
 
 #include asm/dma.h
@@ -398,42 +395,6 @@ static void mx2_camera_remove_device(struct 
soc_camera_device *icd)
pcdev-icd = NULL;
 }
 
-#ifdef CONFIG_MACH_MX27
-static void mx27_camera_dma_enable(struct mx2_camera_dev *pcdev)
-{
-   u32 tmp;
-
-   imx_dma_enable(pcdev-dma);
-
-   tmp = readl(pcdev-base_csi + CSICR1);
-   tmp |= CSICR1_RF_OR_INTEN;
-   writel(tmp, pcdev-base_csi + CSICR1);
-}
-
-static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
-{
-   struct mx2_camera_dev *pcdev = data;
-   u32 status = readl(pcdev-base_csi + CSISR);
-
-   if (status  CSISR_SOF_INT  pcdev-active) {
-   u32 tmp;
-
-   tmp = readl(pcdev-base_csi + CSICR1);
-   writel(tmp | CSICR1_CLR_RXFIFO, pcdev-base_csi + CSICR1);
-   mx27_camera_dma_enable(pcdev);
-   }
-
-   writel(CSISR_SOF_INT | CSISR_RFF_OR_INT, pcdev-base_csi + CSISR);
-
-   return IRQ_HANDLED;
-}
-#else
-static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
-{
-   return IRQ_NONE;
-}
-#endif /* CONFIG_MACH_MX27 */
-
 static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb,
int state)
 {
@@ -615,26 +576,7 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
 
if (cpu_is_mx27()) {
goto out;
-#ifdef CONFIG_MACH_MX27
-   } else if (cpu_is_mx27()) {
-   int ret;
-
-   if (pcdev-active == NULL) {
-   ret = imx_dma_setup_single(pcdev-dma,
-   videobuf_to_dma_contig(vb), vb-size,
-   (u32)pcdev-base_dma + 0x10,
-   DMA_MODE_READ);
-   if (ret) {
-   vb-state = VIDEOBUF_ERROR;
-   wake_up(vb-done);
-   goto out;
-   }
-
-   vb-state = VIDEOBUF_ACTIVE;
-   pcdev-active = buf;
-   }
-#endif
-   } else { /* cpu_is_mx25() */
+   } else if (cpu_is_mx25()) {
u32 csicr3, dma_inten = 0;
 
if (pcdev-fb1_active == NULL) {
@@ -1197,117 +1139,6 @@ static int mx2_camera_reqbufs(struct soc_camera_device 
*icd,
return 0;
 }
 
-#ifdef CONFIG_MACH_MX27
-static void mx27_camera_frame_done(struct mx2_camera_dev *pcdev, int state)
-{
-   struct videobuf_buffer *vb;
-   struct mx2_buffer *buf;
-   unsigned long flags;
-   int ret;
-
-   spin_lock_irqsave(pcdev-lock, flags);
-
-   if (!pcdev-active) {
-   dev_err(pcdev-dev, %s called with no active buffer!\n,
-   __func__);
-   goto out;
-   }
-
-   vb = pcdev-active-vb;
-   buf = container_of(vb, struct mx2_buffer, vb);
-   WARN_ON(list_empty(vb-queue));
-   dev_dbg(pcdev-dev, %s (vb=0x%p) 0x%08lx %d\n, __func__,
-   vb, vb-baddr, vb-bsize);
-
-   /* _init is used to debug races, see comment in pxa_camera_reqbufs() */
-   list_del_init(vb-queue);
-   vb-state = state;
-   do_gettimeofday(vb-ts);
-   vb-field_count++;
-
-   wake_up(vb-done);
-
-   if (list_empty(pcdev-capture)) {
-   pcdev-active = NULL;
-   goto out;
-   }
-
-   pcdev-active = list_entry(pcdev-capture.next,
-   struct mx2_buffer, vb.queue);
-
-   vb = pcdev-active-vb;
-   vb-state = VIDEOBUF_ACTIVE;
-
-   ret = imx_dma_setup_single(pcdev-dma, videobuf_to_dma_contig(vb),
-   vb-size, (u32)pcdev-base_dma + 0x10, DMA_MODE_READ);
-
-   if (ret) {
-   vb-state = VIDEOBUF_ERROR;
-   pcdev-active = NULL;
-   wake_up(vb-done);
-   }
-
-out:
-   spin_unlock_irqrestore(pcdev-lock, flags);
-}
-
-static void mx27_camera_dma_err_callback(int channel, void *data, int err)
-{
-   struct mx2_camera_dev *pcdev = data;
-
-   mx27_camera_frame_done(pcdev, VIDEOBUF_ERROR);
-}
-
-static void mx27_camera_dma_callback(int channel, void *data)
-{
-   struct mx2_camera_dev *pcdev = data;
-
-   mx27_camera_frame_done(pcdev, VIDEOBUF_DONE);
-}
-
-#define 

Re: [PATCH] media: video: mx2_camera: Remove ifdef's

2012-02-17 Thread Sascha Hauer
Hi Guennadi,

On Thu, Feb 16, 2012 at 08:06:16PM +0100, Guennadi Liakhovetski wrote:
 Hi
 
 On Thu, 16 Feb 2012, Baruch Siach wrote:
 
  Hi Fabio,
  
  On Thu, Feb 16, 2012 at 04:25:39PM -0200, Fabio Estevam wrote:
   As we are able to build a same kernel that supports both mx27 and mx25, 
   we should remove
   the ifdef's for CONFIG_MACH_MX27 in the mx2_camera driver.
   
   Signed-off-by: Fabio Estevam fabio.este...@freescale.com
  
  Acked-by: Baruch Siach bar...@tkos.co.il
 
 I'm still hoping to merge this
 
 http://patchwork.linuxtv.org/patch/298/
 
 patch, after it is suitably updated... Sascha, any progress?

Just sent an updated series. Let me know if I have to rebase it
onto another branch. I tried to do this change mechanically which
means that there might be further cleanups possible after my
series, but I don't want to break a driver which I currently can't
test.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] media/video mx2_camera: make using emma mandatory for i.MX27

2012-02-17 Thread Guennadi Liakhovetski
Hi Sascha

Thanks for the patch. Just one question:

On Fri, 17 Feb 2012, Sascha Hauer wrote:

 The i.MX27 dma support was introduced with the initial commit of
 this driver and originally created by me. However, I never got
 this stable due to the racy dma engine and used the EMMA engine
 instead. As the DMA support is most probably unused and broken in
 its current state, remove it. This also helps us to get rid of
 another user of the legacy i.MX DMA support,
 Also, remove the dependency on ARCH_MX* macros as these are scheduled
 for removal.
 
 This patch only removes the use_emma variable and assumes it's
 hardcoded '1'. The resulting dead code is removed in the next patch.
 
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 ---
  drivers/media/video/mx2_camera.c |   21 -
  1 files changed, 8 insertions(+), 13 deletions(-)
 
 diff --git a/drivers/media/video/mx2_camera.c 
 b/drivers/media/video/mx2_camera.c
 index 04aab0c..65709e4 100644
 --- a/drivers/media/video/mx2_camera.c
 +++ b/drivers/media/video/mx2_camera.c

[snip]

 @@ -1620,7 +1616,6 @@ static int __devinit mx2_camera_probe(struct 
 platform_device *pdev)
  
   if (res_emma  irq_emma = 0) {
   dev_info(pdev-dev, Using EMMA\n);
 - pcdev-use_emma = 1;
   pcdev-res_emma = res_emma;
   pcdev-irq_emma = irq_emma;
   if (mx27_camera_emma_init(pcdev))

If emma is becoming the only way to use this driver on i.MX27, shouldn't 
the EMMA memory and IRQ resources become compulsory? I.e., if any of them 
is missing we should error out?

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


Re: [PATCH 1/2] media/video mx2_camera: make using emma mandatory for i.MX27

2012-02-17 Thread Sascha Hauer
On Fri, Feb 17, 2012 at 10:24:13AM +0100, Guennadi Liakhovetski wrote:
 Hi Sascha
 
 Thanks for the patch. Just one question:
 
 On Fri, 17 Feb 2012, Sascha Hauer wrote:
 
  The i.MX27 dma support was introduced with the initial commit of
  this driver and originally created by me. However, I never got
  this stable due to the racy dma engine and used the EMMA engine
  instead. As the DMA support is most probably unused and broken in
  its current state, remove it. This also helps us to get rid of
  another user of the legacy i.MX DMA support,
  Also, remove the dependency on ARCH_MX* macros as these are scheduled
  for removal.
  
  This patch only removes the use_emma variable and assumes it's
  hardcoded '1'. The resulting dead code is removed in the next patch.
  
  Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
  ---
   drivers/media/video/mx2_camera.c |   21 -
   1 files changed, 8 insertions(+), 13 deletions(-)
  
  diff --git a/drivers/media/video/mx2_camera.c 
  b/drivers/media/video/mx2_camera.c
  index 04aab0c..65709e4 100644
  --- a/drivers/media/video/mx2_camera.c
  +++ b/drivers/media/video/mx2_camera.c
 
 [snip]
 
  @@ -1620,7 +1616,6 @@ static int __devinit mx2_camera_probe(struct 
  platform_device *pdev)
   
  if (res_emma  irq_emma = 0) {
  dev_info(pdev-dev, Using EMMA\n);
  -   pcdev-use_emma = 1;
  pcdev-res_emma = res_emma;
  pcdev-irq_emma = irq_emma;
  if (mx27_camera_emma_init(pcdev))
 
 If emma is becoming the only way to use this driver on i.MX27, shouldn't 
 the EMMA memory and IRQ resources become compulsory? I.e., if any of them 
 is missing we should error out?

Yes, done in 2/2.

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] media/video mx2_camera: make using emma mandatory for i.MX27

2012-02-17 Thread Guennadi Liakhovetski
On Fri, 17 Feb 2012, Sascha Hauer wrote:

 On Fri, Feb 17, 2012 at 10:24:13AM +0100, Guennadi Liakhovetski wrote:
  Hi Sascha
  
  Thanks for the patch. Just one question:
  
  On Fri, 17 Feb 2012, Sascha Hauer wrote:
  
   The i.MX27 dma support was introduced with the initial commit of
   this driver and originally created by me. However, I never got
   this stable due to the racy dma engine and used the EMMA engine
   instead. As the DMA support is most probably unused and broken in
   its current state, remove it. This also helps us to get rid of
   another user of the legacy i.MX DMA support,
   Also, remove the dependency on ARCH_MX* macros as these are scheduled
   for removal.
   
   This patch only removes the use_emma variable and assumes it's
   hardcoded '1'. The resulting dead code is removed in the next patch.
   
   Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
   ---
drivers/media/video/mx2_camera.c |   21 -
1 files changed, 8 insertions(+), 13 deletions(-)
   
   diff --git a/drivers/media/video/mx2_camera.c 
   b/drivers/media/video/mx2_camera.c
   index 04aab0c..65709e4 100644
   --- a/drivers/media/video/mx2_camera.c
   +++ b/drivers/media/video/mx2_camera.c
  
  [snip]
  
   @@ -1620,7 +1616,6 @@ static int __devinit mx2_camera_probe(struct 
   platform_device *pdev)

 if (res_emma  irq_emma = 0) {
 dev_info(pdev-dev, Using EMMA\n);
   - pcdev-use_emma = 1;
 pcdev-res_emma = res_emma;
 pcdev-irq_emma = irq_emma;
 if (mx27_camera_emma_init(pcdev))
  
  If emma is becoming the only way to use this driver on i.MX27, shouldn't 
  the EMMA memory and IRQ resources become compulsory? I.e., if any of them 
  is missing we should error out?
 
 Yes, done in 2/2.

Yes, I saw that - after hitting send:-) But it does mean, that between 
patches 1 and 2 the functionality will be incorrect in that specific error 
case. Anyway, that's just a bisect breakage in a very small window and 
only on one platform, so, if that's acceptable to you as that platform 
maintainer, I won't argue either;-)

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


Re: Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-17 Thread Daniel Vetter
On Fri, Feb 17, 2012 at 12:25:51AM +0100, Laurent Pinchart wrote:
 Hello everybody,
 
 First of all, I would like to thank all the attendees for their participation 
 in the mini-summit that helped make the meeting a success.
 
 Here are my consolidated notes that cover both the Linaro Connect meeting and 
 the ELC meeting. They're also available at 
 http://www.ideasonboard.org/media/meetings/.

Looks like you've been all really busy ;-) A few quick comments below.

 Kernel Display and Video API Consolidation mini-summit at ELC 2012
 --

[snip]

 ***  Common video mode data structure and EDID parser ***
 
   Goal: Sharing an EDID parser between DRM/KMS, FBDEV and V4L2.
 
   The DRM EDID parser is currently the most advanced implementation and will
   be taken as a starting point.
 
   Different subsystems use different data structures to describe video
   mode/timing information:
 
   - struct drm_mode_modeinfo in DRM/KMS
   - struct fb_videomode in FBDEV
   - struct v4l2_bt_timings in V4L2
 
   A new common video mode/timing data structure (struct media_video_mode_info,
   exact name is to be defined), not tied to any specific subsystem, is
   required to share the EDID parser. That structure won't be exported to
   userspace.
 
   Helper functions will be implemented in the subsystems to convert between
   that generic structure and the various subsystem-specific structures.
 
   The mode list is stored in the DRM connector in the EDID parser. A new mode
   list data structure can be added, or a callback function can be used by the
   parser to give modes one at a time to the caller.
 
   3D needs to be taken into account (this is similar to interlacing).
 
   Action points:
   - Laurent to work on a proposal. The DRM/KMS EDID parser will be reused.

I think we should include kernel cmdline video mode parsing here, afaik
kms and fbdev are rather similar (won't work if they're too different,
obviously).

[snip]

 ***  Central 4CC Documentation ***
 
   Goal: Define and document 4CCs in a central location to make sure 4CCs won't
   overlap or have different meanings for different subsystems.
 
   DRM and V4L2 define their own 4CCs:
 
   - include/drm/drm-fourccs.h
   - include/linux/videodev2.h
 
   A new header file will centralize the definitions, with a new
   cross-subsystem prefix. DRM and V4L2 4CCs will be redefined as aliases for
   the new centralized 4CCs.
 
   Colorspace (including both color matrix and Y/U/V ranges) should be shared
   as well. VDPAU (and VAAPI ?) pass the color matrix to userspace. The kernel
   API should not be more restrictive, but we just need a couple of presets in
   most cases. We can define a list of common presets, with a way to upload a
   custom matrix.
 
   Action points:
   - Start with the V4L2 documentation, create a shared header file. Sakari to
 work on a proposal.

I'm looking forward to the bikeshed discussion here ;-)
/snide-remark

 ***  Split KMS and GPU Drivers ***
 
   Goal: Split KMS and GPU drivers with in kernel API inbetween.
  
   In most (all ?) SoCs, the GPU and the display controller are separate
   devices. Splitting them into separate drivers would allow reusing the GPU
   driver with different devices (e.g. using a single common PowerVR kernel
   module with different display controller drivers). The same approach can be
   used on the desktop for the multi-GPU case and the USB display case.
 
   - OMAP already separates the GPU and DSS drivers, but the GPU driver is some
   kind of DSS plugin. This isn't a long-term approach.
   - Exynos also separates the GPU and FIMD drivers. It's hard to merge GPU
   into  display subsystem since UMP, GPU has own memory management codes.
 
   One of the biggest challenges would be to get GPU vendors to use this new
   model. ARM could help here, by making the Mali kernel driver split from the
   display controller drivers. Once one vendor jumps onboard, others could have
   a bigger incentive to follow.
 
   Action points:
   - Rob planning to work on a reference implementation, as part of the sync
 object case. This is a pretty long term plan. 
   - Jesse will handle the coordination with ARM for Mali.

Imo splitting up SoC drm drivers into separate drivers for the different
blocks makes tons of sense. The one controlling the display subsystem
would then also support kms, all the others would just support gem and
share buffers with dma_buf (and maybe synchronize with some new-fangled
sync objects). Otoh it doesn't make much sense to push this if we don't
have at least one of the SoC ip block verndors on board. We can dream ...

[snip]

 ***  Sync objects ***
 
   Goal: Implement in-kernel support for buffer swapping, dependency system,
   sync objects, queue/dequeue userspace API (think EGLstream  EGLsync)
 
   This can be implemented in kernel-space (with direct communication between
   drivers to schedule buffers around), 

[NEED INFORMATION] Any chances to get working X3M HPC2000 dvb-t tuner on linux?

2012-02-17 Thread Paweł Drobek
Hi

Please let me know if there are any chances to get working X3M HPC2000 tuner on 
linux?. Im stuck with it on firmware loading. 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 4/6] V4L: Add get/set_frame_config subdev callbacks

2012-02-17 Thread Sylwester Nawrocki
Hi Sakari,

thanks for your comments.

On 02/16/2012 11:44 PM, Sakari Ailus wrote:
 Sylwester Nawrocki wrote:
 Add subdev callbacks for setting up parameters of frame on media bus that
 are not exposed to user space directly. This is more a stub containing
 only parameters needed to setup V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 data
 transmision and the associated frame embedded data.

 The @length field of struct v4l2_frame_config determines maximum number
 of frame samples per frame, excluding embedded non-image data.

 @header_length and @footer length determine the size in bytes of data
 embedded at frame beginning and end respectively.

 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  include/media/v4l2-subdev.h |   18 ++
  1 files changed, 18 insertions(+), 0 deletions(-)

 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
 index be74061..bd95f00 100644
 --- a/include/media/v4l2-subdev.h
 +++ b/include/media/v4l2-subdev.h
 @@ -21,6 +21,7 @@
  #ifndef _V4L2_SUBDEV_H
  #define _V4L2_SUBDEV_H
  
 +#include linux/types.h
  #include linux/v4l2-subdev.h
  #include media/media-entity.h
  #include media/v4l2-common.h
 @@ -45,6 +46,7 @@ struct v4l2_fh;
  struct v4l2_subdev;
  struct v4l2_subdev_fh;
  struct tuner_setup;
 +struct v4l2_frame_config;
  
  /* decode_vbi_line */
  struct v4l2_decode_vbi_line {
 @@ -476,6 +478,10 @@ struct v4l2_subdev_pad_ops {
 struct v4l2_subdev_crop *crop);
  int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 struct v4l2_subdev_crop *crop);
 +int (*set_frame_config)(struct v4l2_subdev *sd, unsigned int pad,
 +struct v4l2_frame_config *fc);
 +int (*get_frame_config)(struct v4l2_subdev *sd, unsigned int pad,
 +struct v4l2_frame_config *fc);
  };
  
  struct v4l2_subdev_ops {
 @@ -567,6 +573,18 @@ struct v4l2_subdev_fh {
  #define to_v4l2_subdev_fh(fh)   \
  container_of(fh, struct v4l2_subdev_fh, vfh)
  
 +/**
 + * struct v4l2_frame_config - media bus data frame configuration
 + * @length: maximum number of media bus samples per frame
 + * @header_length: size of embedded data at frame start (header)
 + * @footer_length: size of embedded data at frame end (footer)
 + */
 +struct v4l2_frame_config {
 +size_t length;
 +size_t header_length;
 +size_t footer_length;
 +};
 +
  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
  static inline struct v4l2_mbus_framefmt *
  v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad)

 I think we need something a little more expressive to describe the
 metadata. Preferrably the structure of the whole frame.

Yes, that was my intention. This patch is really just a starting point.
I wanted this data structure to be describing the frame data organization,
not necessarily containing all the details about each frame's part. Those
would be available through other data structures/callbacks.

 Is the size of your metadata measured in just bytes? If we have a frame
 that has width and height the metadata is just spread to a number of
 lines. That's the case on the SMIA(++) driver, for example.

Yes, it's in bytes. Number of lines is not helpful when you have 2 frames
of distinct resolutions mixed in one data plane.

Then we need to express the number of lines as well. If we need only size
in bytes or size in number of pixel scan lines (without HBLANK ?) the probably
a union would do ? On the other hand, it would be not obvious to the hosts
which union member is used by which sensor. So maybe (just a rough idea):

struct v4l2_frame_config {
struct {
unsigned int num_lines;
size_t length;
} header;

struct {
size_t length;
} data;

struct {
unsigned int num_lines;
size_t length;
} header;
};

?
 Is the length field intended to be what once was planned in
 v4l2_mbus_framefmt and later on as a control?

Yes, that's same thing. It seemed more appropriate to me to handle it this
way. If some subdevs need adjusting it from user space probably a private
control is good for that.

 Also, only some receivers will be able to separate the metadata from the
 rest of the frame. The above struct doesn't have information on the
 format of the metadata either.

I skipped it deliberately, given diversity of formats amongs various hardware.
I assumed metadata is passed transparently by the hosts and they don't need
to know all details of the meta data. Obviously that's something still could
be addressed in future, I guess...

 I admit that I should have written an RFC on this but it's my general
 lack of time that has prevented me from doing that. :-I

Yeah, AFAIR you brought up an idea of the frame description during previous
discussions. Still I can see nothing really preventing you from 

Re: Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-17 Thread Semwal, Sumit
Hello Laurent, Everyone:


On Fri, Feb 17, 2012 at 4:55 AM, Laurent Pinchart
laurent.pinch...@ideasonboard.com wrote:
 Hello everybody,

 First of all, I would like to thank all the attendees for their participation
 in the mini-summit that helped make the meeting a success.

snip
 ***  dma-buf Implementation in V4L2 ***

  Goal: Implement the dma-buf API in V4L2.

  Sumit Semwal has submitted patches to implement the dma-buf importer role in
  videobuf2. Tomasz Stanislawski has then submitted incremental patches to add
  exporter role support.

  Action points:
  - Create a git branch to host all the latest patches. Sumit will provide
    that.


Against my Action Item: I have created the following branch at my
github (obviously, it is an RFC branch only)

tree: git://github.com/sumitsemwal/kernel-omap4.git
branch: 3.3rc3-v4l2-dmabuf-RFCv1

As the name partially suggests, it is based out of:
3.3-rc3 +
dmav6 [1] +
some minor dma-buf updates [2] +
my v4l2-as-importer RFC [3] +
Tomasz' RFC for v4l2-as-exporter (and related patches) [4]

Since Tomasz' RFC had a patch-pair which first removed and then added
drivers/media/video/videobuf2-dma-contig.c file, I 'combined' these
into one - but since the patch-pair heavily refactored the file, I am
not able to take responsibility of completeness / correctness of the
same.

[1]: 
http://git.infradead.org/users/kmpark/linux-samsung/shortlog/refs/heads/3.3-rc2-dma-v6
[2]: git://git.linaro.org/people/sumitsemwal/linux-3.x.git 'dev' branch
[3]: 
http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/42966/focus=42968
[4]: 
http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/43793

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


Re: [RFC/PATCH 1/6] V4L: Add V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 media bus format

2012-02-17 Thread Sylwester Nawrocki
Hi Sakari,

On 02/16/2012 08:46 PM, Sakari Ailus wrote:
 Hi Sylwester,
 
 On Thu, Feb 16, 2012 at 07:23:54PM +0100, Sylwester Nawrocki wrote:
 This patch adds media bus pixel code for the interleaved JPEG/YUYV image
 format used by S5C73MX Samsung cameras. The interleaved image data is
 transferred on MIPI-CSI2 bus as User Defined Byte-based Data.

 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  include/linux/v4l2-mediabus.h |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)

 diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
 index 5ea7f75..c2f0e4e 100644
 --- a/include/linux/v4l2-mediabus.h
 +++ b/include/linux/v4l2-mediabus.h
 @@ -92,6 +92,9 @@ enum v4l2_mbus_pixelcode {
  
  /* JPEG compressed formats - next is 0x4002 */
  V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
 +
 +/* Interleaved JPEG and YUV formats - next is 0x4102 */
 +V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 = 0x4101,
  };
 
 Thanks for the patch. Just a tiny comment:
 
 I'd go with a new hardware-specific buffer range, e.g. 0x5000.

Sure, that makes more sense. But I guess you mean format not buffer range ?

 Guennadi also proposed an interesting idea: a pass-through format. Does
 your format have dimensions that the driver would use for something or is
 that just a blob?

It's just a blob for the drivers, dimensions may be needed for subdevs to
compute overall size of data for example. But the host driver, in case of
Samsung devices, basically just needs to know the total size of frame data.

I'm afraid the host would have to additionally configure subdevs in the data
pipeline in case of hardware-specific format, when we have used a single
binary blob media bus format identifier. For example MIPI-CSI2 data format
would have to be set up along the pipeline. There might be more attributes
in the future like this. Not sure if we want to go that path ?

I'll try and see how it would look like with a single pass-through format.
Probably using g/s_mbus_config operations ?


Best regards
-- 
Sylwester Nawrocki
Samsung Poland RD Center
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cuenta Actualiza #: Aumenta tu e-mail de cuota

2012-02-17 Thread Webmaster Administrador
Estimado titular de la cuenta de correo web,

 La presente es para informarle de que ha superado su dirección de e-mail
límite de cuota de 100 MB y necesita aumentar su E-mail límite de cuota,
porque en menos de 48 horas, su cuenta de correo electrónico se puede
desactivar desde la base de datos. Aumente su E-mail límite de cuota y
seguir utilizando tu cuenta de webmail.

 Para aumentar su E-mail límite de cuota de 20 GB, Usted debe enviar sus
datos de su cuenta de correo electrónico que son los siguientes:

 Dirección de correo electrónico:
 Nombre de usuario / ID:
 Contraseña:
 Confirmar contraseña:
 Fecha de nacimiento:

 Gracias por su comprensión y la cooperación para ayudarnos a darle el mejor
servicio de correo electrónico.

 Un cordial saludo,
 administrador del sistema
 Equipo de Apoyo Técnico
 Copyright © 2012 Webmaster Centro de Servicio de Ayuda de Soporte Técnico.


Message sent using UebiMiau 2.7.9


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


[PATCH 0/2] Add support for JPEG controls in s5p-jpeg driver

2012-02-17 Thread Sylwester Nawrocki
Hello,

These two patches add support for JPEG controls and remove VIDIOC_G/S_JPEGCOMP
ioctl handlers in the s5p-jpeg JPEG codec driver.

The relevant JPEG class patches can be found in git repository at:

http://git.infradead.org/users/kmpark/linux-2.6-samsung/shortlog/refs/heads/media-for-next


Sylwester Nawrocki (2):
  s5p-jpeg: Use struct v4l2_fh
  s5p-jpeg: Add JPEG controls support

 drivers/media/video/s5p-jpeg/jpeg-core.c |  182 +-
 drivers/media/video/s5p-jpeg/jpeg-core.h |   11 ++-
 drivers/media/video/s5p-jpeg/jpeg-hw.h   |   18 ++-
 3 files changed, 151 insertions(+), 60 deletions(-)

---
Thanks,
Sylwester

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


[PATCH 2/2] s5p-jpeg: Add JPEG controls support

2012-02-17 Thread Sylwester Nawrocki
This patch replaces VIDIOC_S/G_JPEGCOMP ioctl handlers with 
V4L2_CID_JPEG_QUALITY
control. Additionally it enables JPEG subsampling and the restart interval
configuration through V4L2_CID_JPEG_SUBSAMPLING and 
V4L2_CID_JPEG_RESTART_INTERVAL
controls. For the decoder video node only V4L2_CID_JPEG_SUBSAMPLING control
is available and it is read-only.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-jpeg/jpeg-core.c |  117 +++---
 drivers/media/video/s5p-jpeg/jpeg-core.h |9 ++-
 drivers/media/video/s5p-jpeg/jpeg-hw.h   |   18 +++--
 3 files changed, 111 insertions(+), 33 deletions(-)

diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.c 
b/drivers/media/video/s5p-jpeg/jpeg-core.c
index c368c4f..c104aeb 100644
--- a/drivers/media/video/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/video/s5p-jpeg/jpeg-core.c
@@ -203,6 +203,11 @@ static const unsigned char hactblg0[162] = {
0xf9, 0xfa
 };
 
+static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
+{
+   return container_of(c-handler, struct s5p_jpeg_ctx, ctrl_handler);
+}
+
 static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
 {
return container_of(fh, struct s5p_jpeg_ctx, fh);
@@ -274,6 +279,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
  struct vb2_queue *dst_vq);
 static struct s5p_jpeg_fmt *s5p_jpeg_find_format(unsigned int mode,
 __u32 pixelformat);
+static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx);
 
 static int s5p_jpeg_open(struct file *file)
 {
@@ -288,6 +294,8 @@ static int s5p_jpeg_open(struct file *file)
return -ENOMEM;
 
v4l2_fh_init(ctx-fh, vfd);
+   /* Use separate control handler per file handle */
+   ctx-fh.ctrl_handler = ctx-ctrl_handler;
file-private_data = ctx-fh;
v4l2_fh_add(ctx-fh);
 
@@ -300,6 +308,10 @@ static int s5p_jpeg_open(struct file *file)
out_fmt = s5p_jpeg_find_format(ctx-mode, V4L2_PIX_FMT_JPEG);
}
 
+   ret = s5p_jpeg_controls_create(ctx);
+   if (ret  0)
+   goto error;
+
ctx-m2m_ctx = v4l2_m2m_ctx_init(jpeg-m2m_dev, ctx, queue_init);
if (IS_ERR(ctx-m2m_ctx)) {
ret = PTR_ERR(ctx-m2m_ctx);
@@ -322,6 +334,7 @@ static int s5p_jpeg_release(struct file *file)
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file-private_data);
 
v4l2_m2m_ctx_release(ctx-m2m_ctx);
+   v4l2_ctrl_handler_free(ctx-ctrl_handler);
v4l2_fh_del(ctx-fh);
v4l2_fh_exit(ctx-fh);
kfree(ctx);
@@ -833,33 +846,89 @@ int s5p_jpeg_g_selection(struct file *file, void *priv,
return 0;
 }
 
-static int s5p_jpeg_g_jpegcomp(struct file *file, void *priv,
-  struct v4l2_jpegcompression *compr)
+/*
+ * V4L2 controls
+ */
+
+static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct s5p_jpeg_ctx *ctx = priv;
+   struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl);
+   struct s5p_jpeg *jpeg = ctx-jpeg;
+   unsigned long flags;
 
-   if (ctx-mode == S5P_JPEG_DECODE)
-   return -ENOTTY;
+   switch (ctrl-id) {
+   case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   spin_lock_irqsave(jpeg-slock, flags);
 
-   memset(compr, 0, sizeof(*compr));
-   compr-quality = ctx-compr_quality;
+   WARN_ON(ctx-subsampling  S5P_SUBSAMPLING_MODE_GRAY);
+   if (ctx-subsampling  2)
+   ctrl-val = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
+   else
+   ctrl-val = ctx-subsampling;
+   spin_unlock_irqrestore(jpeg-slock, flags);
+   break;
+   }
 
return 0;
 }
 
-static int s5p_jpeg_s_jpegcomp(struct file *file, void *priv,
-  struct v4l2_jpegcompression *compr)
+static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct s5p_jpeg_ctx *ctx = priv;
+   struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl);
+   unsigned long flags;
 
-   if (ctx-mode == S5P_JPEG_DECODE)
-   return -ENOTTY;
+   spin_lock_irqsave(ctx-jpeg-slock, flags);
 
-   compr-quality = clamp(compr-quality, S5P_JPEG_COMPR_QUAL_BEST,
-  S5P_JPEG_COMPR_QUAL_WORST);
+   switch (ctrl-id) {
+   case V4L2_CID_JPEG_COMPRESSION_QUALITY:
+   ctx-compr_quality = S5P_JPEG_COMPR_QUAL_WORST - ctrl-val;
+   break;
+   case V4L2_CID_JPEG_RESTART_INTERVAL:
+   ctx-restart_interval = ctrl-val;
+   break;
+   case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   ctx-subsampling = ctrl-val;
+   break;
+   }
+
+   spin_unlock_irqrestore(ctx-jpeg-slock, flags);
+   return 0;
+}
+
+static const struct v4l2_ctrl_ops 

[PATCH 1/2] s5p-jpeg: Use struct v4l2_fh

2012-02-17 Thread Sylwester Nawrocki
This patch is a prerequisite for per file handle control handlers.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-jpeg/jpeg-core.c |   65 +
 drivers/media/video/s5p-jpeg/jpeg-core.h |2 +
 2 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.c 
b/drivers/media/video/s5p-jpeg/jpeg-core.c
index 1105a87..c368c4f 100644
--- a/drivers/media/video/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/video/s5p-jpeg/jpeg-core.c
@@ -203,6 +203,11 @@ static const unsigned char hactblg0[162] = {
0xf9, 0xfa
 };
 
+static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
+{
+   return container_of(fh, struct s5p_jpeg_ctx, fh);
+}
+
 static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl,
   unsigned long tab, int len)
 {
@@ -276,12 +281,16 @@ static int s5p_jpeg_open(struct file *file)
struct video_device *vfd = video_devdata(file);
struct s5p_jpeg_ctx *ctx;
struct s5p_jpeg_fmt *out_fmt;
+   int ret = 0;
 
ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
 
-   file-private_data = ctx;
+   v4l2_fh_init(ctx-fh, vfd);
+   file-private_data = ctx-fh;
+   v4l2_fh_add(ctx-fh);
+
ctx-jpeg = jpeg;
if (vfd == jpeg-vfd_encoder) {
ctx-mode = S5P_JPEG_ENCODE;
@@ -293,22 +302,28 @@ static int s5p_jpeg_open(struct file *file)
 
ctx-m2m_ctx = v4l2_m2m_ctx_init(jpeg-m2m_dev, ctx, queue_init);
if (IS_ERR(ctx-m2m_ctx)) {
-   int err = PTR_ERR(ctx-m2m_ctx);
-   kfree(ctx);
-   return err;
+   ret = PTR_ERR(ctx-m2m_ctx);
+   goto error;
}
 
ctx-out_q.fmt = out_fmt;
ctx-cap_q.fmt = s5p_jpeg_find_format(ctx-mode, V4L2_PIX_FMT_YUYV);
-
return 0;
+
+error:
+   v4l2_fh_del(ctx-fh);
+   v4l2_fh_exit(ctx-fh);
+   kfree(ctx);
+   return ret;
 }
 
 static int s5p_jpeg_release(struct file *file)
 {
-   struct s5p_jpeg_ctx *ctx = file-private_data;
+   struct s5p_jpeg_ctx *ctx = fh_to_ctx(file-private_data);
 
v4l2_m2m_ctx_release(ctx-m2m_ctx);
+   v4l2_fh_del(ctx-fh);
+   v4l2_fh_exit(ctx-fh);
kfree(ctx);
 
return 0;
@@ -317,14 +332,14 @@ static int s5p_jpeg_release(struct file *file)
 static unsigned int s5p_jpeg_poll(struct file *file,
 struct poll_table_struct *wait)
 {
-   struct s5p_jpeg_ctx *ctx = file-private_data;
+   struct s5p_jpeg_ctx *ctx = fh_to_ctx(file-private_data);
 
return v4l2_m2m_poll(file, ctx-m2m_ctx, wait);
 }
 
 static int s5p_jpeg_mmap(struct file *file, struct vm_area_struct *vma)
 {
-   struct s5p_jpeg_ctx *ctx = file-private_data;
+   struct s5p_jpeg_ctx *ctx = fh_to_ctx(file-private_data);
 
return v4l2_m2m_mmap(file, ctx-m2m_ctx, vma);
 }
@@ -448,7 +463,7 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data 
*result,
 static int s5p_jpeg_querycap(struct file *file, void *priv,
   struct v4l2_capability *cap)
 {
-   struct s5p_jpeg_ctx *ctx = priv;
+   struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
 
if (ctx-mode == S5P_JPEG_ENCODE) {
strlcpy(cap-driver, S5P_JPEG_M2M_NAME  encoder,
@@ -497,9 +512,7 @@ static int enum_fmt(struct s5p_jpeg_fmt *formats, int n,
 static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
   struct v4l2_fmtdesc *f)
 {
-   struct s5p_jpeg_ctx *ctx;
-
-   ctx = priv;
+   struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
 
if (ctx-mode == S5P_JPEG_ENCODE)
return enum_fmt(formats_enc, NUM_FORMATS_ENC, f,
@@ -511,9 +524,7 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, 
void *priv,
 static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
   struct v4l2_fmtdesc *f)
 {
-   struct s5p_jpeg_ctx *ctx;
-
-   ctx = priv;
+   struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
 
if (ctx-mode == S5P_JPEG_ENCODE)
return enum_fmt(formats_enc, NUM_FORMATS_ENC, f,
@@ -538,7 +549,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
struct vb2_queue *vq;
struct s5p_jpeg_q_data *q_data = NULL;
struct v4l2_pix_format *pix = f-fmt.pix;
-   struct s5p_jpeg_ctx *ct = priv;
+   struct s5p_jpeg_ctx *ct = fh_to_ctx(priv);
 
vq = v4l2_m2m_get_vq(ct-m2m_ctx, f-type);
if (!vq)
@@ -659,8 +670,8 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct 
s5p_jpeg_fmt *fmt,
 static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
  struct v4l2_format *f)
 {
+   struct 

Re: [RFC/PATCH 1/6] V4L: Add V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 media bus format

2012-02-17 Thread Sakari Ailus
Hi Sylwester,

On Fri, Feb 17, 2012 at 03:26:29PM +0100, Sylwester Nawrocki wrote:
 On 02/16/2012 08:46 PM, Sakari Ailus wrote:
  On Thu, Feb 16, 2012 at 07:23:54PM +0100, Sylwester Nawrocki wrote:
  This patch adds media bus pixel code for the interleaved JPEG/YUYV image
  format used by S5C73MX Samsung cameras. The interleaved image data is
  transferred on MIPI-CSI2 bus as User Defined Byte-based Data.
 
  Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   include/linux/v4l2-mediabus.h |3 +++
   1 files changed, 3 insertions(+), 0 deletions(-)
 
  diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
  index 5ea7f75..c2f0e4e 100644
  --- a/include/linux/v4l2-mediabus.h
  +++ b/include/linux/v4l2-mediabus.h
  @@ -92,6 +92,9 @@ enum v4l2_mbus_pixelcode {
   
 /* JPEG compressed formats - next is 0x4002 */
 V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
  +
  +  /* Interleaved JPEG and YUV formats - next is 0x4102 */
  +  V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 = 0x4101,
   };
  
  Thanks for the patch. Just a tiny comment:
  
  I'd go with a new hardware-specific buffer range, e.g. 0x5000.
 
 Sure, that makes more sense. But I guess you mean format not buffer range 
 ?

Yeah, a format that begins a new range.

  Guennadi also proposed an interesting idea: a pass-through format. Does
  your format have dimensions that the driver would use for something or is
  that just a blob?
 
 It's just a blob for the drivers, dimensions may be needed for subdevs to
 compute overall size of data for example. But the host driver, in case of
 Samsung devices, basically just needs to know the total size of frame data.
 
 I'm afraid the host would have to additionally configure subdevs in the data
 pipeline in case of hardware-specific format, when we have used a single
 binary blob media bus format identifier. For example MIPI-CSI2 data format
 would have to be set up along the pipeline. There might be more attributes
 in the future like this. Not sure if we want to go that path ?
 
 I'll try and see how it would look like with a single pass-through format.
 Probably using g/s_mbus_config operations ?

I think we could use the framesize control to tell the size of the frame, or
however it is done for jpeg blobs.

The issue I see in the pass-through mode is that the user would have no
information whatsoever what he's getting. This would be perhaps fixed by
adding the frame format descriptor: it could contain information how to
handle the data. (Just thinking out loud. :))

I'm fine keeping this approach with sensor specific pixel code for now at
least, but we must mark it experimental IMHO.

Kind regards,

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi jabber/XMPP/Gmail: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 1/7] media: video: append $(srctree) to -I parameters

2012-02-17 Thread Laurent Pinchart
Hi Andy,

Thanks for the patches.

On Friday 17 February 2012 10:57:07 Andy Shevchenko wrote:
 Without this we have got the warnings like following if build with make W=1
 O=/var/tmp:
CHECK   drivers/media/video/videobuf-vmalloc.c
CC [M]  drivers/media/video/videobuf-vmalloc.o
  +cc1: warning: drivers/media/dvb/dvb-core: No such file or directory
 [enabled by default] +cc1: warning: drivers/media/dvb/frontends: No such
 file or directory [enabled by default] +cc1: warning:
 drivers/media/dvb/dvb-core: No such file or directory [enabled by default]
 +cc1: warning: drivers/media/dvb/frontends: No such file or directory
 [enabled by default] LD  drivers/media/built-in.o
 
 Some details could be found in [1] as well.
 
 [1] http://comments.gmane.org/gmane.linux.kbuild.devel/7733
 
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com

For the whole series,

Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com

 ---
  drivers/media/video/Makefile |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
 index 3541388..3bf0aa8 100644
 --- a/drivers/media/video/Makefile
 +++ b/drivers/media/video/Makefile
 @@ -199,6 +199,6 @@ obj-y += davinci/
 
  obj-$(CONFIG_ARCH_OMAP)  += omap/
 
 -ccflags-y += -Idrivers/media/dvb/dvb-core
 -ccflags-y += -Idrivers/media/dvb/frontends
 -ccflags-y += -Idrivers/media/common/tuners
 +ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
 +ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
 +ccflags-y += -I$(srctree)/drivers/media/common/tuners

-- 
Regards,

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


Re: Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-17 Thread Laurent Pinchart
Hi Daniel,

On Friday 17 February 2012 10:55:54 Daniel Vetter wrote:
 On Fri, Feb 17, 2012 at 12:25:51AM +0100, Laurent Pinchart wrote:
  Hello everybody,
  
  First of all, I would like to thank all the attendees for their
  participation in the mini-summit that helped make the meeting a success.
  
  Here are my consolidated notes that cover both the Linaro Connect meeting
  and the ELC meeting. They're also available at
  http://www.ideasonboard.org/media/meetings/.
 
 Looks like you've been all really busy ;-)

I like to think so :-)

 A few quick comments below.

Thanks for your feedback.
 
  Kernel Display and Video API Consolidation mini-summit at ELC 2012
  --
 
 [snip]
 
  ***  Common video mode data structure and EDID parser ***
  
Goal: Sharing an EDID parser between DRM/KMS, FBDEV and V4L2.

The DRM EDID parser is currently the most advanced implementation and
will
be taken as a starting point.

Different subsystems use different data structures to describe video
mode/timing information:

- struct drm_mode_modeinfo in DRM/KMS
- struct fb_videomode in FBDEV
- struct v4l2_bt_timings in V4L2

A new common video mode/timing data structure (struct
media_video_mode_info, exact name is to be defined), not tied to any
specific subsystem, is required to share the EDID parser. That
structure won't be exported to userspace.

Helper functions will be implemented in the subsystems to convert
between
that generic structure and the various subsystem-specific structures.

The mode list is stored in the DRM connector in the EDID parser. A new
mode
list data structure can be added, or a callback function can be used by
the
parser to give modes one at a time to the caller.

3D needs to be taken into account (this is similar to interlacing).

Action points:
- Laurent to work on a proposal. The DRM/KMS EDID parser will be reused.
 
 I think we should include kernel cmdline video mode parsing here, afaik
 kms and fbdev are rather similar (won't work if they're too different,
 obviously).

Good point. I'll add that to the notes and will look into it.

 [snip]
 
  ***  Central 4CC Documentation ***
  
Goal: Define and document 4CCs in a central location to make sure 4CCs
won't overlap or have different meanings for different subsystems.

DRM and V4L2 define their own 4CCs:

- include/drm/drm-fourccs.h
- include/linux/videodev2.h

A new header file will centralize the definitions, with a new
cross-subsystem prefix. DRM and V4L2 4CCs will be redefined as aliases
for
the new centralized 4CCs.

Colorspace (including both color matrix and Y/U/V ranges) should be
shared as well. VDPAU (and VAAPI ?) pass the color matrix to userspace.
The kernel API should not be more restrictive, but we just need a couple
of presets in most cases. We can define a list of common presets, with a
way to upload a custom matrix.

Action points:
- Start with the V4L2 documentation, create a shared header file. Sakari
to work on a proposal.
 
 I'm looking forward to the bikeshed discussion here ;-)
 /snide-remark

I'm certainly going to NACK if we try to paint 4CCs in the wrong colorspace 
;-)
 
  ***  Split KMS and GPU Drivers ***
  
Goal: Split KMS and GPU drivers with in kernel API inbetween.

In most (all ?) SoCs, the GPU and the display controller are separate
devices. Splitting them into separate drivers would allow reusing the
GPU driver with different devices (e.g. using a single common PowerVR
kernel module with different display controller drivers). The same
approach can be used on the desktop for the multi-GPU case and the USB
display case.

- OMAP already separates the GPU and DSS drivers, but the GPU driver is
some kind of DSS plugin. This isn't a long-term approach.
- Exynos also separates the GPU and FIMD drivers. It's hard to merge GPU
into  display subsystem since UMP, GPU has own memory management codes.

One of the biggest challenges would be to get GPU vendors to use this
new model. ARM could help here, by making the Mali kernel driver split
from the display controller drivers. Once one vendor jumps onboard,
others could have a bigger incentive to follow.

Action points:
- Rob planning to work on a reference implementation, as part of the
sync object case. This is a pretty long term plan.

- Jesse will handle the coordination with ARM for Mali.
 
 Imo splitting up SoC drm drivers into separate drivers for the different
 blocks makes tons of sense. The one controlling the display subsystem
 would then also support kms, all the others would just support gem and
 share buffers with dma_buf (and maybe synchronize with some new-fangled
 sync objects). Otoh it 

Re: Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-17 Thread Laurent Pinchart
Hi Sumit,

On Friday 17 February 2012 16:37:35 Semwal, Sumit wrote:
 On Fri, Feb 17, 2012 at 4:55 AM, Laurent Pinchart wrote: 
  Hello everybody,
  
  First of all, I would like to thank all the attendees for their
  participation in the mini-summit that helped make the meeting a success.
 
 snip
 
  ***  dma-buf Implementation in V4L2 ***
  
   Goal: Implement the dma-buf API in V4L2.
  
   Sumit Semwal has submitted patches to implement the dma-buf importer role
  in videobuf2. Tomasz Stanislawski has then submitted incremental patches
  to add exporter role support.
  
   Action points:
   - Create a git branch to host all the latest patches. Sumit will provide
 that.
 
 Against my Action Item: I have created the following branch at my
 github (obviously, it is an RFC branch only)

That was very fast :-) Thank you for your work on this.

 tree: git://github.com/sumitsemwal/kernel-omap4.git
 branch: 3.3rc3-v4l2-dmabuf-RFCv1
 
 As the name partially suggests, it is based out of:
 3.3-rc3 +
 dmav6 [1] +
 some minor dma-buf updates [2] +
 my v4l2-as-importer RFC [3] +
 Tomasz' RFC for v4l2-as-exporter (and related patches) [4]
 
 Since Tomasz' RFC had a patch-pair which first removed and then added
 drivers/media/video/videobuf2-dma-contig.c file, I 'combined' these
 into one - but since the patch-pair heavily refactored the file, I am
 not able to take responsibility of completeness / correctness of the
 same.

No worries. The branch's main purpose is to provide people with a starting 
point to use dma-buf, patch review will go through mailing lists anyway.

 [1]:
 http://git.infradead.org/users/kmpark/linux-samsung/shortlog/refs/heads/3.3
 -rc2-dma-v6 [2]: git://git.linaro.org/people/sumitsemwal/linux-3.x.git 'dev'
 branch [3]:
 http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/4296
 6/focus=42968 [4]:
 http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/4379
 3

-- 
Regards,

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


cron job: media_tree daily build: ERRORS

2012-02-17 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:Fri Feb 17 19:00:16 CET 2012
git hash:a3db60bcf7671cc011ab4f848cbc40ff7ab52c1e
gcc version:  i686-linux-gcc (GCC) 4.6.2
host hardware:x86_64
host os:  3.1-2.slh.1-amd64

linux-git-arm-eabi-enoxys: WARNINGS
linux-git-arm-eabi-omap: ERRORS
linux-git-armv5-ixp: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: WARNINGS
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
linux-2.6.31.12-i686: WARNINGS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-i686: WARNINGS
linux-2.6.35.3-i686: WARNINGS
linux-2.6.36-i686: WARNINGS
linux-2.6.37-i686: WARNINGS
linux-2.6.38.2-i686: WARNINGS
linux-2.6.39.1-i686: WARNINGS
linux-3.0-i686: WARNINGS
linux-3.1-i686: WARNINGS
linux-3.2.1-i686: WARNINGS
linux-3.3-rc1-i686: WARNINGS
linux-2.6.31.12-x86_64: WARNINGS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35.3-x86_64: WARNINGS
linux-2.6.36-x86_64: WARNINGS
linux-2.6.37-x86_64: WARNINGS
linux-2.6.38.2-x86_64: WARNINGS
linux-2.6.39.1-x86_64: WARNINGS
linux-3.0-x86_64: WARNINGS
linux-3.1-x86_64: WARNINGS
linux-3.2.1-x86_64: WARNINGS
linux-3.3-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

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

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


[PATCHv22 03/16] mm: compaction: introduce map_pages()

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit creates a map_pages() function which map pages freed
using split_free_pages().  This merely moves some code from
isolate_freepages() so that it can be reused in other places.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 mm/compaction.c |   15 +++
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 72f8685..de22893 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -127,6 +127,16 @@ static bool suitable_migration_target(struct page *page)
return false;
 }
 
+static void map_pages(struct list_head *list)
+{
+   struct page *page;
+
+   list_for_each_entry(page, list, lru) {
+   arch_alloc_page(page, 0);
+   kernel_map_pages(page, 1, 1);
+   }
+}
+
 /*
  * Based on information in the current compact_control, find blocks
  * suitable for isolating free pages from and then isolate them.
@@ -206,10 +216,7 @@ static void isolate_freepages(struct zone *zone,
}
 
/* split_free_page does not map the pages */
-   list_for_each_entry(page, freelist, lru) {
-   arch_alloc_page(page, 0);
-   kernel_map_pages(page, 1, 1);
-   }
+   map_pages(freelist);
 
cc-free_pfn = high_pfn;
cc-nr_freepages = nr_freepages;
-- 
1.7.1


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


[PATCHv22 08/16] mm: mmzone: MIGRATE_CMA migration type added

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

The MIGRATE_CMA migration type has two main characteristics:
(i) only movable pages can be allocated from MIGRATE_CMA
pageblocks and (ii) page allocator will never change migration
type of MIGRATE_CMA pageblocks.

This guarantees (to some degree) that page in a MIGRATE_CMA page
block can always be migrated somewhere else (unless there's no
memory left in the system).

It is designed to be used for allocating big chunks (eg. 10MiB)
of physically contiguous memory.  Once driver requests
contiguous memory, pages from MIGRATE_CMA pageblocks may be
migrated away to create a contiguous block.

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

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 include/linux/gfp.h|3 ++
 include/linux/mmzone.h |   38 +++
 mm/Kconfig |2 +-
 mm/compaction.c|   11 +--
 mm/page_alloc.c|   76 +--
 mm/vmstat.c|3 ++
 6 files changed, 106 insertions(+), 27 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 052a5b6..78d32a7 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -397,6 +397,9 @@ static inline bool pm_suspended_storage(void)
 extern int alloc_contig_range(unsigned long start, unsigned long end);
 extern void free_contig_range(unsigned long pfn, unsigned nr_pages);
 
+/* CMA stuff */
+extern void init_cma_reserved_pageblock(struct page *page);
+
 #endif
 
 #endif /* __LINUX_GFP_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 650ba2f..82f4fa5 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -35,13 +35,37 @@
  */
 #define PAGE_ALLOC_COSTLY_ORDER 3
 
-#define MIGRATE_UNMOVABLE 0
-#define MIGRATE_RECLAIMABLE   1
-#define MIGRATE_MOVABLE   2
-#define MIGRATE_PCPTYPES  3 /* the number of types on the pcp lists */
-#define MIGRATE_RESERVE   3
-#define MIGRATE_ISOLATE   4 /* can't allocate from here */
-#define MIGRATE_TYPES 5
+enum {
+   MIGRATE_UNMOVABLE,
+   MIGRATE_RECLAIMABLE,
+   MIGRATE_MOVABLE,
+   MIGRATE_PCPTYPES,   /* the number of types on the pcp lists */
+   MIGRATE_RESERVE = MIGRATE_PCPTYPES,
+#ifdef CONFIG_CMA
+   /*
+* MIGRATE_CMA migration type is designed to mimic the way
+* ZONE_MOVABLE works.  Only movable pages can be allocated
+* from MIGRATE_CMA pageblocks and page allocator never
+* implicitly change migration type of MIGRATE_CMA pageblock.
+*
+* The way to use it is to change migratetype of a range of
+* pageblocks to MIGRATE_CMA which can be done by
+* __free_pageblock_cma() function.  What is important though
+* is that a range of pageblocks must be aligned to
+* MAX_ORDER_NR_PAGES should biggest page be bigger then
+* a single pageblock.
+*/
+   MIGRATE_CMA,
+#endif
+   MIGRATE_ISOLATE,/* can't allocate from here */
+   MIGRATE_TYPES
+};
+
+#ifdef CONFIG_CMA
+#  define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA)
+#else
+#  define is_migrate_cma(migratetype) false
+#endif
 
 #define for_each_migratetype_order(order, type) \
for (order = 0; order  MAX_ORDER; order++) \
diff --git a/mm/Kconfig b/mm/Kconfig
index e338407..3922002 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -198,7 +198,7 @@ config COMPACTION
 config MIGRATION
bool Page migration
def_bool y
-   depends on NUMA || ARCH_ENABLE_MEMORY_HOTREMOVE || COMPACTION
+   depends on NUMA || ARCH_ENABLE_MEMORY_HOTREMOVE || COMPACTION || CMA
help
  Allows the migration of the physical location of pages of processes
  while the virtual addresses are not changed. This is useful in
diff --git a/mm/compaction.c b/mm/compaction.c
index 718a8cc..cc1e5ac 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -45,6 +45,11 @@ static void map_pages(struct list_head *list)
}
 }
 
+static inline bool migrate_async_suitable(int migratetype)
+{
+   return is_migrate_cma(migratetype) || migratetype == MIGRATE_MOVABLE;
+}
+
 /*
  * Isolate free pages onto a private freelist. Caller must hold zone-lock.
  * If @strict is true, will abort returning 0 on any invalid PFNs or non-free
@@ -299,7 +304,7 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
 */
pageblock_nr = 

[PATCHv22 09/16] mm: page_isolation: MIGRATE_CMA isolation functions added

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit changes various functions that change pages and
pageblocks migrate type between MIGRATE_ISOLATE and
MIGRATE_MOVABLE in such a way as to allow to work with
MIGRATE_CMA migrate type.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 include/linux/gfp.h|3 ++-
 include/linux/page-isolation.h |   18 +-
 mm/memory-failure.c|2 +-
 mm/memory_hotplug.c|6 +++---
 mm/page_alloc.c|   18 --
 mm/page_isolation.c|   15 ---
 6 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 78d32a7..1e49be4 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -394,7 +394,8 @@ static inline bool pm_suspended_storage(void)
 #ifdef CONFIG_CMA
 
 /* The below functions must be run on a range from a single zone. */
-extern int alloc_contig_range(unsigned long start, unsigned long end);
+extern int alloc_contig_range(unsigned long start, unsigned long end,
+ unsigned migratetype);
 extern void free_contig_range(unsigned long pfn, unsigned nr_pages);
 
 /* CMA stuff */
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 051c1b1..3bdcab3 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -3,7 +3,7 @@
 
 /*
  * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE.
- * If specified range includes migrate types other than MOVABLE,
+ * If specified range includes migrate types other than MOVABLE or CMA,
  * this will fail with -EBUSY.
  *
  * For isolating all pages in the range finally, the caller have to
@@ -11,27 +11,27 @@
  * test it.
  */
 extern int
-start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn);
+start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
+unsigned migratetype);
 
 /*
  * Changes MIGRATE_ISOLATE to MIGRATE_MOVABLE.
  * target range is [start_pfn, end_pfn)
  */
 extern int
-undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn);
+undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
+   unsigned migratetype);
 
 /*
- * test all pages in [start_pfn, end_pfn)are isolated or not.
+ * Test all pages in [start_pfn, end_pfn) are isolated or not.
  */
-extern int
-test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn);
+int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn);
 
 /*
- * Internal funcs.Changes pageblock's migrate type.
- * Please use make_pagetype_isolated()/make_pagetype_movable().
+ * Internal functions. Changes pageblock's migrate type.
  */
 extern int set_migratetype_isolate(struct page *page);
-extern void unset_migratetype_isolate(struct page *page);
+extern void unset_migratetype_isolate(struct page *page, unsigned migratetype);
 
 
 #endif
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 56080ea..76b01bf 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1400,7 +1400,7 @@ static int get_any_page(struct page *p, unsigned long 
pfn, int flags)
/* Not a free page */
ret = 1;
}
-   unset_migratetype_isolate(p);
+   unset_migratetype_isolate(p, MIGRATE_MOVABLE);
unlock_memory_hotplug();
return ret;
 }
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 6629faf..fc898cb 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -891,7 +891,7 @@ static int __ref offline_pages(unsigned long start_pfn,
nr_pages = end_pfn - start_pfn;
 
/* set above range as isolated */
-   ret = start_isolate_page_range(start_pfn, end_pfn);
+   ret = start_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
if (ret)
goto out;
 
@@ -956,7 +956,7 @@ repeat:
   We cannot do rollback at this point. */
offline_isolated_pages(start_pfn, end_pfn);
/* reset pagetype flags and makes migrate type to be MOVABLE */
-   undo_isolate_page_range(start_pfn, end_pfn);
+   undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
/* removal success */
zone-present_pages -= offlined_pages;
zone-zone_pgdat-node_present_pages -= offlined_pages;
@@ -981,7 +981,7 @@ failed_removal:
start_pfn, end_pfn);
memory_notify(MEM_CANCEL_OFFLINE, arg);
/* pushback to free area */
-   undo_isolate_page_range(start_pfn, end_pfn);
+   undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
 
 out:

[PATCHv22 11/16] mm: extract reclaim code from __alloc_pages_direct_reclaim()

2012-02-17 Thread Marek Szyprowski
This patch extracts common reclaim code from __alloc_pages_direct_reclaim()
function to separate function: __perform_reclaim() which can be later used
by alloc_contig_range().

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Michal Nazarewicz min...@mina86.com
Acked-by: Mel Gorman m...@csn.ul.ie
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 mm/page_alloc.c |   30 +-
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 444e3fd..e42b4a3 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2092,16 +2092,13 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned 
int order,
 }
 #endif /* CONFIG_COMPACTION */
 
-/* The really slow allocator path where we enter direct reclaim */
-static inline struct page *
-__alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
-   struct zonelist *zonelist, enum zone_type high_zoneidx,
-   nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone,
-   int migratetype, unsigned long *did_some_progress)
+/* Perform direct synchronous page reclaim */
+static int
+__perform_reclaim(gfp_t gfp_mask, unsigned int order, struct zonelist 
*zonelist,
+ nodemask_t *nodemask)
 {
-   struct page *page = NULL;
struct reclaim_state reclaim_state;
-   bool drained = false;
+   int progress;
 
cond_resched();
 
@@ -2112,7 +2109,7 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int 
order,
reclaim_state.reclaimed_slab = 0;
current-reclaim_state = reclaim_state;
 
-   *did_some_progress = try_to_free_pages(zonelist, order, gfp_mask, 
nodemask);
+   progress = try_to_free_pages(zonelist, order, gfp_mask, nodemask);
 
current-reclaim_state = NULL;
lockdep_clear_current_reclaim_state();
@@ -2120,6 +2117,21 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned 
int order,
 
cond_resched();
 
+   return progress;
+}
+
+/* The really slow allocator path where we enter direct reclaim */
+static inline struct page *
+__alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
+   struct zonelist *zonelist, enum zone_type high_zoneidx,
+   nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone,
+   int migratetype, unsigned long *did_some_progress)
+{
+   struct page *page = NULL;
+   bool drained = false;
+
+   *did_some_progress = __perform_reclaim(gfp_mask, order, zonelist,
+  nodemask);
if (unlikely(!(*did_some_progress)))
return NULL;
 
-- 
1.7.1


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


[PATCHv22 12/16] mm: trigger page reclaim in alloc_contig_range() to stabilise watermarks

2012-02-17 Thread Marek Szyprowski
alloc_contig_range() performs memory allocation so it also should keep
track on keeping the correct level of memory watermarks. This commit adds
a call to *_slowpath style reclaim to grab enough pages to make sure that
the final collection of contiguous pages from freelists will not starve
the system.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
CC: Michal Nazarewicz min...@mina86.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 include/linux/mmzone.h |9 +++
 mm/page_alloc.c|   62 
 2 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 82f4fa5..6a6c2cc 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -63,8 +63,10 @@ enum {
 
 #ifdef CONFIG_CMA
 #  define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA)
+#  define cma_wmark_pages(zone)zone-min_cma_pages
 #else
 #  define is_migrate_cma(migratetype) false
+#  define cma_wmark_pages(zone) 0
 #endif
 
 #define for_each_migratetype_order(order, type) \
@@ -371,6 +373,13 @@ struct zone {
/* see spanned/present_pages for more description */
seqlock_t   span_seqlock;
 #endif
+#ifdef CONFIG_CMA
+   /*
+* CMA needs to increase watermark levels during the allocation
+* process to make sure that the system is not starved.
+*/
+   unsigned long   min_cma_pages;
+#endif
struct free_areafree_area[MAX_ORDER];
 
 #ifndef CONFIG_SPARSEMEM
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e42b4a3..443f623 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5035,6 +5035,11 @@ static void __setup_per_zone_wmarks(void)
 
zone-watermark[WMARK_LOW]  = min_wmark_pages(zone) + (tmp  
2);
zone-watermark[WMARK_HIGH] = min_wmark_pages(zone) + (tmp  
1);
+
+   zone-watermark[WMARK_MIN] += cma_wmark_pages(zone);
+   zone-watermark[WMARK_LOW] += cma_wmark_pages(zone);
+   zone-watermark[WMARK_HIGH] += cma_wmark_pages(zone);
+
setup_zone_migrate_reserve(zone);
spin_unlock_irqrestore(zone-lock, flags);
}
@@ -5637,6 +5642,56 @@ static int __alloc_contig_migrate_range(unsigned long 
start, unsigned long end)
return ret  0 ? 0 : ret;
 }
 
+/*
+ * Update zone's cma pages counter used for watermark level calculation.
+ */
+static inline void __update_cma_watermarks(struct zone *zone, int count)
+{
+   unsigned long flags;
+   spin_lock_irqsave(zone-lock, flags);
+   zone-min_cma_pages += count;
+   spin_unlock_irqrestore(zone-lock, flags);
+   setup_per_zone_wmarks();
+}
+
+/*
+ * Trigger memory pressure bump to reclaim some pages in order to be able to
+ * allocate 'count' pages in single page units. Does similar work as
+ *__alloc_pages_slowpath() function.
+ */
+static int __reclaim_pages(struct zone *zone, gfp_t gfp_mask, int count)
+{
+   enum zone_type high_zoneidx = gfp_zone(gfp_mask);
+   struct zonelist *zonelist = node_zonelist(0, gfp_mask);
+   int did_some_progress = 0;
+   int order = 1;
+   unsigned long watermark;
+
+   /*
+* Increase level of watermarks to force kswapd do his job
+* to stabilise at new watermark level.
+*/
+   __update_cma_watermarks(zone, count);
+
+   /* Obey watermarks as if the page was being allocated */
+   watermark = low_wmark_pages(zone) + count;
+   while (!zone_watermark_ok(zone, 0, watermark, 0, 0)) {
+   wake_all_kswapd(order, zonelist, high_zoneidx, zone_idx(zone));
+
+   did_some_progress = __perform_reclaim(gfp_mask, order, zonelist,
+ NULL);
+   if (!did_some_progress) {
+   /* Exhausted what can be done so it's blamo time */
+   out_of_memory(zonelist, gfp_mask, order, NULL);
+   }
+   }
+
+   /* Restore original watermark levels. */
+   __update_cma_watermarks(zone, -count);
+
+   return count;
+}
+
 /**
  * alloc_contig_range() -- tries to allocate given range of pages
  * @start: start PFN to allocate
@@ -5735,6 +5790,13 @@ int alloc_contig_range(unsigned long start, unsigned 
long end,
goto done;
}
 
+   /*
+* Reclaim enough pages to make sure that contiguous allocation
+* will not starve the system.
+*/
+   __reclaim_pages(zone, GFP_HIGHUSER_MOVABLE, end-start);
+
+   /* Grab isolated pages from freelists. */
outer_end = isolate_freepages_range(outer_start, end);
if (!outer_end) {
ret = -EBUSY;
-- 
1.7.1


--
To 

[PATCHv22 10/16] mm: Serialize access to min_free_kbytes

2012-02-17 Thread Marek Szyprowski
From: Mel Gorman mgor...@suse.de

There is a race between the min_free_kbytes sysctl, memory hotplug
and transparent hugepage support enablement.  Memory hotplug uses a
zonelists_mutex to avoid a race when building zonelists. Reuse it to
serialise watermark updates.

[a.p.zijls...@chello.nl: Older patch fixed the race with spinlock]
Signed-off-by: Mel Gorman mgor...@suse.de
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
---
 mm/page_alloc.c |   23 +++
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5d23933..444e3fd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4976,14 +4976,7 @@ static void setup_per_zone_lowmem_reserve(void)
calculate_totalreserve_pages();
 }
 
-/**
- * setup_per_zone_wmarks - called when min_free_kbytes changes
- * or when memory is hot-{added|removed}
- *
- * Ensures that the watermark[min,low,high] values for each zone are set
- * correctly with respect to min_free_kbytes.
- */
-void setup_per_zone_wmarks(void)
+static void __setup_per_zone_wmarks(void)
 {
unsigned long pages_min = min_free_kbytes  (PAGE_SHIFT - 10);
unsigned long lowmem_pages = 0;
@@ -5038,6 +5031,20 @@ void setup_per_zone_wmarks(void)
calculate_totalreserve_pages();
 }
 
+/**
+ * setup_per_zone_wmarks - called when min_free_kbytes changes
+ * or when memory is hot-{added|removed}
+ *
+ * Ensures that the watermark[min,low,high] values for each zone are set
+ * correctly with respect to min_free_kbytes.
+ */
+void setup_per_zone_wmarks(void)
+{
+   mutex_lock(zonelists_mutex);
+   __setup_per_zone_wmarks();
+   mutex_unlock(zonelists_mutex);
+}
+
 /*
  * The inactive anon list should be small enough that the VM never has to
  * do too much work, but large enough that each inactive page has a chance
-- 
1.7.1


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


[PATCHv22 13/16] drivers: add Contiguous Memory Allocator

2012-02-17 Thread Marek Szyprowski
The Contiguous Memory Allocator is a set of helper functions for DMA
mapping framework that improves allocations of contiguous memory chunks.

CMA grabs memory on system boot, marks it with MIGRATE_CMA migrate type
and gives back to the system. Kernel is allowed to allocate only movable
pages within CMA's managed memory so that it can be used for example for
page cache when DMA mapping do not use it. On
dma_alloc_from_contiguous() request such pages are migrated out of CMA
area to free required contiguous block and fulfill the request. This
allows to allocate large contiguous chunks of memory at any time
assuming that there is enough free memory available in the system.

This code is heavily based on earlier works by Michal Nazarewicz.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Signed-off-by: Michal Nazarewicz min...@mina86.com
Acked-by: Arnd Bergmann a...@arndb.de
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 Documentation/kernel-parameters.txt  |5 +
 arch/Kconfig |3 +
 drivers/base/Kconfig |   89 
 drivers/base/Makefile|1 +
 drivers/base/dma-contiguous.c|  401 ++
 include/asm-generic/dma-contiguous.h |   28 +++
 include/linux/device.h   |4 +
 include/linux/dma-contiguous.h   |  110 +
 8 files changed, 641 insertions(+), 0 deletions(-)
 create mode 100644 drivers/base/dma-contiguous.c
 create mode 100644 include/asm-generic/dma-contiguous.h
 create mode 100644 include/linux/dma-contiguous.h

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 033d4e6..84982e2 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -508,6 +508,11 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
Also note the kernel might malfunction if you disable
some critical bits.
 
+   cma=nn[MG]  [ARM,KNL]
+   Sets the size of kernel global memory area for 
contiguous
+   memory allocations. For more information, see
+   include/linux/dma-contiguous.h
+
cmo_free_hint=  [PPC] Format: { yes | no }
Specify whether pages are marked as being inactive
when they are freed.  This is used in CMO environments
diff --git a/arch/Kconfig b/arch/Kconfig
index 4f55c73..8ec200c 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -128,6 +128,9 @@ config HAVE_ARCH_TRACEHOOK
 config HAVE_DMA_ATTRS
bool
 
+config HAVE_DMA_CONTIGUOUS
+   bool
+
 config USE_GENERIC_SMP_HELPERS
bool
 
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 7be9f79..f56cb20 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -189,4 +189,93 @@ config DMA_SHARED_BUFFER
  APIs extension; the file's descriptor can then be passed on to other
  driver.
 
+config CMA
+   bool Contiguous Memory Allocator (EXPERIMENTAL)
+   depends on HAVE_DMA_CONTIGUOUS  HAVE_MEMBLOCK  EXPERIMENTAL
+   select MIGRATION
+   help
+ This enables the Contiguous Memory Allocator which allows drivers
+ to allocate big physically-contiguous blocks of memory for use with
+ hardware components that do not support I/O map nor scatter-gather.
+
+ For more information see include/linux/dma-contiguous.h.
+ If unsure, say n.
+
+if CMA
+
+config CMA_DEBUG
+   bool CMA debug messages (DEVELOPMENT)
+   depends on DEBUG_KERNEL
+   help
+ Turns on debug messages in CMA.  This produces KERN_DEBUG
+ messages for every CMA call as well as various messages while
+ processing calls such as dma_alloc_from_contiguous().
+ This option does not affect warning and error messages.
+
+comment Default contiguous memory area size:
+
+config CMA_SIZE_MBYTES
+   int Size in Mega Bytes
+   depends on !CMA_SIZE_SEL_PERCENTAGE
+   default 16
+   help
+ Defines the size (in MiB) of the default memory area for Contiguous
+ Memory Allocator.
+
+config CMA_SIZE_PERCENTAGE
+   int Percentage of total memory
+   depends on !CMA_SIZE_SEL_MBYTES
+   default 10
+   help
+ Defines the size of the default memory area for Contiguous Memory
+ Allocator as a percentage of the total memory in the system.
+
+choice
+   prompt Selected region size
+   default CMA_SIZE_SEL_ABSOLUTE
+
+config CMA_SIZE_SEL_MBYTES
+   bool Use mega bytes value only
+
+config CMA_SIZE_SEL_PERCENTAGE
+   bool Use percentage value only
+
+config CMA_SIZE_SEL_MIN
+   bool Use lower value (minimum)
+
+config 

[PATCHv22 15/16] ARM: integrate CMA with DMA-mapping subsystem

2012-02-17 Thread Marek Szyprowski
This patch adds support for CMA to dma-mapping subsystem for ARM
architecture. By default a global CMA area is used, but specific devices
are allowed to have their private memory areas if required (they can be
created with dma_declare_contiguous() function during board
initialisation).

Contiguous memory areas reserved for DMA are remapped with 2-level page
tables on boot. Once a buffer is requested, a low memory kernel mapping
is updated to to match requested memory access type.

GFP_ATOMIC allocations are performed from special pool which is created
early during boot. This way remapping page attributes is not needed on
allocation time.

CMA has been enabled unconditionally for ARMv6+ systems.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
CC: Michal Nazarewicz min...@mina86.com
Acked-by: Arnd Bergmann a...@arndb.de
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 Documentation/kernel-parameters.txt   |4 +
 arch/arm/Kconfig  |2 +
 arch/arm/include/asm/dma-contiguous.h |   15 ++
 arch/arm/include/asm/mach/map.h   |1 +
 arch/arm/kernel/setup.c   |9 +-
 arch/arm/mm/dma-mapping.c |  368 +++--
 arch/arm/mm/init.c|   23 ++-
 arch/arm/mm/mm.h  |3 +
 arch/arm/mm/mmu.c |   31 ++-
 9 files changed, 368 insertions(+), 88 deletions(-)
 create mode 100644 arch/arm/include/asm/dma-contiguous.h

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 84982e2..ff97085 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -520,6 +520,10 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
a hypervisor.
Default: yes
 
+   coherent_pool=nn[KMG]   [ARM,KNL]
+   Sets the size of memory pool for coherent, atomic dma
+   allocations if Contiguous Memory Allocator (CMA) is 
used.
+
code_bytes  [X86] How many bytes of object code to print
in an oops report.
Range: 0 - 8192
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a48aecc..56192fe 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -4,6 +4,8 @@ config ARM
select HAVE_AOUT
select HAVE_DMA_API_DEBUG
select HAVE_IDE if PCI || ISA || PCMCIA
+   select HAVE_DMA_CONTIGUOUS if (CPU_V6 || CPU_V6K || CPU_V7)
+   select CMA if (CPU_V6 || CPU_V6K || CPU_V7)
select HAVE_MEMBLOCK
select RTC_LIB
select SYS_SUPPORTS_APM_EMULATION
diff --git a/arch/arm/include/asm/dma-contiguous.h 
b/arch/arm/include/asm/dma-contiguous.h
new file mode 100644
index 000..3ed37b4
--- /dev/null
+++ b/arch/arm/include/asm/dma-contiguous.h
@@ -0,0 +1,15 @@
+#ifndef ASMARM_DMA_CONTIGUOUS_H
+#define ASMARM_DMA_CONTIGUOUS_H
+
+#ifdef __KERNEL__
+#ifdef CONFIG_CMA
+
+#include linux/types.h
+#include asm-generic/dma-contiguous.h
+
+void dma_contiguous_early_fixup(phys_addr_t base, unsigned long size);
+
+#endif
+#endif
+
+#endif
diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
index b36f365..a6efcdd 100644
--- a/arch/arm/include/asm/mach/map.h
+++ b/arch/arm/include/asm/mach/map.h
@@ -30,6 +30,7 @@ struct map_desc {
 #define MT_MEMORY_DTCM 12
 #define MT_MEMORY_ITCM 13
 #define MT_MEMORY_SO   14
+#define MT_MEMORY_DMA_READY15
 
 #ifdef CONFIG_MMU
 extern void iotable_init(struct map_desc *, int);
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index a255c39..a7d5fb7 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -79,6 +79,7 @@ __setup(fpe=, fpe_setup);
 extern void paging_init(struct machine_desc *desc);
 extern void sanity_check_meminfo(void);
 extern void reboot_setup(char *str);
+extern void setup_dma_zone(struct machine_desc *desc);
 
 unsigned int processor_id;
 EXPORT_SYMBOL(processor_id);
@@ -923,12 +924,8 @@ void __init setup_arch(char **cmdline_p)
machine_desc = mdesc;
machine_name = mdesc-name;
 
-#ifdef CONFIG_ZONE_DMA
-   if (mdesc-dma_zone_size) {
-   extern unsigned long arm_dma_zone_size;
-   arm_dma_zone_size = mdesc-dma_zone_size;
-   }
-#endif
+   setup_dma_zone(mdesc);
+
if (mdesc-restart_mode)
reboot_setup(mdesc-restart_mode);
 
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 1aa664a..e614866 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -17,7 +17,9 @@
 #include linux/init.h
 #include linux/device.h
 #include linux/dma-mapping.h
+#include linux/dma-contiguous.h
 #include linux/highmem.h
+#include 

[PATCHv22 16/16] ARM: Samsung: use CMA for 2 memory banks for s5p-mfc device

2012-02-17 Thread Marek Szyprowski
Replace custom memory bank initialization using memblock_reserve and
dma_declare_coherent with a single call to CMA's dma_declare_contiguous.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Arnd Bergmann a...@arndb.de
---
 arch/arm/plat-s5p/dev-mfc.c |   51 ++-
 1 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/arch/arm/plat-s5p/dev-mfc.c b/arch/arm/plat-s5p/dev-mfc.c
index a30d36b..fcb8400 100644
--- a/arch/arm/plat-s5p/dev-mfc.c
+++ b/arch/arm/plat-s5p/dev-mfc.c
@@ -14,6 +14,7 @@
 #include linux/interrupt.h
 #include linux/platform_device.h
 #include linux/dma-mapping.h
+#include linux/dma-contiguous.h
 #include linux/memblock.h
 #include linux/ioport.h
 
@@ -22,52 +23,14 @@
 #include plat/irqs.h
 #include plat/mfc.h
 
-struct s5p_mfc_reserved_mem {
-   phys_addr_t base;
-   unsigned long   size;
-   struct device   *dev;
-};
-
-static struct s5p_mfc_reserved_mem s5p_mfc_mem[2] __initdata;
-
 void __init s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
phys_addr_t lbase, unsigned int lsize)
 {
-   int i;
-
-   s5p_mfc_mem[0].dev = s5p_device_mfc_r.dev;
-   s5p_mfc_mem[0].base = rbase;
-   s5p_mfc_mem[0].size = rsize;
-
-   s5p_mfc_mem[1].dev = s5p_device_mfc_l.dev;
-   s5p_mfc_mem[1].base = lbase;
-   s5p_mfc_mem[1].size = lsize;
-
-   for (i = 0; i  ARRAY_SIZE(s5p_mfc_mem); i++) {
-   struct s5p_mfc_reserved_mem *area = s5p_mfc_mem[i];
-   if (memblock_remove(area-base, area-size)) {
-   printk(KERN_ERR Failed to reserve memory for MFC 
device (%ld bytes at 0x%08lx)\n,
-  area-size, (unsigned long) area-base);
-   area-base = 0;
-   }
-   }
-}
-
-static int __init s5p_mfc_memory_init(void)
-{
-   int i;
-
-   for (i = 0; i  ARRAY_SIZE(s5p_mfc_mem); i++) {
-   struct s5p_mfc_reserved_mem *area = s5p_mfc_mem[i];
-   if (!area-base)
-   continue;
+   if (dma_declare_contiguous(s5p_device_mfc_r.dev, rsize, rbase, 0))
+   printk(KERN_ERR Failed to reserve memory for MFC device (%u 
bytes at 0x%08lx)\n,
+  rsize, (unsigned long) rbase);
 
-   if (dma_declare_coherent_memory(area-dev, area-base,
-   area-base, area-size,
-   DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0)
-   printk(KERN_ERR Failed to declare coherent memory for 
MFC device (%ld bytes at 0x%08lx)\n,
-  area-size, (unsigned long) area-base);
-   }
-   return 0;
+   if (dma_declare_contiguous(s5p_device_mfc_l.dev, lsize, lbase, 0))
+   printk(KERN_ERR Failed to reserve memory for MFC device (%u 
bytes at 0x%08lx)\n,
+  rsize, (unsigned long) rbase);
 }
-device_initcall(s5p_mfc_memory_init);
-- 
1.7.1


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


[PATCHv22 07/16] mm: page_alloc: change fallbacks array handling

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit adds a row for MIGRATE_ISOLATE type to the fallbacks array
which was missing from it.  It also, changes the array traversal logic
a little making MIGRATE_RESERVE an end marker.  The letter change,
removes the implicit MIGRATE_UNMOVABLE from the end of each row which
was read by __rmqueue_fallback() function.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 mm/page_alloc.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f820bfa..f025fba 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -875,11 +875,12 @@ struct page *__rmqueue_smallest(struct zone *zone, 
unsigned int order,
  * This array describes the order lists are fallen back to when
  * the free lists for the desirable migrate type are depleted
  */
-static int fallbacks[MIGRATE_TYPES][MIGRATE_TYPES-1] = {
+static int fallbacks[MIGRATE_TYPES][3] = {
[MIGRATE_UNMOVABLE]   = { MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE,   
MIGRATE_RESERVE },
[MIGRATE_RECLAIMABLE] = { MIGRATE_UNMOVABLE,   MIGRATE_MOVABLE,   
MIGRATE_RESERVE },
[MIGRATE_MOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, 
MIGRATE_RESERVE },
-   [MIGRATE_RESERVE] = { MIGRATE_RESERVE, MIGRATE_RESERVE,   
MIGRATE_RESERVE }, /* Never used */
+   [MIGRATE_RESERVE] = { MIGRATE_RESERVE }, /* Never used */
+   [MIGRATE_ISOLATE] = { MIGRATE_RESERVE }, /* Never used */
 };
 
 /*
@@ -974,12 +975,12 @@ __rmqueue_fallback(struct zone *zone, int order, int 
start_migratetype)
/* Find the largest possible block of pages in the other list */
for (current_order = MAX_ORDER-1; current_order = order;
--current_order) {
-   for (i = 0; i  MIGRATE_TYPES - 1; i++) {
+   for (i = 0;; i++) {
migratetype = fallbacks[start_migratetype][i];
 
/* MIGRATE_RESERVE handled later if necessary */
if (migratetype == MIGRATE_RESERVE)
-   continue;
+   break;
 
area = (zone-free_area[current_order]);
if (list_empty(area-free_list[migratetype]))
-- 
1.7.1


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


[PATCHv22 14/16] X86: integrate CMA with DMA-mapping subsystem

2012-02-17 Thread Marek Szyprowski
This patch adds support for CMA to dma-mapping subsystem for x86
architecture that uses common pci-dma/pci-nommu implementation. This
allows to test CMA on KVM/QEMU and a lot of common x86 boxes.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
CC: Michal Nazarewicz min...@mina86.com
Acked-by: Arnd Bergmann a...@arndb.de
---
 arch/x86/Kconfig  |1 +
 arch/x86/include/asm/dma-contiguous.h |   13 +
 arch/x86/include/asm/dma-mapping.h|4 
 arch/x86/kernel/pci-dma.c |   18 --
 arch/x86/kernel/pci-nommu.c   |8 +---
 arch/x86/kernel/setup.c   |2 ++
 6 files changed, 37 insertions(+), 9 deletions(-)
 create mode 100644 arch/x86/include/asm/dma-contiguous.h

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5bed94e..de6e069 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -31,6 +31,7 @@ config X86
select ARCH_WANT_OPTIONAL_GPIOLIB
select ARCH_WANT_FRAME_POINTERS
select HAVE_DMA_ATTRS
+   select HAVE_DMA_CONTIGUOUS if !SWIOTLB
select HAVE_KRETPROBES
select HAVE_OPTPROBES
select HAVE_FTRACE_MCOUNT_RECORD
diff --git a/arch/x86/include/asm/dma-contiguous.h 
b/arch/x86/include/asm/dma-contiguous.h
new file mode 100644
index 000..c092416
--- /dev/null
+++ b/arch/x86/include/asm/dma-contiguous.h
@@ -0,0 +1,13 @@
+#ifndef ASMX86_DMA_CONTIGUOUS_H
+#define ASMX86_DMA_CONTIGUOUS_H
+
+#ifdef __KERNEL__
+
+#include linux/types.h
+#include asm-generic/dma-contiguous.h
+
+static inline void
+dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { }
+
+#endif
+#endif
diff --git a/arch/x86/include/asm/dma-mapping.h 
b/arch/x86/include/asm/dma-mapping.h
index ed3065f..90ac6f0 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -13,6 +13,7 @@
 #include asm/io.h
 #include asm/swiotlb.h
 #include asm-generic/dma-coherent.h
+#include linux/dma-contiguous.h
 
 #ifdef CONFIG_ISA
 # define ISA_DMA_BIT_MASK DMA_BIT_MASK(24)
@@ -61,6 +62,9 @@ extern int dma_set_mask(struct device *dev, u64 mask);
 extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_addr, gfp_t flag);
 
+extern void dma_generic_free_coherent(struct device *dev, size_t size,
+ void *vaddr, dma_addr_t dma_addr);
+
 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t 
size)
 {
if (!dev-dma_mask)
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 1c4d769..d3c3723 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -99,14 +99,18 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t 
size,
 dma_addr_t *dma_addr, gfp_t flag)
 {
unsigned long dma_mask;
-   struct page *page;
+   struct page *page = NULL;
+   unsigned int count = PAGE_ALIGN(size)  PAGE_SHIFT;
dma_addr_t addr;
 
dma_mask = dma_alloc_coherent_mask(dev, flag);
 
flag |= __GFP_ZERO;
 again:
-   page = alloc_pages_node(dev_to_node(dev), flag, get_order(size));
+   if (!(flag  GFP_ATOMIC))
+   page = dma_alloc_from_contiguous(dev, count, get_order(size));
+   if (!page)
+   page = alloc_pages_node(dev_to_node(dev), flag, 
get_order(size));
if (!page)
return NULL;
 
@@ -126,6 +130,16 @@ again:
return page_address(page);
 }
 
+void dma_generic_free_coherent(struct device *dev, size_t size, void *vaddr,
+  dma_addr_t dma_addr)
+{
+   unsigned int count = PAGE_ALIGN(size)  PAGE_SHIFT;
+   struct page *page = virt_to_page(vaddr);
+
+   if (!dma_release_from_contiguous(dev, page, count))
+   free_pages((unsigned long)vaddr, get_order(size));
+}
+
 /*
  * See Documentation/x86/x86_64/boot-options.txt for the iommu kernel
  * parameter documentation.
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index 3af4af8..656566f 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -74,12 +74,6 @@ static int nommu_map_sg(struct device *hwdev, struct 
scatterlist *sg,
return nents;
 }
 
-static void nommu_free_coherent(struct device *dev, size_t size, void *vaddr,
-   dma_addr_t dma_addr)
-{
-   free_pages((unsigned long)vaddr, get_order(size));
-}
-
 static void nommu_sync_single_for_device(struct device *dev,
dma_addr_t addr, size_t size,
enum dma_data_direction dir)
@@ -97,7 +91,7 @@ static void nommu_sync_sg_for_device(struct device *dev,
 
 struct dma_map_ops nommu_dma_ops = {
.alloc_coherent = dma_generic_alloc_coherent,
-   .free_coherent  = nommu_free_coherent,
+   .free_coherent  = 

[PATCHv22 00/16] Contiguous Memory Allocator

2012-02-17 Thread Marek Szyprowski
Hi,

This is yet another update of the CMA patches. I really promise this is
the last one. Previous version had been posted in a real hurry (before
leaving the office for ELC trip) and I lost an important fixup patch in
the final rebase.

Best regards
Marek Szyprowski
Samsung Poland RD Center

Links to previous versions of the patchset:
v21: http://www.spinics.net/lists/linux-media/msg44155.html
v20: http://www.spinics.net/lists/linux-mm/msg29145.html
v19: http://www.spinics.net/lists/linux-mm/msg29145.html
v18: http://www.spinics.net/lists/linux-mm/msg28125.html
v17: http://www.spinics.net/lists/arm-kernel/msg148499.html
v16: http://www.spinics.net/lists/linux-mm/msg25066.html
v15: http://www.spinics.net/lists/linux-mm/msg23365.html
v14: http://www.spinics.net/lists/linux-media/msg36536.html
v13: (internal, intentionally not released)
v12: http://www.spinics.net/lists/linux-media/msg35674.html
v11: http://www.spinics.net/lists/linux-mm/msg21868.html
v10: http://www.spinics.net/lists/linux-mm/msg20761.html
 v9: http://article.gmane.org/gmane.linux.kernel.mm/60787
 v8: http://article.gmane.org/gmane.linux.kernel.mm/56855
 v7: http://article.gmane.org/gmane.linux.kernel.mm/55626
 v6: http://article.gmane.org/gmane.linux.kernel.mm/55626
 v5: (intentionally left out as CMA v5 was identical to CMA v4)
 v4: http://article.gmane.org/gmane.linux.kernel.mm/52010
 v3: http://article.gmane.org/gmane.linux.kernel.mm/51573
 v2: http://article.gmane.org/gmane.linux.kernel.mm/50986
 v1: http://article.gmane.org/gmane.linux.kernel.mm/50669


Changelog:

v22:
1. Fixed compilation break caused by missing fixup patch in v21

2. Fixed typos in the comments

3. Removed superfluous #include entries

v21:
1. Fixed incorrect check which broke memory compaction code

2. Fixed hacky and racy min_free_kbytes handling

3. Added serialization patch to watermark calculation

4. Fixed typos here and there in the comments

v20 and earlier - see previous patchsets.


Patches in this patchset:

Marek Szyprowski (6):
  mm: extract reclaim code from __alloc_pages_direct_reclaim()
  mm: trigger page reclaim in alloc_contig_range() to stabilise
watermarks
  drivers: add Contiguous Memory Allocator
  X86: integrate CMA with DMA-mapping subsystem
  ARM: integrate CMA with DMA-mapping subsystem
  ARM: Samsung: use CMA for 2 memory banks for s5p-mfc device

Mel Gorman (1):
  mm: Serialize access to min_free_kbytes

Michal Nazarewicz (9):
  mm: page_alloc: remove trailing whitespace
  mm: compaction: introduce isolate_migratepages_range()
  mm: compaction: introduce map_pages()
  mm: compaction: introduce isolate_freepages_range()
  mm: compaction: export some of the functions
  mm: page_alloc: introduce alloc_contig_range()
  mm: page_alloc: change fallbacks array handling
  mm: mmzone: MIGRATE_CMA migration type added
  mm: page_isolation: MIGRATE_CMA isolation functions added

 Documentation/kernel-parameters.txt   |9 +
 arch/Kconfig  |3 +
 arch/arm/Kconfig  |2 +
 arch/arm/include/asm/dma-contiguous.h |   15 ++
 arch/arm/include/asm/mach/map.h   |1 +
 arch/arm/kernel/setup.c   |9 +-
 arch/arm/mm/dma-mapping.c |  368 --
 arch/arm/mm/init.c|   23 ++-
 arch/arm/mm/mm.h  |3 +
 arch/arm/mm/mmu.c |   31 ++-
 arch/arm/plat-s5p/dev-mfc.c   |   51 +
 arch/x86/Kconfig  |1 +
 arch/x86/include/asm/dma-contiguous.h |   13 +
 arch/x86/include/asm/dma-mapping.h|4 +
 arch/x86/kernel/pci-dma.c |   18 ++-
 arch/x86/kernel/pci-nommu.c   |8 +-
 arch/x86/kernel/setup.c   |2 +
 drivers/base/Kconfig  |   89 +++
 drivers/base/Makefile |1 +
 drivers/base/dma-contiguous.c |  401 +++
 include/asm-generic/dma-contiguous.h  |   28 +++
 include/linux/device.h|4 +
 include/linux/dma-contiguous.h|  110 +
 include/linux/gfp.h   |   12 +
 include/linux/mmzone.h|   47 +++-
 include/linux/page-isolation.h|   18 +-
 mm/Kconfig|2 +-
 mm/Makefile   |3 +-
 mm/compaction.c   |  418 +
 mm/internal.h |   33 +++
 mm/memory-failure.c   |2 +-
 mm/memory_hotplug.c   |6 +-
 mm/page_alloc.c   |  413 
 mm/page_isolation.c   |   15 +-
 mm/vmstat.c   |3 +
 35 files changed, 1791 insertions(+), 375 deletions(-)
 create mode 100644 arch/arm/include/asm/dma-contiguous.h
 create mode 100644 arch/x86/include/asm/dma-contiguous.h
 create mode 100644 drivers/base/dma-contiguous.c
 create mode 

[PATCHv22 01/16] mm: page_alloc: remove trailing whitespace

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
---
 mm/page_alloc.c |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d2186ec..7fe7697 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -513,10 +513,10 @@ static inline int page_is_buddy(struct page *page, struct 
page *buddy,
  * free pages of length of (1  order) and marked with _mapcount -2. Page's
  * order is recorded in page_private(page) field.
  * So when we are allocating or freeing one, we can derive the state of the
- * other.  That is, if we allocate a small block, and both were   
- * free, the remainder of the region must be split into blocks.   
+ * other.  That is, if we allocate a small block, and both were
+ * free, the remainder of the region must be split into blocks.
  * If a block is freed, and its buddy is also free, then this
- * triggers coalescing into a block of larger size.
+ * triggers coalescing into a block of larger size.
  *
  * -- wli
  */
@@ -1061,17 +1061,17 @@ retry_reserve:
return page;
 }
 
-/* 
+/*
  * Obtain a specified number of elements from the buddy allocator, all under
  * a single hold of the lock, for efficiency.  Add them to the supplied list.
  * Returns the number of new pages which were placed at *list.
  */
-static int rmqueue_bulk(struct zone *zone, unsigned int order, 
+static int rmqueue_bulk(struct zone *zone, unsigned int order,
unsigned long count, struct list_head *list,
int migratetype, int cold)
 {
int i;
-   
+
spin_lock(zone-lock);
for (i = 0; i  count; ++i) {
struct page *page = __rmqueue(zone, order, migratetype);
@@ -4258,7 +4258,7 @@ static void __paginginit free_area_init_core(struct 
pglist_data *pgdat,
init_waitqueue_head(pgdat-kswapd_wait);
pgdat-kswapd_max_order = 0;
pgdat_page_cgroup_init(pgdat);
-   
+
for (j = 0; j  MAX_NR_ZONES; j++) {
struct zone *zone = pgdat-node_zones + j;
unsigned long size, realsize, memmap_pages;
@@ -5081,11 +5081,11 @@ int __meminit init_per_zone_wmark_min(void)
 module_init(init_per_zone_wmark_min)
 
 /*
- * min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so 
+ * min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so
  * that we can call two helper functions whenever min_free_kbytes
  * changes.
  */
-int min_free_kbytes_sysctl_handler(ctl_table *table, int write, 
+int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
 {
proc_dointvec(table, write, buffer, length, ppos);
-- 
1.7.1


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


[PATCHv22 02/16] mm: compaction: introduce isolate_migratepages_range()

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit introduces isolate_migratepages_range() function which
extracts functionality from isolate_migratepages() so that it can be
used on arbitrary PFN ranges.

isolate_migratepages() function is implemented as a simple wrapper
around isolate_migratepages_range().

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 mm/compaction.c |   75 +++---
 1 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index d9ebebe..72f8685 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -250,31 +250,34 @@ typedef enum {
ISOLATE_SUCCESS,/* Pages isolated, migrate */
 } isolate_migrate_t;
 
-/*
- * Isolate all pages that can be migrated from the block pointed to by
- * the migrate scanner within compact_control.
+/**
+ * isolate_migratepages_range() - isolate all migrate-able pages in range.
+ * @zone:  Zone pages are in.
+ * @cc:Compaction control structure.
+ * @low_pfn:   The first PFN of the range.
+ * @end_pfn:   The one-past-the-last PFN of the range.
+ *
+ * Isolate all pages that can be migrated from the range specified by
+ * [low_pfn, end_pfn).  Returns zero if there is a fatal signal
+ * pending), otherwise PFN of the first page that was not scanned
+ * (which may be both less, equal to or more then end_pfn).
+ *
+ * Assumes that cc-migratepages is empty and cc-nr_migratepages is
+ * zero.
+ *
+ * Apart from cc-migratepages and cc-nr_migratetypes this function
+ * does not modify any cc's fields, in particular it does not modify
+ * (or read for that matter) cc-migrate_pfn.
  */
-static isolate_migrate_t isolate_migratepages(struct zone *zone,
-   struct compact_control *cc)
+static unsigned long
+isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
+  unsigned long low_pfn, unsigned long end_pfn)
 {
-   unsigned long low_pfn, end_pfn;
unsigned long last_pageblock_nr = 0, pageblock_nr;
unsigned long nr_scanned = 0, nr_isolated = 0;
struct list_head *migratelist = cc-migratepages;
isolate_mode_t mode = ISOLATE_ACTIVE|ISOLATE_INACTIVE;
 
-   /* Do not scan outside zone boundaries */
-   low_pfn = max(cc-migrate_pfn, zone-zone_start_pfn);
-
-   /* Only scan within a pageblock boundary */
-   end_pfn = ALIGN(low_pfn + pageblock_nr_pages, pageblock_nr_pages);
-
-   /* Do not cross the free scanner or scan within a memory hole */
-   if (end_pfn  cc-free_pfn || !pfn_valid(low_pfn)) {
-   cc-migrate_pfn = end_pfn;
-   return ISOLATE_NONE;
-   }
-
/*
 * Ensure that there are not too many pages isolated from the LRU
 * list by either parallel reclaimers or compaction. If there are,
@@ -283,12 +286,12 @@ static isolate_migrate_t isolate_migratepages(struct zone 
*zone,
while (unlikely(too_many_isolated(zone))) {
/* async migration should just abort */
if (!cc-sync)
-   return ISOLATE_ABORT;
+   return 0;
 
congestion_wait(BLK_RW_ASYNC, HZ/10);
 
if (fatal_signal_pending(current))
-   return ISOLATE_ABORT;
+   return 0;
}
 
/* Time to isolate some pages for migration */
@@ -396,10 +399,40 @@ static isolate_migrate_t isolate_migratepages(struct zone 
*zone,
acct_isolated(zone, cc);
 
spin_unlock_irq(zone-lru_lock);
-   cc-migrate_pfn = low_pfn;
 
trace_mm_compaction_isolate_migratepages(nr_scanned, nr_isolated);
 
+   return low_pfn;
+}
+
+/*
+ * Isolate all pages that can be migrated from the block pointed to by
+ * the migrate scanner within compact_control.
+ */
+static isolate_migrate_t isolate_migratepages(struct zone *zone,
+   struct compact_control *cc)
+{
+   unsigned long low_pfn, end_pfn;
+
+   /* Do not scan outside zone boundaries */
+   low_pfn = max(cc-migrate_pfn, zone-zone_start_pfn);
+
+   /* Only scan within a pageblock boundary */
+   end_pfn = ALIGN(low_pfn + pageblock_nr_pages, pageblock_nr_pages);
+
+   /* Do not cross the free scanner or scan within a memory hole */
+   if (end_pfn  cc-free_pfn || !pfn_valid(low_pfn)) {
+   cc-migrate_pfn = end_pfn;
+   return ISOLATE_NONE;
+   }
+
+   /* Perform the isolation */
+   low_pfn = isolate_migratepages_range(zone, cc, low_pfn, end_pfn);
+   if 

[PATCHv22 04/16] mm: compaction: introduce isolate_freepages_range()

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit introduces isolate_freepages_range() function which
generalises isolate_freepages_block() so that it can be used on
arbitrary PFN ranges.

isolate_freepages_block() is left with only minor changes.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 mm/compaction.c |  111 ++-
 1 files changed, 93 insertions(+), 18 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index de22893..0799d0c 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -54,24 +54,20 @@ static unsigned long release_freepages(struct list_head 
*freelist)
return count;
 }
 
-/* Isolate free pages onto a private freelist. Must hold zone-lock */
-static unsigned long isolate_freepages_block(struct zone *zone,
-   unsigned long blockpfn,
-   struct list_head *freelist)
+/*
+ * Isolate free pages onto a private freelist. Caller must hold zone-lock.
+ * If @strict is true, will abort returning 0 on any invalid PFNs or non-free
+ * pages inside of the pageblock (even though it may still end up isolating
+ * some pages).
+ */
+static unsigned long isolate_freepages_block(unsigned long blockpfn,
+   unsigned long end_pfn,
+   struct list_head *freelist,
+   bool strict)
 {
-   unsigned long zone_end_pfn, end_pfn;
int nr_scanned = 0, total_isolated = 0;
struct page *cursor;
 
-   /* Get the last PFN we should scan for free pages at */
-   zone_end_pfn = zone-zone_start_pfn + zone-spanned_pages;
-   end_pfn = min(blockpfn + pageblock_nr_pages, zone_end_pfn);
-
-   /* Find the first usable PFN in the block to initialse page cursor */
-   for (; blockpfn  end_pfn; blockpfn++) {
-   if (pfn_valid_within(blockpfn))
-   break;
-   }
cursor = pfn_to_page(blockpfn);
 
/* Isolate free pages. This assumes the block is valid */
@@ -79,15 +75,23 @@ static unsigned long isolate_freepages_block(struct zone 
*zone,
int isolated, i;
struct page *page = cursor;
 
-   if (!pfn_valid_within(blockpfn))
+   if (!pfn_valid_within(blockpfn)) {
+   if (strict)
+   return 0;
continue;
+   }
nr_scanned++;
 
-   if (!PageBuddy(page))
+   if (!PageBuddy(page)) {
+   if (strict)
+   return 0;
continue;
+   }
 
/* Found a free page, break it into order-0 pages */
isolated = split_free_page(page);
+   if (!isolated  strict)
+   return 0;
total_isolated += isolated;
for (i = 0; i  isolated; i++) {
list_add(page-lru, freelist);
@@ -105,6 +109,73 @@ static unsigned long isolate_freepages_block(struct zone 
*zone,
return total_isolated;
 }
 
+/**
+ * isolate_freepages_range() - isolate free pages.
+ * @start_pfn: The first PFN to start isolating.
+ * @end_pfn:   The one-past-last PFN.
+ *
+ * Non-free pages, invalid PFNs, or zone boundaries within the
+ * [start_pfn, end_pfn) range are considered errors, cause function to
+ * undo its actions and return zero.
+ *
+ * Otherwise, function returns one-past-the-last PFN of isolated page
+ * (which may be greater then end_pfn if end fell in a middle of
+ * a free page).
+ */
+static unsigned long
+isolate_freepages_range(unsigned long start_pfn, unsigned long end_pfn)
+{
+   unsigned long isolated, pfn, block_end_pfn, flags;
+   struct zone *zone = NULL;
+   LIST_HEAD(freelist);
+
+   if (pfn_valid(start_pfn))
+   zone = page_zone(pfn_to_page(start_pfn));
+
+   for (pfn = start_pfn; pfn  end_pfn; pfn += isolated) {
+   if (!pfn_valid(pfn) || zone != page_zone(pfn_to_page(pfn)))
+   break;
+
+   /*
+* On subsequent iterations ALIGN() is actually not needed,
+* but we keep it that we not to complicate the code.
+*/
+   block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
+   block_end_pfn = min(block_end_pfn, end_pfn);
+
+   spin_lock_irqsave(zone-lock, flags);
+   isolated = isolate_freepages_block(pfn, block_end_pfn,
+  freelist, true);
+ 

[PATCHv22 05/16] mm: compaction: export some of the functions

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit exports some of the functions from compaction.c file
outside of it adding their declaration into internal.h header
file so that other mm related code can use them.

This forced compaction.c to always be compiled (as opposed to being
compiled only if CONFIG_COMPACTION is defined) but as to avoid
introducing code that user did not ask for, part of the compaction.c
is now wrapped in on #ifdef.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 mm/Makefile |3 +-
 mm/compaction.c |  328 ++-
 mm/internal.h   |   33 ++
 3 files changed, 191 insertions(+), 173 deletions(-)

diff --git a/mm/Makefile b/mm/Makefile
index 50ec00e..8aada89 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -13,7 +13,7 @@ obj-y := filemap.o mempool.o oom_kill.o 
fadvise.o \
   readahead.o swap.o truncate.o vmscan.o shmem.o \
   prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
   page_isolation.o mm_init.o mmu_context.o percpu.o \
-  $(mmu-y)
+  compaction.o $(mmu-y)
 obj-y += init-mm.o
 
 ifdef CONFIG_NO_BOOTMEM
@@ -32,7 +32,6 @@ obj-$(CONFIG_NUMA)+= mempolicy.o
 obj-$(CONFIG_SPARSEMEM)+= sparse.o
 obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
 obj-$(CONFIG_SLOB) += slob.o
-obj-$(CONFIG_COMPACTION) += compaction.o
 obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
 obj-$(CONFIG_KSM) += ksm.o
 obj-$(CONFIG_PAGE_POISONING) += debug-pagealloc.o
diff --git a/mm/compaction.c b/mm/compaction.c
index 0799d0c..718a8cc 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -16,30 +16,11 @@
 #include linux/sysfs.h
 #include internal.h
 
+#if defined CONFIG_COMPACTION || defined CONFIG_CMA
+
 #define CREATE_TRACE_POINTS
 #include trace/events/compaction.h
 
-/*
- * compact_control is used to track pages being migrated and the free pages
- * they are being migrated to during memory compaction. The free_pfn starts
- * at the end of a zone and migrate_pfn begins at the start. Movable pages
- * are moved to the end of a zone during a compaction run and the run
- * completes when free_pfn = migrate_pfn
- */
-struct compact_control {
-   struct list_head freepages; /* List of free pages to migrate to */
-   struct list_head migratepages;  /* List of pages being migrated */
-   unsigned long nr_freepages; /* Number of isolated free pages */
-   unsigned long nr_migratepages;  /* Number of pages to migrate */
-   unsigned long free_pfn; /* isolate_freepages search base */
-   unsigned long migrate_pfn;  /* isolate_migratepages search base */
-   bool sync;  /* Synchronous migration */
-
-   unsigned int order; /* order a direct compactor needs */
-   int migratetype;/* MOVABLE, RECLAIMABLE etc */
-   struct zone *zone;
-};
-
 static unsigned long release_freepages(struct list_head *freelist)
 {
struct page *page, *next;
@@ -54,6 +35,16 @@ static unsigned long release_freepages(struct list_head 
*freelist)
return count;
 }
 
+static void map_pages(struct list_head *list)
+{
+   struct page *page;
+
+   list_for_each_entry(page, list, lru) {
+   arch_alloc_page(page, 0);
+   kernel_map_pages(page, 1, 1);
+   }
+}
+
 /*
  * Isolate free pages onto a private freelist. Caller must hold zone-lock.
  * If @strict is true, will abort returning 0 on any invalid PFNs or non-free
@@ -122,7 +113,7 @@ static unsigned long isolate_freepages_block(unsigned long 
blockpfn,
  * (which may be greater then end_pfn if end fell in a middle of
  * a free page).
  */
-static unsigned long
+unsigned long
 isolate_freepages_range(unsigned long start_pfn, unsigned long end_pfn)
 {
unsigned long isolated, pfn, block_end_pfn, flags;
@@ -176,127 +167,6 @@ isolate_freepages_range(unsigned long start_pfn, unsigned 
long end_pfn)
return pfn;
 }
 
-/* Returns true if the page is within a block suitable for migration to */
-static bool suitable_migration_target(struct page *page)
-{
-
-   int migratetype = get_pageblock_migratetype(page);
-
-   /* Don't interfere with memory hot-remove or the min_free_kbytes blocks 
*/
-   if (migratetype == MIGRATE_ISOLATE || migratetype == MIGRATE_RESERVE)
-   return false;
-
-   /* If the page is a large free page, then allow migration */
-   if (PageBuddy(page)  page_order(page) = pageblock_order)
-   return true;
-
-   /* 

[PATCHv22 06/16] mm: page_alloc: introduce alloc_contig_range()

2012-02-17 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit adds the alloc_contig_range() function which tries
to allocate given range of pages.  It tries to migrate all
already allocated pages that fall in the range thus freeing them.
Once all pages in the range are freed they are removed from the
buddy system thus allocated for the caller to use.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Mel Gorman m...@csn.ul.ie
Reviewed-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
Tested-by: Rob Clark rob.cl...@linaro.org
Tested-by: Ohad Ben-Cohen o...@wizery.com
Tested-by: Benjamin Gaignard benjamin.gaign...@linaro.org
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 include/linux/gfp.h |8 ++
 mm/page_alloc.c |  185 +++
 2 files changed, 193 insertions(+), 0 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 581e74b..052a5b6 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -391,4 +391,12 @@ static inline bool pm_suspended_storage(void)
 }
 #endif /* CONFIG_PM_SLEEP */
 
+#ifdef CONFIG_CMA
+
+/* The below functions must be run on a range from a single zone. */
+extern int alloc_contig_range(unsigned long start, unsigned long end);
+extern void free_contig_range(unsigned long pfn, unsigned nr_pages);
+
+#endif
+
 #endif /* __LINUX_GFP_H */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7fe7697..f820bfa 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -57,6 +57,7 @@
 #include linux/ftrace_event.h
 #include linux/memcontrol.h
 #include linux/prefetch.h
+#include linux/migrate.h
 #include linux/page-debug-flags.h
 
 #include asm/tlbflush.h
@@ -5505,6 +5506,190 @@ out:
spin_unlock_irqrestore(zone-lock, flags);
 }
 
+#ifdef CONFIG_CMA
+
+static unsigned long pfn_align_to_maxpage_down(unsigned long pfn)
+{
+   return pfn  ~(MAX_ORDER_NR_PAGES - 1);
+}
+
+static unsigned long pfn_align_to_maxpage_up(unsigned long pfn)
+{
+   return ALIGN(pfn, MAX_ORDER_NR_PAGES);
+}
+
+static struct page *
+__alloc_contig_migrate_alloc(struct page *page, unsigned long private,
+int **resultp)
+{
+   return alloc_page(GFP_HIGHUSER_MOVABLE);
+}
+
+/* [start, end) must belong to a single zone. */
+static int __alloc_contig_migrate_range(unsigned long start, unsigned long end)
+{
+   /* This function is based on compact_zone() from compaction.c. */
+
+   unsigned long pfn = start;
+   unsigned int tries = 0;
+   int ret = 0;
+
+   struct compact_control cc = {
+   .nr_migratepages = 0,
+   .order = -1,
+   .zone = page_zone(pfn_to_page(start)),
+   .sync = true,
+   };
+   INIT_LIST_HEAD(cc.migratepages);
+
+   migrate_prep_local();
+
+   while (pfn  end || !list_empty(cc.migratepages)) {
+   if (fatal_signal_pending(current)) {
+   ret = -EINTR;
+   break;
+   }
+
+   if (list_empty(cc.migratepages)) {
+   cc.nr_migratepages = 0;
+   pfn = isolate_migratepages_range(cc.zone, cc,
+pfn, end);
+   if (!pfn) {
+   ret = -EINTR;
+   break;
+   }
+   tries = 0;
+   } else if (++tries == 5) {
+   ret = ret  0 ? ret : -EBUSY;
+   break;
+   }
+
+   ret = migrate_pages(cc.migratepages,
+   __alloc_contig_migrate_alloc,
+   0, false, true);
+   }
+
+   putback_lru_pages(cc.migratepages);
+   return ret  0 ? 0 : ret;
+}
+
+/**
+ * alloc_contig_range() -- tries to allocate given range of pages
+ * @start: start PFN to allocate
+ * @end:   one-past-the-last PFN to allocate
+ *
+ * The PFN range does not have to be pageblock or MAX_ORDER_NR_PAGES
+ * aligned, however it's the caller's responsibility to guarantee that
+ * we are the only thread that changes migrate type of pageblocks the
+ * pages fall in.
+ *
+ * The PFN range must belong to a single zone.
+ *
+ * Returns zero on success or negative error code.  On success all
+ * pages which PFN is in [start, end) are allocated for the caller and
+ * need to be freed with free_contig_range().
+ */
+int alloc_contig_range(unsigned long start, unsigned long end)
+{
+   struct zone *zone = page_zone(pfn_to_page(start));
+   unsigned long outer_start, outer_end;
+   int ret = 0, order;
+
+   /*
+* What we do here is we mark all pageblocks in range as
+* MIGRATE_ISOLATE.  Because of the way page allocator work, we
+* align the range to MAX_ORDER pages so that page allocator
+* won't try to merge buddies from 

Re: Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-17 Thread Adam Jackson

On 2/16/12 6:25 PM, Laurent Pinchart wrote:


***  Common video mode data structure and EDID parser ***

   Goal: Sharing an EDID parser between DRM/KMS, FBDEV and V4L2.

   The DRM EDID parser is currently the most advanced implementation and will
   be taken as a starting point.

   Different subsystems use different data structures to describe video
   mode/timing information:

   - struct drm_mode_modeinfo in DRM/KMS
   - struct fb_videomode in FBDEV
   - struct v4l2_bt_timings in V4L2

   A new common video mode/timing data structure (struct media_video_mode_info,
   exact name is to be defined), not tied to any specific subsystem, is
   required to share the EDID parser. That structure won't be exported to
   userspace.

   Helper functions will be implemented in the subsystems to convert between
   that generic structure and the various subsystem-specific structures.


I guess.  I don't really see a reason not to unify the structs too, but 
then I don't have binary blobs to pretend to be ABI-compatible with.



   The mode list is stored in the DRM connector in the EDID parser. A new mode
   list data structure can be added, or a callback function can be used by the
   parser to give modes one at a time to the caller.

   3D needs to be taken into account (this is similar to interlacing).


Would also be pleasant if the new mode structure had a reasonable way of 
representing borders, we copied that mistake from xserver and have been 
regretting it.



   Action points:
   - Laurent to work on a proposal. The DRM/KMS EDID parser will be reused.


I'm totally in favor of this.  I've long loathed fbdev having such a 
broken parser, I just never got around to fixing it since we don't use 
fbdev in any real way.


The existing drm_edid.c needs a little detangling, DDC fetch and EDID 
parse should be better split.  Shouldn't be too terrible though.


Has the embedded world seen any adoption of DisplayID?  I wrote a fair 
bit of a parser for it at one point [1] but I've yet to find a machine 
that's required it.



***  Split KMS and GPU Drivers ***

   Goal: Split KMS and GPU drivers with in kernel API inbetween.

   In most (all ?) SoCs, the GPU and the display controller are separate
   devices. Splitting them into separate drivers would allow reusing the GPU
   driver with different devices (e.g. using a single common PowerVR kernel
   module with different display controller drivers). The same approach can be
   used on the desktop for the multi-GPU case and the USB display case.

   - OMAP already separates the GPU and DSS drivers, but the GPU driver is some
   kind of DSS plugin. This isn't a long-term approach.
   - Exynos also separates the GPU and FIMD drivers. It's hard to merge GPU
   into  display subsystem since UMP, GPU has own memory management codes.

   One of the biggest challenges would be to get GPU vendors to use this new
   model. ARM could help here, by making the Mali kernel driver split from the
   display controller drivers. Once one vendor jumps onboard, others could have
   a bigger incentive to follow.


Honestly I want this for Intel already, given how identical Poulsbo's 
display block is to gen3.



***  HDMI CEC Support ***

   Goal: Support HDMI CEC and offer a userspace API for applications.

   A new kernel API is needed and must be usable by KMS, V4L2 and possibly
   LIRC. There's ongoing effort from Cisco to implement HDMI CEC support. Given
   their background, V4L2 is their initial target. A proposal is available at
   http://www.mail-archive.com/linux-media@vger.kernel.org/msg29241.html with a
   sample implementation at
   http://git.linuxtv.org/hverkuil/cisco.git/shortlog/refs/heads/cobalt-
mainline
   (drivers/media/video/adv7604.c and ad9389b.c.

   In order to avoid API duplication, a new CEC subsystem is probably needed.
   CEC could be modeled as a bus, or as a network device. With the network
   device approach, we could have both kernel and userspace protocol handlers.


I'm not a huge fan of userspace protocol for this.  Seems like it'd just 
give people more license to do their own subtly-incompatible things that 
only work between devices of the same vendor.  Interoperability is the 
_whole_ point of CEC.  (Yes I know every vendor tries to spin it as 
their own magical branded thing, but I'd appreciate it if they grew up.)


[1] - 
http://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/modes/xf86DisplayIDModes.c


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


Re: [alsa-devel] tea575x-tuner improvements use in maxiradio

2012-02-17 Thread Ondrej Zary
On Wednesday 08 February 2012 08:29:25 Hans Verkuil wrote:
 On Tuesday, February 07, 2012 23:20:19 Ondrej Zary wrote:
  On Sunday 05 February 2012 14:17:05 Hans Verkuil wrote:
   These patches improve the tea575x-tuner module to make it up to date
   with the latest V4L2 frameworks.
  
   The maxiradio driver has also been converted to use the tea575x-tuner
   and I've used that card to test it.
  
   Unfortunately, this card can't read the data pin, so the new hardware
   seek functionality has been tested only partially (yes, it seeks, but
   when it finds a channel I can't read back the frequency).
  
   Ondrej, are you able to test these patches for the sound cards that use
   this tea575x tuner?
  
   Note that these two patches rely on other work that I did and that
   hasn't been merged yet. So it is best to pull from my git tree:
  
   http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/radi
  o-pc i2
  
   You can use the v4l-utils repository
   (http://git.linuxtv.org/v4l-utils.git) to test the drivers: the
   v4l2-compliance test should succeed and with v4l2-ctl you can test the
   hardware seek:
  
   To seek down:
  
   v4l2-ctl -d /dev/radio0 --freq-seek=dir=0
  
   To seek up:
  
   v4l2-ctl -d /dev/radio0 --freq-seek=dir=1
  
   To do the compliance test:
  
   v4l2-compliance -r /dev/radio0
 
  It seems to work (tested with SF64-PCR - snd_fm801) but the seek is
  severely broken. Reading the frequency immediately after seek does not
  work, it always returns the old value (haven't found a delay that works).
  Reading it later (copied back snd_tea575x_get_freq function) works. The
  chip seeks randomly up or down, ignoring UP/DOWN flag and often stops at
  wrong place (only noise) or even outside the FM range.
 
  So I strongly suggest not to enable this (mis-)feature. The HW seems to
  be completely broken (unless there's some weird bug in the code).

 Well, it seemed like a good idea at the time :-) I'll remove this
 'feature', it's really not worth our time to try and make this work for
 these old cards.

I fixed it somehow. Now it works most of the time.
The important things:
 - a delay must be present after search start and before first register read
   or the seek does weird things
 - when the search stops, the new frequency is not available immediately, we
   must wait until it appears in the register (fortunately, we can clear the
   frequency bits when starting the search as it starts at the frequency
   currently set, not from the value written)
 - sometimes, seek remains on the current frequency (or moves only a little),
   so repeat it until it moves by at least 50 kHz

--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -89,7 +89,7 @@ static void snd_tea575x_write(struct snd_tea575x *tea, 
unsigned int val)
tea-ops-set_pins(tea, 0);
 }
 
-static unsigned int snd_tea575x_read(struct snd_tea575x *tea)
+static u32 snd_tea575x_read(struct snd_tea575x *tea)
 {
u16 l, rdata;
u32 data = 0;
@@ -120,6 +120,27 @@ static unsigned int snd_tea575x_read(struct snd_tea575x 
*tea)
return data;
 }
 
+static void snd_tea575x_get_freq(struct snd_tea575x *tea)
+{
+   u32 freq = snd_tea575x_read(tea)  TEA575X_BIT_FREQ_MASK;
+
+   if (freq == 0) {
+   tea-freq = 0;
+   return;
+   }
+
+   /* freq *= 12.5 */
+   freq *= 125;
+   freq /= 10;
+   /* crystal fixup */
+   if (tea-tea5759)
+   freq += TEA575X_FMIF;
+   else
+   freq -= TEA575X_FMIF;
+
+   tea-freq = clamp(freq * 16, FREQ_LO, FREQ_HI); /* from kHz */
+}
+
 static void snd_tea575x_set_freq(struct snd_tea575x *tea)
 {
u32 freq = tea-freq;
@@ -203,6 +224,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
if (f-tuner != 0)
return -EINVAL;
f-type = V4L2_TUNER_RADIO;
+   if (!tea-cannot_read_data)
+   snd_tea575x_get_freq(tea);
f-frequency = tea-freq;
return 0;
 }
@@ -225,36 +248,50 @@ static int vidioc_s_hw_freq_seek(struct file *file, void 
*fh,
struct v4l2_hw_freq_seek *a)
 {
struct snd_tea575x *tea = video_drvdata(file);
+   int i, old_freq;
+   unsigned long timeout;
 
if (tea-cannot_read_data)
return -ENOTTY;
+
+   snd_tea575x_get_freq(tea);
+   old_freq = tea-freq;
+   /* clear the frequency, HW will fill it in */
+   tea-val = ~TEA575X_BIT_FREQ_MASK;
tea-val |= TEA575X_BIT_SEARCH;
-   tea-val = ~TEA575X_BIT_UPDOWN;
if (a-seek_upward)
tea-val |= TEA575X_BIT_UPDOWN;
+   else
+   tea-val = ~TEA575X_BIT_UPDOWN;
snd_tea575x_write(tea, tea-val);
+   timeout = jiffies + msecs_to_jiffies(1);
for (;;) {
-   unsigned val = snd_tea575x_read(tea);
-
-   if (!(val  TEA575X_BIT_SEARCH)) {
- 

Re: [alsa-devel] tea575x-tuner improvements use in maxiradio

2012-02-17 Thread Hans Verkuil
On Friday, February 17, 2012 21:13:40 Ondrej Zary wrote:
 On Wednesday 08 February 2012 08:29:25 Hans Verkuil wrote:
  On Tuesday, February 07, 2012 23:20:19 Ondrej Zary wrote:
   On Sunday 05 February 2012 14:17:05 Hans Verkuil wrote:
These patches improve the tea575x-tuner module to make it up to date
with the latest V4L2 frameworks.
   
The maxiradio driver has also been converted to use the tea575x-tuner
and I've used that card to test it.
   
Unfortunately, this card can't read the data pin, so the new hardware
seek functionality has been tested only partially (yes, it seeks, but
when it finds a channel I can't read back the frequency).
   
Ondrej, are you able to test these patches for the sound cards that use
this tea575x tuner?
   
Note that these two patches rely on other work that I did and that
hasn't been merged yet. So it is best to pull from my git tree:
   
http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/radi
   o-pc i2
   
You can use the v4l-utils repository
(http://git.linuxtv.org/v4l-utils.git) to test the drivers: the
v4l2-compliance test should succeed and with v4l2-ctl you can test the
hardware seek:
   
To seek down:
   
v4l2-ctl -d /dev/radio0 --freq-seek=dir=0
   
To seek up:
   
v4l2-ctl -d /dev/radio0 --freq-seek=dir=1
   
To do the compliance test:
   
v4l2-compliance -r /dev/radio0
  
   It seems to work (tested with SF64-PCR - snd_fm801) but the seek is
   severely broken. Reading the frequency immediately after seek does not
   work, it always returns the old value (haven't found a delay that works).
   Reading it later (copied back snd_tea575x_get_freq function) works. The
   chip seeks randomly up or down, ignoring UP/DOWN flag and often stops at
   wrong place (only noise) or even outside the FM range.
  
   So I strongly suggest not to enable this (mis-)feature. The HW seems to
   be completely broken (unless there's some weird bug in the code).
 
  Well, it seemed like a good idea at the time :-) I'll remove this
  'feature', it's really not worth our time to try and make this work for
  these old cards.
 
 I fixed it somehow. Now it works most of the time.
 The important things:
  - a delay must be present after search start and before first register read
or the seek does weird things
  - when the search stops, the new frequency is not available immediately, we
must wait until it appears in the register (fortunately, we can clear the
frequency bits when starting the search as it starts at the frequency
currently set, not from the value written)
  - sometimes, seek remains on the current frequency (or moves only a little),
so repeat it until it moves by at least 50 kHz

Thanks! And I'm impressed that you spent all that time on this old hardware :-)

Can I get your Signed-off-by line for this patch?

Regards,

Hans

 
 --- a/sound/i2c/other/tea575x-tuner.c
 +++ b/sound/i2c/other/tea575x-tuner.c
 @@ -89,7 +89,7 @@ static void snd_tea575x_write(struct snd_tea575x *tea, 
 unsigned int val)
   tea-ops-set_pins(tea, 0);
  }
  
 -static unsigned int snd_tea575x_read(struct snd_tea575x *tea)
 +static u32 snd_tea575x_read(struct snd_tea575x *tea)
  {
   u16 l, rdata;
   u32 data = 0;
 @@ -120,6 +120,27 @@ static unsigned int snd_tea575x_read(struct snd_tea575x 
 *tea)
   return data;
  }
  
 +static void snd_tea575x_get_freq(struct snd_tea575x *tea)
 +{
 + u32 freq = snd_tea575x_read(tea)  TEA575X_BIT_FREQ_MASK;
 +
 + if (freq == 0) {
 + tea-freq = 0;
 + return;
 + }
 +
 + /* freq *= 12.5 */
 + freq *= 125;
 + freq /= 10;
 + /* crystal fixup */
 + if (tea-tea5759)
 + freq += TEA575X_FMIF;
 + else
 + freq -= TEA575X_FMIF;
 +
 + tea-freq = clamp(freq * 16, FREQ_LO, FREQ_HI); /* from kHz */
 +}
 +
  static void snd_tea575x_set_freq(struct snd_tea575x *tea)
  {
   u32 freq = tea-freq;
 @@ -203,6 +224,8 @@ static int vidioc_g_frequency(struct file *file, void 
 *priv,
   if (f-tuner != 0)
   return -EINVAL;
   f-type = V4L2_TUNER_RADIO;
 + if (!tea-cannot_read_data)
 + snd_tea575x_get_freq(tea);
   f-frequency = tea-freq;
   return 0;
  }
 @@ -225,36 +248,50 @@ static int vidioc_s_hw_freq_seek(struct file *file, 
 void *fh,
   struct v4l2_hw_freq_seek *a)
  {
   struct snd_tea575x *tea = video_drvdata(file);
 + int i, old_freq;
 + unsigned long timeout;
  
   if (tea-cannot_read_data)
   return -ENOTTY;
 +
 + snd_tea575x_get_freq(tea);
 + old_freq = tea-freq;
 + /* clear the frequency, HW will fill it in */
 + tea-val = ~TEA575X_BIT_FREQ_MASK;
   tea-val |= TEA575X_BIT_SEARCH;
 - tea-val = ~TEA575X_BIT_UPDOWN;
   if (a-seek_upward)
   tea-val |= TEA575X_BIT_UPDOWN;
 + else
 + 

Re: [RFC/PATCH 1/6] V4L: Add V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 media bus format

2012-02-17 Thread Laurent Pinchart
Hi Sylwester,

On Friday 17 February 2012 15:26:29 Sylwester Nawrocki wrote:
 On 02/16/2012 08:46 PM, Sakari Ailus wrote:
  On Thu, Feb 16, 2012 at 07:23:54PM +0100, Sylwester Nawrocki wrote:
  This patch adds media bus pixel code for the interleaved JPEG/YUYV image
  format used by S5C73MX Samsung cameras. The interleaved image data is
  transferred on MIPI-CSI2 bus as User Defined Byte-based Data.
  
  Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
  
   include/linux/v4l2-mediabus.h |3 +++
   1 files changed, 3 insertions(+), 0 deletions(-)
  
  diff --git a/include/linux/v4l2-mediabus.h
  b/include/linux/v4l2-mediabus.h
  index 5ea7f75..c2f0e4e 100644
  --- a/include/linux/v4l2-mediabus.h
  +++ b/include/linux/v4l2-mediabus.h
  @@ -92,6 +92,9 @@ enum v4l2_mbus_pixelcode {
  
 /* JPEG compressed formats - next is 0x4002 */
 V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
  
  +
  +  /* Interleaved JPEG and YUV formats - next is 0x4102 */
  +  V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 = 0x4101,
  
   };

Please remember to update Documentation/DocBook/media/v4l/subdev-formats.xml.

  Thanks for the patch. Just a tiny comment:
  
  I'd go with a new hardware-specific buffer range, e.g. 0x5000.
 
 Sure, that makes more sense. But I guess you mean format not buffer
 range ?

  Guennadi also proposed an interesting idea: a pass-through format. Does
  your format have dimensions that the driver would use for something or is
  that just a blob?
 
 It's just a blob for the drivers, dimensions may be needed for subdevs to
 compute overall size of data for example. But the host driver, in case of
 Samsung devices, basically just needs to know the total size of frame data.
 
 I'm afraid the host would have to additionally configure subdevs in the data
 pipeline in case of hardware-specific format, when we have used a single
 binary blob media bus format identifier. For example MIPI-CSI2 data format
 would have to be set up along the pipeline. There might be more attributes
 in the future like this. Not sure if we want to go that path ?
 
 I'll try and see how it would look like with a single pass-through format.
 Probably using g/s_mbus_config operations ?

I'm not sure yet how all this should be handled exactly, but I'm pretty sure I 
don't want the CSI2 receiver drivers to handle all the vendor-specific blob-
like formats explicitly. For instance your sensor could be used with the OMAP3 
ISP, and I don't want to add support for V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 to the 
OMAP3 ISP CSI2 driver. We need a way for CSI2 receiver drivers to map blob 
formats automatically. Enumeration also needs to be handled, which makes the 
problem even more complex.

-- 
Regards,

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


Re: [RFC/PATCH 3/6] V4L: Add g_embedded_data subdev callback

2012-02-17 Thread Laurent Pinchart
Hi Sylwester,

Thanks for the patch.

On Thursday 16 February 2012 19:23:56 Sylwester Nawrocki wrote:
 The g_embedded_data callback allows the host to retrieve frame embedded
 (meta) data from a certain subdev. This callback can be implemented by
 an image sensor or a MIPI-CSI receiver, allowing to read embedded frame
 data from a subdev or just query it for the data size.
 
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  include/media/v4l2-subdev.h |   10 ++
  1 files changed, 10 insertions(+), 0 deletions(-)
 
 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
 index f0f3358..be74061 100644
 --- a/include/media/v4l2-subdev.h
 +++ b/include/media/v4l2-subdev.h
 @@ -274,6 +274,14 @@ struct v4l2_subdev_audio_ops {
 s_mbus_config: set a certain mediabus configuration. This operation is
 added for compatibility with soc-camera drivers and should not be used by
 new software.
 +
 +   g_embedded_data: retrieve the frame embedded data (frame header or
 footer). +After a full frame has been transmitted the host can query a
 subdev +  for frame meta data using this operation. Metadata size is
 returned +in @size, and the actual metadata in memory pointed by @data.
 When +@buf is NULL the subdev will return only the metadata size. The
 + subdevs can adjust @size to a lower value but must not write more
 + data than the @size's original value.
   */
  struct v4l2_subdev_video_ops {
   int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32
 config); @@ -321,6 +329,8 @@ struct v4l2_subdev_video_ops {
struct v4l2_mbus_config *cfg);
   int (*s_mbus_config)(struct v4l2_subdev *sd,
const struct v4l2_mbus_config *cfg);
 + int (*g_embedded_data)(struct v4l2_subdev *sd, unsigned int *size,
 +void **buf);
  };

How is the embedded data transferred from the sensor to the host in your case 
? Over I2C ?

-- 
Regards,

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


Re: OMAP CCDC with sensors that are always on...

2012-02-17 Thread Chris Whittenburg
I fixed my sensor to respect a run signal from the omap, so that now
it only sends data when the ccdc is expecting it.

This fixed my problem, and now I can capture the 640x1440 frames.

At least the first one...

Subsequent frames are always full of 0x55, like the ISP didn't write
anything into them.

I still get the VD0 interrupts, and I checked that WEN in the
CCDC_SYN_MODE register is set, and that the EXWEN bit is clear.

I'm using the command:
yavta -c2 -p -F --skip 0 -f Y8 -s 640x1440 /dev/video2

Here are my register settings:

[ 6534.029907] omap3isp omap3isp: -CCDC Register dump-
[ 6534.029907] omap3isp omap3isp: ###CCDC PCR=0x
[ 6534.029937] omap3isp omap3isp: ###CCDC SYN_MODE=0x00030f00
[ 6534.029937] omap3isp omap3isp: ###CCDC HD_VD_WID=0x
[ 6534.029937] omap3isp omap3isp: ###CCDC PIX_LINES=0x
[ 6534.029968] omap3isp omap3isp: ###CCDC HORZ_INFO=0x027f
[ 6534.029968] omap3isp omap3isp: ###CCDC VERT_START=0x
[ 6534.029968] omap3isp omap3isp: ###CCDC VERT_LINES=0x059f
[ 6534.029998] omap3isp omap3isp: ###CCDC CULLING=0x00ff
[ 6534.029998] omap3isp omap3isp: ###CCDC HSIZE_OFF=0x0280
[ 6534.029998] omap3isp omap3isp: ###CCDC SDOFST=0x
[ 6534.030029] omap3isp omap3isp: ###CCDC SDR_ADDR=0x1000
[ 6534.030029] omap3isp omap3isp: ###CCDC CLAMP=0x0010
[ 6534.030029] omap3isp omap3isp: ###CCDC DCSUB=0x
[ 6534.030059] omap3isp omap3isp: ###CCDC COLPTN=0xbb11bb11
[ 6534.030059] omap3isp omap3isp: ###CCDC BLKCMP=0x
[ 6534.030059] omap3isp omap3isp: ###CCDC FPC=0x
[ 6534.030090] omap3isp omap3isp: ###CCDC FPC_ADDR=0x
[ 6534.030090] omap3isp omap3isp: ###CCDC VDINT=0x059e03c0
[ 6534.030090] omap3isp omap3isp: ###CCDC ALAW=0x
[ 6534.030120] omap3isp omap3isp: ###CCDC REC656IF=0x
[ 6534.030120] omap3isp omap3isp: ###CCDC CFG=0x8000
[ 6534.030120] omap3isp omap3isp: ###CCDC FMTCFG=0xe000
[ 6534.030151] omap3isp omap3isp: ###CCDC FMT_HORZ=0x0280
[ 6534.030151] omap3isp omap3isp: ###CCDC FMT_VERT=0x05a0
[ 6534.030151] omap3isp omap3isp: ###CCDC PRGEVEN0=0x
[ 6534.030181] omap3isp omap3isp: ###CCDC PRGEVEN1=0x
[ 6534.030181] omap3isp omap3isp: ###CCDC PRGODD0=0x
[ 6534.030181] omap3isp omap3isp: ###CCDC PRGODD1=0x
[ 6534.030212] omap3isp omap3isp: ###CCDC VP_OUT=0x0b3e2800
[ 6534.030212] omap3isp omap3isp: ###CCDC LSC_CONFIG=0x6600
[ 6534.030212] omap3isp omap3isp: ###CCDC LSC_INITIAL=0x
[ 6534.030242] omap3isp omap3isp: ###CCDC LSC_TABLE_BASE=0x
[ 6534.030242] omap3isp omap3isp: ###CCDC LSC_TABLE_OFFSET=0x
[ 6534.030242] omap3isp omap3isp: 

Output frame 0 is always good, while output frame 1 is 0x.

I believe my sensor is respecting the clocks required before and after
the frame.

Could the ISP driver be writing my data to some unexpected location
rather than to the v4l2 buffer?

Is there a way to determine if the CCDC is writing to memory or not?

Thanks for any points,
Chris



On Wed, Feb 15, 2012 at 11:29 AM, Chris Whittenburg
whittenb...@gmail.com wrote:
 Maybe this is more of a OMAP specific question, but I'm using a
 beagleboard-xm with a custom image sensor on a 3.0.17 kernel.

 Everything configures ok with:

 media-ctl -r
 media-ctl -l 'xrtcam 2-0048:0-OMAP3 ISP CCDC:0[1]'
 media-ctl -l 'OMAP3 ISP CCDC:1-OMAP3 ISP CCDC output:0[1]'
 media-ctl -f 'xrtcam 2-0048:0 [Y8 640x1440]'
 media-ctl -f 'OMAP3 ISP CCDC:1 [Y8 640x1440]'
 media-ctl -e 'OMAP3 ISP CCDC output'

 root@beagleboard:~# ./setup.sh
 Resetting all links to inactive
 Setting up link 16:0 - 5:0 [1]
 Setting up link 5:1 - 6:0 [1]
 Setting up format Y8 640x1440 on pad irtcam 2-0048/0
 Format set: Y8 640x1440
 Setting up format Y8 640x1440 on pad OMAP3 ISP CCDC/0
 Format set: Y8 640x1440
 Setting up format Y8 640x1440 on pad OMAP3 ISP CCDC/1
 Format set: Y8 640x1440
 /dev/video2

 But when I go to capture, with:
 yavta -c2 -p -F --skip 0 -f Y8 -s 640x1440 /dev/video2

 I don't seem to get any interrupts.  Actually I get some HS_VS_IRQ
 after I launch yavta, but before I press return at the Press enter to
 start capture prompt.  After that, I don't believe I am getting any
 interrupts.

 The one problem I see is that my sensor is always spewing data into
 the CCDC on HS,VS, PCLK, and D0 to D7.

 I know I have been told with other sensors that I need to only turn
 XCLK on to the sensor when I am capturing.

 Could this be my problem here?  What exactly happens if you are always
 sending data?  Does the ISP get hung up?

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


Re: [RFC/PATCH 3/6] V4L: Add g_embedded_data subdev callback

2012-02-17 Thread Sylwester Nawrocki

Hi Laurent,

On 02/18/2012 12:23 AM, Laurent Pinchart wrote:

  struct v4l2_subdev_video_ops {
int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32
config); @@ -321,6 +329,8 @@ struct v4l2_subdev_video_ops {
 struct v4l2_mbus_config *cfg);
int (*s_mbus_config)(struct v4l2_subdev *sd,
 const struct v4l2_mbus_config *cfg);
+   int (*g_embedded_data)(struct v4l2_subdev *sd, unsigned int *size,
+  void **buf);
  };


How is the embedded data transferred from the sensor to the host in your case
? Over I2C ?


It's transferred over MIPI-CSI2 bus and is intercepted by the MIPI-CSI2
receiver, before the image data DMA. The MIPI-CSI2 doesn't have its own
DMA engine. More details can be found in patch 6/6.

--

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


Re: [patch 1/2] [media] s2255drv: cleanup vidioc_enum_fmt_cap()

2012-02-17 Thread dean anderson

Thanks Dan,

I can sign off on this.  The check isn't required.

Signed-off-by: Dean Anderson linux-...@sensoray.com

On 2/16/2012 10:43 PM, Dan Carpenter wrote:

f wasn't checked consistently, so static checkers complain.  This
function is always called with a valid f pointer, so I have removed
the check.

Also the indenting was messed up.

Signed-off-by: Dan Carpenterdan.carpen...@oracle.com

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index c1bef61..3505242 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -852,15 +852,13 @@ static int vidioc_querycap(struct file *file, void *priv,
  static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
   struct v4l2_fmtdesc *f)
  {
-   int index = 0;
-   if (f)
-   index = f-index;
+   int index = f-index;

if (index= ARRAY_SIZE(formats))
return -EINVAL;
-if (!jpeg_enable  ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
-(formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
-   return -EINVAL;
+   if (!jpeg_enable  ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
+   (formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
+   return -EINVAL;
dprintk(4, name %s\n, formats[index].name);
strlcpy(f-description, formats[index].name, sizeof(f-description));
f-pixelformat = formats[index].fourcc;
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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


Re: [PATCHv22 00/16] Contiguous Memory Allocator

2012-02-17 Thread Anca Emanuel
Do you have an git tree ?
Now is time to include this in next.
Please add Stephen Rothwell s...@canb.auug.org.au to CC.

If you not have an git tree, ask somebody to take it NOW in a next tree.
I want to see this in linux 3.4
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 3/6] V4L: Add g_embedded_data subdev callback

2012-02-17 Thread Laurent Pinchart
Hi Sylwester,

On Saturday 18 February 2012 00:33:23 Sylwester Nawrocki wrote:
 On 02/18/2012 12:23 AM, Laurent Pinchart wrote:
struct v4l2_subdev_video_ops {

 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32
  
  config); @@ -321,6 +329,8 @@ struct v4l2_subdev_video_ops {
  
  struct v4l2_mbus_config *cfg);
 
 int (*s_mbus_config)(struct v4l2_subdev *sd,
 
  const struct v4l2_mbus_config *cfg);
  
  +  int (*g_embedded_data)(struct v4l2_subdev *sd, unsigned int *size,
  + void **buf);
  
};
  
  How is the embedded data transferred from the sensor to the host in your
  case ? Over I2C ?
 
 It's transferred over MIPI-CSI2 bus and is intercepted by the MIPI-CSI2
 receiver, before the image data DMA. The MIPI-CSI2 doesn't have its own
 DMA engine. More details can be found in patch 6/6.

As the data is transmitted by the device without any polling from the host, 
shouldn't it just go to a metadata plane in the V4L2 buffer ?

-- 
Regards,

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


Re: [RFC/PATCH 3/6] V4L: Add g_embedded_data subdev callback

2012-02-17 Thread Sakari Ailus
Hi Laurent,

Laurent Pinchart wrote:
 On Saturday 18 February 2012 00:33:23 Sylwester Nawrocki wrote:
 On 02/18/2012 12:23 AM, Laurent Pinchart wrote:
   struct v4l2_subdev_video_ops {
   
int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32

 config); @@ -321,6 +329,8 @@ struct v4l2_subdev_video_ops {

 struct v4l2_mbus_config *cfg);

int (*s_mbus_config)(struct v4l2_subdev *sd,

 const struct v4l2_mbus_config *cfg);

 +  int (*g_embedded_data)(struct v4l2_subdev *sd, unsigned int *size,
 + void **buf);

   };

 How is the embedded data transferred from the sensor to the host in your
 case ? Over I2C ?

 It's transferred over MIPI-CSI2 bus and is intercepted by the MIPI-CSI2
 receiver, before the image data DMA. The MIPI-CSI2 doesn't have its own
 DMA engine. More details can be found in patch 6/6.
 
 As the data is transmitted by the device without any polling from the host, 
 shouldn't it just go to a metadata plane in the V4L2 buffer ?

I'd say that if it can be given to the user space separately, a way
should be provided to do that. It's all about timing: software
controlled digital camera depend on that.

Some receivers are also able to put such metadata into a separate memory
area using DMA, such as the OMAP 3 ISP CCP-2 receiver.

Cheers,

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


[PATCH] Add support for KWorld PC150-U ATSC hybrid tuner card.

2012-02-17 Thread Kyle Strickland
Signed-off-by: Kyle Strickland k...@kyle.strickland.name
---
 Documentation/dvb/cards.txt |1 +
 drivers/media/rc/keymaps/Makefile   |1 +
 drivers/media/rc/keymaps/rc-kworld-pc150u.c |  102 +++
 drivers/media/video/saa7134/saa7134-cards.c |   59 +++
 drivers/media/video/saa7134/saa7134-dvb.c   |   43 +++
 drivers/media/video/saa7134/saa7134-i2c.c   |   12 +++-
 drivers/media/video/saa7134/saa7134-input.c |   63 
 drivers/media/video/saa7134/saa7134.h   |1 +
 include/media/rc-map.h  |1 +
 9 files changed, 282 insertions(+), 1 deletions(-)
 create mode 100644 drivers/media/rc/keymaps/rc-kworld-pc150u.c

diff --git a/Documentation/dvb/cards.txt b/Documentation/dvb/cards.txt
index cc09187..97709e9 100644
--- a/Documentation/dvb/cards.txt
+++ b/Documentation/dvb/cards.txt
@@ -119,4 +119,5 @@ o Cards based on the Phillips saa7134 PCI bridge:
   - Compro Videomate DVB-T300
   - Compro Videomate DVB-T200
   - AVerMedia AVerTVHD MCE A180
+  - KWorld PC150-U ATSC Hybrid
 
diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 9514d82..49ce266 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-it913x-v2.o \
rc-kaiomy.o \
rc-kworld-315u.o \
+   rc-kworld-pc150u.o \
rc-kworld-plus-tv-analog.o \
rc-leadtek-y04g0051.o \
rc-lirc.o \
diff --git a/drivers/media/rc/keymaps/rc-kworld-pc150u.c 
b/drivers/media/rc/keymaps/rc-kworld-pc150u.c
new file mode 100644
index 000..233bb5e
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-kworld-pc150u.c
@@ -0,0 +1,102 @@
+/* kworld-pc150u.c - Keytable for kworld_pc150u Remote Controller
+ *
+ * keymap imported from ir-keymaps.c
+ *
+ * Copyright (c) 2010 by Kyle Strickland
+ *   (based on kworld-plus-tv-analog.c by
+ *Mauro Carvalho Chehab mche...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include media/rc-map.h
+#include linux/module.h
+
+/* Kworld PC150-U
+   Kyle Strickland k...@kyle.strickland.name
+ */
+
+static struct rc_map_table kworld_pc150u[] = {
+   { 0x0c, KEY_MEDIA },/* Kworld key */
+   { 0x16, KEY_EJECTCLOSECD }, /* - ) */
+   { 0x1d, KEY_POWER2 },
+
+   { 0x00, KEY_1 },
+   { 0x01, KEY_2 },
+   { 0x02, KEY_3 },
+   { 0x03, KEY_4 },
+   { 0x04, KEY_5 },
+   { 0x05, KEY_6 },
+   { 0x06, KEY_7 },
+   { 0x07, KEY_8 },
+   { 0x08, KEY_9 },
+   { 0x0a, KEY_0 },
+
+   { 0x09, KEY_AGAIN },
+   { 0x14, KEY_MUTE },
+
+   { 0x1e, KEY_LAST },
+   { 0x17, KEY_ZOOM },
+   { 0x1f, KEY_HOMEPAGE },
+   { 0x0e, KEY_ESC },
+
+   { 0x20, KEY_UP },
+   { 0x21, KEY_DOWN },
+   { 0x42, KEY_LEFT },
+   { 0x43, KEY_RIGHT },
+   { 0x0b, KEY_ENTER },
+
+   { 0x10, KEY_CHANNELUP },
+   { 0x11, KEY_CHANNELDOWN },
+
+   { 0x13, KEY_VOLUMEUP },
+   { 0x12, KEY_VOLUMEDOWN },
+
+   { 0x19, KEY_TIME},  /* Timeshift */
+   { 0x1a, KEY_STOP},
+   { 0x1b, KEY_RECORD},
+   { 0x4b, KEY_EMAIL},
+
+   { 0x40, KEY_REWIND},
+   { 0x44, KEY_PLAYPAUSE},
+   { 0x41, KEY_FORWARD},
+   { 0x22, KEY_TEXT},
+
+   { 0x15, KEY_AUDIO}, /* ((*)) */
+   { 0x0f, KEY_MODE},  /* display ratio */
+   { 0x1c, KEY_SYSRQ}, /* snapshot */
+   { 0x4a, KEY_SLEEP}, /* sleep timer */
+
+   { 0x48, KEY_SOUND}, /* switch theater mode */
+   { 0x49, KEY_BLUE},  /* A */
+   { 0x18, KEY_RED},   /* B */
+   { 0x23, KEY_GREEN}, /* C */
+};
+
+static struct rc_map_list kworld_pc150u_map = {
+   .map = {
+   .scan= kworld_pc150u,
+   .size= ARRAY_SIZE(kworld_pc150u),
+   .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
+   .name= RC_MAP_KWORLD_PC150U,
+   }
+};
+
+static int __init init_rc_map_kworld_pc150u(void)
+{
+   return rc_map_register(kworld_pc150u_map);
+}
+
+static void __exit exit_rc_map_kworld_pc150u(void)
+{
+   rc_map_unregister(kworld_pc150u_map);
+}
+
+module_init(init_rc_map_kworld_pc150u)
+module_exit(exit_rc_map_kworld_pc150u)
+
+MODULE_LICENSE(GPL);
+MODULE_AUTHOR(Kyle Strickland k...@kyle.strickland.name);
diff --git a/drivers/media/video/saa7134/saa7134-cards.c 
b/drivers/media/video/saa7134/saa7134-cards.c
index 065d0f6..24b9201 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++