2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-24 05:04:00 +08:00

media: atmel: atmel-isc-base: add support for Y10 format

The ISC can receive input from sensors using Y10 format directly
(10 bits greyscale). In this case, the ISC must dump the data directly,
either as GREY (8bit) or Y10 (10bit).
Y16 is not supported because we cannot align the MSB 10 bits to the MSB
inside the 16bit container.
For this format, the ISC internal pipeline cannot work (only works with
BAYER), so we must dump the data directly as 8bit/10bit.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Eugen Hristev 2019-11-25 09:32:49 +01:00 committed by Mauro Carvalho Chehab
parent 62387970a4
commit ab04e7e643

View File

@ -73,6 +73,9 @@ const struct isc_format controller_formats[] = {
{ {
.fourcc = V4L2_PIX_FMT_GREY, .fourcc = V4L2_PIX_FMT_GREY,
}, },
{
.fourcc = V4L2_PIX_FMT_Y10,
},
}; };
/* This is a list of formats that the ISC can receive as *input* */ /* This is a list of formats that the ISC can receive as *input* */
@ -164,6 +167,12 @@ struct isc_format formats_list[] = {
.mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE,
.pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT, .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
}, },
{
.fourcc = V4L2_PIX_FMT_Y10,
.mbus_code = MEDIA_BUS_FMT_Y10_1X10,
.pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
},
}; };
/* Gamma table with gamma 1/2.2 */ /* Gamma table with gamma 1/2.2 */
@ -211,6 +220,10 @@ const u32 isc_gamma_table[GAMMA_MAX + 1][GAMMA_ENTRIES] = {
#define ISC_IS_FORMAT_RAW(mbus_code) \ #define ISC_IS_FORMAT_RAW(mbus_code) \
(((mbus_code) & 0xf000) == 0x3000) (((mbus_code) & 0xf000) == 0x3000)
#define ISC_IS_FORMAT_GREY(mbus_code) \
(((mbus_code) == MEDIA_BUS_FMT_Y10_1X10) | \
(((mbus_code) == MEDIA_BUS_FMT_Y8_1X8)))
static inline void isc_update_awb_ctrls(struct isc_device *isc) static inline void isc_update_awb_ctrls(struct isc_device *isc)
{ {
struct isc_ctrls *ctrls = &isc->ctrls; struct isc_ctrls *ctrls = &isc->ctrls;
@ -1003,6 +1016,7 @@ static int isc_try_validate_formats(struct isc_device *isc)
rgb = true; rgb = true;
break; break;
case V4L2_PIX_FMT_GREY: case V4L2_PIX_FMT_GREY:
case V4L2_PIX_FMT_Y10:
ret = 0; ret = 0;
grey = true; grey = true;
break; break;
@ -1010,16 +1024,19 @@ static int isc_try_validate_formats(struct isc_device *isc)
/* any other different formats are not supported */ /* any other different formats are not supported */
ret = -EINVAL; ret = -EINVAL;
} }
/* we cannot output RAW/Grey if we do not receive RAW */
if ((bayer || grey) &&
!ISC_IS_FORMAT_RAW(isc->try_config.sd_format->mbus_code))
return -EINVAL;
v4l2_dbg(1, debug, &isc->v4l2_dev, v4l2_dbg(1, debug, &isc->v4l2_dev,
"Format validation, requested rgb=%u, yuv=%u, grey=%u, bayer=%u\n", "Format validation, requested rgb=%u, yuv=%u, grey=%u, bayer=%u\n",
rgb, yuv, grey, bayer); rgb, yuv, grey, bayer);
/* we cannot output RAW if we do not receive RAW */
if ((bayer) && !ISC_IS_FORMAT_RAW(isc->try_config.sd_format->mbus_code))
return -EINVAL;
/* we cannot output GREY if we do not receive RAW/GREY */
if (grey && !ISC_IS_FORMAT_RAW(isc->try_config.sd_format->mbus_code) &&
!ISC_IS_FORMAT_GREY(isc->try_config.sd_format->mbus_code))
return -EINVAL;
return ret; return ret;
} }
@ -1107,6 +1124,12 @@ static int isc_try_configure_rlp_dma(struct isc_device *isc, bool direct_dump)
isc->try_config.dctrl_dview = ISC_DCTRL_DVIEW_PACKED; isc->try_config.dctrl_dview = ISC_DCTRL_DVIEW_PACKED;
isc->try_config.bpp = 8; isc->try_config.bpp = 8;
break; break;
case V4L2_PIX_FMT_Y10:
isc->try_config.rlp_cfg_mode = ISC_RLP_CFG_MODE_DATY10;
isc->try_config.dcfg_imode = ISC_DCFG_IMODE_PACKED16;
isc->try_config.dctrl_dview = ISC_DCTRL_DVIEW_PACKED;
isc->try_config.bpp = 16;
break;
default: default:
return -EINVAL; return -EINVAL;
} }