* [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support
@ 2020-08-14 20:54 Andrey Konovalov
2020-08-14 20:54 ` [PATCH 1/3] media: camss: Make use of V4L2_CAP_IO_MC Andrey Konovalov
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andrey Konovalov @ 2020-08-14 20:54 UTC (permalink / raw)
To: mchehab, robert.foss
Cc: linux-media, linux-arm-msm, peter.griffin, Andrey Konovalov
The first two patches add mbus_code filtering support to VIDIOC_ENUM_FMT
implementation, and VIDIOC_ENUM_FRAMESIZES support.
The minimum and the maximum frame size values are deduced from
__video_try_fmt() code.
The third patch replaces harcoded limits in __video_try_fmt() with
the definitions introduced by the second patch.
Andrey Konovalov (3):
media: camss: Make use of V4L2_CAP_IO_MC
media: camss: add support for vidioc_enum_framesizes ioctl
media: camss: __video_try_fmt(): don't use hardcoded constants
.../media/platform/qcom/camss/camss-video.c | 112 +++++++++++++++---
1 file changed, 95 insertions(+), 17 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] media: camss: Make use of V4L2_CAP_IO_MC
2020-08-14 20:54 [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Andrey Konovalov
@ 2020-08-14 20:54 ` Andrey Konovalov
2020-08-14 20:54 ` [PATCH 2/3] media: camss: add support for vidioc_enum_framesizes ioctl Andrey Konovalov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Konovalov @ 2020-08-14 20:54 UTC (permalink / raw)
To: mchehab, robert.foss
Cc: linux-media, linux-arm-msm, peter.griffin, Andrey Konovalov
Implement mbus_code filtering for format enumeration.
Without this patch libcamera errors out with:
"ERROR V4L2 v4l2_videodevice.cpp:982 /dev/video0[cap]: Media bus code
filtering not supported by the device"
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
---
.../media/platform/qcom/camss/camss-video.c | 67 +++++++++++++++----
1 file changed, 54 insertions(+), 13 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index cdbd6dba1122..90c7dd29b573 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -529,17 +529,16 @@ static int video_querycap(struct file *file, void *fh,
return 0;
}
-static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
+/*
+ * Returns the index in the video->formats[] array of the element which
+ * has the "ndx"th unique value of pixelformat field.
+ * If not found (no more unique pixelformat's) returns -EINVAL.
+ */
+static int video_get_unique_pixelformat_by_index(struct camss_video *video,
+ int ndx)
{
- struct camss_video *video = video_drvdata(file);
int i, j, k;
- if (f->type != video->type)
- return -EINVAL;
-
- if (f->index >= video->nformats)
- return -EINVAL;
-
/* find index "i" of "k"th unique pixelformat in formats array */
k = -1;
for (i = 0; i < video->nformats; i++) {
@@ -552,11 +551,53 @@ static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
if (j == i)
k++;
- if (k == f->index)
- break;
+ if (k == ndx)
+ return i;
+ }
+
+ return -EINVAL;
+}
+
+/*
+ * Returns the index in the video->formats[] array of the element which
+ * has code equal to mcode.
+ * If not found returns -EINVAL.
+ */
+static int video_get_pixelformat_by_mbus_code(struct camss_video *video,
+ u32 mcode)
+{
+ int i;
+
+ for (i = 0; i < video->nformats; i++) {
+ if (video->formats[i].code == mcode)
+ return i;
+ }
+
+ return -EINVAL;
+}
+
+static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
+{
+ struct camss_video *video = video_drvdata(file);
+ int i;
+
+ if (f->type != video->type)
+ return -EINVAL;
+
+ if (f->index >= video->nformats)
+ return -EINVAL;
+
+ if (f->mbus_code) {
+ /* Each entry in formats[] table has unique mbus_code */
+ if (f->index > 0)
+ return -EINVAL;
+
+ i = video_get_pixelformat_by_mbus_code(video, f->mbus_code);
+ } else {
+ i = video_get_unique_pixelformat_by_index(video, f->index);
}
- if (k < f->index)
+ if (i < 0)
return -EINVAL;
f->pixelformat = video->formats[i].pixelformat;
@@ -911,8 +952,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
}
vdev->fops = &msm_vid_fops;
- vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING |
- V4L2_CAP_READWRITE;
+ vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING
+ | V4L2_CAP_READWRITE | V4L2_CAP_IO_MC;
vdev->ioctl_ops = &msm_vid_ioctl_ops;
vdev->release = msm_video_release;
vdev->v4l2_dev = v4l2_dev;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] media: camss: add support for vidioc_enum_framesizes ioctl
2020-08-14 20:54 [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Andrey Konovalov
2020-08-14 20:54 ` [PATCH 1/3] media: camss: Make use of V4L2_CAP_IO_MC Andrey Konovalov
@ 2020-08-14 20:54 ` Andrey Konovalov
2020-08-14 20:54 ` [PATCH 3/3] media: camss: __video_try_fmt(): don't use hardcoded constants Andrey Konovalov
2020-08-18 13:33 ` [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Robert Foss
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Konovalov @ 2020-08-14 20:54 UTC (permalink / raw)
To: mchehab, robert.foss
Cc: linux-media, linux-arm-msm, peter.griffin, Andrey Konovalov
VIDIOC_ENUM_FRAMESIZES support in the video capture driver is required by
libcamera. Without this change libcamera errors out with:
"ERROR V4L2 v4l2_videodevice.cpp:1059 /dev/video0[cap]: Unable to enumerate
frame sizes: Inappropriate ioctl for device"
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
---
.../media/platform/qcom/camss/camss-video.c | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 90c7dd29b573..e6255f0e6174 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -18,6 +18,12 @@
#include "camss-video.h"
#include "camss.h"
+#define CAMSS_FRAME_MIN_WIDTH 1
+#define CAMSS_FRAME_MAX_WIDTH 8191
+#define CAMSS_FRAME_MIN_HEIGHT 1
+#define CAMSS_FRAME_MAX_HEIGHT_RDI 8191
+#define CAMSS_FRAME_MAX_HEIGHT_PIX 4096
+
struct fract {
u8 numerator;
u8 denominator;
@@ -605,6 +611,36 @@ static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
return 0;
}
+static int video_enum_framesizes(struct file *file, void *fh,
+ struct v4l2_frmsizeenum *fsize)
+{
+ struct camss_video *video = video_drvdata(file);
+ int i;
+
+ if (fsize->index)
+ return -EINVAL;
+
+ /* Only accept pixel format present in the formats[] table */
+ for (i = 0; i < video->nformats; i++) {
+ if (video->formats[i].pixelformat == fsize->pixel_format)
+ break;
+ }
+
+ if (i == video->nformats)
+ return -EINVAL;
+
+ fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
+ fsize->stepwise.min_width = CAMSS_FRAME_MIN_WIDTH;
+ fsize->stepwise.max_width = CAMSS_FRAME_MAX_WIDTH;
+ fsize->stepwise.min_height = CAMSS_FRAME_MIN_HEIGHT;
+ fsize->stepwise.max_height = (video->line_based) ?
+ CAMSS_FRAME_MAX_HEIGHT_PIX : CAMSS_FRAME_MAX_HEIGHT_RDI;
+ fsize->stepwise.step_width = 1;
+ fsize->stepwise.step_height = 1;
+
+ return 0;
+}
+
static int video_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
struct camss_video *video = video_drvdata(file);
@@ -745,6 +781,7 @@ static int video_s_input(struct file *file, void *fh, unsigned int input)
static const struct v4l2_ioctl_ops msm_vid_ioctl_ops = {
.vidioc_querycap = video_querycap,
.vidioc_enum_fmt_vid_cap = video_enum_fmt,
+ .vidioc_enum_framesizes = video_enum_framesizes,
.vidioc_g_fmt_vid_cap_mplane = video_g_fmt,
.vidioc_s_fmt_vid_cap_mplane = video_s_fmt,
.vidioc_try_fmt_vid_cap_mplane = video_try_fmt,
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] media: camss: __video_try_fmt(): don't use hardcoded constants
2020-08-14 20:54 [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Andrey Konovalov
2020-08-14 20:54 ` [PATCH 1/3] media: camss: Make use of V4L2_CAP_IO_MC Andrey Konovalov
2020-08-14 20:54 ` [PATCH 2/3] media: camss: add support for vidioc_enum_framesizes ioctl Andrey Konovalov
@ 2020-08-14 20:54 ` Andrey Konovalov
2020-08-18 13:33 ` [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Robert Foss
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Konovalov @ 2020-08-14 20:54 UTC (permalink / raw)
To: mchehab, robert.foss
Cc: linux-media, linux-arm-msm, peter.griffin, Andrey Konovalov
Use the definitions introduced by commit "media: camss: add support
for vidioc_enum_framesizes ioctl" instead of the hardcoded values.
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
---
drivers/media/platform/qcom/camss/camss-video.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index e6255f0e6174..546393ab0a52 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -670,7 +670,7 @@ static int __video_try_fmt(struct camss_video *video, struct v4l2_format *f)
1, 65528);
sizeimage[i] = clamp_t(u32, p->sizeimage,
bytesperline[i],
- bytesperline[i] * 4096);
+ bytesperline[i] * CAMSS_FRAME_MAX_HEIGHT_PIX);
}
for (j = 0; j < video->nformats; j++)
@@ -687,8 +687,8 @@ static int __video_try_fmt(struct camss_video *video, struct v4l2_format *f)
memset(pix_mp, 0, sizeof(*pix_mp));
pix_mp->pixelformat = fi->pixelformat;
- pix_mp->width = clamp_t(u32, width, 1, 8191);
- pix_mp->height = clamp_t(u32, height, 1, 8191);
+ pix_mp->width = clamp_t(u32, width, 1, CAMSS_FRAME_MAX_WIDTH);
+ pix_mp->height = clamp_t(u32, height, 1, CAMSS_FRAME_MAX_HEIGHT_RDI);
pix_mp->num_planes = fi->planes;
for (i = 0; i < pix_mp->num_planes; i++) {
bpl = pix_mp->width / fi->hsub[i].numerator *
@@ -714,7 +714,7 @@ static int __video_try_fmt(struct camss_video *video, struct v4l2_format *f)
1, 65528);
p->sizeimage = clamp_t(u32, p->sizeimage,
p->bytesperline,
- p->bytesperline * 4096);
+ p->bytesperline * CAMSS_FRAME_MAX_HEIGHT_PIX);
lines = p->sizeimage / p->bytesperline;
if (p->bytesperline < bytesperline[i])
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support
2020-08-14 20:54 [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Andrey Konovalov
` (2 preceding siblings ...)
2020-08-14 20:54 ` [PATCH 3/3] media: camss: __video_try_fmt(): don't use hardcoded constants Andrey Konovalov
@ 2020-08-18 13:33 ` Robert Foss
3 siblings, 0 replies; 5+ messages in thread
From: Robert Foss @ 2020-08-18 13:33 UTC (permalink / raw)
To: Andrey Konovalov
Cc: Mauro Carvalho Chehab, linux-media, linux-arm-msm, Peter Griffin
Hey Andrey,
I've looked through this series, and it all looks good to me.
Acked-by: Robert Foss <robert.foss@linaro.org>
On Fri, 14 Aug 2020 at 22:54, Andrey Konovalov
<andrey.konovalov@linaro.org> wrote:
>
> The first two patches add mbus_code filtering support to VIDIOC_ENUM_FMT
> implementation, and VIDIOC_ENUM_FRAMESIZES support.
>
> The minimum and the maximum frame size values are deduced from
> __video_try_fmt() code.
>
> The third patch replaces harcoded limits in __video_try_fmt() with
> the definitions introduced by the second patch.
>
> Andrey Konovalov (3):
> media: camss: Make use of V4L2_CAP_IO_MC
> media: camss: add support for vidioc_enum_framesizes ioctl
> media: camss: __video_try_fmt(): don't use hardcoded constants
>
> .../media/platform/qcom/camss/camss-video.c | 112 +++++++++++++++---
> 1 file changed, 95 insertions(+), 17 deletions(-)
>
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-18 13:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-14 20:54 [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Andrey Konovalov
2020-08-14 20:54 ` [PATCH 1/3] media: camss: Make use of V4L2_CAP_IO_MC Andrey Konovalov
2020-08-14 20:54 ` [PATCH 2/3] media: camss: add support for vidioc_enum_framesizes ioctl Andrey Konovalov
2020-08-14 20:54 ` [PATCH 3/3] media: camss: __video_try_fmt(): don't use hardcoded constants Andrey Konovalov
2020-08-18 13:33 ` [PATCH 0/3] media: camss: extend VIDIOC_ENUM_* ioctls support Robert Foss
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).