Re: [PATCH v2 01/12] [media] dvb-frontends/stv0367: add flag to make i2c_gatectrl optional
Am 26.03.2017 um 12:34 schrieb Daniel Scheller: > Am Sun, 26 Mar 2017 10:03:33 +0200 > schrieb Matthias Schwarzott : > >> Am 24.03.2017 um 19:23 schrieb Daniel Scheller: >>> From: Daniel Scheller >>> >>> Some hardware and bridges (namely ddbridge) require that tuner >>> access is limited to one concurrent access and wrap i2c gate >>> control with a mutex_lock when attaching frontends. According to >>> vendor information, this is required as concurrent tuner >>> reconfiguration can interfere each other and at worst cause tuning >>> fails or bad reception quality. >>> >>> If the demod driver does gate_ctrl before setting up tuner >>> parameters, and the tuner does another I2C enable, it will deadlock >>> forever when gate_ctrl is wrapped into the mutex_lock. This adds a >>> flag and a conditional before triggering gate_ctrl in the >>> demodulator driver. >> >> If I get this right, the complete call to i2c_gate_ctrl should be >> disabled. Why not just overwrite the function-pointer i2c_gate_ctrl >> with NULL in the relevant attach function (stv0367ddb_attach) or not >> define it in stv0367ddb_ops? > > This will make communication with the TDA18212 tuner chip impossible. > We need to open stv0367's I2C gate, thus need the function. But for the > overall hardware case, concurrent tuner reconfiguration must be avoided > due to the mentioned issues, thus after _attach the bridge driver > remaps the function pointer to wrap i2c_gate_ctrl with a lock to > accomplish this - see [1] and [2]. As the demod AND the tuner driver > both open the I2C gate, this will lead to a dead lock. To not change or > break existing behaviour with other cards and tuner drivers, this > (flag, conditional) appears to be the best option. Ok, I understand: The real problem is that both demod driver (around tuner access) and tuner driver care about the i2c_gate. Regards Matthias
[PATCH] staging: media: atomisp: i2c: removed unnecessary white space before comma in memset()
From: Vaibhav Kothari Removed extra space before comma in memset() as a part of checkpatch.pl fix-up. Signed-off-by: Vaibhav Kothari --- drivers/staging/media/atomisp/i2c/gc2235.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c b/drivers/staging/media/atomisp/i2c/gc2235.c index 9b41023..50f4317 100644 --- a/drivers/staging/media/atomisp/i2c/gc2235.c +++ b/drivers/staging/media/atomisp/i2c/gc2235.c @@ -55,7 +55,7 @@ static int gc2235_read_reg(struct i2c_client *client, return -EINVAL; } - memset(msg, 0 , sizeof(msg)); + memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; msg[0].flags = 0; -- 1.9.1
Re: [PATCH] staging: media: atomisp: i2c: removed unnecessary white space before comma in memset()
On Tue, Mar 28, 2017 at 10:44:44AM +0530, vaibhavd...@gmail.com wrote: > gc2235.c Why is this file name here? > > Removed extra space before comma in memset() as a part of > checkpatch.pl fix-up. Why the extra space at the beginning of the line? > Signed-off-by: Vaibhav Kothari This doesn't match your "From:" line above :( Please fix up. thanks, greg k-h
[PATCH] staging: media: atomisp: i2c: removed unnecessary white space before comma in memset()
gc2235.c Removed extra space before comma in memset() as a part of checkpatch.pl fix-up. Signed-off-by: Vaibhav Kothari --- drivers/staging/media/atomisp/i2c/gc2235.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c b/drivers/staging/media/atomisp/i2c/gc2235.c index 9b41023..50f4317 100644 --- a/drivers/staging/media/atomisp/i2c/gc2235.c +++ b/drivers/staging/media/atomisp/i2c/gc2235.c @@ -55,7 +55,7 @@ static int gc2235_read_reg(struct i2c_client *client, return -EINVAL; } - memset(msg, 0 , sizeof(msg)); + memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; msg[0].flags = 0; -- 1.9.1
Re: [Patch v2 10/11] s5p-mfc: Add support for HEVC encoder
On Mon, 2017-03-27 at 14:09 +0200, Andrzej Hajda wrote: > Hi Smitha, > > Sorry for late reply, it seems I have missed this email. > > > On 14.03.2017 12:41, Smitha T Murthy wrote: > > On Tue, 2017-03-07 at 12:33 +0100, Andrzej Hajda wrote: > >> On 03.03.2017 10:07, Smitha T Murthy wrote: > >>> Add HEVC encoder support and necessary registers, V4L2 CIDs, > >>> and hevc encoder parameters > >>> > >>> Signed-off-by: Smitha T Murthy > >>> --- > >>> drivers/media/platform/s5p-mfc/regs-mfc-v10.h | 28 +- > >>> drivers/media/platform/s5p-mfc/s5p_mfc.c|1 + > >>> drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c |3 + > >>> drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 55 ++- > >>> drivers/media/platform/s5p-mfc/s5p_mfc_enc.c| 595 > >>> +++ > >>> drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|8 + > >>> drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 200 > >>> drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h |8 + > >>> 8 files changed, 896 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h > >>> b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h > >>> index 846dcf5..caf02ff 100644 > >>> --- a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h > >>> +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h > >>> @@ -20,13 +20,35 @@ > >>> #define S5P_FIMV_MFC_STATE_V10 0x7124 > >>> #define S5P_FIMV_D_STATIC_BUFFER_ADDR_V100xF570 > >>> #define S5P_FIMV_D_STATIC_BUFFER_SIZE_V100xF574 > >>> +#define S5P_FIMV_E_NUM_T_LAYER_V10 0xFBAC > >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER0_V100xFBB0 > >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER1_V100xFBB4 > >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER2_V100xFBB8 > >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER3_V100xFBBC > >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER4_V100xFBC0 > >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER5_V100xFBC4 > >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER6_V100xFBC8 > >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER0_V10 0xFD18 > >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER1_V10 0xFD1C > >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER2_V10 0xFD20 > >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER3_V10 0xFD24 > >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER4_V10 0xFD28 > >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER5_V10 0xFD2C > >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER6_V10 0xFD30 > >>> +#define S5P_FIMV_E_HEVC_OPTIONS_V10 0xFDD4 > >>> +#define S5P_FIMV_E_HEVC_REFRESH_PERIOD_V10 0xFDD8 > >>> +#define S5P_FIMV_E_HEVC_CHROMA_QP_OFFSET_V10 0xFDDC > >>> +#define S5P_FIMV_E_HEVC_LF_BETA_OFFSET_DIV2_V10 0xFDE0 > >>> +#define S5P_FIMV_E_HEVC_LF_TC_OFFSET_DIV2_V100xFDE4 > >>> +#define S5P_FIMV_E_HEVC_NAL_CONTROL_V10 0xFDE8 > >>> > >>> /* MFCv10 Context buffer sizes */ > >>> #define MFC_CTX_BUF_SIZE_V10 (30 * SZ_1K)/* 30KB */ > >>> #define MFC_H264_DEC_CTX_BUF_SIZE_V10(2 * SZ_1M) /* 2MB */ > >>> #define MFC_OTHER_DEC_CTX_BUF_SIZE_V10 (20 * SZ_1K)/* 20KB */ > >>> #define MFC_H264_ENC_CTX_BUF_SIZE_V10(100 * SZ_1K) /* 100KB */ > >>> -#define MFC_OTHER_ENC_CTX_BUF_SIZE_V10 (15 * SZ_1K)/* 15KB */ > >>> +#define MFC_HEVC_ENC_CTX_BUF_SIZE_V10(30 * SZ_1K)/* 30KB */ > >>> +#define MFC_OTHER_ENC_CTX_BUF_SIZE_V10 (15 * SZ_1K) /* 15KB */ > >>> > >>> /* MFCv10 variant defines */ > >>> #define MAX_FW_SIZE_V10 (SZ_1M) /* 1MB */ > >>> @@ -58,5 +80,9 @@ > >>> #define ENC_V100_VP8_ME_SIZE(x, y) \ > >>> ENC_V100_BASE_SIZE(x, y) > >>> > >>> +#define ENC_V100_HEVC_ME_SIZE(x, y) \ > >>> + (((x + 3) * (y + 3) * 32) \ > >>> + + ((y * 128) + 1280) * DIV_ROUND_UP(x, 4)) > >>> + > >>> #endif /*_REGS_MFC_V10_H*/ > >>> > >>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c > >>> b/drivers/media/platform/s5p-mfc/s5p_mfc.c > >>> index b014038..b01c556 100644 > >>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > >>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > >>> @@ -1549,6 +1549,7 @@ static int s5p_mfc_resume(struct device *dev) > >>> .h264_dec_ctx = MFC_H264_DEC_CTX_BUF_SIZE_V10, > >>> .other_dec_ctx = MFC_OTHER_DEC_CTX_BUF_SIZE_V10, > >>> .h264_enc_ctx = MFC_H264_ENC_CTX_BUF_SIZE_V10, > >>> + .hevc_enc_ctx = MFC_HEVC_ENC_CTX_BUF_SIZE_V10, > >>> .other_enc_ctx = MFC_OTHER_ENC_CTX_BUF_SIZE_V10, > >>> }; > >>> > >>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c > >>> b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c > >>> index 102b47e..7521fce 100644 > >>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c > >>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c > >>> @@ -122,6 +122,9 @@ static int
cron job: media_tree daily build: ERRORS
This message is generated daily by a cron job that builds media_tree for the kernels and architectures in the list below. Results of the daily build of media_tree: date: Tue Mar 28 05:00:13 CEST 2017 media-tree git hash:c3d4fb0fb41f4b5eafeee51173c14e50be12f839 media_build git hash: bc4c2a205c087c8deff3cd14ed663c4767dd2016 v4l-utils git hash: 8fc88615b49843acb82cd8316d0bc4ab8474cba2 gcc version:i686-linux-gcc (GCC) 6.2.0 sparse version: v0.5.0-3553-g78b2ea6 smatch version: v0.5.0-3553-g78b2ea6 host hardware: x86_64 host os:4.9.0-164 linux-git-arm-at91: OK linux-git-arm-davinci: OK linux-git-arm-multi: OK linux-git-arm-pxa: OK linux-git-blackfin-bf561: OK linux-git-i686: OK linux-git-m32r: OK linux-git-mips: OK linux-git-powerpc64: OK linux-git-sh: OK linux-git-x86_64: OK linux-2.6.36.4-i686: ERRORS linux-2.6.37.6-i686: ERRORS linux-2.6.38.8-i686: ERRORS linux-2.6.39.4-i686: ERRORS linux-3.0.60-i686: ERRORS linux-3.1.10-i686: ERRORS linux-3.2.37-i686: ERRORS linux-3.3.8-i686: ERRORS linux-3.4.27-i686: ERRORS linux-3.5.7-i686: ERRORS linux-3.6.11-i686: ERRORS linux-3.7.4-i686: ERRORS linux-3.8-i686: ERRORS linux-3.9.2-i686: ERRORS linux-3.10.1-i686: ERRORS linux-3.11.1-i686: ERRORS linux-3.12.67-i686: ERRORS linux-3.13.11-i686: WARNINGS linux-3.14.9-i686: WARNINGS linux-3.15.2-i686: WARNINGS linux-3.16.7-i686: WARNINGS linux-3.17.8-i686: WARNINGS linux-3.18.7-i686: WARNINGS linux-3.19-i686: WARNINGS linux-4.0.9-i686: WARNINGS linux-4.1.33-i686: WARNINGS linux-4.2.8-i686: WARNINGS linux-4.3.6-i686: WARNINGS linux-4.4.22-i686: WARNINGS linux-4.5.7-i686: WARNINGS linux-4.6.7-i686: WARNINGS linux-4.7.5-i686: WARNINGS linux-4.8-i686: OK linux-4.9-i686: OK linux-4.10.1-i686: OK linux-4.11-rc1-i686: OK linux-2.6.36.4-x86_64: ERRORS linux-2.6.37.6-x86_64: ERRORS linux-2.6.38.8-x86_64: ERRORS linux-2.6.39.4-x86_64: ERRORS linux-3.0.60-x86_64: ERRORS linux-3.1.10-x86_64: ERRORS linux-3.2.37-x86_64: ERRORS linux-3.3.8-x86_64: ERRORS linux-3.4.27-x86_64: ERRORS linux-3.5.7-x86_64: ERRORS linux-3.6.11-x86_64: ERRORS linux-3.7.4-x86_64: ERRORS linux-3.8-x86_64: ERRORS linux-3.9.2-x86_64: ERRORS linux-3.10.1-x86_64: ERRORS linux-3.11.1-x86_64: ERRORS linux-3.12.67-x86_64: ERRORS linux-3.13.11-x86_64: WARNINGS linux-3.14.9-x86_64: WARNINGS linux-3.15.2-x86_64: WARNINGS linux-3.16.7-x86_64: WARNINGS linux-3.17.8-x86_64: WARNINGS linux-3.18.7-x86_64: WARNINGS linux-3.19-x86_64: WARNINGS linux-4.0.9-x86_64: WARNINGS linux-4.1.33-x86_64: WARNINGS linux-4.2.8-x86_64: WARNINGS linux-4.3.6-x86_64: WARNINGS linux-4.4.22-x86_64: WARNINGS linux-4.5.7-x86_64: WARNINGS linux-4.6.7-x86_64: WARNINGS linux-4.7.5-x86_64: WARNINGS linux-4.8-x86_64: WARNINGS linux-4.9-x86_64: WARNINGS linux-4.10.1-x86_64: WARNINGS linux-4.11-rc1-x86_64: OK apps: WARNINGS spec-git: OK sparse: WARNINGS Detailed results are available here: http://www.xs4all.nl/~hverkuil/logs/Tuesday.log Full logs are available here: http://www.xs4all.nl/~hverkuil/logs/Tuesday.tar.bz2 The Media Infrastructure API from this daily build is here: http://www.xs4all.nl/~hverkuil/spec/index.html
Re: [PATCH v6 1/3] drm_fourcc: Add new P010, P016 video format
從我的 iPad 傳送 > Clint Taylor 於 2017年3月28日 上午6:49 寫道: > >> On 03/26/2017 09:05 PM, Ayaka wrote: >> >> >> 從我的 iPad 傳送 >> Ander Conselvan De Oliveira 於 2017年3月14日 下午9:53 寫道: On Tue, 2017-03-07 at 04:27 +0800, Ayaka wrote: 從我的 iPad 傳送 >> Ville Syrjälä 於 2017年3月7日 上午2:34 寫道: >> >> On Tue, Mar 07, 2017 at 01:58:23AM +0800, Ayaka wrote: >> >> >> 從我的 iPad 傳送 >> Ville Syrjälä 於 2017年3月6日 下午9:06 寫道: On Sun, Mar 05, 2017 at 06:00:31PM +0800, Randy Li wrote: P010 is a planar 4:2:0 YUV with interleaved UV plane, 10 bits per channel video format. P016 is a planar 4:2:0 YUV with interleaved UV plane, 16 bits per channel video format. V3: Added P012 and fixed cpp for P010 V4: format definition refined per review V5: Format comment block for each new pixel format V6: reversed Cb/Cr order in comments v7: reversed Cb/Cr order in comments of header files, remove the wrong part of commit message. >>> >>> What? Why? You just undid what Clint did in v6. >> >> He missed a file also keeping the wrong description of rockchip. > > I don't follow. Who missed what exactly? What he sent is v5, I increase the order number twice in the message, it confuse me as well. I think Clint forgot the include/uapi/drm/drm_fourcc.h . >>> >>> Clint did send a v6, and that updates "include/uapi/drm/drm_fourcc.h": >>> >>> https://patchwork.freedesktop.org/patch/141342/ >> Oh, yes but he still used Cr:Cb, but I think it should be Cb:Cr >> since I think the V is after the U. > > From the MSDN fourcc website: > "If the combined U-V array is addressed as an array of DWORDs, the least > significant word (LSW) contains the U value and the most significant word > (MSW) contains the V value. The stride of the combined U-V plane is equal to > the stride of the Y plane. The U-V plane has half as many lines as the Y > plane." > > The LSW contains U and the MSW contains V, hence the Cr:Cb in the comments of > the V6 patch. > > -Clint ok it is correct. I think I mistake it that is why my converter for gstreamer doesn't work > >>> >>> >>> Ander >>> > > >>> Cc: Daniel Stone Cc: Ville Syrjälä Signed-off-by: Randy Li Signed-off-by: Clint Taylor --- drivers/gpu/drm/drm_fourcc.c | 3 +++ include/uapi/drm/drm_fourcc.h | 21 + 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index 90d2cc8..3e0fd58 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -165,6 +165,9 @@ const struct drm_format_info *__drm_format_info(u32 format) { .format = DRM_FORMAT_UYVY,.depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, { .format = DRM_FORMAT_VYUY,.depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, { .format = DRM_FORMAT_AYUV,.depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 }, +{ .format = DRM_FORMAT_P010,.depth = 0, .num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2 }, +{ .format = DRM_FORMAT_P012,.depth = 0, .num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2 }, +{ .format = DRM_FORMAT_P016,.depth = 0, .num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2 }, }; unsigned int i; diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index ef20abb..306f979 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -128,6 +128,27 @@ extern "C" { #define DRM_FORMAT_NV42fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ /* + * 2 plane YCbCr MSB aligned + * index 0 = Y plane, [15:0] Y:x [10:6] little endian + * index 1 = Cb:Cr plane, [31:0] Cb:x:Cr:x [10:6:10:6] little endian + */ +#define DRM_FORMAT_P010fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cb:Cr plane 10 bits per channel */ + +/* + * 2 plane YCbCr MSB aligned + * index 0 = Y plane, [15:0] Y:x [12:4] little endian + * index 1 = Cb:Cr plane, [31:0] Cb:x:Cr:x [12:4:12:4] little endian + */ +#define DRM_FORMAT_P012fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cb:Cr plane 12 bits per channel */ + +/* + * 2 plane YCbCr MSB aligned + * ind
[PATCH v6 04/39] ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node
Add to the MIPI CSI2 receiver node: compatible strings, interrupt sources, and clocks. Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6qdl.dtsi | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi index 6d7bf64..d28a413 100644 --- a/arch/arm/boot/dts/imx6qdl.dtsi +++ b/arch/arm/boot/dts/imx6qdl.dtsi @@ -1134,7 +1134,14 @@ }; mipi_csi: mipi@021dc000 { + compatible = "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2"; reg = <0x021dc000 0x4000>; + interrupts = <0 100 0x04>, <0 101 0x04>; + clocks = <&clks IMX6QDL_CLK_HSI_TX>, +<&clks IMX6QDL_CLK_VIDEO_27M>, +<&clks IMX6QDL_CLK_EIM_PODF>; + clock-names = "dphy", "ref", "pix"; + status = "disabled"; }; mipi_dsi: mipi@021e { -- 2.7.4
[PATCH v6 01/39] [media] dt-bindings: Add bindings for video-multiplexer device
From: Philipp Zabel Add bindings documentation for the video multiplexer device. Signed-off-by: Sascha Hauer Signed-off-by: Philipp Zabel Signed-off-by: Steve Longerbeam --- .../bindings/media/video-multiplexer.txt | 59 ++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/video-multiplexer.txt diff --git a/Documentation/devicetree/bindings/media/video-multiplexer.txt b/Documentation/devicetree/bindings/media/video-multiplexer.txt new file mode 100644 index 000..9d133d9 --- /dev/null +++ b/Documentation/devicetree/bindings/media/video-multiplexer.txt @@ -0,0 +1,59 @@ +Video Multiplexer += + +Video multiplexers allow to select between multiple input ports. Video received +on the active input port is passed through to the output port. Muxes described +by this binding may be controlled by a syscon register bitfield or by a GPIO. + +Required properties: +- compatible : should be "video-multiplexer" +- reg: should be register base of the register containing the control bitfield +- bit-mask: bitmask of the control bitfield in the control register +- bit-shift: bit offset of the control bitfield in the control register +- gpios: alternatively to reg, bit-mask, and bit-shift, a single GPIO phandle + may be given to switch between two inputs +- #address-cells: should be <1> +- #size-cells: should be <0> +- port@*: at least three port nodes containing endpoints connecting to the + source and sink devices according to of_graph bindings. The last port is + the output port, all others are inputs. + +Example: + +syscon { + compatible = "syscon", "simple-mfd"; + + mux { + compatible = "video-multiplexer"; + /* Single bit (1 << 19) in syscon register 0x04: */ + reg = <0x04>; + bit-mask = <1>; + bit-shift = <19>; + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + mux_in0: endpoint { + remote-endpoint = <&video_source0_out>; + }; + }; + + port@1 { + reg = <1>; + + mux_in1: endpoint { + remote-endpoint = <&video_source1_out>; + }; + }; + + port@2 { + reg = <2>; + + mux_out: endpoint { + remote-endpoint = <&capture_interface_in>; + }; + }; + }; +}; -- 2.7.4
[PATCH v6 02/39] [media] dt-bindings: Add bindings for i.MX media driver
Add bindings documentation for the i.MX media driver. Signed-off-by: Steve Longerbeam --- Documentation/devicetree/bindings/media/imx.txt | 74 + 1 file changed, 74 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/imx.txt diff --git a/Documentation/devicetree/bindings/media/imx.txt b/Documentation/devicetree/bindings/media/imx.txt new file mode 100644 index 000..3059c06 --- /dev/null +++ b/Documentation/devicetree/bindings/media/imx.txt @@ -0,0 +1,74 @@ +Freescale i.MX Media Video Device += + +Video Media Controller node +--- + +This is the media controller node for video capture support. It is a +virtual device that lists the camera serial interface nodes that the +media device will control. + +Required properties: +- compatible : "fsl,imx-capture-subsystem"; +- ports : Should contain a list of phandles pointing to camera + sensor interface ports of IPU devices + +example: + +capture-subsystem { + compatible = "fsl,imx-capture-subsystem"; + ports = <&ipu1_csi0>, <&ipu1_csi1>; +}; + +fim child node +-- + +This is an optional child node of the ipu_csi port nodes. If present and +available, it enables the Frame Interval Monitor. Its properties can be +used to modify the method in which the FIM measures frame intervals. +Refer to Documentation/media/v4l-drivers/imx.rst for more info on the +Frame Interval Monitor. + +Optional properties: +- fsl,input-capture-channel: an input capture channel and channel flags, +specified as . The channel number +must be 0 or 1. The flags can be +IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, or +IRQ_TYPE_EDGE_BOTH, and specify which input +capture signal edge will trigger the input +capture event. If an input capture channel is +specified, the FIM will use this method to +measure frame intervals instead of via the EOF +interrupt. The input capture method is much +preferred over EOF as it is not subject to +interrupt latency errors. However it requires +routing the VSYNC or FIELD output signals of +the camera sensor to one of the i.MX input +capture pads (SD1_DAT0, SD1_DAT1), which also +gives up support for SD1. + + +mipi_csi2 node +-- + +This is the device node for the MIPI CSI-2 Receiver, required for MIPI +CSI-2 sensors. + +Required properties: +- compatible : "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2"; +- reg : physical base address and length of the register set; +- clocks : the MIPI CSI-2 receiver requires three clocks: hsi_tx + (the D-PHY clock), video_27m (D-PHY PLL reference + clock), and eim_podf; +- clock-names : must contain "dphy", "ref", "pix"; +- port@*: five port nodes must exist, containing endpoints + connecting to the source and sink devices according to + of_graph bindings. The first port is an input port, + connecting with a MIPI CSI-2 source, and ports 1 + through 4 are output ports connecting with parallel + bus sink endpoint nodes and correspond to the four + MIPI CSI-2 virtual channel outputs. + +Optional properties: +- interrupts : must contain two level-triggered interrupts, + in order: 100 and 101; -- 2.7.4
[PATCH v6 00/39] i.MX Media Driver
In version 6: - moved FIM error event back to a i.MX private event. I would like to leave this as a (private) event rather than reporting a vb2 queue error, for now. If and when the i.MX6 timer input capture patch is accepted later, then this event can become a queue error. - removed new-frame-before-end-of-frame (NFB4EOF) event. Instead when this IPU DMA channel error occurs, the next captured frame is marked with the vb2 error flag. - updates to Documentation/media/v4l-drivers/imx.rst. - ov5640: propagate return codes from the register read/write primitives in various places. - ov5640: removed the [gs]_parm ops. - ov5640: avoid possible divide-by-0's. - only the CSI subdevice implements [gs]_frame_interval now (or needs to). Those ops have been removed from the subdevices that have no control over frame rate. - removed the patch that adds v4l2_subdev_link_validate_frame_interval(). - properly propagate the TRY formats from sink to source pads within the subdevices (spotted by Philipp Zabel ). - added enum_frame_size op to imx-ic-prpencvf and CSI subdevices. - added enum_frame_intervals op to CSI subdevice (patch from Russell King ). - added V4L2 interface ops enum_framesizes and enum_frameintervals, which calls the corresponding subdev op at the connected source subdev (patch from Russell King ). - added missing Bayer support to CSI subdevice (patch from Russell King ). - switched to v4l2_pipeline_pm_use() and v4l2_pipeline_link_notify() for the pipeline power management. - the power-on order has changed due to above: the sensor now is powered on _before_ the MIPI CSI-2 receiver, which means MIPI CSI-2 receiver startup sequence steps 3, 4, and 5 can be moved up to csi2_s_power() from csi2_s_stream(). And that means step 7 (wait for clock lane) now has a place to be called in csi2_s_stream(). - changed the bus_info string for the capture device interfaces to "platform:[src_sd->name]" instead of using the capture device name, so that the bus_info strings are unique between the capture devices. I was hoping this would provide unique device node symlink names under /dev/v4l/by-path/, but they are still named "platform-capture-subsystem-video-indexNN". - fixed cropping and /2 downsizing in the CSI subdevice. These should be specified using the crop and compose APIs at the sink pad, not the source pad (patch from Philipp Zabel ). - added a check at CSI subdevice stream on. If the connected sensor reports faulty frames at power on via g_skip_frames op, the CSI should avoid capturing those frames before enabling the CSI. - moved imx.h UAPI header to include/linux/imx-media.h while imx-media driver is still under staging. Philipp Zabel (8): [media] dt-bindings: Add bindings for video-multiplexer device ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections add mux and video interface bridge entity functions platform: add video-multiplexer subdevice driver media: imx: csi: fix crop rectangle changes in set_fmt media: imx: csi: add frame skipping support media: imx: csi: fix crop rectangle reset in sink set_fmt media: imx: csi: add sink selection rectangles Russell King (5): media: imx: add support for bayer formats media: imx: csi: add support for bayer formats media: imx: csi/fim: add support for frame intervals media: imx-csi: add frame size/interval enumeration media: imx-media-capture: add frame sizes/interval enumeration Steve Longerbeam (26): [media] dt-bindings: Add bindings for i.MX media driver [media] dt/bindings: Add bindings for OV5640 ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node ARM: dts: imx6qdl: add capture-subsystem device ARM: dts: imx6qdl-sabrelite: remove erratum ERR006687 workaround ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors ARM: dts: imx6-sabreauto: create i2cmux for i2c3 ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture ARM: dts: imx6-sabreauto: add the ADV7180 video decoder [media] v4l2-mc: add a function to inherit controls from a pipeline [media] add Omnivision OV5640 sensor driver media: Add userspace header file for i.MX media: Add i.MX media core driver media: imx: Add Capture Device Interface media: imx: Add CSI subdev driver media: imx: Add VDIC subdev driver media: imx: Add IC subdev drivers media: imx: Add MIPI CSI-2 Receiver subdev driver ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers media: imx: csi: add __csi_get_fmt media: imx: redo pixel format enumeration and negotiation media: imx: csi: Avoid faulty sensor frames at stream start media: imx: propagate sink pad formats to source pads media: imx-ic-prpencvf: add frame size enumeration .../devicetree/bindings/media/i2c/ov5640.txt | 45 + Document
[PATCH v6 07/39] ARM: dts: imx6qdl-sabrelite: remove erratum ERR006687 workaround
There is a pin conflict with GPIO_6. This pin functions as a power input pin to the OV5642 camera sensor, but ENET uses it as the h/w workaround for erratum ERR006687, to wake-up the ARM cores on normal RX and TX packet done events. So we need to remove the h/w workaround to support the OV5642. The result is that the CPUidle driver will no longer allow entering the deep idle states on the sabrelite. This is a partial revert of commit 6261c4c8f13e ("ARM: dts: imx6qdl-sabrelite: use GPIO_6 for FEC interrupt.") commit a28eeb43ee57 ("ARM: dts: imx6: tag boards that have the HW workaround for ERR006687") Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6qdl-sabrelite.dtsi | 4 1 file changed, 4 deletions(-) diff --git a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi index 8413179..89dce27 100644 --- a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi @@ -270,9 +270,6 @@ txd1-skew-ps = <0>; txd2-skew-ps = <0>; txd3-skew-ps = <0>; - interrupts-extended = <&gpio1 6 IRQ_TYPE_LEVEL_HIGH>, - <&intc 0 119 IRQ_TYPE_LEVEL_HIGH>; - fsl,err006687-workaround-present; status = "okay"; }; @@ -373,7 +370,6 @@ MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL 0x1b030 /* Phy reset */ MX6QDL_PAD_EIM_D23__GPIO3_IO23 0x000b0 - MX6QDL_PAD_GPIO_6__ENET_IRQ 0x000b1 >; }; -- 2.7.4
[PATCH v6 10/39] ARM: dts: imx6-sabreauto: create i2cmux for i2c3
The sabreauto uses a steering pin to select between the SDA signal on i2c3 bus, and a data-in pin for an SPI NOR chip. Use i2cmux to control this steering pin. Idle state of the i2cmux selects SPI NOR. This is not a classic way to use i2cmux, since one side of the mux selects something other than an i2c bus, but it works and is probably the cleanest solution. Note that if one thread is attempting to access SPI NOR while another thread is accessing i2c3, the SPI NOR access will fail since the i2cmux has selected the SDA pin rather than SPI NOR data-in. This couldn't be avoided in any case, the board is not designed to allow concurrent i2c3 and SPI NOR functions (and the default device-tree does not enable SPI NOR anyway). Devices hanging off i2c3 should now be defined under i2cmux, so that the steering pin can be properly controlled to access those devices. The port expanders (MAX7310) are thus moved into i2cmux. Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 65 +--- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi index a2a714d..c8e35c4 100644 --- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi @@ -108,6 +108,44 @@ default-brightness-level = <7>; status = "okay"; }; + + i2cmux { + compatible = "i2c-mux-gpio"; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c3mux>; + mux-gpios = <&gpio5 4 0>; + i2c-parent = <&i2c3>; + idle-state = <0>; + + i2c@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + + max7310_a: gpio@30 { + compatible = "maxim,max7310"; + reg = <0x30>; + gpio-controller; + #gpio-cells = <2>; + }; + + max7310_b: gpio@32 { + compatible = "maxim,max7310"; + reg = <0x32>; + gpio-controller; + #gpio-cells = <2>; + }; + + max7310_c: gpio@34 { + compatible = "maxim,max7310"; + reg = <0x34>; + gpio-controller; + #gpio-cells = <2>; + }; + }; + }; }; &clks { @@ -290,27 +328,6 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_i2c3>; status = "okay"; - - max7310_a: gpio@30 { - compatible = "maxim,max7310"; - reg = <0x30>; - gpio-controller; - #gpio-cells = <2>; - }; - - max7310_b: gpio@32 { - compatible = "maxim,max7310"; - reg = <0x32>; - gpio-controller; - #gpio-cells = <2>; - }; - - max7310_c: gpio@34 { - compatible = "maxim,max7310"; - reg = <0x34>; - gpio-controller; - #gpio-cells = <2>; - }; }; &iomuxc { @@ -418,6 +435,12 @@ >; }; + pinctrl_i2c3mux: i2c3muxgrp { + fsl,pins = < + MX6QDL_PAD_EIM_A24__GPIO5_IO04 0x0b0b1 + >; + }; + pinctrl_pwm3: pwm1grp { fsl,pins = < MX6QDL_PAD_SD4_DAT1__PWM3_OUT 0x1b0b1 -- 2.7.4
[PATCH v6 13/39] ARM: dts: imx6-sabreauto: add the ADV7180 video decoder
Enables the ADV7180 decoder sensor. The ADV7180 connects to the parallel-bus mux input on ipu1_csi0_mux. The ADV7180 power pin is via max7310_b port expander. Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 58 1 file changed, 58 insertions(+) diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi index 1212f82..a712ff1 100644 --- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi @@ -124,6 +124,21 @@ #size-cells = <0>; reg = <1>; + adv7180: camera@21 { + compatible = "adi,adv7180"; + reg = <0x21>; + powerdown-gpios = <&max7310_b 2 GPIO_ACTIVE_LOW>; + interrupt-parent = <&gpio1>; + interrupts = <27 0x8>; + + port { + adv7180_to_ipu1_csi0_mux: endpoint { + remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>; + bus-width = <8>; + }; + }; + }; + max7310_a: gpio@30 { compatible = "maxim,max7310"; reg = <0x30>; @@ -151,6 +166,25 @@ }; }; +&ipu1_csi0_from_ipu1_csi0_mux { + bus-width = <8>; +}; + +&ipu1_csi0_mux_from_parallel_sensor { + remote-endpoint = <&adv7180_to_ipu1_csi0_mux>; + bus-width = <8>; +}; + +&ipu1_csi0 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ipu1_csi0>; + + /* enable frame interval monitor on this port */ + fim { + status = "okay"; + }; +}; + &clks { assigned-clocks = <&clks IMX6QDL_PLL4_BYPASS_SRC>, <&clks IMX6QDL_PLL4_BYPASS>, @@ -444,6 +478,30 @@ >; }; + pinctrl_ipu1_csi0: ipu1csi0grp { + fsl,pins = < + MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04 0x1b0b0 + MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05 0x1b0b0 + MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06 0x1b0b0 + MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07 0x1b0b0 + MX6QDL_PAD_CSI0_DAT8__IPU1_CSI0_DATA08 0x1b0b0 + MX6QDL_PAD_CSI0_DAT9__IPU1_CSI0_DATA09 0x1b0b0 + MX6QDL_PAD_CSI0_DAT10__IPU1_CSI0_DATA10 0x1b0b0 + MX6QDL_PAD_CSI0_DAT11__IPU1_CSI0_DATA11 0x1b0b0 + MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12 0x1b0b0 + MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13 0x1b0b0 + MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14 0x1b0b0 + MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15 0x1b0b0 + MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16 0x1b0b0 + MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA17 0x1b0b0 + MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA18 0x1b0b0 + MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA19 0x1b0b0 + MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK 0x1b0b0 + MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC0x1b0b0 + MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC 0x1b0b0 + >; + }; + pinctrl_max7310: max7310grp { fsl,pins = < MX6QDL_PAD_SD2_DAT0__GPIO1_IO15 0x1b0b0 -- 2.7.4
[PATCH v6 03/39] [media] dt/bindings: Add bindings for OV5640
Add device tree binding documentation for the OV5640 camera sensor. Signed-off-by: Steve Longerbeam --- .../devicetree/bindings/media/i2c/ov5640.txt | 45 ++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5640.txt diff --git a/Documentation/devicetree/bindings/media/i2c/ov5640.txt b/Documentation/devicetree/bindings/media/i2c/ov5640.txt new file mode 100644 index 000..540b36c --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ov5640.txt @@ -0,0 +1,45 @@ +* Omnivision OV5640 MIPI CSI-2 sensor + +Required Properties: +- compatible: should be "ovti,ov5640" +- clocks: reference to the xclk input clock. +- clock-names: should be "xclk". +- DOVDD-supply: Digital I/O voltage supply, 1.8 volts +- AVDD-supply: Analog voltage supply, 2.8 volts +- DVDD-supply: Digital core voltage supply, 1.5 volts + +Optional Properties: +- reset-gpios: reference to the GPIO connected to the reset pin, if any. + This is an active low signal to the OV5640. +- powerdown-gpios: reference to the GPIO connected to the powerdown pin, + if any. This is an active high signal to the OV5640. + +The device node must contain one 'port' child node for its digital output +video port, in accordance with the video interface bindings defined in +Documentation/devicetree/bindings/media/video-interfaces.txt. + +Example: + +&i2c1 { + ov5640: camera@3c { + compatible = "ovti,ov5640"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ov5640>; + reg = <0x3c>; + clocks = <&clks IMX6QDL_CLK_CKO>; + clock-names = "xclk"; + DOVDD-supply = <&vgen4_reg>; /* 1.8v */ + AVDD-supply = <&vgen3_reg>; /* 2.8v */ + DVDD-supply = <&vgen2_reg>; /* 1.5v */ + powerdown-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>; + + port { + ov5640_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_from_ov5640>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; +}; -- 2.7.4
[PATCH v6 08/39] ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors
Adds the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor. Both hang off the same i2c2 bus, so they require different (and non- default) i2c slave addresses. The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux. The OV5640 connects to the input port on the MIPI CSI-2 receiver on mipi_csi. The OV5642 node is disabled temporarily while the subdev driver is cleaned up and submitted later. Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6dl-sabrelite.dts | 5 ++ arch/arm/boot/dts/imx6q-sabrelite.dts| 5 ++ arch/arm/boot/dts/imx6qdl-sabrelite.dtsi | 148 +++ 3 files changed, 158 insertions(+) diff --git a/arch/arm/boot/dts/imx6dl-sabrelite.dts b/arch/arm/boot/dts/imx6dl-sabrelite.dts index 2f90452..3304076 100644 --- a/arch/arm/boot/dts/imx6dl-sabrelite.dts +++ b/arch/arm/boot/dts/imx6dl-sabrelite.dts @@ -48,3 +48,8 @@ model = "Freescale i.MX6 DualLite SABRE Lite Board"; compatible = "fsl,imx6dl-sabrelite", "fsl,imx6dl"; }; + +&ipu1_csi1_from_ipu1_csi1_mux { + clock-lanes = <0>; + data-lanes = <1 2>; +}; diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts index 02a7cdf..dc51262e 100644 --- a/arch/arm/boot/dts/imx6q-sabrelite.dts +++ b/arch/arm/boot/dts/imx6q-sabrelite.dts @@ -52,3 +52,8 @@ &sata { status = "okay"; }; + +&ipu1_csi1_from_mipi_vc1 { + clock-lanes = <0>; + data-lanes = <1 2>; +}; diff --git a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi index 89dce27..afe7449 100644 --- a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi @@ -39,6 +39,8 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +#include #include #include @@ -94,6 +96,42 @@ pinctrl-0 = <&pinctrl_can_xcvr>; gpio = <&gpio1 2 GPIO_ACTIVE_LOW>; }; + + reg_1p5v: regulator@4 { + compatible = "regulator-fixed"; + reg = <4>; + regulator-name = "1P5V"; + regulator-min-microvolt = <150>; + regulator-max-microvolt = <150>; + regulator-always-on; + }; + + reg_1p8v: regulator@5 { + compatible = "regulator-fixed"; + reg = <5>; + regulator-name = "1P8V"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <180>; + regulator-always-on; + }; + + reg_2p8v: regulator@6 { + compatible = "regulator-fixed"; + reg = <6>; + regulator-name = "2P8V"; + regulator-min-microvolt = <280>; + regulator-max-microvolt = <280>; + regulator-always-on; + }; + }; + + mipi_xclk: mipi_xclk { + compatible = "pwm-clock"; + #clock-cells = <0>; + clock-frequency = <2200>; + clock-output-names = "mipi_pwm3"; + pwms = <&pwm3 0 45>; /* 1 / 45 ns = 22 MHz */ + status = "okay"; }; gpio-keys { @@ -220,6 +258,22 @@ }; }; +&ipu1_csi0_from_ipu1_csi0_mux { + bus-width = <8>; + data-shift = <12>; /* Lines 19:12 used */ + hsync-active = <1>; + vync-active = <1>; +}; + +&ipu1_csi0_mux_from_parallel_sensor { + remote-endpoint = <&ov5642_to_ipu1_csi0_mux>; +}; + +&ipu1_csi0 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ipu1_csi0>; +}; + &audmux { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_audmux>; @@ -298,6 +352,53 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_i2c2>; status = "okay"; + + ov5640: camera@40 { + compatible = "ovti,ov5640"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ov5640>; + reg = <0x40>; + clocks = <&mipi_xclk>; + clock-names = "xclk"; + DOVDD-supply = <®_1p8v>; + AVDD-supply = <®_2p8v>; + DVDD-supply = <®_1p5v>; + reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; /* NANDF_D5 */ + powerdown-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* NANDF_WP_B */ + + port { + #address-cells = <1>; + #size-cells = <0>; + + ov5640_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_in>; + clock-lanes = <0>; + data-lanes = <1 2>; +
[PATCH v6 15/39] [media] v4l2-mc: add a function to inherit controls from a pipeline
v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device. Signed-off-by: Steve Longerbeam --- drivers/media/v4l2-core/v4l2-mc.c | 50 +++ include/media/v4l2-mc.h | 31 2 files changed, 81 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 303980b..fda580e 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -238,6 +239,55 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q) } EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source); +int __v4l2_pipeline_inherit_controls(struct video_device *vfd, +struct media_entity *start_entity) +{ + struct media_device *mdev = start_entity->graph_obj.mdev; + struct media_entity *entity; + struct media_graph graph; + struct v4l2_subdev *sd; + int ret; + + lockdep_assert_held(&mdev->graph_mutex); + + ret = media_graph_walk_init(&graph, mdev); + if (ret) + return ret; + + media_graph_walk_start(&graph, start_entity); + + while ((entity = media_graph_walk_next(&graph))) { + if (!is_media_entity_v4l2_subdev(entity)) + continue; + + sd = media_entity_to_v4l2_subdev(entity); + + ret = v4l2_ctrl_add_handler(vfd->ctrl_handler, + sd->ctrl_handler, + NULL); + if (ret) + break; + } + + media_graph_walk_cleanup(&graph); + return ret; +} +EXPORT_SYMBOL_GPL(__v4l2_pipeline_inherit_controls); + +int v4l2_pipeline_inherit_controls(struct video_device *vfd, + struct media_entity *start_entity) +{ + struct media_device *mdev = start_entity->graph_obj.mdev; + int ret; + + mutex_lock(&mdev->graph_mutex); + ret = __v4l2_pipeline_inherit_controls(vfd, start_entity); + mutex_unlock(&mdev->graph_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(v4l2_pipeline_inherit_controls); + /* - * Pipeline power management * diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index 2634d9d..299d75d 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -171,6 +171,23 @@ void v4l_disable_media_source(struct video_device *vdev); */ int v4l_vb2q_enable_media_source(struct vb2_queue *q); +/** + * v4l2_pipeline_inherit_controls - Add the v4l2 controls from all + * subdev entities in a pipeline to + * the given video device. + * @vfd: the video device + * @start_entity: Starting entity + * + * This function is intended to be called from the link_notify callback, + * which holds the media graph mutex lock. __v4l2_pipeline_inherit_controls + * is provided (which does not acquire the lock) for this purpose. + * v4l2_pipeline_inherit_controls is also provided for use in other + * locations where the graph mutex is not held. + */ +int __v4l2_pipeline_inherit_controls(struct video_device *vfd, +struct media_entity *start_entity); +int v4l2_pipeline_inherit_controls(struct video_device *vfd, + struct media_entity *start_entity); /** * v4l2_pipeline_pm_use - Update the use count of an entity @@ -231,6 +248,20 @@ static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q) return 0; } +static inline int __v4l2_pipeline_inherit_controls( + struct video_device *vfd, + struct media_entity *start_entity) +{ + return 0; +} + +static inline int v4l2_pipeline_inherit_controls( + struct video_device *vfd, + struct media_entity *start_entity) +{ + return 0; +} + static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use) { return 0; -- 2.7.4
[PATCH v6 06/39] ARM: dts: imx6qdl: add capture-subsystem device
Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6dl.dtsi | 5 + arch/arm/boot/dts/imx6q.dtsi | 5 + 2 files changed, 10 insertions(+) diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi index 8958c4a..a959c76 100644 --- a/arch/arm/boot/dts/imx6dl.dtsi +++ b/arch/arm/boot/dts/imx6dl.dtsi @@ -100,6 +100,11 @@ }; }; + capture-subsystem { + compatible = "fsl,imx-capture-subsystem"; + ports = <&ipu1_csi0>, <&ipu1_csi1>; + }; + display-subsystem { compatible = "fsl,imx-display-subsystem"; ports = <&ipu1_di0>, <&ipu1_di1>; diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi index b833b0d..4cc6579 100644 --- a/arch/arm/boot/dts/imx6q.dtsi +++ b/arch/arm/boot/dts/imx6q.dtsi @@ -206,6 +206,11 @@ }; }; + capture-subsystem { + compatible = "fsl,imx-capture-subsystem"; + ports = <&ipu1_csi0>, <&ipu1_csi1>, <&ipu2_csi0>, <&ipu2_csi1>; + }; + display-subsystem { compatible = "fsl,imx-display-subsystem"; ports = <&ipu1_di0>, <&ipu1_di1>, <&ipu2_di0>, <&ipu2_di1>; -- 2.7.4
[PATCH v6 09/39] ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors
Enables the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor. The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux. The OV5640 connects to the input port on the MIPI CSI-2 receiver on mipi_csi. Until the OV5652 sensor module compatible with the SabreSD becomes available for testing, the ov5642 node is currently disabled. Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6dl-sabresd.dts | 5 ++ arch/arm/boot/dts/imx6q-sabresd.dts| 5 ++ arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 114 - 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/imx6dl-sabresd.dts b/arch/arm/boot/dts/imx6dl-sabresd.dts index 1e45f2f..9607afe 100644 --- a/arch/arm/boot/dts/imx6dl-sabresd.dts +++ b/arch/arm/boot/dts/imx6dl-sabresd.dts @@ -15,3 +15,8 @@ model = "Freescale i.MX6 DualLite SABRE Smart Device Board"; compatible = "fsl,imx6dl-sabresd", "fsl,imx6dl"; }; + +&ipu1_csi1_from_ipu1_csi1_mux { + clock-lanes = <0>; + data-lanes = <1 2>; +}; diff --git a/arch/arm/boot/dts/imx6q-sabresd.dts b/arch/arm/boot/dts/imx6q-sabresd.dts index 9cbdfe7..527772b 100644 --- a/arch/arm/boot/dts/imx6q-sabresd.dts +++ b/arch/arm/boot/dts/imx6q-sabresd.dts @@ -23,3 +23,8 @@ &sata { status = "okay"; }; + +&ipu1_csi1_from_mipi_vc1 { + clock-lanes = <0>; + data-lanes = <1 2>; +}; diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi index 63bf95e..643c1d4 100644 --- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi @@ -10,6 +10,7 @@ * http://www.gnu.org/copyleft/gpl.html */ +#include #include #include @@ -146,6 +147,36 @@ }; }; +&ipu1_csi0_from_ipu1_csi0_mux { + bus-width = <8>; + data-shift = <12>; /* Lines 19:12 used */ + hsync-active = <1>; + vsync-active = <1>; +}; + +&ipu1_csi0_mux_from_parallel_sensor { + remote-endpoint = <&ov5642_to_ipu1_csi0_mux>; +}; + +&ipu1_csi0 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ipu1_csi0>; +}; + +&mipi_csi { + status = "okay"; + + port@0 { + reg = <0>; + + mipi_csi2_in: endpoint { + remote-endpoint = <&ov5640_to_mipi_csi2>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; +}; + &audmux { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_audmux>; @@ -213,7 +244,32 @@ 0x8014 /* 4:FN_DMICCDAT */ 0x /* 5:Default */ >; - }; + }; + + ov5642: camera@3c { + compatible = "ovti,ov5642"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ov5642>; + clocks = <&clks IMX6QDL_CLK_CKO>; + clock-names = "xclk"; + reg = <0x3c>; + DOVDD-supply = <&vgen4_reg>; /* 1.8v */ + AVDD-supply = <&vgen3_reg>; /* 2.8v, rev C board is VGEN3 + rev B board is VGEN5 */ + DVDD-supply = <&vgen2_reg>; /* 1.5v*/ + powerdown-gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 17 GPIO_ACTIVE_LOW>; + status = "disabled"; + + port { + ov5642_to_ipu1_csi0_mux: endpoint { + remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>; + bus-width = <8>; + hsync-active = <1>; + vsync-active = <1>; + }; + }; + }; }; &i2c2 { @@ -222,6 +278,32 @@ pinctrl-0 = <&pinctrl_i2c2>; status = "okay"; + ov5640: camera@3c { + compatible = "ovti,ov5640"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ov5640>; + reg = <0x3c>; + clocks = <&clks IMX6QDL_CLK_CKO>; + clock-names = "xclk"; + DOVDD-supply = <&vgen4_reg>; /* 1.8v */ + AVDD-supply = <&vgen3_reg>; /* 2.8v, rev C board is VGEN3 + rev B board is VGEN5 */ + DVDD-supply = <&vgen2_reg>; /* 1.5v*/ + powerdown-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>; + + port { + #address-cells = <1>; + #size-cells = <0>; + + ov5640_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_in>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; + pmic: pfuze100@08 { compatib
[PATCH v6 05/39] ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections
From: Philipp Zabel This patch adds the device tree graph connecting the input multiplexers to the IPU CSIs and the MIPI-CSI2 gasket on i.MX6. The MIPI_IPU multiplexers are added as children of the iomuxc-gpr syscon device node. On i.MX6Q/D two two-input multiplexers in front of IPU1 CSI0 and IPU2 CSI1 allow to select between CSI0/1 parallel input pads and the MIPI CSI-2 virtual channels 0/3. On i.MX6DL/S two five-input multiplexers in front of IPU1 CSI0 and IPU1 CSI1 allow to select between CSI0/1 parallel input pads and any of the four MIPI CSI-2 virtual channels. Signed-off-by: Philipp Zabel -- - Removed some dangling/unused endpoints (ipu2_csi0_from_csi2ipu) - Renamed the mipi virtual channel endpoint labels, from "mipi_csiX_..." to "mipi_vcX...". - Added input endpoint anchors to the video muxes for the connections from parallel sensors. Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6dl.dtsi | 180 + arch/arm/boot/dts/imx6q.dtsi | 116 ++ arch/arm/boot/dts/imx6qdl.dtsi | 10 ++- 3 files changed, 305 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi index 7aa120f..8958c4a 100644 --- a/arch/arm/boot/dts/imx6dl.dtsi +++ b/arch/arm/boot/dts/imx6dl.dtsi @@ -181,6 +181,186 @@ "di0", "di1"; }; +&gpr { + ipu1_csi0_mux: ipu1_csi0_mux@34 { + compatible = "video-multiplexer"; + reg = <0x34>; + bit-mask = <0x7>; + bit-shift = <0>; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + port@0 { + reg = <0>; + + ipu1_csi0_mux_from_mipi_vc0: endpoint { + remote-endpoint = <&mipi_vc0_to_ipu1_csi0_mux>; + }; + }; + + port@1 { + reg = <1>; + + ipu1_csi0_mux_from_mipi_vc1: endpoint { + remote-endpoint = <&mipi_vc1_to_ipu1_csi0_mux>; + }; + }; + + port@2 { + reg = <2>; + + ipu1_csi0_mux_from_mipi_vc2: endpoint { + remote-endpoint = <&mipi_vc2_to_ipu1_csi0_mux>; + }; + }; + + port@3 { + reg = <3>; + + ipu1_csi0_mux_from_mipi_vc3: endpoint { + remote-endpoint = <&mipi_vc3_to_ipu1_csi0_mux>; + }; + }; + + port@4 { + reg = <4>; + + ipu1_csi0_mux_from_parallel_sensor: endpoint { + }; + }; + + port@5 { + reg = <5>; + + ipu1_csi0_mux_to_ipu1_csi0: endpoint { + remote-endpoint = <&ipu1_csi0_from_ipu1_csi0_mux>; + }; + }; + }; + + ipu1_csi1_mux: ipu1_csi1_mux@34 { + compatible = "video-multiplexer"; + reg = <0x34>; + bit-mask = <0x7>; + bit-shift = <3>; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + port@0 { + reg = <0>; + + ipu1_csi1_mux_from_mipi_vc0: endpoint { + remote-endpoint = <&mipi_vc0_to_ipu1_csi1_mux>; + }; + }; + + port@1 { + reg = <1>; + + ipu1_csi1_mux_from_mipi_vc1: endpoint { + remote-endpoint = <&mipi_vc1_to_ipu1_csi1_mux>; + }; + }; + + port@2 { + reg = <2>; + + ipu1_csi1_mux_from_mipi_vc2: endpoint { + remote-endpoint = <&mipi_vc2_to_ipu1_csi1_mux>; + }; + }; + + port@3 { + reg = <3>; + + ipu1_csi1_mux_from_mipi_vc3: endpoint { + remote-endpoint = <&mipi_vc3_to_ipu1_csi1_mux>; + }; + }; + + port@4 { + reg = <4>; + + ipu1_csi1_mux_from_parallel_sensor: endpoint { + }; + }; + + port@5 { + reg = <5>; + + ipu1_csi1_mux_to_ipu1_csi1: endpoint { + remote-endpoint = <&ipu1_csi1_from_ipu1_csi1_mux>; + }; + }; + }; +}; + +&ipu1_csi1 { + ipu1_csi1_from_ipu1_csi1_mux: endpoint { + r
[PATCH v6 14/39] add mux and video interface bridge entity functions
From: Philipp Zabel Signed-off-by: Philipp Zabel - renamed MEDIA_ENT_F_MUX to MEDIA_ENT_F_VID_MUX Signed-off-by: Steve Longerbeam --- Documentation/media/uapi/mediactl/media-types.rst | 22 ++ include/uapi/linux/media.h| 6 ++ 2 files changed, 28 insertions(+) diff --git a/Documentation/media/uapi/mediactl/media-types.rst b/Documentation/media/uapi/mediactl/media-types.rst index 2a5164a..47ee003 100644 --- a/Documentation/media/uapi/mediactl/media-types.rst +++ b/Documentation/media/uapi/mediactl/media-types.rst @@ -299,6 +299,28 @@ Types and flags used to represent the media graph elements received on its sink pad and outputs the statistics data on its source pad. +- .. row 29 + + .. _MEDIA-ENT-F-VID-MUX: + + - ``MEDIA_ENT_F_VID_MUX`` + + - Video multiplexer. An entity capable of multiplexing must have at + least two sink pads and one source pad, and must pass the video + frame(s) received from the active sink pad to the source pad. Video + frame(s) from the inactive sink pads are discarded. + +- .. row 30 + + .. _MEDIA-ENT-F-VID-IF-BRIDGE: + + - ``MEDIA_ENT_F_VID_IF_BRIDGE`` + + - Video interface bridge. A video interface bridge entity must have at + least one sink pad and one source pad. It receives video frame(s) on + its sink pad in one bus format (HDMI, eDP, MIPI CSI-2, ...) and + converts them and outputs them on its source pad in another bus format + (eDP, MIPI CSI-2, parallel, ...). .. tabularcolumns:: |p{5.5cm}|p{12.0cm}| diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 4890787..fac96c6 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -105,6 +105,12 @@ struct media_device_info { #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006) /* + * Switch and bridge entitites + */ +#define MEDIA_ENT_F_VID_MUX(MEDIA_ENT_F_BASE + 0x5001) +#define MEDIA_ENT_F_VID_IF_BRIDGE (MEDIA_ENT_F_BASE + 0x5002) + +/* * Connectors */ /* It is a responsibility of the entity drivers to add connectors and links */ -- 2.7.4
[PATCH v6 28/39] media: imx: csi: fix crop rectangle changes in set_fmt
From: Philipp Zabel The cropping rectangle was being modified by the output pad's set_fmt, which is the wrong pad to do this. The crop rectangle should not be modified by the output pad set_fmt. It instead should be reset to the full input frame when the input pad format is set. The output pad set_fmt should set width/height to the current crop dimensions, or 1/2 the crop width/height to enable downscaling. So the other part of this patch is to enable downscaling if the output pad dimension(s) are 1/2 the crop dimension(s) at csi_setup() time. Signed-off-by: Philipp Zabel Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 35 --- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 37c68d8..730966b 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -555,6 +555,10 @@ static int csi_setup(struct csi_priv *priv) ipu_csi_set_window(priv->csi, &priv->crop); + ipu_csi_set_downsize(priv->csi, +priv->crop.width == 2 * outfmt->width, +priv->crop.height == 2 * outfmt->height); + ipu_csi_init_interface(priv->csi, &sensor_mbus_cfg, &if_fmt); ipu_csi_set_dest(priv->csi, priv->dest); @@ -945,15 +949,15 @@ static int csi_set_fmt(struct v4l2_subdev *sd, switch (sdformat->pad) { case CSI_SRC_PAD_DIRECT: case CSI_SRC_PAD_IDMAC: - crop.left = priv->crop.left; - crop.top = priv->crop.top; - crop.width = sdformat->format.width; - crop.height = sdformat->format.height; - ret = csi_try_crop(priv, &crop, sensor); - if (ret) - goto out; - sdformat->format.width = crop.width; - sdformat->format.height = crop.height; + if (sdformat->format.width < priv->crop.width * 3 / 4) + sdformat->format.width = priv->crop.width / 2; + else + sdformat->format.width = priv->crop.width; + + if (sdformat->format.height < priv->crop.height * 3 / 4) + sdformat->format.height = priv->crop.height / 2; + else + sdformat->format.height = priv->crop.height; if (sdformat->pad == CSI_SRC_PAD_IDMAC) { cc = imx_media_find_format(0, sdformat->format.code, @@ -999,6 +1003,14 @@ static int csi_set_fmt(struct v4l2_subdev *sd, } break; case CSI_SINK_PAD: + crop.left = 0; + crop.top = 0; + crop.width = sdformat->format.width; + crop.height = sdformat->format.height; + ret = csi_try_crop(priv, &crop, sensor); + if (ret) + goto out; + cc = imx_media_find_format(0, sdformat->format.code, true, false); if (!cc) { @@ -1017,9 +1029,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd, } else { priv->format_mbus[sdformat->pad] = sdformat->format; priv->cc[sdformat->pad] = cc; - /* Update the crop window if this is an output pad */ - if (sdformat->pad == CSI_SRC_PAD_DIRECT || - sdformat->pad == CSI_SRC_PAD_IDMAC) + /* Reset the crop window if this is the input pad */ + if (sdformat->pad == CSI_SINK_PAD) priv->crop = crop; } -- 2.7.4
[PATCH v6 18/39] media: Add userspace header file for i.MX
This adds a header file for use by userspace programs wanting to interact with the i.MX media driver. It defines custom events and v4l2 controls for the i.MX v4l2 subdevices. Signed-off-by: Steve Longerbeam --- include/linux/imx-media.h | 27 +++ 1 file changed, 27 insertions(+) create mode 100644 include/linux/imx-media.h diff --git a/include/linux/imx-media.h b/include/linux/imx-media.h new file mode 100644 index 000..26f --- /dev/null +++ b/include/linux/imx-media.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2014-2017 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the + * License, or (at your option) any later version + */ + +#ifndef __LINUX_IMX_MEDIA_H__ +#define __LINUX_IMX_MEDIA_H__ + +/* + * events from the subdevs + */ +#define V4L2_EVENT_IMX_CLASSV4L2_EVENT_PRIVATE_START +#define V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR (V4L2_EVENT_IMX_CLASS + 1) + +enum imx_ctrl_id { + V4L2_CID_IMX_FIM_ENABLE = (V4L2_CID_USER_IMX_BASE + 0), + V4L2_CID_IMX_FIM_NUM, + V4L2_CID_IMX_FIM_TOLERANCE_MIN, + V4L2_CID_IMX_FIM_TOLERANCE_MAX, + V4L2_CID_IMX_FIM_NUM_SKIP, +}; + +#endif -- 2.7.4
[PATCH v6 23/39] media: imx: Add IC subdev drivers
This is a set of three media entity subdevice drivers for the i.MX Image Converter: - Pre-process Router: Takes input frames from CSI0, CSI1, or VDIC. Two output pads enable either or both of the preprocess tasks below. If the input is from one of the CSIs, both proprocess task links can be enabled to process frames from that CSI simultaneously. If the input is the VDIC, only the Pre-processing Viewfinder task link can be enabled. - Pre-processing Encode task: video frames are routed directly from the CSI and can be scaled, color-space converted, and rotated. Scaled output is limited to 1024x1024 resolution. Output frames are routed to the capture device. - Pre-processing Viewfinder task: this task can perform the same conversions as the pre-process encode task, but in addition can be used for hardware motion compensated deinterlacing. Frames can come either directly from the CSI or from the VDIC. Scaled output is limited to 1024x1024 resolution. Output frames are routed to the capture device. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/Makefile |2 + drivers/staging/media/imx/imx-ic-common.c | 113 +++ drivers/staging/media/imx/imx-ic-prp.c | 434 ++ drivers/staging/media/imx/imx-ic-prpencvf.c | 1170 +++ drivers/staging/media/imx/imx-ic.h | 38 + 5 files changed, 1757 insertions(+) create mode 100644 drivers/staging/media/imx/imx-ic-common.c create mode 100644 drivers/staging/media/imx/imx-ic-prp.c create mode 100644 drivers/staging/media/imx/imx-ic-prpencvf.c create mode 100644 drivers/staging/media/imx/imx-ic.h diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 1f01520..878a126 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -1,9 +1,11 @@ imx-media-objs := imx-media-dev.o imx-media-internal-sd.o imx-media-of.o imx-media-common-objs := imx-media-utils.o imx-media-fim.o +imx-media-ic-objs := imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o +obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o diff --git a/drivers/staging/media/imx/imx-ic-common.c b/drivers/staging/media/imx/imx-ic-common.c new file mode 100644 index 000..cfdd490 --- /dev/null +++ b/drivers/staging/media/imx/imx-ic-common.c @@ -0,0 +1,113 @@ +/* + * V4L2 Image Converter Subdev for Freescale i.MX5/6 SOC + * + * Copyright (c) 2014-2016 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include "imx-media.h" +#include "imx-ic.h" + +#define IC_TASK_PRP IC_NUM_TASKS +#define IC_NUM_OPS (IC_NUM_TASKS + 1) + +static struct imx_ic_ops *ic_ops[IC_NUM_OPS] = { + [IC_TASK_PRP]= &imx_ic_prp_ops, + [IC_TASK_ENCODER]= &imx_ic_prpencvf_ops, + [IC_TASK_VIEWFINDER] = &imx_ic_prpencvf_ops, +}; + +static int imx_ic_probe(struct platform_device *pdev) +{ + struct imx_media_internal_sd_platformdata *pdata; + struct imx_ic_priv *priv; + int ret; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + platform_set_drvdata(pdev, &priv->sd); + priv->dev = &pdev->dev; + + /* get our ipu_id, grp_id and IC task id */ + pdata = priv->dev->platform_data; + priv->ipu_id = pdata->ipu_id; + switch (pdata->grp_id) { + case IMX_MEDIA_GRP_ID_IC_PRP: + priv->task_id = IC_TASK_PRP; + break; + case IMX_MEDIA_GRP_ID_IC_PRPENC: + priv->task_id = IC_TASK_ENCODER; + break; + case IMX_MEDIA_GRP_ID_IC_PRPVF: + priv->task_id = IC_TASK_VIEWFINDER; + break; + default: + return -EINVAL; + } + + v4l2_subdev_init(&priv->sd, ic_ops[priv->task_id]->subdev_ops); + v4l2_set_subdevdata(&priv->sd, priv); + priv->sd.internal_ops = ic_ops[priv->task_id]->internal_ops; + priv->sd.entity.ops = ic_ops[priv->task_id]->entity_ops; + priv->sd.entity.function = MEDIA_ENT_F_PROC_VIDEO_SCALER; + priv->sd.dev = &pdev->dev; + priv->sd.owner = THIS_MODULE; + priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; + priv->sd.grp_id = pdata->grp_id; + strncpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name)); + + ret = ic_ops[priv->task_id]->init(priv); + if (ret) + return ret; + + r
[PATCH v6 30/39] media: imx: csi/fim: add support for frame intervals
From: Russell King Add support to CSI for negotiation of frame intervals, and use this information to configure the frame interval monitor. Signed-off-by: Russell King Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 46 +-- drivers/staging/media/imx/imx-media-fim.c | 28 +++ drivers/staging/media/imx/imx-media.h | 2 +- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index f4c6a33..59d80ba 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -63,6 +63,7 @@ struct csi_priv { struct v4l2_mbus_framefmt format_mbus[CSI_NUM_PADS]; const struct imx_media_pixfmt *cc[CSI_NUM_PADS]; + struct v4l2_fract frame_interval; struct v4l2_rect crop; /* active vb2 buffers to send to video dev sink */ @@ -589,7 +590,8 @@ static int csi_start(struct csi_priv *priv) /* start the frame interval monitor */ if (priv->fim) { - ret = imx_media_fim_set_stream(priv->fim, priv->sensor, true); + ret = imx_media_fim_set_stream(priv->fim, + &priv->frame_interval, true); if (ret) goto idmac_stop; } @@ -604,7 +606,8 @@ static int csi_start(struct csi_priv *priv) fim_off: if (priv->fim) - imx_media_fim_set_stream(priv->fim, priv->sensor, false); + imx_media_fim_set_stream(priv->fim, +&priv->frame_interval, false); idmac_stop: if (priv->dest == IPU_CSI_DEST_IDMAC) csi_idmac_stop(priv); @@ -618,7 +621,8 @@ static void csi_stop(struct csi_priv *priv) /* stop the frame interval monitor */ if (priv->fim) - imx_media_fim_set_stream(priv->fim, priv->sensor, false); + imx_media_fim_set_stream(priv->fim, +&priv->frame_interval, false); ipu_csi_disable(priv->csi); } @@ -627,6 +631,36 @@ static void csi_stop(struct csi_priv *priv) * V4L2 subdev operations. */ +static int csi_g_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_frame_interval *fi) +{ + struct csi_priv *priv = v4l2_get_subdevdata(sd); + + mutex_lock(&priv->lock); + fi->interval = priv->frame_interval; + mutex_unlock(&priv->lock); + + return 0; +} + +static int csi_s_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_frame_interval *fi) +{ + struct csi_priv *priv = v4l2_get_subdevdata(sd); + + mutex_lock(&priv->lock); + + /* Output pads mirror active input pad, no limits on input pads */ + if (fi->pad == CSI_SRC_PAD_IDMAC || fi->pad == CSI_SRC_PAD_DIRECT) + fi->interval = priv->frame_interval; + + priv->frame_interval = fi->interval; + + mutex_unlock(&priv->lock); + + return 0; +} + static int csi_s_stream(struct v4l2_subdev *sd, int enable) { struct csi_priv *priv = v4l2_get_subdevdata(sd); @@ -1216,6 +1250,10 @@ static int csi_registered(struct v4l2_subdev *sd) goto put_csi; } + /* init default frame interval */ + priv->frame_interval.numerator = 1; + priv->frame_interval.denominator = 30; + priv->fim = imx_media_fim_init(&priv->sd); if (IS_ERR(priv->fim)) { ret = PTR_ERR(priv->fim); @@ -1266,6 +1304,8 @@ static struct v4l2_subdev_core_ops csi_core_ops = { }; static struct v4l2_subdev_video_ops csi_video_ops = { + .g_frame_interval = csi_g_frame_interval, + .s_frame_interval = csi_s_frame_interval, .s_stream = csi_s_stream, }; diff --git a/drivers/staging/media/imx/imx-media-fim.c b/drivers/staging/media/imx/imx-media-fim.c index 0623bc5..e9525cd 100644 --- a/drivers/staging/media/imx/imx-media-fim.c +++ b/drivers/staging/media/imx/imx-media-fim.c @@ -67,26 +67,18 @@ struct imx_media_fim { }; static void update_fim_nominal(struct imx_media_fim *fim, - struct imx_media_subdev *sensor) + const struct v4l2_fract *fi) { - struct v4l2_streamparm parm; - struct v4l2_fract tpf; - int ret; - - parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - ret = v4l2_subdev_call(sensor->sd, video, g_parm, &parm); - tpf = parm.parm.capture.timeperframe; - - if (ret || tpf.denominator == 0) { - dev_dbg(fim->sd->dev, "no tpf from sensor, FIM disabled\n"); + if (fi->denominator == 0) { + dev_dbg(fim->sd->dev, "no frame interval, FIM disabled\n"); fim->enabled = false; return; } - fim->nominal = DIV_ROUND_CLOSEST(1000 * 1000 * tpf.numer
[PATCH v6 17/39] platform: add video-multiplexer subdevice driver
From: Philipp Zabel This driver can handle SoC internal and external video bus multiplexers, controlled either by register bit fields or by a GPIO. The subdevice passes through frame interval and mbus configuration of the active input to the output side. Signed-off-by: Sascha Hauer Signed-off-by: Philipp Zabel - fixed a cut&paste error in vidsw_remove(): v4l2_async_register_subdev() should be unregister. - added media_entity_cleanup() to vidsw_remove(). - added missing MODULE_DEVICE_TABLE(). Suggested-by: Javier Martinez Canillas - there was a line left over from a previous iteration that negated the new way of determining the pad count just before it which has been removed (num_pads = of_get_child_count(np)). - removed [gs]_frame_interval ops. timeperframe is not used anywhwere in this subdev, and currently it has no control over frame rate. - add link_validate to media_entity_operations. - moved devicetree binding doc to a separate commit. - Philipp Zabel has developed a set of patches that allow adding to the subdev async notifier waiting list using a chaining method from the async registered callbacks (v4l2_of_subdev_registered() and the prep patches for that). For now, I've removed the use of v4l2_of_subdev_registered() for the vidmux driver's registered callback. This doesn't affect the functionality of this driver, but allows for it to be merged now, before adding the chaining support. Signed-off-by: Steve Longerbeam --- drivers/media/platform/Kconfig | 8 + drivers/media/platform/Makefile| 2 + drivers/media/platform/video-multiplexer.c | 451 + 3 files changed, 461 insertions(+) create mode 100644 drivers/media/platform/video-multiplexer.c diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index ab0bb48..c9b8d9c 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -74,6 +74,14 @@ config VIDEO_M32R_AR_M64278 To compile this driver as a module, choose M here: the module will be called arv. +config VIDEO_MULTIPLEXER + tristate "Video Multiplexer" + depends on VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER + help + This driver provides support for SoC internal N:1 video bus + multiplexers controlled by register bitfields as well as external + 2:1 video multiplexers controlled by a single GPIO. + config VIDEO_OMAP3 tristate "OMAP 3 Camera support" depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && ARCH_OMAP3 diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile index 8959f6e..d418add 100644 --- a/drivers/media/platform/Makefile +++ b/drivers/media/platform/Makefile @@ -27,6 +27,8 @@ obj-$(CONFIG_VIDEO_SH_VEU)+= sh_veu.o obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)+= m2m-deinterlace.o +obj-$(CONFIG_VIDEO_MULTIPLEXER)+= video-multiplexer.o + obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif/ obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/ diff --git a/drivers/media/platform/video-multiplexer.c b/drivers/media/platform/video-multiplexer.c new file mode 100644 index 000..b18c317 --- /dev/null +++ b/drivers/media/platform/video-multiplexer.c @@ -0,0 +1,451 @@ +/* + * video stream multiplexer controlled via gpio or syscon + * + * Copyright (C) 2013 Pengutronix, Sascha Hauer + * Copyright (C) 2016 Pengutronix, Philipp Zabel + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct vidsw { + struct v4l2_subdev subdev; + unsigned int num_pads; + struct media_pad *pads; + struct v4l2_mbus_framefmt *format_mbus; + struct v4l2_of_endpoint *endpoint; + struct regmap_field *field; + struct gpio_desc *gpio; + int active; +}; + +static inline struct vidsw *v4l2_subdev_to_vidsw(struct v4l2_subdev *sd) +{ + return container_of(sd, struct vidsw, subdev); +} + +static void vidsw_set_active(struct vidsw *vidsw, int active) +{ + vidsw->active = active; + if (active < 0) + return; + + dev_dbg(vidsw->subdev.dev, "setting %d active\n", active); + + if (vidsw->field) + regmap_field_write(vidsw->field, active); + else if (vidsw->gpio) + gpiod_set
[PATCH v6 24/39] media: imx: Add MIPI CSI-2 Receiver subdev driver
Adds MIPI CSI-2 Receiver subdev driver. This subdev is required for sensors with a MIPI CSI2 interface. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/Makefile | 1 + drivers/staging/media/imx/imx6-mipi-csi2.c | 673 + 2 files changed, 674 insertions(+) create mode 100644 drivers/staging/media/imx/imx6-mipi-csi2.c diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 878a126..3569625 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o +obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c new file mode 100644 index 000..6411b48 --- /dev/null +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -0,0 +1,673 @@ +/* + * MIPI CSI-2 Receiver Subdev for Freescale i.MX6 SOC. + * + * Copyright (c) 2012-2017 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "imx-media.h" + +/* + * there must be 5 pads: 1 input pad from sensor, and + * the 4 virtual channel output pads + */ +#define CSI2_SINK_PAD 0 +#define CSI2_NUM_SINK_PADS 1 +#define CSI2_NUM_SRC_PADS 4 +#define CSI2_NUM_PADS 5 + +/* + * The default maximum bit-rate per lane in Mbps, if the + * source subdev does not provide V4L2_CID_LINK_FREQ. + */ +#define CSI2_DEFAULT_MAX_MBPS 849 + +struct csi2_dev { + struct device *dev; + struct v4l2_subdev sd; + struct media_pad pad[CSI2_NUM_PADS]; + struct clk *dphy_clk; + struct clk *pllref_clk; + struct clk *pix_clk; /* what is this? */ + void __iomem *base; + struct v4l2_of_bus_mipi_csi2 bus; + + /* lock to protect all members below */ + struct mutex lock; + + struct v4l2_mbus_framefmt format_mbus; + + int power_count; + boolstream_on; + struct v4l2_subdev *src_sd; + boolsink_linked[CSI2_NUM_SRC_PADS]; +}; + +#define DEVICE_NAME "imx6-mipi-csi2" + +/* Register offsets */ +#define CSI2_VERSION0x000 +#define CSI2_N_LANES0x004 +#define CSI2_PHY_SHUTDOWNZ 0x008 +#define CSI2_DPHY_RSTZ 0x00c +#define CSI2_RESETN 0x010 +#define CSI2_PHY_STATE 0x014 +#define PHY_STOPSTATEDATA_BIT 4 +#define PHY_STOPSTATEDATA(n)BIT(PHY_STOPSTATEDATA_BIT + (n)) +#define PHY_RXCLKACTIVEHS BIT(8) +#define PHY_RXULPSCLKNOTBIT(9) +#define PHY_STOPSTATECLKBIT(10) +#define CSI2_DATA_IDS_1 0x018 +#define CSI2_DATA_IDS_2 0x01c +#define CSI2_ERR1 0x020 +#define CSI2_ERR2 0x024 +#define CSI2_MSK1 0x028 +#define CSI2_MSK2 0x02c +#define CSI2_PHY_TST_CTRL0 0x030 +#define PHY_TESTCLRBIT(0) +#define PHY_TESTCLKBIT(1) +#define CSI2_PHY_TST_CTRL1 0x034 +#define PHY_TESTEN BIT(16) +#define CSI2_SFT_RESET 0xf00 + +static inline struct csi2_dev *sd_to_dev(struct v4l2_subdev *sdev) +{ + return container_of(sdev, struct csi2_dev, sd); +} + +/* + * The required sequence of MIPI CSI-2 startup as specified in the i.MX6 + * reference manual is as follows: + * + * 1. Deassert presetn signal (global reset). + *It's not clear what this "global reset" signal is (maybe APB + *global reset), but in any case this step would be probably + *be carried out during driver load in csi2_probe(). + * + * 2. Configure MIPI Camera Sensor to put all Tx lanes in LP-11 state. + *This must be carried out by the MIPI sensor's s_power(ON) subdev + *op. + * + * 3. D-PHY initialization. + * 4. CSI2 Controller programming (Set N_LANES, deassert PHY_SHUTDOWNZ, + *deassert PHY_RSTZ, deassert CSI2_RESETN). + * 5. Read the PHY status register (PHY_STATE) to confirm that all data and + *clock lanes of the D-PHY are in LP-11 state. + *These steps (3,4,5) are carried out by csi2_s_power(ON) here. + * + * 6. Configure the MIPI Camera Sensor to start transmitting a clock on the + *D-PHY clock lane. + *This must be carried out by the MIPI sensor's s_stream(ON) subdev + *op. + * + * 7. CSI2 Controller programming - Read the PHY status register (PHY_STATE) + *to confirm that the D-PHY is receiving a clock on the D-PHY clock lane. + *Th
[PATCH v6 19/39] media: Add i.MX media core driver
Add the core media driver for i.MX SOC. Signed-off-by: Steve Longerbeam --- Documentation/media/v4l-drivers/imx.rst | 590 ++ drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile| 1 + drivers/staging/media/imx/Kconfig | 6 + drivers/staging/media/imx/Makefile| 5 + drivers/staging/media/imx/TODO| 17 + drivers/staging/media/imx/imx-media-dev.c | 503 drivers/staging/media/imx/imx-media-fim.c | 471 +++ drivers/staging/media/imx/imx-media-internal-sd.c | 349 +++ drivers/staging/media/imx/imx-media-of.c | 267 drivers/staging/media/imx/imx-media-utils.c | 704 ++ drivers/staging/media/imx/imx-media.h | 297 + include/media/imx.h | 15 + include/uapi/linux/v4l2-controls.h| 4 + 14 files changed, 3231 insertions(+) create mode 100644 Documentation/media/v4l-drivers/imx.rst create mode 100644 drivers/staging/media/imx/Kconfig create mode 100644 drivers/staging/media/imx/Makefile create mode 100644 drivers/staging/media/imx/TODO create mode 100644 drivers/staging/media/imx/imx-media-dev.c create mode 100644 drivers/staging/media/imx/imx-media-fim.c create mode 100644 drivers/staging/media/imx/imx-media-internal-sd.c create mode 100644 drivers/staging/media/imx/imx-media-of.c create mode 100644 drivers/staging/media/imx/imx-media-utils.c create mode 100644 drivers/staging/media/imx/imx-media.h create mode 100644 include/media/imx.h diff --git a/Documentation/media/v4l-drivers/imx.rst b/Documentation/media/v4l-drivers/imx.rst new file mode 100644 index 000..c508d5b --- /dev/null +++ b/Documentation/media/v4l-drivers/imx.rst @@ -0,0 +1,590 @@ +i.MX Video Capture Driver += + +Introduction + + +The Freescale i.MX5/6 contains an Image Processing Unit (IPU), which +handles the flow of image frames to and from capture devices and +display devices. + +For image capture, the IPU contains the following internal subunits: + +- Image DMA Controller (IDMAC) +- Camera Serial Interface (CSI) +- Image Converter (IC) +- Sensor Multi-FIFO Controller (SMFC) +- Image Rotator (IRT) +- Video De-Interlacing or Combining Block (VDIC) + +The IDMAC is the DMA controller for transfer of image frames to and from +memory. Various dedicated DMA channels exist for both video capture and +display paths. During transfer, the IDMAC is also capable of vertical +image flip, 8x8 block transfer (see IRT description), pixel component +re-ordering (for example UYVY to YUYV) within the same colorspace, and +even packed <--> planar conversion. It can also perform a simple +de-interlacing by interleaving even and odd lines during transfer +(without motion compensation which requires the VDIC). + +The CSI is the backend capture unit that interfaces directly with +camera sensors over Parallel, BT.656/1120, and MIPI CSI-2 busses. + +The IC handles color-space conversion, resizing (downscaling and +upscaling), horizontal flip, and 90/270 degree rotation operations. + +There are three independent "tasks" within the IC that can carry out +conversions concurrently: pre-process encoding, pre-process viewfinder, +and post-processing. Within each task, conversions are split into three +sections: downsizing section, main section (upsizing, flip, colorspace +conversion, and graphics plane combining), and rotation section. + +The IPU time-shares the IC task operations. The time-slice granularity +is one burst of eight pixels in the downsizing section, one image line +in the main processing section, one image frame in the rotation section. + +The SMFC is composed of four independent FIFOs that each can transfer +captured frames from sensors directly to memory concurrently via four +IDMAC channels. + +The IRT carries out 90 and 270 degree image rotation operations. The +rotation operation is carried out on 8x8 pixel blocks at a time. This +operation is supported by the IDMAC which handles the 8x8 block transfer +along with block reordering, in coordination with vertical flip. + +The VDIC handles the conversion of interlaced video to progressive, with +support for different motion compensation modes (low, medium, and high +motion). The deinterlaced output frames from the VDIC can be sent to the +IC pre-process viewfinder task for further conversions. The VDIC also +contains a Combiner that combines two image planes, with alpha blending +and color keying. + +In addition to the IPU internal subunits, there are also two units +outside the IPU that are also involved in video capture on i.MX: + +- MIPI CSI-2 Receiver for camera sensors with the MIPI CSI-2 bus + interface. This is a Synopsys DesignWare core. +- Two video multiplexers for selecting among multiple sensor inputs + to send to a CSI. + +For more info, re
[PATCH v6 11/39] ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b
The reset pin to the port expander chip (MAX7310) is controlled by a gpio, so define a reset-gpios property to control it. There are three MAX7310's on the SabreAuto CPU card (max7310_[abc]), but all use the same pin for their reset. Since all can't acquire the same pin, assign it to max7310_b, that chip is needed by more functions (usb and adv7180). Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi index c8e35c4..21dea5f 100644 --- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi @@ -136,6 +136,9 @@ reg = <0x32>; gpio-controller; #gpio-cells = <2>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_max7310>; + reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; }; max7310_c: gpio@34 { @@ -441,6 +444,12 @@ >; }; + pinctrl_max7310: max7310grp { + fsl,pins = < + MX6QDL_PAD_SD2_DAT0__GPIO1_IO15 0x1b0b0 + >; + }; + pinctrl_pwm3: pwm1grp { fsl,pins = < MX6QDL_PAD_SD4_DAT1__PWM3_OUT 0x1b0b1 -- 2.7.4
[PATCH v6 12/39] ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture
Add pinctrl groups for both GPT input capture channels. Signed-off-by: Steve Longerbeam --- arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 12 1 file changed, 12 insertions(+) diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi index 21dea5f..1212f82 100644 --- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi @@ -456,6 +456,18 @@ >; }; + pinctrl_gpt_input_capture0: gptinputcapture0grp { + fsl,pins = < + MX6QDL_PAD_SD1_DAT0__GPT_CAPTURE1 0x1b0b0 + >; + }; + + pinctrl_gpt_input_capture1: gptinputcapture1grp { + fsl,pins = < + MX6QDL_PAD_SD1_DAT1__GPT_CAPTURE2 0x1b0b0 + >; + }; + pinctrl_spdif: spdifgrp { fsl,pins = < MX6QDL_PAD_KEY_COL3__SPDIF_IN 0x1b0b0 -- 2.7.4
[PATCH v6 20/39] media: imx: Add Capture Device Interface
This is the capture device interface driver that provides the v4l2 user interface. Frames can be received from various sources: - directly from CSI for capturing unconverted images directly from camera sensors. - from the IC pre-process encode task. - from the IC pre-process viewfinder task. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/Makefile| 1 + drivers/staging/media/imx/imx-media-capture.c | 663 ++ 2 files changed, 664 insertions(+) create mode 100644 drivers/staging/media/imx/imx-media-capture.c diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index ddd7d94..4606a3a 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -3,3 +3,4 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o +obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c new file mode 100644 index 000..3a09710 --- /dev/null +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -0,0 +1,663 @@ +/* + * Video Capture Subdev for Freescale i.MX5/6 SOC + * + * Copyright (c) 2012-2016 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "imx-media.h" + +struct capture_priv { + struct imx_media_video_dev vdev; + + struct v4l2_subdev*src_sd; + int src_sd_pad; + struct device *dev; + + struct media_pipeline mp; + struct imx_media_dev *md; + + struct media_pad vdev_pad; + + struct mutex mutex; /* capture device mutex */ + + /* the videobuf2 queue */ + struct vb2_queue q; + /* list of ready imx_media_buffer's from q */ + struct list_head ready_q; + /* protect ready_q */ + spinlock_t q_lock; + + /* controls inherited from subdevs */ + struct v4l2_ctrl_handler ctrl_hdlr; + + /* misc status */ + bool stop; /* streaming is stopping */ +}; + +#define to_capture_priv(v) container_of(v, struct capture_priv, vdev) + +/* In bytes, per queue */ +#define VID_MEM_LIMIT SZ_64M + +static struct vb2_ops capture_qops; + +/* + * Video ioctls follow + */ + +static int vidioc_querycap(struct file *file, void *fh, + struct v4l2_capability *cap) +{ + struct capture_priv *priv = video_drvdata(file); + + strncpy(cap->driver, "imx-media-capture", sizeof(cap->driver) - 1); + strncpy(cap->card, "imx-media-capture", sizeof(cap->card) - 1); + snprintf(cap->bus_info, sizeof(cap->bus_info), +"platform:%s", priv->src_sd->name); + + return 0; +} + +static int capture_enum_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_fmtdesc *f) +{ + u32 fourcc; + int ret; + + ret = imx_media_enum_format(&fourcc, NULL, f->index, true, true); + if (ret) + return ret; + + f->pixelformat = fourcc; + + return 0; +} + +static int capture_g_fmt_vid_cap(struct file *file, void *fh, +struct v4l2_format *f) +{ + struct capture_priv *priv = video_drvdata(file); + + *f = priv->vdev.fmt; + + return 0; +} + +static int capture_try_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) +{ + struct capture_priv *priv = video_drvdata(file); + struct v4l2_subdev_format fmt_src; + const struct imx_media_pixfmt *cc, *src_cc; + u32 fourcc; + int ret; + + fourcc = f->fmt.pix.pixelformat; + cc = imx_media_find_format(fourcc, 0, true, true); + if (!cc) { + imx_media_enum_format(&fourcc, NULL, 0, true, true); + cc = imx_media_find_format(fourcc, 0, true, true); + } + + /* +* user frame dimensions are the same as src_sd's pad. +*/ + fmt_src.pad = priv->src_sd_pad; + fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; + ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src); + if (ret) + return ret; + + /* +* but we can allow planar pixel formats if the src_sd's +* pad configured a YUV format +*/ + src_cc = imx_media_find_format(0, fmt_src.format.code, true, false); + i
[PATCH v6 16/39] [media] add Omnivision OV5640 sensor driver
This driver is based on ov5640_mipi.c from Freescale imx_3.10.17_1.0.0_beta branch, modified heavily to bring forward to latest interfaces and code cleanup. Signed-off-by: Steve Longerbeam --- drivers/media/i2c/Kconfig |7 + drivers/media/i2c/Makefile |1 + drivers/media/i2c/ov5640.c | 2219 3 files changed, 2227 insertions(+) create mode 100644 drivers/media/i2c/ov5640.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index cee1dae..bf67661 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -531,6 +531,13 @@ config VIDEO_OV2659 To compile this driver as a module, choose M here: the module will be called ov2659. +config VIDEO_OV5640 + tristate "OmniVision OV5640 sensor support" + depends on GPIOLIB && VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + ---help--- + This is a V4L2 sensor-level driver for the Omnivision + OV5640 camera sensor with a MIPI CSI-2 interface. + config VIDEO_OV7640 tristate "OmniVision OV7640 sensor support" depends on I2C && VIDEO_V4L2 diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index 5bc7bbe..3a9d73a 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -57,6 +57,7 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o +obj-$(CONFIG_VIDEO_OV5640) += ov5640.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.o obj-$(CONFIG_VIDEO_OV7670) += ov7670.o obj-$(CONFIG_VIDEO_OV9650) += ov9650.o diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c new file mode 100644 index 000..87a02b4 --- /dev/null +++ b/drivers/media/i2c/ov5640.c @@ -0,0 +1,2219 @@ +/* + * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright (C) 2014-2017 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* min/typical/max system clock (xclk) frequencies */ +#define OV5640_XCLK_MIN 600 +#define OV5640_XCLK_MAX 2400 + +/* + * FIXME: there is no subdev API to set the MIPI CSI-2 + * virtual channel yet, so this is hardcoded for now. + */ +#define OV5640_MIPI_VC 1 + +#define OV5640_DEFAULT_SLAVE_ID 0x3c + +#define OV5640_REG_CHIP_ID 0x300a +#define OV5640_REG_PAD_OUTPUT000x3019 +#define OV5640_REG_SC_PLL_CTRL00x3034 +#define OV5640_REG_SC_PLL_CTRL10x3035 +#define OV5640_REG_SC_PLL_CTRL20x3036 +#define OV5640_REG_SC_PLL_CTRL30x3037 +#define OV5640_REG_SLAVE_ID0x3100 +#define OV5640_REG_SYS_ROOT_DIVIDER0x3108 +#define OV5640_REG_AWB_R_GAIN 0x3400 +#define OV5640_REG_AWB_G_GAIN 0x3402 +#define OV5640_REG_AWB_B_GAIN 0x3404 +#define OV5640_REG_AWB_MANUAL_CTRL 0x3406 +#define OV5640_REG_AEC_PK_EXPOSURE_HI 0x3500 +#define OV5640_REG_AEC_PK_EXPOSURE_MED 0x3501 +#define OV5640_REG_AEC_PK_EXPOSURE_LO 0x3502 +#define OV5640_REG_AEC_PK_MANUAL 0x3503 +#define OV5640_REG_AEC_PK_REAL_GAIN0x350a +#define OV5640_REG_AEC_PK_VTS 0x350c +#define OV5640_REG_TIMING_HTS 0x380c +#define OV5640_REG_TIMING_VTS 0x380e +#define OV5640_REG_TIMING_TC_REG21 0x3821 +#define OV5640_REG_AEC_CTRL00 0x3a00 +#define OV5640_REG_AEC_B50_STEP0x3a08 +#define OV5640_REG_AEC_B60_STEP0x3a0a +#define OV5640_REG_AEC_CTRL0D 0x3a0d +#define OV5640_REG_AEC_CTRL0E 0x3a0e +#define OV5640_REG_AEC_CTRL0F 0x3a0f +#define OV5640_REG_AEC_CTRL10 0x3a10 +#define OV5640_REG_AEC_CTRL11 0x3a11 +#define OV5640_REG_AEC_CTRL1B 0x3a1b +#define OV5640_REG_AEC_CTRL1E 0x3a1e +#define OV5640_REG_AEC_CTRL1F 0x3a1f +#define OV5640_REG_HZ5060_CTRL00 0x3c00 +#define OV5640_REG_HZ5060_CTRL01 0x3c01 +#define OV5640_REG_SIGMADELTA_CTRL0C 0x3c0c +#define OV5640_REG_FRAME_CTRL010x4202 +#define OV5640_REG_MIPI_CTRL00 0x4800 +#define OV5640_REG_DEBUG_MODE 0x4814 +#define OV5640_REG_PRE_ISP_TEST_SET1 0x503d +#define OV5640_REG_SDE_CTRL0 0x5580 +#define OV5640_REG_SDE_CTRL1 0x5581 +#define OV5640_REG_SDE_CTRL3 0x5583 +#define OV5640_REG_SDE_CTRL4 0x5584 +#define OV5640_REG_SDE_CTRL5 0x5585 +#define OV5640_REG_AVG_READOUT 0x56a1 + +enum ov5640_mode_id { + OV5640_MODE_Q
[PATCH v6 32/39] media: imx: csi: add frame skipping support
From: Philipp Zabel The CSI can skip any out of up to 6 input frames, allowing to reduce the frame rate at the output pads by small fractions. Signed-off-by: Philipp Zabel Signed-off-by: Steve Longerbeam Signed-off-by: Russell King --- drivers/staging/media/imx/imx-media-csi.c | 127 -- 1 file changed, 122 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 5a09fa8..d9c3a3b 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1,13 +1,15 @@ /* * V4L2 Capture CSI Subdev for Freescale i.MX5/6 SOC * - * Copyright (c) 2014-2016 Mentor Graphics Inc. + * Copyright (c) 2014-2017 Mentor Graphics Inc. + * Copyright (C) 2017 Pengutronix, Philipp Zabel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ +#include #include #include #include @@ -40,6 +42,18 @@ #define H_ALIGN1 /* multiple of 2 lines */ #define S_ALIGN1 /* multiple of 2 */ +/* + * struct csi_skip_desc - CSI frame skipping descriptor + * @keep - number of frames kept per max_ratio frames + * @max_ratio - width of skip_smfc, written to MAX_RATIO bitfield + * @skip_smfc - skip pattern written to the SKIP_SMFC bitfield + */ +struct csi_skip_desc { + u8 keep; + u8 max_ratio; + u8 skip_smfc; +}; + struct csi_priv { struct device *dev; struct ipu_soc *ipu; @@ -65,6 +79,7 @@ struct csi_priv { const struct imx_media_pixfmt *cc[CSI_NUM_PADS]; struct v4l2_fract frame_interval; struct v4l2_rect crop; + const struct csi_skip_desc *skip[CSI_NUM_PADS - 1]; /* active vb2 buffers to send to video dev sink */ struct imx_media_buffer *active_vb2_buf[2]; @@ -536,10 +551,12 @@ static int csi_setup(struct csi_priv *priv) struct v4l2_mbus_config sensor_mbus_cfg; struct v4l2_of_endpoint *sensor_ep; struct v4l2_mbus_framefmt if_fmt; + const struct csi_skip_desc *skip; infmt = &priv->format_mbus[CSI_SINK_PAD]; outfmt = &priv->format_mbus[priv->active_output_pad]; sensor_ep = &priv->sensor->sensor_ep; + skip = priv->skip[priv->active_output_pad - 1]; /* compose mbus_config from sensor endpoint */ sensor_mbus_cfg.type = sensor_ep->bus_type; @@ -564,6 +581,9 @@ static int csi_setup(struct csi_priv *priv) ipu_csi_set_dest(priv->csi, priv->dest); + ipu_csi_set_skip_smfc(priv->csi, skip->skip_smfc, skip->max_ratio - 1, + 0); + ipu_csi_dump(priv->csi); return 0; @@ -627,6 +647,79 @@ static void csi_stop(struct csi_priv *priv) ipu_csi_disable(priv->csi); } +static const struct csi_skip_desc csi_skip[12] = { + { 1, 1, 0x00 }, /* Keep all frames */ + { 5, 6, 0x10 }, /* Skip every sixth frame */ + { 4, 5, 0x08 }, /* Skip every fifth frame */ + { 3, 4, 0x04 }, /* Skip every fourth frame */ + { 2, 3, 0x02 }, /* Skip every third frame */ + { 3, 5, 0x0a }, /* Skip frames 1 and 3 of every 5 */ + { 1, 2, 0x01 }, /* Skip every second frame */ + { 2, 5, 0x0b }, /* Keep frames 1 and 4 of every 5 */ + { 1, 3, 0x03 }, /* Keep one in three frames */ + { 1, 4, 0x07 }, /* Keep one in four frames */ + { 1, 5, 0x0f }, /* Keep one in five frames */ + { 1, 6, 0x1f }, /* Keep one in six frames */ +}; + +static void csi_apply_skip_interval(const struct csi_skip_desc *skip, + struct v4l2_fract *interval) +{ + unsigned int div; + + interval->numerator *= skip->max_ratio; + interval->denominator *= skip->keep; + + /* Reduce fraction to lowest terms */ + div = gcd(interval->numerator, interval->denominator); + if (div > 1) { + interval->numerator /= div; + interval->denominator /= div; + } +} + +/* + * Find the skip pattern to produce the output frame interval closest to the + * requested one, for the given input frame interval. Updates the output frame + * interval to the exact value. + */ +static const struct csi_skip_desc *csi_find_best_skip(struct v4l2_fract *in, + struct v4l2_fract *out) +{ + const struct csi_skip_desc *skip = &csi_skip[0], *best_skip = skip; + u32 min_err = UINT_MAX; + u64 want_us; + int i; + + /* Default to 1:1 ratio */ + if (out->numerator == 0 || out->denominator == 0 || + in->numerator == 0 || in->denominator == 0) { + *out = *in; + return best_skip; + } + + want_us = div_u64((u64)USEC_PER_SEC * out->numerator, out->denominator); + + /*
[PATCH v6 34/39] media: imx: csi: fix crop rectangle reset in sink set_fmt
From: Philipp Zabel The csi_try_crop call in set_fmt should compare the cropping rectangle to the currently set input format, not to the previous input format. Signed-off-by: Philipp Zabel Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 8597d7e..dee5733 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1025,13 +1025,11 @@ __csi_get_fmt(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg, static int csi_try_crop(struct csi_priv *priv, struct v4l2_rect *crop, struct v4l2_subdev_pad_config *cfg, - enum v4l2_subdev_format_whence which, + struct v4l2_mbus_framefmt *infmt, struct imx_media_subdev *sensor) { struct v4l2_of_endpoint *sensor_ep; - struct v4l2_mbus_framefmt *infmt; - infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, which); sensor_ep = &sensor->sensor_ep; crop->width = min_t(__u32, infmt->width, crop->width); @@ -1214,8 +1212,7 @@ static int csi_set_fmt(struct v4l2_subdev *sd, crop.top = 0; crop.width = sdformat->format.width; crop.height = sdformat->format.height; - ret = csi_try_crop(priv, &crop, cfg, - sdformat->which, sensor); + ret = csi_try_crop(priv, &crop, cfg, &sdformat->format, sensor); if (ret) goto out; @@ -1299,6 +1296,7 @@ static int csi_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_selection *sel) { struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct v4l2_mbus_framefmt *infmt; struct imx_media_subdev *sensor; int ret = 0; @@ -1332,7 +1330,8 @@ static int csi_set_selection(struct v4l2_subdev *sd, goto out; } - ret = csi_try_crop(priv, &sel->r, cfg, sel->which, sensor); + infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sel->which); + ret = csi_try_crop(priv, &sel->r, cfg, infmt, sensor); if (ret) goto out; -- 2.7.4
[PATCH v6 22/39] media: imx: Add VDIC subdev driver
This is a media entity subdevice driver for the i.MX Video De-Interlacing or Combining Block. So far this entity does not implement the Combining function but only motion compensated deinterlacing. Video frames are received from the CSI and are routed to the IC PRPVF entity. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/Makefile | 1 + drivers/staging/media/imx/imx-media-vdic.c | 911 + 2 files changed, 912 insertions(+) create mode 100644 drivers/staging/media/imx/imx-media-vdic.c diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index c054490..1f01520 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -4,5 +4,6 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o +obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o diff --git a/drivers/staging/media/imx/imx-media-vdic.c b/drivers/staging/media/imx/imx-media-vdic.c new file mode 100644 index 000..aaf3590 --- /dev/null +++ b/drivers/staging/media/imx/imx-media-vdic.c @@ -0,0 +1,911 @@ +/* + * V4L2 Deinterlacer Subdev for Freescale i.MX5/6 SOC + * + * Copyright (c) 2017 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "imx-media.h" + +/* + * This subdev implements two different video pipelines: + * + * CSI -> VDIC + * + * In this pipeline, the CSI sends a single interlaced field F(n-1) + * directly to the VDIC (and optionally the following field F(n) + * can be sent to memory via IDMAC channel 13). This pipeline only works + * in VDIC's high motion mode, which only requires a single field for + * processing. The other motion modes (low and medium) require three + * fields, so this pipeline does not work in those modes. Also, it is + * not clear how this pipeline can deal with the various field orders + * (sequential BT/TB, interlaced BT/TB). + * + * MEM -> CH8,9,10 -> VDIC + * + * In this pipeline, previous field F(n-1), current field F(n), and next + * field F(n+1) are transferred to the VDIC via IDMAC channels 8,9,10. + * These memory buffers can come from a video output or mem2mem device. + * All motion modes are supported by this pipeline. + * + * The "direct" CSI->VDIC pipeline requires no DMA, but it can only be + * used in high motion mode. + */ + +struct vdic_priv; + +struct vdic_pipeline_ops { + int (*setup)(struct vdic_priv *priv); + void (*start)(struct vdic_priv *priv); + void (*stop)(struct vdic_priv *priv); + void (*disable)(struct vdic_priv *priv); +}; + +/* + * Min/Max supported width and heights. + */ +#define MIN_W 176 +#define MIN_H 144 +#define MAX_W_VDIC 968 +#define MAX_H_VDIC 2048 +#define W_ALIGN4 /* multiple of 16 pixels */ +#define H_ALIGN1 /* multiple of 2 lines */ +#define S_ALIGN1 /* multiple of 2 */ + +struct vdic_priv { + struct device*dev; + struct ipu_soc *ipu; + struct imx_media_dev *md; + struct v4l2_subdev sd; + struct media_pad pad[VDIC_NUM_PADS]; + int ipu_id; + + /* lock to protect all members below */ + struct mutex lock; + + /* IPU units we require */ + struct ipu_vdi *vdi; + + int active_input_pad; + + struct ipuv3_channel *vdi_in_ch_p; /* F(n-1) transfer channel */ + struct ipuv3_channel *vdi_in_ch; /* F(n) transfer channel */ + struct ipuv3_channel *vdi_in_ch_n; /* F(n+1) transfer channel */ + + /* pipeline operations */ + struct vdic_pipeline_ops *ops; + + /* current and previous input buffers indirect path */ + struct imx_media_buffer *curr_in_buf; + struct imx_media_buffer *prev_in_buf; + + /* +* translated field type, input line stride, and field size +* for indirect path +*/ + u32 fieldtype; + u32 in_stride; + u32 field_size; + + /* the source (a video device or subdev) */ + struct media_entity *src; + /* the sink that will receive the progressive out buffers */ + struct v4l2_subdev *sink_sd; + + struct v4l2_mbus_framefmt format_mbus[VDIC_NUM_PADS]; + const struct imx_media_pixfmt *cc[VDIC_NUM_PADS]; + + /* the video device at IDMAC input pad */ + struct imx_media_video_dev *vdev; + + bool csi_direct; /* using direct CSI->VDIC->IC pipeline */ + + /* motion select control */ + struct v4l2_ctrl
[PATCH v6 26/39] media: imx: add support for bayer formats
From: Russell King Add the bayer formats to imx-media's list of supported pixel and bus formats. Signed-off-by: Russell King - added a bayer boolean to struct imx_media_pixfmt. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-utils.c | 68 + drivers/staging/media/imx/imx-media.h | 1 + 2 files changed, 69 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 3e94179..83d227d 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -61,6 +61,74 @@ static const struct imx_media_pixfmt imx_media_formats[] = { .cs = IPUV3_COLORSPACE_RGB, .bpp= 32, .ipufmt = true, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR8, + .codes = {MEDIA_BUS_FMT_SBGGR8_1X8}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 8, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG8, + .codes = {MEDIA_BUS_FMT_SGBRG8_1X8}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 8, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG8, + .codes = {MEDIA_BUS_FMT_SGRBG8_1X8}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 8, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB8, + .codes = {MEDIA_BUS_FMT_SRGGB8_1X8}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 8, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR16, + .codes = { + MEDIA_BUS_FMT_SBGGR10_1X10, + MEDIA_BUS_FMT_SBGGR12_1X12, + MEDIA_BUS_FMT_SBGGR14_1X14, + MEDIA_BUS_FMT_SBGGR16_1X16 + }, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG16, + .codes = { + MEDIA_BUS_FMT_SGBRG10_1X10, + MEDIA_BUS_FMT_SGBRG12_1X12, + MEDIA_BUS_FMT_SGBRG14_1X14, + MEDIA_BUS_FMT_SGBRG16_1X16, + }, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG16, + .codes = { + MEDIA_BUS_FMT_SGRBG10_1X10, + MEDIA_BUS_FMT_SGRBG12_1X12, + MEDIA_BUS_FMT_SGRBG14_1X14, + MEDIA_BUS_FMT_SGRBG16_1X16, + }, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB16, + .codes = { + MEDIA_BUS_FMT_SRGGB10_1X10, + MEDIA_BUS_FMT_SRGGB12_1X12, + MEDIA_BUS_FMT_SRGGB14_1X14, + MEDIA_BUS_FMT_SRGGB16_1X16, + }, + .cs = IPUV3_COLORSPACE_RGB, + .bpp= 16, + .bayer = true, }, /*** non-mbus formats start here ***/ { diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 96a6931..b991081 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -91,6 +91,7 @@ struct imx_media_pixfmt { int bpp; /* total bpp */ enum ipu_color_space cs; boolplanar; /* is a planar format */ + boolbayer; /* is a raw bayer format */ boolipufmt; /* is one of the IPU internal formats */ }; -- 2.7.4
[PATCH v6 21/39] media: imx: Add CSI subdev driver
This is a media entity subdevice for the i.MX Camera Sensor Interface module. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/Kconfig | 14 + drivers/staging/media/imx/Makefile|2 + drivers/staging/media/imx/imx-media-csi.c | 1318 + 3 files changed, 1334 insertions(+) create mode 100644 drivers/staging/media/imx/imx-media-csi.c diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig index 62a3c34..e27ad6d 100644 --- a/drivers/staging/media/imx/Kconfig +++ b/drivers/staging/media/imx/Kconfig @@ -4,3 +4,17 @@ config VIDEO_IMX_MEDIA ---help--- Say yes here to enable support for video4linux media controller driver for the i.MX5/6 SOC. + +if VIDEO_IMX_MEDIA +menu "i.MX5/6 Media Sub devices" + +config VIDEO_IMX_CSI + tristate "i.MX5/6 Camera Sensor Interface driver" + depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C + select VIDEOBUF2_DMA_CONTIG + default y + ---help--- + A video4linux camera sensor interface driver for i.MX5/6. + +endmenu +endif diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 4606a3a..c054490 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -4,3 +4,5 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o + +obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c new file mode 100644 index 000..9e2a73c --- /dev/null +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -0,0 +1,1318 @@ +/* + * V4L2 Capture CSI Subdev for Freescale i.MX5/6 SOC + * + * Copyright (c) 2014-2016 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "imx-media.h" + +/* + * Min/Max supported width and heights. + * + * We allow planar output, so we have to align width by 16 pixels + * to meet IDMAC alignment requirements. + * + * TODO: move this into pad format negotiation, if capture device + * has not requested planar formats, we should allow 8 pixel + * alignment. + */ +#define MIN_W 176 +#define MIN_H 144 +#define MAX_W 4096 +#define MAX_H 4096 +#define W_ALIGN4 /* multiple of 16 pixels */ +#define H_ALIGN1 /* multiple of 2 lines */ +#define S_ALIGN1 /* multiple of 2 */ + +struct csi_priv { + struct device *dev; + struct ipu_soc *ipu; + struct imx_media_dev *md; + struct v4l2_subdev sd; + struct media_pad pad[CSI_NUM_PADS]; + /* the video device at IDMAC output pad */ + struct imx_media_video_dev *vdev; + struct imx_media_fim *fim; + int csi_id; + int smfc_id; + + /* lock to protect all members below */ + struct mutex lock; + + int active_output_pad; + + struct ipuv3_channel *idmac_ch; + struct ipu_smfc *smfc; + struct ipu_csi *csi; + + struct v4l2_mbus_framefmt format_mbus[CSI_NUM_PADS]; + const struct imx_media_pixfmt *cc[CSI_NUM_PADS]; + struct v4l2_rect crop; + + /* active vb2 buffers to send to video dev sink */ + struct imx_media_buffer *active_vb2_buf[2]; + struct imx_media_dma_buf underrun_buf; + + int ipu_buf_num; /* ipu double buffer index: 0-1 */ + + /* the sink for the captured frames */ + struct media_entity *sink; + enum ipu_csi_dest dest; + /* the source subdev */ + struct v4l2_subdev *src_sd; + + /* the mipi virtual channel number at link validate */ + int vc_num; + + /* the attached sensor at stream on */ + struct imx_media_subdev *sensor; + + spinlock_t irqlock; /* protect eof_irq handler */ + struct timer_list eof_timeout_timer; + int eof_irq; + int nfb4eof_irq; + + struct v4l2_ctrl_handler ctrl_hdlr; + + int power_count; /* power counter */ + bool stream_on; /* streaming is on */ + bool last_eof; /* waiting for last EOF at stream off */ + bool nfb4eof;/* NFB4EOF encountered during streaming */ + struct completion last_eof_comp; +}; + +static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev) +{ + return container_of(sdev, struct csi_priv, sd); +} + +static void csi_idmac_put_ipu_resources(struct csi_priv *priv) +{ + if (!IS_ERR_OR_NULL(priv->idmac_ch)) + ipu_idmac_put(priv->idmac_ch); + priv->idmac_ch = NULL; +
[PATCH v6 31/39] media: imx: redo pixel format enumeration and negotiation
The previous API and negotiation of mbus codes and pixel formats was broken, and has been completely redone. The negotiation of media bus codes should be as follows: CSI: sink pad direct src pad IDMAC src pad - RGB (any)IPU RGB IPU RGB YUV (any)IPU YUV IPU YUV Bayer N/A must be same bayer code as sink VDIC: direct sink padIDMAC sink paddirect src pad ------- IPU YUV only IPU YUV only IPU YUV only PRP: direct sink paddirect src pads ------ IPU (any) same as sink code PRP ENC/VF: direct sink padIDMAC src pads ----- IPU (any) IPU RGB or IPU YUV Given the above, a new internal API is created: enum codespace_sel { CS_SEL_YUV = 0, /* find or enumerate only YUV codes */ CS_SEL_RGB, /* find or enumerate only RGB codes */ CS_SEL_ANY, /* find or enumerate both YUV and RGB codes */ }; /* Find and enumerate fourcc pixel formats */ const struct imx_media_pixfmt * imx_media_find_format(u32 fourcc, enum codespace_sel cs_sel, bool allow_bayer); int imx_media_enum_format(u32 *fourcc, u32 index, enum codespace_sel cs_sel); /* Find and enumerate media bus codes */ const struct imx_media_pixfmt * imx_media_find_mbus_format(u32 code, enum codespace_sel cs_sel, bool allow_bayer); int imx_media_enum_mbus_format(u32 *code, u32 index, enum codespace_sel cs_sel, bool allow_bayer); /* Find and enumerate IPU internal media bus codes */ const struct imx_media_pixfmt * imx_media_find_ipu_format(u32 code, enum codespace_sel cs_sel); int imx_media_enum_ipu_format(u32 *code, u32 index, enum codespace_sel cs_sel); The tables have been split into separate tables for YUV and RGB formats to support the implementation of the above. The subdev's .enum_mbus_code() and .set_fmt() operations have been rewritten using the above APIs. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-ic-prp.c| 77 -- drivers/staging/media/imx/imx-ic-prpencvf.c | 57 ++-- drivers/staging/media/imx/imx-media-capture.c | 85 -- drivers/staging/media/imx/imx-media-csi.c | 108 +--- drivers/staging/media/imx/imx-media-utils.c | 371 +++--- drivers/staging/media/imx/imx-media-vdic.c| 69 ++--- drivers/staging/media/imx/imx-media.h | 27 +- 7 files changed, 504 insertions(+), 290 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prp.c b/drivers/staging/media/imx/imx-ic-prp.c index d0f4e82..505f456 100644 --- a/drivers/staging/media/imx/imx-ic-prp.c +++ b/drivers/staging/media/imx/imx-ic-prp.c @@ -88,16 +88,6 @@ static void prp_stop(struct prp_priv *priv) { } -static int prp_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) -{ - if (code->pad >= PRP_NUM_PADS) - return -EINVAL; - - return imx_media_enum_ipu_format(NULL, &code->code, code->index, true); -} - static struct v4l2_mbus_framefmt * __prp_get_fmt(struct prp_priv *priv, struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) @@ -114,6 +104,38 @@ __prp_get_fmt(struct prp_priv *priv, struct v4l2_subdev_pad_config *cfg, * V4L2 subdev operations. */ +static int prp_enum_mbus_code(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_mbus_code_enum *code) +{ + struct prp_priv *priv = sd_to_priv(sd); + struct v4l2_mbus_framefmt *infmt; + int ret = 0; + + mutex_lock(&priv->lock); + + switch (code->pad) { + case PRP_SINK_PAD: + ret = imx_media_enum_ipu_format(&code->code, code->index, + CS_SEL_ANY); + break; + case PRP_SRC_PAD_PRPENC: + case PRP_SRC_PAD_PRPVF: + if (code->index != 0) { + ret = -EINVAL; + goto out; + } + infmt = __prp_get_fmt(priv, cfg, PRP_SINK_PAD, code->which); + code->code = infmt->code; + break; + default: + ret = -EINVAL; + } +out: + mutex_unlock(&priv->lock); + return ret; +} + static int prp_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *sdformat) @@ -159,23 +181,28 @@ static int prp_set_fmt(struct v4l2_subdev *sd, goto out; } - cc = imx_media_find_ipu_format(0, sdformat->format.code, true); - if (!cc) { - imx_media_enum_ipu_format(NULL, &code, 0
[PATCH v6 29/39] media: imx: csi: add __csi_get_fmt
Add __csi_get_fmt() and use it to return the correct mbus format (active or try) in get_fmt. Use it in other places as well. Signed-off-by: Steve Longerbeam Suggested-by: Russell King --- drivers/staging/media/imx/imx-media-csi.c | 61 --- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 730966b..f4c6a33 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -843,13 +843,26 @@ static int csi_eof_isr(struct v4l2_subdev *sd, u32 status, bool *handled) return 0; } -static int csi_try_crop(struct csi_priv *priv, struct v4l2_rect *crop, +static struct v4l2_mbus_framefmt * +__csi_get_fmt(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg, + unsigned int pad, enum v4l2_subdev_format_whence which) +{ + if (which == V4L2_SUBDEV_FORMAT_TRY) + return v4l2_subdev_get_try_format(&priv->sd, cfg, pad); + else + return &priv->format_mbus[pad]; +} + +static int csi_try_crop(struct csi_priv *priv, + struct v4l2_rect *crop, + struct v4l2_subdev_pad_config *cfg, + enum v4l2_subdev_format_whence which, struct imx_media_subdev *sensor) { struct v4l2_of_endpoint *sensor_ep; struct v4l2_mbus_framefmt *infmt; - infmt = &priv->format_mbus[CSI_SINK_PAD]; + infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, which); sensor_ep = &sensor->sensor_ep; crop->width = min_t(__u32, infmt->width, crop->width); @@ -899,17 +912,24 @@ static int csi_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *sdformat) { struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct v4l2_mbus_framefmt *fmt; + int ret = 0; if (sdformat->pad >= CSI_NUM_PADS) return -EINVAL; mutex_lock(&priv->lock); - sdformat->format = priv->format_mbus[sdformat->pad]; + fmt = __csi_get_fmt(priv, cfg, sdformat->pad, sdformat->which); + if (!fmt) { + ret = -EINVAL; + goto out; + } + sdformat->format = *fmt; +out: mutex_unlock(&priv->lock); - - return 0; + return ret; } static int csi_set_fmt(struct v4l2_subdev *sd, @@ -940,8 +960,6 @@ static int csi_set_fmt(struct v4l2_subdev *sd, goto out; } - infmt = &priv->format_mbus[CSI_SINK_PAD]; - v4l_bound_align_image(&sdformat->format.width, MIN_W, MAX_W, W_ALIGN, &sdformat->format.height, MIN_H, MAX_H, H_ALIGN, S_ALIGN); @@ -949,6 +967,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd, switch (sdformat->pad) { case CSI_SRC_PAD_DIRECT: case CSI_SRC_PAD_IDMAC: + infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which); + if (sdformat->format.width < priv->crop.width * 3 / 4) sdformat->format.width = priv->crop.width / 2; else @@ -1007,7 +1027,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd, crop.top = 0; crop.width = sdformat->format.width; crop.height = sdformat->format.height; - ret = csi_try_crop(priv, &crop, sensor); + ret = csi_try_crop(priv, &crop, cfg, + sdformat->which, sensor); if (ret) goto out; @@ -1052,7 +1073,11 @@ static int csi_get_selection(struct v4l2_subdev *sd, mutex_lock(&priv->lock); - infmt = &priv->format_mbus[CSI_SINK_PAD]; + infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sel->which); + if (!infmt) { + ret = -EINVAL; + goto out; + } switch (sel->target) { case V4L2_SEL_TGT_CROP_BOUNDS: @@ -1062,12 +1087,20 @@ static int csi_get_selection(struct v4l2_subdev *sd, sel->r.height = infmt->height; break; case V4L2_SEL_TGT_CROP: - sel->r = priv->crop; + if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { + struct v4l2_rect *try_crop = + v4l2_subdev_get_try_crop(&priv->sd, +cfg, sel->pad); + sel->r = *try_crop; + } else { + sel->r = priv->crop; + } break; default: ret = -EINVAL; } +out: mutex_unlock(&priv->lock); return ret; } @@ -1077,7 +1110,6 @@ static int csi_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_selection *sel) { struct csi_priv *priv = v4l2_get_subdevdata(sd); - str
[PATCH v6 37/39] media: imx-csi: add frame size/interval enumeration
From: Russell King Add frame size and frame interval enumeration to CSI. CSI can downscale the image independently horizontally and vertically by a factor of two, which enumerates to four different frame sizes at the output pads. The input pad supports a range of frame sizes. CSI can also drop frames, resulting in frame rate reduction, so enumerate the resulting possible output frame rates. Signed-off-by: Russell King Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 62 +++ 1 file changed, 62 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 19609a7..b11e80f 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1123,6 +1123,66 @@ static int csi_enum_mbus_code(struct v4l2_subdev *sd, return ret; } +static int csi_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) +{ + struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct v4l2_rect *crop; + int ret = 0; + + if (fse->pad >= CSI_NUM_PADS || + fse->index > (fse->pad == CSI_SINK_PAD ? 0 : 3)) + return -EINVAL; + + mutex_lock(&priv->lock); + + if (fse->pad == CSI_SINK_PAD) { + fse->min_width = MIN_W; + fse->max_width = MAX_W; + fse->min_height = MIN_H; + fse->max_height = MAX_H; + } else { + crop = __csi_get_crop(priv, cfg, fse->which); + + fse->min_width = fse->max_width = fse->index & 1 ? + crop->width / 2 : crop->width; + fse->min_height = fse->max_height = fse->index & 2 ? + crop->height / 2 : crop->height; + } + + mutex_unlock(&priv->lock); + return ret; +} + +static int csi_enum_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_interval_enum *fie) +{ + struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct v4l2_rect *crop; + int ret = 0; + + if (fie->pad >= CSI_NUM_PADS || + fie->index >= (fie->pad == CSI_SINK_PAD ? 1 : ARRAY_SIZE(csi_skip))) + return -EINVAL; + + mutex_lock(&priv->lock); + + crop = __csi_get_crop(priv, cfg, fie->which); + + if ((fie->width == crop->width || fie->width == crop->width / 2) && + (fie->height == crop->height || fie->height == crop->height / 2)) { + fie->interval = priv->frame_interval; + csi_apply_skip_interval(&csi_skip[fie->index], &fie->interval); + } else { + ret = -EINVAL; + } + mutex_unlock(&priv->lock); + + return ret; +} + static int csi_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *sdformat) @@ -1587,6 +1647,8 @@ static struct v4l2_subdev_video_ops csi_video_ops = { static struct v4l2_subdev_pad_ops csi_pad_ops = { .enum_mbus_code = csi_enum_mbus_code, + .enum_frame_size = csi_enum_frame_size, + .enum_frame_interval = csi_enum_frame_interval, .get_fmt = csi_get_fmt, .set_fmt = csi_set_fmt, .get_selection = csi_get_selection, -- 2.7.4
[PATCH v6 36/39] media: imx: csi: add sink selection rectangles
From: Philipp Zabel Move the crop rectangle to the sink pad and add a sink compose rectangle to configure scaling. Also propagate rectangles from sink pad to crop rectangle, to compose rectangle, and to the source pads both in ACTIVE and TRY variants of set_fmt/selection, and initialize the default crop and compose rectangles. Signed-off-by: Philipp Zabel --- drivers/staging/media/imx/imx-media-csi.c | 153 +++--- 1 file changed, 117 insertions(+), 36 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 6b8f875..19609a7 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -80,6 +80,7 @@ struct csi_priv { const struct imx_media_pixfmt *cc[CSI_NUM_PADS]; struct v4l2_fract frame_interval; struct v4l2_rect crop; + struct v4l2_rect compose; const struct csi_skip_desc *skip[CSI_NUM_PADS - 1]; /* active vb2 buffers to send to video dev sink */ @@ -575,8 +576,8 @@ static int csi_setup(struct csi_priv *priv) ipu_csi_set_window(priv->csi, &priv->crop); ipu_csi_set_downsize(priv->csi, -priv->crop.width == 2 * outfmt->width, -priv->crop.height == 2 * outfmt->height); +priv->crop.width == 2 * priv->compose.width, +priv->crop.height == 2 * priv->compose.height); ipu_csi_init_interface(priv->csi, &sensor_mbus_cfg, &if_fmt); @@ -1032,6 +1033,17 @@ __csi_get_crop(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg, return &priv->crop; } +static struct v4l2_rect * +__csi_get_compose(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg, + enum v4l2_subdev_format_whence which) +{ + if (which == V4L2_SUBDEV_FORMAT_TRY) + return v4l2_subdev_get_try_compose(&priv->sd, cfg, + CSI_SINK_PAD); + else + return &priv->compose; +} + static void csi_try_crop(struct csi_priv *priv, struct v4l2_rect *crop, struct v4l2_subdev_pad_config *cfg, @@ -1141,6 +1153,7 @@ static void csi_try_fmt(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *sdformat, struct v4l2_rect *crop, + struct v4l2_rect *compose, const struct imx_media_pixfmt **cc) { const struct imx_media_pixfmt *incc; @@ -1155,15 +1168,8 @@ static void csi_try_fmt(struct csi_priv *priv, incc = imx_media_find_mbus_format(infmt->code, CS_SEL_ANY, true); - if (sdformat->format.width < crop->width * 3 / 4) - sdformat->format.width = crop->width / 2; - else - sdformat->format.width = crop->width; - - if (sdformat->format.height < crop->height * 3 / 4) - sdformat->format.height = crop->height / 2; - else - sdformat->format.height = crop->height; + sdformat->format.width = compose->width; + sdformat->format.height = compose->height; if (incc->bayer) { sdformat->format.code = infmt->code; @@ -1199,11 +1205,17 @@ static void csi_try_fmt(struct csi_priv *priv, v4l_bound_align_image(&sdformat->format.width, MIN_W, MAX_W, W_ALIGN, &sdformat->format.height, MIN_H, MAX_H, H_ALIGN, S_ALIGN); + + /* Reset crop and compose rectangles */ crop->left = 0; crop->top = 0; crop->width = sdformat->format.width; crop->height = sdformat->format.height; csi_try_crop(priv, crop, cfg, &sdformat->format, sensor); + compose->left = 0; + compose->top = 0; + compose->width = crop->width; + compose->height = crop->height; *cc = imx_media_find_mbus_format(sdformat->format.code, CS_SEL_ANY, true); @@ -1228,7 +1240,7 @@ static int csi_set_fmt(struct v4l2_subdev *sd, struct imx_media_subdev *sensor; struct v4l2_pix_format vdev_fmt; struct v4l2_mbus_framefmt *fmt; - struct v4l2_rect *crop; + struct v4l2_rect *crop, *compose; int ret = 0; if (sdformat->pad >= CSI_NUM_PADS) @@ -1248,8 +1260,9 @@ static int csi_set_fmt(struct v4l2_subdev *sd, } crop = __csi_get_crop(priv, cfg, sdformat->which); + compose = __csi_get_compose(priv, cfg, sdformat->which); - csi_try_fmt(priv, sensor, cfg, sd
[PATCH v6 38/39] media: imx-ic-prpencvf: add frame size enumeration
Add frame size enumeration operation. The PRP ENC/VF subdevices are scalers, so they can output a continuous range of widths/ heights on their source pads. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-ic-prpencvf.c | 40 + 1 file changed, 40 insertions(+) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index 4123b03..860b406 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -875,6 +875,45 @@ static int prp_set_fmt(struct v4l2_subdev *sd, return ret; } +static int prp_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) +{ + struct prp_priv *priv = sd_to_priv(sd); + struct v4l2_subdev_format format = {0}; + const struct imx_media_pixfmt *cc; + int ret = 0; + + if (fse->pad >= PRPENCVF_NUM_PADS || fse->index != 0) + return -EINVAL; + + mutex_lock(&priv->lock); + + format.pad = fse->pad; + format.which = fse->which; + format.format.code = fse->code; + format.format.width = 1; + format.format.height = 1; + prp_try_fmt(priv, cfg, &format, &cc); + fse->min_width = format.format.width; + fse->min_height = format.format.height; + + if (format.format.code != fse->code) { + ret = -EINVAL; + goto out; + } + + format.format.code = fse->code; + format.format.width = -1; + format.format.height = -1; + prp_try_fmt(priv, cfg, &format, &cc); + fse->max_width = format.format.width; + fse->max_height = format.format.height; +out: + mutex_unlock(&priv->lock); + return ret; +} + static int prp_link_setup(struct media_entity *entity, const struct media_pad *local, const struct media_pad *remote, u32 flags) @@ -1125,6 +1164,7 @@ static void prp_unregistered(struct v4l2_subdev *sd) static struct v4l2_subdev_pad_ops prp_pad_ops = { .enum_mbus_code = prp_enum_mbus_code, + .enum_frame_size = prp_enum_frame_size, .get_fmt = prp_get_fmt, .set_fmt = prp_set_fmt, .link_validate = prp_link_validate, -- 2.7.4
[PATCH v6 27/39] media: imx: csi: add support for bayer formats
From: Russell King Bayer formats must be treated as generic data and passthrough mode must be used. Add the correct setup for these formats. Signed-off-by: Russell King - added check to csi_link_validate() to verify that destination is IDMAC output pad when passthrough conditions exist: bayer formats and 16-bit parallel buses. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 75 +++ 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 9e2a73c..37c68d8 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -285,10 +285,11 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) struct imx_media_video_dev *vdev = priv->vdev; struct v4l2_of_endpoint *sensor_ep; struct v4l2_mbus_framefmt *infmt; - unsigned int burst_size; struct ipu_image image; + u32 passthrough_bits; dma_addr_t phys[2]; bool passthrough; + u32 burst_size; int ret; infmt = &priv->format_mbus[CSI_SINK_PAD]; @@ -306,24 +307,52 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) image.phys0 = phys[0]; image.phys1 = phys[1]; - ret = ipu_cpmem_set_image(priv->idmac_ch, &image); - if (ret) - goto unsetup_vb2; - - burst_size = (image.pix.width & 0xf) ? 8 : 16; - - ipu_cpmem_set_burstsize(priv->idmac_ch, burst_size); - /* -* If the sensor uses 16-bit parallel CSI bus, we must handle -* the data internally in the IPU as 16-bit generic, aka -* passthrough mode. +* Check for conditions that require the IPU to handle the +* data internally as generic data, aka passthrough mode: +* - raw bayer formats +* - the sensor bus is 16-bit parallel */ - passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && - sensor_ep->bus.parallel.bus_width >= 16); + switch (image.pix.pixelformat) { + case V4L2_PIX_FMT_SBGGR8: + case V4L2_PIX_FMT_SGBRG8: + case V4L2_PIX_FMT_SGRBG8: + case V4L2_PIX_FMT_SRGGB8: + burst_size = 8; + passthrough = true; + passthrough_bits = 8; + break; + case V4L2_PIX_FMT_SBGGR16: + case V4L2_PIX_FMT_SGBRG16: + case V4L2_PIX_FMT_SGRBG16: + case V4L2_PIX_FMT_SRGGB16: + burst_size = 4; + passthrough = true; + passthrough_bits = 16; + break; + default: + burst_size = (image.pix.width & 0xf) ? 8 : 16; + passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && + sensor_ep->bus.parallel.bus_width >= 16); + passthrough_bits = 16; + break; + } - if (passthrough) - ipu_cpmem_set_format_passthrough(priv->idmac_ch, 16); + if (passthrough) { + ipu_cpmem_set_resolution(priv->idmac_ch, image.rect.width, +image.rect.height); + ipu_cpmem_set_stride(priv->idmac_ch, image.pix.bytesperline); + ipu_cpmem_set_buffer(priv->idmac_ch, 0, image.phys0); + ipu_cpmem_set_buffer(priv->idmac_ch, 1, image.phys1); + ipu_cpmem_set_format_passthrough(priv->idmac_ch, +passthrough_bits); + } else { + ret = ipu_cpmem_set_image(priv->idmac_ch, &image); + if (ret) + goto unsetup_vb2; + } + + ipu_cpmem_set_burstsize(priv->idmac_ch, burst_size); /* * Set the channel for the direct CSI-->memory via SMFC @@ -737,6 +766,7 @@ static int csi_link_validate(struct v4l2_subdev *sd, struct v4l2_subdev_format *sink_fmt) { struct csi_priv *priv = v4l2_get_subdevdata(sd); + const struct imx_media_pixfmt *incc; struct v4l2_of_endpoint *sensor_ep; struct imx_media_subdev *sensor; bool is_csi2; @@ -757,8 +787,17 @@ static int csi_link_validate(struct v4l2_subdev *sd, priv->sensor = sensor; sensor_ep = &priv->sensor->sensor_ep; - is_csi2 = (sensor_ep->bus_type == V4L2_MBUS_CSI2); + incc = priv->cc[CSI_SINK_PAD]; + + if (priv->dest != IPU_CSI_DEST_IDMAC && + (incc->bayer || (!is_csi2 && +sensor_ep->bus.parallel.bus_width >= 16))) { + v4l2_err(&priv->sd, +"bayer/16-bit parallel buses must go to IDMAC pad\n"); + ret = -EINVAL; + goto out; + } if (is_csi2) { int vc_num = 0; @@ -783,7 +822,7 @@ static int csi_link_validate(struct v4l2_subdev *sd, /* select either para
[PATCH v6 39/39] media: imx-media-capture: add frame sizes/interval enumeration
From: Russell King Add support for enumerating frame sizes and frame intervals from the first subdev via the V4L2 interfaces. Signed-off-by: Russell King Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-capture.c | 73 +++ 1 file changed, 73 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 7521ca9..11a8689 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -82,6 +82,76 @@ static int vidioc_querycap(struct file *file, void *fh, return 0; } +static int capture_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *fsize) +{ + struct capture_priv *priv = video_drvdata(file); + const struct imx_media_pixfmt *cc; + struct v4l2_subdev_frame_size_enum fse = { + .index = fsize->index, + .pad = priv->src_sd_pad, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; + int ret; + + cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY, true); + if (!cc) + return -EINVAL; + + fse.code = cc->codes[0]; + + ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_size, NULL, &fse); + if (ret) + return ret; + + if (fse.min_width == fse.max_width && + fse.min_height == fse.max_height) { + fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; + fsize->discrete.width = fse.min_width; + fsize->discrete.height = fse.min_height; + } else { + fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; + fsize->stepwise.min_width = fse.min_width; + fsize->stepwise.max_width = fse.max_width; + fsize->stepwise.min_height = fse.min_height; + fsize->stepwise.max_height = fse.max_height; + fsize->stepwise.step_width = 1; + fsize->stepwise.step_height = 1; + } + + return 0; +} + +static int capture_enum_frameintervals(struct file *file, void *fh, + struct v4l2_frmivalenum *fival) +{ + struct capture_priv *priv = video_drvdata(file); + const struct imx_media_pixfmt *cc; + struct v4l2_subdev_frame_interval_enum fie = { + .index = fival->index, + .pad = priv->src_sd_pad, + .width = fival->width, + .height = fival->height, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; + int ret; + + cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true); + if (!cc) + return -EINVAL; + + fie.code = cc->codes[0]; + + ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, &fie); + if (ret) + return ret; + + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; + fival->discrete = fie.interval; + + return 0; +} + static int capture_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { @@ -270,6 +340,9 @@ static int capture_s_parm(struct file *file, void *fh, static const struct v4l2_ioctl_ops capture_ioctl_ops = { .vidioc_querycap= vidioc_querycap, + .vidioc_enum_framesizes = capture_enum_framesizes, + .vidioc_enum_frameintervals = capture_enum_frameintervals, + .vidioc_enum_fmt_vid_cap= capture_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap = capture_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap = capture_try_fmt_vid_cap, -- 2.7.4
[PATCH v6 33/39] media: imx: csi: Avoid faulty sensor frames at stream start
If the attached sensor reports faulty frames at stream start via g_skip_frames callback, add a delay to avoid them before enabling the CSI hardware. Especially for sensors with a bt.656 interface, any shifts in the SAV/EAV sync codes will cause the CSI to lose vert/horiz sync. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 21 + 1 file changed, 21 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index d9c3a3b..8597d7e 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -9,6 +9,7 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ +#include #include #include #include @@ -591,6 +592,7 @@ static int csi_setup(struct csi_priv *priv) static int csi_start(struct csi_priv *priv) { + u32 bad_frames = 0; int ret; if (!priv->sensor) { @@ -598,6 +600,25 @@ static int csi_start(struct csi_priv *priv) return -EINVAL; } + ret = v4l2_subdev_call(priv->sensor->sd, sensor, + g_skip_frames, &bad_frames); + if (!ret && bad_frames) { + struct v4l2_fract *fi = &priv->frame_interval; + u32 delay_usec; + + /* +* This sensor has bad frames when it is turned on, +* add a delay to avoid them before enabling the CSI +* hardware. Especially for sensors with a bt.656 interface, +* any shifts in the SAV/EAV sync codes will cause the CSI +* to lose vert/horiz sync. +*/ + delay_usec = DIV_ROUND_UP_ULL( + (u64)USEC_PER_SEC * fi->numerator * bad_frames, + fi->denominator); + usleep_range(delay_usec, delay_usec + 1000); + } + if (priv->dest == IPU_CSI_DEST_IDMAC) { ret = csi_idmac_start(priv); if (ret) -- 2.7.4
[PATCH v6 25/39] ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers
Enable i.MX v4l2 media staging driver. For video capture on i.MX, the video multiplexer subdev is required. On the SabreAuto, the ADV7180 video decoder is required along with i2c-mux-gpio. The Sabrelite and SabreSD require the OV5640 and the SabreLite requires PWM clocks for the OV5640. Increase max zoneorder to allow larger video buffer allocations. Signed-off-by: Steve Longerbeam --- arch/arm/configs/imx_v6_v7_defconfig | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig index eaba3b1..5d8c94a 100644 --- a/arch/arm/configs/imx_v6_v7_defconfig +++ b/arch/arm/configs/imx_v6_v7_defconfig @@ -51,6 +51,7 @@ CONFIG_PREEMPT_VOLUNTARY=y CONFIG_AEABI=y CONFIG_HIGHMEM=y CONFIG_CMA=y +CONFIG_FORCE_MAX_ZONEORDER=14 CONFIG_CMDLINE="noinitrd console=ttymxc0,115200" CONFIG_KEXEC=y CONFIG_CPU_FREQ=y @@ -181,6 +182,7 @@ CONFIG_SERIAL_FSL_LPUART=y CONFIG_SERIAL_FSL_LPUART_CONSOLE=y # CONFIG_I2C_COMPAT is not set CONFIG_I2C_CHARDEV=y +CONFIG_I2C_MUX=y CONFIG_I2C_MUX_GPIO=y # CONFIG_I2C_HELPER_AUTO is not set CONFIG_I2C_ALGOPCF=m @@ -221,14 +223,20 @@ CONFIG_REGULATOR_PFUZE100=y CONFIG_MEDIA_SUPPORT=y CONFIG_MEDIA_CAMERA_SUPPORT=y CONFIG_MEDIA_RC_SUPPORT=y +CONFIG_MEDIA_CONTROLLER=y +CONFIG_VIDEO_V4L2_SUBDEV_API=y CONFIG_RC_DEVICES=y CONFIG_IR_GPIO_CIR=y CONFIG_MEDIA_USB_SUPPORT=y CONFIG_USB_VIDEO_CLASS=m CONFIG_V4L_PLATFORM_DRIVERS=y +CONFIG_VIDEO_MULTIPLEXER=y CONFIG_SOC_CAMERA=y CONFIG_V4L_MEM2MEM_DRIVERS=y CONFIG_VIDEO_CODA=y +# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set +CONFIG_VIDEO_ADV7180=m +CONFIG_VIDEO_OV5640=m CONFIG_SOC_CAMERA_OV2640=y CONFIG_IMX_IPUV3_CORE=y CONFIG_DRM=y @@ -338,6 +346,9 @@ CONFIG_FSL_EDMA=y CONFIG_IMX_SDMA=y CONFIG_MXS_DMA=y CONFIG_STAGING=y +CONFIG_STAGING_MEDIA=y +CONFIG_VIDEO_IMX_MEDIA=y +CONFIG_COMMON_CLK_PWM=y CONFIG_IIO=y CONFIG_VF610_ADC=y CONFIG_MPL3115=y -- 2.7.4
[PATCH v6 35/39] media: imx: propagate sink pad formats to source pads
As part of this, separate format try code from *_set_fmt() into *_try_fmt(), so that the latter function can be used to propagate a legal format from sink to source. This also reduces subsequent bloat in *_set_fmt(). imx-ic-prp never needed separate formats for sink and source pads, so propagation in this case was easy, just have only a single format shared by both pads. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-ic-prp.c| 39 ++--- drivers/staging/media/imx/imx-ic-prpencvf.c | 95 +++ drivers/staging/media/imx/imx-media-capture.c | 13 ++ drivers/staging/media/imx/imx-media-csi.c | 224 +++--- drivers/staging/media/imx/imx-media-vdic.c| 82 ++ 5 files changed, 279 insertions(+), 174 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prp.c b/drivers/staging/media/imx/imx-ic-prp.c index 505f456..b4d4e48 100644 --- a/drivers/staging/media/imx/imx-ic-prp.c +++ b/drivers/staging/media/imx/imx-ic-prp.c @@ -56,8 +56,7 @@ struct prp_priv { /* the CSI id at link validate */ int csi_id; - struct v4l2_mbus_framefmt format_mbus[PRP_NUM_PADS]; - const struct imx_media_pixfmt *cc[PRP_NUM_PADS]; + struct v4l2_mbus_framefmt format_mbus; bool stream_on; /* streaming is on */ }; @@ -97,7 +96,7 @@ __prp_get_fmt(struct prp_priv *priv, struct v4l2_subdev_pad_config *cfg, if (which == V4L2_SUBDEV_FORMAT_TRY) return v4l2_subdev_get_try_format(&ic_priv->sd, cfg, pad); else - return &priv->format_mbus[pad]; + return &priv->format_mbus; } /* @@ -166,8 +165,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *sdformat) { struct prp_priv *priv = sd_to_priv(sd); - const struct imx_media_pixfmt *cc = NULL; - struct v4l2_mbus_framefmt *infmt; + const struct imx_media_pixfmt *cc; + struct v4l2_mbus_framefmt *fmt; int ret = 0; u32 code; @@ -198,20 +197,13 @@ static int prp_set_fmt(struct v4l2_subdev *sd, case PRP_SRC_PAD_PRPENC: case PRP_SRC_PAD_PRPVF: /* Output pads mirror input pad */ - infmt = __prp_get_fmt(priv, cfg, PRP_SINK_PAD, - sdformat->which); - cc = imx_media_find_ipu_format(infmt->code, CS_SEL_ANY); - sdformat->format = *infmt; + fmt = __prp_get_fmt(priv, cfg, PRP_SINK_PAD, sdformat->which); + sdformat->format = *fmt; break; } - if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) { - cfg->try_fmt = sdformat->format; - } else { - priv->format_mbus[sdformat->pad] = sdformat->format; - priv->cc[sdformat->pad] = cc; - } - + fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which); + *fmt = sdformat->format; out: mutex_unlock(&priv->lock); return ret; @@ -392,16 +384,15 @@ static int prp_registered(struct v4l2_subdev *sd) for (i = 0; i < PRP_NUM_PADS; i++) { priv->pad[i].flags = (i == PRP_SINK_PAD) ? MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; - - /* set a default mbus format */ - imx_media_enum_ipu_format(&code, 0, CS_SEL_YUV); - ret = imx_media_init_mbus_fmt(&priv->format_mbus[i], - 640, 480, code, V4L2_FIELD_NONE, - &priv->cc[i]); - if (ret) - return ret; } + /* set a default mbus format */ + imx_media_enum_ipu_format(&code, 0, CS_SEL_YUV); + ret = imx_media_init_mbus_fmt(&priv->format_mbus, 640, 480, code, + V4L2_FIELD_NONE, NULL); + if (ret) + return ret; + return media_entity_pads_init(&sd->entity, PRP_NUM_PADS, priv->pad); } diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index 9babfa3..4123b03 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -767,35 +767,23 @@ static int prp_get_fmt(struct v4l2_subdev *sd, return ret; } -static int prp_set_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *sdformat) +static void prp_try_fmt(struct prp_priv *priv, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *sdformat, + const struct imx_media_pixfmt **cc) { - struct prp_priv *priv = sd_to_priv(sd); - const struct imx_media_pixfmt *cc; - struct v4l2_mbus_framefmt *infmt; - int ret = 0; - u32 code; - - if (sdformat->pad >= PRPENCVF_NUM_PADS) -
Re: [PATCH v6 1/3] drm_fourcc: Add new P010, P016 video format
On 03/26/2017 09:05 PM, Ayaka wrote: 從我的 iPad 傳送 Ander Conselvan De Oliveira 於 2017年3月14日 下午9:53 寫道: On Tue, 2017-03-07 at 04:27 +0800, Ayaka wrote: 從我的 iPad 傳送 Ville Syrjälä 於 2017年3月7日 上午2:34 寫道: On Tue, Mar 07, 2017 at 01:58:23AM +0800, Ayaka wrote: 從我的 iPad 傳送 Ville Syrjälä 於 2017年3月6日 下午9:06 寫道: On Sun, Mar 05, 2017 at 06:00:31PM +0800, Randy Li wrote: P010 is a planar 4:2:0 YUV with interleaved UV plane, 10 bits per channel video format. P016 is a planar 4:2:0 YUV with interleaved UV plane, 16 bits per channel video format. V3: Added P012 and fixed cpp for P010 V4: format definition refined per review V5: Format comment block for each new pixel format V6: reversed Cb/Cr order in comments v7: reversed Cb/Cr order in comments of header files, remove the wrong part of commit message. What? Why? You just undid what Clint did in v6. He missed a file also keeping the wrong description of rockchip. I don't follow. Who missed what exactly? What he sent is v5, I increase the order number twice in the message, it confuse me as well. I think Clint forgot the include/uapi/drm/drm_fourcc.h . Clint did send a v6, and that updates "include/uapi/drm/drm_fourcc.h": https://patchwork.freedesktop.org/patch/141342/ Oh, yes but he still used Cr:Cb, but I think it should be Cb:Cr since I think the V is after the U. From the MSDN fourcc website: "If the combined U-V array is addressed as an array of DWORDs, the least significant word (LSW) contains the U value and the most significant word (MSW) contains the V value. The stride of the combined U-V plane is equal to the stride of the Y plane. The U-V plane has half as many lines as the Y plane." The LSW contains U and the MSW contains V, hence the Cr:Cb in the comments of the V6 patch. -Clint Ander Cc: Daniel Stone Cc: Ville Syrjälä Signed-off-by: Randy Li Signed-off-by: Clint Taylor --- drivers/gpu/drm/drm_fourcc.c | 3 +++ include/uapi/drm/drm_fourcc.h | 21 + 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index 90d2cc8..3e0fd58 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -165,6 +165,9 @@ const struct drm_format_info *__drm_format_info(u32 format) { .format = DRM_FORMAT_UYVY,.depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, { .format = DRM_FORMAT_VYUY,.depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, { .format = DRM_FORMAT_AYUV,.depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 }, +{ .format = DRM_FORMAT_P010,.depth = 0, .num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2 }, +{ .format = DRM_FORMAT_P012,.depth = 0, .num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2 }, +{ .format = DRM_FORMAT_P016,.depth = 0, .num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2 }, }; unsigned int i; diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index ef20abb..306f979 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -128,6 +128,27 @@ extern "C" { #define DRM_FORMAT_NV42fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ /* + * 2 plane YCbCr MSB aligned + * index 0 = Y plane, [15:0] Y:x [10:6] little endian + * index 1 = Cb:Cr plane, [31:0] Cb:x:Cr:x [10:6:10:6] little endian + */ +#define DRM_FORMAT_P010fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cb:Cr plane 10 bits per channel */ + +/* + * 2 plane YCbCr MSB aligned + * index 0 = Y plane, [15:0] Y:x [12:4] little endian + * index 1 = Cb:Cr plane, [31:0] Cb:x:Cr:x [12:4:12:4] little endian + */ +#define DRM_FORMAT_P012fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cb:Cr plane 12 bits per channel */ + +/* + * 2 plane YCbCr MSB aligned + * index 0 = Y plane, [15:0] Y little endian + * index 1 = Cb:Cr plane, [31:0] Cb:Cr [16:16] little endian + */ +#define DRM_FORMAT_P016fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cb:Cr plane 16 bits per channel */ + +/* * 3 plane YCbCr * index 0: Y plane, [7:0] Y * index 1: Cb plane, [7:0] Cb -- 2.7.4 -- Ville Syrjälä Intel OTC -- Ville Syrjälä Intel OTC ___ dri-devel mailing list dri-de...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC v2 07/11] vb2: dma-contig: Remove redundant sgt_base field
On Thu, Dec 15, 2016 at 6:24 PM, Laurent Pinchart wrote: > From: Sakari Ailus > > The struct vb2_dc_buf contains two struct sg_table fields: sgt_base and > dma_sgt. The former is used by DMA-BUF buffers whereas the latter is used > by USERPTR. > > Unify the two, leaving dma_sgt. I think this patch should be split in two. 1. Unifying dma_sgt and sgt_base > > MMAP buffers do not need cache flushing since they have been allocated > using dma_alloc_coherent(). 2. That uses vec to check for checking for no flush needed condition. > > Signed-off-by: Sakari Ailus > --- > Changes since v1: > > - Test for MMAP or DMABUF type through the vec field instead of the now > gone vma field. What is this gone vma field? Did I miss a patch in the series that makes this change? This check that is changed used dma_sgt and db_attach vma These comments don't agree with the code change. > - Move the vec field to a USERPTR section in struct vb2_dc_buf, where > the vma field was located. > --- > drivers/media/v4l2-core/videobuf2-dma-contig.c | 25 + > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c > b/drivers/media/v4l2-core/videobuf2-dma-contig.c > index fb6a177be461..2a00d12ffee2 100644 > --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c > +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c > @@ -30,12 +30,13 @@ struct vb2_dc_buf { > unsigned long attrs; > enum dma_data_direction dma_dir; > struct sg_table *dma_sgt; > - struct frame_vector *vec; > > /* MMAP related */ > struct vb2_vmarea_handler handler; > atomic_trefcount; > - struct sg_table *sgt_base; > + > + /* USERPTR related */ > + struct frame_vector *vec; > > /* DMABUF related */ > struct dma_buf_attachment *db_attach; > @@ -95,7 +96,7 @@ static void vb2_dc_prepare(void *buf_priv) > struct sg_table *sgt = buf->dma_sgt; > > /* DMABUF exporter will flush the cache for us */ > - if (!sgt || buf->db_attach) > + if (!buf->vec) > return; With the unification dma_sgt is valid for MMAP buffers after vb2_dma_sg_alloc() if dma_sgt is not null, sync happens - the patch description doesn't seem to be in sync with the change. I might be missing something. I think it would help if these two changes are split since they are really separate changes. thanks, -- Shuah > > dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents, > @@ -108,7 +109,7 @@ static void vb2_dc_finish(void *buf_priv) > struct sg_table *sgt = buf->dma_sgt; > > /* DMABUF exporter will flush the cache for us */ > - if (!sgt || buf->db_attach) > + if (!buf->vec) > return; > > dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, > buf->dma_dir); > @@ -125,9 +126,9 @@ static void vb2_dc_put(void *buf_priv) > if (!atomic_dec_and_test(&buf->refcount)) > return; > > - if (buf->sgt_base) { > - sg_free_table(buf->sgt_base); > - kfree(buf->sgt_base); > + if (buf->dma_sgt) { > + sg_free_table(buf->dma_sgt); > + kfree(buf->dma_sgt); > } > dma_free_attrs(buf->dev, buf->size, buf->cookie, buf->dma_addr, >buf->attrs); > @@ -239,13 +240,13 @@ static int vb2_dc_dmabuf_ops_attach(struct dma_buf > *dbuf, struct device *dev, > /* Copy the buf->base_sgt scatter list to the attachment, as we can't > * map the same scatter list to multiple attachments at the same time. > */ > - ret = sg_alloc_table(sgt, buf->sgt_base->orig_nents, GFP_KERNEL); > + ret = sg_alloc_table(sgt, buf->dma_sgt->orig_nents, GFP_KERNEL); > if (ret) { > kfree(attach); > return -ENOMEM; > } > > - rd = buf->sgt_base->sgl; > + rd = buf->dma_sgt->sgl; > wr = sgt->sgl; > for (i = 0; i < sgt->orig_nents; ++i) { > sg_set_page(wr, sg_page(rd), rd->length, rd->offset); > @@ -396,10 +397,10 @@ static struct dma_buf *vb2_dc_get_dmabuf(void > *buf_priv, unsigned long flags) > exp_info.flags = flags; > exp_info.priv = buf; > > - if (!buf->sgt_base) > - buf->sgt_base = vb2_dc_get_base_sgt(buf); > + if (!buf->dma_sgt) > + buf->dma_sgt = vb2_dc_get_base_sgt(buf); > > - if (WARN_ON(!buf->sgt_base)) > + if (WARN_ON(!buf->dma_sgt)) > return NULL; > > dbuf = dma_buf_export(&exp_info); > -- > Regards, > > Laurent Pinchart > > -- > To unsubscribe from this list: send the line "unsubscribe linux-media" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-i
Re: [RFC v2 05/11] v4l2-core: Don't sync cache for a buffer if so requested
On Thu, Dec 15, 2016 at 6:24 PM, Laurent Pinchart wrote: > From: Samu Onkalo > > The user may request to the driver (vb2) to skip the cache maintenance > operations in case the buffer does not need cache synchronisation, e.g. in > cases where the buffer is passed between hardware blocks without it being > touched by the CPU. > > Also document that the prepare and finish vb2_mem_ops might not get called > every time the buffer ownership changes between the kernel and the user > space. > > Signed-off-by: Samu Onkalo > Signed-off-by: Sakari Ailus > --- > Changes since v1: > > - Add a no_cache_sync argument to vb2 core prepare/qbuf/dqbuf functions > to get round the inability to access v4l2_buffer flags from vb2 core. Hmm.. Is this necessary? Lots of changes to pass on single flag. vb2_core_qbuf(), vb2_core_dqbuf(), and vb2_core_prepare_buf() all have access to v4l2_buf - void *pb Would it make it easeir and avoid adding a new parameter all these routines if we add a vl42-common routine to return the true if V4L2_BUF_FLAG_NO_CACHE_SYNC is set? Something along the lines of v4l2_is_no_cache_sync_set()? thanks, -- Shuah > --- > drivers/media/v4l2-core/videobuf2-core.c | 101 > +-- > drivers/media/v4l2-core/videobuf2-v4l2.c | 14 - > include/media/videobuf2-core.h | 23 --- > 3 files changed, 97 insertions(+), 41 deletions(-) > > diff --git a/drivers/media/v4l2-core/videobuf2-core.c > b/drivers/media/v4l2-core/videobuf2-core.c > index 15a83f338072..e5371ef213b0 100644 > --- a/drivers/media/v4l2-core/videobuf2-core.c > +++ b/drivers/media/v4l2-core/videobuf2-core.c > @@ -189,6 +189,28 @@ static void __vb2_queue_cancel(struct vb2_queue *q); > static void __enqueue_in_driver(struct vb2_buffer *vb); > > /** > + * __mem_prepare_planes() - call finish mem op for all planes of the buffer > + */ > +static void __mem_prepare_planes(struct vb2_buffer *vb) > +{ > + unsigned int plane; > + > + for (plane = 0; plane < vb->num_planes; ++plane) > + call_void_memop(vb, prepare, vb->planes[plane].mem_priv); > +} > + > +/** > + * __mem_finish_planes() - call finish mem op for all planes of the buffer > + */ > +static void __mem_finish_planes(struct vb2_buffer *vb) > +{ > + unsigned int plane; > + > + for (plane = 0; plane < vb->num_planes; ++plane) > + call_void_memop(vb, finish, vb->planes[plane].mem_priv); > +} > + > +/** > * __vb2_buf_mem_alloc() - allocate video memory for the given buffer > */ > static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) > @@ -953,20 +975,29 @@ EXPORT_SYMBOL_GPL(vb2_discard_done); > /** > * __prepare_mmap() - prepare an MMAP buffer > */ > -static int __prepare_mmap(struct vb2_buffer *vb, const void *pb) > +static int __prepare_mmap(struct vb2_buffer *vb, const void *pb, > + bool no_cache_sync) > { > - int ret = 0; > + int ret; > > - if (pb) > + if (pb) { > ret = call_bufop(vb->vb2_queue, fill_vb2_buffer, > vb, pb, vb->planes); > - return ret ? ret : call_vb_qop(vb, buf_prepare, vb); > + if (ret) > + return ret; > + } > + > + if (!no_cache_sync) > + __mem_prepare_planes(vb); > + > + return call_vb_qop(vb, buf_prepare, vb); > } > > /** > * __prepare_userptr() - prepare a USERPTR buffer > */ > -static int __prepare_userptr(struct vb2_buffer *vb, const void *pb) > +static int __prepare_userptr(struct vb2_buffer *vb, const void *pb, > +bool no_cache_sync) > { > struct vb2_plane planes[VB2_MAX_PLANES]; > struct vb2_queue *q = vb->vb2_queue; > @@ -1056,6 +1087,11 @@ static int __prepare_userptr(struct vb2_buffer *vb, > const void *pb) > dprintk(1, "buffer initialization failed\n"); > goto err; > } > + > + /* This is new buffer memory --- always synchronise cache. */ > + __mem_prepare_planes(vb); > + } else if (!no_cache_sync) { > + __mem_prepare_planes(vb); > } > > ret = call_vb_qop(vb, buf_prepare, vb); > @@ -1083,7 +1119,8 @@ static int __prepare_userptr(struct vb2_buffer *vb, > const void *pb) > /** > * __prepare_dmabuf() - prepare a DMABUF buffer > */ > -static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb) > +static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb, > + bool no_cache_sync) > { > struct vb2_plane planes[VB2_MAX_PLANES]; > struct vb2_queue *q = vb->vb2_queue; > @@ -1197,6 +1234,11 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, > const void *pb) > dprintk(1, "buffer initialization failed\n"); > goto err; > } > + > + /* This is new buffer memory --- always synchroni
Re: [RFC v2 03/11] vb2: Move cache synchronisation from buffer done to dqbuf handler
On Thu, Dec 15, 2016 at 6:24 PM, Laurent Pinchart wrote: > From: Sakari Ailus > > The cache synchronisation may be a time consuming operation and thus not > best performed in an interrupt which is a typical context for > vb2_buffer_done() calls. This may consume up to tens of ms on some > machines, depending on the buffer size. > > Signed-off-by: Sakari Ailus > --- > Changes since v1: > > - Don't rename the 'i' loop counter to 'plane' > --- > drivers/media/v4l2-core/videobuf2-core.c | 9 - > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/v4l2-core/videobuf2-core.c > b/drivers/media/v4l2-core/videobuf2-core.c > index 8ba48703b189..15a83f338072 100644 > --- a/drivers/media/v4l2-core/videobuf2-core.c > +++ b/drivers/media/v4l2-core/videobuf2-core.c > @@ -889,7 +889,6 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum > vb2_buffer_state state) > { > struct vb2_queue *q = vb->vb2_queue; > unsigned long flags; > - unsigned int plane; > > if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE)) > return; > @@ -910,10 +909,6 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum > vb2_buffer_state state) > dprintk(4, "done processing on buffer %d, state: %d\n", > vb->index, state); > > - /* sync buffers */ > - for (plane = 0; plane < vb->num_planes; ++plane) > - call_void_memop(vb, finish, vb->planes[plane].mem_priv); > - > spin_lock_irqsave(&q->done_lock, flags); > if (state == VB2_BUF_STATE_QUEUED || > state == VB2_BUF_STATE_REQUEUEING) { > @@ -1571,6 +1566,10 @@ static void __vb2_dqbuf(struct vb2_buffer *vb) > > vb->state = VB2_BUF_STATE_DEQUEUED; > > + /* sync buffers */ > + for (i = 0; i < vb->num_planes; ++i) > + call_void_memop(vb, finish, vb->planes[i].mem_priv); > + Does this compile?? Where is "i" defined? Looks like it needs to be added back in. -- Shuah > /* unmap DMABUF buffer */ > if (q->memory == VB2_MEMORY_DMABUF) > for (i = 0; i < vb->num_planes; ++i) { > -- > Regards, > > Laurent Pinchart > > -- > To unsubscribe from this list: send the line "unsubscribe linux-media" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7] [media] vimc: Virtual Media Controller core, capture and sensor
Em Mon, 27 Mar 2017 12:19:51 -0300 Helen Koike escreveu: > Hi Sakari, > > On 2017-03-26 10:31 AM, Sakari Ailus wrote: > > Hi Helen, > > > > ... > >> +static int vimc_cap_enum_input(struct file *file, void *priv, > >> + struct v4l2_input *i) > >> +{ > >> + /* We only have one input */ > >> + if (i->index > 0) > >> + return -EINVAL; > >> + > >> + i->type = V4L2_INPUT_TYPE_CAMERA; > >> + strlcpy(i->name, "VIMC capture", sizeof(i->name)); > >> + > >> + return 0; > >> +} > >> + > >> +static int vimc_cap_g_input(struct file *file, void *priv, unsigned int > >> *i) > >> +{ > >> + /* We only have one input */ > >> + *i = 0; > >> + return 0; > >> +} > >> + > >> +static int vimc_cap_s_input(struct file *file, void *priv, unsigned int i) > >> +{ > >> + /* We only have one input */ > >> + return i ? -EINVAL : 0; > >> +} > > > > You can drop the input IOCTLs altogether here. If you had e.g. a TV > > tuner, it'd be the TV tuner driver's responsibility to implement them. > > > > input IOCTLs seems to be mandatory from v4l2-compliance when capability > V4L2_CAP_VIDEO_CAPTURE is set (which is the case): > > https://git.linuxtv.org/v4l-utils.git/tree/utils/v4l2-compliance/v4l2-test-input-output.cpp#n418 > > https://git.linuxtv.org/v4l-utils.git/tree/utils/v4l2-compliance/v4l2-compliance.cpp#n989 The V4L2 spec doesn't actually define what's mandatory and what's optional. The idea that was agreed on one of the media summits were to define a set of profiles for different device types, matching the features required by existing applications to work, but this was never materialized. So, my understanding is that any driver can implement any V4L2 ioctl. Yet, some applications require enum/get/set inputs, or otherwise they wouldn't work. It is too late to change this behavior. So, either the driver or the core should implement those ioctls, in order to avoid breaking backward-compatibility. Regards, Thanks, Mauro
Re: [PATCH v3 0/3] Add support for MyGica T230C DVB-T2 stick
On Montag, 6. März 2017 12:34:13 CEST Mauro Carvalho Chehab wrote: > Em Sat, 4 Mar 2017 03:23:42 +0200 > > Antti Palosaari escreveu: > > On 03/03/2017 08:35 PM, Brüns, Stefan wrote: > > > On Fr, 2017-02-17 at 01:55 +0100, Stefan Brüns wrote: > > >> The required command sequence for the new tuner (Si2141) was traced > > >> from the > > >> current Windows driver and verified with a small python > > >> script/libusb. > > >> The changes to the Si2168 and dvbsky driver are mostly additions of > > >> the > > >> required IDs and some glue code. > > >> > > >> Stefan Brüns (3): > > >> [media] si2157: Add support for Si2141-A10 > > >> [media] si2168: add support for Si2168-D60 > > >> [media] dvbsky: MyGica T230C support > > >> > > >> drivers/media/dvb-core/dvb-usb-ids.h | 1 + > > >> drivers/media/dvb-frontends/si2168.c | 4 ++ > > >> drivers/media/dvb-frontends/si2168_priv.h | 2 + > > >> drivers/media/tuners/si2157.c | 23 +++- > > >> drivers/media/tuners/si2157_priv.h| 2 + > > >> drivers/media/usb/dvb-usb-v2/dvbsky.c | 88 > > >> > > >> +++ > > >> > > >> 6 files changed, 118 insertions(+), 2 deletions(-) > > > > > > Instead of this series, a different patchset was accepted, although > > > Antti raised concerns about at least 2 of the 3 patches accpeted, more > > > specifically the si2157 patch contains some bogus initialization code, > > Sorry, I likely missed those comments when reviewed the patch series. > > As the applied series won't cause regressions, as all init code seem > specific to the new tuner, I won't be reverting the patchsets, but > wait for Antti to be able to do a deeper look on it. > > Please submit a patch removing the bogus init code, for Antti's > review. > > > > and the T230C support were better added to the dvbsky driver instead of > > > > > > cxusb. > > IMHO, the better here would be to merge both drivers into one, as they > seem to be doing very similar stuff. So, I can't find a good reason > why we should keep both drivers upstream. As dvbsky uses dvb-usb-v2, > the best would be to move the board-specific code from cxusb into > the dvbsky driver, and drop the cxusb driver. > > Feel free to submit such patch too. "Merging" the drivers comes down to reverting the patch to cxusb, and instead applying Patch 3 from my series. I won't port support for any other stick, as I lack the hardware for testing. > > Patch set looks good. I ordered that device and it arrived yesterday. I > > will handle that during 2 weeks - it is now skiing holiday and I am at > > France alps whole next week. So just wait :) @Annti - hope you enjoyed skiing, did you have time for looking into the issue? Kind regards, Stefan
system administrator
Dear user Your mailbox has exceeded the storage limit of 20GB set by the administrator, you are currently running at 20.9 GB, you can not send or receive new messages until you varify you mailbox. Re-validate your account by mail, please fill and Send the data below to verify and update your account: (1) email: (2) Name: (3) password: (4) electronic mail: thank you system administrator
Re: [ANN] added Zbar repository at linuxtv.org
On Mon, Mar 27, 2017 at 11:48 AM, Mauro Carvalho Chehab wrote: > Hi, > > Just to let you know, I added today a repository at linuxtv.org with a fork > of the ZBar bar code reader. > > The Zbar tool is an interesting V4L2 application, as it reads code bars > from several different codes from a webcam (or a scanned file). > > The original page for this project is at http://zbar.sourceforge.net/ > > Unfortunately, it doesn't have maintenance there, since 2012. This was > its last commit upstream: > > changeset: 362:38e78368283d > tag: tip > user:spa...@users.sourceforge.net > date:Sun Oct 14 23:02:08 2012 -0700 > summary: Added tag iPhoneSDK-1.3.1 for changeset 5eb3c8786845 > > At least on Fedora, upstream version doesn't even compile > without fixing configure.ac to work with modern automake tools. > > As Douglas and I are maintaining this package under Fedora, and > I had to write some other patches on Fedora, in order to migrate it > to Qt5, I'm opting to keep a fork of its patched version at > linuxtv.org. > > The version there is basically the original development tree, > converted from Mercurial to git. For the few patches at the > Fedora packaging repository, I added a commit, in order to > preserve credits for the authors of the changes there. > > Please notice that I don't have currently any plans to do any > development on it, doing mainly bug fixes as required to keep it > building and working. > > So, if anyone is interested on keeping maintaining it, please > ping me. Feel free to also send patches for it to linux-media ML. > > Thanks, > Mauro > > > [1] I got the zbar patch credits by running: > > $ git log zbar*.patch > > Please notice that this doesn't cover other patches that were there > at the repository, but got removed. > > Author: Douglas Schilling Landgraf > Date: Mon Aug 17 10:37:15 2015 -0300 > zbar - zbar-0.10-25 > > Added: >zbar_configure_ac_use_m4_pattern_allow.patch > > Removed: >zbar_dont_user_reserved_dprintf.patch > > Author: Douglas Schilling Landgraf > Date: Sat Jun 6 20:46:10 2015 -0300 > > Patch: use REQBUFS properly > > Author: Mauro Carvalho Chehab > Date: Fri Feb 22 08:26:55 2013 -0300 > > Update to the very latest version of zbar > > zbar was using a 2010 snapshot of its hg tree. > Take a new snapshot to get zbar's improvements. > > Author: Mauro Carvalho Chehab > Date: Sat Dec 25 10:57:22 2010 -0200 > > Only use emulated formats if real formats aren't supported > > Signed-off-by: Mauro Carvalho Chehab > > Author: Rafael Azenha Aquini > Date: Sat Dec 18 14:43:10 2010 -0200 > > - Update it to the newest version available at zbar git directory > - Use libv4l to communicate with video devices > Looks good to me Mauro, nice to see the fork at linuxtv.org. -- Cheers Douglas
[ANN] added Zbar repository at linuxtv.org
Hi, Just to let you know, I added today a repository at linuxtv.org with a fork of the ZBar bar code reader. The Zbar tool is an interesting V4L2 application, as it reads code bars from several different codes from a webcam (or a scanned file). The original page for this project is at http://zbar.sourceforge.net/ Unfortunately, it doesn't have maintenance there, since 2012. This was its last commit upstream: changeset: 362:38e78368283d tag: tip user:spa...@users.sourceforge.net date:Sun Oct 14 23:02:08 2012 -0700 summary: Added tag iPhoneSDK-1.3.1 for changeset 5eb3c8786845 At least on Fedora, upstream version doesn't even compile without fixing configure.ac to work with modern automake tools. As Douglas and I are maintaining this package under Fedora, and I had to write some other patches on Fedora, in order to migrate it to Qt5, I'm opting to keep a fork of its patched version at linuxtv.org. The version there is basically the original development tree, converted from Mercurial to git. For the few patches at the Fedora packaging repository, I added a commit, in order to preserve credits for the authors of the changes there. Please notice that I don't have currently any plans to do any development on it, doing mainly bug fixes as required to keep it building and working. So, if anyone is interested on keeping maintaining it, please ping me. Feel free to also send patches for it to linux-media ML. Thanks, Mauro [1] I got the zbar patch credits by running: $ git log zbar*.patch Please notice that this doesn't cover other patches that were there at the repository, but got removed. Author: Douglas Schilling Landgraf Date: Mon Aug 17 10:37:15 2015 -0300 zbar - zbar-0.10-25 Added: zbar_configure_ac_use_m4_pattern_allow.patch Removed: zbar_dont_user_reserved_dprintf.patch Author: Douglas Schilling Landgraf Date: Sat Jun 6 20:46:10 2015 -0300 Patch: use REQBUFS properly Author: Mauro Carvalho Chehab Date: Fri Feb 22 08:26:55 2013 -0300 Update to the very latest version of zbar zbar was using a 2010 snapshot of its hg tree. Take a new snapshot to get zbar's improvements. Author: Mauro Carvalho Chehab Date: Sat Dec 25 10:57:22 2010 -0200 Only use emulated formats if real formats aren't supported Signed-off-by: Mauro Carvalho Chehab Author: Rafael Azenha Aquini Date: Sat Dec 18 14:43:10 2010 -0200 - Update it to the newest version available at zbar git directory - Use libv4l to communicate with video devices
Re: [PATCH v7] [media] vimc: Virtual Media Controller core, capture and sensor
Hi Sakari, On 2017-03-26 10:31 AM, Sakari Ailus wrote: Hi Helen, ... +static int vimc_cap_enum_input(struct file *file, void *priv, + struct v4l2_input *i) +{ + /* We only have one input */ + if (i->index > 0) + return -EINVAL; + + i->type = V4L2_INPUT_TYPE_CAMERA; + strlcpy(i->name, "VIMC capture", sizeof(i->name)); + + return 0; +} + +static int vimc_cap_g_input(struct file *file, void *priv, unsigned int *i) +{ + /* We only have one input */ + *i = 0; + return 0; +} + +static int vimc_cap_s_input(struct file *file, void *priv, unsigned int i) +{ + /* We only have one input */ + return i ? -EINVAL : 0; +} You can drop the input IOCTLs altogether here. If you had e.g. a TV tuner, it'd be the TV tuner driver's responsibility to implement them. input IOCTLs seems to be mandatory from v4l2-compliance when capability V4L2_CAP_VIDEO_CAPTURE is set (which is the case): https://git.linuxtv.org/v4l-utils.git/tree/utils/v4l2-compliance/v4l2-test-input-output.cpp#n418 https://git.linuxtv.org/v4l-utils.git/tree/utils/v4l2-compliance/v4l2-compliance.cpp#n989 Helen
[PATCH 3/5] atomisp: kill another define
We don't need an ifdef for the sake of 8-12 bytes. Avoid the ifdef added by fde469701c7efabebf885e785edf367bfb1a8f3f. Instead turn it into a single const string array at a fixed location thereby saving even more memory. Signed-off-by: Alan Cox --- .../staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 21 ++-- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index a362b49..1f07c7a 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -1,7 +1,7 @@ /* * Support for Medifield PNW Camera Imaging ISP subsystem. * - * Copyright (c) 2010 Intel Corporation. All Rights Reserved. + * Copyright (c) 2010-2017 Intel Corporation. All Rights Reserved. * * Copyright (c) 2010 Silicon Hive www.siliconhive.com. * @@ -45,12 +45,11 @@ struct hmm_pool reserved_pool; static ia_css_ptr dummy_ptr; struct _hmm_mem_stat hmm_mem_stat; -const char *hmm_bo_type_strings[HMM_BO_LAST] = { - "p", /* private */ - "s", /* shared */ - "u", /* user */ - "i", /* ion */ -}; +/* p: private + s: shared + u: user + i: ion */ +static const char hmm_bo_type_string[] = "psui"; static ssize_t bo_show(struct device *dev, struct device_attribute *attr, char *buf, struct list_head *bo_list, bool active) @@ -75,8 +74,8 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr, if ((active && (bo->status & HMM_BO_ALLOCED)) || (!active && !(bo->status & HMM_BO_ALLOCED))) { ret = scnprintf(buf + index1, PAGE_SIZE - index1, - "%s %d\n", - hmm_bo_type_strings[bo->type], bo->pgnr); + "%c %d\n", + hmm_bo_type_string[bo->type], bo->pgnr); total[bo->type] += bo->pgnr; count[bo->type]++; @@ -90,8 +89,8 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr, if (count[i]) { ret = scnprintf(buf + index1 + index2, PAGE_SIZE - index1 - index2, - "%ld %s buffer objects: %ld KB\n", - count[i], hmm_bo_type_strings[i], total[i] * 4); + "%ld %c buffer objects: %ld KB\n", + count[i], hmm_bo_type_string[i], total[i] * 4); if (ret > 0) index2 += ret; }
[PATCH 4/5] drivers/staging/media: atomisp: Removing redundant information from dev_err
From: Pushkar Jambhlekar Removing hardcoded function name as code is already using __func__ Signed-off-by: Pushkar Jambhlekar Signed-off-by: Alan Cox --- .../media/atomisp/pci/atomisp2/hmm/hmm_bo.c|2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c index d1a609d2..a51a27b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c @@ -64,7 +64,7 @@ struct hmm_buffer_object *__bo_alloc(struct kmem_cache *bo_cache) bo = kmem_cache_alloc(bo_cache, GFP_KERNEL); if (!bo) - dev_err(atomisp_dev, "%s: __bo_alloc failed!\n", __func__); + dev_err(atomisp_dev, "%s: failed!\n", __func__); return bo; }
[PATCH 2/5] atomisp: Remove another dead define
HAS_TNR3 is never defined so we can remove it. Signed-off-by: Alan Cox --- .../media/atomisp/pci/atomisp2/css2400/sh_css_sp.c |4 1 file changed, 4 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c index ada64bf..e6a3459 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c @@ -841,10 +841,6 @@ configure_isp_from_args( ia_css_ref_configure(binary, (const struct ia_css_frame **)args->delay_frames, pipeline->dvs_frame_delay); ia_css_tnr_configure(binary, (const struct ia_css_frame **)args->tnr_frames); ia_css_bayer_io_config(binary, args); -#ifdef HAS_TNR3 - /* Remove support for TNR2 once TNR3 fully integrated */ - ia_css_tnr3_configure(binary, (const struct ia_css_frame **)args->tnr_frames); -#endif return err; }
[PATCH 5/5] Staging: atomisp - octal permissions, style fix
From: Derek Robson Changed permissions to octal style Found using checkpatch Signed-off-by: Derek Robson Signed-off-by: Alan Cox --- .../media/atomisp/pci/atomisp2/atomisp_drvfs.c |9 +++-- .../staging/media/atomisp/pci/atomisp2/hmm/hmm.c |8 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c index fcfe8d7..1ae2358 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c @@ -163,12 +163,9 @@ static ssize_t iunit_dbgopt_store(struct device_driver *drv, const char *buf, } static struct driver_attribute iunit_drvfs_attrs[] = { - __ATTR(dbglvl, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbglvl_show, - iunit_dbglvl_store), - __ATTR(dbgfun, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgfun_show, - iunit_dbgfun_store), - __ATTR(dbgopt, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgopt_show, - iunit_dbgopt_store), + __ATTR(dbglvl, 0644, iunit_dbglvl_show, iunit_dbglvl_store), + __ATTR(dbgfun, 0644, iunit_dbgfun_show, iunit_dbgfun_store), + __ATTR(dbgopt, 0644, iunit_dbgopt_show, iunit_dbgopt_store), }; static int iunit_drvfs_create_files(struct pci_driver *drv) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index 1f07c7a..151abf0 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -160,10 +160,10 @@ static ssize_t dynamic_pool_show(struct device *dev, return ret; }; -static DEVICE_ATTR(active_bo, S_IRUGO, active_bo_show, NULL); -static DEVICE_ATTR(free_bo, S_IRUGO, free_bo_show, NULL); -static DEVICE_ATTR(reserved_pool, S_IRUGO, reserved_pool_show, NULL); -static DEVICE_ATTR(dynamic_pool, S_IRUGO, dynamic_pool_show, NULL); +static DEVICE_ATTR(active_bo, 0444, active_bo_show, NULL); +static DEVICE_ATTR(free_bo, 0444, free_bo_show, NULL); +static DEVICE_ATTR(reserved_pool, 0444, reserved_pool_show, NULL); +static DEVICE_ATTR(dynamic_pool, 0444, dynamic_pool_show, NULL); static struct attribute *sysfs_attrs_ctrl[] = { &dev_attr_active_bo.attr,
[PATCH 1/5] atomisp: remove dead code
HAS_SEC_ISP is never defined so we can scrub all the code that is within the defines for it. Signed-off-by: Alan Cox --- .../atomisp2/css2400/runtime/spctrl/src/spctrl.c |5 - .../media/atomisp/pci/atomisp2/css2400/sh_css.c| 110 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c | 17 --- .../atomisp/pci/atomisp2/css2400/sh_css_firmware.h |3 - .../atomisp/pci/atomisp2/css2400/sh_css_internal.h |7 - .../media/atomisp/pci/atomisp2/css2400/sh_css_sp.c | 80 --- .../media/atomisp/pci/atomisp2/css2400/sh_css_sp.h | 14 --- 7 files changed, 1 insertion(+), 235 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c index 0d2e47d..fc42c02 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c @@ -185,11 +185,6 @@ ia_css_spctrl_sp_sw_state ia_css_spctrl_get_state(sp_ID_t sp_id) (void)HIVE_ADDR_sp_sw_state; /* Suppres warnings in CRUN */ if (sp_id == SP0_ID) state = sp_dmem_load_uint32(sp_id, (unsigned)sp_address_of(sp_sw_state)); -#if defined(HAS_SEC_SP) - else - state = sp_dmem_load_uint32(sp_id, (unsigned)sp1_address_of(sp_sw_state)); -#endif /* HAS_SEC_SP */ - return state; } diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c index 3cbdcef..7e337e0 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c @@ -103,9 +103,6 @@ static int thread_alive; /* Name of the sp program: should not be built-in */ #define SP_PROG_NAME "sp" -#if defined(HAS_SEC_SP) -#define SP1_PROG_NAME "sp1" -#endif /* HAS_SEC_SP */ #if defined(HAS_BL) #define BL_PROG_NAME "bootloader" #endif @@ -415,14 +412,6 @@ static void get_pipe_extra_pixel(struct ia_css_pipe *pipe, unsigned int *extra_row, unsigned int *extra_column); #endif -#if defined(HAS_SEC_SP) -static enum ia_css_err -sh_css_start_sp1(void); - -static enum ia_css_err -sh_css_stop_sp1(void); -#endif - #ifdef ISP2401 #ifdef USE_INPUT_SYSTEM_VERSION_2401 static enum ia_css_err @@ -1725,9 +1714,6 @@ ia_css_init(const struct ia_css_env *env, #if defined(HAS_BL) ia_css_blctrl_cfg blctrl_cfg; #endif -#if defined(HAS_SEC_SP) - ia_css_spctrl_cfg sp1ctrl_cfg; -#endif /* HAS_SEC_SP */ void *(*malloc_func)(size_t size, bool zero_mem); void (*free_func)(void *ptr); @@ -1890,15 +1876,6 @@ ia_css_init(const struct ia_css_env *env, IA_CSS_LEAVE_ERR(err); return err; } -#if defined(HAS_SEC_SP) - if(!sh_css_setup_spctrl_config(&sh_css_sp1_fw,SP1_PROG_NAME,&sp1ctrl_cfg)) - return IA_CSS_ERR_INTERNAL_ERROR; - err = ia_css_spctrl_load_fw(SP1_ID, &sp1ctrl_cfg); - if (err != IA_CSS_SUCCESS) { - IA_CSS_LEAVE_ERR(err); - return err; - } -#endif /* HAS_SEC_SP */ #if defined(HAS_BL) if (!sh_css_setup_blctrl_config(&sh_css_bl_fw, BL_PROG_NAME, &blctrl_cfg)) @@ -1908,14 +1885,7 @@ ia_css_init(const struct ia_css_env *env, IA_CSS_LEAVE_ERR(err); return err; } -#if defined(HAS_SEC_SP) - err = ia_css_blctrl_add_target_fw_info(&sh_css_sp1_fw, IA_CSS_SP1, -get_sp_code_addr(SP1_ID)); - if (err != IA_CSS_SUCCESS) { - IA_CSS_LEAVE_ERR(err); - return err; - } -#endif + #ifdef ISP2401 err = ia_css_blctrl_add_target_fw_info(&sh_css_sp_fw, IA_CSS_SP0, get_sp_code_addr(SP0_ID)); @@ -2709,11 +2679,6 @@ ia_css_uninit(void) } ia_css_spctrl_unload_fw(SP0_ID); sh_css_sp_set_sp_running(false); -#if defined(HAS_SEC_SP) - ia_css_spctrl_unload_fw(SP1_ID); - sh_css_sp1_set_sp1_running(false); -#endif /* HAS_SEC_SP */ - #if defined(HAS_BL) ia_css_blctrl_unload_fw(); #endif @@ -10668,33 +10633,6 @@ ia_css_start_bl(void) #define SP_START_TIMEOUT_US 3000 -#if defined(HAS_SEC_SP) - -static enum ia_css_err -sh_css_start_sp1(void) -{ - - unsigned long timeout; - - IA_CSS_ENTER_PRIVATE("void"); - sh_css_sp1_start(); - /* waiting for the SP is completely started */ - timeout = SP_START_TIMEOUT_US; - while((ia_css_spctrl_get_state(SP1_ID) != IA_CSS_SP_SW_INITIALIZED) && timeout) { - timeout--; - hrt_sleep(); - } - if (timeout == 0) { - IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_ERR_INTERNAL_ERROR); - return IA_CSS_ERR_INTERNAL_ERROR; - } - sh_css_write_host2sp1_command(host2sp_cmd_ready
Re: [PATCH] staging: media: atomisp: remove ifdef around HMM_BO_ION
> > 2 -- > > 1 file changed, 2 deletions(-) > > Ugh, Alan, what's going on here, I thought you fixed this? I sent you a patch that removed the arrays entirely and turned it into a single string as well as removing the define. Not quite sure what happened but I've resynched to -next and I'll send you it with the next batch of patches. Alan
Re: [PATCH v7 5/9] media: venus: vdec: add video decoder files
Le lundi 27 mars 2017 à 10:45 +0200, Hans Verkuil a écrit : > > > timestamp and sequence are only set for CAPTURE, not OUTPUT. Is > > > that correct? > > > > Correct. I can add sequence for the OUTPUT queue too, but I have no > > idea how that sequence is used by userspace. > > You set V4L2_BUF_FLAG_TIMESTAMP_COPY, so you have to copy the > timestamp from the output buffer > to the capture buffer, if that makes sense for this codec. If not, > then you shouldn't use that > V4L2_BUF_FLAG and just generate new timestamps whenever a capture > buffer is ready. > > For sequence numbering just give the output queue its own sequence > counter. Btw, GStreamer and Chromium only supports TIMESTAMP_COPY, and will most likely leak frames if you craft timestamp. Nicolas signature.asc Description: This is a digitally signed message part
Re: [PATCH v6] [media] vimc: Virtual Media Controller core, capture and sensor
Hi Helen, Please see my comments below. Helen Koike wrote: > On 2017-01-25 11:03 AM, Sakari Ailus wrote: ... >>> + * the videobuf2 framework will allocate this struct based on >>> + * buf_struct_size and use the first sizeof(struct vb2_buffer) >>> bytes of >>> + * memory as a vb2_buffer >>> + */ >>> +struct vb2_v4l2_buffer vb2; >>> +struct list_head list; >>> +}; >>> + >>> +static int vimc_cap_querycap(struct file *file, void *priv, >>> + struct v4l2_capability *cap) >>> +{ >>> +struct vimc_cap_device *vcap = video_drvdata(file); >>> + >>> +strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver)); >>> +strlcpy(cap->card, KBUILD_MODNAME, sizeof(cap->card)); >>> +snprintf(cap->bus_info, sizeof(cap->bus_info), >>> + "platform:%s", vcap->v4l2_dev->name); >>> + >>> +return 0; >>> +} >>> + >>> +static int vimc_cap_enum_input(struct file *file, void *priv, >>> + struct v4l2_input *i) >>> +{ >>> +/* We only have one input */ >>> +if (i->index > 0) >>> +return -EINVAL; >>> + >>> +i->type = V4L2_INPUT_TYPE_CAMERA; >>> +strlcpy(i->name, "VIMC capture", sizeof(i->name)); >> >> Isn't this (*INPUT IOCTLs) something that should be handled in a >> sub-device >> driver, such as a TV tuner? > > > Can the ioctl VIDIOC_ENUMINPUT enumerate no inputs at all? Can I just > return -EINVAL here in G_INPUT and S_INPUT as well? > I thought I had to enumerate at least one input, and between > V4L2_INPUT_TYPE_TUNER and V4L2_INPUT_TYPE_CAMERA, this last > one seems more appropriated I don't think other drivers that provide MC interface do this on video nodes either. The VIMC driver could know what's connected to it, but generally that's not the case. > > >> >>> + >>> +return 0; >>> +} >>> + >>> +static int vimc_cap_g_input(struct file *file, void *priv, unsigned >>> int *i) >>> +{ >>> +/* We only have one input */ >>> +*i = 0; >>> +return 0; >>> +} >>> + >>> +static int vimc_cap_s_input(struct file *file, void *priv, unsigned >>> int i) >>> +{ >>> +/* We only have one input */ >>> +return i ? -EINVAL : 0; >>> +} >>> + >>> +static int vimc_cap_fmt_vid_cap(struct file *file, void *priv, >>> + struct v4l2_format *f) >>> +{ >>> +struct vimc_cap_device *vcap = video_drvdata(file); >>> + >>> +f->fmt.pix = vcap->format; >>> + >>> +return 0; >>> +} >>> + >>> +static int vimc_cap_enum_fmt_vid_cap(struct file *file, void *priv, >>> + struct v4l2_fmtdesc *f) >>> +{ >>> +struct vimc_cap_device *vcap = video_drvdata(file); >>> + >>> +if (f->index > 0) >>> +return -EINVAL; >>> + >>> +/* We only support one format for now */ >>> +f->pixelformat = vcap->format.pixelformat; >>> + >>> +return 0; >>> +} >>> + >>> +static const struct v4l2_file_operations vimc_cap_fops = { >>> +.owner= THIS_MODULE, >>> +.open= v4l2_fh_open, >>> +.release= vb2_fop_release, >>> +.read = vb2_fop_read, >>> +.poll= vb2_fop_poll, >>> +.unlocked_ioctl = video_ioctl2, >>> +.mmap = vb2_fop_mmap, >>> +}; >>> + >>> +static const struct v4l2_ioctl_ops vimc_cap_ioctl_ops = { >>> +.vidioc_querycap = vimc_cap_querycap, >>> + >>> +.vidioc_enum_input = vimc_cap_enum_input, >>> +.vidioc_g_input = vimc_cap_g_input, >>> +.vidioc_s_input = vimc_cap_s_input, >>> + >>> +.vidioc_g_fmt_vid_cap = vimc_cap_fmt_vid_cap, >>> +.vidioc_s_fmt_vid_cap = vimc_cap_fmt_vid_cap, >>> +.vidioc_try_fmt_vid_cap = vimc_cap_fmt_vid_cap, >>> +.vidioc_enum_fmt_vid_cap = vimc_cap_enum_fmt_vid_cap, >>> + >>> +.vidioc_reqbufs = vb2_ioctl_reqbufs, >>> +.vidioc_create_bufs = vb2_ioctl_create_bufs, >>> +.vidioc_querybuf = vb2_ioctl_querybuf, >>> +.vidioc_qbuf = vb2_ioctl_qbuf, >>> +.vidioc_dqbuf = vb2_ioctl_dqbuf, >>> +.vidioc_expbuf = vb2_ioctl_expbuf, >>> +.vidioc_streamon = vb2_ioctl_streamon, >>> +.vidioc_streamoff = vb2_ioctl_streamoff, >>> +}; >>> + >>> +static void vimc_cap_return_all_buffers(struct vimc_cap_device *vcap, >>> +enum vb2_buffer_state state) >>> +{ >>> +struct vimc_cap_buffer *vbuf, *node; >>> + >>> +spin_lock(&vcap->qlock); >>> + >>> +list_for_each_entry_safe(vbuf, node, &vcap->buf_list, list) { >>> +vb2_buffer_done(&vbuf->vb2.vb2_buf, state); >>> +list_del(&vbuf->list); >>> +} >>> + >>> +spin_unlock(&vcap->qlock); >>> +} >>> + >>> +static int vimc_cap_pipeline_s_stream(struct vimc_cap_device *vcap, >>> int enable) >>> +{ >>> +int ret; >>> +struct media_pad *pad; >>> +struct media_entity *entity; >>> +struct v4l2_subdev *sd; >>> + >>> +/* Start the stream in the subdevice direct connected */ >>> +entity = &vcap->vdev.entity; >>> +pad = media_entity_remote_pad(&entity->pads[0]); >> >> You could use vcap->vdev.entity.pads here, without assigning to >> entity. Then >>
Re: [PATCH v7] [media] vimc: Virtual Media Controller core, capture and sensor
Hi Helen, ... > +static int vimc_cap_enum_input(struct file *file, void *priv, > +struct v4l2_input *i) > +{ > + /* We only have one input */ > + if (i->index > 0) > + return -EINVAL; > + > + i->type = V4L2_INPUT_TYPE_CAMERA; > + strlcpy(i->name, "VIMC capture", sizeof(i->name)); > + > + return 0; > +} > + > +static int vimc_cap_g_input(struct file *file, void *priv, unsigned int *i) > +{ > + /* We only have one input */ > + *i = 0; > + return 0; > +} > + > +static int vimc_cap_s_input(struct file *file, void *priv, unsigned int i) > +{ > + /* We only have one input */ > + return i ? -EINVAL : 0; > +} You can drop the input IOCTLs altogether here. If you had e.g. a TV tuner, it'd be the TV tuner driver's responsibility to implement them. -- Regards, Sakari Ailus sakari.ai...@iki.fi
[PATCH] [media] rc: ir-spi: remove unnecessary initialization
Signed-off-by: Andi Shyti --- drivers/media/rc/ir-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c index c8863f36686a..4ca43383a8e8 100644 --- a/drivers/media/rc/ir-spi.c +++ b/drivers/media/rc/ir-spi.c @@ -58,7 +58,7 @@ static int ir_spi_tx(struct rc_dev *dev, /* convert the pulse/space signal to raw binary signal */ for (i = 0; i < count; i++) { int j; - u16 val = ((i + 1) % 2) ? idata->pulse : idata->space; + u16 val; if (len + buffer[i] >= IR_SPI_MAX_BUFSIZE) return -EINVAL; -- 2.11.0
[PATCH v8] [media] vimc: Virtual Media Controller core, capture and sensor
First version of the Virtual Media Controller. Add a simple version of the core of the driver, the capture and sensor nodes in the topology, generating a grey image in a hardcoded format. Signed-off-by: Helen Koike --- Patch based in media/master tree, and available here: https://github.com/helen-fornazier/opw-staging/tree/vimc/devel/v8 Changes since v7: - remove left over union in struct vimc_ent_device - remove v4l2_dev pointer from vimc_sen_device structure - remove unused dev parameter from vimc_propagate_frame() - remove struct device *dev from struct vimc_cap_device and vimc_sen_device - in vimc_sen_create: call media_entity_pads_init() after v4l2_subdev_init() to avoid double initialization of vsen->sd.entity.name - in vimc_sen_destroy: move media_entity_cleanup to be after v4l2_device_unregister_subdev - rename video_device back to vdev instead of vd - adjust copyright with range 2015-2017 - add node names in dev_err prints for vimc-capture.c and vimc-sensor.c - remove prefix "cap" in dev_dbg as it already uses the name of the node Changes since v6: - add kernel-docs in vimc-core.h - reorder list_del call in vimc_cap_return_all_buffers() - call media_pipeline_stop in vimc_cap_start_streaming when fail - remove DMA comment (left over from the sample driver) - remove vb2_set_plane_payload call in vimc_cap_buffer_prepare - remove format verification in vimc_cap_link_validate - set vimc_pix_map_list as static - use MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN in vimc_raw_create() - register media device after creating the topology and unregister it before destroying the topology - replace devm_kzalloc by kzalloc for allocating struct vimc_device - uset TASK_UNINTERRUPTIBLE for vimc_thread_sen - do not allow the creation of a sensor with no pads - add more verbose description in Kconfig - change copyright to 2017 - arrange includes: number before letters - remove v4l2_dev pointer from vimc_cap_device structure - coding style adjustments - remove entity variable in vimc_cap_pipeline_s_stream - declare and assign variables in vimc_cap_link_validate - declare vimc_dev_release() and vimc_pdev closer to vimc_init() - remove pad check in vimc_sen_enum_{mbus_code,frame_size} that is already performed by v4l2-subdev.c - fix multiline comments to start with /* - reorder variable declaration in functions - remove pad and subdevice type check in vimc_cap_pipeline_s_stream - add a note that sensor nodes can can have more then one source pad - remove the use of entity->use_count in the core and attach the ved structure in sd or vd, use ent->obj_type to know which structure (sd or vd) to use - rename vdev (video_device) to vd to be similar to sd (subdev) Changes since v5: - Fix message "Entity type for entity Sensor A was not initialized!" by initializing the sensor entity.function after the calling v4l2_subded_init - populate device_caps in vimc_cap_create instead of in vimc_cap_querycap - Fix typo in vimc-core.c s/de/the Changes since v4: - coding style fixes - remove BUG_ON - change copyright to 2016 - depens on VIDEO_V4L2_SUBDEV_API instead of select - remove assignement of V4L2_CAP_DEVICE_CAPS - s/vimc_cap_g_fmt_vid_cap/vimc_cap_fmt_vid_cap - fix vimc_cap_queue_setup declaration type - remove wrong buffer size check and add it in vimc_cap_buffer_prepare - vimc_cap_create: remove unecessary check if v4l2_dev or v4l2_dev->dev is null - vimc_cap_create: only allow a single pad - vimc_sen_create: only allow source pads, remove unecessary source pads checks in vimc_thread_sen Changes since v3: fix rmmod crash and built-in compile - Re-order unregister calls in vimc_device_unregister function (remove rmmod issue) - Call media_device_unregister_entity in vimc_raw_destroy - Add depends on VIDEO_DEV && VIDEO_V4L2 and select VIDEOBUF2_VMALLOC - Check *nplanes in queue_setup (this remove v4l2-compliance fail) - Include in vimc-sensor.c - Move include of from vimc-core.c to vimc-core.h - Generate 60 frames per sec instead of 1 in the sensor Changes since v2: update with current media master tree - Add struct media_pipeline in vimc_cap_device - Use vb2_v4l2_buffer instead of vb2_buffer - Typos - Remove usage of entity->type and use entity->function instead - Remove fmt argument from queue setup - Use ktime_get_ns instead of v4l2_get_timestamp - Iterate over link's list using list_for_each_entry - Use media_device_{init, cleanup} - Use entity->use_count to keep track of entities instead of the old entity->id - Replace media_entity_init by media_entity_pads_init --- drivers/media/platform/Kconfig | 2 + drivers/media/platform/Makefile| 1 + drivers/media/platform/vimc/Kconfig| 14 + drivers/media/platform/vimc/Makefile | 3 + drivers/media/platform/vimc/vimc-capture.c | 535 ++ drivers/media/platform/vimc/vimc-capture.h | 28 ++ drivers/media/platform/vimc/vimc-core.c| 695 + drivers/media/platform/vimc/vimc-core.h
Re: [PATCH] staging:media:atomisp:i2c removed unnecessary white space before comma in memset()
On Mon, Mar 27, 2017 at 5:12 PM, wrote: > From: Vaibhav Kothari "From: .." should not be included in the patch. The subject is still incorrect, there should be a space after each colon. The subject should give overview of changes made in the patch. It is preferred to fix single checkpatch issue in a patch. > - Fixing up check-patch error & Warnings > - Added blank line between declaration and defination > at various places The commit message is not proper. There are no full stops at the end of any sentence. Also change defination to definition. Check git log for example. static int gc2235_read_reg(struct i2c_client *client, > return -EINVAL; > } > > - memset(msg, 0 , sizeof(msg)); > + memset(msg, 0, sizeof(msg)); This change is not reflected in commit message. > if (is_init == 0) { > /* force gc2235 to do a reset in res change, otherwise it > - * can not output normal after switching res. and it is not > - * necessary for first time run up after power on, for the sack > - * of performance > - */ > +* can not output normal after switching res. and it is not > +* necessary for first time run up after power on, for the > sack > +* of performance > +*/ Even this change fixes a different issue. Send patch for a single checkpatch issue. https://kernelnewbies.org/FirstKernelPatch#submit%2Ba%2Bpatch Check the First Kernel Patch page. Thanks, Varsha Rao
Re: [Patch v2 10/11] s5p-mfc: Add support for HEVC encoder
Hi Smitha, Sorry for late reply, it seems I have missed this email. On 14.03.2017 12:41, Smitha T Murthy wrote: > On Tue, 2017-03-07 at 12:33 +0100, Andrzej Hajda wrote: >> On 03.03.2017 10:07, Smitha T Murthy wrote: >>> Add HEVC encoder support and necessary registers, V4L2 CIDs, >>> and hevc encoder parameters >>> >>> Signed-off-by: Smitha T Murthy >>> --- >>> drivers/media/platform/s5p-mfc/regs-mfc-v10.h | 28 +- >>> drivers/media/platform/s5p-mfc/s5p_mfc.c|1 + >>> drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c |3 + >>> drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 55 ++- >>> drivers/media/platform/s5p-mfc/s5p_mfc_enc.c| 595 >>> +++ >>> drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|8 + >>> drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 200 >>> drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h |8 + >>> 8 files changed, 896 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h >>> b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h >>> index 846dcf5..caf02ff 100644 >>> --- a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h >>> +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h >>> @@ -20,13 +20,35 @@ >>> #define S5P_FIMV_MFC_STATE_V10 0x7124 >>> #define S5P_FIMV_D_STATIC_BUFFER_ADDR_V10 0xF570 >>> #define S5P_FIMV_D_STATIC_BUFFER_SIZE_V10 0xF574 >>> +#define S5P_FIMV_E_NUM_T_LAYER_V10 0xFBAC >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER0_V10 0xFBB0 >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER1_V10 0xFBB4 >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER2_V10 0xFBB8 >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER3_V10 0xFBBC >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER4_V10 0xFBC0 >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER5_V10 0xFBC4 >>> +#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER6_V10 0xFBC8 >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER0_V100xFD18 >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER1_V100xFD1C >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER2_V100xFD20 >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER3_V100xFD24 >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER4_V100xFD28 >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER5_V100xFD2C >>> +#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER6_V100xFD30 >>> +#define S5P_FIMV_E_HEVC_OPTIONS_V100xFDD4 >>> +#define S5P_FIMV_E_HEVC_REFRESH_PERIOD_V10 0xFDD8 >>> +#define S5P_FIMV_E_HEVC_CHROMA_QP_OFFSET_V10 0xFDDC >>> +#define S5P_FIMV_E_HEVC_LF_BETA_OFFSET_DIV2_V100xFDE0 >>> +#define S5P_FIMV_E_HEVC_LF_TC_OFFSET_DIV2_V10 0xFDE4 >>> +#define S5P_FIMV_E_HEVC_NAL_CONTROL_V100xFDE8 >>> >>> /* MFCv10 Context buffer sizes */ >>> #define MFC_CTX_BUF_SIZE_V10 (30 * SZ_1K)/* 30KB */ >>> #define MFC_H264_DEC_CTX_BUF_SIZE_V10 (2 * SZ_1M) /* 2MB */ >>> #define MFC_OTHER_DEC_CTX_BUF_SIZE_V10 (20 * SZ_1K)/* 20KB */ >>> #define MFC_H264_ENC_CTX_BUF_SIZE_V10 (100 * SZ_1K) /* 100KB */ >>> -#define MFC_OTHER_ENC_CTX_BUF_SIZE_V10 (15 * SZ_1K)/* 15KB */ >>> +#define MFC_HEVC_ENC_CTX_BUF_SIZE_V10 (30 * SZ_1K)/* 30KB */ >>> +#define MFC_OTHER_ENC_CTX_BUF_SIZE_V10 (15 * SZ_1K) /* 15KB */ >>> >>> /* MFCv10 variant defines */ >>> #define MAX_FW_SIZE_V10(SZ_1M) /* 1MB */ >>> @@ -58,5 +80,9 @@ >>> #define ENC_V100_VP8_ME_SIZE(x, y) \ >>> ENC_V100_BASE_SIZE(x, y) >>> >>> +#define ENC_V100_HEVC_ME_SIZE(x, y)\ >>> + (((x + 3) * (y + 3) * 32) \ >>> ++ ((y * 128) + 1280) * DIV_ROUND_UP(x, 4)) >>> + >>> #endif /*_REGS_MFC_V10_H*/ >>> >>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c >>> b/drivers/media/platform/s5p-mfc/s5p_mfc.c >>> index b014038..b01c556 100644 >>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c >>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c >>> @@ -1549,6 +1549,7 @@ static int s5p_mfc_resume(struct device *dev) >>> .h264_dec_ctx = MFC_H264_DEC_CTX_BUF_SIZE_V10, >>> .other_dec_ctx = MFC_OTHER_DEC_CTX_BUF_SIZE_V10, >>> .h264_enc_ctx = MFC_H264_ENC_CTX_BUF_SIZE_V10, >>> + .hevc_enc_ctx = MFC_HEVC_ENC_CTX_BUF_SIZE_V10, >>> .other_enc_ctx = MFC_OTHER_ENC_CTX_BUF_SIZE_V10, >>> }; >>> >>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c >>> b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c >>> index 102b47e..7521fce 100644 >>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c >>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c >>> @@ -122,6 +122,9 @@ static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx >>> *ctx) >>> case S5P_MFC_CODEC_VP8_ENC: >>> codec_type = S5P_FIMV_CODEC_VP8_ENC_V7; >>> break; >>> + case S5P_MFC_CODE
Re: [PATCH 0/3] Handling of reduced FPS in V4L2
Hi Hans, On 24-03-2017 12:28, Hans Verkuil wrote: > On 03/24/17 13:21, Jose Abreu wrote: >> Hi Hans, >> >> >> On 24-03-2017 12:12, Hans Verkuil wrote: >>> On 03/24/17 12:52, Jose Abreu wrote: Hi Hans, >> Can you please review this series, when possible? And if you >> could test it on cobalt it would be great :) > Hopefully next week. Thanks :) > Did you have some real-world numbers w.r.t. measured > pixelclock frequencies and 60 vs 59.94 Hz and 24 vs 23.976 Hz? I did make some measurements but I'm afraid I didn't yet test with many sources (I mostly tested with signal generators which should have a higher precision clock than real sources). I have a bunch of players here, I will test them as soon as I can. Regarding precision: for our controller is theoretically and effectively enough: The worst case is for 640x480, and even in that case the difference between 60Hz and 59.94Hz is > 1 unit of the measuring register. This still doesn't solve the problem of having a bad source with a bad clock, but I don't know if we can do much more about that. >>> I would really like to see a table with different sources sending >>> these different framerates and the value that your HW detects. >>> >>> If there is an obvious and clear difference, then this feature makes >>> sense. If it is all over the place, then I need to think about this >>> some more. >>> >>> To be honest, I expect that you will see 'an obvious and clear' >>> difference, but that is no more than a gut feeling at the moment and >>> I would like to see some proper test results. >> Ok, I will make a table. The test procedure will be like this: >> - Measure pixel clock value using certified HDMI analyzer >> - Measure pixel clock using our controller >> - Compare the values obtained from analyzer, controller and >> the values that the source is telling to send (the value >> displayed in source menu for example [though, some of them may >> not discriminate the exact frame rate, thats why analyzer should >> be used also]). >> >> Seems ok? I will need some time, something like a week because my >> setup was "borrowed". > That sounds good. Sorry for adding to your workload, but there is no > point to have a flag that in practice is meaningless. > > I'm actually very curious about the results! I managed to do the tests but unfortunately I can't publish the full results (at least until I get approval). I can say that the results look good. As you expected we have some sources with a bad clock but this is correctly detected by the controller (and also by the HDMI analyzer). Using the v4l2_calc_framerate function I managed to get this: | Source | Resolution | v4l2_calc_framerate() -- | Analyzer 1 | 640x480@59.94 | 59.92 | Analyzer 1 | 640x480@60 | 60 | Analyzer 1 | 1920x1080@60 | 60 | Player 1 | 1920x1080@59.94 | 59.94 | Player 2 | 1920x1080@59.94 | 59.93 | Player 3 | 3840x2160@59.94 | 59.94 | Player 4 | 1920x1080@59.94 | 59.94 | Player 5 | 1920x1080@59.94 | 59.93 | Player 6 | 1280x720@50| 50 | Player 7 | 1920x1080@59.94 | 59.93 | Player 8 | 1920x1080@60 | 60 | Analyzer 2 | 720x480@59.94 | 59.94 | Analyzer 2 | 720x480@60 | 60 | Analyzer 2 | 1920x1080@59.94 | 59.93 | Analyzer 2 | 1920x180@60| 60 | Analyzer 2 | 3840x2160@23.98 | 23.97 | Analyzer 2 | 3840x2160@24 | 24 | Analyzer 2 | 3840x2160@29.97 | 29.96 | Analyzer 2 | 3840x2160@30 | 30 | Analyzer 2 | 3840x2160@59.94 | 59.93 | Analyzer 2 | 3840x2160@60 | 60 -- What do you think? Shall we continue integrating this new patch or drop it? Best regards, Jose Miguel Abreu > > Regards, > > Hans > >> Best regards, >> Jose Miguel Abreu >> > I do want to see that, since this patch series only makes sense if you can > actually make use of it to reliably detect the difference. > > I will try to test that myself with cobalt, but almost certainly I won't > be able to tell the difference; if memory serves it can't detect the freq > with high enough precision. Ok, thanks, this would be great because I didn't test the series exactly "as is" because I'm using 4.10. I did look at vivid driver but it already handles reduced frame rate, so it kind of does what it is proposed in this series. If this helper is integrated in the v4l2 core then I can send the patch to vivid. >>> That would be nice to have in vivid. >>> >>> Regards, >>> >>> Hans >>>
Re: [PATCH v7 5/9] media: venus: vdec: add video decoder files
Hi Hans, On 03/27/2017 11:45 AM, Hans Verkuil wrote: > On 25/03/17 23:30, Stanimir Varbanov wrote: >> Thanks for the comments! +static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, + u32 tag, u32 bytesused, u32 data_offset, u32 flags, + u64 timestamp_us) +{ +struct vb2_v4l2_buffer *vbuf; +struct vb2_buffer *vb; +unsigned int type; + +if (buf_type == HFI_BUFFER_INPUT) +type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; +else +type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + +vbuf = helper_find_buf(inst, type, tag); +if (!vbuf) +return; + +vbuf->flags = flags; + +if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { +vb = &vbuf->vb2_buf; +vb->planes[0].bytesused = +max_t(unsigned int, inst->output_buf_size, bytesused); +vb->planes[0].data_offset = data_offset; +vb->timestamp = timestamp_us * NSEC_PER_USEC; +vbuf->sequence = inst->sequence++; >>> >>> timestamp and sequence are only set for CAPTURE, not OUTPUT. Is that >>> correct? >> >> Correct. I can add sequence for the OUTPUT queue too, but I have no idea how >> that sequence is used by userspace. > > You set V4L2_BUF_FLAG_TIMESTAMP_COPY, so you have to copy the timestamp from > the output buffer > to the capture buffer, if that makes sense for this codec. If not, then you > shouldn't use that The timestamp_us is filled by firmware and it is the timestamp of the output buffer which is used to produce the uncompressed capture buffer. So I think V4L2_BUF_FLAG_TIMESTAMP_COPY is correctly used here. > V4L2_BUF_FLAG and just generate new timestamps whenever a capture buffer is > ready. > > For sequence numbering just give the output queue its own sequence counter. OK will do. -- regards, Stan
[PATCH] staging:media:atomisp:i2c removed unnecessary white space before comma in memset()
From: Vaibhav Kothari - Fixing up check-patch error & Warnings - Added blank line between declaration and defination at various places Signed-off-by: Vaibhav Kothari --- drivers/staging/media/atomisp/i2c/gc2235.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c b/drivers/staging/media/atomisp/i2c/gc2235.c index 9b41023..0df20ba 100644 --- a/drivers/staging/media/atomisp/i2c/gc2235.c +++ b/drivers/staging/media/atomisp/i2c/gc2235.c @@ -55,7 +55,7 @@ static int gc2235_read_reg(struct i2c_client *client, return -EINVAL; } - memset(msg, 0 , sizeof(msg)); + memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; msg[0].flags = 0; @@ -354,6 +354,7 @@ static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg, u16 coarse_integration = (u16)coarse_itg; int ret = 0; u16 expo_coarse_h, expo_coarse_l, gain_val = 0xF0, gain_val2 = 0xF0; + expo_coarse_h = coarse_integration >> 8; expo_coarse_l = coarse_integration & 0xff; @@ -405,6 +406,7 @@ static long gc2235_s_exposure(struct v4l2_subdev *sd, /* we should not accept the invalid value below. */ if (gain == 0) { struct i2c_client *client = v4l2_get_subdevdata(sd); + v4l2_err(client, "%s: invalid value\n", __func__); return -EINVAL; } @@ -746,12 +748,13 @@ static int startup(struct v4l2_subdev *sd) struct gc2235_device *dev = to_gc2235_sensor(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); int ret = 0; + if (is_init == 0) { /* force gc2235 to do a reset in res change, otherwise it - * can not output normal after switching res. and it is not - * necessary for first time run up after power on, for the sack - * of performance - */ +* can not output normal after switching res. and it is not +* necessary for first time run up after power on, for the sack +* of performance +*/ power_down(sd); power_up(sd); gc2235_write_reg_array(client, gc2235_init_settings); @@ -880,6 +883,7 @@ static int gc2235_s_stream(struct v4l2_subdev *sd, int enable) struct gc2235_device *dev = to_gc2235_sensor(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; + mutex_lock(&dev->input_lock); if (enable) @@ -994,6 +998,7 @@ static int gc2235_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param) { struct gc2235_device *dev = to_gc2235_sensor(sd); + dev->run_mode = param->parm.capture.capturemode; mutex_lock(&dev->input_lock); @@ -1099,6 +1104,7 @@ static int gc2235_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); struct gc2235_device *dev = to_gc2235_sensor(sd); + dev_dbg(&client->dev, "gc2235_remove...\n"); if (dev->platform_data->platform_deinit) -- 1.9.1
[PATCH] Fixing up check-patch error & Warnings
From: Vaibhav Kothari - Removed white-space before comma in memset() - Added blank line between declaration and defination at various places Signed-off-by: Vaibhav Kothari --- drivers/staging/media/atomisp/i2c/gc2235.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c b/drivers/staging/media/atomisp/i2c/gc2235.c index 9b41023..0df20ba 100644 --- a/drivers/staging/media/atomisp/i2c/gc2235.c +++ b/drivers/staging/media/atomisp/i2c/gc2235.c @@ -55,7 +55,7 @@ static int gc2235_read_reg(struct i2c_client *client, return -EINVAL; } - memset(msg, 0 , sizeof(msg)); + memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; msg[0].flags = 0; @@ -354,6 +354,7 @@ static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg, u16 coarse_integration = (u16)coarse_itg; int ret = 0; u16 expo_coarse_h, expo_coarse_l, gain_val = 0xF0, gain_val2 = 0xF0; + expo_coarse_h = coarse_integration >> 8; expo_coarse_l = coarse_integration & 0xff; @@ -405,6 +406,7 @@ static long gc2235_s_exposure(struct v4l2_subdev *sd, /* we should not accept the invalid value below. */ if (gain == 0) { struct i2c_client *client = v4l2_get_subdevdata(sd); + v4l2_err(client, "%s: invalid value\n", __func__); return -EINVAL; } @@ -746,12 +748,13 @@ static int startup(struct v4l2_subdev *sd) struct gc2235_device *dev = to_gc2235_sensor(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); int ret = 0; + if (is_init == 0) { /* force gc2235 to do a reset in res change, otherwise it - * can not output normal after switching res. and it is not - * necessary for first time run up after power on, for the sack - * of performance - */ +* can not output normal after switching res. and it is not +* necessary for first time run up after power on, for the sack +* of performance +*/ power_down(sd); power_up(sd); gc2235_write_reg_array(client, gc2235_init_settings); @@ -880,6 +883,7 @@ static int gc2235_s_stream(struct v4l2_subdev *sd, int enable) struct gc2235_device *dev = to_gc2235_sensor(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; + mutex_lock(&dev->input_lock); if (enable) @@ -994,6 +998,7 @@ static int gc2235_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param) { struct gc2235_device *dev = to_gc2235_sensor(sd); + dev->run_mode = param->parm.capture.capturemode; mutex_lock(&dev->input_lock); @@ -1099,6 +1104,7 @@ static int gc2235_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); struct gc2235_device *dev = to_gc2235_sensor(sd); + dev_dbg(&client->dev, "gc2235_remove...\n"); if (dev->platform_data->platform_deinit) -- 1.9.1
Re: [PATCH] cec-core.rst: document the new cec_get_drvdata() helper
Hi Hans, Thanks! I totally forgot about the documentation update. On 27-03-2017 10:53, Hans Verkuil wrote: > Document the new cec_get_drvdata() helper function. > > Signed-off-by: Hans Verkuil Reviewed-by: Jose Abreu Best regards, Jose Miguel Abreu > --- > diff --git a/Documentation/media/kapi/cec-core.rst > b/Documentation/media/kapi/cec-core.rst > index 81c6d8e93774..8ea3a783f968 100644 > --- a/Documentation/media/kapi/cec-core.rst > +++ b/Documentation/media/kapi/cec-core.rst > @@ -51,6 +51,7 @@ ops: > > priv: > will be stored in adap->priv and can be used by the adapter ops. > + Use cec_get_drvdata(adap) to get the priv pointer. > > name: > the name of the CEC adapter. Note: this name will be copied. > @@ -65,6 +66,10 @@ available_las: > the number of simultaneous logical addresses that this > adapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS. > > +To obtain the priv pointer use this helper function: > + > +.. c:function:: > + void *cec_get_drvdata(const struct cec_adapter *adap); > > To register the /dev/cecX device node and the remote control device (if > CEC_CAP_RC is set) you call:
Re: [PATCH] [media] coda: remove redundant call to v4l2_m2m_get_vq
Am 27.03.2017 12:10, schrieb Philipp Zabel: > On Mon, 2017-03-27 at 11:46 +0200, Hans Verkuil wrote: >> On 23/03/17 12:57, Colin King wrote: >>> From: Colin Ian King >>> >>> The call to v4ls_m2m_get_vq is only used to get the return value >>> which is not being used, so it appears to be redundant and can >>> be removed. >>> >>> Detected with CoverityScan, CID#1420674 ("Useless call") >>> >>> Signed-off-by: Colin Ian King >>> --- >>> drivers/media/platform/coda/coda-common.c | 2 -- >>> 1 file changed, 2 deletions(-) >>> >>> diff --git a/drivers/media/platform/coda/coda-common.c >>> b/drivers/media/platform/coda/coda-common.c >>> index 800d2477f1a0..95e4648f18e6 100644 >>> --- a/drivers/media/platform/coda/coda-common.c >>> +++ b/drivers/media/platform/coda/coda-common.c >>> @@ -817,8 +817,6 @@ static int coda_qbuf(struct file *file, void *priv, >>> static bool coda_buf_is_end_of_stream(struct coda_ctx *ctx, >>> struct vb2_v4l2_buffer *buf) >>> { >>> - v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); >>> - >>> return ((ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG) && >>> (buf->sequence == (ctx->qsequence - 1))); >>> } >>> >> >> Philipp, is this correct, or should this actually check whether the queue is >> an >> output queue? > > Yes, this was previously assigned to an unused local variable src_vq, > since initial commit 918c66fd4126 ("[media] coda: add CODA7541 decoding > support"). > > coda_buf_is_end_of_stream is called from coda_m2m_buf_done, which is > exclusively used on destination buffers on the capture queue. > > Acked-by: Philipp Zabel > > regards > Philipp > Is that function needed at all ? re, wh
[PATCH] Fixing Coding Style Errors & Warning
From: Vaibhav Kothari - Removed white-space before comma in memset() - Added blanck line between declaration and defination at various places Signed-off-by: Vaibhav Kothari --- drivers/staging/media/atomisp/i2c/gc2235.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c b/drivers/staging/media/atomisp/i2c/gc2235.c index 9b41023..0df20ba 100644 --- a/drivers/staging/media/atomisp/i2c/gc2235.c +++ b/drivers/staging/media/atomisp/i2c/gc2235.c @@ -55,7 +55,7 @@ static int gc2235_read_reg(struct i2c_client *client, return -EINVAL; } - memset(msg, 0 , sizeof(msg)); + memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; msg[0].flags = 0; @@ -354,6 +354,7 @@ static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg, u16 coarse_integration = (u16)coarse_itg; int ret = 0; u16 expo_coarse_h, expo_coarse_l, gain_val = 0xF0, gain_val2 = 0xF0; + expo_coarse_h = coarse_integration >> 8; expo_coarse_l = coarse_integration & 0xff; @@ -405,6 +406,7 @@ static long gc2235_s_exposure(struct v4l2_subdev *sd, /* we should not accept the invalid value below. */ if (gain == 0) { struct i2c_client *client = v4l2_get_subdevdata(sd); + v4l2_err(client, "%s: invalid value\n", __func__); return -EINVAL; } @@ -746,12 +748,13 @@ static int startup(struct v4l2_subdev *sd) struct gc2235_device *dev = to_gc2235_sensor(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); int ret = 0; + if (is_init == 0) { /* force gc2235 to do a reset in res change, otherwise it - * can not output normal after switching res. and it is not - * necessary for first time run up after power on, for the sack - * of performance - */ +* can not output normal after switching res. and it is not +* necessary for first time run up after power on, for the sack +* of performance +*/ power_down(sd); power_up(sd); gc2235_write_reg_array(client, gc2235_init_settings); @@ -880,6 +883,7 @@ static int gc2235_s_stream(struct v4l2_subdev *sd, int enable) struct gc2235_device *dev = to_gc2235_sensor(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; + mutex_lock(&dev->input_lock); if (enable) @@ -994,6 +998,7 @@ static int gc2235_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param) { struct gc2235_device *dev = to_gc2235_sensor(sd); + dev->run_mode = param->parm.capture.capturemode; mutex_lock(&dev->input_lock); @@ -1099,6 +1104,7 @@ static int gc2235_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); struct gc2235_device *dev = to_gc2235_sensor(sd); + dev_dbg(&client->dev, "gc2235_remove...\n"); if (dev->platform_data->platform_deinit) -- 1.9.1
Re: [PATCH] [media] coda: remove redundant call to v4l2_m2m_get_vq
On Mon, 2017-03-27 at 11:46 +0200, Hans Verkuil wrote: > On 23/03/17 12:57, Colin King wrote: > > From: Colin Ian King > > > > The call to v4ls_m2m_get_vq is only used to get the return value > > which is not being used, so it appears to be redundant and can > > be removed. > > > > Detected with CoverityScan, CID#1420674 ("Useless call") > > > > Signed-off-by: Colin Ian King > > --- > > drivers/media/platform/coda/coda-common.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > diff --git a/drivers/media/platform/coda/coda-common.c > > b/drivers/media/platform/coda/coda-common.c > > index 800d2477f1a0..95e4648f18e6 100644 > > --- a/drivers/media/platform/coda/coda-common.c > > +++ b/drivers/media/platform/coda/coda-common.c > > @@ -817,8 +817,6 @@ static int coda_qbuf(struct file *file, void *priv, > > static bool coda_buf_is_end_of_stream(struct coda_ctx *ctx, > > struct vb2_v4l2_buffer *buf) > > { > > - v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); > > - > > return ((ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG) && > > (buf->sequence == (ctx->qsequence - 1))); > > } > > > > Philipp, is this correct, or should this actually check whether the queue is > an > output queue? Yes, this was previously assigned to an unused local variable src_vq, since initial commit 918c66fd4126 ("[media] coda: add CODA7541 decoding support"). coda_buf_is_end_of_stream is called from coda_m2m_buf_done, which is exclusively used on destination buffers on the capture queue. Acked-by: Philipp Zabel regards Philipp
[GIT PULL FOR v4.12] Various fixes, improvements
Various fixes and improvements. Regards, Hans The following changes since commit 700ea5e0e0dd70420a04e703ff264cc133834cba: Merge tag 'v4.11-rc1' into patchwork (2017-03-06 06:49:34 -0300) are available in the git repository at: git://linuxtv.org/hverkuil/media_tree.git for-v4.12d for you to fetch changes up to 6798d00f15b0c965a1a030516c0933684d61a7bd: cec-core.rst: document the new cec_get_drvdata() helper (2017-03-27 11:55:58 +0200) Anton Leontiev (1): vb2: Fix queue_setup() callback description Baruch Siach (1): doc: kapi: fix typo Colin Ian King (2): atmel-isc: fix off-by-one comparison and out of bounds read issue usb: au0828: remove redundant code Geliang Tang (1): ivtv: use for_each_sg Hans Verkuil (2): vivid: fix g_edid implementation cec-core.rst: document the new cec_get_drvdata() helper Hugues Fruchet (1): st-delta: mjpeg: fix static checker warning Johan Hovold (1): gspca: konica: add missing endpoint sanity check Jose Abreu (8): cec: Add cec_get_drvdata() staging: st-cec: Use cec_get_drvdata() staging: s5p-cec: Use cec_get_drvdata() i2c: adv7511: Use cec_get_drvdata() i2c: adv7604: Use cec_get_drvdata() i2c: adv7842: Use cec_get_drvdata() usb: pulse8-cec: Use cec_get_drvdata() platform: vivid: Use cec_get_drvdata() Matthias Kaehlcke (1): vcodec: mediatek: Remove double parentheses Minghsiu Tsai (1): media: mtk-jpeg: fix continuous log "Context is NULL" Documentation/media/kapi/cec-core.rst| 5 + Documentation/media/kapi/v4l2-core.rst | 2 +- drivers/media/i2c/adv7511.c | 6 +++--- drivers/media/i2c/adv7604.c | 6 +++--- drivers/media/i2c/adv7842.c | 6 +++--- drivers/media/pci/ivtv/ivtv-udma.c | 2 +- drivers/media/platform/atmel/atmel-isc.c | 2 +- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 14 ++ drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c | 4 ++-- drivers/media/platform/sti/delta/delta-mjpeg-dec.c | 2 +- drivers/media/platform/vivid/vivid-cec.c | 4 ++-- drivers/media/platform/vivid/vivid-vid-common.c | 4 ++-- drivers/media/usb/au0828/au0828-video.c | 7 --- drivers/media/usb/gspca/konica.c | 3 +++ drivers/media/usb/pulse8-cec/pulse8-cec.c| 6 +++--- drivers/staging/media/s5p-cec/s5p_cec.c | 6 +++--- drivers/staging/media/st-cec/stih-cec.c | 6 +++--- include/media/cec.h | 5 + include/media/videobuf2-core.h | 12 ++-- 19 files changed, 49 insertions(+), 53 deletions(-)
Start development on dragonboard 410c with OV5645 camera
Hi all, I want to get into the development of the v4l driver for OV5645 camera. I want to work on features like zoom and manual exposure time / gain control. And get our own camera module connected later on as well (mostly a hardware issue) The starting point for me is a dragonboard 410c (which I got already) and the Mezzanine MIPI Adapter board plus OV5645 Camera module (which I expect to get this week) I will first - as soon as I get the camera - follow the set up CSI procedure on https://builds.96boards.org/releases/dragonboard410c/linaro/debian/16.09/ of course Could somebody give me some hints what would be the best steps to get into a position to modify driver code. I am new to the v4l driver development, but have some experience with driver development in Linux (although it got somehow rusty ;-) ) I usually like to start with modules, but I have seen the driver is statically linked. Any hints on that? Is development usually done native or via cross compile? Heinz
Re: [PATCH] [media] coda: remove redundant call to v4l2_m2m_get_vq
On 23/03/17 12:57, Colin King wrote: > From: Colin Ian King > > The call to v4ls_m2m_get_vq is only used to get the return value > which is not being used, so it appears to be redundant and can > be removed. > > Detected with CoverityScan, CID#1420674 ("Useless call") > > Signed-off-by: Colin Ian King > --- > drivers/media/platform/coda/coda-common.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/media/platform/coda/coda-common.c > b/drivers/media/platform/coda/coda-common.c > index 800d2477f1a0..95e4648f18e6 100644 > --- a/drivers/media/platform/coda/coda-common.c > +++ b/drivers/media/platform/coda/coda-common.c > @@ -817,8 +817,6 @@ static int coda_qbuf(struct file *file, void *priv, > static bool coda_buf_is_end_of_stream(struct coda_ctx *ctx, > struct vb2_v4l2_buffer *buf) > { > - v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); > - > return ((ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG) && > (buf->sequence == (ctx->qsequence - 1))); > } > Philipp, is this correct, or should this actually check whether the queue is an output queue? Regards, Hans
[PATCH] cec-core.rst: document the new cec_get_drvdata() helper
Document the new cec_get_drvdata() helper function. Signed-off-by: Hans Verkuil --- diff --git a/Documentation/media/kapi/cec-core.rst b/Documentation/media/kapi/cec-core.rst index 81c6d8e93774..8ea3a783f968 100644 --- a/Documentation/media/kapi/cec-core.rst +++ b/Documentation/media/kapi/cec-core.rst @@ -51,6 +51,7 @@ ops: priv: will be stored in adap->priv and can be used by the adapter ops. + Use cec_get_drvdata(adap) to get the priv pointer. name: the name of the CEC adapter. Note: this name will be copied. @@ -65,6 +66,10 @@ available_las: the number of simultaneous logical addresses that this adapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS. +To obtain the priv pointer use this helper function: + +.. c:function:: + void *cec_get_drvdata(const struct cec_adapter *adap); To register the /dev/cecX device node and the remote control device (if CEC_CAP_RC is set) you call:
Re: [PATCH] [media] platform: Order the Makefile alphabetically
On Mon, Mar 20, 2017 at 11:22:02AM +0100, Maxime Ripard wrote: > Hi Mauro, > > On Tue, Mar 07, 2017 at 02:39:28PM +0100, Maxime Ripard wrote: > > The Makefile was a free for all without a clear order defined. Sort all the > > options based on the Kconfig symbol. > > > > Signed-off-by: Maxime Ripard > > Any news on this one? Ping? Maxime -- Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com signature.asc Description: PGP signature
Re: [PATCH v7] [media] vimc: Virtual Media Controller core, capture and sensor
Two small comments: On 25/03/17 18:11, Helen Koike wrote: > First version of the Virtual Media Controller. > Add a simple version of the core of the driver, the capture and > sensor nodes in the topology, generating a grey image in a hardcoded > format. > > Signed-off-by: Helen Koike > > --- > > Patch based in media/master tree, and available here: > https://github.com/helen-fornazier/opw-staging/tree/vimc/devel/v7 > > Changes since v6: > - add kernel-docs in vimc-core.h > - reorder list_del call in vimc_cap_return_all_buffers() > - call media_pipeline_stop in vimc_cap_start_streaming when fail > - remove DMA comment (left over from the sample driver) > - remove vb2_set_plane_payload call in vimc_cap_buffer_prepare > - remove format verification in vimc_cap_link_validate > - set vimc_pix_map_list as static > - use MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN in vimc_raw_create() > - register media device after creating the topology and unregister it before > destroying the topology > - replace devm_kzalloc by kzalloc for allocating struct vimc_device > - uset TASK_UNINTERRUPTIBLE for vimc_thread_sen > - do not allow the creation of a sensor with no pads > - add more verbose description in Kconfig > - change copyright to 2017 > - arrange includes: number before letters > - remove v4l2_dev pointer from vimc_cap_device structure > - coding style adjustments > - remove entity variable in vimc_cap_pipeline_s_stream > - declare and assign variables in vimc_cap_link_validate > - declare vimc_dev_release() and vimc_pdev closer to vimc_init() > - remove pad check in vimc_sen_enum_{mbus_code,frame_size} that is already > performed by v4l2-subdev.c > - fix multiline comments to start with /* > - reorder variable declaration in functions > - remove pad and subdevice type check in vimc_cap_pipeline_s_stream > - add a note that sensor nodes can can have more then one source pad > - remove the use of entity->use_count in the core and attach the ved > structure in sd or vd, use > ent->obj_type to know which structure (sd or vd) to use > - rename vdev (video_device) to vd to be similar to sd (subdev) Hmm, vdev is what everyone uses, so I would prefer that this change is reverted. Did someone comment on this in a code review? > > Changes since v5: > - Fix message "Entity type for entity Sensor A was not initialized!" > by initializing the sensor entity.function after the calling > v4l2_subded_init > - populate device_caps in vimc_cap_create instead of in > vimc_cap_querycap > - Fix typo in vimc-core.c s/de/the > > Changes since v4: > - coding style fixes > - remove BUG_ON > - change copyright to 2016 > - depens on VIDEO_V4L2_SUBDEV_API instead of select > - remove assignement of V4L2_CAP_DEVICE_CAPS > - s/vimc_cap_g_fmt_vid_cap/vimc_cap_fmt_vid_cap > - fix vimc_cap_queue_setup declaration type > - remove wrong buffer size check and add it in vimc_cap_buffer_prepare > - vimc_cap_create: remove unecessary check if v4l2_dev or v4l2_dev->dev is > null > - vimc_cap_create: only allow a single pad > - vimc_sen_create: only allow source pads, remove unecessary source pads > checks in vimc_thread_sen > > Changes since v3: fix rmmod crash and built-in compile > - Re-order unregister calls in vimc_device_unregister function (remove > rmmod issue) > - Call media_device_unregister_entity in vimc_raw_destroy > - Add depends on VIDEO_DEV && VIDEO_V4L2 and select VIDEOBUF2_VMALLOC > - Check *nplanes in queue_setup (this remove v4l2-compliance fail) > - Include in vimc-sensor.c > - Move include of from vimc-core.c to vimc-core.h > - Generate 60 frames per sec instead of 1 in the sensor > > Changes since v2: update with current media master tree > - Add struct media_pipeline in vimc_cap_device > - Use vb2_v4l2_buffer instead of vb2_buffer > - Typos > - Remove usage of entity->type and use entity->function instead > - Remove fmt argument from queue setup > - Use ktime_get_ns instead of v4l2_get_timestamp > - Iterate over link's list using list_for_each_entry > - Use media_device_{init, cleanup} > - Use entity->use_count to keep track of entities instead of the old > entity->id > - Replace media_entity_init by media_entity_pads_init > --- > drivers/media/platform/Kconfig | 2 + > drivers/media/platform/Makefile| 1 + > drivers/media/platform/vimc/Kconfig| 14 + > drivers/media/platform/vimc/Makefile | 3 + > drivers/media/platform/vimc/vimc-capture.c | 536 ++ > drivers/media/platform/vimc/vimc-capture.h | 28 ++ > drivers/media/platform/vimc/vimc-core.c| 696 > + > drivers/media/platform/vimc/vimc-core.h| 123 + > drivers/media/platform/vimc/vimc-sensor.c | 279 > drivers/media/platform/vimc/vimc-sensor.h | 28 ++ > 10 files changed, 1710 insertions(+) > create mode 100644 drivers/media/platform/vimc/Kconfig > create mode 100644 drivers/media/platform/vimc/Makefile > create mode 100644 drivers/media/plat
[PATCH] staging: atomisp: fix an issue timeout value for checking error
The timeout variable could be zero even if the bits has expected result. The checking expected bits again would be better instead whether the timeout value is zero or not. Signed-off-by: Daeseok Youn --- drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c index 94bc793..f2e5749 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c @@ -220,11 +220,11 @@ static int write_target_freq_to_hw(struct atomisp_device *isp, timeout--; } - if (timeout != 0) + if (!(isp_sspm1 & ISP_FREQ_VALID_MASK)) break; } - if (timeout == 0) { + if (isp_sspm1 & ISP_FREQ_VALID_MASK) { dev_err(isp->dev, "DFS failed due to HW error.\n"); return -EINVAL; } @@ -238,7 +238,7 @@ static int write_target_freq_to_hw(struct atomisp_device *isp, udelay(100); timeout--; } - if (timeout == 0) { + if ((isp_sspm1 >> ISP_FREQ_STAT_OFFSET) != ratio) { dev_err(isp->dev, "DFS target freq is rejected by HW.\n"); return -EINVAL; } -- 1.9.1
Re: [PATCH] [media] platform: Order the Makefile alphabetically
Hi Maxime, Thank you for the patch. On Tuesday 07 Mar 2017 14:39:28 Maxime Ripard wrote: > The Makefile was a free for all without a clear order defined. Sort all the > options based on the Kconfig symbol. I've been annoyed in the past by not knowing where to put entries for new drivers. I think this is a good improvement. > Signed-off-by: Maxime Ripard Acked-by: Laurent Pinchart > --- > drivers/media/platform/Makefile | 89 - > 1 file changed, 31 insertions(+), 58 deletions(-) > > diff --git a/drivers/media/platform/Makefile > b/drivers/media/platform/Makefile index 349ddf6a69da..bd5dc3068cbc 100644 > --- a/drivers/media/platform/Makefile > +++ b/drivers/media/platform/Makefile > @@ -1,73 +1,46 @@ > # > # Makefile for the video capture/playback device drivers. > # > +ccflags-y += -I$(srctree)/drivers/media/i2c > > -obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o > - > -obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o > -obj-$(CONFIG_VIDEO_CAFE_CCIC) += marvell-ccic/ > -obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/ > - > -obj-$(CONFIG_VIDEO_OMAP3)+= omap3isp/ > -obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o > - > -obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o > - > -obj-$(CONFIG_VIDEO_VIVID)+= vivid/ > -obj-$(CONFIG_VIDEO_VIM2M)+= vim2m.o > - > -obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/ > - > -obj-$(CONFIG_VIDEO_TI_CAL) += ti-vpe/ > - > -obj-$(CONFIG_VIDEO_MX2_EMMAPRP) += mx2_emmaprp.o > +obj-y+= omap/ > +obj-$(CONFIG_ARCH_DAVINCI) += davinci/ > +obj-$(CONFIG_BLACKFIN) += blackfin/ > +obj-$(CONFIG_DVB_C8SECTPFE) += sti/c8sectpfe/ > +obj-$(CONFIG_SOC_CAMERA) += soc_camera/ > +obj-$(CONFIG_VIDEO_AM437X_VPFE) += am437x/ > +obj-$(CONFIG_VIDEO_ATMEL_ISC)+= atmel/ > +obj-$(CONFIG_VIDEO_CAFE_CCIC)+= marvell-ccic/ > obj-$(CONFIG_VIDEO_CODA) += coda/ > - > -obj-$(CONFIG_VIDEO_SH_VEU) += sh_veu.o > - > +obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o > +obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp/ > +obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec/ > +obj-$(CONFIG_VIDEO_MEDIATEK_VPU) += mtk-vpu/ > obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE) += m2m-deinterlace.o > - > +obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/ > +obj-$(CONFIG_VIDEO_MX2_EMMAPRP) += mx2_emmaprp.o > +obj-$(CONFIG_VIDEO_OMAP3)+= omap3isp/ > +obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o > +obj-$(CONFIG_VIDEO_RCAR_VIN) += rcar-vin/ > +obj-$(CONFIG_VIDEO_RENESAS_FCP) += rcar-fcp.o > +obj-$(CONFIG_VIDEO_RENESAS_FDP1) += rcar_fdp1.o > +obj-$(CONFIG_VIDEO_RENESAS_JPU) += rcar_jpu.o > +obj-$(CONFIG_VIDEO_RENESAS_VSP1) += vsp1/ > obj-$(CONFIG_VIDEO_S3C_CAMIF)+= s3c-camif/ > obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/ > obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/ > obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/ > - > obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D) += s5p-g2d/ > obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/ > - > +obj-$(CONFIG_VIDEO_SH_VEU) += sh_veu.o > +obj-$(CONFIG_VIDEO_SH_VOU) += sh_vou.o > obj-$(CONFIG_VIDEO_STI_BDISP)+= sti/bdisp/ > -obj-$(CONFIG_VIDEO_STI_HVA) += sti/hva/ > -obj-$(CONFIG_DVB_C8SECTPFE) += sti/c8sectpfe/ > - > obj-$(CONFIG_VIDEO_STI_DELTA)+= sti/delta/ > - > -obj-$(CONFIG_BLACKFIN) += blackfin/ > - > -obj-$(CONFIG_ARCH_DAVINCI) += davinci/ > - > -obj-$(CONFIG_VIDEO_SH_VOU) += sh_vou.o > - > -obj-$(CONFIG_SOC_CAMERA) += soc_camera/ > - > -obj-$(CONFIG_VIDEO_RENESAS_FCP) += rcar-fcp.o > -obj-$(CONFIG_VIDEO_RENESAS_FDP1) += rcar_fdp1.o > -obj-$(CONFIG_VIDEO_RENESAS_JPU) += rcar_jpu.o > -obj-$(CONFIG_VIDEO_RENESAS_VSP1) += vsp1/ > - > -obj-y+= omap/ > - > -obj-$(CONFIG_VIDEO_AM437X_VPFE) += am437x/ > - > +obj-$(CONFIG_VIDEO_STI_HVA) += sti/hva/ > +obj-$(CONFIG_VIDEO_TI_CAL) += ti-vpe/ > +obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/ > +obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o > +obj-$(CONFIG_VIDEO_VIM2M)+= vim2m.o > +obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o > +obj-$(CONFIG_VIDEO_VIVID)+= vivid/ > obj-$(CONFIG_VIDEO_XILINX) += xilinx/ > - > -obj-$(CONFIG_VIDEO_RCAR_VIN) += rcar-vin/ > - > -obj-$(CONFIG_VIDEO_ATMEL_ISC)+= atmel/ > - > -ccflags-y += -I$(srctree)/drivers/media/i2c > - > -obj-$(CONFIG_VIDEO_MEDIATEK_VPU) += mtk-vpu/ > - > -obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec/ > - > -obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp/ -- Regards, Laurent Pinchart
Re: [PATCH v7 5/9] media: venus: vdec: add video decoder files
On 27/03/17 04:18, Nicolas Dufresne wrote: > Le dimanche 26 mars 2017 à 00:30 +0200, Stanimir Varbanov a écrit : +vb->planes[0].data_offset = data_offset; +vb->timestamp = timestamp_us * NSEC_PER_USEC; +vbuf->sequence = inst->sequence++; >>> >>> timestamp and sequence are only set for CAPTURE, not OUTPUT. Is >>> that correct? >> >> Correct. I can add sequence for the OUTPUT queue too, but I have no idea >> how that sequence is used by userspace. > > Neither GStreamer or Chromium seems to use it. What does that number > means for a m2m driver ? Does it really means something ? It can be used to detect dropped frame (the sequence counter will skip in that case). Unlikely to happen for m2m devices, and most apps ignore it as well. But you still need to fill it in, it's a V4L2 requirement. Regards, Hans
Re: [PATCH v7 5/9] media: venus: vdec: add video decoder files
On 25/03/17 23:30, Stanimir Varbanov wrote: > Thanks for the comments! > > On 03/24/2017 04:41 PM, Hans Verkuil wrote: >> Some comments and questions below: >> >> On 03/13/17 17:37, Stanimir Varbanov wrote: >>> This consists of video decoder implementation plus decoder >>> controls. >>> >>> Signed-off-by: Stanimir Varbanov >>> --- >>> drivers/media/platform/qcom/venus/vdec.c | 1091 >>> >>> drivers/media/platform/qcom/venus/vdec.h | 23 + >>> drivers/media/platform/qcom/venus/vdec_ctrls.c | 149 >>> 3 files changed, 1263 insertions(+) >>> create mode 100644 drivers/media/platform/qcom/venus/vdec.c >>> create mode 100644 drivers/media/platform/qcom/venus/vdec.h >>> create mode 100644 drivers/media/platform/qcom/venus/vdec_ctrls.c >>> >>> diff --git a/drivers/media/platform/qcom/venus/vdec.c >>> b/drivers/media/platform/qcom/venus/vdec.c >>> new file mode 100644 >>> index ..ec5203f2ba81 >>> --- /dev/null >>> +++ b/drivers/media/platform/qcom/venus/vdec.c >>> @@ -0,0 +1,1091 @@ >>> +/* >>> + * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. >>> + * Copyright (C) 2017 Linaro Ltd. >>> + * >>> + * This program is free software; you can redistribute it and/or modify >>> + * it under the terms of the GNU General Public License version 2 and >>> + * only version 2 as published by the Free Software Foundation. >>> + * >>> + * This program is distributed in the hope that it will be useful, >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >>> + * GNU General Public License for more details. >>> + * >>> + */ >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "hfi_venus_io.h" >>> +#include "core.h" >>> +#include "helpers.h" >>> +#include "vdec.h" >>> + >>> +static u32 get_framesize_uncompressed(unsigned int plane, u32 width, u32 >>> height) >>> +{ >>> +u32 y_stride, uv_stride, y_plane; >>> +u32 y_sclines, uv_sclines, uv_plane; >>> +u32 size; >>> + >>> +y_stride = ALIGN(width, 128); >>> +uv_stride = ALIGN(width, 128); >>> +y_sclines = ALIGN(height, 32); >>> +uv_sclines = ALIGN(((height + 1) >> 1), 16); >>> + >>> +y_plane = y_stride * y_sclines; >>> +uv_plane = uv_stride * uv_sclines + SZ_4K; >>> +size = y_plane + uv_plane + SZ_8K; >>> + >>> +return ALIGN(size, SZ_4K); >>> +} >>> + >>> +static u32 get_framesize_compressed(unsigned int width, unsigned int >>> height) >>> +{ >>> +return ((width * height * 3 / 2) / 2) + 128; >>> +} >>> + >>> +static const struct venus_format vdec_formats[] = { >>> +{ >>> +.pixfmt = V4L2_PIX_FMT_NV12, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, >> >> Just curious: is NV12 the only uncompressed format supported by the hardware? >> Or just the only one that is implemented here? >> >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_MPEG4, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_MPEG2, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_H263, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_H264, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_VP8, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_XVID, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, >> >> num_planes is always 1, do you need it at all? And if it is always one, >> why use _MPLANE at all? Is this for future additions? >> >>> +}; >>> + > > three reasons: > - _MPLAIN allows one plane only > - downstream qualcomm driver use _MPLAIN (the second plain is used for > extaradata, I ignored the extaradata support for now until v4l2 metadata api > is merged) > - I still believe that qualcomm firmware guys will add support the second or > even third plain at some point. Please add a comment in the code explaining the reason. Just before this format list would be a good place for that. Hans > >>> + >>> +static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, >>> + u32 tag, u32 bytesused, u32 data_offset, u32 flags, >>> +
Re: [PATCH v7 5/9] media: venus: vdec: add video decoder files
On 25/03/17 23:30, Stanimir Varbanov wrote: > Thanks for the comments! > > On 03/24/2017 04:41 PM, Hans Verkuil wrote: >> Some comments and questions below: >> >> On 03/13/17 17:37, Stanimir Varbanov wrote: >>> This consists of video decoder implementation plus decoder >>> controls. >>> >>> Signed-off-by: Stanimir Varbanov >>> --- >>> drivers/media/platform/qcom/venus/vdec.c | 1091 >>> >>> drivers/media/platform/qcom/venus/vdec.h | 23 + >>> drivers/media/platform/qcom/venus/vdec_ctrls.c | 149 >>> 3 files changed, 1263 insertions(+) >>> create mode 100644 drivers/media/platform/qcom/venus/vdec.c >>> create mode 100644 drivers/media/platform/qcom/venus/vdec.h >>> create mode 100644 drivers/media/platform/qcom/venus/vdec_ctrls.c >>> >>> diff --git a/drivers/media/platform/qcom/venus/vdec.c >>> b/drivers/media/platform/qcom/venus/vdec.c >>> new file mode 100644 >>> index ..ec5203f2ba81 >>> --- /dev/null >>> +++ b/drivers/media/platform/qcom/venus/vdec.c >>> @@ -0,0 +1,1091 @@ >>> +/* >>> + * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. >>> + * Copyright (C) 2017 Linaro Ltd. >>> + * >>> + * This program is free software; you can redistribute it and/or modify >>> + * it under the terms of the GNU General Public License version 2 and >>> + * only version 2 as published by the Free Software Foundation. >>> + * >>> + * This program is distributed in the hope that it will be useful, >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >>> + * GNU General Public License for more details. >>> + * >>> + */ >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "hfi_venus_io.h" >>> +#include "core.h" >>> +#include "helpers.h" >>> +#include "vdec.h" >>> + >>> +static u32 get_framesize_uncompressed(unsigned int plane, u32 width, u32 >>> height) >>> +{ >>> +u32 y_stride, uv_stride, y_plane; >>> +u32 y_sclines, uv_sclines, uv_plane; >>> +u32 size; >>> + >>> +y_stride = ALIGN(width, 128); >>> +uv_stride = ALIGN(width, 128); >>> +y_sclines = ALIGN(height, 32); >>> +uv_sclines = ALIGN(((height + 1) >> 1), 16); >>> + >>> +y_plane = y_stride * y_sclines; >>> +uv_plane = uv_stride * uv_sclines + SZ_4K; >>> +size = y_plane + uv_plane + SZ_8K; >>> + >>> +return ALIGN(size, SZ_4K); >>> +} >>> + >>> +static u32 get_framesize_compressed(unsigned int width, unsigned int >>> height) >>> +{ >>> +return ((width * height * 3 / 2) / 2) + 128; >>> +} >>> + >>> +static const struct venus_format vdec_formats[] = { >>> +{ >>> +.pixfmt = V4L2_PIX_FMT_NV12, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, >> >> Just curious: is NV12 the only uncompressed format supported by the hardware? >> Or just the only one that is implemented here? >> >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_MPEG4, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_MPEG2, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_H263, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_H264, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_VP8, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, { >>> +.pixfmt = V4L2_PIX_FMT_XVID, >>> +.num_planes = 1, >>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, >>> +}, >> >> num_planes is always 1, do you need it at all? And if it is always one, >> why use _MPLANE at all? Is this for future additions? >> >>> +}; >>> + > > three reasons: > - _MPLAIN allows one plane only > - downstream qualcomm driver use _MPLAIN (the second plain is used for > extaradata, I ignored the extaradata support for now until v4l2 metadata api > is merged) > - I still believe that qualcomm firmware guys will add support the second or > even third plain at some point. > >>> + >>> +static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, >>> + u32 tag, u32 bytesused, u32 data_offset, u32 flags, >>> + u64 timestamp_us) >>> +{ >>> +struct vb2_v4l2_buffer *vbuf; >>> +struct vb2_buffer *vb; >>> +unsigned int type; >>> +
[PATCH] vivid: fix g_edid implementation
The VIDIOC_G_EDID implementation in vivid didn't take edid->start_block into account when copying the EDID data. Make sure that the internal EDID is updated with the correct CEC physical address. Currently the returned EDID is updated, but that will only work well if edid->start_block is 0. Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/platform/vivid/vivid-vid-common.c b/drivers/media/platform/vivid/vivid-vid-common.c index 5fc010f6ce67..f0f423c7ca41 100644 --- a/drivers/media/platform/vivid/vivid-vid-common.c +++ b/drivers/media/platform/vivid/vivid-vid-common.c @@ -858,7 +858,7 @@ int vidioc_g_edid(struct file *file, void *_fh, return -EINVAL; if (edid->start_block + edid->blocks > dev->edid_blocks) edid->blocks = dev->edid_blocks - edid->start_block; - memcpy(edid->edid, dev->edid, edid->blocks * 128); - cec_set_edid_phys_addr(edid->edid, edid->blocks * 128, adap->phys_addr); + cec_set_edid_phys_addr(dev->edid, dev->edid_blocks * 128, adap->phys_addr); + memcpy(edid->edid, dev->edid + edid->start_block * 128, edid->blocks * 128); return 0; }
Re: [PATCH 1/3] [media] mceusb: RX -EPIPE (urb status = -32) lockup failure fix
On 3/26/2017 4:31 PM, Sean Young wrote: > On Sun, Mar 26, 2017 at 02:28:08PM -0400, A Sun wrote: >> commit >> https://github.com/asunxx/linux/commit/17fe3b51f4ad5202a876ea4c92b5d99d4e166823 >> Author: A Sun >> Date: Sun, 26 Mar 2017 13:24:18 -0400 > > Please don't include this. > >> ... >> mceusb 1-1.2:1.0: 2 tx ports (0x1 cabled) and 2 rx sensors (0x1 active) > > It would be nice to have this tested against a mainline kernel. I thought > that was entirely possible on raspberry pis nowadays. ... >> +/* kevent support */ >> +struct work_struct kevent; > > kevent is not a descriptive name. How about something like clear_halt? > >> +unsigned long kevent_flags; >> +# define EVENT_TX_HALT0 >> +# define EVENT_RX_HALT1 > > EVENT_TX_HALT is never used, so kevent_flags is only ever set to 1. The > entire field can be dropped. > ... >> +if (!schedule_work(&ir->kevent)) { >> +dev_err(ir->dev, "kevent %d may have been dropped", kevent); >> +} else { >> +dev_dbg(ir->dev, "kevent %d scheduled", kevent); >> +} >> +} > > Again name is not very descriptive. > ... >> +dev_err(ir->dev, "Error: urb status = %d (RX HALT)", >> +urb->status); >> +mceusb_defer_kevent(ir, EVENT_RX_HALT); > > Here you could simply call schedule_work(). Note that EPIPE might also > be returned for device disconnect for some host controllers. > >> +return; ... >> +int status; >> + >> +if (test_bit(EVENT_RX_HALT, &ir->kevent_flags)) { > > If condition can go. > >> +usb_unlink_urb(ir->urb_in); >> +status = usb_clear_halt(ir->usbdev, ir->pipe_in); Hi Sean, Thanks again for looking at this. This patch is based on similar error and recovery, with the USB ethernet driver usbnet (usbnet.c, usbnet.h). In usbnet, they call "kevent" (kernel device event?) any kind of hardware state change or event in interrupt context that requires invoking non-interrupt code to handle. I'm not sure what else I should name it. Possible kevent-s are not limited to situations needing usb_clear_halt(). From usbnet: 69 # define EVENT_TX_HALT0 70 # define EVENT_RX_HALT1 71 # define EVENT_RX_MEMORY 2 72 # define EVENT_STS_SPLIT 3 73 # define EVENT_LINK_RESET 4 74 # define EVENT_RX_PAUSED 5 75 # define EVENT_DEV_ASLEEP 6 76 # define EVENT_DEV_OPEN 7 77 # define EVENT_DEVICE_REPORT_IDLE 8 78 # define EVENT_NO_RUNTIME_PM 9 79 # define EVENT_RX_KILL10 80 # define EVENT_LINK_CHANGE11 81 # define EVENT_SET_RX_MODE12 So far, the first two are appearing applicable for mceusb. The unused EVENT_TX_HALT and the apparently extra _kevent functions and kevent_flags are necessary for a later: [PATCH] [media] mceusb: TX -EPIPE lockup fix ...not yet written, transmit side equivalent bug. I respectfully recommend keeping these hooks in place. For now, I think the transmit side EPIPE bug fix is less critical, since the TX bug avoids hanging the host/kernel, but would still cause lockup of the device. In case of RX EPIPE on disconnect, the fix is still safe. Recovery attempt should fail (in usb_clear_halt() or usb_submit_urb()) and abort without further retry, and the recovery handler itself gets shutdown in mceusb_dev_disconnect(). Please let me know how to proceed. Thanks. ..A Sun