Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Helen Koike and committed by
Mauro Carvalho Chehab
09c41a23 10b1aed6

+342 -308
+26 -50
drivers/media/platform/vimc/vimc-capture.c
··· 18 18 19 19 #define VIMC_CAP_DRV_NAME "vimc-capture" 20 20 21 - static 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 - 47 21 struct vimc_cap_device { 48 22 struct vimc_ent_device ved; 49 23 struct video_device vdev; ··· 91 117 struct v4l2_format *f) 92 118 { 93 119 struct v4l2_pix_format *format = &f->fmt.pix; 120 + const struct vimc_pix_map *vpix; 94 121 95 122 format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH, 96 123 VIMC_FRAME_MAX_WIDTH) & ~1; 97 124 format->height = clamp_t(u32, format->height, VIMC_FRAME_MIN_HEIGHT, 98 125 VIMC_FRAME_MAX_HEIGHT) & ~1; 99 126 100 - vimc_colorimetry_clamp(format); 127 + /* Don't accept a pixelformat that is not on the table */ 128 + vpix = vimc_pix_map_by_pixelformat(format->pixelformat); 129 + if (!vpix) { 130 + format->pixelformat = fmt_default.pixelformat; 131 + vpix = vimc_pix_map_by_pixelformat(format->pixelformat); 132 + } 133 + /* TODO: Add support for custom bytesperline values */ 134 + format->bytesperline = format->width * vpix->bpp; 135 + format->sizeimage = format->bytesperline * format->height; 101 136 102 137 if (format->field == V4L2_FIELD_ANY) 103 138 format->field = fmt_default.field; 104 139 105 - /* TODO: Add support for custom bytesperline values */ 140 + vimc_colorimetry_clamp(format); 106 141 107 - /* Don't accept a pixelformat that is not on the table */ 108 - if (!v4l2_format_info(format->pixelformat)) 109 - format->pixelformat = fmt_default.pixelformat; 110 - 111 - return v4l2_fill_pixfmt(format, format->pixelformat, 112 - format->width, format->height); 142 + return 0; 113 143 } 114 144 115 145 static int vimc_cap_s_fmt_vid_cap(struct file *file, void *priv, ··· 152 174 static int vimc_cap_enum_fmt_vid_cap(struct file *file, void *priv, 153 175 struct v4l2_fmtdesc *f) 154 176 { 155 - if (f->index >= ARRAY_SIZE(vimc_cap_supported_pixfmt)) 177 + const struct vimc_pix_map *vpix = vimc_pix_map_by_index(f->index); 178 + 179 + if (!vpix) 156 180 return -EINVAL; 157 181 158 - f->pixelformat = vimc_cap_supported_pixfmt[f->index]; 182 + f->pixelformat = vpix->pixelformat; 159 183 160 184 return 0; 161 - } 162 - 163 - static bool vimc_cap_is_pixfmt_supported(u32 pixelformat) 164 - { 165 - unsigned int i; 166 - 167 - for (i = 0; i < ARRAY_SIZE(vimc_cap_supported_pixfmt); i++) 168 - if (vimc_cap_supported_pixfmt[i] == pixelformat) 169 - return true; 170 - return false; 171 185 } 172 186 173 187 static int vimc_cap_enum_framesizes(struct file *file, void *fh, 174 188 struct v4l2_frmsizeenum *fsize) 175 189 { 190 + const struct vimc_pix_map *vpix; 191 + 176 192 if (fsize->index) 177 193 return -EINVAL; 178 194 179 - if (!vimc_cap_is_pixfmt_supported(fsize->pixel_format)) 195 + /* Only accept code in the pix map table */ 196 + vpix = vimc_pix_map_by_code(fsize->pixel_format); 197 + if (!vpix) 180 198 return -EINVAL; 181 199 182 200 fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; ··· 246 272 return ret; 247 273 } 248 274 249 - vcap->stream.producer_pixfmt = vcap->format.pixelformat; 250 275 ret = vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 1); 251 276 if (ret) { 252 277 media_pipeline_stop(entity); ··· 396 423 { 397 424 struct v4l2_device *v4l2_dev = master_data; 398 425 struct vimc_platform_data *pdata = comp->platform_data; 426 + const struct vimc_pix_map *vpix; 399 427 struct vimc_cap_device *vcap; 400 428 struct video_device *vdev; 401 429 struct vb2_queue *q; ··· 451 477 452 478 /* Set default frame format */ 453 479 vcap->format = fmt_default; 454 - v4l2_fill_pixfmt(&vcap->format, vcap->format.pixelformat, 455 - vcap->format.width, vcap->format.height); 480 + vpix = vimc_pix_map_by_pixelformat(vcap->format.pixelformat); 481 + vcap->format.bytesperline = vcap->format.width * vpix->bpp; 482 + vcap->format.sizeimage = vcap->format.bytesperline * 483 + vcap->format.height; 456 484 457 485 /* Fill the vimc_ent_device struct */ 458 486 vcap->ved.ent = &vcap->vdev.entity;
+180 -129
drivers/media/platform/vimc/vimc-common.c
··· 10 10 11 11 #include "vimc-common.h" 12 12 13 - static const __u32 vimc_mbus_list[] = { 14 - MEDIA_BUS_FMT_FIXED, 15 - MEDIA_BUS_FMT_RGB444_1X12, 16 - MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, 17 - MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE, 18 - MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, 19 - MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, 20 - MEDIA_BUS_FMT_RGB565_1X16, 21 - MEDIA_BUS_FMT_BGR565_2X8_BE, 22 - MEDIA_BUS_FMT_BGR565_2X8_LE, 23 - MEDIA_BUS_FMT_RGB565_2X8_BE, 24 - MEDIA_BUS_FMT_RGB565_2X8_LE, 25 - MEDIA_BUS_FMT_RGB666_1X18, 26 - MEDIA_BUS_FMT_RBG888_1X24, 27 - MEDIA_BUS_FMT_RGB666_1X24_CPADHI, 28 - MEDIA_BUS_FMT_RGB666_1X7X3_SPWG, 29 - MEDIA_BUS_FMT_BGR888_1X24, 30 - MEDIA_BUS_FMT_GBR888_1X24, 31 - MEDIA_BUS_FMT_RGB888_1X24, 32 - MEDIA_BUS_FMT_RGB888_2X12_BE, 33 - MEDIA_BUS_FMT_RGB888_2X12_LE, 34 - MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, 35 - MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, 36 - MEDIA_BUS_FMT_ARGB8888_1X32, 37 - MEDIA_BUS_FMT_RGB888_1X32_PADHI, 38 - MEDIA_BUS_FMT_RGB101010_1X30, 39 - MEDIA_BUS_FMT_RGB121212_1X36, 40 - MEDIA_BUS_FMT_RGB161616_1X48, 41 - MEDIA_BUS_FMT_Y8_1X8, 42 - MEDIA_BUS_FMT_UV8_1X8, 43 - MEDIA_BUS_FMT_UYVY8_1_5X8, 44 - MEDIA_BUS_FMT_VYUY8_1_5X8, 45 - MEDIA_BUS_FMT_YUYV8_1_5X8, 46 - MEDIA_BUS_FMT_YVYU8_1_5X8, 47 - MEDIA_BUS_FMT_UYVY8_2X8, 48 - MEDIA_BUS_FMT_VYUY8_2X8, 49 - MEDIA_BUS_FMT_YUYV8_2X8, 50 - MEDIA_BUS_FMT_YVYU8_2X8, 51 - MEDIA_BUS_FMT_Y10_1X10, 52 - MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 53 - MEDIA_BUS_FMT_UYVY10_2X10, 54 - MEDIA_BUS_FMT_VYUY10_2X10, 55 - MEDIA_BUS_FMT_YUYV10_2X10, 56 - MEDIA_BUS_FMT_YVYU10_2X10, 57 - MEDIA_BUS_FMT_Y12_1X12, 58 - MEDIA_BUS_FMT_UYVY12_2X12, 59 - MEDIA_BUS_FMT_VYUY12_2X12, 60 - MEDIA_BUS_FMT_YUYV12_2X12, 61 - MEDIA_BUS_FMT_YVYU12_2X12, 62 - MEDIA_BUS_FMT_UYVY8_1X16, 63 - MEDIA_BUS_FMT_VYUY8_1X16, 64 - MEDIA_BUS_FMT_YUYV8_1X16, 65 - MEDIA_BUS_FMT_YVYU8_1X16, 66 - MEDIA_BUS_FMT_YDYUYDYV8_1X16, 67 - MEDIA_BUS_FMT_UYVY10_1X20, 68 - MEDIA_BUS_FMT_VYUY10_1X20, 69 - MEDIA_BUS_FMT_YUYV10_1X20, 70 - MEDIA_BUS_FMT_YVYU10_1X20, 71 - MEDIA_BUS_FMT_VUY8_1X24, 72 - MEDIA_BUS_FMT_YUV8_1X24, 73 - MEDIA_BUS_FMT_UYYVYY8_0_5X24, 74 - MEDIA_BUS_FMT_UYVY12_1X24, 75 - MEDIA_BUS_FMT_VYUY12_1X24, 76 - MEDIA_BUS_FMT_YUYV12_1X24, 77 - MEDIA_BUS_FMT_YVYU12_1X24, 78 - MEDIA_BUS_FMT_YUV10_1X30, 79 - MEDIA_BUS_FMT_UYYVYY10_0_5X30, 80 - MEDIA_BUS_FMT_AYUV8_1X32, 81 - MEDIA_BUS_FMT_UYYVYY12_0_5X36, 82 - MEDIA_BUS_FMT_YUV12_1X36, 83 - MEDIA_BUS_FMT_YUV16_1X48, 84 - MEDIA_BUS_FMT_UYYVYY16_0_5X48, 85 - MEDIA_BUS_FMT_SBGGR8_1X8, 86 - MEDIA_BUS_FMT_SGBRG8_1X8, 87 - MEDIA_BUS_FMT_SGRBG8_1X8, 88 - MEDIA_BUS_FMT_SRGGB8_1X8, 89 - MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, 90 - MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, 91 - MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, 92 - MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, 93 - MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, 94 - MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, 95 - MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, 96 - MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, 97 - MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, 98 - MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 99 - MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, 100 - MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, 101 - MEDIA_BUS_FMT_SBGGR10_1X10, 102 - MEDIA_BUS_FMT_SGBRG10_1X10, 103 - MEDIA_BUS_FMT_SGRBG10_1X10, 104 - MEDIA_BUS_FMT_SRGGB10_1X10, 105 - MEDIA_BUS_FMT_SBGGR12_1X12, 106 - MEDIA_BUS_FMT_SGBRG12_1X12, 107 - MEDIA_BUS_FMT_SGRBG12_1X12, 108 - MEDIA_BUS_FMT_SRGGB12_1X12, 109 - MEDIA_BUS_FMT_SBGGR14_1X14, 110 - MEDIA_BUS_FMT_SGBRG14_1X14, 111 - MEDIA_BUS_FMT_SGRBG14_1X14, 112 - MEDIA_BUS_FMT_SRGGB14_1X14, 113 - MEDIA_BUS_FMT_SBGGR16_1X16, 114 - MEDIA_BUS_FMT_SGBRG16_1X16, 115 - MEDIA_BUS_FMT_SGRBG16_1X16, 116 - MEDIA_BUS_FMT_SRGGB16_1X16, 117 - MEDIA_BUS_FMT_JPEG_1X8, 118 - MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8, 119 - MEDIA_BUS_FMT_AHSV8888_1X32, 13 + /* 14 + * NOTE: non-bayer formats need to come first (necessary for enum_mbus_code 15 + * in the scaler) 16 + */ 17 + static const struct vimc_pix_map vimc_pix_map_list[] = { 18 + /* TODO: add all missing formats */ 19 + 20 + /* RGB formats */ 21 + { 22 + .code = MEDIA_BUS_FMT_BGR888_1X24, 23 + .pixelformat = V4L2_PIX_FMT_BGR24, 24 + .bpp = 3, 25 + .bayer = false, 26 + }, 27 + { 28 + .code = MEDIA_BUS_FMT_RGB888_1X24, 29 + .pixelformat = V4L2_PIX_FMT_RGB24, 30 + .bpp = 3, 31 + .bayer = false, 32 + }, 33 + { 34 + .code = MEDIA_BUS_FMT_ARGB8888_1X32, 35 + .pixelformat = V4L2_PIX_FMT_ARGB32, 36 + .bpp = 4, 37 + .bayer = false, 38 + }, 39 + 40 + /* Bayer formats */ 41 + { 42 + .code = MEDIA_BUS_FMT_SBGGR8_1X8, 43 + .pixelformat = V4L2_PIX_FMT_SBGGR8, 44 + .bpp = 1, 45 + .bayer = true, 46 + }, 47 + { 48 + .code = MEDIA_BUS_FMT_SGBRG8_1X8, 49 + .pixelformat = V4L2_PIX_FMT_SGBRG8, 50 + .bpp = 1, 51 + .bayer = true, 52 + }, 53 + { 54 + .code = MEDIA_BUS_FMT_SGRBG8_1X8, 55 + .pixelformat = V4L2_PIX_FMT_SGRBG8, 56 + .bpp = 1, 57 + .bayer = true, 58 + }, 59 + { 60 + .code = MEDIA_BUS_FMT_SRGGB8_1X8, 61 + .pixelformat = V4L2_PIX_FMT_SRGGB8, 62 + .bpp = 1, 63 + .bayer = true, 64 + }, 65 + { 66 + .code = MEDIA_BUS_FMT_SBGGR10_1X10, 67 + .pixelformat = V4L2_PIX_FMT_SBGGR10, 68 + .bpp = 2, 69 + .bayer = true, 70 + }, 71 + { 72 + .code = MEDIA_BUS_FMT_SGBRG10_1X10, 73 + .pixelformat = V4L2_PIX_FMT_SGBRG10, 74 + .bpp = 2, 75 + .bayer = true, 76 + }, 77 + { 78 + .code = MEDIA_BUS_FMT_SGRBG10_1X10, 79 + .pixelformat = V4L2_PIX_FMT_SGRBG10, 80 + .bpp = 2, 81 + .bayer = true, 82 + }, 83 + { 84 + .code = MEDIA_BUS_FMT_SRGGB10_1X10, 85 + .pixelformat = V4L2_PIX_FMT_SRGGB10, 86 + .bpp = 2, 87 + .bayer = true, 88 + }, 89 + 90 + /* 10bit raw bayer a-law compressed to 8 bits */ 91 + { 92 + .code = MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, 93 + .pixelformat = V4L2_PIX_FMT_SBGGR10ALAW8, 94 + .bpp = 1, 95 + .bayer = true, 96 + }, 97 + { 98 + .code = MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, 99 + .pixelformat = V4L2_PIX_FMT_SGBRG10ALAW8, 100 + .bpp = 1, 101 + .bayer = true, 102 + }, 103 + { 104 + .code = MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, 105 + .pixelformat = V4L2_PIX_FMT_SGRBG10ALAW8, 106 + .bpp = 1, 107 + .bayer = true, 108 + }, 109 + { 110 + .code = MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, 111 + .pixelformat = V4L2_PIX_FMT_SRGGB10ALAW8, 112 + .bpp = 1, 113 + .bayer = true, 114 + }, 115 + 116 + /* 10bit raw bayer DPCM compressed to 8 bits */ 117 + { 118 + .code = MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, 119 + .pixelformat = V4L2_PIX_FMT_SBGGR10DPCM8, 120 + .bpp = 1, 121 + .bayer = true, 122 + }, 123 + { 124 + .code = MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, 125 + .pixelformat = V4L2_PIX_FMT_SGBRG10DPCM8, 126 + .bpp = 1, 127 + .bayer = true, 128 + }, 129 + { 130 + .code = MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, 131 + .pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8, 132 + .bpp = 1, 133 + .bayer = true, 134 + }, 135 + { 136 + .code = MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, 137 + .pixelformat = V4L2_PIX_FMT_SRGGB10DPCM8, 138 + .bpp = 1, 139 + .bayer = true, 140 + }, 141 + { 142 + .code = MEDIA_BUS_FMT_SBGGR12_1X12, 143 + .pixelformat = V4L2_PIX_FMT_SBGGR12, 144 + .bpp = 2, 145 + .bayer = true, 146 + }, 147 + { 148 + .code = MEDIA_BUS_FMT_SGBRG12_1X12, 149 + .pixelformat = V4L2_PIX_FMT_SGBRG12, 150 + .bpp = 2, 151 + .bayer = true, 152 + }, 153 + { 154 + .code = MEDIA_BUS_FMT_SGRBG12_1X12, 155 + .pixelformat = V4L2_PIX_FMT_SGRBG12, 156 + .bpp = 2, 157 + .bayer = true, 158 + }, 159 + { 160 + .code = MEDIA_BUS_FMT_SRGGB12_1X12, 161 + .pixelformat = V4L2_PIX_FMT_SRGGB12, 162 + .bpp = 2, 163 + .bayer = true, 164 + }, 120 165 }; 121 166 122 - /* Helper function to check mbus codes */ 123 - bool vimc_mbus_code_supported(__u32 code) 167 + const struct vimc_pix_map *vimc_pix_map_by_index(unsigned int i) 168 + { 169 + if (i >= ARRAY_SIZE(vimc_pix_map_list)) 170 + return NULL; 171 + 172 + return &vimc_pix_map_list[i]; 173 + } 174 + EXPORT_SYMBOL_GPL(vimc_pix_map_by_index); 175 + 176 + const struct vimc_pix_map *vimc_pix_map_by_code(u32 code) 124 177 { 125 178 unsigned int i; 126 179 127 - for (i = 0; i < ARRAY_SIZE(vimc_mbus_list); i++) 128 - if (code == vimc_mbus_list[i]) 129 - return true; 130 - return false; 180 + for (i = 0; i < ARRAY_SIZE(vimc_pix_map_list); i++) { 181 + if (vimc_pix_map_list[i].code == code) 182 + return &vimc_pix_map_list[i]; 183 + } 184 + return NULL; 131 185 } 132 - EXPORT_SYMBOL_GPL(vimc_mbus_code_supported); 186 + EXPORT_SYMBOL_GPL(vimc_pix_map_by_code); 133 187 134 - /* Helper function to enumerate mbus codes */ 135 - int vimc_enum_mbus_code(struct v4l2_subdev *sd, 136 - struct v4l2_subdev_pad_config *cfg, 137 - struct v4l2_subdev_mbus_code_enum *code) 188 + const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat) 138 189 { 139 - if (code->index >= ARRAY_SIZE(vimc_mbus_list)) 140 - return -EINVAL; 190 + unsigned int i; 141 191 142 - code->code = vimc_mbus_list[code->index]; 143 - return 0; 192 + for (i = 0; i < ARRAY_SIZE(vimc_pix_map_list); i++) { 193 + if (vimc_pix_map_list[i].pixelformat == pixelformat) 194 + return &vimc_pix_map_list[i]; 195 + } 196 + return NULL; 144 197 } 145 - EXPORT_SYMBOL_GPL(vimc_enum_mbus_code); 198 + EXPORT_SYMBOL_GPL(vimc_pix_map_by_pixelformat); 146 199 147 200 /* Helper function to allocate and initialize pads */ 148 201 struct media_pad *vimc_pads_init(u16 num_pads, const unsigned long *pads_flag) ··· 267 214 struct video_device, 268 215 entity); 269 216 struct vimc_ent_device *ved = video_get_drvdata(vdev); 217 + const struct vimc_pix_map *vpix; 270 218 struct v4l2_pix_format vdev_fmt; 271 219 272 220 if (!ved->vdev_get_format) 273 221 return -ENOIOCTLCMD; 274 222 275 223 ved->vdev_get_format(ved, &vdev_fmt); 276 - v4l2_fill_mbus_format(&fmt->format, &vdev_fmt, 0); 224 + vpix = vimc_pix_map_by_pixelformat(vdev_fmt.pixelformat); 225 + v4l2_fill_mbus_format(&fmt->format, &vdev_fmt, vpix->code); 277 226 } else { 278 227 return -EINVAL; 279 228 } ··· 315 260 /* The width, height and code must match. */ 316 261 if (source_fmt.format.width != sink_fmt.format.width 317 262 || source_fmt.format.height != sink_fmt.format.height 318 - || (source_fmt.format.code && sink_fmt.format.code && 319 - source_fmt.format.code != sink_fmt.format.code)) { 320 - pr_err("vimc: format doesn't match in link %s->%s\n", 321 - link->source->entity->name, link->sink->entity->name); 263 + || source_fmt.format.code != sink_fmt.format.code) 322 264 return -EPIPE; 323 - } 324 265 325 266 /* 326 267 * The field order must match, or the sink field order must be NONE
+38 -20
drivers/media/platform/vimc/vimc-common.h
··· 12 12 #include <media/media-device.h> 13 13 #include <media/v4l2-device.h> 14 14 15 - #include "vimc-streamer.h" 16 - 17 15 #define VIMC_PDEV_NAME "vimc" 18 16 19 17 /* VIMC-specific controls */ ··· 68 70 }; 69 71 70 72 /** 73 + * struct vimc_pix_map - maps media bus code with v4l2 pixel format 74 + * 75 + * @code: media bus format code defined by MEDIA_BUS_FMT_* macros 76 + * @bbp: number of bytes each pixel occupies 77 + * @pixelformat: pixel format devined by V4L2_PIX_FMT_* macros 78 + * 79 + * Struct which matches the MEDIA_BUS_FMT_* codes with the corresponding 80 + * V4L2_PIX_FMT_* fourcc pixelformat and its bytes per pixel (bpp) 81 + */ 82 + struct vimc_pix_map { 83 + unsigned int code; 84 + unsigned int bpp; 85 + u32 pixelformat; 86 + bool bayer; 87 + }; 88 + 89 + /** 71 90 * struct vimc_ent_device - core struct that represents a node in the topology 72 91 * 73 92 * @ent: the pointer to struct media_entity for the node ··· 105 90 struct vimc_ent_device { 106 91 struct media_entity *ent; 107 92 struct media_pad *pads; 108 - struct vimc_stream *stream; 109 93 void * (*process_frame)(struct vimc_ent_device *ved, 110 94 const void *frame); 111 95 void (*vdev_get_format)(struct vimc_ent_device *ved, 112 96 struct v4l2_pix_format *fmt); 113 97 }; 114 - 115 - /** 116 - * vimc_mbus_code_supported - helper to check supported mbus codes 117 - * 118 - * Helper function to check if mbus code is enumerated by vimc_enum_mbus_code() 119 - */ 120 - bool vimc_mbus_code_supported(__u32 code); 121 - 122 - /** 123 - * vimc_enum_mbus_code - enumerate mbus codes 124 - * 125 - * Helper function to be pluged in .enum_mbus_code from 126 - * struct v4l2_subdev_pad_ops. 127 - */ 128 - int vimc_enum_mbus_code(struct v4l2_subdev *sd, 129 - struct v4l2_subdev_pad_config *cfg, 130 - struct v4l2_subdev_mbus_code_enum *code); 131 98 132 99 /** 133 100 * vimc_pads_init - initialize pads ··· 144 147 * in all the sink pads of the entity 145 148 */ 146 149 int vimc_pipeline_s_stream(struct media_entity *ent, int enable); 150 + 151 + /** 152 + * vimc_pix_map_by_index - get vimc_pix_map struct by its index 153 + * 154 + * @i: index of the vimc_pix_map struct in vimc_pix_map_list 155 + */ 156 + const struct vimc_pix_map *vimc_pix_map_by_index(unsigned int i); 157 + 158 + /** 159 + * vimc_pix_map_by_code - get vimc_pix_map struct by media bus code 160 + * 161 + * @code: media bus format code defined by MEDIA_BUS_FMT_* macros 162 + */ 163 + const struct vimc_pix_map *vimc_pix_map_by_code(u32 code); 164 + 165 + /** 166 + * vimc_pix_map_by_pixelformat - get vimc_pix_map struct by v4l2 pixel format 167 + * 168 + * @pixelformat: pixel format devined by V4L2_PIX_FMT_* macros 169 + */ 170 + const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat); 147 171 148 172 /** 149 173 * vimc_ent_sd_register - initialize and register a subdev node
+29 -54
drivers/media/platform/vimc/vimc-debayer.c
··· 16 16 #include "vimc-common.h" 17 17 18 18 #define VIMC_DEB_DRV_NAME "vimc-debayer" 19 - /* This module only supports transforming a bayer format 20 - * to V4L2_PIX_FMT_RGB24 21 - */ 22 - #define VIMC_DEB_SRC_PIXFMT V4L2_PIX_FMT_RGB24 23 - #define VIMC_DEB_SRC_MBUS_FMT_DEFAULT MEDIA_BUS_FMT_RGB888_1X24 24 19 25 20 static unsigned int deb_mean_win_size = 3; 26 21 module_param(deb_mean_win_size, uint, 0000); ··· 34 39 }; 35 40 36 41 struct vimc_deb_pix_map { 37 - u32 pixelformat; 38 42 u32 code; 39 43 enum vimc_deb_rgb_colors order[2][2]; 40 44 }; ··· 63 69 64 70 static const struct vimc_deb_pix_map vimc_deb_pix_map_list[] = { 65 71 { 66 - .pixelformat = V4L2_PIX_FMT_SBGGR8, 67 72 .code = MEDIA_BUS_FMT_SBGGR8_1X8, 68 73 .order = { { VIMC_DEB_BLUE, VIMC_DEB_GREEN }, 69 74 { VIMC_DEB_GREEN, VIMC_DEB_RED } } 70 75 }, 71 76 { 72 - .pixelformat = V4L2_PIX_FMT_SGBRG8, 73 77 .code = MEDIA_BUS_FMT_SGBRG8_1X8, 74 78 .order = { { VIMC_DEB_GREEN, VIMC_DEB_BLUE }, 75 79 { VIMC_DEB_RED, VIMC_DEB_GREEN } } 76 80 }, 77 81 { 78 - .pixelformat = V4L2_PIX_FMT_SGRBG8, 79 82 .code = MEDIA_BUS_FMT_SGRBG8_1X8, 80 83 .order = { { VIMC_DEB_GREEN, VIMC_DEB_RED }, 81 84 { VIMC_DEB_BLUE, VIMC_DEB_GREEN } } 82 85 }, 83 86 { 84 - .pixelformat = V4L2_PIX_FMT_SRGGB8, 85 87 .code = MEDIA_BUS_FMT_SRGGB8_1X8, 86 88 .order = { { VIMC_DEB_RED, VIMC_DEB_GREEN }, 87 89 { VIMC_DEB_GREEN, VIMC_DEB_BLUE } } 88 90 }, 89 91 { 90 - .pixelformat = V4L2_PIX_FMT_SBGGR10, 91 92 .code = MEDIA_BUS_FMT_SBGGR10_1X10, 92 93 .order = { { VIMC_DEB_BLUE, VIMC_DEB_GREEN }, 93 94 { VIMC_DEB_GREEN, VIMC_DEB_RED } } 94 95 }, 95 96 { 96 - .pixelformat = V4L2_PIX_FMT_SGBRG10, 97 97 .code = MEDIA_BUS_FMT_SGBRG10_1X10, 98 98 .order = { { VIMC_DEB_GREEN, VIMC_DEB_BLUE }, 99 99 { VIMC_DEB_RED, VIMC_DEB_GREEN } } 100 100 }, 101 101 { 102 - .pixelformat = V4L2_PIX_FMT_SGRBG10, 103 102 .code = MEDIA_BUS_FMT_SGRBG10_1X10, 104 103 .order = { { VIMC_DEB_GREEN, VIMC_DEB_RED }, 105 104 { VIMC_DEB_BLUE, VIMC_DEB_GREEN } } 106 105 }, 107 106 { 108 - .pixelformat = V4L2_PIX_FMT_SRGGB10, 109 107 .code = MEDIA_BUS_FMT_SRGGB10_1X10, 110 108 .order = { { VIMC_DEB_RED, VIMC_DEB_GREEN }, 111 109 { VIMC_DEB_GREEN, VIMC_DEB_BLUE } } 112 110 }, 113 111 { 114 - .pixelformat = V4L2_PIX_FMT_SBGGR12, 115 112 .code = MEDIA_BUS_FMT_SBGGR12_1X12, 116 113 .order = { { VIMC_DEB_BLUE, VIMC_DEB_GREEN }, 117 114 { VIMC_DEB_GREEN, VIMC_DEB_RED } } 118 115 }, 119 116 { 120 - .pixelformat = V4L2_PIX_FMT_SGBRG12, 121 117 .code = MEDIA_BUS_FMT_SGBRG12_1X12, 122 118 .order = { { VIMC_DEB_GREEN, VIMC_DEB_BLUE }, 123 119 { VIMC_DEB_RED, VIMC_DEB_GREEN } } 124 120 }, 125 121 { 126 - .pixelformat = V4L2_PIX_FMT_SGRBG12, 127 122 .code = MEDIA_BUS_FMT_SGRBG12_1X12, 128 123 .order = { { VIMC_DEB_GREEN, VIMC_DEB_RED }, 129 124 { VIMC_DEB_BLUE, VIMC_DEB_GREEN } } 130 125 }, 131 126 { 132 - .pixelformat = V4L2_PIX_FMT_SRGGB12, 133 127 .code = MEDIA_BUS_FMT_SRGGB12_1X12, 134 128 .order = { { VIMC_DEB_RED, VIMC_DEB_GREEN }, 135 129 { VIMC_DEB_GREEN, VIMC_DEB_BLUE } } ··· 158 176 struct v4l2_subdev_pad_config *cfg, 159 177 struct v4l2_subdev_mbus_code_enum *code) 160 178 { 161 - /* For the sink pad we only support codes in the map_list */ 162 - if (IS_SINK(code->pad)) { 179 + /* We only support one format for source pads */ 180 + if (IS_SRC(code->pad)) { 181 + struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd); 182 + 183 + if (code->index) 184 + return -EINVAL; 185 + 186 + code->code = vdeb->src_code; 187 + } else { 163 188 if (code->index >= ARRAY_SIZE(vimc_deb_pix_map_list)) 164 189 return -EINVAL; 165 190 166 191 code->code = vimc_deb_pix_map_list[code->index].code; 167 - return 0; 168 192 } 169 193 170 - return vimc_enum_mbus_code(sd, cfg, code); 194 + return 0; 171 195 } 172 196 173 197 static int vimc_deb_enum_frame_size(struct v4l2_subdev *sd, 174 198 struct v4l2_subdev_pad_config *cfg, 175 199 struct v4l2_subdev_frame_size_enum *fse) 176 200 { 201 + struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd); 202 + 177 203 if (fse->index) 178 204 return -EINVAL; 179 205 180 - /* For the sink pad we only support codes in the map_list */ 181 206 if (IS_SINK(fse->pad)) { 182 207 const struct vimc_deb_pix_map *vpix = 183 208 vimc_deb_pix_map_by_code(fse->code); 184 209 185 210 if (!vpix) 186 211 return -EINVAL; 212 + } else if (fse->code != vdeb->src_code) { 213 + return -EINVAL; 187 214 } 188 215 189 216 fse->min_width = VIMC_FRAME_MIN_WIDTH; ··· 248 257 struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd); 249 258 struct v4l2_mbus_framefmt *sink_fmt; 250 259 251 - if (!vimc_mbus_code_supported(fmt->format.code)) 252 - fmt->format.code = sink_fmt_default.code; 253 - 254 260 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 255 261 /* Do not change the format while stream is on */ 256 262 if (vdeb->src_frame) ··· 260 272 261 273 /* 262 274 * Do not change the format of the source pad, 263 - * it is propagated from the sink (except for the code) 275 + * it is propagated from the sink 264 276 */ 265 277 if (IS_SRC(fmt->pad)) { 266 - vdeb->src_code = fmt->format.code; 267 278 fmt->format = *sink_fmt; 279 + /* TODO: Add support for other formats */ 268 280 fmt->format.code = vdeb->src_code; 269 281 } else { 270 282 /* Set the new format in the sink pad */ ··· 296 308 .set_fmt = vimc_deb_set_fmt, 297 309 }; 298 310 299 - static void vimc_deb_set_rgb_pix_rgb24(struct vimc_deb_device *vdeb, 311 + static void vimc_deb_set_rgb_mbus_fmt_rgb888_1x24(struct vimc_deb_device *vdeb, 300 312 unsigned int lin, 301 313 unsigned int col, 302 314 unsigned int rgb[3]) ··· 313 325 struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd); 314 326 315 327 if (enable) { 316 - u32 src_pixelformat = vdeb->ved.stream->producer_pixfmt; 317 - const struct v4l2_format_info *pix_info; 328 + const struct vimc_pix_map *vpix; 318 329 unsigned int frame_size; 319 330 320 331 if (vdeb->src_frame) 321 332 return 0; 322 333 323 - /* We only support translating bayer to RGB24 */ 324 - if (src_pixelformat != V4L2_PIX_FMT_RGB24) { 325 - dev_err(vdeb->dev, 326 - "translating to pixfmt (0x%08x) is not supported\n", 327 - src_pixelformat); 328 - return -EINVAL; 329 - } 334 + /* Calculate the frame size of the source pad */ 335 + vpix = vimc_pix_map_by_code(vdeb->src_code); 336 + frame_size = vdeb->sink_fmt.width * vdeb->sink_fmt.height * 337 + vpix->bpp; 338 + 339 + /* Save the bytes per pixel of the sink */ 340 + vpix = vimc_pix_map_by_code(vdeb->sink_fmt.code); 341 + vdeb->sink_bpp = vpix->bpp; 330 342 331 343 /* Get the corresponding pixel map from the table */ 332 344 vdeb->sink_pix_map = 333 345 vimc_deb_pix_map_by_code(vdeb->sink_fmt.code); 334 - 335 - /* Request bayer format from the pipeline for the sink pad */ 336 - vdeb->ved.stream->producer_pixfmt = 337 - vdeb->sink_pix_map->pixelformat; 338 - 339 - /* Calculate frame_size of the source */ 340 - pix_info = v4l2_format_info(src_pixelformat); 341 - frame_size = vdeb->sink_fmt.width * vdeb->sink_fmt.height * 342 - pix_info->bpp[0]; 343 - 344 - /* Get bpp from the sink */ 345 - pix_info = v4l2_format_info(vdeb->sink_pix_map->pixelformat); 346 - vdeb->sink_bpp = pix_info->bpp[0]; 347 346 348 347 /* 349 348 * Allocate the frame buffer. Use vmalloc to be able to ··· 532 557 533 558 /* Initialize the frame format */ 534 559 vdeb->sink_fmt = sink_fmt_default; 535 - vdeb->src_code = VIMC_DEB_SRC_MBUS_FMT_DEFAULT; 536 560 /* 537 561 * TODO: Add support for more output formats, we only support 538 - * RGB24 for now. 562 + * RGB888 for now 539 563 * NOTE: the src format is always the same as the sink, except 540 564 * for the code 541 565 */ 542 - vdeb->set_rgb_src = vimc_deb_set_rgb_pix_rgb24; 566 + vdeb->src_code = MEDIA_BUS_FMT_RGB888_1X24; 567 + vdeb->set_rgb_src = vimc_deb_set_rgb_mbus_fmt_rgb888_1x24; 543 568 544 569 return 0; 545 570 }
+33 -30
drivers/media/platform/vimc/vimc-scaler.c
··· 25 25 #define IS_SRC(pad) (pad) 26 26 #define MAX_ZOOM 8 27 27 28 - static const u32 vimc_sca_supported_pixfmt[] = { 29 - V4L2_PIX_FMT_BGR24, 30 - V4L2_PIX_FMT_RGB24, 31 - V4L2_PIX_FMT_ARGB32, 32 - }; 33 - 34 28 struct vimc_sca_device { 35 29 struct vimc_ent_device ved; 36 30 struct v4l2_subdev sd; ··· 47 53 .colorspace = V4L2_COLORSPACE_DEFAULT, 48 54 }; 49 55 50 - static bool vimc_sca_is_pixfmt_supported(u32 pixelformat) 51 - { 52 - unsigned int i; 53 - 54 - for (i = 0; i < ARRAY_SIZE(vimc_sca_supported_pixfmt); i++) 55 - if (vimc_sca_supported_pixfmt[i] == pixelformat) 56 - return true; 57 - return false; 58 - } 59 - 60 56 static int vimc_sca_init_cfg(struct v4l2_subdev *sd, 61 57 struct v4l2_subdev_pad_config *cfg) 62 58 { ··· 66 82 return 0; 67 83 } 68 84 85 + static int vimc_sca_enum_mbus_code(struct v4l2_subdev *sd, 86 + struct v4l2_subdev_pad_config *cfg, 87 + struct v4l2_subdev_mbus_code_enum *code) 88 + { 89 + const struct vimc_pix_map *vpix = vimc_pix_map_by_index(code->index); 90 + 91 + /* We don't support bayer format */ 92 + if (!vpix || vpix->bayer) 93 + return -EINVAL; 94 + 95 + code->code = vpix->code; 96 + 97 + return 0; 98 + } 99 + 69 100 static int vimc_sca_enum_frame_size(struct v4l2_subdev *sd, 70 101 struct v4l2_subdev_pad_config *cfg, 71 102 struct v4l2_subdev_frame_size_enum *fse) 72 103 { 104 + const struct vimc_pix_map *vpix; 105 + 73 106 if (fse->index) 107 + return -EINVAL; 108 + 109 + /* Only accept code in the pix map table in non bayer format */ 110 + vpix = vimc_pix_map_by_code(fse->code); 111 + if (!vpix || vpix->bayer) 74 112 return -EINVAL; 75 113 76 114 fse->min_width = VIMC_FRAME_MIN_WIDTH; ··· 131 125 132 126 static void vimc_sca_adjust_sink_fmt(struct v4l2_mbus_framefmt *fmt) 133 127 { 128 + const struct vimc_pix_map *vpix; 129 + 130 + /* Only accept code in the pix map table in non bayer format */ 131 + vpix = vimc_pix_map_by_code(fmt->code); 132 + if (!vpix || vpix->bayer) 133 + fmt->code = sink_fmt_default.code; 134 + 134 135 fmt->width = clamp_t(u32, fmt->width, VIMC_FRAME_MIN_WIDTH, 135 136 VIMC_FRAME_MAX_WIDTH) & ~1; 136 137 fmt->height = clamp_t(u32, fmt->height, VIMC_FRAME_MIN_HEIGHT, ··· 155 142 { 156 143 struct vimc_sca_device *vsca = v4l2_get_subdevdata(sd); 157 144 struct v4l2_mbus_framefmt *sink_fmt; 158 - 159 - if (!vimc_mbus_code_supported(fmt->format.code)) 160 - fmt->format.code = sink_fmt_default.code; 161 145 162 146 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 163 147 /* Do not change the format while stream is on */ ··· 198 188 199 189 static const struct v4l2_subdev_pad_ops vimc_sca_pad_ops = { 200 190 .init_cfg = vimc_sca_init_cfg, 201 - .enum_mbus_code = vimc_enum_mbus_code, 191 + .enum_mbus_code = vimc_sca_enum_mbus_code, 202 192 .enum_frame_size = vimc_sca_enum_frame_size, 203 193 .get_fmt = vimc_sca_get_fmt, 204 194 .set_fmt = vimc_sca_set_fmt, ··· 209 199 struct vimc_sca_device *vsca = v4l2_get_subdevdata(sd); 210 200 211 201 if (enable) { 212 - u32 pixelformat = vsca->ved.stream->producer_pixfmt; 213 - const struct v4l2_format_info *pix_info; 202 + const struct vimc_pix_map *vpix; 214 203 unsigned int frame_size; 215 204 216 205 if (vsca->src_frame) 217 206 return 0; 218 207 219 - if (!vimc_sca_is_pixfmt_supported(pixelformat)) { 220 - dev_err(vsca->dev, "pixfmt (0x%08x) is not supported\n", 221 - pixelformat); 222 - return -EINVAL; 223 - } 224 - 225 208 /* Save the bytes per pixel of the sink */ 226 - pix_info = v4l2_format_info(pixelformat); 227 - vsca->bpp = pix_info->bpp[0]; 209 + vpix = vimc_pix_map_by_code(vsca->sink_fmt.code); 210 + vsca->bpp = vpix->bpp; 228 211 229 212 /* Calculate the width in bytes of the src frame */ 230 213 vsca->src_line_size = vsca->sink_fmt.width *
+36 -15
drivers/media/platform/vimc/vimc-sensor.c
··· 55 55 return 0; 56 56 } 57 57 58 + static int vimc_sen_enum_mbus_code(struct v4l2_subdev *sd, 59 + struct v4l2_subdev_pad_config *cfg, 60 + struct v4l2_subdev_mbus_code_enum *code) 61 + { 62 + const struct vimc_pix_map *vpix = vimc_pix_map_by_index(code->index); 63 + 64 + if (!vpix) 65 + return -EINVAL; 66 + 67 + code->code = vpix->code; 68 + 69 + return 0; 70 + } 71 + 58 72 static int vimc_sen_enum_frame_size(struct v4l2_subdev *sd, 59 73 struct v4l2_subdev_pad_config *cfg, 60 74 struct v4l2_subdev_frame_size_enum *fse) 61 75 { 76 + const struct vimc_pix_map *vpix; 77 + 62 78 if (fse->index) 79 + return -EINVAL; 80 + 81 + /* Only accept code in the pix map table */ 82 + vpix = vimc_pix_map_by_code(fse->code); 83 + if (!vpix) 63 84 return -EINVAL; 64 85 65 86 fse->min_width = VIMC_FRAME_MIN_WIDTH; ··· 107 86 108 87 static void vimc_sen_tpg_s_format(struct vimc_sen_device *vsen) 109 88 { 110 - u32 pixelformat = vsen->ved.stream->producer_pixfmt; 111 - const struct v4l2_format_info *pix_info; 112 - 113 - pix_info = v4l2_format_info(pixelformat); 89 + const struct vimc_pix_map *vpix = 90 + vimc_pix_map_by_code(vsen->mbus_format.code); 114 91 115 92 tpg_reset_source(&vsen->tpg, vsen->mbus_format.width, 116 93 vsen->mbus_format.height, vsen->mbus_format.field); 117 - tpg_s_bytesperline(&vsen->tpg, 0, 118 - vsen->mbus_format.width * pix_info->bpp[0]); 94 + tpg_s_bytesperline(&vsen->tpg, 0, vsen->mbus_format.width * vpix->bpp); 119 95 tpg_s_buf_height(&vsen->tpg, vsen->mbus_format.height); 120 - tpg_s_fourcc(&vsen->tpg, pixelformat); 96 + tpg_s_fourcc(&vsen->tpg, vpix->pixelformat); 121 97 /* TODO: add support for V4L2_FIELD_ALTERNATE */ 122 98 tpg_s_field(&vsen->tpg, vsen->mbus_format.field, false); 123 99 tpg_s_colorspace(&vsen->tpg, vsen->mbus_format.colorspace); ··· 125 107 126 108 static void vimc_sen_adjust_fmt(struct v4l2_mbus_framefmt *fmt) 127 109 { 110 + const struct vimc_pix_map *vpix; 111 + 112 + /* Only accept code in the pix map table */ 113 + vpix = vimc_pix_map_by_code(fmt->code); 114 + if (!vpix) 115 + fmt->code = fmt_default.code; 116 + 128 117 fmt->width = clamp_t(u32, fmt->width, VIMC_FRAME_MIN_WIDTH, 129 118 VIMC_FRAME_MAX_WIDTH) & ~1; 130 119 fmt->height = clamp_t(u32, fmt->height, VIMC_FRAME_MIN_HEIGHT, ··· 150 125 { 151 126 struct vimc_sen_device *vsen = v4l2_get_subdevdata(sd); 152 127 struct v4l2_mbus_framefmt *mf; 153 - 154 - if (!vimc_mbus_code_supported(fmt->format.code)) 155 - fmt->format.code = fmt_default.code; 156 128 157 129 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 158 130 /* Do not change the format while stream is on */ ··· 183 161 184 162 static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = { 185 163 .init_cfg = vimc_sen_init_cfg, 186 - .enum_mbus_code = vimc_enum_mbus_code, 164 + .enum_mbus_code = vimc_sen_enum_mbus_code, 187 165 .enum_frame_size = vimc_sen_enum_frame_size, 188 166 .get_fmt = vimc_sen_get_fmt, 189 167 .set_fmt = vimc_sen_set_fmt, ··· 205 183 container_of(sd, struct vimc_sen_device, sd); 206 184 207 185 if (enable) { 208 - u32 pixelformat = vsen->ved.stream->producer_pixfmt; 209 - const struct v4l2_format_info *pix_info; 186 + const struct vimc_pix_map *vpix; 210 187 unsigned int frame_size; 211 188 212 189 if (vsen->kthread_sen) ··· 213 192 return 0; 214 193 215 194 /* Calculate the frame size */ 216 - pix_info = v4l2_format_info(pixelformat); 217 - frame_size = vsen->mbus_format.width * pix_info->bpp[0] * 195 + vpix = vimc_pix_map_by_code(vsen->mbus_format.code); 196 + frame_size = vsen->mbus_format.width * vpix->bpp * 218 197 vsen->mbus_format.height; 219 198 220 199 /*
-2
drivers/media/platform/vimc/vimc-streamer.c
··· 54 54 while (stream->pipe_size) { 55 55 stream->pipe_size--; 56 56 ved = stream->ved_pipeline[stream->pipe_size]; 57 - ved->stream = NULL; 58 57 stream->ved_pipeline[stream->pipe_size] = NULL; 59 58 60 59 if (!is_media_entity_v4l2_subdev(ved->ent)) ··· 92 93 return -EINVAL; 93 94 } 94 95 stream->ved_pipeline[stream->pipe_size++] = ved; 95 - ved->stream = stream; 96 96 97 97 if (is_media_entity_v4l2_subdev(ved->ent)) { 98 98 sd = media_entity_to_v4l2_subdev(ved->ent);
-8
drivers/media/platform/vimc/vimc-streamer.h
··· 25 25 * processed in the pipeline. 26 26 * @pipe_size: size of @ved_pipeline 27 27 * @kthread: thread that generates the frames of the stream. 28 - * @producer_pixfmt: the pixel format requested from the pipeline. This must 29 - * be set just before calling 30 - * vimc_streamer_s_stream(ent, 1). This value is propagated 31 - * up to the source of the base image (usually a sensor 32 - * node) and can be modified by entities during s_stream 33 - * callback to request a differentformat from rest of 34 - * the pipeline. 35 28 * 36 29 * When the user call stream_on in a video device, struct vimc_stream is 37 30 * used to keep track of all entities and subdevices that generates and ··· 35 42 struct vimc_ent_device *ved_pipeline[VIMC_STREAMER_PIPELINE_MAX_SIZE]; 36 43 unsigned int pipe_size; 37 44 struct task_struct *kthread; 38 - u32 producer_pixfmt; 39 45 }; 40 46 41 47 int vimc_streamer_s_stream(struct vimc_stream *stream,