aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/vimc/vimc-capture.c
diff options
context:
space:
mode:
authorHelen Koike <helen.koike@collabora.com>2019-08-08 20:27:41 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-08-13 10:40:38 -0400
commit09c41a23a2e2de7ed347251d7079a42de0dd230b (patch)
tree04317b6c35374a578a8df257de210c06c527d71d /drivers/media/platform/vimc/vimc-capture.c
parent10b1aed6dac01d566b6b3c261a191546c82f0157 (diff)
media: Revert "media: vimc: propagate pixel format in the stream"
This reverts commit b6c61a6c37317efd7327199bfe24770af3d7e799. The requested pixelformat is being propagated from the capture to the tpg in the sensor. This was a bad design choice, as we start having the following issues: * We set a pixelformat in the capture; * We set matching media bus formats in the subdevices pads; * Link validate looks fine (sizes matches, media bus formats matches); * Issue: if some of the subdevice doesn't know how to generate the requested pixelformat in the capture, then stream_on fails. This is bad because capture says it supports that pixelformat, everything looks fine, but it is not, and there is no way to find it out through the links. This patch was implemented so we could request any pixelformat from the pipeline regardeless of the media bus format configured between pads. Not all pixelformat can be mapped into a media bus code (e.g. multiplanar formats), so with this patch we could request those pixelformats from the tpg. Solution: map pixelformats to media bus codes as before, and implement conversions to other pixelformats in the capture to support multiplanar. So first step to this solution is to revert this patch. Signed-off-by: Helen Koike <helen.koike@collabora.com> Signed-off-by: Lucas A. M. Magalhaes <lucmaga@gmail.com> Tested-by: André Almeida <andrealmeid@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/platform/vimc/vimc-capture.c')
-rw-r--r--drivers/media/platform/vimc/vimc-capture.c76
1 files changed, 26 insertions, 50 deletions
diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c
index 664855708fdf..1d56b91830ba 100644
--- a/drivers/media/platform/vimc/vimc-capture.c
+++ b/drivers/media/platform/vimc/vimc-capture.c
@@ -18,32 +18,6 @@
18 18
19#define VIMC_CAP_DRV_NAME "vimc-capture" 19#define VIMC_CAP_DRV_NAME "vimc-capture"
20 20
21static const u32 vimc_cap_supported_pixfmt[] = {
22 V4L2_PIX_FMT_BGR24,
23 V4L2_PIX_FMT_RGB24,
24 V4L2_PIX_FMT_ARGB32,
25 V4L2_PIX_FMT_SBGGR8,
26 V4L2_PIX_FMT_SGBRG8,
27 V4L2_PIX_FMT_SGRBG8,
28 V4L2_PIX_FMT_SRGGB8,
29 V4L2_PIX_FMT_SBGGR10,
30 V4L2_PIX_FMT_SGBRG10,
31 V4L2_PIX_FMT_SGRBG10,
32 V4L2_PIX_FMT_SRGGB10,
33 V4L2_PIX_FMT_SBGGR10ALAW8,
34 V4L2_PIX_FMT_SGBRG10ALAW8,
35 V4L2_PIX_FMT_SGRBG10ALAW8,
36 V4L2_PIX_FMT_SRGGB10ALAW8,
37 V4L2_PIX_FMT_SBGGR10DPCM8,
38 V4L2_PIX_FMT_SGBRG10DPCM8,
39 V4L2_PIX_FMT_SGRBG10DPCM8,
40 V4L2_PIX_FMT_SRGGB10DPCM8,
41 V4L2_PIX_FMT_SBGGR12,
42 V4L2_PIX_FMT_SGBRG12,
43 V4L2_PIX_FMT_SGRBG12,
44 V4L2_PIX_FMT_SRGGB12,
45};
46
47struct vimc_cap_device { 21struct vimc_cap_device {
48 struct vimc_ent_device ved; 22 struct vimc_ent_device ved;
49 struct video_device vdev; 23 struct video_device vdev;
@@ -117,25 +91,29 @@ static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv,
117 struct v4l2_format *f) 91 struct v4l2_format *f)
118{ 92{
119 struct v4l2_pix_format *format = &f->fmt.pix; 93 struct v4l2_pix_format *format = &f->fmt.pix;
94 const struct vimc_pix_map *vpix;
120 95
121 format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH, 96 format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH,
122 VIMC_FRAME_MAX_WIDTH) & ~1; 97 VIMC_FRAME_MAX_WIDTH) & ~1;
123 format->height = clamp_t(u32, format->height, VIMC_FRAME_MIN_HEIGHT, 98 format->height = clamp_t(u32, format->height, VIMC_FRAME_MIN_HEIGHT,
124 VIMC_FRAME_MAX_HEIGHT) & ~1; 99 VIMC_FRAME_MAX_HEIGHT) & ~1;
125 100
126 vimc_colorimetry_clamp(format); 101 /* Don't accept a pixelformat that is not on the table */
102 vpix = vimc_pix_map_by_pixelformat(format->pixelformat);
103 if (!vpix) {
104 format->pixelformat = fmt_default.pixelformat;
105 vpix = vimc_pix_map_by_pixelformat(format->pixelformat);
106 }
107 /* TODO: Add support for custom bytesperline values */
108 format->bytesperline = format->width * vpix->bpp;
109 format->sizeimage = format->bytesperline * format->height;
127 110
128 if (format->field == V4L2_FIELD_ANY) 111 if (format->field == V4L2_FIELD_ANY)
129 format->field = fmt_default.field; 112 format->field = fmt_default.field;
130 113
131 /* TODO: Add support for custom bytesperline values */ 114 vimc_colorimetry_clamp(format);
132
133 /* Don't accept a pixelformat that is not on the table */
134 if (!v4l2_format_info(format->pixelformat))
135 format->pixelformat = fmt_default.pixelformat;
136 115
137 return v4l2_fill_pixfmt(format, format->pixelformat, 116 return 0;
138 format->width, format->height);
139} 117}
140 118
141static int vimc_cap_s_fmt_vid_cap(struct file *file, void *priv, 119static int vimc_cap_s_fmt_vid_cap(struct file *file, void *priv,
@@ -174,31 +152,27 @@ static int vimc_cap_s_fmt_vid_cap(struct file *file, void *priv,
174static int vimc_cap_enum_fmt_vid_cap(struct file *file, void *priv, 152static int vimc_cap_enum_fmt_vid_cap(struct file *file, void *priv,
175 struct v4l2_fmtdesc *f) 153 struct v4l2_fmtdesc *f)
176{ 154{
177 if (f->index >= ARRAY_SIZE(vimc_cap_supported_pixfmt)) 155 const struct vimc_pix_map *vpix = vimc_pix_map_by_index(f->index);
156
157 if (!vpix)
178 return -EINVAL; 158 return -EINVAL;
179 159
180 f->pixelformat = vimc_cap_supported_pixfmt[f->index]; 160 f->pixelformat = vpix->pixelformat;
181 161
182 return 0; 162 return 0;
183} 163}
184 164
185static bool vimc_cap_is_pixfmt_supported(u32 pixelformat)
186{
187 unsigned int i;
188
189 for (i = 0; i < ARRAY_SIZE(vimc_cap_supported_pixfmt); i++)
190 if (vimc_cap_supported_pixfmt[i] == pixelformat)
191 return true;
192 return false;
193}
194
195static int vimc_cap_enum_framesizes(struct file *file, void *fh, 165static int vimc_cap_enum_framesizes(struct file *file, void *fh,
196 struct v4l2_frmsizeenum *fsize) 166 struct v4l2_frmsizeenum *fsize)
197{ 167{
168 const struct vimc_pix_map *vpix;
169
198 if (fsize->index) 170 if (fsize->index)
199 return -EINVAL; 171 return -EINVAL;
200 172
201 if (!vimc_cap_is_pixfmt_supported(fsize->pixel_format)) 173 /* Only accept code in the pix map table */
174 vpix = vimc_pix_map_by_code(fsize->pixel_format);
175 if (!vpix)
202 return -EINVAL; 176 return -EINVAL;
203 177
204 fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; 178 fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
@@ -272,7 +246,6 @@ static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
272 return ret; 246 return ret;
273 } 247 }
274 248
275 vcap->stream.producer_pixfmt = vcap->format.pixelformat;
276 ret = vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 1); 249 ret = vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 1);
277 if (ret) { 250 if (ret) {
278 media_pipeline_stop(entity); 251 media_pipeline_stop(entity);
@@ -423,6 +396,7 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master,
423{ 396{
424 struct v4l2_device *v4l2_dev = master_data; 397 struct v4l2_device *v4l2_dev = master_data;
425 struct vimc_platform_data *pdata = comp->platform_data; 398 struct vimc_platform_data *pdata = comp->platform_data;
399 const struct vimc_pix_map *vpix;
426 struct vimc_cap_device *vcap; 400 struct vimc_cap_device *vcap;
427 struct video_device *vdev; 401 struct video_device *vdev;
428 struct vb2_queue *q; 402 struct vb2_queue *q;
@@ -477,8 +451,10 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master,
477 451
478 /* Set default frame format */ 452 /* Set default frame format */
479 vcap->format = fmt_default; 453 vcap->format = fmt_default;
480 v4l2_fill_pixfmt(&vcap->format, vcap->format.pixelformat, 454 vpix = vimc_pix_map_by_pixelformat(vcap->format.pixelformat);
481 vcap->format.width, vcap->format.height); 455 vcap->format.bytesperline = vcap->format.width * vpix->bpp;
456 vcap->format.sizeimage = vcap->format.bytesperline *
457 vcap->format.height;
482 458
483 /* Fill the vimc_ent_device struct */ 459 /* Fill the vimc_ent_device struct */
484 vcap->ved.ent = &vcap->vdev.entity; 460 vcap->ved.ent = &vcap->vdev.entity;