1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2011-2018 Magewell Electronics Co., Ltd. (Nanjing)
5 * Author: Yong Deng <yong.deng@magewell.com>
8 #ifndef __SUN6I_CSI_H__
9 #define __SUN6I_CSI_H__
11 #include <media/v4l2-ctrls.h>
12 #include <media/v4l2-device.h>
13 #include <media/v4l2-fwnode.h>
15 #include "sun6i_video.h"
20 * struct sun6i_csi_config - configs for sun6i csi
21 * @pixelformat: v4l2 pixel format (V4L2_PIX_FMT_*)
22 * @code: media bus format code (MEDIA_BUS_FMT_*)
23 * @field: used interlacing type (enum v4l2_field)
25 * @height: frame height
27 struct sun6i_csi_config
{
37 struct v4l2_ctrl_handler ctrl_handler
;
38 struct v4l2_device v4l2_dev
;
39 struct media_device media_dev
;
41 struct v4l2_async_notifier notifier
;
43 /* video port settings */
44 struct v4l2_fwnode_endpoint v4l2_ep
;
46 struct sun6i_csi_config config
;
48 struct sun6i_video video
;
52 * sun6i_csi_is_format_supported() - check if the format supported by csi
53 * @csi: pointer to the csi
54 * @pixformat: v4l2 pixel format (V4L2_PIX_FMT_*)
55 * @mbus_code: media bus format code (MEDIA_BUS_FMT_*)
57 bool sun6i_csi_is_format_supported(struct sun6i_csi
*csi
, u32 pixformat
,
61 * sun6i_csi_set_power() - power on/off the csi
62 * @csi: pointer to the csi
65 int sun6i_csi_set_power(struct sun6i_csi
*csi
, bool enable
);
68 * sun6i_csi_update_config() - update the csi register settings
69 * @csi: pointer to the csi
70 * @config: see struct sun6i_csi_config
72 int sun6i_csi_update_config(struct sun6i_csi
*csi
,
73 struct sun6i_csi_config
*config
);
76 * sun6i_csi_update_buf_addr() - update the csi frame buffer address
77 * @csi: pointer to the csi
78 * @addr: frame buffer's physical address
80 void sun6i_csi_update_buf_addr(struct sun6i_csi
*csi
, dma_addr_t addr
);
83 * sun6i_csi_set_stream() - start/stop csi streaming
84 * @csi: pointer to the csi
87 void sun6i_csi_set_stream(struct sun6i_csi
*csi
, bool enable
);
89 /* get bpp form v4l2 pixformat */
90 static inline int sun6i_csi_get_bpp(unsigned int pixformat
)
93 case V4L2_PIX_FMT_SBGGR8
:
94 case V4L2_PIX_FMT_SGBRG8
:
95 case V4L2_PIX_FMT_SGRBG8
:
96 case V4L2_PIX_FMT_SRGGB8
:
97 case V4L2_PIX_FMT_JPEG
:
99 case V4L2_PIX_FMT_SBGGR10
:
100 case V4L2_PIX_FMT_SGBRG10
:
101 case V4L2_PIX_FMT_SGRBG10
:
102 case V4L2_PIX_FMT_SRGGB10
:
104 case V4L2_PIX_FMT_SBGGR12
:
105 case V4L2_PIX_FMT_SGBRG12
:
106 case V4L2_PIX_FMT_SGRBG12
:
107 case V4L2_PIX_FMT_SRGGB12
:
108 case V4L2_PIX_FMT_HM12
:
109 case V4L2_PIX_FMT_NV12
:
110 case V4L2_PIX_FMT_NV21
:
111 case V4L2_PIX_FMT_YUV420
:
112 case V4L2_PIX_FMT_YVU420
:
114 case V4L2_PIX_FMT_YUYV
:
115 case V4L2_PIX_FMT_YVYU
:
116 case V4L2_PIX_FMT_UYVY
:
117 case V4L2_PIX_FMT_VYUY
:
118 case V4L2_PIX_FMT_NV16
:
119 case V4L2_PIX_FMT_NV61
:
120 case V4L2_PIX_FMT_YUV422P
:
121 case V4L2_PIX_FMT_RGB565
:
122 case V4L2_PIX_FMT_RGB565X
:
124 case V4L2_PIX_FMT_RGB24
:
125 case V4L2_PIX_FMT_BGR24
:
127 case V4L2_PIX_FMT_RGB32
:
128 case V4L2_PIX_FMT_BGR32
:
131 WARN(1, "Unsupported pixformat: 0x%x\n", pixformat
);
138 #endif /* __SUN6I_CSI_H__ */