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: Chen-Yu Tsai <wens@csie.org> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
d31b282e2c
commit
19b18e78b3
@ -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 @@ clk_mod_disable:
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user