* [PATCH v1 0/5] Camera support on STM32F746G-DISCO board @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet This patchset enables OV9655 camera support of STM32F4DIS-CAM extension board plugged on connector P1 of STM32F746G-DISCO board. Tested by doing a fullscreen preview with a modified version of yavta [1] which redirects captured frames to framebuffer: yavta -s 480x272 -n 1 --capture=-1 /dev/video0 -D (note the unofficial "-D" option for "Display output") First part of patches brings few fixes in DCMI driver and introduces internal crop support in order to enable fullscreen preview (480x272) by cropping VGA sensor output. Second part relates to devicetree and configuration to enable DCMI on STM32F746 MCU then enable DCMI and OV9655 support on STM32F746G-DISCO [2]. [1] http://git.ideasonboard.org/?p=yavta.git;a=summary [2] due to STM32F746G-DISCO support not yet in media tree (4.13-rc1), devicetree patches related to STM32F746G-DISCO are not yet provided. =========== = history = =========== version 1: - Initial submission for code review with restrictions [2]. Hugues Fruchet (5): [media] stm32-dcmi: catch dma submission error [media] stm32-dcmi: revisit control register handling [media] stm32-dcmi: crop sensor image to match user resolution ARM: dts: stm32: Enable DCMI support on STM32F746 MCU ARM: configs: stm32: DCMI + OV9655 camera support arch/arm/boot/dts/stm32f746.dtsi | 31 +++++++++++++ arch/arm/configs/stm32_defconfig | 9 ++++ drivers/media/platform/stm32/stm32-dcmi.c | 72 ++++++++++++++++++++++++++----- 3 files changed, 101 insertions(+), 11 deletions(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 0/5] Camera support on STM32F746G-DISCO board @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: linux-arm-kernel This patchset enables OV9655 camera support of STM32F4DIS-CAM extension board plugged on connector P1 of STM32F746G-DISCO board. Tested by doing a fullscreen preview with a modified version of yavta [1] which redirects captured frames to framebuffer: yavta -s 480x272 -n 1 --capture=-1 /dev/video0 -D (note the unofficial "-D" option for "Display output") First part of patches brings few fixes in DCMI driver and introduces internal crop support in order to enable fullscreen preview (480x272) by cropping VGA sensor output. Second part relates to devicetree and configuration to enable DCMI on STM32F746 MCU then enable DCMI and OV9655 support on STM32F746G-DISCO [2]. [1] http://git.ideasonboard.org/?p=yavta.git;a=summary [2] due to STM32F746G-DISCO support not yet in media tree (4.13-rc1), devicetree patches related to STM32F746G-DISCO are not yet provided. =========== = history = =========== version 1: - Initial submission for code review with restrictions [2]. Hugues Fruchet (5): [media] stm32-dcmi: catch dma submission error [media] stm32-dcmi: revisit control register handling [media] stm32-dcmi: crop sensor image to match user resolution ARM: dts: stm32: Enable DCMI support on STM32F746 MCU ARM: configs: stm32: DCMI + OV9655 camera support arch/arm/boot/dts/stm32f746.dtsi | 31 +++++++++++++ arch/arm/configs/stm32_defconfig | 9 ++++ drivers/media/platform/stm32/stm32-dcmi.c | 72 ++++++++++++++++++++++++++----- 3 files changed, 101 insertions(+), 11 deletions(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 0/5] Camera support on STM32F746G-DISCO board @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-kernel, Yannick Fertre, Benjamin Gaignard, Hugues Fruchet, linux-arm-kernel, linux-media This patchset enables OV9655 camera support of STM32F4DIS-CAM extension board plugged on connector P1 of STM32F746G-DISCO board. Tested by doing a fullscreen preview with a modified version of yavta [1] which redirects captured frames to framebuffer: yavta -s 480x272 -n 1 --capture=-1 /dev/video0 -D (note the unofficial "-D" option for "Display output") First part of patches brings few fixes in DCMI driver and introduces internal crop support in order to enable fullscreen preview (480x272) by cropping VGA sensor output. Second part relates to devicetree and configuration to enable DCMI on STM32F746 MCU then enable DCMI and OV9655 support on STM32F746G-DISCO [2]. [1] http://git.ideasonboard.org/?p=yavta.git;a=summary [2] due to STM32F746G-DISCO support not yet in media tree (4.13-rc1), devicetree patches related to STM32F746G-DISCO are not yet provided. =========== = history = =========== version 1: - Initial submission for code review with restrictions [2]. Hugues Fruchet (5): [media] stm32-dcmi: catch dma submission error [media] stm32-dcmi: revisit control register handling [media] stm32-dcmi: crop sensor image to match user resolution ARM: dts: stm32: Enable DCMI support on STM32F746 MCU ARM: configs: stm32: DCMI + OV9655 camera support arch/arm/boot/dts/stm32f746.dtsi | 31 +++++++++++++ arch/arm/configs/stm32_defconfig | 9 ++++ drivers/media/platform/stm32/stm32-dcmi.c | 72 ++++++++++++++++++++++++++----- 3 files changed, 101 insertions(+), 11 deletions(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 1/5] [media] stm32-dcmi: catch dma submission error @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Test cookie return by dmaengine_submit() and return error if any. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 83d32a5..0dd5d1c 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -295,6 +295,10 @@ static int dcmi_start_dma(struct stm32_dcmi *dcmi, /* Push current DMA transaction in the pending queue */ dcmi->dma_cookie = dmaengine_submit(desc); + if (dma_submit_error(dcmi->dma_cookie)) { + dev_err(dcmi->dev, "%s: DMA submission failed\n", __func__); + return -ENXIO; + } dma_async_issue_pending(dcmi->dma_chan); -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 1/5] [media] stm32-dcmi: catch dma submission error @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: linux-arm-kernel Test cookie return by dmaengine_submit() and return error if any. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 83d32a5..0dd5d1c 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -295,6 +295,10 @@ static int dcmi_start_dma(struct stm32_dcmi *dcmi, /* Push current DMA transaction in the pending queue */ dcmi->dma_cookie = dmaengine_submit(desc); + if (dma_submit_error(dcmi->dma_cookie)) { + dev_err(dcmi->dev, "%s: DMA submission failed\n", __func__); + return -ENXIO; + } dma_async_issue_pending(dcmi->dma_chan); -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 1/5] [media] stm32-dcmi: catch dma submission error @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-media-u79uwXL29TY76Z2rM5mHXA, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Test cookie return by dmaengine_submit() and return error if any. Signed-off-by: Hugues Fruchet <hugues.fruchet-qxv4g6HH51o@public.gmane.org> --- drivers/media/platform/stm32/stm32-dcmi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 83d32a5..0dd5d1c 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -295,6 +295,10 @@ static int dcmi_start_dma(struct stm32_dcmi *dcmi, /* Push current DMA transaction in the pending queue */ dcmi->dma_cookie = dmaengine_submit(desc); + if (dma_submit_error(dcmi->dma_cookie)) { + dev_err(dcmi->dev, "%s: DMA submission failed\n", __func__); + return -ENXIO; + } dma_async_issue_pending(dcmi->dma_chan); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling 2017-06-22 15:12 ` Hugues Fruchet (?) @ 2017-06-22 15:12 ` Hugues Fruchet -1 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Simplify bits handling of DCMI_CR register. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 0dd5d1c..75d53aa 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -490,7 +490,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) { struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq); struct dcmi_buf *buf, *node; - u32 val; + u32 val = 0; int ret; ret = clk_enable(dcmi->mclk); @@ -510,22 +510,16 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) spin_lock_irq(&dcmi->irqlock); - val = reg_read(dcmi->regs, DCMI_CR); - - val &= ~(CR_PCKPOL | CR_HSPOL | CR_VSPOL | - CR_EDM_0 | CR_EDM_1 | CR_FCRC_0 | - CR_FCRC_1 | CR_JPEG | CR_ESS); - /* Set bus width */ switch (dcmi->bus.bus_width) { case 14: - val &= CR_EDM_0 + CR_EDM_1; + val |= CR_EDM_0 | CR_EDM_1; break; case 12: - val &= CR_EDM_1; + val |= CR_EDM_1; break; case 10: - val &= CR_EDM_0; + val |= CR_EDM_0; break; default: /* Set bus width to 8 bits by default */ -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: linux-arm-kernel Simplify bits handling of DCMI_CR register. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 0dd5d1c..75d53aa 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -490,7 +490,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) { struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq); struct dcmi_buf *buf, *node; - u32 val; + u32 val = 0; int ret; ret = clk_enable(dcmi->mclk); @@ -510,22 +510,16 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) spin_lock_irq(&dcmi->irqlock); - val = reg_read(dcmi->regs, DCMI_CR); - - val &= ~(CR_PCKPOL | CR_HSPOL | CR_VSPOL | - CR_EDM_0 | CR_EDM_1 | CR_FCRC_0 | - CR_FCRC_1 | CR_JPEG | CR_ESS); - /* Set bus width */ switch (dcmi->bus.bus_width) { case 14: - val &= CR_EDM_0 + CR_EDM_1; + val |= CR_EDM_0 | CR_EDM_1; break; case 12: - val &= CR_EDM_1; + val |= CR_EDM_1; break; case 10: - val &= CR_EDM_0; + val |= CR_EDM_0; break; default: /* Set bus width to 8 bits by default */ -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Simplify bits handling of DCMI_CR register. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 0dd5d1c..75d53aa 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -490,7 +490,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) { struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq); struct dcmi_buf *buf, *node; - u32 val; + u32 val = 0; int ret; ret = clk_enable(dcmi->mclk); @@ -510,22 +510,16 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) spin_lock_irq(&dcmi->irqlock); - val = reg_read(dcmi->regs, DCMI_CR); - - val &= ~(CR_PCKPOL | CR_HSPOL | CR_VSPOL | - CR_EDM_0 | CR_EDM_1 | CR_FCRC_0 | - CR_FCRC_1 | CR_JPEG | CR_ESS); - /* Set bus width */ switch (dcmi->bus.bus_width) { case 14: - val &= CR_EDM_0 + CR_EDM_1; + val |= CR_EDM_0 | CR_EDM_1; break; case 12: - val &= CR_EDM_1; + val |= CR_EDM_1; break; case 10: - val &= CR_EDM_0; + val |= CR_EDM_0; break; default: /* Set bus width to 8 bits by default */ -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 2017-06-22 15:12 ` Hugues Fruchet (?) @ 2017-06-22 15:12 ` Hugues Fruchet -1 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Add flexibility on supported resolutions by cropping sensor image to fit user resolution format request. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 75d53aa..bc5e052 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -131,6 +131,8 @@ struct stm32_dcmi { struct v4l2_async_notifier notifier; struct dcmi_graph_entity entity; struct v4l2_format fmt; + struct v4l2_rect crop; + bool do_crop; const struct dcmi_format **user_formats; unsigned int num_user_formats; @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) val |= CR_PCKPOL; + if (dcmi->do_crop) { + u32 size, start; + + /* Crop resolution */ + size = ((dcmi->crop.height - 1) << 16) | + ((dcmi->crop.width << 1) - 1); + reg_write(dcmi->regs, DCMI_CWSIZE, size); + + /* Crop start point */ + start = ((dcmi->crop.top) << 16) | + ((dcmi->crop.left << 1)); + reg_write(dcmi->regs, DCMI_CWSTRT, start); + + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", + dcmi->crop.width, dcmi->crop.height, + dcmi->crop.left, dcmi->crop.top); + + /* Enable crop */ + val |= CR_CROP; + }; + reg_write(dcmi->regs, DCMI_CR, val); /* Enable dcmi */ @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, .which = V4L2_SUBDEV_FORMAT_TRY, }; int ret; + __u32 width, height; + struct v4l2_mbus_framefmt *mf = &format.format; dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); if (!dcmi_fmt) { @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, if (ret < 0) return ret; + /* Align format on what sensor can do */ + width = pixfmt->width; + height = pixfmt->height; v4l2_fill_pix_format(pixfmt, &format.format); + /* We can do any resolution thanks to crop */ + if ((mf->width > width) || (mf->height > height)) { + /* Restore width/height */ + pixfmt->width = width; + pixfmt->height = height; + }; + pixfmt->field = V4L2_FIELD_NONE; pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; + struct v4l2_mbus_framefmt *mf = &format.format; + struct v4l2_pix_format *pixfmt = &f->fmt.pix; const struct dcmi_format *current_fmt; int ret; @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) if (ret) return ret; - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, + v4l2_fill_mbus_format(&format.format, pixfmt, current_fmt->mbus_code); ret = v4l2_subdev_call(dcmi->entity.subdev, pad, set_fmt, NULL, &format); if (ret < 0) return ret; + /* Enable crop if sensor resolution is larger than request */ + dcmi->do_crop = false; + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { + dcmi->crop.width = pixfmt->width; + dcmi->crop.height = pixfmt->height; + dcmi->crop.left = (mf->width - pixfmt->width) / 2; + dcmi->crop.top = (mf->height - pixfmt->height) / 2; + dcmi->do_crop = true; + + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", + mf->width, mf->height, + dcmi->crop.width, dcmi->crop.height, + dcmi->crop.left, dcmi->crop.top); + }; + dcmi->fmt = *f; dcmi->current_fmt = current_fmt; -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: linux-arm-kernel Add flexibility on supported resolutions by cropping sensor image to fit user resolution format request. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 75d53aa..bc5e052 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -131,6 +131,8 @@ struct stm32_dcmi { struct v4l2_async_notifier notifier; struct dcmi_graph_entity entity; struct v4l2_format fmt; + struct v4l2_rect crop; + bool do_crop; const struct dcmi_format **user_formats; unsigned int num_user_formats; @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) val |= CR_PCKPOL; + if (dcmi->do_crop) { + u32 size, start; + + /* Crop resolution */ + size = ((dcmi->crop.height - 1) << 16) | + ((dcmi->crop.width << 1) - 1); + reg_write(dcmi->regs, DCMI_CWSIZE, size); + + /* Crop start point */ + start = ((dcmi->crop.top) << 16) | + ((dcmi->crop.left << 1)); + reg_write(dcmi->regs, DCMI_CWSTRT, start); + + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", + dcmi->crop.width, dcmi->crop.height, + dcmi->crop.left, dcmi->crop.top); + + /* Enable crop */ + val |= CR_CROP; + }; + reg_write(dcmi->regs, DCMI_CR, val); /* Enable dcmi */ @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, .which = V4L2_SUBDEV_FORMAT_TRY, }; int ret; + __u32 width, height; + struct v4l2_mbus_framefmt *mf = &format.format; dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); if (!dcmi_fmt) { @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, if (ret < 0) return ret; + /* Align format on what sensor can do */ + width = pixfmt->width; + height = pixfmt->height; v4l2_fill_pix_format(pixfmt, &format.format); + /* We can do any resolution thanks to crop */ + if ((mf->width > width) || (mf->height > height)) { + /* Restore width/height */ + pixfmt->width = width; + pixfmt->height = height; + }; + pixfmt->field = V4L2_FIELD_NONE; pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; + struct v4l2_mbus_framefmt *mf = &format.format; + struct v4l2_pix_format *pixfmt = &f->fmt.pix; const struct dcmi_format *current_fmt; int ret; @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) if (ret) return ret; - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, + v4l2_fill_mbus_format(&format.format, pixfmt, current_fmt->mbus_code); ret = v4l2_subdev_call(dcmi->entity.subdev, pad, set_fmt, NULL, &format); if (ret < 0) return ret; + /* Enable crop if sensor resolution is larger than request */ + dcmi->do_crop = false; + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { + dcmi->crop.width = pixfmt->width; + dcmi->crop.height = pixfmt->height; + dcmi->crop.left = (mf->width - pixfmt->width) / 2; + dcmi->crop.top = (mf->height - pixfmt->height) / 2; + dcmi->do_crop = true; + + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", + mf->width, mf->height, + dcmi->crop.width, dcmi->crop.height, + dcmi->crop.left, dcmi->crop.top); + }; + dcmi->fmt = *f; dcmi->current_fmt = current_fmt; -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-kernel, Yannick Fertre, Benjamin Gaignard, Hugues Fruchet, linux-arm-kernel, linux-media Add flexibility on supported resolutions by cropping sensor image to fit user resolution format request. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 75d53aa..bc5e052 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -131,6 +131,8 @@ struct stm32_dcmi { struct v4l2_async_notifier notifier; struct dcmi_graph_entity entity; struct v4l2_format fmt; + struct v4l2_rect crop; + bool do_crop; const struct dcmi_format **user_formats; unsigned int num_user_formats; @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) val |= CR_PCKPOL; + if (dcmi->do_crop) { + u32 size, start; + + /* Crop resolution */ + size = ((dcmi->crop.height - 1) << 16) | + ((dcmi->crop.width << 1) - 1); + reg_write(dcmi->regs, DCMI_CWSIZE, size); + + /* Crop start point */ + start = ((dcmi->crop.top) << 16) | + ((dcmi->crop.left << 1)); + reg_write(dcmi->regs, DCMI_CWSTRT, start); + + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", + dcmi->crop.width, dcmi->crop.height, + dcmi->crop.left, dcmi->crop.top); + + /* Enable crop */ + val |= CR_CROP; + }; + reg_write(dcmi->regs, DCMI_CR, val); /* Enable dcmi */ @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, .which = V4L2_SUBDEV_FORMAT_TRY, }; int ret; + __u32 width, height; + struct v4l2_mbus_framefmt *mf = &format.format; dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); if (!dcmi_fmt) { @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, if (ret < 0) return ret; + /* Align format on what sensor can do */ + width = pixfmt->width; + height = pixfmt->height; v4l2_fill_pix_format(pixfmt, &format.format); + /* We can do any resolution thanks to crop */ + if ((mf->width > width) || (mf->height > height)) { + /* Restore width/height */ + pixfmt->width = width; + pixfmt->height = height; + }; + pixfmt->field = V4L2_FIELD_NONE; pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; + struct v4l2_mbus_framefmt *mf = &format.format; + struct v4l2_pix_format *pixfmt = &f->fmt.pix; const struct dcmi_format *current_fmt; int ret; @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) if (ret) return ret; - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, + v4l2_fill_mbus_format(&format.format, pixfmt, current_fmt->mbus_code); ret = v4l2_subdev_call(dcmi->entity.subdev, pad, set_fmt, NULL, &format); if (ret < 0) return ret; + /* Enable crop if sensor resolution is larger than request */ + dcmi->do_crop = false; + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { + dcmi->crop.width = pixfmt->width; + dcmi->crop.height = pixfmt->height; + dcmi->crop.left = (mf->width - pixfmt->width) / 2; + dcmi->crop.top = (mf->height - pixfmt->height) / 2; + dcmi->do_crop = true; + + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", + mf->width, mf->height, + dcmi->crop.width, dcmi->crop.height, + dcmi->crop.left, dcmi->crop.top); + }; + dcmi->fmt = *f; dcmi->current_fmt = current_fmt; -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 2017-06-22 15:12 ` Hugues Fruchet @ 2017-06-22 15:19 ` Hans Verkuil -1 siblings, 0 replies; 40+ messages in thread From: Hans Verkuil @ 2017-06-22 15:19 UTC (permalink / raw) To: Hugues Fruchet, Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre On 06/22/2017 05:12 PM, Hugues Fruchet wrote: > Add flexibility on supported resolutions by cropping sensor > image to fit user resolution format request. > > Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> > --- > drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c > index 75d53aa..bc5e052 100644 > --- a/drivers/media/platform/stm32/stm32-dcmi.c > +++ b/drivers/media/platform/stm32/stm32-dcmi.c > @@ -131,6 +131,8 @@ struct stm32_dcmi { > struct v4l2_async_notifier notifier; > struct dcmi_graph_entity entity; > struct v4l2_format fmt; > + struct v4l2_rect crop; > + bool do_crop; > > const struct dcmi_format **user_formats; > unsigned int num_user_formats; > @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) > if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) > val |= CR_PCKPOL; > > + if (dcmi->do_crop) { > + u32 size, start; > + > + /* Crop resolution */ > + size = ((dcmi->crop.height - 1) << 16) | > + ((dcmi->crop.width << 1) - 1); > + reg_write(dcmi->regs, DCMI_CWSIZE, size); > + > + /* Crop start point */ > + start = ((dcmi->crop.top) << 16) | > + ((dcmi->crop.left << 1)); > + reg_write(dcmi->regs, DCMI_CWSTRT, start); > + > + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", > + dcmi->crop.width, dcmi->crop.height, > + dcmi->crop.left, dcmi->crop.top); > + > + /* Enable crop */ > + val |= CR_CROP; > + }; > + > reg_write(dcmi->regs, DCMI_CR, val); > > /* Enable dcmi */ > @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, > .which = V4L2_SUBDEV_FORMAT_TRY, > }; > int ret; > + __u32 width, height; > + struct v4l2_mbus_framefmt *mf = &format.format; > > dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); > if (!dcmi_fmt) { > @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, > if (ret < 0) > return ret; > > + /* Align format on what sensor can do */ > + width = pixfmt->width; > + height = pixfmt->height; > v4l2_fill_pix_format(pixfmt, &format.format); > > + /* We can do any resolution thanks to crop */ > + if ((mf->width > width) || (mf->height > height)) { > + /* Restore width/height */ > + pixfmt->width = width; > + pixfmt->height = height; > + }; > + > pixfmt->field = V4L2_FIELD_NONE; > pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; > pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; > @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) > struct v4l2_subdev_format format = { > .which = V4L2_SUBDEV_FORMAT_ACTIVE, > }; > + struct v4l2_mbus_framefmt *mf = &format.format; > + struct v4l2_pix_format *pixfmt = &f->fmt.pix; > const struct dcmi_format *current_fmt; > int ret; > > @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) > if (ret) > return ret; > > - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, > + v4l2_fill_mbus_format(&format.format, pixfmt, > current_fmt->mbus_code); > ret = v4l2_subdev_call(dcmi->entity.subdev, pad, > set_fmt, NULL, &format); > if (ret < 0) > return ret; > > + /* Enable crop if sensor resolution is larger than request */ > + dcmi->do_crop = false; > + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { > + dcmi->crop.width = pixfmt->width; > + dcmi->crop.height = pixfmt->height; > + dcmi->crop.left = (mf->width - pixfmt->width) / 2; > + dcmi->crop.top = (mf->height - pixfmt->height) / 2; > + dcmi->do_crop = true; Why not implement the selection API instead? I assume that you can crop from any region of the sensor, not just the center part. Regards, Hans > + > + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", > + mf->width, mf->height, > + dcmi->crop.width, dcmi->crop.height, > + dcmi->crop.left, dcmi->crop.top); > + }; > + > dcmi->fmt = *f; > dcmi->current_fmt = current_fmt; > > ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-22 15:19 ` Hans Verkuil 0 siblings, 0 replies; 40+ messages in thread From: Hans Verkuil @ 2017-06-22 15:19 UTC (permalink / raw) To: linux-arm-kernel On 06/22/2017 05:12 PM, Hugues Fruchet wrote: > Add flexibility on supported resolutions by cropping sensor > image to fit user resolution format request. > > Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> > --- > drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c > index 75d53aa..bc5e052 100644 > --- a/drivers/media/platform/stm32/stm32-dcmi.c > +++ b/drivers/media/platform/stm32/stm32-dcmi.c > @@ -131,6 +131,8 @@ struct stm32_dcmi { > struct v4l2_async_notifier notifier; > struct dcmi_graph_entity entity; > struct v4l2_format fmt; > + struct v4l2_rect crop; > + bool do_crop; > > const struct dcmi_format **user_formats; > unsigned int num_user_formats; > @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) > if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) > val |= CR_PCKPOL; > > + if (dcmi->do_crop) { > + u32 size, start; > + > + /* Crop resolution */ > + size = ((dcmi->crop.height - 1) << 16) | > + ((dcmi->crop.width << 1) - 1); > + reg_write(dcmi->regs, DCMI_CWSIZE, size); > + > + /* Crop start point */ > + start = ((dcmi->crop.top) << 16) | > + ((dcmi->crop.left << 1)); > + reg_write(dcmi->regs, DCMI_CWSTRT, start); > + > + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", > + dcmi->crop.width, dcmi->crop.height, > + dcmi->crop.left, dcmi->crop.top); > + > + /* Enable crop */ > + val |= CR_CROP; > + }; > + > reg_write(dcmi->regs, DCMI_CR, val); > > /* Enable dcmi */ > @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, > .which = V4L2_SUBDEV_FORMAT_TRY, > }; > int ret; > + __u32 width, height; > + struct v4l2_mbus_framefmt *mf = &format.format; > > dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); > if (!dcmi_fmt) { > @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, > if (ret < 0) > return ret; > > + /* Align format on what sensor can do */ > + width = pixfmt->width; > + height = pixfmt->height; > v4l2_fill_pix_format(pixfmt, &format.format); > > + /* We can do any resolution thanks to crop */ > + if ((mf->width > width) || (mf->height > height)) { > + /* Restore width/height */ > + pixfmt->width = width; > + pixfmt->height = height; > + }; > + > pixfmt->field = V4L2_FIELD_NONE; > pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; > pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; > @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) > struct v4l2_subdev_format format = { > .which = V4L2_SUBDEV_FORMAT_ACTIVE, > }; > + struct v4l2_mbus_framefmt *mf = &format.format; > + struct v4l2_pix_format *pixfmt = &f->fmt.pix; > const struct dcmi_format *current_fmt; > int ret; > > @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) > if (ret) > return ret; > > - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, > + v4l2_fill_mbus_format(&format.format, pixfmt, > current_fmt->mbus_code); > ret = v4l2_subdev_call(dcmi->entity.subdev, pad, > set_fmt, NULL, &format); > if (ret < 0) > return ret; > > + /* Enable crop if sensor resolution is larger than request */ > + dcmi->do_crop = false; > + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { > + dcmi->crop.width = pixfmt->width; > + dcmi->crop.height = pixfmt->height; > + dcmi->crop.left = (mf->width - pixfmt->width) / 2; > + dcmi->crop.top = (mf->height - pixfmt->height) / 2; > + dcmi->do_crop = true; Why not implement the selection API instead? I assume that you can crop from any region of the sensor, not just the center part. Regards, Hans > + > + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", > + mf->width, mf->height, > + dcmi->crop.width, dcmi->crop.height, > + dcmi->crop.left, dcmi->crop.top); > + }; > + > dcmi->fmt = *f; > dcmi->current_fmt = current_fmt; > > ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 9:53 ` Hugues FRUCHET 0 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 9:53 UTC (permalink / raw) To: Hans Verkuil, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick FERTRE Hi Hans, thanks for review. Reply below. BR Hugues. On 06/22/2017 05:19 PM, Hans Verkuil wrote: > On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >> Add flexibility on supported resolutions by cropping sensor >> image to fit user resolution format request. >> >> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >> --- >> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >> 1 file changed, 53 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >> index 75d53aa..bc5e052 100644 >> --- a/drivers/media/platform/stm32/stm32-dcmi.c >> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >> @@ -131,6 +131,8 @@ struct stm32_dcmi { >> struct v4l2_async_notifier notifier; >> struct dcmi_graph_entity entity; >> struct v4l2_format fmt; >> + struct v4l2_rect crop; >> + bool do_crop; >> >> const struct dcmi_format **user_formats; >> unsigned int num_user_formats; >> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >> val |= CR_PCKPOL; >> >> + if (dcmi->do_crop) { >> + u32 size, start; >> + >> + /* Crop resolution */ >> + size = ((dcmi->crop.height - 1) << 16) | >> + ((dcmi->crop.width << 1) - 1); >> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >> + >> + /* Crop start point */ >> + start = ((dcmi->crop.top) << 16) | >> + ((dcmi->crop.left << 1)); >> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >> + >> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + >> + /* Enable crop */ >> + val |= CR_CROP; >> + }; >> + >> reg_write(dcmi->regs, DCMI_CR, val); >> >> /* Enable dcmi */ >> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> .which = V4L2_SUBDEV_FORMAT_TRY, >> }; >> int ret; >> + __u32 width, height; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> >> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >> if (!dcmi_fmt) { >> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> if (ret < 0) >> return ret; >> >> + /* Align format on what sensor can do */ >> + width = pixfmt->width; >> + height = pixfmt->height; >> v4l2_fill_pix_format(pixfmt, &format.format); >> >> + /* We can do any resolution thanks to crop */ >> + if ((mf->width > width) || (mf->height > height)) { >> + /* Restore width/height */ >> + pixfmt->width = width; >> + pixfmt->height = height; >> + }; >> + >> pixfmt->field = V4L2_FIELD_NONE; >> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> struct v4l2_subdev_format format = { >> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >> }; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >> const struct dcmi_format *current_fmt; >> int ret; >> >> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> if (ret) >> return ret; >> >> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >> + v4l2_fill_mbus_format(&format.format, pixfmt, >> current_fmt->mbus_code); >> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >> set_fmt, NULL, &format); >> if (ret < 0) >> return ret; >> >> + /* Enable crop if sensor resolution is larger than request */ >> + dcmi->do_crop = false; >> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >> + dcmi->crop.width = pixfmt->width; >> + dcmi->crop.height = pixfmt->height; >> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >> + dcmi->do_crop = true; > > Why not implement the selection API instead? I assume that you can crop from any > region of the sensor, not just the center part. The point here was to add some flexibility for user in term of resolution and also less memory consumption. For example here I want to make a 480x272 preview: - without this change: S_FMT(480x272) returns VGA (the OV9655 larger discrete resolution), then app has to capture VGA frames then crop to fit 480x272 frame buffer. - with this change: S_FMT(480x272) returns 480x272 (crop done by hardware), app can directly capture 480x272 then copy to framebuffer without any conversion. Implementation of V4L2 crop using SELECTION API could also be used, but I need to change app. More generally, with a given couple ISP+sensor, will S_FMT() return the sensor only supported resolutions ? or the supported resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop the sensor discrete resolution to fit user request) ? Hans, what are your recommendations ? > > Regards, > > Hans > >> + >> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >> + mf->width, mf->height, >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + }; >> + >> dcmi->fmt = *f; >> dcmi->current_fmt = current_fmt; >> >> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 9:53 ` Hugues FRUCHET 0 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 9:53 UTC (permalink / raw) To: linux-arm-kernel Hi Hans, thanks for review. Reply below. BR Hugues. On 06/22/2017 05:19 PM, Hans Verkuil wrote: > On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >> Add flexibility on supported resolutions by cropping sensor >> image to fit user resolution format request. >> >> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >> --- >> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >> 1 file changed, 53 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >> index 75d53aa..bc5e052 100644 >> --- a/drivers/media/platform/stm32/stm32-dcmi.c >> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >> @@ -131,6 +131,8 @@ struct stm32_dcmi { >> struct v4l2_async_notifier notifier; >> struct dcmi_graph_entity entity; >> struct v4l2_format fmt; >> + struct v4l2_rect crop; >> + bool do_crop; >> >> const struct dcmi_format **user_formats; >> unsigned int num_user_formats; >> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >> val |= CR_PCKPOL; >> >> + if (dcmi->do_crop) { >> + u32 size, start; >> + >> + /* Crop resolution */ >> + size = ((dcmi->crop.height - 1) << 16) | >> + ((dcmi->crop.width << 1) - 1); >> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >> + >> + /* Crop start point */ >> + start = ((dcmi->crop.top) << 16) | >> + ((dcmi->crop.left << 1)); >> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >> + >> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + >> + /* Enable crop */ >> + val |= CR_CROP; >> + }; >> + >> reg_write(dcmi->regs, DCMI_CR, val); >> >> /* Enable dcmi */ >> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> .which = V4L2_SUBDEV_FORMAT_TRY, >> }; >> int ret; >> + __u32 width, height; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> >> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >> if (!dcmi_fmt) { >> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> if (ret < 0) >> return ret; >> >> + /* Align format on what sensor can do */ >> + width = pixfmt->width; >> + height = pixfmt->height; >> v4l2_fill_pix_format(pixfmt, &format.format); >> >> + /* We can do any resolution thanks to crop */ >> + if ((mf->width > width) || (mf->height > height)) { >> + /* Restore width/height */ >> + pixfmt->width = width; >> + pixfmt->height = height; >> + }; >> + >> pixfmt->field = V4L2_FIELD_NONE; >> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> struct v4l2_subdev_format format = { >> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >> }; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >> const struct dcmi_format *current_fmt; >> int ret; >> >> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> if (ret) >> return ret; >> >> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >> + v4l2_fill_mbus_format(&format.format, pixfmt, >> current_fmt->mbus_code); >> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >> set_fmt, NULL, &format); >> if (ret < 0) >> return ret; >> >> + /* Enable crop if sensor resolution is larger than request */ >> + dcmi->do_crop = false; >> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >> + dcmi->crop.width = pixfmt->width; >> + dcmi->crop.height = pixfmt->height; >> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >> + dcmi->do_crop = true; > > Why not implement the selection API instead? I assume that you can crop from any > region of the sensor, not just the center part. The point here was to add some flexibility for user in term of resolution and also less memory consumption. For example here I want to make a 480x272 preview: - without this change: S_FMT(480x272) returns VGA (the OV9655 larger discrete resolution), then app has to capture VGA frames then crop to fit 480x272 frame buffer. - with this change: S_FMT(480x272) returns 480x272 (crop done by hardware), app can directly capture 480x272 then copy to framebuffer without any conversion. Implementation of V4L2 crop using SELECTION API could also be used, but I need to change app. More generally, with a given couple ISP+sensor, will S_FMT() return the sensor only supported resolutions ? or the supported resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop the sensor discrete resolution to fit user request) ? Hans, what are your recommendations ? > > Regards, > > Hans > >> + >> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >> + mf->width, mf->height, >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + }; >> + >> dcmi->fmt = *f; >> dcmi->current_fmt = current_fmt; >> >> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 9:53 ` Hugues FRUCHET 0 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 9:53 UTC (permalink / raw) To: Hans Verkuil, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick FERTRE Hi Hans, thanks for review. Reply below. BR Hugues. On 06/22/2017 05:19 PM, Hans Verkuil wrote: > On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >> Add flexibility on supported resolutions by cropping sensor >> image to fit user resolution format request. >> >> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >> --- >> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >> 1 file changed, 53 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >> index 75d53aa..bc5e052 100644 >> --- a/drivers/media/platform/stm32/stm32-dcmi.c >> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >> @@ -131,6 +131,8 @@ struct stm32_dcmi { >> struct v4l2_async_notifier notifier; >> struct dcmi_graph_entity entity; >> struct v4l2_format fmt; >> + struct v4l2_rect crop; >> + bool do_crop; >> >> const struct dcmi_format **user_formats; >> unsigned int num_user_formats; >> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >> val |= CR_PCKPOL; >> >> + if (dcmi->do_crop) { >> + u32 size, start; >> + >> + /* Crop resolution */ >> + size = ((dcmi->crop.height - 1) << 16) | >> + ((dcmi->crop.width << 1) - 1); >> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >> + >> + /* Crop start point */ >> + start = ((dcmi->crop.top) << 16) | >> + ((dcmi->crop.left << 1)); >> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >> + >> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + >> + /* Enable crop */ >> + val |= CR_CROP; >> + }; >> + >> reg_write(dcmi->regs, DCMI_CR, val); >> >> /* Enable dcmi */ >> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> .which = V4L2_SUBDEV_FORMAT_TRY, >> }; >> int ret; >> + __u32 width, height; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> >> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >> if (!dcmi_fmt) { >> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> if (ret < 0) >> return ret; >> >> + /* Align format on what sensor can do */ >> + width = pixfmt->width; >> + height = pixfmt->height; >> v4l2_fill_pix_format(pixfmt, &format.format); >> >> + /* We can do any resolution thanks to crop */ >> + if ((mf->width > width) || (mf->height > height)) { >> + /* Restore width/height */ >> + pixfmt->width = width; >> + pixfmt->height = height; >> + }; >> + >> pixfmt->field = V4L2_FIELD_NONE; >> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> struct v4l2_subdev_format format = { >> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >> }; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >> const struct dcmi_format *current_fmt; >> int ret; >> >> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> if (ret) >> return ret; >> >> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >> + v4l2_fill_mbus_format(&format.format, pixfmt, >> current_fmt->mbus_code); >> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >> set_fmt, NULL, &format); >> if (ret < 0) >> return ret; >> >> + /* Enable crop if sensor resolution is larger than request */ >> + dcmi->do_crop = false; >> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >> + dcmi->crop.width = pixfmt->width; >> + dcmi->crop.height = pixfmt->height; >> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >> + dcmi->do_crop = true; > > Why not implement the selection API instead? I assume that you can crop from any > region of the sensor, not just the center part. The point here was to add some flexibility for user in term of resolution and also less memory consumption. For example here I want to make a 480x272 preview: - without this change: S_FMT(480x272) returns VGA (the OV9655 larger discrete resolution), then app has to capture VGA frames then crop to fit 480x272 frame buffer. - with this change: S_FMT(480x272) returns 480x272 (crop done by hardware), app can directly capture 480x272 then copy to framebuffer without any conversion. Implementation of V4L2 crop using SELECTION API could also be used, but I need to change app. More generally, with a given couple ISP+sensor, will S_FMT() return the sensor only supported resolutions ? or the supported resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop the sensor discrete resolution to fit user request) ? Hans, what are your recommendations ? > > Regards, > > Hans > >> + >> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >> + mf->width, mf->height, >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + }; >> + >> dcmi->fmt = *f; >> dcmi->current_fmt = current_fmt; >> >> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 9:53 ` Hugues FRUCHET 0 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 9:53 UTC (permalink / raw) To: Hans Verkuil, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-media-u79uwXL29TY76Z2rM5mHXA, Benjamin Gaignard, Yannick FERTRE Hi Hans, thanks for review. Reply below. BR Hugues. On 06/22/2017 05:19 PM, Hans Verkuil wrote: > On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >> Add flexibility on supported resolutions by cropping sensor >> image to fit user resolution format request. >> >> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >> --- >> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >> 1 file changed, 53 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >> index 75d53aa..bc5e052 100644 >> --- a/drivers/media/platform/stm32/stm32-dcmi.c >> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >> @@ -131,6 +131,8 @@ struct stm32_dcmi { >> struct v4l2_async_notifier notifier; >> struct dcmi_graph_entity entity; >> struct v4l2_format fmt; >> + struct v4l2_rect crop; >> + bool do_crop; >> >> const struct dcmi_format **user_formats; >> unsigned int num_user_formats; >> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >> val |= CR_PCKPOL; >> >> + if (dcmi->do_crop) { >> + u32 size, start; >> + >> + /* Crop resolution */ >> + size = ((dcmi->crop.height - 1) << 16) | >> + ((dcmi->crop.width << 1) - 1); >> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >> + >> + /* Crop start point */ >> + start = ((dcmi->crop.top) << 16) | >> + ((dcmi->crop.left << 1)); >> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >> + >> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + >> + /* Enable crop */ >> + val |= CR_CROP; >> + }; >> + >> reg_write(dcmi->regs, DCMI_CR, val); >> >> /* Enable dcmi */ >> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> .which = V4L2_SUBDEV_FORMAT_TRY, >> }; >> int ret; >> + __u32 width, height; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> >> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >> if (!dcmi_fmt) { >> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >> if (ret < 0) >> return ret; >> >> + /* Align format on what sensor can do */ >> + width = pixfmt->width; >> + height = pixfmt->height; >> v4l2_fill_pix_format(pixfmt, &format.format); >> >> + /* We can do any resolution thanks to crop */ >> + if ((mf->width > width) || (mf->height > height)) { >> + /* Restore width/height */ >> + pixfmt->width = width; >> + pixfmt->height = height; >> + }; >> + >> pixfmt->field = V4L2_FIELD_NONE; >> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> struct v4l2_subdev_format format = { >> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >> }; >> + struct v4l2_mbus_framefmt *mf = &format.format; >> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >> const struct dcmi_format *current_fmt; >> int ret; >> >> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >> if (ret) >> return ret; >> >> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >> + v4l2_fill_mbus_format(&format.format, pixfmt, >> current_fmt->mbus_code); >> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >> set_fmt, NULL, &format); >> if (ret < 0) >> return ret; >> >> + /* Enable crop if sensor resolution is larger than request */ >> + dcmi->do_crop = false; >> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >> + dcmi->crop.width = pixfmt->width; >> + dcmi->crop.height = pixfmt->height; >> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >> + dcmi->do_crop = true; > > Why not implement the selection API instead? I assume that you can crop from any > region of the sensor, not just the center part. The point here was to add some flexibility for user in term of resolution and also less memory consumption. For example here I want to make a 480x272 preview: - without this change: S_FMT(480x272) returns VGA (the OV9655 larger discrete resolution), then app has to capture VGA frames then crop to fit 480x272 frame buffer. - with this change: S_FMT(480x272) returns 480x272 (crop done by hardware), app can directly capture 480x272 then copy to framebuffer without any conversion. Implementation of V4L2 crop using SELECTION API could also be used, but I need to change app. More generally, with a given couple ISP+sensor, will S_FMT() return the sensor only supported resolutions ? or the supported resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop the sensor discrete resolution to fit user request) ? Hans, what are your recommendations ? > > Regards, > > Hans > >> + >> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >> + mf->width, mf->height, >> + dcmi->crop.width, dcmi->crop.height, >> + dcmi->crop.left, dcmi->crop.top); >> + }; >> + >> dcmi->fmt = *f; >> dcmi->current_fmt = current_fmt; >> >> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 2017-06-26 9:53 ` Hugues FRUCHET (?) @ 2017-06-26 10:07 ` Hans Verkuil -1 siblings, 0 replies; 40+ messages in thread From: Hans Verkuil @ 2017-06-26 10:07 UTC (permalink / raw) To: Hugues FRUCHET, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick FERTRE On 26/06/17 11:53, Hugues FRUCHET wrote: > Hi Hans, thanks for review. > > Reply below. > > BR > Hugues. > > On 06/22/2017 05:19 PM, Hans Verkuil wrote: >> On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >>> Add flexibility on supported resolutions by cropping sensor >>> image to fit user resolution format request. >>> >>> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >>> --- >>> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >>> 1 file changed, 53 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >>> index 75d53aa..bc5e052 100644 >>> --- a/drivers/media/platform/stm32/stm32-dcmi.c >>> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >>> @@ -131,6 +131,8 @@ struct stm32_dcmi { >>> struct v4l2_async_notifier notifier; >>> struct dcmi_graph_entity entity; >>> struct v4l2_format fmt; >>> + struct v4l2_rect crop; >>> + bool do_crop; >>> >>> const struct dcmi_format **user_formats; >>> unsigned int num_user_formats; >>> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >>> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >>> val |= CR_PCKPOL; >>> >>> + if (dcmi->do_crop) { >>> + u32 size, start; >>> + >>> + /* Crop resolution */ >>> + size = ((dcmi->crop.height - 1) << 16) | >>> + ((dcmi->crop.width << 1) - 1); >>> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >>> + >>> + /* Crop start point */ >>> + start = ((dcmi->crop.top) << 16) | >>> + ((dcmi->crop.left << 1)); >>> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >>> + >>> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >>> + dcmi->crop.width, dcmi->crop.height, >>> + dcmi->crop.left, dcmi->crop.top); >>> + >>> + /* Enable crop */ >>> + val |= CR_CROP; >>> + }; >>> + >>> reg_write(dcmi->regs, DCMI_CR, val); >>> >>> /* Enable dcmi */ >>> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>> .which = V4L2_SUBDEV_FORMAT_TRY, >>> }; >>> int ret; >>> + __u32 width, height; >>> + struct v4l2_mbus_framefmt *mf = &format.format; >>> >>> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >>> if (!dcmi_fmt) { >>> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>> if (ret < 0) >>> return ret; >>> >>> + /* Align format on what sensor can do */ >>> + width = pixfmt->width; >>> + height = pixfmt->height; >>> v4l2_fill_pix_format(pixfmt, &format.format); >>> >>> + /* We can do any resolution thanks to crop */ >>> + if ((mf->width > width) || (mf->height > height)) { >>> + /* Restore width/height */ >>> + pixfmt->width = width; >>> + pixfmt->height = height; >>> + }; >>> + >>> pixfmt->field = V4L2_FIELD_NONE; >>> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >>> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >>> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>> struct v4l2_subdev_format format = { >>> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >>> }; >>> + struct v4l2_mbus_framefmt *mf = &format.format; >>> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >>> const struct dcmi_format *current_fmt; >>> int ret; >>> >>> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>> if (ret) >>> return ret; >>> >>> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >>> + v4l2_fill_mbus_format(&format.format, pixfmt, >>> current_fmt->mbus_code); >>> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >>> set_fmt, NULL, &format); >>> if (ret < 0) >>> return ret; >>> >>> + /* Enable crop if sensor resolution is larger than request */ >>> + dcmi->do_crop = false; >>> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >>> + dcmi->crop.width = pixfmt->width; >>> + dcmi->crop.height = pixfmt->height; >>> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >>> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >>> + dcmi->do_crop = true; >> >> Why not implement the selection API instead? I assume that you can crop from any >> region of the sensor, not just the center part. > > The point here was to add some flexibility for user in term of > resolution and also less memory consumption. > For example here I want to make a 480x272 preview: > - without this change: S_FMT(480x272) returns VGA (the OV9655 larger > discrete resolution), then app has to capture VGA frames then crop to > fit 480x272 frame buffer. > - with this change: S_FMT(480x272) returns 480x272 (crop done by > hardware), app can directly capture 480x272 then copy to framebuffer > without any conversion. > > Implementation of V4L2 crop using SELECTION API could also be used, > but I need to change app. > > More generally, with a given couple ISP+sensor, will S_FMT() > return the sensor only supported resolutions ? or the supported > resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop > the sensor discrete resolution to fit user request) ? > > Hans, what are your recommendations ? This is not the way the V4L2 API works. Sensors report their supported resolutions through the ENUM_FRAMESIZES (and the related ENUM_FRAMEINTERVALS) ioctls. With S_FMT you pick the resolution you want. If you then want to crop the driver should implement the selection API (this will also automatically enable the G/S_CROP/CROPCAP ioctls) so the application can select which part of the image should be cropped. Assuming there is no scaler then after cropping the format size will be reduced to the size of the cropped image. That's in a nutshell how these ioctls relate to one another. Regards, Hans > >> >> Regards, >> >> Hans >> >>> + >>> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >>> + mf->width, mf->height, >>> + dcmi->crop.width, dcmi->crop.height, >>> + dcmi->crop.left, dcmi->crop.top); >>> + }; >>> + >>> dcmi->fmt = *f; >>> dcmi->current_fmt = current_fmt; >>> >>> ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 10:07 ` Hans Verkuil 0 siblings, 0 replies; 40+ messages in thread From: Hans Verkuil @ 2017-06-26 10:07 UTC (permalink / raw) To: linux-arm-kernel On 26/06/17 11:53, Hugues FRUCHET wrote: > Hi Hans, thanks for review. > > Reply below. > > BR > Hugues. > > On 06/22/2017 05:19 PM, Hans Verkuil wrote: >> On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >>> Add flexibility on supported resolutions by cropping sensor >>> image to fit user resolution format request. >>> >>> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >>> --- >>> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >>> 1 file changed, 53 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >>> index 75d53aa..bc5e052 100644 >>> --- a/drivers/media/platform/stm32/stm32-dcmi.c >>> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >>> @@ -131,6 +131,8 @@ struct stm32_dcmi { >>> struct v4l2_async_notifier notifier; >>> struct dcmi_graph_entity entity; >>> struct v4l2_format fmt; >>> + struct v4l2_rect crop; >>> + bool do_crop; >>> >>> const struct dcmi_format **user_formats; >>> unsigned int num_user_formats; >>> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >>> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >>> val |= CR_PCKPOL; >>> >>> + if (dcmi->do_crop) { >>> + u32 size, start; >>> + >>> + /* Crop resolution */ >>> + size = ((dcmi->crop.height - 1) << 16) | >>> + ((dcmi->crop.width << 1) - 1); >>> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >>> + >>> + /* Crop start point */ >>> + start = ((dcmi->crop.top) << 16) | >>> + ((dcmi->crop.left << 1)); >>> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >>> + >>> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >>> + dcmi->crop.width, dcmi->crop.height, >>> + dcmi->crop.left, dcmi->crop.top); >>> + >>> + /* Enable crop */ >>> + val |= CR_CROP; >>> + }; >>> + >>> reg_write(dcmi->regs, DCMI_CR, val); >>> >>> /* Enable dcmi */ >>> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>> .which = V4L2_SUBDEV_FORMAT_TRY, >>> }; >>> int ret; >>> + __u32 width, height; >>> + struct v4l2_mbus_framefmt *mf = &format.format; >>> >>> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >>> if (!dcmi_fmt) { >>> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>> if (ret < 0) >>> return ret; >>> >>> + /* Align format on what sensor can do */ >>> + width = pixfmt->width; >>> + height = pixfmt->height; >>> v4l2_fill_pix_format(pixfmt, &format.format); >>> >>> + /* We can do any resolution thanks to crop */ >>> + if ((mf->width > width) || (mf->height > height)) { >>> + /* Restore width/height */ >>> + pixfmt->width = width; >>> + pixfmt->height = height; >>> + }; >>> + >>> pixfmt->field = V4L2_FIELD_NONE; >>> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >>> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >>> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>> struct v4l2_subdev_format format = { >>> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >>> }; >>> + struct v4l2_mbus_framefmt *mf = &format.format; >>> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >>> const struct dcmi_format *current_fmt; >>> int ret; >>> >>> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>> if (ret) >>> return ret; >>> >>> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >>> + v4l2_fill_mbus_format(&format.format, pixfmt, >>> current_fmt->mbus_code); >>> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >>> set_fmt, NULL, &format); >>> if (ret < 0) >>> return ret; >>> >>> + /* Enable crop if sensor resolution is larger than request */ >>> + dcmi->do_crop = false; >>> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >>> + dcmi->crop.width = pixfmt->width; >>> + dcmi->crop.height = pixfmt->height; >>> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >>> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >>> + dcmi->do_crop = true; >> >> Why not implement the selection API instead? I assume that you can crop from any >> region of the sensor, not just the center part. > > The point here was to add some flexibility for user in term of > resolution and also less memory consumption. > For example here I want to make a 480x272 preview: > - without this change: S_FMT(480x272) returns VGA (the OV9655 larger > discrete resolution), then app has to capture VGA frames then crop to > fit 480x272 frame buffer. > - with this change: S_FMT(480x272) returns 480x272 (crop done by > hardware), app can directly capture 480x272 then copy to framebuffer > without any conversion. > > Implementation of V4L2 crop using SELECTION API could also be used, > but I need to change app. > > More generally, with a given couple ISP+sensor, will S_FMT() > return the sensor only supported resolutions ? or the supported > resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop > the sensor discrete resolution to fit user request) ? > > Hans, what are your recommendations ? This is not the way the V4L2 API works. Sensors report their supported resolutions through the ENUM_FRAMESIZES (and the related ENUM_FRAMEINTERVALS) ioctls. With S_FMT you pick the resolution you want. If you then want to crop the driver should implement the selection API (this will also automatically enable the G/S_CROP/CROPCAP ioctls) so the application can select which part of the image should be cropped. Assuming there is no scaler then after cropping the format size will be reduced to the size of the cropped image. That's in a nutshell how these ioctls relate to one another. Regards, Hans > >> >> Regards, >> >> Hans >> >>> + >>> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >>> + mf->width, mf->height, >>> + dcmi->crop.width, dcmi->crop.height, >>> + dcmi->crop.left, dcmi->crop.top); >>> + }; >>> + >>> dcmi->fmt = *f; >>> dcmi->current_fmt = current_fmt; >>> >>> ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 10:07 ` Hans Verkuil 0 siblings, 0 replies; 40+ messages in thread From: Hans Verkuil @ 2017-06-26 10:07 UTC (permalink / raw) To: Hugues FRUCHET, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick FERTRE On 26/06/17 11:53, Hugues FRUCHET wrote: > Hi Hans, thanks for review. > > Reply below. > > BR > Hugues. > > On 06/22/2017 05:19 PM, Hans Verkuil wrote: >> On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >>> Add flexibility on supported resolutions by cropping sensor >>> image to fit user resolution format request. >>> >>> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >>> --- >>> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >>> 1 file changed, 53 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >>> index 75d53aa..bc5e052 100644 >>> --- a/drivers/media/platform/stm32/stm32-dcmi.c >>> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >>> @@ -131,6 +131,8 @@ struct stm32_dcmi { >>> struct v4l2_async_notifier notifier; >>> struct dcmi_graph_entity entity; >>> struct v4l2_format fmt; >>> + struct v4l2_rect crop; >>> + bool do_crop; >>> >>> const struct dcmi_format **user_formats; >>> unsigned int num_user_formats; >>> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >>> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >>> val |= CR_PCKPOL; >>> >>> + if (dcmi->do_crop) { >>> + u32 size, start; >>> + >>> + /* Crop resolution */ >>> + size = ((dcmi->crop.height - 1) << 16) | >>> + ((dcmi->crop.width << 1) - 1); >>> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >>> + >>> + /* Crop start point */ >>> + start = ((dcmi->crop.top) << 16) | >>> + ((dcmi->crop.left << 1)); >>> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >>> + >>> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >>> + dcmi->crop.width, dcmi->crop.height, >>> + dcmi->crop.left, dcmi->crop.top); >>> + >>> + /* Enable crop */ >>> + val |= CR_CROP; >>> + }; >>> + >>> reg_write(dcmi->regs, DCMI_CR, val); >>> >>> /* Enable dcmi */ >>> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>> .which = V4L2_SUBDEV_FORMAT_TRY, >>> }; >>> int ret; >>> + __u32 width, height; >>> + struct v4l2_mbus_framefmt *mf = &format.format; >>> >>> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >>> if (!dcmi_fmt) { >>> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>> if (ret < 0) >>> return ret; >>> >>> + /* Align format on what sensor can do */ >>> + width = pixfmt->width; >>> + height = pixfmt->height; >>> v4l2_fill_pix_format(pixfmt, &format.format); >>> >>> + /* We can do any resolution thanks to crop */ >>> + if ((mf->width > width) || (mf->height > height)) { >>> + /* Restore width/height */ >>> + pixfmt->width = width; >>> + pixfmt->height = height; >>> + }; >>> + >>> pixfmt->field = V4L2_FIELD_NONE; >>> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >>> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >>> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>> struct v4l2_subdev_format format = { >>> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >>> }; >>> + struct v4l2_mbus_framefmt *mf = &format.format; >>> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >>> const struct dcmi_format *current_fmt; >>> int ret; >>> >>> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>> if (ret) >>> return ret; >>> >>> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >>> + v4l2_fill_mbus_format(&format.format, pixfmt, >>> current_fmt->mbus_code); >>> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >>> set_fmt, NULL, &format); >>> if (ret < 0) >>> return ret; >>> >>> + /* Enable crop if sensor resolution is larger than request */ >>> + dcmi->do_crop = false; >>> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >>> + dcmi->crop.width = pixfmt->width; >>> + dcmi->crop.height = pixfmt->height; >>> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >>> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >>> + dcmi->do_crop = true; >> >> Why not implement the selection API instead? I assume that you can crop from any >> region of the sensor, not just the center part. > > The point here was to add some flexibility for user in term of > resolution and also less memory consumption. > For example here I want to make a 480x272 preview: > - without this change: S_FMT(480x272) returns VGA (the OV9655 larger > discrete resolution), then app has to capture VGA frames then crop to > fit 480x272 frame buffer. > - with this change: S_FMT(480x272) returns 480x272 (crop done by > hardware), app can directly capture 480x272 then copy to framebuffer > without any conversion. > > Implementation of V4L2 crop using SELECTION API could also be used, > but I need to change app. > > More generally, with a given couple ISP+sensor, will S_FMT() > return the sensor only supported resolutions ? or the supported > resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop > the sensor discrete resolution to fit user request) ? > > Hans, what are your recommendations ? This is not the way the V4L2 API works. Sensors report their supported resolutions through the ENUM_FRAMESIZES (and the related ENUM_FRAMEINTERVALS) ioctls. With S_FMT you pick the resolution you want. If you then want to crop the driver should implement the selection API (this will also automatically enable the G/S_CROP/CROPCAP ioctls) so the application can select which part of the image should be cropped. Assuming there is no scaler then after cropping the format size will be reduced to the size of the cropped image. That's in a nutshell how these ioctls relate to one another. Regards, Hans > >> >> Regards, >> >> Hans >> >>> + >>> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >>> + mf->width, mf->height, >>> + dcmi->crop.width, dcmi->crop.height, >>> + dcmi->crop.left, dcmi->crop.top); >>> + }; >>> + >>> dcmi->fmt = *f; >>> dcmi->current_fmt = current_fmt; >>> >>> ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 2017-06-26 10:07 ` Hans Verkuil (?) (?) @ 2017-06-26 14:41 ` Hugues FRUCHET -1 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 14:41 UTC (permalink / raw) To: Hans Verkuil, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick FERTRE On 06/26/2017 12:07 PM, Hans Verkuil wrote: > On 26/06/17 11:53, Hugues FRUCHET wrote: >> Hi Hans, thanks for review. >> >> Reply below. >> >> BR >> Hugues. >> >> On 06/22/2017 05:19 PM, Hans Verkuil wrote: >>> On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >>>> Add flexibility on supported resolutions by cropping sensor >>>> image to fit user resolution format request. >>>> >>>> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >>>> --- >>>> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >>>> 1 file changed, 53 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >>>> index 75d53aa..bc5e052 100644 >>>> --- a/drivers/media/platform/stm32/stm32-dcmi.c >>>> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >>>> @@ -131,6 +131,8 @@ struct stm32_dcmi { >>>> struct v4l2_async_notifier notifier; >>>> struct dcmi_graph_entity entity; >>>> struct v4l2_format fmt; >>>> + struct v4l2_rect crop; >>>> + bool do_crop; >>>> >>>> const struct dcmi_format **user_formats; >>>> unsigned int num_user_formats; >>>> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >>>> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >>>> val |= CR_PCKPOL; >>>> >>>> + if (dcmi->do_crop) { >>>> + u32 size, start; >>>> + >>>> + /* Crop resolution */ >>>> + size = ((dcmi->crop.height - 1) << 16) | >>>> + ((dcmi->crop.width << 1) - 1); >>>> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >>>> + >>>> + /* Crop start point */ >>>> + start = ((dcmi->crop.top) << 16) | >>>> + ((dcmi->crop.left << 1)); >>>> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >>>> + >>>> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + >>>> + /* Enable crop */ >>>> + val |= CR_CROP; >>>> + }; >>>> + >>>> reg_write(dcmi->regs, DCMI_CR, val); >>>> >>>> /* Enable dcmi */ >>>> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> .which = V4L2_SUBDEV_FORMAT_TRY, >>>> }; >>>> int ret; >>>> + __u32 width, height; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> >>>> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >>>> if (!dcmi_fmt) { >>>> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Align format on what sensor can do */ >>>> + width = pixfmt->width; >>>> + height = pixfmt->height; >>>> v4l2_fill_pix_format(pixfmt, &format.format); >>>> >>>> + /* We can do any resolution thanks to crop */ >>>> + if ((mf->width > width) || (mf->height > height)) { >>>> + /* Restore width/height */ >>>> + pixfmt->width = width; >>>> + pixfmt->height = height; >>>> + }; >>>> + >>>> pixfmt->field = V4L2_FIELD_NONE; >>>> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >>>> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >>>> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> struct v4l2_subdev_format format = { >>>> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >>>> }; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >>>> const struct dcmi_format *current_fmt; >>>> int ret; >>>> >>>> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> if (ret) >>>> return ret; >>>> >>>> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >>>> + v4l2_fill_mbus_format(&format.format, pixfmt, >>>> current_fmt->mbus_code); >>>> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >>>> set_fmt, NULL, &format); >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Enable crop if sensor resolution is larger than request */ >>>> + dcmi->do_crop = false; >>>> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >>>> + dcmi->crop.width = pixfmt->width; >>>> + dcmi->crop.height = pixfmt->height; >>>> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >>>> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >>>> + dcmi->do_crop = true; >>> >>> Why not implement the selection API instead? I assume that you can crop from any >>> region of the sensor, not just the center part. >> >> The point here was to add some flexibility for user in term of >> resolution and also less memory consumption. >> For example here I want to make a 480x272 preview: >> - without this change: S_FMT(480x272) returns VGA (the OV9655 larger >> discrete resolution), then app has to capture VGA frames then crop to >> fit 480x272 frame buffer. >> - with this change: S_FMT(480x272) returns 480x272 (crop done by >> hardware), app can directly capture 480x272 then copy to framebuffer >> without any conversion. >> >> Implementation of V4L2 crop using SELECTION API could also be used, >> but I need to change app. >> >> More generally, with a given couple ISP+sensor, will S_FMT() >> return the sensor only supported resolutions ? or the supported >> resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop >> the sensor discrete resolution to fit user request) ? >> >> Hans, what are your recommendations ? > > This is not the way the V4L2 API works. > > Sensors report their supported resolutions through the ENUM_FRAMESIZES > (and the related ENUM_FRAMEINTERVALS) ioctls. > > With S_FMT you pick the resolution you want. > > If you then want to crop the driver should implement the selection API > (this will also automatically enable the G/S_CROP/CROPCAP ioctls) so the > application can select which part of the image should be cropped. Assuming > there is no scaler then after cropping the format size will be reduced > to the size of the cropped image. > > That's in a nutshell how these ioctls relate to one another. > > Regards, > > Hans > Ok, crystal clear, I'll implement selection API so. BR, Hugues. >> >>> >>> Regards, >>> >>> Hans >>> >>>> + >>>> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >>>> + mf->width, mf->height, >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + }; >>>> + >>>> dcmi->fmt = *f; >>>> dcmi->current_fmt = current_fmt; >>>> >>>> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 14:41 ` Hugues FRUCHET 0 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 14:41 UTC (permalink / raw) To: linux-arm-kernel On 06/26/2017 12:07 PM, Hans Verkuil wrote: > On 26/06/17 11:53, Hugues FRUCHET wrote: >> Hi Hans, thanks for review. >> >> Reply below. >> >> BR >> Hugues. >> >> On 06/22/2017 05:19 PM, Hans Verkuil wrote: >>> On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >>>> Add flexibility on supported resolutions by cropping sensor >>>> image to fit user resolution format request. >>>> >>>> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >>>> --- >>>> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >>>> 1 file changed, 53 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >>>> index 75d53aa..bc5e052 100644 >>>> --- a/drivers/media/platform/stm32/stm32-dcmi.c >>>> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >>>> @@ -131,6 +131,8 @@ struct stm32_dcmi { >>>> struct v4l2_async_notifier notifier; >>>> struct dcmi_graph_entity entity; >>>> struct v4l2_format fmt; >>>> + struct v4l2_rect crop; >>>> + bool do_crop; >>>> >>>> const struct dcmi_format **user_formats; >>>> unsigned int num_user_formats; >>>> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >>>> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >>>> val |= CR_PCKPOL; >>>> >>>> + if (dcmi->do_crop) { >>>> + u32 size, start; >>>> + >>>> + /* Crop resolution */ >>>> + size = ((dcmi->crop.height - 1) << 16) | >>>> + ((dcmi->crop.width << 1) - 1); >>>> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >>>> + >>>> + /* Crop start point */ >>>> + start = ((dcmi->crop.top) << 16) | >>>> + ((dcmi->crop.left << 1)); >>>> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >>>> + >>>> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + >>>> + /* Enable crop */ >>>> + val |= CR_CROP; >>>> + }; >>>> + >>>> reg_write(dcmi->regs, DCMI_CR, val); >>>> >>>> /* Enable dcmi */ >>>> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> .which = V4L2_SUBDEV_FORMAT_TRY, >>>> }; >>>> int ret; >>>> + __u32 width, height; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> >>>> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >>>> if (!dcmi_fmt) { >>>> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Align format on what sensor can do */ >>>> + width = pixfmt->width; >>>> + height = pixfmt->height; >>>> v4l2_fill_pix_format(pixfmt, &format.format); >>>> >>>> + /* We can do any resolution thanks to crop */ >>>> + if ((mf->width > width) || (mf->height > height)) { >>>> + /* Restore width/height */ >>>> + pixfmt->width = width; >>>> + pixfmt->height = height; >>>> + }; >>>> + >>>> pixfmt->field = V4L2_FIELD_NONE; >>>> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >>>> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >>>> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> struct v4l2_subdev_format format = { >>>> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >>>> }; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >>>> const struct dcmi_format *current_fmt; >>>> int ret; >>>> >>>> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> if (ret) >>>> return ret; >>>> >>>> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >>>> + v4l2_fill_mbus_format(&format.format, pixfmt, >>>> current_fmt->mbus_code); >>>> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >>>> set_fmt, NULL, &format); >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Enable crop if sensor resolution is larger than request */ >>>> + dcmi->do_crop = false; >>>> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >>>> + dcmi->crop.width = pixfmt->width; >>>> + dcmi->crop.height = pixfmt->height; >>>> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >>>> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >>>> + dcmi->do_crop = true; >>> >>> Why not implement the selection API instead? I assume that you can crop from any >>> region of the sensor, not just the center part. >> >> The point here was to add some flexibility for user in term of >> resolution and also less memory consumption. >> For example here I want to make a 480x272 preview: >> - without this change: S_FMT(480x272) returns VGA (the OV9655 larger >> discrete resolution), then app has to capture VGA frames then crop to >> fit 480x272 frame buffer. >> - with this change: S_FMT(480x272) returns 480x272 (crop done by >> hardware), app can directly capture 480x272 then copy to framebuffer >> without any conversion. >> >> Implementation of V4L2 crop using SELECTION API could also be used, >> but I need to change app. >> >> More generally, with a given couple ISP+sensor, will S_FMT() >> return the sensor only supported resolutions ? or the supported >> resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop >> the sensor discrete resolution to fit user request) ? >> >> Hans, what are your recommendations ? > > This is not the way the V4L2 API works. > > Sensors report their supported resolutions through the ENUM_FRAMESIZES > (and the related ENUM_FRAMEINTERVALS) ioctls. > > With S_FMT you pick the resolution you want. > > If you then want to crop the driver should implement the selection API > (this will also automatically enable the G/S_CROP/CROPCAP ioctls) so the > application can select which part of the image should be cropped. Assuming > there is no scaler then after cropping the format size will be reduced > to the size of the cropped image. > > That's in a nutshell how these ioctls relate to one another. > > Regards, > > Hans > Ok, crystal clear, I'll implement selection API so. BR, Hugues. >> >>> >>> Regards, >>> >>> Hans >>> >>>> + >>>> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >>>> + mf->width, mf->height, >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + }; >>>> + >>>> dcmi->fmt = *f; >>>> dcmi->current_fmt = current_fmt; >>>> >>>> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 14:41 ` Hugues FRUCHET 0 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 14:41 UTC (permalink / raw) To: Hans Verkuil, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick FERTRE On 06/26/2017 12:07 PM, Hans Verkuil wrote: > On 26/06/17 11:53, Hugues FRUCHET wrote: >> Hi Hans, thanks for review. >> >> Reply below. >> >> BR >> Hugues. >> >> On 06/22/2017 05:19 PM, Hans Verkuil wrote: >>> On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >>>> Add flexibility on supported resolutions by cropping sensor >>>> image to fit user resolution format request. >>>> >>>> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >>>> --- >>>> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >>>> 1 file changed, 53 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >>>> index 75d53aa..bc5e052 100644 >>>> --- a/drivers/media/platform/stm32/stm32-dcmi.c >>>> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >>>> @@ -131,6 +131,8 @@ struct stm32_dcmi { >>>> struct v4l2_async_notifier notifier; >>>> struct dcmi_graph_entity entity; >>>> struct v4l2_format fmt; >>>> + struct v4l2_rect crop; >>>> + bool do_crop; >>>> >>>> const struct dcmi_format **user_formats; >>>> unsigned int num_user_formats; >>>> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >>>> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >>>> val |= CR_PCKPOL; >>>> >>>> + if (dcmi->do_crop) { >>>> + u32 size, start; >>>> + >>>> + /* Crop resolution */ >>>> + size = ((dcmi->crop.height - 1) << 16) | >>>> + ((dcmi->crop.width << 1) - 1); >>>> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >>>> + >>>> + /* Crop start point */ >>>> + start = ((dcmi->crop.top) << 16) | >>>> + ((dcmi->crop.left << 1)); >>>> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >>>> + >>>> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + >>>> + /* Enable crop */ >>>> + val |= CR_CROP; >>>> + }; >>>> + >>>> reg_write(dcmi->regs, DCMI_CR, val); >>>> >>>> /* Enable dcmi */ >>>> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> .which = V4L2_SUBDEV_FORMAT_TRY, >>>> }; >>>> int ret; >>>> + __u32 width, height; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> >>>> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >>>> if (!dcmi_fmt) { >>>> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Align format on what sensor can do */ >>>> + width = pixfmt->width; >>>> + height = pixfmt->height; >>>> v4l2_fill_pix_format(pixfmt, &format.format); >>>> >>>> + /* We can do any resolution thanks to crop */ >>>> + if ((mf->width > width) || (mf->height > height)) { >>>> + /* Restore width/height */ >>>> + pixfmt->width = width; >>>> + pixfmt->height = height; >>>> + }; >>>> + >>>> pixfmt->field = V4L2_FIELD_NONE; >>>> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >>>> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >>>> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> struct v4l2_subdev_format format = { >>>> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >>>> }; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >>>> const struct dcmi_format *current_fmt; >>>> int ret; >>>> >>>> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> if (ret) >>>> return ret; >>>> >>>> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >>>> + v4l2_fill_mbus_format(&format.format, pixfmt, >>>> current_fmt->mbus_code); >>>> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >>>> set_fmt, NULL, &format); >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Enable crop if sensor resolution is larger than request */ >>>> + dcmi->do_crop = false; >>>> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >>>> + dcmi->crop.width = pixfmt->width; >>>> + dcmi->crop.height = pixfmt->height; >>>> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >>>> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >>>> + dcmi->do_crop = true; >>> >>> Why not implement the selection API instead? I assume that you can crop from any >>> region of the sensor, not just the center part. >> >> The point here was to add some flexibility for user in term of >> resolution and also less memory consumption. >> For example here I want to make a 480x272 preview: >> - without this change: S_FMT(480x272) returns VGA (the OV9655 larger >> discrete resolution), then app has to capture VGA frames then crop to >> fit 480x272 frame buffer. >> - with this change: S_FMT(480x272) returns 480x272 (crop done by >> hardware), app can directly capture 480x272 then copy to framebuffer >> without any conversion. >> >> Implementation of V4L2 crop using SELECTION API could also be used, >> but I need to change app. >> >> More generally, with a given couple ISP+sensor, will S_FMT() >> return the sensor only supported resolutions ? or the supported >> resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop >> the sensor discrete resolution to fit user request) ? >> >> Hans, what are your recommendations ? > > This is not the way the V4L2 API works. > > Sensors report their supported resolutions through the ENUM_FRAMESIZES > (and the related ENUM_FRAMEINTERVALS) ioctls. > > With S_FMT you pick the resolution you want. > > If you then want to crop the driver should implement the selection API > (this will also automatically enable the G/S_CROP/CROPCAP ioctls) so the > application can select which part of the image should be cropped. Assuming > there is no scaler then after cropping the format size will be reduced > to the size of the cropped image. > > That's in a nutshell how these ioctls relate to one another. > > Regards, > > Hans > Ok, crystal clear, I'll implement selection API so. BR, Hugues. >> >>> >>> Regards, >>> >>> Hans >>> >>>> + >>>> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >>>> + mf->width, mf->height, >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + }; >>>> + >>>> dcmi->fmt = *f; >>>> dcmi->current_fmt = current_fmt; >>>> >>>> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-26 14:41 ` Hugues FRUCHET 0 siblings, 0 replies; 40+ messages in thread From: Hugues FRUCHET @ 2017-06-26 14:41 UTC (permalink / raw) To: Hans Verkuil, Maxime Coquelin, Alexandre TORGUE, Mauro Carvalho Chehab Cc: devicetree, linux-kernel, Yannick FERTRE, Benjamin Gaignard, linux-arm-kernel, linux-media On 06/26/2017 12:07 PM, Hans Verkuil wrote: > On 26/06/17 11:53, Hugues FRUCHET wrote: >> Hi Hans, thanks for review. >> >> Reply below. >> >> BR >> Hugues. >> >> On 06/22/2017 05:19 PM, Hans Verkuil wrote: >>> On 06/22/2017 05:12 PM, Hugues Fruchet wrote: >>>> Add flexibility on supported resolutions by cropping sensor >>>> image to fit user resolution format request. >>>> >>>> Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> >>>> --- >>>> drivers/media/platform/stm32/stm32-dcmi.c | 54 ++++++++++++++++++++++++++++++- >>>> 1 file changed, 53 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c >>>> index 75d53aa..bc5e052 100644 >>>> --- a/drivers/media/platform/stm32/stm32-dcmi.c >>>> +++ b/drivers/media/platform/stm32/stm32-dcmi.c >>>> @@ -131,6 +131,8 @@ struct stm32_dcmi { >>>> struct v4l2_async_notifier notifier; >>>> struct dcmi_graph_entity entity; >>>> struct v4l2_format fmt; >>>> + struct v4l2_rect crop; >>>> + bool do_crop; >>>> >>>> const struct dcmi_format **user_formats; >>>> unsigned int num_user_formats; >>>> @@ -538,6 +540,27 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) >>>> if (dcmi->bus.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) >>>> val |= CR_PCKPOL; >>>> >>>> + if (dcmi->do_crop) { >>>> + u32 size, start; >>>> + >>>> + /* Crop resolution */ >>>> + size = ((dcmi->crop.height - 1) << 16) | >>>> + ((dcmi->crop.width << 1) - 1); >>>> + reg_write(dcmi->regs, DCMI_CWSIZE, size); >>>> + >>>> + /* Crop start point */ >>>> + start = ((dcmi->crop.top) << 16) | >>>> + ((dcmi->crop.left << 1)); >>>> + reg_write(dcmi->regs, DCMI_CWSTRT, start); >>>> + >>>> + dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n", >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + >>>> + /* Enable crop */ >>>> + val |= CR_CROP; >>>> + }; >>>> + >>>> reg_write(dcmi->regs, DCMI_CR, val); >>>> >>>> /* Enable dcmi */ >>>> @@ -707,6 +730,8 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> .which = V4L2_SUBDEV_FORMAT_TRY, >>>> }; >>>> int ret; >>>> + __u32 width, height; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> >>>> dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); >>>> if (!dcmi_fmt) { >>>> @@ -724,8 +749,18 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Align format on what sensor can do */ >>>> + width = pixfmt->width; >>>> + height = pixfmt->height; >>>> v4l2_fill_pix_format(pixfmt, &format.format); >>>> >>>> + /* We can do any resolution thanks to crop */ >>>> + if ((mf->width > width) || (mf->height > height)) { >>>> + /* Restore width/height */ >>>> + pixfmt->width = width; >>>> + pixfmt->height = height; >>>> + }; >>>> + >>>> pixfmt->field = V4L2_FIELD_NONE; >>>> pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; >>>> pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; >>>> @@ -741,6 +776,8 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> struct v4l2_subdev_format format = { >>>> .which = V4L2_SUBDEV_FORMAT_ACTIVE, >>>> }; >>>> + struct v4l2_mbus_framefmt *mf = &format.format; >>>> + struct v4l2_pix_format *pixfmt = &f->fmt.pix; >>>> const struct dcmi_format *current_fmt; >>>> int ret; >>>> >>>> @@ -748,13 +785,28 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f) >>>> if (ret) >>>> return ret; >>>> >>>> - v4l2_fill_mbus_format(&format.format, &f->fmt.pix, >>>> + v4l2_fill_mbus_format(&format.format, pixfmt, >>>> current_fmt->mbus_code); >>>> ret = v4l2_subdev_call(dcmi->entity.subdev, pad, >>>> set_fmt, NULL, &format); >>>> if (ret < 0) >>>> return ret; >>>> >>>> + /* Enable crop if sensor resolution is larger than request */ >>>> + dcmi->do_crop = false; >>>> + if ((mf->width > pixfmt->width) || (mf->height > pixfmt->height)) { >>>> + dcmi->crop.width = pixfmt->width; >>>> + dcmi->crop.height = pixfmt->height; >>>> + dcmi->crop.left = (mf->width - pixfmt->width) / 2; >>>> + dcmi->crop.top = (mf->height - pixfmt->height) / 2; >>>> + dcmi->do_crop = true; >>> >>> Why not implement the selection API instead? I assume that you can crop from any >>> region of the sensor, not just the center part. >> >> The point here was to add some flexibility for user in term of >> resolution and also less memory consumption. >> For example here I want to make a 480x272 preview: >> - without this change: S_FMT(480x272) returns VGA (the OV9655 larger >> discrete resolution), then app has to capture VGA frames then crop to >> fit 480x272 frame buffer. >> - with this change: S_FMT(480x272) returns 480x272 (crop done by >> hardware), app can directly capture 480x272 then copy to framebuffer >> without any conversion. >> >> Implementation of V4L2 crop using SELECTION API could also be used, >> but I need to change app. >> >> More generally, with a given couple ISP+sensor, will S_FMT() >> return the sensor only supported resolutions ? or the supported >> resolutions of the couple ISP+sensor (ISP will downscale/upscale/crop >> the sensor discrete resolution to fit user request) ? >> >> Hans, what are your recommendations ? > > This is not the way the V4L2 API works. > > Sensors report their supported resolutions through the ENUM_FRAMESIZES > (and the related ENUM_FRAMEINTERVALS) ioctls. > > With S_FMT you pick the resolution you want. > > If you then want to crop the driver should implement the selection API > (this will also automatically enable the G/S_CROP/CROPCAP ioctls) so the > application can select which part of the image should be cropped. Assuming > there is no scaler then after cropping the format size will be reduced > to the size of the cropped image. > > That's in a nutshell how these ioctls relate to one another. > > Regards, > > Hans > Ok, crystal clear, I'll implement selection API so. BR, Hugues. >> >>> >>> Regards, >>> >>> Hans >>> >>>> + >>>> + dev_dbg(dcmi->dev, "%ux%u cropped to %ux%u@(%u,%u)\n", >>>> + mf->width, mf->height, >>>> + dcmi->crop.width, dcmi->crop.height, >>>> + dcmi->crop.left, dcmi->crop.top); >>>> + }; >>>> + >>>> dcmi->fmt = *f; >>>> dcmi->current_fmt = current_fmt; >>>> >>>> > ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH] stm32-dcmi: fix semicolon.cocci warnings 2017-06-22 15:12 ` Hugues Fruchet (?) @ 2017-06-25 15:02 ` kbuild test robot -1 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-06-25 15:02 UTC (permalink / raw) To: Hugues Fruchet Cc: kbuild-all, Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil, devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet drivers/media/platform/stm32/stm32-dcmi.c:808:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:562:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:762:2-3: Unneeded semicolon Remove unneeded semicolon. Generated by: scripts/coccinelle/misc/semicolon.cocci Fixes: a8a270dedb25 ("stm32-dcmi: crop sensor image to match user resolution") CC: Hugues Fruchet <hugues.fruchet@st.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> --- stm32-dcmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -559,7 +559,7 @@ static int dcmi_start_streaming(struct v /* Enable crop */ val |= CR_CROP; - }; + } reg_write(dcmi->regs, DCMI_CR, val); @@ -759,7 +759,7 @@ static int dcmi_try_fmt(struct stm32_dcm /* Restore width/height */ pixfmt->width = width; pixfmt->height = height; - }; + } pixfmt->field = V4L2_FIELD_NONE; pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; @@ -805,7 +805,7 @@ static int dcmi_set_fmt(struct stm32_dcm mf->width, mf->height, dcmi->crop.width, dcmi->crop.height, dcmi->crop.left, dcmi->crop.top); - }; + } dcmi->fmt = *f; dcmi->current_fmt = current_fmt; ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH] stm32-dcmi: fix semicolon.cocci warnings @ 2017-06-25 15:02 ` kbuild test robot 0 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-06-25 15:02 UTC (permalink / raw) To: linux-arm-kernel drivers/media/platform/stm32/stm32-dcmi.c:808:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:562:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:762:2-3: Unneeded semicolon Remove unneeded semicolon. Generated by: scripts/coccinelle/misc/semicolon.cocci Fixes: a8a270dedb25 ("stm32-dcmi: crop sensor image to match user resolution") CC: Hugues Fruchet <hugues.fruchet@st.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> --- stm32-dcmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -559,7 +559,7 @@ static int dcmi_start_streaming(struct v /* Enable crop */ val |= CR_CROP; - }; + } reg_write(dcmi->regs, DCMI_CR, val); @@ -759,7 +759,7 @@ static int dcmi_try_fmt(struct stm32_dcm /* Restore width/height */ pixfmt->width = width; pixfmt->height = height; - }; + } pixfmt->field = V4L2_FIELD_NONE; pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; @@ -805,7 +805,7 @@ static int dcmi_set_fmt(struct stm32_dcm mf->width, mf->height, dcmi->crop.width, dcmi->crop.height, dcmi->crop.left, dcmi->crop.top); - }; + } dcmi->fmt = *f; dcmi->current_fmt = current_fmt; ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH] stm32-dcmi: fix semicolon.cocci warnings @ 2017-06-25 15:02 ` kbuild test robot 0 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-06-25 15:02 UTC (permalink / raw) Cc: kbuild-all, Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil, devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet drivers/media/platform/stm32/stm32-dcmi.c:808:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:562:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:762:2-3: Unneeded semicolon Remove unneeded semicolon. Generated by: scripts/coccinelle/misc/semicolon.cocci Fixes: a8a270dedb25 ("stm32-dcmi: crop sensor image to match user resolution") CC: Hugues Fruchet <hugues.fruchet@st.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> --- stm32-dcmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -559,7 +559,7 @@ static int dcmi_start_streaming(struct v /* Enable crop */ val |= CR_CROP; - }; + } reg_write(dcmi->regs, DCMI_CR, val); @@ -759,7 +759,7 @@ static int dcmi_try_fmt(struct stm32_dcm /* Restore width/height */ pixfmt->width = width; pixfmt->height = height; - }; + } pixfmt->field = V4L2_FIELD_NONE; pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; @@ -805,7 +805,7 @@ static int dcmi_set_fmt(struct stm32_dcm mf->width, mf->height, dcmi->crop.width, dcmi->crop.height, dcmi->crop.left, dcmi->crop.top); - }; + } dcmi->fmt = *f; dcmi->current_fmt = current_fmt; ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 2017-06-22 15:12 ` Hugues Fruchet (?) @ 2017-06-25 15:02 ` kbuild test robot -1 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-06-25 15:02 UTC (permalink / raw) To: Hugues Fruchet Cc: kbuild-all, Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil, devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Hi Hugues, [auto build test WARNING on linuxtv-media/master] [also build test WARNING on next-20170623] [cannot apply to v4.12-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hugues-Fruchet/Camera-support-on-STM32F746G-DISCO-board/20170625-204425 base: git://linuxtv.org/media_tree.git master coccinelle warnings: (new ones prefixed by >>) >> drivers/media/platform/stm32/stm32-dcmi.c:808:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:562:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:762:2-3: Unneeded semicolon Please review and possibly fold the followup patch. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-25 15:02 ` kbuild test robot 0 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-06-25 15:02 UTC (permalink / raw) To: linux-arm-kernel Hi Hugues, [auto build test WARNING on linuxtv-media/master] [also build test WARNING on next-20170623] [cannot apply to v4.12-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hugues-Fruchet/Camera-support-on-STM32F746G-DISCO-board/20170625-204425 base: git://linuxtv.org/media_tree.git master coccinelle warnings: (new ones prefixed by >>) >> drivers/media/platform/stm32/stm32-dcmi.c:808:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:562:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:762:2-3: Unneeded semicolon Please review and possibly fold the followup patch. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution @ 2017-06-25 15:02 ` kbuild test robot 0 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-06-25 15:02 UTC (permalink / raw) Cc: kbuild-all, Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil, devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Hi Hugues, [auto build test WARNING on linuxtv-media/master] [also build test WARNING on next-20170623] [cannot apply to v4.12-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hugues-Fruchet/Camera-support-on-STM32F746G-DISCO-board/20170625-204425 base: git://linuxtv.org/media_tree.git master coccinelle warnings: (new ones prefixed by >>) >> drivers/media/platform/stm32/stm32-dcmi.c:808:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:562:2-3: Unneeded semicolon drivers/media/platform/stm32/stm32-dcmi.c:762:2-3: Unneeded semicolon Please review and possibly fold the followup patch. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU 2017-06-22 15:12 ` Hugues Fruchet (?) @ 2017-06-22 15:12 ` Hugues Fruchet -1 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Enable DCMI camera interface on STM32F746 MCU. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- arch/arm/boot/dts/stm32f746.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi index c2765ce..4bdf37c 100644 --- a/arch/arm/boot/dts/stm32f746.dtsi +++ b/arch/arm/boot/dts/stm32f746.dtsi @@ -326,6 +326,23 @@ bias-disable; }; }; + + dcmi_pins: dcmi_pins@0 { + pins { + pinmux = <STM32F746_PA4_FUNC_DCMI_HSYNC>, + <STM32F746_PG9_FUNC_DCMI_VSYNC>, + <STM32F746_PA6_FUNC_DCMI_PIXCLK>, + <STM32F746_PH9_FUNC_DCMI_D0>, + <STM32F746_PH10_FUNC_DCMI_D1>, + <STM32F746_PH11_FUNC_DCMI_D2>, + <STM32F746_PH12_FUNC_DCMI_D3>, + <STM32F746_PH14_FUNC_DCMI_D4>, + <STM32F746_PD3_FUNC_DCMI_D5>, + <STM32F746_PE5_FUNC_DCMI_D6>, + <STM32F746_PE6_FUNC_DCMI_D7>; + slew-rate = <3>; + }; + }; }; crc: crc@40023000 { @@ -344,6 +361,20 @@ assigned-clocks = <&rcc 1 CLK_HSE_RTC>; assigned-clock-rates = <1000000>; }; + + dcmi: dcmi@50050000 { + compatible = "st,stm32-dcmi"; + reg = <0x50050000 0x400>; + interrupts = <78>; + resets = <&rcc STM32F7_AHB2_RESET(DCMI)>; + clocks = <&rcc 0 STM32F7_AHB2_CLOCK(DCMI)>; + clock-names = "mclk"; + pinctrl-names = "default"; + pinctrl-0 = <&dcmi_pins>; + dmas = <&dma2 1 1 0x414 0x3>; + dma-names = "tx"; + status = "disabled"; + }; }; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: linux-arm-kernel Enable DCMI camera interface on STM32F746 MCU. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- arch/arm/boot/dts/stm32f746.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi index c2765ce..4bdf37c 100644 --- a/arch/arm/boot/dts/stm32f746.dtsi +++ b/arch/arm/boot/dts/stm32f746.dtsi @@ -326,6 +326,23 @@ bias-disable; }; }; + + dcmi_pins: dcmi_pins at 0 { + pins { + pinmux = <STM32F746_PA4_FUNC_DCMI_HSYNC>, + <STM32F746_PG9_FUNC_DCMI_VSYNC>, + <STM32F746_PA6_FUNC_DCMI_PIXCLK>, + <STM32F746_PH9_FUNC_DCMI_D0>, + <STM32F746_PH10_FUNC_DCMI_D1>, + <STM32F746_PH11_FUNC_DCMI_D2>, + <STM32F746_PH12_FUNC_DCMI_D3>, + <STM32F746_PH14_FUNC_DCMI_D4>, + <STM32F746_PD3_FUNC_DCMI_D5>, + <STM32F746_PE5_FUNC_DCMI_D6>, + <STM32F746_PE6_FUNC_DCMI_D7>; + slew-rate = <3>; + }; + }; }; crc: crc at 40023000 { @@ -344,6 +361,20 @@ assigned-clocks = <&rcc 1 CLK_HSE_RTC>; assigned-clock-rates = <1000000>; }; + + dcmi: dcmi at 50050000 { + compatible = "st,stm32-dcmi"; + reg = <0x50050000 0x400>; + interrupts = <78>; + resets = <&rcc STM32F7_AHB2_RESET(DCMI)>; + clocks = <&rcc 0 STM32F7_AHB2_CLOCK(DCMI)>; + clock-names = "mclk"; + pinctrl-names = "default"; + pinctrl-0 = <&dcmi_pins>; + dmas = <&dma2 1 1 0x414 0x3>; + dma-names = "tx"; + status = "disabled"; + }; }; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Enable DCMI camera interface on STM32F746 MCU. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- arch/arm/boot/dts/stm32f746.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi index c2765ce..4bdf37c 100644 --- a/arch/arm/boot/dts/stm32f746.dtsi +++ b/arch/arm/boot/dts/stm32f746.dtsi @@ -326,6 +326,23 @@ bias-disable; }; }; + + dcmi_pins: dcmi_pins@0 { + pins { + pinmux = <STM32F746_PA4_FUNC_DCMI_HSYNC>, + <STM32F746_PG9_FUNC_DCMI_VSYNC>, + <STM32F746_PA6_FUNC_DCMI_PIXCLK>, + <STM32F746_PH9_FUNC_DCMI_D0>, + <STM32F746_PH10_FUNC_DCMI_D1>, + <STM32F746_PH11_FUNC_DCMI_D2>, + <STM32F746_PH12_FUNC_DCMI_D3>, + <STM32F746_PH14_FUNC_DCMI_D4>, + <STM32F746_PD3_FUNC_DCMI_D5>, + <STM32F746_PE5_FUNC_DCMI_D6>, + <STM32F746_PE6_FUNC_DCMI_D7>; + slew-rate = <3>; + }; + }; }; crc: crc@40023000 { @@ -344,6 +361,20 @@ assigned-clocks = <&rcc 1 CLK_HSE_RTC>; assigned-clock-rates = <1000000>; }; + + dcmi: dcmi@50050000 { + compatible = "st,stm32-dcmi"; + reg = <0x50050000 0x400>; + interrupts = <78>; + resets = <&rcc STM32F7_AHB2_RESET(DCMI)>; + clocks = <&rcc 0 STM32F7_AHB2_CLOCK(DCMI)>; + clock-names = "mclk"; + pinctrl-names = "default"; + pinctrl-0 = <&dcmi_pins>; + dmas = <&dma2 1 1 0x414 0x3>; + dma-names = "tx"; + status = "disabled"; + }; }; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU @ 2017-07-02 0:40 ` kbuild test robot 0 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-07-02 0:40 UTC (permalink / raw) To: Hugues Fruchet Cc: kbuild-all, Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil, devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet [-- Attachment #1: Type: text/plain, Size: 992 bytes --] Hi Hugues, [auto build test ERROR on linuxtv-media/master] [cannot apply to v4.12-rc7 next-20170630] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hugues-Fruchet/Camera-support-on-STM32F746G-DISCO-board/20170625-204425 base: git://linuxtv.org/media_tree.git master config: arm-spear6xx_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=arm All errors (new ones prefixed by >>): >> ERROR: Input tree has errors, aborting (use -f to force output) --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 14926 bytes --] ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU @ 2017-07-02 0:40 ` kbuild test robot 0 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-07-02 0:40 UTC (permalink / raw) To: linux-arm-kernel Hi Hugues, [auto build test ERROR on linuxtv-media/master] [cannot apply to v4.12-rc7 next-20170630] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hugues-Fruchet/Camera-support-on-STM32F746G-DISCO-board/20170625-204425 base: git://linuxtv.org/media_tree.git master config: arm-spear6xx_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=arm All errors (new ones prefixed by >>): >> ERROR: Input tree has errors, aborting (use -f to force output) --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -------------- next part -------------- A non-text attachment was scrubbed... Name: .config.gz Type: application/gzip Size: 14926 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170702/61b07578/attachment-0001.gz> ^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU @ 2017-07-02 0:40 ` kbuild test robot 0 siblings, 0 replies; 40+ messages in thread From: kbuild test robot @ 2017-07-02 0:40 UTC (permalink / raw) Cc: kbuild-all-JC7UmRfGjtg, Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-media-u79uwXL29TY76Z2rM5mHXA, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet [-- Attachment #1: Type: text/plain, Size: 992 bytes --] Hi Hugues, [auto build test ERROR on linuxtv-media/master] [cannot apply to v4.12-rc7 next-20170630] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hugues-Fruchet/Camera-support-on-STM32F746G-DISCO-board/20170625-204425 base: git://linuxtv.org/media_tree.git master config: arm-spear6xx_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=arm All errors (new ones prefixed by >>): >> ERROR: Input tree has errors, aborting (use -f to force output) --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 14926 bytes --] ^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v1 5/5] ARM: configs: stm32: DCMI + OV9655 camera support 2017-06-22 15:12 ` Hugues Fruchet (?) @ 2017-06-22 15:12 ` Hugues Fruchet -1 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-arm-kernel, linux-kernel, linux-media, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet Enable DCMI camera interface and OV9655 camera sensor drivers. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- arch/arm/configs/stm32_defconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig index a097538..0c3cd01 100644 --- a/arch/arm/configs/stm32_defconfig +++ b/arch/arm/configs/stm32_defconfig @@ -55,6 +55,15 @@ CONFIG_I2C_STM32F4=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y # CONFIG_USB_SUPPORT is not set +CONFIG_VIDEO_V4L2=y +CONFIG_MEDIA_CONTROLLER=y +CONFIG_VIDEO_V4L2_SUBDEV_API=y +CONFIG_MEDIA_SUBDRV_AUTOSELECT=n +CONFIG_V4L_PLATFORM_DRIVERS=y +CONFIG_MEDIA_SUPPORT=y +CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_VIDEO_STM32_DCMI=y +CONFIG_VIDEO_OV9650=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_GPIO=y -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 5/5] ARM: configs: stm32: DCMI + OV9655 camera support @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: linux-arm-kernel Enable DCMI camera interface and OV9655 camera sensor drivers. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- arch/arm/configs/stm32_defconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig index a097538..0c3cd01 100644 --- a/arch/arm/configs/stm32_defconfig +++ b/arch/arm/configs/stm32_defconfig @@ -55,6 +55,15 @@ CONFIG_I2C_STM32F4=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y # CONFIG_USB_SUPPORT is not set +CONFIG_VIDEO_V4L2=y +CONFIG_MEDIA_CONTROLLER=y +CONFIG_VIDEO_V4L2_SUBDEV_API=y +CONFIG_MEDIA_SUBDRV_AUTOSELECT=n +CONFIG_V4L_PLATFORM_DRIVERS=y +CONFIG_MEDIA_SUPPORT=y +CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_VIDEO_STM32_DCMI=y +CONFIG_VIDEO_OV9650=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_GPIO=y -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v1 5/5] ARM: configs: stm32: DCMI + OV9655 camera support @ 2017-06-22 15:12 ` Hugues Fruchet 0 siblings, 0 replies; 40+ messages in thread From: Hugues Fruchet @ 2017-06-22 15:12 UTC (permalink / raw) To: Maxime Coquelin, Alexandre Torgue, Mauro Carvalho Chehab, Hans Verkuil Cc: devicetree, linux-kernel, Yannick Fertre, Benjamin Gaignard, Hugues Fruchet, linux-arm-kernel, linux-media Enable DCMI camera interface and OV9655 camera sensor drivers. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> --- arch/arm/configs/stm32_defconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig index a097538..0c3cd01 100644 --- a/arch/arm/configs/stm32_defconfig +++ b/arch/arm/configs/stm32_defconfig @@ -55,6 +55,15 @@ CONFIG_I2C_STM32F4=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y # CONFIG_USB_SUPPORT is not set +CONFIG_VIDEO_V4L2=y +CONFIG_MEDIA_CONTROLLER=y +CONFIG_VIDEO_V4L2_SUBDEV_API=y +CONFIG_MEDIA_SUBDRV_AUTOSELECT=n +CONFIG_V4L_PLATFORM_DRIVERS=y +CONFIG_MEDIA_SUPPORT=y +CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_VIDEO_STM32_DCMI=y +CONFIG_VIDEO_OV9650=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_GPIO=y -- 1.9.1 ^ permalink raw reply related [flat|nested] 40+ messages in thread
end of thread, other threads:[~2017-07-02 0:41 UTC | newest] Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-06-22 15:12 [PATCH v1 0/5] Camera support on STM32F746G-DISCO board Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` [PATCH v1 1/5] [media] stm32-dcmi: catch dma submission error Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:19 ` Hans Verkuil 2017-06-22 15:19 ` Hans Verkuil 2017-06-26 9:53 ` Hugues FRUCHET 2017-06-26 9:53 ` Hugues FRUCHET 2017-06-26 9:53 ` Hugues FRUCHET 2017-06-26 9:53 ` Hugues FRUCHET 2017-06-26 10:07 ` Hans Verkuil 2017-06-26 10:07 ` Hans Verkuil 2017-06-26 10:07 ` Hans Verkuil 2017-06-26 14:41 ` Hugues FRUCHET 2017-06-26 14:41 ` Hugues FRUCHET 2017-06-26 14:41 ` Hugues FRUCHET 2017-06-26 14:41 ` Hugues FRUCHET 2017-06-25 15:02 ` [PATCH] stm32-dcmi: fix semicolon.cocci warnings kbuild test robot 2017-06-25 15:02 ` kbuild test robot 2017-06-25 15:02 ` kbuild test robot 2017-06-25 15:02 ` [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution kbuild test robot 2017-06-25 15:02 ` kbuild test robot 2017-06-25 15:02 ` kbuild test robot 2017-06-22 15:12 ` [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-07-02 0:40 ` kbuild test robot 2017-07-02 0:40 ` kbuild test robot 2017-07-02 0:40 ` kbuild test robot 2017-06-22 15:12 ` [PATCH v1 5/5] ARM: configs: stm32: DCMI + OV9655 camera support Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:12 ` Hugues Fruchet
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.