* [PATCH v1 0/5] Camera support on STM32F746G-DISCO board
@ 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
` (4 more replies)
0 siblings, 5 replies; 14+ 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] 14+ messages in thread* [PATCH v1 1/5] [media] stm32-dcmi: catch dma submission error 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 ` [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling Hugues Fruchet ` (3 subsequent siblings) 4 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling 2017-06-22 15:12 [PATCH v1 0/5] Camera support on STM32F746G-DISCO board 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 ` [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution Hugues Fruchet ` (2 subsequent siblings) 4 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 2017-06-22 15:12 [PATCH v1 0/5] Camera support on STM32F746G-DISCO board 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 ` [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling Hugues Fruchet @ 2017-06-22 15:12 ` Hugues Fruchet 2017-06-22 15:19 ` Hans Verkuil ` (2 more replies) 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 ` [PATCH v1 5/5] ARM: configs: stm32: DCMI + OV9655 camera support Hugues Fruchet 4 siblings, 3 replies; 14+ 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] 14+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 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:19 ` Hans Verkuil 2017-06-26 9:53 ` Hugues FRUCHET 2017-06-25 15:02 ` [PATCH] stm32-dcmi: fix semicolon.cocci warnings 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 2 siblings, 1 reply; 14+ 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] 14+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 2017-06-22 15:19 ` Hans Verkuil @ 2017-06-26 9:53 ` Hugues FRUCHET 2017-06-26 10:07 ` Hans Verkuil 0 siblings, 1 reply; 14+ 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] 14+ messages in thread
* [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 2017-06-26 14:41 ` Hugues FRUCHET 0 siblings, 1 reply; 14+ 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] 14+ messages in thread
* [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 0 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH] stm32-dcmi: fix semicolon.cocci warnings 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:19 ` Hans Verkuil @ 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 2 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution 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:19 ` Hans Verkuil 2017-06-25 15:02 ` [PATCH] stm32-dcmi: fix semicolon.cocci warnings kbuild test robot @ 2017-06-25 15:02 ` kbuild test robot 2 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU 2017-06-22 15:12 [PATCH v1 0/5] Camera support on STM32F746G-DISCO board Hugues Fruchet ` (2 preceding siblings ...) 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-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 4 siblings, 1 reply; 14+ 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] 14+ messages in thread
* [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU 2017-06-22 15:12 ` [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU Hugues Fruchet @ 2017-07-02 0:40 ` kbuild test robot 0 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH v1 5/5] ARM: configs: stm32: DCMI + OV9655 camera support 2017-06-22 15:12 [PATCH v1 0/5] Camera support on STM32F746G-DISCO board Hugues Fruchet ` (3 preceding siblings ...) 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 4 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH v1 0/5] STM32 DCMI camera interface crop support
@ 2017-07-28 10:04 Hugues Fruchet
2017-07-28 10:04 ` [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling Hugues Fruchet
0 siblings, 1 reply; 14+ messages in thread
From: Hugues Fruchet @ 2017-07-28 10:04 UTC (permalink / raw)
To: linux-arm-kernel
This patchset implements crop feature of Digital Camera Memory Interface
(DCMI) of STMicroelectronics STM32 SoC series, allowing user to crop
at pixel level inside sensor captured frame.
This patchset follows discussions initiated from a first submission of DCMI
crop support, see [1].
First part of patches brings few fixes and cleanup in DCMI driver
to prepare support of crop through g_/s_selection interface in latest
commit.
This has been tested on STM32F746G-DISCO + STM32F4DIS-CAM extension
running OV9655 sensor, using a modified version of yavta [2] utility
to support crop through S_SELECTION(V4L2_SEL_TGT_CROP) ioctl:
yavta -s 480x272 -n 1 --capture=2 /dev/video0 --crop=0,0,480,272
v4l2-compliance cropping test is failed due to OV9655 sensor supporting
several discrete frame sizes and crop support added by DCMI interface [3]:
fail: v4l2-test-formats.cpp(1266): node->frmsizes_count[pixfmt] > 1
test Cropping: FAIL
If sensor is restricted to only a single supported resolution, test is OK.
Compliance test should be adapted to support this case.
[1] http://www.mail-archive.com/linux-media at vger.kernel.org/msg114652.html
[2] http://git.ideasonboard.org/?p=yavta.git;a=summary
[3] see v4l2-compliance test report below
===========
= history =
===========
version 1:
- Initial version
===================
= v4l2-compliance =
===================
Below is the v4l2-compliance report for this current version of the DCMI camera interface.
v4l2-compliance has been built from v4l-utils-1.12.5.
~ # v4l2-compliance -s -f -d /dev/video0
v4l2-compliance SHA : f5f45e17ee98a0ebad7836ade2b34ceec909d751
Driver Info:
Driver name : stm32-dcmi
Card type : STM32 Camera Memory Interface
Bus info : platform:dcmi
Driver version: 4.12.0
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Compliance test for device /dev/video0 (not using libv4l2):
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Test input 0:
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
fail: v4l2-test-formats.cpp(1266): node->frmsizes_count[pixfmt] > 1
test Cropping: FAIL
test Composing: OK (Not Supported)
fail: v4l2-test-formats.cpp(1633): node->can_scale && node->frmsizes_count[v4l_format_g_pixelformat(&cur)]
test Scaling: OK
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
Test input 0:
Streaming ioctls:
test read/write: OK
test MMAP: OK
test USERPTR: OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Stream using all formats:
test MMAP for Format RGBP, Frame Size 160x120:
Crop 160x120 at 0x0, Stride 320, Field None: OK
Crop 0x0 at 0x0, Stride 320, Field None, SelTest: OK
Crop 160x120 at 0x0, Stride 320, Field None, SelTest: OK
test MMAP for Format RGBP, Frame Size 160x120:
Crop 160x120 at 0x0, Stride 320, Field None: OK
test MMAP for Format RGBP, Frame Size 160x120:
Crop 160x120 at 0x0, Stride 320, Field None: OK
Total: 51, Succeeded: 50, Failed: 1, Warnings: 0
Hugues Fruchet (5):
[media] stm32-dcmi: catch dma submission error
[media] stm32-dcmi: revisit control register handling
[media] stm32-dcmi: cleanup variable/fields namings
[media] stm32-dcmi: set default format at open()
[media] stm32-dcmi: g_/s_selection crop support
drivers/media/platform/stm32/stm32-dcmi.c | 527 +++++++++++++++++++++++++-----
1 file changed, 448 insertions(+), 79 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling 2017-07-28 10:04 [PATCH v1 0/5] STM32 DCMI camera interface crop support Hugues Fruchet @ 2017-07-28 10:04 ` Hugues Fruchet 0 siblings, 0 replies; 14+ messages in thread From: Hugues Fruchet @ 2017-07-28 10:04 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 716b3db..526e354 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] 14+ messages in thread
end of thread, other threads:[~2017-07-28 10:04 UTC | newest] Thread overview: 14+ 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 ` [PATCH v1 1/5] [media] stm32-dcmi: catch dma submission error 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 ` [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution Hugues Fruchet 2017-06-22 15:19 ` Hans Verkuil 2017-06-26 9:53 ` Hugues FRUCHET 2017-06-26 10:07 ` Hans Verkuil 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 ` [PATCH v1 3/5] [media] stm32-dcmi: crop sensor image to match user resolution kbuild test robot 2017-06-22 15:12 ` [PATCH v1 4/5] ARM: dts: stm32: Enable DCMI support on STM32F746 MCU Hugues Fruchet 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 -- strict thread matches above, loose matches on Subject: below -- 2017-07-28 10:04 [PATCH v1 0/5] STM32 DCMI camera interface crop support Hugues Fruchet 2017-07-28 10:04 ` [PATCH v1 2/5] [media] stm32-dcmi: revisit control register handling Hugues Fruchet
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).