Commit 19b18e78 authored by Chen-Yu Tsai's avatar Chen-Yu Tsai Committed by Mauro Carvalho Chehab

media: sun6i: Add support for RGB565 formats

The CSI controller can take raw data from the data bus and output RGB565
format. The controller does not distinguish between RGB565 LE and BE.
Instead this is determined by the media bus format, i.e. the format or
order the sensor is sending data in.
Signed-off-by: default avatarChen-Yu Tsai <wens@csie.org>
Acked-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent d31b282e
......@@ -144,6 +144,12 @@ bool sun6i_csi_is_format_supported(struct sun6i_csi *csi,
break;
}
break;
case V4L2_PIX_FMT_RGB565:
return (mbus_code == MEDIA_BUS_FMT_RGB565_2X8_LE);
case V4L2_PIX_FMT_RGB565X:
return (mbus_code == MEDIA_BUS_FMT_RGB565_2X8_BE);
default:
dev_dbg(sdev->dev, "Unsupported pixformat: 0x%x\n", pixformat);
break;
......@@ -208,8 +214,8 @@ int sun6i_csi_set_power(struct sun6i_csi *csi, bool enable)
static enum csi_input_fmt get_csi_input_format(struct sun6i_csi_dev *sdev,
u32 mbus_code, u32 pixformat)
{
/* bayer */
if ((mbus_code & 0xF000) == 0x3000)
/* non-YUV */
if ((mbus_code & 0xF000) != 0x2000)
return CSI_INPUT_FORMAT_RAW;
switch (pixformat) {
......@@ -278,6 +284,11 @@ static enum csi_output_fmt get_csi_output_format(struct sun6i_csi_dev *sdev,
case V4L2_PIX_FMT_YUV422P:
return buf_interlaced ? CSI_FRAME_PLANAR_YUV422 :
CSI_FIELD_PLANAR_YUV422;
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_RGB565X:
return buf_interlaced ? CSI_FRAME_RGB565 : CSI_FIELD_RGB565;
default:
dev_warn(sdev->dev, "Unsupported pixformat: 0x%x\n", pixformat);
break;
......@@ -289,6 +300,10 @@ static enum csi_output_fmt get_csi_output_format(struct sun6i_csi_dev *sdev,
static enum csi_input_seq get_csi_input_seq(struct sun6i_csi_dev *sdev,
u32 mbus_code, u32 pixformat)
{
/* Input sequence does not apply to non-YUV formats */
if ((mbus_code & 0xF000) != 0x2000)
return 0;
switch (pixformat) {
case V4L2_PIX_FMT_HM12:
case V4L2_PIX_FMT_NV12:
......
......@@ -117,6 +117,8 @@ static inline int sun6i_csi_get_bpp(unsigned int pixformat)
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61:
case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_RGB565X:
return 16;
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
......
......@@ -56,6 +56,8 @@ static const u32 supported_pixformats[] = {
V4L2_PIX_FMT_NV16,
V4L2_PIX_FMT_NV61,
V4L2_PIX_FMT_YUV422P,
V4L2_PIX_FMT_RGB565,
V4L2_PIX_FMT_RGB565X,
};
static bool is_pixformat_valid(unsigned int pixformat)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment