From 3b3f2d97e9746739b87554146a511aba8191f12d Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 1 Mar 2024 19:59:16 +0900 Subject: [PATCH] arch: cxd56: Follow interface change of set_buf() operation set_buf() operation is changed to have the argument about format. Follow the change. --- arch/arm/src/cxd56xx/cxd56_cisif.c | 43 +++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/arch/arm/src/cxd56xx/cxd56_cisif.c b/arch/arm/src/cxd56xx/cxd56_cisif.c index 651e625bf0..dcb30fa2b3 100644 --- a/arch/arm/src/cxd56xx/cxd56_cisif.c +++ b/arch/arm/src/cxd56xx/cxd56_cisif.c @@ -978,14 +978,36 @@ static int cxd56_cisif_validate_buf(struct imgdata_s *data, return OK; } +static int32_t cisif_get_mode(uint8_t nr_datafmts, + imgdata_format_t *datafmts) +{ + switch (datafmts[IMGDATA_FMT_MAIN].pixelformat) + { + case IMGDATA_PIX_FMT_UYVY: /* YUV 4:2:2 */ + case IMGDATA_PIX_FMT_RGB565: /* RGB565 */ + + /* CISIF does not distinguish between YUV and RGB */ + + return MODE_YUV_TRS_EN; + + case IMGDATA_PIX_FMT_JPEG: /* JPEG */ + return MODE_JPG_TRS_EN; + + case IMGDATA_PIX_FMT_JPEG_WITH_SUBIMG: /* JPEG + YUV 4:2:2 */ + return MODE_INTLEV_TRS_EN; + + default: + return -EINVAL; + } +} + static int cxd56_cisif_set_buf(struct imgdata_s *data, uint8_t nr_datafmts, - FAR imgdata_format_t *datafmts, + imgdata_format_t *datafmts, uint8_t *addr, uint32_t size) { int ret; - uint32_t mode; - uint32_t regval; + int32_t mode; uint16_t w; uint16_t h; @@ -995,7 +1017,7 @@ static int cxd56_cisif_set_buf(struct imgdata_s *data, return ret; } - mode = cisif_reg_read(CISIF_MODE); + mode = cisif_get_mode(nr_datafmts, datafmts); switch (mode) { @@ -1007,18 +1029,19 @@ static int cxd56_cisif_set_buf(struct imgdata_s *data, ret = cisif_set_jpg_sarea(addr, size); break; - default: /* MODE_INTLEV_TRS_EN */ + case MODE_INTLEV_TRS_EN: - /* Get YUV frame size information */ - - regval = cisif_reg_read(CISIF_ACT_SIZE); - h = (regval >> 16) & 0x1ff; - w = regval & 0x01ff; + w = datafmts[IMGDATA_FMT_SUB].width; + h = datafmts[IMGDATA_FMT_SUB].height; ret = cisif_set_intlev_sarea(addr, size, YUV_SIZE(w, h)); break; + + default: + ret = -EINVAL; + break; } if (ret != OK)