@@ -68,14 +68,12 @@ struct rzg2l_cru_ip {
* @code: Media bus code
* @format: 4CC format identifier (V4L2_PIX_FMT_*)
* @datatype: MIPI CSI2 data type
- * @bpp: bytes per pixel
* @icndmr: ICnDMR register value
*/
struct rzg2l_cru_ip_format {
u32 code;
u32 format;
u32 datatype;
- u8 bpp;
u32 icndmr;
};
@@ -169,7 +167,6 @@ void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format);
int rzg2l_cru_ip_index_to_pix_fmt(u32 index);
int rzg2l_cru_ip_pix_fmt_to_icndmr(u32 format);
@@ -16,35 +16,30 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
.code = MEDIA_BUS_FMT_UYVY8_1X16,
.format = V4L2_PIX_FMT_UYVY,
.datatype = MIPI_CSI2_DT_YUV422_8B,
- .bpp = 2,
.icndmr = ICnDMR_YCMODE_UYVY,
},
{
.code = MEDIA_BUS_FMT_SBGGR8_1X8,
.format = V4L2_PIX_FMT_SBGGR8,
.datatype = MIPI_CSI2_DT_RAW8,
- .bpp = 1,
.icndmr = 0,
},
{
.code = MEDIA_BUS_FMT_SGBRG8_1X8,
.format = V4L2_PIX_FMT_SGBRG8,
.datatype = MIPI_CSI2_DT_RAW8,
- .bpp = 1,
.icndmr = 0,
},
{
.code = MEDIA_BUS_FMT_SGRBG8_1X8,
.format = V4L2_PIX_FMT_SGRBG8,
.datatype = MIPI_CSI2_DT_RAW8,
- .bpp = 1,
.icndmr = 0,
},
{
.code = MEDIA_BUS_FMT_SRGGB8_1X8,
.format = V4L2_PIX_FMT_SRGGB8,
.datatype = MIPI_CSI2_DT_RAW8,
- .bpp = 1,
.icndmr = 0,
},
};
@@ -60,17 +55,6 @@ const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
return NULL;
}
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++)
- if (rzg2l_cru_ip_formats[i].format == format)
- return rzg2l_cru_ip_formats[i].bpp;
-
- return 0;
-}
-
int rzg2l_cru_ip_index_to_pix_fmt(u32 index)
{
if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats))
@@ -800,27 +800,11 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
* V4L2 stuff
*/
-static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
-{
- u8 bpp;
-
- bpp = rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat);
-
- if (WARN_ON(!bpp))
- return 0;
-
- return pix->width * bpp;
-}
-
-static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix)
-{
- return pix->bytesperline * pix->height;
-}
static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
struct v4l2_pix_format *pix)
{
- if (!rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat))
+ if (rzg2l_cru_ip_pix_fmt_to_icndmr(pix->pixelformat) < 0)
pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
switch (pix->field) {
@@ -840,8 +824,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH, 1,
&pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
- pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
- pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
+ v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);
dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
pix->width, pix->height, pix->bytesperline, pix->sizeimage);