[PATCH v2 12/13] ARM: pxa: remove the DMA IO resources

2018-05-24 Thread Robert Jarzmik
As the last driver using the former mechanism to acquire the DMA
requestor line has be converted to the dma_slave_map, remove all these
resources from the PXA devices.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/devices.c | 136 
 1 file changed, 136 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index 1e8915fc340d..5a16ea74e28a 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -60,16 +60,6 @@ static struct resource pxamci_resources[] = {
.end= IRQ_MMC,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 21,
-   .end= 21,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   .start  = 22,
-   .end= 22,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 static u64 pxamci_dmamask = 0xUL;
@@ -407,16 +397,6 @@ static struct resource pxa_ir_resources[] = {
.end= 0x40700023,
.flags  = IORESOURCE_MEM,
},
-   [5] = {
-   .start  = 17,
-   .end= 17,
-   .flags  = IORESOURCE_DMA,
-   },
-   [6] = {
-   .start  = 18,
-   .end= 18,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa_device_ficp = {
@@ -545,18 +525,6 @@ static struct resource pxa25x_resource_ssp[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_ssp = {
@@ -583,18 +551,6 @@ static struct resource pxa25x_resource_nssp[] = {
.end= IRQ_NSSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_nssp = {
@@ -621,18 +577,6 @@ static struct resource pxa25x_resource_assp[] = {
.end= IRQ_ASSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 23,
-   .end= 23,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 24,
-   .end= 24,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_assp = {
@@ -751,18 +695,6 @@ static struct resource pxa27x_resource_ssp1[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp1 = {
@@ -789,18 +721,6 @@ static struct resource pxa27x_resource_ssp2[] = {
.end= IRQ_SSP2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp2 = {
@@ -827,18 +747,6 @@ static struct resource pxa27x_resource_ssp3[] = {
.end= IRQ_SSP3,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 66,
-   .end= 66,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 67,
-   .end= 67,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp3 = {
@@ -895,16 +803,6 @@ static struct resource pxa3xx_resources_mci2[] = {
.end= IRQ_MMC2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 93,
-   .end= 93,
-   .flags  = IORESOURCE_DMA,
-   },
-   

[PATCH v2 06/13] net: smc911x: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc911x.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index 05157442a980..4c3713bd5caa 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -74,7 +74,6 @@ static const char version[] =
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -1794,8 +1793,6 @@ static int smc911x_probe(struct net_device *dev)
unsigned long irq_flags;
 #ifdef SMC_USE_DMA
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
 #endif
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
@@ -1969,17 +1966,8 @@ static int smc911x_probe(struct net_device *dev)
 
 #ifdef SMC_USE_DMA
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
-   lp->rxdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "rx");
-   lp->txdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "tx");
+   lp->rxdma = dma_request_slave_channel(>dev, "rx");
+   lp->txdma = dma_request_slave_channel(>dev, "tx");
lp->rxdma_active = 0;
lp->txdma_active = 0;
 
-- 
2.11.0



[PATCH v2 02/13] ARM: pxa: add dma slave map

2018-05-24 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
---
Since v1: revamped the SSP part, split into pxa25.c, pxa27x.c and
  pxa3xx.c, and add pxa-i2s.
---
 arch/arm/mach-pxa/devices.c | 12 +++-
 arch/arm/mach-pxa/devices.h |  6 +-
 arch/arm/mach-pxa/pxa25x.c  | 41 -
 arch/arm/mach-pxa/pxa27x.c  | 42 +-
 arch/arm/mach-pxa/pxa3xx.c  | 44 +++-
 5 files changed, 132 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index d7c9a8476d57..1e8915fc340d 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1202,11 +1203,6 @@ void __init pxa2xx_set_spi_info(unsigned id, struct 
pxa2xx_spi_master *info)
platform_device_add(pd);
 }
 
-static struct mmp_dma_platdata pxa_dma_pdata = {
-   .dma_channels   = 0,
-   .nb_requestors  = 0,
-};
-
 static struct resource pxa_dma_resource[] = {
[0] = {
.start  = 0x4000,
@@ -1233,9 +1229,7 @@ static struct platform_device pxa2xx_pxa_dma = {
.resource   = pxa_dma_resource,
 };
 
-void __init pxa2xx_set_dmac_info(int nb_channels, int nb_requestors)
+void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata)
 {
-   pxa_dma_pdata.dma_channels = nb_channels;
-   pxa_dma_pdata.nb_requestors = nb_requestors;
-   pxa_register_device(_pxa_dma, _dma_pdata);
+   pxa_register_device(_pxa_dma, dma_pdata);
 }
diff --git a/arch/arm/mach-pxa/devices.h b/arch/arm/mach-pxa/devices.h
index 11263f7c455b..498b07bc6a3e 100644
--- a/arch/arm/mach-pxa/devices.h
+++ b/arch/arm/mach-pxa/devices.h
@@ -1,4 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#define PDMA_FILTER_PARAM(_prio, _requestor) (&(struct pxad_param) { \
+   .prio = PXAD_PRIO_##_prio, .drcmr = _requestor })
+struct mmp_dma_platdata;
+
 extern struct platform_device pxa_device_pmu;
 extern struct platform_device pxa_device_mci;
 extern struct platform_device pxa3xx_device_mci2;
@@ -55,7 +59,7 @@ extern struct platform_device pxa3xx_device_gpio;
 extern struct platform_device pxa93x_device_gpio;
 
 void __init pxa_register_device(struct platform_device *dev, void *data);
-void __init pxa2xx_set_dmac_info(int nb_channels, int nb_requestors);
+void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata);
 
 struct i2c_pxa_platform_data;
 extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index ba431fad5c47..2d61de41a9d5 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -16,6 +16,8 @@
  * initialization stuff for PXA machines which can be overridden later if
  * need be.
  */
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -201,6 +204,42 @@ static struct platform_device *pxa25x_devices[] __initdata 
= {
_device_asoc_platform,
 };
 
+static const struct dma_slave_map pxa25x_slave_map[] = {
+   /* PXA25x, PXA27x and PXA3xx common entries */
+   { "pxa2xx-ac97", "pcm_pcm_mic_mono", PDMA_FILTER_PARAM(LOWEST, 8) },
+   { "pxa2xx-ac97", "pcm_pcm_aux_mono_in", PDMA_FILTER_PARAM(LOWEST, 9) },
+   { "pxa2xx-ac97", "pcm_pcm_aux_mono_out",
+ PDMA_FILTER_PARAM(LOWEST, 10) },
+   { "pxa2xx-ac97", "pcm_pcm_stereo_in", PDMA_FILTER_PARAM(LOWEST, 11) },
+   { "pxa2xx-ac97", "pcm_pcm_stereo_out", PDMA_FILTER_PARAM(LOWEST, 12) },
+   { "pxa-ssp-dai.1", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa-ssp-dai.1", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa-ssp-dai.2", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-ssp-dai.2", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa2xx-ir", "rx", PDMA_FILTER_PARAM(LOWEST, 17) },
+   { "pxa2xx-ir", "tx", PDMA_FILTER_PARAM(LOWEST, 18) },
+   { "pxa2xx-mci.0", "rx", PDMA_FILTER_PARAM(LOWEST, 21) },
+   { "pxa2xx-mci.0", "tx", PDMA_FILTER_PARAM(LOWEST, 22) },
+   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc91x.0", "da

[PATCH v2 09/13] ata: pata_pxa: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnier...@samsung.com>
---
 drivers/ata/pata_pxa.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index f6c46e9a4dc0..e8b6a2e464c9 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -180,8 +179,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
struct resource *irq_res;
struct pata_pxa_pdata *pdata = dev_get_platdata(>dev);
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret = 0;
 
/*
@@ -278,10 +275,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
 
ap->private_data = data;
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = pdata->dma_dreq;
memset(, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
config.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -294,8 +287,7 @@ static int pxa_ata_probe(struct platform_device *pdev)
 * Request the DMA channel
 */
data->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "data");
+   dma_request_slave_channel(>dev, "data");
if (!data->dma_chan)
return -EBUSY;
ret = dmaengine_slave_config(data->dma_chan, );
-- 
2.11.0



[PATCH v2 08/13] ASoC: pxa: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 sound/arm/pxa2xx-ac97.c | 14 ++
 sound/arm/pxa2xx-pcm-lib.c  |  6 +++---
 sound/soc/pxa/pxa2xx-ac97.c | 32 +---
 sound/soc/pxa/pxa2xx-i2s.c  |  6 ++
 4 files changed, 12 insertions(+), 46 deletions(-)

diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 4bc244c40f80..236a63cdaf9f 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -63,28 +63,18 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_legacy_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_out_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_in_req,
 };
 
 static struct snd_pcm *pxa2xx_ac97_pcm;
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index e8da3b8ee721..dcbe7ecc1835 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -125,9 +125,9 @@ int __pxa2xx_pcm_open(struct snd_pcm_substream *substream)
if (ret < 0)
return ret;
 
-   return snd_dmaengine_pcm_open_request_chan(substream,
-   pxad_filter_fn,
-   dma_params->filter_data);
+   return snd_dmaengine_pcm_open(
+   substream, dma_request_slave_channel(rtd->cpu_dai->dev,
+dma_params->chan_name));
 }
 EXPORT_SYMBOL(__pxa2xx_pcm_open);
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 803818aabee9..1b41c0f2a8fb 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -68,61 +68,39 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_cold_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_stereo_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_in_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_stereo_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 10,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_out",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 9,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_in",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_in_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mic_mono_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 8,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = {
.addr   = __PREG(MCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mic_mono",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mic_mono_req,
 };
 
 static int pxa2xx_ac97_hifi_startup(s

[PATCH v2 03/13] mmc: pxamci: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Ulf Hansson <ulf.hans...@linaro.org>
---
 drivers/mmc/host/pxamci.c | 29 +++--
 1 file changed, 3 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index c763b404510f..6c94474e36f4 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -637,10 +636,8 @@ static int pxamci_probe(struct platform_device *pdev)
 {
struct mmc_host *mmc;
struct pxamci_host *host = NULL;
-   struct resource *r, *dmarx, *dmatx;
-   struct pxad_param param_rx, param_tx;
+   struct resource *r;
int ret, irq, gpio_cd = -1, gpio_ro = -1, gpio_power = -1;
-   dma_cap_mask_t mask;
 
ret = pxamci_of_init(pdev);
if (ret)
@@ -739,34 +736,14 @@ static int pxamci_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mmc);
 
-   if (!pdev->dev.of_node) {
-   dmarx = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   dmatx = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (!dmarx || !dmatx) {
-   ret = -ENXIO;
-   goto out;
-   }
-   param_rx.prio = PXAD_PRIO_LOWEST;
-   param_rx.drcmr = dmarx->start;
-   param_tx.prio = PXAD_PRIO_LOWEST;
-   param_tx.drcmr = dmatx->start;
-   }
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-
-   host->dma_chan_rx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_rx, >dev, "rx");
+   host->dma_chan_rx = dma_request_slave_channel(>dev, "rx");
if (host->dma_chan_rx == NULL) {
dev_err(>dev, "unable to request rx dma channel\n");
ret = -ENODEV;
goto out;
}
 
-   host->dma_chan_tx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_tx,  >dev, "tx");
+   host->dma_chan_tx = dma_request_slave_channel(>dev, "tx");
if (host->dma_chan_tx == NULL) {
dev_err(>dev, "unable to request tx dma channel\n");
ret = -ENODEV;
-- 
2.11.0



[PATCH v2 11/13] dmaengine: pxa: make the filter function internal

2018-05-24 Thread Robert Jarzmik
As the pxa architecture and all its related drivers do not rely anymore
on the filter function, thanks to the slave map conversion, make
pxad_filter_fn() static, and remove it from the global namespace.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/dma/pxa_dma.c   |  5 ++---
 include/linux/dma/pxa-dma.h | 11 ---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 9505334f9c6e..a332ad1d7dfb 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,7 +179,7 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
+static bool pxad_filter_fn(struct dma_chan *chan, void *param);
 
 /*
  * Debug fs
@@ -1496,7 +1496,7 @@ static struct platform_driver pxad_driver = {
.remove = pxad_remove,
 };
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param)
+static bool pxad_filter_fn(struct dma_chan *chan, void *param)
 {
struct pxad_chan *c = to_pxad_chan(chan);
struct pxad_param *p = param;
@@ -1509,7 +1509,6 @@ bool pxad_filter_fn(struct dma_chan *chan, void *param)
 
return true;
 }
-EXPORT_SYMBOL_GPL(pxad_filter_fn);
 
 module_platform_driver(pxad_driver);
 
diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index 9fc594f69eff..fceb5df07097 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -23,15 +23,4 @@ struct pxad_param {
enum pxad_chan_prio prio;
 };
 
-struct dma_chan;
-
-#ifdef CONFIG_PXA_DMA
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
-#else
-static inline bool pxad_filter_fn(struct dma_chan *chan, void *param)
-{
-   return false;
-}
-#endif
-
 #endif /* _PXA_DMA_H_ */
-- 
2.11.0



[PATCH v2 10/13] dmaengine: pxa: document pxad_param

2018-05-24 Thread Robert Jarzmik
Add some documentation for the pxad_param structure, and describe the
contract behind the minimal required priority of a DMA channel.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 include/linux/dma/pxa-dma.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index e56ec7af4fd7..9fc594f69eff 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -9,6 +9,15 @@ enum pxad_chan_prio {
PXAD_PRIO_LOWEST,
 };
 
+/**
+ * struct pxad_param - dma channel request parameters
+ * @drcmr: requestor line number
+ * @prio: minimal mandatory priority of the channel
+ *
+ * If a requested channel is granted, its priority will be at least @prio,
+ * ie. if PXAD_PRIO_LOW is required, the requested channel will be either
+ * PXAD_PRIO_LOW, PXAD_PRIO_NORMAL or PXAD_PRIO_HIGHEST.
+ */
 struct pxad_param {
unsigned int drcmr;
enum pxad_chan_prio prio;
-- 
2.11.0



[PATCH v2 05/13] mtd: rawnand: marvell: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Signed-off-by: Daniel Mack <dan...@zonque.org>
Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/mtd/nand/raw/marvell_nand.c | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/raw/marvell_nand.c 
b/drivers/mtd/nand/raw/marvell_nand.c
index 10e953218948..f9763be078ef 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -2613,8 +2613,6 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
dev);
struct dma_slave_config config = {};
struct resource *r;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret;
 
if (!IS_ENABLED(CONFIG_PXA_DMA)) {
@@ -2627,20 +2625,7 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
if (ret)
return ret;
 
-   r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   if (!r) {
-   dev_err(nfc->dev, "No resource defined for data DMA\n");
-   return -ENXIO;
-   }
-
-   param.drcmr = r->start;
-   param.prio = PXAD_PRIO_LOWEST;
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   nfc->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, nfc->dev,
-"data");
+   nfc->dma_chan = dma_request_slave_channel(>dev, "data");
if (!nfc->dma_chan) {
dev_err(nfc->dev,
"Unable to request data DMA channel\n");
-- 
2.11.0



[PATCH v2 04/13] media: pxa_camera: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Hans Verkuil <hans.verk...@cisco.com>
Acked-by: Mauro Carvalho Chehab <mchehab+sams...@kernel.org>
---
 drivers/media/platform/pxa_camera.c | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index c71a00736541..4c82d1880753 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
.src_maxburst = 8,
.direction = DMA_DEV_TO_MEM,
};
-   dma_cap_mask_t mask;
-   struct pxad_param params;
char clk_name[V4L2_CLK_NAME_SIZE];
int irq;
int err = 0, i;
@@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
*pdev)
pcdev->base = base;
 
/* request dma */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   dma_cap_set(DMA_PRIVATE, mask);
-
-   params.prio = 0;
-   params.drcmr = 68;
-   pcdev->dma_chans[0] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_Y");
+   pcdev->dma_chans[0] = dma_request_slave_channel(>dev, "CI_Y");
if (!pcdev->dma_chans[0]) {
dev_err(>dev, "Can't request DMA for Y\n");
return -ENODEV;
}
 
-   params.drcmr = 69;
-   pcdev->dma_chans[1] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_U");
+   pcdev->dma_chans[1] = dma_request_slave_channel(>dev, "CI_U");
if (!pcdev->dma_chans[1]) {
dev_err(>dev, "Can't request DMA for Y\n");
err = -ENODEV;
goto exit_free_dma_y;
}
 
-   params.drcmr = 70;
-   pcdev->dma_chans[2] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_V");
+   pcdev->dma_chans[2] = dma_request_slave_channel(>dev, "CI_V");
if (!pcdev->dma_chans[2]) {
dev_err(>dev, "Can't request DMA for V\n");
err = -ENODEV;
-- 
2.11.0



[PATCH v2 01/13] dmaengine: pxa: use a dma slave map

2018-05-24 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This won't impact MMP architecture, but is aimed only at all PXA boards.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
Acked-by: Vinod Koul <vk...@kernel.org>
---
 drivers/dma/pxa_dma.c | 10 +-
 include/linux/platform_data/mmp_dma.h |  4 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b53fb618bbf6..9505334f9c6e 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,6 +179,8 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
+bool pxad_filter_fn(struct dma_chan *chan, void *param);
+
 /*
  * Debug fs
  */
@@ -1396,9 +1398,10 @@ static int pxad_probe(struct platform_device *op)
 {
struct pxad_device *pdev;
const struct of_device_id *of_id;
+   const struct dma_slave_map *slave_map = NULL;
struct mmp_dma_platdata *pdata = dev_get_platdata(>dev);
struct resource *iores;
-   int ret, dma_channels = 0, nb_requestors = 0;
+   int ret, dma_channels = 0, nb_requestors = 0, slave_map_cnt = 0;
const enum dma_slave_buswidth widths =
DMA_SLAVE_BUSWIDTH_1_BYTE   | DMA_SLAVE_BUSWIDTH_2_BYTES |
DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -1429,6 +1432,8 @@ static int pxad_probe(struct platform_device *op)
} else if (pdata && pdata->dma_channels) {
dma_channels = pdata->dma_channels;
nb_requestors = pdata->nb_requestors;
+   slave_map = pdata->slave_map;
+   slave_map_cnt = pdata->slave_map_cnt;
} else {
dma_channels = 32;  /* default 32 channel */
}
@@ -1440,6 +1445,9 @@ static int pxad_probe(struct platform_device *op)
pdev->slave.device_prep_dma_memcpy = pxad_prep_memcpy;
pdev->slave.device_prep_slave_sg = pxad_prep_slave_sg;
pdev->slave.device_prep_dma_cyclic = pxad_prep_dma_cyclic;
+   pdev->slave.filter.map = slave_map;
+   pdev->slave.filter.mapcnt = slave_map_cnt;
+   pdev->slave.filter.fn = pxad_filter_fn;
 
pdev->slave.copy_align = PDMA_ALIGNMENT;
pdev->slave.src_addr_widths = widths;
diff --git a/include/linux/platform_data/mmp_dma.h 
b/include/linux/platform_data/mmp_dma.h
index d1397c8ed94e..6397b9c8149a 100644
--- a/include/linux/platform_data/mmp_dma.h
+++ b/include/linux/platform_data/mmp_dma.h
@@ -12,9 +12,13 @@
 #ifndef MMP_DMA_H
 #define MMP_DMA_H
 
+struct dma_slave_map;
+
 struct mmp_dma_platdata {
int dma_channels;
int nb_requestors;
+   int slave_map_cnt;
+   const struct dma_slave_map *slave_map;
 };
 
 #endif /* MMP_DMA_H */
-- 
2.11.0



[PATCH v2 13/13] ARM: pxa: change SSP DMA channels allocation

2018-05-24 Thread Robert Jarzmik
Now the dma_slave_map is available for PXA architecture, switch the SSP
device to it.

This specifically means that :
- for platform data based machines, the DMA requestor channels are
  extracted from the slave map, where pxa-ssp-dai. is a 1-1 match to
  ssp., and the channels are either "rx" or "tx".

- for device tree platforms, the dma node should be hooked into the
  pxa2xx-ac97 or pxa-ssp-dai node.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: Removed channel names from platform_data
---
 arch/arm/plat-pxa/ssp.c| 47 --
 include/linux/pxa2xx_ssp.h |  2 --
 sound/soc/pxa/pxa-ssp.c|  5 ++---
 3 files changed, 2 insertions(+), 52 deletions(-)

diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ba13f793fbce..ed36dcab80f1 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -127,53 +127,6 @@ static int pxa_ssp_probe(struct platform_device *pdev)
if (IS_ERR(ssp->clk))
return PTR_ERR(ssp->clk);
 
-   if (dev->of_node) {
-   struct of_phandle_args dma_spec;
-   struct device_node *np = dev->of_node;
-   int ret;
-
-   /*
-* FIXME: we should allocate the DMA channel from this
-* context and pass the channel down to the ssp users.
-* For now, we lookup the rx and tx indices manually
-*/
-
-   /* rx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-0, _spec);
-
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-
-   /* tx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-1, _spec);
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-   } else {
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   if (res == NULL) {
-   dev_err(dev, "no SSP RX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = res->start;
-
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (res == NULL) {
-   dev_err(dev, "no SSP TX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = res->start;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
dev_err(dev, "no memory resource defined\n");
diff --git a/include/linux/pxa2xx_ssp.h b/include/linux/pxa2xx_ssp.h
index 8461b18e4608..03a7ca46735b 100644
--- a/include/linux/pxa2xx_ssp.h
+++ b/include/linux/pxa2xx_ssp.h
@@ -212,8 +212,6 @@ struct ssp_device {
int type;
int use_count;
int irq;
-   int drcmr_rx;
-   int drcmr_tx;
 
struct device_node  *of_node;
 };
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 0291c7cb64eb..e09368d89bbc 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -104,9 +104,8 @@ static int pxa_ssp_startup(struct snd_pcm_substream 
*substream,
dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL);
if (!dma)
return -ENOMEM;
-
-   dma->filter_data = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-   >drcmr_tx : >drcmr_rx;
+   dma->chan_name = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+   "tx" : "rx";
 
snd_soc_dai_set_dma_data(cpu_dai, substream, dma);
 
-- 
2.11.0



[PATCH v2 07/13] net: smc91x: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c | 12 +---
 drivers/net/ethernet/smsc/smc91x.h |  1 -
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 080428762858..4c600f430f6d 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2018,18 +2018,8 @@ static int smc_probe(struct net_device *dev, void 
__iomem *ioaddr,
lp->cfg.flags |= SMC91X_USE_DMA;
 #  endif
if (lp->cfg.flags & SMC91X_USE_DMA) {
-   dma_cap_mask_t mask;
-   struct pxad_param param;
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
lp->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev,
-"data");
+   dma_request_slave_channel(lp->device, "data");
}
 #endif
 
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index b337ee97e0c0..a27352229fc2 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -301,7 +301,6 @@ struct smc_local {
  * as RX which can overrun memory and lose packets.
  */
 #include 
-#include 
 
 #ifdef SMC_insl
 #undef SMC_insl
-- 
2.11.0



[PATCH v2 00/13] ARM: pxa: switch to DMA slave maps

2018-05-24 Thread Robert Jarzmik
This v1 cover letter is quoted in [1].

For maintainers the table below should help you focus on the patches targetted 
at you, and ignore the other noise.

The differences since v1 is by maintainers / topic / patch :
- Arnd and Daniel / PXA topic / 0002
  devices.c split into pxa25x.c, pxa27x.c and pxa3xx.c
- Boris and Daniel / MTD topic / 0005
  Review and ack of this one
- Arnd and netdev / NET topic / 0006 and 0007
  Arnd comment taken, review and ack of these one
- Mark and alsa-devel / ASoC topic / 0008
  Mark, I couldn't keep your former Ack because :
- I changed one line so that the cpu device provides the DMA
- I added pxa2xx-i2s which was forgotten
  Therefore I need a new ack
- Arnd and Daniel / SSP topic / 0013
  Review and ack of this one

Happy review.

--
Robert

Robert Jarzmik (13):
  dmaengine: pxa: use a dma slave map
  ARM: pxa: add dma slave map
  mmc: pxamci: remove the dmaengine compat need
  media: pxa_camera: remove the dmaengine compat need
  mtd: rawnand: marvell: remove the dmaengine compat need
  net: smc911x: remove the dmaengine compat need
  net: smc91x: remove the dmaengine compat need
  ASoC: pxa: remove the dmaengine compat need
  ata: pata_pxa: remove the dmaengine compat need
  dmaengine: pxa: document pxad_param
  dmaengine: pxa: make the filter function internal
  ARM: pxa: remove the DMA IO resources
  ARM: pxa: change SSP DMA channels allocation

 arch/arm/mach-pxa/devices.c   | 148 +-
 arch/arm/mach-pxa/devices.h   |   6 +-
 arch/arm/mach-pxa/pxa25x.c|  41 +-
 arch/arm/mach-pxa/pxa27x.c|  42 +-
 arch/arm/mach-pxa/pxa3xx.c|  44 +-
 arch/arm/plat-pxa/ssp.c   |  47 ---
 drivers/ata/pata_pxa.c|  10 +--
 drivers/dma/pxa_dma.c |  13 ++-
 drivers/media/platform/pxa_camera.c   |  22 +
 drivers/mmc/host/pxamci.c |  29 +--
 drivers/mtd/nand/raw/marvell_nand.c   |  17 +---
 drivers/net/ethernet/smsc/smc911x.c   |  16 +---
 drivers/net/ethernet/smsc/smc91x.c|  12 +--
 drivers/net/ethernet/smsc/smc91x.h|   1 -
 include/linux/dma/pxa-dma.h   |  20 +++--
 include/linux/platform_data/mmp_dma.h |   4 +
 include/linux/pxa2xx_ssp.h|   2 -
 sound/arm/pxa2xx-ac97.c   |  14 +---
 sound/arm/pxa2xx-pcm-lib.c|   6 +-
 sound/soc/pxa/pxa-ssp.c   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c   |  32 ++--
 sound/soc/pxa/pxa2xx-i2s.c|   6 +-
 22 files changed, 180 insertions(+), 357 deletions(-)

-- 
2.11.0

---
[1] Former v1 cover letter
This serie is aimed at removing the dmaengine slave compat use, and transfer
knowledge of the DMA requestors into architecture code.

This was discussed/advised by Arnd a couple of years back, it's almost time.

The serie is divided in 3 phasees :
 - phase 1 : patch 1/15 and patch 2/15
   => this is the preparation work
 - phase 2 : patches 3/15 .. 10/15
   => this is the switch of all the drivers
   => this one will require either an Ack of the maintainers or be taken by them
  once phase 1 is merged
 - phase 3 : patches 11/15
   => this is the last part, cleanup and removal of export of the DMA filter
  function

As this looks like a patch bomb, each maintainer expressing for his tree either
an Ack or "I want to take through my tree" will be spared in the next iterations
of this serie.

Several of these changes have been tested on actual hardware, including :
 - pxamci
 - pxa_camera
 - smc*
 - ASoC and SSP


Re: [PATCH 04/15] media: pxa_camera: remove the dmaengine compat need

2018-04-21 Thread Robert Jarzmik
Robert Jarzmik <robert.jarz...@free.fr> writes:

> From: Robert Jarzmik <robert.jarz...@renault.com>
>
> As the pxa architecture switched towards the dmaengine slave map, the
> old compatibility mechanism to acquire the dma requestor line number and
> priority are not needed anymore.
>
> This patch simplifies the dma resource acquisition, using the more
> generic function dma_request_slave_channel().
>
> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
> ---
>  drivers/media/platform/pxa_camera.c | 22 +++---
>  1 file changed, 3 insertions(+), 19 deletions(-)
Hans, could I have your ack please ?

Cheers.

--
Robert

PS: The submitted patch
>
> diff --git a/drivers/media/platform/pxa_camera.c 
> b/drivers/media/platform/pxa_camera.c
> index c71a00736541..4c82d1880753 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device 
> *pdev)
>   .src_maxburst = 8,
>   .direction = DMA_DEV_TO_MEM,
>   };
> - dma_cap_mask_t mask;
> - struct pxad_param params;
>   char clk_name[V4L2_CLK_NAME_SIZE];
>   int irq;
>   int err = 0, i;
> @@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
> *pdev)
>   pcdev->base = base;
>  
>   /* request dma */
> - dma_cap_zero(mask);
> - dma_cap_set(DMA_SLAVE, mask);
> - dma_cap_set(DMA_PRIVATE, mask);
> -
> - params.prio = 0;
> - params.drcmr = 68;
> - pcdev->dma_chans[0] =
> - dma_request_slave_channel_compat(mask, pxad_filter_fn,
> -  , >dev, "CI_Y");
> + pcdev->dma_chans[0] = dma_request_slave_channel(>dev, "CI_Y");
>   if (!pcdev->dma_chans[0]) {
>   dev_err(>dev, "Can't request DMA for Y\n");
>   return -ENODEV;
>   }
>  
> - params.drcmr = 69;
> - pcdev->dma_chans[1] =
> - dma_request_slave_channel_compat(mask, pxad_filter_fn,
> -  , >dev, "CI_U");
> + pcdev->dma_chans[1] = dma_request_slave_channel(>dev, "CI_U");
>   if (!pcdev->dma_chans[1]) {
>   dev_err(>dev, "Can't request DMA for Y\n");
>   err = -ENODEV;
>   goto exit_free_dma_y;
>   }
>  
> - params.drcmr = 70;
> - pcdev->dma_chans[2] =
> - dma_request_slave_channel_compat(mask, pxad_filter_fn,
> -  , >dev, "CI_V");
> + pcdev->dma_chans[2] = dma_request_slave_channel(>dev, "CI_V");
>   if (!pcdev->dma_chans[2]) {
>   dev_err(>dev, "Can't request DMA for V\n");
>   err = -ENODEV;


Re: [PATCH 1/7] i2c: i2c-gpio: move header to platform_data

2018-04-20 Thread Robert Jarzmik
Wolfram Sang <w...@the-dreams.de> writes:

> This header only contains platform_data. Move it to the proper directory.
>
> Signed-off-by: Wolfram Sang <w...@the-dreams.de>
For mach-pxa:
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Take it through your tree, no problem for the pxa part.

Cheers.

--
Robert


Re: [PATCH 08/15] ASoC: pxa: remove the dmaengine compat need

2018-04-12 Thread Robert Jarzmik
Mark Brown <broo...@kernel.org> writes:

> On Mon, Apr 02, 2018 at 04:26:49PM +0200, Robert Jarzmik wrote:
>> As the pxa architecture switched towards the dmaengine slave map, the
>> old compatibility mechanism to acquire the dma requestor line number and
>> priority are not needed anymore.
>
> Acked-by: Mark Brown <broo...@kernel.org>
>
> If there's no dependency I'm happy to take this for 4.18.
Thanks for the ack.

The patches 1 and 2 are the dependency here, so I'd rather push it through my
tree once the review is complete.

Cheers.

-- 
Robert


Re: [PATCH 00/15] ARM: pxa: switch to DMA slave maps

2018-04-04 Thread Robert Jarzmik
Ulf Hansson <ulf.hans...@linaro.org> writes:

> On 2 April 2018 at 16:26, Robert Jarzmik <robert.jarz...@free.fr> wrote:
>> Hi,
>>
>> This serie is aimed at removing the dmaengine slave compat use, and transfer
>> knowledge of the DMA requestors into architecture code.
>> As this looks like a patch bomb, each maintainer expressing for his tree 
>> either
>> an Ack or "I want to take through my tree" will be spared in the next 
>> iterations
>> of this serie.
>
> Perhaps an option is to send this hole series as PR for 3.17 rc1, that
> would removed some churns and make this faster/easier? Well, if you
> receive the needed acks of course.
For 3.17-rc1 it looks a bit optimistic with the review time ... If I have all
acks, I'll queue it into my pxa tree. If at least one maintainer withholds his
ack, the end of the serie (phase 3) won't be applied until it is sorted out.

Cheers.

--
Robert


Re: [PATCH 02/15] ARM: pxa: add dma slave map

2018-04-03 Thread Robert Jarzmik
Arnd Bergmann  writes:

>> +   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
>> +   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
>> +   { "smc91x.0", "data", PDMA_FILTER_PARAM(LOWEST, -1) },
>
> This one is interesting, as you are dealing with an off-chip device,
> and the channel number is '-'1. How does this even work? Does it
> mean

This relies on pxa_dma, in which the "-1" for a requestor line means "no
requestor" or said in another way "always requesting". As a consequence, as soon
as the DMA descriptors are queued, the transfer begins, and it is supposed
implicitely that the FIFO output availability is at least as quick as the system
bus and the DMA size is perfectly fit for the FIFO available bytes.

This is what has been the underlying of DMA transfers of smc91x(x) on the PXA
platforms, where the smc91x(s) are directly wired on the system bus (the same
bus having DRAM, SRAM, IO-mapped devices).

>
>> +   /* PXA25x specific map */
>> +   { "pxa25x-ssp.0", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
>> +   { "pxa25x-ssp.0", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
>> +   { "pxa25x-nssp.1", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
>> +   { "pxa25x-nssp.1", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
>> +   { "pxa25x-nssp.2", "rx", PDMA_FILTER_PARAM(LOWEST, 23) },
>> +   { "pxa25x-nssp.2", "tx", PDMA_FILTER_PARAM(LOWEST, 24) },
>> +   { "pxa-pcm-audio", "nssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
>> +   { "pxa-pcm-audio", "nssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
>> +   { "pxa-pcm-audio", "nssp3_rx", PDMA_FILTER_PARAM(LOWEST, 23) },
>> +   { "pxa-pcm-audio", "nssp3_tx", PDMA_FILTER_PARAM(LOWEST, 24) },
>> +
>> +   /* PXA27x specific map */
>> +   { "pxa-pcm-audio", "ssp3_rx", PDMA_FILTER_PARAM(LOWEST, 66) },
>> +   { "pxa-pcm-audio", "ssp3_tx", PDMA_FILTER_PARAM(LOWEST, 67) },
>> +   { "pxa27x-camera.0", "CI_Y", PDMA_FILTER_PARAM(HIGHEST, 68) },
>> +   { "pxa27x-camera.0", "CI_U", PDMA_FILTER_PARAM(HIGHEST, 69) },
>> +   { "pxa27x-camera.0", "CI_V", PDMA_FILTER_PARAM(HIGHEST, 70) },
>> +
>> +   /* PXA3xx specific map */
>> +   { "pxa-pcm-audio", "ssp4_rx", PDMA_FILTER_PARAM(LOWEST, 2) },
>> +   { "pxa-pcm-audio", "ssp4_tx", PDMA_FILTER_PARAM(LOWEST, 3) },
>> +   { "pxa2xx-mci.1", "rx", PDMA_FILTER_PARAM(LOWEST, 93) },
>> +   { "pxa2xx-mci.1", "tx", PDMA_FILTER_PARAM(LOWEST, 94) },
>> +   { "pxa3xx-nand", "data", PDMA_FILTER_PARAM(LOWEST, 97) },
>> +   { "pxa2xx-mci.2", "rx", PDMA_FILTER_PARAM(LOWEST, 100) },
>> +   { "pxa2xx-mci.2", "tx", PDMA_FILTER_PARAM(LOWEST, 101) },
>> +};
>
> Since more than half the entries in here are chip specific, maybe it would be
> better to split that table into three and have a copy for each one in
> arch/arm/mach-pxa/pxa{25x.27x.3xx}.c?
Mmmh, today the split is :
 - 16 common entries
 - 10 pxa25x specific entries
 - 5 pxa27x specific entries
 - 7 pxa3xx specific entries
 => total of 38 lines

After the split we'll have :
 - 26 pxa25x specific entries
 - 21 pxa27x specific entries
 - 23 pxa3xx specific entries
 => total of 70 lines

That doubles the number of lines, not counting the declarations, and amending of
pxa2xx_set_dmac_info().

If you think it's worth it, what is the driving benefit behind ?

> Does that mean it's actually a memory-to-memory transfer with a device being
> on the external SRAM interface?
I'm taking this is the follow up to the "-1" question :0

Cheers.

-- 
Robert


[PATCH 08/15] ASoC: pxa: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 sound/arm/pxa2xx-ac97.c | 14 ++
 sound/arm/pxa2xx-pcm-lib.c  |  6 +++---
 sound/soc/pxa/pxa2xx-ac97.c | 32 +---
 3 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 4bc244c40f80..236a63cdaf9f 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -63,28 +63,18 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_legacy_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_out_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_in_req,
 };
 
 static struct snd_pcm *pxa2xx_ac97_pcm;
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index e8da3b8ee721..cbfaba60b79a 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -125,9 +125,9 @@ int __pxa2xx_pcm_open(struct snd_pcm_substream *substream)
if (ret < 0)
return ret;
 
-   return snd_dmaengine_pcm_open_request_chan(substream,
-   pxad_filter_fn,
-   dma_params->filter_data);
+   return snd_dmaengine_pcm_open(
+   substream, dma_request_slave_channel(rtd->platform->dev,
+dma_params->chan_name));
 }
 EXPORT_SYMBOL(__pxa2xx_pcm_open);
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 803818aabee9..1b41c0f2a8fb 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -68,61 +68,39 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_cold_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_stereo_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_in_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_stereo_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 10,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_out",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 9,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_in",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_in_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mic_mono_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 8,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = {
.addr   = __PREG(MCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mic_mono",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mic_mono_req,
 };
 
 static int pxa2xx_ac97_hifi_startup(struct snd_pcm_substream *substream,
-- 
2.11.0



[PATCH 00/15] ARM: pxa: switch to DMA slave maps

2018-04-02 Thread Robert Jarzmik
Hi,

This serie is aimed at removing the dmaengine slave compat use, and transfer
knowledge of the DMA requestors into architecture code.

This was discussed/advised by Arnd a couple of years back, it's almost time.

The serie is divided in 3 phasees :
 - phase 1 : patch 1/15 and patch 2/15
   => this is the preparation work
 - phase 2 : patches 3/15 .. 10/15
   => this is the switch of all the drivers
   => this one will require either an Ack of the maintainers or be taken by them
  once phase 1 is merged
 - phase 3 : patches 11/15
   => this is the last part, cleanup and removal of export of the DMA filter
  function

As this looks like a patch bomb, each maintainer expressing for his tree either
an Ack or "I want to take through my tree" will be spared in the next iterations
of this serie.

Several of these changes have been tested on actual hardware, including :
 - pxamci
 - pxa_camera
 - smc*
 - ASoC and SSP

Happy review.

Robert Jarzmik (15):
  dmaengine: pxa: use a dma slave map
  ARM: pxa: add dma slave map
  mmc: pxamci: remove the dmaengine compat need
  media: pxa_camera: remove the dmaengine compat need
  mtd: nand: pxa3xx: remove the dmaengine compat need
  net: smc911x: remove the dmaengine compat need
  net: smc91x: remove the dmaengine compat need
  ASoC: pxa: remove the dmaengine compat need
  net: irda: pxaficp_ir: remove the dmaengine compat need
  ata: pata_pxa: remove the dmaengine compat need
  dmaengine: pxa: document pxad_param
  dmaengine: pxa: make the filter function internal
  ARM: pxa: remove the DMA IO resources
  ARM: pxa: change SSP devices allocation
  ARM: pxa: change SSP DMA channels allocation

 arch/arm/mach-pxa/devices.c   | 269 ++
 arch/arm/mach-pxa/devices.h   |  14 +-
 arch/arm/mach-pxa/include/mach/audio.h|  12 ++
 arch/arm/mach-pxa/pxa25x.c|   4 +-
 arch/arm/mach-pxa/pxa27x.c|   4 +-
 arch/arm/mach-pxa/pxa3xx.c|   5 +-
 arch/arm/plat-pxa/ssp.c   |  50 +-
 drivers/ata/pata_pxa.c|  10 +-
 drivers/dma/pxa_dma.c |  13 +-
 drivers/media/platform/pxa_camera.c   |  22 +--
 drivers/mmc/host/pxamci.c |  29 +---
 drivers/mtd/nand/pxa3xx_nand.c|  10 +-
 drivers/net/ethernet/smsc/smc911x.c   |  16 +-
 drivers/net/ethernet/smsc/smc91x.c|  12 +-
 drivers/net/ethernet/smsc/smc91x.h|   1 -
 drivers/staging/irda/drivers/pxaficp_ir.c |  14 +-
 include/linux/dma/pxa-dma.h   |  20 +--
 include/linux/platform_data/mmp_dma.h |   4 +
 include/linux/pxa2xx_ssp.h|   4 +-
 sound/arm/pxa2xx-ac97.c   |  14 +-
 sound/arm/pxa2xx-pcm-lib.c|   6 +-
 sound/soc/pxa/pxa-ssp.c   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c   |  32 +---
 23 files changed, 196 insertions(+), 374 deletions(-)

-- 
2.11.0



[PATCH 02/15] ARM: pxa: add dma slave map

2018-04-02 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
---
 arch/arm/mach-pxa/devices.c | 55 +
 1 file changed, 55 insertions(+)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index d7c9a8476d57..da67ebe9a7d5 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -4,6 +4,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -1202,9 +1204,62 @@ void __init pxa2xx_set_spi_info(unsigned id, struct 
pxa2xx_spi_master *info)
platform_device_add(pd);
 }
 
+#define PDMA_FILTER_PARAM(_prio, _requestor) (&(struct pxad_param) { \
+   .prio = PXAD_PRIO_##_prio, .drcmr = _requestor })
+
+static const struct dma_slave_map pxa_slave_map[] = {
+   /* PXA25x, PXA27x and PXA3xx common entries */
+   { "pxa-pcm-audio", "ac97_mic_mono", PDMA_FILTER_PARAM(LOWEST, 8) },
+   { "pxa-pcm-audio", "ac97_aux_mono_in", PDMA_FILTER_PARAM(LOWEST, 9) },
+   { "pxa-pcm-audio", "ac97_aux_mono_out", PDMA_FILTER_PARAM(LOWEST, 10) },
+   { "pxa-pcm-audio", "ac97_stereo_in", PDMA_FILTER_PARAM(LOWEST, 11) },
+   { "pxa-pcm-audio", "ac97_stereo_out", PDMA_FILTER_PARAM(LOWEST, 12) },
+   { "pxa-pcm-audio", "ssp1_rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa-pcm-audio", "ssp1_tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa-pcm-audio", "ssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-pcm-audio", "ssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa2xx-ir", "rx", PDMA_FILTER_PARAM(LOWEST, 17) },
+   { "pxa2xx-ir", "tx", PDMA_FILTER_PARAM(LOWEST, 18) },
+   { "pxa2xx-mci.0", "rx", PDMA_FILTER_PARAM(LOWEST, 21) },
+   { "pxa2xx-mci.0", "tx", PDMA_FILTER_PARAM(LOWEST, 22) },
+   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc91x.0", "data", PDMA_FILTER_PARAM(LOWEST, -1) },
+
+   /* PXA25x specific map */
+   { "pxa25x-ssp.0", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa25x-ssp.0", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa25x-nssp.1", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa25x-nssp.1", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa25x-nssp.2", "rx", PDMA_FILTER_PARAM(LOWEST, 23) },
+   { "pxa25x-nssp.2", "tx", PDMA_FILTER_PARAM(LOWEST, 24) },
+   { "pxa-pcm-audio", "nssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-pcm-audio", "nssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa-pcm-audio", "nssp3_rx", PDMA_FILTER_PARAM(LOWEST, 23) },
+   { "pxa-pcm-audio", "nssp3_tx", PDMA_FILTER_PARAM(LOWEST, 24) },
+
+   /* PXA27x specific map */
+   { "pxa-pcm-audio", "ssp3_rx", PDMA_FILTER_PARAM(LOWEST, 66) },
+   { "pxa-pcm-audio", "ssp3_tx", PDMA_FILTER_PARAM(LOWEST, 67) },
+   { "pxa27x-camera.0", "CI_Y", PDMA_FILTER_PARAM(HIGHEST, 68) },
+   { "pxa27x-camera.0", "CI_U", PDMA_FILTER_PARAM(HIGHEST, 69) },
+   { "pxa27x-camera.0", "CI_V", PDMA_FILTER_PARAM(HIGHEST, 70) },
+
+   /* PXA3xx specific map */
+   { "pxa-pcm-audio", "ssp4_rx", PDMA_FILTER_PARAM(LOWEST, 2) },
+   { "pxa-pcm-audio", "ssp4_tx", PDMA_FILTER_PARAM(LOWEST, 3) },
+   { "pxa2xx-mci.1", "rx", PDMA_FILTER_PARAM(LOWEST, 93) },
+   { "pxa2xx-mci.1", "tx", PDMA_FILTER_PARAM(LOWEST, 94) },
+   { "pxa3xx-nand", "data", PDMA_FILTER_PARAM(LOWEST, 97) },
+   { "pxa2xx-mci.2", "rx", PDMA_FILTER_PARAM(LOWEST, 100) },
+   { "pxa2xx-mci.2", "tx", PDMA_FILTER_PARAM(LOWEST, 101) },
+};
+
 static struct mmp_dma_platdata pxa_dma_pdata = {
.dma_channels   = 0,
.nb_requestors  = 0,
+   .slave_map  = pxa_slave_map,
+   .slave_map_cnt  = ARRAY_SIZE(pxa_slave_map),
 };
 
 static struct resource pxa_dma_resource[] = {
-- 
2.11.0



[PATCH 01/15] dmaengine: pxa: use a dma slave map

2018-04-02 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This won't impact MMP architecture, but is aimed only at all PXA boards.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
---
 drivers/dma/pxa_dma.c | 10 +-
 include/linux/platform_data/mmp_dma.h |  4 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b53fb618bbf6..9505334f9c6e 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,6 +179,8 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
+bool pxad_filter_fn(struct dma_chan *chan, void *param);
+
 /*
  * Debug fs
  */
@@ -1396,9 +1398,10 @@ static int pxad_probe(struct platform_device *op)
 {
struct pxad_device *pdev;
const struct of_device_id *of_id;
+   const struct dma_slave_map *slave_map = NULL;
struct mmp_dma_platdata *pdata = dev_get_platdata(>dev);
struct resource *iores;
-   int ret, dma_channels = 0, nb_requestors = 0;
+   int ret, dma_channels = 0, nb_requestors = 0, slave_map_cnt = 0;
const enum dma_slave_buswidth widths =
DMA_SLAVE_BUSWIDTH_1_BYTE   | DMA_SLAVE_BUSWIDTH_2_BYTES |
DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -1429,6 +1432,8 @@ static int pxad_probe(struct platform_device *op)
} else if (pdata && pdata->dma_channels) {
dma_channels = pdata->dma_channels;
nb_requestors = pdata->nb_requestors;
+   slave_map = pdata->slave_map;
+   slave_map_cnt = pdata->slave_map_cnt;
} else {
dma_channels = 32;  /* default 32 channel */
}
@@ -1440,6 +1445,9 @@ static int pxad_probe(struct platform_device *op)
pdev->slave.device_prep_dma_memcpy = pxad_prep_memcpy;
pdev->slave.device_prep_slave_sg = pxad_prep_slave_sg;
pdev->slave.device_prep_dma_cyclic = pxad_prep_dma_cyclic;
+   pdev->slave.filter.map = slave_map;
+   pdev->slave.filter.mapcnt = slave_map_cnt;
+   pdev->slave.filter.fn = pxad_filter_fn;
 
pdev->slave.copy_align = PDMA_ALIGNMENT;
pdev->slave.src_addr_widths = widths;
diff --git a/include/linux/platform_data/mmp_dma.h 
b/include/linux/platform_data/mmp_dma.h
index d1397c8ed94e..6397b9c8149a 100644
--- a/include/linux/platform_data/mmp_dma.h
+++ b/include/linux/platform_data/mmp_dma.h
@@ -12,9 +12,13 @@
 #ifndef MMP_DMA_H
 #define MMP_DMA_H
 
+struct dma_slave_map;
+
 struct mmp_dma_platdata {
int dma_channels;
int nb_requestors;
+   int slave_map_cnt;
+   const struct dma_slave_map *slave_map;
 };
 
 #endif /* MMP_DMA_H */
-- 
2.11.0



[PATCH 03/15] mmc: pxamci: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/mmc/host/pxamci.c | 29 +++--
 1 file changed, 3 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index c763b404510f..6c94474e36f4 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -637,10 +636,8 @@ static int pxamci_probe(struct platform_device *pdev)
 {
struct mmc_host *mmc;
struct pxamci_host *host = NULL;
-   struct resource *r, *dmarx, *dmatx;
-   struct pxad_param param_rx, param_tx;
+   struct resource *r;
int ret, irq, gpio_cd = -1, gpio_ro = -1, gpio_power = -1;
-   dma_cap_mask_t mask;
 
ret = pxamci_of_init(pdev);
if (ret)
@@ -739,34 +736,14 @@ static int pxamci_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mmc);
 
-   if (!pdev->dev.of_node) {
-   dmarx = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   dmatx = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (!dmarx || !dmatx) {
-   ret = -ENXIO;
-   goto out;
-   }
-   param_rx.prio = PXAD_PRIO_LOWEST;
-   param_rx.drcmr = dmarx->start;
-   param_tx.prio = PXAD_PRIO_LOWEST;
-   param_tx.drcmr = dmatx->start;
-   }
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-
-   host->dma_chan_rx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_rx, >dev, "rx");
+   host->dma_chan_rx = dma_request_slave_channel(>dev, "rx");
if (host->dma_chan_rx == NULL) {
dev_err(>dev, "unable to request rx dma channel\n");
ret = -ENODEV;
goto out;
}
 
-   host->dma_chan_tx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_tx,  >dev, "tx");
+   host->dma_chan_tx = dma_request_slave_channel(>dev, "tx");
if (host->dma_chan_tx == NULL) {
dev_err(>dev, "unable to request tx dma channel\n");
ret = -ENODEV;
-- 
2.11.0



[PATCH 06/15] net: smc911x: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc911x.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index 05157442a980..4c3713bd5caa 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -74,7 +74,6 @@ static const char version[] =
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -1794,8 +1793,6 @@ static int smc911x_probe(struct net_device *dev)
unsigned long irq_flags;
 #ifdef SMC_USE_DMA
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
 #endif
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
@@ -1969,17 +1966,8 @@ static int smc911x_probe(struct net_device *dev)
 
 #ifdef SMC_USE_DMA
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
-   lp->rxdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "rx");
-   lp->txdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "tx");
+   lp->rxdma = dma_request_slave_channel(>dev, "rx");
+   lp->txdma = dma_request_slave_channel(>dev, "tx");
lp->rxdma_active = 0;
lp->txdma_active = 0;
 
-- 
2.11.0



[PATCH 07/15] net: smc91x: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c | 12 +---
 drivers/net/ethernet/smsc/smc91x.h |  1 -
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 080428762858..4c600f430f6d 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2018,18 +2018,8 @@ static int smc_probe(struct net_device *dev, void 
__iomem *ioaddr,
lp->cfg.flags |= SMC91X_USE_DMA;
 #  endif
if (lp->cfg.flags & SMC91X_USE_DMA) {
-   dma_cap_mask_t mask;
-   struct pxad_param param;
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
lp->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev,
-"data");
+   dma_request_slave_channel(lp->device, "data");
}
 #endif
 
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index 08b17adf0a65..e849b6c2fa60 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -327,7 +327,6 @@ struct smc_local {
  * as RX which can overrun memory and lose packets.
  */
 #include 
-#include 
 
 #ifdef SMC_insl
 #undef SMC_insl
-- 
2.11.0



[PATCH 09/15] net: irda: pxaficp_ir: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/staging/irda/drivers/pxaficp_ir.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/irda/drivers/pxaficp_ir.c 
b/drivers/staging/irda/drivers/pxaficp_ir.c
index 2ea00a6531f9..9dd6e21dc11e 100644
--- a/drivers/staging/irda/drivers/pxaficp_ir.c
+++ b/drivers/staging/irda/drivers/pxaficp_ir.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -735,9 +734,7 @@ static void pxa_irda_shutdown(struct pxa_irda *si)
 static int pxa_irda_start(struct net_device *dev)
 {
struct pxa_irda *si = netdev_priv(dev);
-   dma_cap_mask_t mask;
struct dma_slave_config config;
-   struct pxad_param param;
int err;
 
si->speed = 9600;
@@ -757,9 +754,6 @@ static int pxa_irda_start(struct net_device *dev)
disable_irq(si->icp_irq);
 
err = -EBUSY;
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
 
memset(, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
@@ -769,15 +763,11 @@ static int pxa_irda_start(struct net_device *dev)
config.src_maxburst = 32;
config.dst_maxburst = 32;
 
-   param.drcmr = si->drcmr_rx;
-   si->rxdma = dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "rx");
+   si->rxdma = dma_request_slave_channel(>dev, "rx");
if (!si->rxdma)
goto err_rx_dma;
 
-   param.drcmr = si->drcmr_tx;
-   si->txdma = dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "tx");
+   si->txdma = dma_request_slave_channel(>dev, "tx");
if (!si->txdma)
goto err_tx_dma;
 
-- 
2.11.0



[PATCH 10/15] ata: pata_pxa: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/ata/pata_pxa.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index f6c46e9a4dc0..e8b6a2e464c9 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -180,8 +179,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
struct resource *irq_res;
struct pata_pxa_pdata *pdata = dev_get_platdata(>dev);
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret = 0;
 
/*
@@ -278,10 +275,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
 
ap->private_data = data;
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = pdata->dma_dreq;
memset(, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
config.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -294,8 +287,7 @@ static int pxa_ata_probe(struct platform_device *pdev)
 * Request the DMA channel
 */
data->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "data");
+   dma_request_slave_channel(>dev, "data");
if (!data->dma_chan)
return -EBUSY;
ret = dmaengine_slave_config(data->dma_chan, );
-- 
2.11.0



[PATCH 11/15] dmaengine: pxa: document pxad_param

2018-04-02 Thread Robert Jarzmik
Add some documentation for the pxad_param structure, and describe the
contract behind the minimal required priority of a DMA channel.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 include/linux/dma/pxa-dma.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index e56ec7af4fd7..9fc594f69eff 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -9,6 +9,15 @@ enum pxad_chan_prio {
PXAD_PRIO_LOWEST,
 };
 
+/**
+ * struct pxad_param - dma channel request parameters
+ * @drcmr: requestor line number
+ * @prio: minimal mandatory priority of the channel
+ *
+ * If a requested channel is granted, its priority will be at least @prio,
+ * ie. if PXAD_PRIO_LOW is required, the requested channel will be either
+ * PXAD_PRIO_LOW, PXAD_PRIO_NORMAL or PXAD_PRIO_HIGHEST.
+ */
 struct pxad_param {
unsigned int drcmr;
enum pxad_chan_prio prio;
-- 
2.11.0



[PATCH 12/15] dmaengine: pxa: make the filter function internal

2018-04-02 Thread Robert Jarzmik
As the pxa architecture and all its related drivers do not rely anymore
on the filter function, thanks to the slave map conversion, make
pxad_filter_fn() static, and remove it from the global namespace.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/dma/pxa_dma.c   |  5 ++---
 include/linux/dma/pxa-dma.h | 11 ---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 9505334f9c6e..a332ad1d7dfb 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,7 +179,7 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
+static bool pxad_filter_fn(struct dma_chan *chan, void *param);
 
 /*
  * Debug fs
@@ -1496,7 +1496,7 @@ static struct platform_driver pxad_driver = {
.remove = pxad_remove,
 };
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param)
+static bool pxad_filter_fn(struct dma_chan *chan, void *param)
 {
struct pxad_chan *c = to_pxad_chan(chan);
struct pxad_param *p = param;
@@ -1509,7 +1509,6 @@ bool pxad_filter_fn(struct dma_chan *chan, void *param)
 
return true;
 }
-EXPORT_SYMBOL_GPL(pxad_filter_fn);
 
 module_platform_driver(pxad_driver);
 
diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index 9fc594f69eff..fceb5df07097 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -23,15 +23,4 @@ struct pxad_param {
enum pxad_chan_prio prio;
 };
 
-struct dma_chan;
-
-#ifdef CONFIG_PXA_DMA
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
-#else
-static inline bool pxad_filter_fn(struct dma_chan *chan, void *param)
-{
-   return false;
-}
-#endif
-
 #endif /* _PXA_DMA_H_ */
-- 
2.11.0



[PATCH 15/15] ARM: pxa: change SSP DMA channels allocation

2018-04-02 Thread Robert Jarzmik
Now the dma_slave_map is available for PXA architecture, switch the SSP
device to it.

This specifically means that :
- for platform data based machines, the DMA requestor channels are
  extracted from platform data and passed further to the SSP user,
  ie. usually the pxa-pcm-audio driver

- for device tree platforms, the dma node should be hooked into the
  pxa-pcm-audio node.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/plat-pxa/ssp.c| 50 +-
 include/linux/pxa2xx_ssp.h |  4 ++--
 sound/soc/pxa/pxa-ssp.c|  5 ++---
 3 files changed, 9 insertions(+), 50 deletions(-)

diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ba13f793fbce..3457f01e3340 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -16,6 +16,7 @@
  *  Author: Liam Girdwood <liam.girdw...@wolfsonmicro.com>
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -116,6 +117,7 @@ static int pxa_ssp_probe(struct platform_device *pdev)
struct resource *res;
struct ssp_device *ssp;
struct device *dev = >dev;
+   struct pxa_ssp_info *info = dev_get_platdata(dev);
 
ssp = devm_kzalloc(dev, sizeof(struct ssp_device), GFP_KERNEL);
if (ssp == NULL)
@@ -127,51 +129,9 @@ static int pxa_ssp_probe(struct platform_device *pdev)
if (IS_ERR(ssp->clk))
return PTR_ERR(ssp->clk);
 
-   if (dev->of_node) {
-   struct of_phandle_args dma_spec;
-   struct device_node *np = dev->of_node;
-   int ret;
-
-   /*
-* FIXME: we should allocate the DMA channel from this
-* context and pass the channel down to the ssp users.
-* For now, we lookup the rx and tx indices manually
-*/
-
-   /* rx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-0, _spec);
-
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-
-   /* tx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-1, _spec);
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-   } else {
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   if (res == NULL) {
-   dev_err(dev, "no SSP RX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = res->start;
-
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (res == NULL) {
-   dev_err(dev, "no SSP TX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = res->start;
+   if (!dev->of_node && info) {
+   ssp->dma_chan_rx = info->dma_chan_rx_name;
+   ssp->dma_chan_tx = info->dma_chan_tx_name;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/include/linux/pxa2xx_ssp.h b/include/linux/pxa2xx_ssp.h
index 8461b18e4608..99c99d397e4d 100644
--- a/include/linux/pxa2xx_ssp.h
+++ b/include/linux/pxa2xx_ssp.h
@@ -212,9 +212,9 @@ struct ssp_device {
int type;
int use_count;
int irq;
-   int drcmr_rx;
-   int drcmr_tx;
 
+   const char  *dma_chan_rx;
+   const char  *dma_chan_tx;
struct device_node  *of_node;
 };
 
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 0291c7cb64eb..a0189b88f1d2 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -104,9 +104,8 @@ static int pxa_ssp_startup(struct snd_pcm_substream 
*substream,
dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL);
if (!dma)
return -ENOMEM;
-
-   dma->filter_data = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-   >drcmr_tx : >drcmr_rx;
+   dma->chan_name = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+   ssp->dma_chan_tx : ssp->dma_chan_rx;
 
snd_soc_dai_set_dma_data(cpu_dai, substream, dma);
 
-- 
2.11.0



[PATCH 14/15] ARM: pxa: change SSP devices allocation

2018-04-02 Thread Robert Jarzmik
In order to prepare for the dma_slave_map change for SSP DMA channels
allocation, the SSP platform devices will now include a platform data
structure which in turn selects which dma channel has to be used for
data transfers, especially the PCM ones.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/devices.c| 78 +-
 arch/arm/mach-pxa/devices.h| 14 ++
 arch/arm/mach-pxa/include/mach/audio.h | 12 ++
 arch/arm/mach-pxa/pxa25x.c |  4 +-
 arch/arm/mach-pxa/pxa27x.c |  4 +-
 arch/arm/mach-pxa/pxa3xx.c |  5 +--
 6 files changed, 86 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index c0b3c90fd67f..955d255dc4f4 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -481,6 +481,17 @@ void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
pxa_register_device(_device_ac97, ops);
 }
 
+static struct pxa_ssp_info pxa_ssp_infos[] = {
+   { .dma_chan_rx_name = "ssp1_rx", .dma_chan_tx_name = "ssp1_tx", },
+   { .dma_chan_rx_name = "ssp1_rx", .dma_chan_tx_name = "ssp1_tx", },
+   { .dma_chan_rx_name = "ssp2_rx", .dma_chan_tx_name = "ssp2_tx", },
+   { .dma_chan_rx_name = "ssp2_rx", .dma_chan_tx_name = "ssp2_tx", },
+   { .dma_chan_rx_name = "ssp3_rx", .dma_chan_tx_name = "ssp3_tx", },
+   { .dma_chan_rx_name = "ssp3_rx", .dma_chan_tx_name = "ssp3_tx", },
+   { .dma_chan_rx_name = "ssp4_rx", .dma_chan_tx_name = "ssp4_tx", },
+   { .dma_chan_rx_name = "ssp4_rx", .dma_chan_tx_name = "ssp4_tx", },
+};
+
 #ifdef CONFIG_PXA25x
 
 static struct resource pxa25x_resource_pwm0[] = {
@@ -528,7 +539,7 @@ static struct resource pxa25x_resource_ssp[] = {
},
 };
 
-struct platform_device pxa25x_device_ssp = {
+static struct platform_device pxa25x_device_ssp = {
.name   = "pxa25x-ssp",
.id = 0,
.dev= {
@@ -554,7 +565,7 @@ static struct resource pxa25x_resource_nssp[] = {
},
 };
 
-struct platform_device pxa25x_device_nssp = {
+static struct platform_device pxa25x_device_nssp = {
.name   = "pxa25x-nssp",
.id = 1,
.dev= {
@@ -580,7 +591,7 @@ static struct resource pxa25x_resource_assp[] = {
},
 };
 
-struct platform_device pxa25x_device_assp = {
+static struct platform_device pxa25x_device_assp = {
/* ASSP is basically equivalent to NSSP */
.name   = "pxa25x-nssp",
.id = 2,
@@ -591,6 +602,22 @@ struct platform_device pxa25x_device_assp = {
.resource   = pxa25x_resource_assp,
.num_resources  = ARRAY_SIZE(pxa25x_resource_assp),
 };
+
+static struct platform_device *pxa25x_device_ssps[] = {
+   _device_ssp,
+   _device_nssp,
+   _device_assp,
+};
+
+void __init pxa25x_set_ssp_info(void)
+{
+   int ssp;
+
+   for (ssp = 0; ssp < ARRAY_SIZE(pxa25x_device_ssps); ssp++)
+   pxa_register_device(pxa25x_device_ssps[ssp],
+   _ssp_infos[ssp]);
+}
+
 #endif /* CONFIG_PXA25x */
 
 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
@@ -698,7 +725,7 @@ static struct resource pxa27x_resource_ssp1[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp1 = {
+static struct platform_device pxa27x_device_ssp1 = {
.name   = "pxa27x-ssp",
.id = 0,
.dev= {
@@ -724,7 +751,7 @@ static struct resource pxa27x_resource_ssp2[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp2 = {
+static struct platform_device pxa27x_device_ssp2 = {
.name   = "pxa27x-ssp",
.id = 1,
.dev= {
@@ -750,7 +777,7 @@ static struct resource pxa27x_resource_ssp3[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp3 = {
+static struct platform_device pxa27x_device_ssp3 = {
.name   = "pxa27x-ssp",
.id = 2,
.dev= {
@@ -761,6 +788,21 @@ struct platform_device pxa27x_device_ssp3 = {
.num_resources  = ARRAY_SIZE(pxa27x_resource_ssp3),
 };
 
+static struct platform_device *pxa27x_device_ssps[] = {
+   _device_ssp1,
+   _device_ssp2,
+   _device_ssp3,
+};
+
+void __init pxa27x_set_ssp_info(void)
+{
+   int ssp;
+
+   for (ssp = 0; ssp < ARRAY_SIZE(pxa27x_device_ssps); ssp++)
+   pxa_register_device(pxa27x_device_ssps[ssp],
+   _ssp_infos[ssp]);
+}
+
 static struct resource pxa27x_resource_pwm0[] = {
[0] = {
.start  = 0x40b0,
@@ -951,7 +993,7 @@ static struct re

[PATCH 13/15] ARM: pxa: remove the DMA IO resources

2018-04-02 Thread Robert Jarzmik
As the last driver using the former mechanism to acquire the DMA
requestor line has be converted to the dma_slave_map, remove all these
resources from the PXA devices.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/devices.c | 136 
 1 file changed, 136 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index da67ebe9a7d5..c0b3c90fd67f 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -61,16 +61,6 @@ static struct resource pxamci_resources[] = {
.end= IRQ_MMC,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 21,
-   .end= 21,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   .start  = 22,
-   .end= 22,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 static u64 pxamci_dmamask = 0xUL;
@@ -408,16 +398,6 @@ static struct resource pxa_ir_resources[] = {
.end= 0x40700023,
.flags  = IORESOURCE_MEM,
},
-   [5] = {
-   .start  = 17,
-   .end= 17,
-   .flags  = IORESOURCE_DMA,
-   },
-   [6] = {
-   .start  = 18,
-   .end= 18,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa_device_ficp = {
@@ -546,18 +526,6 @@ static struct resource pxa25x_resource_ssp[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_ssp = {
@@ -584,18 +552,6 @@ static struct resource pxa25x_resource_nssp[] = {
.end= IRQ_NSSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_nssp = {
@@ -622,18 +578,6 @@ static struct resource pxa25x_resource_assp[] = {
.end= IRQ_ASSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 23,
-   .end= 23,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 24,
-   .end= 24,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_assp = {
@@ -752,18 +696,6 @@ static struct resource pxa27x_resource_ssp1[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp1 = {
@@ -790,18 +722,6 @@ static struct resource pxa27x_resource_ssp2[] = {
.end= IRQ_SSP2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp2 = {
@@ -828,18 +748,6 @@ static struct resource pxa27x_resource_ssp3[] = {
.end= IRQ_SSP3,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 66,
-   .end= 66,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 67,
-   .end= 67,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp3 = {
@@ -896,16 +804,6 @@ static struct resource pxa3xx_resources_mci2[] = {
.end= IRQ_MMC2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 93,
-   .end= 93,
-   .flags  = IORESOURCE_DMA,
-   },
-   

[PATCH 05/15] mtd: nand: pxa3xx: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/mtd/nand/pxa3xx_nand.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index d1979c7dbe7e..4a56a0aef5b1 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -1518,8 +1518,6 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info 
*info)
 {
struct platform_device *pdev = info->pdev;
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret;
 
info->data_buff = kmalloc(info->buf_size, GFP_KERNEL);
@@ -1533,13 +1531,7 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info 
*info)
return ret;
 
sg_init_one(>sg, info->data_buff, info->buf_size);
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = info->drcmr_dat;
-   info->dma_chan = dma_request_slave_channel_compat(mask, pxad_filter_fn,
- , >dev,
- "data");
+   info->dma_chan = dma_request_slave_channel(>dev, "data");
if (!info->dma_chan) {
dev_err(>dev, "unable to request data dma channel\n");
return -ENODEV;
-- 
2.11.0



[PATCH 04/15] media: pxa_camera: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/pxa_camera.c | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index c71a00736541..4c82d1880753 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
.src_maxburst = 8,
.direction = DMA_DEV_TO_MEM,
};
-   dma_cap_mask_t mask;
-   struct pxad_param params;
char clk_name[V4L2_CLK_NAME_SIZE];
int irq;
int err = 0, i;
@@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
*pdev)
pcdev->base = base;
 
/* request dma */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   dma_cap_set(DMA_PRIVATE, mask);
-
-   params.prio = 0;
-   params.drcmr = 68;
-   pcdev->dma_chans[0] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_Y");
+   pcdev->dma_chans[0] = dma_request_slave_channel(>dev, "CI_Y");
if (!pcdev->dma_chans[0]) {
dev_err(>dev, "Can't request DMA for Y\n");
return -ENODEV;
}
 
-   params.drcmr = 69;
-   pcdev->dma_chans[1] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_U");
+   pcdev->dma_chans[1] = dma_request_slave_channel(>dev, "CI_U");
if (!pcdev->dma_chans[1]) {
dev_err(>dev, "Can't request DMA for Y\n");
err = -ENODEV;
goto exit_free_dma_y;
}
 
-   params.drcmr = 70;
-   pcdev->dma_chans[2] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_V");
+   pcdev->dma_chans[2] = dma_request_slave_channel(>dev, "CI_V");
if (!pcdev->dma_chans[2]) {
dev_err(>dev, "Can't request DMA for V\n");
err = -ENODEV;
-- 
2.11.0



Re: [PATCH] [media] pxa_camera: Delete an error message for a failed memory allocation in pxa_camera_probe()

2017-09-09 Thread Robert Jarzmik
SF Markus Elfring <elfr...@users.sourceforge.net> writes:

> From: Markus Elfring <elfr...@users.sourceforge.net>
> Date: Fri, 8 Sep 2017 22:05:14 +0200
>
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfr...@users.sourceforge.net>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert


Re: [RFC] [PATCH 0/4] [media] pxa_camera: Fixing bugs and missing colorformats

2017-05-02 Thread Robert Jarzmik
Petr Cvek  writes:

> Dne 1.5.2017 v 06:20 Petr Cvek napsal(a):
>> This patchset is just a grouping of a few bugfixes I've found during
>> the ov9640 sensor support re-adding. 
>
> P.S. I've manually calculated every format variant for the image size
> calculation functions, but still these functions are not too robust (for every
> hypothetical bps/packing/layout combination). For example:
>
> MEDIA_BUS_FMT_Y8_1X8
>   .name   = "Grey",
>   .bits_per_sample= 8,
>   .packing= PXA_MBUS_PACKING_NONE,
>   .order  = PXA_MBUS_ORDER_LE,
>   .layout = PXA_MBUS_LAYOUT_PACKED,
>
> seems to me as a little bit misleading. The better solution would be to have 
> something like bytes_per_line and image_size coefficients. Is my idea worth a 
> try?
>
> Anyway the .order field seems to be unused (it is a pxa_camera defined 
> structure). I'm for removing it (I can create a patch and test it on the real 
> hardware). Unless there are plans for it.
>
> The pxa_camera_get_formats() could be probably simplified even up to the point
> of a removal of the soc_camera_format_xlate structure. If no one works on it 
> (in
> like 2 months) I can try to simplify it.

Yes, simplifing get soc_camera_format_xlate struct would be great. And yeah,
nobody will be working on it in the next 2 monthes. Besides, Hans had expressed
interest in having it removed.

On my side, as long as the format translation happens, ie. pxa_camera provides a
list of formats which is a _superset_ of the sensor formats as today (especially
YUV422P, YUYV and its permutations, RGB), I'll be totally fine with it, even
if it was my idea several years ago to have a translation...

Let's see what new ideas can provide, new blood etc ...

Cheers.

-- 
Robert


Re: [PATCH 4/4] [media] pxa_camera: Fix a call with an uninitialized device pointer

2017-05-02 Thread Robert Jarzmik
Petr Cvek <petr.c...@tul.cz> writes:

> In 'commit 295ab497d6357 ("[media] media: platform: pxa_camera: make
> printk consistent")' a pointer to the device structure in
> mclk_get_divisor() was changed to pcdev_to_dev(pcdev). The pointer used
> by pcdev_to_dev() is still uninitialized during the call to
> mclk_get_divisor() as it happens in v4l2_device_register() at the end
> of the probe. The dev_warn and dev_dbg caused a line in the log:
>
>   (NULL device *): Limiting master clock to 2600
>
> Fix this by using an initialized pointer from the platform_device
> (as before the old patch).
>
> Signed-off-by: Petr Cvek <petr.c...@tul.cz>
Right, would be good to add to the commit message :
Fixes: 295ab497d635 ("[media] media: platform: pxa_camera: make printk 
consistent")

And :
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert

> ---
>  drivers/media/platform/pxa_camera.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/pxa_camera.c 
> b/drivers/media/platform/pxa_camera.c
> index 79fd7269d1e6..c8466c63be22 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -1124,7 +1124,7 @@ static u32 mclk_get_divisor(struct platform_device 
> *pdev,
>   /* mclk <= ciclk / 4 (27.4.2) */
>   if (mclk > lcdclk / 4) {
>   mclk = lcdclk / 4;
> - dev_warn(pcdev_to_dev(pcdev),
> + dev_warn(>dev,
>"Limiting master clock to %lu\n", mclk);
>   }
>  
> @@ -1135,7 +1135,7 @@ static u32 mclk_get_divisor(struct platform_device 
> *pdev,
>   if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
>   pcdev->mclk = lcdclk / (2 * (div + 1));
>  
> - dev_dbg(pcdev_to_dev(pcdev), "LCD clock %luHz, target freq %luHz, 
> divisor %u\n",
> + dev_dbg(>dev, "LCD clock %luHz, target freq %luHz, divisor %u\n",
>   lcdclk, mclk, div);
>  
>   return div;


Re: [PATCH 3/4] [media] pxa_camera: Add (un)subscribe_event ioctl

2017-05-02 Thread Robert Jarzmik
Petr Cvek  writes:

> The v4l2-compliance complains about nonexistent vidioc_subscribe_event
> and vidioc_unsubscribe_event calls. Add them to fix the complaints.
>
> Signed-off-by: Petr Cvek 
Don't know on that one, let others on the mailing list comment, I'm not familiar
with the event interface of v4l2.

Cheers.

--
Robert

> ---
>  drivers/media/platform/pxa_camera.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/media/platform/pxa_camera.c 
> b/drivers/media/platform/pxa_camera.c
> index f71e7e0a652b..79fd7269d1e6 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -37,7 +37,9 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -2089,6 +2091,8 @@ static const struct v4l2_ioctl_ops pxa_camera_ioctl_ops 
> = {
>   .vidioc_g_register  = pxac_vidioc_g_register,
>   .vidioc_s_register  = pxac_vidioc_s_register,
>  #endif
> + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
> + .vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
>  };
>  
>  static struct v4l2_clk_ops pxa_camera_mclk_ops = {


Re: [PATCH 2/4] [media] pxa_camera: Fix incorrect test in the image size generation

2017-05-02 Thread Robert Jarzmik
Petr Cvek  writes:

> During the transfer from the soc_camera a test in pxa_mbus_image_size()
> got removed. Without it any PXA_MBUS_LAYOUT_PACKED format causes either
> the return of a wrong value (PXA_MBUS_PACKING_2X8_PADHI doubles
> the correct value) or EINVAL (PXA_MBUS_PACKING_NONE and
> PXA_MBUS_PACKING_EXTEND16). This was observed in an error from the ffmpeg
> (for some of the YUYV subvariants).
>
> This patch re-adds the same test as in soc_camera version.
>
> Signed-off-by: Petr Cvek 
Did you test that with YUV422P format ?
If yes, then you can have my ack.

And you should add Hans to the reviewers list, it's his call ultimately, and his
tree which should carry it on.

Cheers.

--
Robert


Re: [PATCH 1/4] [media] pxa_camera: Add remaining Bayer 8 formats

2017-05-02 Thread Robert Jarzmik
Petr Cvek <petr.c...@tul.cz> writes:

> This patch adds Bayer 8 GBRG and RGGB support and move GRBG definition
> close to BGGR (so all Bayer 8 variants are together). No other changes are
> needed as the driver handles them as RAW data stream.
>
> The RGGB variant was tested in a modified OV9640 driver.
>
> Signed-off-by: Petr Cvek <petr.c...@tul.cz>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert


Re: [PATCH] [media] pxa_camera: fix module remove codepath for v4l2 clock

2017-04-28 Thread Robert Jarzmik
Petr Cvek  writes:

> I will post some other bugfixes (and feature adding) for pxa_camera soon. Do 
> you wish to be CC'd? 
>
> P.S. Who is the the maintainer of pxa_camera BTW? Still Guennadi Liakhovetski?
Euh no, that's me.

I had submitted a patch for that here :
  https://patchwork.kernel.org/patch/9316499

Hans, do you want to pick it up ?

Cheers.

-- 
Robert


Re: [PATCH] [media] pxa_camera: fix module remove codepath for v4l2 clock

2017-04-27 Thread Robert Jarzmik
Petr Cvek <petr.c...@tul.cz> writes:

> The conversion from soc_camera omitted a correct handling of the clock
> gating for a sensor. When the pxa_camera driver module was removed it
> tried to unregister clk, but this caused a similar warning:
>
>   WARNING: CPU: 0 PID: 6740 at drivers/media/v4l2-core/v4l2-clk.c:278
>   v4l2_clk_unregister(): Refusing to unregister ref-counted 0-0030 clock!
>
> The clock was at time still refcounted by the sensor driver. Before
> the removing of the pxa_camera the clock must be dropped by the sensor
> driver. This should be triggered by v4l2_async_notifier_unregister() call
> which removes sensor driver module too, calls unbind() function and then
> tries to probe sensor driver again. Inside unbind() we can safely
> unregister the v4l2 clock as the sensor driver got removed. The original
> v4l2_clk_unregister() should be put inside test as the clock can be
> already unregistered from unbind(). If there was not any bound sensor
> the clock is still present.
>
> The codepath is practically a copy from the old soc_camera. The bug was
> tested with a pxa_camera+ov9640 combination during the conversion
> of the ov9640 from the soc_camera.
>
> Signed-off-by: Petr Cvek <petr.c...@tul.cz>

Yeah, it's way better with this patch, especially the insmod/rmmod/insmod/rmmod
test.

Tested-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert


Re: [PATCH 1/2] media: platform: pxa_camera: add missing sensor power on

2016-10-18 Thread Robert Jarzmik
Robert Jarzmik <robert.jarz...@free.fr> writes:

> During sensors binding, there is a window where the sensor is switched
> off, while there is a call it to set a new format, which can end up in
> an access to the sensor, especially an I2C based sensor.
>
> Remove this window by activating the sensor.
Hi guys,

I can't remember if I have review issues I have to address for this serie or
not. My mailer seems to tell no, but let's check again.

This serie is adding back the "power on" of the sensors through the generic
regulator API, and is my prequisite for pxa submitted changes, which were
formerly a "hook" in soc_camera_link structure, see:
 https://www.spinics.net/lists/kernel/msg2350167.html

Cheers.

--
Robert

[1] Remaining of the patch for reference

> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
> ---
>  drivers/media/platform/pxa_camera.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/pxa_camera.c 
> b/drivers/media/platform/pxa_camera.c
> index 2978cd6efa63..794c41d24d9f 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2128,17 +2128,22 @@ static int pxa_camera_sensor_bound(struct 
> v4l2_async_notifier *notifier,
>   pix->bytesperline, pix->height);
>   pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc;
>   v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code);
> - err = sensor_call(pcdev, pad, set_fmt, NULL, );
> +
> + err = sensor_call(pcdev, core, s_power, 1);
>   if (err)
>   goto out;
>  
> + err = sensor_call(pcdev, pad, set_fmt, NULL, );
> + if (err)
> + goto out_sensor_poweroff;
> +
>   v4l2_fill_pix_format(pix, mf);
>   pr_info("%s(): colorspace=0x%x pixfmt=0x%x\n",
>   __func__, pix->colorspace, pix->pixelformat);
>  
>   err = pxa_camera_init_videobuf2(pcdev);
>   if (err)
> - goto out;
> + goto out_sensor_poweroff;
>  
>   err = video_register_device(>vdev, VFL_TYPE_GRABBER, -1);
>   if (err) {
> @@ -2149,6 +2154,9 @@ static int pxa_camera_sensor_bound(struct 
> v4l2_async_notifier *notifier,
>"PXA Camera driver attached to camera %s\n",
>subdev->name);
>   }
> +
> +out_sensor_poweroff:
> + err = sensor_call(pcdev, core, s_power, 0);
>  out:
>   mutex_unlock(>mlock);
>   return err;

-- 
Robert
--
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 54/57] [media] platform: don't break long lines

2016-10-14 Thread Robert Jarzmik
Mauro Carvalho Chehab <mche...@s-opensource.com> writes:

> Due to the 80-cols checkpatch warnings, several strings
> were broken into multiple lines. This is not considered
> a good practice anymore, as it makes harder to grep for
> strings at the source code. So, join those continuation
> lines.
>
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
> ---
>  drivers/media/platform/mx2_emmaprp.c | 3 +--
>  drivers/media/platform/pxa_camera.c  | 6 ++
>  drivers/media/platform/via-camera.c  | 7 ++-
>  3 files changed, 5 insertions(+), 11 deletions(-)
For pxa_camera, FWIW:
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert
--
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: mt9m111: add regulator support

2016-09-23 Thread Robert Jarzmik
In the soc_camera removal, the board specific power callback was
dropped. This at least will remove the power optimization from ezx and
em-x270 pxa based boards.

As to recreate the same level of functionality, make the mt9m111 have a
regulator providing it its power, so that board designers can plug in a
gpio based or ldo regulator, mimicking their former soc_camera power
hook.

Fixes: 5c10113cc668 ("media: mt9m111: make a standalone v4l2 subdevice")
Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/mt9m111.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 72e71b762827..bb8ed4927e44 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -215,6 +216,7 @@ struct mt9m111 {
int power_count;
const struct mt9m111_datafmt *fmt;
int lastpage;   /* PageMap cache value */
+   struct regulator *regulator;
 };
 
 /* Find a data format by a pixel code */
@@ -788,6 +790,9 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
if (ret < 0)
return ret;
 
+   if (mt9m111->regulator)
+   regulator_enable(mt9m111->regulator);
+
ret = mt9m111_resume(mt9m111);
if (ret < 0) {
dev_err(>dev, "Failed to resume the sensor: %d\n", ret);
@@ -800,6 +805,8 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 static void mt9m111_power_off(struct mt9m111 *mt9m111)
 {
mt9m111_suspend(mt9m111);
+   if (mt9m111->regulator)
+   regulator_disable(mt9m111->regulator);
v4l2_clk_disable(mt9m111->clk);
 }
 
@@ -943,6 +950,13 @@ static int mt9m111_probe(struct i2c_client *client,
if (!mt9m111)
return -ENOMEM;
 
+   mt9m111->regulator = devm_regulator_get(>dev, "vdd");
+   if (IS_ERR(mt9m111->regulator)) {
+   dev_err(>dev, "regulator not found: %d\n",
+   PTR_ERR(mt9m111->regulator));
+   return PTR_ERR(mt9m111->regulator);
+   }
+
mt9m111->clk = v4l2_clk_get(>dev, "mclk");
if (IS_ERR(mt9m111->clk))
return -EPROBE_DEFER;
-- 
2.1.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


[PATCH 1/2] media: platform: pxa_camera: add missing sensor power on

2016-09-23 Thread Robert Jarzmik
During sensors binding, there is a window where the sensor is switched
off, while there is a call it to set a new format, which can end up in
an access to the sensor, especially an I2C based sensor.

Remove this window by activating the sensor.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/pxa_camera.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index 2978cd6efa63..794c41d24d9f 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2128,17 +2128,22 @@ static int pxa_camera_sensor_bound(struct 
v4l2_async_notifier *notifier,
pix->bytesperline, pix->height);
pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc;
v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code);
-   err = sensor_call(pcdev, pad, set_fmt, NULL, );
+
+   err = sensor_call(pcdev, core, s_power, 1);
if (err)
goto out;
 
+   err = sensor_call(pcdev, pad, set_fmt, NULL, );
+   if (err)
+   goto out_sensor_poweroff;
+
v4l2_fill_pix_format(pix, mf);
pr_info("%s(): colorspace=0x%x pixfmt=0x%x\n",
__func__, pix->colorspace, pix->pixelformat);
 
err = pxa_camera_init_videobuf2(pcdev);
if (err)
-   goto out;
+   goto out_sensor_poweroff;
 
err = video_register_device(>vdev, VFL_TYPE_GRABBER, -1);
if (err) {
@@ -2149,6 +2154,9 @@ static int pxa_camera_sensor_bound(struct 
v4l2_async_notifier *notifier,
 "PXA Camera driver attached to camera %s\n",
 subdev->name);
}
+
+out_sensor_poweroff:
+   err = sensor_call(pcdev, core, s_power, 0);
 out:
mutex_unlock(>mlock);
return err;
-- 
2.1.4

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


Re: [PATCH] pxa_camera: merge soc_mediabus.c into pxa_camera.c

2016-09-23 Thread Robert Jarzmik
Hans Verkuil <hverk...@xs4all.nl> writes:

>> Hi Hans,
>> 
>> I wonder why you chose to copy-paste this code instead of adding in the 
>> Kconfig
>> a "depends on !SOC_CAMERA". Any specific reason ? As this will have to be 
>> dealt
>> with later anyway as you pointed out earlier, this format translation I 
>> mean, I
>> was wondering if this was the best approach.
>
> I thought about that, but that would make it impossible to COMPILE_TEST both 
> the
> pxa and the soc_camera driver. In addition, the pxa and soc_camera are the 
> only
> drivers that use this, and I prefer to just merge that code into pxa so that 
> it can
> be modified independently from soc_camera.
>
> I really want to remove all dependencies to soc_camera. That will also make 
> it easier
> to refactor soc_camera once I get the atmel-isi driver out of soc_camera.
Ok, fair enough.

I have tested that for at least YUV422, YUYV, YVYU and RGB565 formats :
Tested-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

-- 
Robert
--
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] pxa_camera: merge soc_mediabus.c into pxa_camera.c

2016-09-21 Thread Robert Jarzmik
Hans Verkuil <hverk...@xs4all.nl> writes:

> Linking soc_mediabus into this driver causes multiple definition linker 
> warnings
> if soc_camera is also enabled:
>
>
> drivers/media/platform/soc_camera/built-in.o:(___ksymtab+soc_mbus_image_size+0x0):
>  multiple definition of `__ksymtab_soc_mbus_image_size'
>
> drivers/media/platform/soc_camera/soc_mediabus.o:(___ksymtab+soc_mbus_image_size+0x0):
>  first defined here
>>> drivers/media/platform/soc_camera/built-in.o:(___ksymtab+soc_mbus_samples_per_pixel+0x0):
>>>  multiple definition of `__ksymtab_soc_mbus_samples_per_pixel'
>
> drivers/media/platform/soc_camera/soc_mediabus.o:(___ksymtab+soc_mbus_samples_per_pixel+0x0):
>  first defined here
>drivers/media/platform/soc_camera/built-in.o: In function 
> `soc_mbus_config_compatible':
>(.text+0x3840): multiple definition of `soc_mbus_config_compatible'
>drivers/media/platform/soc_camera/soc_mediabus.o:(.text+0x134): first 
> defined here
>
> Since we really don't want to have to use any of the soc-camera code this 
> patch
> copies the relevant code and data structures from soc_mediabus and renames it 
> to pxa_mbus_*.
>
> The large table of formats has been culled a bit, removing formats that are 
> not supported
> by this driver.
>
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
> Cc: Robert Jarzmik <robert.jarz...@free.fr>

Hi Hans,

I wonder why you chose to copy-paste this code instead of adding in the Kconfig
a "depends on !SOC_CAMERA". Any specific reason ? As this will have to be dealt
with later anyway as you pointed out earlier, this format translation I mean, I
was wondering if this was the best approach.

Cheers.

--
Robert
--
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 -next] [media] pxa_camera: remove duplicated include from pxa_camera.c

2016-09-21 Thread Robert Jarzmik
Wei Yongjun <weiyj...@gmail.com> writes:

> From: Wei Yongjun <weiyongj...@huawei.com>
>
> Remove duplicated include.
>
> Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

-- 
Robert
--
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 -next] [media] pxa_camera: fix error return code in pxa_camera_probe()

2016-09-21 Thread Robert Jarzmik
Wei Yongjun <weiyj...@gmail.com> writes:

> From: Wei Yongjun <weiyongj...@huawei.com>
>
> Fix to return error code -ENODEV from dma_request_slave_channel_compat()
> error handling case instead of 0, as done elsewhere in this function.
>
> Also fix to release resources in v4l2_clk_register() error handling.
>
> Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert
--
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] platform: pxa_camera: add VIDEO_V4L2 dependency

2016-09-21 Thread Robert Jarzmik
Arnd Bergmann <a...@arndb.de> writes:

> Moving the pxa_camera driver from soc_camera lots the implied
> VIDEO_V4L2 Kconfig dependency, and building the driver without
> V4L2 results in a kernel that cannot link:
>
> drivers/media/platform/pxa_camera.o: In function `pxa_camera_remove':
> pxa_camera.c:(.text.pxa_camera_remove+0x10): undefined reference to 
> `v4l2_clk_unregister'
> pxa_camera.c:(.text.pxa_camera_remove+0x18): undefined reference to 
> `v4l2_device_unregister'
> drivers/media/platform/pxa_camera.o: In function `pxa_camera_probe':
> pxa_camera.c:(.text.pxa_camera_probe+0x458): undefined reference to 
> `v4l2_of_parse_endpoint'
> drivers/media/v4l2-core/videobuf2-core.o: In function `__enqueue_in_driver':
> drivers/media/v4l2-core/videobuf2-core.o: In function `vb2_core_streamon':
> videobuf2-core.c:(.text.vb2_core_streamon+0x1b4): undefined reference to 
> `v4l_vb2q_enable_media_source'
> drivers/media/v4l2-core/videobuf2-v4l2.o: In function `vb2_ioctl_reqbufs':
> videobuf2-v4l2.c:(.text.vb2_ioctl_reqbufs+0xc): undefined reference to 
> `video_devdata'
>
> This adds back an explicit dependency.
That looks right to me.

Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert
--
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 2/2] [media] pxa_camera: remove an unused structure pointer

2016-09-18 Thread Robert Jarzmik
Mauro Carvalho Chehab <mche...@s-opensource.com> writes:

> As reported by smatch:
>
> drivers/media/platform/pxa_camera.c: In function 'pxa_dma_start_channels':
> drivers/media/platform/pxa_camera.c:457:21: warning: variable 'active' set 
> but not used [-Wunused-but-set-variable]
>   struct pxa_buffer *active;
>  ^~
>
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

-- 
Robert
--
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] pxa_camera: make soc_mbus_xlate_by_fourcc() static

2016-09-18 Thread Robert Jarzmik
Mauro Carvalho Chehab <mche...@s-opensource.com> writes:

> As warned by smatch:
>
> drivers/media/platform/pxa_camera.c:283:39: warning: no previous prototype 
> for 'soc_mbus_xlate_by_fourcc' [-Wmissing-prototypes]
>  const struct soc_camera_format_xlate *soc_mbus_xlate_by_fourcc(
>^~~~
>
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert
--
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] pxa_camera: allow building it if COMPILE_TEST is set

2016-09-06 Thread Robert Jarzmik
Hans Verkuil <hverk...@xs4all.nl> writes:

> Allow building this driver if COMPILE_TEST is set.
>
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

--
Robert
--
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 v6 13/14] media: platform: pxa_camera: move pxa_camera out of soc_camera

2016-09-06 Thread Robert Jarzmik
As the conversion to a v4l2 standalone device is finished, move
pxa_camera one directory up and finish severing any dependency to
soc_camera.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/Kconfig   | 8 
 drivers/media/platform/Makefile  | 1 +
 drivers/media/platform/{soc_camera => }/pxa_camera.c | 0
 drivers/media/platform/soc_camera/Kconfig| 8 
 drivers/media/platform/soc_camera/Makefile   | 1 -
 5 files changed, 9 insertions(+), 9 deletions(-)
 rename drivers/media/platform/{soc_camera => }/pxa_camera.c (100%)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 46f14ddeee65..09ad0659e1f8 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -91,6 +91,14 @@ config VIDEO_OMAP3_DEBUG
---help---
  Enable debug messages on OMAP 3 camera controller driver.
 
+config VIDEO_PXA27x
+   tristate "PXA27x Quick Capture Interface driver"
+   depends on VIDEO_DEV && PXA27x && HAS_DMA
+   select VIDEOBUF2_DMA_SG
+   select SG_SPLIT
+   ---help---
+ This is a v4l2 driver for the PXA27x Quick Capture Interface
+
 config VIDEO_S3C_CAMIF
tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 536d1d8ef022..44baff208452 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_VIDEO_CAFE_CCIC) += marvell-ccic/
 obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/
 
 obj-$(CONFIG_VIDEO_OMAP3)  += omap3isp/
+obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o soc_camera/soc_mediabus.o
 
 obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o
 
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
similarity index 100%
rename from drivers/media/platform/soc_camera/pxa_camera.c
rename to drivers/media/platform/pxa_camera.c
diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index 6b87b3a9d546..8b046dc49392 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -17,14 +17,6 @@ config SOC_CAMERA_PLATFORM
help
  This is a generic SoC camera platform driver, useful for testing
 
-config VIDEO_PXA27x
-   tristate "PXA27x Quick Capture Interface driver"
-   depends on VIDEO_DEV && PXA27x && HAS_DMA
-   select VIDEOBUF2_DMA_SG
-   select SG_SPLIT
-   ---help---
- This is a v4l2 driver for the PXA27x Quick Capture Interface
-
 config VIDEO_RCAR_VIN_OLD
tristate "R-Car Video Input (VIN) support (DEPRECATED)"
depends on VIDEO_DEV && SOC_CAMERA
diff --git a/drivers/media/platform/soc_camera/Makefile 
b/drivers/media/platform/soc_camera/Makefile
index ee8f9a4ae2a4..e189870a333d 100644
--- a/drivers/media/platform/soc_camera/Makefile
+++ b/drivers/media/platform/soc_camera/Makefile
@@ -7,6 +7,5 @@ obj-$(CONFIG_SOC_CAMERA_PLATFORM)   += soc_camera_platform.o
 
 # soc-camera host drivers have to be linked after camera drivers
 obj-$(CONFIG_VIDEO_ATMEL_ISI)  += atmel-isi.o
-obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
 obj-$(CONFIG_VIDEO_SH_MOBILE_CEU)  += sh_mobile_ceu_camera.o
 obj-$(CONFIG_VIDEO_RCAR_VIN_OLD)   += rcar_vin.o
-- 
2.1.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


[PATCH v6 06/14] media: platform: pxa_camera: introduce sensor_call

2016-09-06 Thread Robert Jarzmik
Introduce sensor_call(), which will be used for all sensor invocations.
This is a preparation move to v4l2 device conversion, ie. soc_camera
adherence removal.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 27 ++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 62e3f69a17ec..3091ec708a46 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -168,6 +168,9 @@
CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
CICR0_EOFM | CICR0_FOM)
 
+#define sensor_call(cam, o, f, args...) \
+   v4l2_subdev_call(sd, o, f, ##args)
+
 /*
  * Structures
  */
@@ -731,7 +734,7 @@ static void pxa_camera_setup_cicr(struct soc_camera_device 
*icd,
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
unsigned long dw, bpp;
u32 cicr0, cicr1, cicr2, cicr3, cicr4 = 0, y_skip_top;
-   int ret = v4l2_subdev_call(sd, sensor, g_skip_top_lines, _skip_top);
+   int ret = sensor_call(pcdev, sensor, g_skip_top_lines, _skip_top);
 
if (ret < 0)
y_skip_top = 0;
@@ -1073,7 +1076,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
if (ret < 0)
return ret;
 
-   ret = v4l2_subdev_call(sd, video, g_mbus_config, );
+   ret = sensor_call(pcdev, video, g_mbus_config, );
if (!ret) {
common_flags = soc_mbus_config_compatible(,
  bus_flags);
@@ -1117,7 +1120,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
}
 
cfg.flags = common_flags;
-   ret = v4l2_subdev_call(sd, video, s_mbus_config, );
+   ret = sensor_call(pcdev, video, s_mbus_config, );
if (ret < 0 && ret != -ENOIOCTLCMD) {
dev_dbg(icd->parent, "camera s_mbus_config(0x%lx) returned 
%d\n",
common_flags, ret);
@@ -1144,7 +1147,7 @@ static int pxa_camera_try_bus_param(struct 
soc_camera_device *icd,
if (ret < 0)
return ret;
 
-   ret = v4l2_subdev_call(sd, video, g_mbus_config, );
+   ret = sensor_call(pcdev, video, g_mbus_config, );
if (!ret) {
common_flags = soc_mbus_config_compatible(,
  bus_flags);
@@ -1195,7 +1198,7 @@ static int pxa_camera_get_formats(struct 
soc_camera_device *icd, unsigned int id
};
const struct soc_mbus_pixelfmt *fmt;
 
-   ret = v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, );
+   ret = sensor_call(pcdev, pad, enum_mbus_code, NULL, );
if (ret < 0)
/* No more formats */
return 0;
@@ -1303,7 +1306,7 @@ static int pxa_camera_set_selection(struct 
soc_camera_device *icd,
if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
icd->sense = 
 
-   ret = v4l2_subdev_call(sd, pad, set_selection, NULL, );
+   ret = sensor_call(pcdev, pad, set_selection, NULL, );
 
icd->sense = NULL;
 
@@ -1314,7 +1317,7 @@ static int pxa_camera_set_selection(struct 
soc_camera_device *icd,
}
sel->r = sdsel.r;
 
-   ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, get_fmt, NULL, );
if (ret < 0)
return ret;
 
@@ -1326,7 +1329,7 @@ static int pxa_camera_set_selection(struct 
soc_camera_device *icd,
v4l_bound_align_image(>width, 48, 2048, 1,
>height, 32, 2048, 0,
fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
-   ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
if (ret < 0)
return ret;
 
@@ -1391,7 +1394,7 @@ static int pxa_camera_set_fmt(struct soc_camera_device 
*icd,
mf->colorspace  = pix->colorspace;
mf->code= xlate->code;
 
-   ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
 
if (mf->code != xlate->code)
return -EINVAL;
@@ -1466,7 +1469,7 @@ static int pxa_camera_try_fmt(struct soc_camera_device 
*icd,
mf->colorspace  = pix->colorspace;
mf->code= xlate->code;
 
-   ret = v4l2_subdev_call(sd, pad, set_fmt, _cfg, );
+   ret = sensor_call(pcdev, pad, set_fmt, _cfg, );
if (ret < 0)
return ret;
 
@@ -1524,7 +1527,7 @@ static int pxa_camera_suspend(struct device *dev)
 
if (pcdev->soc_host.icd) {
struct v4l2_subdev *sd = 
soc_camera_to_subdev(pcdev->s

[PATCH v6 12/14] media: platform: pxa_camera: change stop_streaming semantics

2016-09-06 Thread Robert Jarzmik
Instead of the legacy behavior where it was required to wait for all
video buffers to be finished by the hardware, use a cancel like strategy
: as soon as the stop_streaming() call is done, abort all DMA transfers,
report the already buffers as failed and return.

This makes stop_streaming() more a "cancel capture" than a "wait for end
of capture" semantic.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index fb89b85f59ab..868c6ad4784c 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -523,7 +523,8 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev 
*pcdev)
 }
 
 static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
- struct pxa_buffer *buf)
+ struct pxa_buffer *buf,
+ enum vb2_buffer_state state)
 {
struct vb2_buffer *vb = >vbuf.vb2_buf;
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -645,7 +646,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
}
buf->active_dma &= ~act_dma;
if (!buf->active_dma) {
-   pxa_camera_wakeup(pcdev, buf);
+   pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_DONE);
pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan],
   last_issued);
}
@@ -1087,7 +1088,15 @@ static int pxac_vb2_start_streaming(struct vb2_queue 
*vq, unsigned int count)
 
 static void pxac_vb2_stop_streaming(struct vb2_queue *vq)
 {
-   vb2_wait_for_all_buffers(vq);
+   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
+   struct pxa_buffer *buf, *tmp;
+
+   dev_dbg(pcdev_to_dev(pcdev), "%s active=%p\n",
+   __func__, pcdev->active);
+   pxa_camera_stop_capture(pcdev);
+
+   list_for_each_entry_safe(buf, tmp, >capture, queue)
+   pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR);
 }
 
 static struct vb2_ops pxac_vb2_ops = {
-- 
2.1.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


[PATCH v6 11/14] media: platform: pxa_camera: add debug register access

2016-09-06 Thread Robert Jarzmik
Add pxa_camera registers access through advanced video debugging.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 32 ++
 1 file changed, 32 insertions(+)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 395cd398c32b..fb89b85f59ab 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1342,6 +1342,34 @@ static int pxa_camera_check_frame(u32 width, u32 height)
(width & 0x01);
 }
 
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int pxac_vidioc_g_register(struct file *file, void *priv,
+ struct v4l2_dbg_register *reg)
+{
+   struct pxa_camera_dev *pcdev = video_drvdata(file);
+
+   if (reg->reg > CIBR2)
+   return -ERANGE;
+
+   reg->val = __raw_readl(pcdev->base + reg->reg);
+   reg->size = sizeof(__u32);
+   return 0;
+}
+
+static int pxac_vidioc_s_register(struct file *file, void *priv,
+ const struct v4l2_dbg_register *reg)
+{
+   struct pxa_camera_dev *pcdev = video_drvdata(file);
+
+   if (reg->reg > CIBR2)
+   return -ERANGE;
+   if (reg->size != sizeof(__u32))
+   return -EINVAL;
+   __raw_writel(reg->val, pcdev->base + reg->reg);
+   return 0;
+}
+#endif
+
 static int pxac_vidioc_enum_fmt_vid_cap(struct file *filp, void  *priv,
struct v4l2_fmtdesc *f)
 {
@@ -1592,6 +1620,10 @@ static const struct v4l2_ioctl_ops pxa_camera_ioctl_ops 
= {
.vidioc_expbuf  = vb2_ioctl_expbuf,
.vidioc_streamon= vb2_ioctl_streamon,
.vidioc_streamoff   = vb2_ioctl_streamoff,
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+   .vidioc_g_register  = pxac_vidioc_g_register,
+   .vidioc_s_register  = pxac_vidioc_s_register,
+#endif
 };
 
 static struct v4l2_clk_ops pxa_camera_mclk_ops = {
-- 
2.1.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


[PATCH v6 07/14] media: platform: pxa_camera: make printk consistent

2016-09-06 Thread Robert Jarzmik
Make all print consistent by always using :
 - dev_xxx(pcdev_to_dev(pcdev), )

This prepares the soc_camera adherence removal by making these call rely
on only pcdev, and not the soc_camera icd structure.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 70 --
 1 file changed, 43 insertions(+), 27 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 3091ec708a46..026ed308fea8 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -236,6 +236,14 @@ struct pxa_cam {
 
 static const char *pxa_cam_driver_description = "PXA_Camera";
 
+static struct pxa_camera_dev *icd_to_pcdev(struct soc_camera_device *icd)
+{
+   struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+   struct pxa_camera_dev *pcdev = ici->priv;
+
+   return pcdev;
+}
+
 /*
  *  Videobuf operations
  */
@@ -465,7 +473,6 @@ static void pxa_camera_check_link_miss(struct 
pxa_camera_dev *pcdev,
 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
   enum pxa_camera_active_dma act_dma)
 {
-   struct device *dev = pcdev_to_dev(pcdev);
struct pxa_buffer *buf, *last_buf;
unsigned long flags;
u32 camera_status, overrun;
@@ -476,7 +483,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
spin_lock_irqsave(>lock, flags);
 
camera_status = __raw_readl(pcdev->base + CISR);
-   dev_dbg(dev, "camera dma irq, cisr=0x%x dma=%d\n",
+   dev_dbg(pcdev_to_dev(pcdev), "camera dma irq, cisr=0x%x dma=%d\n",
camera_status, act_dma);
overrun = CISR_IFO_0;
if (pcdev->channels == 3)
@@ -522,7 +529,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
   NULL, _issued);
if (camera_status & overrun &&
last_status != DMA_COMPLETE) {
-   dev_dbg(dev, "FIFO overrun! CISR: %x\n",
+   dev_dbg(pcdev_to_dev(pcdev), "FIFO overrun! CISR: %x\n",
camera_status);
pxa_camera_stop_capture(pcdev);
list_for_each_entry(buf, >capture, queue)
@@ -545,7 +552,6 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
struct pxa_camera_dev *pcdev)
 {
unsigned long mclk = pcdev->mclk;
-   struct device *dev = >dev;
u32 div;
unsigned long lcdclk;
 
@@ -555,7 +561,8 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
/* mclk <= ciclk / 4 (27.4.2) */
if (mclk > lcdclk / 4) {
mclk = lcdclk / 4;
-   dev_warn(dev, "Limiting master clock to %lu\n", mclk);
+   dev_warn(pcdev_to_dev(pcdev),
+"Limiting master clock to %lu\n", mclk);
}
 
/* We verify mclk != 0, so if anyone breaks it, here comes their Oops */
@@ -565,7 +572,7 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
pcdev->mclk = lcdclk / (2 * (div + 1));
 
-   dev_dbg(dev, "LCD clock %luHz, target freq %luHz, divisor %u\n",
+   dev_dbg(pcdev_to_dev(pcdev), "LCD clock %luHz, target freq %luHz, 
divisor %u\n",
lcdclk, mclk, div);
 
return div;
@@ -662,7 +669,9 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
 
 static int pxa_camera_add_device(struct soc_camera_device *icd)
 {
-   dev_info(icd->parent, "PXA Camera driver attached to camera %d\n",
+   struct pxa_camera_dev *pcdev = icd_to_pcdev(icd);
+
+   dev_info(pcdev_to_dev(pcdev), "PXA Camera driver attached to camera 
%d\n",
 icd->devnum);
 
return 0;
@@ -670,7 +679,9 @@ static int pxa_camera_add_device(struct soc_camera_device 
*icd)
 
 static void pxa_camera_remove_device(struct soc_camera_device *icd)
 {
-   dev_info(icd->parent, "PXA Camera driver detached from camera %d\n",
+   struct pxa_camera_dev *pcdev = icd_to_pcdev(icd);
+
+   dev_info(pcdev_to_dev(pcdev), "PXA Camera driver detached from camera 
%d\n",
 icd->devnum);
 }
 
@@ -1081,7 +1092,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
common_flags = soc_mbus_config_compatible(,
  bus_flags);
if (!common_flags) {
-   dev_warn(icd->parent,
+   dev_warn(pcdev_to_dev(pcdev),
 "Flags incompatible: camera 0x%x, host 
0x%lx\n",
 cfg.flags, b

[PATCH v6 14/14] media: platform: pxa_camera: fix style

2016-09-06 Thread Robert Jarzmik
This is a tiny fix for a switch case which quiets 2 checkpatch harmless
warnings. The generated code is not affected.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/pxa_camera.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index 868c6ad4784c..c2d1ceaea49b 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -1296,6 +1296,7 @@ static int pxa_camera_get_formats(struct v4l2_device 
*v4l2_dev,
"Providing format %s using code %d\n",
pxa_camera_formats[0].name, code.code);
}
+   /* fall through */
case MEDIA_BUS_FMT_VYUY8_2X8:
case MEDIA_BUS_FMT_YUYV8_2X8:
case MEDIA_BUS_FMT_YVYU8_2X8:
@@ -1313,6 +1314,7 @@ static int pxa_camera_get_formats(struct v4l2_device 
*v4l2_dev,
dev_dbg(pcdev_to_dev(pcdev),
"Providing format %s in pass-through mode\n",
fmt->name);
+   break;
}
 
/* Generic pass-through */
-- 
2.1.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


[PATCH v6 02/14] media: mt9m111: use only the SRGB colorspace

2016-09-06 Thread Robert Jarzmik
mt9m111 being a camera sensor, its colorspace should always be SRGB, for
both RGB based formats or YCbCr based ones.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/soc_camera/mt9m111.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index 7faf49f0d9f9..72e71b762827 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -188,10 +188,10 @@ struct mt9m111_datafmt {
 };
 
 static const struct mt9m111_datafmt mt9m111_colour_fmts[] = {
-   {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG},
+   {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
-- 
2.1.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


[PATCH v6 05/14] media: platform: pxa_camera: trivial move of functions

2016-09-06 Thread Robert Jarzmik
Move the functions in the file to be regrouped into meaningful blocks :
 1. pxa camera core handling functions, manipulating the herdware
 2. videobuf2 functions, dealing with video buffers
 3. video ioctl (vidioc) related functions
 4. driver probing, removal, suspend and resume

This patch doesn't modify a single line of code.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 473 +
 1 file changed, 241 insertions(+), 232 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index d565bcb9f2d6..62e3f69a17ec 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -538,238 +538,6 @@ out:
spin_unlock_irqrestore(>lock, flags);
 }
 
-static void pxa_buffer_cleanup(struct pxa_buffer *buf)
-{
-   int i;
-
-   for (i = 0; i < 3 && buf->descs[i]; i++) {
-   dmaengine_desc_free(buf->descs[i]);
-   kfree(buf->sg[i]);
-   buf->descs[i] = NULL;
-   buf->sg[i] = NULL;
-   buf->sg_len[i] = 0;
-   buf->plane_sizes[i] = 0;
-   }
-   buf->nb_planes = 0;
-}
-
-static int pxa_buffer_init(struct pxa_camera_dev *pcdev,
-  struct pxa_buffer *buf)
-{
-   struct vb2_buffer *vb = >vbuf.vb2_buf;
-   struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
-   int nb_channels = pcdev->channels;
-   int i, ret = 0;
-   unsigned long size = vb2_plane_size(vb, 0);
-
-   switch (nb_channels) {
-   case 1:
-   buf->plane_sizes[0] = size;
-   break;
-   case 3:
-   buf->plane_sizes[0] = size / 2;
-   buf->plane_sizes[1] = size / 4;
-   buf->plane_sizes[2] = size / 4;
-   break;
-   default:
-   return -EINVAL;
-   };
-   buf->nb_planes = nb_channels;
-
-   ret = sg_split(sgt->sgl, sgt->nents, 0, nb_channels,
-  buf->plane_sizes, buf->sg, buf->sg_len, GFP_KERNEL);
-   if (ret < 0) {
-   dev_err(pcdev_to_dev(pcdev),
-   "sg_split failed: %d\n", ret);
-   return ret;
-   }
-   for (i = 0; i < nb_channels; i++) {
-   ret = pxa_init_dma_channel(pcdev, buf, i,
-  buf->sg[i], buf->sg_len[i]);
-   if (ret) {
-   pxa_buffer_cleanup(buf);
-   return ret;
-   }
-   }
-   INIT_LIST_HEAD(>queue);
-
-   return ret;
-}
-
-static void pxac_vb2_cleanup(struct vb2_buffer *vb)
-{
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s(vb=%p)\n", __func__, vb);
-   pxa_buffer_cleanup(buf);
-}
-
-static void pxac_vb2_queue(struct vb2_buffer *vb)
-{
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s(vb=%p) nb_channels=%d size=%lu active=%p\n",
-   __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0),
-   pcdev->active);
-
-   list_add_tail(>queue, >capture);
-
-   pxa_dma_add_tail_buf(pcdev, buf);
-}
-
-/*
- * Please check the DMA prepared buffer structure in :
- *   Documentation/video4linux/pxa_camera.txt
- * Please check also in pxa_camera_check_link_miss() to understand why DMA 
chain
- * modification while DMA chain is running will work anyway.
- */
-static int pxac_vb2_prepare(struct vb2_buffer *vb)
-{
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
-   int ret = 0;
-
-   switch (pcdev->channels) {
-   case 1:
-   case 3:
-   vb2_set_plane_payload(vb, 0, icd->sizeimage);
-   break;
-   default:
-   return -EINVAL;
-   }
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s (vb=%p) nb_channels=%d size=%lu\n",
-   __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0));
-
-   WARN_ON(!icd->current_fmt);
-
-#ifdef DEBUG
-   /*
-* This can be useful if you want to see if we actually fill
-* the buffer with something
-*/
-   for (i = 0; i < vb->num_planes; i++)
-   memset((void *)vb2_plane_vaddr(vb, i),
-  0xaa, vb2_get_plane_payload(vb, i));
-#endif
-
-   /*
-* I think, in buf_prepare you only have to pr

[PATCH v6 01/14] media: mt9m111: make a standalone v4l2 subdevice

2016-09-06 Thread Robert Jarzmik
Remove the soc_camera adherence. Mostly the change removes the power
manipulation provided by soc_camera, and instead :
 - powers on the sensor when the s_power control is activated
 - powers on the sensor in initial probe
 - enables and disables the MCLK provided to it in power on/off

This patch also drops support for inverters on synchronisation and clock
lines. It is assumed, if any board ever needs such inverters, support
for them can be added in the future

Acked-by: Guennadi Liakhovetski <g.liakhovet...@gmx.de>
Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/soc_camera/mt9m111.c | 51 ++
 1 file changed, 15 insertions(+), 36 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index 6c8d1123658c..7faf49f0d9f9 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -16,10 +16,11 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 /*
  * MT9M111, MT9M112 and MT9M131:
@@ -391,7 +392,7 @@ static int mt9m111_set_selection(struct v4l2_subdev *sd,
struct mt9m111 *mt9m111 = to_mt9m111(client);
struct v4l2_rect rect = sel->r;
int width, height;
-   int ret;
+   int ret, align = 0;
 
if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE ||
sel->target != V4L2_SEL_TGT_CROP)
@@ -400,17 +401,19 @@ static int mt9m111_set_selection(struct v4l2_subdev *sd,
if (mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 ||
mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) {
/* Bayer format - even size lengths */
-   rect.width  = ALIGN(rect.width, 2);
-   rect.height = ALIGN(rect.height, 2);
+   align = 1;
/* Let the user play with the starting pixel */
}
 
/* FIXME: the datasheet doesn't specify minimum sizes */
-   soc_camera_limit_side(, ,
-MT9M111_MIN_DARK_COLS, 2, MT9M111_MAX_WIDTH);
-
-   soc_camera_limit_side(, ,
-MT9M111_MIN_DARK_ROWS, 2, MT9M111_MAX_HEIGHT);
+   v4l_bound_align_image(, 2, MT9M111_MAX_WIDTH, align,
+ , 2, MT9M111_MAX_HEIGHT, align, 0);
+   rect.left = clamp(rect.left, MT9M111_MIN_DARK_COLS,
+ MT9M111_MIN_DARK_COLS + MT9M111_MAX_WIDTH -
+ (__s32)rect.width);
+   rect.top = clamp(rect.top, MT9M111_MIN_DARK_ROWS,
+MT9M111_MIN_DARK_ROWS + MT9M111_MAX_HEIGHT -
+(__s32)rect.height);
 
width = min(mt9m111->width, rect.width);
height = min(mt9m111->height, rect.height);
@@ -779,17 +782,16 @@ static int mt9m111_init(struct mt9m111 *mt9m111)
 static int mt9m111_power_on(struct mt9m111 *mt9m111)
 {
struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
 
-   ret = soc_camera_power_on(>dev, ssdd, mt9m111->clk);
+   ret = v4l2_clk_enable(mt9m111->clk);
if (ret < 0)
return ret;
 
ret = mt9m111_resume(mt9m111);
if (ret < 0) {
dev_err(>dev, "Failed to resume the sensor: %d\n", ret);
-   soc_camera_power_off(>dev, ssdd, mt9m111->clk);
+   v4l2_clk_disable(mt9m111->clk);
}
 
return ret;
@@ -797,11 +799,8 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 
 static void mt9m111_power_off(struct mt9m111 *mt9m111)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
-
mt9m111_suspend(mt9m111);
-   soc_camera_power_off(>dev, ssdd, mt9m111->clk);
+   v4l2_clk_disable(mt9m111->clk);
 }
 
 static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
@@ -858,14 +857,10 @@ static int mt9m111_enum_mbus_code(struct v4l2_subdev *sd,
 static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
struct v4l2_mbus_config *cfg)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
-
cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
V4L2_MBUS_DATA_ACTIVE_HIGH;
cfg->type = V4L2_MBUS_PARALLEL;
-   cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
 
return 0;
 }
@@ -936,20 +931,8 @@ static int mt9m111_probe(struct i2c_client *client,
 {
struct mt9m111 *mt9m111;
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);

[PATCH v6 03/14] media: mt9m111: move mt9m111 out of soc_camera

2016-09-06 Thread Robert Jarzmik
As the mt9m111 is now working as a standalone v4l2 subdevice sensor,
move it out of soc_camera directory and severe its dependency on
soc_camera.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/Kconfig| 7 +++
 drivers/media/i2c/Makefile   | 1 +
 drivers/media/i2c/{soc_camera => }/mt9m111.c | 0
 drivers/media/i2c/soc_camera/Kconfig | 7 +--
 drivers/media/i2c/soc_camera/Makefile| 1 -
 5 files changed, 13 insertions(+), 3 deletions(-)
 rename drivers/media/i2c/{soc_camera => }/mt9m111.c (100%)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 92cc54401339..7f929336c409 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -578,6 +578,13 @@ config VIDEO_MT9M032
  This driver supports MT9M032 camera sensors from Aptina, monochrome
  models only.
 
+config VIDEO_MT9M111
+   tristate "mt9m111, mt9m112 and mt9m131 support"
+   depends on I2C && VIDEO_V4L2
+   help
+ This driver supports MT9M111, MT9M112 and MT9M131 cameras from
+ Micron/Aptina
+
 config VIDEO_MT9P031
tristate "Aptina MT9P031 support"
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 0216af0f9281..92773b2e6225 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
 obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
+obj-$(CONFIG_VIDEO_MT9M111) += mt9m111.o
 obj-$(CONFIG_VIDEO_MT9P031) += mt9p031.o
 obj-$(CONFIG_VIDEO_MT9T001) += mt9t001.o
 obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/mt9m111.c
similarity index 100%
rename from drivers/media/i2c/soc_camera/mt9m111.c
rename to drivers/media/i2c/mt9m111.c
diff --git a/drivers/media/i2c/soc_camera/Kconfig 
b/drivers/media/i2c/soc_camera/Kconfig
index 23d352f0adf0..7704bcf5cc25 100644
--- a/drivers/media/i2c/soc_camera/Kconfig
+++ b/drivers/media/i2c/soc_camera/Kconfig
@@ -14,11 +14,14 @@ config SOC_CAMERA_MT9M001
  and colour models.
 
 config SOC_CAMERA_MT9M111
-   tristate "mt9m111, mt9m112 and mt9m131 support"
+   tristate "legacy soc_camera mt9m111, mt9m112 and mt9m131 support"
depends on SOC_CAMERA && I2C
+   select VIDEO_MT9M111
help
  This driver supports MT9M111, MT9M112 and MT9M131 cameras from
- Micron/Aptina
+ Micron/Aptina.
+ This is the legacy configuration which shouldn't be used anymore,
+ while VIDEO_MT9M111 should be used instead.
 
 config SOC_CAMERA_MT9T031
tristate "mt9t031 support"
diff --git a/drivers/media/i2c/soc_camera/Makefile 
b/drivers/media/i2c/soc_camera/Makefile
index d0421feaa796..6f994f9353a0 100644
--- a/drivers/media/i2c/soc_camera/Makefile
+++ b/drivers/media/i2c/soc_camera/Makefile
@@ -1,6 +1,5 @@
 obj-$(CONFIG_SOC_CAMERA_IMX074)+= imx074.o
 obj-$(CONFIG_SOC_CAMERA_MT9M001)   += mt9m001.o
-obj-$(CONFIG_SOC_CAMERA_MT9M111)   += mt9m111.o
 obj-$(CONFIG_SOC_CAMERA_MT9T031)   += mt9t031.o
 obj-$(CONFIG_SOC_CAMERA_MT9T112)   += mt9t112.o
 obj-$(CONFIG_SOC_CAMERA_MT9V022)   += mt9v022.o
-- 
2.1.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


[PATCH v6 10/14] media: platform: pxa_camera: make a standalone v4l2 device

2016-09-06 Thread Robert Jarzmik
This patch removes the soc_camera API dependency from pxa_camera.
In the current status :
 - all previously captures are working the same on pxa270
 - the s_crop() call was removed, judged not working
   (see what happens soc_camera_s_crop() when get_crop() == NULL)
 - if the pixel clock is provided by then sensor, ie. not MCLK, the dual
   stage change is not handled yet.
   => there is no in-tree user of this, so I'll let it that way

 - the MCLK is not yet finished, it's as in the legacy way,
   ie. activated at video device opening and closed at video device
   closing.
   In a subsequence patch pxa_camera_mclk_ops should be used, and
   platform data MCLK ignored. It will be the sensor's duty to request
   the clock and enable it, which will end in pxa_camera_mclk_ops.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/Kconfig  |   2 +-
 drivers/media/platform/soc_camera/pxa_camera.c | 753 +
 include/linux/platform_data/media/camera-pxa.h |   2 +
 3 files changed, 518 insertions(+), 239 deletions(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index de1767899ddc..6b87b3a9d546 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -19,7 +19,7 @@ config SOC_CAMERA_PLATFORM
 
 config VIDEO_PXA27x
tristate "PXA27x Quick Capture Interface driver"
-   depends on VIDEO_DEV && PXA27x && SOC_CAMERA && HAS_DMA
+   depends on VIDEO_DEV && PXA27x && HAS_DMA
select VIDEOBUF2_DMA_SG
select SG_SPLIT
---help---
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 8f329d0b2cda..395cd398c32b 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2006, Sascha Hauer, Pengutronix
  * Copyright (C) 2008, Guennadi Liakhovetski <ker...@pengutronix.de>
+ * Copyright (C) 2016, Robert Jarzmik <robert.jarz...@free.fr>
  *
  * 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
@@ -14,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -32,13 +35,16 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include 
@@ -46,6 +52,9 @@
 #define PXA_CAM_VERSION "0.0.6"
 #define PXA_CAM_DRV_NAME "pxa27x-camera"
 
+#define DEFAULT_WIDTH  640
+#define DEFAULT_HEIGHT 480
+
 /* Camera Interface */
 #define CICR0  0x
 #define CICR1  0x0004
@@ -169,7 +178,25 @@
CICR0_EOFM | CICR0_FOM)
 
 #define sensor_call(cam, o, f, args...) \
-   v4l2_subdev_call(sd, o, f, ##args)
+   v4l2_subdev_call(cam->sensor, o, f, ##args)
+
+/*
+ * Format handling
+ */
+/**
+ * struct soc_camera_format_xlate - match between host and sensor formats
+ * @code: code of a sensor provided format
+ * @host_fmt: host format after host translation from code
+ *
+ * Host and sensor translation structure. Used in table of host and sensor
+ * formats matchings in soc_camera_device. A host can override the generic list
+ * generation by implementing get_formats(), and use it for format checks and
+ * format setup.
+ */
+struct soc_camera_format_xlate {
+   u32 code;
+   const struct soc_mbus_pixelfmt *host_fmt;
+};
 
 /*
  * Structures
@@ -198,7 +225,18 @@ struct pxa_buffer {
 };
 
 struct pxa_camera_dev {
-   struct soc_camera_host  soc_host;
+   struct v4l2_device  v4l2_dev;
+   struct video_device vdev;
+   struct v4l2_async_notifier notifier;
+   struct vb2_queuevb2_vq;
+   struct v4l2_subdev  *sensor;
+   struct soc_camera_format_xlate *user_formats;
+   const struct soc_camera_format_xlate *current_fmt;
+   struct v4l2_pix_format  current_pix;
+
+   struct v4l2_async_subdev asd;
+   struct v4l2_async_subdev *asds[1];
+
/*
 * PXA27x is only supposed to handle one camera on its Quick Capture
 * interface. If anyone ever builds hardware to enable more than
@@ -218,11 +256,13 @@ struct pxa_camera_dev {
unsigned long   ciclk;
unsigned long   mclk;
u32 mclk_divisor;
+   struct v4l2_clk *mclk_clk;
u16 width_flags;/* max 10 bits */
 
struct list_headcapture;
 
spinlock_t  lock;
+   struct mutexmlock;
unsigned intbuf_sequence;
 
  

[PATCH v6 08/14] media: platform: pxa_camera: add buffer sequencing

2016-09-06 Thread Robert Jarzmik
Add sequence numbers to completed buffers.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 026ed308fea8..d9e2570d3931 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -223,6 +223,7 @@ struct pxa_camera_dev {
struct list_headcapture;
 
spinlock_t  lock;
+   unsigned intbuf_sequence;
 
struct pxa_buffer   *active;
struct tasklet_struct   task_eof;
@@ -423,10 +424,13 @@ static void pxa_camera_wakeup(struct pxa_camera_dev 
*pcdev,
  struct pxa_buffer *buf)
 {
struct vb2_buffer *vb = >vbuf.vb2_buf;
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 
/* _init is used to debug races, see comment in pxa_camera_reqbufs() */
list_del_init(>queue);
vb->timestamp = ktime_get_ns();
+   vbuf->sequence = pcdev->buf_sequence++;
+   vbuf->field = V4L2_FIELD_NONE;
vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
dev_dbg(pcdev_to_dev(pcdev), "%s dequeud buffer (buf=0x%p)\n",
__func__, buf);
@@ -1022,6 +1026,7 @@ static int pxac_vb2_start_streaming(struct vb2_queue *vq, 
unsigned int count)
dev_dbg(pcdev_to_dev(pcdev), "%s(count=%d) active=%p\n",
__func__, count, pcdev->active);
 
+   pcdev->buf_sequence = 0;
if (!pcdev->active)
pxa_camera_start_capture(pcdev);
 
-- 
2.1.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


[PATCH v6 04/14] media: platform: pxa_camera: convert to vb2

2016-09-06 Thread Robert Jarzmik
Convert pxa_camera from videobuf to videobuf2.

As the soc_camera was already compatible with videobuf2, the port is
quite straightforward.

The special case of this code in which the vb2 to prepare is "too
big" in terms of size for the new capture format, the pxa_camera will
fail.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/Kconfig  |   4 +-
 drivers/media/platform/soc_camera/pxa_camera.c | 579 -
 2 files changed, 269 insertions(+), 314 deletions(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index 99cf471a5fc0..de1767899ddc 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -19,8 +19,8 @@ config SOC_CAMERA_PLATFORM
 
 config VIDEO_PXA27x
tristate "PXA27x Quick Capture Interface driver"
-   depends on VIDEO_DEV && PXA27x && SOC_CAMERA
-   select VIDEOBUF_DMA_SG
+   depends on VIDEO_DEV && PXA27x && SOC_CAMERA && HAS_DMA
+   select VIDEOBUF2_DMA_SG
select SG_SPLIT
---help---
  This is a v4l2 driver for the PXA27x Quick Capture Interface
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index ebbe514d64e2..d565bcb9f2d6 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -34,7 +34,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -180,13 +180,16 @@ enum pxa_camera_active_dma {
 /* buffer for one video frame */
 struct pxa_buffer {
/* common v4l buffer stuff -- must be first */
-   struct videobuf_buffer  vb;
+   struct vb2_v4l2_buffer  vbuf;
+   struct list_headqueue;
u32 code;
+   int nb_planes;
/* our descriptor lists for Y, U and V channels */
struct dma_async_tx_descriptor  *descs[3];
dma_cookie_tcookie[3];
struct scatterlist  *sg[3];
int sg_len[3];
+   size_t  plane_sizes[3];
int inwork;
enum pxa_camera_active_dma  active_dma;
 };
@@ -230,59 +233,19 @@ struct pxa_cam {
 
 static const char *pxa_cam_driver_description = "PXA_Camera";
 
-static unsigned int vid_limit = 16;/* Video memory limit, in Mb */
-
 /*
  *  Videobuf operations
  */
-static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
- unsigned int *size)
+static struct pxa_buffer *vb2_to_pxa_buffer(struct vb2_buffer *vb)
 {
-   struct soc_camera_device *icd = vq->priv_data;
-
-   dev_dbg(icd->parent, "count=%d, size=%d\n", *count, *size);
-
-   *size = icd->sizeimage;
-
-   if (0 == *count)
-   *count = 32;
-   if (*size * *count > vid_limit * 1024 * 1024)
-   *count = (vid_limit * 1024 * 1024) / *size;
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 
-   return 0;
+   return container_of(vbuf, struct pxa_buffer, vbuf);
 }
 
-static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
+static struct device *pcdev_to_dev(struct pxa_camera_dev *pcdev)
 {
-   struct soc_camera_device *icd = vq->priv_data;
-   struct videobuf_dmabuf *dma = videobuf_to_dma(>vb);
-   int i;
-
-   BUG_ON(in_interrupt());
-
-   dev_dbg(icd->parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
-   >vb, buf->vb.baddr, buf->vb.bsize);
-
-   /*
-* This waits until this buffer is out of danger, i.e., until it is no
-* longer in STATE_QUEUED or STATE_ACTIVE
-*/
-   videobuf_waiton(vq, >vb, 0, 0);
-
-   for (i = 0; i < 3 && buf->descs[i]; i++) {
-   dmaengine_desc_free(buf->descs[i]);
-   kfree(buf->sg[i]);
-   buf->descs[i] = NULL;
-   buf->sg[i] = NULL;
-   buf->sg_len[i] = 0;
-   }
-   videobuf_dma_unmap(vq->dev, dma);
-   videobuf_dma_free(dma);
-
-   buf->vb.state = VIDEOBUF_NEEDS_INIT;
-
-   dev_dbg(icd->parent, "%s end (vb=0x%p) 0x%08lx %d\n", __func__,
-   >vb, buf->vb.baddr, buf->vb.bsize);
+   return pcdev->soc_host.v4l2_dev.dev;
 }
 
 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
@@ -312,31 +275,26 @@ static void pxa_camera_dma_irq_v(void *data)
 /**
  * pxa_init_dma_channel - init dma descriptors
  * @pcdev: pxa camera device
- * @buf: pxa buffer to find pxa dma channel
+ * @vb: videobuffer2 buffer
  * @dma: dma video buffer
  * @channel: dma channel (0 => 'Y', 1 => 'U', 2 => 'V')
  * @cibr

[PATCH v6 09/14] media: platform: pxa_camera: remove set_selection

2016-09-06 Thread Robert Jarzmik
This is to be seen as a regression as the set_selection (former
set_crop) function is removed. This is a temporary situation in the v4l2
porting, and will have to be added later.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 83 --
 1 file changed, 83 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index d9e2570d3931..8f329d0b2cda 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1294,88 +1294,6 @@ static int pxa_camera_check_frame(u32 width, u32 height)
(width & 0x01);
 }
 
-static int pxa_camera_set_selection(struct soc_camera_device *icd,
-   struct v4l2_selection *sel)
-{
-   const struct v4l2_rect *rect = >r;
-   struct device *dev = icd->parent;
-   struct soc_camera_host *ici = to_soc_camera_host(dev);
-   struct pxa_camera_dev *pcdev = ici->priv;
-   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct soc_camera_sense sense = {
-   .master_clock = pcdev->mclk,
-   .pixel_clock_max = pcdev->ciclk / 4,
-   };
-   struct v4l2_subdev_format fmt = {
-   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
-   };
-   struct v4l2_mbus_framefmt *mf = 
-   struct pxa_cam *cam = icd->host_priv;
-   u32 fourcc = icd->current_fmt->host_fmt->fourcc;
-   struct v4l2_subdev_selection sdsel = {
-   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
-   .target = sel->target,
-   .flags = sel->flags,
-   .r = sel->r,
-   };
-   int ret;
-
-   /* If PCLK is used to latch data from the sensor, check sense */
-   if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
-   icd->sense = 
-
-   ret = sensor_call(pcdev, pad, set_selection, NULL, );
-
-   icd->sense = NULL;
-
-   if (ret < 0) {
-   dev_warn(pcdev_to_dev(pcdev), "Failed to crop to %ux%u@%u:%u\n",
-rect->width, rect->height, rect->left, rect->top);
-   return ret;
-   }
-   sel->r = sdsel.r;
-
-   ret = sensor_call(pcdev, pad, get_fmt, NULL, );
-   if (ret < 0)
-   return ret;
-
-   if (pxa_camera_check_frame(mf->width, mf->height)) {
-   /*
-* Camera cropping produced a frame beyond our capabilities.
-* FIXME: just extract a subframe, that we can process.
-*/
-   v4l_bound_align_image(>width, 48, 2048, 1,
-   >height, 32, 2048, 0,
-   fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
-   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
-   if (ret < 0)
-   return ret;
-
-   if (pxa_camera_check_frame(mf->width, mf->height)) {
-   dev_warn(pcdev_to_dev(pcdev),
-"Inconsistent state. Use S_FMT to repair\n");
-   return -EINVAL;
-   }
-   }
-
-   if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
-   if (sense.pixel_clock > sense.pixel_clock_max) {
-   dev_err(pcdev_to_dev(pcdev),
-   "pixel clock %lu set by the camera too high!",
-   sense.pixel_clock);
-   return -EIO;
-   }
-   recalculate_fifo_timeout(pcdev, sense.pixel_clock);
-   }
-
-   icd->user_width = mf->width;
-   icd->user_height= mf->height;
-
-   pxa_camera_setup_cicr(icd, cam->flags, fourcc);
-
-   return ret;
-}
-
 static int pxa_camera_set_fmt(struct soc_camera_device *icd,
  struct v4l2_format *f)
 {
@@ -1588,7 +1506,6 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops 
= {
.remove = pxa_camera_remove_device,
.clock_start= pxa_camera_clock_start,
.clock_stop = pxa_camera_clock_stop,
-   .set_selection  = pxa_camera_set_selection,
.get_formats= pxa_camera_get_formats,
.put_formats= pxa_camera_put_formats,
.set_fmt= pxa_camera_set_fmt,
-- 
2.1.4

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


Re: [PATCH v5 00/13] pxa_camera transition to v4l2 standalone device

2016-09-06 Thread Robert Jarzmik
Hans Verkuil <hverk...@xs4all.nl> writes:

> On 08/29/2016 07:55 PM, Robert Jarzmik wrote:
>> There is no change between v4 and v5, ie. the global diff is empty, only one
>> line was shifted to prevent breaking bisectablility.
>
> Against which tree do you develop? Unfortunately this patch series doesn't 
> apply
> to the media_tree master branch anymore due to conflicts with a merged patch 
> that
> converts s/g_crop to s/g_selection in all subdev drivers.
v4.8-rc1 is their base, so Linus's master.

> When you make the new patch series, please use the -M option with git 
> send-email so
> patches that move files around are handled cleanly. That makes it much easier
> to review.
Ok.

> BTW, checkpatch reported issues in a switch statement in function
> pxa_camera_get_formats():
Yep, I noticed.

> switch (code.code) {
> case MEDIA_BUS_FMT_UYVY8_2X8:
> formats++;
> if (xlate) {
> xlate->host_fmt = _camera_formats[0];
> xlate->code = code.code;
> xlate++;
> dev_dbg(dev, "Providing format %s using code %d\n",
> pxa_camera_formats[0].name, code.code);
> }
> case MEDIA_BUS_FMT_VYUY8_2X8:
> case MEDIA_BUS_FMT_YUYV8_2X8:
> case MEDIA_BUS_FMT_YVYU8_2X8:
> case MEDIA_BUS_FMT_RGB565_2X8_LE:
> case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
> if (xlate)
> dev_dbg(dev, "Providing format %s packed\n",
> fmt->name);
> break;
> default:
> if (!pxa_camera_packing_supported(fmt))
> return 0;
> if (xlate)
> dev_dbg(dev,
> "Providing format %s in pass-through mode\n",
> fmt->name);
> }
>
> Before 'case MEDIA_BUS_FMT_VYUY8_2X8' should there be a break? If not, then
> there should be a '/* fall through */' comment.
There should have been a '/* fall through */' in the original code, even if that
was not strictly "required" at the time of writing.
>
> At the end of the default case there should also be a break statement.
>
> This is already in the existing code, so just make a separate patch fixing
> this.
Ok, will do.

Cheers.

--
Robert
--
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 v5 01/13] media: mt9m111: make a standalone v4l2 subdevice

2016-08-30 Thread Robert Jarzmik
Guennadi Liakhovetski <g.liakhovet...@gmx.de> writes:

> Hi Robert,
>
> On Mon, 29 Aug 2016, Robert Jarzmik wrote:
>
>> Remove the soc_camera adherence. Mostly the change removes the power
>> manipulation provided by soc_camera, and instead :
>>  - powers on the sensor when the s_power control is activated
>>  - powers on the sensor in initial probe
>>  - enables and disables the MCLK provided to it in power on/off
>
> Your patch also drops support for inverters on synchronisation and clock 
> lines, I guess, your board doesn't use any. I assume, if any board ever 
> needs such inverters, support for them can be added in the future.
Ah yeah, that would deserve a notice in the commit message.

It's a bit a pity to respin the whole serie for it, but you've got a fair
point. Maybe Hans would agree to apply 4/13 to 13/13 (if there is no comment
remaining), and let me respin the 3 patches around mtm9111.

> Also, as I mentioned in my reply to your other patch, maybe good to join this
> with #3. Otherwise and with that in mind
I'd like to keep the move separate from the remaining part. And yes, I should
have used the "-M" option ... I added it to my submission script so that I don't
forget it again :)

Thanks for the Ack, and cheers.

--
Robert
--
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 v5 09/13] media: platform: pxa_camera: remove set_crop

2016-08-29 Thread Robert Jarzmik
This is to be seen as a regression as the set_crop function is
removed. This is a temporary situation in the v4l2 porting, and will
have to be added later.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 76 --
 1 file changed, 76 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 9b294a14fa2e..8f329d0b2cda 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1294,81 +1294,6 @@ static int pxa_camera_check_frame(u32 width, u32 height)
(width & 0x01);
 }
 
-static int pxa_camera_set_crop(struct soc_camera_device *icd,
-  const struct v4l2_crop *a)
-{
-   const struct v4l2_rect *rect = >c;
-   struct device *dev = icd->parent;
-   struct soc_camera_host *ici = to_soc_camera_host(dev);
-   struct pxa_camera_dev *pcdev = ici->priv;
-   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct soc_camera_sense sense = {
-   .master_clock = pcdev->mclk,
-   .pixel_clock_max = pcdev->ciclk / 4,
-   };
-   struct v4l2_subdev_format fmt = {
-   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
-   };
-   struct v4l2_mbus_framefmt *mf = 
-   struct pxa_cam *cam = icd->host_priv;
-   u32 fourcc = icd->current_fmt->host_fmt->fourcc;
-   int ret;
-
-   /* If PCLK is used to latch data from the sensor, check sense */
-   if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
-   icd->sense = 
-
-   ret = sensor_call(pcdev, video, s_crop, a);
-
-   icd->sense = NULL;
-
-   if (ret < 0) {
-   dev_warn(pcdev_to_dev(pcdev), "Failed to crop to %ux%u@%u:%u\n",
-rect->width, rect->height, rect->left, rect->top);
-   return ret;
-   }
-
-   ret = sensor_call(pcdev, pad, get_fmt, NULL, );
-   if (ret < 0)
-   return ret;
-
-   if (pxa_camera_check_frame(mf->width, mf->height)) {
-   /*
-* Camera cropping produced a frame beyond our capabilities.
-* FIXME: just extract a subframe, that we can process.
-*/
-   v4l_bound_align_image(>width, 48, 2048, 1,
-   >height, 32, 2048, 0,
-   fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
-   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
-   if (ret < 0)
-   return ret;
-
-   if (pxa_camera_check_frame(mf->width, mf->height)) {
-   dev_warn(pcdev_to_dev(pcdev),
-"Inconsistent state. Use S_FMT to repair\n");
-   return -EINVAL;
-   }
-   }
-
-   if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
-   if (sense.pixel_clock > sense.pixel_clock_max) {
-   dev_err(pcdev_to_dev(pcdev),
-   "pixel clock %lu set by the camera too high!",
-   sense.pixel_clock);
-   return -EIO;
-   }
-   recalculate_fifo_timeout(pcdev, sense.pixel_clock);
-   }
-
-   icd->user_width = mf->width;
-   icd->user_height= mf->height;
-
-   pxa_camera_setup_cicr(icd, cam->flags, fourcc);
-
-   return ret;
-}
-
 static int pxa_camera_set_fmt(struct soc_camera_device *icd,
  struct v4l2_format *f)
 {
@@ -1581,7 +1506,6 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops 
= {
.remove = pxa_camera_remove_device,
.clock_start= pxa_camera_clock_start,
.clock_stop = pxa_camera_clock_stop,
-   .set_crop   = pxa_camera_set_crop,
.get_formats= pxa_camera_get_formats,
.put_formats= pxa_camera_put_formats,
.set_fmt= pxa_camera_set_fmt,
-- 
2.1.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


[PATCH v5 10/13] media: platform: pxa_camera: make a standalone v4l2 device

2016-08-29 Thread Robert Jarzmik
This patch removes the soc_camera API dependency from pxa_camera.
In the current status :
 - all previously captures are working the same on pxa270
 - the s_crop() call was removed, judged not working
   (see what happens soc_camera_s_crop() when get_crop() == NULL)
 - if the pixel clock is provided by then sensor, ie. not MCLK, the dual
   stage change is not handled yet.
   => there is no in-tree user of this, so I'll let it that way

 - the MCLK is not yet finished, it's as in the legacy way,
   ie. activated at video device opening and closed at video device
   closing.
   In a subsequence patch pxa_camera_mclk_ops should be used, and
   platform data MCLK ignored. It will be the sensor's duty to request
   the clock and enable it, which will end in pxa_camera_mclk_ops.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1:
  - function namings were cleaned into pxac_XXX_()
  - function were regrouped in the 3 big categories :
- device probing/removal : pxa_camera_*()
- videobuf2 : pxac_vb2_*()
- v42l file operations : pxac_vidioc_*()
- internal driver functions : pxa_camera_*() : to be found a cute
  pattern for RFC v3
Since v2:
  - split functions
  - start_streaming() implemented
Since v3:
  - conflict in void *alloc_ctxt by struct device *alloc_devs change
  - ctrl_handler for video device added
  - 2 ioctrl disables removed
  - disable sensor module removal, it will be loaded forever ...
Since v4:
 - videobuf2 device initialization moved
---
 drivers/media/platform/soc_camera/Kconfig  |   2 +-
 drivers/media/platform/soc_camera/pxa_camera.c | 753 +
 include/linux/platform_data/media/camera-pxa.h |   2 +
 3 files changed, 518 insertions(+), 239 deletions(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index 3f927f96763a..0bf33ccf9a1e 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -19,7 +19,7 @@ config SOC_CAMERA_PLATFORM
 
 config VIDEO_PXA27x
tristate "PXA27x Quick Capture Interface driver"
-   depends on VIDEO_DEV && PXA27x && SOC_CAMERA && HAS_DMA
+   depends on VIDEO_DEV && PXA27x && HAS_DMA
select VIDEOBUF2_DMA_SG
select SG_SPLIT
---help---
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 8f329d0b2cda..395cd398c32b 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2006, Sascha Hauer, Pengutronix
  * Copyright (C) 2008, Guennadi Liakhovetski <ker...@pengutronix.de>
+ * Copyright (C) 2016, Robert Jarzmik <robert.jarz...@free.fr>
  *
  * 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
@@ -14,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -32,13 +35,16 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include 
@@ -46,6 +52,9 @@
 #define PXA_CAM_VERSION "0.0.6"
 #define PXA_CAM_DRV_NAME "pxa27x-camera"
 
+#define DEFAULT_WIDTH  640
+#define DEFAULT_HEIGHT 480
+
 /* Camera Interface */
 #define CICR0  0x
 #define CICR1  0x0004
@@ -169,7 +178,25 @@
CICR0_EOFM | CICR0_FOM)
 
 #define sensor_call(cam, o, f, args...) \
-   v4l2_subdev_call(sd, o, f, ##args)
+   v4l2_subdev_call(cam->sensor, o, f, ##args)
+
+/*
+ * Format handling
+ */
+/**
+ * struct soc_camera_format_xlate - match between host and sensor formats
+ * @code: code of a sensor provided format
+ * @host_fmt: host format after host translation from code
+ *
+ * Host and sensor translation structure. Used in table of host and sensor
+ * formats matchings in soc_camera_device. A host can override the generic list
+ * generation by implementing get_formats(), and use it for format checks and
+ * format setup.
+ */
+struct soc_camera_format_xlate {
+   u32 code;
+   const struct soc_mbus_pixelfmt *host_fmt;
+};
 
 /*
  * Structures
@@ -198,7 +225,18 @@ struct pxa_buffer {
 };
 
 struct pxa_camera_dev {
-   struct soc_camera_host  soc_host;
+   struct v4l2_device  v4l2_dev;
+   struct video_device vdev;
+   struct v4l2_async_notifier notifier;
+   struct vb2_queuevb2_vq;
+   struct v4l2_subdev  *sensor;
+   struct soc_camera_format_xlate *user_formats;
+   const struct soc_camera_format_xlate *current_fmt;
+   struct v4l2_pix_format  current_pix;
+
+   struct v4l2_async_subdev asd;
+   struct v4

[PATCH v5 08/13] media: platform: pxa_camera: add buffer sequencing

2016-08-29 Thread Robert Jarzmik
Add sequence numbers to completed buffers.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v3: reset buffer sequence number in start_streaming()
---
 drivers/media/platform/soc_camera/pxa_camera.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 45583a40a4bd..9b294a14fa2e 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -223,6 +223,7 @@ struct pxa_camera_dev {
struct list_headcapture;
 
spinlock_t  lock;
+   unsigned intbuf_sequence;
 
struct pxa_buffer   *active;
struct tasklet_struct   task_eof;
@@ -423,10 +424,13 @@ static void pxa_camera_wakeup(struct pxa_camera_dev 
*pcdev,
  struct pxa_buffer *buf)
 {
struct vb2_buffer *vb = >vbuf.vb2_buf;
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 
/* _init is used to debug races, see comment in pxa_camera_reqbufs() */
list_del_init(>queue);
vb->timestamp = ktime_get_ns();
+   vbuf->sequence = pcdev->buf_sequence++;
+   vbuf->field = V4L2_FIELD_NONE;
vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
dev_dbg(pcdev_to_dev(pcdev), "%s dequeud buffer (buf=0x%p)\n",
__func__, buf);
@@ -1022,6 +1026,7 @@ static int pxac_vb2_start_streaming(struct vb2_queue *vq, 
unsigned int count)
dev_dbg(pcdev_to_dev(pcdev), "%s(count=%d) active=%p\n",
__func__, count, pcdev->active);
 
+   pcdev->buf_sequence = 0;
if (!pcdev->active)
pxa_camera_start_capture(pcdev);
 
-- 
2.1.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


[PATCH v5 12/13] media: platform: pxa_camera: change stop_streaming semantics

2016-08-29 Thread Robert Jarzmik
Instead of the legacy behavior where it was required to wait for all
video buffers to be finished by the hardware, use a cancel like strategy
: as soon as the stop_streaming() call is done, abort all DMA transfers,
report the already buffers as failed and return.

This makes stop_streaming() more a "cancel capture" than a "wait for end
of capture" semantic.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index fb89b85f59ab..868c6ad4784c 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -523,7 +523,8 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev 
*pcdev)
 }
 
 static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
- struct pxa_buffer *buf)
+ struct pxa_buffer *buf,
+ enum vb2_buffer_state state)
 {
struct vb2_buffer *vb = >vbuf.vb2_buf;
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -645,7 +646,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
}
buf->active_dma &= ~act_dma;
if (!buf->active_dma) {
-   pxa_camera_wakeup(pcdev, buf);
+   pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_DONE);
pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan],
   last_issued);
}
@@ -1087,7 +1088,15 @@ static int pxac_vb2_start_streaming(struct vb2_queue 
*vq, unsigned int count)
 
 static void pxac_vb2_stop_streaming(struct vb2_queue *vq)
 {
-   vb2_wait_for_all_buffers(vq);
+   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
+   struct pxa_buffer *buf, *tmp;
+
+   dev_dbg(pcdev_to_dev(pcdev), "%s active=%p\n",
+   __func__, pcdev->active);
+   pxa_camera_stop_capture(pcdev);
+
+   list_for_each_entry_safe(buf, tmp, >capture, queue)
+   pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR);
 }
 
 static struct vb2_ops pxac_vb2_ops = {
-- 
2.1.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


[PATCH v5 05/13] media: platform: pxa_camera: trivial move of functions

2016-08-29 Thread Robert Jarzmik
Move the functions in the file to be regrouped into meaningful blocks :
 1. pxa camera core handling functions, manipulating the herdware
 2. videobuf2 functions, dealing with video buffers
 3. video ioctl (vidioc) related functions
 4. driver probing, removal, suspend and resume

This patch doesn't modify a single line of code.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v3: replace void *alloc_ctxt by struct device *alloc_devs impact
Since v4: videobuf2 device init change impact
---
 drivers/media/platform/soc_camera/pxa_camera.c | 473 +
 1 file changed, 241 insertions(+), 232 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index d1881d35d81d..9d7c30cb1463 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -538,238 +538,6 @@ out:
spin_unlock_irqrestore(>lock, flags);
 }
 
-static void pxa_buffer_cleanup(struct pxa_buffer *buf)
-{
-   int i;
-
-   for (i = 0; i < 3 && buf->descs[i]; i++) {
-   dmaengine_desc_free(buf->descs[i]);
-   kfree(buf->sg[i]);
-   buf->descs[i] = NULL;
-   buf->sg[i] = NULL;
-   buf->sg_len[i] = 0;
-   buf->plane_sizes[i] = 0;
-   }
-   buf->nb_planes = 0;
-}
-
-static int pxa_buffer_init(struct pxa_camera_dev *pcdev,
-  struct pxa_buffer *buf)
-{
-   struct vb2_buffer *vb = >vbuf.vb2_buf;
-   struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
-   int nb_channels = pcdev->channels;
-   int i, ret = 0;
-   unsigned long size = vb2_plane_size(vb, 0);
-
-   switch (nb_channels) {
-   case 1:
-   buf->plane_sizes[0] = size;
-   break;
-   case 3:
-   buf->plane_sizes[0] = size / 2;
-   buf->plane_sizes[1] = size / 4;
-   buf->plane_sizes[2] = size / 4;
-   break;
-   default:
-   return -EINVAL;
-   };
-   buf->nb_planes = nb_channels;
-
-   ret = sg_split(sgt->sgl, sgt->nents, 0, nb_channels,
-  buf->plane_sizes, buf->sg, buf->sg_len, GFP_KERNEL);
-   if (ret < 0) {
-   dev_err(pcdev_to_dev(pcdev),
-   "sg_split failed: %d\n", ret);
-   return ret;
-   }
-   for (i = 0; i < nb_channels; i++) {
-   ret = pxa_init_dma_channel(pcdev, buf, i,
-  buf->sg[i], buf->sg_len[i]);
-   if (ret) {
-   pxa_buffer_cleanup(buf);
-   return ret;
-   }
-   }
-   INIT_LIST_HEAD(>queue);
-
-   return ret;
-}
-
-static void pxac_vb2_cleanup(struct vb2_buffer *vb)
-{
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s(vb=%p)\n", __func__, vb);
-   pxa_buffer_cleanup(buf);
-}
-
-static void pxac_vb2_queue(struct vb2_buffer *vb)
-{
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s(vb=%p) nb_channels=%d size=%lu active=%p\n",
-   __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0),
-   pcdev->active);
-
-   list_add_tail(>queue, >capture);
-
-   pxa_dma_add_tail_buf(pcdev, buf);
-}
-
-/*
- * Please check the DMA prepared buffer structure in :
- *   Documentation/video4linux/pxa_camera.txt
- * Please check also in pxa_camera_check_link_miss() to understand why DMA 
chain
- * modification while DMA chain is running will work anyway.
- */
-static int pxac_vb2_prepare(struct vb2_buffer *vb)
-{
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
-   int ret = 0;
-
-   switch (pcdev->channels) {
-   case 1:
-   case 3:
-   vb2_set_plane_payload(vb, 0, icd->sizeimage);
-   break;
-   default:
-   return -EINVAL;
-   }
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s (vb=%p) nb_channels=%d size=%lu\n",
-   __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0));
-
-   WARN_ON(!icd->current_fmt);
-
-#ifdef DEBUG
-   /*
-* This can be useful if you want to see if we actually fill
-* the buffer with something
-*/
-   for (i = 0; i < vb->num_planes; i++)
-   memset((void *)vb2_plane_vaddr(vb, i),
- 

[PATCH v5 03/13] media: mt9m111: move mt9m111 out of soc_camera

2016-08-29 Thread Robert Jarzmik
As the mt9m111 is now working as a standalone v4l2 subdevice sensor,
move it out of soc_camera directory and severe its dependency on
soc_camera.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/Kconfig  |7 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/mt9m111.c| 1033 
 drivers/media/i2c/soc_camera/Kconfig   |7 +-
 drivers/media/i2c/soc_camera/Makefile  |1 -
 drivers/media/i2c/soc_camera/mt9m111.c | 1033 
 6 files changed, 1046 insertions(+), 1036 deletions(-)
 create mode 100644 drivers/media/i2c/mt9m111.c
 delete mode 100644 drivers/media/i2c/soc_camera/mt9m111.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index ce9006e10a30..7f8790507660 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -571,6 +571,13 @@ config VIDEO_MT9M032
  This driver supports MT9M032 camera sensors from Aptina, monochrome
  models only.
 
+config VIDEO_MT9M111
+   tristate "mt9m111, mt9m112 and mt9m131 support"
+   depends on I2C && VIDEO_V4L2
+   help
+ This driver supports MT9M111, MT9M112 and MT9M131 cameras from
+ Micron/Aptina
+
 config VIDEO_MT9P031
tristate "Aptina MT9P031 support"
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 94f2c99e890d..a1a82331bebc 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
 obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
+obj-$(CONFIG_VIDEO_MT9M111) += mt9m111.o
 obj-$(CONFIG_VIDEO_MT9P031) += mt9p031.o
 obj-$(CONFIG_VIDEO_MT9T001) += mt9t001.o
 obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
new file mode 100644
index ..b7c4f371bae1
--- /dev/null
+++ b/drivers/media/i2c/mt9m111.c
@@ -0,0 +1,1033 @@
+/*
+ * Driver for MT9M111/MT9M112/MT9M131 CMOS Image Sensor from Micron/Aptina
+ *
+ * Copyright (C) 2008, Robert Jarzmik <robert.jarz...@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * MT9M111, MT9M112 and MT9M131:
+ * i2c address is 0x48 or 0x5d (depending on SADDR pin)
+ * The platform has to define struct i2c_board_info objects and link to them
+ * from struct soc_camera_host_desc
+ */
+
+/*
+ * Sensor core register addresses (0x000..0x0ff)
+ */
+#define MT9M111_CHIP_VERSION   0x000
+#define MT9M111_ROW_START  0x001
+#define MT9M111_COLUMN_START   0x002
+#define MT9M111_WINDOW_HEIGHT  0x003
+#define MT9M111_WINDOW_WIDTH   0x004
+#define MT9M111_HORIZONTAL_BLANKING_B  0x005
+#define MT9M111_VERTICAL_BLANKING_B0x006
+#define MT9M111_HORIZONTAL_BLANKING_A  0x007
+#define MT9M111_VERTICAL_BLANKING_A0x008
+#define MT9M111_SHUTTER_WIDTH  0x009
+#define MT9M111_ROW_SPEED  0x00a
+#define MT9M111_EXTRA_DELAY0x00b
+#define MT9M111_SHUTTER_DELAY  0x00c
+#define MT9M111_RESET  0x00d
+#define MT9M111_READ_MODE_B0x020
+#define MT9M111_READ_MODE_A0x021
+#define MT9M111_FLASH_CONTROL  0x023
+#define MT9M111_GREEN1_GAIN0x02b
+#define MT9M111_BLUE_GAIN  0x02c
+#define MT9M111_RED_GAIN   0x02d
+#define MT9M111_GREEN2_GAIN0x02e
+#define MT9M111_GLOBAL_GAIN0x02f
+#define MT9M111_CONTEXT_CONTROL0x0c8
+#define MT9M111_PAGE_MAP   0x0f0
+#define MT9M111_BYTE_WISE_ADDR 0x0f1
+
+#define MT9M111_RESET_SYNC_CHANGES (1 << 15)
+#define MT9M111_RESET_RESTART_BAD_FRAME(1 << 9)
+#define MT9M111_RESET_SHOW_BAD_FRAMES  (1 << 8)
+#define MT9M111_RESET_RESET_SOC(1 << 5)
+#define MT9M111_RESET_OUTPUT_DISABLE   (1 << 4)
+#define MT9M111_RESET_CHIP_ENABLE  (1 << 3)
+#define MT9M111_RESET_ANALOG_STANDBY   (1 << 2)
+#define MT9M111_RESET_RESTART_FRAME(1 << 1)
+#define MT9M111_RESET_RESET_MODE   (1 << 0)
+
+#define MT9M111_RM_FULL_POWER_RD   (0 << 10)
+#define MT9M111_RM_LOW_POWER_RD(1 << 10)
+#define MT9M111_RM_COL_SKIP_4X (1 << 5)
+#define MT9M111_RM_ROW_SKIP_4X (1 << 4)
+#define MT9M111_RM_COL_SKIP_2X (1 << 3)
+#define MT9M111_RM_ROW_SKIP_2X (1 << 2)
+#define MT9M111_RMB_MIRRO

[PATCH v5 02/13] media: mt9m111: use only the SRGB colorspace

2016-08-29 Thread Robert Jarzmik
mt9m111 being a camera sensor, its colorspace should always be SRGB, for
both RGB based formats or YCbCr based ones.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/soc_camera/mt9m111.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index a7efaa5964d1..b7c4f371bae1 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -188,10 +188,10 @@ struct mt9m111_datafmt {
 };
 
 static const struct mt9m111_datafmt mt9m111_colour_fmts[] = {
-   {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG},
+   {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
-- 
2.1.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


[PATCH v5 13/13] media: platform: pxa_camera: move pxa_camera out of soc_camera

2016-08-29 Thread Robert Jarzmik
As the conversion to a v4l2 standalone device is finished, move
pxa_camera one directory up and finish severing any dependency to
soc_camera.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/pxa_camera.c| 2096 
 drivers/media/platform/soc_camera/Kconfig  |8 -
 drivers/media/platform/soc_camera/Makefile |1 -
 drivers/media/platform/soc_camera/pxa_camera.c | 2096 
 6 files changed, 2105 insertions(+), 2105 deletions(-)
 create mode 100644 drivers/media/platform/pxa_camera.c
 delete mode 100644 drivers/media/platform/soc_camera/pxa_camera.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344bc7912..299af1977d61 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -91,6 +91,14 @@ config VIDEO_OMAP3_DEBUG
---help---
  Enable debug messages on OMAP 3 camera controller driver.
 
+config VIDEO_PXA27x
+   tristate "PXA27x Quick Capture Interface driver"
+   depends on VIDEO_DEV && PXA27x && HAS_DMA
+   select VIDEOBUF2_DMA_SG
+   select SG_SPLIT
+   ---help---
+ This is a v4l2 driver for the PXA27x Quick Capture Interface
+
 config VIDEO_S3C_CAMIF
tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1a13fb..e38918bbe0d0 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_VIDEO_CAFE_CCIC) += marvell-ccic/
 obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/
 
 obj-$(CONFIG_VIDEO_OMAP3)  += omap3isp/
+obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o soc_camera/soc_mediabus.o
 
 obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o
 
diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
new file mode 100644
index ..868c6ad4784c
--- /dev/null
+++ b/drivers/media/platform/pxa_camera.c
@@ -0,0 +1,2096 @@
+/*
+ * V4L2 Driver for PXA camera host
+ *
+ * Copyright (C) 2006, Sascha Hauer, Pengutronix
+ * Copyright (C) 2008, Guennadi Liakhovetski <ker...@pengutronix.de>
+ * Copyright (C) 2016, Robert Jarzmik <robert.jarz...@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define PXA_CAM_VERSION "0.0.6"
+#define PXA_CAM_DRV_NAME "pxa27x-camera"
+
+#define DEFAULT_WIDTH  640
+#define DEFAULT_HEIGHT 480
+
+/* Camera Interface */
+#define CICR0  0x
+#define CICR1  0x0004
+#define CICR2  0x0008
+#define CICR3  0x000C
+#define CICR4  0x0010
+#define CISR   0x0014
+#define CIFR   0x0018
+#define CITOR  0x001C
+#define CIBR0  0x0028
+#define CIBR1  0x0030
+#define CIBR2  0x0038
+
+#define CICR0_DMAEN(1 << 31)   /* DMA request enable */
+#define CICR0_PAR_EN   (1 << 30)   /* Parity enable */
+#define CICR0_SL_CAP_EN(1 << 29)   /* Capture enable for slave 
mode */
+#define CICR0_ENB  (1 << 28)   /* Camera interface enable */
+#define CICR0_DIS  (1 << 27)   /* Camera interface disable */
+#define CICR0_SIM  (0x7 << 24) /* Sensor interface mode mask */
+#define CICR0_TOM  (1 << 9)/* Time-out mask */
+#define CICR0_RDAVM(1 << 8)/* Receive-data-available mask */
+#define CICR0_FEM  (1 << 7)/* FIFO-empty mask */
+#define CICR0_EOLM (1 << 6)/* End-of-line mask */
+#define CICR0_PERRM(1 << 5)/* Parity-error mask */
+#define CICR0_QDM  (1 << 4)/* Quick-disable mask */
+#define CICR0_CDM  (1 << 3)/* Disable-done mask */
+#define CICR0_SOFM (1 << 2)/* Start-of-frame mask */
+#define CICR0_EOFM (1 << 1)/* End-of-frame mask */
+#define CICR0_FOM  (1 << 0)/* FIFO-overrun mask */
+
+#define CICR1_TBIT (1 << 31)   /* Transparency bit */
+#define CICR1_RGBT_CONV(0x3 << 29) /* RGBT conversion mask */

[PATCH v5 06/13] media: platform: pxa_camera: introduce sensor_call

2016-08-29 Thread Robert Jarzmik
Introduce sensor_call(), which will be used for all sensor invocations.
This is a preparation move to v4l2 device conversion, ie. soc_camera
adherence removal.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 27 ++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 9d7c30cb1463..9870c53e0ec2 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -168,6 +168,9 @@
CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
CICR0_EOFM | CICR0_FOM)
 
+#define sensor_call(cam, o, f, args...) \
+   v4l2_subdev_call(sd, o, f, ##args)
+
 /*
  * Structures
  */
@@ -731,7 +734,7 @@ static void pxa_camera_setup_cicr(struct soc_camera_device 
*icd,
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
unsigned long dw, bpp;
u32 cicr0, cicr1, cicr2, cicr3, cicr4 = 0, y_skip_top;
-   int ret = v4l2_subdev_call(sd, sensor, g_skip_top_lines, _skip_top);
+   int ret = sensor_call(pcdev, sensor, g_skip_top_lines, _skip_top);
 
if (ret < 0)
y_skip_top = 0;
@@ -1073,7 +1076,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
if (ret < 0)
return ret;
 
-   ret = v4l2_subdev_call(sd, video, g_mbus_config, );
+   ret = sensor_call(pcdev, video, g_mbus_config, );
if (!ret) {
common_flags = soc_mbus_config_compatible(,
  bus_flags);
@@ -1117,7 +1120,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
}
 
cfg.flags = common_flags;
-   ret = v4l2_subdev_call(sd, video, s_mbus_config, );
+   ret = sensor_call(pcdev, video, s_mbus_config, );
if (ret < 0 && ret != -ENOIOCTLCMD) {
dev_dbg(icd->parent, "camera s_mbus_config(0x%lx) returned 
%d\n",
common_flags, ret);
@@ -1144,7 +1147,7 @@ static int pxa_camera_try_bus_param(struct 
soc_camera_device *icd,
if (ret < 0)
return ret;
 
-   ret = v4l2_subdev_call(sd, video, g_mbus_config, );
+   ret = sensor_call(pcdev, video, g_mbus_config, );
if (!ret) {
common_flags = soc_mbus_config_compatible(,
  bus_flags);
@@ -1195,7 +1198,7 @@ static int pxa_camera_get_formats(struct 
soc_camera_device *icd, unsigned int id
};
const struct soc_mbus_pixelfmt *fmt;
 
-   ret = v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, );
+   ret = sensor_call(pcdev, pad, enum_mbus_code, NULL, );
if (ret < 0)
/* No more formats */
return 0;
@@ -1297,7 +1300,7 @@ static int pxa_camera_set_crop(struct soc_camera_device 
*icd,
if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
icd->sense = 
 
-   ret = v4l2_subdev_call(sd, video, s_crop, a);
+   ret = sensor_call(pcdev, video, s_crop, a);
 
icd->sense = NULL;
 
@@ -1307,7 +1310,7 @@ static int pxa_camera_set_crop(struct soc_camera_device 
*icd,
return ret;
}
 
-   ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, get_fmt, NULL, );
if (ret < 0)
return ret;
 
@@ -1319,7 +1322,7 @@ static int pxa_camera_set_crop(struct soc_camera_device 
*icd,
v4l_bound_align_image(>width, 48, 2048, 1,
>height, 32, 2048, 0,
fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
-   ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
if (ret < 0)
return ret;
 
@@ -1384,7 +1387,7 @@ static int pxa_camera_set_fmt(struct soc_camera_device 
*icd,
mf->colorspace  = pix->colorspace;
mf->code= xlate->code;
 
-   ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
 
if (mf->code != xlate->code)
return -EINVAL;
@@ -1459,7 +1462,7 @@ static int pxa_camera_try_fmt(struct soc_camera_device 
*icd,
mf->colorspace  = pix->colorspace;
mf->code= xlate->code;
 
-   ret = v4l2_subdev_call(sd, pad, set_fmt, _cfg, );
+   ret = sensor_call(pcdev, pad, set_fmt, _cfg, );
if (ret < 0)
return ret;
 
@@ -1517,7 +1520,7 @@ static int pxa_camera_suspend(struct device *dev)
 
if (pcdev->soc_host.icd) {
struct v4l2_subdev *sd = 
soc_camera_to_subdev(pcdev->soc_host.icd);
-

[PATCH v5 04/13] media: platform: pxa_camera: convert to vb2

2016-08-29 Thread Robert Jarzmik
Convert pxa_camera from videobuf to videobuf2.

As the soc_camera was already compatible with videobuf2, the port is
quite straightforward.

The special case of this code in which the vb2 to prepare is "too
big" in terms of size for the new capture format, the pxa_camera will
fail.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: took into account Hans's comments
  renamed all vb2 functions to pxac_vb2_*()
Since v2: spit queue_buffer() and start_streaming()
Since v3: replace void *alloc_ctxs by struct device *alloc_devs
Since v4: move the queue device initialization to v4l2 standalone patch
---
 drivers/media/platform/soc_camera/Kconfig  |   4 +-
 drivers/media/platform/soc_camera/pxa_camera.c | 579 -
 2 files changed, 269 insertions(+), 314 deletions(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index 39f66414f621..3f927f96763a 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -19,8 +19,8 @@ config SOC_CAMERA_PLATFORM
 
 config VIDEO_PXA27x
tristate "PXA27x Quick Capture Interface driver"
-   depends on VIDEO_DEV && PXA27x && SOC_CAMERA
-   select VIDEOBUF_DMA_SG
+   depends on VIDEO_DEV && PXA27x && SOC_CAMERA && HAS_DMA
+   select VIDEOBUF2_DMA_SG
select SG_SPLIT
---help---
  This is a v4l2 driver for the PXA27x Quick Capture Interface
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 2aaf4a8f71a0..d1881d35d81d 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -34,7 +34,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -180,13 +180,16 @@ enum pxa_camera_active_dma {
 /* buffer for one video frame */
 struct pxa_buffer {
/* common v4l buffer stuff -- must be first */
-   struct videobuf_buffer  vb;
+   struct vb2_v4l2_buffer  vbuf;
+   struct list_headqueue;
u32 code;
+   int nb_planes;
/* our descriptor lists for Y, U and V channels */
struct dma_async_tx_descriptor  *descs[3];
dma_cookie_tcookie[3];
struct scatterlist  *sg[3];
int sg_len[3];
+   size_t  plane_sizes[3];
int inwork;
enum pxa_camera_active_dma  active_dma;
 };
@@ -230,59 +233,19 @@ struct pxa_cam {
 
 static const char *pxa_cam_driver_description = "PXA_Camera";
 
-static unsigned int vid_limit = 16;/* Video memory limit, in Mb */
-
 /*
  *  Videobuf operations
  */
-static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
- unsigned int *size)
+static struct pxa_buffer *vb2_to_pxa_buffer(struct vb2_buffer *vb)
 {
-   struct soc_camera_device *icd = vq->priv_data;
-
-   dev_dbg(icd->parent, "count=%d, size=%d\n", *count, *size);
-
-   *size = icd->sizeimage;
-
-   if (0 == *count)
-   *count = 32;
-   if (*size * *count > vid_limit * 1024 * 1024)
-   *count = (vid_limit * 1024 * 1024) / *size;
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 
-   return 0;
+   return container_of(vbuf, struct pxa_buffer, vbuf);
 }
 
-static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
+static struct device *pcdev_to_dev(struct pxa_camera_dev *pcdev)
 {
-   struct soc_camera_device *icd = vq->priv_data;
-   struct videobuf_dmabuf *dma = videobuf_to_dma(>vb);
-   int i;
-
-   BUG_ON(in_interrupt());
-
-   dev_dbg(icd->parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
-   >vb, buf->vb.baddr, buf->vb.bsize);
-
-   /*
-* This waits until this buffer is out of danger, i.e., until it is no
-* longer in STATE_QUEUED or STATE_ACTIVE
-*/
-   videobuf_waiton(vq, >vb, 0, 0);
-
-   for (i = 0; i < 3 && buf->descs[i]; i++) {
-   dmaengine_desc_free(buf->descs[i]);
-   kfree(buf->sg[i]);
-   buf->descs[i] = NULL;
-   buf->sg[i] = NULL;
-   buf->sg_len[i] = 0;
-   }
-   videobuf_dma_unmap(vq->dev, dma);
-   videobuf_dma_free(dma);
-
-   buf->vb.state = VIDEOBUF_NEEDS_INIT;
-
-   dev_dbg(icd->parent, "%s end (vb=0x%p) 0x%08lx %d\n", __func__,
-   >vb, buf->vb.baddr, buf->vb.bsize);
+   return pcdev->soc_host.v4l2_dev.dev;
 }
 
 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
@@ -312,31 +275,26 @@ static void pxa_camera_dma

[PATCH v5 07/13] media: platform: pxa_camera: make printk consistent

2016-08-29 Thread Robert Jarzmik
Make all print consistent by always using :
 - dev_xxx(pcdev_to_dev(pcdev), )

This prepares the soc_camera adherence removal by making these call rely
on only pcdev, and not the soc_camera icd structure.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 70 --
 1 file changed, 43 insertions(+), 27 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 9870c53e0ec2..45583a40a4bd 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -236,6 +236,14 @@ struct pxa_cam {
 
 static const char *pxa_cam_driver_description = "PXA_Camera";
 
+static struct pxa_camera_dev *icd_to_pcdev(struct soc_camera_device *icd)
+{
+   struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+   struct pxa_camera_dev *pcdev = ici->priv;
+
+   return pcdev;
+}
+
 /*
  *  Videobuf operations
  */
@@ -465,7 +473,6 @@ static void pxa_camera_check_link_miss(struct 
pxa_camera_dev *pcdev,
 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
   enum pxa_camera_active_dma act_dma)
 {
-   struct device *dev = pcdev_to_dev(pcdev);
struct pxa_buffer *buf, *last_buf;
unsigned long flags;
u32 camera_status, overrun;
@@ -476,7 +483,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
spin_lock_irqsave(>lock, flags);
 
camera_status = __raw_readl(pcdev->base + CISR);
-   dev_dbg(dev, "camera dma irq, cisr=0x%x dma=%d\n",
+   dev_dbg(pcdev_to_dev(pcdev), "camera dma irq, cisr=0x%x dma=%d\n",
camera_status, act_dma);
overrun = CISR_IFO_0;
if (pcdev->channels == 3)
@@ -522,7 +529,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
   NULL, _issued);
if (camera_status & overrun &&
last_status != DMA_COMPLETE) {
-   dev_dbg(dev, "FIFO overrun! CISR: %x\n",
+   dev_dbg(pcdev_to_dev(pcdev), "FIFO overrun! CISR: %x\n",
camera_status);
pxa_camera_stop_capture(pcdev);
list_for_each_entry(buf, >capture, queue)
@@ -545,7 +552,6 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
struct pxa_camera_dev *pcdev)
 {
unsigned long mclk = pcdev->mclk;
-   struct device *dev = >dev;
u32 div;
unsigned long lcdclk;
 
@@ -555,7 +561,8 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
/* mclk <= ciclk / 4 (27.4.2) */
if (mclk > lcdclk / 4) {
mclk = lcdclk / 4;
-   dev_warn(dev, "Limiting master clock to %lu\n", mclk);
+   dev_warn(pcdev_to_dev(pcdev),
+"Limiting master clock to %lu\n", mclk);
}
 
/* We verify mclk != 0, so if anyone breaks it, here comes their Oops */
@@ -565,7 +572,7 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
pcdev->mclk = lcdclk / (2 * (div + 1));
 
-   dev_dbg(dev, "LCD clock %luHz, target freq %luHz, divisor %u\n",
+   dev_dbg(pcdev_to_dev(pcdev), "LCD clock %luHz, target freq %luHz, 
divisor %u\n",
lcdclk, mclk, div);
 
return div;
@@ -662,7 +669,9 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
 
 static int pxa_camera_add_device(struct soc_camera_device *icd)
 {
-   dev_info(icd->parent, "PXA Camera driver attached to camera %d\n",
+   struct pxa_camera_dev *pcdev = icd_to_pcdev(icd);
+
+   dev_info(pcdev_to_dev(pcdev), "PXA Camera driver attached to camera 
%d\n",
 icd->devnum);
 
return 0;
@@ -670,7 +679,9 @@ static int pxa_camera_add_device(struct soc_camera_device 
*icd)
 
 static void pxa_camera_remove_device(struct soc_camera_device *icd)
 {
-   dev_info(icd->parent, "PXA Camera driver detached from camera %d\n",
+   struct pxa_camera_dev *pcdev = icd_to_pcdev(icd);
+
+   dev_info(pcdev_to_dev(pcdev), "PXA Camera driver detached from camera 
%d\n",
 icd->devnum);
 }
 
@@ -1081,7 +1092,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
common_flags = soc_mbus_config_compatible(,
  bus_flags);
if (!common_flags) {
-   dev_warn(icd->parent,
+   dev_warn(pcdev_to_dev(pcdev),
 "Flags incompatible: camera 0x%x, host 
0x%lx\n",
 cfg.flags, b

[PATCH v5 11/13] media: platform: pxa_camera: add debug register access

2016-08-29 Thread Robert Jarzmik
Add pxa_camera registers access through advanced video debugging.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 32 ++
 1 file changed, 32 insertions(+)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 395cd398c32b..fb89b85f59ab 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1342,6 +1342,34 @@ static int pxa_camera_check_frame(u32 width, u32 height)
(width & 0x01);
 }
 
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int pxac_vidioc_g_register(struct file *file, void *priv,
+ struct v4l2_dbg_register *reg)
+{
+   struct pxa_camera_dev *pcdev = video_drvdata(file);
+
+   if (reg->reg > CIBR2)
+   return -ERANGE;
+
+   reg->val = __raw_readl(pcdev->base + reg->reg);
+   reg->size = sizeof(__u32);
+   return 0;
+}
+
+static int pxac_vidioc_s_register(struct file *file, void *priv,
+ const struct v4l2_dbg_register *reg)
+{
+   struct pxa_camera_dev *pcdev = video_drvdata(file);
+
+   if (reg->reg > CIBR2)
+   return -ERANGE;
+   if (reg->size != sizeof(__u32))
+   return -EINVAL;
+   __raw_writel(reg->val, pcdev->base + reg->reg);
+   return 0;
+}
+#endif
+
 static int pxac_vidioc_enum_fmt_vid_cap(struct file *filp, void  *priv,
struct v4l2_fmtdesc *f)
 {
@@ -1592,6 +1620,10 @@ static const struct v4l2_ioctl_ops pxa_camera_ioctl_ops 
= {
.vidioc_expbuf  = vb2_ioctl_expbuf,
.vidioc_streamon= vb2_ioctl_streamon,
.vidioc_streamoff   = vb2_ioctl_streamoff,
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+   .vidioc_g_register  = pxac_vidioc_g_register,
+   .vidioc_s_register  = pxac_vidioc_s_register,
+#endif
 };
 
 static struct v4l2_clk_ops pxa_camera_mclk_ops = {
-- 
2.1.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


[PATCH v5 00/13] pxa_camera transition to v4l2 standalone device

2016-08-29 Thread Robert Jarzmik
There is no change between v4 and v5, ie. the global diff is empty, only one
line was shifted to prevent breaking bisectablility.

All the text in https://lkml.org/lkml/2016/8/15/609 is still applicable.

Cheers.

--
Robert

Robert Jarzmik (13):
  media: mt9m111: make a standalone v4l2 subdevice
  media: mt9m111: use only the SRGB colorspace
  media: mt9m111: move mt9m111 out of soc_camera
  media: platform: pxa_camera: convert to vb2
  media: platform: pxa_camera: trivial move of functions
  media: platform: pxa_camera: introduce sensor_call
  media: platform: pxa_camera: make printk consistent
  media: platform: pxa_camera: add buffer sequencing
  media: platform: pxa_camera: remove set_crop
  media: platform: pxa_camera: make a standalone v4l2 device
  media: platform: pxa_camera: add debug register access
  media: platform: pxa_camera: change stop_streaming semantics
  media: platform: pxa_camera: move pxa_camera out of soc_camera

 drivers/media/i2c/Kconfig  |7 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/mt9m111.c| 1033 
 drivers/media/i2c/soc_camera/Kconfig   |7 +-
 drivers/media/i2c/soc_camera/Makefile  |1 -
 drivers/media/i2c/soc_camera/mt9m111.c | 1054 
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/pxa_camera.c| 2096 
 drivers/media/platform/soc_camera/Kconfig  |8 -
 drivers/media/platform/soc_camera/Makefile |1 -
 drivers/media/platform/soc_camera/pxa_camera.c | 1866 -
 include/linux/platform_data/media/camera-pxa.h |2 +
 13 files changed, 3153 insertions(+), 2932 deletions(-)
 create mode 100644 drivers/media/i2c/mt9m111.c
 delete mode 100644 drivers/media/i2c/soc_camera/mt9m111.c
 create mode 100644 drivers/media/platform/pxa_camera.c
 delete mode 100644 drivers/media/platform/soc_camera/pxa_camera.c

-- 
2.1.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


[PATCH v5 01/13] media: mt9m111: make a standalone v4l2 subdevice

2016-08-29 Thread Robert Jarzmik
Remove the soc_camera adherence. Mostly the change removes the power
manipulation provided by soc_camera, and instead :
 - powers on the sensor when the s_power control is activated
 - powers on the sensor in initial probe
 - enables and disables the MCLK provided to it in power on/off

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/soc_camera/mt9m111.c | 51 ++
 1 file changed, 15 insertions(+), 36 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index 6dfaead6aaa8..a7efaa5964d1 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -16,10 +16,11 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 /*
  * MT9M111, MT9M112 and MT9M131:
@@ -388,7 +389,7 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, const 
struct v4l2_crop *a)
struct v4l2_rect rect = a->c;
struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
int width, height;
-   int ret;
+   int ret, align = 0;
 
if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -396,17 +397,19 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, const 
struct v4l2_crop *a)
if (mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 ||
mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) {
/* Bayer format - even size lengths */
-   rect.width  = ALIGN(rect.width, 2);
-   rect.height = ALIGN(rect.height, 2);
+   align = 1;
/* Let the user play with the starting pixel */
}
 
/* FIXME: the datasheet doesn't specify minimum sizes */
-   soc_camera_limit_side(, ,
-MT9M111_MIN_DARK_COLS, 2, MT9M111_MAX_WIDTH);
-
-   soc_camera_limit_side(, ,
-MT9M111_MIN_DARK_ROWS, 2, MT9M111_MAX_HEIGHT);
+   v4l_bound_align_image(, 2, MT9M111_MAX_WIDTH, align,
+ , 2, MT9M111_MAX_HEIGHT, align, 0);
+   rect.left = clamp(rect.left, MT9M111_MIN_DARK_COLS,
+ MT9M111_MIN_DARK_COLS + MT9M111_MAX_WIDTH -
+ (__s32)rect.width);
+   rect.top = clamp(rect.top, MT9M111_MIN_DARK_ROWS,
+MT9M111_MIN_DARK_ROWS + MT9M111_MAX_HEIGHT -
+(__s32)rect.height);
 
width = min(mt9m111->width, rect.width);
height = min(mt9m111->height, rect.height);
@@ -775,17 +778,16 @@ static int mt9m111_init(struct mt9m111 *mt9m111)
 static int mt9m111_power_on(struct mt9m111 *mt9m111)
 {
struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
 
-   ret = soc_camera_power_on(>dev, ssdd, mt9m111->clk);
+   ret = v4l2_clk_enable(mt9m111->clk);
if (ret < 0)
return ret;
 
ret = mt9m111_resume(mt9m111);
if (ret < 0) {
dev_err(>dev, "Failed to resume the sensor: %d\n", ret);
-   soc_camera_power_off(>dev, ssdd, mt9m111->clk);
+   v4l2_clk_disable(mt9m111->clk);
}
 
return ret;
@@ -793,11 +795,8 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 
 static void mt9m111_power_off(struct mt9m111 *mt9m111)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
-
mt9m111_suspend(mt9m111);
-   soc_camera_power_off(>dev, ssdd, mt9m111->clk);
+   v4l2_clk_disable(mt9m111->clk);
 }
 
 static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
@@ -854,14 +853,10 @@ static int mt9m111_enum_mbus_code(struct v4l2_subdev *sd,
 static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
struct v4l2_mbus_config *cfg)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
-
cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
V4L2_MBUS_DATA_ACTIVE_HIGH;
cfg->type = V4L2_MBUS_PARALLEL;
-   cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
 
return 0;
 }
@@ -933,20 +928,8 @@ static int mt9m111_probe(struct i2c_client *client,
 {
struct mt9m111 *mt9m111;
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
 
-   if (client->dev.of_node) {
-   ssdd = devm_kzalloc(>dev, sizeof(*ssdd), GFP_KERNEL);
-   if (!ssdd)
-   return -ENOMEM;
-   

Re: [PATCH v4 04/13] media: platform: pxa_camera: convert to vb2

2016-08-16 Thread Robert Jarzmik
Robert Jarzmik <robert.jarz...@free.fr> writes:

> Convert pxa_camera from videobuf to videobuf2.
>
> As the soc_camera was already compatible with videobuf2, the port is
> quite straightforward.
>
> The special case of this code in which the vb2 to prepare is "too
> big" in terms of size for the new capture format, the pxa_camera will
> fail.
>
> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
...zip...

> diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
> b/drivers/media/platform/soc_camera/pxa_camera.c
> index 2aaf4a8f71a0..5bf97c6b6810 100644
> --- a/drivers/media/platform/soc_camera/pxa_camera.c
> +++ b/drivers/media/platform/soc_camera/pxa_camera.c
> -static void pxa_camera_init_videobuf(struct videobuf_queue *q,
> -   struct soc_camera_device *icd)
> +static int pxa_camera_init_videobuf2(struct vb2_queue *vq,
> +  struct soc_camera_device *icd)
>  {
>   struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
>   struct pxa_camera_dev *pcdev = ici->priv;
> + int ret;
>  
> - /*
> -  * We must pass NULL as dev pointer, then all pci_* dma operations
> -  * transform to normal dma_* ones.
> -  */
> - videobuf_queue_sg_init(q, _videobuf_ops, NULL, >lock,
> - V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,
> - sizeof(struct pxa_buffer), icd, 
> >host_lock);
> + vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> + vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
> + vq->drv_priv = pcdev;
> + vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + vq->buf_struct_size = sizeof(struct pxa_buffer);
> + vq->dev = pcdev->v4l2_dev.dev;

This last line breaks bisectability as the v4l2_dev only appears in patch 10
... I'm afraid at least this will trigger a v5 respin of the patches.

Cheers.

--
Robert
--
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 v4 10/13] media: platform: pxa_camera: make a standalone v4l2 device

2016-08-15 Thread Robert Jarzmik
This patch removes the soc_camera API dependency from pxa_camera.
In the current status :
 - all previously captures are working the same on pxa270
 - the s_crop() call was removed, judged not working
   (see what happens soc_camera_s_crop() when get_crop() == NULL)
 - if the pixel clock is provided by then sensor, ie. not MCLK, the dual
   stage change is not handled yet.
   => there is no in-tree user of this, so I'll let it that way

 - the MCLK is not yet finished, it's as in the legacy way,
   ie. activated at video device opening and closed at video device
   closing.
   In a subsequence patch pxa_camera_mclk_ops should be used, and
   platform data MCLK ignored. It will be the sensor's duty to request
   the clock and enable it, which will end in pxa_camera_mclk_ops.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1:
  - function namings were cleaned into pxac_XXX_()
  - function were regrouped in the 3 big categories :
- device probing/removal : pxa_camera_*()
- videobuf2 : pxac_vb2_*()
- v42l file operations : pxac_vidioc_*()
- internal driver functions : pxa_camera_*() : to be found a cute
  pattern for RFC v3
Since v2:
  - split functions
  - start_streaming() implemented
Since v3:
  - conflict in void *alloc_ctxt by struct device *alloc_devs change
  - ctrl_handler for video device added
  - 2 ioctrl disables removed
  - disable sensor module removal, it will be loaded forever ...
---
 drivers/media/platform/soc_camera/Kconfig  |   2 +-
 drivers/media/platform/soc_camera/pxa_camera.c | 752 +
 include/linux/platform_data/media/camera-pxa.h |   2 +
 3 files changed, 517 insertions(+), 239 deletions(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index 3f927f96763a..0bf33ccf9a1e 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -19,7 +19,7 @@ config SOC_CAMERA_PLATFORM
 
 config VIDEO_PXA27x
tristate "PXA27x Quick Capture Interface driver"
-   depends on VIDEO_DEV && PXA27x && SOC_CAMERA && HAS_DMA
+   depends on VIDEO_DEV && PXA27x && HAS_DMA
select VIDEOBUF2_DMA_SG
select SG_SPLIT
---help---
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index a2fedc9bb71c..395cd398c32b 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2006, Sascha Hauer, Pengutronix
  * Copyright (C) 2008, Guennadi Liakhovetski <ker...@pengutronix.de>
+ * Copyright (C) 2016, Robert Jarzmik <robert.jarz...@free.fr>
  *
  * 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
@@ -14,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -32,13 +35,16 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include 
@@ -46,6 +52,9 @@
 #define PXA_CAM_VERSION "0.0.6"
 #define PXA_CAM_DRV_NAME "pxa27x-camera"
 
+#define DEFAULT_WIDTH  640
+#define DEFAULT_HEIGHT 480
+
 /* Camera Interface */
 #define CICR0  0x
 #define CICR1  0x0004
@@ -169,7 +178,25 @@
CICR0_EOFM | CICR0_FOM)
 
 #define sensor_call(cam, o, f, args...) \
-   v4l2_subdev_call(sd, o, f, ##args)
+   v4l2_subdev_call(cam->sensor, o, f, ##args)
+
+/*
+ * Format handling
+ */
+/**
+ * struct soc_camera_format_xlate - match between host and sensor formats
+ * @code: code of a sensor provided format
+ * @host_fmt: host format after host translation from code
+ *
+ * Host and sensor translation structure. Used in table of host and sensor
+ * formats matchings in soc_camera_device. A host can override the generic list
+ * generation by implementing get_formats(), and use it for format checks and
+ * format setup.
+ */
+struct soc_camera_format_xlate {
+   u32 code;
+   const struct soc_mbus_pixelfmt *host_fmt;
+};
 
 /*
  * Structures
@@ -198,7 +225,18 @@ struct pxa_buffer {
 };
 
 struct pxa_camera_dev {
-   struct soc_camera_host  soc_host;
+   struct v4l2_device  v4l2_dev;
+   struct video_device vdev;
+   struct v4l2_async_notifier notifier;
+   struct vb2_queuevb2_vq;
+   struct v4l2_subdev  *sensor;
+   struct soc_camera_format_xlate *user_formats;
+   const struct soc_camera_format_xlate *current_fmt;
+   struct v4l2_pix_format  current_pix;
+
+   struct v4l2_async_subdev asd;
+   struct v4l2_async_subdev *asds[1];
+
/*
   

[PATCH v4 08/13] media: platform: pxa_camera: add buffer sequencing

2016-08-15 Thread Robert Jarzmik
Add sequence numbers to completed buffers.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v3: reset buffer sequence number in start_streaming()
---
 drivers/media/platform/soc_camera/pxa_camera.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index f3922a99405b..2471d036a835 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -223,6 +223,7 @@ struct pxa_camera_dev {
struct list_headcapture;
 
spinlock_t  lock;
+   unsigned intbuf_sequence;
 
struct pxa_buffer   *active;
struct tasklet_struct   task_eof;
@@ -423,10 +424,13 @@ static void pxa_camera_wakeup(struct pxa_camera_dev 
*pcdev,
  struct pxa_buffer *buf)
 {
struct vb2_buffer *vb = >vbuf.vb2_buf;
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 
/* _init is used to debug races, see comment in pxa_camera_reqbufs() */
list_del_init(>queue);
vb->timestamp = ktime_get_ns();
+   vbuf->sequence = pcdev->buf_sequence++;
+   vbuf->field = V4L2_FIELD_NONE;
vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
dev_dbg(pcdev_to_dev(pcdev), "%s dequeud buffer (buf=0x%p)\n",
__func__, buf);
@@ -1022,6 +1026,7 @@ static int pxac_vb2_start_streaming(struct vb2_queue *vq, 
unsigned int count)
dev_dbg(pcdev_to_dev(pcdev), "%s(count=%d) active=%p\n",
__func__, count, pcdev->active);
 
+   pcdev->buf_sequence = 0;
if (!pcdev->active)
pxa_camera_start_capture(pcdev);
 
-- 
2.1.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


[PATCH v4 03/13] media: mt9m111: move mt9m111 out of soc_camera

2016-08-15 Thread Robert Jarzmik
As the mt9m111 is now working as a standalone v4l2 subdevice sensor,
move it out of soc_camera directory and severe its dependency on
soc_camera.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/Kconfig  |7 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/mt9m111.c| 1033 
 drivers/media/i2c/soc_camera/Kconfig   |7 +-
 drivers/media/i2c/soc_camera/Makefile  |1 -
 drivers/media/i2c/soc_camera/mt9m111.c | 1033 
 6 files changed, 1046 insertions(+), 1036 deletions(-)
 create mode 100644 drivers/media/i2c/mt9m111.c
 delete mode 100644 drivers/media/i2c/soc_camera/mt9m111.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index ce9006e10a30..7f8790507660 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -571,6 +571,13 @@ config VIDEO_MT9M032
  This driver supports MT9M032 camera sensors from Aptina, monochrome
  models only.
 
+config VIDEO_MT9M111
+   tristate "mt9m111, mt9m112 and mt9m131 support"
+   depends on I2C && VIDEO_V4L2
+   help
+ This driver supports MT9M111, MT9M112 and MT9M131 cameras from
+ Micron/Aptina
+
 config VIDEO_MT9P031
tristate "Aptina MT9P031 support"
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 94f2c99e890d..a1a82331bebc 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
 obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
+obj-$(CONFIG_VIDEO_MT9M111) += mt9m111.o
 obj-$(CONFIG_VIDEO_MT9P031) += mt9p031.o
 obj-$(CONFIG_VIDEO_MT9T001) += mt9t001.o
 obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
new file mode 100644
index ..b7c4f371bae1
--- /dev/null
+++ b/drivers/media/i2c/mt9m111.c
@@ -0,0 +1,1033 @@
+/*
+ * Driver for MT9M111/MT9M112/MT9M131 CMOS Image Sensor from Micron/Aptina
+ *
+ * Copyright (C) 2008, Robert Jarzmik <robert.jarz...@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * MT9M111, MT9M112 and MT9M131:
+ * i2c address is 0x48 or 0x5d (depending on SADDR pin)
+ * The platform has to define struct i2c_board_info objects and link to them
+ * from struct soc_camera_host_desc
+ */
+
+/*
+ * Sensor core register addresses (0x000..0x0ff)
+ */
+#define MT9M111_CHIP_VERSION   0x000
+#define MT9M111_ROW_START  0x001
+#define MT9M111_COLUMN_START   0x002
+#define MT9M111_WINDOW_HEIGHT  0x003
+#define MT9M111_WINDOW_WIDTH   0x004
+#define MT9M111_HORIZONTAL_BLANKING_B  0x005
+#define MT9M111_VERTICAL_BLANKING_B0x006
+#define MT9M111_HORIZONTAL_BLANKING_A  0x007
+#define MT9M111_VERTICAL_BLANKING_A0x008
+#define MT9M111_SHUTTER_WIDTH  0x009
+#define MT9M111_ROW_SPEED  0x00a
+#define MT9M111_EXTRA_DELAY0x00b
+#define MT9M111_SHUTTER_DELAY  0x00c
+#define MT9M111_RESET  0x00d
+#define MT9M111_READ_MODE_B0x020
+#define MT9M111_READ_MODE_A0x021
+#define MT9M111_FLASH_CONTROL  0x023
+#define MT9M111_GREEN1_GAIN0x02b
+#define MT9M111_BLUE_GAIN  0x02c
+#define MT9M111_RED_GAIN   0x02d
+#define MT9M111_GREEN2_GAIN0x02e
+#define MT9M111_GLOBAL_GAIN0x02f
+#define MT9M111_CONTEXT_CONTROL0x0c8
+#define MT9M111_PAGE_MAP   0x0f0
+#define MT9M111_BYTE_WISE_ADDR 0x0f1
+
+#define MT9M111_RESET_SYNC_CHANGES (1 << 15)
+#define MT9M111_RESET_RESTART_BAD_FRAME(1 << 9)
+#define MT9M111_RESET_SHOW_BAD_FRAMES  (1 << 8)
+#define MT9M111_RESET_RESET_SOC(1 << 5)
+#define MT9M111_RESET_OUTPUT_DISABLE   (1 << 4)
+#define MT9M111_RESET_CHIP_ENABLE  (1 << 3)
+#define MT9M111_RESET_ANALOG_STANDBY   (1 << 2)
+#define MT9M111_RESET_RESTART_FRAME(1 << 1)
+#define MT9M111_RESET_RESET_MODE   (1 << 0)
+
+#define MT9M111_RM_FULL_POWER_RD   (0 << 10)
+#define MT9M111_RM_LOW_POWER_RD(1 << 10)
+#define MT9M111_RM_COL_SKIP_4X (1 << 5)
+#define MT9M111_RM_ROW_SKIP_4X (1 << 4)
+#define MT9M111_RM_COL_SKIP_2X (1 << 3)
+#define MT9M111_RM_ROW_SKIP_2X (1 << 2)
+#define MT9M111_RMB_MIRRO

[PATCH v4 01/13] media: mt9m111: make a standalone v4l2 subdevice

2016-08-15 Thread Robert Jarzmik
Remove the soc_camera adherence. Mostly the change removes the power
manipulation provided by soc_camera, and instead :
 - powers on the sensor when the s_power control is activated
 - powers on the sensor in initial probe
 - enables and disables the MCLK provided to it in power on/off

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/soc_camera/mt9m111.c | 51 ++
 1 file changed, 15 insertions(+), 36 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index 6dfaead6aaa8..a7efaa5964d1 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -16,10 +16,11 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 /*
  * MT9M111, MT9M112 and MT9M131:
@@ -388,7 +389,7 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, const 
struct v4l2_crop *a)
struct v4l2_rect rect = a->c;
struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
int width, height;
-   int ret;
+   int ret, align = 0;
 
if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -396,17 +397,19 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, const 
struct v4l2_crop *a)
if (mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 ||
mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) {
/* Bayer format - even size lengths */
-   rect.width  = ALIGN(rect.width, 2);
-   rect.height = ALIGN(rect.height, 2);
+   align = 1;
/* Let the user play with the starting pixel */
}
 
/* FIXME: the datasheet doesn't specify minimum sizes */
-   soc_camera_limit_side(, ,
-MT9M111_MIN_DARK_COLS, 2, MT9M111_MAX_WIDTH);
-
-   soc_camera_limit_side(, ,
-MT9M111_MIN_DARK_ROWS, 2, MT9M111_MAX_HEIGHT);
+   v4l_bound_align_image(, 2, MT9M111_MAX_WIDTH, align,
+ , 2, MT9M111_MAX_HEIGHT, align, 0);
+   rect.left = clamp(rect.left, MT9M111_MIN_DARK_COLS,
+ MT9M111_MIN_DARK_COLS + MT9M111_MAX_WIDTH -
+ (__s32)rect.width);
+   rect.top = clamp(rect.top, MT9M111_MIN_DARK_ROWS,
+MT9M111_MIN_DARK_ROWS + MT9M111_MAX_HEIGHT -
+(__s32)rect.height);
 
width = min(mt9m111->width, rect.width);
height = min(mt9m111->height, rect.height);
@@ -775,17 +778,16 @@ static int mt9m111_init(struct mt9m111 *mt9m111)
 static int mt9m111_power_on(struct mt9m111 *mt9m111)
 {
struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
 
-   ret = soc_camera_power_on(>dev, ssdd, mt9m111->clk);
+   ret = v4l2_clk_enable(mt9m111->clk);
if (ret < 0)
return ret;
 
ret = mt9m111_resume(mt9m111);
if (ret < 0) {
dev_err(>dev, "Failed to resume the sensor: %d\n", ret);
-   soc_camera_power_off(>dev, ssdd, mt9m111->clk);
+   v4l2_clk_disable(mt9m111->clk);
}
 
return ret;
@@ -793,11 +795,8 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 
 static void mt9m111_power_off(struct mt9m111 *mt9m111)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
-
mt9m111_suspend(mt9m111);
-   soc_camera_power_off(>dev, ssdd, mt9m111->clk);
+   v4l2_clk_disable(mt9m111->clk);
 }
 
 static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
@@ -854,14 +853,10 @@ static int mt9m111_enum_mbus_code(struct v4l2_subdev *sd,
 static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
struct v4l2_mbus_config *cfg)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
-
cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
V4L2_MBUS_DATA_ACTIVE_HIGH;
cfg->type = V4L2_MBUS_PARALLEL;
-   cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
 
return 0;
 }
@@ -933,20 +928,8 @@ static int mt9m111_probe(struct i2c_client *client,
 {
struct mt9m111 *mt9m111;
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
-   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
 
-   if (client->dev.of_node) {
-   ssdd = devm_kzalloc(>dev, sizeof(*ssdd), GFP_KERNEL);
-   if (!ssdd)
-   return -ENOMEM;
-   

[PATCH v4 00/13] pxa_camera transition to v4l2 standalone device

2016-08-15 Thread Robert Jarzmik
Hi Hans,

Now only your comments have been taken between v3 and v4, the buffer sequence
number reset, and the rebase on top of v4.8-rc1, which makes the diffstat with
the former submission :
 drivers/media/i2c/mt9m111.c   | 14 ++
 drivers/media/platform/pxa_camera.c   | 45 
+
 drivers/media/platform/soc_camera/Kconfig | 12 ++--
 3 files changed, 9 insertions(+), 62 deletions(-)

I've also put the whole serie here if you want to fetch and review from git 
directly :
 - git fetch https://github.com/rjarzmik/linux.git work/v4l2

The result of v4l-compliance -s is in [1].
The result of v4l-compliance -f is in [2].

Happy review.

--
Robert

Robert Jarzmik (13):
  media: mt9m111: make a standalone v4l2 subdevice
  media: mt9m111: use only the SRGB colorspace
  media: mt9m111: move mt9m111 out of soc_camera
  media: platform: pxa_camera: convert to vb2
  media: platform: pxa_camera: trivial move of functions
  media: platform: pxa_camera: introduce sensor_call
  media: platform: pxa_camera: make printk consistent
  media: platform: pxa_camera: add buffer sequencing
  media: platform: pxa_camera: remove set_crop
  media: platform: pxa_camera: make a standalone v4l2 device
  media: platform: pxa_camera: add debug register access
  media: platform: pxa_camera: change stop_streaming semantics
  media: platform: pxa_camera: move pxa_camera out of soc_camera

 drivers/media/i2c/Kconfig  |7 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/mt9m111.c| 1033 
 drivers/media/i2c/soc_camera/Kconfig   |7 +-
 drivers/media/i2c/soc_camera/Makefile  |1 -
 drivers/media/i2c/soc_camera/mt9m111.c | 1054 
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/pxa_camera.c| 2096 
 drivers/media/platform/soc_camera/Kconfig  |8 -
 drivers/media/platform/soc_camera/Makefile |1 -
 drivers/media/platform/soc_camera/pxa_camera.c | 1866 -
 include/linux/platform_data/media/camera-pxa.h |2 +
 13 files changed, 3153 insertions(+), 2932 deletions(-)
 create mode 100644 drivers/media/i2c/mt9m111.c
 delete mode 100644 drivers/media/i2c/soc_camera/mt9m111.c
 create mode 100644 drivers/media/platform/pxa_camera.c
 delete mode 100644 drivers/media/platform/soc_camera/pxa_camera.c

-- 
2.1.4

[1] v4l-compliance -s
v4l2-compliance SHA   : f1348b4a819271d4138d62be5cee2e5aed1601d7

Driver Info:
Driver name   : pxa27x-camera
Card type : PXA_Camera
Bus info  : platform:pxa-camera
Driver version: 4.8.0
Capabilities  : 0x8421
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x0421
Video Capture
Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
fail: v4l2-test-controls.cpp(782): subscribe event for control 
'User Controls' failed
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 7 Private Controls: 0

Format ioctls

[PATCH v4 04/13] media: platform: pxa_camera: convert to vb2

2016-08-15 Thread Robert Jarzmik
Convert pxa_camera from videobuf to videobuf2.

As the soc_camera was already compatible with videobuf2, the port is
quite straightforward.

The special case of this code in which the vb2 to prepare is "too
big" in terms of size for the new capture format, the pxa_camera will
fail.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: took into account Hans's comments
  renamed all vb2 functions to pxac_vb2_*()
Since v2: spit queue_buffer() and start_streaming()
Since v3: replace void *alloc_ctxs by struct device *alloc_devs
---
 drivers/media/platform/soc_camera/Kconfig  |   4 +-
 drivers/media/platform/soc_camera/pxa_camera.c | 580 -
 2 files changed, 270 insertions(+), 314 deletions(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig 
b/drivers/media/platform/soc_camera/Kconfig
index 39f66414f621..3f927f96763a 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -19,8 +19,8 @@ config SOC_CAMERA_PLATFORM
 
 config VIDEO_PXA27x
tristate "PXA27x Quick Capture Interface driver"
-   depends on VIDEO_DEV && PXA27x && SOC_CAMERA
-   select VIDEOBUF_DMA_SG
+   depends on VIDEO_DEV && PXA27x && SOC_CAMERA && HAS_DMA
+   select VIDEOBUF2_DMA_SG
select SG_SPLIT
---help---
  This is a v4l2 driver for the PXA27x Quick Capture Interface
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 2aaf4a8f71a0..5bf97c6b6810 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -34,7 +34,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -180,13 +180,16 @@ enum pxa_camera_active_dma {
 /* buffer for one video frame */
 struct pxa_buffer {
/* common v4l buffer stuff -- must be first */
-   struct videobuf_buffer  vb;
+   struct vb2_v4l2_buffer  vbuf;
+   struct list_headqueue;
u32 code;
+   int nb_planes;
/* our descriptor lists for Y, U and V channels */
struct dma_async_tx_descriptor  *descs[3];
dma_cookie_tcookie[3];
struct scatterlist  *sg[3];
int sg_len[3];
+   size_t  plane_sizes[3];
int inwork;
enum pxa_camera_active_dma  active_dma;
 };
@@ -230,59 +233,19 @@ struct pxa_cam {
 
 static const char *pxa_cam_driver_description = "PXA_Camera";
 
-static unsigned int vid_limit = 16;/* Video memory limit, in Mb */
-
 /*
  *  Videobuf operations
  */
-static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
- unsigned int *size)
+static struct pxa_buffer *vb2_to_pxa_buffer(struct vb2_buffer *vb)
 {
-   struct soc_camera_device *icd = vq->priv_data;
-
-   dev_dbg(icd->parent, "count=%d, size=%d\n", *count, *size);
-
-   *size = icd->sizeimage;
-
-   if (0 == *count)
-   *count = 32;
-   if (*size * *count > vid_limit * 1024 * 1024)
-   *count = (vid_limit * 1024 * 1024) / *size;
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 
-   return 0;
+   return container_of(vbuf, struct pxa_buffer, vbuf);
 }
 
-static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
+static struct device *pcdev_to_dev(struct pxa_camera_dev *pcdev)
 {
-   struct soc_camera_device *icd = vq->priv_data;
-   struct videobuf_dmabuf *dma = videobuf_to_dma(>vb);
-   int i;
-
-   BUG_ON(in_interrupt());
-
-   dev_dbg(icd->parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
-   >vb, buf->vb.baddr, buf->vb.bsize);
-
-   /*
-* This waits until this buffer is out of danger, i.e., until it is no
-* longer in STATE_QUEUED or STATE_ACTIVE
-*/
-   videobuf_waiton(vq, >vb, 0, 0);
-
-   for (i = 0; i < 3 && buf->descs[i]; i++) {
-   dmaengine_desc_free(buf->descs[i]);
-   kfree(buf->sg[i]);
-   buf->descs[i] = NULL;
-   buf->sg[i] = NULL;
-   buf->sg_len[i] = 0;
-   }
-   videobuf_dma_unmap(vq->dev, dma);
-   videobuf_dma_free(dma);
-
-   buf->vb.state = VIDEOBUF_NEEDS_INIT;
-
-   dev_dbg(icd->parent, "%s end (vb=0x%p) 0x%08lx %d\n", __func__,
-   >vb, buf->vb.baddr, buf->vb.bsize);
+   return pcdev->soc_host.v4l2_dev.dev;
 }
 
 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
@@ -312,31 +275,26 @@ static void pxa_camera_dma_irq_v(void *data)
 /**
  * pxa_init_dma_channel - init dma descript

[PATCH v4 06/13] media: platform: pxa_camera: introduce sensor_call

2016-08-15 Thread Robert Jarzmik
Introduce sensor_call(), which will be used for all sensor invocations.
This is a preparation move to v4l2 device conversion, ie. soc_camera
adherence removal.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 27 ++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 0a9e4bdccece..171e3c57615c 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -168,6 +168,9 @@
CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
CICR0_EOFM | CICR0_FOM)
 
+#define sensor_call(cam, o, f, args...) \
+   v4l2_subdev_call(sd, o, f, ##args)
+
 /*
  * Structures
  */
@@ -731,7 +734,7 @@ static void pxa_camera_setup_cicr(struct soc_camera_device 
*icd,
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
unsigned long dw, bpp;
u32 cicr0, cicr1, cicr2, cicr3, cicr4 = 0, y_skip_top;
-   int ret = v4l2_subdev_call(sd, sensor, g_skip_top_lines, _skip_top);
+   int ret = sensor_call(pcdev, sensor, g_skip_top_lines, _skip_top);
 
if (ret < 0)
y_skip_top = 0;
@@ -1074,7 +1077,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
if (ret < 0)
return ret;
 
-   ret = v4l2_subdev_call(sd, video, g_mbus_config, );
+   ret = sensor_call(pcdev, video, g_mbus_config, );
if (!ret) {
common_flags = soc_mbus_config_compatible(,
  bus_flags);
@@ -1118,7 +1121,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
}
 
cfg.flags = common_flags;
-   ret = v4l2_subdev_call(sd, video, s_mbus_config, );
+   ret = sensor_call(pcdev, video, s_mbus_config, );
if (ret < 0 && ret != -ENOIOCTLCMD) {
dev_dbg(icd->parent, "camera s_mbus_config(0x%lx) returned 
%d\n",
common_flags, ret);
@@ -1145,7 +1148,7 @@ static int pxa_camera_try_bus_param(struct 
soc_camera_device *icd,
if (ret < 0)
return ret;
 
-   ret = v4l2_subdev_call(sd, video, g_mbus_config, );
+   ret = sensor_call(pcdev, video, g_mbus_config, );
if (!ret) {
common_flags = soc_mbus_config_compatible(,
  bus_flags);
@@ -1196,7 +1199,7 @@ static int pxa_camera_get_formats(struct 
soc_camera_device *icd, unsigned int id
};
const struct soc_mbus_pixelfmt *fmt;
 
-   ret = v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, );
+   ret = sensor_call(pcdev, pad, enum_mbus_code, NULL, );
if (ret < 0)
/* No more formats */
return 0;
@@ -1298,7 +1301,7 @@ static int pxa_camera_set_crop(struct soc_camera_device 
*icd,
if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
icd->sense = 
 
-   ret = v4l2_subdev_call(sd, video, s_crop, a);
+   ret = sensor_call(pcdev, video, s_crop, a);
 
icd->sense = NULL;
 
@@ -1308,7 +1311,7 @@ static int pxa_camera_set_crop(struct soc_camera_device 
*icd,
return ret;
}
 
-   ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, get_fmt, NULL, );
if (ret < 0)
return ret;
 
@@ -1320,7 +1323,7 @@ static int pxa_camera_set_crop(struct soc_camera_device 
*icd,
v4l_bound_align_image(>width, 48, 2048, 1,
>height, 32, 2048, 0,
fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
-   ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
if (ret < 0)
return ret;
 
@@ -1385,7 +1388,7 @@ static int pxa_camera_set_fmt(struct soc_camera_device 
*icd,
mf->colorspace  = pix->colorspace;
mf->code= xlate->code;
 
-   ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, );
+   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
 
if (mf->code != xlate->code)
return -EINVAL;
@@ -1460,7 +1463,7 @@ static int pxa_camera_try_fmt(struct soc_camera_device 
*icd,
mf->colorspace  = pix->colorspace;
mf->code= xlate->code;
 
-   ret = v4l2_subdev_call(sd, pad, set_fmt, _cfg, );
+   ret = sensor_call(pcdev, pad, set_fmt, _cfg, );
if (ret < 0)
return ret;
 
@@ -1518,7 +1521,7 @@ static int pxa_camera_suspend(struct device *dev)
 
if (pcdev->soc_host.icd) {
struct v4l2_subdev *sd = 
soc_camera_to_subdev(pcdev->soc_host.icd);
-

[PATCH v4 02/13] media: mt9m111: use only the SRGB colorspace

2016-08-15 Thread Robert Jarzmik
mt9m111 being a camera sensor, its colorspace should always be SRGB, for
both RGB based formats or YCbCr based ones.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/i2c/soc_camera/mt9m111.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index a7efaa5964d1..b7c4f371bae1 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -188,10 +188,10 @@ struct mt9m111_datafmt {
 };
 
 static const struct mt9m111_datafmt mt9m111_colour_fmts[] = {
-   {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
-   {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG},
+   {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_SRGB},
+   {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
-- 
2.1.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


[PATCH v4 05/13] media: platform: pxa_camera: trivial move of functions

2016-08-15 Thread Robert Jarzmik
Move the functions in the file to be regrouped into meaningful blocks :
 1. pxa camera core handling functions, manipulating the herdware
 2. videobuf2 functions, dealing with video buffers
 3. video ioctl (vidioc) related functions
 4. driver probing, removal, suspend and resume

This patch doesn't modify a single line of code.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v3: replace void *alloc_ctxt by struct device *alloc_devs impact
---
 drivers/media/platform/soc_camera/pxa_camera.c | 475 +
 1 file changed, 242 insertions(+), 233 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 5bf97c6b6810..0a9e4bdccece 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -538,239 +538,6 @@ out:
spin_unlock_irqrestore(>lock, flags);
 }
 
-static void pxa_buffer_cleanup(struct pxa_buffer *buf)
-{
-   int i;
-
-   for (i = 0; i < 3 && buf->descs[i]; i++) {
-   dmaengine_desc_free(buf->descs[i]);
-   kfree(buf->sg[i]);
-   buf->descs[i] = NULL;
-   buf->sg[i] = NULL;
-   buf->sg_len[i] = 0;
-   buf->plane_sizes[i] = 0;
-   }
-   buf->nb_planes = 0;
-}
-
-static int pxa_buffer_init(struct pxa_camera_dev *pcdev,
-  struct pxa_buffer *buf)
-{
-   struct vb2_buffer *vb = >vbuf.vb2_buf;
-   struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
-   int nb_channels = pcdev->channels;
-   int i, ret = 0;
-   unsigned long size = vb2_plane_size(vb, 0);
-
-   switch (nb_channels) {
-   case 1:
-   buf->plane_sizes[0] = size;
-   break;
-   case 3:
-   buf->plane_sizes[0] = size / 2;
-   buf->plane_sizes[1] = size / 4;
-   buf->plane_sizes[2] = size / 4;
-   break;
-   default:
-   return -EINVAL;
-   };
-   buf->nb_planes = nb_channels;
-
-   ret = sg_split(sgt->sgl, sgt->nents, 0, nb_channels,
-  buf->plane_sizes, buf->sg, buf->sg_len, GFP_KERNEL);
-   if (ret < 0) {
-   dev_err(pcdev_to_dev(pcdev),
-   "sg_split failed: %d\n", ret);
-   return ret;
-   }
-   for (i = 0; i < nb_channels; i++) {
-   ret = pxa_init_dma_channel(pcdev, buf, i,
-  buf->sg[i], buf->sg_len[i]);
-   if (ret) {
-   pxa_buffer_cleanup(buf);
-   return ret;
-   }
-   }
-   INIT_LIST_HEAD(>queue);
-
-   return ret;
-}
-
-static void pxac_vb2_cleanup(struct vb2_buffer *vb)
-{
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s(vb=%p)\n", __func__, vb);
-   pxa_buffer_cleanup(buf);
-}
-
-static void pxac_vb2_queue(struct vb2_buffer *vb)
-{
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s(vb=%p) nb_channels=%d size=%lu active=%p\n",
-   __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0),
-   pcdev->active);
-
-   list_add_tail(>queue, >capture);
-
-   pxa_dma_add_tail_buf(pcdev, buf);
-}
-
-/*
- * Please check the DMA prepared buffer structure in :
- *   Documentation/video4linux/pxa_camera.txt
- * Please check also in pxa_camera_check_link_miss() to understand why DMA 
chain
- * modification while DMA chain is running will work anyway.
- */
-static int pxac_vb2_prepare(struct vb2_buffer *vb)
-{
-   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
-   struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
-   struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
-   int ret = 0;
-
-   switch (pcdev->channels) {
-   case 1:
-   case 3:
-   vb2_set_plane_payload(vb, 0, icd->sizeimage);
-   break;
-   default:
-   return -EINVAL;
-   }
-
-   dev_dbg(pcdev_to_dev(pcdev),
-"%s (vb=%p) nb_channels=%d size=%lu\n",
-   __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0));
-
-   WARN_ON(!icd->current_fmt);
-
-#ifdef DEBUG
-   /*
-* This can be useful if you want to see if we actually fill
-* the buffer with something
-*/
-   for (i = 0; i < vb->num_planes; i++)
-   memset((void *)vb2_plane_vaddr(vb, i),
-  0xaa, vb2_get_plane_payload

[PATCH v4 13/13] media: platform: pxa_camera: move pxa_camera out of soc_camera

2016-08-15 Thread Robert Jarzmik
As the conversion to a v4l2 standalone device is finished, move
pxa_camera one directory up and finish severing any dependency to
soc_camera.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/pxa_camera.c| 2096 
 drivers/media/platform/soc_camera/Kconfig  |8 -
 drivers/media/platform/soc_camera/Makefile |1 -
 drivers/media/platform/soc_camera/pxa_camera.c | 2096 
 6 files changed, 2105 insertions(+), 2105 deletions(-)
 create mode 100644 drivers/media/platform/pxa_camera.c
 delete mode 100644 drivers/media/platform/soc_camera/pxa_camera.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344bc7912..299af1977d61 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -91,6 +91,14 @@ config VIDEO_OMAP3_DEBUG
---help---
  Enable debug messages on OMAP 3 camera controller driver.
 
+config VIDEO_PXA27x
+   tristate "PXA27x Quick Capture Interface driver"
+   depends on VIDEO_DEV && PXA27x && HAS_DMA
+   select VIDEOBUF2_DMA_SG
+   select SG_SPLIT
+   ---help---
+ This is a v4l2 driver for the PXA27x Quick Capture Interface
+
 config VIDEO_S3C_CAMIF
tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1a13fb..e38918bbe0d0 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_VIDEO_CAFE_CCIC) += marvell-ccic/
 obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/
 
 obj-$(CONFIG_VIDEO_OMAP3)  += omap3isp/
+obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o soc_camera/soc_mediabus.o
 
 obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o
 
diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
new file mode 100644
index ..868c6ad4784c
--- /dev/null
+++ b/drivers/media/platform/pxa_camera.c
@@ -0,0 +1,2096 @@
+/*
+ * V4L2 Driver for PXA camera host
+ *
+ * Copyright (C) 2006, Sascha Hauer, Pengutronix
+ * Copyright (C) 2008, Guennadi Liakhovetski <ker...@pengutronix.de>
+ * Copyright (C) 2016, Robert Jarzmik <robert.jarz...@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define PXA_CAM_VERSION "0.0.6"
+#define PXA_CAM_DRV_NAME "pxa27x-camera"
+
+#define DEFAULT_WIDTH  640
+#define DEFAULT_HEIGHT 480
+
+/* Camera Interface */
+#define CICR0  0x
+#define CICR1  0x0004
+#define CICR2  0x0008
+#define CICR3  0x000C
+#define CICR4  0x0010
+#define CISR   0x0014
+#define CIFR   0x0018
+#define CITOR  0x001C
+#define CIBR0  0x0028
+#define CIBR1  0x0030
+#define CIBR2  0x0038
+
+#define CICR0_DMAEN(1 << 31)   /* DMA request enable */
+#define CICR0_PAR_EN   (1 << 30)   /* Parity enable */
+#define CICR0_SL_CAP_EN(1 << 29)   /* Capture enable for slave 
mode */
+#define CICR0_ENB  (1 << 28)   /* Camera interface enable */
+#define CICR0_DIS  (1 << 27)   /* Camera interface disable */
+#define CICR0_SIM  (0x7 << 24) /* Sensor interface mode mask */
+#define CICR0_TOM  (1 << 9)/* Time-out mask */
+#define CICR0_RDAVM(1 << 8)/* Receive-data-available mask */
+#define CICR0_FEM  (1 << 7)/* FIFO-empty mask */
+#define CICR0_EOLM (1 << 6)/* End-of-line mask */
+#define CICR0_PERRM(1 << 5)/* Parity-error mask */
+#define CICR0_QDM  (1 << 4)/* Quick-disable mask */
+#define CICR0_CDM  (1 << 3)/* Disable-done mask */
+#define CICR0_SOFM (1 << 2)/* Start-of-frame mask */
+#define CICR0_EOFM (1 << 1)/* End-of-frame mask */
+#define CICR0_FOM  (1 << 0)/* FIFO-overrun mask */
+
+#define CICR1_TBIT (1 << 31)   /* Transparency bit */
+#define CICR1_RGBT_CONV(0x3 << 29) /* RGBT conversion mask */

[PATCH v4 09/13] media: platform: pxa_camera: remove set_crop

2016-08-15 Thread Robert Jarzmik
This is to be seen as a regression as the set_crop function is
removed. This is a temporary situation in the v4l2 porting, and will
have to be added later.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 76 --
 1 file changed, 76 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 2471d036a835..a2fedc9bb71c 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1295,81 +1295,6 @@ static int pxa_camera_check_frame(u32 width, u32 height)
(width & 0x01);
 }
 
-static int pxa_camera_set_crop(struct soc_camera_device *icd,
-  const struct v4l2_crop *a)
-{
-   const struct v4l2_rect *rect = >c;
-   struct device *dev = icd->parent;
-   struct soc_camera_host *ici = to_soc_camera_host(dev);
-   struct pxa_camera_dev *pcdev = ici->priv;
-   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct soc_camera_sense sense = {
-   .master_clock = pcdev->mclk,
-   .pixel_clock_max = pcdev->ciclk / 4,
-   };
-   struct v4l2_subdev_format fmt = {
-   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
-   };
-   struct v4l2_mbus_framefmt *mf = 
-   struct pxa_cam *cam = icd->host_priv;
-   u32 fourcc = icd->current_fmt->host_fmt->fourcc;
-   int ret;
-
-   /* If PCLK is used to latch data from the sensor, check sense */
-   if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
-   icd->sense = 
-
-   ret = sensor_call(pcdev, video, s_crop, a);
-
-   icd->sense = NULL;
-
-   if (ret < 0) {
-   dev_warn(pcdev_to_dev(pcdev), "Failed to crop to %ux%u@%u:%u\n",
-rect->width, rect->height, rect->left, rect->top);
-   return ret;
-   }
-
-   ret = sensor_call(pcdev, pad, get_fmt, NULL, );
-   if (ret < 0)
-   return ret;
-
-   if (pxa_camera_check_frame(mf->width, mf->height)) {
-   /*
-* Camera cropping produced a frame beyond our capabilities.
-* FIXME: just extract a subframe, that we can process.
-*/
-   v4l_bound_align_image(>width, 48, 2048, 1,
-   >height, 32, 2048, 0,
-   fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
-   ret = sensor_call(pcdev, pad, set_fmt, NULL, );
-   if (ret < 0)
-   return ret;
-
-   if (pxa_camera_check_frame(mf->width, mf->height)) {
-   dev_warn(pcdev_to_dev(pcdev),
-"Inconsistent state. Use S_FMT to repair\n");
-   return -EINVAL;
-   }
-   }
-
-   if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
-   if (sense.pixel_clock > sense.pixel_clock_max) {
-   dev_err(pcdev_to_dev(pcdev),
-   "pixel clock %lu set by the camera too high!",
-   sense.pixel_clock);
-   return -EIO;
-   }
-   recalculate_fifo_timeout(pcdev, sense.pixel_clock);
-   }
-
-   icd->user_width = mf->width;
-   icd->user_height= mf->height;
-
-   pxa_camera_setup_cicr(icd, cam->flags, fourcc);
-
-   return ret;
-}
-
 static int pxa_camera_set_fmt(struct soc_camera_device *icd,
  struct v4l2_format *f)
 {
@@ -1582,7 +1507,6 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops 
= {
.remove = pxa_camera_remove_device,
.clock_start= pxa_camera_clock_start,
.clock_stop = pxa_camera_clock_stop,
-   .set_crop   = pxa_camera_set_crop,
.get_formats= pxa_camera_get_formats,
.put_formats= pxa_camera_put_formats,
.set_fmt= pxa_camera_set_fmt,
-- 
2.1.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


[PATCH v4 11/13] media: platform: pxa_camera: add debug register access

2016-08-15 Thread Robert Jarzmik
Add pxa_camera registers access through advanced video debugging.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 32 ++
 1 file changed, 32 insertions(+)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 395cd398c32b..fb89b85f59ab 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1342,6 +1342,34 @@ static int pxa_camera_check_frame(u32 width, u32 height)
(width & 0x01);
 }
 
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int pxac_vidioc_g_register(struct file *file, void *priv,
+ struct v4l2_dbg_register *reg)
+{
+   struct pxa_camera_dev *pcdev = video_drvdata(file);
+
+   if (reg->reg > CIBR2)
+   return -ERANGE;
+
+   reg->val = __raw_readl(pcdev->base + reg->reg);
+   reg->size = sizeof(__u32);
+   return 0;
+}
+
+static int pxac_vidioc_s_register(struct file *file, void *priv,
+ const struct v4l2_dbg_register *reg)
+{
+   struct pxa_camera_dev *pcdev = video_drvdata(file);
+
+   if (reg->reg > CIBR2)
+   return -ERANGE;
+   if (reg->size != sizeof(__u32))
+   return -EINVAL;
+   __raw_writel(reg->val, pcdev->base + reg->reg);
+   return 0;
+}
+#endif
+
 static int pxac_vidioc_enum_fmt_vid_cap(struct file *filp, void  *priv,
struct v4l2_fmtdesc *f)
 {
@@ -1592,6 +1620,10 @@ static const struct v4l2_ioctl_ops pxa_camera_ioctl_ops 
= {
.vidioc_expbuf  = vb2_ioctl_expbuf,
.vidioc_streamon= vb2_ioctl_streamon,
.vidioc_streamoff   = vb2_ioctl_streamoff,
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+   .vidioc_g_register  = pxac_vidioc_g_register,
+   .vidioc_s_register  = pxac_vidioc_s_register,
+#endif
 };
 
 static struct v4l2_clk_ops pxa_camera_mclk_ops = {
-- 
2.1.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


[PATCH v4 12/13] media: platform: pxa_camera: change stop_streaming semantics

2016-08-15 Thread Robert Jarzmik
Instead of the legacy behavior where it was required to wait for all
video buffers to be finished by the hardware, use a cancel like strategy
: as soon as the stop_streaming() call is done, abort all DMA transfers,
report the already buffers as failed and return.

This makes stop_streaming() more a "cancel capture" than a "wait for end
of capture" semantic.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index fb89b85f59ab..868c6ad4784c 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -523,7 +523,8 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev 
*pcdev)
 }
 
 static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
- struct pxa_buffer *buf)
+ struct pxa_buffer *buf,
+ enum vb2_buffer_state state)
 {
struct vb2_buffer *vb = >vbuf.vb2_buf;
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -645,7 +646,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
}
buf->active_dma &= ~act_dma;
if (!buf->active_dma) {
-   pxa_camera_wakeup(pcdev, buf);
+   pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_DONE);
pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan],
   last_issued);
}
@@ -1087,7 +1088,15 @@ static int pxac_vb2_start_streaming(struct vb2_queue 
*vq, unsigned int count)
 
 static void pxac_vb2_stop_streaming(struct vb2_queue *vq)
 {
-   vb2_wait_for_all_buffers(vq);
+   struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
+   struct pxa_buffer *buf, *tmp;
+
+   dev_dbg(pcdev_to_dev(pcdev), "%s active=%p\n",
+   __func__, pcdev->active);
+   pxa_camera_stop_capture(pcdev);
+
+   list_for_each_entry_safe(buf, tmp, >capture, queue)
+   pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR);
 }
 
 static struct vb2_ops pxac_vb2_ops = {
-- 
2.1.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


[PATCH v4 07/13] media: platform: pxa_camera: make printk consistent

2016-08-15 Thread Robert Jarzmik
Make all print consistent by always using :
 - dev_xxx(pcdev_to_dev(pcdev), )

This prepares the soc_camera adherence removal by making these call rely
on only pcdev, and not the soc_camera icd structure.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/soc_camera/pxa_camera.c | 70 --
 1 file changed, 43 insertions(+), 27 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 171e3c57615c..f3922a99405b 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -236,6 +236,14 @@ struct pxa_cam {
 
 static const char *pxa_cam_driver_description = "PXA_Camera";
 
+static struct pxa_camera_dev *icd_to_pcdev(struct soc_camera_device *icd)
+{
+   struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+   struct pxa_camera_dev *pcdev = ici->priv;
+
+   return pcdev;
+}
+
 /*
  *  Videobuf operations
  */
@@ -465,7 +473,6 @@ static void pxa_camera_check_link_miss(struct 
pxa_camera_dev *pcdev,
 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
   enum pxa_camera_active_dma act_dma)
 {
-   struct device *dev = pcdev_to_dev(pcdev);
struct pxa_buffer *buf, *last_buf;
unsigned long flags;
u32 camera_status, overrun;
@@ -476,7 +483,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
spin_lock_irqsave(>lock, flags);
 
camera_status = __raw_readl(pcdev->base + CISR);
-   dev_dbg(dev, "camera dma irq, cisr=0x%x dma=%d\n",
+   dev_dbg(pcdev_to_dev(pcdev), "camera dma irq, cisr=0x%x dma=%d\n",
camera_status, act_dma);
overrun = CISR_IFO_0;
if (pcdev->channels == 3)
@@ -522,7 +529,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
   NULL, _issued);
if (camera_status & overrun &&
last_status != DMA_COMPLETE) {
-   dev_dbg(dev, "FIFO overrun! CISR: %x\n",
+   dev_dbg(pcdev_to_dev(pcdev), "FIFO overrun! CISR: %x\n",
camera_status);
pxa_camera_stop_capture(pcdev);
list_for_each_entry(buf, >capture, queue)
@@ -545,7 +552,6 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
struct pxa_camera_dev *pcdev)
 {
unsigned long mclk = pcdev->mclk;
-   struct device *dev = >dev;
u32 div;
unsigned long lcdclk;
 
@@ -555,7 +561,8 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
/* mclk <= ciclk / 4 (27.4.2) */
if (mclk > lcdclk / 4) {
mclk = lcdclk / 4;
-   dev_warn(dev, "Limiting master clock to %lu\n", mclk);
+   dev_warn(pcdev_to_dev(pcdev),
+"Limiting master clock to %lu\n", mclk);
}
 
/* We verify mclk != 0, so if anyone breaks it, here comes their Oops */
@@ -565,7 +572,7 @@ static u32 mclk_get_divisor(struct platform_device *pdev,
if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
pcdev->mclk = lcdclk / (2 * (div + 1));
 
-   dev_dbg(dev, "LCD clock %luHz, target freq %luHz, divisor %u\n",
+   dev_dbg(pcdev_to_dev(pcdev), "LCD clock %luHz, target freq %luHz, 
divisor %u\n",
lcdclk, mclk, div);
 
return div;
@@ -662,7 +669,9 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
 
 static int pxa_camera_add_device(struct soc_camera_device *icd)
 {
-   dev_info(icd->parent, "PXA Camera driver attached to camera %d\n",
+   struct pxa_camera_dev *pcdev = icd_to_pcdev(icd);
+
+   dev_info(pcdev_to_dev(pcdev), "PXA Camera driver attached to camera 
%d\n",
 icd->devnum);
 
return 0;
@@ -670,7 +679,9 @@ static int pxa_camera_add_device(struct soc_camera_device 
*icd)
 
 static void pxa_camera_remove_device(struct soc_camera_device *icd)
 {
-   dev_info(icd->parent, "PXA Camera driver detached from camera %d\n",
+   struct pxa_camera_dev *pcdev = icd_to_pcdev(icd);
+
+   dev_info(pcdev_to_dev(pcdev), "PXA Camera driver detached from camera 
%d\n",
 icd->devnum);
 }
 
@@ -1082,7 +1093,7 @@ static int pxa_camera_set_bus_param(struct 
soc_camera_device *icd)
common_flags = soc_mbus_config_compatible(,
  bus_flags);
if (!common_flags) {
-   dev_warn(icd->parent,
+   dev_warn(pcdev_to_dev(pcdev),
 "Flags incompatible: camera 0x%x, host 
0x%lx\n",
 cfg.flags, b

  1   2   3   >